Skip to contentSkip to conversation

iio: humidity: Add driver for ti HDC302x humidity sensors

PATCH In review Li peiyu 5 participants 10 messages Dec 11, 2023 – Jan 21, 2024

Subsystems (3)
lore
Share & tools
lore

Li peiyu

author maintainer
#0 lore raw

v6 cover 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.

---
changes in v6:
sensor driver:
- Drop offset for humidity channel.
- Use put_unaligned_be16 to assign the 14-bit heater value.
- Remove error message if devm_action_or_reset() fails.
- Add eror message if devm_iio_device_register() fails.
dt-bindings:
- remove items before "- const: ti,hdc3020".
- add vdd-supply to required.
changes in v5:
iio ABI:
- Document _TROUGH as an info element.
sensor driver:
- Correct heater enable/disable commands
- Rearrang header files in alphabetical order.
- Change .info_mask_separate to BIT(IIO_CHAN_INFO_RAW).
- Add details to mutex comment.
- Add error handling for chan->type in read_raw call.
- Remove error message for devm_iio_device_register.
changes in v4:
iio core:
- Add an IIO_CHAN_INFO_TROUGH modifier for minimum values.
iio ABI:
- Document the new _TROUGH modifier.
sensor driver:
- Add MAINTAINERS.
- Use new IIO_CHAN_INFO_TROUGH modifier.
- Support the complete heater range.
- Remove measurement values from the data structure.
- Use guard(mutex)(...), make the code simpler
- Removed buffer mode and direct mode conversion code
- Minor coding-style fixes.
dt-bindings:
- removed unnecessary example
- add vdd-supply to the example
changes in v3:
sensor driver:
- Removed the custom ABI
- Give up calculating values in the driver
- Use read_avail callback to get available parameters
- Changed the scope of the lock to make the code more concise
- Fixed the code format issue
dt-bindings:
- Use a fallback compatible
changes in v2:
sensor driver:
- Added static modification to global variables
- change the methord to read peak value
dt-bindings:
- change the maintainers to me.
- hdc3020,hdc3021,hdc3022 are compatible,I've changed the dirver.
- change the node name to humidity-sensor.

---
Javier Carrasco (2):
iio: core: introduce trough modifier for minimum values
iio: ABI: document temperature and humidity peak/trough raw attributes

Li peiyu (2):
dt-bindings: iio: humidity: Add TI HDC302x support
iio: humidity: Add driver for TI HDC302x humidity sensors

 Documentation/ABI/testing/sysfs-bus-iio            |  13 +-
 .../bindings/iio/humidity/ti,hdc3020.yaml          |  55 +++
 MAINTAINERS                                        |   8 +
 drivers/iio/humidity/Kconfig                       |  12 +
 drivers/iio/humidity/Makefile                      |   1 +
 drivers/iio/humidity/hdc3020.c                     | 473 +++++++++++++++++++++
 drivers/iio/industrialio-core.c                    |   1 +
 include/linux/iio/types.h                          |   1 +
 8 files changed, 563 insertions(+), 1 deletion(-)

---
base-commit: 33cc938e65a98f1d29d0a18403dbbee050dcad9a

Best regards,

author maintainer
#1 lore raw

PATCH v6 1/4 iio: core: introduce trough info element for minimum values

From: Javier Carrasco <[email protected]>

The IIO_CHAN_INFO_PEAK info element is used for maximum values and currently there is no equivalent for minimum values. Instead of overloading the existing peak info element, a new info element can be added.

In principle there is no need to add a _TROUGH_SCALE element as the scale will be the same as the one required for INFO_PEAK, which in turn is sometimes omitted if a single scale for peaks and raw values is required.

Add an IIO_CHAN_INFO_TROUGH info element for minimum values.

---
 drivers/iio/industrialio-core.c | 1 +
 include/linux/iio/types.h       | 1 +
 2 files changed, 2 insertions(+)
drivers/iio/industrialio-core.c +1 -0
index f6a123d397db..9a85752124dd 100644
@@ -184,6 +184,7 @@ static const char * const iio_chan_info_postfix[] = {
 	[IIO_CHAN_INFO_THERMOCOUPLE_TYPE] = "thermocouple_type",
 	[IIO_CHAN_INFO_CALIBAMBIENT] = "calibambient",
 	[IIO_CHAN_INFO_ZEROPOINT] = "zeropoint",
+	[IIO_CHAN_INFO_TROUGH] = "trough_raw",
 };
 /**
  * iio_device_id() - query the unique ID for the device
include/linux/iio/types.h +1 -0
index 117bde7d6ad7..d89982c98368 100644
@@ -68,6 +68,7 @@ enum iio_chan_info_enum {
 	IIO_CHAN_INFO_THERMOCOUPLE_TYPE,
 	IIO_CHAN_INFO_CALIBAMBIENT,
 	IIO_CHAN_INFO_ZEROPOINT,
+	IIO_CHAN_INFO_TROUGH,
 };
 
 #endif /* _IIO_TYPES_H_ */
Signature · 1 line
2.34.1
author maintainer
#2 lore raw

PATCH v6 2/4 iio: ABI: document temperature and humidity peak/trough raw attributes

In reply to Li peiyu

From: Javier Carrasco <[email protected]>

The in_temp_peak_raw attribute is already in use, but its documentation is still missing. The in_humidityrelative_raw must be documented for a new iio user that supports this attribute. Add temp and humidityrelative use cases.
When at it, remove an extra blank space in the description.

For users that support minimum values, a new in_<type>_trough_raw attribute is required. Add this attribute and document the first uses of it for temp and humidityrelative types.

---
 Documentation/ABI/testing/sysfs-bus-iio | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-bus-iio +12 -1
index 0d3ec5fc45f2..9d937e29724b 100644
@@ -362,10 +362,21 @@ Description:
 What:		/sys/bus/iio/devices/iio:deviceX/in_accel_x_peak_raw
 What:		/sys/bus/iio/devices/iio:deviceX/in_accel_y_peak_raw
 What:		/sys/bus/iio/devices/iio:deviceX/in_accel_z_peak_raw
+What:		/sys/bus/iio/devices/iio:deviceX/in_humidityrelative_peak_raw
+What:		/sys/bus/iio/devices/iio:deviceX/in_temp_peak_raw
 KernelVersion:	2.6.36
 Contact:	[email protected]
 Description:
-		Highest value since some reset condition.  These
+		Highest value since some reset condition. These
+		attributes allow access to this and are otherwise
+		the direct equivalent of the <type>Y[_name]_raw attributes.
+
+What:		/sys/bus/iio/devices/iio:deviceX/in_humidityrelative_trough_raw
+What:		/sys/bus/iio/devices/iio:deviceX/in_temp_trough_raw
+KernelVersion:	6.7
+Contact:	[email protected]
+Description:
+		Lowest value since some reset condition. These
 		attributes allow access to this and are otherwise
 		the direct equivalent of the <type>Y[_name]_raw attributes.
 
Signature · 1 line
2.34.1
author maintainer
#3 lore raw

PATCH v6 3/4 iio: humidity: Add driver for ti HDC302x humidity sensors

In reply to Li peiyu

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.

---
 MAINTAINERS                    |   8 +
 drivers/iio/humidity/Kconfig   |  12 +
 drivers/iio/humidity/Makefile  |   1 +
 drivers/iio/humidity/hdc3020.c | 473 +++++++++++++++++++++++++++++++++
 4 files changed, 494 insertions(+)
 create mode 100644 drivers/iio/humidity/hdc3020.c
MAINTAINERS +8 -0
index 788be9ab5b73..485dcbf37a19 100644
@@ -21795,6 +21795,14 @@ F:	Documentation/devicetree/bindings/media/i2c/ti,ds90*
 F:	drivers/media/i2c/ds90*
 F:	include/media/i2c/ds90*
 
+TI HDC302X HUMIDITY DRIVER
+M:	Javier Carrasco <[email protected]>
+M:	Li peiyu <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/iio/humidity/ti,hdc3020.yaml
+F:	drivers/iio/humidity/hdc3020.c
+
 TI ICSSG ETHERNET DRIVER (ICSSG)
 R:	MD Danish Anwar <[email protected]>
 R:	Roger Quadros <[email protected]>
drivers/iio/humidity/Kconfig +12 -0
index 2de5494e7c22..b15b7a3b66d5 100644
@@ -48,6 +48,18 @@ 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
+	select CRC8
+	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 +473 -0

473 lines not on this page · raw message

Signature · 1 line
2.39.2
#4 lore raw
Quoted 6 lines · Li peiyu

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.

Quoted 8 lines
---
  MAINTAINERS                    |   8 +
  drivers/iio/humidity/Kconfig   |  12 +
  drivers/iio/humidity/Makefile  |   1 +
  drivers/iio/humidity/hdc3020.c | 473 +++++++++++++++++++++++++++++++++

I was just trying to use this driver. Somehow the Makefile and Kconfig changes were lost when the patch was applied to the IIO tree.

maintainer
#5 lore raw
Quoted 15 lines · Lars-Peter Clausen
Quoted 6 lines · Li peiyu

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.

Quoted 8 lines

---
  MAINTAINERS                    |   8 + drivers/iio/humidity/Kconfig   |  12 + drivers/iio/humidity/Makefile  |   1 + drivers/iio/humidity/hdc3020.c | 473 +++++++++++++++++++++++++++++++++

Quoted 4 lines

I was just trying to use this driver. Somehow the Makefile and Kconfig changes were lost when the patch was applied to the IIO tree.

Apparently only the driver code was added. The new entry in the MAINTAINERS file is also missing.

Best regards,
Javier Carrasco

maintainer
#6 lore raw
Quoted 20 lines · On Sat, 20 Jan 2024 17:14:21 +0100 Javier Carrasco…
Quoted 15 lines · Lars-Peter Clausen
Quoted 6 lines · Li peiyu

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.

Quoted 8 lines

---
  MAINTAINERS                    |   8 + drivers/iio/humidity/Kconfig   |  12 + drivers/iio/humidity/Makefile  |   1 + drivers/iio/humidity/hdc3020.c | 473 +++++++++++++++++++++++++++++++++

Quoted 4 lines

I was just trying to use this driver. Somehow the Makefile and Kconfig changes were lost when the patch was applied to the IIO tree.

Quoted 5 lines

Apparently only the driver code was added. The new entry in the MAINTAINERS file is also missing.

Best regards,
Javier Carrasco

Gah, I clearly messed up. My guess is a messy merge that went wrong..

Anyhow, I'll post a patch to put this back in a few mins and pick it directly given it's just putting in the missing stuff from this patch.

That will be on the fixes-togreg branch of iio.git shortly.

Extra tags etc are fine, but I'm keen to get this into linux-next at least quickly so we get some testing before I send a fixes pull request (probably next weekend).

Sorry for the mess up!

Jonathan

author maintainer
#7 lore raw

PATCH v6 4/4 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.

---
changes in v6:
- remove items before "- const: ti,hdc3020".
- add vdd-supply to required.
changes in v4:
- removed unnecessary example.
- add vdd-supply to the example.
changes in v3:
- Use a fallback compatible.
changes in v2:
- change the maintainers to me.
- hdc3020,hdc3021,hdc3022 are compatible,I've changed the dirver.
- change the node name to humidity-sensor.

 .../bindings/iio/humidity/ti,hdc3020.yaml     | 55 +++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/humidity/ti,hdc3020.yaml
Documentation/devicetree/bindings/iio/humidity/ti,hdc3020.yaml new file +55 -0
new file mode 100644
index 000000000000..7f6d0f9edc75
@@ -0,0 +1,55 @@
+# 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:
+  - Li peiyu <[email protected]>
+  - Javier Carrasco <[email protected]>
+
+description:
+  https://www.ti.com/lit/ds/symlink/hdc3020.pdf
+
+  The HDC302x is an integrated capacitive based relative humidity (RH)
+  and temperature sensor.
+
+properties:
+  compatible:
+    oneOf:
+      - items:
+          - enum:
+              - ti,hdc3021
+              - ti,hdc3022
+          - const: ti,hdc3020
+      - const: ti,hdc3020
+
+  interrupts:
+    maxItems: 1
+
+  vdd-supply: true
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - vdd-supply
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        humidity-sensor@47 {
+            compatible = "ti,hdc3021", "ti,hdc3020";
+            reg = <0x47>;
+            vdd-supply = <&vcc_3v3>;
+        };
+    };
Signature · 1 line
2.34.1
maintainer
#9 lore raw
In reply to Li peiyu
Quoted 7 lines · On Mon, 11 Dec 2023 20:22:01 +0800 Li peiyu <[email protected]> wrote:

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.

Series applied to the togreg branch of iio.git but initially that's just pushed out as testing to let 0-day see if it can find anything we missed.

Thanks!

Jonathan

Quoted 76 lines

---
changes in v6:
sensor driver:
- Drop offset for humidity channel.
- Use put_unaligned_be16 to assign the 14-bit heater value.
- Remove error message if devm_action_or_reset() fails.
- Add eror message if devm_iio_device_register() fails.
dt-bindings:
- remove items before "- const: ti,hdc3020".
- add vdd-supply to required.
changes in v5:
iio ABI:
- Document _TROUGH as an info element.
sensor driver:
- Correct heater enable/disable commands
- Rearrang header files in alphabetical order.
- Change .info_mask_separate to BIT(IIO_CHAN_INFO_RAW).
- Add details to mutex comment.
- Add error handling for chan->type in read_raw call.
- Remove error message for devm_iio_device_register.
changes in v4:
iio core:
- Add an IIO_CHAN_INFO_TROUGH modifier for minimum values.
iio ABI:
- Document the new _TROUGH modifier.
sensor driver:
- Add MAINTAINERS.
- Use new IIO_CHAN_INFO_TROUGH modifier.
- Support the complete heater range.
- Remove measurement values from the data structure.
- Use guard(mutex)(...), make the code simpler
- Removed buffer mode and direct mode conversion code
- Minor coding-style fixes.
dt-bindings:
- removed unnecessary example
- add vdd-supply to the example
changes in v3:
sensor driver:
- Removed the custom ABI
- Give up calculating values in the driver
- Use read_avail callback to get available parameters
- Changed the scope of the lock to make the code more concise
- Fixed the code format issue
dt-bindings:
- Use a fallback compatible
changes in v2:
sensor driver:
- Added static modification to global variables
- change the methord to read peak value
dt-bindings:
- change the maintainers to me.
- hdc3020,hdc3021,hdc3022 are compatible,I've changed the dirver.
- change the node name to humidity-sensor.

---
Javier Carrasco (2):
iio: core: introduce trough modifier for minimum values
iio: ABI: document temperature and humidity peak/trough raw attributes

Li peiyu (2):
dt-bindings: iio: humidity: Add TI HDC302x support
iio: humidity: Add driver for TI HDC302x humidity sensors

 Documentation/ABI/testing/sysfs-bus-iio            |  13 +-
 .../bindings/iio/humidity/ti,hdc3020.yaml          |  55 +++
 MAINTAINERS                                        |   8 +
 drivers/iio/humidity/Kconfig                       |  12 +
 drivers/iio/humidity/Makefile                      |   1 +
 drivers/iio/humidity/hdc3020.c                     | 473 +++++++++++++++++++++
 drivers/iio/industrialio-core.c                    |   1 +
 include/linux/iio/types.h                          |   1 +
 8 files changed, 563 insertions(+), 1 deletion(-)

---
base-commit: 33cc938e65a98f1d29d0a18403dbbee050dcad9a

Best regards,