[PATCH 3/3] hwmon: Add Maxim MAX17135 temperature sensor driver
From: Michiel van Beers via B4 Relay
Date: Wed Dec 02 2026 - 11:44:43 EST
From: Michiel van Beers <michielvanbeers@xxxxxxxxx>
The MAX17135 E-paper display PMIC has a temperature sensor that measures
the die and an external diode. Add a driver for it. The driver binds to
the auxiliary device that the regulator driver creates.
Reading the external channel fails with -ENODATA while the chip reports
the diode as open or shorted.
Signed-off-by: Michiel van Beers <michielvanbeers@xxxxxxxxx>
---
Documentation/hwmon/index.rst | 1 +
Documentation/hwmon/max17135.rst | 37 +++++++++++
MAINTAINERS | 2 +
drivers/hwmon/Kconfig | 11 ++++
drivers/hwmon/Makefile | 1 +
drivers/hwmon/max17135-hwmon.c | 135 +++++++++++++++++++++++++++++++++++++++
6 files changed, 187 insertions(+)
diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst
index 199ca79621e9..a4207f737197 100644
--- a/Documentation/hwmon/index.rst
+++ b/Documentation/hwmon/index.rst
@@ -164,6 +164,7 @@ Hardware Monitoring Kernel Drivers
max1619
max16601
max1668
+ max17135
max17616
max197
max20730
diff --git a/Documentation/hwmon/max17135.rst b/Documentation/hwmon/max17135.rst
new file mode 100644
index 000000000000..dad24d6f677e
--- /dev/null
+++ b/Documentation/hwmon/max17135.rst
@@ -0,0 +1,37 @@
+.. SPDX-License-Identifier: GPL-2.0-only
+
+Kernel driver max17135-hwmon
+============================
+
+Supported chips:
+
+ * Maxim MAX17135
+
+ Prefix: 'max17135'
+
+ Datasheet:
+
+ https://www.analog.com/media/en/technical-documentation/data-sheets/MAX17135.pdf
+
+Author: Michiel van Beers <michielvanbeers@xxxxxxxxx>
+
+Description
+-----------
+
+The MAX17135 is a power management IC for E-paper displays. This driver
+supports its temperature sensor, which measures the temperature of the die and
+of an external diode.
+
+Both channels have a resolution of 0.5 degrees Celsius. The chip converts once
+per second by default.
+
+Sysfs entries
+-------------
+
+=============== ==============================================================
+temp1_input Die temperature
+temp2_input Temperature of the external diode. Reading it fails with
+ ENODATA while temp2_fault is set.
+temp2_fault 1 if the external diode is open or shorted, for example
+ because the board has none
+=============== ==============================================================
diff --git a/MAINTAINERS b/MAINTAINERS
index 6b2af23ec2bf..6bc6d22339f8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -16496,6 +16496,8 @@ M: Michiel van Beers <michielvanbeers@xxxxxxxxx>
L: linux-kernel@xxxxxxxxxxxxxxx
S: Maintained
F: Documentation/devicetree/bindings/regulator/maxim,max17135.yaml
+F: Documentation/hwmon/max17135.rst
+F: drivers/hwmon/max17135-hwmon.c
F: drivers/regulator/max17135.c
F: include/linux/regulator/max17135.h
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 247507a4ddde..2f6d5d9517ef 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -1311,6 +1311,17 @@ config SENSORS_MAX1668
This driver can also be built as a module. If so, the module
will be called max1668.
+config SENSORS_MAX17135
+ tristate "Maxim MAX17135 temperature sensor"
+ depends on REGULATOR_MAX17135
+ help
+ If you say yes here you get support for the temperature sensor
+ of the Maxim MAX17135 E-paper display PMIC: the die temperature
+ and an external diode.
+
+ This driver can also be built as a module. If so, the module
+ will be called max17135-hwmon.
+
config SENSORS_MAX197
tristate "Maxim MAX197 and compatibles"
help
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index d4c345ed7261..a96bdb037592 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -162,6 +162,7 @@ obj-$(CONFIG_SENSORS_MAX127) += max127.o
obj-$(CONFIG_SENSORS_MAX16065) += max16065.o
obj-$(CONFIG_SENSORS_MAX1619) += max1619.o
obj-$(CONFIG_SENSORS_MAX1668) += max1668.o
+obj-$(CONFIG_SENSORS_MAX17135) += max17135-hwmon.o
obj-$(CONFIG_SENSORS_MAX197) += max197.o
obj-$(CONFIG_SENSORS_MAX31722) += max31722.o
obj-$(CONFIG_SENSORS_MAX31730) += max31730.o
diff --git a/drivers/hwmon/max17135-hwmon.c b/drivers/hwmon/max17135-hwmon.c
new file mode 100644
index 000000000000..c49f98e8c8e3
--- /dev/null
+++ b/drivers/hwmon/max17135-hwmon.c
@@ -0,0 +1,135 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Temperature sensor of the Maxim MAX17135 E-paper display PMIC
+ *
+ * Copyright (C) 2026 Michiel van Beers
+ */
+
+#include <linux/auxiliary_bus.h>
+#include <linux/bits.h>
+#include <linux/device.h>
+#include <linux/device/devres.h>
+#include <linux/err.h>
+#include <linux/errno.h>
+#include <linux/hwmon.h>
+#include <linux/module.h>
+#include <linux/regmap.h>
+#include <linux/regulator/max17135.h>
+#include <linux/types.h>
+
+#define MAX17135_REG_STATUS 0x05
+#define MAX17135_STATUS_OPEN BIT(1)
+#define MAX17135_STATUS_SHORT BIT(2)
+
+struct max17135_hwmon {
+ struct device *chip;
+ struct regmap *regmap;
+};
+
+static int max17135_hwmon_diode_fault(struct max17135_hwmon *hwmon, long *val)
+{
+ unsigned int status;
+ int ret;
+
+ ret = regmap_read(hwmon->regmap, MAX17135_REG_STATUS, &status);
+ if (ret)
+ return ret;
+
+ *val = !!(status & (MAX17135_STATUS_OPEN | MAX17135_STATUS_SHORT));
+
+ return 0;
+}
+
+static int max17135_hwmon_read_input(struct max17135_hwmon *hwmon, int channel,
+ long *val)
+{
+ long fault;
+ int ret;
+
+ if (channel == 0)
+ return max17135_read_temp(hwmon->chip, MAX17135_TEMP_INTERNAL,
+ val);
+
+ /* Without a working diode the register holds a dummy value. */
+ ret = max17135_hwmon_diode_fault(hwmon, &fault);
+ if (ret)
+ return ret;
+ if (fault)
+ return -ENODATA;
+
+ return max17135_read_temp(hwmon->chip, MAX17135_TEMP_EXTERNAL, val);
+}
+
+static int max17135_hwmon_read(struct device *dev,
+ enum hwmon_sensor_types type, u32 attr,
+ int channel, long *val)
+{
+ struct max17135_hwmon *hwmon = dev_get_drvdata(dev);
+
+ switch (attr) {
+ case hwmon_temp_input:
+ return max17135_hwmon_read_input(hwmon, channel, val);
+ case hwmon_temp_fault:
+ return max17135_hwmon_diode_fault(hwmon, val);
+ default:
+ return -EOPNOTSUPP;
+ }
+}
+
+static const struct hwmon_channel_info * const max17135_hwmon_info[] = {
+ HWMON_CHANNEL_INFO(temp,
+ HWMON_T_INPUT,
+ HWMON_T_INPUT | HWMON_T_FAULT),
+ NULL
+};
+
+static const struct hwmon_ops max17135_hwmon_ops = {
+ .visible = 0444,
+ .read = max17135_hwmon_read,
+};
+
+static const struct hwmon_chip_info max17135_hwmon_chip_info = {
+ .ops = &max17135_hwmon_ops,
+ .info = max17135_hwmon_info,
+};
+
+static int max17135_hwmon_probe(struct auxiliary_device *adev,
+ const struct auxiliary_device_id *id)
+{
+ struct device *dev = &adev->dev;
+ struct max17135_hwmon *hwmon;
+ struct device *hwmon_dev;
+
+ hwmon = devm_kzalloc_obj(dev, *hwmon);
+ if (!hwmon)
+ return -ENOMEM;
+
+ hwmon->chip = dev->parent;
+ hwmon->regmap = dev_get_regmap(dev->parent, NULL);
+ if (!hwmon->regmap)
+ return -ENODEV;
+
+ hwmon_dev = devm_hwmon_device_register_with_info(dev, "max17135",
+ hwmon,
+ &max17135_hwmon_chip_info,
+ NULL);
+
+ return PTR_ERR_OR_ZERO(hwmon_dev);
+}
+
+static const struct auxiliary_device_id max17135_hwmon_ids[] = {
+ { .name = "max17135.hwmon" },
+ { }
+};
+MODULE_DEVICE_TABLE(auxiliary, max17135_hwmon_ids);
+
+static struct auxiliary_driver max17135_hwmon_driver = {
+ .probe = max17135_hwmon_probe,
+ .id_table = max17135_hwmon_ids,
+};
+module_auxiliary_driver(max17135_hwmon_driver);
+
+MODULE_AUTHOR("Michiel van Beers <michielvanbeers@xxxxxxxxx>");
+MODULE_DESCRIPTION("Maxim MAX17135 temperature sensor driver");
+MODULE_IMPORT_NS("MAX17135");
+MODULE_LICENSE("GPL");
--
2.43.0