Skip to content

Commit e7593bd

Browse files
PatrickRudolphgroeck
authored andcommitted
hwmon: pmbus: Fix -EIO seen on pli1209
After doing performance optimizations the pli1209 driver failed to probe with a probabilty of 2%. It wasn't able to read the PMBUS_OPERATION register due to an -EIO error. An investigation showed that the PLI1209 takes 230 usec to execute the CLEAR_FAULTS command. During that time it's busy and NACKs all requests on the SMBUS interface. It also NACKs reads on PMBUS_STATUS_BYTE making it impossible to poll the BUSY flag. Add a custom write_data function to just wait for not BUSY unconditionally after sending a CLEAR_FAULTS command. TEST: Verified using an I2C bus analyser that no more NACKs are seen after sending a CLEAR_FAULTS command. Signed-off-by: Patrick Rudolph <[email protected]> Signed-off-by: Naresh Solanki <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent 3fd2188 commit e7593bd

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

drivers/hwmon/pmbus/pli1209bc.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Copyright (c) 2022 9elements GmbH
66
*/
77

8+
#include <linux/delay.h>
89
#include <linux/i2c.h>
910
#include <linux/module.h>
1011
#include <linux/pmbus.h>
@@ -53,6 +54,30 @@ static int pli1209bc_read_word_data(struct i2c_client *client, int page,
5354
}
5455
}
5556

57+
static int pli1209bc_write_byte(struct i2c_client *client, int page, u8 reg)
58+
{
59+
int ret;
60+
61+
switch (reg) {
62+
case PMBUS_CLEAR_FAULTS:
63+
ret = pmbus_write_byte(client, page, reg);
64+
/*
65+
* PLI1209 takes 230 usec to execute the CLEAR_FAULTS command.
66+
* During that time it's busy and NACKs all requests on the
67+
* SMBUS interface. It also NACKs reads on PMBUS_STATUS_BYTE
68+
* making it impossible to poll the BUSY flag.
69+
*
70+
* Just wait for not BUSY unconditionally.
71+
*/
72+
usleep_range(250, 300);
73+
break;
74+
default:
75+
ret = -ENODATA;
76+
break;
77+
}
78+
return ret;
79+
}
80+
5681
#if IS_ENABLED(CONFIG_SENSORS_PLI1209BC_REGULATOR)
5782
static const struct regulator_desc pli1209bc_reg_desc = {
5883
.name = "vout2",
@@ -102,6 +127,7 @@ static struct pmbus_driver_info pli1209bc_info = {
102127
| PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP
103128
| PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_STATUS_INPUT,
104129
.read_word_data = pli1209bc_read_word_data,
130+
.write_byte = pli1209bc_write_byte,
105131
#if IS_ENABLED(CONFIG_SENSORS_PLI1209BC_REGULATOR)
106132
.num_regulators = 1,
107133
.reg_desc = &pli1209bc_reg_desc,

0 commit comments

Comments
 (0)