devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marco Felsch <m.felsch@pengutronix.de>
To: puranjay12@gmail.com, jic23@kernel.org, lars@metafoo.de,
	robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org
Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	kernel@pengutronix.de
Subject: [PATCH v4 4/5] iio: temperature: tmp117: add TI TMP116 support
Date: Mon, 20 Feb 2023 13:25:51 +0100	[thread overview]
Message-ID: <20230220122552.925216-5-m.felsch@pengutronix.de> (raw)
In-Reply-To: <20230220122552.925216-1-m.felsch@pengutronix.de>

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>
---
v4:
- split into two patches
  - 1st) handle fallback (Jonathan)
  - 2nd) this one, adding the support for tmp116

v3:
- use switch case within probe() as well
- don't hide smbus_read error within tmp117_identify()
- add dedicated compatible

v2:
- no changes

 drivers/iio/temperature/tmp117.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/temperature/tmp117.c b/drivers/iio/temperature/tmp117.c
index 4ddb8cf9a29ab..4915aceb66ee2 100644
--- a/drivers/iio/temperature/tmp117.c
+++ b/drivers/iio/temperature/tmp117.c
@@ -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;
@@ -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),
 	},
 };
 
@@ -115,12 +124,14 @@ static const struct iio_info tmp117_info = {
 };
 
 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 },
 	{ }
 };
@@ -136,6 +147,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;
 	}
@@ -181,6 +193,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);
-- 
2.30.2


  parent reply	other threads:[~2023-02-20 12:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-20 12:25 [PATCH v4 0/5] Add TI TMP116 Support Marco Felsch
2023-02-20 12:25 ` [PATCH v4 1/5] dt-bindings: iio: ti,tmp117: fix documentation link Marco Felsch
2023-02-20 12:25 ` [PATCH v4 2/5] iio: temperature: tmp117: improve fallback capabilities Marco Felsch
2023-02-26 13:07   ` Jonathan Cameron
2023-02-27 18:44     ` Marco Felsch
2023-03-04 13:13       ` Jonathan Cameron
2023-02-20 12:25 ` [PATCH v4 3/5] dt-bindings: iio: ti,tmp117: add binding for the TMP116 Marco Felsch
2023-02-20 12:25 ` Marco Felsch [this message]
2023-02-20 12:25 ` [PATCH v4 5/5] iio: temperature: tmp117: cosmetic alignment cleanup Marco Felsch
2023-02-26 13:09   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230220122552.925216-5-m.felsch@pengutronix.de \
    --to=m.felsch@pengutronix.de \
    --cc=devicetree@vger.kernel.org \
    --cc=jic23@kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=puranjay12@gmail.com \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).