From patchwork Thu Sep 27 20:08:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11799 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 132AC24140 for ; Thu, 27 Sep 2012 20:09:54 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id B97E0A18351 for ; Thu, 27 Sep 2012 20:09:53 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so5234801iej.11 for ; Thu, 27 Sep 2012 13:09:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=040Fex2B/Uf/zdzFCVYpFiXGxr7hSlZjW9236U1LYLQ=; b=g4cFeuRAjwQZDiS2yHQLZGbRmgc3iblxMvGjNV2+EDjA+c5IH9LLn6CSgqDzMwqGn+ c3h5eCsH8CXqzDCBr1+/du3/ljnqClyCZI35WOi0BAEvKodCREhnhv+N7yHR2NS2spf5 Kf898uYcj0NWHo+X22xgccRxn+YUarMQsKu8GjdSh2C1CPit9+kdI8QqwlnoIzCtastf AP9p7eBOitRg9Pc/iINCUS9yGZb1R2H+Q36ZvuURKFqaT8d0vXrPgyH7OgRC3ahGptHs EybYlW+zF0jDI1Y3B1nFeTYOpC23oh7MXvaR4wZNahwtp7x/E1oxfGFX4fiYJIMqA5jv ERbA== Received: by 10.50.217.227 with SMTP id pb3mr15358472igc.28.1348776593535; Thu, 27 Sep 2012 13:09:53 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp436322igc; Thu, 27 Sep 2012 13:09:53 -0700 (PDT) Received: by 10.68.195.195 with SMTP id ig3mr14662367pbc.108.1348776593047; Thu, 27 Sep 2012 13:09:53 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id pi9si5467641pbb.12.2012.09.27.13.09.52 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 13:09:53 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of mathieu.poirier@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of mathieu.poirier@linaro.org) smtp.mail=mathieu.poirier@linaro.org Received: by mail-pb0-f50.google.com with SMTP id md4so1686045pbc.37 for ; Thu, 27 Sep 2012 13:09:52 -0700 (PDT) Received: by 10.66.75.168 with SMTP id d8mr12163672paw.63.1348776592758; Thu, 27 Sep 2012 13:09:52 -0700 (PDT) Received: from localhost.localdomain (S0106002369de4dac.cg.shawcable.net. [70.73.24.112]) by mx.google.com with ESMTPS id sa2sm1587890pbc.4.2012.09.27.13.09.51 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 13:09:52 -0700 (PDT) From: mathieu.poirier@linaro.org To: patches@linaro.org Subject: [PATCH 26/57] power: charge: update watchdog for pm2xxx support Date: Thu, 27 Sep 2012 14:08:43 -0600 Message-Id: <1348776554-10019-27-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1348776554-10019-1-git-send-email-mathieu.poirier@linaro.org> References: <1348776554-10019-1-git-send-email-mathieu.poirier@linaro.org> X-Gm-Message-State: ALoCoQncwtwXdG25x3J5JlyL0qjK5S5cWGCIFLJwAHdyBzFdhpDbYs8jm8Y+r3BxecwFp5jtZ+8N From: Loic Pallardy 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 Signed-off-by: Loic Pallardy Signed-off-by: Mathieu Poirier Reviewed-by: Michel JAOUEN Reviewed-by: Marcus COOPER Reviewed-by: Jonas ABERG --- drivers/power/ab8500_charger.c | 6 ++++++ drivers/power/abx500_chargalg.c | 23 +++++++++++++++++++++-- include/linux/mfd/abx500/ux500_chargalg.h | 3 +++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c index 3100f11..4129599 100644 --- a/drivers/power/ab8500_charger.c +++ b/drivers/power/ab8500_charger.c @@ -90,6 +90,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, @@ -2945,7 +2947,9 @@ static int __devinit 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 */ @@ -2964,7 +2968,9 @@ static int __devinit 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 = diff --git a/drivers/power/abx500_chargalg.c b/drivers/power/abx500_chargalg.c index ca87cb2..d3efc2a 100644 --- a/drivers/power/abx500_chargalg.c +++ b/drivers/power/abx500_chargalg.c @@ -453,8 +453,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); @@ -1591,6 +1601,8 @@ static void abx500_chargalg_periodic_work(struct work_struct *work) static void abx500_chargalg_wd_work(struct work_struct *work) { int ret; + int refresh_time; + struct abx500_chargalg *di = container_of(work, struct abx500_chargalg, chargalg_wd_work.work); @@ -1600,8 +1612,15 @@ static void abx500_chargalg_wd_work(struct work_struct *work) if (ret < 0) dev_err(di->dev, "failed to kick watchdog\n"); + if (di->chg_info.online_chg & AC_CHG) + refresh_time = di->ac_chg->wdt_refresh; + else if (di->chg_info.online_chg & USB_CHG) + refresh_time = di->usb_chg->wdt_refresh; + else + refresh_time = CHG_WD_INTERVAL; + queue_delayed_work(di->chargalg_wq, - &di->chargalg_wd_work, CHG_WD_INTERVAL); + &di->chargalg_wd_work, refresh_time); } /** diff --git a/include/linux/mfd/abx500/ux500_chargalg.h b/include/linux/mfd/abx500/ux500_chargalg.h index 5b77a61..d43ac0f 100644 --- a/include/linux/mfd/abx500/ux500_chargalg.h +++ b/include/linux/mfd/abx500/ux500_chargalg.h @@ -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