power: rk81x battery: fix charger online init
authorAndy Yan <yxj@rock-chips.com>
Mon, 8 Jun 2015 01:38:49 +0000 (09:38 +0800)
committer许盛飞 <xsf@rock-chips.com>
Wed, 17 Jun 2015 06:57:50 +0000 (14:57 +0800)
if the system boot with charger online, use it
as init state for power_supply_register

Signed-off-by: Andy Yan <yxj@rock-chips.com>
Signed-off-by: Jianhong Chen <chenjh@rock-chips.com>
drivers/power/rk818_battery.c

index d78ee5df75574f745121ba258920509dcfdfcc60..81742a7975b3c8f302844ace4bb80f4d7bdf708d 100644 (file)
@@ -3897,8 +3897,13 @@ static void rk81x_bat_irq_init(struct rk81x_battery *di)
 static void rk81x_bat_info_init(struct rk81x_battery *di,
                                struct rk818 *chip)
 {
+       u8 val;
        unsigned long time_base = get_runtime_sec();
 
+       rk81x_bat_read(di, RK818_VB_MON_REG, &val, 1);
+       if (val & PLUG_IN_STS)
+               rk81x_bat_set_power_supply_state(di, USB_CHARGER);
+
        di->cell.config = di->pdata->cell_cfg;
        di->design_capacity = di->pdata->cell_cfg->design_capacity;
        di->qmax = di->pdata->cell_cfg->design_qmax;
@@ -4295,6 +4300,7 @@ static int rk81x_battery_resume(struct platform_device *dev)
        if ((!rk81x_chrg_online(di) && di->voltage <= pwroff_thresd) ||
            rk81x_chrg_online(di))
                wake_lock_timeout(&di->resume_wake_lock, 5 * HZ);
+
        /*
         * do not modify the g_base_sec
         */