battery: sec_battery: export {CURRENT/VOLTAGE}_MAX to sysfs lineage-18.1
authorJesse Chan <jc@lineageos.org>
Sat, 21 Apr 2018 07:08:51 +0000 (00:08 -0700)
committerDanny Wood <danwood76@gmail.com>
Tue, 28 Sep 2021 12:15:44 +0000 (13:15 +0100)
Change-Id: I54c775bb80c2151bdc69ea9fb53a48a34327bbef

drivers/battery/sec_battery.c
drivers/battery/sec_battery_s5neo.c

index eba4a7c0db20e3d83420e47e6bef2548133f9f52..032e7b96e422d79b254361e9c5aba7f5d079f668 100644 (file)
@@ -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;
index 19901b7c0a82aaf8d2c1648ccd75a363b7aba404..8b24442723c479811f595ce557da77809292b5a7 100644 (file)
@@ -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;