diff mbox series

[v9,1/2] iio: humidity: Add TI HDC20x0 support

Message ID 86d053d1re.fsf@norphonic.com (mailing list archive)
State New, archived
Headers show
Series [v9,1/2] iio: humidity: Add TI HDC20x0 support | expand

Commit Message

Eugene Zaikonnikov July 10, 2020, 11:53 a.m. UTC
Add support for HDC2010/2080 driver and sysfs documentation for its
heater element.

HDC2010 is an integrated high-accuracy humidity and temperature sensor
with very low power consumption. The device includes a resistive heating
element. The temperature range is -40C to 125C with 0.2C
accuracy. Humidity measurement is 0 to 100% with 2% RH accuracy.

Signed-off-by: Eugene Zaikonnikov <ez@norphonic.com>

Comments

Andy Shevchenko July 11, 2020, 3:16 p.m. UTC | #1
On Fri, Jul 10, 2020 at 2:54 PM Eugene Zaikonnikov <ez@norphonic.com> wrote:
>
> Add support for HDC2010/2080 driver and sysfs documentation for its
> heater element.
>
> HDC2010 is an integrated high-accuracy humidity and temperature sensor
> with very low power consumption. The device includes a resistive heating
> element. The temperature range is -40C to 125C with 0.2C
> accuracy. Humidity measurement is 0 to 100% with 2% RH accuracy.
>
> Signed-off-by: Eugene Zaikonnikov <ez@norphonic.com>

You have to use Git tools, such as `git format-patch ...` followed by
`git send-email ...`
Attachments are very hard to review.
Andy Shevchenko July 11, 2020, 3:27 p.m. UTC | #2
On Fri, Jul 10, 2020 at 2:54 PM Eugene Zaikonnikov <ez@norphonic.com> wrote:
>
> Add support for HDC2010/2080 driver and sysfs documentation for its
> heater element.
>
> HDC2010 is an integrated high-accuracy humidity and temperature sensor
> with very low power consumption. The device includes a resistive heating
> element. The temperature range is -40C to 125C with 0.2C
> accuracy. Humidity measurement is 0 to 100% with 2% RH accuracy.

Now, some almost context-less comments to the contribution.

Please, use Datasheet tag(s) here with URL(s) to the datasheet(s).
Also, be sure you are using https (note S) everywhere.

Datasheet: https://...
Datasheet: ...

> Signed-off-by: Eugene Zaikonnikov <ez@norphonic.com>

1. No need to put file name into the file
2. Missed at least bits.h inclusion
3. Keep comma in HDC2010_GROUP_HUMIDITY
4. IIO_CONST_ATTR can be one line, but hey don't we have IIO core to
take care of it?
5. Use traditional pattern

if (ret)
  return ret;

data->drdy_config = tmp;

return 0;

6. Indent better

if (!i2c_check_functionality(client->adapter,
    I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_I2C))

(or split last line above by operand per line or alike)

7. Drop unneeded casting
tmp = (data->measurement_config & ~HDC2010_MEAS_CONF) | HDC2010_MEAS_TRIG;

8. It's one line
ret = i2c_smbus_write_byte_data(client,
    HDC2010_REG_MEASUREMENT_CONF, tmp);

Ditto:
dev_warn(&client->dev, "Unable to restore default AMM\n");

In general it doesn't look bad!
Jonathan Cameron July 12, 2020, 10:54 a.m. UTC | #3
On Sat, 11 Jul 2020 18:27:09 +0300
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Fri, Jul 10, 2020 at 2:54 PM Eugene Zaikonnikov <ez@norphonic.com> wrote:
> >
> > Add support for HDC2010/2080 driver and sysfs documentation for its
> > heater element.
> >
> > HDC2010 is an integrated high-accuracy humidity and temperature sensor
> > with very low power consumption. The device includes a resistive heating
> > element. The temperature range is -40C to 125C with 0.2C
> > accuracy. Humidity measurement is 0 to 100% with 2% RH accuracy.  
> 
> Now, some almost context-less comments to the contribution.
> 
> Please, use Datasheet tag(s) here with URL(s) to the datasheet(s).
> Also, be sure you are using https (note S) everywhere.
> 
> Datasheet: https://...
> Datasheet: ...
> 
> > Signed-off-by: Eugene Zaikonnikov <ez@norphonic.com>  
> 
> 1. No need to put file name into the file
> 2. Missed at least bits.h inclusion
> 3. Keep comma in HDC2010_GROUP_HUMIDITY
> 4. IIO_CONST_ATTR can be one line, but hey don't we have IIO core to
> take care of it?

For that one, we could indeed use the read_avail callback here
for the out_current_heater_raw_available. I've not yet started insisting
on this because of the huge number of drivers that predate introduction of
that stuff to the core and as a result a lack of good examples.
Eugene, if you are happy to change this one over to that and hence act
as an example it would be great!

> 5. Use traditional pattern
> 
> if (ret)
>   return ret;
> 
> data->drdy_config = tmp;
> 
> return 0;
> 
> 6. Indent better
> 
> if (!i2c_check_functionality(client->adapter,
>     I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_I2C))
> 
> (or split last line above by operand per line or alike)
> 
> 7. Drop unneeded casting
> tmp = (data->measurement_config & ~HDC2010_MEAS_CONF) | HDC2010_MEAS_TRIG;
> 
> 8. It's one line
> ret = i2c_smbus_write_byte_data(client,
>     HDC2010_REG_MEASUREMENT_CONF, tmp);
> 
> Ditto:
> dev_warn(&client->dev, "Unable to restore default AMM\n");
> 
> In general it doesn't look bad!
> 

Thanks,

Jonathan
Eugene Zaikonnikov Aug. 3, 2020, 2:43 p.m. UTC | #4
Andy,

Thanks for the comments, going to fix the style/indentation as
suggested.

Sorry for the attachments, it was an accident.

> On Fri, Jul 10, 2020 at 2:54 PM Eugene Zaikonnikov <ez@norphonic.com> wrote:

[...]

> 8. It's one line
> ret = i2c_smbus_write_byte_data(client,
>     HDC2010_REG_MEASUREMENT_CONF, tmp);
>
> Ditto:
> dev_warn(&client->dev, "Unable to restore default AMM\n");
>
Must be misunderstanding something, as neither of these fits 80 column
fill if made into one line. Found also couple other places I need in
fact to wrap down to 80.

--
Regards,

  Eugene Zaikonnikov

  Norphonic AS
  Tel: +47 98 23 97 73
Andy Shevchenko Aug. 3, 2020, 4:37 p.m. UTC | #5
On Mon, Aug 3, 2020 at 5:44 PM Eugene Zaikonnikov <ez@norphonic.com> wrote:

> Sorry for the attachments, it was an accident.
I hope the next version will be sent properly.

> > On Fri, Jul 10, 2020 at 2:54 PM Eugene Zaikonnikov <ez@norphonic.com> wrote:
>
> [...]
>
> > 8. It's one line
> > ret = i2c_smbus_write_byte_data(client,
> >     HDC2010_REG_MEASUREMENT_CONF, tmp);
> >
> > Ditto:
> > dev_warn(&client->dev, "Unable to restore default AMM\n");
> >
> Must be misunderstanding something, as neither of these fits 80 column
> fill if made into one line. Found also couple other places I need in
> fact to wrap down to 80.

For how many? And since it's a new driver you may use 100.
Besides that there is no limitation for the messages for a long time
(see dev_warn() example above).
Eugene Zaikonnikov Aug. 4, 2020, 10:23 a.m. UTC | #6
Hello,

Jonathan Cameron <jic23@kernel.org> writes:

> On Sat, 11 Jul 2020 18:27:09 +0300
> Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
>

[...]

>> 4. IIO_CONST_ATTR can be one line, but hey don't we have IIO core to
>> take care of it?
>
> For that one, we could indeed use the read_avail callback here
> for the out_current_heater_raw_available. I've not yet started insisting
> on this because of the huge number of drivers that predate introduction of
> that stuff to the core and as a result a lack of good examples.
> Eugene, if you are happy to change this one over to that and hence act
> as an example it would be great!
>
Just looked into that.

We use this driver here with trees as early as 4.9.11, and it does not
appear to have this callback in iio_info yet. Hope it's OK as it is in
this iteration.

--
Regards,

  Eugene Zaikonnikov

  Norphonic AS
  Tel: +47 98 23 97 73
Jonathan Cameron Aug. 6, 2020, 6:46 p.m. UTC | #7
On Tue, 04 Aug 2020 12:23:56 +0200
Eugene Zaikonnikov <ez@norphonic.com> wrote:

> Hello,
> 
> Jonathan Cameron <jic23@kernel.org> writes:
> 
> > On Sat, 11 Jul 2020 18:27:09 +0300
> > Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> >  
> 
> [...]
> 
> >> 4. IIO_CONST_ATTR can be one line, but hey don't we have IIO core to
> >> take care of it?  
> >
> > For that one, we could indeed use the read_avail callback here
> > for the out_current_heater_raw_available. I've not yet started insisting
> > on this because of the huge number of drivers that predate introduction of
> > that stuff to the core and as a result a lack of good examples.
> > Eugene, if you are happy to change this one over to that and hence act
> > as an example it would be great!
> >  
> Just looked into that.
> 
> We use this driver here with trees as early as 4.9.11, and it does not
> appear to have this callback in iio_info yet. Hope it's OK as it is in
> this iteration.
OK.   It is more than possible that someone will post patches tidying
that up though and I'm not going to reject them to make life easier
for your older trees.  For now, put a note in the commit log though
so I don't forget it.

Thanks,

Jonathan

> 
> --
> Regards,
> 
>   Eugene Zaikonnikov
> 
>   Norphonic AS
>   Tel: +47 98 23 97 73
Eugene Zaikonnikov Aug. 7, 2020, 7:28 a.m. UTC | #8
Hi Jonathan,

Jonathan Cameron <jic23@kernel.org> writes:

> On Tue, 04 Aug 2020 12:23:56 +0200
> Eugene Zaikonnikov <ez@norphonic.com> wrote:

[...]

>> We use this driver here with trees as early as 4.9.11, and it does not
>> appear to have this callback in iio_info yet. Hope it's OK as it is in
>> this iteration.
> OK.   It is more than possible that someone will post patches tidying
> that up though and I'm not going to reject them to make life easier
> for your older trees.  For now, put a note in the commit log though
> so I don't forget it.
>
That's reasonable. We didn't plan to sit on 4.9.x for so long and we'll
eventually move to newer trees on all products here too. I may as well
tidy this part up myself later in the year, along with fuller support
for device features.

--
Regards,

  Eugene Zaikonnikov

  Norphonic AS
  Tel: +47 98 23 97 73
diff mbox series

Patch

diff -uprN -X linux-5.3.8/Documentation/dontdiff linux-5.3.8/Documentation/ABI/testing/sysfs-bus-iio-humidity-hdc2010 linux-5.3.8_hdc2010/Documentation/ABI/testing/sysfs-bus-iio-humidity-hdc2010
--- linux-5.3.8/Documentation/ABI/testing/sysfs-bus-iio-humidity-hdc2010	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.3.8_hdc2010/Documentation/ABI/testing/sysfs-bus-iio-humidity-hdc2010	2019-12-02 11:09:25.803326999 +0100
@@ -0,0 +1,9 @@ 
+What:		/sys/bus/iio/devices/iio:deviceX/out_current_heater_raw
+What:		/sys/bus/iio/devices/iio:deviceX/out_current_heater_raw_available
+KernelVersion:	5.3.8
+Contact:	linux-iio@vger.kernel.org
+Description:
+		Controls the heater device within the humidity sensor to get
+		rid of excess condensation.
+
+		Valid control values are 0 = OFF, and 1 = ON.
diff -uprN -X linux-5.3.8/Documentation/dontdiff linux-5.3.8/drivers/iio/humidity/hdc2010.c linux-5.3.8_hdc2010/drivers/iio/humidity/hdc2010.c
--- linux-5.3.8/drivers/iio/humidity/hdc2010.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-5.3.8_hdc2010/drivers/iio/humidity/hdc2010.c	2020-07-01 16:14:46.670806646 +0200
@@ -0,0 +1,354 @@ 
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * hdc2010.c - Support for the TI HDC2010 and HDC2080
+ * temperature + relative humidity sensors
+ *
+ * Copyright (C) 2020 Norphonic AS
+ * Author: Eugene Zaikonnikov <ez@norphonic.com>
+ *
+ * Datasheets:
+ * http://www.ti.com/product/HDC2010/datasheet
+ * http://www.ti.com/product/HDC2080/datasheet
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/i2c.h>
+
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+
+#define HDC2010_REG_TEMP_LOW			0x00
+#define HDC2010_REG_TEMP_HIGH			0x01
+#define HDC2010_REG_HUMIDITY_LOW		0x02
+#define HDC2010_REG_HUMIDITY_HIGH		0x03
+#define HDC2010_REG_INTERRUPT_DRDY		0x04
+#define HDC2010_REG_TEMP_MAX			0x05
+#define HDC2010_REG_HUMIDITY_MAX		0x06
+#define HDC2010_REG_INTERRUPT_EN		0x07
+#define HDC2010_REG_TEMP_OFFSET_ADJ		0x08
+#define HDC2010_REG_HUMIDITY_OFFSET_ADJ		0x09
+#define HDC2010_REG_TEMP_THR_L			0x0a
+#define HDC2010_REG_TEMP_THR_H			0x0b
+#define HDC2010_REG_RH_THR_L			0x0c
+#define HDC2010_REG_RH_THR_H			0x0d
+#define HDC2010_REG_RESET_DRDY_INT_CONF		0x0e
+#define HDC2010_REG_MEASUREMENT_CONF		0x0f
+
+#define HDC2010_MEAS_CONF			GENMASK(2, 1)
+#define HDC2010_MEAS_TRIG			BIT(0)
+#define HDC2010_HEATER_EN			BIT(3)
+#define HDC2010_AMM				GENMASK(6, 4)
+
+struct hdc2010_data {
+	struct i2c_client *client;
+	struct mutex lock;
+	u8 measurement_config;
+	u8 interrupt_config;
+	u8 drdy_config;
+};
+
+enum hdc2010_addr_groups {
+	HDC2010_GROUP_TEMP = 0,
+	HDC2010_GROUP_HUMIDITY
+};
+
+struct hdc2010_reg_record {
+	unsigned long primary;
+	unsigned long peak;
+};
+
+static const struct hdc2010_reg_record hdc2010_reg_translation[] = {
+	[HDC2010_GROUP_TEMP] = {
+		.primary = HDC2010_REG_TEMP_LOW,
+		.peak = HDC2010_REG_TEMP_MAX,
+	},
+	[HDC2010_GROUP_HUMIDITY] = {
+		.primary = HDC2010_REG_HUMIDITY_LOW,
+		.peak = HDC2010_REG_HUMIDITY_MAX,
+	},
+};
+
+static IIO_CONST_ATTR(out_current_heater_raw_available,
+		"0 1");
+
+static struct attribute *hdc2010_attributes[] = {
+	&iio_const_attr_out_current_heater_raw_available.dev_attr.attr,
+	NULL
+};
+
+static const struct attribute_group hdc2010_attribute_group = {
+	.attrs = hdc2010_attributes,
+};
+
+static const struct iio_chan_spec hdc2010_channels[] = {
+	{
+		.type = IIO_TEMP,
+		.address = HDC2010_GROUP_TEMP,
+		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+			BIT(IIO_CHAN_INFO_PEAK) |
+			BIT(IIO_CHAN_INFO_OFFSET) |
+			BIT(IIO_CHAN_INFO_SCALE),
+	},
+	{
+		.type = IIO_HUMIDITYRELATIVE,
+		.address = HDC2010_GROUP_HUMIDITY,
+		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+			BIT(IIO_CHAN_INFO_PEAK) |
+			BIT(IIO_CHAN_INFO_SCALE),
+	},
+	{
+		.type = IIO_CURRENT,
+		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+		.extend_name = "heater",
+		.output = 1,
+	},
+};
+
+static int hdc2010_update_drdy_config(struct hdc2010_data *data,
+					     char mask, char val)
+{
+	u8 tmp = (~mask & data->drdy_config) | val;
+	int ret;
+
+	ret = i2c_smbus_write_byte_data(data->client,
+					HDC2010_REG_RESET_DRDY_INT_CONF, tmp);
+	if (!ret)
+		data->drdy_config = tmp;
+
+	return ret;
+}
+
+static int hdc2010_get_prim_measurement_word(struct hdc2010_data *data,
+					     struct iio_chan_spec const *chan)
+{
+	struct i2c_client *client = data->client;
+	s32 ret;
+
+	ret = i2c_smbus_read_word_data(client,
+			hdc2010_reg_translation[chan->address].primary);
+
+	if (ret < 0)
+		dev_err(&client->dev, "Could not read sensor measurement word\n");
+
+	return ret;
+}
+
+static int hdc2010_get_peak_measurement_byte(struct hdc2010_data *data,
+					     struct iio_chan_spec const *chan)
+{
+	struct i2c_client *client = data->client;
+	s32 ret;
+
+	ret = i2c_smbus_read_byte_data(client,
+			hdc2010_reg_translation[chan->address].peak);
+
+	if (ret < 0)
+		dev_err(&client->dev, "Could not read sensor measurement byte\n");
+
+	return ret;
+}
+
+static int hdc2010_get_heater_status(struct hdc2010_data *data)
+{
+	return !!(data->drdy_config & HDC2010_HEATER_EN);
+}
+
+static int hdc2010_read_raw(struct iio_dev *indio_dev,
+			    struct iio_chan_spec const *chan, int *val,
+			    int *val2, long mask)
+{
+	struct hdc2010_data *data = iio_priv(indio_dev);
+
+	switch (mask) {
+	case IIO_CHAN_INFO_RAW: {
+		int ret;
+
+		if (chan->type == IIO_CURRENT) {
+			*val = hdc2010_get_heater_status(data);
+			return IIO_VAL_INT;
+		}
+		ret = iio_device_claim_direct_mode(indio_dev);
+		if (ret)
+			return ret;
+		mutex_lock(&data->lock);
+		ret = hdc2010_get_prim_measurement_word(data, chan);
+		mutex_unlock(&data->lock);
+		iio_device_release_direct_mode(indio_dev);
+		if (ret < 0)
+			return ret;
+		*val = ret;
+		return IIO_VAL_INT;
+	}
+	case IIO_CHAN_INFO_PEAK: {
+		int ret;
+
+		ret = iio_device_claim_direct_mode(indio_dev);
+		if (ret)
+			return ret;
+		mutex_lock(&data->lock);
+		ret = hdc2010_get_peak_measurement_byte(data, chan);
+		mutex_unlock(&data->lock);
+		iio_device_release_direct_mode(indio_dev);
+		if (ret < 0)
+			return ret;
+		/* Scaling up the value so we can use same offset as RAW */
+		*val = ret * 256;
+		return IIO_VAL_INT;
+	}
+	case IIO_CHAN_INFO_SCALE:
+		*val2 = 65536;
+		if (chan->type == IIO_TEMP)
+			*val = 165000;
+		else
+			*val = 100000;
+		return IIO_VAL_FRACTIONAL;
+	case IIO_CHAN_INFO_OFFSET:
+		*val = -15887;
+		*val2 = 515151;
+		return IIO_VAL_INT_PLUS_MICRO;
+	default:
+		return -EINVAL;
+	}
+}
+
+static int hdc2010_write_raw(struct iio_dev *indio_dev,
+			     struct iio_chan_spec const *chan,
+			     int val, int val2, long mask)
+{
+	struct hdc2010_data *data = iio_priv(indio_dev);
+	int new, ret;
+
+	switch (mask) {
+	case IIO_CHAN_INFO_RAW:
+		if (chan->type != IIO_CURRENT || val2 != 0)
+			return -EINVAL;
+
+		switch (val) {
+		case 1:
+			new = HDC2010_HEATER_EN;
+			break;
+		case 0:
+			new = 0;
+			break;
+		default:
+			return -EINVAL;
+		}
+
+		mutex_lock(&data->lock);
+		ret = hdc2010_update_drdy_config(data, HDC2010_HEATER_EN, new);
+		mutex_unlock(&data->lock);
+		return ret;
+	default:
+		return -EINVAL;
+	}
+}
+
+static const struct iio_info hdc2010_info = {
+	.read_raw = hdc2010_read_raw,
+	.write_raw = hdc2010_write_raw,
+	.attrs = &hdc2010_attribute_group,
+};
+
+static int hdc2010_probe(struct i2c_client *client,
+			 const struct i2c_device_id *id)
+{
+	struct iio_dev *indio_dev;
+	struct hdc2010_data *data;
+	u8 tmp;
+	int ret;
+
+	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA |
+				     I2C_FUNC_SMBUS_BYTE | I2C_FUNC_I2C))
+		return -EOPNOTSUPP;
+
+	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
+	if (!indio_dev)
+		return -ENOMEM;
+
+	data = iio_priv(indio_dev);
+	i2c_set_clientdata(client, indio_dev);
+	data->client = client;
+	mutex_init(&data->lock);
+
+	indio_dev->dev.parent = &client->dev;
+	/*
+	 * As DEVICE ID register does not differentiate between
+	 * HDC2010 and HDC2080, we have the name hardcoded
+	 */
+	indio_dev->name = "hdc2010";
+	indio_dev->modes = INDIO_DIRECT_MODE;
+	indio_dev->info = &hdc2010_info;
+
+	indio_dev->channels = hdc2010_channels;
+	indio_dev->num_channels = ARRAY_SIZE(hdc2010_channels);
+
+	/* Enable Automatic Measurement Mode at 5Hz */
+	ret = hdc2010_update_drdy_config(data, HDC2010_AMM, HDC2010_AMM);
+	if (ret)
+		return ret;
+
+	/*
+	 * We enable both temp and humidity measurement.
+	 * However the measurement won't start even in AMM until triggered.
+	 */
+	tmp = (u8)(data->measurement_config & ~HDC2010_MEAS_CONF) |
+		HDC2010_MEAS_TRIG;
+
+	ret = i2c_smbus_write_byte_data(client,
+					HDC2010_REG_MEASUREMENT_CONF, tmp);
+	if (ret) {
+		dev_warn(&client->dev, "Unable to set up measurement\n");
+		if (hdc2010_update_drdy_config(data, HDC2010_AMM, 0))
+			dev_warn(&client->dev,
+				 "Unable to restore default AMM\n");
+		return ret;
+	};
+
+	data->measurement_config = tmp;
+
+	return iio_device_register(indio_dev);
+}
+
+static int hdc2010_remove(struct i2c_client *client)
+{
+	struct iio_dev *indio_dev = i2c_get_clientdata(client);
+	struct hdc2010_data *data = iio_priv(indio_dev);
+
+	iio_device_unregister(indio_dev);
+
+	/* Disable Automatic Measurement Mode */
+	if (hdc2010_update_drdy_config(data, HDC2010_AMM, 0))
+		dev_warn(&client->dev, "Unable to restore default AMM\n");
+
+	return 0;
+}
+
+static const struct i2c_device_id hdc2010_id[] = {
+	{ "hdc2010" },
+	{ "hdc2080" },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, hdc2010_id);
+
+static const struct of_device_id hdc2010_dt_ids[] = {
+	{ .compatible = "ti,hdc2010" },
+	{ .compatible = "ti,hdc2080" },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, hdc2010_dt_ids);
+
+static struct i2c_driver hdc2010_driver = {
+	.driver = {
+		.name	= "hdc2010",
+		.of_match_table = hdc2010_dt_ids,
+	},
+	.probe = hdc2010_probe,
+	.remove = hdc2010_remove,
+	.id_table = hdc2010_id,
+};
+module_i2c_driver(hdc2010_driver);
+
+MODULE_AUTHOR("Eugene Zaikonnikov <ez@norphonic.com>");
+MODULE_DESCRIPTION("TI HDC2010 humidity and temperature sensor driver");
+MODULE_LICENSE("GPL");
diff -uprN -X linux-5.3.8/Documentation/dontdiff linux-5.3.8/drivers/iio/humidity/Kconfig linux-5.3.8_hdc2010/drivers/iio/humidity/Kconfig
--- linux-5.3.8/drivers/iio/humidity/Kconfig	2019-10-29 09:22:48.000000000 +0100
+++ linux-5.3.8_hdc2010/drivers/iio/humidity/Kconfig	2019-11-28 14:31:27.794242693 +0100
@@ -38,6 +38,16 @@  config HDC100X
 	  To compile this driver as a module, choose M here: the module
 	  will be called hdc100x.
 
+config HDC2010
+	tristate "TI HDC2010 relative humidity and temperature sensor"
+	depends on I2C
+	help
+	  Say yes here to build support for the Texas Instruments
+	  HDC2010 and HDC2080 relative humidity and temperature sensors.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called hdc2010.
+
 config HID_SENSOR_HUMIDITY
 	tristate "HID Environmental humidity sensor"
 	depends on HID_SENSOR_HUB
diff -uprN -X linux-5.3.8/Documentation/dontdiff linux-5.3.8/drivers/iio/humidity/Makefile linux-5.3.8_hdc2010/drivers/iio/humidity/Makefile
--- linux-5.3.8/drivers/iio/humidity/Makefile	2019-10-29 09:22:48.000000000 +0100
+++ linux-5.3.8_hdc2010/drivers/iio/humidity/Makefile	2019-11-28 14:30:40.609892061 +0100
@@ -6,6 +6,7 @@ 
 obj-$(CONFIG_AM2315) += am2315.o
 obj-$(CONFIG_DHT11) += dht11.o
 obj-$(CONFIG_HDC100X) += hdc100x.o
+obj-$(CONFIG_HDC2010) += hdc2010.o
 obj-$(CONFIG_HID_SENSOR_HUMIDITY) += hid-sensor-humidity.o
 
 hts221-y := hts221_core.o \