[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <30bad12b-13a3-46b1-b03f-877729fb01e5@roeck-us.net>
Date: Wed, 4 Feb 2026 14:39:41 -0800
From: Guenter Roeck <linux@...ck-us.net>
To: Kyle Hsieh <kylehsieh1995@...il.com>
Cc: linux-hwmon@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] hwmon: pmbus: tda38640: Add identification for
PMBUS_VOUT_MODE
On 2/3/26 23:04, Kyle Hsieh wrote:
> 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)
This is odd for a chip supposedly supporting the command. Why check
for 0xff ?
> + return vout_mode < 0 ? vout_mode : -ENODEV;
> + switch (vout_mode >> 5) {
> + case 0: /* Linear */
> + info->format[PSC_VOLTAGE_OUT] = linear;
This is already set, so there no need to update it.
> + 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;
The datasheet doesn't claim support for direct mode. Where is this documented,
and where do the coefficients come from ?
Also, I am concerned that this interferes with svid mode.
We'll have to ensure that this is not the case before proceeding.
Thanks,
Guenter
> + 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,
Powered by blists - more mailing lists