iio: adc: add max11410 adc driver
Subsystems (3)
v8 cover iio: adc: add max11410 adc driver
Hi Krzysztof,
I had accidentally inclueded a different binding file in two previous patch, thus irq flags slipped my eyes, sorry for that.
Best Regards,
Ibrahim
Note: No sign-off tag for David as he was unreachable when the initial patch was sent.
Changelog:
since v8:
- dtbinding: remove quotes around adc.yaml
- dtbinding: use defines for interrupt flags
since v7:
- add asm-generic/unaligned.h header (reported by kernel test robot)
- dtbinding: specify 2 items for interrupt-names
- dtbinding: reorder required block
since v6:
- don't require avdd supply if not needed
since v5:
- allow user to specify both interrupt pins
- keep irq info in max11410_state struct and use irq by name
- get irqs by fwnode_get_irq_byname
- don't allocate trigger when no irq supplied
- fix deadlock condition in write_raw
- minor style fixes
- fix devicetree binding errors reported by dt_binding_check
- convert module license to GPL as suggested by checkpatch
since v4:
- add in_voltage_filter2_notch_{center,en} attrs for sinc4 filter
- add ABI documentation for filter sysfs
- check interrupt-names property for configuring gpio of max11410
- remove hardwaregain property
- add scale_available property for channes using PGA
- separate vref regulator error -ENODEV from other errors
- don't register trigger if no irq specified
- style fixes
since v3:
- prefix defines with MAX11410_
- group vref regulators
- use builtin iio_validate_scan_mask_onehot
- validate iio trigger
- move scan data into state struct
- require vrefn regulator in DT if used by any channel
- don't require irq for triggered buffer
- remove filter sysfs attr and ABI documentation
- add in_voltage_filter[0-1]_notch_{center,en} attrs
since v2:
- remove bit position shifting, use field_prep instead
- reduce the amount of reg writes in max11410_configure_channel
- add error checking in max11410_parse_channels
- remove some unneeded blank lines and minor style fixes
- remove scan data assignment in max11410_trigger_handler
Ibrahim Tilki (3):
iio: adc: add max11410 adc driver
dt-bindings: iio: adc: add adi,max11410.yaml
Documentation: ABI: testing: add max11410 doc
.../ABI/testing/sysfs-bus-iio-adc-max11410 | 13 + .../bindings/iio/adc/adi,max11410.yaml | 177 +++ drivers/iio/adc/Kconfig | 13 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/max11410.c | 1050 +++++++++++++++++ 5 files changed, 1254 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-adc-max11410 create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,max11410.yaml create mode 100644 drivers/iio/adc/max11410.c
Signature · 1 line
2.25.1
PATCH v8 1/3 iio: adc: add max11410 adc driver
Adding support for max11410 24-bit, 1.9ksps delta-sigma adc which has 3 differential reference and 10 differential channel inputs. Inputs and references can be buffered internally. Inputs can also be amplified with internal PGA.
Device has four digital filter modes: FIR50/60, FIR50, FIR60 and SINC4. FIR 50Hz and 60Hz rejections can be enabled/disabled separately. Digital filter selection affects sampling frequency range so driver has to consider the configured filter when configuring sampling frequency.
--- drivers/iio/adc/Kconfig | 13 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/max11410.c | 1050 ++++++++++++++++++++++++++++++++++++ 3 files changed, 1064 insertions(+) create mode 100644 drivers/iio/adc/max11410.c
drivers/iio/adc/Kconfig +13 -0
@@ -667,6 +667,19 @@ config MAX11205 To compile this driver as a module, choose M here: the module will be called max11205. +config MAX11410 + tristate "Analog Devices MAX11410 ADC driver" + depends on SPI + select REGMAP_SPI + select IIO_BUFFER + select IIO_TRIGGER + select IIO_TRIGGERED_BUFFER + help + Say yes here to build support for Analog Devices MAX11410 ADCs. + + To compile this driver as a module, choose M here: the module will be + called max11410. + config MAX1241 tristate "Maxim max1241 ADC driver" depends on SPI_MASTER
drivers/iio/adc/Makefile +1 -0
@@ -62,6 +62,7 @@ obj-$(CONFIG_MAX1027) += max1027.o obj-$(CONFIG_MAX11100) += max11100.o obj-$(CONFIG_MAX1118) += max1118.o obj-$(CONFIG_MAX11205) += max11205.o +obj-$(CONFIG_MAX11410) += max11410.o obj-$(CONFIG_MAX1241) += max1241.o obj-$(CONFIG_MAX1363) += max1363.o obj-$(CONFIG_MAX9611) += max9611.o
drivers/iio/adc/max11410.c new file +1050 -0
1,050 lines not on this page · raw message
Signature · 1 line
2.25.1
Jonathan Cameron
maintainerQuoted 11 lines · On Mon, 3 Oct 2022 13:59:01 +0300 Ibrahim Tilki <[email protected]>…
Adding support for max11410 24-bit, 1.9ksps delta-sigma adc which has 3 differential reference and 10 differential channel inputs. Inputs and references can be buffered internally. Inputs can also be amplified with internal PGA.
Device has four digital filter modes: FIR50/60, FIR50, FIR60 and SINC4. FIR 50Hz and 60Hz rejections can be enabled/disabled separately. Digital filter selection affects sampling frequency range so driver has to consider the configured filter when configuring sampling frequency.
Signed-off-by Ibrahim Tilki <[email protected]>
One small thing inline that I tidied up whilst applying.
Quoted 10 lines
drivers/iio/adc/max11410.c new file +10
-0+static int max11410_configure_channel (struct max11410_state *st, +struct iio_chan_spec const *chan) +{ +struct max11410_channel_config cfg = st->channels[chan->address]; +unsigned int regval; +int ret; + +if (chan->differential) + ret =max11410_set_input_mux (st, chan->channel, chan->channel2); +else
drivers/iio/adc/max11410.c line 370
Quoted 10 lines
drivers/iio/adc/max11410.c new file +10
-0+ ret =max11410_set_input_mux (st, chan->channel, +MAX11410_AINN_GND ); + +if (ret) +return ret; + + regval =FIELD_PREP (MAX11410_CTRL_VREFP_BUF_BIT , cfg.buffered_vrefp) | +FIELD_PREP (MAX11410_CTRL_VREFN_BUF_BIT , cfg.buffered_vrefn) | +FIELD_PREP (MAX11410_CTRL_REFSEL_MASK , cfg.refsel) | +FIELD_PREP (MAX11410_CTRL_UNIPOLAR_BIT , !cfg.bipolar);
drivers/iio/adc/max11410.c:370:18: warning: dubious: x & !y
I've fixed it with
... cfg.bipolar ? 0 : 1);
Shout if that's an issue (I've gotten these backwards in the past ;)
PATCH v8 2/3 dt-bindings: iio: adc: add adi,max11410.yaml
In reply to Ibrahim TilkiAdding devicetree binding documentation for max11410 adc.
--- .../bindings/iio/adc/adi,max11410.yaml | 177 ++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,max11410.yaml
Documentation/devicetree/bindings/iio/adc/adi,max11410.yaml new file +177 -0
@@ -0,0 +1,177 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2022 Analog Devices Inc. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/adi,max11410.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices MAX11410 ADC device driver + +maintainers: + - Ibrahim Tilki <[email protected]> + +description: | + Bindings for the Analog Devices MAX11410 ADC device. Datasheet can be + found here: + https://datasheets.maximintegrated.com/en/ds/MAX11410.pdf + +properties: + compatible: + enum: + - adi,max11410 + + reg: + maxItems: 1 + + interrupts: + minItems: 1 + maxItems: 2 + + interrupt-names: + description: Name of the gpio pin of max11410 used for IRQ + minItems: 1 + items: + - enum: [gpio0, gpio1] + - const: gpio1 + + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + avdd-supply: + description: Optional avdd supply. Used as reference when no explicit reference supplied. + + vref0p-supply: + description: vref0p supply can be used as reference for conversion. + + vref1p-supply: + description: vref1p supply can be used as reference for conversion. + + vref2p-supply: + description: vref2p supply can be used as reference for conversion. + + vref0n-supply: + description: vref0n supply can be used as reference for conversion. + + vref1n-supply: + description: vref1n supply can be used as reference for conversion. + + vref2n-supply: + description: vref2n supply can be used as reference for conversion. + + spi-max-frequency: + maximum: 8000000 + +patternProperties: + "^channel(@[0-9])?$": + $ref: adc.yaml + type: object + description: Represents the external channels which are connected to the ADC. + + properties: + reg: + description: The channel number in single-ended mode. + minimum: 0 + maximum: 9 + + adi,reference: + description: | + Select the reference source to use when converting on + the specific channel. Valid values are: + 0: VREF0P/VREF0N + 1: VREF1P/VREF1N + 2: VREF2P/VREF2N + 3: AVDD/AGND + 4: VREF0P/AGND + 5: VREF1P/AGND + 6: VREF2P/AGND + If this field is left empty, AVDD/AGND is selected. + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1, 2, 3, 4, 5, 6] + default: 3 + + adi,input-mode: + description: | + Select signal path of input channels. Valid values are: + 0: Buffered, low-power, unity-gain path (default) + 1: Bypass path + 2: PGA path + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1, 2] + default: 0 + + diff-channels: true + + bipolar: true + + settling-time-us: true + + adi,buffered-vrefp: + description: Enable buffered mode for positive reference. + type: boolean + + adi,buffered-vrefn: + description: Enable buffered mode for negative reference. + type: boolean + + required: + - reg + + additionalProperties: false + +required: + - compatible + - reg + +allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml# + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + spi { + #address-cells = <1>; + #size-cells = <0>; + + adc@0 { + reg = <0>; + compatible = "adi,max11410"; + spi-max-frequency = <8000000>; + + interrupt-parent = <&gpio>; + interrupts = <25 IRQ_TYPE_EDGE_FALLING>; + interrupt-names = "gpio1"; + + avdd-supply = <&adc_avdd>; + + vref1p-supply = <&adc_vref1p>; + vref1n-supply = <&adc_vref1n>; + + #address-cells = <1>; + #size-cells = <0>; + + channel@0 { + reg = <0>; + }; + + channel@1 { + reg = <1>; + diff-channels = <2 3>; + adi,reference = <1>; + bipolar; + settling-time-us = <100000>; + }; + + channel@2 { + reg = <2>; + diff-channels = <7 9>; + adi,reference = <5>; + adi,input-mode = <2>; + settling-time-us = <50000>; + }; + }; + };
Signature · 1 line
2.25.1
Re: [PATCH v8 2/3] dt-bindings: iio: adc: add adi,max11410.yaml
Quoted 5 lines · Ibrahim Tilki
Adding devicetree binding documentation for max11410 adc.
Signed-off-by Ibrahim Tilki <[email protected]>--- .../bindings/iio/adc/adi,max11410.yaml | 177 ++++++++++++++++++
Jonathan,
With merging please wait till Rob's bot tests the patch. The status can be checked:
https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]/
Best regards,
Krzysztof
PATCH v8 3/3 Documentation: ABI: testing: add max11410 doc
In reply to Ibrahim TilkiAdding documentation for Analog Devices max11410 adc userspace sysfs.
--- .../ABI/testing/sysfs-bus-iio-adc-max11410 | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-adc-max11410
Documentation/ABI/testing/sysfs-bus-iio-adc-max11410 new file +13 -0
@@ -0,0 +1,13 @@ +What: /sys/bus/iio/devices/iio:deviceX/in_voltage_filterY_notch_en +Date: September 2022 +KernelVersion: 6.0 +Contact: [email protected] +Description: + Enable or disable a notch filter. + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage_filterY_notch_center +Date: September 2022 +KernelVersion: 6.0 +Contact: [email protected] +Description: + Center frequency of the notch filter in Hz.
Signature · 1 line
2.25.1
Quoted 9 lines · On Mon, 3 Oct 2022 13:59:00 +0300 Ibrahim Tilki <[email protected]>…
Hi Krzysztof,
I had accidentally inclueded a different binding file in two previous patch, thus irq flags slipped my eyes, sorry for that.
Best Regards,
IbrahimNote: No sign-off tag for David as he was unreachable when the initial patch was sent.
Series applied with one small tweak as per reply to patch 1.
Applied to the togreg branch of iio.git but that currently has an unstable mid merge window base so I'll be rebasing on rc1 once available.
Hence for now, just pushed out as testing to see if 0-day can find anything we missed in review.
Thanks,
Jonathan
Quoted 69 lines
Changelog:
since v8:
- dtbinding: remove quotes aroundadc.yaml
- dtbinding: use defines for interrupt flagssince v7:
- addasm-generic/unaligned.hheader (reported by kernel test robot)
- dtbinding: specify 2 items for interrupt-names
- dtbinding: reorder required blocksince v6:
- don't require avdd supply if not neededsince v5:
- allow user to specify both interrupt pins
- keep irq info inmax11410_statestruct and use irq by name
- get irqs byfwnode_get_irq_byname
- don't allocate trigger when no irq supplied
- fix deadlock condition inwrite_raw
- minor style fixes
- fix devicetree binding errors reported bydt_binding_check
- convert module license to GPL as suggested by checkpatchsince v4:
- add in_voltage_filter2_notch_{center,en} attrs for sinc4 filter
- add ABI documentation for filter sysfs
- check interrupt-names property for configuring gpio of max11410
- remove hardwaregain property
- addscale_availableproperty for channes using PGA
- separate vref regulator error-ENODEVfrom other errors
- don't register trigger if no irq specified
- style fixessince v3:
- prefix defines withMAX11410_
- group vref regulators
- use builtiniio_validate_scan_mask_onehot
- validate iio trigger
- move scan data into state struct
- require vrefn regulator in DT if used by any channel
- don't require irq for triggered buffer
- remove filter sysfs attr and ABI documentation
- add in_voltage_filter[0-1]_notch_{center,en} attrssince v2:
- remove bit position shifting, usefield_prepinstead
- reduce the amount of reg writes inmax11410_configure_channel
- add error checking inmax11410_parse_channels
- remove some unneeded blank lines and minor style fixes
- remove scan data assignment inmax11410_trigger_handlerIbrahim Tilki (3):
iio: adc: add max11410 adc driver
dt-bindings: iio: adc: add adi,max11410.yaml
Documentation: ABI: testing: add max11410 doc.../ABI/testing/sysfs-bus-iio-adc-max11410 | 13 + .../bindings/iio/adc/adi,max11410.yaml | 177 +++ drivers/iio/adc/Kconfig | 13 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/max11410.c | 1050 +++++++++++++++++ 5 files changed, 1254 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-adc-max11410 create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,max11410.yaml create mode 100644 drivers/iio/adc/max11410.c