From: hzf Date: Wed, 25 Sep 2013 08:18:33 +0000 (+0800) Subject: ac:add charge current set X-Git-Tag: firefly_0821_release~6606 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b20f71aef0f75f40d6dc327af1679056bf5b0c84;p=firefly-linux-kernel-4.4.55.git ac:add charge current set --- diff --git a/arch/arm/configs/rk3188_ac_defconfig b/arch/arm/configs/rk3188_ac_defconfig index 6a0f614f3763..fbb726e83c90 100644 --- a/arch/arm/configs/rk3188_ac_defconfig +++ b/arch/arm/configs/rk3188_ac_defconfig @@ -299,6 +299,7 @@ CONFIG_BACKLIGHT_LCD_SUPPORT=y # CONFIG_LCD_CLASS_DEVICE is not set CONFIG_BACKLIGHT_CLASS_DEVICE=y # CONFIG_BACKLIGHT_GENERIC is not set +# CONFIG_BACKLIGHT_RK29_BL is not set CONFIG_DISPLAY_SUPPORT=y CONFIG_FB_ROCKCHIP=y CONFIG_DUAL_LCDC_DUAL_DISP_IN_KERNEL=y diff --git a/arch/arm/mach-rk3188/board-rk3188-ac.c b/arch/arm/mach-rk3188/board-rk3188-ac.c index 8e680cd76347..9bf68649c678 100755 --- a/arch/arm/mach-rk3188/board-rk3188-ac.c +++ b/arch/arm/mach-rk3188/board-rk3188-ac.c @@ -940,6 +940,81 @@ struct rk29_sdmmc_platform_data default_sdmmc1_data = { **************************************************************************************************/ #ifdef CONFIG_BATTERY_RK30_ADC_FAC +static int ac_current = -1; +#define CHARING_CURRENT_500MA 0 +#define CHARING_CURRENT_1000MA 1 + +#define DC_CUR_SET_PIN RK30_PIN0_PB0 +#define CHARGE_OK_PIN RK30_PIN0_PA6 +#define DC_DET_PIN RK30_PIN0_PB2 +static int rk30_battery_adc_io_init(void) +{ + int ret = 0; + printk("charging: set charging current 500ma \n"); + ac_current = CHARING_CURRENT_500MA; + //dc charge detect pin + ret = gpio_request(DC_DET_PIN, NULL); + if (ret) { + printk("failed to request dc_det gpio\n"); + return ret ; + } + + gpio_pull_updown(DC_DET_PIN, 1);//important + ret = gpio_direction_input(DC_DET_PIN); + if (ret) { + printk("failed to set gpio dc_det input\n"); + return ret ; + } + + //charge ok pin + ret = gpio_request(CHARGE_OK_PIN, NULL); + if (ret) { + printk("failed to request charge_ok gpio\n"); + return ret ; + } + + gpio_pull_updown(CHARGE_OK_PIN, 1);//important + ret = gpio_direction_input(CHARGE_OK_PIN); + if (ret) { + printk("failed to set gpio charge_ok input\n"); + return ret ; + } + //charge current set pin + ret = gpio_request(DC_CUR_SET_PIN, NULL); + if (ret) { + printk("failed to request DC_CUR_SET_PIN gpio\n"); + return ret ; + } + + ret = gpio_direction_output(DC_CUR_SET_PIN, GPIO_LOW);//500ma + if (ret) { + printk("failed to set gpio DC_CUR_SET_PIN output\n"); + return ret ; + } + + return 0; + +} + +static int set_usb_charging_current(int mode) +{ +#if 0 + if ( (ac_current==CHARING_CURRENT_1000MA) && (mode == PC_MODE) ) { + gpio_set_value(DC_CUR_SET_PIN, GPIO_LOW); + ac_current = CHARING_CURRENT_500MA; + } + else if ((mode == ADAPT_MODE) && (ac_current==CHARING_CURRENT_500MA)) + { + gpio_set_value(DC_CUR_SET_PIN, GPIO_HIGH); + ac_current = CHARING_CURRENT_1000MA; + + } +#endif + gpio_set_value(DC_CUR_SET_PIN, GPIO_LOW); + ac_current = CHARING_CURRENT_500MA; +} + + static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = { .dc_det_pin = RK30_PIN0_PB2, .batt_low_pin = INVALID_GPIO, @@ -955,7 +1030,9 @@ static struct rk30_adc_battery_platform_data rk30_adc_battery_platdata = { .is_reboot_charging = 1, .save_capacity = 1 , - .low_voltage_protection = 3600, + .low_voltage_protection = 3600, + .io_init = rk30_battery_adc_io_init, + .control_usb_charging= set_usb_charging_current, }; static struct platform_device rk30_device_adc_battery = {