rk2928: act8931: switch charge current when suspend
authorxieyi <xieyi@rock-chips.com>
Tue, 9 Oct 2012 10:36:16 +0000 (18:36 +0800)
committerxieyi <xieyi@rock-chips.com>
Tue, 9 Oct 2012 10:41:53 +0000 (18:41 +0800)
arch/arm/mach-rk2928/board-rk2928-sdk-act8931.c
drivers/regulator/act8931.c

index 6a816138d819287c3b5e893686119f7112e6f969..d495acb3251a944051d79d1a45e61958f4b8de0d 100755 (executable)
@@ -8,12 +8,16 @@
 
 #ifdef CONFIG_REGULATOR_ACT8931
 
+#define ACT8931_CHGSEL_PIN RK2928_PIN1_PA1
+#define ACT8931_CHGSEL_VALUE GPIO_LOW /* Decline to 20% current */
+
 extern int platform_device_register(struct platform_device *pdev);
 
 static int act8931_set_init(struct act8931 *act8931)
 {
        struct regulator *dcdc;
        struct regulator *ldo;
+       int ret;
        printk("%s,line=%d\n", __func__,__LINE__);
 
        g_pmic_type = PMIC_TYPE_ACT8931;
@@ -73,6 +77,10 @@ static int act8931_set_init(struct act8931 *act8931)
        regulator_put(dcdc);
        udelay(100);
        
+       ret = gpio_request(ACT8931_CHGSEL_PIN, "ACT8931_CHGSEL");
+       if (ret != 0)
+               gpio_free(ACT8931_CHGSEL_PIN);
+       gpio_direction_output(ACT8931_CHGSEL_PIN, ACT8931_CHGSEL_VALUE);
 
        printk("%s,line=%d END\n", __func__,__LINE__);
        
@@ -273,9 +281,19 @@ static struct act8931_platform_data act8931_data={
        .set_init=act8931_set_init,
        .num_regulators=7,
        .regulators=act8931_regulator_subdev_id,
-       
 };
 
+#ifdef CONFIG_HAS_EARLYSUSPEND
+void act8931_early_suspend(struct early_suspend *h)
+{
+       gpio_direction_output(ACT8931_CHGSEL_PIN, ACT8931_CHGSEL_VALUE);
+}
+
+void act8931_late_resume(struct early_suspend *h)
+{
+       gpio_direction_output(ACT8931_CHGSEL_PIN, !ACT8931_CHGSEL_VALUE);
+}
+#endif
 
 #endif
 
index 2bc2d429835dbaaf2bd6ddf1b2d2e0328a6e7468..5c7034c9f7178176b9f429148cfa9c7993bfbbef 100755 (executable)
 #include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <plat/board.h>
-
+#ifdef CONFIG_HAS_EARLYSUSPEND
+#include <linux/earlysuspend.h>
+#endif
+  
 #if 0
 #define DBG(x...)      printk(KERN_INFO x)
 #else
@@ -42,6 +45,7 @@ struct act8931 {
        struct i2c_client *i2c;
        int num_regulators;
        struct regulator_dev **rdev;
+       struct early_suspend act8931_suspend;
 };
 
 static u8 act8931_reg_read(struct act8931 *act8931, u8 reg);
@@ -586,6 +590,12 @@ static irqreturn_t act8931_irq_thread(unsigned int irq, void *dev_id)
        rk28_send_wakeup_key();
        return IRQ_HANDLED;
 }
+
+#ifdef CONFIG_HAS_EARLYSUSPEND
+__weak void act8931_early_suspend(struct early_suspend *h) {}
+__weak void act8931_late_resume(struct early_suspend *h) {}
+#endif
+
 static int __devinit act8931_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
 {
        struct act8931 *act8931;        
@@ -657,6 +667,14 @@ static int __devinit act8931_i2c_probe(struct i2c_client *i2c, const struct i2c_
        }       
 
        enable_irq_wake(act8931->irq);
+
+       #ifdef CONFIG_HAS_EARLYSUSPEND
+       act8931->act8931_suspend.suspend = act8931_early_suspend,
+       act8931->act8931_suspend.resume = act8931_late_resume,
+       act8931->act8931_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB + 1,
+       register_early_suspend(&act8931->act8931_suspend);
+       #endif
+
        return 0;
 
 err: