rk30:phone:support pmic tps80032 vbat low detection,support pmic tps80032 early suspend
author张晴 <zhangqing@rock-chips.com>
Mon, 9 Jul 2012 01:49:32 +0000 (09:49 +0800)
committer张晴 <zhangqing@rock-chips.com>
Mon, 9 Jul 2012 01:49:32 +0000 (09:49 +0800)
arch/arm/mach-rk30/board-rk30-phone-twl60xx.c
drivers/mfd/twl-core.c
drivers/mfd/twl6030-irq.c
drivers/power/Kconfig

index ea28129bfe280959941abef46de46e3bccb67c6f..913055c06c784958d842810664ec2a3b83f3c4f0 100755 (executable)
@@ -737,6 +737,27 @@ static struct twl4030_power_data tps80032_scripts_data __initdata = {
        .resource_config = twl4030_rconfig,
 };
 
+#ifdef CONFIG_HAS_EARLYSUSPEND
+void twl60xx_pmu_early_suspend(struct regulator_dev *rdev)
+{
+       printk("%s\n", __func__);
+       
+       twl_reg_write(0x06,TWL_MODULE_PIH, 0x00);
+}
+void twl60xx_pmu_early_resume(struct regulator_dev *rdev)
+{
+       printk("%s\n", __func__);
+
+       twl_reg_write(0x06,TWL_MODULE_PIH, 0x04);
+}
+#else
+void twl60xx_pmu_early_suspend(struct regulator_dev *rdev)
+{
+}
+void twl60xx_pmu_early_resume(struct regulator_dev *rdev)
+{
+}
+#endif
 
 void __sramfunc board_pmu_suspend(void)
 {      
index d6187db14aa29058ed50f6231d01f1757c2d973f..3dedd5a0df152fe42f91aa2f9da9ca8a21fdd2e4 100755 (executable)
 #include <linux/i2c/twl.h>
 #include "twl-core.h"
 
+#include <linux/earlysuspend.h>
+#ifdef CONFIG_HAS_EARLYSUSPEND
+static struct early_suspend twl60xx_early_suspend;
+#endif
+
 #if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
 #include <plat/cpu.h>
 #endif
@@ -1381,6 +1386,9 @@ static int __devexit twl_remove(struct i2c_client *client)
 }
 
 /* NOTE:  this driver only handles a single twl4030/tps659x0 chip */
+__weak void  twl60xx_pmu_early_suspend(struct regulator_dev *rdev) {}
+__weak void  twl60xx_pmu_early_resume(struct regulator_dev *rdev) {}
+
 static int __devinit
 twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {
@@ -1508,6 +1516,13 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
                        printk(" tps80032 set_init() failed\n");
                }
        }
+       #ifdef CONFIG_HAS_EARLYSUSPEND
+       twl60xx_early_suspend.level = 0xffff;
+    twl60xx_early_suspend.suspend = twl60xx_pmu_early_suspend;
+    twl60xx_early_suspend.resume = twl60xx_pmu_early_resume;
+    register_early_suspend(&twl60xx_early_suspend);
+       #endif
+
        
 fail:
        if (status < 0)
index 05c4b478052f3f2e795aff47ce455c08c3722982..59e2ea63e1886422b9e756cc24631690ef6cd5d7 100755 (executable)
@@ -42,6 +42,7 @@
 
 #include "twl-core.h"
 
+#include <mach/board.h>
 /*
  * TWL6030 (unlike its predecessors, which had two level interrupt handling)
  * three interrupt registers INT_STS_A, INT_STS_B and INT_STS_C.
@@ -265,9 +266,11 @@ static irqreturn_t handle_twl6030_pih(int irq, void *devid)
  */
 static irqreturn_t handle_twl6030_vlow(int irq, void *unused)
 {
+#ifdef CONFIG_TWL60xx_VBAT_LOW_DETECTION
+       rk28_send_wakeup_key();
+#else
        pr_err("twl6030: BAT_VLOW interrupt; threshold=%dmV\n",
               2300 + (vbatmin_hi_threshold - 0b110) * 50);
-
 #if 1 /* temporary */
        pr_err("%s: disabling BAT_VLOW interrupt\n", __func__);
        disable_irq_nosync(twl6030_irq_base + TWL_VLOW_INTR_OFFSET);
@@ -275,6 +278,7 @@ static irqreturn_t handle_twl6030_vlow(int irq, void *unused)
 #else
        pr_emerg("handle_twl6030_vlow: kernel_power_off()\n");
        kernel_power_off();
+#endif
 #endif
        return IRQ_HANDLED;
 }
index 9ba570d708a45138a4cf446b5811277d56c82d11..acd40a735dabec595d4979d1d401d940df4cc2ac 100755 (executable)
@@ -342,4 +342,8 @@ config WM8326_VBAT_LOW_DETECTION
        tristate "Support for WM8326 battery voltage detection."
        default n
 
+config TWL60xx_VBAT_LOW_DETECTION
+       tristate "Support for twl60xx low battery detection."
+       default n
+
 endif # POWER_SUPPLY