[PATCH v4 3/3] hwmon: (lm75) add MAX31875 support
From: John Erasmus Mari Geronimo
Date: Fri Oct 23 2026 - 05:18:20 EST
Add support for the Maxim MAX31875 I2C temperature sensor by
extending the lm75 driver. The MAX31875 features a 16-bit
configuration register, configurable resolution (8, 9, 10, or
12 bits), and selectable conversion rates (125ms, 250ms, 1s, 4s).
The MAX31875 has no alert polarity bit, and the bit the driver would
use for 16-bit chips is part of its conversion rate field, so skip
the polarity configuration for it. Also set the default resolution
and conversion rate at probe so the driver state matches the chip.
Suggested-by: Guenter Roeck <linux@xxxxxxxxxxxx>
Signed-off-by: John Erasmus Mari Geronimo <johnerasmusmari.geronimo@xxxxxxxxxx>
---
drivers/hwmon/Kconfig | 2 +-
drivers/hwmon/lm75.c | 30 +++++++++++++++++++++++++++++-
2 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 18c682e1a..3123f1282 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -1597,7 +1597,7 @@ config SENSORS_LM75
If you say yes here you get support for one common type of
temperature sensor chip, with models including:
- - Analog Devices ADT75
+ - Analog Devices ADT75, MAX31875
- Atmel (now Microchip) AT30TS74
- Dallas Semiconductor DS75, DS1775 and DS7505
- Global Mixed-mode Technology (GMT) G751
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index 2d2d752ae..349648fd0 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -38,6 +38,7 @@ enum lm75_type { /* keep sorted in alphabetical order */
max6625,
max6626,
max31725,
+ max31875,
mcp980x,
p3t1750,
p3t1755,
@@ -222,6 +223,16 @@ static const struct lm75_params device_params[] = {
.default_resolution = 16,
.default_sample_time = MSEC_PER_SEC / 20,
},
+ [max31875] = {
+ .config_reg_16bits = true,
+ .set_mask = 2 << 13, /* 10-bit resolution */
+ .clr_mask = 3 << 13 | 3 << 9, /* resolution, 4 s conversion rate */
+ .default_resolution = 10,
+ .default_sample_time = 4000,
+ .num_sample_times = 4,
+ .sample_times = (unsigned int []){ 125, 250, 1000, 4000 },
+ .alarm = true,
+ },
[tcn75] = {
.default_resolution = 9,
.default_sample_time = MSEC_PER_SEC / 18,
@@ -420,6 +431,9 @@ static int lm75_read(struct device *dev, enum hwmon_sensor_types type,
case tmp112:
*val = !!(regval & BIT(13)) == !!(regval & BIT(2));
break;
+ case max31875:
+ *val = !!(regval & BIT(7));
+ break;
default:
return -EINVAL;
}
@@ -494,6 +508,13 @@ static int lm75_update_interval(struct device *dev, long val)
return err;
data->sample_time = data->params->sample_times[index];
break;
+ case max31875:
+ err = regmap_update_bits(data->regmap, LM75_REG_CONF,
+ 0x0600, (3 - index) << 9);
+ if (err < 0)
+ return err;
+ data->sample_time = data->params->sample_times[index];
+ break;
case pct2075:
err = regmap_write(data->regmap, PCT2075_REG_IDLE, index + 1);
if (err)
@@ -770,7 +791,9 @@ static int lm75_generic_probe(struct device *dev, const char *name,
data->orig_conf = status;
/* Enforce polarity active-low (default) or active-high (devicetree) */
- if (!data->params->config_reg_16bits)
+ if (data->kind == max31875)
+ pol_mask = 0; /* no alert polarity bit */
+ else if (!data->params->config_reg_16bits)
pol_mask = LM75_ALERT_POLARITY_HIGH_8_BIT;
else
pol_mask = LM75_ALERT_POLARITY_HIGH_16_BIT;
@@ -847,6 +870,7 @@ static const struct i2c_device_id lm75_i2c_ids[] = {
{ .name = "max6626", .driver_data = max6626 },
{ .name = "max31725", .driver_data = max31725 },
{ .name = "max31726", .driver_data = max31725 },
+ { .name = "max31875", .driver_data = max31875 },
{ .name = "mcp980x", .driver_data = mcp980x },
{ .name = "p3t1750", .driver_data = p3t1750 },
{ .name = "p3t1755", .driver_data = p3t1755 },
@@ -904,6 +928,10 @@ static const struct of_device_id lm75_of_match[] = {
.compatible = "adi,adt75",
.data = (void *)adt75
},
+ {
+ .compatible = "adi,max31875",
+ .data = (void *)max31875
+ },
{
.compatible = "ams,as6200",
.data = (void *)as6200
--
2.34.1