From 0f917255046a2d782d9792ebd5ab99b5e1e8bd89 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=BC=A0=E6=99=B4?= Date: Wed, 16 Jan 2013 11:21:21 +0800 Subject: [PATCH] rk3168:act8846:support act8846 pmic reset --- arch/arm/mach-rk30/board-pmu-act8846.c | 57 +++++++++++++++----------- arch/arm/mach-rk30/board-rk3168-tb.c | 8 ++-- arch/arm/plat-rk/include/plat/sram.h | 2 +- arch/arm/plat-rk/sram.c | 2 +- drivers/regulator/Kconfig | 7 ++++ drivers/regulator/act8846.c | 21 ++++++++-- 6 files changed, 64 insertions(+), 33 deletions(-) diff --git a/arch/arm/mach-rk30/board-pmu-act8846.c b/arch/arm/mach-rk30/board-pmu-act8846.c index 42a78d2b9b75..6c7f416e8853 100755 --- a/arch/arm/mach-rk30/board-pmu-act8846.c +++ b/arch/arm/mach-rk30/board-pmu-act8846.c @@ -16,26 +16,6 @@ static int act8846_set_init(struct act8846 *act8846) int i = 0; printk("%s,line=%d\n", __func__,__LINE__); - #ifdef CONFIG_RK_CONFIG - if(sram_gpio_init(get_port_config(pmic_slp).gpio, &pmic_sleep) < 0){ - printk(KERN_ERR "sram_gpio_init failed\n"); - return -EINVAL; - } - if(port_output_init(pmic_slp, 0, "pmic_slp") < 0){ - printk(KERN_ERR "port_output_init failed\n"); - return -EINVAL; - } - #else - if(sram_gpio_init(PMU_POWER_SLEEP, &pmic_sleep) < 0){ - printk(KERN_ERR "sram_gpio_init failed\n"); - return -EINVAL; - } - - gpio_request(PMU_POWER_SLEEP, "NULL"); - gpio_direction_output(PMU_POWER_SLEEP, GPIO_LOW); - #endif - - #ifndef CONFIG_RK_CONFIG g_pmic_type = PMIC_TYPE_ACT8846; #endif @@ -66,8 +46,38 @@ static int act8846_set_init(struct act8846 *act8846) regulator_put(ldo); } + #ifdef CONFIG_RK_CONFIG + if(sram_gpio_init(get_port_config(pmic_slp).gpio, &pmic_sleep) < 0){ + printk(KERN_ERR "sram_gpio_init failed\n"); + return -EINVAL; + } + if(port_output_init(pmic_slp, 0, "pmic_slp") < 0){ + printk(KERN_ERR "port_output_init failed\n"); + return -EINVAL; + } + #else + if(sram_gpio_init(PMU_POWER_SLEEP, &pmic_sleep) < 0){ + printk(KERN_ERR "sram_gpio_init failed\n"); + return -EINVAL; + } + gpio_request(PMU_POWER_SLEEP, "NULL"); + gpio_direction_output(PMU_POWER_SLEEP, GPIO_LOW); + + #ifdef CONFIG_ACT8846_SUPPORT_RESET + if(sram_gpio_init(PMU_VSEL, &pmic_vsel) < 0){ + printk(KERN_ERR "sram_gpio_init failed\n"); + return -EINVAL; + } + rk30_mux_api_set(GPIO3D3_PWM0_NAME,GPIO3D_GPIO3D3); + gpio_request(PMU_VSEL, "NULL"); + gpio_direction_output(PMU_VSEL, GPIO_HIGH); + #endif + + #endif + printk("%s,line=%d END\n", __func__,__LINE__); + return 0; } @@ -432,9 +442,6 @@ void act8846_late_resume(struct early_suspend *h) { } #endif - -#endif - void __sramfunc board_pmu_act8846_suspend(void) { #ifdef CONFIG_CLK_SWITCH_TO_32K @@ -449,4 +456,8 @@ void __sramfunc board_pmu_act8846_resume(void) #endif } +#endif + + + diff --git a/arch/arm/mach-rk30/board-rk3168-tb.c b/arch/arm/mach-rk30/board-rk3168-tb.c index 8b1fa831c427..02c32d676ca7 100755 --- a/arch/arm/mach-rk30/board-rk3168-tb.c +++ b/arch/arm/mach-rk30/board-rk3168-tb.c @@ -1561,7 +1561,7 @@ static struct pmu_info tps65910_ldo_info[] = { #ifdef CONFIG_REGULATOR_ACT8846 #define PMU_POWER_SLEEP RK30_PIN0_PA1 - +#define PMU_VSEL RK30_PIN3_PD3 static struct pmu_info act8846_dcdc_info[] = { { .name = "act_dcdc1", //ddr @@ -1573,19 +1573,19 @@ static struct pmu_info act8846_dcdc_info[] = { .name = "vdd_core", //logic .min_uv = 1000000, .max_uv = 1000000, - .suspend_vol = 900000, + .suspend_vol = 1000000, }, { .name = "vdd_cpu", //arm .min_uv = 1000000, .max_uv = 1000000, - .suspend_vol = 900000, + .suspend_vol = 1000000, }, { .name = "act_dcdc4", //vccio .min_uv = 3000000, .max_uv = 3000000, - .suspend_vol = 2800000, + .suspend_vol = 3000000, }, }; diff --git a/arch/arm/plat-rk/include/plat/sram.h b/arch/arm/plat-rk/include/plat/sram.h index 51c520cb2076..3702b787e973 100755 --- a/arch/arm/plat-rk/include/plat/sram.h +++ b/arch/arm/plat-rk/include/plat/sram.h @@ -22,7 +22,7 @@ struct sram_gpio_data { uint offset; }; -extern struct sram_gpio_data __sramdata pmic_sleep; +extern struct sram_gpio_data __sramdata pmic_sleep,pmic_vsel; int sram_gpio_init(int gpio, struct sram_gpio_data *data); void __sramfunc sram_gpio_set_value(struct sram_gpio_data data, uint value); diff --git a/arch/arm/plat-rk/sram.c b/arch/arm/plat-rk/sram.c index f7455c55c4d3..ec1cbadf9388 100755 --- a/arch/arm/plat-rk/sram.c +++ b/arch/arm/plat-rk/sram.c @@ -178,7 +178,7 @@ void __sramfunc sram_printhex(unsigned int hex) } } -struct sram_gpio_data __sramdata pmic_sleep; +struct sram_gpio_data __sramdata pmic_sleep,pmic_vsel; #if defined(CONFIG_ARCH_RK2928) static void __iomem *gpio_base[] = {RK2928_GPIO0_BASE, RK2928_GPIO1_BASE, RK2928_GPIO2_BASE, RK2928_GPIO3_BASE}; #elif defined(CONFIG_ARCH_RK3066B) || defined(CONFIG_ARCH_RK3188) diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 8468f4f9ccd6..e01f5afcb377 100755 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -288,6 +288,13 @@ config REGULATOR_ACT8846 help Support the voltage and current regulators of the ACT8846 series of PMIC devices. +config ACT8846_SUPPORT_RESET + tristate "ACT8846 PMIC SUPPORT RESET" + depends on REGULATOR_ACT8846=y + help + Support short press key to restart. + + config RK29_PWM_REGULATOR tristate "rk2918 pwm voltage regulator" help diff --git a/drivers/regulator/act8846.c b/drivers/regulator/act8846.c index 9dbab96a3609..181a9b502ab9 100755 --- a/drivers/regulator/act8846.c +++ b/drivers/regulator/act8846.c @@ -323,7 +323,11 @@ static int act8846_dcdc_get_voltage(struct regulator_dev *dev) int buck = rdev_get_id(dev) - ACT8846_DCDC1; u16 reg = 0; int val; + #ifdef CONFIG_ACT8846_SUPPORT_RESET + reg = act8846_reg_read(act8846,(act8846_BUCK_SET_VOL_REG(buck)+0x1)); + #else reg = act8846_reg_read(act8846,act8846_BUCK_SET_VOL_REG(buck)); + #endif reg &= BUCK_VOL_MASK; DBG("%d\n", reg); val = 1000 * buck_voltage_map[reg]; @@ -352,8 +356,13 @@ static int act8846_dcdc_set_voltage(struct regulator_dev *dev, if (vol_map[val] > max_vol) printk("WARNING:this voltage is not support!voltage set is %d mv\n",vol_map[val]); - ret = act8846_set_bits(act8846, act8846_BUCK_SET_VOL_REG(buck), - BUCK_VOL_MASK, val); + + #ifdef CONFIG_ACT8846_SUPPORT_RESET + ret = act8846_set_bits(act8846, (act8846_BUCK_SET_VOL_REG(buck) +0x1),BUCK_VOL_MASK, val); + #else + ret = act8846_set_bits(act8846, act8846_BUCK_SET_VOL_REG(buck) ,BUCK_VOL_MASK, val); + #endif + return ret; } static int act8846_dcdc_set_sleep_voltage(struct regulator_dev *dev, @@ -378,8 +387,12 @@ static int act8846_dcdc_set_sleep_voltage(struct regulator_dev *dev, if (vol_map[val] > max_vol) printk("WARNING:this voltage is not support!voltage set is %d mv\n",vol_map[val]); - ret = act8846_set_bits(act8846, (act8846_BUCK_SET_VOL_REG(buck) + 0x01), - BUCK_VOL_MASK, val); + #ifdef CONFIG_ACT8846_SUPPORT_RESET + ret = act8846_set_bits(act8846, (act8846_BUCK_SET_VOL_REG(buck) ),BUCK_VOL_MASK, val); + #else + ret = act8846_set_bits(act8846, (act8846_BUCK_SET_VOL_REG(buck) +0x01),BUCK_VOL_MASK, val); + #endif + return ret; } static unsigned int act8846_dcdc_get_mode(struct regulator_dev *dev) -- 2.34.1