Support for TI ADS7128 and ADS7138 ADCs
Subsystems (2)
v2 cover Support for TI ADS7128 and ADS7138 ADCs
This patch series adds support for Texas Instruments ADS7128 and ADS7138, which are 12-bit, 8 channel analog-to-digital converters (ADCs) with build-in digital window comparator (DWC), using the I2C interface.
The driver exposes the interfaces to read the raw values, as well as the minimum and maximum value for each channel. In addition several settings can be configured, like the DWC, sampling frequency or an averaging filter/oversampling. Interrupts triggered by the DWC, if configured, are then exposed as IIO events.
ADS7128 differs in the addition of further hardware features, like a root-mean-square (RMS) and a zero-crossing-detect (ZCD) module, which are not yet supported by the driver.
Regarding the I2C interface the chips using opcodes to define the way how the registeres are accessed, like single or multiple register(s) read/write or setting/clearing only bits.
---
Changes in v1 (to patch series without b4):
- dt-bindings: Extended description
Changes in v2:
- Improved commit messages.
- dt-bindings: drop info about what driver supports, make 'avdd-supply' optional.
- General rework of driver regarding indentation and code style.
- General code improvements to make code shorter and improve readability, like remove 'goto's, order of declarations, ...
- Use kernel macros and functions, like FIELD_*, guard(), ...
- Rework i2c functions to return 0 in case of success and use i2c_master_send() if possible.
- Use struct for chip data instead of enum.
- Add comment to what the lock is used for and make sure it's used in these cases.
- Use read_avail of iio_info and extend to return also the available values for OSR.
- Rework to only accept values of the availability list.
- Use devm_* if possible and therefore drop 'remove' callback.
- Rebase to kernel 6.13 and adjust to API changes.
- Link to v1:
https://lore.kernel.org/r/[email protected]
---
Tobias Sperling (2):
dt-bindings: iio: adc: Introduce ADS7138
iio: adc: Add driver for ADS7128 / ADS7138
.../devicetree/bindings/iio/adc/ti,ads7138.yaml | 62 ++ drivers/iio/adc/Kconfig | 10 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ti-ads7138.c | 755 +++++++++++++++++++++ 4 files changed, 828 insertions(+)
---
base-commit: 05dbaf8dd8bf537d4b4eb3115ab42a5fb40ff1f5
change-id: 20241122-adc_ml-d1ce86e85b2c
Best regards,
Signature · 1 line
Tobias Sperling <[email protected]>
PATCH v2 1/2 dt-bindings: iio: adc: Introduce ADS7138
Add documentation for the driver of ADS7128 and ADS7138 12-bit, 8-channel analog-to-digital converters. These ADCs have a wide operating range and a wide feature set. Communication is based on the I2C interface. ADS7128 differs in the addition of further hardware features, like a root-mean-square (RMS) and a zero-crossing-detect (ZCD) module.
--- .../devicetree/bindings/iio/adc/ti,ads7138.yaml | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+)
Documentation/devicetree/bindings/iio/adc/ti,ads7138.yaml new file +62 -0
@@ -0,0 +1,62 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/ti,ads7138.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments ADS7128/ADS7138 analog-to-digital converter (ADC) + +maintainers: + - Tobias Sperling <[email protected]> + +description: | + The ADS7128 and ADS7138 chips are 12-bit, 8 channel analog-to-digital + converters (ADC) with build-in digital window comparator (DWC), using the + I2C interface. + ADS7128 differs in the addition of further hardware features, like a + root-mean-square (RMS) and a zero-crossing-detect (ZCD) module. + + Datasheets: + https://www.ti.com/product/ADS7128 + https://www.ti.com/product/ADS7138 + +properties: + compatible: + enum: + - ti,ads7128 + - ti,ads7138 + + reg: + maxItems: 1 + + avdd-supply: + description: + The regulator used as analog supply voltage as well as reference voltage. + + interrupts: + description: + Interrupt on ALERT pin, triggers on low level. + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + + adc@10 { + compatible = "ti,ads7138"; + reg = <0x10>; + avdd-supply = <®_stb_3v3>; + interrupt-parent = <&gpio2>; + interrupts = <12 IRQ_TYPE_LEVEL_LOW>; + }; + }; +...
Signature · 1 line
2.34.1
PATCH v2 2/2 iio: adc: Add driver for ADS7128 / ADS7138
In reply to Tobias SperlingAdd driver for ADS7128 and ADS7138 12-bit, 8-channel analog-to-digital converters. These ADCs have a wide operating range and a wide feature set. Communication is based on the I2C interface.
ADS7128 differs in the addition of further hardware features, like a root-mean-square (RMS) and a zero-crossing-detect (ZCD) module.
--- drivers/iio/adc/Kconfig | 10 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ti-ads7138.c | 755 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 766 insertions(+)
drivers/iio/adc/Kconfig +10 -0
@@ -1467,6 +1467,16 @@ config TI_ADS1119 This driver can also be built as a module. If so, the module will be called ti-ads1119. +config TI_ADS7138 + tristate "Texas Instruments ADS7128 and ADS7138 ADC driver" + depends on I2C + help + If you say yes here you get support for Texas Instruments ADS7128 and + ADS7138 8-channel A/D converters with 12-bit resolution. + + This driver can also be built as a module. If so, the module will be + called ti-ads7138. + config TI_ADS7924 tristate "Texas Instruments ADS7924 ADC" depends on I2C
drivers/iio/adc/Makefile +1 -0
@@ -133,6 +133,7 @@ obj-$(CONFIG_TI_ADS1119) += ti-ads1119.o obj-$(CONFIG_TI_ADS124S08) += ti-ads124s08.o obj-$(CONFIG_TI_ADS1298) += ti-ads1298.o obj-$(CONFIG_TI_ADS131E08) += ti-ads131e08.o +obj-$(CONFIG_TI_ADS7138) += ti-ads7138.o obj-$(CONFIG_TI_ADS7924) += ti-ads7924.o obj-$(CONFIG_TI_ADS7950) += ti-ads7950.o obj-$(CONFIG_TI_ADS8344) += ti-ads8344.o
drivers/iio/adc/ti-ads7138.c new file +755 -0
755 lines not on this page · raw message
Signature · 1 line
2.34.1
kernel test robot
build botRe: [PATCH v2 2/2] iio: adc: Add driver for ADS7128 / ADS7138
kernel test robot noticed the following build warnings:
Hi Tobias,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 05dbaf8dd8bf537d4b4eb3115ab42a5fb40ff1f5]
url: https://github.com/intel-lab-lkp/linux/commits/Tobias-Sperling-via-B4-Relay/dt-bindings-iio-adc-Introduce-ADS7138/20250204-003030 base: 05dbaf8dd8bf537d4b4eb3115ab42a5fb40ff1f5 patch link: https://lore.kernel.org/r/20250203-adc_ml-v2-2-8a597660c395%40softing.com patch subject: [PATCH v2 2/2] iio: adc: Add driver for ADS7128 / ADS7138 config: m68k-allmodconfig (https://download.01.org/0day-ci/archive/20250204/[email protected]/config) compiler: m68k-linux-gcc (GCC) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250204/[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]/
All warnings (new ones prefixed by >>):
>> drivers/iio/adc/ti-ads7138.c:706:12: warning: 'ads71x8_runtime_resume' defined but not used [-Wunused-function]
706 | static int ads71x8_runtime_resume(struct device *dev)
| ^~~~~~~~~~~~~~~~~~~~~~
>> drivers/iio/adc/ti-ads7138.c:698:12: warning: 'ads71x8_runtime_suspend' defined but not used [-Wunused-function] 698 | static int ads71x8_runtime_suspend(struct device *dev)
| ^~~~~~~~~~~~~~~~~~~~~~~
vim +/ads71x8_runtime_resume +706 drivers/iio/adc/ti-ads7138.c
697
> 698 static int ads71x8_runtime_suspend(struct device *dev)
699 {
700 struct iio_dev *indio_dev = dev_get_drvdata(dev);
701 struct ads71x8_data *data = iio_priv(indio_dev);
702
703 return ads71x8_set_conv_mode(data, ADS71x8_MODE_MANUAL);
704 }
705
> 706 static int ads71x8_runtime_resume(struct device *dev) 707 {
708 struct iio_dev *indio_dev = dev_get_drvdata(dev);
709 struct ads71x8_data *data = iio_priv(indio_dev);
710
711 return ads71x8_set_conv_mode(data, ADS71x8_MODE_AUTO);
712 }
713
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki