From patchwork Thu Sep 27 20:09:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11816 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 98CBA24140 for ; Thu, 27 Sep 2012 20:10:20 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 3CEB3A18968 for ; Thu, 27 Sep 2012 20:10:20 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so5234855iej.11 for ; Thu, 27 Sep 2012 13:10:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=Bu9VRWBX+TLifHdMv6wIKtceRitex2wIVX55XmO7Hxo=; b=B6Bne9tmtLtZeiPEUPVV1DHrYmhJq8Od2jOlWBjjn3d4+6U2g6z2GLWX1P758G1Lrl 61CvgCBmfOGs1KbLPaWyVmrthG/NzeuqxbIcEwYy3m8vmrSiMk94BZEzDGv2ktspX85l uZcD5KpbzW2q0dwicZjatWXaOJnzuHE4ysWXBDibNqbBhjqIL1eiPdeWmt1ghAbNIMqz 72HVY8ZFLB5He90v+WVvXPsca1Zxv81ewkG8iNbs7KuuETgcLnxZR4sspHSDZ3wM93fn BTHdgsSWrnyOHq7LvYfnNXmhDaxpu34HPuG4ic/IkjQJdFm9VLfhtCaO2td1xlP9EaUV l0Yw== Received: by 10.42.109.194 with SMTP id m2mr3832234icp.48.1348776620016; Thu, 27 Sep 2012 13:10:20 -0700 (PDT) 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.50.184.232 with SMTP id ex8csp436376igc; Thu, 27 Sep 2012 13:10:19 -0700 (PDT) Received: by 10.66.82.101 with SMTP id h5mr12162737pay.15.1348776619339; Thu, 27 Sep 2012 13:10:19 -0700 (PDT) Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by mx.google.com with ESMTPS id vn9si8390651pbc.17.2012.09.27.13.10.19 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 13:10:19 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.50 is neither permitted nor denied by best guess record for domain of mathieu.poirier@linaro.org) client-ip=209.85.220.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.50 is neither permitted nor denied by best guess record for domain of mathieu.poirier@linaro.org) smtp.mail=mathieu.poirier@linaro.org Received: by mail-pa0-f50.google.com with SMTP id hz11so1847989pad.37 for ; Thu, 27 Sep 2012 13:10:19 -0700 (PDT) Received: by 10.66.72.132 with SMTP id d4mr12145212pav.61.1348776618998; Thu, 27 Sep 2012 13:10:18 -0700 (PDT) Received: from localhost.localdomain (S0106002369de4dac.cg.shawcable.net. [70.73.24.112]) by mx.google.com with ESMTPS id sa2sm1587890pbc.4.2012.09.27.13.10.17 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 13:10:18 -0700 (PDT) From: mathieu.poirier@linaro.org To: patches@linaro.org Subject: [PATCH 43/57] power: charging: Add AB8505_USB_LINK_STATUS Date: Thu, 27 Sep 2012 14:09:00 -0600 Message-Id: <1348776554-10019-44-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1348776554-10019-1-git-send-email-mathieu.poirier@linaro.org> References: <1348776554-10019-1-git-send-email-mathieu.poirier@linaro.org> X-Gm-Message-State: ALoCoQl8avmeBbR1BUNstf5P+gvjZcad8IQhHe8tGCxaDyC6fhzgJO/RayajOsKPaFEnGywDWV/X 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: Mathieu Poirier Reviewed-by: Mian Yousaf KAUKAB Reviewed-by: Marcus COOPER Reviewed-by: Rabin VINCENT --- drivers/power/ab8500_charger.c | 46 ++++++++++++++++++++++++++++++++------- 1 files changed, 37 insertions(+), 9 deletions(-) diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c index 18931e4..9449a33 100644 --- a/drivers/power/ab8500_charger.c +++ b/drivers/power/ab8500_charger.c @@ -77,6 +77,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 */ @@ -801,10 +802,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__); @@ -812,7 +815,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); @@ -848,12 +858,17 @@ 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; @@ -867,7 +882,15 @@ 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; } @@ -2277,6 +2300,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); @@ -2303,9 +2327,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"); @@ -2338,7 +2366,7 @@ static void ab8500_charger_usb_link_status_work(struct work_struct *work) 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 {