* [PATCH 0/4] Add TI TMP116 Support
@ 2022-12-20 15:02 Marco Felsch
2022-12-20 15:02 ` [PATCH 1/4] dt-bindings: iio: ti,tmp117: fix documentation link Marco Felsch
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Marco Felsch @ 2022-12-20 15:02 UTC (permalink / raw)
To: puranjay12, jic23, lars, robh+dt, krzysztof.kozlowski+dt
Cc: linux-iio, devicetree, kernel
Hi,
this small series adds the support for the TI TMP116 temperature sensor
which is predecessor of the TMP117 but still in production.
Regards,
Marco
Marco Felsch (4):
dt-bindings: iio: ti,tmp117: fix documentation link
dt-bindings: iio: ti,tmp117: add binding for the TMP116
iio: temperature: tmp117: add TI TMP116 support
iio: temperature: tmp117: cosmetic alignment cleanup
.../bindings/iio/temperature/ti,tmp117.yaml | 17 ++++--
drivers/iio/temperature/tmp117.c | 57 ++++++++++++-------
2 files changed, 49 insertions(+), 25 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/4] dt-bindings: iio: ti,tmp117: fix documentation link
2022-12-20 15:02 [PATCH 0/4] Add TI TMP116 Support Marco Felsch
@ 2022-12-20 15:02 ` Marco Felsch
2022-12-20 15:17 ` Krzysztof Kozlowski
2022-12-20 15:02 ` [PATCH 2/4] dt-bindings: iio: ti,tmp117: add binding for the TMP116 Marco Felsch
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Marco Felsch @ 2022-12-20 15:02 UTC (permalink / raw)
To: puranjay12, jic23, lars, robh+dt, krzysztof.kozlowski+dt
Cc: linux-iio, devicetree, kernel
Fix the broken link to point to the correct homepage.
Fixes: 5e713b25d137 ("dt-bindings: iio: temperature: Add DT bindings for TMP117")
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
.../devicetree/bindings/iio/temperature/ti,tmp117.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/iio/temperature/ti,tmp117.yaml b/Documentation/devicetree/bindings/iio/temperature/ti,tmp117.yaml
index 347bc16a4671..8d1ec4d39b28 100644
--- a/Documentation/devicetree/bindings/iio/temperature/ti,tmp117.yaml
+++ b/Documentation/devicetree/bindings/iio/temperature/ti,tmp117.yaml
@@ -9,7 +9,7 @@ title: "TI TMP117 - Digital temperature sensor with integrated NV memory"
description: |
TI TMP117 - Digital temperature sensor with integrated NV memory that supports
I2C interface.
- https://www.ti.com/lit/gpn/tmp1
+ https://www.ti.com/lit/gpn/tmp117
maintainers:
- Puranjay Mohan <puranjay12@gmail.com>
--
2.30.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/4] dt-bindings: iio: ti,tmp117: add binding for the TMP116
2022-12-20 15:02 [PATCH 0/4] Add TI TMP116 Support Marco Felsch
2022-12-20 15:02 ` [PATCH 1/4] dt-bindings: iio: ti,tmp117: fix documentation link Marco Felsch
@ 2022-12-20 15:02 ` Marco Felsch
2022-12-20 15:17 ` Krzysztof Kozlowski
2022-12-20 15:02 ` [PATCH 3/4] iio: temperature: tmp117: add TI TMP116 support Marco Felsch
2022-12-20 15:02 ` [PATCH 4/4] iio: temperature: tmp117: cosmetic alignment cleanup Marco Felsch
3 siblings, 1 reply; 7+ messages in thread
From: Marco Felsch @ 2022-12-20 15:02 UTC (permalink / raw)
To: puranjay12, jic23, lars, robh+dt, krzysztof.kozlowski+dt
Cc: linux-iio, devicetree, kernel
The TMP116 is the predecessor of the TMP117.
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
.../bindings/iio/temperature/ti,tmp117.yaml | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/Documentation/devicetree/bindings/iio/temperature/ti,tmp117.yaml b/Documentation/devicetree/bindings/iio/temperature/ti,tmp117.yaml
index 8d1ec4d39b28..d56fbf11edaf 100644
--- a/Documentation/devicetree/bindings/iio/temperature/ti,tmp117.yaml
+++ b/Documentation/devicetree/bindings/iio/temperature/ti,tmp117.yaml
@@ -7,8 +7,9 @@ $schema: "http://devicetree.org/meta-schemas/core.yaml#"
title: "TI TMP117 - Digital temperature sensor with integrated NV memory"
description: |
- TI TMP117 - Digital temperature sensor with integrated NV memory that supports
- I2C interface.
+ TI TMP116/117 - Digital temperature sensor with integrated NV memory that
+ supports I2C interface.
+ https://www.ti.com/lit/gpn/tmp116
https://www.ti.com/lit/gpn/tmp117
maintainers:
@@ -16,8 +17,14 @@ maintainers:
properties:
compatible:
- enum:
- - ti,tmp117
+ oneOf:
+ - items:
+ - enum:
+ - ti,tmp117
+ - items:
+ - enum:
+ - ti,tmp116
+ - const: ti,tmp117
reg:
maxItems: 1
--
2.30.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/4] iio: temperature: tmp117: add TI TMP116 support
2022-12-20 15:02 [PATCH 0/4] Add TI TMP116 Support Marco Felsch
2022-12-20 15:02 ` [PATCH 1/4] dt-bindings: iio: ti,tmp117: fix documentation link Marco Felsch
2022-12-20 15:02 ` [PATCH 2/4] dt-bindings: iio: ti,tmp117: add binding for the TMP116 Marco Felsch
@ 2022-12-20 15:02 ` Marco Felsch
2022-12-20 15:02 ` [PATCH 4/4] iio: temperature: tmp117: cosmetic alignment cleanup Marco Felsch
3 siblings, 0 replies; 7+ messages in thread
From: Marco Felsch @ 2022-12-20 15:02 UTC (permalink / raw)
To: puranjay12, jic23, lars, robh+dt, krzysztof.kozlowski+dt
Cc: linux-iio, devicetree, kernel
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>
---
drivers/iio/temperature/tmp117.c | 40 ++++++++++++++++++++++----------
1 file changed, 28 insertions(+), 12 deletions(-)
diff --git a/drivers/iio/temperature/tmp117.c b/drivers/iio/temperature/tmp117.c
index f9b8f2b570f6..468dafa6fa8e 100644
--- a/drivers/iio/temperature/tmp117.c
+++ b/drivers/iio/temperature/tmp117.c
@@ -31,9 +31,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;
@@ -105,6 +107,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),
},
};
@@ -118,27 +127,28 @@ static int tmp117_identify(struct i2c_client *client)
int dev_id;
dev_id = i2c_smbus_read_word_swapped(client, TMP117_REG_DEVICE_ID);
- if (dev_id < 0)
+ switch (dev_id) {
+ case TMP116_DEVICE_ID:
+ case TMP117_DEVICE_ID:
return dev_id;
- if (dev_id != TMP117_DEVICE_ID) {
- dev_err(&client->dev, "TMP117 not found\n");
+ default:
+ dev_err(&client->dev, "TMP116/117 not found\n");
return -ENODEV;
}
- return 0;
}
static int tmp117_probe(struct i2c_client *client)
{
struct tmp117_data *data;
struct iio_dev *indio_dev;
- int ret;
+ int dev_id;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA))
return -EOPNOTSUPP;
- ret = tmp117_identify(client);
- if (ret < 0)
- return ret;
+ dev_id = tmp117_identify(client);
+ if (dev_id < 0)
+ return dev_id;
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
if (!indio_dev)
@@ -148,12 +158,18 @@ static int tmp117_probe(struct i2c_client *client)
data->client = client;
data->calibbias = 0;
- indio_dev->name = "tmp117";
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->info = &tmp117_info;
- indio_dev->channels = tmp117_channels;
- indio_dev->num_channels = ARRAY_SIZE(tmp117_channels);
+ if (dev_id == TMP117_DEVICE_ID) {
+ indio_dev->channels = tmp117_channels;
+ indio_dev->num_channels = ARRAY_SIZE(tmp117_channels);
+ indio_dev->name = "tmp117";
+ } else {
+ indio_dev->channels = tmp116_channels;
+ indio_dev->num_channels = ARRAY_SIZE(tmp116_channels);
+ indio_dev->name = "tmp116";
+ }
return devm_iio_device_register(&client->dev, indio_dev);
}
--
2.30.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/4] iio: temperature: tmp117: cosmetic alignment cleanup
2022-12-20 15:02 [PATCH 0/4] Add TI TMP116 Support Marco Felsch
` (2 preceding siblings ...)
2022-12-20 15:02 ` [PATCH 3/4] iio: temperature: tmp117: add TI TMP116 support Marco Felsch
@ 2022-12-20 15:02 ` Marco Felsch
3 siblings, 0 replies; 7+ messages in thread
From: Marco Felsch @ 2022-12-20 15:02 UTC (permalink / raw)
To: puranjay12, jic23, lars, robh+dt, krzysztof.kozlowski+dt
Cc: linux-iio, devicetree, kernel
Align the code correctly if possible and align the channel bit mask to
make it easier to read.
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
drivers/iio/temperature/tmp117.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/iio/temperature/tmp117.c b/drivers/iio/temperature/tmp117.c
index 468dafa6fa8e..df0ee1231975 100644
--- a/drivers/iio/temperature/tmp117.c
+++ b/drivers/iio/temperature/tmp117.c
@@ -42,8 +42,8 @@ struct tmp117_data {
};
static int tmp117_read_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *channel, int *val,
- int *val2, long mask)
+ struct iio_chan_spec const *channel, int *val,
+ int *val2, long mask)
{
struct tmp117_data *data = iio_priv(indio_dev);
s32 ret;
@@ -51,7 +51,7 @@ static int tmp117_read_raw(struct iio_dev *indio_dev,
switch (mask) {
case IIO_CHAN_INFO_RAW:
ret = i2c_smbus_read_word_swapped(data->client,
- TMP117_REG_TEMP);
+ TMP117_REG_TEMP);
if (ret < 0)
return ret;
*val = sign_extend32(ret, 15);
@@ -59,7 +59,7 @@ static int tmp117_read_raw(struct iio_dev *indio_dev,
case IIO_CHAN_INFO_CALIBBIAS:
ret = i2c_smbus_read_word_swapped(data->client,
- TMP117_REG_TEMP_OFFSET);
+ TMP117_REG_TEMP_OFFSET);
if (ret < 0)
return ret;
*val = sign_extend32(ret, 15);
@@ -81,9 +81,8 @@ static int tmp117_read_raw(struct iio_dev *indio_dev,
}
}
-static int tmp117_write_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *channel, int val,
- int val2, long mask)
+static int tmp117_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec
+ const *channel, int val, int val2, long mask)
{
struct tmp117_data *data = iio_priv(indio_dev);
s16 off;
@@ -106,7 +105,9 @@ 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),
+ BIT(IIO_CHAN_INFO_CALIBBIAS) |
+ BIT(IIO_CHAN_INFO_SCALE),
+ },
};
static const struct iio_chan_spec tmp116_channels[] = {
--
2.30.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/4] dt-bindings: iio: ti,tmp117: fix documentation link
2022-12-20 15:02 ` [PATCH 1/4] dt-bindings: iio: ti,tmp117: fix documentation link Marco Felsch
@ 2022-12-20 15:17 ` Krzysztof Kozlowski
0 siblings, 0 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2022-12-20 15:17 UTC (permalink / raw)
To: Marco Felsch, puranjay12, jic23, lars, robh+dt,
krzysztof.kozlowski+dt
Cc: linux-iio, devicetree, kernel
On 20/12/2022 16:02, Marco Felsch wrote:
> Fix the broken link to point to the correct homepage.
>
> Fixes: 5e713b25d137 ("dt-bindings: iio: temperature: Add DT bindings for TMP117")
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/4] dt-bindings: iio: ti,tmp117: add binding for the TMP116
2022-12-20 15:02 ` [PATCH 2/4] dt-bindings: iio: ti,tmp117: add binding for the TMP116 Marco Felsch
@ 2022-12-20 15:17 ` Krzysztof Kozlowski
0 siblings, 0 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2022-12-20 15:17 UTC (permalink / raw)
To: Marco Felsch, puranjay12, jic23, lars, robh+dt,
krzysztof.kozlowski+dt
Cc: linux-iio, devicetree, kernel
On 20/12/2022 16:02, Marco Felsch wrote:
> The TMP116 is the predecessor of the TMP117.
>
> Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> ---
> .../bindings/iio/temperature/ti,tmp117.yaml | 15 +++++++++++----
> 1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/iio/temperature/ti,tmp117.yaml b/Documentation/devicetree/bindings/iio/temperature/ti,tmp117.yaml
> index 8d1ec4d39b28..d56fbf11edaf 100644
> --- a/Documentation/devicetree/bindings/iio/temperature/ti,tmp117.yaml
> +++ b/Documentation/devicetree/bindings/iio/temperature/ti,tmp117.yaml
> @@ -7,8 +7,9 @@ $schema: "http://devicetree.org/meta-schemas/core.yaml#"
> title: "TI TMP117 - Digital temperature sensor with integrated NV memory"
>
> description: |
> - TI TMP117 - Digital temperature sensor with integrated NV memory that supports
> - I2C interface.
> + TI TMP116/117 - Digital temperature sensor with integrated NV memory that
> + supports I2C interface.
> + https://www.ti.com/lit/gpn/tmp116
> https://www.ti.com/lit/gpn/tmp117
>
> maintainers:
> @@ -16,8 +17,14 @@ maintainers:
>
> properties:
> compatible:
> - enum:
> - - ti,tmp117
> + oneOf:
> + - items:
These are not items. Just enum.
> + - enum:
> + - ti,tmp117
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-12-20 15:17 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-20 15:02 [PATCH 0/4] Add TI TMP116 Support Marco Felsch
2022-12-20 15:02 ` [PATCH 1/4] dt-bindings: iio: ti,tmp117: fix documentation link Marco Felsch
2022-12-20 15:17 ` Krzysztof Kozlowski
2022-12-20 15:02 ` [PATCH 2/4] dt-bindings: iio: ti,tmp117: add binding for the TMP116 Marco Felsch
2022-12-20 15:17 ` Krzysztof Kozlowski
2022-12-20 15:02 ` [PATCH 3/4] iio: temperature: tmp117: add TI TMP116 support Marco Felsch
2022-12-20 15:02 ` [PATCH 4/4] iio: temperature: tmp117: cosmetic alignment cleanup Marco Felsch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).