battery: sec_battery: export {CURRENT/VOLTAGE}_MAX to sysfs
authorJesse Chan <jc@lineageos.org>
Sat, 21 Apr 2018 07:08:51 +0000 (00:08 -0700)
committerMichael Benedict <michaelbt@live.com>
Sun, 25 Aug 2019 07:48:32 +0000 (17:48 +1000)
Change-Id: I54c775bb80c2151bdc69ea9fb53a48a34327bbef

drivers/battery_v2/sec_battery.c

index 6b089004da82de986ce8b86781472942f9538be1..a67256024b425deaff772892d78af322e52c8315 100755 (executable)
@@ -205,16 +205,22 @@ 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_wireless_props[] = {
        POWER_SUPPLY_PROP_ONLINE,
        POWER_SUPPLY_PROP_PRESENT,
+       POWER_SUPPLY_PROP_VOLTAGE_MAX,
+       POWER_SUPPLY_PROP_CURRENT_MAX,
 };
 
 static enum power_supply_property sec_ac_props[] = {
        POWER_SUPPLY_PROP_ONLINE,
        POWER_SUPPLY_PROP_TEMP,
+       POWER_SUPPLY_PROP_VOLTAGE_MAX,
+       POWER_SUPPLY_PROP_CURRENT_MAX,
 };
 
 static enum power_supply_property sec_ps_props[] = {
@@ -6688,8 +6694,20 @@ static int sec_usb_get_property(struct power_supply *psy,
 {
        struct sec_battery_info *battery = power_supply_get_drvdata(psy);
 
-       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)) {
@@ -6762,6 +6780,14 @@ static int sec_ac_get_property(struct power_supply *psy,
        case POWER_SUPPLY_PROP_TEMP:
                val->intval = battery->chg_temp;
                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;
        case POWER_SUPPLY_PROP_MAX ... POWER_SUPPLY_EXT_PROP_MAX:
                switch (ext_psp) {
                        case POWER_SUPPLY_EXT_PROP_WATER_DETECT:
@@ -6803,6 +6829,14 @@ static int sec_wireless_get_property(struct power_supply *psy,
                val->intval = (battery->pdata->wireless_charger_name) ?
                        1 : 0;
                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;
        }