From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=178.238.236.174 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796232982; b=5EeLblSEccUt1FBkZCCxn9rPa2Poc6rFcKmBG0b+cW5JbbJpL/y/vB5iqyl+IMmOBhQk +RB/bvTvid18leySWMPa1JhmayXaEtzep8CVdxbq6hftyknjNd7ebOZlVGzCpZTFD7d9Q Ed9OKojsTfx4Ywnk7tlcFMYLJS9D86O1snnW9RHklFuuM7FzVbROl7WaSFHKC/Q2Xga6+ dFU0BFFmi5hdJQ+J0malkhixsrvtW3E4N8RKGrIgTe28HHDj3nUxPVr8rLjYrZDcDl47a TKQGm+MhdiwM3WQtw+Fwdr9ngyOec1ScXefAev8MJUhWL2f1+fvQiUZyxFQ09UKiJ5g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796232982; h=DMARC-Filter:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: In-Reply-To:References:X-Mailer:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=M9OM12Z5gwb7WTLY0pv5j4SMS6C646I/cKWqnTAq4zk=; b=xPFJ5EMzFDgI+V9+XYTSAHJc2NjB/nXPSd8MjjEbt8yIF1/yjIuJz52oRi4l0ut47SB+ vxOBfaBlOcaAyqohXKmBZ+eiu1NSZRHb+grVpInQInNXSDKP7xz1M20XUhOlJcRLA3wW4 jiq08XBnFDCJo417hfNfnTzhoXzFHVVfWnMy7thPVZPvSd9KaQU/sY8K7J3jGfmcfhoJr quTW6WqU5cZQGRrmsi7AigaddlGGs9u2DrvGDi99YENPPDvzfjhZrN3j1uwfITpaAFB1c ucde+RTjqJ0Fahk7VJkVpJgUEtwD4Vk9+7xpSJabH+HCj3cHSnroEjGisWwieNcwCpA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=kemnade.info; spf=pass smtp.mailfrom=kemnade.info; dkim=pass header.d=kemnade.info header.i=@kemnade.info header.a=rsa-sha256 header.s=20220719 header.b=9mQxO8Ae; arc=none smtp.remote-ip=178.238.236.174 Received: from mail.andi.de1.cc (mail.andi.de1.cc [178.238.236.174]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4546B606A322; Wed, 2 Dec 2026 17:36:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4546B606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=kemnade.info Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kemnade.info Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kemnade.info header.i=@kemnade.info header.a=rsa-sha256 header.s=20220719 header.b=9mQxO8Ae DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kemnade.info; s=20220719; h=References:In-Reply-To:Subject:Cc:To:From: Reply-To:Content-ID:Content-Description; bh=M9OM12Z5gwb7WTLY0pv5j4SMS6C646I/cKWqnTAq4zk=; t=1796232981; x=1797442581; b=9mQxO8Aey91MyucK+49AtwyReda3gUJh1UmEPv/LO5RKBY9UT2GvK24qi8nEORbyL7liQMQFSvU T7T5eWBLtIwPgYTvgXuL+I7ooXMHkF1NjuIkynKK4RnhdRvoeTgG3TR44IWP0GFsoD27O9lswXiGH 80XWg1ujJK2z/sUhw6VJHOekie+FC2ng/DGxiBAMyfOZ/GAltvMlolMlq8eMgB8g8RyPgIpXzzzw/ xPIABsOg1VBI95KiqieQTPVfXk9VFxA/4Zo45HH6eSNKF/9a647ot2PLsc5GtOnSG7NlFbSeNSUrn MJkbBMs3djQuLoBxjdBANDC3VOLVM4DkeuhQ==; Date: Wed, 2 Dec 2026 18:36:02 +0100 From: Andreas Kemnade To: Michiel van Beers via B4 Relay Cc: michielvanbeers@gmail.com, Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Guenter Roeck , Jonathan Corbet , Shuah Khan , Randy Dunlap , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, Pablo Mazzini Subject: Re: [PATCH 3/3] hwmon: Add Maxim MAX17135 temperature sensor driver Message-ID: <20261202183602.0dc10175@kemnade.info> In-Reply-To: <20261202-max17135-v1-3-beae6b70d575@gmail.com> References: <20261202-max17135-v1-0-beae6b70d575@gmail.com> <20261202-max17135-v1-3-beae6b70d575@gmail.com> X-Mailer: Claws Mail 4.3.1 (GTK 3.24.49; aarch64-unknown-linux-gnu) X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 02 Dec 2026 17:43:40 +0100 Michiel van Beers via B4 Relay wrote: > From: Michiel van Beers > > 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. > just in general: do have something cooking to use temperature you graphics driver? Pinebook folks use an non-mainline iio driver instead and use the iio in-kernel driver. bindings/display/repaper.txt defines a separate thermal-zone and the corresponding the drm driver uses thermal zone api to get temperature. For Kobos (display is not in mainline) I currntly do the same. Another dirty way of doing things... It is on my todo list to provide a clean interface. Regards, Andreas > Signed-off-by: Michiel van Beers > --- > 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 > + > +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 > 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 > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#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 "); > +MODULE_DESCRIPTION("Maxim MAX17135 temperature sensor driver"); > +MODULE_IMPORT_NS("MAX17135"); > +MODULE_LICENSE("GPL"); >