From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754140AbaEGD50 (ORCPT ); Tue, 6 May 2014 23:57:26 -0400 Received: from top.free-electrons.com ([176.31.233.9]:56099 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751129AbaEGD5Z (ORCPT ); Tue, 6 May 2014 23:57:25 -0400 From: Maxime Ripard To: Emilio Lopez , Mike Turquette , stern@rowland.harvard.edu, kishon@ti.com, hdegoede@redhat.com Cc: Boris Brezillon , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-usb@vger.kernel.org, kevin.z.m.zh@gmail.com, sunny@allwinnertech.com, shuge@allwinnertech.com, zhuzhenhua@allwinnertech.com, linux-sunxi@googlegroups.com, Boris BREZILLON , Maxime Ripard Subject: [PATCH 4/7] usb: ehci-platform: add optional reset controller retrieval Date: Tue, 6 May 2014 22:50:20 -0500 Message-Id: <1399434623-20383-5-git-send-email-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1399434623-20383-1-git-send-email-maxime.ripard@free-electrons.com> References: <1399434623-20383-1-git-send-email-maxime.ripard@free-electrons.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Boris BREZILLON On the Allwinner's A31 SoC the reset line connected to the EHCI IP has to be deasserted for the EHCI block to be usable. Add support for an optional reset controller that will be deasserted on power off and asserted on power on. Signed-off-by: Boris BREZILLON Signed-off-by: Maxime Ripard --- Documentation/devicetree/bindings/usb/usb-ehci.txt | 1 + drivers/usb/host/ehci-platform.c | 25 +++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/usb/usb-ehci.txt b/Documentation/devicetree/bindings/usb/usb-ehci.txt index ff151ec084c4..43c1a4e06767 100644 --- a/Documentation/devicetree/bindings/usb/usb-ehci.txt +++ b/Documentation/devicetree/bindings/usb/usb-ehci.txt @@ -15,6 +15,7 @@ Optional properties: - clocks : a list of phandle + clock specifier pairs - phys : phandle + phy specifier pair - phy-names : "usb" + - resets : phandle + reset specifier pair Example (Sequoia 440EPx): ehci@e0000300 { diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index c7dd93aad20c..4ee67728e443 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 @@ -41,6 +42,7 @@ struct ehci_platform_priv { struct clk *clks[EHCI_MAX_CLKS]; + struct reset_control *rst; struct phy *phy; }; @@ -84,10 +86,16 @@ static int ehci_platform_power_on(struct platform_device *dev) goto err_disable_clks; } + if (priv->rst) { + ret = reset_control_deassert(priv->rst); + if (ret) + goto err_disable_clks; + } + if (priv->phy) { ret = phy_init(priv->phy); if (ret) - goto err_disable_clks; + goto err_assert_rst; ret = phy_power_on(priv->phy); if (ret) @@ -98,6 +106,9 @@ static int ehci_platform_power_on(struct platform_device *dev) err_exit_phy: phy_exit(priv->phy); +err_assert_rst: + if (priv->rst) + reset_control_assert(priv->rst); err_disable_clks: while (--clk >= 0) clk_disable_unprepare(priv->clks[clk]); @@ -119,6 +130,9 @@ static void ehci_platform_power_off(struct platform_device *dev) for (clk = EHCI_MAX_CLKS - 1; clk >= 0; clk--) if (priv->clks[clk]) clk_disable_unprepare(priv->clks[clk]); + + if (priv->rst) + reset_control_assert(priv->rst); } static struct hc_driver __read_mostly ehci_platform_hc_driver; @@ -206,6 +220,15 @@ static int ehci_platform_probe(struct platform_device *dev) break; } } + + priv->rst = devm_reset_control_get_optional(&dev->dev, + NULL); + if (IS_ERR(priv->rst)) { + err = PTR_ERR(priv->rst); + if (err == -EPROBE_DEFER) + goto err_put_clks; + priv->rst = NULL; + } } if (pdata->big_endian_desc) -- 1.9.1