Skip to content

Commit 1e50769

Browse files
joshermarpopcornmix
authored andcommitted
hwmon: aht10: Fix AHT20 initialization
The existing driver claims AHT20 support in i2c_device_id, but fails to: 1. Use the correct init command (0xBE for AHT20 vs 0xE1 for AHT10) 2. Omit AHT10_MODE_CYC which AHT20 doesn't support/require Add proper initialization sequence and include "aosong,aht20" in the device tree match table to fully support the AHT20. Signed-off-by: Josh Martinez <8892161+joshermar@users.noreply.github.com>
1 parent 1ea4143 commit 1e50769

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

drivers/hwmon/aht10.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
#define AHT10_CMD_MEAS 0b10101100
3838
#define AHT10_CMD_RST 0b10111010
3939

40+
#define AHT20_CMD_INIT 0b10111110
41+
4042
/*
4143
* Flags in the answer byte/command
4244
*/
@@ -59,6 +61,7 @@ MODULE_DEVICE_TABLE(i2c, aht10_id);
5961

6062
static const struct of_device_id aht10_of_id[] = {
6163
{ .compatible = "aosong,aht10", },
64+
{ .compatible = "aosong,aht20", },
6265
{ }
6366
};
6467
MODULE_DEVICE_TABLE(of, aht10_of_id);
@@ -107,8 +110,13 @@ struct aht10_data {
107110
*/
108111
static int aht10_init(struct aht10_data *data)
109112
{
110-
const u8 cmd_init[] = {AHT10_CMD_INIT, AHT10_CAL_ENABLED | AHT10_MODE_CYC,
111-
0x00};
113+
u8 cmd_init[] = {AHT10_CMD_INIT, AHT10_CAL_ENABLED | AHT10_MODE_CYC, 0x00};
114+
115+
if (data->crc8) { /* AHT20 */
116+
cmd_init[0] = AHT20_CMD_INIT;
117+
cmd_init[1] = AHT10_CAL_ENABLED;
118+
}
119+
112120
int res;
113121
u8 status;
114122
struct i2c_client *client = data->client;

0 commit comments

Comments
 (0)