From 08fced76b59bba31872e36f4209558fa4e06b20c Mon Sep 17 00:00:00 2001 From: "yangjie@rock-chips.com" Date: Fri, 21 Mar 2014 15:21:29 +0800 Subject: [PATCH] charge display: support --- drivers/power/rk29_charger_display.c | 57 ++++------------------------ 1 file changed, 8 insertions(+), 49 deletions(-) diff --git a/drivers/power/rk29_charger_display.c b/drivers/power/rk29_charger_display.c index f384a9745dea..af377b17e97c 100755 --- a/drivers/power/rk29_charger_display.c +++ b/drivers/power/rk29_charger_display.c @@ -4,17 +4,15 @@ #include #include #include +#include #include #include #include #include #include -#include -#include -#include #include #include - +#include #if 0 #define DBG(x...) printk(KERN_INFO x) @@ -22,16 +20,8 @@ #define DBG(x...) #endif -//#define RK29_PLAY_ON_PIN RK29_PIN6_PA7 -//#define MAX_PRE_CNT 2 -//#define DET_CNT 5 -#define PWR_ON_THRESHD 5 //power on threshd of capacity -//unsigned int pre_cnt = 0; //for long press counter -//int charge_disp_mode = 0; static int pwr_on_thrsd = 5; //power on capcity threshold -//extern int boot_mode_init(char * s); - static int __init pwr_on_thrsd_setup(char *str) { @@ -96,26 +86,18 @@ int rk_get_system_battery_capacity(void) } EXPORT_SYMBOL(rk_get_system_battery_capacity); -#ifdef CONFIG_POWER_ON_CHARGER_DISPLAY -//int charger_mode=0; //1:charge,0:not charge +#ifdef CONFIG_CHARGER_DISPLAY static void add_bootmode_charger_to_cmdline(void) { char *pmode=" androidboot.mode=charger"; - //int off = strlen(saved_command_line); char *new_command_line = kzalloc(strlen(saved_command_line) + strlen(pmode) + 1, GFP_KERNEL); + sprintf(new_command_line, "%s%s", saved_command_line, pmode); saved_command_line = new_command_line; - //strcpy(saved_command_line+off,pmode); - - //int off = strlen(boot_command_line); - //strcpy(boot_command_line+off,pmode); printk("Kernel command line: %s\n", saved_command_line); } -//display charger logo in kernel CAPACITY - - static int __init start_charge_logo_display(void) { union power_supply_propval val_status = {POWER_SUPPLY_STATUS_DISCHARGING}; @@ -123,18 +105,15 @@ static int __init start_charge_logo_display(void) printk("start_charge_logo_display\n"); - if(board_boot_mode() == BOOT_MODE_RECOVERY) //recovery mode + if(rockchip_boot_mode() == BOOT_MODE_RECOVERY) //recovery mode { printk("recovery mode \n"); return 0; - } - if (rk_get_system_battery_status() != POWER_SUPPLY_TYPE_BATTERY) val_status.intval = POWER_SUPPLY_STATUS_CHARGING; val_capacity.intval = rk_get_system_battery_capacity(); - // low power and discharging #if 0 if((val_capacity.intval < pwr_on_thrsd )&&(val_status.intval != POWER_SUPPLY_STATUS_CHARGING)) @@ -146,37 +125,17 @@ static int __init start_charge_logo_display(void) } #endif - - //low power and charging -#if 0 - if((val_capacity.intval < pwr_on_thrsd )&&(val_status.intval == POWER_SUPPLY_STATUS_CHARGING)) - { - while((val_capacity.intval < pwr_on_thrsd )) - { - list_for_each_entry(psy, &rk_psy_head, rk_psy_node) - { - psy->get_property(psy,POWER_SUPPLY_PROP_CAPACITY,&val_capacity); - } - - //printk("charging ... \n"); - } - } - -#endif - if(val_status.intval == POWER_SUPPLY_STATUS_CHARGING) { - if ((board_boot_mode() == BOOT_MODE_NORMAL) ||(board_boot_mode() == BOOT_MODE_CHARGE)|| (val_capacity.intval <= pwr_on_thrsd)) //do not enter power on charge mode when soft reset + if (((rockchip_boot_mode() == BOOT_MODE_NORMAL) ||(rockchip_boot_mode() == BOOT_MODE_CHARGE)) && (val_capacity.intval <= pwr_on_thrsd)) { add_bootmode_charger_to_cmdline(); - //boot_mode_init("charge"); - printk("power in charge mode\n"); - } + printk("power in charge mode %d %d %d\n\n",rockchip_boot_mode(),val_capacity.intval,pwr_on_thrsd); + } } return 0; } -//subsys_initcall_sync(start_charge_logo_display); module_init(start_charge_logo_display); #endif -- 2.34.1