Received: by 10.223.185.116 with SMTP id b49csp834237wrg; Tue, 20 Feb 2018 08:36:09 -0800 (PST) X-Google-Smtp-Source: AH8x224ByOLs0BM2AGZkuM7iWYU8e8DspSE0XEwn/zIZOTRm4s0Mti9xNgC+KCYeSO08S969fUY1 X-Received: by 2002:a17:902:6e8c:: with SMTP id v12-v6mr183324plk.424.1519144568816; Tue, 20 Feb 2018 08:36:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519144568; cv=none; d=google.com; s=arc-20160816; b=aHEGeBVnmOSCDgy09EFHOQ03i4Z2o7UjjWQhB7PujKoZwELqNAUZXQt1jDSmaUsZKw A+4DQZk9dYnNhgJDiIexS9Wpt8MdkYA/l2ElCjKnFN514cKEL0X+uZiIWQzQjlWQavEY BmNYgw4KXp37spWJg6Dcn2ZILSuU/KT04pDb85TAXwUhmUQ7E6TB0ATi4S42o8YIJgXN OwwlCoEiC4yql4LvmJplO/Oo/2EsIatKlirqGW7Mxm2VGOIpUkZHCnHyrONfAZn+e+Cx 1nN9fVq8QmHdToRY8iZSJ/SYkygMHiTdix1foZSpE3NNvIhq90wtU/f/CYMOGJu0SmK/ O/Xw== 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=SsbJhPqx2ZaDvKxWyKuyZewfj0c7oTxXIcjk/8pnFsM=; b=vYGndccx0bM1ywwH1oDMdEUaGukYntWkVrgGkN5u2rrnTP99wk2Vfp2BCwpG3xzAVS rG5CHvZoMnMNIpmPRaPgfHyw1fjyrKy5TsaTYpK2lQG3KylsZ4+AwUXpOFsvpxfHu025 /2d41cJ2MCOCvXqrS6IQf/MFahJdSOpBJ8LM6xtlDOEty2Gj+jwSlqhIU8fe5hAHBGaJ B7zXQtXriLd3mH76gDAh1IHi2wpHQWOOuX5tbdEu7nCjWd2u2FNtVqJ0n36ksictC3Sn 55hDRutKjzxg0zUXAipA2nIgSxXLKC64umthA9FD05LkokDJgrDQ75XlCnfkiuLIqlwo vWkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=kJXpRSlw; 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 1-v6si7719375plk.504.2018.02.20.08.35.53; Tue, 20 Feb 2018 08:36:08 -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=kJXpRSlw; 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 S1752515AbeBTQe1 (ORCPT + 99 others); Tue, 20 Feb 2018 11:34:27 -0500 Received: from lelnx193.ext.ti.com ([198.47.27.77]:16516 "EHLO lelnx193.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752456AbeBTQeX (ORCPT ); Tue, 20 Feb 2018 11:34:23 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id w1KGXacU029360; Tue, 20 Feb 2018 10:33:36 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1519144416; bh=zEbBrpLXY6SPH6K44Nhw/kleBUbmIcdA+Vh7DihDDRA=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=kJXpRSlwn7K9gc9SFF4Qnk3DZ+bne6r545DDVdbbbYPWEys5JafEtKcAqBgR3k4NF 7zd/JBU3SSKJx3vBXS+SsDOEVSlXuSHchSXNMbaNukOuWxaFkUmeVy6t60aRzWKLXN Y59ge5i0eaiSpfYMt6cqwoJ3TKVqHQjrJA9p6IwU= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1KGXaxb018081; Tue, 20 Feb 2018 10:33:36 -0600 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE112.ent.ti.com (157.170.170.23) 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 10:33:36 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE107.ent.ti.com (157.170.170.37) 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 10:33:36 -0600 Received: from [192.168.2.6] (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1KGXX4s010841; Tue, 20 Feb 2018 10:33:34 -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: "linux-usb@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" References: <1519131492-27913-1-git-send-email-amelie.delaunay@st.com> <2ef38200-947c-1419-1c91-f033da390f74@st.com> From: Roger Quadros Message-ID: Date: Tue, 20 Feb 2018 18:33:33 +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: <2ef38200-947c-1419-1c91-f033da390f74@st.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-GB Content-Transfer-Encoding: 8bit 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 On 20/02/18 16:46, Amelie DELAUNAY wrote: > Hi, > > On 02/20/2018 03:00 PM, Roger Quadros wrote: >> 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? >> > > I imagine that yes, platforms could have one regulator per port. > Regulator consumers bindings impose a -supply property per > regulator, so, what do you think about : > vbus0-supply for port#0 > vbus1-supply for port#1 > ... > vbusN-supply for port#N > > And then in probe, allocate 'struct regulator *vbus_supplies' with a > size corresponding to 'HCS_N_PORTS(ehci->hcs_params) * sizeof(struct > regulator *)'. > And loop to get optional regulator vbus0, vbus1,..., vbusN. > And then enable/disable the corresponding regulator in > ehci_platform_port_power thanks to portnum. Looks fine to me but we need to get Alan's opinion if this is worth the effort. If there isn't a single platform needing it we could probably do without it but the DT binding must be scalable to add this feature in the future. And what if it is ganged power? i.e. one regulator for more than one port. Probably they all can point to the same regulator instance and it should work. > >>> 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