hwmon: (pmbus/core): Update regulator flag map
PATCH 1/3 hwmon: (pmbus/core): Update regulator flag map
Add regulator flag map for PMBUS status byte & status input.
--- drivers/hwmon/pmbus/pmbus_core.c | 52 +++++++++++++++++--------------- 1 file changed, 28 insertions(+), 24 deletions(-)
drivers/hwmon/pmbus/pmbus_core.c +28 -24
@@ -2756,26 +2756,47 @@ static const struct pmbus_regulator_status_category pmbus_regulator_flag_map[] = .reg = PMBUS_STATUS_VOUT, .bits = (const struct pmbus_regulator_status_assoc []) { {PB_VOLTAGE_UV_WARNING ,REGULATOR_ERROR_UNDER_VOLTAGE_WARN }, - {PB_VOLTAGE_UV_FAULT ,REGULATOR_ERROR_UNDER_VOLTAGE }, + {PB_VOLTAGE_UV_FAULT ,REGULATOR_ERROR_UNDER_VOLTAGE }, {PB_VOLTAGE_OV_WARNING ,REGULATOR_ERROR_OVER_VOLTAGE_WARN }, - {PB_VOLTAGE_OV_FAULT ,REGULATOR_ERROR_REGULATION_OUT }, + {PB_VOLTAGE_OV_FAULT ,REGULATOR_ERROR_REGULATION_OUT }, { }, }, }, { .func = PMBUS_HAVE_STATUS_IOUT, .reg = PMBUS_STATUS_IOUT, .bits = (const struct pmbus_regulator_status_assoc []) { - {PB_IOUT_OC_WARNING ,REGULATOR_ERROR_OVER_CURRENT_WARN }, - {PB_IOUT_OC_FAULT ,REGULATOR_ERROR_OVER_CURRENT }, - {PB_IOUT_OC_LV_FAULT ,REGULATOR_ERROR_OVER_CURRENT }, + {PB_IOUT_OC_WARNING ,REGULATOR_ERROR_OVER_CURRENT_WARN }, + {PB_IOUT_OC_FAULT ,REGULATOR_ERROR_OVER_CURRENT }, + {PB_IOUT_OC_LV_FAULT ,REGULATOR_ERROR_OVER_CURRENT }, + {PB_POUT_OP_FAULT ,REGULATOR_ERROR_OVER_CURRENT }, { }, }, }, { .func = PMBUS_HAVE_STATUS_TEMP, .reg = PMBUS_STATUS_TEMPERATURE, .bits = (const struct pmbus_regulator_status_assoc []) { - {PB_TEMP_OT_WARNING ,REGULATOR_ERROR_OVER_TEMP_WARN }, - {PB_TEMP_OT_FAULT ,REGULATOR_ERROR_OVER_TEMP }, + {PB_TEMP_OT_WARNING ,REGULATOR_ERROR_OVER_TEMP_WARN }, + {PB_TEMP_OT_FAULT ,REGULATOR_ERROR_OVER_TEMP }, + { }, + }, + }, { + .func = -1, + .reg = PMBUS_STATUS_BYTE, + .bits = (const struct pmbus_regulator_status_assoc []) { + {PB_STATUS_IOUT_OC ,REGULATOR_ERROR_OVER_CURRENT }, + {PB_STATUS_VOUT_OV ,REGULATOR_ERROR_REGULATION_OUT }, + {PB_STATUS_VIN_UV ,REGULATOR_ERROR_UNDER_VOLTAGE }, + {PB_STATUS_NONE_ABOVE ,REGULATOR_ERROR_FAIL }, + { }, + }, + }, { + .func = PMBUS_HAVE_STATUS_INPUT, + .reg = PMBUS_STATUS_INPUT, + .bits = (const struct pmbus_regulator_status_assoc []) { + {PB_IIN_OC_FAULT ,REGULATOR_ERROR_OVER_CURRENT }, + {PB_VOLTAGE_OV_FAULT ,REGULATOR_ERROR_OVER_VOLTAGE_WARN }, + {PB_VOLTAGE_OV_WARNING ,REGULATOR_ERROR_OVER_VOLTAGE_WARN }, + {PB_VOLTAGE_UV_FAULT ,REGULATOR_ERROR_UNDER_VOLTAGE }, { }, }, },
@@ -2834,23 +2855,6 @@ static int pmbus_regulator_get_error_flags(struct regulator_dev *rdev, unsignedif (status &PB_STATUS_POWER_GOOD_N ) *flags |=REGULATOR_ERROR_REGULATION_OUT ; } -/* -* Unlike most other status bits, PB_STATUS_{IOUT_OC,VOUT_OV} are -* defined strictly as fault indicators (not warnings). -*/ -if (status &PB_STATUS_IOUT_OC ) - *flags |=REGULATOR_ERROR_OVER_CURRENT ; -if (status &PB_STATUS_VOUT_OV ) - *flags |=REGULATOR_ERROR_REGULATION_OUT ; - -/* -* If we haven't discovered any thermal faults or warnings via -* PMBUS_STATUS_TEMPERATURE, map PB_STATUS_TEMPERATURE to a warning as -* a (conservative) best-effort interpretation. -*/ -if (!(*flags & (REGULATOR_ERROR_OVER_TEMP |REGULATOR_ERROR_OVER_TEMP_WARN )) && - (status &PB_STATUS_TEMPERATURE )) - *flags |=REGULATOR_ERROR_OVER_TEMP_WARN ;return 0 ; }
base-commit: 2c71b3246ec3246522e8cb7c8191dc7a5d62cc70
Signature · 1 line
2.37.3
PATCH 2/3 hwmon: (pmbus/core): Add events to regulator flag map
From: Patrick Rudolph <[email protected]>
Add regulator events corresponding to regulator error in regulator flag map.
--- drivers/hwmon/pmbus/pmbus_core.c | 68 ++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 20 deletions(-)
drivers/hwmon/pmbus/pmbus_core.c +48 -20
@@ -2738,9 +2738,9 @@ static int pmbus_regulator_disable(struct regulator_dev *rdev)return _pmbus_regulator_on_off (rdev,0 ); } -/* A PMBus status flag and the corresponding REGULATOR_ERROR_* flag */ +/* A PMBus status flag and the corresponding REGULATOR_ERROR_* and REGULATOR_EVENTS_* flag */ struct pmbus_regulator_status_assoc { -int pflag, rflag; +int pflag, rflag, eflag; };/* PMBus->regulator bit mappings for a PMBus status register */
@@ -2755,48 +2755,76 @@ static const struct pmbus_regulator_status_category pmbus_regulator_flag_map[] = .func = PMBUS_HAVE_STATUS_VOUT, .reg = PMBUS_STATUS_VOUT, .bits = (const struct pmbus_regulator_status_assoc []) { - {PB_VOLTAGE_UV_WARNING ,REGULATOR_ERROR_UNDER_VOLTAGE_WARN }, - {PB_VOLTAGE_UV_FAULT ,REGULATOR_ERROR_UNDER_VOLTAGE }, - {PB_VOLTAGE_OV_WARNING ,REGULATOR_ERROR_OVER_VOLTAGE_WARN }, - {PB_VOLTAGE_OV_FAULT ,REGULATOR_ERROR_REGULATION_OUT }, + {PB_VOLTAGE_UV_WARNING ,REGULATOR_ERROR_UNDER_VOLTAGE_WARN , +REGULATOR_EVENT_UNDER_VOLTAGE_WARN }, + {PB_VOLTAGE_UV_FAULT ,REGULATOR_ERROR_UNDER_VOLTAGE , +REGULATOR_EVENT_UNDER_VOLTAGE }, + {PB_VOLTAGE_OV_WARNING ,REGULATOR_ERROR_OVER_VOLTAGE_WARN , +REGULATOR_EVENT_OVER_VOLTAGE_WARN }, + {PB_VOLTAGE_OV_FAULT ,REGULATOR_ERROR_REGULATION_OUT , +REGULATOR_EVENT_OVER_VOLTAGE_WARN }, { }, }, }, { .func = PMBUS_HAVE_STATUS_IOUT, .reg = PMBUS_STATUS_IOUT, .bits = (const struct pmbus_regulator_status_assoc []) { - {PB_IOUT_OC_WARNING ,REGULATOR_ERROR_OVER_CURRENT_WARN }, - {PB_IOUT_OC_FAULT ,REGULATOR_ERROR_OVER_CURRENT }, - {PB_IOUT_OC_LV_FAULT ,REGULATOR_ERROR_OVER_CURRENT }, - {PB_POUT_OP_FAULT ,REGULATOR_ERROR_OVER_CURRENT }, + {PB_IOUT_OC_WARNING ,REGULATOR_ERROR_OVER_CURRENT_WARN , +REGULATOR_EVENT_OVER_CURRENT_WARN }, + {PB_IOUT_OC_FAULT ,REGULATOR_ERROR_OVER_CURRENT , +REGULATOR_EVENT_OVER_CURRENT }, + {PB_IOUT_OC_LV_FAULT ,REGULATOR_ERROR_OVER_CURRENT , +REGULATOR_EVENT_OVER_CURRENT }, + {PB_POUT_OP_FAULT ,REGULATOR_ERROR_OVER_CURRENT , +REGULATOR_EVENT_OVER_CURRENT }, { }, }, }, { .func = PMBUS_HAVE_STATUS_TEMP, .reg = PMBUS_STATUS_TEMPERATURE, .bits = (const struct pmbus_regulator_status_assoc []) { - {PB_TEMP_OT_WARNING ,REGULATOR_ERROR_OVER_TEMP_WARN }, - {PB_TEMP_OT_FAULT ,REGULATOR_ERROR_OVER_TEMP }, + {PB_TEMP_OT_WARNING ,REGULATOR_ERROR_OVER_TEMP_WARN , +REGULATOR_EVENT_OVER_TEMP_WARN }, + {PB_TEMP_OT_FAULT ,REGULATOR_ERROR_OVER_TEMP , +REGULATOR_EVENT_OVER_TEMP }, { }, }, }, { .func = -1, .reg = PMBUS_STATUS_BYTE, .bits = (const struct pmbus_regulator_status_assoc []) { - {PB_STATUS_IOUT_OC ,REGULATOR_ERROR_OVER_CURRENT }, - {PB_STATUS_VOUT_OV ,REGULATOR_ERROR_REGULATION_OUT }, - {PB_STATUS_VIN_UV ,REGULATOR_ERROR_UNDER_VOLTAGE }, - {PB_STATUS_NONE_ABOVE ,REGULATOR_ERROR_FAIL }, + {PB_STATUS_IOUT_OC ,REGULATOR_ERROR_OVER_CURRENT , +REGULATOR_EVENT_OVER_CURRENT }, + {PB_STATUS_VOUT_OV ,REGULATOR_ERROR_OVER_VOLTAGE_WARN , +REGULATOR_EVENT_OVER_VOLTAGE_WARN }, + {PB_STATUS_VIN_UV ,REGULATOR_ERROR_UNDER_VOLTAGE , +REGULATOR_EVENT_UNDER_VOLTAGE }, + {PB_STATUS_OFF ,0 , +REGULATOR_EVENT_DISABLE }, + {PB_STATUS_NONE_ABOVE ,REGULATOR_ERROR_FAIL , +REGULATOR_EVENT_FAIL }, + { }, + }, + }, { + .func = -1, + .reg = PMBUS_STATUS_WORD, + .bits = (const struct pmbus_regulator_status_assoc []) { + {PB_STATUS_POWER_GOOD_N ,0 , +REGULATOR_EVENT_REGULATION_OUT }, { }, }, }, { .func = PMBUS_HAVE_STATUS_INPUT, .reg = PMBUS_STATUS_INPUT, .bits = (const struct pmbus_regulator_status_assoc []) { - {PB_IIN_OC_FAULT ,REGULATOR_ERROR_OVER_CURRENT }, - {PB_VOLTAGE_OV_FAULT ,REGULATOR_ERROR_OVER_VOLTAGE_WARN }, - {PB_VOLTAGE_OV_WARNING ,REGULATOR_ERROR_OVER_VOLTAGE_WARN }, - {PB_VOLTAGE_UV_FAULT ,REGULATOR_ERROR_UNDER_VOLTAGE }, + {PB_IIN_OC_FAULT ,REGULATOR_ERROR_OVER_CURRENT , +REGULATOR_EVENT_OVER_CURRENT }, + {PB_VOLTAGE_OV_FAULT ,REGULATOR_ERROR_OVER_VOLTAGE_WARN , +REGULATOR_EVENT_OVER_VOLTAGE_WARN }, + {PB_VOLTAGE_OV_WARNING ,REGULATOR_ERROR_OVER_VOLTAGE_WARN , +REGULATOR_EVENT_OVER_VOLTAGE_WARN }, + {PB_VOLTAGE_UV_FAULT ,REGULATOR_ERROR_UNDER_VOLTAGE , +REGULATOR_EVENT_UNDER_VOLTAGE }, { }, }, },
Signature · 1 line
2.37.3
PATCH 3/3 hwmon: (pmbus/core): Implement IRQ support
In reply to Naresh SolankiFrom: Patrick Rudolph <[email protected]>
Implement IRQ support to monitor PMBUS regulator events.
--- drivers/hwmon/pmbus/pmbus.h | 2 +- drivers/hwmon/pmbus/pmbus_core.c | 151 ++++++++++++++++++++++++++++--- 2 files changed, 140 insertions(+), 13 deletions(-)
drivers/hwmon/pmbus/pmbus.h +1 -1
@@ -26,7 +26,7 @@ enum pmbus_regs {PMBUS_CAPABILITY =0x19 ,PMBUS_QUERY =0x1A , - +PMBUS_SMBALERT_MASK =0x1B ,PMBUS_VOUT_MODE =0x20 ,PMBUS_VOUT_COMMAND =0x21 , PMBUS_VOUT_TRIM = 0x22,
drivers/hwmon/pmbus/pmbus_core.c +139 -12
177 lines not on this page · raw message
Signature · 1 line
2.37.3
Guenter Roeck
maintainerRe: [PATCH 3/3] hwmon: (pmbus/core): Implement IRQ support
Quoted 6 lines · Naresh Solanki
From: Patrick Rudolph <[email protected]>
Implement IRQ support to monitor PMBUS regulator events.
Signed-off-by Patrick Rudolph <[email protected]>Signed-off-by Naresh Solanki <[email protected]>
Adding a PMBus interrupt handler should be generic and also handle hwmon specific events. It should report any status changes as sysfs attribute notifications.
Guenter
Re: [PATCH 3/3] hwmon: (pmbus/core): Implement IRQ support
Hi Guenter,
Quoted 11 lines · Guenter Roeck
Quoted 6 lines · Naresh Solanki
From: Patrick Rudolph <[email protected]>
Implement IRQ support to monitor PMBUS regulator events.
Signed-off-by Patrick Rudolph <[email protected]>Signed-off-by Naresh Solanki <[email protected]>Adding a PMBus interrupt handler should be generic and also handle hwmon specific events. It should report any status changes as sysfs attribute notifications.
This handler scope is to address regulator faults.
Quoted 3 lines
Guenter
Regards,
Naresh
Guenter Roeck
maintainerRe: [PATCH 3/3] hwmon: (pmbus/core): Implement IRQ support
Quoted 8 lines · Naresh Solanki
Hi Guenter,
Quoted 5 lines · Guenter Roeck
Quoted 4 lines · Naresh Solanki
From: Patrick Rudolph <[email protected]>
Implement IRQ support to monitor PMBUS regulator events.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Signed-off-by Patrick Rudolph <[email protected]>Signed-off-by Naresh Solanki <[email protected]>Adding a PMBus interrupt handler should be generic and also handle hwmon specific events. It should report any status changes as sysfs attribute notifications.
This handler scope is to address regulator faults.
Maybe that is the use case from your perspective, but this is primarily a hardware monitoring driver and needs to primarily serve its hardware monitoring functionality.
Guenter
Re: [PATCH 3/3] hwmon: (pmbus/core): Implement IRQ support
Hi Guenter
Quoted 15 lines · Guenter Roeck
Quoted 14 lines · Naresh Solanki
Hi Guenter,
Quoted 11 lines · Guenter Roeck
Quoted 6 lines · Naresh Solanki
From: Patrick Rudolph <[email protected]>
Implement IRQ support to monitor PMBUS regulator events.
Signed-off-by Patrick Rudolph <[email protected]>Signed-off-by Naresh Solanki <[email protected]>Adding a PMBus interrupt handler should be generic and also handle hwmon specific events. It should report any status changes as sysfs attribute notifications.
Quoted 6 lines
Quoted 2 lines
This handler scope is to address regulator faults.
Maybe that is the use case from your perspective, but this is primarily a hardware monitoring driver and needs to primarily serve its hardware monitoring functionality.
Yeah. What you said makes more sense. I'll do necessary changes & test & get back. Thanks :)
Quoted 4 lines
Guenter
Regards,
Naresh