Received: by 10.223.185.116 with SMTP id b49csp668585wrg; Tue, 20 Feb 2018 06:02:16 -0800 (PST) X-Google-Smtp-Source: AH8x227AQLvJEpWqaVClxZKQFwQ+R/UsO7wpReaNhxkHuojF+8X9gMQBT4K0ya5gpKYPlDYma1G4 X-Received: by 2002:a17:902:a610:: with SMTP id u16-v6mr7543769plq.293.1519135336088; Tue, 20 Feb 2018 06:02:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519135336; cv=none; d=google.com; s=arc-20160816; b=jB3p+C5V3WF/hUmZqlbNxVBoMsgKMLaFegejuP2RIANC3DyhmFEVav0dr3kug0yn6w Cm217MlpwqStqDoo88yufWv3TnYSgkgi4tUzAKeIeXD4yHSXl6ULnbmybciefjUepO3u 98At2F8b0777GBmU8XBi7CS+h/31pXp+GFObeEmm+NeWj4NUbRdOZBuAX4I3D458orHz POBNn9VIyFynS3+E7ELF4nu6TaMXEocUl+rGSgkG/+iJZF5kJL8faWkExB+dRaKEISHx QvW5h2TsxndIm6hZ46awQokQiax/PKbYWtdxfh4e72g3TJZm+zdE0AgS/ukZaN6KXuy7 ytig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=ZpV12qcL9Vio9bqj+uMjGLn3+pzSCyDvxj+vq9XQAxk=; b=cdv6nz8bs3PHNZNba+wDYYWkLikfblS1/ApNNhxy2nsM4+f0SCf1uG/d8hkwohw9xx qnWH37W9/+zVrw5JHJ9ACizt+BAgoa1aauVm9UP5rmmplfPo6fj9MeUTfQO5YrFnmnU9 xOrha/gDqyjfWJqu1NZfoo57la9oe2/MChyDKt8QhihnibahilX9+GbojpRAYDUrCdVm hz9mLtfYVwDt/HWo39SO/acPOOXignGUxLRZZr+KbyrD9tdjePFKE7H++oGS6CHCPLoj lJTgcC4yC0Yvqx27kRUBtxVxrop3qXpiWXN0KofU+mlmr21nM8n9FoNg8NsOiVPVhZUz KQNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=QGTdYBBs; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o7si7735641pgs.314.2018.02.20.06.01.58; Tue, 20 Feb 2018 06:02:16 -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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=QGTdYBBs; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751039AbeBTOBJ (ORCPT + 99 others); Tue, 20 Feb 2018 09:01:09 -0500 Received: from lelnx193.ext.ti.com ([198.47.27.77]:10620 "EHLO lelnx193.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750732AbeBTOBH (ORCPT ); Tue, 20 Feb 2018 09:01:07 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id w1KE0dRI001633; Tue, 20 Feb 2018 08:00:39 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1519135239; bh=Xvc66+4rzos6gTTPnYBj4O7D0Srftyp6si55E1L817M=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=QGTdYBBsIZCWw7nR3Vp6uBtYGpQ4Lrhvp+dUnqSmut6BL9gC0O2xKjYVorw2kh6CO A8HwxAGrJajjt4z1yMIzyCrF3F+hVk6iK34nZvuT/scJeR17deO6/3+Y7lG5eywwez jaer/oY7ATkHd68yCe/Fqlbr/ZnxNk1HMAoGPANY= Received: from DLEE101.ent.ti.com (dlee101.ent.ti.com [157.170.170.31]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1KE0dwC016251; Tue, 20 Feb 2018 08:00:39 -0600 Received: from DLEE106.ent.ti.com (157.170.170.36) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Tue, 20 Feb 2018 08:00:39 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Tue, 20 Feb 2018 08:00:39 -0600 Received: from [192.168.2.6] (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1KE0aTI024792; Tue, 20 Feb 2018 08:00:37 -0600 Subject: Re: [PATCH v2] usb: host: ehci-platform: add support for optional external vbus supply To: Amelie Delaunay , Greg Kroah-Hartman , Rob Herring , Mark Rutland , Tony Prisk , Alan Stern CC: , , , References: <1519131492-27913-1-git-send-email-amelie.delaunay@st.com> From: Roger Quadros Message-ID: Date: Tue, 20 Feb 2018 16:00:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <1519131492-27913-1-git-send-email-amelie.delaunay@st.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-GB Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 20/02/18 14:58, Amelie Delaunay wrote: > 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 > Can platforms have more than one regulator e.g. one regulator per port? > 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) > -- cheers, -roger Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki