rk30:Support both of compatible pmic wm8326 and tps65910
author张晴 <zhangqing@rock-chips.com>
Wed, 1 Aug 2012 09:13:56 +0000 (17:13 +0800)
committer张晴 <zhangqing@rock-chips.com>
Wed, 1 Aug 2012 09:13:56 +0000 (17:13 +0800)
arch/arm/mach-rk30/board-rk30-phonepad.c
arch/arm/mach-rk30/board-rk30-sdk-tps65910.c
arch/arm/mach-rk30/board-rk30-sdk-wm8326.c
arch/arm/mach-rk30/board-rk30-sdk.c

index 86020f098eb776be4b9f0090583a8de83647f653..7680d9e6576dde9fbfe4abfd4e0c2b0def9f0ab4 100755 (executable)
@@ -1798,6 +1798,9 @@ static struct i2c_board_info __initdata i2c0_info[] = {
 };
 #endif
 
+#define PMIC_TYPE_WM8326       1
+#define PMIC_TYPE_TPS65910     2
+int __sramdata g_pmic_type =  0;
 #ifdef CONFIG_I2C1_RK30
 #ifdef CONFIG_MFD_WM831X_I2C
 #include "board-rk30-sdk-wm8326.c"
@@ -1829,6 +1832,25 @@ static struct i2c_board_info __initdata i2c1_info[] = {
 };
 #endif
 
+
+void __sramfunc board_pmu_suspend(void)
+{      
+       if(g_pmic_type == PMIC_TYPE_WM8326)
+       board_pmu_wm8326_suspend();
+       else if(g_pmic_type == PMIC_TYPE_TPS65910)
+       board_pmu_tps65910_suspend(); 
+       
+}
+
+void __sramfunc board_pmu_resume(void)
+{      
+       if(g_pmic_type == PMIC_TYPE_WM8326)
+       board_pmu_wm8326_resume();
+       else if(g_pmic_type == PMIC_TYPE_TPS65910)
+       board_pmu_tps65910_resume();      
+}
+
+
 #ifdef CONFIG_I2C2_RK30
 static struct i2c_board_info __initdata i2c2_info[] = {
 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
@@ -1955,16 +1977,19 @@ void rk30_pm_power_off(void)
               arm_pm_restart(0, NULL);
        }
 #endif
-#if PMIC_IS_WM831X 
-#if defined(CONFIG_MFD_WM831X)
-       wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000);  //set sys_pwr 0
-       wm831x_device_shutdown(Wm831x);//wm8326 shutdown
-#endif
-#else
-#if defined(CONFIG_MFD_TPS65910)
-       tps65910_device_shutdown();//tps65910 shutdown
-#endif
-#endif
+       #if defined(CONFIG_MFD_WM831X)  
+       if(g_pmic_type == PMIC_TYPE_WM8326)
+       {
+               wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000);  //set sys_pwr 0
+               wm831x_device_shutdown(Wm831x);//wm8326 shutdown
+       }
+       #endif
+       #if defined(CONFIG_MFD_TPS65910)
+       if(g_pmic_type == PMIC_TYPE_TPS65910)
+       {
+               tps65910_device_shutdown();//tps65910 shutdown
+       }
+       #endif
   gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
        while(1);
 }
index ac2ee6b19f1f911f93baa773fe54fdcc44d58a9f..69e4afa8f076261b3ffa4d753808c9af0aa5a6d8 100755 (executable)
@@ -230,6 +230,9 @@ int tps65910_post_init(struct tps65910 *tps65910)
        struct regulator *ldo;
        printk("%s,line=%d\n", __func__,__LINE__);
 
+       g_pmic_type = PMIC_TYPE_TPS65910;
+       printk("%s:g_pmic_type=%d\n",__func__,g_pmic_type);
+       
        dcdc = regulator_get(NULL, "vio");      //vcc_io
        regulator_set_voltage(dcdc, 3000000, 3000000);
        regulator_enable(dcdc);
@@ -576,13 +579,13 @@ static struct regulator_init_data tps65910_ldo8 = {
        .consumer_supplies =  tps65910_ldo8_supply,
 };
 
-void __sramfunc board_pmu_suspend(void)
+void __sramfunc board_pmu_tps65910_suspend(void)
 {      
        grf_writel(GPIO6_PB1_DIR_OUT, GRF_GPIO6L_DIR_ADDR);
        grf_writel(GPIO6_PB1_DO_HIGH, GRF_GPIO6L_DO_ADDR);  //set gpio6_b1 output low
        grf_writel(GPIO6_PB1_EN_MASK, GRF_GPIO6L_EN_ADDR);
 }
-void __sramfunc board_pmu_resume(void)
+void __sramfunc board_pmu_tps65910_resume(void)
 {
        grf_writel(GPIO6_PB1_DIR_OUT, GRF_GPIO6L_DIR_ADDR);
        grf_writel(GPIO6_PB1_DO_LOW, GRF_GPIO6L_DO_ADDR);  //set gpio6_b1 output low
index ce3050e7e6df8dfaa58edc2cf516324ebd0895dd..fbba1ea0aeb37f4be4591752b5aa970d53c10787 100755 (executable)
@@ -182,7 +182,10 @@ int wm831x_post_init(struct wm831x *Wm831x)
        struct regulator *dcdc;
        struct regulator *ldo;
 
-
+       
+       g_pmic_type = PMIC_TYPE_WM8326;
+       printk("%s:g_pmic_type=%d\n",__func__,g_pmic_type);
+       
        ldo = regulator_get(NULL, "ldo6");      //vcc_33
        regulator_set_voltage(ldo, 3300000, 3300000);
        regulator_set_suspend_voltage(ldo, 3300000);
@@ -774,14 +777,14 @@ out:
        return 0;
 }
 
-void __sramfunc board_pmu_suspend(void)
+void __sramfunc board_pmu_wm8326_suspend(void)
 {      
        cru_writel(CRU_CLKGATE5_GRFCLK_ON,CRU_CLKGATE5_CON_ADDR); //open grf clk
        grf_writel(GPIO6_PB1_DIR_OUT, GRF_GPIO6L_DIR_ADDR);
        grf_writel(GPIO6_PB1_DO_HIGH, GRF_GPIO6L_DO_ADDR);  //set gpio6_b1 output low
        grf_writel(GPIO6_PB1_EN_MASK, GRF_GPIO6L_EN_ADDR);
 }
-void __sramfunc board_pmu_resume(void)
+void __sramfunc board_pmu_wm8326_resume(void)
 {
        grf_writel(GPIO6_PB1_DIR_OUT, GRF_GPIO6L_DIR_ADDR);
        grf_writel(GPIO6_PB1_DO_LOW, GRF_GPIO6L_DO_ADDR);     //set gpio6_b1 output high
@@ -792,6 +795,7 @@ void __sramfunc board_pmu_resume(void)
        sram_udelay(10000);
 #endif
 }
+
 static struct wm831x_pdata wm831x_platdata = {
 
        /** Called before subdevices are set up */
index 0b27edc772ddf81aad67db233110dd3b8e6553d4..1eaec78a130872a2c4972478ee791561a38e37da 100755 (executable)
@@ -1538,9 +1538,17 @@ static struct i2c_board_info __initdata i2c0_info[] = {
 
 };
 #endif
-
+#define PMIC_TYPE_WM8326       1
+#define PMIC_TYPE_TPS65910     2
+int __sramdata g_pmic_type =  0;
 #ifdef CONFIG_I2C1_RK30
+#ifdef CONFIG_MFD_WM831X_I2C
 #include "board-rk30-sdk-wm8326.c"
+#endif
+#ifdef CONFIG_MFD_TPS65910
+#define TPS65910_HOST_IRQ        RK30_PIN6_PA4
+#include "board-rk30-sdk-tps65910.c"
+#endif
 
 static struct i2c_board_info __initdata i2c1_info[] = {
 #if defined (CONFIG_MFD_WM831X_I2C)
@@ -1552,9 +1560,36 @@ static struct i2c_board_info __initdata i2c1_info[] = {
                .platform_data = &wm831x_platdata,
        },
 #endif
+#if defined (CONFIG_MFD_TPS65910)
+       {
+        .type           = "tps65910",
+        .addr           = TPS65910_I2C_ID0,
+        .flags          = 0,
+        .irq            = TPS65910_HOST_IRQ,
+       .platform_data = &tps65910_data,
+       },
+#endif
 };
 #endif
 
+
+void __sramfunc board_pmu_suspend(void)
+{      
+       if(g_pmic_type == PMIC_TYPE_WM8326)
+       board_pmu_wm8326_suspend();
+       else if(g_pmic_type == PMIC_TYPE_TPS65910)
+       board_pmu_tps65910_suspend(); 
+       
+}
+
+void __sramfunc board_pmu_resume(void)
+{      
+       if(g_pmic_type == PMIC_TYPE_WM8326)
+       board_pmu_wm8326_resume();
+       else if(g_pmic_type == PMIC_TYPE_TPS65910)
+       board_pmu_tps65910_resume();      
+}
+
 #ifdef CONFIG_I2C2_RK30
 static struct i2c_board_info __initdata i2c2_info[] = {
 #if defined (CONFIG_TOUCHSCREEN_GT8XX)
@@ -1638,10 +1673,20 @@ static void rk30_pm_power_off(void)
 {
        printk(KERN_ERR "rk30_pm_power_off start...\n");
        gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
-#if defined(CONFIG_MFD_WM831X)
-       wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000);  //set sys_pwr 0
-       wm831x_device_shutdown(Wm831x);//wm8326 shutdown
-#endif
+       #if defined(CONFIG_MFD_WM831X)  
+       if(g_pmic_type == PMIC_TYPE_WM8326)
+       {
+               wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000);  //set sys_pwr 0
+               wm831x_device_shutdown(Wm831x);//wm8326 shutdown
+       }
+       #endif
+       #if defined(CONFIG_MFD_TPS65910)
+       if(g_pmic_type == PMIC_TYPE_TPS65910)
+       {
+               tps65910_device_shutdown();//tps65910 shutdown
+       }
+       #endif
+
        while (1);
 }