From 1f0a3da031916aedcff51f2c666ee2833f89a468 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=BC=A0=E6=99=B4?= Date: Wed, 1 Aug 2012 17:13:56 +0800 Subject: [PATCH] rk30:Support both of compatible pmic wm8326 and tps65910 --- arch/arm/mach-rk30/board-rk30-phonepad.c | 45 ++++++++++++---- arch/arm/mach-rk30/board-rk30-sdk-tps65910.c | 7 ++- arch/arm/mach-rk30/board-rk30-sdk-wm8326.c | 10 ++-- arch/arm/mach-rk30/board-rk30-sdk.c | 55 ++++++++++++++++++-- 4 files changed, 97 insertions(+), 20 deletions(-) diff --git a/arch/arm/mach-rk30/board-rk30-phonepad.c b/arch/arm/mach-rk30/board-rk30-phonepad.c index 86020f098eb7..7680d9e6576d 100755 --- a/arch/arm/mach-rk30/board-rk30-phonepad.c +++ b/arch/arm/mach-rk30/board-rk30-phonepad.c @@ -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); } diff --git a/arch/arm/mach-rk30/board-rk30-sdk-tps65910.c b/arch/arm/mach-rk30/board-rk30-sdk-tps65910.c index ac2ee6b19f1f..69e4afa8f076 100755 --- a/arch/arm/mach-rk30/board-rk30-sdk-tps65910.c +++ b/arch/arm/mach-rk30/board-rk30-sdk-tps65910.c @@ -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 diff --git a/arch/arm/mach-rk30/board-rk30-sdk-wm8326.c b/arch/arm/mach-rk30/board-rk30-sdk-wm8326.c index ce3050e7e6df..fbba1ea0aeb3 100755 --- a/arch/arm/mach-rk30/board-rk30-sdk-wm8326.c +++ b/arch/arm/mach-rk30/board-rk30-sdk-wm8326.c @@ -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 */ diff --git a/arch/arm/mach-rk30/board-rk30-sdk.c b/arch/arm/mach-rk30/board-rk30-sdk.c index 0b27edc772dd..1eaec78a1308 100755 --- a/arch/arm/mach-rk30/board-rk30-sdk.c +++ b/arch/arm/mach-rk30/board-rk30-sdk.c @@ -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); } -- 2.34.1