On Thu, May 11, 2023 at 10:26:33PM +0200, Kirill Yatsenko wrote: > Add support for compatible AHT20 temperature/humidity sensor. The only > software difference between the two is that AHT20 has additional crc8 > byte. > > It seems like AHT15 is also supported by the driver but it wasn't > verified and tested yet. > > Tested on Beaglebone black rev C. > > Signed-off-by: Kirill Yatsenko <kiriyatsenko@xxxxxxxxx> > --- > Documentation/hwmon/aht10.rst | 20 +++++++++---- > drivers/hwmon/Kconfig | 11 +++++-- > drivers/hwmon/aht10.c | 54 ++++++++++++++++++++++++++++------- > 3 files changed, 68 insertions(+), 17 deletions(-) > > diff --git a/Documentation/hwmon/aht10.rst b/Documentation/hwmon/aht10.rst > index 4e198c5eb683..213644b4ecba 100644 > --- a/Documentation/hwmon/aht10.rst > +++ b/Documentation/hwmon/aht10.rst > @@ -5,32 +5,42 @@ Kernel driver aht10 > > Supported chips: > > - * Aosong AHT10 > + * Aosong AHT10/AHT20 > > Prefix: 'aht10' > > Addresses scanned: None > > - Datasheet: > + Datasheet(AHT10): > > Chinese: http://www.aosong.com/userfiles/files/media/AHT10%E4%BA%A7%E5%93%81%E6%89%8B%E5%86%8C%20A3%2020201210.pdf > English: https://server4.eca.ir/eshop/AHT10/Aosong_AHT10_en_draft_0c.pdf > > + Datasheet(AHT20): > + > + English: http://www.aosong.com/userfiles/files/media/Data%20Sheet%20AHT20.pdf > + > Author: Johannes Cornelis Draaijer <jcdra1@xxxxxxxxx> > > > Description > ----------- > > -The AHT10 is a Temperature and Humidity sensor > +The AHT10/AHT20 is a Temperature and Humidity sensor > > The address of this i2c device may only be 0x38 > > +Special Features > +---------------- > + > +AHT20 has additional CRC8 support which is sent as the last byte of the sensor > +values. > + > Usage Notes > ----------- > > -This driver does not probe for AHT10 devices, as there is no reliable > -way to determine if an i2c chip is or isn't an AHT10. The device has > +This driver does not probe for AHT10/ATH20 devices, as there is no reliable > +way to determine if an i2c chip is or isn't an AHT10/AHT20. The device has > to be instantiated explicitly with the address 0x38. See > Documentation/i2c/instantiating-devices.rst for details. > > diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig > index fc640201a2de..ccb295312102 100644 > --- a/drivers/hwmon/Kconfig > +++ b/drivers/hwmon/Kconfig > @@ -255,15 +255,22 @@ config SENSORS_ADT7475 > will be called adt7475. > > config SENSORS_AHT10 > - tristate "Aosong AHT10" > + tristate "Aosong AHT10, AHT20" > depends on I2C > help > - If you say yes here, you get support for the Aosong AHT10 > + If you say yes here, you get support for the Aosong AHT10 and AHT20 > temperature and humidity sensors > > This driver can also be built as a module. If so, the module > will be called aht10. > > +config SENSORS_AHT20_CRC > + bool "Aosong AHT20 crc8 check" > + depends on SENSORS_AHT10 > + select CRC8 > + help > + If you say yes here, you get support for the Aosong AHT20 CRC8 check > + This is not an appropriate configuration flag. aht20 needs to be added to aht10_id, and the code needs to use a flag in driver data (struct aht10_data) to determine if the crc check needs to be applied or not. There must be no related ifdefs in the code. Guenter