From patchwork Wed Apr 5 14:06:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sjoerd Simons X-Patchwork-Id: 96880 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp282799qgd; Wed, 5 Apr 2017 07:11:25 -0700 (PDT) X-Received: by 10.99.109.195 with SMTP id i186mr27157450pgc.215.1491401485203; Wed, 05 Apr 2017 07:11:25 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x74si20749376pfa.169.2017.04.05.07.11.24; Wed, 05 Apr 2017 07:11:25 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755344AbdDEOGq (ORCPT + 13 others); Wed, 5 Apr 2017 10:06:46 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:52051 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753300AbdDEOGQ (ORCPT ); Wed, 5 Apr 2017 10:06:16 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sjoerd) with ESMTPSA id 59FEF265660 Received: by dawn.luon.net (Postfix, from userid 1000) id 1B1DA2E404E5; Wed, 5 Apr 2017 16:06:13 +0200 (CEST) From: Sjoerd Simons To: John Youn , Heiko Stuebner Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Randy Li , linux-rockchip@lists.infradead.org, Rob Herring , Kishon Vijay Abraham I , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/3] phy: rockchip-usb: Add vbus regulator support. Date: Wed, 5 Apr 2017 16:06:10 +0200 Message-Id: <20170405140613.4444-2-sjoerd.simons@collabora.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170405140613.4444-1-sjoerd.simons@collabora.co.uk> References: <20170405140613.4444-1-sjoerd.simons@collabora.co.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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(+) -- 2.11.0 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 From patchwork Wed Apr 5 14:06:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sjoerd Simons X-Patchwork-Id: 96879 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp280957qgd; Wed, 5 Apr 2017 07:07:40 -0700 (PDT) X-Received: by 10.98.39.134 with SMTP id n128mr28914121pfn.17.1491401260483; Wed, 05 Apr 2017 07:07:40 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d2si3438018pgf.380.2017.04.05.07.07.40; Wed, 05 Apr 2017 07:07:40 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755379AbdDEOGq (ORCPT + 13 others); Wed, 5 Apr 2017 10:06:46 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:52058 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753428AbdDEOGQ (ORCPT ); Wed, 5 Apr 2017 10:06:16 -0400 Received: from dawn.luon.net (unknown [IPv6:2001:1af8:fe00:8421:4dce:99df:b40f:9871]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: sjoerd) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 7B5222656B5; Wed, 5 Apr 2017 15:06:15 +0100 (BST) Received: by dawn.luon.net (Postfix, from userid 1000) id 324902E404E7; Wed, 5 Apr 2017 16:06:13 +0200 (CEST) From: Sjoerd Simons To: John Youn , Heiko Stuebner Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Rob Herring , Mark Rutland , Russell King , linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/3] ARM: dts: rockchip: rock2: Setup usb vbus-supply Date: Wed, 5 Apr 2017 16:06:11 +0200 Message-Id: <20170405140613.4444-3-sjoerd.simons@collabora.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170405140613.4444-1-sjoerd.simons@collabora.co.uk> References: <20170405140613.4444-1-sjoerd.simons@collabora.co.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that the rockchip usb phy has a vbus-supply property use that to control the vbus regulator on rock2. Signed-off-by: Sjoerd Simons --- arch/arm/boot/dts/rk3288-rock2-square.dts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.11.0 diff --git a/arch/arm/boot/dts/rk3288-rock2-square.dts b/arch/arm/boot/dts/rk3288-rock2-square.dts index a23a94811be8..8ed25e9f60bc 100644 --- a/arch/arm/boot/dts/rk3288-rock2-square.dts +++ b/arch/arm/boot/dts/rk3288-rock2-square.dts @@ -125,10 +125,6 @@ gpio = <&gpio0 RK_PB6 GPIO_ACTIVE_HIGH>; pinctrl-names = "default"; pinctrl-0 = <&host_vbus_drv>; - /* Always on as the rockchip usb phy doesn't have a vbus-supply - * property - */ - regulator-always-on; regulator-name = "vcc_host"; }; @@ -279,6 +275,10 @@ status = "okay"; }; +&usbphy1 { + vbus-supply = <&vcc_usb_host>; +}; + &usb_host0_ehci { status = "okay"; }; From patchwork Wed Apr 5 14:06:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sjoerd Simons X-Patchwork-Id: 96882 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp283078qgd; Wed, 5 Apr 2017 07:12:00 -0700 (PDT) X-Received: by 10.98.219.2 with SMTP id f2mr29906727pfg.23.1491401520173; Wed, 05 Apr 2017 07:12:00 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g24si20784394pfd.250.2017.04.05.07.11.59; Wed, 05 Apr 2017 07:12:00 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755045AbdDEOGo (ORCPT + 13 others); Wed, 5 Apr 2017 10:06:44 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:52076 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753588AbdDEOGV (ORCPT ); Wed, 5 Apr 2017 10:06:21 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sjoerd) with ESMTPSA id 25C632656B8 Received: by dawn.luon.net (Postfix, from userid 1000) id 3F6AF2E404E9; Wed, 5 Apr 2017 16:06:13 +0200 (CEST) From: Sjoerd Simons To: John Youn , Heiko Stuebner Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] usb: dwc2: Power off the phy on shutdown Date: Wed, 5 Apr 2017 16:06:12 +0200 Message-Id: <20170405140613.4444-4-sjoerd.simons@collabora.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170405140613.4444-1-sjoerd.simons@collabora.co.uk> References: <20170405140613.4444-1-sjoerd.simons@collabora.co.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On a board with a usb->sata bridge behind a usb hub, the bridge only appears on cold boot and becomes non-functional after a reboot. Testing thusfar shows that it gets confused during reboot if the usb hub is left on (Interestingly a similar setup without the usb hub in between doesn't have the issue). This can be avoided by turning off the phy (thus vbus) during shutdown, which turns off the usb hub. For devices where this isn't required, powering down the phy is harmless so we can do this unconditionally. Signed-off-by: Sjoerd Simons --- drivers/usb/dwc2/platform.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.11.0 diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c index 9564bc76c56f..b5bbc433c94d 100644 --- a/drivers/usb/dwc2/platform.c +++ b/drivers/usb/dwc2/platform.c @@ -348,6 +348,9 @@ static void dwc2_driver_shutdown(struct platform_device *dev) { struct dwc2_hsotg *hsotg = platform_get_drvdata(dev); + if (hsotg->phy) + phy_power_off(hsotg->phy); + disable_irq(hsotg->irq); }