rk3168:act8846:support pmic shut down and early suspend
author张晴 <zhangqing@rock-chips.com>
Thu, 27 Dec 2012 02:52:41 +0000 (10:52 +0800)
committer张晴 <zhangqing@rock-chips.com>
Thu, 27 Dec 2012 02:52:41 +0000 (10:52 +0800)
arch/arm/mach-rk30/board-rk3168-tb.c
drivers/regulator/act8846.c
include/linux/regulator/act8846.h

index 762450bf2e09d2e87e1ce27b17cc1ed64f4ab28e..ced11193d5bb155b68e5b8ec9f968a7986f7806b 100755 (executable)
@@ -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);
 }
 
index 2c4da0dbfafe3093eb4d52b0253e9dc09bd571af..9dbab96a36099ea2e17a97746a7474aa1185f7a3 100755 (executable)
 #include <linux/delay.h>
 #include <mach/iomux.h>
 #include <linux/slab.h>
+#ifdef CONFIG_HAS_EARLYSUSPEND
+#include <linux/earlysuspend.h>
+#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:
index 8e8bbd5f84dea410fddb2bc23c14cbfbeb149d14..9914372b329749f286e5b2b57b499356a390090a 100755 (executable)
@@ -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;