Re: [PATCH 2/2] hwmon: (aht10) Fix initialization commands and add DT support
From: Guenter Roeck
Date: Sun Feb 22 2026 - 10:45:02 EST
On 2/22/26 02:58, Hao Yu wrote:
Correct AHT20 initialization command sequence and
change DHT20 command format to 0bxxxxx notation.
That needs to explain what is wrong. The current initialization command
is 0b11100001. Changing it to 0b10111110 but does not explain why the old
value is incorrect. Something like "Per AHT20 datasheet, the initialization
command for AHT20 is 0b10111110" plus an explanation that the AHT10
initialization sequence does not work as intended.
Tested on rk3566_lckfb board with aht20 sensor connected at i2c-2 port.
Signed-off-by: Hao Yu <haoyufine@xxxxxxxxx>
Fixes: d2abcb5cc885 ("hwmon: (aht10) Add support for compatible aht20")
---
drivers/hwmon/aht10.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/aht10.c b/drivers/hwmon/aht10.c
index 007befdba977..c18332cc48ba 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
tab after AHT20_CMD_INIT
Thanks,
Guenter
+
+#define DHT20_CMD_INIT 0b01110001
/*
* Flags in the answer byte/command
@@ -60,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
@@ -341,7 +352,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;
@@ -375,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,