From patchwork Fri Jan 11 13:12:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 1966031 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 4C7AB3FF0F for ; Fri, 11 Jan 2013 13:22:11 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TteUs-00048d-WC; Fri, 11 Jan 2013 13:18:12 +0000 Received: from mail-wg0-f47.google.com ([74.125.82.47]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TteQX-0001OF-Hl for linux-arm-kernel@lists.infradead.org; Fri, 11 Jan 2013 13:13:43 +0000 Received: by mail-wg0-f47.google.com with SMTP id dq11so793484wgb.2 for ; Fri, 11 Jan 2013 05:13:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=tROI8M0oqN/pfG31mp+6P64UNiAQBO9NzC7AarGzVDc=; b=at2g+kYUQuoWOTr/j702dowtnPREIYLnlSehaHq8OB1QyVq6zuEuM/3/f4cxta/1Ng neMYyUlXUZNhSjzgkAcDh+pmjyvP7C0RufUzp9r/0p1OIStSuSPivM0EcT2IEw3aWtFw N+x180dPXA2zIDFBg6bIwL/U8ybnMs3sa0DhEsD+FWvfajG3G5DDmmUqajgo61pfsZtB +LvewbAeCLGWuSHFF69V4nQZXQRq74l0uMD/Nq/Nkx8TKADS3zHeM9FB/6TbRyZZUZdo VFCKC0rZnsYWUhJdjMo6zUF0Etb+EeOkyU/doBxtO8hf69VYHCNQFAXF1idfnA1QJpgW 7OGQ== X-Received: by 10.194.57.206 with SMTP id k14mr120458724wjq.26.1357910019103; Fri, 11 Jan 2013 05:13:39 -0800 (PST) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id p2sm7204515wic.7.2013.01.11.05.13.37 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 11 Jan 2013 05:13:38 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/18] power: ab8500_bm: Adds support for Car/Travel Adapters Date: Fri, 11 Jan 2013 13:12:58 +0000 Message-Id: <1357909986-9262-11-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1357909986-9262-1-git-send-email-lee.jones@linaro.org> References: <1357909986-9262-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQnOLay0dciY9/CHAUCS9aZDrZsuOFDtHMiY8UO8S5BCK5XnqSV+3oZsuWmxN0ITStbVpofF X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130111_081341_953219_1C8EDBBA X-CRM114-Status: GOOD ( 19.32 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.47 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linus.walleij@stericsson.com, arnd@arndb.de, Marcus Cooper , Hakan Berg , cbouatmailru@gmail.com, Lee Jones X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Hakan Berg The Travel and Carkit adapter should be handled directly by the charger driver. Signed-off-by: Lee Jones Signed-off-by: Marcus Cooper Reviewed-by: Jonas ABERG --- drivers/power/ab8500_charger.c | 92 +++++++++++++++++++++++++--------- include/linux/mfd/abx500/ab8500-bm.h | 1 + 2 files changed, 69 insertions(+), 24 deletions(-) diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c index 919d156..ff18617 100644 --- a/drivers/power/ab8500_charger.c +++ b/drivers/power/ab8500_charger.c @@ -108,6 +108,18 @@ enum ab8500_charger_link_status { USB_STAT_HM_IDGND, USB_STAT_RESERVED, USB_STAT_NOT_VALID_LINK, + USB_STAT_PHY_EN, + USB_STAT_SUP_NO_IDGND_VBUS, + USB_STAT_SUP_IDGND_VBUS, + USB_STAT_CHARGER_LINE_1, + USB_STAT_CARKIT_1, + USB_STAT_CARKIT_2, + USB_STAT_ACA_DOCK_CHARGER, + USB_STAT_SAMSUNG_USB_PHY_DIS, + USB_STAT_SAMSUNG_USB_PHY_ENA, + USB_STAT_SAMSUNG_UART_PHY_DIS, + USB_STAT_SAMSUNG_UART_PHY_ENA, + USB_STAT_MOTOROLA_USB_PHY_ENA, }; enum ab8500_usb_state { @@ -586,7 +598,7 @@ static int ab8500_charger_detect_chargers(struct ab8500_charger *di) * Returns error code in case of failure else 0 on success */ static int ab8500_charger_max_usb_curr(struct ab8500_charger *di, - enum ab8500_charger_link_status link_status) + enum ab8500_charger_link_status link_status) { int ret = 0; @@ -595,15 +607,19 @@ static int ab8500_charger_max_usb_curr(struct ab8500_charger *di, case USB_STAT_STD_HOST_C_NS: case USB_STAT_STD_HOST_C_S: dev_dbg(di->dev, "USB Type - Standard host is " - "detected through USB driver\n"); + "detected through USB driver\n"); di->max_usb_in_curr = USB_CH_IP_CUR_LVL_0P09; break; case USB_STAT_HOST_CHG_HS_CHIRP: di->max_usb_in_curr = USB_CH_IP_CUR_LVL_0P5; + dev_dbg(di->dev, "USB Type - 0x%02x MaxCurr: %d", link_status, + di->max_usb_in_curr); break; case USB_STAT_HOST_CHG_HS: case USB_STAT_ACA_RID_C_HS: di->max_usb_in_curr = USB_CH_IP_CUR_LVL_0P9; + dev_dbg(di->dev, "USB Type - 0x%02x MaxCurr: %d", link_status, + di->max_usb_in_curr); break; case USB_STAT_ACA_RID_A: /* @@ -611,6 +627,8 @@ static int ab8500_charger_max_usb_curr(struct ab8500_charger *di, * can consume (300mA). Closest level is 1100mA */ di->max_usb_in_curr = USB_CH_IP_CUR_LVL_1P1; + dev_dbg(di->dev, "USB Type - 0x%02x MaxCurr: %d", link_status, + di->max_usb_in_curr); break; case USB_STAT_ACA_RID_B: /* @@ -618,34 +636,50 @@ static int ab8500_charger_max_usb_curr(struct ab8500_charger *di, * 100mA for potential accessory). Closest level is 1300mA */ di->max_usb_in_curr = USB_CH_IP_CUR_LVL_1P3; + dev_dbg(di->dev, "USB Type - 0x%02x MaxCurr: %d", link_status, + di->max_usb_in_curr); break; - case USB_STAT_DEDICATED_CHG: case USB_STAT_HOST_CHG_NM: - case USB_STAT_ACA_RID_C_HS_CHIRP: + case USB_STAT_DEDICATED_CHG: case USB_STAT_ACA_RID_C_NM: + case USB_STAT_ACA_RID_C_HS_CHIRP: di->max_usb_in_curr = USB_CH_IP_CUR_LVL_1P5; - break; - case USB_STAT_RESERVED: - /* - * This state is used to indicate that VBUS has dropped below - * the detection level 4 times in a row. This is due to the - * charger output current is set to high making the charger - * voltage collapse. This have to be propagated through to - * chargalg. This is done using the property - * POWER_SUPPLY_PROP_CURRENT_AVG = 1 - */ - di->flags.vbus_collapse = true; - dev_dbg(di->dev, "USB Type - USB_STAT_RESERVED " - "VBUS has collapsed\n"); - ret = -1; + dev_dbg(di->dev, "USB Type - 0x%02x MaxCurr: %d", link_status, + di->max_usb_in_curr); break; case USB_STAT_HM_IDGND: - case USB_STAT_NOT_CONFIGURED: case USB_STAT_NOT_VALID_LINK: + case USB_STAT_NOT_CONFIGURED: dev_err(di->dev, "USB Type - Charging not allowed\n"); di->max_usb_in_curr = USB_CH_IP_CUR_LVL_0P05; ret = -ENXIO; break; + case USB_STAT_RESERVED: + if (is_ab8500(di->parent)) { + di->flags.vbus_collapse = true; + dev_err(di->dev, "USB Type - USB_STAT_RESERVED " + "VBUS has collapsed\n"); + ret = -ENXIO; + break; + } + if (is_ab9540(di->parent) || is_ab8505(di->parent)) { + dev_dbg(di->dev, "USB Type - Charging not allowed\n"); + di->max_usb_in_curr = USB_CH_IP_CUR_LVL_0P05; + dev_dbg(di->dev, "USB Type - 0x%02x MaxCurr: %d", + link_status, di->max_usb_in_curr); + ret = -ENXIO; + break; + } + break; + case USB_STAT_CARKIT_1: + case USB_STAT_CARKIT_2: + case USB_STAT_ACA_DOCK_CHARGER: + case USB_STAT_CHARGER_LINE_1: + di->max_usb_in_curr = USB_CH_IP_CUR_LVL_0P5; + dev_dbg(di->dev, "USB Type - 0x%02x MaxCurr: %d", link_status, + di->max_usb_in_curr); + break; + default: dev_err(di->dev, "USB Type - Unknown\n"); di->max_usb_in_curr = USB_CH_IP_CUR_LVL_0P05; @@ -677,8 +711,14 @@ static int ab8500_charger_read_usb_type(struct ab8500_charger *di) dev_err(di->dev, "%s ab8500 read failed\n", __func__); return ret; } - ret = abx500_get_register_interruptible(di->dev, AB8500_USB, - AB8500_USB_LINE_STAT_REG, &val); + 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)) + ret = abx500_get_register_interruptible(di->dev, + AB8500_USB, AB8500_USB_LINK1_STAT_REG, &val); + } if (ret < 0) { dev_err(di->dev, "%s ab8500 read failed\n", __func__); return ret; @@ -718,8 +758,13 @@ static int ab8500_charger_detect_usb_type(struct ab8500_charger *di) dev_err(di->dev, "%s ab8500 read failed\n", __func__); return ret; } - ret = abx500_get_register_interruptible(di->dev, AB8500_USB, - AB8500_USB_LINE_STAT_REG, &val); + + if (is_ab8500(di->parent)) + ret = abx500_get_register_interruptible(di->dev, + AB8500_USB, AB8500_USB_LINE_STAT_REG, &val); + else + ret = abx500_get_register_interruptible(di->dev, + AB8500_USB, AB8500_USB_LINK1_STAT_REG, &val); if (ret < 0) { dev_err(di->dev, "%s ab8500 read failed\n", __func__); return ret; @@ -2947,7 +2992,6 @@ static int __devinit ab8500_charger_probe(struct platform_device *pdev) } if (charger_status & USB_PW_CONN) { - dev_dbg(di->dev, "VBUS Detect during startup\n"); di->vbus_detected = true; di->vbus_detected_start = true; queue_work(di->charger_wq, diff --git a/include/linux/mfd/abx500/ab8500-bm.h b/include/linux/mfd/abx500/ab8500-bm.h index fac684a..e2a1e6d 100644 --- a/include/linux/mfd/abx500/ab8500-bm.h +++ b/include/linux/mfd/abx500/ab8500-bm.h @@ -23,6 +23,7 @@ * Bank : 0x5 */ #define AB8500_USB_LINE_STAT_REG 0x80 +#define AB8500_USB_LINK1_STAT_REG 0x94 /* * Charger / status register offfsets