public inbox for linux-hwmon@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] Add AHT20 sensor bindings and fix driver initialization
@ 2026-02-22 17:03 Hao Yu
  2026-02-22 17:03 ` [PATCH v2 1/3] dt-bindings: hwmon: add aosong,aht10 family Hao Yu
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Hao Yu @ 2026-02-22 17:03 UTC (permalink / raw)
  To: linux, robh, krzk+dt, conor+dt
  Cc: jcdra1, akhilesh, linux-hwmon, devicetree, linux-kernel, Hao Yu

This patch series adds device tree binding documentation for Aosong
AHT10/AHT20 series sensors, fixes the initialization command sequence
for AHT20, and adds Device Tree support to the driver.

The AHT20 sensor was tested on a rk3566_lckfb board with the I2C-2 port.
Temperature and humidity readings are now accurate after fixing the
initialization command.

Changes in v2:
- Split the driver patch into two separate commits:
  - Patch 2/3: A fix for the initialization bug (includes Fixes tag).
  - Patch 3/3: A feature patch for adding Device Tree support.
- Improved the commit message for the initialization fix with a detailed
  explanation as requested by Guenter Roeck.
- Fixed indentation in aht10.c (ensured tab usage after macro definition).

Hao Yu (3):
  dt-bindings: hwmon: add aosong,aht10 family
  hwmon: (aht10) Fix initialization commands for AHT20
  hwmon: (aht10) Add Device Tree support

 .../bindings/hwmon/aosong,aht10.yaml          | 41 +++++++++++++++++++
 drivers/hwmon/aht10.c                         | 16 +++++++-
 2 files changed, 55 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/hwmon/aosong,aht10.yaml

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/3] dt-bindings: hwmon: add aosong,aht10 family
  2026-02-22 17:03 [PATCH v2 0/3] Add AHT20 sensor bindings and fix driver initialization Hao Yu
@ 2026-02-22 17:03 ` Hao Yu
  2026-02-23 10:32   ` Krzysztof Kozlowski
  2026-02-22 17:03 ` [PATCH v2 2/3] hwmon: (aht10) Fix initialization commands for AHT20 Hao Yu
  2026-02-22 17:03 ` [PATCH v2 3/3] hwmon: (aht10) Add Device Tree support Hao Yu
  2 siblings, 1 reply; 6+ messages in thread
From: Hao Yu @ 2026-02-22 17:03 UTC (permalink / raw)
  To: linux, robh, krzk+dt, conor+dt
  Cc: jcdra1, akhilesh, linux-hwmon, devicetree, linux-kernel, Hao Yu

Add device tree bindings for Aosong AHT10, AHT20 and DHT20 sensors.

Signed-off-by: Hao Yu <haoyufine@gmail.com>
---
 .../bindings/hwmon/aosong,aht10.yaml          | 41 +++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/hwmon/aosong,aht10.yaml

diff --git a/Documentation/devicetree/bindings/hwmon/aosong,aht10.yaml b/Documentation/devicetree/bindings/hwmon/aosong,aht10.yaml
new file mode 100644
index 000000000000..6eb3944ae3da
--- /dev/null
+++ b/Documentation/devicetree/bindings/hwmon/aosong,aht10.yaml
@@ -0,0 +1,41 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/aosong,aht10.yaml#
+$schema: http://devicetree.org/meta-schema.yaml#
+
+title: Aosong AHT10/AHT20/DHT20 Temperature and Humidity Sensor
+
+maintainers:
+  - Hao Yu <haoyufine@gmail.com>
+
+description: |
+  The Aosong AHT10, AHT20, and DHT20 are I2C humidity and temperature sensors.
+
+properties:
+  compatible:
+    enum:
+      - aosong,aht10
+      - aosong,aht20
+      - aosong,dht20
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        sensor@38 {
+            compatible = "aosong,aht20";
+            reg = <0x38>;
+        };
+    };
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/3] hwmon: (aht10) Fix initialization commands for AHT20
  2026-02-22 17:03 [PATCH v2 0/3] Add AHT20 sensor bindings and fix driver initialization Hao Yu
  2026-02-22 17:03 ` [PATCH v2 1/3] dt-bindings: hwmon: add aosong,aht10 family Hao Yu
@ 2026-02-22 17:03 ` Hao Yu
  2026-02-22 18:33   ` Guenter Roeck
  2026-02-22 17:03 ` [PATCH v2 3/3] hwmon: (aht10) Add Device Tree support Hao Yu
  2 siblings, 1 reply; 6+ messages in thread
From: Hao Yu @ 2026-02-22 17:03 UTC (permalink / raw)
  To: linux, robh, krzk+dt, conor+dt
  Cc: jcdra1, akhilesh, linux-hwmon, devicetree, linux-kernel, Hao Yu

According to the AHT20 datasheet (updated to V1.0 after the 2023.09
version), the initialization command for AHT20 is 0b10111110 (0xBE).
The previous sequence (0xE1) used in earlier versions is no longer
compatible with newer AHT20 sensors. Update the initialization
command to ensure the sensor is properly initialized.

Fixes: d2abcb5cc885 ("hwmon: (aht10) Add support for compatible aht20")
Signed-off-by: Hao Yu <haoyufine@gmail.com>
---
 drivers/hwmon/aht10.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/aht10.c b/drivers/hwmon/aht10.c
index 007befdba977..4ce019d2cc80 100644
--- a/drivers/hwmon/aht10.c
+++ b/drivers/hwmon/aht10.c
@@ -37,7 +37,9 @@
 #define AHT10_CMD_MEAS	0b10101100
 #define AHT10_CMD_RST	0b10111010
 
-#define DHT20_CMD_INIT	0x71
+#define AHT20_CMD_INIT	0b10111110
+
+#define DHT20_CMD_INIT	0b01110001
 
 /*
  * Flags in the answer byte/command
@@ -341,7 +343,7 @@ static int aht10_probe(struct i2c_client *client)
 		data->meas_size = AHT20_MEAS_SIZE;
 		data->crc8 = true;
 		crc8_populate_msb(crc8_table, AHT20_CRC8_POLY);
-		data->init_cmd = AHT10_CMD_INIT;
+		data->init_cmd = AHT20_CMD_INIT;
 		break;
 	case dht20:
 		data->meas_size = AHT20_MEAS_SIZE;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/3] hwmon: (aht10) Add Device Tree support
  2026-02-22 17:03 [PATCH v2 0/3] Add AHT20 sensor bindings and fix driver initialization Hao Yu
  2026-02-22 17:03 ` [PATCH v2 1/3] dt-bindings: hwmon: add aosong,aht10 family Hao Yu
  2026-02-22 17:03 ` [PATCH v2 2/3] hwmon: (aht10) Fix initialization commands for AHT20 Hao Yu
@ 2026-02-22 17:03 ` Hao Yu
  2 siblings, 0 replies; 6+ messages in thread
From: Hao Yu @ 2026-02-22 17:03 UTC (permalink / raw)
  To: linux, robh, krzk+dt, conor+dt
  Cc: jcdra1, akhilesh, linux-hwmon, devicetree, linux-kernel, Hao Yu

Add support for Device Tree probing by adding an of_match_table. This
allows the driver to be used with aosong,aht10, aosong,aht20, and
aosong,dht20 compatible strings in device tree files.

Signed-off-by: Hao Yu <haoyufine@gmail.com>
---
 drivers/hwmon/aht10.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/hwmon/aht10.c b/drivers/hwmon/aht10.c
index 4ce019d2cc80..66955395d058 100644
--- a/drivers/hwmon/aht10.c
+++ b/drivers/hwmon/aht10.c
@@ -62,6 +62,15 @@ static const struct i2c_device_id aht10_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, aht10_id);
 
+static const struct of_device_id aht10_of_match[] = {
+	{ .compatible = "aosong,aht10", .data = (void *)aht10 },
+	{ .compatible = "aosong,aht20", .data = (void *)aht20 },
+	{ .compatible = "aosong,dht20", .data = (void *)dht20 },
+	{}
+};
+
+MODULE_DEVICE_TABLE(of, aht10_of_match);
+
 /**
  *   struct aht10_data - All the data required to operate an AHT10/AHT20 chip
  *   @client: the i2c client associated with the AHT10/AHT20
@@ -377,6 +386,7 @@ static int aht10_probe(struct i2c_client *client)
 static struct i2c_driver aht10_driver = {
 	.driver = {
 		.name = "aht10",
+		.of_match_table = aht10_of_match,
 	},
 	.probe      = aht10_probe,
 	.id_table   = aht10_id,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/3] hwmon: (aht10) Fix initialization commands for AHT20
  2026-02-22 17:03 ` [PATCH v2 2/3] hwmon: (aht10) Fix initialization commands for AHT20 Hao Yu
@ 2026-02-22 18:33   ` Guenter Roeck
  0 siblings, 0 replies; 6+ messages in thread
From: Guenter Roeck @ 2026-02-22 18:33 UTC (permalink / raw)
  To: Hao Yu
  Cc: robh, krzk+dt, conor+dt, jcdra1, akhilesh, linux-hwmon,
	devicetree, linux-kernel

On Mon, Feb 23, 2026 at 01:03:31AM +0800, Hao Yu wrote:
> According to the AHT20 datasheet (updated to V1.0 after the 2023.09
> version), the initialization command for AHT20 is 0b10111110 (0xBE).
> The previous sequence (0xE1) used in earlier versions is no longer
> compatible with newer AHT20 sensors. Update the initialization
> command to ensure the sensor is properly initialized.
> 
> Fixes: d2abcb5cc885 ("hwmon: (aht10) Add support for compatible aht20")
> Signed-off-by: Hao Yu <haoyufine@gmail.com>

Applied, since htis is a fix which doewsn't depend on the devicetree patches.

Thanks,
Guenter

> ---
>  drivers/hwmon/aht10.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwmon/aht10.c b/drivers/hwmon/aht10.c
> index 007befdba977..4ce019d2cc80 100644
> --- a/drivers/hwmon/aht10.c
> +++ b/drivers/hwmon/aht10.c
> @@ -37,7 +37,9 @@
>  #define AHT10_CMD_MEAS	0b10101100
>  #define AHT10_CMD_RST	0b10111010
>  
> -#define DHT20_CMD_INIT	0x71
> +#define AHT20_CMD_INIT	0b10111110
> +
> +#define DHT20_CMD_INIT	0b01110001
>  
>  /*
>   * Flags in the answer byte/command
> @@ -341,7 +343,7 @@ static int aht10_probe(struct i2c_client *client)
>  		data->meas_size = AHT20_MEAS_SIZE;
>  		data->crc8 = true;
>  		crc8_populate_msb(crc8_table, AHT20_CRC8_POLY);
> -		data->init_cmd = AHT10_CMD_INIT;
> +		data->init_cmd = AHT20_CMD_INIT;
>  		break;
>  	case dht20:
>  		data->meas_size = AHT20_MEAS_SIZE;

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/3] dt-bindings: hwmon: add aosong,aht10 family
  2026-02-22 17:03 ` [PATCH v2 1/3] dt-bindings: hwmon: add aosong,aht10 family Hao Yu
@ 2026-02-23 10:32   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2026-02-23 10:32 UTC (permalink / raw)
  To: Hao Yu
  Cc: linux, robh, krzk+dt, conor+dt, jcdra1, akhilesh, linux-hwmon,
	devicetree, linux-kernel

On Mon, Feb 23, 2026 at 01:03:30AM +0800, Hao Yu wrote:
> Add device tree bindings for Aosong AHT10, AHT20 and DHT20 sensors.
> 
> Signed-off-by: Hao Yu <haoyufine@gmail.com>
> ---
>  .../bindings/hwmon/aosong,aht10.yaml          | 41 +++++++++++++++++++

This should go to trivial-devices schema.

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-02-23 10:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-22 17:03 [PATCH v2 0/3] Add AHT20 sensor bindings and fix driver initialization Hao Yu
2026-02-22 17:03 ` [PATCH v2 1/3] dt-bindings: hwmon: add aosong,aht10 family Hao Yu
2026-02-23 10:32   ` Krzysztof Kozlowski
2026-02-22 17:03 ` [PATCH v2 2/3] hwmon: (aht10) Fix initialization commands for AHT20 Hao Yu
2026-02-22 18:33   ` Guenter Roeck
2026-02-22 17:03 ` [PATCH v2 3/3] hwmon: (aht10) Add Device Tree support Hao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox