18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0+
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * hdc2010.c - Support for the TI HDC2010 and HDC2080
48c2ecf20Sopenharmony_ci * temperature + relative humidity sensors
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Copyright (C) 2020 Norphonic AS
78c2ecf20Sopenharmony_ci * Author: Eugene Zaikonnikov <ez@norphonic.com>
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci * Datasheet: https://www.ti.com/product/HDC2010/datasheet
108c2ecf20Sopenharmony_ci * Datasheet: https://www.ti.com/product/HDC2080/datasheet
118c2ecf20Sopenharmony_ci */
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include <linux/module.h>
148c2ecf20Sopenharmony_ci#include <linux/init.h>
158c2ecf20Sopenharmony_ci#include <linux/i2c.h>
168c2ecf20Sopenharmony_ci#include <linux/bitops.h>
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#include <linux/iio/iio.h>
198c2ecf20Sopenharmony_ci#include <linux/iio/sysfs.h>
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#define HDC2010_REG_TEMP_LOW			0x00
228c2ecf20Sopenharmony_ci#define HDC2010_REG_TEMP_HIGH			0x01
238c2ecf20Sopenharmony_ci#define HDC2010_REG_HUMIDITY_LOW		0x02
248c2ecf20Sopenharmony_ci#define HDC2010_REG_HUMIDITY_HIGH		0x03
258c2ecf20Sopenharmony_ci#define HDC2010_REG_INTERRUPT_DRDY		0x04
268c2ecf20Sopenharmony_ci#define HDC2010_REG_TEMP_MAX			0x05
278c2ecf20Sopenharmony_ci#define HDC2010_REG_HUMIDITY_MAX		0x06
288c2ecf20Sopenharmony_ci#define HDC2010_REG_INTERRUPT_EN		0x07
298c2ecf20Sopenharmony_ci#define HDC2010_REG_TEMP_OFFSET_ADJ		0x08
308c2ecf20Sopenharmony_ci#define HDC2010_REG_HUMIDITY_OFFSET_ADJ		0x09
318c2ecf20Sopenharmony_ci#define HDC2010_REG_TEMP_THR_L			0x0a
328c2ecf20Sopenharmony_ci#define HDC2010_REG_TEMP_THR_H			0x0b
338c2ecf20Sopenharmony_ci#define HDC2010_REG_RH_THR_L			0x0c
348c2ecf20Sopenharmony_ci#define HDC2010_REG_RH_THR_H			0x0d
358c2ecf20Sopenharmony_ci#define HDC2010_REG_RESET_DRDY_INT_CONF		0x0e
368c2ecf20Sopenharmony_ci#define HDC2010_REG_MEASUREMENT_CONF		0x0f
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci#define HDC2010_MEAS_CONF			GENMASK(2, 1)
398c2ecf20Sopenharmony_ci#define HDC2010_MEAS_TRIG			BIT(0)
408c2ecf20Sopenharmony_ci#define HDC2010_HEATER_EN			BIT(3)
418c2ecf20Sopenharmony_ci#define HDC2010_AMM				GENMASK(6, 4)
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_cistruct hdc2010_data {
448c2ecf20Sopenharmony_ci	struct i2c_client *client;
458c2ecf20Sopenharmony_ci	struct mutex lock;
468c2ecf20Sopenharmony_ci	u8 measurement_config;
478c2ecf20Sopenharmony_ci	u8 interrupt_config;
488c2ecf20Sopenharmony_ci	u8 drdy_config;
498c2ecf20Sopenharmony_ci};
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_cienum hdc2010_addr_groups {
528c2ecf20Sopenharmony_ci	HDC2010_GROUP_TEMP = 0,
538c2ecf20Sopenharmony_ci	HDC2010_GROUP_HUMIDITY,
548c2ecf20Sopenharmony_ci};
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_cistruct hdc2010_reg_record {
578c2ecf20Sopenharmony_ci	unsigned long primary;
588c2ecf20Sopenharmony_ci	unsigned long peak;
598c2ecf20Sopenharmony_ci};
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_cistatic const struct hdc2010_reg_record hdc2010_reg_translation[] = {
628c2ecf20Sopenharmony_ci	[HDC2010_GROUP_TEMP] = {
638c2ecf20Sopenharmony_ci		.primary = HDC2010_REG_TEMP_LOW,
648c2ecf20Sopenharmony_ci		.peak = HDC2010_REG_TEMP_MAX,
658c2ecf20Sopenharmony_ci	},
668c2ecf20Sopenharmony_ci	[HDC2010_GROUP_HUMIDITY] = {
678c2ecf20Sopenharmony_ci		.primary = HDC2010_REG_HUMIDITY_LOW,
688c2ecf20Sopenharmony_ci		.peak = HDC2010_REG_HUMIDITY_MAX,
698c2ecf20Sopenharmony_ci	},
708c2ecf20Sopenharmony_ci};
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_cistatic IIO_CONST_ATTR(out_current_heater_raw_available, "0 1");
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_cistatic struct attribute *hdc2010_attributes[] = {
758c2ecf20Sopenharmony_ci	&iio_const_attr_out_current_heater_raw_available.dev_attr.attr,
768c2ecf20Sopenharmony_ci	NULL
778c2ecf20Sopenharmony_ci};
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_cistatic const struct attribute_group hdc2010_attribute_group = {
808c2ecf20Sopenharmony_ci	.attrs = hdc2010_attributes,
818c2ecf20Sopenharmony_ci};
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_cistatic const struct iio_chan_spec hdc2010_channels[] = {
848c2ecf20Sopenharmony_ci	{
858c2ecf20Sopenharmony_ci		.type = IIO_TEMP,
868c2ecf20Sopenharmony_ci		.address = HDC2010_GROUP_TEMP,
878c2ecf20Sopenharmony_ci		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
888c2ecf20Sopenharmony_ci			BIT(IIO_CHAN_INFO_PEAK) |
898c2ecf20Sopenharmony_ci			BIT(IIO_CHAN_INFO_OFFSET) |
908c2ecf20Sopenharmony_ci			BIT(IIO_CHAN_INFO_SCALE),
918c2ecf20Sopenharmony_ci	},
928c2ecf20Sopenharmony_ci	{
938c2ecf20Sopenharmony_ci		.type = IIO_HUMIDITYRELATIVE,
948c2ecf20Sopenharmony_ci		.address = HDC2010_GROUP_HUMIDITY,
958c2ecf20Sopenharmony_ci		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
968c2ecf20Sopenharmony_ci			BIT(IIO_CHAN_INFO_PEAK) |
978c2ecf20Sopenharmony_ci			BIT(IIO_CHAN_INFO_SCALE),
988c2ecf20Sopenharmony_ci	},
998c2ecf20Sopenharmony_ci	{
1008c2ecf20Sopenharmony_ci		.type = IIO_CURRENT,
1018c2ecf20Sopenharmony_ci		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
1028c2ecf20Sopenharmony_ci		.extend_name = "heater",
1038c2ecf20Sopenharmony_ci		.output = 1,
1048c2ecf20Sopenharmony_ci	},
1058c2ecf20Sopenharmony_ci};
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_cistatic int hdc2010_update_drdy_config(struct hdc2010_data *data,
1088c2ecf20Sopenharmony_ci					     char mask, char val)
1098c2ecf20Sopenharmony_ci{
1108c2ecf20Sopenharmony_ci	u8 tmp = (~mask & data->drdy_config) | val;
1118c2ecf20Sopenharmony_ci	int ret;
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci	ret = i2c_smbus_write_byte_data(data->client,
1148c2ecf20Sopenharmony_ci					HDC2010_REG_RESET_DRDY_INT_CONF, tmp);
1158c2ecf20Sopenharmony_ci	if (ret)
1168c2ecf20Sopenharmony_ci		return ret;
1178c2ecf20Sopenharmony_ci
1188c2ecf20Sopenharmony_ci	data->drdy_config = tmp;
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci	return 0;
1218c2ecf20Sopenharmony_ci}
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_cistatic int hdc2010_get_prim_measurement_word(struct hdc2010_data *data,
1248c2ecf20Sopenharmony_ci					     struct iio_chan_spec const *chan)
1258c2ecf20Sopenharmony_ci{
1268c2ecf20Sopenharmony_ci	struct i2c_client *client = data->client;
1278c2ecf20Sopenharmony_ci	s32 ret;
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci	ret = i2c_smbus_read_word_data(client,
1308c2ecf20Sopenharmony_ci			hdc2010_reg_translation[chan->address].primary);
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci	if (ret < 0)
1338c2ecf20Sopenharmony_ci		dev_err(&client->dev, "Could not read sensor measurement word\n");
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci	return ret;
1368c2ecf20Sopenharmony_ci}
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_cistatic int hdc2010_get_peak_measurement_byte(struct hdc2010_data *data,
1398c2ecf20Sopenharmony_ci					     struct iio_chan_spec const *chan)
1408c2ecf20Sopenharmony_ci{
1418c2ecf20Sopenharmony_ci	struct i2c_client *client = data->client;
1428c2ecf20Sopenharmony_ci	s32 ret;
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci	ret = i2c_smbus_read_byte_data(client,
1458c2ecf20Sopenharmony_ci			hdc2010_reg_translation[chan->address].peak);
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci	if (ret < 0)
1488c2ecf20Sopenharmony_ci		dev_err(&client->dev, "Could not read sensor measurement byte\n");
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci	return ret;
1518c2ecf20Sopenharmony_ci}
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_cistatic int hdc2010_get_heater_status(struct hdc2010_data *data)
1548c2ecf20Sopenharmony_ci{
1558c2ecf20Sopenharmony_ci	return !!(data->drdy_config & HDC2010_HEATER_EN);
1568c2ecf20Sopenharmony_ci}
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_cistatic int hdc2010_read_raw(struct iio_dev *indio_dev,
1598c2ecf20Sopenharmony_ci			    struct iio_chan_spec const *chan, int *val,
1608c2ecf20Sopenharmony_ci			    int *val2, long mask)
1618c2ecf20Sopenharmony_ci{
1628c2ecf20Sopenharmony_ci	struct hdc2010_data *data = iio_priv(indio_dev);
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci	switch (mask) {
1658c2ecf20Sopenharmony_ci	case IIO_CHAN_INFO_RAW: {
1668c2ecf20Sopenharmony_ci		int ret;
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci		if (chan->type == IIO_CURRENT) {
1698c2ecf20Sopenharmony_ci			*val = hdc2010_get_heater_status(data);
1708c2ecf20Sopenharmony_ci			return IIO_VAL_INT;
1718c2ecf20Sopenharmony_ci		}
1728c2ecf20Sopenharmony_ci		ret = iio_device_claim_direct_mode(indio_dev);
1738c2ecf20Sopenharmony_ci		if (ret)
1748c2ecf20Sopenharmony_ci			return ret;
1758c2ecf20Sopenharmony_ci		mutex_lock(&data->lock);
1768c2ecf20Sopenharmony_ci		ret = hdc2010_get_prim_measurement_word(data, chan);
1778c2ecf20Sopenharmony_ci		mutex_unlock(&data->lock);
1788c2ecf20Sopenharmony_ci		iio_device_release_direct_mode(indio_dev);
1798c2ecf20Sopenharmony_ci		if (ret < 0)
1808c2ecf20Sopenharmony_ci			return ret;
1818c2ecf20Sopenharmony_ci		*val = ret;
1828c2ecf20Sopenharmony_ci		return IIO_VAL_INT;
1838c2ecf20Sopenharmony_ci	}
1848c2ecf20Sopenharmony_ci	case IIO_CHAN_INFO_PEAK: {
1858c2ecf20Sopenharmony_ci		int ret;
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci		ret = iio_device_claim_direct_mode(indio_dev);
1888c2ecf20Sopenharmony_ci		if (ret)
1898c2ecf20Sopenharmony_ci			return ret;
1908c2ecf20Sopenharmony_ci		mutex_lock(&data->lock);
1918c2ecf20Sopenharmony_ci		ret = hdc2010_get_peak_measurement_byte(data, chan);
1928c2ecf20Sopenharmony_ci		mutex_unlock(&data->lock);
1938c2ecf20Sopenharmony_ci		iio_device_release_direct_mode(indio_dev);
1948c2ecf20Sopenharmony_ci		if (ret < 0)
1958c2ecf20Sopenharmony_ci			return ret;
1968c2ecf20Sopenharmony_ci		/* Scaling up the value so we can use same offset as RAW */
1978c2ecf20Sopenharmony_ci		*val = ret * 256;
1988c2ecf20Sopenharmony_ci		return IIO_VAL_INT;
1998c2ecf20Sopenharmony_ci	}
2008c2ecf20Sopenharmony_ci	case IIO_CHAN_INFO_SCALE:
2018c2ecf20Sopenharmony_ci		*val2 = 65536;
2028c2ecf20Sopenharmony_ci		if (chan->type == IIO_TEMP)
2038c2ecf20Sopenharmony_ci			*val = 165000;
2048c2ecf20Sopenharmony_ci		else
2058c2ecf20Sopenharmony_ci			*val = 100000;
2068c2ecf20Sopenharmony_ci		return IIO_VAL_FRACTIONAL;
2078c2ecf20Sopenharmony_ci	case IIO_CHAN_INFO_OFFSET:
2088c2ecf20Sopenharmony_ci		*val = -15887;
2098c2ecf20Sopenharmony_ci		*val2 = 515151;
2108c2ecf20Sopenharmony_ci		return IIO_VAL_INT_PLUS_MICRO;
2118c2ecf20Sopenharmony_ci	default:
2128c2ecf20Sopenharmony_ci		return -EINVAL;
2138c2ecf20Sopenharmony_ci	}
2148c2ecf20Sopenharmony_ci}
2158c2ecf20Sopenharmony_ci
2168c2ecf20Sopenharmony_cistatic int hdc2010_write_raw(struct iio_dev *indio_dev,
2178c2ecf20Sopenharmony_ci			     struct iio_chan_spec const *chan,
2188c2ecf20Sopenharmony_ci			     int val, int val2, long mask)
2198c2ecf20Sopenharmony_ci{
2208c2ecf20Sopenharmony_ci	struct hdc2010_data *data = iio_priv(indio_dev);
2218c2ecf20Sopenharmony_ci	int new, ret;
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ci	switch (mask) {
2248c2ecf20Sopenharmony_ci	case IIO_CHAN_INFO_RAW:
2258c2ecf20Sopenharmony_ci		if (chan->type != IIO_CURRENT || val2 != 0)
2268c2ecf20Sopenharmony_ci			return -EINVAL;
2278c2ecf20Sopenharmony_ci
2288c2ecf20Sopenharmony_ci		switch (val) {
2298c2ecf20Sopenharmony_ci		case 1:
2308c2ecf20Sopenharmony_ci			new = HDC2010_HEATER_EN;
2318c2ecf20Sopenharmony_ci			break;
2328c2ecf20Sopenharmony_ci		case 0:
2338c2ecf20Sopenharmony_ci			new = 0;
2348c2ecf20Sopenharmony_ci			break;
2358c2ecf20Sopenharmony_ci		default:
2368c2ecf20Sopenharmony_ci			return -EINVAL;
2378c2ecf20Sopenharmony_ci		}
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci		mutex_lock(&data->lock);
2408c2ecf20Sopenharmony_ci		ret = hdc2010_update_drdy_config(data, HDC2010_HEATER_EN, new);
2418c2ecf20Sopenharmony_ci		mutex_unlock(&data->lock);
2428c2ecf20Sopenharmony_ci		return ret;
2438c2ecf20Sopenharmony_ci	default:
2448c2ecf20Sopenharmony_ci		return -EINVAL;
2458c2ecf20Sopenharmony_ci	}
2468c2ecf20Sopenharmony_ci}
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_cistatic const struct iio_info hdc2010_info = {
2498c2ecf20Sopenharmony_ci	.read_raw = hdc2010_read_raw,
2508c2ecf20Sopenharmony_ci	.write_raw = hdc2010_write_raw,
2518c2ecf20Sopenharmony_ci	.attrs = &hdc2010_attribute_group,
2528c2ecf20Sopenharmony_ci};
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_cistatic int hdc2010_probe(struct i2c_client *client,
2558c2ecf20Sopenharmony_ci			 const struct i2c_device_id *id)
2568c2ecf20Sopenharmony_ci{
2578c2ecf20Sopenharmony_ci	struct iio_dev *indio_dev;
2588c2ecf20Sopenharmony_ci	struct hdc2010_data *data;
2598c2ecf20Sopenharmony_ci	u8 tmp;
2608c2ecf20Sopenharmony_ci	int ret;
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_ci	if (!i2c_check_functionality(client->adapter,
2638c2ecf20Sopenharmony_ci	    I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BYTE | I2C_FUNC_I2C))
2648c2ecf20Sopenharmony_ci		return -EOPNOTSUPP;
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
2678c2ecf20Sopenharmony_ci	if (!indio_dev)
2688c2ecf20Sopenharmony_ci		return -ENOMEM;
2698c2ecf20Sopenharmony_ci
2708c2ecf20Sopenharmony_ci	data = iio_priv(indio_dev);
2718c2ecf20Sopenharmony_ci	i2c_set_clientdata(client, indio_dev);
2728c2ecf20Sopenharmony_ci	data->client = client;
2738c2ecf20Sopenharmony_ci	mutex_init(&data->lock);
2748c2ecf20Sopenharmony_ci
2758c2ecf20Sopenharmony_ci	indio_dev->dev.parent = &client->dev;
2768c2ecf20Sopenharmony_ci	/*
2778c2ecf20Sopenharmony_ci	 * As DEVICE ID register does not differentiate between
2788c2ecf20Sopenharmony_ci	 * HDC2010 and HDC2080, we have the name hardcoded
2798c2ecf20Sopenharmony_ci	 */
2808c2ecf20Sopenharmony_ci	indio_dev->name = "hdc2010";
2818c2ecf20Sopenharmony_ci	indio_dev->modes = INDIO_DIRECT_MODE;
2828c2ecf20Sopenharmony_ci	indio_dev->info = &hdc2010_info;
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_ci	indio_dev->channels = hdc2010_channels;
2858c2ecf20Sopenharmony_ci	indio_dev->num_channels = ARRAY_SIZE(hdc2010_channels);
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_ci	/* Enable Automatic Measurement Mode at 5Hz */
2888c2ecf20Sopenharmony_ci	ret = hdc2010_update_drdy_config(data, HDC2010_AMM, HDC2010_AMM);
2898c2ecf20Sopenharmony_ci	if (ret)
2908c2ecf20Sopenharmony_ci		return ret;
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_ci	/*
2938c2ecf20Sopenharmony_ci	 * We enable both temp and humidity measurement.
2948c2ecf20Sopenharmony_ci	 * However the measurement won't start even in AMM until triggered.
2958c2ecf20Sopenharmony_ci	 */
2968c2ecf20Sopenharmony_ci	tmp = (data->measurement_config & ~HDC2010_MEAS_CONF) |
2978c2ecf20Sopenharmony_ci		HDC2010_MEAS_TRIG;
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_ci	ret = i2c_smbus_write_byte_data(client, HDC2010_REG_MEASUREMENT_CONF, tmp);
3008c2ecf20Sopenharmony_ci	if (ret) {
3018c2ecf20Sopenharmony_ci		dev_warn(&client->dev, "Unable to set up measurement\n");
3028c2ecf20Sopenharmony_ci		if (hdc2010_update_drdy_config(data, HDC2010_AMM, 0))
3038c2ecf20Sopenharmony_ci			dev_warn(&client->dev, "Unable to restore default AMM\n");
3048c2ecf20Sopenharmony_ci		return ret;
3058c2ecf20Sopenharmony_ci	}
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_ci	data->measurement_config = tmp;
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ci	return iio_device_register(indio_dev);
3108c2ecf20Sopenharmony_ci}
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_cistatic int hdc2010_remove(struct i2c_client *client)
3138c2ecf20Sopenharmony_ci{
3148c2ecf20Sopenharmony_ci	struct iio_dev *indio_dev = i2c_get_clientdata(client);
3158c2ecf20Sopenharmony_ci	struct hdc2010_data *data = iio_priv(indio_dev);
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_ci	iio_device_unregister(indio_dev);
3188c2ecf20Sopenharmony_ci
3198c2ecf20Sopenharmony_ci	/* Disable Automatic Measurement Mode */
3208c2ecf20Sopenharmony_ci	if (hdc2010_update_drdy_config(data, HDC2010_AMM, 0))
3218c2ecf20Sopenharmony_ci		dev_warn(&client->dev, "Unable to restore default AMM\n");
3228c2ecf20Sopenharmony_ci
3238c2ecf20Sopenharmony_ci	return 0;
3248c2ecf20Sopenharmony_ci}
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_cistatic const struct i2c_device_id hdc2010_id[] = {
3278c2ecf20Sopenharmony_ci	{ "hdc2010" },
3288c2ecf20Sopenharmony_ci	{ "hdc2080" },
3298c2ecf20Sopenharmony_ci	{ }
3308c2ecf20Sopenharmony_ci};
3318c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(i2c, hdc2010_id);
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_cistatic const struct of_device_id hdc2010_dt_ids[] = {
3348c2ecf20Sopenharmony_ci	{ .compatible = "ti,hdc2010" },
3358c2ecf20Sopenharmony_ci	{ .compatible = "ti,hdc2080" },
3368c2ecf20Sopenharmony_ci	{ }
3378c2ecf20Sopenharmony_ci};
3388c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(of, hdc2010_dt_ids);
3398c2ecf20Sopenharmony_ci
3408c2ecf20Sopenharmony_cistatic struct i2c_driver hdc2010_driver = {
3418c2ecf20Sopenharmony_ci	.driver = {
3428c2ecf20Sopenharmony_ci		.name	= "hdc2010",
3438c2ecf20Sopenharmony_ci		.of_match_table = hdc2010_dt_ids,
3448c2ecf20Sopenharmony_ci	},
3458c2ecf20Sopenharmony_ci	.probe = hdc2010_probe,
3468c2ecf20Sopenharmony_ci	.remove = hdc2010_remove,
3478c2ecf20Sopenharmony_ci	.id_table = hdc2010_id,
3488c2ecf20Sopenharmony_ci};
3498c2ecf20Sopenharmony_cimodule_i2c_driver(hdc2010_driver);
3508c2ecf20Sopenharmony_ci
3518c2ecf20Sopenharmony_ciMODULE_AUTHOR("Eugene Zaikonnikov <ez@norphonic.com>");
3528c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("TI HDC2010 humidity and temperature sensor driver");
3538c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
354