Skip to contentSkip to conversation

] iio: humidity: Add driver for ti HDC302x humidity sensors

PATCH Superseded Li peiyu 3 participants 6 messages Nov 16, 2023 – Nov 17, 2023

Subsystems (3)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Li peiyu

author maintainer
#0 lore raw

PATCH 1/2 ] iio: humidity: Add driver for ti HDC302x humidity sensors

Add support for HDC302x integrated capacitive based relative humidity (RH) and temperature sensor.
This driver supports reading values, reading the maximum and minimum of values and controlling the integrated heater of the sensor.

---
 drivers/iio/humidity/Kconfig   |  11 +
 drivers/iio/humidity/Makefile  |   1 +
 drivers/iio/humidity/hdc3020.c | 481 +++++++++++++++++++++++++++++++++
 3 files changed, 493 insertions(+)
 create mode 100644 drivers/iio/humidity/hdc3020.c
drivers/iio/humidity/Kconfig +11 -0
index 2de5494e7c22..7b585bc7db9a 100644
@@ -48,6 +48,17 @@ config HDC2010
 	  To compile this driver as a module, choose M here: the module
 	  will be called hdc2010.
 
+config HDC3020
+	tristate "TI HDC3020 relative humidity and temperature sensor"
+	depends on I2C
+	help
+	  Say yes here to build support for the Texas Instruments
+	  HDC3020,HDC3021 and HDC3022 relative humidity and temperature
+	  sensors.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called hdc3020.
+
 config HID_SENSOR_HUMIDITY
 	tristate "HID Environmental humidity sensor"
 	depends on HID_SENSOR_HUB
drivers/iio/humidity/Makefile +1 -0
index f19ff3de97c5..5fbeef299f61 100644
@@ -7,6 +7,7 @@ obj-$(CONFIG_AM2315) += am2315.o
 obj-$(CONFIG_DHT11) += dht11.o
 obj-$(CONFIG_HDC100X) += hdc100x.o
 obj-$(CONFIG_HDC2010) += hdc2010.o
+obj-$(CONFIG_HDC3020) += hdc3020.o
 obj-$(CONFIG_HID_SENSOR_HUMIDITY) += hid-sensor-humidity.o
 
 hts221-y := hts221_core.o \
drivers/iio/humidity/hdc3020.c new file +481 -0

481 lines not on this page · raw message

Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH 1/2 ] iio: humidity: Add driver for ti HDC302x humidity sensors

Add support for HDC302x integrated capacitive based relative humidity (RH) and temperature sensor.
This driver supports reading values, reading the maximum and minimum of values and controlling the integrated heater of the sensor.

---
 drivers/iio/humidity/Kconfig   |  11 +
 drivers/iio/humidity/Makefile  |   1 +
 drivers/iio/humidity/hdc3020.c | 481 +++++++++++++++++++++++++++++++++
 3 files changed, 493 insertions(+)
 create mode 100644 drivers/iio/humidity/hdc3020.c
drivers/iio/humidity/Kconfig +11 -0
index 2de5494e7c22..7b585bc7db9a 100644
@@ -48,6 +48,17 @@ config HDC2010
 	  To compile this driver as a module, choose M here: the module
 	  will be called hdc2010.
 
+config HDC3020
+	tristate "TI HDC3020 relative humidity and temperature sensor"
+	depends on I2C
+	help
+	  Say yes here to build support for the Texas Instruments
+	  HDC3020,HDC3021 and HDC3022 relative humidity and temperature
+	  sensors.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called hdc3020.
+
 config HID_SENSOR_HUMIDITY
 	tristate "HID Environmental humidity sensor"
 	depends on HID_SENSOR_HUB
drivers/iio/humidity/Makefile +1 -0
index f19ff3de97c5..5fbeef299f61 100644
@@ -7,6 +7,7 @@ obj-$(CONFIG_AM2315) += am2315.o
 obj-$(CONFIG_DHT11) += dht11.o
 obj-$(CONFIG_HDC100X) += hdc100x.o
 obj-$(CONFIG_HDC2010) += hdc2010.o
+obj-$(CONFIG_HDC3020) += hdc3020.o
 obj-$(CONFIG_HID_SENSOR_HUMIDITY) += hid-sensor-humidity.o
 
 hts221-y := hts221_core.o \
drivers/iio/humidity/hdc3020.c new file +481 -0

481 lines not on this page · raw message

Signature · 1 line
2.34.1
author maintainer
#4 lore raw

PATCH 2/2 ] dt-bindings: iio: humidity: Add TI HDC302x support

In reply to Li peiyu

Add device tree bindings for HDC3020/HDC3021/HDC3022 humidity and temperature sensors.

---
 .../bindings/iio/humidity/ti,hdc3020.yaml     | 48 +++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/humidity/ti,hdc3020.yaml
Documentation/devicetree/bindings/iio/humidity/ti,hdc3020.yaml new file +48 -0
new file mode 100644
index 000000000000..8015c4bb5b2f
@@ -0,0 +1,48 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/humidity/ti,hdc3020.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: HDC3020/HDC3021/HDC3022 humidity and temperature iio sensors
+
+maintainers:
+  - Jonathan Cameron <[email protected]>
+
+description: |
+  The HDC302x is an integrated capacitive based relative humidity (RH)
+  and temperature sensor.
+
+  datasheet is available:
+    https://www.ti.com/lit/ds/symlink/hdc3020.pdf
+
+properties:
+  compatible:
+    enum:
+      - ti,hdc3020
+      - ti,hdc3021
+      - ti,hdc3022
+
+  interrupts:
+    maxItems: 1
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        humidity@47 {
+            compatible = "ti,hdc3020";
+            reg = <0x47>;
+        };
+    };
Signature · 1 line
2.34.1
author maintainer
#2 lore raw

Sorry,please ingore this email,this one is no is no different from the previous one.

In reply to Li peiyu

I'm sorry that I used the wrong patch name when sending the email. thanks,
Li peiyu.

Quoted 8 lines

Add support for HDC302x integrated capacitive based relative humidity (RH) and temperature sensor.
This driver supports reading values, reading the maximum and minimum of values and controlling the integrated heater of the sensor.

#5 lore raw

Re: [PATCH [2/2]] dt-bindings: iio: humidity: Add TI HDC302x support

In reply to Li peiyu
Quoted 15 lines · Li peiyu

Add device tree bindings for HDC3020/HDC3021/HDC3022 humidity and temperature sensors.

---
 .../bindings/iio/humidity/ti,hdc3020.yaml     | 48 +++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/humidity/ti,hdc3020.yaml
Documentation/devicetree/bindings/iio/humidity/ti,hdc3020.yaml new file +0 -0
new file mode 100644
index 000000000000..8015c4bb5b2f

Documentation/devicetree/bindings/iio/humidity/ti,hdc3020.yaml line 10

Quoted 10 lines
Documentation/devicetree/bindings/iio/humidity/ti,hdc3020.yaml new file +10 -0
@@ -0,0 +1,48 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/humidity/ti,hdc3020.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: HDC3020/HDC3021/HDC3022 humidity and temperature iio sensors
+
+maintainers:
+  - Jonathan Cameron <[email protected]>

Usually this is you, not the maintainer of the subsystem, since you have the hardware in question and an interest in it specifically.

Quoted 4 lines
Documentation/devicetree/bindings/iio/humidity/ti,hdc3020.yaml new file +4 -0
+
+description: |
+  The HDC302x is an integrated capacitive based relative humidity (RH)
+  and temperature sensor.

Documentation/devicetree/bindings/iio/humidity/ti,hdc3020.yaml line 24

Quoted 10 lines
Documentation/devicetree/bindings/iio/humidity/ti,hdc3020.yaml new file +10 -0
+
+  datasheet is available:
+    https://www.ti.com/lit/ds/symlink/hdc3020.pdf
+
+properties:
+  compatible:
+    enum:
+      - ti,hdc3020
+      - ti,hdc3021
+      - ti,hdc3022

Looking at your driver, all three of these seem to be compatible? I did only have a quick look though, so please correct me if that is not the case. If they are compatible, please set this up to use a fallback compatible - for example allow
compatible = "ti,hdc3020";
compatible = "ti,hdc3021", "ti,hdc3020";
compatible = "ti,hdc3022", "ti,hdc3020";

Quoted 10 lines
Documentation/devicetree/bindings/iio/humidity/ti,hdc3020.yaml new file +10 -0
+
+  interrupts:
+    maxItems: 1
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg

Documentation/devicetree/bindings/iio/humidity/ti,hdc3020.yaml line 44

Quoted 10 lines
Documentation/devicetree/bindings/iio/humidity/ti,hdc3020.yaml new file +10 -0
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        humidity@47 {

The generic node name here should probably be "humidity-sensor".

Cheers,
Conor.

Quoted 7 lines
Documentation/devicetree/bindings/iio/humidity/ti,hdc3020.yaml new file +4 -0
+            compatible = "ti,hdc3020";
+            reg = <0x47>;
+        };
+    };
Signature · 1 line
2.34.1
#3 lore raw
In reply to Li peiyu
kernel test robot noticed the following build warnings:

Hi Li,

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-rc1 next-20231116] [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/Li-peiyu/iio-humidity-Add-driver-for-ti-HDC302x-humidity-sensors/20231116-210050
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
patch link:    https://lore.kernel.org/r/20231116125805.13466-1-579lpy%40gmail.com
patch subject: [PATCH [1/2]] iio: humidity: Add driver for ti HDC302x humidity sensors
config: x86_64-randconfig-r111-20231117 (https://download.01.org/0day-ci/archive/20231117/[email protected]/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231117/[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]/

sparse warnings: (new ones prefixed by >>)

>> drivers/iio/humidity/hdc3020.c:23:10: sparse: sparse: symbol 'HDC3020_S_AUTO_10HZ_MOD0' was not declared. Should it be static?
>> drivers/iio/humidity/hdc3020.c:25:10: sparse: sparse: symbol 'HDC3020_EXIT_AUTO' was not declared. Should it be static?
>> drivers/iio/humidity/hdc3020.c:27:10: sparse: sparse: symbol 'HDC3020_R_T_RH_AUTO' was not declared. Should it be static?
>> drivers/iio/humidity/hdc3020.c:28:10: sparse: sparse: symbol 'HDC3020_R_T_LOW_AUTO' was not declared. Should it be static?
>> drivers/iio/humidity/hdc3020.c:29:10: sparse: sparse: symbol 'HDC3020_R_T_HIGH_AUTO' was not declared. Should it be static?
>> drivers/iio/humidity/hdc3020.c:30:10: sparse: sparse: symbol 'HDC3020_R_RH_LOW_AUTO' was not declared. Should it be static?
>> drivers/iio/humidity/hdc3020.c:31:10: sparse: sparse: symbol 'HDC3020_R_RH_HIGH_AUTO' was not declared. Should it be static?
>> drivers/iio/humidity/hdc3020.c:33:10: sparse: sparse: symbol 'HDC3020_ENABLE_HEATER' was not declared. Should it be static?
>> drivers/iio/humidity/hdc3020.c:34:10: sparse: sparse: symbol 'HDC3020_DISABLE_HEATER' was not declared. Should it be static?
>> drivers/iio/humidity/hdc3020.c:36:10: sparse: sparse: symbol 'HDC3020_HEATER_FULL' was not declared. Should it be static?
>> drivers/iio/humidity/hdc3020.c:37:10: sparse: sparse: symbol 'HDC3020_HEATER_HALF' was not declared. Should it be static?
>> drivers/iio/humidity/hdc3020.c:38:10: sparse: sparse: symbol 'HDC3020_HEATER_QUARTER' was not declared. Should it be static?

vim +/HDC3020_S_AUTO_10HZ_MOD0 +23 drivers/iio/humidity/hdc3020.c

    22	
  > 23	const u8 HDC3020_S_AUTO_10HZ_MOD0[2] = { 0x27, 0x37 };
    24	
  > 25	const u8 HDC3020_EXIT_AUTO[2] = { 0x30, 0x93 };
    26	
  > 27	const u8 HDC3020_R_T_RH_AUTO[2] = { 0xE0, 0x00 };
  > 28	const u8 HDC3020_R_T_LOW_AUTO[2] = { 0xE0, 0x02 };
  > 29	const u8 HDC3020_R_T_HIGH_AUTO[2] = { 0xE0, 0x03 };
  > 30	const u8 HDC3020_R_RH_LOW_AUTO[2] = { 0xE0, 0x04 };
  > 31	const u8 HDC3020_R_RH_HIGH_AUTO[2] = { 0xE0, 0x05 };
    32	
  > 33	const u8 HDC3020_ENABLE_HEATER[2] = { 0x30, 0x6D };
  > 34	const u8 HDC3020_DISABLE_HEATER[2] = { 0x30, 0x66 };
    35	
  > 36	const u8 HDC3020_HEATER_FULL[5] = { 0x30, 0x6E, 0x3F, 0xFF, 0x06 };
  > 37	const u8 HDC3020_HEATER_HALF[5] = { 0x30, 0x6E, 0x03, 0xFF, 0x00 };
  > 38	const u8 HDC3020_HEATER_QUARTER[5] = { 0x30, 0x6E, 0x00, 0x9F, 0x96 };
    39	
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki