Skip to content

Commit 2047107

Browse files
pblxptrgroeck
authored andcommitted
hwmon: (pmbus) Conditionally clear individual status bits for pmbus rev >= 1.2
The current implementation of pmbus_show_boolean assumes that all devices support write-back operation of status register to clear pending warnings or faults. Since clearing individual bits in the status registers was only introduced in PMBus specification 1.2, this operation may not be supported by some older devices. This can result in an error while reading boolean attributes such as temp1_max_alarm. Fetch PMBus revision supported by the device and modify pmbus_show_boolean so that it only tries to clear individual status bits if the device is compliant with PMBus specs >= 1.2. Otherwise clear all fault indicators on the current page after a fault status was reported. Fixes: 35f165f ("hwmon: (pmbus) Clear pmbus fault/warning bits after read") Signed-off-by: Patryk Biel <pbiel7@gmail.com> Message-ID: <20240909-pmbus-status-reg-clearing-v1-1-f1c0d68c6408@gmail.com> [groeck: Rewrote description Moved revision detection code ahead of clear faults command Assigned revision if return value from PMBUS_REVISION command is 0 Improved return value check from calling _pmbus_write_byte_data()] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent da3ea35 commit 2047107

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

drivers/hwmon/pmbus/pmbus.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,12 @@ enum pmbus_sensor_classes {
418418
enum pmbus_data_format { linear = 0, ieee754, direct, vid };
419419
enum vrm_version { vr11 = 0, vr12, vr13, imvp9, amd625mv };
420420

421+
/* PMBus revision identifiers */
422+
#define PMBUS_REV_10 0x00 /* PMBus revision 1.0 */
423+
#define PMBUS_REV_11 0x11 /* PMBus revision 1.1 */
424+
#define PMBUS_REV_12 0x22 /* PMBus revision 1.2 */
425+
#define PMBUS_REV_13 0x33 /* PMBus revision 1.3 */
426+
421427
struct pmbus_driver_info {
422428
int pages; /* Total number of pages */
423429
u8 phases[PMBUS_PAGES]; /* Number of phases per page */

drivers/hwmon/pmbus/pmbus_core.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ struct pmbus_data {
8585

8686
u32 flags; /* from platform data */
8787

88+
u8 revision; /* The PMBus revision the device is compliant with */
89+
8890
int exponent[PMBUS_PAGES];
8991
/* linear mode: exponent for output voltages */
9092

@@ -1095,9 +1097,14 @@ static int pmbus_get_boolean(struct i2c_client *client, struct pmbus_boolean *b,
10951097

10961098
regval = status & mask;
10971099
if (regval) {
1098-
ret = _pmbus_write_byte_data(client, page, reg, regval);
1099-
if (ret)
1100-
goto unlock;
1100+
if (data->revision >= PMBUS_REV_12) {
1101+
ret = _pmbus_write_byte_data(client, page, reg, regval);
1102+
if (ret)
1103+
goto unlock;
1104+
} else {
1105+
pmbus_clear_fault_page(client, page);
1106+
}
1107+
11011108
}
11021109
if (s1 && s2) {
11031110
s64 v1, v2;
@@ -2640,6 +2647,10 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data,
26402647
data->flags |= PMBUS_WRITE_PROTECTED | PMBUS_SKIP_STATUS_CHECK;
26412648
}
26422649

2650+
ret = i2c_smbus_read_byte_data(client, PMBUS_REVISION);
2651+
if (ret >= 0)
2652+
data->revision = ret;
2653+
26432654
if (data->info->pages)
26442655
pmbus_clear_faults(client);
26452656
else

0 commit comments

Comments
 (0)