[PATCH v2 3/3] hwmon: (lm75) add MAX31875 support

From: John Erasmus Mari Geronimo

Date: Thu Sep 24 2026 - 04:44:48 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).

Suggested-by: Guenter Roeck <linux@xxxxxxxxxxxx>
Signed-off-by: John Erasmus Mari Geronimo <johnerasmusmari.geronimo@xxxxxxxxxx>
---
drivers/hwmon/Kconfig | 2 +-
drivers/hwmon/lm75.c | 25 +++++++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index e4c4f2b09732d..c68b6c3c2f866 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -1525,7 +1525,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 104149a03bad0..886f83c8b0420 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -39,6 +39,7 @@ enum lm75_type { /* keep sorted in alphabetical order */
max6625,
max6626,
max31725,
+ max31875,
mcp980x,
p3t1750,
p3t1755,
@@ -223,6 +224,15 @@ static const struct lm75_params device_params[] = {
.default_resolution = 16,
.default_sample_time = MSEC_PER_SEC / 20,
},
+ [max31875] = {
+ .config_reg_16bits = true,
+ .default_resolution = 10,
+ .resolutions = (u8 []) {8, 9, 10, 12 },
+ .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,
@@ -421,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 >> 7) & 0x1;
+ break;
default:
return -EINVAL;
}
@@ -495,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)
@@ -848,6 +868,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 },
@@ -905,6 +926,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