Skip to content

Commit c60fe56

Browse files
Kostrgroeck
authored andcommitted
hwmon: (pmbus/mp2975) Fix driver initialization for MP2975 device
The commit 1feb31e ("hwmon: (pmbus/mp2975) Simplify VOUT code") has introduced a bug that makes it impossible to initialize MP2975 device: """ mp2975 5-0020: Failed to identify chip capabilities i2c i2c-5: new_device: Instantiated device mp2975 at 0x20 i2c i2c-5: delete_device: Deleting device mp2975 at 0x20 """ Since the 'read_byte_data' function was removed from the 'pmbus_driver_info ' structure the driver no longer reports correctly that VOUT mode is direct. Therefore 'pmbus_identify_common' fails with error, making it impossible to initialize the device. Restore 'read_byte_data' function to fix the issue. Tested: - before: it is not possible to initialize MP2975 device with the 'mp2975' driver, - after: 'mp2975' correctly initializes MP2975 device and all sensor data is correct. Fixes: 1feb31e ("hwmon: (pmbus/mp2975) Simplify VOUT code") Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com> Link: https://lore.kernel.org/r/20240126205714.2363-1-aladyshev22@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent 97aab85 commit c60fe56

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

drivers/hwmon/pmbus/mp2975.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,22 @@ static const struct regulator_desc __maybe_unused mp2975_reg_desc[] = {
126126

127127
#define to_mp2975_data(x) container_of(x, struct mp2975_data, info)
128128

129+
static int mp2975_read_byte_data(struct i2c_client *client, int page, int reg)
130+
{
131+
switch (reg) {
132+
case PMBUS_VOUT_MODE:
133+
/*
134+
* Enforce VOUT direct format, since device allows to set the
135+
* different formats for the different rails. Conversion from
136+
* VID to direct provided by driver internally, in case it is
137+
* necessary.
138+
*/
139+
return PB_VOUT_MODE_DIRECT;
140+
default:
141+
return -ENODATA;
142+
}
143+
}
144+
129145
static int
130146
mp2975_read_word_helper(struct i2c_client *client, int page, int phase, u8 reg,
131147
u16 mask)
@@ -869,6 +885,7 @@ static struct pmbus_driver_info mp2975_info = {
869885
PMBUS_HAVE_IIN | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
870886
PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP | PMBUS_HAVE_POUT |
871887
PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT | PMBUS_PHASE_VIRTUAL,
888+
.read_byte_data = mp2975_read_byte_data,
872889
.read_word_data = mp2975_read_word_data,
873890
#if IS_ENABLED(CONFIG_SENSORS_MP2975_REGULATOR)
874891
.num_regulators = 1,

0 commit comments

Comments
 (0)