diff options
author | Jae Hyun Yoo <jae.hyun.yoo@intel.com> | 2019-08-08 20:38:00 +0300 |
---|---|---|
committer | Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com> | 2021-11-05 10:22:08 +0300 |
commit | f2d3c244755c4cefc8ceebc0cfc5aca4d6c7597e (patch) | |
tree | 05f04d46a8c2e2c577dd384ae146d000ca16e990 | |
parent | e5a672c1c0e433d986acbb21af8ebb7a92e51554 (diff) | |
download | linux-f2d3c244755c4cefc8ceebc0cfc5aca4d6c7597e.tar.xz |
pmbus: add 'fault' and 'beep' attributes
This commit adds two more attirbutes to reflect MFR_SPECIFIC bit in
the STATUS_WORD and 'Unit Off For Insufficient Input Voltage' bit in
the STATUS_INPUT into 'fault' and 'beep' attributes respectively.
The attributes will be enumerated as 'inX_fault' and 'inX_beep' in
a 'vin' group.
Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@intel.com>
-rw-r--r-- | drivers/hwmon/pmbus/pmbus.h | 1 | ||||
-rw-r--r-- | drivers/hwmon/pmbus/pmbus_core.c | 30 |
2 files changed, 31 insertions, 0 deletions
diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h index e0aa8aa46d8c..e655cbf6299b 100644 --- a/drivers/hwmon/pmbus/pmbus.h +++ b/drivers/hwmon/pmbus/pmbus.h @@ -330,6 +330,7 @@ enum pmbus_fan_mode { percent = 0, rpm }; #define PB_PIN_OP_WARNING BIT(0) #define PB_IIN_OC_WARNING BIT(1) #define PB_IIN_OC_FAULT BIT(2) +#define PB_UNIT_OFF_FOR_INSUF_VIN BIT(3) /* * STATUS_TEMPERATURE diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index f9896872390d..a4bf6f0fe013 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -1193,6 +1193,8 @@ struct pmbus_limit_attr { struct pmbus_sensor_attr { u16 reg; /* sensor register */ u16 gbit; /* generic status bit */ + u16 gfbit; /* generic fault status bit */ + u16 sbbit; /* beep status bit */ u8 nlimit; /* # of limit registers */ enum pmbus_sensor_classes class;/* sensor class */ const char *label; /* sensor label */ @@ -1295,6 +1297,32 @@ static int pmbus_add_sensor_attrs_one(struct i2c_client *client, return ret; } } + /* + * Add fault attribute if there is a generic fault bit, and if + * the generic status register (word or byte, depending on which global + * bit is set) for this page is accessible. + */ + if (attr->gfbit) { + upper = !!(attr->gfbit & 0xff00); /* need to check STATUS_WORD */ + if ((!upper || (upper && data->has_status_word)) && + pmbus_check_status_register(client, page)) { + ret = pmbus_add_boolean(data, name, "fault", index, + NULL, NULL, + page, PMBUS_STATUS_WORD, + attr->gfbit); + if (ret) + return ret; + } + } + /* Add beep attribute if there is a beep status bit. */ + if (attr->sbbit) { + ret = pmbus_add_boolean(data, name, "beep", index, + NULL, NULL, + page, attr->sreg, + attr->sbbit); + if (ret) + return ret; + } return 0; } @@ -1493,6 +1521,8 @@ static const struct pmbus_sensor_attr voltage_attributes[] = { .gbit = PB_STATUS_VIN_UV, .limit = vin_limit_attrs, .nlimit = ARRAY_SIZE(vin_limit_attrs), + .gfbit = PB_STATUS_WORD_MFR, + .sbbit = PB_UNIT_OFF_FOR_INSUF_VIN, }, { .reg = PMBUS_VIRT_READ_VMON, .class = PSC_VOLTAGE_IN, |