pm2301: Update watchdog for pm2xxx support
authorLoic Pallardy <loic.pallardy@stericsson.com>
Thu, 10 May 2012 13:33:56 +0000 (15:33 +0200)
committerLee Jones <lee.jones@linaro.org>
Wed, 23 Jan 2013 14:39:15 +0000 (14:39 +0000)
AB and PMxxx doesn't have same watchdog refresh period. Add watchdog
to refresh period parameters in x500 charger structure, this should
kick watchdog every 30sec. The AC charging should also kick both
pm2xxx and the AB charger watchdog.

Signed-off-by: Rajkumar Kasirajan <rajkumar.kasirajan@stericsson.com>
Signed-off-by: Loic Pallardy <loic.pallardy@stericsson.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Reviewed-by: Michel JAOUEN <michel.jaouen@stericsson.com>
Reviewed-by: Marcus COOPER <marcus.xm.cooper@stericsson.com>
Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com>
Tested-by: Michel JAOUEN <michel.jaouen@stericsson.com>
Tested-by: Jonas ABERG <jonas.aberg@stericsson.com>
drivers/power/ab8500_charger.c
drivers/power/abx500_chargalg.c
drivers/power/pm2301_charger.c
drivers/power/pm2301_charger.h
include/linux/mfd/abx500/ux500_chargalg.h

index 4c66172aaa64067737284e0912c2cde4de42c892..0483e7cb226850dcbef77c4c316119a2d1b538d6 100644 (file)
@@ -93,6 +93,8 @@
 
 #define CHARGER_STATUS_POLL 10 /* in ms */
 
+#define CHG_WD_INTERVAL                        (60 * HZ)
+
 /* UsbLineStatus register - usb types */
 enum ab8500_charger_link_status {
        USB_STAT_NOT_CONFIGURED,
@@ -2953,7 +2955,9 @@ static int ab8500_charger_probe(struct platform_device *pdev)
                ARRAY_SIZE(ab8500_charger_voltage_map) - 1];
        di->ac_chg.max_out_curr = ab8500_charger_current_map[
                ARRAY_SIZE(ab8500_charger_current_map) - 1];
+       di->ac_chg.wdt_refresh = CHG_WD_INTERVAL;
        di->ac_chg.enabled = di->pdata->ac_enabled;
+       di->ac_chg.external = false;
 
        /* USB supply */
        /* power_supply base class */
@@ -2972,7 +2976,9 @@ static int ab8500_charger_probe(struct platform_device *pdev)
                ARRAY_SIZE(ab8500_charger_voltage_map) - 1];
        di->usb_chg.max_out_curr = ab8500_charger_current_map[
                ARRAY_SIZE(ab8500_charger_current_map) - 1];
+       di->usb_chg.wdt_refresh = CHG_WD_INTERVAL;
        di->usb_chg.enabled = di->pdata->usb_enabled;
+       di->usb_chg.external = false;
 
        /* Create a work queue for the charger */
        di->charger_wq =
index f59bc025ca58be8a6b5fdd094331874bf9d31469..7defb3e91d59f0e7e72c50b38d68640dd585fcbb 100644 (file)
@@ -445,8 +445,18 @@ static int abx500_chargalg_kick_watchdog(struct abx500_chargalg *di)
 {
        /* Check if charger exists and kick watchdog if charging */
        if (di->ac_chg && di->ac_chg->ops.kick_wd &&
-                       di->chg_info.online_chg & AC_CHG)
+           di->chg_info.online_chg & AC_CHG) {
+               /*
+                * If AB charger watchdog expired, pm2xxx charging
+                * gets disabled. To be safe, kick both AB charger watchdog
+                * and pm2xxx watchdog.
+                */
+               if (di->ac_chg->external &&
+                   di->usb_chg && di->usb_chg->ops.kick_wd)
+                       di->usb_chg->ops.kick_wd(di->usb_chg);
+
                return di->ac_chg->ops.kick_wd(di->ac_chg);
+       }
        else if (di->usb_chg && di->usb_chg->ops.kick_wd &&
                        di->chg_info.online_chg & USB_CHG)
                return di->usb_chg->ops.kick_wd(di->usb_chg);
index 085e468d8a2bf33061cd2fa102e9689c27560438..8c1dd5628d16fd7d9f81e9ecf10406170fafd59e 100644 (file)
@@ -875,7 +875,9 @@ static int __devinit pm2xxx_wall_charger_probe(struct i2c_client *i2c_client,
                ARRAY_SIZE(pm2xxx_charger_voltage_map) - 1];
        pm2->ac_chg.max_out_curr = pm2xxx_charger_current_map[
                ARRAY_SIZE(pm2xxx_charger_current_map) - 1];
+       pm2->ac_chg.wdt_refresh = WD_KICK_INTERVAL;
        pm2->ac_chg.enabled = true;
+       pm2->ac_chg.external = true;
 
        /* Create a work queue for the charger */
        pm2->charger_wq =
index da804716aa82389d66dd18e7f2f0fc4a76f94261..3531cc5a9056a7995619f64348077e67b9953cc8 100644 (file)
@@ -32,7 +32,7 @@
 
 /* Watchdog timeout constant */
 #define WD_TIMER                       0x30 /* 4min */
-#define WD_KICK_INTERVAL               (60 * HZ)
+#define WD_KICK_INTERVAL               (30 * HZ)
 
 #define PM2XXX_NUM_INT_REG             0x6
 
index 5b77a610c6b613989e12dff233727ed9f7934355..d43ac0f355263e7ac188d09616fef59476feec03 100644 (file)
@@ -28,13 +28,16 @@ struct ux500_charger_ops {
  * @max_out_volt       maximum output charger voltage in mV
  * @max_out_curr       maximum output charger current in mA
  * @enabled            indicates if this charger is used or not
+ * @external           external charger unit (pm2xxx)
  */
 struct ux500_charger {
        struct power_supply psy;
        struct ux500_charger_ops ops;
        int max_out_volt;
        int max_out_curr;
+       int wdt_refresh;
        bool enabled;
+       bool external;
 };
 
 #endif