diff options
author | Xin Xie <xxie@nvidia.com> | 2013-04-23 17:28:54 -0700 |
---|---|---|
committer | Riham Haidar <rhaidar@nvidia.com> | 2013-05-31 15:27:51 -0700 |
commit | 1ebfeb6091b59cacf93f61f79220c81424747636 (patch) | |
tree | 9a8a263c28c66bca1fa9807041f932bd31767f9d /drivers | |
parent | 43e96b352cdfb1438edc326da0ac4ae05e14c03e (diff) |
power: max77665: add charging state status display
bug 1281009
Change-Id: I1305b43dd17db544e432c3a4085ebf0bb937bc88
Signed-off-by: Xin Xie <xxie@nvidia.com>
Reviewed-on: http://git-master/r/224098
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/power/max77665-charger.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/drivers/power/max77665-charger.c b/drivers/power/max77665-charger.c index 132ca9256bda..45bd02ae971a 100644 --- a/drivers/power/max77665-charger.c +++ b/drivers/power/max77665-charger.c @@ -786,13 +786,45 @@ static ssize_t max77665_show_battery_oc_count(struct device *dev, struct max77665_charger *charger = dev_get_drvdata(dev); return sprintf(buf, "%u\n", charger->oc_count); } - static DEVICE_ATTR(oc_count, 0444, max77665_show_battery_oc_count, NULL); +static ssize_t max77665_show_battery_charging_state(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct max77665_charger *charger = dev_get_drvdata(dev); + char *state_string[] = { + "PREQUALIFICATION MODE", /* 0X0 */ + "FAST CONSTANT CURRENT MODE", /* 0X1 */ + "FAST CONSTANT VOLTAGE MODE", /* 0X2 */ + "TOP OFF MODE", /* 0X3 */ + "DONE MODE", /* 0X4 */ + "HIGH TEMP CHG MODE", /* 0X5 */ + "TIME FAULT MODE", /* 0X6 */ + "THERMISTOR SUSPEND FAULT MODE", /* 0X7 */ + "CHG OFF INPUT INVALID", /* 0X8 */ + "RSVD", /* 0X9 */ + "CHG OFF JUNCT TEMP", /* 0XA */ + "CHG OFF WDT EXPIRE", /* 0XB */ + }; + int val; + + if (0 > max77665_read_reg(charger, MAX77665_CHG_DTLS_01, &val)) + return -EINVAL; + + val = CHG_DTLS_MASK(val); + if (val >= ARRAY_SIZE(state_string)) + return -EINVAL; + + return sprintf(buf, "%s(%d)\n", state_string[val], val); +} +static DEVICE_ATTR(charging_state, 0444, + max77665_show_battery_charging_state, NULL); + static struct attribute *max77665_chg_attributes[] = { &dev_attr_oc_threshold.attr, &dev_attr_oc_state.attr, &dev_attr_oc_count.attr, + &dev_attr_charging_state.attr, NULL, }; |