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,
Hakan Berg <hakan.berg@stericsson.com>,
Lee Jones <lee.jones@linaro.org>
Subject: [PATCH 18/40] ab8500-charger: Add AB8505_USB_LINK_STATUS
Date: Fri, 15 Feb 2013 12:44:48 +0000 [thread overview]
Message-ID: <1360932310-30065-19-git-send-email-lee.jones@linaro.org> (raw)
In-Reply-To: <1360932310-30065-1-git-send-email-lee.jones@linaro.org>
From: Hakan Berg <hakan.berg@stericsson.com>
The AB8505 does not have the same address for USB link-status
as has ab8500. Add AB8505_USB_LINK_STATUS and code to switch
to correct constant.
Signed-off-by: Hakan Berg <hakan.berg@stericsson.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Reviewed-by: Mian Yousaf KAUKAB <mian.yousaf.kaukab@stericsson.com>
Reviewed-by: Marcus COOPER <marcus.xm.cooper@stericsson.com>
Reviewed-by: Rabin VINCENT <rabin.vincent@stericsson.com>
---
drivers/power/ab8500_charger.c | 43 ++++++++++++++++++++++++++++++++--------
1 file changed, 35 insertions(+), 8 deletions(-)
diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c
index 547f6ea..b5c7a39 100644
--- a/drivers/power/ab8500_charger.c
+++ b/drivers/power/ab8500_charger.c
@@ -80,6 +80,7 @@
/* UsbLineStatus register bit masks */
#define AB8500_USB_LINK_STATUS 0x78
+#define AB8505_USB_LINK_STATUS 0xF8
#define AB8500_STD_HOST_SUSP 0x18
/* Watchdog timeout constant */
@@ -809,10 +810,12 @@ static int ab8500_charger_read_usb_type(struct ab8500_charger *di)
if (is_ab8500(di->parent)) {
ret = abx500_get_register_interruptible(di->dev, AB8500_USB,
AB8500_USB_LINE_STAT_REG, &val);
- } else {
- if (is_ab9540(di->parent) || is_ab8505(di->parent))
+ } else if (is_ab9540(di->parent) || is_ab8505(di->parent)) {
ret = abx500_get_register_interruptible(di->dev,
AB8500_USB, AB8500_USB_LINK1_STAT_REG, &val);
+ } else {
+ dev_err(di->dev, "%s unsupported analog baseband\n", __func__);
+ return -ENXIO;
}
if (ret < 0) {
dev_err(di->dev, "%s ab8500 read failed\n", __func__);
@@ -820,7 +823,14 @@ static int ab8500_charger_read_usb_type(struct ab8500_charger *di)
}
/* get the USB type */
- val = (val & AB8500_USB_LINK_STATUS) >> 3;
+ if (is_ab8500(di->parent)) {
+ val = (val & AB8500_USB_LINK_STATUS) >> 3;
+ } else if (is_ab9540(di->parent) || is_ab8505(di->parent)) {
+ val = (val & AB8505_USB_LINK_STATUS) >> 3;
+ } else {
+ dev_err(di->dev, "%s unsupported analog baseband\n", __func__);
+ return -ENXIO;
+ }
ret = ab8500_charger_max_usb_curr(di,
(enum ab8500_charger_link_status) val);
@@ -856,12 +866,16 @@ static int ab8500_charger_detect_usb_type(struct ab8500_charger *di)
return ret;
}
- if (is_ab8500(di->parent))
+ if (is_ab8500(di->parent)) {
ret = abx500_get_register_interruptible(di->dev,
AB8500_USB, AB8500_USB_LINE_STAT_REG, &val);
- else
+ } else if (is_ab9540(di->parent) || is_ab8505(di->parent)) {
ret = abx500_get_register_interruptible(di->dev,
AB8500_USB, AB8500_USB_LINK1_STAT_REG, &val);
+ } else {
+ dev_err(di->dev, "%s unsupported analog baseband\n", __func__);
+ return -ENXIO;
+ }
if (ret < 0) {
dev_err(di->dev, "%s ab8500 read failed\n", __func__);
return ret;
@@ -875,7 +889,14 @@ static int ab8500_charger_detect_usb_type(struct ab8500_charger *di)
*/
/* get the USB type */
- val = (val & AB8500_USB_LINK_STATUS) >> 3;
+ if (is_ab8500(di->parent)) {
+ val = (val & AB8500_USB_LINK_STATUS) >> 3;
+ } else if (is_ab9540(di->parent) || is_ab8505(di->parent)) {
+ val = (val & AB8505_USB_LINK_STATUS) >> 3;
+ } else {
+ dev_err(di->dev, "%s unsupported analog baseband\n", __func__);
+ return -ENXIO;
+ }
if (val)
break;
}
@@ -2287,6 +2308,7 @@ static void ab8500_charger_usb_link_status_work(struct work_struct *work)
int detected_chargers;
int ret;
u8 val;
+ u8 link_status;
struct ab8500_charger *di = container_of(work,
struct ab8500_charger, usb_link_status_work);
@@ -2313,8 +2335,13 @@ static void ab8500_charger_usb_link_status_work(struct work_struct *work)
else
dev_dbg(di->dev, "Error reading USB link status\n");
+ if (is_ab9540(di->parent) || is_ab8505(di->parent))
+ link_status = AB8505_USB_LINK_STATUS;
+ else
+ link_status = AB8500_USB_LINK_STATUS;
+
if (detected_chargers & USB_PW_CONN) {
- if (((val & AB8500_USB_LINK_STATUS) >> 3) == USB_STAT_NOT_VALID_LINK &&
+ if (((val & link_status) >> 3) == USB_STAT_NOT_VALID_LINK &&
di->invalid_charger_detect_state == 0) {
dev_dbg(di->dev, "Invalid charger detected, state= 0\n");
/*Enable charger*/
@@ -2337,7 +2364,7 @@ static void ab8500_charger_usb_link_status_work(struct work_struct *work)
ret = abx500_get_register_interruptible(di->dev, AB8500_USB,
AB8500_USB_LINE_STAT_REG, &val);
dev_dbg(di->dev, "USB link status= 0x%02x\n",
- (val & AB8500_USB_LINK_STATUS) >> 3);
+ (val & link_status) >> 3);
di->invalid_charger_detect_state = 2;
}
} else {
--
1.7.10.4
next prev parent reply other threads:[~2013-02-15 12:53 UTC|newest]
Thread overview: 44+ 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 ` [PATCH 01/40] mfd: Differentiate between newly added abx500 based platforms 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 ` [PATCH 03/40] abx500-chargalg: Store the AB8500 MFD parent device for platform differentiation 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 ` [PATCH 05/40] ab8500-fg: Report unscaled capacity Lee Jones
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 ` [PATCH 08/40] ab8500-bm: Quick re-attach charging behaviour 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 ` [PATCH 10/40] ab8500-bm: Charge only mode fixes for " Lee Jones
2013-02-15 12:44 ` [PATCH 11/40] pm2301-charger: Force main charger detect 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 ` [PATCH 13/40] ab8500_charger: Prevent auto drop of VBUS Lee Jones
2013-02-15 12:44 ` [PATCH 14/40] pm2301-charger: Die temp thermal protection 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 ` [PATCH 16/40] ab8500-btemp: Filter btemp readings 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 [this message]
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 ` [PATCH 20/40] ab8500-bm: Add usb power path support Lee Jones
2013-02-15 12:44 ` [PATCH 21/40] ab8500-btemp: Defer btemp filtering while initialising 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 ` [PATCH 23/40] ab8500-charger: Use USBLink1Status Register 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 ` [PATCH 25/40] ab8500-chargalg: Use hrtimer Lee Jones
2013-02-15 12:44 ` [PATCH 26/40] ab8500-charger: Add UsbLineCtrl2 reference Lee Jones
2013-02-15 12:44 ` [PATCH 27/40] pm2301-charger: Adjust interrupt handler behavior 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 ` [PATCH 29/40] ab8500-charger: Run detect workaround only on AB8500 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 ` [PATCH 31/40] abx500-chargalg: Use module_platform_driver() rather Lee Jones
2013-02-15 12:45 ` [PATCH 32/40] ab8500-charger: Remove duplicate code 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 ` [PATCH 34/40] pm2301-charger: Charging LED control for pm2301 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 ` [PATCH 36/40] pm2301-charger: Wake device on register access Lee Jones
2013-02-15 12:45 ` [PATCH 37/40] pm2301-charger: Reference put missing after access Lee Jones
2013-02-15 12:45 ` [PATCH 38/40] abx500-chargalg: Add charging current step interface Lee Jones
2013-02-15 12:45 ` [PATCH 39/40] ab8500-fg: Change current calculation Lee Jones
2013-02-15 12:45 ` [PATCH 40/40] ab8500-charger: Do not use [delayed_]work_pending() Lee Jones
2013-03-02 23:33 ` [PATCH 00/40] Power: AB8500: Internal development push Anton Vorontsov
2013-03-04 10:08 ` Samuel Ortiz
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-19-git-send-email-lee.jones@linaro.org \
--to=lee.jones@linaro.org \
--cc=arnd@arndb.de \
--cc=cbouatmailru@gmail.com \
--cc=hakan.berg@stericsson.com \
--cc=linus.walleij@stericsson.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sameo@linux.intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®