Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'iio-for-6.8b' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next

Jonathan writes:

IIO: 2nd set of new device support, features and cleanup for 6.8

A late/optimistic second pull request. The bots have been poking them
since Wednesday without any issues. There are a few fixes in the
ad7091r5 driver as part of rework to enable the ad7091r8 parts that
are included at start of that series.

Includes pre-work for major changes to the DMA buffers that should
land in 6.9 and will greatly improve performance and flexibility for
high performance devices by enabling DMABUF based zero copy transfers
when we don't need to bounce the data via user space.

New device support
------------------
adi,ad7091r8
- Major refactor of existing adi,ad7091r5 driver to separate out useful
shared library code that can be used by I2C and SPI parts.
- Use that library from a new driver supporting the AD7091R-2, AD7091R-4
and AD7091R-8 12-Bit SPI ADCs.
- Series includes some late breaking fixes for the ad7091r5.

microchip,mcp4821
- New driver for MCP4801, MCP4802, MCP4811, MCP4812, MCP4821 and MCP4822
I2C single / dual channel DACs.

Cleanup
-------
buffers:
- Use IIO_SEPARATE in place of some hard-coded 0 values.
dma-buffers:
- Simplify things to not use an outgoing queue given it only ever has
up to two elements and we only need to track which is first.
- Split the iio_dma_buffer_fileio_free() function up to make it easier
to read and enable reuse in a series lining up for 6.9
iio.h
- Drop some stale documentation of struct fields that don't exist.

* tag 'iio-for-6.8b' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio:
iio: linux/iio.h: fix Excess kernel-doc description warning
MAINTAINERS: Add MAINTAINERS entry for AD7091R
iio: adc: Add support for AD7091R-8
dt-bindings: iio: Add AD7091R-8
iio: adc: Split AD7091R-5 config symbol
iio: adc: ad7091r: Add chip_info callback to get conversion result channel
iio: adc: ad7091r: Set device mode through chip_info callback
iio: adc: ad7091r: Remove unneeded probe parameters
iio: adc: ad7091r: Move chip init data to container struct
iio: adc: ad7091r: Move generic AD7091R code to base driver and header file
iio: adc: ad7091r: Enable internal vref if external vref is not supplied
iio: adc: ad7091r: Allow users to configure device events
iio: dac: driver for MCP4821
dt-bindings: iio: dac: add MCP4821
iio: buffer-dma: split iio_dma_buffer_fileio_free() function
iio: buffer-dma: Get rid of outgoing queue
iio: buffer: Use IIO_SEPARATE instead of a hard-coded 0

+1107 -193
+78 -4
Documentation/devicetree/bindings/iio/adc/adi,ad7091r5.yaml
··· 4 4 $id: http://devicetree.org/schemas/iio/adc/adi,ad7091r5.yaml# 5 5 $schema: http://devicetree.org/meta-schemas/core.yaml# 6 6 7 - title: Analog Devices AD7091R5 4-Channel 12-Bit ADC 7 + title: Analog Devices AD7091R-2/-4/-5/-8 Multi-Channel 12-Bit ADCs 8 8 9 9 maintainers: 10 10 - Michael Hennerich <michael.hennerich@analog.com> 11 + - Marcelo Schmitt <marcelo.schmitt@analog.com> 11 12 12 13 description: | 13 - Analog Devices AD7091R5 4-Channel 12-Bit ADC 14 + Analog Devices AD7091R5 4-Channel 12-Bit ADC supporting I2C interface 14 15 https://www.analog.com/media/en/technical-documentation/data-sheets/ad7091r-5.pdf 16 + Analog Devices AD7091R-2/AD7091R-4/AD7091R-8 2-/4-/8-Channel 12-Bit ADCs 17 + supporting SPI interface 18 + https://www.analog.com/media/en/technical-documentation/data-sheets/AD7091R-2_7091R-4_7091R-8.pdf 15 19 16 20 properties: 17 21 compatible: 18 22 enum: 23 + - adi,ad7091r2 24 + - adi,ad7091r4 19 25 - adi,ad7091r5 26 + - adi,ad7091r8 20 27 21 28 reg: 22 29 maxItems: 1 30 + 31 + vdd-supply: 32 + description: 33 + Provide VDD power to the sensor (VDD range is from 2.7V to 5.25V). 34 + 35 + vdrive-supply: 36 + description: 37 + Determines the voltage level at which the interface logic will operate. 38 + The V_drive voltage range is from 1.8V to 5.25V and must not exceed VDD by 39 + more than 0.3V. 23 40 24 41 vref-supply: 25 42 description: 26 43 Phandle to the vref power supply 27 44 28 - interrupts: 45 + convst-gpios: 46 + description: 47 + GPIO connected to the CONVST pin. 48 + This logic input is used to initiate conversions on the analog 49 + input channels. 29 50 maxItems: 1 30 51 52 + reset-gpios: 53 + maxItems: 1 54 + 55 + interrupts: 56 + description: 57 + Interrupt for signaling when conversion results exceed the high limit for 58 + ADC readings or fall below the low limit for them. Interrupt source must 59 + be attached to ALERT/BUSY/GPO0 pin. 60 + maxItems: 1 31 61 32 62 required: 33 63 - compatible 34 64 - reg 35 65 36 - additionalProperties: false 66 + allOf: 67 + - $ref: /schemas/spi/spi-peripheral-props.yaml# 68 + 69 + # AD7091R-2 does not have ALERT/BUSY/GPO pin 70 + - if: 71 + properties: 72 + compatible: 73 + contains: 74 + enum: 75 + - adi,ad7091r2 76 + then: 77 + properties: 78 + interrupts: false 79 + 80 + - if: 81 + properties: 82 + compatible: 83 + contains: 84 + enum: 85 + - adi,ad7091r2 86 + - adi,ad7091r4 87 + - adi,ad7091r8 88 + then: 89 + required: 90 + - convst-gpios 91 + 92 + unevaluatedProperties: false 37 93 38 94 examples: 39 95 - | ··· 104 48 reg = <0x2f>; 105 49 106 50 interrupts = <25 IRQ_TYPE_EDGE_FALLING>; 51 + interrupt-parent = <&gpio>; 52 + }; 53 + }; 54 + - | 55 + #include <dt-bindings/gpio/gpio.h> 56 + #include <dt-bindings/interrupt-controller/irq.h> 57 + spi { 58 + #address-cells = <1>; 59 + #size-cells = <0>; 60 + 61 + adc@0 { 62 + compatible = "adi,ad7091r8"; 63 + reg = <0x0>; 64 + spi-max-frequency = <1000000>; 65 + vref-supply = <&adc_vref>; 66 + convst-gpios = <&gpio 25 GPIO_ACTIVE_LOW>; 67 + reset-gpios = <&gpio 27 GPIO_ACTIVE_LOW>; 68 + interrupts = <22 IRQ_TYPE_EDGE_FALLING>; 107 69 interrupt-parent = <&gpio>; 108 70 }; 109 71 };
+86
Documentation/devicetree/bindings/iio/dac/microchip,mcp4821.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/iio/dac/microchip,mcp4821.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Microchip MCP4821 and similar DACs 8 + 9 + description: | 10 + Supports MCP48x1 (single channel) and MCP48x2 (dual channel) series of DACs. 11 + Device supports simplex communication over SPI in Mode 0 and Mode 3. 12 + 13 + +---------+--------------+-------------+ 14 + | Device | Resolution | Channels | 15 + |---------|--------------|-------------| 16 + | MCP4801 | 8-bit | 1 | 17 + | MCP4802 | 8-bit | 2 | 18 + | MCP4811 | 10-bit | 1 | 19 + | MCP4812 | 10-bit | 2 | 20 + | MCP4821 | 12-bit | 1 | 21 + | MCP4822 | 12-bit | 2 | 22 + +---------+--------------+-------------+ 23 + 24 + Datasheet: 25 + MCP48x1: https://ww1.microchip.com/downloads/en/DeviceDoc/22244B.pdf 26 + MCP48x2: https://ww1.microchip.com/downloads/en/DeviceDoc/20002249B.pdf 27 + 28 + maintainers: 29 + - Anshul Dalal <anshulusr@gmail.com> 30 + 31 + allOf: 32 + - $ref: /schemas/spi/spi-peripheral-props.yaml# 33 + 34 + properties: 35 + compatible: 36 + enum: 37 + - microchip,mcp4801 38 + - microchip,mcp4802 39 + - microchip,mcp4811 40 + - microchip,mcp4812 41 + - microchip,mcp4821 42 + - microchip,mcp4822 43 + 44 + reg: 45 + maxItems: 1 46 + 47 + vdd-supply: true 48 + 49 + ldac-gpios: 50 + description: | 51 + Active Low LDAC (Latch DAC Input) pin used to update the DAC output. 52 + maxItems: 1 53 + 54 + powerdown-gpios: 55 + description: | 56 + Active Low SHDN pin used to enter the shutdown mode. 57 + maxItems: 1 58 + 59 + spi-cpha: true 60 + spi-cpol: true 61 + 62 + required: 63 + - compatible 64 + - reg 65 + - vdd-supply 66 + 67 + additionalProperties: false 68 + 69 + examples: 70 + - | 71 + #include <dt-bindings/gpio/gpio.h> 72 + 73 + spi { 74 + #address-cells = <1>; 75 + #size-cells = <0>; 76 + 77 + dac@0 { 78 + compatible = "microchip,mcp4821"; 79 + reg = <0>; 80 + vdd-supply = <&vdd_regulator>; 81 + ldac-gpios = <&gpio0 1 GPIO_ACTIVE_HIGH>; 82 + powerdown-gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>; 83 + spi-cpha; 84 + spi-cpol; 85 + }; 86 + };
+15
MAINTAINERS
··· 1122 1122 F: Documentation/devicetree/bindings/iio/adc/adi,ad4130.yaml 1123 1123 F: drivers/iio/adc/ad4130.c 1124 1124 1125 + ANALOG DEVICES INC AD7091R DRIVER 1126 + M: Marcelo Schmitt <marcelo.schmitt@analog.com> 1127 + L: linux-iio@vger.kernel.org 1128 + S: Supported 1129 + W: http://ez.analog.com/community/linux-device-drivers 1130 + F: Documentation/devicetree/bindings/iio/adc/adi,ad7091r* 1131 + F: drivers/iio/adc/drivers/iio/adc/ad7091r* 1132 + 1125 1133 ANALOG DEVICES INC AD7192 DRIVER 1126 1134 M: Alexandru Tachici <alexandru.tachici@analog.com> 1127 1135 L: linux-iio@vger.kernel.org ··· 13187 13179 F: Documentation/ABI/testing/sysfs-bus-iio-potentiometer-mcp4531 13188 13180 F: drivers/iio/potentiometer/mcp4018.c 13189 13181 F: drivers/iio/potentiometer/mcp4531.c 13182 + 13183 + MCP4821 DAC DRIVER 13184 + M: Anshul Dalal <anshulusr@gmail.com> 13185 + L: linux-iio@vger.kernel.org 13186 + S: Maintained 13187 + F: Documentation/devicetree/bindings/iio/dac/microchip,mcp4821.yaml 13188 + F: drivers/iio/dac/mcp4821.c 13190 13189 13191 13190 MCR20A IEEE-802.15.4 RADIO DRIVER 13192 13191 M: Stefan Schmidt <stefan@datenfreihafen.org>
+16
drivers/iio/adc/Kconfig
··· 36 36 To compile this driver as a module, choose M here: the module will be 37 37 called ad4130. 38 38 39 + config AD7091R 40 + tristate 41 + 39 42 config AD7091R5 40 43 tristate "Analog Devices AD7091R5 ADC Driver" 41 44 depends on I2C 45 + select AD7091R 42 46 select REGMAP_I2C 43 47 help 44 48 Say yes here to build support for Analog Devices AD7091R-5 ADC. 49 + 50 + config AD7091R8 51 + tristate "Analog Devices AD7091R8 ADC Driver" 52 + depends on SPI 53 + select AD7091R 54 + select REGMAP_SPI 55 + help 56 + Say yes here to build support for Analog Devices AD7091R-2, AD7091R-4, 57 + and AD7091R-8 ADC. 58 + 59 + To compile this driver as a module, choose M here: the module will be 60 + called ad7091r8. 45 61 46 62 config AD7124 47 63 tristate "Analog Devices AD7124 and similar sigma-delta ADCs driver"
+3 -1
drivers/iio/adc/Makefile
··· 7 7 obj-$(CONFIG_AB8500_GPADC) += ab8500-gpadc.o 8 8 obj-$(CONFIG_AD_SIGMA_DELTA) += ad_sigma_delta.o 9 9 obj-$(CONFIG_AD4130) += ad4130.o 10 - obj-$(CONFIG_AD7091R5) += ad7091r5.o ad7091r-base.o 10 + obj-$(CONFIG_AD7091R) += ad7091r-base.o 11 + obj-$(CONFIG_AD7091R5) += ad7091r5.o 12 + obj-$(CONFIG_AD7091R8) += ad7091r8.o 11 13 obj-$(CONFIG_AD7124) += ad7124.o 12 14 obj-$(CONFIG_AD7192) += ad7192.o 13 15 obj-$(CONFIG_AD7266) += ad7266.o
+187 -82
drivers/iio/adc/ad7091r-base.c
··· 6 6 */ 7 7 8 8 #include <linux/bitops.h> 9 + #include <linux/bitfield.h> 9 10 #include <linux/iio/events.h> 10 11 #include <linux/iio/iio.h> 11 12 #include <linux/interrupt.h> ··· 16 15 17 16 #include "ad7091r-base.h" 18 17 19 - #define AD7091R_REG_RESULT 0 20 - #define AD7091R_REG_CHANNEL 1 21 - #define AD7091R_REG_CONF 2 22 - #define AD7091R_REG_ALERT 3 23 - #define AD7091R_REG_CH_LOW_LIMIT(ch) ((ch) * 3 + 4) 24 - #define AD7091R_REG_CH_HIGH_LIMIT(ch) ((ch) * 3 + 5) 25 - #define AD7091R_REG_CH_HYSTERESIS(ch) ((ch) * 3 + 6) 26 - 27 - /* AD7091R_REG_RESULT */ 28 - #define AD7091R_REG_RESULT_CH_ID(x) (((x) >> 13) & 0x3) 29 - #define AD7091R_REG_RESULT_CONV_RESULT(x) ((x) & 0xfff) 30 - 31 - /* AD7091R_REG_CONF */ 32 - #define AD7091R_REG_CONF_ALERT_EN BIT(4) 33 - #define AD7091R_REG_CONF_AUTO BIT(8) 34 - #define AD7091R_REG_CONF_CMD BIT(10) 35 - 36 - #define AD7091R_REG_CONF_MODE_MASK \ 37 - (AD7091R_REG_CONF_AUTO | AD7091R_REG_CONF_CMD) 38 - 39 - enum ad7091r_mode { 40 - AD7091R_MODE_SAMPLE, 41 - AD7091R_MODE_COMMAND, 42 - AD7091R_MODE_AUTOCYCLE, 18 + const struct iio_event_spec ad7091r_events[] = { 19 + { 20 + .type = IIO_EV_TYPE_THRESH, 21 + .dir = IIO_EV_DIR_RISING, 22 + .mask_separate = BIT(IIO_EV_INFO_VALUE) | 23 + BIT(IIO_EV_INFO_ENABLE), 24 + }, 25 + { 26 + .type = IIO_EV_TYPE_THRESH, 27 + .dir = IIO_EV_DIR_FALLING, 28 + .mask_separate = BIT(IIO_EV_INFO_VALUE) | 29 + BIT(IIO_EV_INFO_ENABLE), 30 + }, 31 + { 32 + .type = IIO_EV_TYPE_THRESH, 33 + .dir = IIO_EV_DIR_EITHER, 34 + .mask_separate = BIT(IIO_EV_INFO_HYSTERESIS), 35 + }, 43 36 }; 44 - 45 - struct ad7091r_state { 46 - struct device *dev; 47 - struct regmap *map; 48 - struct regulator *vref; 49 - const struct ad7091r_chip_info *chip_info; 50 - enum ad7091r_mode mode; 51 - struct mutex lock; /*lock to prevent concurent reads */ 52 - }; 53 - 54 - static int ad7091r_set_mode(struct ad7091r_state *st, enum ad7091r_mode mode) 55 - { 56 - int ret, conf; 57 - 58 - switch (mode) { 59 - case AD7091R_MODE_SAMPLE: 60 - conf = 0; 61 - break; 62 - case AD7091R_MODE_COMMAND: 63 - conf = AD7091R_REG_CONF_CMD; 64 - break; 65 - case AD7091R_MODE_AUTOCYCLE: 66 - conf = AD7091R_REG_CONF_AUTO; 67 - break; 68 - default: 69 - return -EINVAL; 70 - } 71 - 72 - ret = regmap_update_bits(st->map, AD7091R_REG_CONF, 73 - AD7091R_REG_CONF_MODE_MASK, conf); 74 - if (ret) 75 - return ret; 76 - 77 - st->mode = mode; 78 - 79 - return 0; 80 - } 37 + EXPORT_SYMBOL_NS_GPL(ad7091r_events, IIO_AD7091R); 81 38 82 39 static int ad7091r_set_channel(struct ad7091r_state *st, unsigned int channel) 83 40 { ··· 70 111 if (ret) 71 112 return ret; 72 113 73 - if (AD7091R_REG_RESULT_CH_ID(val) != channel) 114 + if (st->chip_info->reg_result_chan_id(val) != channel) 74 115 return -EIO; 75 116 76 117 *read_val = AD7091R_REG_RESULT_CONV_RESULT(val); ··· 128 169 return ret; 129 170 } 130 171 172 + static int ad7091r_read_event_config(struct iio_dev *indio_dev, 173 + const struct iio_chan_spec *chan, 174 + enum iio_event_type type, 175 + enum iio_event_direction dir) 176 + { 177 + struct ad7091r_state *st = iio_priv(indio_dev); 178 + int val, ret; 179 + 180 + switch (dir) { 181 + case IIO_EV_DIR_RISING: 182 + ret = regmap_read(st->map, 183 + AD7091R_REG_CH_HIGH_LIMIT(chan->channel), 184 + &val); 185 + if (ret) 186 + return ret; 187 + return val != AD7091R_HIGH_LIMIT; 188 + case IIO_EV_DIR_FALLING: 189 + ret = regmap_read(st->map, 190 + AD7091R_REG_CH_LOW_LIMIT(chan->channel), 191 + &val); 192 + if (ret) 193 + return ret; 194 + return val != AD7091R_LOW_LIMIT; 195 + default: 196 + return -EINVAL; 197 + } 198 + } 199 + 200 + static int ad7091r_write_event_config(struct iio_dev *indio_dev, 201 + const struct iio_chan_spec *chan, 202 + enum iio_event_type type, 203 + enum iio_event_direction dir, int state) 204 + { 205 + struct ad7091r_state *st = iio_priv(indio_dev); 206 + 207 + if (state) { 208 + return regmap_set_bits(st->map, AD7091R_REG_CONF, 209 + AD7091R_REG_CONF_ALERT_EN); 210 + } else { 211 + /* 212 + * Set thresholds either to 0 or to 2^12 - 1 as appropriate to 213 + * prevent alerts and thus disable event generation. 214 + */ 215 + switch (dir) { 216 + case IIO_EV_DIR_RISING: 217 + return regmap_write(st->map, 218 + AD7091R_REG_CH_HIGH_LIMIT(chan->channel), 219 + AD7091R_HIGH_LIMIT); 220 + case IIO_EV_DIR_FALLING: 221 + return regmap_write(st->map, 222 + AD7091R_REG_CH_LOW_LIMIT(chan->channel), 223 + AD7091R_LOW_LIMIT); 224 + default: 225 + return -EINVAL; 226 + } 227 + } 228 + } 229 + 230 + static int ad7091r_read_event_value(struct iio_dev *indio_dev, 231 + const struct iio_chan_spec *chan, 232 + enum iio_event_type type, 233 + enum iio_event_direction dir, 234 + enum iio_event_info info, int *val, int *val2) 235 + { 236 + struct ad7091r_state *st = iio_priv(indio_dev); 237 + int ret; 238 + 239 + switch (info) { 240 + case IIO_EV_INFO_VALUE: 241 + switch (dir) { 242 + case IIO_EV_DIR_RISING: 243 + ret = regmap_read(st->map, 244 + AD7091R_REG_CH_HIGH_LIMIT(chan->channel), 245 + val); 246 + if (ret) 247 + return ret; 248 + return IIO_VAL_INT; 249 + case IIO_EV_DIR_FALLING: 250 + ret = regmap_read(st->map, 251 + AD7091R_REG_CH_LOW_LIMIT(chan->channel), 252 + val); 253 + if (ret) 254 + return ret; 255 + return IIO_VAL_INT; 256 + default: 257 + return -EINVAL; 258 + } 259 + case IIO_EV_INFO_HYSTERESIS: 260 + ret = regmap_read(st->map, 261 + AD7091R_REG_CH_HYSTERESIS(chan->channel), 262 + val); 263 + if (ret) 264 + return ret; 265 + return IIO_VAL_INT; 266 + default: 267 + return -EINVAL; 268 + } 269 + } 270 + 271 + static int ad7091r_write_event_value(struct iio_dev *indio_dev, 272 + const struct iio_chan_spec *chan, 273 + enum iio_event_type type, 274 + enum iio_event_direction dir, 275 + enum iio_event_info info, int val, int val2) 276 + { 277 + struct ad7091r_state *st = iio_priv(indio_dev); 278 + 279 + switch (info) { 280 + case IIO_EV_INFO_VALUE: 281 + switch (dir) { 282 + case IIO_EV_DIR_RISING: 283 + return regmap_write(st->map, 284 + AD7091R_REG_CH_HIGH_LIMIT(chan->channel), 285 + val); 286 + case IIO_EV_DIR_FALLING: 287 + return regmap_write(st->map, 288 + AD7091R_REG_CH_LOW_LIMIT(chan->channel), 289 + val); 290 + default: 291 + return -EINVAL; 292 + } 293 + case IIO_EV_INFO_HYSTERESIS: 294 + return regmap_write(st->map, 295 + AD7091R_REG_CH_HYSTERESIS(chan->channel), 296 + val); 297 + default: 298 + return -EINVAL; 299 + } 300 + } 301 + 131 302 static const struct iio_info ad7091r_info = { 132 303 .read_raw = ad7091r_read_raw, 304 + .read_event_config = &ad7091r_read_event_config, 305 + .write_event_config = &ad7091r_write_event_config, 306 + .read_event_value = &ad7091r_read_event_value, 307 + .write_event_value = &ad7091r_write_event_value, 133 308 }; 134 309 135 310 static irqreturn_t ad7091r_event_handler(int irq, void *private) ··· 301 208 regulator_disable(st->vref); 302 209 } 303 210 304 - int ad7091r_probe(struct device *dev, const char *name, 305 - const struct ad7091r_chip_info *chip_info, 306 - struct regmap *map, int irq) 211 + int ad7091r_probe(struct device *dev, const struct ad7091r_init_info *init_info, 212 + int irq) 307 213 { 308 214 struct iio_dev *iio_dev; 309 215 struct ad7091r_state *st; ··· 314 222 315 223 st = iio_priv(iio_dev); 316 224 st->dev = dev; 317 - st->chip_info = chip_info; 318 - st->map = map; 225 + init_info->init_adc_regmap(st, init_info->regmap_config); 226 + if (IS_ERR(st->map)) 227 + return dev_err_probe(st->dev, PTR_ERR(st->map), 228 + "Error initializing regmap\n"); 319 229 320 - iio_dev->name = name; 321 230 iio_dev->info = &ad7091r_info; 322 231 iio_dev->modes = INDIO_DIRECT_MODE; 323 232 324 - iio_dev->num_channels = chip_info->num_channels; 325 - iio_dev->channels = chip_info->channels; 233 + if (init_info->setup) { 234 + ret = init_info->setup(st); 235 + if (ret < 0) 236 + return ret; 237 + } 326 238 327 239 if (irq) { 240 + st->chip_info = init_info->info_irq; 328 241 ret = regmap_update_bits(st->map, AD7091R_REG_CONF, 329 242 AD7091R_REG_CONF_ALERT_EN, BIT(4)); 330 243 if (ret) ··· 338 241 ret = devm_request_threaded_irq(dev, irq, NULL, 339 242 ad7091r_event_handler, 340 243 IRQF_TRIGGER_FALLING | 341 - IRQF_ONESHOT, name, iio_dev); 244 + IRQF_ONESHOT, 245 + st->chip_info->name, iio_dev); 342 246 if (ret) 343 247 return ret; 248 + } else { 249 + st->chip_info = init_info->info_no_irq; 344 250 } 251 + 252 + iio_dev->name = st->chip_info->name; 253 + iio_dev->num_channels = st->chip_info->num_channels; 254 + iio_dev->channels = st->chip_info->channels; 345 255 346 256 st->vref = devm_regulator_get_optional(dev, "vref"); 347 257 if (IS_ERR(st->vref)) { 348 258 if (PTR_ERR(st->vref) == -EPROBE_DEFER) 349 259 return -EPROBE_DEFER; 260 + 350 261 st->vref = NULL; 262 + /* Enable internal vref */ 263 + ret = regmap_set_bits(st->map, AD7091R_REG_CONF, 264 + AD7091R_REG_CONF_INT_VREF); 265 + if (ret) 266 + return dev_err_probe(st->dev, ret, 267 + "Error on enable internal reference\n"); 351 268 } else { 352 269 ret = regulator_enable(st->vref); 353 270 if (ret) ··· 372 261 } 373 262 374 263 /* Use command mode by default to convert only desired channels*/ 375 - ret = ad7091r_set_mode(st, AD7091R_MODE_COMMAND); 264 + ret = st->chip_info->set_mode(st, AD7091R_MODE_COMMAND); 376 265 if (ret) 377 266 return ret; 378 267 ··· 380 269 } 381 270 EXPORT_SYMBOL_NS_GPL(ad7091r_probe, IIO_AD7091R); 382 271 383 - static bool ad7091r_writeable_reg(struct device *dev, unsigned int reg) 272 + bool ad7091r_writeable_reg(struct device *dev, unsigned int reg) 384 273 { 385 274 switch (reg) { 386 275 case AD7091R_REG_RESULT: ··· 390 279 return true; 391 280 } 392 281 } 282 + EXPORT_SYMBOL_NS_GPL(ad7091r_writeable_reg, IIO_AD7091R); 393 283 394 - static bool ad7091r_volatile_reg(struct device *dev, unsigned int reg) 284 + bool ad7091r_volatile_reg(struct device *dev, unsigned int reg) 395 285 { 396 286 switch (reg) { 397 287 case AD7091R_REG_RESULT: ··· 402 290 return false; 403 291 } 404 292 } 405 - 406 - const struct regmap_config ad7091r_regmap_config = { 407 - .reg_bits = 8, 408 - .val_bits = 16, 409 - .writeable_reg = ad7091r_writeable_reg, 410 - .volatile_reg = ad7091r_volatile_reg, 411 - }; 412 - EXPORT_SYMBOL_NS_GPL(ad7091r_regmap_config, IIO_AD7091R); 293 + EXPORT_SYMBOL_NS_GPL(ad7091r_volatile_reg, IIO_AD7091R); 413 294 414 295 MODULE_AUTHOR("Beniamin Bia <beniamin.bia@analog.com>"); 415 296 MODULE_DESCRIPTION("Analog Devices AD7091Rx multi-channel converters");
+78 -5
drivers/iio/adc/ad7091r-base.h
··· 8 8 #ifndef __DRIVERS_IIO_ADC_AD7091R_BASE_H__ 9 9 #define __DRIVERS_IIO_ADC_AD7091R_BASE_H__ 10 10 11 + #include <linux/regmap.h> 12 + 13 + #define AD7091R_REG_RESULT 0 14 + #define AD7091R_REG_CHANNEL 1 15 + #define AD7091R_REG_CONF 2 16 + #define AD7091R_REG_ALERT 3 17 + #define AD7091R_REG_CH_LOW_LIMIT(ch) ((ch) * 3 + 4) 18 + #define AD7091R_REG_CH_HIGH_LIMIT(ch) ((ch) * 3 + 5) 19 + #define AD7091R_REG_CH_HYSTERESIS(ch) ((ch) * 3 + 6) 20 + 21 + /* AD7091R_REG_RESULT */ 22 + #define AD7091R5_REG_RESULT_CH_ID(x) (((x) >> 13) & 0x3) 23 + #define AD7091R8_REG_RESULT_CH_ID(x) (((x) >> 13) & 0x7) 24 + #define AD7091R_REG_RESULT_CONV_RESULT(x) ((x) & 0xfff) 25 + 26 + /* AD7091R_REG_CONF */ 27 + #define AD7091R_REG_CONF_INT_VREF BIT(0) 28 + #define AD7091R_REG_CONF_ALERT_EN BIT(4) 29 + #define AD7091R_REG_CONF_AUTO BIT(8) 30 + #define AD7091R_REG_CONF_CMD BIT(10) 31 + 32 + #define AD7091R_REG_CONF_MODE_MASK \ 33 + (AD7091R_REG_CONF_AUTO | AD7091R_REG_CONF_CMD) 34 + 35 + /* AD7091R_REG_CH_LIMIT */ 36 + #define AD7091R_HIGH_LIMIT 0xFFF 37 + #define AD7091R_LOW_LIMIT 0x0 38 + 39 + #define AD7091R_CHANNEL(idx, bits, ev, num_ev) { \ 40 + .type = IIO_VOLTAGE, \ 41 + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ 42 + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ 43 + .indexed = 1, \ 44 + .channel = idx, \ 45 + .event_spec = ev, \ 46 + .num_event_specs = num_ev, \ 47 + .scan_type.storagebits = 16, \ 48 + .scan_type.realbits = bits, \ 49 + } 50 + 11 51 struct device; 12 - struct ad7091r_state; 52 + struct gpio_desc; 53 + 54 + enum ad7091r_mode { 55 + AD7091R_MODE_SAMPLE, 56 + AD7091R_MODE_COMMAND, 57 + AD7091R_MODE_AUTOCYCLE, 58 + }; 59 + 60 + struct ad7091r_state { 61 + struct device *dev; 62 + struct regmap *map; 63 + struct gpio_desc *convst_gpio; 64 + struct gpio_desc *reset_gpio; 65 + struct regulator *vref; 66 + const struct ad7091r_chip_info *chip_info; 67 + enum ad7091r_mode mode; 68 + struct mutex lock; /*lock to prevent concurent reads */ 69 + __be16 tx_buf __aligned(IIO_DMA_MINALIGN); 70 + __be16 rx_buf; 71 + }; 13 72 14 73 struct ad7091r_chip_info { 74 + const char *name; 15 75 unsigned int num_channels; 16 76 const struct iio_chan_spec *channels; 17 77 unsigned int vref_mV; 78 + unsigned int (*reg_result_chan_id)(unsigned int val); 79 + int (*set_mode)(struct ad7091r_state *st, enum ad7091r_mode mode); 18 80 }; 19 81 20 - extern const struct regmap_config ad7091r_regmap_config; 82 + struct ad7091r_init_info { 83 + const struct ad7091r_chip_info *info_irq; 84 + const struct ad7091r_chip_info *info_no_irq; 85 + const struct regmap_config *regmap_config; 86 + void (*init_adc_regmap)(struct ad7091r_state *st, 87 + const struct regmap_config *regmap_conf); 88 + int (*setup)(struct ad7091r_state *st); 89 + }; 21 90 22 - int ad7091r_probe(struct device *dev, const char *name, 23 - const struct ad7091r_chip_info *chip_info, 24 - struct regmap *map, int irq); 91 + extern const struct iio_event_spec ad7091r_events[3]; 92 + 93 + int ad7091r_probe(struct device *dev, const struct ad7091r_init_info *init_info, 94 + int irq); 95 + 96 + bool ad7091r_volatile_reg(struct device *dev, unsigned int reg); 97 + bool ad7091r_writeable_reg(struct device *dev, unsigned int reg); 25 98 26 99 #endif /* __DRIVERS_IIO_ADC_AD7091R_BASE_H__ */
+72 -48
drivers/iio/adc/ad7091r5.c
··· 12 12 13 13 #include "ad7091r-base.h" 14 14 15 - static const struct iio_event_spec ad7091r5_events[] = { 16 - { 17 - .type = IIO_EV_TYPE_THRESH, 18 - .dir = IIO_EV_DIR_RISING, 19 - .mask_separate = BIT(IIO_EV_INFO_VALUE) | 20 - BIT(IIO_EV_INFO_ENABLE), 21 - }, 22 - { 23 - .type = IIO_EV_TYPE_THRESH, 24 - .dir = IIO_EV_DIR_FALLING, 25 - .mask_separate = BIT(IIO_EV_INFO_VALUE) | 26 - BIT(IIO_EV_INFO_ENABLE), 27 - }, 28 - { 29 - .type = IIO_EV_TYPE_THRESH, 30 - .dir = IIO_EV_DIR_EITHER, 31 - .mask_separate = BIT(IIO_EV_INFO_HYSTERESIS), 32 - }, 33 - }; 34 - 35 - #define AD7091R_CHANNEL(idx, bits, ev, num_ev) { \ 36 - .type = IIO_VOLTAGE, \ 37 - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ 38 - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ 39 - .indexed = 1, \ 40 - .channel = idx, \ 41 - .event_spec = ev, \ 42 - .num_event_specs = num_ev, \ 43 - .scan_type.storagebits = 16, \ 44 - .scan_type.realbits = bits, \ 45 - } 46 15 static const struct iio_chan_spec ad7091r5_channels_irq[] = { 47 - AD7091R_CHANNEL(0, 12, ad7091r5_events, ARRAY_SIZE(ad7091r5_events)), 48 - AD7091R_CHANNEL(1, 12, ad7091r5_events, ARRAY_SIZE(ad7091r5_events)), 49 - AD7091R_CHANNEL(2, 12, ad7091r5_events, ARRAY_SIZE(ad7091r5_events)), 50 - AD7091R_CHANNEL(3, 12, ad7091r5_events, ARRAY_SIZE(ad7091r5_events)), 16 + AD7091R_CHANNEL(0, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), 17 + AD7091R_CHANNEL(1, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), 18 + AD7091R_CHANNEL(2, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), 19 + AD7091R_CHANNEL(3, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), 51 20 }; 52 21 53 22 static const struct iio_chan_spec ad7091r5_channels_noirq[] = { ··· 26 57 AD7091R_CHANNEL(3, 12, NULL, 0), 27 58 }; 28 59 60 + static int ad7091r5_set_mode(struct ad7091r_state *st, enum ad7091r_mode mode) 61 + { 62 + int ret, conf; 63 + 64 + switch (mode) { 65 + case AD7091R_MODE_SAMPLE: 66 + conf = 0; 67 + break; 68 + case AD7091R_MODE_COMMAND: 69 + conf = AD7091R_REG_CONF_CMD; 70 + break; 71 + case AD7091R_MODE_AUTOCYCLE: 72 + conf = AD7091R_REG_CONF_AUTO; 73 + break; 74 + default: 75 + return -EINVAL; 76 + } 77 + 78 + ret = regmap_update_bits(st->map, AD7091R_REG_CONF, 79 + AD7091R_REG_CONF_MODE_MASK, conf); 80 + if (ret) 81 + return ret; 82 + 83 + st->mode = mode; 84 + 85 + return 0; 86 + } 87 + 88 + static unsigned int ad7091r5_reg_result_chan_id(unsigned int val) 89 + { 90 + return AD7091R5_REG_RESULT_CH_ID(val); 91 + } 92 + 29 93 static const struct ad7091r_chip_info ad7091r5_chip_info_irq = { 94 + .name = "ad7091r-5", 30 95 .channels = ad7091r5_channels_irq, 31 96 .num_channels = ARRAY_SIZE(ad7091r5_channels_irq), 32 97 .vref_mV = 2500, 98 + .reg_result_chan_id = &ad7091r5_reg_result_chan_id, 99 + .set_mode = &ad7091r5_set_mode, 33 100 }; 34 101 35 102 static const struct ad7091r_chip_info ad7091r5_chip_info_noirq = { 103 + .name = "ad7091r-5", 36 104 .channels = ad7091r5_channels_noirq, 37 105 .num_channels = ARRAY_SIZE(ad7091r5_channels_noirq), 38 106 .vref_mV = 2500, 107 + .reg_result_chan_id = &ad7091r5_reg_result_chan_id, 108 + .set_mode = &ad7091r5_set_mode, 109 + }; 110 + 111 + static const struct regmap_config ad7091r_regmap_config = { 112 + .reg_bits = 8, 113 + .val_bits = 16, 114 + .writeable_reg = ad7091r_writeable_reg, 115 + .volatile_reg = ad7091r_volatile_reg, 116 + }; 117 + 118 + static void ad7091r5_regmap_init(struct ad7091r_state *st, 119 + const struct regmap_config *regmap_conf) 120 + { 121 + struct i2c_client *i2c = container_of(st->dev, struct i2c_client, dev); 122 + 123 + st->map = devm_regmap_init_i2c(i2c, regmap_conf); 124 + } 125 + 126 + static struct ad7091r_init_info ad7091r5_init_info = { 127 + .info_irq = &ad7091r5_chip_info_irq, 128 + .info_no_irq = &ad7091r5_chip_info_noirq, 129 + .regmap_config = &ad7091r_regmap_config, 130 + .init_adc_regmap = &ad7091r5_regmap_init 39 131 }; 40 132 41 133 static int ad7091r5_i2c_probe(struct i2c_client *i2c) 42 134 { 43 - const struct i2c_device_id *id = i2c_client_get_device_id(i2c); 44 - const struct ad7091r_chip_info *chip_info; 45 - struct regmap *map = devm_regmap_init_i2c(i2c, &ad7091r_regmap_config); 135 + const struct ad7091r_init_info *init_info; 46 136 47 - if (IS_ERR(map)) 48 - return PTR_ERR(map); 137 + init_info = i2c_get_match_data(i2c); 138 + if (!init_info) 139 + return -EINVAL; 49 140 50 - if (i2c->irq) 51 - chip_info = &ad7091r5_chip_info_irq; 52 - else 53 - chip_info = &ad7091r5_chip_info_noirq; 54 - 55 - return ad7091r_probe(&i2c->dev, id->name, chip_info, map, i2c->irq); 141 + return ad7091r_probe(&i2c->dev, init_info, i2c->irq); 56 142 } 57 143 58 144 static const struct of_device_id ad7091r5_dt_ids[] = { 59 - { .compatible = "adi,ad7091r5" }, 145 + { .compatible = "adi,ad7091r5", .data = &ad7091r5_init_info }, 60 146 {}, 61 147 }; 62 148 MODULE_DEVICE_TABLE(of, ad7091r5_dt_ids); 63 149 64 150 static const struct i2c_device_id ad7091r5_i2c_ids[] = { 65 - {"ad7091r5", 0}, 151 + {"ad7091r5", (kernel_ulong_t)&ad7091r5_init_info }, 66 152 {} 67 153 }; 68 154 MODULE_DEVICE_TABLE(i2c, ad7091r5_i2c_ids);
+272
drivers/iio/adc/ad7091r8.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Analog Devices AD7091R8 12-bit SAR ADC driver 4 + * 5 + * Copyright 2023 Analog Devices Inc. 6 + */ 7 + 8 + #include <linux/bitfield.h> 9 + #include <linux/iio/iio.h> 10 + #include <linux/module.h> 11 + #include <linux/regmap.h> 12 + #include <linux/gpio/consumer.h> 13 + #include <linux/spi/spi.h> 14 + 15 + #include "ad7091r-base.h" 16 + 17 + #define AD7091R8_REG_ADDR_MSK GENMASK(15, 11) 18 + #define AD7091R8_RD_WR_FLAG_MSK BIT(10) 19 + #define AD7091R8_REG_DATA_MSK GENMASK(9, 0) 20 + 21 + #define AD7091R_SPI_REGMAP_CONFIG(n) { \ 22 + .reg_bits = 8, \ 23 + .val_bits = 16, \ 24 + .volatile_reg = ad7091r_volatile_reg, \ 25 + .writeable_reg = ad7091r_writeable_reg, \ 26 + .max_register = AD7091R_REG_CH_HYSTERESIS(n), \ 27 + } 28 + 29 + static int ad7091r8_set_mode(struct ad7091r_state *st, enum ad7091r_mode mode) 30 + { 31 + /* AD7091R-2/-4/-8 don't set sample/command/autocycle mode in conf reg */ 32 + st->mode = mode; 33 + return 0; 34 + } 35 + 36 + static unsigned int ad7091r8_reg_result_chan_id(unsigned int val) 37 + { 38 + return AD7091R8_REG_RESULT_CH_ID(val); 39 + } 40 + 41 + #define AD7091R_SPI_CHIP_INFO(_n, _name) { \ 42 + .name = _name, \ 43 + .channels = ad7091r##_n##_channels, \ 44 + .num_channels = ARRAY_SIZE(ad7091r##_n##_channels), \ 45 + .vref_mV = 2500, \ 46 + .reg_result_chan_id = &ad7091r8_reg_result_chan_id, \ 47 + .set_mode = &ad7091r8_set_mode, \ 48 + } 49 + 50 + #define AD7091R_SPI_CHIP_INFO_IRQ(_n, _name) { \ 51 + .name = _name, \ 52 + .channels = ad7091r##_n##_channels_irq, \ 53 + .num_channels = ARRAY_SIZE(ad7091r##_n##_channels_irq), \ 54 + .vref_mV = 2500, \ 55 + .reg_result_chan_id = &ad7091r8_reg_result_chan_id, \ 56 + .set_mode = &ad7091r8_set_mode, \ 57 + } 58 + 59 + enum ad7091r8_info_ids { 60 + AD7091R2_INFO, 61 + AD7091R4_INFO, 62 + AD7091R4_INFO_IRQ, 63 + AD7091R8_INFO, 64 + AD7091R8_INFO_IRQ, 65 + }; 66 + 67 + static const struct iio_chan_spec ad7091r2_channels[] = { 68 + AD7091R_CHANNEL(0, 12, NULL, 0), 69 + AD7091R_CHANNEL(1, 12, NULL, 0), 70 + }; 71 + 72 + static const struct iio_chan_spec ad7091r4_channels[] = { 73 + AD7091R_CHANNEL(0, 12, NULL, 0), 74 + AD7091R_CHANNEL(1, 12, NULL, 0), 75 + AD7091R_CHANNEL(2, 12, NULL, 0), 76 + AD7091R_CHANNEL(3, 12, NULL, 0), 77 + }; 78 + 79 + static const struct iio_chan_spec ad7091r4_channels_irq[] = { 80 + AD7091R_CHANNEL(0, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), 81 + AD7091R_CHANNEL(1, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), 82 + AD7091R_CHANNEL(2, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), 83 + AD7091R_CHANNEL(3, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), 84 + }; 85 + 86 + static const struct iio_chan_spec ad7091r8_channels[] = { 87 + AD7091R_CHANNEL(0, 12, NULL, 0), 88 + AD7091R_CHANNEL(1, 12, NULL, 0), 89 + AD7091R_CHANNEL(2, 12, NULL, 0), 90 + AD7091R_CHANNEL(3, 12, NULL, 0), 91 + AD7091R_CHANNEL(4, 12, NULL, 0), 92 + AD7091R_CHANNEL(5, 12, NULL, 0), 93 + AD7091R_CHANNEL(6, 12, NULL, 0), 94 + AD7091R_CHANNEL(7, 12, NULL, 0), 95 + }; 96 + 97 + static const struct iio_chan_spec ad7091r8_channels_irq[] = { 98 + AD7091R_CHANNEL(0, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), 99 + AD7091R_CHANNEL(1, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), 100 + AD7091R_CHANNEL(2, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), 101 + AD7091R_CHANNEL(3, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), 102 + AD7091R_CHANNEL(4, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), 103 + AD7091R_CHANNEL(5, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), 104 + AD7091R_CHANNEL(6, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), 105 + AD7091R_CHANNEL(7, 12, ad7091r_events, ARRAY_SIZE(ad7091r_events)), 106 + }; 107 + 108 + static void ad7091r_pulse_convst(struct ad7091r_state *st) 109 + { 110 + gpiod_set_value_cansleep(st->convst_gpio, 1); 111 + gpiod_set_value_cansleep(st->convst_gpio, 0); 112 + } 113 + 114 + static int ad7091r_regmap_bus_reg_read(void *context, unsigned int reg, 115 + unsigned int *val) 116 + { 117 + struct ad7091r_state *st = context; 118 + struct spi_device *spi = container_of(st->dev, struct spi_device, dev); 119 + int ret; 120 + 121 + struct spi_transfer t[] = { 122 + { 123 + .tx_buf = &st->tx_buf, 124 + .len = 2, 125 + .cs_change = 1, 126 + }, { 127 + .rx_buf = &st->rx_buf, 128 + .len = 2, 129 + } 130 + }; 131 + 132 + if (reg == AD7091R_REG_RESULT) 133 + ad7091r_pulse_convst(st); 134 + 135 + st->tx_buf = cpu_to_be16(reg << 11); 136 + 137 + ret = spi_sync_transfer(spi, t, ARRAY_SIZE(t)); 138 + if (ret < 0) 139 + return ret; 140 + 141 + *val = be16_to_cpu(st->rx_buf); 142 + return 0; 143 + } 144 + 145 + static int ad7091r_regmap_bus_reg_write(void *context, unsigned int reg, 146 + unsigned int val) 147 + { 148 + struct ad7091r_state *st = context; 149 + struct spi_device *spi = container_of(st->dev, struct spi_device, dev); 150 + 151 + /* 152 + * AD7091R-2/-4/-8 protocol (datasheet page 31) is to do a single SPI 153 + * transfer with reg address set in bits B15:B11 and value set in B9:B0. 154 + */ 155 + st->tx_buf = cpu_to_be16(FIELD_PREP(AD7091R8_REG_DATA_MSK, val) | 156 + FIELD_PREP(AD7091R8_RD_WR_FLAG_MSK, 1) | 157 + FIELD_PREP(AD7091R8_REG_ADDR_MSK, reg)); 158 + 159 + return spi_write(spi, &st->tx_buf, 2); 160 + } 161 + 162 + static struct regmap_bus ad7091r8_regmap_bus = { 163 + .reg_read = ad7091r_regmap_bus_reg_read, 164 + .reg_write = ad7091r_regmap_bus_reg_write, 165 + .reg_format_endian_default = REGMAP_ENDIAN_BIG, 166 + .val_format_endian_default = REGMAP_ENDIAN_BIG, 167 + }; 168 + 169 + static const struct ad7091r_chip_info ad7091r8_infos[] = { 170 + [AD7091R2_INFO] = AD7091R_SPI_CHIP_INFO(2, "ad7091r-2"), 171 + [AD7091R4_INFO] = AD7091R_SPI_CHIP_INFO(4, "ad7091r-4"), 172 + [AD7091R4_INFO_IRQ] = AD7091R_SPI_CHIP_INFO_IRQ(4, "ad7091r-4"), 173 + [AD7091R8_INFO] = AD7091R_SPI_CHIP_INFO(8, "ad7091r-8"), 174 + [AD7091R8_INFO_IRQ] = AD7091R_SPI_CHIP_INFO_IRQ(8, "ad7091r-8") 175 + }; 176 + 177 + static const struct regmap_config ad7091r2_reg_conf = AD7091R_SPI_REGMAP_CONFIG(2); 178 + static const struct regmap_config ad7091r4_reg_conf = AD7091R_SPI_REGMAP_CONFIG(4); 179 + static const struct regmap_config ad7091r8_reg_conf = AD7091R_SPI_REGMAP_CONFIG(8); 180 + 181 + static void ad7091r8_regmap_init(struct ad7091r_state *st, 182 + const struct regmap_config *regmap_conf) 183 + { 184 + st->map = devm_regmap_init(st->dev, &ad7091r8_regmap_bus, st, 185 + regmap_conf); 186 + } 187 + 188 + static int ad7091r8_gpio_setup(struct ad7091r_state *st) 189 + { 190 + st->convst_gpio = devm_gpiod_get(st->dev, "convst", GPIOD_OUT_LOW); 191 + if (IS_ERR(st->convst_gpio)) 192 + return dev_err_probe(st->dev, PTR_ERR(st->convst_gpio), 193 + "Error getting convst GPIO\n"); 194 + 195 + st->reset_gpio = devm_gpiod_get_optional(st->dev, "reset", 196 + GPIOD_OUT_HIGH); 197 + if (IS_ERR(st->reset_gpio)) 198 + return dev_err_probe(st->dev, PTR_ERR(st->convst_gpio), 199 + "Error on requesting reset GPIO\n"); 200 + 201 + if (st->reset_gpio) { 202 + fsleep(20); 203 + gpiod_set_value_cansleep(st->reset_gpio, 0); 204 + } 205 + 206 + return 0; 207 + } 208 + 209 + static struct ad7091r_init_info ad7091r2_init_info = { 210 + .info_no_irq = &ad7091r8_infos[AD7091R2_INFO], 211 + .regmap_config = &ad7091r2_reg_conf, 212 + .init_adc_regmap = &ad7091r8_regmap_init, 213 + .setup = &ad7091r8_gpio_setup 214 + }; 215 + 216 + static struct ad7091r_init_info ad7091r4_init_info = { 217 + .info_no_irq = &ad7091r8_infos[AD7091R4_INFO], 218 + .info_irq = &ad7091r8_infos[AD7091R4_INFO_IRQ], 219 + .regmap_config = &ad7091r4_reg_conf, 220 + .init_adc_regmap = &ad7091r8_regmap_init, 221 + .setup = &ad7091r8_gpio_setup 222 + }; 223 + 224 + static struct ad7091r_init_info ad7091r8_init_info = { 225 + .info_no_irq = &ad7091r8_infos[AD7091R8_INFO], 226 + .info_irq = &ad7091r8_infos[AD7091R8_INFO_IRQ], 227 + .regmap_config = &ad7091r8_reg_conf, 228 + .init_adc_regmap = &ad7091r8_regmap_init, 229 + .setup = &ad7091r8_gpio_setup 230 + }; 231 + 232 + static int ad7091r8_spi_probe(struct spi_device *spi) 233 + { 234 + const struct ad7091r_init_info *init_info; 235 + 236 + init_info = spi_get_device_match_data(spi); 237 + if (!init_info) 238 + return -EINVAL; 239 + 240 + return ad7091r_probe(&spi->dev, init_info, spi->irq); 241 + } 242 + 243 + static const struct of_device_id ad7091r8_of_match[] = { 244 + { .compatible = "adi,ad7091r2", .data = &ad7091r2_init_info }, 245 + { .compatible = "adi,ad7091r4", .data = &ad7091r4_init_info }, 246 + { .compatible = "adi,ad7091r8", .data = &ad7091r8_init_info }, 247 + { } 248 + }; 249 + MODULE_DEVICE_TABLE(of, ad7091r8_of_match); 250 + 251 + static const struct spi_device_id ad7091r8_spi_id[] = { 252 + { "ad7091r2", (kernel_ulong_t)&ad7091r2_init_info }, 253 + { "ad7091r4", (kernel_ulong_t)&ad7091r4_init_info }, 254 + { "ad7091r8", (kernel_ulong_t)&ad7091r8_init_info }, 255 + { } 256 + }; 257 + MODULE_DEVICE_TABLE(spi, ad7091r8_spi_id); 258 + 259 + static struct spi_driver ad7091r8_driver = { 260 + .driver = { 261 + .name = "ad7091r8", 262 + .of_match_table = ad7091r8_of_match, 263 + }, 264 + .probe = ad7091r8_spi_probe, 265 + .id_table = ad7091r8_spi_id, 266 + }; 267 + module_spi_driver(ad7091r8_driver); 268 + 269 + MODULE_AUTHOR("Marcelo Schmitt <marcelo.schmitt@analog.com>"); 270 + MODULE_DESCRIPTION("Analog Devices AD7091R8 ADC driver"); 271 + MODULE_LICENSE("GPL"); 272 + MODULE_IMPORT_NS(IIO_AD7091R);
+47 -40
drivers/iio/buffer/industrialio-buffer-dma.c
··· 179 179 } 180 180 181 181 block->size = size; 182 - block->state = IIO_BLOCK_STATE_DEQUEUED; 182 + block->state = IIO_BLOCK_STATE_DONE; 183 183 block->queue = queue; 184 184 INIT_LIST_HEAD(&block->head); 185 185 kref_init(&block->kref); ··· 191 191 192 192 static void _iio_dma_buffer_block_done(struct iio_dma_buffer_block *block) 193 193 { 194 - struct iio_dma_buffer_queue *queue = block->queue; 195 - 196 - /* 197 - * The buffer has already been freed by the application, just drop the 198 - * reference. 199 - */ 200 - if (block->state != IIO_BLOCK_STATE_DEAD) { 194 + if (block->state != IIO_BLOCK_STATE_DEAD) 201 195 block->state = IIO_BLOCK_STATE_DONE; 202 - list_add_tail(&block->head, &queue->outgoing); 203 - } 204 196 } 205 197 206 198 /** ··· 253 261 * not support abort and has not given back the block yet. 254 262 */ 255 263 switch (block->state) { 256 - case IIO_BLOCK_STATE_DEQUEUED: 257 264 case IIO_BLOCK_STATE_QUEUED: 258 265 case IIO_BLOCK_STATE_DONE: 259 266 return true; ··· 308 317 * dead. This means we can reset the lists without having to fear 309 318 * corrution. 310 319 */ 311 - INIT_LIST_HEAD(&queue->outgoing); 312 320 spin_unlock_irq(&queue->list_lock); 313 321 314 322 INIT_LIST_HEAD(&queue->incoming); ··· 345 355 return ret; 346 356 } 347 357 EXPORT_SYMBOL_GPL(iio_dma_buffer_request_update); 358 + 359 + static void iio_dma_buffer_fileio_free(struct iio_dma_buffer_queue *queue) 360 + { 361 + unsigned int i; 362 + 363 + spin_lock_irq(&queue->list_lock); 364 + for (i = 0; i < ARRAY_SIZE(queue->fileio.blocks); i++) { 365 + if (!queue->fileio.blocks[i]) 366 + continue; 367 + queue->fileio.blocks[i]->state = IIO_BLOCK_STATE_DEAD; 368 + } 369 + spin_unlock_irq(&queue->list_lock); 370 + 371 + INIT_LIST_HEAD(&queue->incoming); 372 + 373 + for (i = 0; i < ARRAY_SIZE(queue->fileio.blocks); i++) { 374 + if (!queue->fileio.blocks[i]) 375 + continue; 376 + iio_buffer_block_put(queue->fileio.blocks[i]); 377 + queue->fileio.blocks[i] = NULL; 378 + } 379 + queue->fileio.active_block = NULL; 380 + } 348 381 349 382 static void iio_dma_buffer_submit_block(struct iio_dma_buffer_queue *queue, 350 383 struct iio_dma_buffer_block *block) ··· 469 456 struct iio_dma_buffer_queue *queue) 470 457 { 471 458 struct iio_dma_buffer_block *block; 459 + unsigned int idx; 472 460 473 461 spin_lock_irq(&queue->list_lock); 474 - block = list_first_entry_or_null(&queue->outgoing, struct 475 - iio_dma_buffer_block, head); 476 - if (block != NULL) { 477 - list_del(&block->head); 478 - block->state = IIO_BLOCK_STATE_DEQUEUED; 462 + 463 + idx = queue->fileio.next_dequeue; 464 + block = queue->fileio.blocks[idx]; 465 + 466 + if (block->state == IIO_BLOCK_STATE_DONE) { 467 + idx = (idx + 1) % ARRAY_SIZE(queue->fileio.blocks); 468 + queue->fileio.next_dequeue = idx; 469 + } else { 470 + block = NULL; 479 471 } 472 + 480 473 spin_unlock_irq(&queue->list_lock); 481 474 482 475 return block; ··· 558 539 struct iio_dma_buffer_queue *queue = iio_buffer_to_queue(buf); 559 540 struct iio_dma_buffer_block *block; 560 541 size_t data_available = 0; 542 + unsigned int i; 561 543 562 544 /* 563 545 * For counting the available bytes we'll use the size of the block not ··· 572 552 data_available += queue->fileio.active_block->size; 573 553 574 554 spin_lock_irq(&queue->list_lock); 575 - list_for_each_entry(block, &queue->outgoing, head) 576 - data_available += block->size; 555 + 556 + for (i = 0; i < ARRAY_SIZE(queue->fileio.blocks); i++) { 557 + block = queue->fileio.blocks[i]; 558 + 559 + if (block != queue->fileio.active_block 560 + && block->state == IIO_BLOCK_STATE_DONE) 561 + data_available += block->size; 562 + } 563 + 577 564 spin_unlock_irq(&queue->list_lock); 578 565 mutex_unlock(&queue->lock); 579 566 ··· 644 617 queue->ops = ops; 645 618 646 619 INIT_LIST_HEAD(&queue->incoming); 647 - INIT_LIST_HEAD(&queue->outgoing); 648 620 649 621 mutex_init(&queue->lock); 650 622 spin_lock_init(&queue->list_lock); ··· 661 635 */ 662 636 void iio_dma_buffer_exit(struct iio_dma_buffer_queue *queue) 663 637 { 664 - unsigned int i; 665 - 666 638 mutex_lock(&queue->lock); 667 639 668 - spin_lock_irq(&queue->list_lock); 669 - for (i = 0; i < ARRAY_SIZE(queue->fileio.blocks); i++) { 670 - if (!queue->fileio.blocks[i]) 671 - continue; 672 - queue->fileio.blocks[i]->state = IIO_BLOCK_STATE_DEAD; 673 - } 674 - INIT_LIST_HEAD(&queue->outgoing); 675 - spin_unlock_irq(&queue->list_lock); 676 - 677 - INIT_LIST_HEAD(&queue->incoming); 678 - 679 - for (i = 0; i < ARRAY_SIZE(queue->fileio.blocks); i++) { 680 - if (!queue->fileio.blocks[i]) 681 - continue; 682 - iio_buffer_block_put(queue->fileio.blocks[i]); 683 - queue->fileio.blocks[i] = NULL; 684 - } 685 - queue->fileio.active_block = NULL; 640 + iio_dma_buffer_fileio_free(queue); 686 641 queue->ops = NULL; 687 642 688 643 mutex_unlock(&queue->lock);
+10
drivers/iio/dac/Kconfig
··· 400 400 To compile this driver as a module, choose M here: the module 401 401 will be called mcp4728. 402 402 403 + config MCP4821 404 + tristate "MCP4801/02/11/12/21/22 DAC driver" 405 + depends on SPI 406 + help 407 + Say yes here to build the driver for the Microchip MCP4801 408 + MCP4802, MCP4811, MCP4812, MCP4821 and MCP4822 DAC devices. 409 + 410 + To compile this driver as a module, choose M here: the module 411 + will be called mcp4821. 412 + 403 413 config MCP4922 404 414 tristate "MCP4902, MCP4912, MCP4922 DAC driver" 405 415 depends on SPI
+1
drivers/iio/dac/Makefile
··· 42 42 obj-$(CONFIG_MAX5821) += max5821.o 43 43 obj-$(CONFIG_MCP4725) += mcp4725.o 44 44 obj-$(CONFIG_MCP4728) += mcp4728.o 45 + obj-$(CONFIG_MCP4821) += mcp4821.o 45 46 obj-$(CONFIG_MCP4922) += mcp4922.o 46 47 obj-$(CONFIG_STM32_DAC_CORE) += stm32-dac-core.o 47 48 obj-$(CONFIG_STM32_DAC) += stm32-dac.o
+236
drivers/iio/dac/mcp4821.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + /* 3 + * Copyright (C) 2023 Anshul Dalal <anshulusr@gmail.com> 4 + * 5 + * Driver for Microchip MCP4801, MCP4802, MCP4811, MCP4812, MCP4821 and MCP4822 6 + * 7 + * Based on the work of: 8 + * Michael Welling (MCP4922 Driver) 9 + * 10 + * Datasheet: 11 + * MCP48x1: https://ww1.microchip.com/downloads/en/DeviceDoc/22244B.pdf 12 + * MCP48x2: https://ww1.microchip.com/downloads/en/DeviceDoc/20002249B.pdf 13 + * 14 + * TODO: 15 + * - Configurable gain 16 + * - Regulator control 17 + */ 18 + 19 + #include <linux/module.h> 20 + #include <linux/of.h> 21 + #include <linux/spi/spi.h> 22 + 23 + #include <linux/iio/iio.h> 24 + #include <linux/iio/types.h> 25 + 26 + #include <asm/unaligned.h> 27 + 28 + #define MCP4821_ACTIVE_MODE BIT(12) 29 + #define MCP4802_SECOND_CHAN BIT(15) 30 + 31 + /* DAC uses an internal Voltage reference of 4.096V at a gain of 2x */ 32 + #define MCP4821_2X_GAIN_VREF_MV 4096 33 + 34 + enum mcp4821_supported_drvice_ids { 35 + ID_MCP4801, 36 + ID_MCP4802, 37 + ID_MCP4811, 38 + ID_MCP4812, 39 + ID_MCP4821, 40 + ID_MCP4822, 41 + }; 42 + 43 + struct mcp4821_state { 44 + struct spi_device *spi; 45 + u16 dac_value[2]; 46 + }; 47 + 48 + struct mcp4821_chip_info { 49 + const char *name; 50 + int num_channels; 51 + const struct iio_chan_spec channels[2]; 52 + }; 53 + 54 + #define MCP4821_CHAN(channel_id, resolution) \ 55 + { \ 56 + .type = IIO_VOLTAGE, .output = 1, .indexed = 1, \ 57 + .channel = (channel_id), \ 58 + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ 59 + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ 60 + .scan_type = { \ 61 + .realbits = (resolution), \ 62 + .shift = 12 - (resolution), \ 63 + }, \ 64 + } 65 + 66 + static const struct mcp4821_chip_info mcp4821_chip_info_table[6] = { 67 + [ID_MCP4801] = { 68 + .name = "mcp4801", 69 + .num_channels = 1, 70 + .channels = { 71 + MCP4821_CHAN(0, 8), 72 + }, 73 + }, 74 + [ID_MCP4802] = { 75 + .name = "mcp4802", 76 + .num_channels = 2, 77 + .channels = { 78 + MCP4821_CHAN(0, 8), 79 + MCP4821_CHAN(1, 8), 80 + }, 81 + }, 82 + [ID_MCP4811] = { 83 + .name = "mcp4811", 84 + .num_channels = 1, 85 + .channels = { 86 + MCP4821_CHAN(0, 10), 87 + }, 88 + }, 89 + [ID_MCP4812] = { 90 + .name = "mcp4812", 91 + .num_channels = 2, 92 + .channels = { 93 + MCP4821_CHAN(0, 10), 94 + MCP4821_CHAN(1, 10), 95 + }, 96 + }, 97 + [ID_MCP4821] = { 98 + .name = "mcp4821", 99 + .num_channels = 1, 100 + .channels = { 101 + MCP4821_CHAN(0, 12), 102 + }, 103 + }, 104 + [ID_MCP4822] = { 105 + .name = "mcp4822", 106 + .num_channels = 2, 107 + .channels = { 108 + MCP4821_CHAN(0, 12), 109 + MCP4821_CHAN(1, 12), 110 + }, 111 + }, 112 + }; 113 + 114 + static int mcp4821_read_raw(struct iio_dev *indio_dev, 115 + struct iio_chan_spec const *chan, int *val, 116 + int *val2, long mask) 117 + { 118 + struct mcp4821_state *state; 119 + 120 + switch (mask) { 121 + case IIO_CHAN_INFO_RAW: 122 + state = iio_priv(indio_dev); 123 + *val = state->dac_value[chan->channel]; 124 + return IIO_VAL_INT; 125 + case IIO_CHAN_INFO_SCALE: 126 + *val = MCP4821_2X_GAIN_VREF_MV; 127 + *val2 = chan->scan_type.realbits; 128 + return IIO_VAL_FRACTIONAL_LOG2; 129 + default: 130 + return -EINVAL; 131 + } 132 + } 133 + 134 + static int mcp4821_write_raw(struct iio_dev *indio_dev, 135 + struct iio_chan_spec const *chan, int val, 136 + int val2, long mask) 137 + { 138 + struct mcp4821_state *state = iio_priv(indio_dev); 139 + u16 write_val; 140 + __be16 write_buffer; 141 + int ret; 142 + 143 + if (val2 != 0) 144 + return -EINVAL; 145 + 146 + if (val < 0 || val >= BIT(chan->scan_type.realbits)) 147 + return -EINVAL; 148 + 149 + if (mask != IIO_CHAN_INFO_RAW) 150 + return -EINVAL; 151 + 152 + write_val = MCP4821_ACTIVE_MODE | val << chan->scan_type.shift; 153 + if (chan->channel) 154 + write_val |= MCP4802_SECOND_CHAN; 155 + 156 + write_buffer = cpu_to_be16(write_val); 157 + ret = spi_write(state->spi, &write_buffer, sizeof(write_buffer)); 158 + if (ret) { 159 + dev_err(&state->spi->dev, "Failed to write to device: %d", ret); 160 + return ret; 161 + } 162 + 163 + state->dac_value[chan->channel] = val; 164 + 165 + return 0; 166 + } 167 + 168 + static const struct iio_info mcp4821_info = { 169 + .read_raw = &mcp4821_read_raw, 170 + .write_raw = &mcp4821_write_raw, 171 + }; 172 + 173 + static int mcp4821_probe(struct spi_device *spi) 174 + { 175 + struct iio_dev *indio_dev; 176 + struct mcp4821_state *state; 177 + const struct mcp4821_chip_info *info; 178 + 179 + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*state)); 180 + if (indio_dev == NULL) 181 + return -ENOMEM; 182 + 183 + state = iio_priv(indio_dev); 184 + state->spi = spi; 185 + 186 + info = spi_get_device_match_data(spi); 187 + indio_dev->name = info->name; 188 + indio_dev->info = &mcp4821_info; 189 + indio_dev->modes = INDIO_DIRECT_MODE; 190 + indio_dev->channels = info->channels; 191 + indio_dev->num_channels = info->num_channels; 192 + 193 + return devm_iio_device_register(&spi->dev, indio_dev); 194 + } 195 + 196 + #define MCP4821_COMPATIBLE(of_compatible, id) \ 197 + { \ 198 + .compatible = of_compatible, \ 199 + .data = &mcp4821_chip_info_table[id] \ 200 + } 201 + 202 + static const struct of_device_id mcp4821_of_table[] = { 203 + MCP4821_COMPATIBLE("microchip,mcp4801", ID_MCP4801), 204 + MCP4821_COMPATIBLE("microchip,mcp4802", ID_MCP4802), 205 + MCP4821_COMPATIBLE("microchip,mcp4811", ID_MCP4811), 206 + MCP4821_COMPATIBLE("microchip,mcp4812", ID_MCP4812), 207 + MCP4821_COMPATIBLE("microchip,mcp4821", ID_MCP4821), 208 + MCP4821_COMPATIBLE("microchip,mcp4822", ID_MCP4822), 209 + { /* Sentinel */ } 210 + }; 211 + MODULE_DEVICE_TABLE(of, mcp4821_of_table); 212 + 213 + static const struct spi_device_id mcp4821_id_table[] = { 214 + { "mcp4801", (kernel_ulong_t)&mcp4821_chip_info_table[ID_MCP4801]}, 215 + { "mcp4802", (kernel_ulong_t)&mcp4821_chip_info_table[ID_MCP4802]}, 216 + { "mcp4811", (kernel_ulong_t)&mcp4821_chip_info_table[ID_MCP4811]}, 217 + { "mcp4812", (kernel_ulong_t)&mcp4821_chip_info_table[ID_MCP4812]}, 218 + { "mcp4821", (kernel_ulong_t)&mcp4821_chip_info_table[ID_MCP4821]}, 219 + { "mcp4822", (kernel_ulong_t)&mcp4821_chip_info_table[ID_MCP4822]}, 220 + { /* Sentinel */ } 221 + }; 222 + MODULE_DEVICE_TABLE(spi, mcp4821_id_table); 223 + 224 + static struct spi_driver mcp4821_driver = { 225 + .driver = { 226 + .name = "mcp4821", 227 + .of_match_table = mcp4821_of_table, 228 + }, 229 + .probe = mcp4821_probe, 230 + .id_table = mcp4821_id_table, 231 + }; 232 + module_spi_driver(mcp4821_driver); 233 + 234 + MODULE_AUTHOR("Anshul Dalal <anshulusr@gmail.com>"); 235 + MODULE_DESCRIPTION("Microchip MCP4821 DAC Driver"); 236 + MODULE_LICENSE("GPL");
+3 -3
drivers/iio/industrialio-buffer.c
··· 616 616 &iio_show_fixed_type, 617 617 NULL, 618 618 0, 619 - 0, 619 + IIO_SEPARATE, 620 620 &indio_dev->dev, 621 621 buffer, 622 622 &buffer->buffer_attr_list); ··· 629 629 &iio_scan_el_show, 630 630 &iio_scan_el_store, 631 631 chan->scan_index, 632 - 0, 632 + IIO_SEPARATE, 633 633 &indio_dev->dev, 634 634 buffer, 635 635 &buffer->buffer_attr_list); ··· 639 639 &iio_scan_el_ts_show, 640 640 &iio_scan_el_ts_store, 641 641 chan->scan_index, 642 - 0, 642 + IIO_SEPARATE, 643 643 &indio_dev->dev, 644 644 buffer, 645 645 &buffer->buffer_attr_list);
+3 -4
include/linux/iio/buffer-dma.h
··· 19 19 20 20 /** 21 21 * enum iio_block_state - State of a struct iio_dma_buffer_block 22 - * @IIO_BLOCK_STATE_DEQUEUED: Block is not queued 23 22 * @IIO_BLOCK_STATE_QUEUED: Block is on the incoming queue 24 23 * @IIO_BLOCK_STATE_ACTIVE: Block is currently being processed by the DMA 25 24 * @IIO_BLOCK_STATE_DONE: Block is on the outgoing queue 26 25 * @IIO_BLOCK_STATE_DEAD: Block has been marked as to be freed 27 26 */ 28 27 enum iio_block_state { 29 - IIO_BLOCK_STATE_DEQUEUED, 30 28 IIO_BLOCK_STATE_QUEUED, 31 29 IIO_BLOCK_STATE_ACTIVE, 32 30 IIO_BLOCK_STATE_DONE, ··· 71 73 * @active_block: Block being used in read() 72 74 * @pos: Read offset in the active block 73 75 * @block_size: Size of each block 76 + * @next_dequeue: index of next block that will be dequeued 74 77 */ 75 78 struct iio_dma_buffer_queue_fileio { 76 79 struct iio_dma_buffer_block *blocks[2]; 77 80 struct iio_dma_buffer_block *active_block; 78 81 size_t pos; 79 82 size_t block_size; 83 + 84 + unsigned int next_dequeue; 80 85 }; 81 86 82 87 /** ··· 94 93 * list and typically also a list of active blocks in the part that handles 95 94 * the DMA controller 96 95 * @incoming: List of buffers on the incoming queue 97 - * @outgoing: List of buffers on the outgoing queue 98 96 * @active: Whether the buffer is currently active 99 97 * @fileio: FileIO state 100 98 */ ··· 105 105 struct mutex lock; 106 106 spinlock_t list_lock; 107 107 struct list_head incoming; 108 - struct list_head outgoing; 109 108 110 109 bool active; 111 110
-6
include/linux/iio/iio.h
··· 434 434 * @update_scan_mode: function to configure device and scan buffer when 435 435 * channels have changed 436 436 * @debugfs_reg_access: function to read or write register value of device 437 - * @of_xlate: function pointer to obtain channel specifier index. 438 - * When #iio-cells is greater than '0', the driver could 439 - * provide a custom of_xlate function that reads the 440 - * *args* and returns the appropriate index in registered 441 - * IIO channels array. 442 437 * @fwnode_xlate: fwnode based function pointer to obtain channel specifier index. 443 - * Functionally the same as @of_xlate. 444 438 * @hwfifo_set_watermark: function pointer to set the current hardware 445 439 * fifo watermark level; see hwfifo_* entries in 446 440 * Documentation/ABI/testing/sysfs-bus-iio for details on