Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934520AbdDFKis (ORCPT ); Thu, 6 Apr 2017 06:38:48 -0400 Received: from fllnx210.ext.ti.com ([198.47.19.17]:40608 "EHLO fllnx210.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932442AbdDFKiq (ORCPT ); Thu, 6 Apr 2017 06:38:46 -0400 Subject: Re: [PATCH 1/3] phy: rockchip-usb: Add vbus regulator support. To: Sjoerd Simons , John Youn , Heiko Stuebner References: <20170405140613.4444-1-sjoerd.simons@collabora.co.uk> <20170405140613.4444-2-sjoerd.simons@collabora.co.uk> CC: , , Randy Li , , Rob Herring , Mark Rutland , From: Kishon Vijay Abraham I Message-ID: <59ed8834-75d4-2001-73d4-6081d42d2aeb@ti.com> Date: Thu, 6 Apr 2017 16:07:55 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <20170405140613.4444-2-sjoerd.simons@collabora.co.uk> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2676 Lines: 81 On Wednesday 05 April 2017 07:36 PM, Sjoerd Simons wrote: > On rockchip devices vbus is supplied by a separate power supply, often > through a regulator. Add support for describing the the regulator in > device-tree following the same convention as several other usb phy's. > merged, thanks. -Kishon > Signed-off-by: Sjoerd Simons > --- > > .../devicetree/bindings/phy/rockchip-usb-phy.txt | 1 + > drivers/phy/phy-rockchip-usb.c | 19 +++++++++++++++++++ > 2 files changed, 20 insertions(+) > > diff --git a/Documentation/devicetree/bindings/phy/rockchip-usb-phy.txt b/Documentation/devicetree/bindings/phy/rockchip-usb-phy.txt > index 57dc388e2fa2..4ed569046daf 100644 > --- a/Documentation/devicetree/bindings/phy/rockchip-usb-phy.txt > +++ b/Documentation/devicetree/bindings/phy/rockchip-usb-phy.txt > @@ -30,6 +30,7 @@ Optional Properties: > - reset-names: Only allow the following entries: > - phy-reset > - resets: Must contain an entry for each entry in reset-names. > +- vbus-supply: power-supply phandle for vbus power source > > Example: > > diff --git a/drivers/phy/phy-rockchip-usb.c b/drivers/phy/phy-rockchip-usb.c > index 734987fa0ad7..3378eeb7a562 100644 > --- a/drivers/phy/phy-rockchip-usb.c > +++ b/drivers/phy/phy-rockchip-usb.c > @@ -66,6 +66,7 @@ struct rockchip_usb_phy { > struct phy *phy; > bool uart_enabled; > struct reset_control *reset; > + struct regulator *vbus; > }; > > static int rockchip_usb_phy_power(struct rockchip_usb_phy *phy, > @@ -88,6 +89,9 @@ static void rockchip_usb_phy480m_disable(struct clk_hw *hw) > struct rockchip_usb_phy, > clk480m_hw); > > + if (phy->vbus) > + regulator_disable(phy->vbus); > + > /* Power down usb phy analog blocks by set siddq 1 */ > rockchip_usb_phy_power(phy, 1); > } > @@ -143,6 +147,14 @@ static int rockchip_usb_phy_power_on(struct phy *_phy) > if (phy->uart_enabled) > return -EBUSY; > > + if (phy->vbus) { > + int ret; > + > + ret = regulator_enable(phy->vbus); > + if (ret) > + return ret; > + } > + > return clk_prepare_enable(phy->clk480m); > } > > @@ -268,6 +280,13 @@ static int rockchip_usb_phy_init(struct rockchip_usb_phy_base *base, > } > phy_set_drvdata(rk_phy->phy, rk_phy); > > + rk_phy->vbus = devm_regulator_get_optional(&rk_phy->phy->dev, "vbus"); > + if (IS_ERR(rk_phy->vbus)) { > + if (PTR_ERR(rk_phy->vbus) == -EPROBE_DEFER) > + return PTR_ERR(rk_phy->vbus); > + rk_phy->vbus = NULL; > + } > + > /* > * When acting as uart-pipe, just keep clock on otherwise > * only power up usb phy when it use, so disable it when init >