hwmon: (pmbus/max16601) Support byte data writes on VSA rail
PATCH v3 1/2 hwmon: (pmbus/max16601) Support byte data writes on VSA rail
MAX16601 exposes the secondary VSA rail on virtual PMBus page 2 backed by a separate I2C client (data->vsa), while page 1 is a read-only virtual page for VCORE input current and power telemetry. Although the driver routes byte reads on page 2 to data->vsa via max16601_read_byte() and PMBUS_CLEAR_FAULTS byte writes via max16601_write_byte(), it does not implement write_byte_data(), and max16601_write_byte() falls through to -ENODATA on virtual page 1.
As a result, PMBus 1.2+ byte-data status writes from pmbus_core (such as clearing individual status bits in pmbus_get_boolean() or clearing STATUS_CML faults during probe) on page 2 are sent to the primary VCORE client instead of data->vsa, and byte writes on virtual page 1 fall through to page 0.
Implement max16601_write_byte_data() mirroring max16601_read_byte() to forward page 2 byte-data writes to data->vsa and reject virtual page 1 with -EOPNOTSUPP, and reject virtual page 1 in max16601_write_byte() as well.
---
Changes in v3:
- New preparatory patch to route MAX16601 page 2 (VSA) byte-data writes to data->vsa and reject virtual page 1 byte/byte-data writes.
drivers/hwmon/pmbus/max16601.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
drivers/hwmon/pmbus/max16601.c +17 -2
@@ -153,14 +153,28 @@ static int max16601_write_byte(struct i2c_client *client, int page, u8 reg)const struct pmbus_driver_info *info =pmbus_get_driver_info (client);struct max16601_data *data =to_max16601_data (info); -if (page ==2 ) { -if (reg ==PMBUS_CLEAR_FAULTS ) +if (page >0 ) { +if (page ==2 && reg ==PMBUS_CLEAR_FAULTS )return i2c_smbus_write_byte (data->vsa, reg);return -EOPNOTSUPP ; }return -ENODATA ; } +static int max16601_write_byte_data (struct i2c_client *client,int page, +int reg,u8 value) +{ +const struct pmbus_driver_info *info =pmbus_get_driver_info (client); +struct max16601_data *data =to_max16601_data (info); + +if (page >0 ) { +if (page ==2 )/* VSA */ +return i2c_smbus_write_byte_data (data->vsa, reg, value); +return -EOPNOTSUPP ; + } +return -ENODATA ; +} +static int max16601_write_word (struct i2c_client *client,int page,int reg,u16 value) {
@@ -252,6 +266,7 @@ static struct pmbus_driver_info max16601_info = { .read_byte_data = max16601_read_byte, .read_word_data = max16601_read_word, .write_byte = max16601_write_byte, + .write_byte_data = max16601_write_byte_data, .write_word_data = max16601_write_word, };
Signature · 1 line
2.56.1.703.gf848ed807c-goog
PATCH v3 2/2 hwmon: (pmbus) Clear only CML command and data faults during probe
During driver initialization, register capability probing, and SMBALERT mask setup, pmbus_core and the generic pmbus driver send CLEAR_FAULTS (0x03) to clear any communication or command faults triggered while probing unsupported commands or out-of-range page/register operands. However, CLEAR_FAULTS unconditionally clears all latched fault status bits across the device, including hardware power fault registers such as STATUS_WORD, STATUS_VOUT, STATUS_IOUT, and STATUS_MFR_SPECIFIC. As a result, a BMC reboot or driver re-probe erases pre-existing voltage regulator fault telemetry before monitoring or diagnostic tools can inspect it.
Simply omitting fault clearing during probe is not viable because probing unsupported commands asserts PB_CML_FAULT_INVALID_COMMAND in STATUS_CML (causing pmbus_check_status_cml() to fail subsequent checks with -EIO), and probing out-of-range PMBUS_PAGE or PMBUS_SMBALERT_MASK operands asserts PB_CML_FAULT_INVALID_DATA and PB_STATUS_CML.
Starting with PMBus Revision 1.2, individual bits in STATUS_CML can be cleared via Write-1-to-Clear (W1C), a mechanism pmbus_core already uses in pmbus_get_boolean(). Introduce pmbus_clear_cml_fault() and export pmbus_clear_cml_faults() in the "PMBUS" module namespace to clear PB_CML_FAULT_INVALID_COMMAND | PB_CML_FAULT_INVALID_DATA in PMBUS_STATUS_CML during device initialization, register probing, pmbus_write_smbalert_mask(), and pmbus_identify() while preserving all other latched fault bits:
- Verify during pmbus_init_common() that PMBUS_REVISION is valid (>= 1.2 and not 0xff), that the driver does not hook write_byte() without write_byte_data(), and that PMBUS_STATUS_CML is readable before enabling STATUS_CML W1C clearing.
- Fall back to pmbus_clear_fault_page() when STATUS_CML W1C is unavailable or if writing PMBUS_STATUS_CML fails.
Tested on BMC hardware across 130 hwmon devices (105 PMBus devices covering tda38740/xdpe1a2g5b, isl68137/raa228234, adm1266, ltc4286/ltc4287, and generic pmbus regulators including TI tps546e25/tps546b25 and factory write-protected converters), verifying clean probing with no -EIO regressions, preservation of non-CML status faults across re-binds, and fallback when writing PMBUS_STATUS_CML is NACKed.
---
Changes in v3:
- Clear PB_CML_FAULT_INVALID_DATA in addition to PB_CML_FAULT_INVALID_COMMAND so out-of-range PMBUS_PAGE and PMBUS_SMBALERT_MASK operand probes do not leave CML faults latched.
- Use pmbus_clear_cml_fault() in pmbus_write_smbalert_mask() so IRQ setup during probe also preserves pre-existing non-CML faults.
- Gate STATUS_CML W1C clearing via data->has_status_cml in pmbus_init_common() (requiring valid PMBUS_REVISION >= 1.2 and != 0xff, no write_byte() hook without write_byte_data(), and readable PMBUS_STATUS_CML != 0xff) so driver write_byte() / read_byte_data() filters are respected.
Changes in v2:
- Fall back to pmbus_clear_fault_page() if writing PMBUS_STATUS_CML fails (e.g. NACK on devices that do not support W1C on STATUS_CML).
- Export pmbus_clear_cml_faults() in the "PMBUS" namespace and use it in pmbus_identify() (pmbus.c) so generic pmbus devices also preserve non-CML faults during probe.
- Re-tested on hardware covering generic pmbus_identify() fault preservation and the STATUS_CML write-failure fallback path.
drivers/hwmon/pmbus/pmbus.c | 2 +- drivers/hwmon/pmbus/pmbus.h | 1 + drivers/hwmon/pmbus/pmbus_core.c | 44 +++++++++++++++++++++++++++----- 3 files changed, 39 insertions(+), 8 deletions(-)
drivers/hwmon/pmbus/pmbus.c +1 -1
@@ -113,7 +113,7 @@ static int pmbus_identify(struct i2c_client *client, info->pages =1 ; } -pmbus_clear_faults (client); +pmbus_clear_cml_faults (client); }if (pmbus_check_byte_register (client,0 ,PMBUS_VOUT_MODE )) {
drivers/hwmon/pmbus/pmbus.h +1 -0
@@ -581,6 +581,7 @@ int pmbus_write_byte_data(struct i2c_client *client, int page, u8 reg,int pmbus_update_byte_data (struct i2c_client *client,int page,u8 reg,u8 mask,u8 value);void pmbus_clear_faults (struct i2c_client *client); +void pmbus_clear_cml_faults (struct i2c_client *client);void pmbus_check_and_notify_faults (struct i2c_client *client);bool pmbus_check_byte_register (struct i2c_client *client,int page,int reg);bool pmbus_check_word_register (struct i2c_client *client,int page,int reg);
drivers/hwmon/pmbus/pmbus_core.c +37 -7
93 lines not on this page · raw message
Signature · 1 line
2.56.1.703.gf848ed807c-goog
[email protected]
AI reviewRe: [PATCH v3 2/2] hwmon: (pmbus) Clear only CML command and data faults during probe
Sashiko has reviewed this patch and found no issues.
Quoted 20 lines
During driver initialization, register capability probing, and SMBALERT mask setup,
pmbus_coreand the generic pmbus driver sendCLEAR_FAULTS(0x03) to clear any communication or command faults triggered while probing unsupported commands or out-of-range page/register operands. However,CLEAR_FAULTSunconditionally clears all latched fault status bits across the device, including hardware power fault registers such asSTATUS_WORD,STATUS_VOUT,STATUS_IOUT, andSTATUS_MFR_SPECIFIC. As a result, a BMC reboot or driver re-probe erases pre-existing voltage regulator fault telemetry before monitoring or diagnostic tools can inspect it.Simply omitting fault clearing during probe is not viable because probing unsupported commands asserts
PB_CML_FAULT_INVALID_COMMANDinSTATUS_CML(causingpmbus_check_status_cml()to fail subsequent checks with-EIO), and probing out-of-rangePMBUS_PAGEorPMBUS_SMBALERT_MASK[ ... ]
clean probing with no-EIOregressions, preservation of non-CML status faults across re-binds, and fallback when writingPMBUS_STATUS_CMLis NACKed.
Quoted 1 line
Signed-off-by Arthur Korn <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Re: [PATCH v3 2/2] hwmon: (pmbus) Clear only CML command and data faults during probe
In reply to Arthur KornQuoted 41 lines · Arthur Korn
During driver initialization, register capability probing, and SMBALERT mask setup,
pmbus_coreand the generic pmbus driver sendCLEAR_FAULTS(0x03) to clear any communication or command faults triggered while probing unsupported commands or out-of-range page/register operands. However,CLEAR_FAULTSunconditionally clears all latched fault status bits across the device, including hardware power fault registers such asSTATUS_WORD,STATUS_VOUT,STATUS_IOUT, andSTATUS_MFR_SPECIFIC. As a result, a BMC reboot or driver re-probe erases pre-existing voltage regulator fault telemetry before monitoring or diagnostic tools can inspect it.Simply omitting fault clearing during probe is not viable because probing unsupported commands asserts
PB_CML_FAULT_INVALID_COMMANDinSTATUS_CML(causingpmbus_check_status_cml()to fail subsequent checks with-EIO), and probing out-of-rangePMBUS_PAGEorPMBUS_SMBALERT_MASKoperands assertsPB_CML_FAULT_INVALID_DATAandPB_STATUS_CML.Starting with PMBus Revision 1.2, individual bits in
STATUS_CMLcan be cleared via Write-1-to-Clear (W1C), a mechanismpmbus_corealready uses inpmbus_get_boolean(). Introducepmbus_clear_cml_fault()and exportpmbus_clear_cml_faults()in the "PMBUS" module namespace to clearPB_CML_FAULT_INVALID_COMMAND|PB_CML_FAULT_INVALID_DATAinPMBUS_STATUS_CMLduring device initialization, register probing,pmbus_write_smbalert_mask(), andpmbus_identify()while preserving all other latched fault bits:- Verify during
pmbus_init_common()thatPMBUS_REVISIONis valid (>= 1.2 and not0xff), that the driver does not hookwrite_byte()withoutwrite_byte_data(), and thatPMBUS_STATUS_CMLis readable before enablingSTATUS_CMLW1C clearing.
- Fall back topmbus_clear_fault_page()whenSTATUS_CMLW1C is unavailable or if writingPMBUS_STATUS_CMLfails.Tested on BMC hardware across 130 hwmon devices (105 PMBus devices covering tda38740/xdpe1a2g5b, isl68137/raa228234, adm1266, ltc4286/ltc4287, and generic pmbus regulators including TI tps546e25/tps546b25 and factory write-protected converters), verifying clean probing with no
-EIOregressions, preservation of non-CML status faults across re-binds, and fallback when writingPMBUS_STATUS_CMLis NACKed.
Quoted 1 line
Signed-off-by Arthur Korn <[email protected]>
Applied.
Thanks,
Guenter
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 14 lines
MAX16601 exposes the secondary VSA rail on virtual PMBus page 2 backed by a separate I2C client (
data->vsa), while page 1 is a read-only virtual page for VCORE input current and power telemetry. Although the driver routes byte reads on page 2 todata->vsaviamax16601_read_byte()andPMBUS_CLEAR_FAULTSbyte writes viamax16601_write_byte(), it does not implementwrite_byte_data(), andmax16601_write_byte()falls through to-ENODATAon virtual page 1.As a result, PMBus 1.2+ byte-data status writes from
pmbus_core(such as clearing individual status bits inpmbus_get_boolean()or clearingSTATUS_CMLfaults during probe) on page 2 are sent to the primary VCORE client instead ofdata->vsa, and byte writes on virtual page 1 fall through to page 0.
Quoted 7 lines
Implement
max16601_write_byte_data()mirroringmax16601_read_byte()to forward page 2 byte-data writes todata->vsaand reject virtual page 1 with-EOPNOTSUPP, and reject virtual page 1 inmax16601_write_byte()as well.Fixes 2138f8853a00 ("hwmon: (pmbus) Driver for Maxim MAX16601")Signed-off-by Arthur Korn <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 14 lines · Arthur Korn
MAX16601 exposes the secondary VSA rail on virtual PMBus page 2 backed by a separate I2C client (
data->vsa), while page 1 is a read-only virtual page for VCORE input current and power telemetry. Although the driver routes byte reads on page 2 todata->vsaviamax16601_read_byte()andPMBUS_CLEAR_FAULTSbyte writes viamax16601_write_byte(), it does not implementwrite_byte_data(), andmax16601_write_byte()falls through to-ENODATAon virtual page 1.As a result, PMBus 1.2+ byte-data status writes from
pmbus_core(such as clearing individual status bits inpmbus_get_boolean()or clearingSTATUS_CMLfaults during probe) on page 2 are sent to the primary VCORE client instead ofdata->vsa, and byte writes on virtual page 1 fall through to page 0.
Quoted 7 lines
Implement
max16601_write_byte_data()mirroringmax16601_read_byte()to forward page 2 byte-data writes todata->vsaand reject virtual page 1 with-EOPNOTSUPP, and reject virtual page 1 inmax16601_write_byte()as well.Fixes 2138f8853a00 ("hwmon: (pmbus) Driver for Maxim MAX16601")Signed-off-by Arthur Korn <[email protected]>
Applied.
Thanks,
Guenter