]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
power: max17048: report scaled SoC by manipulating kernel threshold
authorVenkat Reddy Talla <vreddytalla@nvidia.com>
Wed, 29 Jan 2014 11:40:55 +0000 (17:10 +0530)
committerLaxman Dewangan <ldewangan@nvidia.com>
Thu, 6 Feb 2014 12:54:18 +0000 (04:54 -0800)
Make kernel threshold SoC as 0% and scale the SoC read from device
as:
Read from device: 0 to threshold -> report 0%
Read from device: threshold+1 to 100% -> report as 1 to 100%.

Change-Id: I08db7ebc08f3f9bb7e69d7397ce5b5d7a98f516a
Signed-off-by: Venkat Reddy Talla <vreddytalla@nvidia.com>
Reviewed-on: http://git-master/r/361480
(cherry picked from commit 826bbd7843f06a960f8f7832fd29f6357164646d)
Reviewed-on: http://git-master/r/364229
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
drivers/power/max17048_battery.c
include/linux/max17048_battery.h

index 053f4c1054757c6276ece825449b09c7164e6c3f..7c003b150f3d192a1367f42ec0cd84908269db47 100644 (file)
@@ -251,6 +251,9 @@ static void max17048_get_soc(struct i2c_client *client)
                        chip->soc = (uint16_t)soc >> 9;
        }
 
+       chip->soc = battery_gauge_get_scaled_soc(chip->bg_dev,
+                       chip->soc * 100, chip->pdata->threshold_soc);
+
        if (chip->soc >= MAX17048_BATTERY_FULL && chip->charge_complete != 1)
                chip->soc = MAX17048_BATTERY_FULL-1;
 
@@ -594,6 +597,10 @@ static struct max17048_platform_data *max17048_parse_dt(struct device *dev)
        pdata->model_data = model_data;
        of_property_read_string(np, "tz-name", &pdata->tz_name);
 
+       ret = of_property_read_u32(np, "maxim,kernel-threshold-soc", &val);
+       if (!ret)
+               pdata->threshold_soc = val;
+
        ret = of_property_read_u32(np, "bits", &val);
        if (ret < 0)
                return ERR_PTR(ret);
index bfbacc1cd8abb9c38bc1f26c7511b5ea8238ae3d..1dfed8005cda105d92c072f9e3061668f5fb9b19 100644 (file)
@@ -33,6 +33,7 @@ struct max17048_battery_model {
 struct max17048_platform_data {
        struct max17048_battery_model *model_data;
        const char *tz_name;
+       int threshold_soc;
 };
 #ifdef CONFIG_BATTERY_MAX17048
 extern void max17048_battery_status(int status);