From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796229852; b=UXiZ8mg0h8Yp5Fuy79YuBnuG4OwNCOWdX4vZNRGTZM+5amqx4Fj1exSu6tG/61DTTaxv d4ingKyS/pPb9KqmvGaS7+nQPYyeBvaZNq1ky9Sf7k+4K6N7DCbdT+oQSnfg1fb9k3LMQ 3qFRsI7MLFuAdIsdtIqQxSZamgCEnx8GThMLShTNzUqRqA9jidatJcL3w5MhIJOeDn2n/ IHvzeCE7h+Y7XU7F0/m+6qghlUyvGd9UxtJAiyfvKw4LjANn/h6r+6vAHG+5DrHYyyEoZ mb/8L9jCyx8kIUk/m0rwTviWuFcoJKBDlYpx1ujboKMlXi0A8R16tOPsmbL4YEzeDCQ== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796229852; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=A9zElmXKiOlZGXZz2qgnLKIRx6p00YVo1AJAGxhXWLE=; b=GgM6gZFgAhK7Dgfi0xSlgjrCYrQm4F0dICWj6YYnsjpkKzTFpM1l/lIT7SR43OaVECdL 0xJOsL51ciAffHuzcvNHZH1ZOH7xqtY6CjhhAAaOIMgZWjTe670Mjy1fA1K/cAQFHqCVL yvumvLIHiUCko8p2ni9/Pya6/+awxyZYfKlZ3YD1pcLuKW+qdzyVZvgdf2t+PChHn8WUv 5cTvnT+N1aUpGiaXp4FU/T2mxNRpwPS3x6agGnH5508mYyNiOjoOuJdfA9AfSsikUkCY4 tcTy7HPp7TktV5RTZnrBNbVNnic+KnTA6jkxzSCSvB/CkQ1TNy4yXKFCkbm234zTyDA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DdQcOdh9; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8605D606A330; Wed, 2 Dec 2026 16:44:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DdQcOdh9 Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1796229852; b=oaWhD+2fpx8+o2nI8WmEXajp0TiRR8F6AfhgAAZECbhYbFWX8I4LWwaNeUwzv0WUu4JD sTWefG9x7U5E/yIX84csFmkhx/4ZmX+kbQxXDsO0L+68obOgPm4wdOeaeuuR6K8N03R2M 7G027D8IxtH05SbDGM8ZL34/SEOXW5khnsXB2fK23xDatih4EL7ZoGrMEvmK3z0gapewF MrMakQuTaz91kMzvI2k+jbKeN5OvfceXPJ9wZUS/mVc9kCXYnkM0J91e4KpI1APCXLXg7 R8aLHbr9JR271F3fVqEB2kzFrdBvlhdHvscF7L3B024o+m0umYqFzL+PHt7Y3zjs7kw== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796229852; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=A9zElmXKiOlZGXZz2qgnLKIRx6p00YVo1AJAGxhXWLE=; b=JJGVrjauEpdSqDQ7OZwEPfKe+LY8gB8liGcmmvW2dKpfCP8UCj7dTa5fcbp7iA3diO8f vQcYdPAtl25X31Svgmf8kSMqlhENuZjTGMq7dc2vQOps9hibCZo3zcRIXXguyd58AjPrH q9jbvm/cNx8oqzfz2W/fIH3rIyD8o9yvIcVma2byBRInoa+LNpoaziSpT46b7i/EpoP13 yTLBlFzy/FlgHiHEdiyXZMwLSj93wnwzmLguNUofYP712aOryLz02fKqZ6uYU26/MoybW 3fB6pGBLj5TXKaVP5plfhMj+KeNqIjDvK2YJRC3XCjO+fl2HGmQu1uZt8TU22m0Ur1Q== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 2E4A21F00A27; Wed, 2 Dec 2026 16:44:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796229852; bh=A9zElmXKiOlZGXZz2qgnLKIRx6p00YVo1AJAGxhXWLE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=DdQcOdh9ItbyEOsgvQnwb4LYNB/dREwLSL5bPA3lqHqByvOTQhjzpsAa5B4ok27oD dTozfyiA36KZHvseDYp8PWTqVXMIo/f3TjKDE2ZF5vI/OW9FU7kYY7Mbb47Jpv58iP jS4rW5bS/04U7HGOpinE/6+QFYu+rfuGerSaAwRnP5FsnpSESKC8qRLy9ra3iiMmlh rH014NnHUG9Vth31XBaCi6IMQaCaNzndtiwav+1qE02+1qFxUTPZ3lcl8qam4TXcvA F+TdmbKNKi0TTsjS4lQO/IEyf4qWYGVs3Ce39aLeXhL2xGM6ahAiMgd+D/gV0a7MUN n7L7hz3PR3sZQ== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id AD9724F52D; Wed, 2 Dec 2026 16:44:00 +0000 (UTC) From: Michiel van Beers via B4 Relay Date: Wed, 02 Dec 2026 17:43:40 +0100 Subject: [PATCH 3/3] hwmon: Add Maxim MAX17135 temperature sensor driver X-Mailing-List: linux-kernel@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="utf-8" Message-Id: <20261202-max17135-v1-3-beae6b70d575@gmail.com> References: <20261202-max17135-v1-0-beae6b70d575@gmail.com> In-Reply-To: <20261202-max17135-v1-0-beae6b70d575@gmail.com> 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@vger.kernel.org, devicetree@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, Andreas Kemnade , Pablo Mazzini X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796229839; l=7979; i=michielvanbeers@gmail.com; s=20261107; h=from:subject:message-id; bh=ig8ckwjbXNhZU/YaGbyRLLO2w8/7nONSdlxon1zxFfc=; b=KbJoRL1tkgLzLHA2knoo/JmVsAGK0JEVjILr2y5W4/TKxw6gKIKdJcXkh0qFszfA7qXFpkQf7 evACw6tcdThAUc89etuPjZpUIIbNnswWitbZipswonBhhNm2wEIiBrQ X-Developer-Key: i=michielvanbeers@gmail.com; a=ed25519; pk=C+lOje7u3+2x3o2NLMXrwz2veP2++eXfIi9MtYsUo4k= X-Endpoint-Received: by B4 Relay for michielvanbeers@gmail.com/20261107 with auth_id=1444 X-Original-From: Michiel van Beers Reply-To: michielvanbeers@gmail.com Content-Transfer-Encoding: 7bit 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. 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"); -- 2.43.0