From e5c10971fa4c5e958c8d5a920545ec9ab30c7981 Mon Sep 17 00:00:00 2001 From: zyk <“zyk@rock-chips.com”> Date: Fri, 21 Nov 2014 11:52:34 +0800 Subject: [PATCH] rk312x adc battery: save capacity increment from uboot --- drivers/power/rk30_factory_adc_battery.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/power/rk30_factory_adc_battery.c b/drivers/power/rk30_factory_adc_battery.c index 9f31c0d704e4..f435bd0fc3d7 100755 --- a/drivers/power/rk30_factory_adc_battery.c +++ b/drivers/power/rk30_factory_adc_battery.c @@ -104,6 +104,7 @@ int gDoubleVoltageCnt = 6800; unsigned long gSecondsCnt = 0; char gDischargeFlag[4] = {"on "}; static int g_old_cap = -1; +static int g_uboot_incre = 0; #if 1 #define BATT_MAX_VOL_VALUE 4250/*Full charge volatge*/ @@ -343,6 +344,17 @@ static ssize_t rkbatt_restore_flag_attrs(struct device *dev, return size; } +static int __init adc_bootloader_setup(char *str) +{ + + if(str) { + printk("adc.incre is %s\n", str); + sscanf(str, "%d", &g_uboot_incre); + } + return 0; +} +early_param("adc.incre", adc_bootloader_setup); + static ssize_t rkbatt_show_oldcap_attrs(struct device *dev, struct device_attribute *attr, char *buf) { return sprintf(buf, "%d\n", g_old_cap); @@ -1377,13 +1389,16 @@ static void rk30_adc_battery_poweron_capacity_check(struct rk30_adc_battery_data new_capacity = bat ->bat_capacity; while( cnt -- ){ + g_old_cap = g_old_cap + g_uboot_incre; + if(g_old_cap > 100) + g_old_cap = 100; old_capacity = g_old_cap; // rk30_adc_battery_load_capacity(); if( old_capacity != -1 ){ break ; } msleep(100); } - printk("func:%s; line:%d; old_capacity = %d; new_capacity = %d\n", __func__, __LINE__, old_capacity, new_capacity); + printk("func:%s; line:%d; old_capacity = %d; new_capacity = %d; g_uboot_incre = %d\n", __func__, __LINE__, old_capacity, new_capacity,g_uboot_incre); if ((old_capacity < 0) || (old_capacity > 100)){ old_capacity = new_capacity; -- 2.34.1