From 2a746c1bc1a41eae05988c153f527c8a5dc72d07 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Sat, 21 Apr 2018 00:08:51 -0700 Subject: [PATCH] battery: sec_battery: export {CURRENT/VOLTAGE}_MAX to sysfs Change-Id: I54c775bb80c2151bdc69ea9fb53a48a34327bbef --- drivers/battery/sec_battery.c | 44 +++++++++++++++++++++++++++-- drivers/battery/sec_battery_s5neo.c | 44 +++++++++++++++++++++++++++-- 2 files changed, 82 insertions(+), 6 deletions(-) diff --git a/drivers/battery/sec_battery.c b/drivers/battery/sec_battery.c index eba4a7c0db2..032e7b96e42 100644 --- a/drivers/battery/sec_battery.c +++ b/drivers/battery/sec_battery.c @@ -126,6 +126,8 @@ static enum power_supply_property sec_battery_props[] = { static enum power_supply_property sec_power_props[] = { POWER_SUPPLY_PROP_ONLINE, + POWER_SUPPLY_PROP_VOLTAGE_MAX, + POWER_SUPPLY_PROP_CURRENT_MAX, }; static enum power_supply_property sec_ps_props[] = { @@ -4784,8 +4786,20 @@ static int sec_usb_get_property(struct power_supply *psy, struct sec_battery_info *battery = container_of(psy, struct sec_battery_info, psy_usb); - if (psp != POWER_SUPPLY_PROP_ONLINE) + switch (psp) { + case POWER_SUPPLY_PROP_ONLINE: + break; + case POWER_SUPPLY_PROP_VOLTAGE_MAX: + /* V -> uV */ + val->intval = battery->input_voltage * 1000000; + return 0; + case POWER_SUPPLY_PROP_CURRENT_MAX: + /* mA -> uA */ + val->intval = battery->pdata->charging_current[battery->cable_type].input_current_limit * 1000; + return 0; + default: return -EINVAL; + } if ((battery->health == POWER_SUPPLY_HEALTH_OVERVOLTAGE) || (battery->health == POWER_SUPPLY_HEALTH_UNDERVOLTAGE)) { @@ -4819,8 +4833,20 @@ static int sec_ac_get_property(struct power_supply *psy, struct sec_battery_info *battery = container_of(psy, struct sec_battery_info, psy_ac); - if (psp != POWER_SUPPLY_PROP_ONLINE) + switch (psp) { + case POWER_SUPPLY_PROP_ONLINE: + break; + case POWER_SUPPLY_PROP_VOLTAGE_MAX: + /* V -> uV */ + val->intval = battery->input_voltage * 1000000; + return 0; + case POWER_SUPPLY_PROP_CURRENT_MAX: + /* mA -> uA */ + val->intval = battery->pdata->charging_current[battery->cable_type].input_current_limit * 1000; + return 0; + default: return -EINVAL; + } if ((battery->health == POWER_SUPPLY_HEALTH_OVERVOLTAGE) || (battery->health == POWER_SUPPLY_HEALTH_UNDERVOLTAGE)) { @@ -4867,8 +4893,20 @@ static int sec_wireless_get_property(struct power_supply *psy, struct sec_battery_info *battery = container_of(psy, struct sec_battery_info, psy_wireless); - if (psp != POWER_SUPPLY_PROP_ONLINE) + switch (psp) { + case POWER_SUPPLY_PROP_ONLINE: + break; + case POWER_SUPPLY_PROP_VOLTAGE_MAX: + /* V -> uV */ + val->intval = battery->input_voltage * 1000000; + return 0; + case POWER_SUPPLY_PROP_CURRENT_MAX: + /* mA -> uA */ + val->intval = battery->pdata->charging_current[battery->cable_type].input_current_limit * 1000; + return 0; + default: return -EINVAL; + } if (battery->wc_status) val->intval = 1; diff --git a/drivers/battery/sec_battery_s5neo.c b/drivers/battery/sec_battery_s5neo.c index 19901b7c0a8..8b24442723c 100644 --- a/drivers/battery/sec_battery_s5neo.c +++ b/drivers/battery/sec_battery_s5neo.c @@ -127,6 +127,8 @@ static enum power_supply_property sec_battery_props[] = { static enum power_supply_property sec_power_props[] = { POWER_SUPPLY_PROP_ONLINE, + POWER_SUPPLY_PROP_VOLTAGE_MAX, + POWER_SUPPLY_PROP_CURRENT_MAX, }; static enum power_supply_property sec_ps_props[] = { @@ -4787,8 +4789,20 @@ static int sec_usb_get_property(struct power_supply *psy, struct sec_battery_info *battery = container_of(psy, struct sec_battery_info, psy_usb); - if (psp != POWER_SUPPLY_PROP_ONLINE) + switch (psp) { + case POWER_SUPPLY_PROP_ONLINE: + break; + case POWER_SUPPLY_PROP_VOLTAGE_MAX: + /* V -> uV */ + val->intval = battery->input_voltage * 1000000; + return 0; + case POWER_SUPPLY_PROP_CURRENT_MAX: + /* mA -> uA */ + val->intval = battery->pdata->charging_current[battery->cable_type].input_current_limit * 1000; + return 0; + default: return -EINVAL; + } if ((battery->health == POWER_SUPPLY_HEALTH_OVERVOLTAGE) || (battery->health == POWER_SUPPLY_HEALTH_UNDERVOLTAGE)) { @@ -4822,8 +4836,20 @@ static int sec_ac_get_property(struct power_supply *psy, struct sec_battery_info *battery = container_of(psy, struct sec_battery_info, psy_ac); - if (psp != POWER_SUPPLY_PROP_ONLINE) + switch (psp) { + case POWER_SUPPLY_PROP_ONLINE: + break; + case POWER_SUPPLY_PROP_VOLTAGE_MAX: + /* V -> uV */ + val->intval = battery->input_voltage * 1000000; + return 0; + case POWER_SUPPLY_PROP_CURRENT_MAX: + /* mA -> uA */ + val->intval = battery->pdata->charging_current[battery->cable_type].input_current_limit * 1000; + return 0; + default: return -EINVAL; + } if ((battery->health == POWER_SUPPLY_HEALTH_OVERVOLTAGE) || (battery->health == POWER_SUPPLY_HEALTH_UNDERVOLTAGE)) { @@ -4870,8 +4896,20 @@ static int sec_wireless_get_property(struct power_supply *psy, struct sec_battery_info *battery = container_of(psy, struct sec_battery_info, psy_wireless); - if (psp != POWER_SUPPLY_PROP_ONLINE) + switch (psp) { + case POWER_SUPPLY_PROP_ONLINE: + break; + case POWER_SUPPLY_PROP_VOLTAGE_MAX: + /* V -> uV */ + val->intval = battery->input_voltage * 1000000; + return 0; + case POWER_SUPPLY_PROP_CURRENT_MAX: + /* mA -> uA */ + val->intval = battery->pdata->charging_current[battery->cable_type].input_current_limit * 1000; + return 0; + default: return -EINVAL; + } if (battery->wc_status) val->intval = 1; -- 2.20.1