Received: by 10.223.185.116 with SMTP id b49csp605683wrg; Tue, 20 Feb 2018 04:59:58 -0800 (PST) X-Google-Smtp-Source: AH8x227FqiR7BGN0aF2poXTvQwtafWAmTTxmUW4G0OX0DdQJiBQq1hVNE8pSBinpcqSH4aV09jBV X-Received: by 10.98.163.67 with SMTP id s64mr16479587pfe.67.1519131597923; Tue, 20 Feb 2018 04:59:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519131597; cv=none; d=google.com; s=arc-20160816; b=VXMAGpJV7azhSLQeCHlKavK+pZM3QmEg1hZqUgsCJP9abrTWN0aEsJuHw8oooOOoCv nPFKnhWGSyaQgRtjXJ2SWKDcuhzheC1YxBPYVWqdIBt4RpFVASplybCGPGBYyHOBAQG1 CVhL2rCE+bXdJPcYRzEhkcDCxu3A/g2KAMBlnby2WEbu9JSD5PIrdBqfSF8OoIbOvu34 eFv8V5/Y3KkqhUK1T0k1R8Umj7oM7rqERzL0v9lxnuKPPdqEoUYCrBHxLjNhhwT+vhPp jMqejPbnShxKUt3QUOVycb3YIxazx6NVQEQy2733Mkt2aNmYeKBVf/WuW9V7iXoYbEoP EOdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=BAnUPYSfeK1CAYQdIHm38Vzwobi0WZi28qDTJPE+NLA=; b=R7Klnc4Dkam2mxXKbFMdI72HtXTRSCidobpywhMJJkU+a6dacDpLGGWG3Kw8U11lkG SBr4psvfbKlCYwXJNuf8XoPpuLuwzZNGR9uy9+LbTAndCEkE97KF0W4HyNjCVtCx1Hi8 RlAPjwwjFT5qrNpZBd6hYOJxXB+/7UlitEeE31aqe8/vFj9dO1JPqIgjm9nHjzk3sSLk suMOteY5DwSsCBmozqG4h1pjmyYzISDoR+jilMMuUOucyoDCxMwuRZwk8liRWh2FmjvR F0A5tH/WUPNjUsaPaKbZAvmdK8KNqct/NC4JxqEPurfzvqCQd3gRRjStw7I9J69vVhHX Hk4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i6si1088589pgq.471.2018.02.20.04.59.43; Tue, 20 Feb 2018 04:59:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751934AbeBTM6v (ORCPT + 99 others); Tue, 20 Feb 2018 07:58:51 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:61515 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751888AbeBTM6s (ORCPT ); Tue, 20 Feb 2018 07:58:48 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w1KCruYb012274; Tue, 20 Feb 2018 13:58:17 +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 2g6ar0ny37-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 20 Feb 2018 13:58:17 +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 70FC931; Tue, 20 Feb 2018 12:58:13 +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 1F37629FA; Tue, 20 Feb 2018 12:58:13 +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 13:58:13 +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 13:58:12 +0100 From: Amelie Delaunay To: Greg Kroah-Hartman , Rob Herring , Mark Rutland , Tony Prisk , Alan Stern CC: , , , , Amelie Delaunay Subject: [PATCH v2] usb: host: ehci-platform: add support for optional external vbus supply Date: Tue, 20 Feb 2018 13:58:12 +0100 Message-ID: <1519131492-27913-1-git-send-email-amelie.delaunay@st.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.201.20.5] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-20_04:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- Changes in v2: * Address Roger Quadros comments: move regulator_enable/disable from ehci_platform_power_on/off to ehci_platform_port_power. --- Documentation/devicetree/bindings/usb/usb-ehci.txt | 1 + drivers/usb/host/ehci-platform.c | 31 ++++++++++++++++++++++ 2 files changed, 32 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..05be100 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; }; @@ -76,6 +78,25 @@ static int ehci_platform_reset(struct usb_hcd *hcd) return 0; } +static int ehci_platform_port_power(struct usb_hcd *hcd, int portnum, + bool enable) +{ + struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd); + int ret = 0; + + if (priv->vbus_supply) { + if (enable) + ret = regulator_enable(priv->vbus_supply); + else + ret = regulator_disable(priv->vbus_supply); + if (ret) + dev_err(hcd->self.controller, + "failed to %s vbus supply: %d\n", + enable ? "enable" : "disable", ret); + } + return ret; +} + static int ehci_platform_power_on(struct platform_device *dev) { struct usb_hcd *hcd = platform_get_drvdata(dev); @@ -134,6 +155,7 @@ static struct hc_driver __read_mostly ehci_platform_hc_driver; static const struct ehci_driver_overrides platform_overrides __initconst = { .reset = ehci_platform_reset, .extra_priv_size = sizeof(struct ehci_platform_priv), + .port_power = ehci_platform_port_power, }; static struct usb_ehci_pdata ehci_platform_defaults = { @@ -247,6 +269,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) -- 2.7.4