[PATCH 5/7] regulator: sy7636a: report the temperature
From: Pablo Mazzini
Date: Sun Oct 25 2026 - 20:43:51 EST
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@xxxxxxxxx>
---
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@xxxxxxxxxxxxxx>
- * Alistair Francis <alistair@xxxxxxxxxxxxx>
- */
-
-#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, ®_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