From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760717AbcDFAZi (ORCPT ); Tue, 5 Apr 2016 20:25:38 -0400 Received: from relmlor4.renesas.com ([210.160.252.174]:49142 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753912AbcDFAZf convert rfc822-to-8bit (ORCPT ); Tue, 5 Apr 2016 20:25:35 -0400 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'208";a="208528150" From: Yoshihiro Shimoda To: Kishon Vijay Abraham I , "robh+dt@kernel.org" , "pawel.moll@arm.com" , "mark.rutland@arm.com" , "ijc+devicetree@hellion.org.uk" , "galak@codeaurora.org" CC: "linux-kernel@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-renesas-soc@vger.kernel.org" Subject: RE: [PATCH 2/3] phy: rcar-gen3-usb2: Add vbus-supply to handle VBUS on/off Thread-Topic: [PATCH 2/3] phy: rcar-gen3-usb2: Add vbus-supply to handle VBUS on/off Thread-Index: AQHRdTTGvYj15Eh/LkuX1YJCbMd/7597aGOAgADfgfA= Date: Wed, 6 Apr 2016 00:25:27 +0000 Message-ID: References: <1456999746-2800-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> <1456999746-2800-3-git-send-email-yoshihiro.shimoda.uh@renesas.com> <5703992F.7090601@ti.com> In-Reply-To: <5703992F.7090601@ti.com> Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: ti.com; dkim=none (message not signed) header.d=none;ti.com; dmarc=none action=none header.from=renesas.com; x-originating-ip: [211.11.155.144] x-ms-office365-filtering-correlation-id: c1a133f6-af65-4055-cc07-08d35db1f40e x-microsoft-exchange-diagnostics: 1;SG2PR06MB0919;5:44AI3GmADxNo0O7vd2udVb2wgWWqwnUWBCK+RiVy2PAx2FN2jerNQcWWPAw1UVbKS44Gwmz2qWrA94Njdb82SoTItSRZkPYPEFOkuiT/fizqQvBQtmJJcu40GUNi4DE04OU388alVqrcn7Oi7+XQuw==;24:gZcJJarHqj3E1sNE7Th/ZwvwSwH+ZuKXt88ArrVWBqXicOx2iIgcKdw3kNhOeWl9p8iq3UKWmSbaFP/yCDxiyuhzmi6XsdmvDDCSJ+jU760=;20:thAae8rCXDg+tjOkgnVU8N9ZVj5zxzJai4FLLwOLnBg6FDn2UGs34WuW5DqVEnSvPZf6SwZeRWypCX99TXGH9trUyq3ML7Ygf6i1YstrrL/fiRzWCWieYq0nw8iF3hpCcKCN6zVaSNqSkuHqkVTRkAxWMFgCigkyB6O2VVQ9rOs= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SG2PR06MB0919; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046);SRVR:SG2PR06MB0919;BCL:0;PCL:0;RULEID:;SRVR:SG2PR06MB0919; x-forefront-prvs: 0904004ECB x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(24454002)(377454003)(86362001)(2501003)(2900100001)(2950100001)(66066001)(87936001)(76576001)(15975445007)(5004730100002)(106116001)(4326007)(76176999)(2906002)(77096005)(586003)(345774005)(11100500001)(50986999)(81166005)(5008740100001)(10400500002)(5001770100001)(33656002)(1096002)(3846002)(74316001)(5002640100001)(19580395003)(1220700001)(122556002)(102836003)(6116002)(575784001)(3660700001)(92566002)(5003600100002)(3280700002)(189998001)(230783001)(54356999)(19580405001);DIR:OUT;SFP:1102;SCL:1;SRVR:SG2PR06MB0919;H:SG2PR06MB0919.apcprd06.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Apr 2016 00:25:27.2701 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB0919 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, > From: Kishon Vijay Abraham I > Sent: Tuesday, April 05, 2016 7:54 PM > > Hi, > > On Thursday 03 March 2016 03:39 PM, Yoshihiro Shimoda wrote: > > To handle the VBUS on/off by a regulator driver, this patch adds > > regulator APIs calling in the driver and description about vbus-supply > > in the rcar-gen3-phy-usb2.txt. > > > > Signed-off-by: Yoshihiro Shimoda > > Acked-by: Rob Herring > > --- > > .../devicetree/bindings/phy/rcar-gen3-phy-usb2.txt | 2 ++ > > drivers/phy/phy-rcar-gen3-usb2.c | 28 ++++++++++++++++++++++ > > 2 files changed, 30 insertions(+) > > > > diff --git a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt > b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt > > index 86826ca..7243b3b 100644 > > --- a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt > > +++ b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt > > @@ -21,6 +21,8 @@ To use a USB channel where USB 2.0 Host and HSUSB (USB 2.0 Peripheral) are > > combined, the device tree node should set interrupt properties to use the > > channel as USB OTG: > > - interrupts: interrupt specifier for the PHY. > > +- vbus-supply: Phandle to a regulator that provides power to the VBUS. This > > + regulator will be managed during the PHY power on/off sequence. > > Why not use phy-supply from the generic PHY binding? It can then be managed by > the phy core during power_on/power_off. Thank you for the review! I'm afraid, I should have added your address as CC when I sent RFC patch set. Anyway, Rob had a comment about "phy-supply": http://thread.gmane.org/gmane.linux.kernel.renesas-soc/366/focus=406 I agreed with Rob because the document mentioned the followings: Optional Properties: phy-supply: Phandle to a regulator that provides power to the PHY. This regulator will be managed during the PHY power on/off sequence. https://git.kernel.org/cgit/linux/kernel/git/kishon/linux-phy.git/tree/Documentation/devicetree/bindings/phy/phy-bindings.txt?h=next#n13 And then, I changed the "phy-supply" to "vbus-supply" and this driver managed the "vbus-supply". Or, do I misunderstand the document? Best regards, Yoshihiro Shimoda > Thanks > Kishon > > > > > Example (R-Car H3): > > > > diff --git a/drivers/phy/phy-rcar-gen3-usb2.c b/drivers/phy/phy-rcar-gen3-usb2.c > > index 3c647cd..7b14244 100644 > > --- a/drivers/phy/phy-rcar-gen3-usb2.c > > +++ b/drivers/phy/phy-rcar-gen3-usb2.c > > @@ -19,6 +19,7 @@ > > #include > > #include > > #include > > +#include > > > > /******* USB2.0 Host registers (original offset is +0x200) *******/ > > #define USB2_INT_ENABLE 0x000 > > @@ -77,6 +78,7 @@ > > struct rcar_gen3_chan { > > void __iomem *base; > > struct phy *phy; > > + struct regulator *vbus; > > bool has_otg; > > }; > > > > @@ -210,6 +212,13 @@ static int rcar_gen3_phy_usb2_power_on(struct phy *p) > > struct rcar_gen3_chan *channel = phy_get_drvdata(p); > > void __iomem *usb2_base = channel->base; > > u32 val; > > + int ret; > > + > > + if (channel->vbus) { > > + ret = regulator_enable(channel->vbus); > > + if (ret) > > + return ret; > > + } > > > > val = readl(usb2_base + USB2_USBCTR); > > val |= USB2_USBCTR_PLL_RST; > > @@ -220,10 +229,22 @@ static int rcar_gen3_phy_usb2_power_on(struct phy *p) > > return 0; > > } > > > > +static int rcar_gen3_phy_usb2_power_off(struct phy *p) > > +{ > > + struct rcar_gen3_chan *channel = phy_get_drvdata(p); > > + int ret = 0; > > + > > + if (channel->vbus) > > + ret = regulator_disable(channel->vbus); > > + > > + return ret; > > +} > > + > > static struct phy_ops rcar_gen3_phy_usb2_ops = { > > .init = rcar_gen3_phy_usb2_init, > > .exit = rcar_gen3_phy_usb2_exit, > > .power_on = rcar_gen3_phy_usb2_power_on, > > + .power_off = rcar_gen3_phy_usb2_power_off, > > .owner = THIS_MODULE, > > }; > > > > @@ -290,6 +311,13 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) > > return PTR_ERR(channel->phy); > > } > > > > + channel->vbus = devm_regulator_get_optional(dev, "vbus"); > > + if (IS_ERR(channel->vbus)) { > > + if (PTR_ERR(channel->vbus) == -EPROBE_DEFER) > > + return PTR_ERR(channel->vbus); > > + channel->vbus = NULL; > > + } > > + > > phy_set_drvdata(channel->phy, channel); > > > > provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); > > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yoshihiro Shimoda Subject: RE: [PATCH 2/3] phy: rcar-gen3-usb2: Add vbus-supply to handle VBUS on/off Date: Wed, 6 Apr 2016 00:25:27 +0000 Message-ID: References: <1456999746-2800-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> <1456999746-2800-3-git-send-email-yoshihiro.shimoda.uh@renesas.com> <5703992F.7090601@ti.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT Return-path: In-Reply-To: <5703992F.7090601@ti.com> Content-Language: ja-JP Sender: linux-renesas-soc-owner@vger.kernel.org To: Kishon Vijay Abraham I , "robh+dt@kernel.org" , "pawel.moll@arm.com" , "mark.rutland@arm.com" , "ijc+devicetree@hellion.org.uk" , "galak@codeaurora.org" Cc: "linux-kernel@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-renesas-soc@vger.kernel.org" List-Id: devicetree@vger.kernel.org Hi, > From: Kishon Vijay Abraham I > Sent: Tuesday, April 05, 2016 7:54 PM > > Hi, > > On Thursday 03 March 2016 03:39 PM, Yoshihiro Shimoda wrote: > > To handle the VBUS on/off by a regulator driver, this patch adds > > regulator APIs calling in the driver and description about vbus-supply > > in the rcar-gen3-phy-usb2.txt. > > > > Signed-off-by: Yoshihiro Shimoda > > Acked-by: Rob Herring > > --- > > .../devicetree/bindings/phy/rcar-gen3-phy-usb2.txt | 2 ++ > > drivers/phy/phy-rcar-gen3-usb2.c | 28 ++++++++++++++++++++++ > > 2 files changed, 30 insertions(+) > > > > diff --git a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt > b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt > > index 86826ca..7243b3b 100644 > > --- a/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt > > +++ b/Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt > > @@ -21,6 +21,8 @@ To use a USB channel where USB 2.0 Host and HSUSB (USB 2.0 Peripheral) are > > combined, the device tree node should set interrupt properties to use the > > channel as USB OTG: > > - interrupts: interrupt specifier for the PHY. > > +- vbus-supply: Phandle to a regulator that provides power to the VBUS. This > > + regulator will be managed during the PHY power on/off sequence. > > Why not use phy-supply from the generic PHY binding? It can then be managed by > the phy core during power_on/power_off. Thank you for the review! I'm afraid, I should have added your address as CC when I sent RFC patch set. Anyway, Rob had a comment about "phy-supply": http://thread.gmane.org/gmane.linux.kernel.renesas-soc/366/focus=406 I agreed with Rob because the document mentioned the followings: Optional Properties: phy-supply: Phandle to a regulator that provides power to the PHY. This regulator will be managed during the PHY power on/off sequence. https://git.kernel.org/cgit/linux/kernel/git/kishon/linux-phy.git/tree/Documentation/devicetree/bindings/phy/phy-bindings.txt?h=next#n13 And then, I changed the "phy-supply" to "vbus-supply" and this driver managed the "vbus-supply". Or, do I misunderstand the document? Best regards, Yoshihiro Shimoda > Thanks > Kishon > > > > > Example (R-Car H3): > > > > diff --git a/drivers/phy/phy-rcar-gen3-usb2.c b/drivers/phy/phy-rcar-gen3-usb2.c > > index 3c647cd..7b14244 100644 > > --- a/drivers/phy/phy-rcar-gen3-usb2.c > > +++ b/drivers/phy/phy-rcar-gen3-usb2.c > > @@ -19,6 +19,7 @@ > > #include > > #include > > #include > > +#include > > > > /******* USB2.0 Host registers (original offset is +0x200) *******/ > > #define USB2_INT_ENABLE 0x000 > > @@ -77,6 +78,7 @@ > > struct rcar_gen3_chan { > > void __iomem *base; > > struct phy *phy; > > + struct regulator *vbus; > > bool has_otg; > > }; > > > > @@ -210,6 +212,13 @@ static int rcar_gen3_phy_usb2_power_on(struct phy *p) > > struct rcar_gen3_chan *channel = phy_get_drvdata(p); > > void __iomem *usb2_base = channel->base; > > u32 val; > > + int ret; > > + > > + if (channel->vbus) { > > + ret = regulator_enable(channel->vbus); > > + if (ret) > > + return ret; > > + } > > > > val = readl(usb2_base + USB2_USBCTR); > > val |= USB2_USBCTR_PLL_RST; > > @@ -220,10 +229,22 @@ static int rcar_gen3_phy_usb2_power_on(struct phy *p) > > return 0; > > } > > > > +static int rcar_gen3_phy_usb2_power_off(struct phy *p) > > +{ > > + struct rcar_gen3_chan *channel = phy_get_drvdata(p); > > + int ret = 0; > > + > > + if (channel->vbus) > > + ret = regulator_disable(channel->vbus); > > + > > + return ret; > > +} > > + > > static struct phy_ops rcar_gen3_phy_usb2_ops = { > > .init = rcar_gen3_phy_usb2_init, > > .exit = rcar_gen3_phy_usb2_exit, > > .power_on = rcar_gen3_phy_usb2_power_on, > > + .power_off = rcar_gen3_phy_usb2_power_off, > > .owner = THIS_MODULE, > > }; > > > > @@ -290,6 +311,13 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) > > return PTR_ERR(channel->phy); > > } > > > > + channel->vbus = devm_regulator_get_optional(dev, "vbus"); > > + if (IS_ERR(channel->vbus)) { > > + if (PTR_ERR(channel->vbus) == -EPROBE_DEFER) > > + return PTR_ERR(channel->vbus); > > + channel->vbus = NULL; > > + } > > + > > phy_set_drvdata(channel->phy, channel); > > > > provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); > >