Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AD2S1210 updates #2261

Merged
merged 47 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
78b7999
staging: iio: ad2s1210: revert merge commits
dlech Sep 11, 2023
508fa17
staging: iio: resolver: ads1210: fix config mode
nunojsa Mar 27, 2023
e9e19fa
staging: iio: resolver: ad2s1210: Add explicit include for of.h
robherring Apr 5, 2023
2fafa38
staging: iio: resolver: ad2s1210: fix ad2s1210_show_fault
dlech Sep 21, 2023
24de148
staging: iio: resolver: ad2s1210: fix not restoring sample gpio in ch…
dlech Sep 21, 2023
2cf226b
staging: iio: resolver: ad2s1210: fix use before initialization
dlech Sep 29, 2023
f8e76d4
staging: iio: resolver: ad2s1210: remove call to spi_setup()
dlech Sep 29, 2023
c686b31
staging: iio: resolver: ad2s1210: check return of ad2s1210_initial()
dlech Sep 29, 2023
84deb82
staging: iio: resolver: ad2s1210: remove spi_set_drvdata()
dlech Sep 29, 2023
19a5f4d
staging: iio: resolver: ad2s1210: sort imports
dlech Sep 29, 2023
181ef2c
staging: iio: resolver: ad2s1210: always use 16-bit value for raw read
dlech Sep 29, 2023
028a24e
staging: iio: resolver: ad2s1210: implement IIO_CHAN_INFO_SCALE
dlech Sep 29, 2023
6b0cf6a
staging: iio: resolver: ad2s1210: use devicetree to get CLKIN rate
dlech Sep 29, 2023
0efcb8c
staging: iio: resolver: ad2s1210: use regmap for config registers
dlech Sep 29, 2023
d65e953
staging: iio: resolver: ad2s1210: add debugfs reg access
dlech Sep 29, 2023
ae47871
staging: iio: resolver: ad2s1210: remove config attribute
dlech Sep 29, 2023
0e0be0a
staging: iio: resolver: ad2s1210: rework gpios
dlech Sep 29, 2023
0f3ac7a
staging: iio: resolver: ad2s1210: refactor setting excitation frequency
dlech Sep 29, 2023
5b3f5f4
staging: iio: resolver: ad2s1210: read excitation frequency from cont…
dlech Sep 29, 2023
5497120
dt-bindings: iio: resolver: add devicetree bindings for ad2s1210
dlech Sep 29, 2023
73d839a
staging: iio: resolver: ad2s1210: do not use fault register for dummy…
dlech Oct 6, 2023
17c98dc
staging: iio: resolver: ad2s1210: implement hysteresis as channel attr
dlech Oct 6, 2023
9284ac0
staging: iio: resolver: ad2s1210: convert fexcit to channel attribute
dlech Oct 6, 2023
3b071fc
staging: iio: resolver: ad2s1210: convert resolution to devicetree pr…
dlech Oct 6, 2023
a8d4e56
staging: iio: resolver: ad2s1210: add phase lock range support
dlech Oct 6, 2023
ca6855f
staging: iio: resolver: ad2s1210: add triggered buffer support
dlech Oct 6, 2023
eea15ed
staging: iio: resolver: ad2s1210: convert LOT threshold attrs to even…
dlech Oct 6, 2023
e3902e1
staging: iio: resolver: ad2s1210: convert LOS threshold to event attr
dlech Oct 6, 2023
0683144
staging: iio: resolver: ad2s1210: convert DOS overrange threshold to …
dlech Oct 6, 2023
ece0564
staging: iio: resolver: ad2s1210: convert DOS mismatch threshold to e…
dlech Oct 6, 2023
5b0fe5c
staging: iio: resolver: ad2s1210: rename DOS reset min/max attrs
dlech Oct 6, 2023
47094aa
iio: event: add optional event label support
dlech Oct 6, 2023
62a0e05
staging: iio: resolver: ad2s1210: implement fault events
dlech Oct 6, 2023
23d7440
staging: iio: resolver: ad2s1210: add register/fault support summary
dlech Oct 6, 2023
da106b6
staging: iio: resolver: ad2s1210: add label attribute support
dlech Oct 6, 2023
84d7cc5
staging: iio: resolver: ad2s1210: remove fault attribute
dlech Oct 6, 2023
12d1ead
staging: iio: resolver: ad2s1210: refactor sample toggle
dlech Oct 10, 2023
e3e270e
staging: iio: resolver: ad2s1210: clear faults after soft reset
dlech Oct 9, 2023
97c72b2
locking: Introduce __cleanup() based infrastructure
May 26, 2023
d5b28e2
kbuild: Drop -Wdeclaration-after-statement
Jun 9, 2023
8528283
staging: iio: resolver: ad2s1210: simplify code with guard(mutex)
dlech Oct 10, 2023
290d1b6
iio: resolver: ad2s1210: move out of staging
dlech Oct 10, 2023
342ea2f
iio: resolver: ad2s1210: remove DRV_NAME macro
dlech Oct 12, 2023
0970e11
iio: resolver: ad2s1210: remove of_match_ptr()
dlech Oct 12, 2023
bc8c5d7
iio: resolver: ad2s1210: add support for adi,fixed-mode
dlech Oct 16, 2023
56e3c1d
iio: resolver: ad2s1210: add reset gpio support
dlech Oct 16, 2023
087e7af
arm: dts: zynq-adv7511: ad2s1210: add devicetree for ad2s1210 eval
dlech Sep 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Documentation/ABI/testing/sysfs-bus-iio
Original file line number Diff line number Diff line change
Expand Up @@ -2207,3 +2207,18 @@ Contact: [email protected]
Description:
An example format is 16-bytes, 2-digits-per-byte, HEX-string
representing the sensor unique ID number.

What: /sys/bus/iio/devices/iio:deviceX/events/in_altvoltageY_mag_either_label
What: /sys/bus/iio/devices/iio:deviceX/events/in_altvoltageY_mag_rising_label
What: /sys/bus/iio/devices/iio:deviceX/events/in_altvoltageY_thresh_falling_label
What: /sys/bus/iio/devices/iio:deviceX/events/in_altvoltageY_thresh_rising_label
What: /sys/bus/iio/devices/iio:deviceX/events/in_anglvelY_mag_rising_label
What: /sys/bus/iio/devices/iio:deviceX/events/in_anglY_thresh_rising_label
What: /sys/bus/iio/devices/iio:deviceX/events/in_phaseY_mag_rising_label
KernelVersion: 6.7
Contact: [email protected]
Description:
Optional symbolic label to a device channel event.
If a label is defined for this event add that to the event
specific attributes. This is useful for userspace to be able to
better identify an individual event.
27 changes: 27 additions & 0 deletions Documentation/ABI/testing/sysfs-bus-iio-resolver-ad2s1210
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
What: /sys/bus/iio/devices/iio:deviceX/events/in_altvoltage0_mag_rising_reset_max
KernelVersion: 6.7
Contact: [email protected]
Description:
Reading returns the current Degradation of Signal Reset Maximum
Threshold value in millivolts. Writing sets the value.

What: /sys/bus/iio/devices/iio:deviceX/events/in_altvoltage0_mag_rising_reset_max_available
KernelVersion: 6.7
Contact: [email protected]
Description:
Reading returns the allowable voltage range for
in_altvoltage0_mag_rising_reset_max.

What: /sys/bus/iio/devices/iio:deviceX/events/in_altvoltage0_mag_rising_reset_min
KernelVersion: 6.7
Contact: [email protected]
Description:
Reading returns the current Degradation of Signal Reset Minimum
Threshold value in millivolts. Writing sets the value.

What: /sys/bus/iio/devices/iio:deviceX/events/in_altvoltage0_mag_rising_reset_min_available
KernelVersion: 6.7
Contact: [email protected]
Description:
Reading returns the allowable voltage range for
in_altvoltage0_mag_rising_reset_min.
177 changes: 177 additions & 0 deletions Documentation/devicetree/bindings/iio/resolver/adi,ad2s1210.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/iio/resolver/adi,ad2s1210.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Analog Devices AD2S1210 Resolver-to-Digital Converter

maintainers:
- Michael Hennerich <[email protected]>

description: |
The AD2S1210 is a complete 10-bit to 16-bit resolution tracking
resolver-to-digital converter, integrating an on-board programmable
sinusoidal oscillator that provides sine wave excitation for
resolvers.

The AD2S1210 allows the user to read the angular position or the
angular velocity data directly from the parallel outputs or through
the serial interface.

The mode of operation of the communication channel (parallel or serial) is
selected by the A0 and A1 input pins. In normal mode, data is latched by
toggling the SAMPLE line and can then be read directly. In configuration mode,
data is read or written using a register access scheme (address byte with
read/write flag and data byte).

A1 A0 Result
0 0 Normal mode - position output
0 1 Normal mode - velocity output
1 0 Reserved
1 1 Configuration mode

In normal mode, the resolution of the digital output is selected using
the RES0 and RES1 input pins. In configuration mode, the resolution is
selected by setting the RES0 and RES1 bits in the control register.

RES1 RES0 Resolution (Bits)
0 0 10
0 1 12
1 0 14
1 1 16

Note on SPI connections: The CS line on the AD2S1210 should hard-wired to
logic low and the WR/FSYNC line on the AD2S1210 should be connected to the
SPI CSn output of the SPI controller.

Datasheet:
https://www.analog.com/media/en/technical-documentation/data-sheets/ad2s1210.pdf

properties:
compatible:
const: adi,ad2s1210

reg:
maxItems: 1

spi-max-frequency:
maximum: 25000000

spi-cpha: true

avdd-supply:
description:
A 4.75 to 5.25 V regulator that powers the Analog Supply Voltage (AVDD)
pin.

dvdd-supply:
description:
A 4.75 to 5.25 V regulator that powers the Digital Supply Voltage (DVDD)
pin.

vdrive-supply:
description:
A 2.3 to 5.25 V regulator that powers the Logic Power Supply Input
(VDrive) pin.

clocks:
maxItems: 1
description: External oscillator clock (CLKIN).

reset-gpios:
description:
GPIO connected to the /RESET pin. As the line needs to be low for the
reset to be active, it should be configured as GPIO_ACTIVE_LOW.
maxItems: 1

sample-gpios:
description:
GPIO connected to the /SAMPLE pin. As the line needs to be low to trigger
a sample, it should be configured as GPIO_ACTIVE_LOW.
maxItems: 1

mode-gpios:
description:
GPIO lines connected to the A0 and A1 pins. These pins select the data
transfer mode.
minItems: 2
maxItems: 2

resolution-gpios:
description:
GPIO lines connected to the RES0 and RES1 pins. These pins select the
resolution of the digital output. If omitted, it is assumed that the
RES0 and RES1 pins are hard-wired to match the assigned-resolution-bits
property.
minItems: 2
maxItems: 2

fault-gpios:
description:
GPIO lines connected to the LOT and DOS pins. These pins combined indicate
the type of fault present, if any. As these pins a pulled low to indicate
a fault condition, they should be configured as GPIO_ACTIVE_LOW.
minItems: 2
maxItems: 2

adi,fixed-mode:
description:
This is used to indicate the selected mode if A0 and A1 are hard-wired
instead of connected to GPIOS (i.e. mode-gpios is omitted).
$ref: /schemas/types.yaml#/definitions/string
enum: [config, velocity, position]

assigned-resolution-bits:
description:
Resolution of the digital output required by the application. This
determines the precision of the angle and/or the maximum speed that can
be measured. If resolution-gpios is omitted, it is assumed that RES0 and
RES1 are hard-wired to match this value.
enum: [10, 12, 14, 16]

required:
- compatible
- reg
- spi-cpha
- avdd-supply
- dvdd-supply
- vdrive-supply
- clocks
- sample-gpios
- assigned-resolution-bits

oneOf:
- required:
- mode-gpios
- required:
- adi,fixed-mode

allOf:
- $ref: /schemas/spi/spi-peripheral-props.yaml#

unevaluatedProperties: false

examples:
- |
#include <dt-bindings/gpio/gpio.h>

spi {
#address-cells = <1>;
#size-cells = <0>;

resolver@0 {
compatible = "adi,ad2s1210";
reg = <0>;
spi-max-frequency = <20000000>;
spi-cpha;
avdd-supply = <&avdd_regulator>;
dvdd-supply = <&dvdd_regulator>;
vdrive-supply = <&vdrive_regulator>;
clocks = <&ext_osc>;
sample-gpios = <&gpio0 90 GPIO_ACTIVE_LOW>;
mode-gpios = <&gpio0 86 0>, <&gpio0 87 0>;
resolution-gpios = <&gpio0 88 0>, <&gpio0 89 0>;
assigned-resolution-bits = <16>;
};
};
dlech marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,7 @@ HOSTRUSTC = rustc
HOSTPKG_CONFIG = pkg-config

KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
-O2 -fomit-frame-pointer -std=gnu11 \
-Wdeclaration-after-statement
-O2 -fomit-frame-pointer -std=gnu11
KBUILD_USERCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(USERCFLAGS)
KBUILD_USERLDFLAGS := $(USERLDFLAGS)

Expand Down Expand Up @@ -1011,9 +1010,6 @@ endif
# arch Makefile may override CC so keep this after arch Makefile is included
NOSTDINC_FLAGS += -nostdinc

# warn about C99 declaration after statement
KBUILD_CFLAGS += -Wdeclaration-after-statement

# Variable Length Arrays (VLAs) should not be used anywhere in the kernel
KBUILD_CFLAGS += -Wvla

Expand Down
63 changes: 63 additions & 0 deletions arch/arm/boot/dts/zynq-zed-adv7511-ad2s1210.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Analog Devices AD2S1210
* https://wiki.analog.com/resources/tools-software/linux-drivers/iio-resolver/ad2s1210
* https://wiki.analog.com/resources/eval/user-guides/ad2s1210_sdz
*
* hdl_project: <ad2s1210_sdz/zed>
* board_revision: <>
*
* Copyright (C) 2023 BayLibre SAS.
*/
/dts-v1/;

#include <dt-bindings/gpio/gpio.h>

#include "zynq-zed.dtsi"
#include "zynq-zed-adv7511.dtsi"

&spi0 {
status = "okay";

ad2s1210@0 {
compatible = "adi,ad2s1210";
reg = <0>;
spi-cpha;
spi-max-frequency = <20000000>;
clocks = <&ad2s1210_clkin>;
sample-gpios = <&gpio0 90 GPIO_ACTIVE_LOW>;
mode-gpios = <&gpio0 87 0>, <&gpio0 86 0>;
resolution-gpios = <&gpio0 89 0>, <&gpio0 88 0>;
assigned-resolution-bits = <16>;
avdd-supply = <&ad2s1210_avdd>;
dvdd-supply = <&ad2s1210_dvdd>;
vdrive-supply = <&ad2s1210_dvdd>;
};
};

/ {
/* external oscilator on AD2S1210 eval board */
ad2s1210_clkin: ad2s1210-clkin-clock {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <8192000>;
};

/* U704 on eval board */
ad2s1210_avdd: ad2s1210-avdd-regulator {
compatible = "regulator-fixed";
regulator-name = "ad2s1210_avdd";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
regulator-always-on;
};

/* U700 on eval board */
ad2s1210_dvdd: ad2s1210-dvdd-regulator {
compatible = "regulator-fixed";
regulator-name = "ad2s1210_dvdd";
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5000000>;
regulator-always-on;
};
};
2 changes: 0 additions & 2 deletions arch/arm64/kernel/vdso32/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,9 @@ VDSO_CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-fno-strict-aliasing -fno-common \
-Werror-implicit-function-declaration \
-Wno-format-security \
-Wdeclaration-after-statement \
-std=gnu11
VDSO_CFLAGS += -O2
# Some useful compiler-dependent flags from top-level Makefile
VDSO_CFLAGS += $(call cc32-option,-Wdeclaration-after-statement,)
VDSO_CFLAGS += $(call cc32-option,-Wno-pointer-sign)
VDSO_CFLAGS += -fno-strict-overflow
VDSO_CFLAGS += $(call cc32-option,-Werror=strict-prototypes)
Expand Down
55 changes: 55 additions & 0 deletions drivers/iio/industrialio-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,21 @@ static ssize_t iio_ev_value_store(struct device *dev,
return len;
}

static ssize_t iio_ev_label_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);

if (indio_dev->info->read_event_label)
return indio_dev->info->read_event_label(indio_dev,
this_attr->c, iio_ev_attr_type(this_attr),
iio_ev_attr_dir(this_attr), buf);

return -EINVAL;
}

static int iio_device_add_event(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan, unsigned int spec_index,
enum iio_event_type type, enum iio_event_direction dir,
Expand Down Expand Up @@ -409,6 +424,41 @@ static int iio_device_add_event(struct iio_dev *indio_dev,
return attrcount;
}

static int iio_device_add_event_label(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan,
unsigned int spec_index,
enum iio_event_type type,
enum iio_event_direction dir)
{
struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
char *postfix;
int ret;

if (!indio_dev->info->read_event_label)
return 0;

if (dir != IIO_EV_DIR_NONE)
postfix = kasprintf(GFP_KERNEL, "%s_%s_label",
iio_ev_type_text[type],
iio_ev_dir_text[dir]);
else
postfix = kasprintf(GFP_KERNEL, "%s_label",
iio_ev_type_text[type]);
if (postfix == NULL)
return -ENOMEM;

ret = __iio_add_chan_devattr(postfix, chan, &iio_ev_label_show, NULL,
spec_index, IIO_SEPARATE, &indio_dev->dev, NULL,
&iio_dev_opaque->event_interface->dev_attr_list);

kfree(postfix);

if (ret < 0)
return ret;

return 1;
}

static int iio_device_add_event_sysfs(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan)
{
Expand Down Expand Up @@ -446,6 +496,11 @@ static int iio_device_add_event_sysfs(struct iio_dev *indio_dev,
if (ret < 0)
return ret;
attrcount += ret;

ret = iio_device_add_event_label(indio_dev, chan, i, type, dir);
if (ret < 0)
return ret;
attrcount += ret;
}
ret = attrcount;
return ret;
Expand Down
Loading
Loading