* [PATCH 2/3] regulator: Add Maxim MAX17135 driver
2026-12-02 16:43 [PATCH 0/3] regulator: Add Maxim MAX17135 E-paper PMIC driver Michiel van Beers via B4 Relay
2026-12-02 16:43 ` [PATCH 1/3] regulator: dt-bindings: Add Maxim MAX17135 Michiel van Beers via B4 Relay
@ 2026-12-02 16:43 ` Michiel van Beers via B4 Relay
2026-12-02 16:54 ` sashiko-bot
2026-12-02 16:43 ` [PATCH 3/3] hwmon: Add Maxim MAX17135 temperature sensor driver Michiel van Beers via B4 Relay
2026-12-02 16:54 ` [PATCH 0/3] regulator: Add Maxim MAX17135 E-paper PMIC driver sashiko-bot
3 siblings, 1 reply; 7+ messages in thread
From: Michiel van Beers via B4 Relay @ 2026-12-02 16:43 UTC (permalink / raw)
To: Michiel van Beers, Liam Girdwood, Mark Brown, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Guenter Roeck, Jonathan Corbet,
Shuah Khan, Randy Dunlap
Cc: linux-kernel, devicetree, linux-hwmon, linux-doc, Andreas Kemnade,
Pablo Mazzini
From: Michiel van Beers <michielvanbeers@gmail.com>
Add a driver for the MAX17135 E-paper display PMIC.
The display rails POS, NEG, GVDD and GVEE share one enable and one power
good signal, so implement them as a single regulator, vposneg. VCOM is a
second regulator, supplied by vposneg.
VCOM is only set through the volatile DVR register; the non-volatile
memory is never written. As VCOM is panel specific, refuse to enable it
while the chip holds a default value and the device tree gives no
voltage.
The temperature sensor is exposed to a hwmon driver through an auxiliary
device.
Signed-off-by: Michiel van Beers <michielvanbeers@gmail.com>
---
MAINTAINERS | 8 +
drivers/regulator/Kconfig | 14 +
drivers/regulator/Makefile | 1 +
drivers/regulator/max17135.c | 643 +++++++++++++++++++++++++++++++++++++
include/linux/regulator/max17135.h | 18 ++
5 files changed, 684 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index 9eaee28958b6..6b2af23ec2bf 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -16491,6 +16491,14 @@ S: Maintained
F: Documentation/devicetree/bindings/power/supply/maxim,max17042.yaml
F: drivers/power/supply/max17042_battery.c
+MAXIM MAX17135 E-PAPER DISPLAY PMIC DRIVER
+M: Michiel van Beers <michielvanbeers@gmail.com>
+L: linux-kernel@vger.kernel.org
+S: Maintained
+F: Documentation/devicetree/bindings/regulator/maxim,max17135.yaml
+F: drivers/regulator/max17135.c
+F: include/linux/regulator/max17135.h
+
MAXIM MAX20086 CAMERA POWER PROTECTOR DRIVER
M: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
L: linux-kernel@vger.kernel.org
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 390d109ad932..08f92967d427 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -622,6 +622,20 @@ config REGULATOR_MAX1586
regulator via I2C bus. The provided regulator is suitable
for PXA27x chips to control VCC_CORE and VCC_USIM voltages.
+config REGULATOR_MAX17135
+ tristate "Maxim MAX17135 E-paper display PMIC"
+ depends on I2C
+ select REGMAP_I2C
+ select AUXILIARY_BUS
+ help
+ This driver supports the Maxim MAX17135 power management IC for
+ E-paper displays. It provides the display rails and the VCOM
+ output as regulators. The temperature sensor of the chip is
+ supported by a separate hardware monitoring driver.
+
+ This driver can also be built as a module. If so, the module
+ will be called max17135.
+
config REGULATOR_MAX5970
tristate "Maxim 5970/5978 power switch and monitor"
depends on I2C
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 9332c68a90f6..ab562e775b28 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -75,6 +75,7 @@ obj-$(CONFIG_REGULATOR_LTC3589) += ltc3589.o
obj-$(CONFIG_REGULATOR_LTC3676) += ltc3676.o
obj-$(CONFIG_REGULATOR_MAX14577) += max14577-regulator.o
obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o
+obj-$(CONFIG_REGULATOR_MAX17135) += max17135.o
obj-$(CONFIG_REGULATOR_MAX5970) += max5970-regulator.o
obj-$(CONFIG_REGULATOR_MAX77503) += max77503-regulator.o
obj-$(CONFIG_REGULATOR_MAX77541) += max77541-regulator.o
diff --git a/drivers/regulator/max17135.c b/drivers/regulator/max17135.c
new file mode 100644
index 000000000000..b192a228d0aa
--- /dev/null
+++ b/drivers/regulator/max17135.c
@@ -0,0 +1,643 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Maxim MAX17135 power management IC for E-paper displays
+ *
+ * Copyright (C) 2026 Michiel van Beers
+ *
+ * Datasheet:
+ * https://www.analog.com/media/en/technical-documentation/data-sheets/MAX17135.pdf
+ */
+
+#include <linux/array_size.h>
+#include <linux/auxiliary_bus.h>
+#include <linux/bitops.h>
+#include <linux/bits.h>
+#include <linux/completion.h>
+#include <linux/delay.h>
+#include <linux/dev_printk.h>
+#include <linux/device.h>
+#include <linux/device/devres.h>
+#include <linux/err.h>
+#include <linux/errno.h>
+#include <linux/export.h>
+#include <linux/gpio/consumer.h>
+#include <linux/i2c.h>
+#include <linux/interrupt.h>
+#include <linux/jiffies.h>
+#include <linux/minmax.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/pm.h>
+#include <linux/property.h>
+#include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
+#include <linux/regulator/driver.h>
+#include <linux/regulator/max17135.h>
+#include <linux/types.h>
+
+#define MAX17135_REG_TEMP_EXT 0x00 /* 16 bit, word read only */
+#define MAX17135_REG_CONFIG 0x01
+#define MAX17135_REG_TEMP_INT 0x04 /* 16 bit, word read only */
+#define MAX17135_REG_STATUS 0x05
+#define MAX17135_REG_ID 0x07
+#define MAX17135_REG_DVR 0x08
+#define MAX17135_REG_ENABLE 0x09
+#define MAX17135_REG_FAULT 0x0a
+#define MAX17135_REG_HVINP 0x0b
+#define MAX17135_REG_CONV_RATE 0x0f
+#define MAX17135_REG_T1 0x10
+#define MAX17135_REG_T5 0x14
+#define MAX17135_REG_T8 0x17
+
+#define MAX17135_CONFIG_SHUTDOWN BIT(0)
+#define MAX17135_ENABLE_EN BIT(0)
+#define MAX17135_ENABLE_CEN BIT(1)
+#define MAX17135_FAULT_MASK GENMASK(6, 0)
+
+#define MAX17135_ID 0x4d
+#define MAX17135_DVR_POR 0xff
+#define MAX17135_DVR_FACTORY 0x7f
+
+#define MAX17135_NUM_DELAYS 4
+#define MAX17135_STARTUP_MS 10
+/*
+ * Typical worst case: two 5 ms converter soft starts, t1-t4 of up to 255 ms
+ * and a 10 ms rail soft start.
+ */
+#define MAX17135_POK_TIMEOUT_MS 400
+#define MAX17135_OFF_MARGIN_MS 5
+
+struct max17135 {
+ struct device *dev;
+ struct regmap *regmap;
+ struct gpio_desc *pok_gpio;
+ struct gpio_desc *en_gpio;
+ struct gpio_desc *cen_gpio;
+ struct completion pok_done;
+ u32 up_delays[MAX17135_NUM_DELAYS];
+ u32 down_delays[MAX17135_NUM_DELAYS];
+ bool has_up_delays;
+ bool has_down_delays;
+ unsigned int off_delay_ms;
+ /* The DT or a consumer chose the VCOM voltage, DVR may be written */
+ bool vcom_programmed;
+ unsigned int vcom_sel;
+};
+
+/*
+ * 0x0b (HVINP) sets the level of the display rails and 0x0c (PCR) burns the
+ * non-volatile memory, which survives only a few writes. Neither is ever
+ * written.
+ */
+static const struct regmap_range max17135_wr_ranges[] = {
+ regmap_reg_range(MAX17135_REG_CONFIG, MAX17135_REG_CONFIG),
+ regmap_reg_range(MAX17135_REG_DVR, MAX17135_REG_ENABLE),
+ regmap_reg_range(MAX17135_REG_T1, MAX17135_REG_T8),
+};
+
+static const struct regmap_access_table max17135_wr_table = {
+ .yes_ranges = max17135_wr_ranges,
+ .n_yes_ranges = ARRAY_SIZE(max17135_wr_ranges),
+};
+
+/*
+ * The temperature registers 0x00 and 0x04 are 16 bits wide. A byte read of
+ * them can leave the chip holding SDA low, so they are kept out of the regmap
+ * and are only read by max17135_read_temp(). 0x0c is write only.
+ */
+static const struct regmap_range max17135_rd_ranges[] = {
+ regmap_reg_range(MAX17135_REG_CONFIG, MAX17135_REG_CONFIG),
+ regmap_reg_range(MAX17135_REG_STATUS, MAX17135_REG_HVINP),
+ regmap_reg_range(MAX17135_REG_CONV_RATE, MAX17135_REG_T8),
+};
+
+static const struct regmap_access_table max17135_rd_table = {
+ .yes_ranges = max17135_rd_ranges,
+ .n_yes_ranges = ARRAY_SIZE(max17135_rd_ranges),
+};
+
+static const struct regmap_config max17135_regmap_config = {
+ .reg_bits = 8,
+ .val_bits = 8,
+ .max_register = MAX17135_REG_T8,
+ .wr_table = &max17135_wr_table,
+ .rd_table = &max17135_rd_table,
+};
+
+/**
+ * max17135_read_temp() - read one of the temperature channels
+ * @dev: the I2C device of the MAX17135
+ * @channel: internal sensor or external diode
+ * @millicelsius: result
+ *
+ * Return: 0 on success, a negative errno otherwise.
+ */
+int max17135_read_temp(struct device *dev,
+ enum max17135_temp_channel channel,
+ long *millicelsius)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ u8 reg = channel == MAX17135_TEMP_EXTERNAL ?
+ MAX17135_REG_TEMP_EXT : MAX17135_REG_TEMP_INT;
+ int ret;
+
+ ret = i2c_smbus_read_word_swapped(client, reg);
+ if (ret < 0)
+ return ret;
+
+ /* 9 bits, two's complement, in D15..D7; 0.5 degrees per step */
+ *millicelsius = sign_extend32(ret >> 7, 8) * 500;
+
+ return 0;
+}
+EXPORT_SYMBOL_NS_GPL(max17135_read_temp, "MAX17135");
+
+static int max17135_set_en(struct max17135 *ddata, bool on)
+{
+ if (ddata->en_gpio)
+ return gpiod_set_value_cansleep(ddata->en_gpio, on);
+
+ return regmap_update_bits(ddata->regmap, MAX17135_REG_ENABLE,
+ MAX17135_ENABLE_EN,
+ on ? MAX17135_ENABLE_EN : 0);
+}
+
+static int max17135_set_cen(struct max17135 *ddata, bool on)
+{
+ if (ddata->cen_gpio)
+ return gpiod_set_value_cansleep(ddata->cen_gpio, on);
+
+ return regmap_update_bits(ddata->regmap, MAX17135_REG_ENABLE,
+ MAX17135_ENABLE_CEN,
+ on ? MAX17135_ENABLE_CEN : 0);
+}
+
+/* Switch everything off and wait for the power-down sequence to end. */
+static void max17135_power_off(struct max17135 *ddata)
+{
+ max17135_set_cen(ddata, false);
+ max17135_set_en(ddata, false);
+ msleep(ddata->off_delay_ms);
+}
+
+static void max17135_power_off_action(void *data)
+{
+ max17135_power_off(data);
+}
+
+static irqreturn_t max17135_pok_handler(int irq, void *dev_id)
+{
+ struct max17135 *ddata = dev_id;
+
+ complete(&ddata->pok_done);
+
+ return IRQ_HANDLED;
+}
+
+static int max17135_vposneg_enable(struct regulator_dev *rdev)
+{
+ struct max17135 *ddata = rdev_get_drvdata(rdev);
+ unsigned int fault;
+ int ret;
+
+ ret = regmap_read(ddata->regmap, MAX17135_REG_FAULT, &fault);
+ if (ret)
+ return ret;
+
+ /* A latched fault is only cleared by cycling VDD. */
+ if (fault & MAX17135_FAULT_MASK) {
+ dev_err(ddata->dev, "fault 0x%02lx latched, rails stay off\n",
+ fault & MAX17135_FAULT_MASK);
+ return -EIO;
+ }
+
+ reinit_completion(&ddata->pok_done);
+
+ ret = max17135_set_en(ddata, true);
+ if (ret)
+ goto err_off;
+
+ wait_for_completion_timeout(&ddata->pok_done,
+ msecs_to_jiffies(MAX17135_POK_TIMEOUT_MS));
+
+ ret = gpiod_get_value_cansleep(ddata->pok_gpio);
+ if (ret < 0)
+ goto err_off;
+ if (!ret) {
+ /* On a fault the chip switches itself off and says why. */
+ if (!regmap_read(ddata->regmap, MAX17135_REG_FAULT, &fault))
+ dev_err(ddata->dev, "no power good, fault 0x%02lx\n",
+ fault & MAX17135_FAULT_MASK);
+ ret = -ETIMEDOUT;
+ goto err_off;
+ }
+
+ return 0;
+
+err_off:
+ /* Never leave the high voltage half on. */
+ max17135_power_off(ddata);
+ return ret;
+}
+
+static int max17135_vposneg_disable(struct regulator_dev *rdev)
+{
+ struct max17135 *ddata = rdev_get_drvdata(rdev);
+ int ret;
+
+ ret = max17135_set_en(ddata, false);
+ if (ret)
+ return ret;
+
+ msleep(ddata->off_delay_ms);
+
+ return 0;
+}
+
+static int max17135_vposneg_is_enabled(struct regulator_dev *rdev)
+{
+ struct max17135 *ddata = rdev_get_drvdata(rdev);
+
+ return gpiod_get_value_cansleep(ddata->pok_gpio);
+}
+
+static const struct regulator_ops max17135_vposneg_ops = {
+ .enable = max17135_vposneg_enable,
+ .disable = max17135_vposneg_disable,
+ .is_enabled = max17135_vposneg_is_enabled,
+};
+
+static bool max17135_dvr_is_default(unsigned int dvr)
+{
+ return dvr == MAX17135_DVR_POR || dvr == MAX17135_DVR_FACTORY;
+}
+
+static int max17135_vcom_enable(struct regulator_dev *rdev)
+{
+ struct max17135 *ddata = rdev_get_drvdata(rdev);
+ unsigned int dvr;
+ int ret;
+
+ if (!ddata->vcom_programmed) {
+ ret = regmap_read(ddata->regmap, MAX17135_REG_DVR, &dvr);
+ if (ret)
+ return ret;
+
+ /* VCOM is panel specific; a default value is not calibrated. */
+ if (max17135_dvr_is_default(dvr)) {
+ dev_err(ddata->dev, "VCOM is not calibrated\n");
+ return -EINVAL;
+ }
+ }
+
+ return max17135_set_cen(ddata, true);
+}
+
+static int max17135_vcom_disable(struct regulator_dev *rdev)
+{
+ struct max17135 *ddata = rdev_get_drvdata(rdev);
+
+ return max17135_set_cen(ddata, false);
+}
+
+static int max17135_vcom_is_enabled(struct regulator_dev *rdev)
+{
+ struct max17135 *ddata = rdev_get_drvdata(rdev);
+ unsigned int val;
+ int ret;
+
+ if (ddata->cen_gpio)
+ return gpiod_get_value_cansleep(ddata->cen_gpio);
+
+ ret = regmap_read(ddata->regmap, MAX17135_REG_ENABLE, &val);
+ if (ret)
+ return ret;
+
+ return !!(val & MAX17135_ENABLE_CEN);
+}
+
+static int max17135_vcom_set_voltage_sel(struct regulator_dev *rdev,
+ unsigned int selector)
+{
+ struct max17135 *ddata = rdev_get_drvdata(rdev);
+ int ret;
+
+ ret = regulator_set_voltage_sel_regmap(rdev, selector);
+ if (ret)
+ return ret;
+
+ ddata->vcom_sel = selector;
+ ddata->vcom_programmed = true;
+
+ return 0;
+}
+
+static const struct regulator_ops max17135_vcom_ops = {
+ .list_voltage = regulator_list_voltage_linear,
+ .map_voltage = regulator_map_voltage_linear,
+ .get_voltage_sel = regulator_get_voltage_sel_regmap,
+ .set_voltage_sel = max17135_vcom_set_voltage_sel,
+ .enable = max17135_vcom_enable,
+ .disable = max17135_vcom_disable,
+ .is_enabled = max17135_vcom_is_enabled,
+};
+
+static int max17135_vcom_of_parse(struct device_node *np,
+ const struct regulator_desc *desc,
+ struct regulator_config *config)
+{
+ struct max17135 *ddata = config->driver_data;
+ u32 min, max;
+
+ /* A single voltage in the DT is the calibration of this panel. */
+ if (!of_property_read_u32(np, "regulator-min-microvolt", &min) &&
+ !of_property_read_u32(np, "regulator-max-microvolt", &max) &&
+ min == max)
+ ddata->vcom_programmed = true;
+
+ return 0;
+}
+
+static const struct regulator_desc max17135_vposneg_desc = {
+ .name = "vposneg",
+ .of_match = "vposneg",
+ .regulators_node = "regulators",
+ .id = 0,
+ .ops = &max17135_vposneg_ops,
+ .type = REGULATOR_VOLTAGE,
+ .owner = THIS_MODULE,
+};
+
+/* VCOM is negative; it is exposed as its magnitude, 0.5 V to 3.05 V. */
+static const struct regulator_desc max17135_vcom_desc = {
+ .name = "vcom",
+ .of_match = "vcom",
+ .regulators_node = "regulators",
+ .of_parse_cb = max17135_vcom_of_parse,
+ .supply_name = "vposneg",
+ .id = 1,
+ .ops = &max17135_vcom_ops,
+ .type = REGULATOR_VOLTAGE,
+ .owner = THIS_MODULE,
+ .n_voltages = 256,
+ .min_uV = 500000,
+ .uV_step = 10000,
+ .vsel_reg = MAX17135_REG_DVR,
+ .vsel_mask = 0xff,
+};
+
+static int max17135_read_delays(struct max17135 *ddata, const char *prop,
+ u32 *delays, bool *present)
+{
+ int ret, i;
+
+ if (!device_property_present(ddata->dev, prop))
+ return 0;
+
+ ret = device_property_read_u32_array(ddata->dev, prop, delays,
+ MAX17135_NUM_DELAYS);
+ if (ret)
+ return ret;
+
+ for (i = 0; i < MAX17135_NUM_DELAYS; i++)
+ if (delays[i] > 255)
+ return -EINVAL;
+
+ *present = true;
+
+ return 0;
+}
+
+/* The timing registers are volatile; the preset in the NVM is not touched. */
+static int max17135_write_delays(struct max17135 *ddata)
+{
+ int ret, i;
+
+ for (i = 0; i < MAX17135_NUM_DELAYS; i++) {
+ if (ddata->has_up_delays) {
+ ret = regmap_write(ddata->regmap, MAX17135_REG_T1 + i,
+ ddata->up_delays[i]);
+ if (ret)
+ return ret;
+ }
+
+ if (ddata->has_down_delays) {
+ ret = regmap_write(ddata->regmap, MAX17135_REG_T5 + i,
+ ddata->down_delays[i]);
+ if (ret)
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+static int max17135_read_off_delay(struct max17135 *ddata)
+{
+ unsigned int val, longest = 0;
+ int ret, i;
+
+ for (i = 0; i < MAX17135_NUM_DELAYS; i++) {
+ ret = regmap_read(ddata->regmap, MAX17135_REG_T5 + i, &val);
+ if (ret)
+ return ret;
+
+ longest = max(longest, val);
+ }
+
+ ddata->off_delay_ms = longest + MAX17135_OFF_MARGIN_MS;
+
+ return 0;
+}
+
+static int max17135_probe(struct i2c_client *client)
+{
+ struct device *dev = &client->dev;
+ struct regulator_config config = { };
+ struct auxiliary_device *adev;
+ struct regulator_dev *rdev;
+ struct max17135 *ddata;
+ unsigned int val;
+ int id, irq, ret;
+
+ if (!i2c_check_functionality(client->adapter,
+ I2C_FUNC_SMBUS_READ_WORD_DATA))
+ return -ENODEV;
+
+ ddata = devm_kzalloc_obj(dev, *ddata);
+ if (!ddata)
+ return -ENOMEM;
+
+ ddata->dev = dev;
+ init_completion(&ddata->pok_done);
+ i2c_set_clientdata(client, ddata);
+
+ ddata->regmap = devm_regmap_init_i2c(client, &max17135_regmap_config);
+ if (IS_ERR(ddata->regmap))
+ return dev_err_probe(dev, PTR_ERR(ddata->regmap),
+ "failed to init regmap\n");
+
+ ddata->pok_gpio = devm_gpiod_get(dev, "pwr-good", GPIOD_IN);
+ if (IS_ERR(ddata->pok_gpio))
+ return dev_err_probe(dev, PTR_ERR(ddata->pok_gpio),
+ "failed to get pwr-good gpio\n");
+
+ ddata->en_gpio = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW);
+ if (IS_ERR(ddata->en_gpio))
+ return dev_err_probe(dev, PTR_ERR(ddata->en_gpio),
+ "failed to get enable gpio\n");
+
+ ddata->cen_gpio = devm_gpiod_get_optional(dev, "vcom-ctrl",
+ GPIOD_OUT_LOW);
+ if (IS_ERR(ddata->cen_gpio))
+ return dev_err_probe(dev, PTR_ERR(ddata->cen_gpio),
+ "failed to get vcom-ctrl gpio\n");
+
+ ret = max17135_read_delays(ddata, "maxim,power-up-delays-ms",
+ ddata->up_delays, &ddata->has_up_delays);
+ if (ret)
+ return dev_err_probe(dev, ret, "invalid power-up delays\n");
+
+ ret = max17135_read_delays(ddata, "maxim,power-down-delays-ms",
+ ddata->down_delays, &ddata->has_down_delays);
+ if (ret)
+ return dev_err_probe(dev, ret, "invalid power-down delays\n");
+
+ ret = devm_regulator_get_enable(dev, "vin");
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to enable vin\n");
+
+ ret = devm_regulator_get_enable_optional(dev, "vdd");
+ if (ret && ret != -ENODEV)
+ return dev_err_probe(dev, ret, "failed to enable vdd\n");
+
+ /* The datasheet gives no start-up time; 10 ms is ample in practice. */
+ msleep(MAX17135_STARTUP_MS);
+
+ ret = regmap_read(ddata->regmap, MAX17135_REG_ID, &val);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to read the ID\n");
+ if (val != MAX17135_ID)
+ return dev_err_probe(dev, -ENODEV, "unexpected ID 0x%02x\n",
+ val);
+
+ /* Start with everything off, also after a warm reboot. */
+ ret = regmap_update_bits(ddata->regmap, MAX17135_REG_ENABLE,
+ MAX17135_ENABLE_EN | MAX17135_ENABLE_CEN, 0);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to clear enables\n");
+
+ ret = max17135_write_delays(ddata);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to write delays\n");
+
+ ret = max17135_read_off_delay(ddata);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to read delays\n");
+
+ ret = devm_add_action_or_reset(dev, max17135_power_off_action, ddata);
+ if (ret)
+ return ret;
+
+ irq = gpiod_to_irq(ddata->pok_gpio);
+ if (irq < 0)
+ return dev_err_probe(dev, irq, "failed to get pwr-good irq\n");
+
+ ret = devm_request_threaded_irq(dev, irq, NULL, max17135_pok_handler,
+ IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+ "max17135-pok", ddata);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to request irq\n");
+
+ config.dev = dev;
+ config.driver_data = ddata;
+ config.regmap = ddata->regmap;
+
+ rdev = devm_regulator_register(dev, &max17135_vposneg_desc, &config);
+ if (IS_ERR(rdev))
+ return dev_err_probe(dev, PTR_ERR(rdev),
+ "failed to register vposneg\n");
+
+ rdev = devm_regulator_register(dev, &max17135_vcom_desc, &config);
+ if (IS_ERR(rdev))
+ return dev_err_probe(dev, PTR_ERR(rdev),
+ "failed to register vcom\n");
+
+ ret = regmap_read(ddata->regmap, MAX17135_REG_DVR, &val);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to read VCOM\n");
+
+ if (ddata->vcom_programmed)
+ ddata->vcom_sel = val;
+ else if (max17135_dvr_is_default(val))
+ dev_warn(dev, "VCOM is not calibrated, vcom stays off\n");
+
+ /* Last, so that it is removed first: the hwmon driver uses our I2C. */
+ id = (client->adapter->nr << 10) | client->addr;
+ adev = __devm_auxiliary_device_create(dev, KBUILD_MODNAME, "hwmon",
+ NULL, id);
+ if (!adev)
+ return dev_err_probe(dev, -ENODEV,
+ "failed to create hwmon device\n");
+
+ return 0;
+}
+
+static void max17135_shutdown(struct i2c_client *client)
+{
+ max17135_power_off(i2c_get_clientdata(client));
+}
+
+static int max17135_suspend(struct device *dev)
+{
+ struct max17135 *ddata = dev_get_drvdata(dev);
+
+ /* This only stops the temperature sensor. */
+ return regmap_set_bits(ddata->regmap, MAX17135_REG_CONFIG,
+ MAX17135_CONFIG_SHUTDOWN);
+}
+
+static int max17135_resume(struct device *dev)
+{
+ struct max17135 *ddata = dev_get_drvdata(dev);
+ int ret;
+
+ /* The chip reloads its NVM presets if it lost power. */
+ ret = max17135_write_delays(ddata);
+ if (ret)
+ return ret;
+
+ if (ddata->vcom_programmed) {
+ ret = regmap_update_bits(ddata->regmap, MAX17135_REG_DVR,
+ 0xff, ddata->vcom_sel);
+ if (ret)
+ return ret;
+ }
+
+ return regmap_clear_bits(ddata->regmap, MAX17135_REG_CONFIG,
+ MAX17135_CONFIG_SHUTDOWN);
+}
+
+static DEFINE_SIMPLE_DEV_PM_OPS(max17135_pm_ops, max17135_suspend,
+ max17135_resume);
+
+static const struct of_device_id max17135_of_match[] = {
+ { .compatible = "maxim,max17135" },
+ { }
+};
+MODULE_DEVICE_TABLE(of, max17135_of_match);
+
+static struct i2c_driver max17135_driver = {
+ .driver = {
+ .name = "max17135",
+ .of_match_table = max17135_of_match,
+ .pm = pm_sleep_ptr(&max17135_pm_ops),
+ },
+ .probe = max17135_probe,
+ .shutdown = max17135_shutdown,
+};
+module_i2c_driver(max17135_driver);
+
+MODULE_AUTHOR("Michiel van Beers <michielvanbeers@gmail.com>");
+MODULE_DESCRIPTION("Maxim MAX17135 E-paper display PMIC driver");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/regulator/max17135.h b/include/linux/regulator/max17135.h
new file mode 100644
index 000000000000..8116e484ec39
--- /dev/null
+++ b/include/linux/regulator/max17135.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Maxim MAX17135 E-paper display PMIC */
+
+#ifndef __LINUX_REGULATOR_MAX17135_H
+#define __LINUX_REGULATOR_MAX17135_H
+
+struct device;
+
+enum max17135_temp_channel {
+ MAX17135_TEMP_INTERNAL,
+ MAX17135_TEMP_EXTERNAL,
+};
+
+int max17135_read_temp(struct device *dev,
+ enum max17135_temp_channel channel,
+ long *millicelsius);
+
+#endif
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 3/3] hwmon: Add Maxim MAX17135 temperature sensor driver
2026-12-02 16:43 [PATCH 0/3] regulator: Add Maxim MAX17135 E-paper PMIC driver Michiel van Beers via B4 Relay
2026-12-02 16:43 ` [PATCH 1/3] regulator: dt-bindings: Add Maxim MAX17135 Michiel van Beers via B4 Relay
2026-12-02 16:43 ` [PATCH 2/3] regulator: Add Maxim MAX17135 driver Michiel van Beers via B4 Relay
@ 2026-12-02 16:43 ` Michiel van Beers via B4 Relay
2026-12-02 17:36 ` Andreas Kemnade
2026-12-02 16:54 ` [PATCH 0/3] regulator: Add Maxim MAX17135 E-paper PMIC driver sashiko-bot
3 siblings, 1 reply; 7+ messages in thread
From: Michiel van Beers via B4 Relay @ 2026-12-02 16:43 UTC (permalink / raw)
To: Michiel van Beers, Liam Girdwood, Mark Brown, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Guenter Roeck, Jonathan Corbet,
Shuah Khan, Randy Dunlap
Cc: linux-kernel, devicetree, linux-hwmon, linux-doc, Andreas Kemnade,
Pablo Mazzini
From: Michiel van Beers <michielvanbeers@gmail.com>
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@gmail.com>
---
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@gmail.com>
+
+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@gmail.com>
L: linux-kernel@vger.kernel.org
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@gmail.com>");
+MODULE_DESCRIPTION("Maxim MAX17135 temperature sensor driver");
+MODULE_IMPORT_NS("MAX17135");
+MODULE_LICENSE("GPL");
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread