From 557246bac9ace29db5c0f50a6b4b0f49b7a85f28 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=BC=A0=E6=99=B4?= Date: Tue, 25 Mar 2014 14:13:56 +0800 Subject: [PATCH] rk3288:bq24296:slove bq24296 reset reg when poweron;set init charger current --- arch/arm/boot/dts/rk3288-tb.dts | 2 +- drivers/power/bq24296_charger.c | 54 ++++++++++++++++++--------------- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/arch/arm/boot/dts/rk3288-tb.dts b/arch/arm/boot/dts/rk3288-tb.dts index 0a849c21ac3a..3f1506417449 100755 --- a/arch/arm/boot/dts/rk3288-tb.dts +++ b/arch/arm/boot/dts/rk3288-tb.dts @@ -284,7 +284,7 @@ compatible = "ti,bq24296"; reg = <0x6b>; gpios = <&gpio0 GPIO_A7 GPIO_ACTIVE_HIGH>,<&gpio0 GPIO_B0 GPIO_ACTIVE_HIGH>; - bq24296,chg_current = <1000 500 3000>; + bq24296,chg_current = <1000 2000 3000>; status = "okay"; }; bq27320: bq27320@55 { diff --git a/drivers/power/bq24296_charger.c b/drivers/power/bq24296_charger.c index b25919de3946..7e31f4fb4925 100755 --- a/drivers/power/bq24296_charger.c +++ b/drivers/power/bq24296_charger.c @@ -154,6 +154,7 @@ static int bq24296_init_registers(void) int ret = 0; /* reset the register */ + /* ret = bq24296_update_reg(bq24296_di->client, POWE_ON_CONFIGURATION_REGISTER, REGISTER_RESET_ENABLE << REGISTER_RESET_OFFSET, @@ -165,7 +166,7 @@ static int bq24296_init_registers(void) } mdelay(5); - +*/ /* Disable the watchdog */ ret = bq24296_update_reg(bq24296_di->client, TERMINATION_TIMER_CONTROL_REGISTER, @@ -220,7 +221,6 @@ static int bq24296_get_limit_current(int value) data = 6; else data = 7; - data &= 0xff; return data; } @@ -382,8 +382,9 @@ static void usb_detect_work_func(struct work_struct *work) bq24296_chag_down =0; DBG("%s: retval = %08x bq24296_chag_down = %d\n", __func__,retval,bq24296_chag_down); + + mutex_lock(&pi->var_lock); - #ifdef CONFIG_OF if (gpio_is_valid(bq24296_pdata->dc_det_pin)){ ret = gpio_request(bq24296_pdata->dc_det_pin, "bq24296_dc_det"); if (ret < 0) { @@ -393,49 +394,54 @@ static void usb_detect_work_func(struct work_struct *work) ret = gpio_get_value(bq24296_pdata->dc_det_pin); if (ret ==0){ bq24296_update_input_current_limit(bq24296_di->adp_input_current); - bq24296_set_charge_current(bq24296_di->chg_current); + bq24296_set_charge_current(CHARGE_CURRENT_2048MA); bq24296_charge_mode_config(0); } + else { + bq24296_update_input_current_limit(IINLIM_500MA); + bq24296_set_charge_current(CHARGE_CURRENT_512MA); + } gpio_free(bq24296_pdata->dc_det_pin); DBG("%s: bq24296_di->dc_det_pin=%x\n", __func__, ret); - } - #endif - - mutex_lock(&pi->var_lock); - DBG("%s: dwc_otg_check_dpdm %d\n", __func__, dwc_otg_check_dpdm(0)); - switch(dwc_otg_check_dpdm(0)) - { - case 2: // USB Wall charger - bq24296_update_input_current_limit(bq24296_di->adp_input_current); - bq24296_set_charge_current(bq24296_di->chg_current); + } + else{ + DBG("%s: dwc_otg_check_dpdm %d\n", __func__, dwc_otg_check_dpdm(0)); + switch(dwc_otg_check_dpdm(0)) + { + case 2: // USB Wall charger + bq24296_update_input_current_limit(bq24296_di->usb_input_current); + bq24296_set_charge_current(CHARGE_CURRENT_2048MA); bq24296_charge_mode_config(0); DBG("bq24296: detect usb wall charger\n"); - break; - case 1: //normal USB + break; + case 1: //normal USB #if 0 if (0 == get_gadget_connect_flag()){ // non-standard AC charger - bq24296_update_input_current_limit(IINLIM_2000MA); - bq24296_set_charge_current(CHARGE_CURRENT_1024MA); + bq24296_update_input_current_limit((bq24296_di->usb_input_current); + bq24296_set_charge_current(CHARGE_CURRENT_2048MA); bq24296_charge_mode_config(0);; }else{ #endif // connect to pc - bq24296_update_input_current_limit(bq24296_di->adp_input_current); + bq24296_update_input_current_limit(bq24296_di->usb_input_current); bq24296_set_charge_current(CHARGE_CURRENT_512MA); bq24296_charge_mode_config(0); DBG("bq24296: detect normal usb charger\n"); - // } - break; - default: + // } + break; + default: + bq24296_update_input_current_limit(IINLIM_500MA); + bq24296_set_charge_current(CHARGE_CURRENT_512MA); DBG("bq24296: detect no usb \n"); - break; + break; + } } + mutex_unlock(&pi->var_lock); schedule_delayed_work(&pi->usb_detect_work, 1*HZ); } - static void irq_work_func(struct work_struct *work) { // struct bq24296_device_info *info= container_of(work, struct bq24296_device_info, irq_work); -- 2.34.1