* [PATCH v4 0/2] iio: temperature: Add support for NXP P3T175x temperature sensors
@ 2025-10-08 10:07 Lakshay Piplani
2025-10-08 10:07 ` [PATCH v4 1/2] dt-bindings: iio: temperature: Add NXP P3T175x support Lakshay Piplani
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Lakshay Piplani @ 2025-10-08 10:07 UTC (permalink / raw)
To: linux-kernel, linux-iio, jic23, dlechner, nuno.sa, andy,
marcelo.schmitt1, gregkh, viro, peterz, jstephan, robh, krzk+dt,
conor+dt, devicetree
Cc: jdelvare, linux, vikash.bansal, priyanka.jain,
shashank.rebbapragada, Lakshay Piplani
This patch adds support for the P3T1750/P3T1755 temperature sensors under the IIO subsystem.
P3T1750/P3T1755 support two operational modes:
1. Comparator Mode
2. Interrupt (Latched) Mode
The HWMON subsystem is more suitable for implementing drivers for comparator mode operations.
Reason:
- Temperature thresholds can be polled and exposed via sysfs.
- Register reads do not clear status, allowing safe alarm state derivation.
- Matches existing drivers under hwmon.
The IIO subsystem is more suitable for implementing drivers for interrupt (latched) mode operations.
Reason:
- Interrupt mode uses edge-triggered ALERT/IBI signal interrupts, which can be pushed to user space using iio_push_event.
- IIO’s event API (IIO_EV_TYPE_THRESH) supports timestamped rising/falling edge events.
- I3C IBI integration maps naturally to IIO’s event push model.
- No persistent alarm bits are available; so polling in HWMON may result in missing events.
This patch adds interrupt mode support under IIO while leaving comparator mode support in hwmon untouched.
The split reflects the sensor’s dual behavior and aligns with subsystem semantics.
Changes since v3:
- Added cover letter for the first time.
- Updated commit message to clarify P3T1750 vs P3T1755 difference.
- Minor cleanups and style fixes.
Thanks for your time and review.
-------------------------------------------------
Lakshay Piplani (2):
dt-bindings: iio: temperature: Add NXP P3T175x support
iio: temperature: Add driver for NXP P3T175x temperature sensor
.../bindings/iio/temperature/nxp,p3t1755.yaml | 62 +++
drivers/iio/temperature/Kconfig | 2 +
drivers/iio/temperature/p3t/Kconfig | 28 ++
drivers/iio/temperature/p3t/Makefile | 5 +
drivers/iio/temperature/p3t/p3t1755.h | 45 +++
drivers/iio/temperature/p3t/p3t1755_core.c | 363 ++++++++++++++++++
drivers/iio/temperature/p3t/p3t1755_i2c.c | 67 ++++
drivers/iio/temperature/p3t/p3t1755_i3c.c | 108 ++++++
8 files changed, 680 insertions(+)
create mode 100644 Documentation/devicetree/bindings/iio/temperature/nxp,p3t1755.yaml
create mode 100644 drivers/iio/temperature/p3t/Kconfig
create mode 100644 drivers/iio/temperature/p3t/Makefile
create mode 100644 drivers/iio/temperature/p3t/p3t1755.h
create mode 100644 drivers/iio/temperature/p3t/p3t1755_core.c
create mode 100644 drivers/iio/temperature/p3t/p3t1755_i2c.c
create mode 100644 drivers/iio/temperature/p3t/p3t1755_i3c.c
--
2.25.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v4 1/2] dt-bindings: iio: temperature: Add NXP P3T175x support
2025-10-08 10:07 [PATCH v4 0/2] iio: temperature: Add support for NXP P3T175x temperature sensors Lakshay Piplani
@ 2025-10-08 10:07 ` Lakshay Piplani
2025-10-08 21:01 ` Conor Dooley
2025-10-12 17:10 ` Jonathan Cameron
2025-10-08 10:07 ` [PATCH v4 2/2] iio: temperature: Add driver for NXP P3T175x temperature sensor Lakshay Piplani
2025-10-08 14:10 ` [PATCH v4 0/2] iio: temperature: Add support for NXP P3T175x temperature sensors Guenter Roeck
2 siblings, 2 replies; 9+ messages in thread
From: Lakshay Piplani @ 2025-10-08 10:07 UTC (permalink / raw)
To: linux-kernel, linux-iio, jic23, dlechner, nuno.sa, andy,
marcelo.schmitt1, gregkh, viro, peterz, jstephan, robh, krzk+dt,
conor+dt, devicetree
Cc: jdelvare, linux, vikash.bansal, priyanka.jain,
shashank.rebbapragada, Lakshay Piplani
Add bindings for the NXP P3T175x (P3T1750/P3T1755) temperature
sensor, supporting both I2C & I3C interfaces.
The P3T1750 and P3T1755 are functionally equivalent temperature
sensors with identical interfaces and features. The P3T1755 offers
improved accuracy(±0.5°C) in the –20°C to +85°C range, while both
maintain ±1°C accuracy across –40°C to +125°C.
Signed-off-by: Lakshay Piplani <lakshay.piplani@nxp.com>
---
V3 -> V4: Changes since V3:
- Updated commit message to clarify the difference between P3T1750 and P3T1755.
V2 -> V3: Changes since V2:
- Removed nxp,interrupt-mode and nxp,fault-queue properties from DT binding
- Updated compatible strings:
- nxp,p3t1750-iio → nxp,p3t1750dp
- nxp,p3t1755-iio → nxp,p3t1755dp
V1 -> V2: Changes since V1:
- Dropped nxp,alert-active-high
- Fixed YAML formatting, line wrapping, and examples
.../bindings/iio/temperature/nxp,p3t1755.yaml | 62 +++++++++++++++++++
1 file changed, 62 insertions(+)
create mode 100644 Documentation/devicetree/bindings/iio/temperature/nxp,p3t1755.yaml
diff --git a/Documentation/devicetree/bindings/iio/temperature/nxp,p3t1755.yaml b/Documentation/devicetree/bindings/iio/temperature/nxp,p3t1755.yaml
new file mode 100644
index 000000000000..16a01fa81251
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/temperature/nxp,p3t1755.yaml
@@ -0,0 +1,62 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/temperature/nxp,p3t1755.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NXP P3T175xDP Temperature Sensor
+
+maintainers:
+ - Lakshay Piplani <lakshay.piplani@nxp.com>
+
+description: |
+ Datasheet: https://www.nxp.com/docs/en/data-sheet/P3T1755.pdf
+
+ P3T175xDP (P3T1750/P3T1755) is a digital temperature sensor with a range of
+ -40°C to +125°C and a 12-bit resolution. It supports communication over both
+ I2C and I3C interfaces.
+
+ The I2C interface supports up to 32 static addresses and provides an ALERT
+ output to signal when temperature thresholds are crossed.
+
+ The I3C interface supports In-Band interrupts (IBI) in interrupt mode,
+ allowing the device to notify the controller of threshold events without
+ dedicated alert pin.
+
+properties:
+ compatible:
+ enum:
+ - nxp,p3t1750dp
+ - nxp,p3t1755dp
+
+ interrupts:
+ maxItems: 1
+
+ reg:
+ maxItems: 1
+ description: |
+ In I2C mode, the device supports up to 32 static addresses.
+ In I3C mode, the 'reg' property encodes a triplet of
+ <static-address BCR PID> used for device matching.
+ Static address is optional if matching is done via PID.
+
+required:
+ - compatible
+ - reg
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/interrupt-controller/irq.h>
+ i2c {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ temp-sensor@48 {
+ compatible = "nxp,p3t1755dp";
+ reg = <0x48>;
+ interrupt-parent = <&gpio2>;
+ interrupts = <3 IRQ_TYPE_EDGE_FALLING>;
+ };
+ };
--
2.25.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 2/2] iio: temperature: Add driver for NXP P3T175x temperature sensor
2025-10-08 10:07 [PATCH v4 0/2] iio: temperature: Add support for NXP P3T175x temperature sensors Lakshay Piplani
2025-10-08 10:07 ` [PATCH v4 1/2] dt-bindings: iio: temperature: Add NXP P3T175x support Lakshay Piplani
@ 2025-10-08 10:07 ` Lakshay Piplani
2025-10-08 14:10 ` [PATCH v4 0/2] iio: temperature: Add support for NXP P3T175x temperature sensors Guenter Roeck
2 siblings, 0 replies; 9+ messages in thread
From: Lakshay Piplani @ 2025-10-08 10:07 UTC (permalink / raw)
To: linux-kernel, linux-iio, jic23, dlechner, nuno.sa, andy,
marcelo.schmitt1, gregkh, viro, peterz, jstephan, robh, krzk+dt,
conor+dt, devicetree
Cc: jdelvare, linux, vikash.bansal, priyanka.jain,
shashank.rebbapragada, Lakshay Piplani
Add support for the NXP P3T175x (P3T1750/P3T1755) family of temperature
sensor devices. These devices communicates via both I2C or I3C interfaces.
Signed-off-by: Lakshay Piplani <lakshay.piplani@nxp.com>
---
V3 -> V4: Changes since V3
- Added cover letter for the first time in the series.
- Replaced wildcard driver name `p3t175x_i2c` with specific part number `p3t1755_i2c`.
- Removed unnecessary cast in `p3t1755_free_ibi()` (void * to struct i3c_device *).
- Dropped error print for `devm_add_action_or_reset()` as only -ENOMEM is expected.
V2 -> V3: Changes since V2:
- Dropped nxp,interrupt-mode and nxp,fault-queue from driver and YAML (not suitable for DT)
- Removed trigger_one_shot sysfs attribute and its ABI doc
- Applied IWYU principle: cleaned up unused headers
- Fixed sampling frequency handling
- Removed dev_err/dev_dbg statements wherever not necessary
V1 -> V2: Changes since V1:
- Added endian-safe handling for register read (__be16 conversion)
- Replaced manual bit masking with FIELD_GET bit extraction
- Dropped sysfs attributes for fault queue length and thermostat mode (comparator or interrupt)
- Added ABI doc: Documentation/ABI/testing/sysfs-bus-iio-temperature-p3t1755 describing
trigger_one_shot attribute
- Updated Kconfig to allow building both I2C and I3C drivers simultaneously
- I3C: switched to device_property_* from of_property_*
- Added devm_add_action_or_reset() for IBI disable/free
drivers/iio/temperature/Kconfig | 2 +
drivers/iio/temperature/p3t/Kconfig | 28 ++
drivers/iio/temperature/p3t/Makefile | 5 +
drivers/iio/temperature/p3t/p3t1755.h | 45 +++
drivers/iio/temperature/p3t/p3t1755_core.c | 363 +++++++++++++++++++++
drivers/iio/temperature/p3t/p3t1755_i2c.c | 67 ++++
drivers/iio/temperature/p3t/p3t1755_i3c.c | 108 ++++++
7 files changed, 618 insertions(+)
create mode 100644 drivers/iio/temperature/p3t/Kconfig
create mode 100644 drivers/iio/temperature/p3t/Makefile
create mode 100644 drivers/iio/temperature/p3t/p3t1755.h
create mode 100644 drivers/iio/temperature/p3t/p3t1755_core.c
create mode 100644 drivers/iio/temperature/p3t/p3t1755_i2c.c
create mode 100644 drivers/iio/temperature/p3t/p3t1755_i3c.c
diff --git a/drivers/iio/temperature/Kconfig b/drivers/iio/temperature/Kconfig
index 1244d8e17d50..d249721c1ea1 100644
--- a/drivers/iio/temperature/Kconfig
+++ b/drivers/iio/temperature/Kconfig
@@ -182,4 +182,6 @@ config MCP9600
This driver can also be built as a module. If so, the module
will be called mcp9600.
+source "drivers/iio/temperature/p3t/Kconfig"
+
endmenu
diff --git a/drivers/iio/temperature/p3t/Kconfig b/drivers/iio/temperature/p3t/Kconfig
new file mode 100644
index 000000000000..0cfd881e065b
--- /dev/null
+++ b/drivers/iio/temperature/p3t/Kconfig
@@ -0,0 +1,28 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+config IIO_P3T1755
+ tristate
+ depends on (I2C || I3C)
+
+config IIO_P3T1755_I2C
+ tristate "NXP P3T1755 temperature sensor I2C driver"
+ select IIO_P3T1755
+ select REGMAP_I2C
+ help
+ Say yes here to build support for NXP P3T1755 I2C temperature
+ sensor.
+
+ To compile this driver as a module, choose M here: the module
+ will be called p3t1755_i2c
+
+config IIO_P3T1755_I3C
+ tristate "NXP P3T1755 temperature sensor I3C driver"
+ select IIO_P3T1755
+ select REGMAP_I3C
+ depends on I3C
+ help
+ Say yes here to build support for NXP P3T1755 I3C temperature
+ sensor.
+
+ To compile this driver as a module, choose M here: the module
+ will be called p3t1755_i3c
diff --git a/drivers/iio/temperature/p3t/Makefile b/drivers/iio/temperature/p3t/Makefile
new file mode 100644
index 000000000000..7d33b507f1f1
--- /dev/null
+++ b/drivers/iio/temperature/p3t/Makefile
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+obj-$(CONFIG_IIO_P3T1755) += p3t1755_core.o
+obj-$(CONFIG_IIO_P3T1755_I2C) += p3t1755_i2c.o
+obj-$(CONFIG_IIO_P3T1755_I3C) += p3t1755_i3c.o
diff --git a/drivers/iio/temperature/p3t/p3t1755.h b/drivers/iio/temperature/p3t/p3t1755.h
new file mode 100644
index 000000000000..29bf57e4ce89
--- /dev/null
+++ b/drivers/iio/temperature/p3t/p3t1755.h
@@ -0,0 +1,45 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * NXP P3T175x Temperature Sensor Driver
+ *
+ * Copyright 2025 NXP
+ */
+#ifndef P3T1755_H
+#define P3T1755_H
+
+#include <linux/bits.h>
+#include <linux/iio/iio.h>
+
+#define P3T1755_REG_TEMP 0x0
+#define P3T1755_REG_CFGR 0x1
+#define P3T1755_REG_LOW_LIM 0x2
+#define P3T1755_REG_HIGH_LIM 0x3
+
+#define P3T1755_SHUTDOWN_BIT BIT(0)
+#define P3T1755_TM_BIT BIT(1)
+
+#define P3T1755_CONVERSION_TIME_BITS GENMASK(6, 5)
+
+#define MICRO 1000000
+
+struct p3t1755_info {
+ const char *name;
+ const struct iio_chan_spec *channels;
+ int num_channels;
+};
+
+struct p3t1755_data {
+ struct device *dev;
+ struct regmap *regmap;
+};
+
+extern const struct p3t1755_info p3t1750_channels_info;
+extern const struct p3t1755_info p3t1755_channels_info;
+
+int p3t1755_probe(struct device *dev, const struct p3t1755_info *chip,
+ struct regmap *regmap, int irq);
+int p3t1755_get_temp_and_limits(struct p3t1755_data *data,
+ int *temp_raw, int *thigh_raw, int *tlow_raw);
+void p3t1755_push_thresh_event(struct iio_dev *indio_dev);
+
+#endif /* P3T1755_H */
diff --git a/drivers/iio/temperature/p3t/p3t1755_core.c b/drivers/iio/temperature/p3t/p3t1755_core.c
new file mode 100644
index 000000000000..c7216e3fab06
--- /dev/null
+++ b/drivers/iio/temperature/p3t/p3t1755_core.c
@@ -0,0 +1,363 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * NXP P3T175x Temperature Sensor Driver
+ *
+ * Copyright 2025 NXP
+ */
+#include <linux/bitops.h>
+#include <linux/bitfield.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/regmap.h>
+#include <linux/types.h>
+
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/events.h>
+
+#include "p3t1755.h"
+
+static const u32 p3t1755_samp_freqs_uhz[] = {
+ 36363636,
+ 18181818,
+ 9090909,
+ 4545454
+};
+
+int p3t1755_get_temp_and_limits(struct p3t1755_data *data,
+ int *temp_raw, int *thigh_raw, int *tlow_raw)
+{
+ __be16 be;
+ int ret;
+ int raw12;
+
+ ret = regmap_bulk_read(data->regmap, P3T1755_REG_TEMP, &be, sizeof(be));
+ if (ret)
+ return ret;
+
+ raw12 = sign_extend32(be16_to_cpu(be) >> 4, 11);
+ *temp_raw = raw12;
+
+ ret = regmap_bulk_read(data->regmap, P3T1755_REG_HIGH_LIM, &be, sizeof(be));
+ if (ret)
+ return ret;
+
+ raw12 = sign_extend32(be16_to_cpu(be) >> 4, 11);
+ *thigh_raw = raw12;
+
+ ret = regmap_bulk_read(data->regmap, P3T1755_REG_LOW_LIM, &be, sizeof(be));
+ if (ret)
+ return ret;
+
+ raw12 = sign_extend32(be16_to_cpu(be) >> 4, 11);
+ *tlow_raw = raw12;
+
+ return 0;
+}
+EXPORT_SYMBOL_NS_GPL(p3t1755_get_temp_and_limits, IIO_P3T1755);
+
+void p3t1755_push_thresh_event(struct iio_dev *indio_dev)
+{
+ struct p3t1755_data *data = iio_priv(indio_dev);
+ int ret, temp, thigh, tlow;
+ unsigned int cfgr;
+
+ /*
+ * Read CFGR register to check device mode and implicitly clear the ALERT latch.
+ * As per Datasheet: "Any register read will clear the interrupt"
+ */
+ ret = regmap_read(data->regmap, P3T1755_REG_CFGR, &cfgr);
+ if (ret) {
+ dev_err(data->dev, "Failed to read CFGR register: %d\n", ret);
+ return;
+ }
+
+ if (FIELD_GET(P3T1755_SHUTDOWN_BIT, cfgr)) {
+ dev_dbg(data->dev, "Device is in shutdown mode, skipping event push\n");
+ return;
+ }
+
+ ret = p3t1755_get_temp_and_limits(data, &temp, &thigh, &tlow);
+ if (ret) {
+ dev_err(data->dev, "Failed to get temperature and limits: %d\n", ret);
+ return;
+ }
+
+ if (temp >= thigh || temp <= tlow) {
+ dev_dbg(data->dev, "Threshold event: DIR_EITHER (T=%d, TH=%d, TL=%d)\n",
+ temp, thigh, tlow);
+
+ iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_TEMP, 0, IIO_NO_MOD,
+ IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER),
+ iio_get_time_ns(indio_dev));
+ } else {
+ dev_dbg(data->dev, "Temperature within limits: no event triggered (T=%d, TH=%d, TL=%d)\n",
+ temp, thigh, tlow);
+ }
+}
+EXPORT_SYMBOL_NS_GPL(p3t1755_push_thresh_event, IIO_P3T1755);
+
+static int p3t1755_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *channel, int *val,
+ int *val2, long mask)
+{
+ struct p3t1755_data *data = iio_priv(indio_dev);
+ unsigned int cfgr;
+ __be16 be;
+ int ret;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_RAW:
+ ret = regmap_bulk_read(data->regmap, P3T1755_REG_TEMP, &be, sizeof(be));
+ if (ret)
+ return ret;
+
+ *val = sign_extend32(be16_to_cpu(be) >> 4, 11);
+
+ return IIO_VAL_INT;
+
+ case IIO_CHAN_INFO_SCALE:
+ *val = 625;
+ *val2 = 10000;
+
+ return IIO_VAL_FRACTIONAL;
+
+ case IIO_CHAN_INFO_ENABLE:
+ ret = regmap_read(data->regmap, P3T1755_REG_CFGR, &cfgr);
+ if (ret)
+ return ret;
+
+ *val = !FIELD_GET(P3T1755_SHUTDOWN_BIT, cfgr);
+
+ return IIO_VAL_INT;
+
+ case IIO_CHAN_INFO_SAMP_FREQ: {
+ unsigned int freq_uhz;
+ u8 sel;
+
+ ret = regmap_read(data->regmap, P3T1755_REG_CFGR, &cfgr);
+ if (ret)
+ return ret;
+
+ sel = FIELD_GET(P3T1755_CONVERSION_TIME_BITS, cfgr);
+ if (sel >= ARRAY_SIZE(p3t1755_samp_freqs_uhz))
+ return -EINVAL;
+
+ freq_uhz = p3t1755_samp_freqs_uhz[sel];
+
+ *val = freq_uhz / MICRO;
+ *val2 = freq_uhz % MICRO;
+
+ return IIO_VAL_INT_PLUS_MICRO;
+ }
+ default:
+ return -EINVAL;
+ }
+}
+
+static int p3t1755_write_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan, int val,
+ int val2, long mask)
+{
+ struct p3t1755_data *data = iio_priv(indio_dev);
+ int ret;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_ENABLE:
+ ret = regmap_update_bits(data->regmap, P3T1755_REG_CFGR,
+ P3T1755_SHUTDOWN_BIT,
+ val == 0 ? P3T1755_SHUTDOWN_BIT : 0);
+ if (ret)
+ return ret;
+
+ return 0;
+ case IIO_CHAN_INFO_SAMP_FREQ: {
+ unsigned int i;
+ u32 regbits;
+ u64 input_uhz;
+
+ input_uhz = (u64)val * MICRO + val2;
+
+ for (i = 0; i < ARRAY_SIZE(p3t1755_samp_freqs_uhz); i++) {
+ if (p3t1755_samp_freqs_uhz[i] == input_uhz)
+ break;
+ }
+
+ if (i == ARRAY_SIZE(p3t1755_samp_freqs_uhz))
+ return -EINVAL;
+
+ regbits = FIELD_PREP(P3T1755_CONVERSION_TIME_BITS, i);
+
+ return regmap_update_bits(data->regmap, P3T1755_REG_CFGR,
+ P3T1755_CONVERSION_TIME_BITS,
+ regbits);
+ }
+ default:
+ return -EINVAL;
+ }
+}
+
+static int p3t1755_read_event_value(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir,
+ enum iio_event_info info, int *val,
+ int *val2)
+{
+ struct p3t1755_data *data = iio_priv(indio_dev);
+ unsigned int reg;
+ __be16 be;
+ int ret, raw;
+
+ if (type != IIO_EV_TYPE_THRESH || info != IIO_EV_INFO_VALUE)
+ return -EINVAL;
+
+ reg = (dir == IIO_EV_DIR_RISING) ? P3T1755_REG_HIGH_LIM :
+ P3T1755_REG_LOW_LIM;
+
+ ret = regmap_bulk_read(data->regmap, reg, &be, sizeof(be));
+ if (ret)
+ return ret;
+
+ raw = sign_extend32(be16_to_cpu(be) >> 4, 11);
+ *val = DIV_ROUND_CLOSEST(raw * 125, 2);
+
+ return IIO_VAL_INT;
+}
+
+static int p3t1755_write_event_value(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir,
+ enum iio_event_info info,
+ int val, int val2)
+{
+ struct p3t1755_data *data = iio_priv(indio_dev);
+ unsigned int reg;
+ __be16 be;
+ int raw;
+
+ if (type != IIO_EV_TYPE_THRESH || info != IIO_EV_INFO_VALUE)
+ return -EINVAL;
+
+ if (val2)
+ return -EINVAL;
+
+ reg = (dir == IIO_EV_DIR_RISING) ? P3T1755_REG_HIGH_LIM :
+ P3T1755_REG_LOW_LIM;
+
+ raw = DIV_ROUND_CLOSEST(val * 2, 125);
+
+ if (raw < -2048 || raw > 2047)
+ return -ERANGE;
+
+ be = cpu_to_be16((u16)(raw << 4));
+
+ /* Use raw_write to ensure 16-bit value is written exactly as formatted */
+ return regmap_raw_write(data->regmap, reg, &be, sizeof(be));
+}
+
+static const struct iio_event_spec p3t1755_events[] = {
+ {
+ .type = IIO_EV_TYPE_THRESH,
+ .dir = IIO_EV_DIR_RISING,
+ .mask_separate = BIT(IIO_EV_INFO_VALUE),
+ },
+ {
+ .type = IIO_EV_TYPE_THRESH,
+ .dir = IIO_EV_DIR_FALLING,
+ .mask_separate = BIT(IIO_EV_INFO_VALUE),
+ },
+};
+
+static const struct iio_chan_spec p3t1755_channels[] = {
+ {
+ .type = IIO_TEMP,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+ BIT(IIO_CHAN_INFO_ENABLE) |
+ BIT(IIO_CHAN_INFO_SAMP_FREQ),
+ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),
+ .event_spec = p3t1755_events,
+ .num_event_specs = ARRAY_SIZE(p3t1755_events),
+ },
+};
+
+const struct p3t1755_info p3t1755_channels_info = {
+ .name = "p3t1755",
+ .channels = p3t1755_channels,
+ .num_channels = ARRAY_SIZE(p3t1755_channels),
+};
+EXPORT_SYMBOL_NS(p3t1755_channels_info, IIO_P3T1755);
+
+const struct p3t1755_info p3t1750_channels_info = {
+ .name = "p3t1750",
+ .channels = p3t1755_channels,
+ .num_channels = ARRAY_SIZE(p3t1755_channels),
+};
+EXPORT_SYMBOL_NS(p3t1750_channels_info, IIO_P3T1755);
+
+static const struct iio_info p3t1755_info = {
+ .read_raw = p3t1755_read_raw,
+ .write_raw = p3t1755_write_raw,
+ .read_event_value = p3t1755_read_event_value,
+ .write_event_value = p3t1755_write_event_value,
+};
+
+static irqreturn_t p3t1755_irq_handler(int irq, void *dev_id)
+{
+ struct iio_dev *indio_dev = dev_id;
+
+ dev_dbg(&indio_dev->dev, "IRQ triggered, processing threshold event\n");
+
+ p3t1755_push_thresh_event(indio_dev);
+
+ return IRQ_HANDLED;
+}
+
+int p3t1755_probe(struct device *dev, const struct p3t1755_info *chip,
+ struct regmap *regmap, int irq)
+{
+ struct p3t1755_data *data;
+ struct iio_dev *iio_dev;
+ int ret;
+
+ iio_dev = devm_iio_device_alloc(dev, sizeof(*data));
+ if (!iio_dev)
+ return -ENOMEM;
+
+ data = iio_priv(iio_dev);
+ data->dev = dev;
+ data->regmap = regmap;
+
+ iio_dev->name = chip->name;
+ iio_dev->modes = INDIO_DIRECT_MODE;
+ iio_dev->info = &p3t1755_info;
+ iio_dev->channels = chip->channels;
+ iio_dev->num_channels = chip->num_channels;
+
+ ret = regmap_update_bits(data->regmap, P3T1755_REG_CFGR,
+ P3T1755_TM_BIT, P3T1755_TM_BIT);
+ if (ret)
+ return dev_err_probe(data->dev, ret, "Failed to update TM bit\n");
+
+ ret = devm_iio_device_register(dev, iio_dev);
+ if (ret)
+ return dev_err_probe(dev, ret, "Temperature sensor failed to register\n");
+
+ if (irq > 0) {
+ ret = devm_request_threaded_irq(dev, irq, NULL,
+ p3t1755_irq_handler, IRQF_ONESHOT,
+ "p3t1755dp", iio_dev);
+ if (ret)
+ dev_err_probe(dev, ret, "Failed to request IRQ: %d\n", ret);
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL_NS(p3t1755_probe, IIO_P3T1755);
+
+MODULE_AUTHOR("Lakshay Piplani <lakshay.piplani@nxp.com>");
+MODULE_DESCRIPTION("NXP P3T1750/P3T1755 Driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/iio/temperature/p3t/p3t1755_i2c.c b/drivers/iio/temperature/p3t/p3t1755_i2c.c
new file mode 100644
index 000000000000..8d45fd7125dd
--- /dev/null
+++ b/drivers/iio/temperature/p3t/p3t1755_i2c.c
@@ -0,0 +1,67 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * NXP P3T175x Temperature Sensor Driver
+ *
+ * Copyright 2025 NXP
+ */
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+
+#include "p3t1755.h"
+
+static const struct regmap_config p3t1755_i2c_regmap_config = {
+ .reg_bits = 8,
+ .val_bits = 8,
+};
+
+static const struct of_device_id p3t1755_i2c_of_match[] = {
+ { .compatible = "nxp,p3t1750dp", .data = &p3t1750_channels_info },
+ { .compatible = "nxp,p3t1755dp", .data = &p3t1755_channels_info },
+ { }
+};
+MODULE_DEVICE_TABLE(of, p3t1755_i2c_of_match);
+
+static const struct i2c_device_id p3t1755_i2c_id_table[] = {
+ { "p3t1750", (kernel_ulong_t)&p3t1750_channels_info },
+ { "p3t1755", (kernel_ulong_t)&p3t1755_channels_info },
+ { }
+};
+MODULE_DEVICE_TABLE(i2c, p3t1755_i2c_id_table);
+
+static int p3t1755_i2c_probe(struct i2c_client *client)
+{
+ struct device *dev = &client->dev;
+ const struct p3t1755_info *chip;
+ struct regmap *regmap;
+ int ret;
+
+ regmap = devm_regmap_init_i2c(client, &p3t1755_i2c_regmap_config);
+ if (IS_ERR(regmap))
+ return dev_err_probe(dev, PTR_ERR(regmap),
+ "regmap init failed\n");
+
+ chip = i2c_get_match_data(client);
+
+ ret = p3t1755_probe(dev, chip, regmap, client->irq);
+ if (ret)
+ return dev_err_probe(dev, ret, "p3t175x probe failed: %d\n", ret);
+
+ return 0;
+}
+
+static struct i2c_driver p3t1755_driver = {
+ .driver = {
+ .name = "p3t1755_i2c",
+ .of_match_table = p3t1755_i2c_of_match,
+ },
+ .probe = p3t1755_i2c_probe,
+ .id_table = p3t1755_i2c_id_table,
+};
+module_i2c_driver(p3t1755_driver);
+
+MODULE_AUTHOR("Lakshay Piplani <lakshay.piplani@nxp.com>");
+MODULE_DESCRIPTION("NXP P3T1750/P3T1755 I2C Driver");
+MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(IIO_P3T1755);
diff --git a/drivers/iio/temperature/p3t/p3t1755_i3c.c b/drivers/iio/temperature/p3t/p3t1755_i3c.c
new file mode 100644
index 000000000000..09810557391e
--- /dev/null
+++ b/drivers/iio/temperature/p3t/p3t1755_i3c.c
@@ -0,0 +1,108 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * NXP P3T175x Temperature Sensor Driver
+ *
+ * Copyright 2025 NXP
+ */
+#include <linux/i3c/device.h>
+#include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/regmap.h>
+
+#include <linux/iio/iio.h>
+#include <linux/iio/events.h>
+
+#include "p3t1755.h"
+
+static const struct regmap_config p3t1755_i3c_regmap_config = {
+ .reg_bits = 8,
+ .val_bits = 8,
+};
+
+static void p3t1755_ibi_handler(struct i3c_device *dev,
+ const struct i3c_ibi_payload *payload)
+{
+ struct iio_dev *indio_dev = dev_get_drvdata(&dev->dev);
+
+ p3t1755_push_thresh_event(indio_dev);
+}
+
+/*
+ * Both P3T1755 and P3T1750 share the same I3C PID (0x011B:0x152A),
+ * making runtime differentiation impossible, so using "p3t1755" as
+ * name in sysfs and IIO for I3C based instances.
+ */
+static const struct i3c_device_id p3t1755_i3c_ids[] = {
+ I3C_DEVICE(0x011B, 0x152A, &p3t1755_channels_info),
+ { }
+};
+MODULE_DEVICE_TABLE(i3c, p3t1755_i3c_ids);
+
+static void p3t1755_disable_ibi(void *data)
+{
+ i3c_device_disable_ibi(data);
+}
+
+static void p3t1755_free_ibi(void *data)
+{
+ i3c_device_free_ibi(data);
+}
+
+static int p3t1755_i3c_probe(struct i3c_device *i3cdev)
+{
+ const struct i3c_device_id *id = i3c_device_match_id(i3cdev, p3t1755_i3c_ids);
+ const struct p3t1755_info *chip;
+ struct device *dev = &i3cdev->dev;
+ struct i3c_ibi_setup ibi_setup;
+ struct regmap *regmap;
+ int ret;
+
+ chip = id ? id->data : NULL;
+
+ regmap = devm_regmap_init_i3c(i3cdev, &p3t1755_i3c_regmap_config);
+ if (IS_ERR(regmap))
+ return dev_err_probe(&i3cdev->dev, PTR_ERR(regmap),
+ "Failed to register I3C regmap %ld\n", PTR_ERR(regmap));
+
+ ret = p3t1755_probe(dev, chip, regmap, 0);
+ if (ret)
+ return dev_err_probe(dev, ret, "p3t175x probe failed: %d\n", ret);
+
+ ibi_setup = (struct i3c_ibi_setup) {
+ .handler = p3t1755_ibi_handler,
+ .num_slots = 4,
+ .max_payload_len = 0,
+ };
+
+ ret = i3c_device_request_ibi(i3cdev, &ibi_setup);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to request IBI\n");
+
+ ret = devm_add_action_or_reset(dev, p3t1755_free_ibi, i3cdev);
+ if (ret)
+ return ret;
+
+ ret = i3c_device_enable_ibi(i3cdev);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to enable IBI\n");
+
+ ret = devm_add_action_or_reset(dev, p3t1755_disable_ibi, i3cdev);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+static struct i3c_driver p3t1755_driver = {
+ .driver = {
+ .name = "p3t1755_i3c",
+ },
+ .probe = p3t1755_i3c_probe,
+ .id_table = p3t1755_i3c_ids,
+};
+module_i3c_driver(p3t1755_driver);
+
+MODULE_AUTHOR("Lakshay Piplani <lakshay.piplani@nxp.com>");
+MODULE_DESCRIPTION("NXP P3T1750/P3T1755 I3C Driver");
+MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(IIO_P3T1755);
--
2.25.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v4 0/2] iio: temperature: Add support for NXP P3T175x temperature sensors
2025-10-08 10:07 [PATCH v4 0/2] iio: temperature: Add support for NXP P3T175x temperature sensors Lakshay Piplani
2025-10-08 10:07 ` [PATCH v4 1/2] dt-bindings: iio: temperature: Add NXP P3T175x support Lakshay Piplani
2025-10-08 10:07 ` [PATCH v4 2/2] iio: temperature: Add driver for NXP P3T175x temperature sensor Lakshay Piplani
@ 2025-10-08 14:10 ` Guenter Roeck
2025-10-09 5:56 ` [EXT] " Lakshay Piplani
2 siblings, 1 reply; 9+ messages in thread
From: Guenter Roeck @ 2025-10-08 14:10 UTC (permalink / raw)
To: Lakshay Piplani, linux-kernel, linux-iio, jic23, dlechner,
nuno.sa, andy, marcelo.schmitt1, gregkh, viro, peterz, jstephan,
robh, krzk+dt, conor+dt, devicetree
Cc: jdelvare, vikash.bansal, priyanka.jain, shashank.rebbapragada
On 10/8/25 03:07, Lakshay Piplani wrote:
> This patch adds support for the P3T1750/P3T1755 temperature sensors under the IIO subsystem.
>
> P3T1750/P3T1755 support two operational modes:
> 1. Comparator Mode
> 2. Interrupt (Latched) Mode
>
> The HWMON subsystem is more suitable for implementing drivers for comparator mode operations.
> Reason:
> - Temperature thresholds can be polled and exposed via sysfs.
> - Register reads do not clear status, allowing safe alarm state derivation.
> - Matches existing drivers under hwmon.
>
> The IIO subsystem is more suitable for implementing drivers for interrupt (latched) mode operations.
> Reason:
> - Interrupt mode uses edge-triggered ALERT/IBI signal interrupts, which can be pushed to user space using iio_push_event.
> - IIO’s event API (IIO_EV_TYPE_THRESH) supports timestamped rising/falling edge events.
> - I3C IBI integration maps naturally to IIO’s event push model.
> - No persistent alarm bits are available; so polling in HWMON may result in missing events.
>
This is just wrong. Interrupt support can just as well be implemented
in a hwmon driver.
Guenter
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v4 1/2] dt-bindings: iio: temperature: Add NXP P3T175x support
2025-10-08 10:07 ` [PATCH v4 1/2] dt-bindings: iio: temperature: Add NXP P3T175x support Lakshay Piplani
@ 2025-10-08 21:01 ` Conor Dooley
2025-10-12 17:10 ` Jonathan Cameron
1 sibling, 0 replies; 9+ messages in thread
From: Conor Dooley @ 2025-10-08 21:01 UTC (permalink / raw)
To: Lakshay Piplani
Cc: linux-kernel, linux-iio, jic23, dlechner, nuno.sa, andy,
marcelo.schmitt1, gregkh, viro, peterz, jstephan, robh, krzk+dt,
conor+dt, devicetree, jdelvare, linux, vikash.bansal,
priyanka.jain, shashank.rebbapragada
[-- Attachment #1: Type: text/plain, Size: 3607 bytes --]
On Wed, Oct 08, 2025 at 03:37:12PM +0530, Lakshay Piplani wrote:
> Add bindings for the NXP P3T175x (P3T1750/P3T1755) temperature
> sensor, supporting both I2C & I3C interfaces.
>
> The P3T1750 and P3T1755 are functionally equivalent temperature
> sensors with identical interfaces and features. The P3T1755 offers
> improved accuracy(±0.5°C) in the –20°C to +85°C range, while both
> maintain ±1°C accuracy across –40°C to +125°C.
>
> Signed-off-by: Lakshay Piplani <lakshay.piplani@nxp.com>
> ---
> V3 -> V4: Changes since V3:
> - Updated commit message to clarify the difference between P3T1750 and P3T1755.
> V2 -> V3: Changes since V2:
> - Removed nxp,interrupt-mode and nxp,fault-queue properties from DT binding
> - Updated compatible strings:
> - nxp,p3t1750-iio → nxp,p3t1750dp
> - nxp,p3t1755-iio → nxp,p3t1755dp
> V1 -> V2: Changes since V1:
> - Dropped nxp,alert-active-high
> - Fixed YAML formatting, line wrapping, and examples
>
> .../bindings/iio/temperature/nxp,p3t1755.yaml | 62 +++++++++++++++++++
> 1 file changed, 62 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/iio/temperature/nxp,p3t1755.yaml
>
> diff --git a/Documentation/devicetree/bindings/iio/temperature/nxp,p3t1755.yaml b/Documentation/devicetree/bindings/iio/temperature/nxp,p3t1755.yaml
> new file mode 100644
> index 000000000000..16a01fa81251
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/temperature/nxp,p3t1755.yaml
This filename should actually match the compatible, so you're missing
dp.
dG
> @@ -0,0 +1,62 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/iio/temperature/nxp,p3t1755.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: NXP P3T175xDP Temperature Sensor
> +
> +maintainers:
> + - Lakshay Piplani <lakshay.piplani@nxp.com>
> +
> +description: |
> + Datasheet: https://www.nxp.com/docs/en/data-sheet/P3T1755.pdf
> +
> + P3T175xDP (P3T1750/P3T1755) is a digital temperature sensor with a range of
> + -40°C to +125°C and a 12-bit resolution. It supports communication over both
> + I2C and I3C interfaces.
> +
> + The I2C interface supports up to 32 static addresses and provides an ALERT
> + output to signal when temperature thresholds are crossed.
> +
> + The I3C interface supports In-Band interrupts (IBI) in interrupt mode,
> + allowing the device to notify the controller of threshold events without
> + dedicated alert pin.
> +
> +properties:
> + compatible:
> + enum:
> + - nxp,p3t1750dp
> + - nxp,p3t1755dp
> +
> + interrupts:
> + maxItems: 1
> +
> + reg:
> + maxItems: 1
> + description: |
> + In I2C mode, the device supports up to 32 static addresses.
> + In I3C mode, the 'reg' property encodes a triplet of
> + <static-address BCR PID> used for device matching.
> + Static address is optional if matching is done via PID.
> +
> +required:
> + - compatible
> + - reg
> +
> +additionalProperties: false
> +
> +examples:
> + - |
> + #include <dt-bindings/interrupt-controller/irq.h>
> + i2c {
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + temp-sensor@48 {
> + compatible = "nxp,p3t1755dp";
> + reg = <0x48>;
> + interrupt-parent = <&gpio2>;
> + interrupts = <3 IRQ_TYPE_EDGE_FALLING>;
> + };
> + };
> --
> 2.25.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [EXT] Re: [PATCH v4 0/2] iio: temperature: Add support for NXP P3T175x temperature sensors
2025-10-08 14:10 ` [PATCH v4 0/2] iio: temperature: Add support for NXP P3T175x temperature sensors Guenter Roeck
@ 2025-10-09 5:56 ` Lakshay Piplani
2025-10-09 22:37 ` Guenter Roeck
0 siblings, 1 reply; 9+ messages in thread
From: Lakshay Piplani @ 2025-10-09 5:56 UTC (permalink / raw)
To: Guenter Roeck, linux-kernel@vger.kernel.org,
linux-iio@vger.kernel.org, jic23@kernel.org,
dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
marcelo.schmitt1@gmail.com, gregkh@linuxfoundation.org,
viro@zeniv.linux.org.uk, peterz@infradead.org,
jstephan@baylibre.com, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, devicetree@vger.kernel.org
Cc: jdelvare@suse.com, Vikash Bansal, Priyanka Jain,
Shashank Rebbapragada
> -----Original Message-----
> From: Guenter Roeck <groeck7@gmail.com> On Behalf Of Guenter Roeck
> Sent: Wednesday, October 8, 2025 7:41 PM
> To: Lakshay Piplani <lakshay.piplani@nxp.com>; linux-kernel@vger.kernel.org;
> linux-iio@vger.kernel.org; jic23@kernel.org; dlechner@baylibre.com;
> nuno.sa@analog.com; andy@kernel.org; marcelo.schmitt1@gmail.com;
> gregkh@linuxfoundation.org; viro@zeniv.linux.org.uk; peterz@infradead.org;
> jstephan@baylibre.com; robh@kernel.org; krzk+dt@kernel.org;
> conor+dt@kernel.org; devicetree@vger.kernel.org
> Cc: jdelvare@suse.com; Vikash Bansal <vikash.bansal@nxp.com>; Priyanka
> Jain <priyanka.jain@nxp.com>; Shashank Rebbapragada
> <shashank.rebbapragada@nxp.com>
> Subject: [EXT] Re: [PATCH v4 0/2] iio: temperature: Add support for NXP
> P3T175x temperature sensors
>
> [You don't often get email from linux@roeck-us.net. Learn why this is
> important at https://aka.ms/LearnAboutSenderIdentification ]
>
> Caution: This is an external email. Please take care when clicking links or
> opening attachments. When in doubt, report the message using the 'Report
> this email' button
>
>
> On 10/8/25 03:07, Lakshay Piplani wrote:
> > This patch adds support for the P3T1750/P3T1755 temperature sensors
> under the IIO subsystem.
> >
> > P3T1750/P3T1755 support two operational modes:
> > 1. Comparator Mode
> > 2. Interrupt (Latched) Mode
> >
> > The HWMON subsystem is more suitable for implementing drivers for
> comparator mode operations.
> > Reason:
> > - Temperature thresholds can be polled and exposed via sysfs.
> > - Register reads do not clear status, allowing safe alarm state derivation.
> > - Matches existing drivers under hwmon.
> >
> > The IIO subsystem is more suitable for implementing drivers for interrupt
> (latched) mode operations.
> > Reason:
> > - Interrupt mode uses edge-triggered ALERT/IBI signal interrupts, which
> can be pushed to user space using iio_push_event.
> > - IIO's event API (IIO_EV_TYPE_THRESH) supports timestamped
> rising/falling edge events.
> > - I3C IBI integration maps naturally to IIO's event push model.
> > - No persistent alarm bits are available; so polling in HWMON may result in
> missing events.
> >
>
> This is just wrong. Interrupt support can just as well be implemented in a
> hwmon driver.
>
> Guenter
Hi Guenter,
Thanks - agreed, hwmon drivers can support interrupts.
The distinction I meant to highlight is about semantic alignment.
Both P3T1750 and P3T1755 does not provide alarm/status bits. In TM=1 (interrupt mode), the alert is latched
but cleared on register read, with no way to query alarm state afterward.
HWMON typically polls alarm flags via IRQs, expecting them to remain asserted during threshold violations.
Without persistent bits, supporting interrupts in hwmon would require emulating state in software, which diverges
from its ABI and could mislead userspace expecting stable *_alarm files.
IIO's event API, being edge-triggered and timestamped, aligns more naturally with
this transient behavior and with I3C IBI signaling.
I'll reword the cover letter to clarify that this is a design choice based on ABI semantics, not a limitation of hwmon.
Thanks again for the review.
Best regards,
Lakshay
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [EXT] Re: [PATCH v4 0/2] iio: temperature: Add support for NXP P3T175x temperature sensors
2025-10-09 5:56 ` [EXT] " Lakshay Piplani
@ 2025-10-09 22:37 ` Guenter Roeck
2025-10-12 17:15 ` Jonathan Cameron
0 siblings, 1 reply; 9+ messages in thread
From: Guenter Roeck @ 2025-10-09 22:37 UTC (permalink / raw)
To: Lakshay Piplani, linux-kernel@vger.kernel.org,
linux-iio@vger.kernel.org, jic23@kernel.org,
dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
marcelo.schmitt1@gmail.com, gregkh@linuxfoundation.org,
viro@zeniv.linux.org.uk, peterz@infradead.org,
jstephan@baylibre.com, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, devicetree@vger.kernel.org
Cc: jdelvare@suse.com, Vikash Bansal, Priyanka Jain,
Shashank Rebbapragada
On 10/8/25 22:56, Lakshay Piplani wrote:
>
>> -----Original Message-----
>> From: Guenter Roeck <groeck7@gmail.com> On Behalf Of Guenter Roeck
>> Sent: Wednesday, October 8, 2025 7:41 PM
>> To: Lakshay Piplani <lakshay.piplani@nxp.com>; linux-kernel@vger.kernel.org;
>> linux-iio@vger.kernel.org; jic23@kernel.org; dlechner@baylibre.com;
>> nuno.sa@analog.com; andy@kernel.org; marcelo.schmitt1@gmail.com;
>> gregkh@linuxfoundation.org; viro@zeniv.linux.org.uk; peterz@infradead.org;
>> jstephan@baylibre.com; robh@kernel.org; krzk+dt@kernel.org;
>> conor+dt@kernel.org; devicetree@vger.kernel.org
>> Cc: jdelvare@suse.com; Vikash Bansal <vikash.bansal@nxp.com>; Priyanka
>> Jain <priyanka.jain@nxp.com>; Shashank Rebbapragada
>> <shashank.rebbapragada@nxp.com>
>> Subject: [EXT] Re: [PATCH v4 0/2] iio: temperature: Add support for NXP
>> P3T175x temperature sensors
>>
>> [You don't often get email from linux@roeck-us.net. Learn why this is
>> important at https://aka.ms/LearnAboutSenderIdentification ]
>>
>> Caution: This is an external email. Please take care when clicking links or
>> opening attachments. When in doubt, report the message using the 'Report
>> this email' button
>>
>>
>> On 10/8/25 03:07, Lakshay Piplani wrote:
>>> This patch adds support for the P3T1750/P3T1755 temperature sensors
>> under the IIO subsystem.
>>>
>>> P3T1750/P3T1755 support two operational modes:
>>> 1. Comparator Mode
>>> 2. Interrupt (Latched) Mode
>>>
>>> The HWMON subsystem is more suitable for implementing drivers for
>> comparator mode operations.
>>> Reason:
>>> - Temperature thresholds can be polled and exposed via sysfs.
>>> - Register reads do not clear status, allowing safe alarm state derivation.
>>> - Matches existing drivers under hwmon.
>>>
>>> The IIO subsystem is more suitable for implementing drivers for interrupt
>> (latched) mode operations.
>>> Reason:
>>> - Interrupt mode uses edge-triggered ALERT/IBI signal interrupts, which
>> can be pushed to user space using iio_push_event.
>>> - IIO's event API (IIO_EV_TYPE_THRESH) supports timestamped
>> rising/falling edge events.
>>> - I3C IBI integration maps naturally to IIO's event push model.
>>> - No persistent alarm bits are available; so polling in HWMON may result in
>> missing events.
>>>
>>
>> This is just wrong. Interrupt support can just as well be implemented in a
>> hwmon driver.
>>
>> Guenter
>
> Hi Guenter,
>
> Thanks - agreed, hwmon drivers can support interrupts.
> The distinction I meant to highlight is about semantic alignment.
> Both P3T1750 and P3T1755 does not provide alarm/status bits. In TM=1 (interrupt mode), the alert is latched
> but cleared on register read, with no way to query alarm state afterward.
>
> HWMON typically polls alarm flags via IRQs, expecting them to remain asserted during threshold violations.
> Without persistent bits, supporting interrupts in hwmon would require emulating state in software, which diverges
So ? Various drivers already do that. It is not even necessary to "emulate
the state in software". Just store the state in the interrupt handler, and
report (and clear) the state when the alarm file(s) are read.
> from its ABI and could mislead userspace expecting stable *_alarm files.
This is just incorrect.
> IIO's event API, being edge-triggered and timestamped, aligns more naturally with
> this transient behavior and with I3C IBI signaling.
>
> I'll reword the cover letter to clarify that this is a design choice based on ABI semantics, not a limitation of hwmon.
Again, that design choice is not a reason to have two drivers for the same chip.
Guenter
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v4 1/2] dt-bindings: iio: temperature: Add NXP P3T175x support
2025-10-08 10:07 ` [PATCH v4 1/2] dt-bindings: iio: temperature: Add NXP P3T175x support Lakshay Piplani
2025-10-08 21:01 ` Conor Dooley
@ 2025-10-12 17:10 ` Jonathan Cameron
1 sibling, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2025-10-12 17:10 UTC (permalink / raw)
To: Lakshay Piplani
Cc: linux-kernel, linux-iio, dlechner, nuno.sa, andy,
marcelo.schmitt1, gregkh, viro, peterz, jstephan, robh, krzk+dt,
conor+dt, devicetree, jdelvare, linux, vikash.bansal,
priyanka.jain, shashank.rebbapragada
On Wed, 8 Oct 2025 15:37:12 +0530
Lakshay Piplani <lakshay.piplani@nxp.com> wrote:
> Add bindings for the NXP P3T175x (P3T1750/P3T1755) temperature
> sensor, supporting both I2C & I3C interfaces.
>
> The P3T1750 and P3T1755 are functionally equivalent temperature
> sensors with identical interfaces and features. The P3T1755 offers
> improved accuracy(±0.5°C) in the –20°C to +85°C range, while both
> maintain ±1°C accuracy across –40°C to +125°C.
>
> Signed-off-by: Lakshay Piplani <lakshay.piplani@nxp.com>
> ---
> V3 -> V4: Changes since V3:
> - Updated commit message to clarify the difference between P3T1750 and P3T1755.
> V2 -> V3: Changes since V2:
> - Removed nxp,interrupt-mode and nxp,fault-queue properties from DT binding
> - Updated compatible strings:
> - nxp,p3t1750-iio → nxp,p3t1750dp
> - nxp,p3t1755-iio → nxp,p3t1755dp
> V1 -> V2: Changes since V1:
> - Dropped nxp,alert-active-high
> - Fixed YAML formatting, line wrapping, and examples
>
> .../bindings/iio/temperature/nxp,p3t1755.yaml | 62 +++++++++++++++++++
> 1 file changed, 62 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/iio/temperature/nxp,p3t1755.yaml
>
> diff --git a/Documentation/devicetree/bindings/iio/temperature/nxp,p3t1755.yaml b/Documentation/devicetree/bindings/iio/temperature/nxp,p3t1755.yaml
> new file mode 100644
> index 000000000000..16a01fa81251
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/temperature/nxp,p3t1755.yaml
> @@ -0,0 +1,62 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/iio/temperature/nxp,p3t1755.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: NXP P3T175xDP Temperature Sensor
> +
> +maintainers:
> + - Lakshay Piplani <lakshay.piplani@nxp.com>
> +
> +description: |
> + Datasheet: https://www.nxp.com/docs/en/data-sheet/P3T1755.pdf
> +
> + P3T175xDP (P3T1750/P3T1755) is a digital temperature sensor with a range of
> + -40°C to +125°C and a 12-bit resolution. It supports communication over both
> + I2C and I3C interfaces.
> +
> + The I2C interface supports up to 32 static addresses and provides an ALERT
> + output to signal when temperature thresholds are crossed.
> +
> + The I3C interface supports In-Band interrupts (IBI) in interrupt mode,
> + allowing the device to notify the controller of threshold events without
> + dedicated alert pin.
> +
> +properties:
> + compatible:
> + enum:
> + - nxp,p3t1750dp
> + - nxp,p3t1755dp
> +
> + interrupts:
> + maxItems: 1
> +
> + reg:
> + maxItems: 1
> + description: |
> + In I2C mode, the device supports up to 32 static addresses.
> + In I3C mode, the 'reg' property encodes a triplet of
> + <static-address BCR PID> used for device matching.
> + Static address is optional if matching is done via PID.
> +
Aim for completeness of description. This sensor needs power so
there should be a regulator. As power must be connected convention
is to make that required as well. That doesn't necessarily mean
specific dts can't rely on fallback 'fake' regulators that get created
by Linux when one is requested that we haven't provided in DT though.
For driver side just use devm_regulator_get_enabled() and forget about it
after that.
> +required:
> + - compatible
> + - reg
> +
> +additionalProperties: false
> +
> +examples:
> + - |
> + #include <dt-bindings/interrupt-controller/irq.h>
> + i2c {
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + temp-sensor@48 {
> + compatible = "nxp,p3t1755dp";
> + reg = <0x48>;
> + interrupt-parent = <&gpio2>;
> + interrupts = <3 IRQ_TYPE_EDGE_FALLING>;
> + };
> + };
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [EXT] Re: [PATCH v4 0/2] iio: temperature: Add support for NXP P3T175x temperature sensors
2025-10-09 22:37 ` Guenter Roeck
@ 2025-10-12 17:15 ` Jonathan Cameron
0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2025-10-12 17:15 UTC (permalink / raw)
To: Guenter Roeck
Cc: Lakshay Piplani, linux-kernel@vger.kernel.org,
linux-iio@vger.kernel.org, dlechner@baylibre.com,
nuno.sa@analog.com, andy@kernel.org, marcelo.schmitt1@gmail.com,
gregkh@linuxfoundation.org, viro@zeniv.linux.org.uk,
peterz@infradead.org, jstephan@baylibre.com, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org,
devicetree@vger.kernel.org, jdelvare@suse.com, Vikash Bansal,
Priyanka Jain, Shashank Rebbapragada
On Thu, 9 Oct 2025 15:37:42 -0700
Guenter Roeck <linux@roeck-us.net> wrote:
> On 10/8/25 22:56, Lakshay Piplani wrote:
> >
> >> -----Original Message-----
> >> From: Guenter Roeck <groeck7@gmail.com> On Behalf Of Guenter Roeck
> >> Sent: Wednesday, October 8, 2025 7:41 PM
> >> To: Lakshay Piplani <lakshay.piplani@nxp.com>; linux-kernel@vger.kernel.org;
> >> linux-iio@vger.kernel.org; jic23@kernel.org; dlechner@baylibre.com;
> >> nuno.sa@analog.com; andy@kernel.org; marcelo.schmitt1@gmail.com;
> >> gregkh@linuxfoundation.org; viro@zeniv.linux.org.uk; peterz@infradead.org;
> >> jstephan@baylibre.com; robh@kernel.org; krzk+dt@kernel.org;
> >> conor+dt@kernel.org; devicetree@vger.kernel.org
> >> Cc: jdelvare@suse.com; Vikash Bansal <vikash.bansal@nxp.com>; Priyanka
> >> Jain <priyanka.jain@nxp.com>; Shashank Rebbapragada
> >> <shashank.rebbapragada@nxp.com>
> >> Subject: [EXT] Re: [PATCH v4 0/2] iio: temperature: Add support for NXP
> >> P3T175x temperature sensors
> >>
> >> [You don't often get email from linux@roeck-us.net. Learn why this is
> >> important at https://aka.ms/LearnAboutSenderIdentification ]
> >>
> >> Caution: This is an external email. Please take care when clicking links or
> >> opening attachments. When in doubt, report the message using the 'Report
> >> this email' button
> >>
> >>
> >> On 10/8/25 03:07, Lakshay Piplani wrote:
> >>> This patch adds support for the P3T1750/P3T1755 temperature sensors
> >> under the IIO subsystem.
> >>>
> >>> P3T1750/P3T1755 support two operational modes:
> >>> 1. Comparator Mode
> >>> 2. Interrupt (Latched) Mode
> >>>
> >>> The HWMON subsystem is more suitable for implementing drivers for
> >> comparator mode operations.
> >>> Reason:
> >>> - Temperature thresholds can be polled and exposed via sysfs.
> >>> - Register reads do not clear status, allowing safe alarm state derivation.
> >>> - Matches existing drivers under hwmon.
> >>>
> >>> The IIO subsystem is more suitable for implementing drivers for interrupt
> >> (latched) mode operations.
> >>> Reason:
> >>> - Interrupt mode uses edge-triggered ALERT/IBI signal interrupts, which
> >> can be pushed to user space using iio_push_event.
> >>> - IIO's event API (IIO_EV_TYPE_THRESH) supports timestamped
> >> rising/falling edge events.
> >>> - I3C IBI integration maps naturally to IIO's event push model.
> >>> - No persistent alarm bits are available; so polling in HWMON may result in
> >> missing events.
> >>>
> >>
> >> This is just wrong. Interrupt support can just as well be implemented in a
> >> hwmon driver.
> >>
> >> Guenter
> >
> > Hi Guenter,
> >
> > Thanks - agreed, hwmon drivers can support interrupts.
> > The distinction I meant to highlight is about semantic alignment.
> > Both P3T1750 and P3T1755 does not provide alarm/status bits. In TM=1 (interrupt mode), the alert is latched
> > but cleared on register read, with no way to query alarm state afterward.
> >
> > HWMON typically polls alarm flags via IRQs, expecting them to remain asserted during threshold violations.
> > Without persistent bits, supporting interrupts in hwmon would require emulating state in software, which diverges
>
> So ? Various drivers already do that. It is not even necessary to "emulate
> the state in software". Just store the state in the interrupt handler, and
> report (and clear) the state when the alarm file(s) are read.
>
> > from its ABI and could mislead userspace expecting stable *_alarm files.
>
> This is just incorrect.
>
> > IIO's event API, being edge-triggered and timestamped, aligns more naturally with
> > this transient behavior and with I3C IBI signaling.
> >
> > I'll reword the cover letter to clarify that this is a design choice based on ABI semantics, not a limitation of hwmon.
>
> Again, that design choice is not a reason to have two drivers for the same chip.
>
> Guenter
+1. I'm not seeing anything yet that rules out a straight forward hwmon driver for this
and as it is a simple temperature sensor hwmon is preferred home.
Jonathan
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-10-12 17:15 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-08 10:07 [PATCH v4 0/2] iio: temperature: Add support for NXP P3T175x temperature sensors Lakshay Piplani
2025-10-08 10:07 ` [PATCH v4 1/2] dt-bindings: iio: temperature: Add NXP P3T175x support Lakshay Piplani
2025-10-08 21:01 ` Conor Dooley
2025-10-12 17:10 ` Jonathan Cameron
2025-10-08 10:07 ` [PATCH v4 2/2] iio: temperature: Add driver for NXP P3T175x temperature sensor Lakshay Piplani
2025-10-08 14:10 ` [PATCH v4 0/2] iio: temperature: Add support for NXP P3T175x temperature sensors Guenter Roeck
2025-10-09 5:56 ` [EXT] " Lakshay Piplani
2025-10-09 22:37 ` Guenter Roeck
2025-10-12 17:15 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox