A22:change power off to restart if charging
authorroot <root@lw.(none)>
Tue, 14 Jun 2011 09:55:47 +0000 (17:55 +0800)
committerroot <root@lw.(none)>
Tue, 14 Jun 2011 09:55:47 +0000 (17:55 +0800)
arch/arm/mach-rk29/board-rk29-a22.c [changed mode: 0755->0644]
drivers/mfd/wm831x-core.c [changed mode: 0755->0644]
include/linux/mfd/wm831x/core.h [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index eac9ede..a8fde27
@@ -2994,18 +2994,10 @@ static void __init machine_rk29_init_irq(void)
 }
 
 #define POWER_ON_PIN RK29_PIN4_PA4
-static void rk29_pm_power_off(void)
-{
-       printk(KERN_ERR "rk29_pm_power_off start...\n");
-       gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
-#if defined(CONFIG_MFD_WM831X)
-       wm831x_device_shutdown(gWm831x);
-#endif
-       while (1);
-}
+
 static void rk29_pm_power_restart(void)
 {
-       printk("%s\n",__FUNCTION__);
+       printk("%s,line=%d\n",__FUNCTION__,__LINE__);
        mdelay(2);
 #if defined(CONFIG_MFD_WM831X)
        wm831x_device_restart(gWm831x);
@@ -3013,6 +3005,19 @@ static void rk29_pm_power_restart(void)
 
 }
 
+static void rk29_pm_power_off(void)
+{
+       printk(KERN_ERR "rk29_pm_power_off start...\n");
+       gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
+#if defined(CONFIG_MFD_WM831X)
+       if(wm831x_read_usb(gWm831x))
+       rk29_pm_power_restart();        //if charging then restart
+       else
+       wm831x_device_shutdown(gWm831x);//else shutdown
+#endif
+       while (1);
+}
+
 static void __init machine_rk29_board_init(void)
 {
        rk29_board_iomux_init();
old mode 100755 (executable)
new mode 100644 (file)
index 50e8dfb..1bfd65b
@@ -1817,6 +1817,24 @@ int wm831x_device_shutdown(struct wm831x *wm831x)
 EXPORT_SYMBOL_GPL(wm831x_device_shutdown);
 
 
+int wm831x_read_usb(struct wm831x *wm831x)
+{
+       int ret, usb_chg = 0, wall_chg = 0;
+       
+       ret = wm831x_reg_read(wm831x, WM831X_SYSTEM_STATUS);
+       if (ret < 0)
+               return ret;
+
+       if (ret & WM831X_PWR_USB)
+               usb_chg = 1;
+       if (ret & WM831X_PWR_WALL)
+               wall_chg = 1;
+
+       return ((usb_chg | wall_chg) ? 1 : 0);
+
+}
+
+
 int wm831x_device_restart(struct wm831x *wm831x)
 {
        wm831x_reg_write(wm831x,WM831X_RESET_ID, 0xffff); 
old mode 100755 (executable)
new mode 100644 (file)
index 22a41d1..b702517
@@ -346,6 +346,7 @@ void wm831x_device_exit(struct wm831x *wm831x);
 int wm831x_device_suspend(struct wm831x *wm831x);
 int wm831x_device_resume(struct wm831x *wm831x);
 int wm831x_device_shutdown(struct wm831x *wm831x);
+int wm831x_read_usb(struct wm831x *wm831x);
 int wm831x_device_restart(struct wm831x *wm831x);
 int wm831x_irq_init(struct wm831x *wm831x, int irq);
 void wm831x_irq_exit(struct wm831x *wm831x);