From patchwork Fri Feb 15 12:44:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 14847 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 291F123E2E for ; Fri, 15 Feb 2013 12:45:49 +0000 (UTC) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by fiordland.canonical.com (Postfix) with ESMTP id C83CEA1828F for ; Fri, 15 Feb 2013 12:45:48 +0000 (UTC) Received: by mail-ve0-f173.google.com with SMTP id oz10so3002257veb.32 for ; Fri, 15 Feb 2013 04:45:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=20qL9xfGQxKCqYXFmdos3dyl9BPaQbFsyx6IxzjxPdc=; b=OjPUo4Au3X/s0JEKgoeN9Ieaxdius/VbexDCnaajHmOKMWWwSVa58QSbt/UX76Q3ZU vjs3AXmBXf5rCNMvEskvKH2YNnRyrqJa9pLPpxaowogsCYNeQxdwQVNJ0++AMG/B8Zbn bdQcNerGBdjE96Y+AAkXaLBhC2eBPBvx6Wf0h1yXBF4yn461lyGO6BOyWCVzsYtLt5Zi BDxNt3+vThMAZ4wgIZmCGv1lsbyHipRdihR16myzCfWqJvS/cPYaHNSnfqfgAZM9/9iu cYZTpZCpPQWtf9+hDtyBa7xk3ctU4QvGUV0YseFYvozp90Wk74KC+OLfcYNydlqTecB4 LNdQ== X-Received: by 10.58.213.37 with SMTP id np5mr2825478vec.54.1360932348252; Fri, 15 Feb 2013 04:45:48 -0800 (PST) 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.221.4.5 with SMTP id oa5csp10799vcb; Fri, 15 Feb 2013 04:45:45 -0800 (PST) X-Received: by 10.194.119.68 with SMTP id ks4mr3895977wjb.3.1360932345397; Fri, 15 Feb 2013 04:45:45 -0800 (PST) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by mx.google.com with ESMTPS id a10si1815159wjx.69.2013.02.15.04.45.44 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 Feb 2013 04:45:45 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.178 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.212.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.178 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-wi0-f178.google.com with SMTP id o1so1103333wic.5 for ; Fri, 15 Feb 2013 04:45:44 -0800 (PST) X-Received: by 10.180.102.164 with SMTP id fp4mr3923476wib.1.1360932344655; Fri, 15 Feb 2013 04:45:44 -0800 (PST) Received: from localhost.localdomain (cpc34-aztw25-2-0-cust250.18-1.cable.virginmedia.com. [86.16.136.251]) by mx.google.com with ESMTPS id bs6sm5133904wib.4.2013.02.15.04.45.42 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 Feb 2013 04:45:43 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: arnd@arndb.de, linus.walleij@stericsson.com, cbouatmailru@gmail.com, sameo@linux.intel.com, Rajkumar Kasirajan , Lee Jones Subject: [PATCH 02/40] pm2301-charger: Enable SW EOC control on the ab9540 Date: Fri, 15 Feb 2013 12:44:32 +0000 Message-Id: <1360932310-30065-3-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1360932310-30065-1-git-send-email-lee.jones@linaro.org> References: <1360932310-30065-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQlRvVG0qZLfbTxCfI7ntYCKucTITHcor0hbPpLZuBlRadIhN4QpNdo9G9UjLk/18r4z5H52 From: Rajkumar Kasirajan End of charging is managed by SW. Signed-off-by: Rajkumar Kasirajan Signed-off-by: Lee Jones Reviewed-by: Jonas ABERG Tested-by: Jonas ABERG --- drivers/power/pm2301_charger.c | 48 +++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/drivers/power/pm2301_charger.c b/drivers/power/pm2301_charger.c index ed48d75..62a172e 100644 --- a/drivers/power/pm2301_charger.c +++ b/drivers/power/pm2301_charger.c @@ -192,11 +192,22 @@ static int pm2xxx_charging_disable_mngt(struct pm2xxx_charger *pm2) { int ret; + /* Disable SW EOC ctrl */ + ret = pm2xxx_reg_write(pm2, PM2XXX_SW_CTRL_REG, PM2XXX_SWCTRL_HW); + if (ret < 0) { + dev_err(pm2->dev, "%s pm2xxx write failed\n", __func__); + return ret; + } + /* Disable charging */ ret = pm2xxx_reg_write(pm2, PM2XXX_BATT_CTRL_REG2, (PM2XXX_CH_AUTO_RESUME_DIS | PM2XXX_CHARGER_DIS)); + if (ret < 0) { + dev_err(pm2->dev, "%s pm2xxx write failed\n", __func__); + return ret; + } - return ret; + return 0; } static int pm2xxx_charger_batt_therm_mngt(struct pm2xxx_charger *pm2, int val) @@ -245,13 +256,29 @@ static int pm2xxx_charger_wd_exp_mngt(struct pm2xxx_charger *pm2, int val) static int pm2xxx_charger_vbat_lsig_mngt(struct pm2xxx_charger *pm2, int val) { + int ret; + switch (val) { case PM2XXX_INT1_ITVBATLOWR: dev_dbg(pm2->dev, "VBAT grows above VBAT_LOW level\n"); + /* Enable SW EOC ctrl */ + ret = pm2xxx_reg_write(pm2, PM2XXX_SW_CTRL_REG, + PM2XXX_SWCTRL_SW); + if (ret < 0) { + dev_err(pm2->dev, "%s pm2xxx write failed\n", __func__); + return ret; + } break; case PM2XXX_INT1_ITVBATLOWF: dev_dbg(pm2->dev, "VBAT drops below VBAT_LOW level\n"); + /* Disable SW EOC ctrl */ + ret = pm2xxx_reg_write(pm2, PM2XXX_SW_CTRL_REG, + PM2XXX_SWCTRL_HW); + if (ret < 0) { + dev_err(pm2->dev, "%s pm2xxx write failed\n", __func__); + return ret; + } break; default: @@ -322,16 +349,27 @@ static int pm2_int_reg0(void *pm2_data, int val) struct pm2xxx_charger *pm2 = pm2_data; int ret = 0; - if (val & (PM2XXX_INT1_ITVBATLOWR | PM2XXX_INT1_ITVBATLOWF)) { - ret = pm2xxx_charger_vbat_lsig_mngt(pm2, val & - (PM2XXX_INT1_ITVBATLOWR | PM2XXX_INT1_ITVBATLOWF)); + if (val & PM2XXX_INT1_ITVBATLOWR) { + ret = pm2xxx_charger_vbat_lsig_mngt(pm2, + PM2XXX_INT1_ITVBATLOWR); + if (ret < 0) + goto out; + } + + if (val & PM2XXX_INT1_ITVBATLOWF) { + ret = pm2xxx_charger_vbat_lsig_mngt(pm2, + PM2XXX_INT1_ITVBATLOWF); + if (ret < 0) + goto out; } if (val & PM2XXX_INT1_ITVBATDISCONNECT) { ret = pm2xxx_charger_bat_disc_mngt(pm2, PM2XXX_INT1_ITVBATDISCONNECT); + if (ret < 0) + goto out; } - +out: return ret; }