From patchwork Fri Feb 15 12:44:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 14863 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 EFD0F23E2E for ; Fri, 15 Feb 2013 12:46:23 +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 99154A18715 for ; Fri, 15 Feb 2013 12:46:23 +0000 (UTC) Received: by mail-ve0-f173.google.com with SMTP id oz10so3013231veb.18 for ; Fri, 15 Feb 2013 04:46:23 -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=eB738sHSozhTRWysP/q8ZrBNcZvOpKDPsdJPNaNHUV4=; b=Rm4c9jAD5peRZzJToEZd4DLzbZoVdJIYCb6fKdhFh19OzhrBZCQvJfJuQuhOT+/nan ifh2CklwZnBKRGUubtXAb+sMwmDvZukPD0bY/iOCXGaDnGNvZI8Pyvy3Cs0AT5i1xdiQ Yka9H28zZYREVajTPlDvCMmrFxqyXb2WyNXFE5UHqIK3jS8QpOFyCPZfT5QfOuFlCR9f emCpCuwNxQoDpzw/CdKC4Tj69YQWUkR0OovNbDmImpsqJRwjwHq0FALIfH+o+yygxQGn o7wBwTGZg42v8uMDZwFDCN4SjDlgnzZMKIuguowFvF6UL5p8FMv3j/3vemu+cfYRuav7 sWGQ== X-Received: by 10.52.175.66 with SMTP id by2mr2631775vdc.53.1360932383044; Fri, 15 Feb 2013 04:46:23 -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 oa5csp10862vcb; Fri, 15 Feb 2013 04:46:22 -0800 (PST) X-Received: by 10.194.76.37 with SMTP id h5mr4044845wjw.21.1360932382202; Fri, 15 Feb 2013 04:46:22 -0800 (PST) Received: from mail-we0-x235.google.com ([2a00:1450:400c:c03::235]) by mx.google.com with ESMTPS id y7si1051392wiv.3.2013.02.15.04.46.21 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 Feb 2013 04:46:22 -0800 (PST) Received-SPF: neutral (google.com: 2a00:1450:400c:c03::235 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=2a00:1450:400c:c03::235; Authentication-Results: mx.google.com; spf=neutral (google.com: 2a00:1450:400c:c03::235 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-we0-f181.google.com with SMTP id t44so2844254wey.40 for ; Fri, 15 Feb 2013 04:46:21 -0800 (PST) X-Received: by 10.180.79.104 with SMTP id i8mr3834964wix.24.1360932381689; Fri, 15 Feb 2013 04:46:21 -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.46.19 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 Feb 2013 04:46:20 -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, Hakan Berg , Lee Jones Subject: [PATCH 18/40] ab8500-charger: Add AB8505_USB_LINK_STATUS Date: Fri, 15 Feb 2013 12:44:48 +0000 Message-Id: <1360932310-30065-19-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: ALoCoQmyT62ujTRWZ8zoE7hD6MGu9Q3zFAPADTMIl8PnlM/dlEDCapApLspmazz4rk1PjArAkLdN From: Hakan Berg 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 Signed-off-by: Lee Jones Reviewed-by: Mian Yousaf KAUKAB Reviewed-by: Marcus COOPER Reviewed-by: Rabin VINCENT --- 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 {