Skip to content

Commit

Permalink
iio: temperature: tmp117: add TI TMP116 support
Browse files Browse the repository at this point in the history
The TMP116 is the predecessor of the TMP117. The TMP116 don't support
custom offset calibration data, instead this register is used as generic
EEPROM storage as well.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
  • Loading branch information
Marco Felsch authored and intel-lab-lkp committed Feb 27, 2023
1 parent 75e825b commit 424113d
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion drivers/iio/temperature/tmp117.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
#define TMP117_REG_DEVICE_ID 0xF

#define TMP117_RESOLUTION_10UC 78125
#define TMP117_DEVICE_ID 0x0117
#define MICRODEGREE_PER_10MILLIDEGREE 10000

#define TMP116_DEVICE_ID 0x1116
#define TMP117_DEVICE_ID 0x0117

struct tmp117_data {
struct i2c_client *client;
s16 calibbias;
Expand Down Expand Up @@ -106,6 +108,13 @@ static const struct iio_chan_spec tmp117_channels[] = {
.type = IIO_TEMP,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_CALIBBIAS) | BIT(IIO_CHAN_INFO_SCALE),
};

static const struct iio_chan_spec tmp116_channels[] = {
{
.type = IIO_TEMP,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_SCALE),
},
};

Expand All @@ -125,6 +134,7 @@ static int tmp117_identify(struct i2c_client *client)
return dev_id;

switch (dev_id) {
case TMP116_DEVICE_ID:
case TMP117_DEVICE_ID:
return dev_id;
}
Expand Down Expand Up @@ -172,6 +182,11 @@ static int tmp117_probe(struct i2c_client *client)
indio_dev->info = &tmp117_info;

switch (dev_id) {
case TMP116_DEVICE_ID:
indio_dev->channels = tmp116_channels;
indio_dev->num_channels = ARRAY_SIZE(tmp116_channels);
indio_dev->name = "tmp116";
break;
case TMP117_DEVICE_ID:
indio_dev->channels = tmp117_channels;
indio_dev->num_channels = ARRAY_SIZE(tmp117_channels);
Expand All @@ -183,12 +198,14 @@ static int tmp117_probe(struct i2c_client *client)
}

static const struct of_device_id tmp117_of_match[] = {
{ .compatible = "ti,tmp116", .data = (void *)TMP116_DEVICE_ID },
{ .compatible = "ti,tmp117", .data = (void *)TMP117_DEVICE_ID },
{ }
};
MODULE_DEVICE_TABLE(of, tmp117_of_match);

static const struct i2c_device_id tmp117_id[] = {
{ "tmp116", TMP116_DEVICE_ID },
{ "tmp117", TMP117_DEVICE_ID },
{ }
};
Expand Down

0 comments on commit 424113d

Please sign in to comment.