* [PATCH v3 1/2] dt-bindings: hwmon: lm75: Add ti,alert-polarity-active-high property
2026-05-04 15:10 [PATCH v3 0/2] Support active-high alert polarity for LM75 Markus Stockhausen
@ 2026-05-04 15:10 ` Markus Stockhausen
2026-05-05 13:24 ` Guenter Roeck
2026-05-04 15:10 ` [PATCH v3 2/2] hwmon: (lm75) Support active-high alert polarity Markus Stockhausen
1 sibling, 1 reply; 5+ messages in thread
From: Markus Stockhausen @ 2026-05-04 15:10 UTC (permalink / raw)
To: linux, robh, krzk+dt, conor+dt, jdelvare, linux-hwmon, devicetree
Cc: Markus Stockhausen, Conor Dooley
The LM75 alert pin is asserted based on the value of alert polarity bit of
the configuration register. The device/driver default is 0 which means alert
pin is configured to be active-low. A value of 1 maps to inverted (active-high).
Add an optional boolean property "ti,alert-polarity-active-high" to
override the alert pin polarity. When absent, the default active-low
polarity is kept.
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
---
Documentation/devicetree/bindings/hwmon/lm75.yaml | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/Documentation/devicetree/bindings/hwmon/lm75.yaml b/Documentation/devicetree/bindings/hwmon/lm75.yaml
index 0b9fda81e3ec..b48bf3fd721f 100644
--- a/Documentation/devicetree/bindings/hwmon/lm75.yaml
+++ b/Documentation/devicetree/bindings/hwmon/lm75.yaml
@@ -54,6 +54,13 @@ properties:
interrupts:
maxItems: 1
+ ti,alert-polarity-active-high:
+ description: Alert pin is asserted based on the value of alert polarity
+ bit of configuration register. Default value is normal (0 which maps to
+ active-low). The other value is inverted (1 which maps to active-high).
+ Specify this property to set the alert polarity to active-high.
+ $ref: /schemas/types.yaml#/definitions/flag
+
required:
- compatible
- reg
--
2.54.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v3 2/2] hwmon: (lm75) Support active-high alert polarity
2026-05-04 15:10 [PATCH v3 0/2] Support active-high alert polarity for LM75 Markus Stockhausen
2026-05-04 15:10 ` [PATCH v3 1/2] dt-bindings: hwmon: lm75: Add ti,alert-polarity-active-high property Markus Stockhausen
@ 2026-05-04 15:10 ` Markus Stockhausen
2026-05-05 13:25 ` Guenter Roeck
1 sibling, 1 reply; 5+ messages in thread
From: Markus Stockhausen @ 2026-05-04 15:10 UTC (permalink / raw)
To: linux, robh, krzk+dt, conor+dt, jdelvare, linux-hwmon, devicetree
Cc: Markus Stockhausen
LM75 devices supported by this driver support configurable active-high
alert polarity. This is already documented in the devicetree description.
Add support for it to the driver.
Follow documentation and defensively enforce active-low if property is
not set. This avoids possible inconsistencies for future devices with
wrong parametrization. No API breakage as all current devices have
their parameters set to active-low.
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
---
drivers/hwmon/lm75.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index 8b74cc314196..391e6dfcc6b2 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -123,7 +123,9 @@ struct lm75_data {
static const u8 lm75_sample_set_masks[] = { 0 << 5, 1 << 5, 2 << 5, 3 << 5 };
-#define LM75_SAMPLE_CLEAR_MASK (3 << 5)
+#define LM75_ALERT_POLARITY_HIGH_8_BIT (BIT(2))
+#define LM75_ALERT_POLARITY_HIGH_16_BIT (BIT(2) << 8)
+#define LM75_SAMPLE_CLEAR_MASK (3 << 5)
/* The structure below stores the configuration values of the supported devices.
* In case of being supported multiple configurations, the default one must
@@ -725,6 +727,7 @@ static void lm75_remove(void *data)
static int lm75_generic_probe(struct device *dev, const char *name,
enum lm75_type kind, int irq, struct regmap *regmap)
{
+ u16 clr_mask, pol_mask, set_mask;
struct device *hwmon_dev;
struct lm75_data *data;
int status, err;
@@ -762,8 +765,18 @@ static int lm75_generic_probe(struct device *dev, const char *name,
return err;
data->orig_conf = status;
- err = lm75_write_config(data, data->params->set_mask,
- data->params->clr_mask);
+ /* Enforce polarity active-low (default) or active-high (devicetree) */
+ if (!data->params->config_reg_16bits)
+ pol_mask = LM75_ALERT_POLARITY_HIGH_8_BIT;
+ else
+ pol_mask = LM75_ALERT_POLARITY_HIGH_16_BIT;
+
+ clr_mask = data->params->clr_mask | pol_mask;
+ set_mask = data->params->set_mask & ~pol_mask;
+ if (device_property_read_bool(dev, "ti,alert-polarity-active-high"))
+ set_mask |= pol_mask;
+
+ err = lm75_write_config(data, set_mask, clr_mask);
if (err)
return err;
--
2.54.0
^ permalink raw reply related [flat|nested] 5+ messages in thread