From f600d449b544006014b6a75d32b4e599d573d494 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=AE=8B=E7=A7=80=E6=9D=B0?= Date: Fri, 1 Oct 2010 06:00:52 -0700 Subject: [PATCH] add pmu channel control in pm.c, old file do not support it --- arch/arm/mach-rk2818/board-raho.c | 2 +- arch/arm/mach-rk2818/pm.c | 50 +++++++++++++++++++++++++++-- arch/arm/mach-rk2818/rk2818-socpm.c | 7 ++-- drivers/regulator/rk2818_lp8725.c | 21 ++++++++++-- 4 files changed, 72 insertions(+), 8 deletions(-) mode change 100644 => 100755 drivers/regulator/rk2818_lp8725.c diff --git a/arch/arm/mach-rk2818/board-raho.c b/arch/arm/mach-rk2818/board-raho.c index b68ed5cdddbf..2bf3776ca7be 100755 --- a/arch/arm/mach-rk2818/board-raho.c +++ b/arch/arm/mach-rk2818/board-raho.c @@ -706,7 +706,7 @@ struct rk2818_i2c_platform_data default_i2c1_data = { .flags = 0, .slave_addr = 0xff, .scl_rate = 400*1000, - .mode = I2C_MODE_IRQ, //I2C_MODE_POLL + .mode = I2C_MODE_POLL, //I2C_MODE_POLL .io_init = rk2818_i2c1_io_init, }; diff --git a/arch/arm/mach-rk2818/pm.c b/arch/arm/mach-rk2818/pm.c index ed0c4af40d3c..a45dde92d231 100755 --- a/arch/arm/mach-rk2818/pm.c +++ b/arch/arm/mach-rk2818/pm.c @@ -13,6 +13,7 @@ #include #include #include +#include extern void rockchip_timer_clocksource_suspend_resume(int suspend); extern int rockchip_timer_clocksource_irq_checkandclear(void); @@ -169,7 +170,7 @@ void __tcmfunc sdram_exit_self_refresh(u32 ctrl_reg_62) tcm_udelay(100, 24); //DRVDelayUs(100); 延时一下比较安全,保证退出后稳定 } -#if 0 +#if 1 static void __tcmlocalfunc noinline tcm_printch(char byte) { unsigned int timeout; @@ -541,6 +542,50 @@ static void rk2818_pm_reg_print(unsigned int *pm_save_reg,unsigned int *pm_ch_re #endif +static void pmu_suspend(void) +{ + struct regulator *ldo1,*ldo2,*ldo4,*ldo5; + struct regulator *lilo2; + + ldo1 = regulator_get(NULL, "ldo1"); + regulator_disable(ldo1); + ldo2 = regulator_get(NULL, "ldo2"); + regulator_disable(ldo2); + ldo4 = regulator_get(NULL, "ldo4"); + regulator_disable(ldo4); + ldo5 = regulator_get(NULL, "ldo5"); + regulator_disable(ldo5); + lilo2 = regulator_get(NULL, "lilo2"); + regulator_disable(lilo2); +} + +static void pmu_resume(void) +{ + struct regulator *ldo1,*ldo2,*ldo4,*ldo5; + struct regulator *lilo2; + int tmp = 0; + + ldo1 = regulator_get(NULL, "ldo1"); + regulator_enable(ldo1); + tmp = regulator_get_voltage(ldo1); + + ldo2 = regulator_get(NULL, "ldo2"); + regulator_enable(ldo2); + tmp = regulator_get_voltage(ldo2); + + ldo4 = regulator_get(NULL, "ldo4"); + regulator_enable(ldo4); + tmp = regulator_get_voltage(ldo4); + + ldo5 = regulator_get(NULL, "ldo5"); + regulator_enable(ldo5); + tmp = regulator_get_voltage(ldo5); + + lilo2 = regulator_get(NULL, "lilo2"); + regulator_enable(lilo2); + tmp = regulator_get_voltage(lilo2); +} + static int __tcmfunc rk2818_tcm_idle(void) { //rk2818_define_value; @@ -652,6 +697,7 @@ static int rk2818_pm_enter(suspend_state_t state) printk(KERN_DEBUG "before core halt\n"); + pmu_suspend( ); clk_set_rate(arm_clk, 24000000); dump_register(); @@ -675,7 +721,7 @@ static int rk2818_pm_enter(suspend_state_t state) rockchip_timer_clocksource_suspend_resume(0); #endif - + pmu_resume( ); dump_register(); clk_set_rate(arm_clk, arm_rate); //rk2818_socpm_print(); diff --git a/arch/arm/mach-rk2818/rk2818-socpm.c b/arch/arm/mach-rk2818/rk2818-socpm.c index 80886d46dc6d..dc12906a8938 100755 --- a/arch/arm/mach-rk2818/rk2818-socpm.c +++ b/arch/arm/mach-rk2818/rk2818-socpm.c @@ -463,7 +463,7 @@ void __tcmfunc rk2818_socpm_suspend_first(void) rk2818_soc_pm.general->reg_ctrbit=0; rk2818_soc_pm.gpio0->reg_ctrbit=0x6db; rk2818_soc_pm.gpio1->reg_ctrbit=0x6db; - + rk2818_socpm_set_gpio(RK2818_PIN_PC2,1,0); //rk2818_soc_pm.save_reg[0]=rk2818_ddr_reg[82]; //rk2818_ddr_reg[82]=rk2818_ddr_reg[82]&(~(0xffff))&(~(0xf<<20)); @@ -476,8 +476,9 @@ void __tcmfunc rk2818_socpm_suspend_first(void) void __tcmfunc rk2818_socpm_resume_first(void) { //unsigned int *rk2818_ddr_reg=(unsigned int *)RK2818_SDRAMC_BASE; - if(rk2818_soc_pm.resume_vol) - rk2818_soc_pm.resume_vol(); + rk2818_socpm_set_gpio(RK2818_PIN_PC2,1,1); + if(rk2818_soc_pm.resume_vol) + rk2818_soc_pm.resume_vol(); } diff --git a/drivers/regulator/rk2818_lp8725.c b/drivers/regulator/rk2818_lp8725.c old mode 100644 new mode 100755 index 4286d81553a8..72875a5ce1c6 --- a/drivers/regulator/rk2818_lp8725.c +++ b/drivers/regulator/rk2818_lp8725.c @@ -33,6 +33,7 @@ REVISION 0.01 #include #include #include +#include //add by robert for reboot notifier #include @@ -53,7 +54,7 @@ REVISION 0.01 #define DBG_INFO(x...) #endif - +//#define PM_CONTROL struct lp8725 { @@ -768,7 +769,7 @@ static int lp8725_set_init(void) int tmp = 0; struct regulator *ldo1,*ldo2,*ldo3,*ldo4,*ldo5; struct regulator *lilo1,*lilo2; - struct regulator *buck1,*buck2; + struct regulator *buck1,*buck1_v2,*buck2; DBG_INFO("***run in %s %d ",__FUNCTION__,__LINE__); @@ -835,6 +836,15 @@ static int lp8725_set_init(void) tmp = regulator_get_voltage(buck1); DBG_INFO("***regulator_set_init: buck1 vcc =%d\n",tmp); + #ifdef PM_CONTROL + DBG_INFO("***buck1 v2 init\n"); + buck1_v2 = regulator_get(NULL, "vdd12_v2");// dvs 0 + regulator_enable(buck1_v2); + regulator_set_voltage(buck1_v2,1000000,1000000);//1300000 + tmp = regulator_get_voltage(buck1_v2); + DBG_INFO("***regulator_set_init: buck1 v2 =%d\n",tmp); + #endif + /*init buck2*/ DBG_INFO("***buck2 vcc init\n"); buck2 = regulator_get(NULL, "vccdr"); @@ -910,6 +920,13 @@ static int __devinit lp8725_i2c_probe(struct i2c_client *i2c, const struct i2c_d } else dev_warn(lp8725->dev, "No platform init data supplied\n"); + //DVS pin control, make sure it is high level at start. + #ifdef PM_CONTROL + rk2818_mux_api_set(GPIOC_LCDC24BIT_SEL_NAME, IOMUXB_GPIO0_C2_7); + ret=gpio_request(RK2818_PIN_PC2,NULL); + gpio_direction_output(RK2818_PIN_PC2,1); + gpio_set_value(RK2818_PIN_PC2,1); + #endif lp8725_set_init(); return 0; -- 2.34.1