rk31xx:act8846:support sleep voltage for new hardware
author张晴 <zhangqing@rock-chips.com>
Tue, 29 Jan 2013 02:15:25 +0000 (10:15 +0800)
committer张晴 <zhangqing@rock-chips.com>
Tue, 29 Jan 2013 02:15:25 +0000 (10:15 +0800)
arch/arm/mach-rk30/board-pmu-act8846.c
arch/arm/mach-rk30/pm.c
drivers/regulator/act8846.c

index ad62ff7827ce56d4d31e0ed075425bd3da5d3843..eaec2fcfa72b93c03458ba044a2e0702bd3cc15e 100755 (executable)
@@ -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
 
index bdc04fec75930b770e7ab52180da23d592eb6be3..2ad5e41c0a48ca2a454e15cd80c9dea59fd257bf 100755 (executable)
@@ -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);
index 4775e1d5e32a517a9e4209e2aa1ec80387c135d8..6b8aa666ea95245c91b38bf6a81dcf4ab7ab2d7d 100755 (executable)
@@ -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)