From patchwork Fri Feb 15 12:44:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 14851 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 EFAB223E2E for ; Fri, 15 Feb 2013 12:45:59 +0000 (UTC) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by fiordland.canonical.com (Postfix) with ESMTP id 910DBA197C1 for ; Fri, 15 Feb 2013 12:45:59 +0000 (UTC) Received: by mail-ve0-f171.google.com with SMTP id b10so2949853vea.16 for ; Fri, 15 Feb 2013 04:45:59 -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=BVy4pBtsdkr5SSEvdgzJ5RAFfYXawXdpgKrtmwkxK6c=; b=hHWUWjnFhFUK1wK6UqoZNGVfGdtMOvf4ZBfuWDJTLfU5GOIYBQHCmOiXYhHntRvaoP jww8nOjENiU5lwG5/tqJ7HNy2eY46xM6Nx9uRztJKtKCQOtXg2E3WOvvKyFnQzzV28GT s4tLl3dMII5bL/D+C15KlNrYxr9wTS0HxX7iKmrdfydFzre6oW2ARqnnWdvuhR6BG40g cBRZ3owmtZRuWckc7WIRUPvfvajoCb1SogXMHWzNGgfhobuHpg+tAN67CmlQHvhhy9eh sXtyA00EE/LZVrIVU14Ykpmk1so2ZMuf2Q3+TJk4kCZ7dIOm81Ran/czwcdRZ11PMsTT dexw== X-Received: by 10.58.85.134 with SMTP id h6mr3043413vez.18.1360932359042; Fri, 15 Feb 2013 04:45:59 -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 oa5csp10822vcb; Fri, 15 Feb 2013 04:45:58 -0800 (PST) X-Received: by 10.181.13.175 with SMTP id ez15mr5739026wid.8.1360932357632; Fri, 15 Feb 2013 04:45:57 -0800 (PST) Received: from mail-wg0-x229.google.com ([2a00:1450:400c:c00::229]) by mx.google.com with ESMTPS id lt1si6136757wjb.12.2013.02.15.04.45.57 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 Feb 2013 04:45:57 -0800 (PST) Received-SPF: neutral (google.com: 2a00:1450:400c:c00::229 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=2a00:1450:400c:c00::229; Authentication-Results: mx.google.com; spf=neutral (google.com: 2a00:1450:400c:c00::229 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-wg0-f41.google.com with SMTP id ds1so852020wgb.4 for ; Fri, 15 Feb 2013 04:45:57 -0800 (PST) X-Received: by 10.194.57.231 with SMTP id l7mr4077659wjq.9.1360932353794; Fri, 15 Feb 2013 04:45:53 -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.51 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 Feb 2013 04:45:52 -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, Yang QU , Lee Jones Subject: [PATCH 06/40] ab8500-charger: Add backup battery charge voltages on the ab8540 Date: Fri, 15 Feb 2013 12:44:36 +0000 Message-Id: <1360932310-30065-7-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: ALoCoQnU4va9MFBEak51vQMV+A6vyLavjScFqfJiDFpXg0AszkwvO+z2aUSVCzbXcK1XtFIOFGvC From: Yang QU Add 2.7v, 2.9v, 3.0v, 3.2v and 3.3v charging voltages for backup battery. Before that only 2.5v, 2.6v, 2.8v, 3.1v were available. Signed-off-by: Yang QU Signed-off-by: Lee Jones Reviewed-by: Maxime COQUELIN Reviewed-by: Marcus COOPER Tested-by: Xiao Mei ZHANG --- drivers/power/ab8500_charger.c | 19 +++++++++++++++++-- include/linux/mfd/abx500/ab8500-bm.h | 24 ++++++++++++++++++++---- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c index 24b30b7..fd3fa2b 100644 --- a/drivers/power/ab8500_charger.c +++ b/drivers/power/ab8500_charger.c @@ -2836,6 +2836,7 @@ static int ab8500_charger_usb_get_property(struct power_supply *psy, static int ab8500_charger_init_hw_registers(struct ab8500_charger *di) { int ret = 0; + u8 bup_vch_range = 0, vbup33_vrtcn = 0; /* Setup maximum charger current and voltage for ABB cut2.0 */ if (!is_ab8500_1p1_or_earlier(di->parent)) { @@ -2945,15 +2946,29 @@ static int ab8500_charger_init_hw_registers(struct ab8500_charger *di) } /* Backup battery voltage and current */ + if (di->bm->bkup_bat_v > BUP_VCH_SEL_3P1V) + bup_vch_range = BUP_VCH_RANGE; + if (di->bm->bkup_bat_v == BUP_VCH_SEL_3P3V) + vbup33_vrtcn = VBUP33_VRTCN; + ret = abx500_set_register_interruptible(di->dev, AB8500_RTC, AB8500_RTC_BACKUP_CHG_REG, - di->bm->bkup_bat_v | - di->bm->bkup_bat_i); + (di->bm->bkup_bat_v & 0x3) | di->bm->bkup_bat_i); if (ret) { dev_err(di->dev, "failed to setup backup battery charging\n"); goto out; } + if (is_ab8540(di->parent)) { + ret = abx500_set_register_interruptible(di->dev, + AB8500_RTC, + AB8500_RTC_CTRL1_REG, + bup_vch_range | vbup33_vrtcn); + if (ret) { + dev_err(di->dev, "failed to setup backup battery charging\n"); + goto out; + } + } /* Enable backup battery charging */ abx500_mask_and_set_register_interruptible(di->dev, diff --git a/include/linux/mfd/abx500/ab8500-bm.h b/include/linux/mfd/abx500/ab8500-bm.h index ff2ac0b..95bdef7 100644 --- a/include/linux/mfd/abx500/ab8500-bm.h +++ b/include/linux/mfd/abx500/ab8500-bm.h @@ -105,6 +105,7 @@ #define AB8500_RTC_BACKUP_CHG_REG 0x0C #define AB8500_RTC_CC_CONF_REG 0x01 #define AB8500_RTC_CTRL_REG 0x0B +#define AB8500_RTC_CTRL1_REG 0x11 /* * OTP register offsets @@ -179,10 +180,25 @@ #define BUP_ICH_SEL_300UA 0x08 #define BUP_ICH_SEL_700UA 0x0C -#define BUP_VCH_SEL_2P5V 0x00 -#define BUP_VCH_SEL_2P6V 0x01 -#define BUP_VCH_SEL_2P8V 0x02 -#define BUP_VCH_SEL_3P1V 0x03 +enum bup_vch_sel { + BUP_VCH_SEL_2P5V, + BUP_VCH_SEL_2P6V, + BUP_VCH_SEL_2P8V, + BUP_VCH_SEL_3P1V, + /* + * Note that the following 5 values 2.7v, 2.9v, 3.0v, 3.2v, 3.3v + * are only available on ab8540. You can't choose these 5 + * voltage on ab8500/ab8505/ab9540. + */ + BUP_VCH_SEL_2P7V, + BUP_VCH_SEL_2P9V, + BUP_VCH_SEL_3P0V, + BUP_VCH_SEL_3P2V, + BUP_VCH_SEL_3P3V, +}; + +#define BUP_VCH_RANGE 0x02 +#define VBUP33_VRTCN 0x01 /* Battery OVV constants */ #define BATT_OVV_ENA 0x02