From 33b57b934c3f6c7e0c6ba71a93f4ebf77911d651 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=BC=A0=E6=99=B4?= Date: Tue, 29 Jan 2013 10:15:25 +0800 Subject: [PATCH] rk31xx:act8846:support sleep voltage for new hardware --- arch/arm/mach-rk30/board-pmu-act8846.c | 72 ++++++++++++++++++++++++++ arch/arm/mach-rk30/pm.c | 14 +++-- drivers/regulator/act8846.c | 31 +++++++++++ 3 files changed, 114 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-rk30/board-pmu-act8846.c b/arch/arm/mach-rk30/board-pmu-act8846.c index ad62ff7827ce..eaec2fcfa72b 100755 --- a/arch/arm/mach-rk30/board-pmu-act8846.c +++ b/arch/arm/mach-rk30/board-pmu-act8846.c @@ -442,6 +442,65 @@ void act8846_late_resume(struct early_suspend *h) { } #endif + +#ifdef CONFIG_PM +int __sramdata vdd_cpu_vol ,vdd_core_vol; +void act8846_device_suspend(void) +{ + struct regulator *dcdc; + #ifdef CONFIG_ACT8846_SUPPORT_RESET + sram_gpio_set_value(pmic_vsel, GPIO_LOW); + + dcdc =dvfs_get_regulator( "vdd_cpu"); + vdd_cpu_vol = regulator_get_voltage(dcdc); + regulator_set_voltage(dcdc, 900000, 900000); + udelay(100); + + dcdc =dvfs_get_regulator( "vdd_core"); + vdd_core_vol = regulator_get_voltage(dcdc); + regulator_set_voltage(dcdc, 900000, 900000); + udelay(100); + + dcdc =regulator_get(NULL, "act_dcdc4"); + regulator_set_voltage(dcdc, 2800000, 2800000); + regulator_put(dcdc); + udelay(100); + + #endif +} + +void act8846_device_resume(void) +{ + struct regulator *dcdc; + #ifdef CONFIG_ACT8846_SUPPORT_RESET + + dcdc =dvfs_get_regulator( "vdd_cpu"); + regulator_set_voltage(dcdc, vdd_cpu_vol, vdd_cpu_vol); + udelay(100); + + dcdc =dvfs_get_regulator( "vdd_core"); + regulator_set_voltage(dcdc, vdd_core_vol, vdd_core_vol); + udelay(100); + + dcdc =regulator_get(NULL, "act_dcdc4"); + regulator_set_voltage(dcdc, 3000000, 3000000); + regulator_put(dcdc); + udelay(100); + + sram_gpio_set_value(pmic_vsel, GPIO_HIGH); + + #endif + +} +#else +void act8846_device_suspend(void) +{ +} +void act8846_device_resume(void) +{ +} +#endif + void __sramfunc board_pmu_act8846_suspend(void) { #ifdef CONFIG_CLK_SWITCH_TO_32K @@ -455,6 +514,19 @@ void __sramfunc board_pmu_act8846_resume(void) sram_udelay(2000); #endif } +void __sramfunc board_act8846_set_suspend_vol(void) +{ +#ifdef CONFIG_ACT8846_SUPPORT_RESET + sram_gpio_set_value(pmic_vsel, GPIO_HIGH); +#endif +} +void __sramfunc board_act8846_set_resume_vol(void) +{ +#ifdef CONFIG_ACT8846_SUPPORT_RESET + sram_gpio_set_value(pmic_vsel, GPIO_LOW); +#endif +} + #endif diff --git a/arch/arm/mach-rk30/pm.c b/arch/arm/mach-rk30/pm.c index bdc04fec7593..2ad5e41c0a48 100755 --- a/arch/arm/mach-rk30/pm.c +++ b/arch/arm/mach-rk30/pm.c @@ -328,6 +328,7 @@ static noinline void interface_ctr_reg_pread(void) readl_relaxed(RK30_DDR_PUBL_BASE); readl_relaxed(RK30_I2C1_BASE+SZ_4K); readl_relaxed(RK30_GPIO0_BASE); + readl_relaxed(RK30_GPIO3_BASE); #if defined(RK30_GPIO6_BASE) readl_relaxed(RK30_GPIO6_BASE); #endif @@ -445,6 +446,8 @@ __weak void __sramfunc rk30_suspend_voltage_resume(unsigned int vol){} __weak void rk30_pwm_suspend_voltage_set(void){} __weak void rk30_pwm_resume_voltage_set(void){} +__weak void board_act8846_set_suspend_vol(void){} +__weak void board_act8846_set_resume_vol(void){} __weak void __sramfunc rk30_pwm_logic_suspend_voltage(void){} __weak void __sramfunc rk30_pwm_logic_resume_voltage(void){} @@ -462,7 +465,9 @@ static void __sramfunc rk30_sram_suspend(void) rk30_suspend_voltage_set(1000000); rk30_pwm_logic_suspend_voltage(); sram_printch('7'); - + #ifdef CONFIG_ACT8846_SUPPORT_RESET + board_act8846_set_suspend_vol(); + #endif for (i = 0; i < CRU_CLKGATES_CON_CNT; i++) { clkgt_regs[i] = cru_readl(CRU_CLKGATES_CON(i)); @@ -498,7 +503,7 @@ static void __sramfunc rk30_sram_suspend(void) | (1 << CLK_GATE_HCLK_IMEM1 % 16) | (1 << CLK_GATE_HCLK_IMEM0 % 16) #endif - , clkgt_regs[4], CRU_CLKGATES_CON(4), 0xffff); + , clkgt_regs[4], CRU_CLKGATES_CON(4), 0xffff); gate_save_soc_clk(0 | (1 << CLK_GATE_PCLK_GRF % 16) | (1 << CLK_GATE_PCLK_PMU % 16) @@ -546,7 +551,10 @@ static void __sramfunc rk30_sram_suspend(void) for (i = 0; i < CRU_CLKGATES_CON_CNT; i++) { cru_writel(clkgt_regs[i] | 0xffff0000, CRU_CLKGATES_CON(i)); } - + + #ifdef CONFIG_ACT8846_SUPPORT_RESET + board_act8846_set_resume_vol(); + #endif sram_printch('7'); rk30_pwm_logic_resume_voltage(); rk30_suspend_voltage_resume(1100000); diff --git a/drivers/regulator/act8846.c b/drivers/regulator/act8846.c index 4775e1d5e32a..6b8aa666ea95 100755 --- a/drivers/regulator/act8846.c +++ b/drivers/regulator/act8846.c @@ -719,6 +719,33 @@ int act8846_device_shutdown(void) } EXPORT_SYMBOL_GPL(act8846_device_shutdown); +__weak void act8846_device_suspend(void) {} +__weak void act8846_device_resume(void) {} +#ifdef CONFIG_PM +static int act8846_suspend(struct i2c_client *i2c, pm_message_t mesg) +{ + act8846_device_suspend(); + return 0; +} + +static int act8846_resume(struct i2c_client *i2c) +{ + act8846_device_resume(); + return 0; +} +#else +static int act8846_suspend(struct i2c_client *i2c, pm_message_t mesg) +{ + return 0; +} + +static int act8846_resume(struct i2c_client *i2c) +{ + return 0; +} +#endif + + #ifdef CONFIG_HAS_EARLYSUSPEND __weak void act8846_early_suspend(struct early_suspend *h) {} __weak void act8846_late_resume(struct early_suspend *h) {} @@ -805,6 +832,10 @@ static struct i2c_driver act8846_i2c_driver = { .probe = act8846_i2c_probe, .remove = __devexit_p(act8846_i2c_remove), .id_table = act8846_i2c_id, + #ifdef CONFIG_PM + .suspend = act8846_suspend, + .resume = act8846_resume, + #endif }; static int __init act8846_module_init(void) -- 2.34.1