From: 张晴 Date: Thu, 27 Dec 2012 02:52:41 +0000 (+0800) Subject: rk3168:act8846:support pmic shut down and early suspend X-Git-Tag: firefly_0821_release~8058 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5410736e6ab1c37c2061df72002aa2b006d3c3c9;p=firefly-linux-kernel-4.4.55.git rk3168:act8846:support pmic shut down and early suspend --- diff --git a/arch/arm/mach-rk30/board-rk3168-tb.c b/arch/arm/mach-rk30/board-rk3168-tb.c index 762450bf2e09..ced11193d5bb 100755 --- a/arch/arm/mach-rk30/board-rk3168-tb.c +++ b/arch/arm/mach-rk30/board-rk3168-tb.c @@ -1894,11 +1894,28 @@ struct rk29_keys_platform_data rk29_keys_pdata = { static void rk30_pm_power_off(void) { printk(KERN_ERR "rk30_pm_power_off start...\n"); + #if defined(CONFIG_MFD_WM831X) + if(pmic_is_wm8326()){ + wm831x_set_bits(Wm831x,WM831X_GPIO_LEVEL,0x0001,0x0000); //set sys_pwr 0 + wm831x_device_shutdown(Wm831x);//wm8326 shutdown + } + #endif + + #if defined(CONFIG_REGULATOR_ACT8846) + if(pmic_is_act8846()) + { + act8846_device_shutdown(); + } + #endif + + #if defined(CONFIG_MFD_TPS65910) + if(pmic_is_tps65910()) + { + tps65910_device_shutdown();//tps65910 shutdown + } + #endif + 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 while (1); } diff --git a/drivers/regulator/act8846.c b/drivers/regulator/act8846.c index 2c4da0dbfafe..9dbab96a3609 100755 --- a/drivers/regulator/act8846.c +++ b/drivers/regulator/act8846.c @@ -21,6 +21,10 @@ #include #include #include +#ifdef CONFIG_HAS_EARLYSUSPEND +#include +#endif + #if 0 #define DBG(x...) printk(KERN_INFO x) @@ -40,8 +44,11 @@ struct act8846 { struct i2c_client *i2c; int num_regulators; struct regulator_dev **rdev; + struct early_suspend act8846_suspend; }; +struct act8846 *g_act8846; + static u8 act8846_reg_read(struct act8846 *act8846, u8 reg); static int act8846_set_bits(struct act8846 *act8846, u8 reg, u16 mask, u16 val); @@ -661,6 +668,31 @@ error: return err; } + +int act8846_device_shutdown(void) +{ + int ret; + int err = -1; + struct act8846 *act8846 = g_act8846; + + printk("%s\n",__func__); + + ret = act8846_reg_read(act8846,0xc3); + ret = act8846_set_bits(act8846, 0xc3,(0x1<<3),(0x1<<3)); + ret = act8846_set_bits(act8846, 0xc3,(0x1<<4),(0x1<<4)); + if (ret < 0) { + printk("act8846 set 0xc3 error!\n"); + return err; + } + return 0; +} +EXPORT_SYMBOL_GPL(act8846_device_shutdown); + +#ifdef CONFIG_HAS_EARLYSUSPEND +__weak void act8846_early_suspend(struct early_suspend *h) {} +__weak void act8846_late_resume(struct early_suspend *h) {} +#endif + static int __devinit act8846_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct act8846 *act8846; @@ -688,9 +720,17 @@ static int __devinit act8846_i2c_probe(struct i2c_client *i2c, const struct i2c_ goto err; } else dev_warn(act8846->dev, "No platform init data supplied\n"); - + + g_act8846 = act8846; pdata->set_init(act8846); + #ifdef CONFIG_HAS_EARLYSUSPEND + act8846->act8846_suspend.suspend = act8846_early_suspend, + act8846->act8846_suspend.resume = act8846_late_resume, + act8846->act8846_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB + 1, + register_early_suspend(&act8846->act8846_suspend); + #endif + return 0; err: diff --git a/include/linux/regulator/act8846.h b/include/linux/regulator/act8846.h index 8e8bbd5f84de..9914372b3297 100755 --- a/include/linux/regulator/act8846.h +++ b/include/linux/regulator/act8846.h @@ -27,6 +27,8 @@ #define act8846_NUM_REGULATORS 13 struct act8846; +int act8846_device_shutdown(void); + struct act8846_regulator_subdev { int id; struct regulator_init_data *initdata;