dt-bindings: adc: add AD7173
Subsystems (4)
PATCH v9 1/2 dt-bindings: adc: add AD7173
The AD7173 family offer a complete integrated Sigma-Delta ADC solution which can be used in high precision, low noise single channel applications or higher speed multiplexed applications. The Sigma-Delta ADC is intended primarily for measurement of signals close to DC but also delivers outstanding performance with input bandwidths out to ~10kHz.
---V8->v9
- Add gpio-controller and "#gpio-cells" properties
- Add missing avdd2 and iovdd supplies
- Add string type to reference-selectV7->V8
- include missing fix from V6V6->V7 <no changes>V5->V6
- Moved global required property to proper placement
V4 -> V5
- Use string enum instead of integers for "adi,reference-select"
- Fix conditional checking in regards to compatible
V3 -> V4
- include supply attributes
- add channel attribute for selecting conversion reference
V2 -> V3
- remove redundant descriptions
- use referenced 'bipolar' property
- remove newlines from example
V1 -> V2 <no changes>
.../bindings/iio/adc/adi,ad7173.yaml | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml
Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml new file +184 -0
@@ -0,0 +1,184 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2023 Analog Devices Inc. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/adi,ad7173.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices AD7173 ADC + +maintainers: + - Ceclan Dumitru <[email protected]> + +description: | + Bindings for the Analog Devices AD717X ADC's. Datasheets for supported chips: + https://www.analog.com/media/en/technical-documentation/data-sheets/AD7172-2.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/AD7173-8.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/AD7175-2.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/AD7176-2.pdf + +properties: + compatible: + enum: + - adi,ad7172-2 + - adi,ad7173-8 + - adi,ad7175-2 + - adi,ad7176-2 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + spi-max-frequency: + maximum: 20000000 + + gpio-controller: + description: Marks the device node as a GPIO controller. + + "#gpio-cells": + const: 1 + + refin-supply: + description: external reference supply, can be used as reference for conversion. + + refin2-supply: + description: external reference supply, can be used as reference for conversion. + + avdd-supply: + description: avdd supply, can be used as reference for conversion. + + avdd2-supply: + description: avdd2 supply, used as the input to the internal voltage regulator. + + iovdd-supply: + description: iovdd supply, used for the chip digital interface. + +patternProperties: + "^channel@[0-9a-f]$": + type: object + $ref: adc.yaml + unevaluatedProperties: false + + properties: + reg: + minimum: 0 + maximum: 15 + + diff-channels: + items: + minimum: 0 + maximum: 31 + + adi,reference-select: + description: | + Select the reference source to use when converting on + the specific channel. Valid values are: + refin : REFIN(+)/REFIN(−). + refin2 : REFIN2(+)/REFIN2(−) + refout-avss: REFOUT/AVSS (Internal reference) + avdd : AVDD + + External reference refin2 only available on ad7173-8. + If not specified, internal reference used. + enum: + - refin + - refin2 + - refout-avss + - avdd + default: refout-avss + type: string + + required: + - reg + - diff-channels + +required: + - compatible + - reg + - interrupts + +allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml# + + - if: + properties: + compatible: + not: + contains: + const: adi,ad7173-8 + then: + properties: + refin2-supply: false + patternProperties: + "^channel@[0-9a-f]$": + properties: + adi,reference-select: + enum: + - refin + - refout-avss + - avdd + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/interrupt-controller/irq.h> + + spi { + #address-cells = <1>; + #size-cells = <0>; + + adc@0 { + compatible = "adi,ad7173-8"; + reg = <0>; + + #address-cells = <1>; + #size-cells = <0>; + + interrupts = <25 IRQ_TYPE_EDGE_FALLING>; + interrupt-parent = <&gpio>; + spi-max-frequency = <5000000>; + gpio-controller; + + refin-supply = <&dummy_regulator>; + + channel@0 { + reg = <0>; + bipolar; + diff-channels = <0 1>; + adi,reference-select = "refin"; + }; + + channel@1 { + reg = <1>; + diff-channels = <2 3>; + }; + + channel@2 { + reg = <2>; + bipolar; + diff-channels = <4 5>; + }; + + channel@3 { + reg = <3>; + bipolar; + diff-channels = <6 7>; + }; + + channel@4 { + reg = <4>; + diff-channels = <8 9>; + adi,reference-select = "avdd"; + }; + }; + };
Signature · 1 line
2.42.0
PATCH v9 2/2 iio: adc: ad7173: add AD7173 driver
The AD7173 family offer a complete integrated Sigma-Delta ADC solution which can be used in high precision, low noise single channel applications or higher speed multiplexed applications. The Sigma-Delta ADC is intended primarily for measurement of signals close to DC but also delivers outstanding performance with input bandwidths out to ~10kHz.
---
V8 -> V9
- Add '(x)' to some macro's definition to reduce NO of checks
- Use reg 0 constant definition in debug_reg_access()
- Rename channels_st_priv_arr to chans_st_arr
- Remove unnecessary u32 cast from read_raw()
- Compute read_raw() offset instead of constant
- Add offset comments to data rate arrays
- Removed redundant newline in _parse_channel_config()
V7 -> V8
- remove Kconfig commas
- reorder include <...gpio/regmap.h>
- GPO12_DATA(x) from BIT(x) -> BIT(x+0)
- use the same pointer to dev in ad7173_setup()
- rewrite temp channel read_raw scale for better readability
- add comment to explain temp channel offset
- follow multi-line comment style
- change ref_sel type to signed int
- use fwnode_property_match_property_string()
V6 -> V7
- format Kconfig supported models using '-'
- include types.h instead of stddef.h
- change device_info->num_gpios type to u8
- reorder fields in ad7173_state, place ad_sigma_delta
- reorder fields in ad7173_device_info, group by type
- add default case in read_raw()
- rename ad7173_debug() to ad7173_debug_reg_access()
- remove explicit u8 cast
- remove return 0; for offset in read_raw()
- add '\n' to error messages
- reorder probe variables -> reversed xmas tree
- remove redundant inner commas in of_match and id_table
- simplify selected reference code by setting default value and ignoring fwnode_property_read_string() error
- use match_string() for finding selected reference
- err on no channels specified
- add missing fwnode_handle_put(child) on err return branches
- remove spi_set_drvdata() from probe
- remove offset variable from find_live_config(), not used
- add comment showing a generic LRU implementation might be used if one
will exist
- MISC: add blank line to chanel_config struct, trailing comma ref_sel_str[], remove blank line in update_scan_mode(), add spaces around '/'V5->V6 <no changes>
V4 -> V5
- List Kconfig supported models one per line
- Include <array_size.h> and <container_of.h>
- Remove bits.h and kernel.h include
- Add spaces before '\' on multi-line definitions
- Change constant definition name from "..._MICROV" to "..._uV"
- Change ad7173_channel_config attributes order for grouping by type
- Remove redundant {} in ad7173_gpio_init()
- Add array with reference select strings
- Change parsing of device tree adi,reference-select from integer to string
- Change indentation for ad7173_find_live_config() header
- Use struct_group() in config struct
- Use offsetofend() and sizeof_field() in ad7173_find_live_config()
- Split line on logic operator in ad7173_find_live_config() at configs comparison
- Use IDA for config slots allocation
- Reverse xmas tree order for probe local variables
- Use BIT() for computing bipolar channels offset
- Change (MICRO/MILLI) to MILLI in read_raw for integer part of sampling frequency
- MISC: remove blank line, use 0 value dirrectly, one line statement devm_kcalloc()
V3 -> V4
- cleaned up includes
- add ad7173_gpio_disable(), include to devm actions
- remove iio_device_claim_direct_mode() from update_scan_mode()
- always set differential iio_chan attribute to true, retain bipolar info only in private struct
- store multiple regulators in state for voltage references
- compute read_raw offset depending on channel used reference
- configure channel setup using selected reference
- add ad7173_get_ref_voltage_milli()
- clean up ad7173_fw_sparse_channel_config() changing array access of channel structs to pointers
- retain chip name in st->info structure
- use spi_device_get_match_data() in probe
V2 -> V3
- change Kconfig GPIO_REGMAP and REGMAP_SPI to be conditioned by GPIOLIB
- cast chip info to (kernel_ulong_t) to suppress warnings
- adjust copyright year to reflect the out-of-tree history
- remove unused sysfs and trigger header files
- clean up defined macros by using FIELD_PREP( ) inline
- use DECLARE_BITMAP( ) for defiining cfg_slots_status
- use clear/set _bit instead of assign_bit
- rename state field regmap to reg_gpiocon_regmap to better represent usage
- replace container_of( ) usages to ad_sigma_delta_to_ad7173( )
- improve readability of sampling frequency conversion in write_raw( )
specifying conversion from Micro to Milli
- use iio_device_claim_direct_mode( ) correctly in write_raw( )
- flip logic in write_raw( ) to reduce line length
- pass only state struct to gpio_init function
- remove else branch at end of probe
- remove comma after list terminator for of_match and id_table arrays
- clarify write_raw( ) realbits 32 bit size check in a comment
- change parsed fw property 'adi,bipolar' to 'bipolar' to matched referenced adc.yaml
- use reg_set_base for gpio regmap xlate
V1 -> V2
- keep original out-of-tree AD7173 naming
- remove gpio_cleanup
- handle 32bit realbits offset case
- use iio_device_claim_direct_mode, drop own mutex
- use dev_err_probe
- cleanup headers include
- use GENMASK() and FIELD_PREP()
- use HZ_PER_MHZ
- change #ifdef GPIOLIB to if( IS_ENABLED(CONFIG_GPIOLIB))
- use gpio-regmap
- change boolean flag in info struct to number of gpios
- NIH memset64
- use struct pointers for config comparison
- use spi_write_then_read for ADC reset
- use stack allocated buffer for reset
- define constant for reset sequence size
- use kcalloc instead of kzalloc
- change of naming to fw of dt parse function
- change de-referencing chain to local variable dev in multiple locations
- drop write_raw_get_fmt
- add driver private data to spi_device_id table
- use fsleep() instead of usleep_range()
- put config value inline
- align read/write raw arguments
- remove zeroed values from channel templates structure
- define constants for temperature sensor positive and negative inputs
- always enable temperature channel
- configure spi clock phase and polarity from driver
misc changes (test bit, return disable all, indentation fix, change statements to single line)
drivers/iio/adc/Kconfig | 17 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ad7173.c | 974 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 992 insertions(+) create mode 100644 drivers/iio/adc/ad7173.c
drivers/iio/adc/Kconfig +17 -0
@@ -54,6 +54,23 @@ config AD7124 To compile this driver as a module, choose M here: the module will be called ad7124. +config AD7173 + tristate "Analog Devices AD7173 driver" + depends on SPI_MASTER + select AD_SIGMA_DELTA + select GPIO_REGMAP if GPIOLIB + select REGMAP_SPI if GPIOLIB + help + Say yes here to build support for Analog Devices AD7173 and similar ADC + Currently supported models: + - AD7172-2 + - AD7173-8 + - AD7175-2 + - AD7176-2 + + To compile this driver as a module, choose M here: the module will be + called ad7173. + config AD7192 tristate "Analog Devices AD7190 AD7192 AD7193 AD7195 ADC driver" depends on SPI
drivers/iio/adc/Makefile +1 -0
@@ -9,6 +9,7 @@ obj-$(CONFIG_AD_SIGMA_DELTA) += ad_sigma_delta.o obj-$(CONFIG_AD4130) += ad4130.o obj-$(CONFIG_AD7091R5) += ad7091r5.o ad7091r-base.o obj-$(CONFIG_AD7124) += ad7124.o +obj-$(CONFIG_AD7173) += ad7173.o obj-$(CONFIG_AD7192) += ad7192.o obj-$(CONFIG_AD7266) += ad7266.o obj-$(CONFIG_AD7280) += ad7280a.o
drivers/iio/adc/ad7173.c new file +974 -0
974 lines not on this page · raw message
Signature · 1 line
2.42.0
Jonathan Cameron
maintainerRe: [PATCH v9 2/2] iio: adc: ad7173: add AD7173 driver
Quoted 9 lines · On Fri, 15 Dec 2023 15:34:58 +0200 Dumitru Ceclan <[email protected]>…
The AD7173 family offer a complete integrated Sigma-Delta ADC solution which can be used in high precision, low noise single channel applications or higher speed multiplexed applications. The Sigma-Delta ADC is intended primarily for measurement of signals close to DC but also delivers outstanding performance with input bandwidths out to ~10kHz.
Reviewed-by Andy Shevchenko <[email protected]>Signed-off-by Dumitru Ceclan <[email protected]>
LGTM. If no other comments come in I'll pick this up once those DT issues Rob's bot pointed out are tidied up.
Jonathan
Rob Herring
maintainerQuoted 29 lines · Dumitru Ceclan
The AD7173 family offer a complete integrated Sigma-Delta ADC solution which can be used in high precision, low noise single channel applications or higher speed multiplexed applications. The Sigma-Delta ADC is intended primarily for measurement of signals close to DC but also delivers outstanding performance with input bandwidths out to ~10kHz.
Signed-off-by Dumitru Ceclan <[email protected]>---
V8->v9
- Add gpio-controller and "#gpio-cells" properties
- Add missing avdd2 and iovdd supplies
- Add string type to reference-selectV7->V8
- include missing fix from V6V6->V7<no changes>V5->V6
- Moved global required property to proper placement
V4 -> V5
- Use string enum instead of integers for "adi,reference-select"
- Fix conditional checking in regards to compatible
V3 -> V4
- include supply attributes
- add channel attribute for selecting conversion reference
V2 -> V3
- remove redundant descriptions
- use referenced 'bipolar' property
- remove newlines from example
V1 -> V2 <no changes>
Quoted 4 lines
.../bindings/iio/adc/adi,ad7173.yaml | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml: patternProperties:^channel@[0-9a-f]$:properties:adi,reference-select:type: 'string' is not one of ['boolean', 'object']
from schema $id: http://devicetree.org/meta-schemas/core.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml: patternProperties:^channel@[0-9a-f]$:properties:adi,reference-select:type: 'boolean' was expected
hint: A vendor boolean property can use "type: boolean"
from schema $id: http://devicetree.org/meta-schemas/vendor-props.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/iio/adc/adi,ad7173.example.dtb: adc@0: '#gpio-cells' is a dependency of 'gpio-controller'
from schema $id: http://devicetree.org/schemas/gpio/gpio.yaml#
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Dumitru,
kernel test robot noticed the following build warnings:
[auto build test WARNING on jic23-iio/togreg]
[also build test WARNING on linus/master v6.7-rc5 next-20231215] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Dumitru-Ceclan/iio-adc-ad7173-add-AD7173-driver/20231215-213722 base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg patch link: https://lore.kernel.org/r/20231215133512.28735-1-mitrutzceclan%40gmail.com patch subject: [PATCH v9 1/2] dt-bindings: adc: add AD7173 compiler: loongarch64-linux-gcc (GCC) 13.2.0 reproduce: (https://download.01.org/0day-ci/archive/20231216/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
dtcheck warnings: (new ones prefixed by >>)
>> Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml: patternProperties:^channel@[0-9a-f]$:properties:adi,reference-select:type: 'string' is not one of ['boolean', 'object'] from schema $id: http://devicetree.org/meta-schemas/core.yaml# >> Documentation/devicetree/bindings/iio/adc/adi,ad7173.yaml: patternProperties:^channel@[0-9a-f]$:properties:adi,reference-select:type: 'boolean' was expected
hint: A vendor boolean property can use "type: boolean" from schema $id: http://devicetree.org/meta-schemas/vendor-props.yaml#
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki