hwmon: pmbus: tda38640: Add identification for PMBUS_VOUT_MODE
PATCH 1/1 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.
---
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(-)
drivers/hwmon/pmbus/tda38640.c +25 -1
@@ -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,
Signature · 1 line
Kyle Hsieh <[email protected]>
Guenter Roeck
maintainerQuoted 27 lines · Kyle Hsieh
Add support for detecting the
PMBUS_VOUT_MODEfor 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 <[email protected]>---
This patch adds proper detection of thePMBUS_VOUT_MODEfor 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(-)drivers/hwmon/pmbus/tda38640.c +0
-0
drivers/hwmon/pmbus/tda38640.c struct tda38640_data { · line 32
Quoted 10 lines
drivers/hwmon/pmbus/tda38640.c +7
-0@@ -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 ?
drivers/hwmon/pmbus/tda38640.c struct tda38640_data { · line 36
Quoted 4 lines
drivers/hwmon/pmbus/tda38640.c +4
-0+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.
drivers/hwmon/pmbus/tda38640.c struct tda38640_data { · line 43
Quoted 7 lines
drivers/hwmon/pmbus/tda38640.c +7
-0+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
Quoted 31 lines
drivers/hwmon/pmbus/tda38640.c +7
-2+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-d6e47121a259Best regards,