public inbox for linux-doc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] hwmon: (tmp108) Add support for P3T1035 and P3T2030
@ 2026-01-15  6:57 Mayank Mahajan
  2026-01-15  6:57 ` [PATCH v2 2/3] dt-bindings: hwmon: ti,tmp108: Add P3T1035,P3T2030 Mayank Mahajan
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Mayank Mahajan @ 2026-01-15  6:57 UTC (permalink / raw)
  To: linux, corbet, robh, krzk+dt, conor+dt, linux-hwmon, devicetree,
	linux-doc, linux-kernel
  Cc: priyanka.jain, vikash.bansal, Mayank Mahajan

Add support for the P3T1035 & P3T2030 temperature sensor. While mostly
compatible with the TMP108, P3T1035 uses an 8-bit configuration register
instead of the 16-bit layout used by TMP108. Updated driver to handle
this difference during configuration read/write.

Signed-off-by: Mayank Mahajan <mayankmahajan.x@nxp.com>
---
V1 -> V2:
- Disabled hysteresis in is_visible function for P3T1035.
- Added tables for conversion rate similar to the LM75 driver.
- Implemented different bus access depending on the chip being used.
  - Removed regmap for 8 bits; now we are using one regmap as before.
  - Added read and write functions for i2c and i3c for use with regmap.
  - Mapped the 8-bit configuration register to a 16 bit value for P3T1035.

 drivers/hwmon/Kconfig  |   2 +-
 drivers/hwmon/tmp108.c | 244 +++++++++++++++++++++++++++++++++--------
 2 files changed, 197 insertions(+), 49 deletions(-)

diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 157678b821fc..31969bddc812 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -2398,7 +2398,7 @@ config SENSORS_TMP108
 	select REGMAP_I3C if I3C
 	help
 	  If you say yes here you get support for Texas Instruments TMP108
-	  sensor chips and NXP P3T1085.
+	  sensor chips, NXP temperature sensors P3T1035, P3T1085 and P3T2030.

 	  This driver can also be built as a module. If so, the module
 	  will be called tmp108.
diff --git a/drivers/hwmon/tmp108.c b/drivers/hwmon/tmp108.c
index 60a237cbedbc..37f7181a7f28 100644
--- a/drivers/hwmon/tmp108.c
+++ b/drivers/hwmon/tmp108.c
@@ -11,22 +11,30 @@
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/i2c.h>
+#include <linux/i3c/master.h>
 #include <linux/i3c/device.h>
 #include <linux/init.h>
 #include <linux/jiffies.h>
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
 #include <linux/slab.h>
+#include <linux/util_macros.h>

 #define	DRIVER_NAME "tmp108"

+enum tmp108_hw_id {
+	P3T1035_ID,		/* For sensors p3t1035 and p3t2030 */
+	P3T1085_ID,
+	TMP108_ID,
+};
+
 #define	TMP108_REG_TEMP		0x00
 #define	TMP108_REG_CONF		0x01
 #define	TMP108_REG_TLOW		0x02
 #define	TMP108_REG_THIGH	0x03

-#define TMP108_TEMP_MIN_MC	-50000 /* Minimum millicelcius. */
-#define TMP108_TEMP_MAX_MC	127937 /* Maximum millicelcius. */
+#define TMP108_TEMP_MIN_MC	-50000 /* Minimum millicelsius. */
+#define TMP108_TEMP_MAX_MC	127937 /* Maximum millicelsius. */

 /* Configuration register bits.
  * Note: these bit definitions are byte swapped.
@@ -61,6 +69,7 @@
 #define TMP108_CONVRATE_1HZ		TMP108_CONF_CR0		/* Default */
 #define TMP108_CONVRATE_4HZ		TMP108_CONF_CR1
 #define TMP108_CONVRATE_16HZ		(TMP108_CONF_CR0|TMP108_CONF_CR1)
+#define TMP108_CONVRATE_SHIFT		13

 #define TMP108_CONF_HYSTERESIS_MASK	(TMP108_CONF_HYS0|TMP108_CONF_HYS1)
 #define TMP108_HYSTERESIS_0C		0x0000
@@ -71,11 +80,21 @@
 #define TMP108_CONVERSION_TIME_MS	30	/* in milli-seconds */

 struct tmp108 {
-	struct regmap *regmap;
-	u16 orig_config;
-	unsigned long ready_time;
+	struct regmap		*regmap;
+	u16			orig_config;
+	unsigned long		ready_time;
+	enum tmp108_hw_id	hw_id;
+	bool			config_reg_16bits;
+	u8			reg_buf[1];
+	u8			val_buf[3];
+	unsigned int		sample_times[4];
 };

+static const u16 tmp108_sample_set_masks[] = { 3 << TMP108_CONVRATE_SHIFT,
+					       2 << TMP108_CONVRATE_SHIFT,
+					       1 << TMP108_CONVRATE_SHIFT,
+					       0 << TMP108_CONVRATE_SHIFT };
+
 /* convert 12-bit TMP108 register value to milliCelsius */
 static inline int tmp108_temp_reg_to_mC(s16 val)
 {
@@ -94,6 +113,8 @@ static int tmp108_read(struct device *dev, enum hwmon_sensor_types type,
 	struct tmp108 *tmp108 = dev_get_drvdata(dev);
 	unsigned int regval;
 	int err, hyst;
+	u16 conv_rate;
+	u8 index;

 	if (type == hwmon_chip) {
 		if (attr == hwmon_chip_update_interval) {
@@ -101,21 +122,10 @@ static int tmp108_read(struct device *dev, enum hwmon_sensor_types type,
 					  &regval);
 			if (err < 0)
 				return err;
-			switch (regval & TMP108_CONF_CONVRATE_MASK) {
-			case TMP108_CONVRATE_0P25HZ:
-			default:
-				*temp = 4000;
-				break;
-			case TMP108_CONVRATE_1HZ:
-				*temp = 1000;
-				break;
-			case TMP108_CONVRATE_4HZ:
-				*temp = 250;
-				break;
-			case TMP108_CONVRATE_16HZ:
-				*temp = 63;
-				break;
-			}
+			conv_rate = regval & TMP108_CONF_CONVRATE_MASK;
+			index = find_closest_descending(conv_rate, tmp108_sample_set_masks,
+							(int)ARRAY_SIZE(tmp108_sample_set_masks));
+			*temp = tmp108->sample_times[index];
 			return 0;
 		}
 		return -EOPNOTSUPP;
@@ -192,22 +202,17 @@ static int tmp108_write(struct device *dev, enum hwmon_sensor_types type,
 {
 	struct tmp108 *tmp108 = dev_get_drvdata(dev);
 	u32 regval, mask;
+	u8 index;
 	int err;

 	if (type == hwmon_chip) {
 		if (attr == hwmon_chip_update_interval) {
-			if (temp < 156)
-				mask = TMP108_CONVRATE_16HZ;
-			else if (temp < 625)
-				mask = TMP108_CONVRATE_4HZ;
-			else if (temp < 2500)
-				mask = TMP108_CONVRATE_1HZ;
-			else
-				mask = TMP108_CONVRATE_0P25HZ;
+			index = find_closest(temp, tmp108->sample_times,
+					     (int)ARRAY_SIZE(tmp108->sample_times));
 			return regmap_update_bits(tmp108->regmap,
 						  TMP108_REG_CONF,
 						  TMP108_CONF_CONVRATE_MASK,
-						  mask);
+						  tmp108_sample_set_masks[index]);
 		}
 		return -EOPNOTSUPP;
 	}
@@ -251,6 +256,8 @@ static int tmp108_write(struct device *dev, enum hwmon_sensor_types type,
 static umode_t tmp108_is_visible(const void *data, enum hwmon_sensor_types type,
 				 u32 attr, int channel)
 {
+	const struct tmp108 *tmp108 = data;
+
 	if (type == hwmon_chip && attr == hwmon_chip_update_interval)
 		return 0644;

@@ -264,8 +271,11 @@ static umode_t tmp108_is_visible(const void *data, enum hwmon_sensor_types type,
 		return 0444;
 	case hwmon_temp_min:
 	case hwmon_temp_max:
+		return 0644;
 	case hwmon_temp_min_hyst:
 	case hwmon_temp_max_hyst:
+		if (tmp108->hw_id == P3T1035_ID)
+			return 0;
 		return 0644;
 	default:
 		return 0;
@@ -311,6 +321,105 @@ static bool tmp108_is_volatile_reg(struct device *dev, unsigned int reg)
 	return reg == TMP108_REG_TEMP || reg == TMP108_REG_CONF;
 }

+static int tmp108_i2c_reg_read(void *context, unsigned int reg, unsigned int *val)
+{
+	struct i2c_client *client = context;
+	struct tmp108 *tmp108 = i2c_get_clientdata(client);
+	int ret;
+
+	if (reg == TMP108_REG_CONF && !tmp108->config_reg_16bits)
+		ret = i2c_smbus_read_byte_data(client, TMP108_REG_CONF);
+	else
+		ret = i2c_smbus_read_word_swapped(client, reg);
+
+	if (ret < 0)
+		return ret;
+
+	if (reg == TMP108_REG_CONF && !tmp108->config_reg_16bits)
+		*val = ret << 8;
+	else
+		*val = ret;
+
+	return 0;
+}
+
+static int tmp108_i2c_reg_write(void *context, unsigned int reg, unsigned int val)
+{
+	struct i2c_client *client = context;
+	struct tmp108 *tmp108 = i2c_get_clientdata(client);
+
+	if (reg == TMP108_REG_CONF && !tmp108->config_reg_16bits)
+		return i2c_smbus_write_byte_data(client, reg, val >> 8);
+	return i2c_smbus_write_word_swapped(client, reg, val);
+}
+
+static const struct regmap_bus tmp108_i2c_regmap_bus = {
+	.reg_read = tmp108_i2c_reg_read,
+	.reg_write = tmp108_i2c_reg_write,
+};
+
+static int tmp108_i3c_reg_read(void *context, unsigned int reg, unsigned int *val)
+{
+	struct i3c_device *i3cdev = context;
+	struct tmp108 *tmp108 = i3cdev_get_drvdata(i3cdev);
+	struct i3c_xfer xfers[] = {
+		{
+			.rnw = false,
+			.len = 1,
+			.data.out = tmp108->reg_buf,
+		},
+		{
+			.rnw = true,
+			.len = 2,
+			.data.in = tmp108->val_buf,
+		},
+	};
+	int ret;
+
+	tmp108->reg_buf[0] = reg;
+
+	if (reg == TMP108_REG_CONF && !tmp108->config_reg_16bits)
+		xfers[1].len--;
+
+	ret = i3c_device_do_xfers(i3cdev, xfers, 2, I3C_SDR);
+	if (ret < 0)
+		return ret;
+
+	*val = tmp108->val_buf[0] << 8;
+	if (!(reg == TMP108_REG_CONF && !tmp108->config_reg_16bits))
+		*val |= tmp108->val_buf[1];
+
+	return 0;
+}
+
+static int tmp108_i3c_reg_write(void *context, unsigned int reg, unsigned int val)
+{
+	struct i3c_device *i3cdev = context;
+	struct tmp108 *tmp108 = i3cdev_get_drvdata(i3cdev);
+	struct i3c_xfer xfers[] = {
+		{
+			.rnw = false,
+			.len = 3,
+			.data.out = tmp108->val_buf,
+		},
+	};
+
+	tmp108->val_buf[0] = reg;
+	tmp108->val_buf[1] = (val >> 8) & 0xff;
+
+	if (reg == TMP108_REG_CONF && !tmp108->config_reg_16bits)
+		xfers[0].len--;
+	else
+		tmp108->val_buf[2] = val & 0xff;
+
+	return i3c_device_do_xfers(i3cdev, xfers, 1, I3C_SDR);
+}
+
+static const struct regmap_bus tmp108_i3c_regmap_bus = {
+	.reg_read = tmp108_i3c_reg_read,
+	.reg_write = tmp108_i3c_reg_write,
+};
+
 static const struct regmap_config tmp108_regmap_config = {
 	.reg_bits = 8,
 	.val_bits = 16,
@@ -323,7 +432,8 @@ static const struct regmap_config tmp108_regmap_config = {
 	.use_single_write = true,
 };

-static int tmp108_common_probe(struct device *dev, struct regmap *regmap, char *name)
+static int tmp108_common_probe(struct device *dev, struct regmap *regmap, char *name,
+			       enum tmp108_hw_id hw_id)
 {
 	struct device *hwmon_dev;
 	struct tmp108 *tmp108;
@@ -340,10 +450,18 @@ static int tmp108_common_probe(struct device *dev, struct regmap *regmap, char *

 	dev_set_drvdata(dev, tmp108);
 	tmp108->regmap = regmap;
+	tmp108->hw_id = hw_id;
+	tmp108->config_reg_16bits = (hw_id == P3T1035_ID) ? false : true;
+	if (hw_id == P3T1035_ID)
+		memcpy(tmp108->sample_times, (unsigned int[]){ 125, 250, 1000, 4000 },
+		       sizeof(tmp108->sample_times));
+	else
+		memcpy(tmp108->sample_times, (unsigned int[]){ 63, 250, 1000, 4000 },
+		       sizeof(tmp108->sample_times));

 	err = regmap_read(tmp108->regmap, TMP108_REG_CONF, &config);
 	if (err < 0) {
-		dev_err(dev, "error reading config register: %d", err);
+		dev_err_probe(dev, err, "Error reading config register");
 		return err;
 	}
 	tmp108->orig_config = config;
@@ -351,13 +469,12 @@ static int tmp108_common_probe(struct device *dev, struct regmap *regmap, char *
 	/* Only continuous mode is supported. */
 	config &= ~TMP108_CONF_MODE_MASK;
 	config |= TMP108_MODE_CONTINUOUS;
-
 	/* Only comparator mode is supported. */
 	config &= ~TMP108_CONF_TM;

 	err = regmap_write(tmp108->regmap, TMP108_REG_CONF, config);
 	if (err < 0) {
-		dev_err(dev, "error writing config register: %d", err);
+		dev_err_probe(dev, err, "Error writing config register");
 		return err;
 	}

@@ -369,7 +486,7 @@ static int tmp108_common_probe(struct device *dev, struct regmap *regmap, char *

 	err = devm_add_action_or_reset(dev, tmp108_restore_config, tmp108);
 	if (err) {
-		dev_err(dev, "add action or reset failed: %d", err);
+		dev_err_probe(dev, err, "Add action or reset failed");
 		return err;
 	}

@@ -384,17 +501,34 @@ static int tmp108_probe(struct i2c_client *client)
 {
 	struct device *dev = &client->dev;
 	struct regmap *regmap;
+	enum tmp108_hw_id hw_id;
+	const void *of_data;

 	if (!i2c_check_functionality(client->adapter,
-				     I2C_FUNC_SMBUS_WORD_DATA))
-		return dev_err_probe(dev, -ENODEV,
+				     I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA))
+		return dev_err_probe(dev, -EOPNOTSUPP,
 				     "adapter doesn't support SMBus word transactions\n");

-	regmap = devm_regmap_init_i2c(client, &tmp108_regmap_config);
+	regmap = devm_regmap_init(dev, &tmp108_i2c_regmap_bus, client, &tmp108_regmap_config);
 	if (IS_ERR(regmap))
 		return dev_err_probe(dev, PTR_ERR(regmap), "regmap init failed");

-	return tmp108_common_probe(dev, regmap, client->name);
+	/* Prefer OF match data (DT-first systems) */
+	of_data = device_get_match_data(&client->dev);
+	if (of_data) {
+		hw_id = (enum tmp108_hw_id)(uintptr_t)of_data;
+	} else {
+		/* Fall back to legacy I2C ID table */
+		const struct i2c_device_id *id = i2c_client_get_device_id(client);
+
+		if (!id) {
+			dev_err_probe(dev, -ENODEV, "No matching device ID for i2c device\n");
+			return -ENODEV;
+		}
+		hw_id = (enum tmp108_hw_id)id->driver_data;
+	}
+
+	return tmp108_common_probe(dev, regmap, client->name, hw_id);
 }

 static int tmp108_suspend(struct device *dev)
@@ -420,16 +554,20 @@ static int tmp108_resume(struct device *dev)
 static DEFINE_SIMPLE_DEV_PM_OPS(tmp108_dev_pm_ops, tmp108_suspend, tmp108_resume);

 static const struct i2c_device_id tmp108_i2c_ids[] = {
-	{ "p3t1085" },
-	{ "tmp108" },
-	{ }
+	{ "p3t1035", P3T1035_ID },
+	{ "p3t1085", P3T1085_ID },
+	{ "p3t2030", P3T1035_ID },
+	{ "tmp108", TMP108_ID },
+	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(i2c, tmp108_i2c_ids);

 static const struct of_device_id tmp108_of_ids[] = {
-	{ .compatible = "nxp,p3t1085", },
-	{ .compatible = "ti,tmp108", },
-	{}
+	{ .compatible = "nxp,p3t1035", .data = (void *)(uintptr_t)P3T1035_ID },
+	{ .compatible = "nxp,p3t1085", .data = (void *)(uintptr_t)P3T1085_ID },
+	{ .compatible = "nxp,p3t2030", .data = (void *)(uintptr_t)P3T1035_ID },
+	{ .compatible = "ti,tmp108", .data = (void *)(uintptr_t)TMP108_ID },
+	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, tmp108_of_ids);

@@ -444,8 +582,9 @@ static struct i2c_driver tmp108_driver = {
 };

 static const struct i3c_device_id p3t1085_i3c_ids[] = {
-	I3C_DEVICE(0x011b, 0x1529, NULL),
-	{}
+	I3C_DEVICE(0x011B, 0x1529, (void *)P3T1085_ID),
+	I3C_DEVICE(0x011B, 0x152B, (void *)P3T1035_ID),
+	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(i3c, p3t1085_i3c_ids);

@@ -453,13 +592,22 @@ static int p3t1085_i3c_probe(struct i3c_device *i3cdev)
 {
 	struct device *dev = i3cdev_to_dev(i3cdev);
 	struct regmap *regmap;
+	const struct i3c_device_id *id;
+	enum tmp108_hw_id hw_id;

-	regmap = devm_regmap_init_i3c(i3cdev, &tmp108_regmap_config);
+	regmap = devm_regmap_init(dev, &tmp108_i3c_regmap_bus, i3cdev, &tmp108_regmap_config);
 	if (IS_ERR(regmap))
 		return dev_err_probe(dev, PTR_ERR(regmap),
 				     "Failed to register i3c regmap\n");

-	return tmp108_common_probe(dev, regmap, "p3t1085_i3c");
+	id = i3c_device_match_id(i3cdev, p3t1085_i3c_ids);
+	if (!id) {
+		dev_err_probe(dev, -ENODEV, "No matching device ID for i3c device\n");
+		return -ENODEV;
+	}
+	hw_id = (enum tmp108_hw_id)(uintptr_t)id->data;
+
+	return tmp108_common_probe(dev, regmap, "p3t1085_i3c", hw_id);
 }

 static struct i3c_driver p3t1085_driver = {
--
2.34.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/3] dt-bindings: hwmon: ti,tmp108: Add P3T1035,P3T2030
  2026-01-15  6:57 [PATCH v2 1/3] hwmon: (tmp108) Add support for P3T1035 and P3T2030 Mayank Mahajan
@ 2026-01-15  6:57 ` Mayank Mahajan
  2026-01-15  9:36   ` Krzysztof Kozlowski
  2026-01-15  6:57 ` [PATCH v2 3/3] hwmon: (tmp108) Add P3T1035 and P3T2030 support Mayank Mahajan
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Mayank Mahajan @ 2026-01-15  6:57 UTC (permalink / raw)
  To: linux, corbet, robh, krzk+dt, conor+dt, linux-hwmon, devicetree,
	linux-doc, linux-kernel
  Cc: priyanka.jain, vikash.bansal, Mayank Mahajan

Document the NXP P3T1035 and P3T2030 compatibles in TMP108.

Signed-off-by: Mayank Mahajan <mayankmahajan.x@nxp.com>
---
V1 -> V2:
- No changes in v2.

 .../devicetree/bindings/hwmon/ti,tmp108.yaml        | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/hwmon/ti,tmp108.yaml b/Documentation/devicetree/bindings/hwmon/ti,tmp108.yaml
index a6f9319e068d..1ca7f3aa4cd4 100644
--- a/Documentation/devicetree/bindings/hwmon/ti,tmp108.yaml
+++ b/Documentation/devicetree/bindings/hwmon/ti,tmp108.yaml
@@ -4,26 +4,29 @@
 $id: http://devicetree.org/schemas/hwmon/ti,tmp108.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#

-title: TMP108/P3T1085(NXP) temperature sensor
+title: TMP108/P3T1035/P3T1085/P3T2030 temperature sensor

 maintainers:
   - Krzysztof Kozlowski <krzk@kernel.org>

 description: |
-  The TMP108/P3T1085(NXP) is a digital-output temperature sensor with a
-  dynamically-programmable limit window, and under- and overtemperature
-  alert functions.
+  The TMP108 or NXP P3T Family (P3T1035, P3T1085 and P3T2030) is a digital-
+  output temperature sensor with a dynamically-programmable limit window,
+  and under- and over-temperature alert functions.

-  P3T1085(NXP) support I3C.
+  NXP P3T Family (P3T1035, P3T1085 and P3T2030) supports I3C.

   Datasheets:
     https://www.ti.com/product/TMP108
     https://www.nxp.com/docs/en/data-sheet/P3T1085UK.pdf
+    https://www.nxp.com/docs/en/data-sheet/P3T1035XUK_P3T2030XUK.pdf

 properties:
   compatible:
     enum:
+      - nxp,p3t1035
       - nxp,p3t1085
+      - nxp,p3t2030
       - ti,tmp108

   interrupts:
--
2.34.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 3/3] hwmon: (tmp108) Add P3T1035 and P3T2030 support
  2026-01-15  6:57 [PATCH v2 1/3] hwmon: (tmp108) Add support for P3T1035 and P3T2030 Mayank Mahajan
  2026-01-15  6:57 ` [PATCH v2 2/3] dt-bindings: hwmon: ti,tmp108: Add P3T1035,P3T2030 Mayank Mahajan
@ 2026-01-15  6:57 ` Mayank Mahajan
  2026-01-15  8:53 ` [PATCH v2 1/3] hwmon: (tmp108) Add support for P3T1035 and P3T2030 Krzysztof Kozlowski
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Mayank Mahajan @ 2026-01-15  6:57 UTC (permalink / raw)
  To: linux, corbet, robh, krzk+dt, conor+dt, linux-hwmon, devicetree,
	linux-doc, linux-kernel
  Cc: priyanka.jain, vikash.bansal, Mayank Mahajan

Update the hwmon driver documentation for sensors: P3T1035 and P3T2030.

Signed-off-by: Mayank Mahajan <mayankmahajan.x@nxp.com>
---
V1 -> V2:
- No changes in v2.

 Documentation/hwmon/tmp108.rst | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/Documentation/hwmon/tmp108.rst b/Documentation/hwmon/tmp108.rst
index bc4941d98268..c218ea333dd6 100644
--- a/Documentation/hwmon/tmp108.rst
+++ b/Documentation/hwmon/tmp108.rst
@@ -3,6 +3,15 @@ Kernel driver tmp108

 Supported chips:

+  * NXP P3T1035
+
+    Prefix: 'p3t1035'
+
+    Addresses scanned: none
+
+    Datasheet: https://www.nxp.com/docs/en/data-sheet/P3T1035XUK_P3T2030XUK.pdf
+
+
   * NXP P3T1085

     Prefix: 'p3t1085'
@@ -11,6 +20,14 @@ Supported chips:

     Datasheet: https://www.nxp.com/docs/en/data-sheet/P3T1085UK.pdf

+  * NXP P3T2030
+
+    Prefix: 'p3t2030'
+
+    Addresses scanned: none
+
+    Datasheet: https://www.nxp.com/docs/en/data-sheet/P3T1035XUK_P3T2030XUK.pdf
+
   * Texas Instruments TMP108

     Prefix: 'tmp108'
--
2.34.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/3] hwmon: (tmp108) Add support for P3T1035 and P3T2030
  2026-01-15  6:57 [PATCH v2 1/3] hwmon: (tmp108) Add support for P3T1035 and P3T2030 Mayank Mahajan
  2026-01-15  6:57 ` [PATCH v2 2/3] dt-bindings: hwmon: ti,tmp108: Add P3T1035,P3T2030 Mayank Mahajan
  2026-01-15  6:57 ` [PATCH v2 3/3] hwmon: (tmp108) Add P3T1035 and P3T2030 support Mayank Mahajan
@ 2026-01-15  8:53 ` Krzysztof Kozlowski
  2026-01-15 12:34 ` kernel test robot
  2026-01-15 14:22 ` kernel test robot
  4 siblings, 0 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-15  8:53 UTC (permalink / raw)
  To: Mayank Mahajan, linux, corbet, robh, krzk+dt, conor+dt,
	linux-hwmon, devicetree, linux-doc, linux-kernel
  Cc: priyanka.jain, vikash.bansal

On 15/01/2026 07:57, Mayank Mahajan wrote:

> @@ -369,7 +486,7 @@ static int tmp108_common_probe(struct device *dev, struct regmap *regmap, char *
> 
>  	err = devm_add_action_or_reset(dev, tmp108_restore_config, tmp108);
>  	if (err) {
> -		dev_err(dev, "add action or reset failed: %d", err);
> +		dev_err_probe(dev, err, "Add action or reset failed");

How is this relevant to new device? Do not mix independent changes into
one commit. Please carefully read submitting patches, although this is
generic programming practice and nothing specific to kernel.

>  		return err;
>  	}
> 
> @@ -384,17 +501,34 @@ static int tmp108_probe(struct i2c_client *client)
>  {
>  	struct device *dev = &client->dev;
>  	struct regmap *regmap;
> +	enum tmp108_hw_id hw_id;
> +	const void *of_data;
> 
>  	if (!i2c_check_functionality(client->adapter,
> -				     I2C_FUNC_SMBUS_WORD_DATA))
> -		return dev_err_probe(dev, -ENODEV,
> +				     I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA))
> +		return dev_err_probe(dev, -EOPNOTSUPP,
>  				     "adapter doesn't support SMBus word transactions\n");

I do not see how changing error code is related/relevant to new device
support...

> 
> -	regmap = devm_regmap_init_i2c(client, &tmp108_regmap_config);
> +	regmap = devm_regmap_init(dev, &tmp108_i2c_regmap_bus, client, &tmp108_regmap_config);
>  	if (IS_ERR(regmap))
>  		return dev_err_probe(dev, PTR_ERR(regmap), "regmap init failed");
> 
> -	return tmp108_common_probe(dev, regmap, client->name);
> +	/* Prefer OF match data (DT-first systems) */
> +	of_data = device_get_match_data(&client->dev);
> +	if (of_data) {
> +		hw_id = (enum tmp108_hw_id)(uintptr_t)of_data;

Completely mixed up cases. First, do not use uintptr_t. Second, last
enum cast is not needed. You only need cast via unsigned long.

> +	} else {
> +		/* Fall back to legacy I2C ID table */
> +		const struct i2c_device_id *id = i2c_client_get_device_id(client);
> +
> +		if (!id) {
> +			dev_err_probe(dev, -ENODEV, "No matching device ID for i2c device\n");
> +			return -ENODEV;

Syntax is return dev_err_probe. Look above - just few lines above you
have it right, so you are you introducing different syntax?

> +		}
> +		hw_id = (enum tmp108_hw_id)id->driver_data;

And this should cause build warnings on W=1.

Are you sure you build tested it with different compilers, with W=1, for
32 and 64 bit platforms?

> +	}
> +
> +	return tmp108_common_probe(dev, regmap, client->name, hw_id);
>  }
> 


> 
>  static const struct of_device_id tmp108_of_ids[] = {
> -	{ .compatible = "nxp,p3t1085", },
> -	{ .compatible = "ti,tmp108", },
> -	{}
> +	{ .compatible = "nxp,p3t1035", .data = (void *)(uintptr_t)P3T1035_ID },
> +	{ .compatible = "nxp,p3t1085", .data = (void *)(uintptr_t)P3T1085_ID },
> +	{ .compatible = "nxp,p3t2030", .data = (void *)(uintptr_t)P3T1035_ID },

So devices are compatible? If so, drop this and express it in the bindings.

> +	{ .compatible = "ti,tmp108", .data = (void *)(uintptr_t)TMP108_ID },
> +	{ /* sentinel */ },

Please organize the patch documenting the compatible (DT bindings)
before the patch using that compatible.
See also:
https://elixir.bootlin.com/linux/v6.14-rc6/source/Documentation/devicetree/bindings/submitting-patches.rst#L46



Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/3] dt-bindings: hwmon: ti,tmp108: Add P3T1035,P3T2030
  2026-01-15  6:57 ` [PATCH v2 2/3] dt-bindings: hwmon: ti,tmp108: Add P3T1035,P3T2030 Mayank Mahajan
@ 2026-01-15  9:36   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2026-01-15  9:36 UTC (permalink / raw)
  To: Mayank Mahajan
  Cc: linux, corbet, robh, krzk+dt, conor+dt, linux-hwmon, devicetree,
	linux-doc, linux-kernel, priyanka.jain, vikash.bansal

On Thu, Jan 15, 2026 at 12:27:56PM +0530, Mayank Mahajan wrote:
>  properties:
>    compatible:
>      enum:
> +      - nxp,p3t1035
>        - nxp,p3t1085
> +      - nxp,p3t2030

Your driver code suggests these are compatible, so express
compatibility (see talks, example-schema, writing bindings).

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/3] hwmon: (tmp108) Add support for P3T1035 and P3T2030
  2026-01-15  6:57 [PATCH v2 1/3] hwmon: (tmp108) Add support for P3T1035 and P3T2030 Mayank Mahajan
                   ` (2 preceding siblings ...)
  2026-01-15  8:53 ` [PATCH v2 1/3] hwmon: (tmp108) Add support for P3T1035 and P3T2030 Krzysztof Kozlowski
@ 2026-01-15 12:34 ` kernel test robot
  2026-01-15 14:22 ` kernel test robot
  4 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2026-01-15 12:34 UTC (permalink / raw)
  To: Mayank Mahajan, linux, corbet, robh, krzk+dt, conor+dt,
	linux-hwmon, devicetree, linux-doc, linux-kernel
  Cc: oe-kbuild-all, priyanka.jain, vikash.bansal, Mayank Mahajan

Hi Mayank,

kernel test robot noticed the following build errors:

[auto build test ERROR on groeck-staging/hwmon-next]
[also build test ERROR on linus/master v6.19-rc5 next-20260115]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Mayank-Mahajan/dt-bindings-hwmon-ti-tmp108-Add-P3T1035-P3T2030/20260115-145945
base:   https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
patch link:    https://lore.kernel.org/r/20260115065757.35-1-mayankmahajan.x%40nxp.com
patch subject: [PATCH v2 1/3] hwmon: (tmp108) Add support for P3T1035 and P3T2030
config: arm-randconfig-r072-20260115 (https://download.01.org/0day-ci/archive/20260115/202601152046.9FkRF3Hu-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 11.5.0
smatch version: v0.5.0-8985-g2614ff1a
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260115/202601152046.9FkRF3Hu-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601152046.9FkRF3Hu-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   drivers/hwmon/tmp108.c: In function 'tmp108_common_probe':
>> drivers/hwmon/tmp108.c:457:52: error: macro "memcpy" passed 6 arguments, but takes just 3
     457 |                        sizeof(tmp108->sample_times));
         |                                                    ^
   In file included from include/linux/string.h:386,
                    from include/linux/bitmap.h:13,
                    from include/linux/cpumask.h:11,
                    from include/linux/smp.h:13,
                    from include/linux/lockdep.h:14,
                    from include/linux/spinlock.h:63,
                    from include/linux/sched.h:37,
                    from include/linux/delay.h:13,
                    from drivers/hwmon/tmp108.c:7:
   include/linux/fortify-string.h:690: note: macro "memcpy" defined here
     690 | #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
         | 
>> drivers/hwmon/tmp108.c:456:17: warning: statement with no effect [-Wunused-value]
     456 |                 memcpy(tmp108->sample_times, (unsigned int[]){ 125, 250, 1000, 4000 },
         |                 ^~~~~~
   drivers/hwmon/tmp108.c:460:52: error: macro "memcpy" passed 6 arguments, but takes just 3
     460 |                        sizeof(tmp108->sample_times));
         |                                                    ^
   In file included from include/linux/string.h:386,
                    from include/linux/bitmap.h:13,
                    from include/linux/cpumask.h:11,
                    from include/linux/smp.h:13,
                    from include/linux/lockdep.h:14,
                    from include/linux/spinlock.h:63,
                    from include/linux/sched.h:37,
                    from include/linux/delay.h:13,
                    from drivers/hwmon/tmp108.c:7:
   include/linux/fortify-string.h:690: note: macro "memcpy" defined here
     690 | #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
         | 
   drivers/hwmon/tmp108.c:459:17: warning: statement with no effect [-Wunused-value]
     459 |                 memcpy(tmp108->sample_times, (unsigned int[]){ 63, 250, 1000, 4000 },
         |                 ^~~~~~


vim +/memcpy +457 drivers/hwmon/tmp108.c

   434	
   435	static int tmp108_common_probe(struct device *dev, struct regmap *regmap, char *name,
   436				       enum tmp108_hw_id hw_id)
   437	{
   438		struct device *hwmon_dev;
   439		struct tmp108 *tmp108;
   440		u32 config;
   441		int err;
   442	
   443		err = devm_regulator_get_enable(dev, "vcc");
   444		if (err)
   445			return dev_err_probe(dev, err, "Failed to enable regulator\n");
   446	
   447		tmp108 = devm_kzalloc(dev, sizeof(*tmp108), GFP_KERNEL);
   448		if (!tmp108)
   449			return -ENOMEM;
   450	
   451		dev_set_drvdata(dev, tmp108);
   452		tmp108->regmap = regmap;
   453		tmp108->hw_id = hw_id;
   454		tmp108->config_reg_16bits = (hw_id == P3T1035_ID) ? false : true;
   455		if (hw_id == P3T1035_ID)
 > 456			memcpy(tmp108->sample_times, (unsigned int[]){ 125, 250, 1000, 4000 },
 > 457			       sizeof(tmp108->sample_times));
   458		else
   459			memcpy(tmp108->sample_times, (unsigned int[]){ 63, 250, 1000, 4000 },
   460			       sizeof(tmp108->sample_times));
   461	
   462		err = regmap_read(tmp108->regmap, TMP108_REG_CONF, &config);
   463		if (err < 0) {
   464			dev_err_probe(dev, err, "Error reading config register");
   465			return err;
   466		}
   467		tmp108->orig_config = config;
   468	
   469		/* Only continuous mode is supported. */
   470		config &= ~TMP108_CONF_MODE_MASK;
   471		config |= TMP108_MODE_CONTINUOUS;
   472		/* Only comparator mode is supported. */
   473		config &= ~TMP108_CONF_TM;
   474	
   475		err = regmap_write(tmp108->regmap, TMP108_REG_CONF, config);
   476		if (err < 0) {
   477			dev_err_probe(dev, err, "Error writing config register");
   478			return err;
   479		}
   480	
   481		tmp108->ready_time = jiffies;
   482		if ((tmp108->orig_config & TMP108_CONF_MODE_MASK) ==
   483		    TMP108_MODE_SHUTDOWN)
   484			tmp108->ready_time +=
   485				msecs_to_jiffies(TMP108_CONVERSION_TIME_MS);
   486	
   487		err = devm_add_action_or_reset(dev, tmp108_restore_config, tmp108);
   488		if (err) {
   489			dev_err_probe(dev, err, "Add action or reset failed");
   490			return err;
   491		}
   492	
   493		hwmon_dev = devm_hwmon_device_register_with_info(dev, name,
   494								 tmp108,
   495								 &tmp108_chip_info,
   496								 NULL);
   497		return PTR_ERR_OR_ZERO(hwmon_dev);
   498	}
   499	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/3] hwmon: (tmp108) Add support for P3T1035 and P3T2030
  2026-01-15  6:57 [PATCH v2 1/3] hwmon: (tmp108) Add support for P3T1035 and P3T2030 Mayank Mahajan
                   ` (3 preceding siblings ...)
  2026-01-15 12:34 ` kernel test robot
@ 2026-01-15 14:22 ` kernel test robot
  4 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2026-01-15 14:22 UTC (permalink / raw)
  To: Mayank Mahajan, linux, corbet, robh, krzk+dt, conor+dt,
	linux-hwmon, devicetree, linux-doc, linux-kernel
  Cc: oe-kbuild-all, priyanka.jain, vikash.bansal, Mayank Mahajan

Hi Mayank,

kernel test robot noticed the following build errors:

[auto build test ERROR on groeck-staging/hwmon-next]
[also build test ERROR on linus/master v6.19-rc5 next-20260115]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Mayank-Mahajan/dt-bindings-hwmon-ti-tmp108-Add-P3T1035-P3T2030/20260115-145945
base:   https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
patch link:    https://lore.kernel.org/r/20260115065757.35-1-mayankmahajan.x%40nxp.com
patch subject: [PATCH v2 1/3] hwmon: (tmp108) Add support for P3T1035 and P3T2030
config: sparc-randconfig-001-20260115 (https://download.01.org/0day-ci/archive/20260115/202601152241.dTXwVh7v-lkp@intel.com/config)
compiler: sparc-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260115/202601152241.dTXwVh7v-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601152241.dTXwVh7v-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/hwmon/tmp108.c: In function 'tmp108_common_probe':
   drivers/hwmon/tmp108.c:457:52: error: macro 'memcpy' passed 6 arguments, but takes just 3
     457 |                        sizeof(tmp108->sample_times));
         |                                                    ^
   In file included from include/linux/string.h:65,
                    from include/linux/bitmap.h:13,
                    from include/linux/cpumask.h:11,
                    from arch/sparc/include/asm/smp_32.h:15,
                    from arch/sparc/include/asm/smp.h:7,
                    from arch/sparc/include/asm/switch_to_32.h:5,
                    from arch/sparc/include/asm/switch_to.h:7,
                    from arch/sparc/include/asm/ptrace.h:120,
                    from arch/sparc/include/asm/thread_info_32.h:19,
                    from arch/sparc/include/asm/thread_info.h:7,
                    from include/linux/thread_info.h:60,
                    from arch/sparc/include/asm/current.h:15,
                    from include/linux/sched.h:12,
                    from include/linux/delay.h:13,
                    from drivers/hwmon/tmp108.c:7:
   arch/sparc/include/asm/string.h:15:9: note: macro 'memcpy' defined here
      15 | #define memcpy(t, f, n) __builtin_memcpy(t, f, n)
         |         ^~~~~~
>> drivers/hwmon/tmp108.c:456:17: error: 'memcpy' undeclared (first use in this function)
     456 |                 memcpy(tmp108->sample_times, (unsigned int[]){ 125, 250, 1000, 4000 },
         |                 ^~~~~~
   drivers/hwmon/tmp108.c:19:1: note: 'memcpy' is defined in header '<string.h>'; this is probably fixable by adding '#include <string.h>'
      18 | #include <linux/regmap.h>
     +++ |+#include <string.h>
      19 | #include <linux/regulator/consumer.h>
   drivers/hwmon/tmp108.c:456:17: note: each undeclared identifier is reported only once for each function it appears in
     456 |                 memcpy(tmp108->sample_times, (unsigned int[]){ 125, 250, 1000, 4000 },
         |                 ^~~~~~
   drivers/hwmon/tmp108.c:460:52: error: macro 'memcpy' passed 6 arguments, but takes just 3
     460 |                        sizeof(tmp108->sample_times));
         |                                                    ^
   arch/sparc/include/asm/string.h:15:9: note: macro 'memcpy' defined here
      15 | #define memcpy(t, f, n) __builtin_memcpy(t, f, n)
         |         ^~~~~~


vim +/memcpy +456 drivers/hwmon/tmp108.c

   434	
   435	static int tmp108_common_probe(struct device *dev, struct regmap *regmap, char *name,
   436				       enum tmp108_hw_id hw_id)
   437	{
   438		struct device *hwmon_dev;
   439		struct tmp108 *tmp108;
   440		u32 config;
   441		int err;
   442	
   443		err = devm_regulator_get_enable(dev, "vcc");
   444		if (err)
   445			return dev_err_probe(dev, err, "Failed to enable regulator\n");
   446	
   447		tmp108 = devm_kzalloc(dev, sizeof(*tmp108), GFP_KERNEL);
   448		if (!tmp108)
   449			return -ENOMEM;
   450	
   451		dev_set_drvdata(dev, tmp108);
   452		tmp108->regmap = regmap;
   453		tmp108->hw_id = hw_id;
   454		tmp108->config_reg_16bits = (hw_id == P3T1035_ID) ? false : true;
   455		if (hw_id == P3T1035_ID)
 > 456			memcpy(tmp108->sample_times, (unsigned int[]){ 125, 250, 1000, 4000 },
   457			       sizeof(tmp108->sample_times));
   458		else
   459			memcpy(tmp108->sample_times, (unsigned int[]){ 63, 250, 1000, 4000 },
   460			       sizeof(tmp108->sample_times));
   461	
   462		err = regmap_read(tmp108->regmap, TMP108_REG_CONF, &config);
   463		if (err < 0) {
   464			dev_err_probe(dev, err, "Error reading config register");
   465			return err;
   466		}
   467		tmp108->orig_config = config;
   468	
   469		/* Only continuous mode is supported. */
   470		config &= ~TMP108_CONF_MODE_MASK;
   471		config |= TMP108_MODE_CONTINUOUS;
   472		/* Only comparator mode is supported. */
   473		config &= ~TMP108_CONF_TM;
   474	
   475		err = regmap_write(tmp108->regmap, TMP108_REG_CONF, config);
   476		if (err < 0) {
   477			dev_err_probe(dev, err, "Error writing config register");
   478			return err;
   479		}
   480	
   481		tmp108->ready_time = jiffies;
   482		if ((tmp108->orig_config & TMP108_CONF_MODE_MASK) ==
   483		    TMP108_MODE_SHUTDOWN)
   484			tmp108->ready_time +=
   485				msecs_to_jiffies(TMP108_CONVERSION_TIME_MS);
   486	
   487		err = devm_add_action_or_reset(dev, tmp108_restore_config, tmp108);
   488		if (err) {
   489			dev_err_probe(dev, err, "Add action or reset failed");
   490			return err;
   491		}
   492	
   493		hwmon_dev = devm_hwmon_device_register_with_info(dev, name,
   494								 tmp108,
   495								 &tmp108_chip_info,
   496								 NULL);
   497		return PTR_ERR_OR_ZERO(hwmon_dev);
   498	}
   499	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-01-15 14:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-15  6:57 [PATCH v2 1/3] hwmon: (tmp108) Add support for P3T1035 and P3T2030 Mayank Mahajan
2026-01-15  6:57 ` [PATCH v2 2/3] dt-bindings: hwmon: ti,tmp108: Add P3T1035,P3T2030 Mayank Mahajan
2026-01-15  9:36   ` Krzysztof Kozlowski
2026-01-15  6:57 ` [PATCH v2 3/3] hwmon: (tmp108) Add P3T1035 and P3T2030 support Mayank Mahajan
2026-01-15  8:53 ` [PATCH v2 1/3] hwmon: (tmp108) Add support for P3T1035 and P3T2030 Krzysztof Kozlowski
2026-01-15 12:34 ` kernel test robot
2026-01-15 14:22 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox