mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pablo Mazzini <pmazzini@gmail.com>
To: Mark Brown <broonie@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Guenter Roeck <linux@roeck-us.net>, Lee Jones <lee@kernel.org>
Cc: Pablo Mazzini <pmazzini@gmail.com>,
	Alistair Francis <alistair@alistair23.me>,
	Andreas Kemnade <andreas@kemnade.info>,
	linux-hwmon@vger.kernel.org, mfd@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: [PATCH 5/7] regulator: sy7636a: report the temperature
Date: Mon, 26 Oct 2026 00:39:16 +0000	[thread overview]
Message-ID: <20261026003918.155321-6-pmazzini@gmail.com> (raw)
In-Reply-To: <20261026003918.155321-1-pmazzini@gmail.com>

The separate hwmon cell enables VCOM at probe. Report the temperature
from here, as the TPS65185 and FP9931 drivers do, and under the chip
name as they do: read it while the rails are on and return -ENODATA
otherwise. Boards that need the rails on mark VCOM always-on. Drop the
hwmon driver.

Signed-off-by: Pablo Mazzini <pmazzini@gmail.com>
---
 Documentation/hwmon/index.rst         |   1 -
 Documentation/hwmon/sy7636a-hwmon.rst |  26 -------
 drivers/hwmon/Kconfig                 |  10 ---
 drivers/hwmon/Makefile                |   1 -
 drivers/hwmon/sy7636a-hwmon.c         | 102 --------------------------
 drivers/mfd/simple-mfd-i2c.c          |   1 -
 drivers/regulator/Kconfig             |   1 +
 drivers/regulator/sy7636a-regulator.c |  56 ++++++++++++++
 8 files changed, 57 insertions(+), 141 deletions(-)
 delete mode 100644 Documentation/hwmon/sy7636a-hwmon.rst
 delete mode 100644 drivers/hwmon/sy7636a-hwmon.c

diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst
index 199ca79621e9..43aecc4e49cd 100644
--- a/Documentation/hwmon/index.rst
+++ b/Documentation/hwmon/index.rst
@@ -265,7 +265,6 @@ Hardware Monitoring Kernel Drivers
    sq24860
    stpddc60
    surface_fan
-   sy7636a-hwmon
    tc654
    tc74
    tda38740
diff --git a/Documentation/hwmon/sy7636a-hwmon.rst b/Documentation/hwmon/sy7636a-hwmon.rst
deleted file mode 100644
index 03d866aba6e8..000000000000
--- a/Documentation/hwmon/sy7636a-hwmon.rst
+++ /dev/null
@@ -1,26 +0,0 @@
-.. SPDX-License-Identifier: GPL-2.0-or-later
-
-Kernel driver sy7636a-hwmon
-===========================
-
-Supported chips:
-
- * Silergy SY7636A PMIC
-
-
-Description
------------
-
-This driver adds hardware temperature reading support for
-the Silergy SY7636A PMIC.
-
-The following sensors are supported
-
-  * Temperature
-      - Temperature of external NTC in milli-degree C
-
-sysfs-Interface
----------------
-
-temp1_input
-	- Temperature of external NTC (milli-degree C)
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 18c682e1a475..36e08c333e01 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -2104,16 +2104,6 @@ config SENSORS_SIS5595
 	  This driver can also be built as a module. If so, the module
 	  will be called sis5595.
 
-config SENSORS_SY7636A
-	tristate "Silergy SY7636A"
-	depends on MFD_SY7636A
-	help
-	  If you say yes here you get support for the thermistor readout of
-	  the Silergy SY7636A PMIC.
-
-	  This driver can also be built as a module.  If so, the module
-	  will be called sy7636a-hwmon.
-
 config SENSORS_DME1737
 	tristate "SMSC DME1737, SCH311x and compatibles"
 	depends on HAS_IOPORT
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index d4c345ed7261..537fb0bc1778 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -234,7 +234,6 @@ obj-$(CONFIG_SENSORS_SPD5118)	+= spd5118.o
 obj-$(CONFIG_SENSORS_STTS751)	+= stts751.o
 obj-$(CONFIG_SENSORS_SURFACE_FAN)+= surface_fan.o
 obj-$(CONFIG_SENSORS_SURFACE_TEMP)+= surface_temp.o
-obj-$(CONFIG_SENSORS_SY7636A)	+= sy7636a-hwmon.o
 obj-$(CONFIG_SENSORS_AMC6821)	+= amc6821.o
 obj-$(CONFIG_SENSORS_TC74)	+= tc74.o
 obj-$(CONFIG_SENSORS_THMC50)	+= thmc50.o
diff --git a/drivers/hwmon/sy7636a-hwmon.c b/drivers/hwmon/sy7636a-hwmon.c
deleted file mode 100644
index d51daaf63d63..000000000000
--- a/drivers/hwmon/sy7636a-hwmon.c
+++ /dev/null
@@ -1,102 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Functions to access SY3686A power management chip temperature
- *
- * Copyright (C) 2021 reMarkable AS - http://www.remarkable.com/
- *
- * Authors: Lars Ivar Miljeteig <lars.ivar.miljeteig@remarkable.com>
- *          Alistair Francis <alistair@alistair23.me>
- */
-
-#include <linux/err.h>
-#include <linux/hwmon.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/regmap.h>
-#include <linux/regulator/machine.h>
-
-#include <linux/mfd/sy7636a.h>
-
-static int sy7636a_read(struct device *dev, enum hwmon_sensor_types type,
-			u32 attr, int channel, long *temp)
-{
-	struct regmap *regmap = dev_get_drvdata(dev);
-	int ret, reg_val;
-
-	ret = regmap_read(regmap,
-			  SY7636A_REG_TERMISTOR_READOUT, &reg_val);
-	if (ret)
-		return ret;
-
-	*temp = reg_val * 1000;
-
-	return 0;
-}
-
-static umode_t sy7636a_is_visible(const void *data,
-				  enum hwmon_sensor_types type,
-				  u32 attr, int channel)
-{
-	if (type != hwmon_temp)
-		return 0;
-
-	if (attr != hwmon_temp_input)
-		return 0;
-
-	return 0444;
-}
-
-static const struct hwmon_ops sy7636a_hwmon_ops = {
-	.is_visible = sy7636a_is_visible,
-	.read = sy7636a_read,
-};
-
-static const struct hwmon_channel_info * const sy7636a_info[] = {
-	HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ),
-	HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT),
-	NULL
-};
-
-static const struct hwmon_chip_info sy7636a_chip_info = {
-	.ops = &sy7636a_hwmon_ops,
-	.info = sy7636a_info,
-};
-
-static int sy7636a_sensor_probe(struct platform_device *pdev)
-{
-	struct regmap *regmap = dev_get_regmap(pdev->dev.parent, NULL);
-	struct device *hwmon_dev;
-	int err;
-
-	if (!regmap)
-		return -EPROBE_DEFER;
-
-	err = devm_regulator_get_enable(&pdev->dev, "vcom");
-	if (err)
-		return err;
-
-	hwmon_dev = devm_hwmon_device_register_with_info(&pdev->dev,
-							 "sy7636a_temperature", regmap,
-							 &sy7636a_chip_info, NULL);
-
-	if (IS_ERR(hwmon_dev)) {
-		err = PTR_ERR(hwmon_dev);
-		dev_err(&pdev->dev, "Unable to register hwmon device, returned %d\n", err);
-		return err;
-	}
-
-	return 0;
-}
-
-static struct platform_driver sy7636a_sensor_driver = {
-	.probe = sy7636a_sensor_probe,
-	.driver = {
-		.name = "sy7636a-temperature",
-	},
-};
-module_platform_driver(sy7636a_sensor_driver);
-
-MODULE_DESCRIPTION("SY7636A sensor driver");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:sy7636a-temperature");
diff --git a/drivers/mfd/simple-mfd-i2c.c b/drivers/mfd/simple-mfd-i2c.c
index ef3ce4bdf98b..168b4cf49b8c 100644
--- a/drivers/mfd/simple-mfd-i2c.c
+++ b/drivers/mfd/simple-mfd-i2c.c
@@ -69,7 +69,6 @@ static int simple_mfd_i2c_probe(struct i2c_client *i2c)
 
 static const struct mfd_cell sy7636a_cells[] = {
 	{ .name = "sy7636a-regulator", },
-	{ .name = "sy7636a-temperature", },
 };
 
 static const struct simple_mfd_data silergy_sy7636a = {
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 88ba2770e378..f0d8d1319a1b 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -1624,6 +1624,7 @@ config REGULATOR_SY7636A
 	depends on MFD_SY7636A
 	help
 	  This driver supports Silergy SY7636A voltage regulator.
+	  If HWMON is enabled, it also provides temperature measurement.
 
 config REGULATOR_SY8106A
 	tristate "Silergy SY8106A regulator"
diff --git a/drivers/regulator/sy7636a-regulator.c b/drivers/regulator/sy7636a-regulator.c
index 5705599d1b55..816df7716c0e 100644
--- a/drivers/regulator/sy7636a-regulator.c
+++ b/drivers/regulator/sy7636a-regulator.c
@@ -9,6 +9,7 @@
 
 #include <linux/completion.h>
 #include <linux/gpio/consumer.h>
+#include <linux/hwmon.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/mfd/sy7636a.h>
@@ -147,6 +148,52 @@ static const struct regulator_desc desc = {
 	.of_match = of_match_ptr("vcom"),
 };
 
+static int sy7636a_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
+			      u32 attr, int channel, long *temp)
+{
+	struct sy7636a_data *data = dev_get_drvdata(dev);
+	unsigned int mode, val;
+	int ret;
+
+	ret = regmap_read(data->regmap, SY7636A_REG_OPERATION_MODE_CRL, &mode);
+	if (ret)
+		return ret;
+
+	/* the thermistor is only sampled while the rails are on */
+	if (!(mode & SY7636A_OPERATION_MODE_CRL_ONOFF))
+		return -ENODATA;
+
+	ret = regmap_read(data->regmap, SY7636A_REG_TERMISTOR_READOUT, &val);
+	if (ret)
+		return ret;
+
+	*temp = (s8)val * 1000;
+
+	return 0;
+}
+
+static umode_t sy7636a_hwmon_is_visible(const void *data, enum hwmon_sensor_types type,
+					u32 attr, int channel)
+{
+	return 0444;
+}
+
+static const struct hwmon_channel_info * const sy7636a_hwmon_info[] = {
+	HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ),
+	HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT),
+	NULL
+};
+
+static const struct hwmon_ops sy7636a_hwmon_ops = {
+	.is_visible = sy7636a_hwmon_is_visible,
+	.read = sy7636a_hwmon_read,
+};
+
+static const struct hwmon_chip_info sy7636a_hwmon_chip_info = {
+	.ops = &sy7636a_hwmon_ops,
+	.info = sy7636a_hwmon_info,
+};
+
 static int sy7636a_regulator_probe(struct platform_device *pdev)
 {
 	struct regmap *regmap = dev_get_regmap(pdev->dev.parent, NULL);
@@ -235,6 +282,15 @@ static int sy7636a_regulator_probe(struct platform_device *pdev)
 		return PTR_ERR(rdev);
 	}
 
+	if (IS_REACHABLE(CONFIG_HWMON)) {
+		struct device *hwmon_dev;
+
+		hwmon_dev = devm_hwmon_device_register_with_info(&pdev->dev, "sy7636a", data,
+								 &sy7636a_hwmon_chip_info, NULL);
+		if (IS_ERR(hwmon_dev))
+			dev_notice(&pdev->dev, "failed to register hwmon\n");
+	}
+
 	return 0;
 }
 
-- 
2.52.0


  parent reply	other threads:[~2026-10-26  0:43 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26  0:39 [PATCH 0/7] sy7636a: power the panel only during updates Pablo Mazzini
2026-10-26  0:39 ` [PATCH 1/7] ARM: dts: imx: keep the SY7636A VCOM on Pablo Mazzini
2026-10-26  7:30   ` Andreas Kemnade
2026-10-26  8:21     ` Pablo Mazzini
2026-10-26  0:39 ` [PATCH 2/7] regulator: sy7636a: fix the chip name Pablo Mazzini
2026-10-26  7:39   ` Andreas Kemnade
2026-10-26  0:39 ` [PATCH 3/7] regulator: sy7636a: add VCOM voltage control Pablo Mazzini
2026-10-26  7:41   ` Andreas Kemnade
2026-10-26  0:39 ` [PATCH 4/7] regulator: sy7636a: wait for power good, then switch VCOM_EN Pablo Mazzini
2026-10-26  8:10   ` Andreas Kemnade
2026-10-26  8:44     ` Pablo Mazzini
2026-10-26  0:39 ` Pablo Mazzini [this message]
2026-10-26  8:42   ` [PATCH 5/7] regulator: sy7636a: report the temperature Andreas Kemnade
2026-10-26 14:35   ` Guenter Roeck
2026-10-26  0:39 ` [PATCH 6/7] regulator: sy7636a: bind to the I2C device directly Pablo Mazzini
2026-10-26  0:39 ` [PATCH 7/7] ARM: imx_v6_v7_defconfig: drop the SY7636A MFD and hwmon options Pablo Mazzini
2026-10-26  9:37 ` [PATCH 0/7] sy7636a: power the panel only during updates Andreas Kemnade
2026-10-26 11:28   ` Pablo Mazzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261026003918.155321-6-pmazzini@gmail.com \
    --to=pmazzini@gmail.com \
    --cc=alistair@alistair23.me \
    --cc=andreas@kemnade.info \
    --cc=broonie@kernel.org \
    --cc=lee@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=mfd@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®