From patchwork Sun Mar 22 17:07:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 453156 X-Patchwork-Delegate: hdegoede@redhat.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id EACB51400DD for ; Mon, 23 Mar 2015 04:08:01 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D1E694B693; Sun, 22 Mar 2015 18:07:53 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Dcm0aVoM-K-v; Sun, 22 Mar 2015 18:07:53 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1B6B64B672; Sun, 22 Mar 2015 18:07:51 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 638554B698 for ; Sun, 22 Mar 2015 18:07:47 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3AvSrctEbq8p for ; Sun, 22 Mar 2015 18:07:47 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from gagarine.paulk.fr (gagarine.paulk.fr [109.190.93.129]) by theia.denx.de (Postfix) with ESMTPS id E6872A7429 for ; Sun, 22 Mar 2015 18:07:40 +0100 (CET) Received: by gagarine.paulk.fr (Postfix, from userid 65534) id 30AF1206E5; Sun, 22 Mar 2015 18:07:40 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on gagarine.paulk.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from armstrong.paulk.fr (armstrong.paulk.fr [82.233.88.171]) by gagarine.paulk.fr (Postfix) with ESMTPS id 6EA422070F; Sun, 22 Mar 2015 18:07:29 +0100 (CET) Received: from localhost.localdomain (aldrin [192.168.0.128]) by armstrong.paulk.fr (Postfix) with ESMTP id A01DA37820; Sun, 22 Mar 2015 18:07:28 +0100 (CET) From: Paul Kocialkowski To: u-boot@lists.denx.de Date: Sun, 22 Mar 2015 18:07:11 +0100 Message-Id: <1427044034-32031-4-git-send-email-contact@paulk.fr> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1427044034-32031-1-git-send-email-contact@paulk.fr> References: <1427044034-32031-1-git-send-email-contact@paulk.fr> Cc: Ian Campbell Subject: [U-Boot] [PATCH v2 4/7] power: axp209: VBUS detection support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Signed-off-by: Paul Kocialkowski --- drivers/power/axp209.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/power/axp209.c b/drivers/power/axp209.c index 4565398..e1cbba9 100644 --- a/drivers/power/axp209.c +++ b/drivers/power/axp209.c @@ -7,6 +7,7 @@ #include #include +#include #include enum axp209_reg { @@ -31,6 +32,7 @@ enum axp209_reg { }; #define AXP209_POWER_STATUS_ON_BY_DC (1 << 0) +#define AXP209_POWER_STATUS_VBUS_USABLE (1 << 4) #define AXP209_IRQ5_PEK_UP (1 << 6) #define AXP209_IRQ5_PEK_DOWN (1 << 5) @@ -205,6 +207,9 @@ static u8 axp209_get_gpio_ctrl_reg(unsigned int pin) int axp_gpio_direction_input(unsigned int pin) { + if (pin == SUNXI_GPIO_AXP0_VBUS_DETECT) + return 0; + u8 reg = axp209_get_gpio_ctrl_reg(pin); /* GPIO3 is "special" */ u8 val = (pin == 3) ? AXP209_GPIO3_INPUT : AXP209_GPIO_INPUT; @@ -232,7 +237,10 @@ int axp_gpio_get_value(unsigned int pin) u8 val, mask; int rc; - if (pin == 3) { + if (pin == SUNXI_GPIO_AXP0_VBUS_DETECT) { + rc = axp209_read(AXP209_POWER_STATUS, &val); + mask = AXP209_POWER_STATUS_VBUS_USABLE; + } else if (pin == 3) { rc = axp209_read(AXP209_GPIO3_CTRL, &val); mask = 1; } else {