From: Jesse Chan Date: Sat, 21 Apr 2018 07:08:51 +0000 (-0700) Subject: battery: sec_battery: export {CURRENT/VOLTAGE}_MAX to sysfs X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=refs%2Fheads%2Flineage-18.1;p=GitHub%2FLineageOS%2Fandroid_kernel_samsung_universal7580.git battery: sec_battery: export {CURRENT/VOLTAGE}_MAX to sysfs Change-Id: I54c775bb80c2151bdc69ea9fb53a48a34327bbef --- 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;