dt-bindings: iio: adc: ti,ads7038: Add description for ADS7038
Subsystems (2)
PATCH 1/2 dt-bindings: iio: adc: ti,ads7038: Add description for ADS7038
From: Andre Werner <[email protected]>
--- .../bindings/iio/adc/ti,ads7038.yaml | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/ti,ads7038.yaml
Documentation/devicetree/bindings/iio/adc/ti,ads7038.yaml new file +51 -0
@@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/ti,ads7038.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments ADS7038 and similar ADCs + +maintainers: + - Andre Werner <[email protected]> + +description: | + Family of 7 channel, 12 bit ADCs with SPI/I2C interface. + + Datasheet: https://www.ti.com/lit/gpn/ads7038 + +properties: + compatible: + enum: + - ti,ads7038 + - ti,ads7138 + + reg: + maxItems: 1 + + spi-max-frequency: + maximum: 60000000 + + vref-supply: + description: Supplies the 2.5V or 5V reference voltage + +required: + - compatible + - reg + - vref-supply + +additionalProperties: false + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + adc@0 { + compatible = "ti,ads7038"; + reg = <0>; + vref-supply = <&refin_supply>; + spi-max-frequency = <10000000>; + }; + };
Signature · 1 line
2.42.0
PATCH 2/2 iio: adc: ads7038: Add driver support for 12bit ADC
From: Andre Werner <[email protected]>
The driver is designed to support both, ADS7038 and ADS7138, but the implementation of the device access is limited to ADS7038 (SPI). The ADS7138 is accessed via I2C.
The driver has a regmap and a core file that abstracts device access. Currently, the driver does support manual mode only.
--- MAINTAINERS | 10 + drivers/iio/adc/Kconfig | 22 ++ drivers/iio/adc/Makefile | 3 + drivers/iio/adc/ti-ads7038-core.c | 137 +++++++ drivers/iio/adc/ti-ads7038-regmap.c | 91 +++++ drivers/iio/adc/ti-ads7038-spi.c | 375 +++++++++++++++++++ drivers/iio/adc/ti-ads7038.h | 551 ++++++++++++++++++++++++++++ 7 files changed, 1189 insertions(+) create mode 100644 drivers/iio/adc/ti-ads7038-core.c create mode 100644 drivers/iio/adc/ti-ads7038-regmap.c create mode 100644 drivers/iio/adc/ti-ads7038-spi.c create mode 100644 drivers/iio/adc/ti-ads7038.h
MAINTAINERS +10 -0
@@ -21252,6 +21252,16 @@ T: git https://github.com/jcmvbkbc/linux-xtensa.git F: arch/xtensa/ F: drivers/irqchip/irq-xtensa-* +TEXAS INSTRUMENT'S ADS7038 ADC DRIVER +M: Andre Werner <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/iio/adc/ti,ads7038.yaml +F: drivers/iio/adc/ti-ads7038.h +F: drivers/iio/adc/ti-ads7038-core.c +F: drivers/iio/adc/ti-ads7038-regmap.c +F: drivers/iio/adc/ti-ads7038-spi.c + TEXAS INSTRUMENTS ASoC DRIVERS M: Peter Ujfalusi <[email protected]> L: [email protected] (moderated for non-subscribers)
drivers/iio/adc/Kconfig +22 -0
@@ -1239,6 +1239,28 @@ config TI_ADS1015 This driver can also be built as a module. If so, the module will be called ti-ads1015. +config TI_ADS7038 + tristate "Texas Instruments ADS7038 ADC driver" + depends on (I2C || SPI_MASTER) + select REGMAP + select TI_ADS7038_SPI if (SPI_MASTER) + help + Say yes here to build support for TI ADS7038 12BIT ADC. + + To compile this driver as a module, choose M here: the core module + will be called ti-ads7038 and you will also get ti-ads7038-spi for SPI support. + +config TI_ADS7038_SPI + tristate + depends on TI_ADS7038 + depends on SPI_MASTER + select REGMAP + help + Say yes here to build support for TI ADS7038 12BIT ADC (SPI connected). + + To compile this driver as a module, choose M here: the core module + will be called ti-ads7038 and you will also get ti-ads7038-spi for SPI support. + config TI_ADS7924 tristate "Texas Instruments ADS7924 ADC" depends on I2C
drivers/iio/adc/Makefile +3 -0
@@ -111,6 +111,9 @@ obj-$(CONFIG_TI_ADC128S052) += ti-adc128s052.o obj-$(CONFIG_TI_ADC161S626) += ti-adc161s626.o obj-$(CONFIG_TI_ADS1015) += ti-ads1015.o obj-$(CONFIG_TI_ADS1100) += ti-ads1100.o +obj-$(CONFIG_TI_ADS7038) += ti-ads7038.o +ti-ads7038-objs := ti-ads7038-core.o ti-ads7038-regmap.o +obj-$(CONFIG_TI_ADS7038_SPI) += ti-ads7038-spi.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-ads7038-core.c new file +137 -0
137 lines not on this page · raw message
drivers/iio/adc/ti-ads7038-regmap.c new file +91 -0
91 lines not on this page · raw message
drivers/iio/adc/ti-ads7038-spi.c new file +375 -0
375 lines not on this page · raw message
drivers/iio/adc/ti-ads7038.h new file +551 -0
551 lines not on this page · raw message
Signature · 1 line
2.42.0
Rob Herring
maintainerQuoted 2 lines · On Wed, Oct 04, 2023 at 12:23:29PM +0200, [email protected] wrote:
From: Andre Werner <[email protected]>
Needs a commit message.
Quoted 32 lines
Signed-off-by Andre Werner <[email protected]>--- .../bindings/iio/adc/ti,ads7038.yaml | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/ti,ads7038.yamlDocumentation/devicetree/bindings/iio/adc/ti,ads7038.yaml new file +20
-0@@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/ti,ads7038.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments ADS7038 and similar ADCs + +maintainers: + - Andre Werner <[email protected]> + +description: | + Family of 7 channel, 12 bit ADCs with SPI/I2C interface. + + Datasheet: https://www.ti.com/lit/gpn/ads7038 + +properties: + compatible: + enum: + - ti,ads7038
Documentation/devicetree/bindings/iio/adc/ti,ads7038.yaml line 30
Quoted 10 lines
Documentation/devicetree/bindings/iio/adc/ti,ads7038.yaml new file +10
-0+ - ti,ads7138 + + reg: + maxItems: 1 + + spi-max-frequency: + maximum: 60000000 + + vref-supply: + description: Supplies the 2.5V or 5V reference voltage
I don't see that in the datasheet. It has AVDD and DVDD.
Also, looks like there are GPIOs. Those aren't ever exposed to the OS?
Quoted 24 lines
Documentation/devicetree/bindings/iio/adc/ti,ads7038.yaml new file +21
-0+ +required: + - compatible + - reg + - vref-supply + +additionalProperties: false + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + adc@0 { + compatible = "ti,ads7038"; + reg = <0>; + vref-supply = <&refin_supply>; + spi-max-frequency = <10000000>; + }; + };Signature · 1 line
2.42.0
kernel test robot
build botRe: [PATCH 2/2] iio: adc: ads7038: Add driver support for 12bit ADC
In reply to [email protected]kernel test robot noticed the following build warnings:
Hi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on jic23-iio/togreg]
[also build test WARNING on robh/for-next linus/master v6.6-rc4 next-20231004] [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/werneazc-gmail-com/iio-adc-ads7038-Add-driver-support-for-12bit-ADC/20231004-182531 base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg patch link: https://lore.kernel.org/r/20231004102330.3713-2-andre.werner%40systec-electronic.com patch subject: [PATCH 2/2] iio: adc: ads7038: Add driver support for 12bit ADC config: csky-allmodconfig (https://download.01.org/0day-ci/archive/20231005/[email protected]/config) compiler: csky-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231005/[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-ads7038-core.c:46:5: warning: no previous prototype for 'ads7038_read_raw' [-Wmissing-prototypes]
46 | int ads7038_read_raw(struct iio_dev *indio_dev,
| ^~~~~~~~~~~~~~~~vim +/ads7038_read_raw +46 drivers/iio/adc/ti-ads7038-core.c
45
> 46 int ads7038_read_raw(struct iio_dev *indio_dev,
47 struct iio_chan_spec const *chan,
48 int *val, int *val2,
49 long mask)
50 {
51 unsigned int ret;
52 struct ads7038_ch_meas_result tmp_val;
53 struct ads7038_data *const data = (struct ads7038_data *)iio_priv(indio_dev);
54 struct ads7038_info *const info = (struct ads7038_info *)data->info;
55
56 ret = info->read_channel(indio_dev, chan->channel, &tmp_val);
57
58 if (ret < 0) {
59 dev_err(&indio_dev->dev, "Read channel returned with error %d", ret);
60 return ret;
61 }
62
63 switch (mask) {
64 case IIO_CHAN_INFO_RAW:
65 *val = tmp_val.raw;
66
67 ret = IIO_VAL_INT;
68 break;
69 case IIO_CHAN_INFO_SCALE:
70 ret = regulator_get_voltage(data->reg);
71 if (ret < 0)
72 break;
73
74 *val = ret / 1000; /* uV -> mV */
75 *val2 = (1 << chan->scan_type.realbits) - 1;
76
77 ret = IIO_VAL_FRACTIONAL;
78 break;
79 default:
80 ret = -EINVAL;
81 break;
82 }
83
84 return ret;
85 }
86 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH 2/2] iio: adc: ads7038: Add driver support for 12bit ADC
In reply to [email protected]kernel test robot noticed the following build warnings:
Hi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on jic23-iio/togreg]
[also build test WARNING on robh/for-next linus/master v6.6-rc4 next-20231004] [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/werneazc-gmail-com/iio-adc-ads7038-Add-driver-support-for-12bit-ADC/20231004-182531 base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg patch link: https://lore.kernel.org/r/20231004102330.3713-2-andre.werner%40systec-electronic.com patch subject: [PATCH 2/2] iio: adc: ads7038: Add driver support for 12bit ADC config: powerpc64-allyesconfig (https://download.01.org/0day-ci/archive/20231005/[email protected]/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231005/[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-ads7038-core.c:46:5: warning: no previous prototype for function 'ads7038_read_raw' [-Wmissing-prototypes]
46 | int ads7038_read_raw(struct iio_dev *indio_dev,
| ^
drivers/iio/adc/ti-ads7038-core.c:46:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
46 | int ads7038_read_raw(struct iio_dev *indio_dev,
| ^
| static 1 warning generated.
vim +/ads7038_read_raw +46 drivers/iio/adc/ti-ads7038-core.c
45
> 46 int ads7038_read_raw(struct iio_dev *indio_dev,
47 struct iio_chan_spec const *chan,
48 int *val, int *val2,
49 long mask)
50 {
51 unsigned int ret;
52 struct ads7038_ch_meas_result tmp_val;
53 struct ads7038_data *const data = (struct ads7038_data *)iio_priv(indio_dev);
54 struct ads7038_info *const info = (struct ads7038_info *)data->info;
55
56 ret = info->read_channel(indio_dev, chan->channel, &tmp_val);
57
58 if (ret < 0) {
59 dev_err(&indio_dev->dev, "Read channel returned with error %d", ret);
60 return ret;
61 }
62
63 switch (mask) {
64 case IIO_CHAN_INFO_RAW:
65 *val = tmp_val.raw;
66
67 ret = IIO_VAL_INT;
68 break;
69 case IIO_CHAN_INFO_SCALE:
70 ret = regulator_get_voltage(data->reg);
71 if (ret < 0)
72 break;
73
74 *val = ret / 1000; /* uV -> mV */
75 *val2 = (1 << chan->scan_type.realbits) - 1;
76
77 ret = IIO_VAL_FRACTIONAL;
78 break;
79 default:
80 ret = -EINVAL;
81 break;
82 }
83
84 return ret;
85 }
86 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Dear Mr. Herring,
Quoted 6 lines · Rob Herring
Quoted 2 lines · On Wed, Oct 04, 2023 at 12:23:29PM +0200, [email protected] wrote:
From: Andre Werner <[email protected]>
Needs a commit message.
Added in an upcoming commit.
Quoted 37 lines
Quoted 37 lines
Signed-off-by Andre Werner <[email protected]>--- .../bindings/iio/adc/ti,ads7038.yaml | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/ti,ads7038.yamlDocumentation/devicetree/bindings/iio/adc/ti,ads7038.yaml new file +24
-0@@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/ti,ads7038.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments ADS7038 and similar ADCs + +maintainers: + - Andre Werner <[email protected]> + +description: | + Family of 7 channel, 12 bit ADCs with SPI/I2C interface. + + Datasheet: https://www.ti.com/lit/gpn/ads7038 + +properties: + compatible: + enum: + - ti,ads7038 + - ti,ads7138 + + reg: + maxItems: 1
Quoted 8 lines
Documentation/devicetree/bindings/iio/adc/ti,ads7038.yaml line 30
Quoted 6 lines
Documentation/devicetree/bindings/iio/adc/ti,ads7038.yaml new file +6
-0+ + spi-max-frequency: + maximum: 60000000 + + vref-supply: + description: Supplies the 2.5V or 5V reference voltageI don't see that in the datasheet. It has AVDD and DVDD.
Yes, that was a copy-and-paste error from another description used as a template.
Quoted 2 lines
Also, looks like there are GPIOs. Those aren't ever exposed to the OS?
Yes, you are right. This is a fundamental implementation of the driver to support the chip family. I want to add further functionalities in upcoming commits.
I wanted to get some feedback when the first steps are done to not reinvent everything from the beginning if something is generally wrong in the driver structure and the way I had used the APIs.
Quoted 17 lines
Quoted 17 lines
Documentation/devicetree/bindings/iio/adc/ti,ads7038.yaml new file +16
-0+ +required: + - compatible + - reg + - vref-supply + +additionalProperties: false + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + adc@0 { + compatible = "ti,ads7038";
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/iio/adc/ti,ads7038.yaml new file +5
-1+ reg = <0>; + vref-supply = <&refin_supply>; + spi-max-frequency = <10000000>; + }; + }; --2.42.0
Regards,
André
Jonathan Cameron
maintainerQuoted 62 lines · On Thu, 5 Oct 2023 05:51:40 +0200 werneazc <[email protected]> wrote:
Dear Mr. Herring,
Quoted 6 lines · Rob Herring
Quoted 2 lines · On Wed, Oct 04, 2023 at 12:23:29PM +0200, [email protected] wrote:
From: Andre Werner <[email protected]>
Needs a commit message.
Added in an upcoming commit.
Quoted 37 lines
Quoted 37 lines
Signed-off-by Andre Werner <[email protected]>--- .../bindings/iio/adc/ti,ads7038.yaml | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/ti,ads7038.yamlDocumentation/devicetree/bindings/iio/adc/ti,ads7038.yaml new file +24
-0@@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/ti,ads7038.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments ADS7038 and similar ADCs + +maintainers: + - Andre Werner <[email protected]> + +description: | + Family of 7 channel, 12 bit ADCs with SPI/I2C interface. + + Datasheet: https://www.ti.com/lit/gpn/ads7038 + +properties: + compatible: + enum: + - ti,ads7038 + - ti,ads7138 + + reg: + maxItems: 1Quoted 8 lines
Documentation/devicetree/bindings/iio/adc/ti,ads7038.yaml line 30
Quoted 6 lines
Documentation/devicetree/bindings/iio/adc/ti,ads7038.yaml new file +6
-0+ + spi-max-frequency: + maximum: 60000000 + + vref-supply: + description: Supplies the 2.5V or 5V reference voltageI don't see that in the datasheet. It has AVDD and DVDD.
Yes, that was a copy-and-paste error from another description used as a template.
Quoted 1 line
Quoted 8 lines
Quoted 1 line
Also, looks like there are GPIOs. Those aren't ever exposed to the OS?
Yes, you are right. This is a fundamental implementation of the driver to support the chip family. I want to add further functionalities in upcoming commits.
I wanted to get some feedback when the first steps are done to not reinvent everything from the beginning if something is generally wrong in the driver structure and the way I had used the APIs.
Device tree binding should fully describe the hardware, not what the driver currently implements.
So add the GPIOs for v3.
Quoted 30 lines
Quoted 18 lines
Quoted 18 lines
Documentation/devicetree/bindings/iio/adc/ti,ads7038.yaml new file +16
-0+ +required: + - compatible + - reg + - vref-supply + +additionalProperties: false + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + adc@0 { + compatible = "ti,ads7038";Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/iio/adc/ti,ads7038.yaml new file +5
-1+ reg = <0>; + vref-supply = <&refin_supply>; + spi-max-frequency = <10000000>; + }; + }; --2.42.0
Regards,
André