Skip to contentSkip to conversation

dt-bindings: iio: adc: Add TI ADS1100 and ADS1000

PATCH Superseded Mike Looijmans 3 participants 4 messages Feb 27, 2023

Subsystems (2)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 dt-bindings: iio: adc: Add TI ADS1100 and ADS1000

The ADS1100 is a 16-bit ADC (at 8 samples per second). The ADS1000 is similar, but has a fixed data rate.

---

Changes in v2:
"reg" property is mandatory.
Add vdd-supply and #io-channel-cells

 .../bindings/iio/adc/ti,ads1100.yaml          | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/ti,ads1100.yaml
Documentation/devicetree/bindings/iio/adc/ti,ads1100.yaml new file +46 -0
new file mode 100644
index 000000000000..970ccab15e1e
@@ -0,0 +1,46 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/adc/ti,ads1100.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: TI ADS1100/ADS1000 single channel I2C analog to digital converter
+
+maintainers:
+  - Mike Looijmans <[email protected]>
+
+description: |
+  Datasheet at: https://www.ti.com/lit/gpn/ads1100
+
+properties:
+  compatible:
+    enum:
+      - ti,ads1100
+      - ti,ads1000
+
+  reg:
+    maxItems: 1
+
+  vdd-supply: true
+
+  "#io-channel-cells":
+    const: 0
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        adc@49 {
+            compatible = "ti,ads1100";
+            reg = <0x49>;
+        };
+    };
+...
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 2/2 iio: adc: Add TI ADS1100 and ADS1000

The ADS1100 is a 16-bit ADC (at 8 samples per second). The ADS1000 is similar, but has a fixed data rate.

---

Changes in v2:
Remove "driver for" from title
Use proper PM_RUNTIME macros
Fix indents
Use dev_err_probe()
Unsigned index and post-increment
Use GENMASK
remove ads1100_set_conv_mode
remove Kconfig BUFFER dependencies
remove unused #include
Set SCALE instead of HARDWAREGAIN
Use devm_add_action_or_reset

 drivers/iio/adc/Kconfig      |  10 +
 drivers/iio/adc/Makefile     |   1 +
 drivers/iio/adc/ti-ads1100.c | 432 +++++++++++++++++++++++++++++++++++
 3 files changed, 443 insertions(+)
 create mode 100644 drivers/iio/adc/ti-ads1100.c
drivers/iio/adc/Kconfig +10 -0
index 63f80d747cbd..257efb25a92e 100644
@@ -1207,6 +1207,16 @@ config TI_ADS1015
 	  This driver can also be built as a module. If so, the module will be
 	  called ti-ads1015.
 
+config TI_ADS1100
+	tristate "Texas Instruments ADS1100 and ADS1000 ADC"
+	depends on I2C
+	help
+	  If you say yes here you get support for Texas Instruments ADS1100 and
+	  ADS1000 ADC chips.
+
+	  This driver can also be built as a module. If so, the module will be
+	  called ti-ads1100.
+
 config TI_ADS7950
 	tristate "Texas Instruments ADS7950 ADC driver"
 	depends on SPI && GPIOLIB
drivers/iio/adc/Makefile +1 -0
index 4ef41a7dfac6..61ef600fab99 100644
@@ -107,6 +107,7 @@ obj-$(CONFIG_TI_ADC108S102) += ti-adc108s102.o
 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_ADS7950) += ti-ads7950.o
 obj-$(CONFIG_TI_ADS8344) += ti-ads8344.o
 obj-$(CONFIG_TI_ADS8688) += ti-ads8688.o
drivers/iio/adc/ti-ads1100.c new file +432 -0

432 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH v2 2/2] iio: adc: Add TI ADS1100 and ADS1000

Thank you for the patch! Yet something to improve:

Hi Mike,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on v6.2]
[cannot apply to jic23-iio/togreg linus/master next-20230227] [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/Mike-Looijmans/iio-adc-Add-TI-ADS1100-and-ADS1000/20230227-213529
patch link:    https://lore.kernel.org/r/20230227133255.32301-2-mike.looijmans%40topic.nl
patch subject: [PATCH v2 2/2] iio: adc: Add TI ADS1100 and ADS1000
config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20230227/[email protected]/config)
compiler: sh4-linux-gcc (GCC) 12.1.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/8bc0b6e697641a7c6274a492bf210faccdeb55bf
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Mike-Looijmans/iio-adc-Add-TI-ADS1100-and-ADS1000/20230227-213529 git checkout 8bc0b6e697641a7c6274a492bf210faccdeb55bf
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh SHELL=/bin/bash drivers/iio/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/iio/adc/ti-ads1100.c: In function 'ads1100_data_bits':

>> drivers/iio/adc/ti-ads1100.c:87:39: error: implicit declaration of function 'FIELD_GET'; did you mean 'FOLL_GET'? [-Werror=implicit-function-declaration]
      87 |         return ads1100_data_rate_bits[FIELD_GET(ADS1100_DR_MASK, data->config)];
         |                                       ^~~~~~~~~
         |                                       FOLL_GET
   drivers/iio/adc/ti-ads1100.c: In function 'ads1100_set_data_rate':
>> drivers/iio/adc/ti-ads1100.c:156:41: error: implicit declaration of function 'FIELD_PREP' [-Werror=implicit-function-declaration]
     156 |                                         FIELD_PREP(ADS1100_DR_MASK, i));
         |                                         ^~~~~~~~~~

cc1: some warnings being treated as errors

vim +87 drivers/iio/adc/ti-ads1100.c

    84	
    85	static int ads1100_data_bits(struct ads1100_data *data)
    86	{
  > 87		return ads1100_data_rate_bits[FIELD_GET(ADS1100_DR_MASK, data->config)];
    88	}
    89	
    90	static int ads1100_get_adc_result(struct ads1100_data *data, int chan, int *val)
    91	{
    92		int ret;
    93		__be16 buffer;
    94		s16 value;
    95	
    96		if (chan != 0)
    97			return -EINVAL;
    98	
    99		ret = pm_runtime_resume_and_get(&data->client->dev);
   100		if (ret < 0)
   101			return ret;
   102	
   103		ret = i2c_master_recv(data->client, (char *)&buffer, sizeof(buffer));
   104	
   105		pm_runtime_mark_last_busy(&data->client->dev);
   106		pm_runtime_put_autosuspend(&data->client->dev);
   107	
   108		if (ret < 0) {
   109			dev_err(&data->client->dev, "I2C read fail: %d\n", ret);
   110			return ret;
   111		}
   112	
   113		/* Value is always 16-bit 2's complement */
   114		value = be16_to_cpu(buffer);
   115		/* Shift result to compensate for bit resolution vs. sample rate */
   116		value <<= 16 - ads1100_data_bits(data);
   117		*val = sign_extend32(value, 15);
   118	
   119		return 0;
   120	}
   121	
   122	static int ads1100_set_scale(struct ads1100_data *data, int val, int val2)
   123	{
   124		int microvolts;
   125		int gain;
   126		int i;
   127	
   128		/* With Vdd between 2.7 and 5V, the scale is always below 1 */
   129		if (val)
   130			return -EINVAL;
   131	
   132		microvolts = regulator_get_voltage(data->reg_vdd);
   133		/* Calculate: gain = ((microvolts / 1000) / (val2 / 1000000)) >> 15 */
   134		gain = ((microvolts + BIT(14)) >> 15) * 1000 / val2;
   135	
   136		for (i = 0; i < 4; i++) {
   137			if (BIT(i) == gain) {
   138				ads1100_set_config_bits(data, ADS1100_PGA_MASK, i);
   139				return 0;
   140			}
   141		}
   142	
   143		return -EINVAL;
   144	}
   145	
   146	static int ads1100_set_data_rate(struct ads1100_data *data, int chan, int rate)
   147	{
   148		unsigned int i;
   149		unsigned int size;
   150	
   151		size = data->supports_data_rate ? ARRAY_SIZE(ads1100_data_rate) : 1;
   152		for (i = 0; i < size; ++i) {
   153			if (ads1100_data_rate[i] == rate) {
   154				return ads1100_set_config_bits(
   155						data, ADS1100_DR_MASK,
 > 156						FIELD_PREP(ADS1100_DR_MASK, i));

157 }
158 }
159
160 return -EINVAL;
161 }
162

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
#3 lore raw

Re: [PATCH v2 2/2] iio: adc: Add TI ADS1100 and ADS1000

Quoted 27 lines · kernel test robot

Hi Mike,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on v6.2]
[cannot apply to jic23-iio/togreg linus/master next-20230227] [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/Mike-Looijmans/iio-adc-Add-TI-ADS1100-and-ADS1000/20230227-213529
patch link:    https://lore.kernel.org/r/20230227133255.32301-2-mike.looijmans%40topic.nl
patch subject: [PATCH v2 2/2] iio: adc: Add TI ADS1100 and ADS1000
config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20230227/[email protected]/config)
compiler: sh4-linux-gcc (GCC) 12.1.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/8bc0b6e697641a7c6274a492bf210faccdeb55bf
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Mike-Looijmans/iio-adc-Add-TI-ADS1100-and-ADS1000/20230227-213529 git checkout 8bc0b6e697641a7c6274a492bf210faccdeb55bf
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh SHELL=/bin/bash drivers/iio/

Quoted 5 lines

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

Missing bitgield.h (and actually bits.h as well).

Signature · 2 lines
With Best Regards,
Andy Shevchenko