[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260204-tda38640_direct_mode-v1-1-72511cd87b41@gmail.com>
Date: Wed, 04 Feb 2026 15:04:16 +0800
From: Kyle Hsieh <kylehsieh1995@...il.com>
To: Guenter Roeck <linux@...ck-us.net>
Cc: linux-hwmon@...r.kernel.org, linux-kernel@...r.kernel.org,
Kyle Hsieh <kylehsieh1995@...il.com>
Subject: [PATCH] hwmon: pmbus: tda38640: Add identification for
PMBUS_VOUT_MODE
Add support for detecting the PMBUS_VOUT_MODE for tda38640. Both
linear and direct modes are now handled. Previously, only linear
mode was assumed, which could trigger "Failed to identify chip
capabilities" for chips in direct mode.
This change ensures proper identification of the chip regardless
of its VOUT mode.
Signed-off-by: Kyle Hsieh <kylehsieh1995@...il.com>
---
This patch adds proper detection of the PMBUS_VOUT_MODE for the
tda38640 PMBus driver. Previously, the driver assumed linear mode
only, which would trigger "Failed to identify chip capabilities"
for chips operating in direct mode.
Changes:
- Add support to identify both linear and direct VOUT modes.
- Prevent misidentification and improve robustness of the driver.
---
drivers/hwmon/pmbus/tda38640.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/drivers/hwmon/pmbus/tda38640.c b/drivers/hwmon/pmbus/tda38640.c
index d902d39f49f4..410b7fc5aef5 100644
--- a/drivers/hwmon/pmbus/tda38640.c
+++ b/drivers/hwmon/pmbus/tda38640.c
@@ -23,6 +23,30 @@ struct tda38640_data {
u32 en_pin_lvl;
};
+static int tda38640_identify(struct i2c_client *client,
+ struct pmbus_driver_info *info)
+{
+ int vout_mode;
+
+ vout_mode = pmbus_read_byte_data(client, 0, PMBUS_VOUT_MODE);
+ if (vout_mode < 0 || vout_mode == 0xff)
+ return vout_mode < 0 ? vout_mode : -ENODEV;
+ switch (vout_mode >> 5) {
+ case 0: /* Linear */
+ info->format[PSC_VOLTAGE_OUT] = linear;
+ break;
+ case 2: /* Direct */
+ info->format[PSC_VOLTAGE_OUT] = direct;
+ info->m[PSC_VOLTAGE_OUT] = 1;
+ info->b[PSC_VOLTAGE_OUT] = 0;
+ info->R[PSC_VOLTAGE_OUT] = 3;
+ break;
+ default:
+ return -ENODEV;
+ }
+ return 0;
+}
+
#define to_tda38640_data(x) container_of(x, struct tda38640_data, info)
/*
@@ -142,7 +166,6 @@ static int svid_mode(struct i2c_client *client, struct tda38640_data *data)
static struct pmbus_driver_info tda38640_info = {
.pages = 1,
.format[PSC_VOLTAGE_IN] = linear,
- .format[PSC_VOLTAGE_OUT] = linear,
.format[PSC_CURRENT_OUT] = linear,
.format[PSC_CURRENT_IN] = linear,
.format[PSC_POWER] = linear,
@@ -153,6 +176,7 @@ static struct pmbus_driver_info tda38640_info = {
| PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
| PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
| PMBUS_HAVE_POUT | PMBUS_HAVE_PIN,
+ .identify = tda38640_identify,
#if IS_ENABLED(CONFIG_SENSORS_TDA38640_REGULATOR)
.num_regulators = 1,
.reg_desc = tda38640_reg_desc,
---
base-commit: 5fd0a1df5d05ad066e5618ccdd3d0fa6cb686c27
change-id: 20260204-tda38640_direct_mode-d6e47121a259
Best regards,
--
Kyle Hsieh <kylehsieh1995@...il.com>
Powered by blists - more mailing lists