All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
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 <yang.qu@stericsson.com>,
	Lee Jones <lee.jones@linaro.org>
Subject: [PATCH 06/40] ab8500-charger: Add backup battery charge voltages on the ab8540
Date: Fri, 15 Feb 2013 12:44:36 +0000	[thread overview]
Message-ID: <1360932310-30065-7-git-send-email-lee.jones@linaro.org> (raw)
In-Reply-To: <1360932310-30065-1-git-send-email-lee.jones@linaro.org>

From: Yang QU <yang.qu@stericsson.com>

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 <yang.qu@stericsson.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Reviewed-by: Maxime COQUELIN <maxime.coquelin@stericsson.com>
Reviewed-by: Marcus COOPER <marcus.xm.cooper@stericsson.com>
Tested-by: Xiao Mei ZHANG <xiaomei.zhang@stericsson.com>
---
 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
-- 
1.7.10.4


WARNING: multiple messages have this Message-ID (diff)
From: lee.jones@linaro.org (Lee Jones)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 06/40] ab8500-charger: Add backup battery charge voltages on the ab8540
Date: Fri, 15 Feb 2013 12:44:36 +0000	[thread overview]
Message-ID: <1360932310-30065-7-git-send-email-lee.jones@linaro.org> (raw)
In-Reply-To: <1360932310-30065-1-git-send-email-lee.jones@linaro.org>

From: Yang QU <yang.qu@stericsson.com>

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 <yang.qu@stericsson.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Reviewed-by: Maxime COQUELIN <maxime.coquelin@stericsson.com>
Reviewed-by: Marcus COOPER <marcus.xm.cooper@stericsson.com>
Tested-by: Xiao Mei ZHANG <xiaomei.zhang@stericsson.com>
---
 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
-- 
1.7.10.4

  parent reply	other threads:[~2013-02-15 12:46 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-15 12:44 [PATCH 00/40] Power: AB8500: Internal development push Lee Jones
2013-02-15 12:44 ` Lee Jones
2013-02-15 12:44 ` [PATCH 01/40] mfd: Differentiate between newly added abx500 based platforms Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 02/40] pm2301-charger: Enable SW EOC control on the ab9540 Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 03/40] abx500-chargalg: Store the AB8500 MFD parent device for platform differentiation Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 04/40] ab8500-fg: Add power cut feature for ab8505 and ab8540 Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 05/40] ab8500-fg: Report unscaled capacity Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` Lee Jones [this message]
2013-02-15 12:44   ` [PATCH 06/40] ab8500-charger: Add backup battery charge voltages on the ab8540 Lee Jones
2013-02-15 12:44 ` [PATCH 07/40] ab8500-charger: Trivial coding style changes Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 08/40] ab8500-bm: Quick re-attach charging behaviour Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 09/40] pm2301-charger: Support for over voltage protection on the ab9540 Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 10/40] ab8500-bm: Charge only mode fixes for " Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 11/40] pm2301-charger: Force main charger detect Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 12/40] pm2301-charger: Resolve I2C detection problem on ab9540 Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 13/40] ab8500_charger: Prevent auto drop of VBUS Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 14/40] pm2301-charger: Die temp thermal protection Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 15/40] pm2301-charger: Wake system when ext charger is plugged-in Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 16/40] ab8500-btemp: Filter btemp readings Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 17/40] ab8500-fg: Allow capacity to raise from 1% when charging Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 18/40] ab8500-charger: Add AB8505_USB_LINK_STATUS Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 19/40] pm2301-charger: Always compile the PM2301 Charger driver with AB8500 Battery Mgnt Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 20/40] ab8500-bm: Add usb power path support Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 21/40] ab8500-btemp: Defer btemp filtering while initialising Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 22/40] ab8500-bm: Add support for the new ab8540 platform Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 23/40] ab8500-charger: Use USBLink1Status Register Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 24/40] abx500-chargalg: Prevent the watchdog from being kicked twice Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 25/40] ab8500-chargalg: Use hrtimer Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 26/40] ab8500-charger: Add UsbLineCtrl2 reference Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 27/40] pm2301-charger: Adjust interrupt handler behavior Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 28/40] pm2301-charger: Add pm_runtime_resume & pm_runtime_suspend Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:44 ` [PATCH 29/40] ab8500-charger: Run detect workaround only on AB8500 Lee Jones
2013-02-15 12:44   ` Lee Jones
2013-02-15 12:45 ` [PATCH 30/40] pm2301-charger: Removed unused code from PM2301 driver Lee Jones
2013-02-15 12:45   ` Lee Jones
2013-02-15 12:45 ` [PATCH 31/40] abx500-chargalg: Use module_platform_driver() rather Lee Jones
2013-02-15 12:45   ` Lee Jones
2013-02-15 12:45 ` [PATCH 32/40] ab8500-charger: Remove duplicate code Lee Jones
2013-02-15 12:45   ` Lee Jones
2013-02-15 12:45 ` [PATCH 33/40] pm2301-charger: lpn pin used only in C2C boards Lee Jones
2013-02-15 12:45   ` Lee Jones
2013-02-15 12:45 ` [PATCH 34/40] pm2301-charger: Charging LED control for pm2301 Lee Jones
2013-02-15 12:45   ` Lee Jones
2013-02-15 12:45 ` [PATCH 35/40] ab8500-bm: Trivially fix up some incorrect and out-of-date comments Lee Jones
2013-02-15 12:45   ` Lee Jones
2013-02-15 12:45 ` [PATCH 36/40] pm2301-charger: Wake device on register access Lee Jones
2013-02-15 12:45   ` Lee Jones
2013-02-15 12:45 ` [PATCH 37/40] pm2301-charger: Reference put missing after access Lee Jones
2013-02-15 12:45   ` Lee Jones
2013-02-15 12:45 ` [PATCH 38/40] abx500-chargalg: Add charging current step interface Lee Jones
2013-02-15 12:45   ` Lee Jones
2013-02-15 12:45 ` [PATCH 39/40] ab8500-fg: Change current calculation Lee Jones
2013-02-15 12:45   ` Lee Jones
2013-02-15 12:45 ` [PATCH 40/40] ab8500-charger: Do not use [delayed_]work_pending() Lee Jones
2013-02-15 12:45   ` Lee Jones
2013-03-02 23:33 ` [PATCH 00/40] Power: AB8500: Internal development push Anton Vorontsov
2013-03-02 23:33   ` Anton Vorontsov
2013-03-04 10:08   ` Samuel Ortiz
2013-03-04 10:08     ` Samuel Ortiz
2013-03-04 17:49     ` Anton Vorontsov
2013-03-04 17:49       ` Anton Vorontsov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1360932310-30065-7-git-send-email-lee.jones@linaro.org \
    --to=lee.jones@linaro.org \
    --cc=arnd@arndb.de \
    --cc=cbouatmailru@gmail.com \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sameo@linux.intel.com \
    --cc=yang.qu@stericsson.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.