From nobody Mon Feb 9 01:12:09 2026 Received: from smtp1.iitb.ac.in (smtpd9.iitb.ac.in [103.21.126.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E24913635E for ; Sun, 2 Nov 2025 09:43:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.21.126.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762076628; cv=none; b=rweDd5bjNJY5/OXUvU8bmxwQQHPM8JpsJBOWnrpjbpvsnu+zJ1fd7KZrVe4OgkAaNi8gPWyweb1QIktTXPUG69x5+wVcerQcL0vuAY3ZZET8bVrqmGUtnObbQUk2iQXwniVDxa+MSxqUX7aNDo3jl8yKQKd1k2yNDsfOCuXEAxM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762076628; c=relaxed/simple; bh=uKq8BRZL1bcOVPXxA803oJ6yh3VoZLWokRQjiujEvJQ=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=Srox7bELOaAus23FdtDQ+WeadkOf1ODDrTm7CdGe2egDBloTFu9Zg2FNyVOzTt7BCAHOg60aDANdvJE4ERFlqvC58DaU8EOZSgEvdKrRg5iHGmMUUNGGz6F6LtX5xjlHNll88jsJCtt9iMRzAL7K53rhLL5IGNcSCsDCQ+dN9YQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ee.iitb.ac.in; spf=pass smtp.mailfrom=ee.iitb.ac.in; dkim=pass (1024-bit key) header.d=iitb.ac.in header.i=@iitb.ac.in header.b=TgGl2Y+X; arc=none smtp.client-ip=103.21.126.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ee.iitb.ac.in Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ee.iitb.ac.in Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=iitb.ac.in header.i=@iitb.ac.in header.b="TgGl2Y+X" Received: from ldns1.iitb.ac.in (ldns1.iitb.ac.in [10.200.12.1]) by smtp1.iitb.ac.in (Postfix) with SMTP id 34F30104C1E6 for ; Sun, 2 Nov 2025 15:13:30 +0530 (IST) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.iitb.ac.in 34F30104C1E6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iitb.ac.in; s=mail; t=1762076610; bh=uKq8BRZL1bcOVPXxA803oJ6yh3VoZLWokRQjiujEvJQ=; h=Date:From:To:Cc:Subject:From; b=TgGl2Y+X2LmW76tTSvUewdL3D744S+S/G31yGxT7ZUZMZvGwEuIY0MMlR8C6EFB86 jpcXqLA8qvlo4HNy8MgQvdz3AiaF1Ru/ycjT9zbRxGBWF5S+EVcwQhSjYAWvXPeiXt FyyMw4yg1IkkGfqOzTfQAxHww7KAnMGyZmqIxSKg= Received: (qmail 2979 invoked by uid 510); 2 Nov 2025 15:13:30 +0530 X-Qmail-Scanner-Diagnostics: from 10.200.1.25 by ldns1 (envelope-from , uid 501) with qmail-scanner-2.11 spamassassin: 3.4.1. mhr: 1.0. {clamdscan: 0.101.4/26439} Clear:RC:1(10.200.1.25):SA:0(0.0/7.0):. Processed in 3.55476 secs; 02 Nov 2025 15:13:30 +0530 X-Spam-Level: X-Spam-Pyzor: Reported 0 times. X-Envelope-From: akhilesh@ee.iitb.ac.in X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received: from unknown (HELO ldns1.iitb.ac.in) (10.200.1.25) by ldns1.iitb.ac.in with SMTP; 2 Nov 2025 15:13:26 +0530 Received: from bhairav.ee.iitb.ac.in (bhairav.ee.iitb.ac.in [10.107.1.1]) by ldns1.iitb.ac.in (Postfix) with ESMTP id 11A3A360079; Sun, 2 Nov 2025 15:13:26 +0530 (IST) Received: from bhairav-test.ee.iitb.ac.in (bhairav.ee.iitb.ac.in [10.107.1.1]) (Authenticated sender: akhilesh) by bhairav.ee.iitb.ac.in (Postfix) with ESMTPSA id E00C21E814DC; Sun, 2 Nov 2025 15:13:25 +0530 (IST) Date: Sun, 2 Nov 2025 15:13:20 +0530 From: Akhilesh Patil To: linux@roeck-us.net, jcdra1@gmail.com, kiriyatsenko@gmail.com, afd@ti.com Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, akhileshpatilvnit@gmail.com, skhan@linuxfoundation.org Subject: [PATCH] hwmon: (aht10) Add support for dht20 Message-ID: <2025112-94320-906858@bhairav-test.ee.iitb.ac.in> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support for dht20 temperature and humidity sensor from Aosong. Modify aht10 driver to handle different init command for dht20 sensor by adding init_cmd entry in the driver data. dht20 sensor is compatible with aht10 hwmon driver with this change. Tested on TI am62x SK board with dht20 sensor connected at i2c-2 port. Signed-off-by: Akhilesh Patil --- Documentation/hwmon/aht10.rst | 10 +++++++++- drivers/hwmon/Kconfig | 6 +++--- drivers/hwmon/aht10.c | 19 ++++++++++++++++--- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/Documentation/hwmon/aht10.rst b/Documentation/hwmon/aht10.rst index 213644b4ecba..7903b6434326 100644 --- a/Documentation/hwmon/aht10.rst +++ b/Documentation/hwmon/aht10.rst @@ -20,6 +20,14 @@ Supported chips: =20 English: http://www.aosong.com/userfiles/files/media/Data%20Sheet%20= AHT20.pdf =20 + * Aosong DHT20 + + Prefix: 'dht20' + + Addresses scanned: None + + Datasheet: https://www.digikey.co.nz/en/htmldatasheets/production/9184= 855/0/0/1/101020932 + Author: Johannes Cornelis Draaijer =20 =20 @@ -33,7 +41,7 @@ The address of this i2c device may only be 0x38 Special Features ---------------- =20 -AHT20 has additional CRC8 support which is sent as the last byte of the se= nsor +AHT20, DHT20 has additional CRC8 support which is sent as the last byte of= the sensor values. =20 Usage Notes diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 2760feb9f83b..2a71b6e834b0 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -245,12 +245,12 @@ config SENSORS_ADT7475 will be called adt7475. =20 config SENSORS_AHT10 - tristate "Aosong AHT10, AHT20" + tristate "Aosong AHT10, AHT20, DHT20" depends on I2C select CRC8 help - If you say yes here, you get support for the Aosong AHT10 and AHT20 - temperature and humidity sensors + If you say yes here, you get support for the Aosong AHT10, AHT20 and + DHT20 temperature and humidity sensors =20 This driver can also be built as a module. If so, the module will be called aht10. diff --git a/drivers/hwmon/aht10.c b/drivers/hwmon/aht10.c index d1c55e2eb479..a153282eef6a 100644 --- a/drivers/hwmon/aht10.c +++ b/drivers/hwmon/aht10.c @@ -37,6 +37,8 @@ #define AHT10_CMD_MEAS 0b10101100 #define AHT10_CMD_RST 0b10111010 =20 +#define DHT20_CMD_INIT 0x71 + /* * Flags in the answer byte/command */ @@ -48,11 +50,12 @@ =20 #define AHT10_MAX_POLL_INTERVAL_LEN 30 =20 -enum aht10_variant { aht10, aht20 }; +enum aht10_variant { aht10, aht20, dht20}; =20 static const struct i2c_device_id aht10_id[] =3D { { "aht10", aht10 }, { "aht20", aht20 }, + { "dht20", dht20 }, { }, }; MODULE_DEVICE_TABLE(i2c, aht10_id); @@ -77,6 +80,7 @@ MODULE_DEVICE_TABLE(i2c, aht10_id); * AHT10/AHT20 * @crc8: crc8 support flag * @meas_size: measurements data size + * @init_cmd: Initialization command */ =20 struct aht10_data { @@ -92,6 +96,7 @@ struct aht10_data { int humidity; bool crc8; unsigned int meas_size; + u8 init_cmd; }; =20 /* @@ -101,13 +106,13 @@ struct aht10_data { */ static int aht10_init(struct aht10_data *data) { - const u8 cmd_init[] =3D {AHT10_CMD_INIT, AHT10_CAL_ENABLED | AHT10_MODE_C= YC, + const u8 cmd_init[] =3D {data->init_cmd, AHT10_CAL_ENABLED | AHT10_MODE_C= YC, 0x00}; int res; u8 status; struct i2c_client *client =3D data->client; =20 - res =3D i2c_master_send(client, cmd_init, 3); + res =3D i2c_master_send(client, cmd_init, sizeof(cmd_init)); if (res < 0) return res; =20 @@ -352,9 +357,17 @@ static int aht10_probe(struct i2c_client *client) data->meas_size =3D AHT20_MEAS_SIZE; data->crc8 =3D true; crc8_populate_msb(crc8_table, AHT20_CRC8_POLY); + data->init_cmd =3D AHT10_CMD_INIT; + break; + case dht20: + data->meas_size =3D AHT20_MEAS_SIZE; + data->crc8 =3D true; + crc8_populate_msb(crc8_table, AHT20_CRC8_POLY); + data->init_cmd =3D DHT20_CMD_INIT; break; default: data->meas_size =3D AHT10_MEAS_SIZE; + data->init_cmd =3D AHT10_CMD_INIT; break; } =20 --=20 2.34.1