From patchwork Tue Feb 20 09:11:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amelie Delaunay X-Patchwork-Id: 10229629 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3F1BB602DC for ; Tue, 20 Feb 2018 09:26:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D3EE28531 for ; Tue, 20 Feb 2018 09:26:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2075E285BE; Tue, 20 Feb 2018 09:26:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9817228531 for ; Tue, 20 Feb 2018 09:26:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=ZKjK9yXLznek4UcLAGI///cDzJTuDpGLQMcb5gJha/Y=; b=AKh9bIsS2JTBm4 GnT++ditEMed7ahZHQnU5pV4TXRDp2JV5RvT5jINrOG0c4QY3w0i7ILEuVm/B8xs3V1B5kz7XFGJU 79mjm9wrA4Lwi2x1Ih/kXRiQOsRV7p8uOZQZgXJaIixfy1cSDFJmX+L7UmyC5HdzUCXCfaqZRHnED ujTXxMEqNhQP1NHpapCcrFI0TqguTfaY60ZROChkA7Bz+RAnBPUpTO+t7IZIvwAthTtkdeSCJSfzZ nh5wGLcRu3XIXFMN54ekWPidlMeJvU48rDQHFqLgUws0BNPsebl4TRj76ls7GQ6wdVyUWFMZkqQyU pvh8bOmdwNwZEMRB+09A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eo4BQ-0000Cg-Sz; Tue, 20 Feb 2018 09:25:56 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eo4B3-0007tv-Kv for linux-arm-kernel@bombadil.infradead.org; Tue, 20 Feb 2018 09:25:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:Message-ID: Date:Subject:CC:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=EftVRuibKs/4TDBPG0N5bEwqIx38b0R/Ug83zkTITXU=; b=VCmQpcs4xWjierLR6zLzubmsUP IhpG/OAagX6lsJBJgSHBkqQ7SqaAShsr1FbAQMYKgCmGGE6Cr0UTltv5IDYI6VDOkplj9O5S3Z838 tVVpNre/rAadn3whhsaE0cwVf1scU+vcYVppFUMf5jNRMDh1Nmg8O8xDO73nT0NREhOUqDomER8Gu FVML/JlHoKLccwDs8oFw2qd1j8iGZJXia/x9Zqm3vlHSeo2B47VX5F38SnIrIKULtch0zU/ENAoLe W2boUnybT3ix67lRvyvtOAWiiwiF4i5ZKHEm96cWBkcYM12xMRFUlOFelJmc6o6sOEwk35ayAdctN pCmjRlmw==; Received: from mx07-00178001.pphosted.com ([62.209.51.94]) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eo3y7-00058S-NY for linux-arm-kernel@lists.infradead.org; Tue, 20 Feb 2018 09:12:14 +0000 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w1K99OkY005154; Tue, 20 Feb 2018 10:11:48 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2g6b1wcyq2-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 20 Feb 2018 10:11:48 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8E2D83A; Tue, 20 Feb 2018 09:11:46 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas21.st.com [10.75.90.44]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 439AA1C0E; Tue, 20 Feb 2018 09:11:46 +0000 (GMT) Received: from SAFEX1HUBCAS24.st.com (10.75.90.94) by SAFEX1HUBCAS21.st.com (10.75.90.44) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 20 Feb 2018 10:11:46 +0100 Received: from localhost (10.201.20.5) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 20 Feb 2018 10:11:45 +0100 From: Amelie Delaunay To: Greg Kroah-Hartman , Rob Herring , Mark Rutland , Tony Prisk , Alan Stern Subject: [PATCH] usb: host: ehci-platform: add support for optional external vbus supply Date: Tue, 20 Feb 2018 10:11:45 +0100 Message-ID: <1519117905-12095-1-git-send-email-amelie.delaunay@st.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.201.20.5] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-20_02:, , signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180220_091211_808509_DAE40950 X-CRM114-Status: GOOD ( 18.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Amelie Delaunay , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On some boards, especially when vbus supply requires large current, and the charge pump on the PHY isn't enough, an external vbus power switch may be used. Add support for this optional external vbus supply in ehci-platform. Signed-off-by: Amelie Delaunay --- Documentation/devicetree/bindings/usb/usb-ehci.txt | 1 + drivers/usb/host/ehci-platform.c | 23 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/usb-ehci.txt b/Documentation/devicetree/bindings/usb/usb-ehci.txt index 3efde12..fc480cd 100644 --- a/Documentation/devicetree/bindings/usb/usb-ehci.txt +++ b/Documentation/devicetree/bindings/usb/usb-ehci.txt @@ -19,6 +19,7 @@ Optional properties: - phys : phandle + phy specifier pair - phy-names : "usb" - resets : phandle + reset specifier pair + - vbus-supply : phandle of regulator supplying vbus Example (Sequoia 440EPx): ehci@e0000300 { diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index b065a96..76cc781 100644 --- a/drivers/usb/host/ehci-platform.c +++ b/drivers/usb/host/ehci-platform.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +47,7 @@ struct ehci_platform_priv { struct reset_control *rsts; struct phy **phys; int num_phys; + struct regulator *vbus_supply; bool reset_on_resume; }; @@ -99,6 +101,15 @@ static int ehci_platform_power_on(struct platform_device *dev) } } + if (priv->vbus_supply) { + ret = regulator_enable(priv->vbus_supply); + if (ret) { + dev_err(&dev->dev, + "failed to enable vbus supply: %d\n", ret); + goto err_exit_phy; + } + } + return 0; err_exit_phy: @@ -119,6 +130,9 @@ static void ehci_platform_power_off(struct platform_device *dev) struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd); int clk, phy_num; + if (priv->vbus_supply) + regulator_disable(priv->vbus_supply); + for (phy_num = 0; phy_num < priv->num_phys; phy_num++) { phy_power_off(priv->phys[phy_num]); phy_exit(priv->phys[phy_num]); @@ -247,6 +261,15 @@ static int ehci_platform_probe(struct platform_device *dev) if (err) goto err_put_clks; + priv->vbus_supply = devm_regulator_get_optional(&dev->dev, "vbus"); + if (IS_ERR(priv->vbus_supply)) { + err = PTR_ERR(priv->vbus_supply); + if (err == -ENODEV) + priv->vbus_supply = NULL; + else + goto err_reset; + } + if (pdata->big_endian_desc) ehci->big_endian_desc = 1; if (pdata->big_endian_mmio)