From patchwork Thu Jul 18 08:53:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 2829545 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9965EC0AB2 for ; Thu, 18 Jul 2013 08:55:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 641D3201F2 for ; Thu, 18 Jul 2013 08:55:11 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BCC89201EC for ; Thu, 18 Jul 2013 08:55:09 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UzjyN-0002Cw-Dk; Thu, 18 Jul 2013 08:54:03 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UzjyC-0004r9-Qn; Thu, 18 Jul 2013 08:53:52 +0000 Received: from arroyo.ext.ti.com ([192.94.94.40]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uzjxz-0004o0-4R for linux-arm-kernel@lists.infradead.org; Thu, 18 Jul 2013 08:53:42 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id r6I8rHB6031089; Thu, 18 Jul 2013 03:53:17 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r6I8rHmd014214; Thu, 18 Jul 2013 03:53:17 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.2.342.3; Thu, 18 Jul 2013 03:53:16 -0500 Received: from localhost.localdomain (h56-67.vpn.ti.com [172.24.56.67]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r6I8rBME011276; Thu, 18 Jul 2013 03:53:14 -0500 From: Roger Quadros To: , Subject: [PATCH 1/6] usb: phy-nop: Use RESET Controller for managing the reset line Date: Thu, 18 Jul 2013 11:53:05 +0300 Message-ID: <1374137590-17865-2-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1374137590-17865-1-git-send-email-rogerq@ti.com> References: <1374137590-17865-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130718_045339_391019_4C6D0ED4 X-CRM114-Status: GOOD ( 17.33 ) X-Spam-Score: -7.3 (-------) Cc: devicetree-discuss@lists.ozlabs.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, p.zabel@pengutronix.de, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Roger Quadros X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Till now we were modelling the RESET line as a voltage regulator and using the regulator framework to manage it. [1] introduces a GPIO based reset controller driver. We use that to manage the PHY reset line, at least for DT boots. For legacy boots, will still need to use the regulator framework for reset lines. [1] - http://thread.gmane.org/gmane.linux.drivers.devicetree/41348 Signed-off-by: Roger Quadros --- .../devicetree/bindings/usb/usb-nop-xceiv.txt | 10 +++-- drivers/usb/phy/Kconfig | 1 + drivers/usb/phy/phy-nop.c | 48 +++++++++++++++----- 3 files changed, 44 insertions(+), 15 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt b/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt index d7e2726..5c3e978 100644 --- a/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt +++ b/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt @@ -15,7 +15,9 @@ Optional properties: - vcc-supply: phandle to the regulator that provides RESET to the PHY. -- reset-supply: phandle to the regulator that provides power to the PHY. +- resets: phandle to the reset controller. + +- reset-names: must be "reset" Example: @@ -25,10 +27,10 @@ Example: clocks = <&osc 0>; clock-names = "main_clk"; vcc-supply = <&hsusb1_vcc_regulator>; - reset-supply = <&hsusb1_reset_regulator>; + resets = <&hsusb1_reset>; + reset-names = "reset" }; hsusb1_phy is a NOP USB PHY device that gets its clock from an oscillator and expects that clock to be configured to 19.2MHz by the NOP PHY driver. -hsusb1_vcc_regulator provides power to the PHY and hsusb1_reset_regulator -controls RESET. +hsusb1_vcc_regulator provides power to the PHY and hsusb1_reset controls RESET. diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index 3622fff..213b5ad 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig @@ -58,6 +58,7 @@ config MV_U3D_PHY config NOP_USB_XCEIV tristate "NOP USB Transceiver Driver" + depends on RESET_CONTROLLER help This driver is to be used by all the usb transceiver which are either built-in with usb ip or which are autonomous and doesn't require any diff --git a/drivers/usb/phy/phy-nop.c b/drivers/usb/phy/phy-nop.c index 55445e5d..a2cbda5 100644 --- a/drivers/usb/phy/phy-nop.c +++ b/drivers/usb/phy/phy-nop.c @@ -35,13 +35,15 @@ #include #include #include +#include struct nop_usb_xceiv { struct usb_phy phy; struct device *dev; struct clk *clk; struct regulator *vcc; - struct regulator *reset; + struct regulator *reset_reg; /* only used for non-DT boot */ + struct reset_control *reset; }; static struct platform_device *pd; @@ -82,9 +84,14 @@ static int nop_init(struct usb_phy *phy) if (!IS_ERR(nop->clk)) clk_enable(nop->clk); + /* De-assert RESET */ + if (!IS_ERR(nop->reset_reg)) { + if (regulator_enable(nop->reset_reg)) + dev_err(phy->dev, "Failed to de-assert reset\n"); + } + if (!IS_ERR(nop->reset)) { - /* De-assert RESET */ - if (regulator_enable(nop->reset)) + if (reset_control_deassert(nop->reset)) dev_err(phy->dev, "Failed to de-assert reset\n"); } @@ -95,9 +102,14 @@ static void nop_shutdown(struct usb_phy *phy) { struct nop_usb_xceiv *nop = dev_get_drvdata(phy->dev); + /* Assert RESET */ + if (!IS_ERR(nop->reset_reg)) { + if (regulator_disable(nop->reset_reg)) + dev_err(phy->dev, "Failed to assert reset\n"); + } + if (!IS_ERR(nop->reset)) { - /* Assert RESET */ - if (regulator_disable(nop->reset)) + if (reset_control_assert(nop->reset)) dev_err(phy->dev, "Failed to assert reset\n"); } @@ -166,7 +178,7 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev) clk_rate = 0; needs_vcc = of_property_read_bool(node, "vcc-supply"); - needs_reset = of_property_read_bool(node, "reset-supply"); + needs_reset = of_property_read_bool(node, "resets"); } else if (pdata) { type = pdata->type; @@ -205,12 +217,26 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev) return -EPROBE_DEFER; } - nop->reset = devm_regulator_get(&pdev->dev, "reset"); - if (IS_ERR(nop->reset)) { - dev_dbg(&pdev->dev, "Error getting reset regulator: %ld\n", + nop->reset_reg = ERR_PTR(-EINVAL); + nop->reset = ERR_PTR(-EINVAL); + + if (dev->of_node) { + nop->reset = devm_reset_control_get(dev, "reset"); + if (IS_ERR(nop->reset)) { + dev_dbg(dev, "Couldn't get reset controller: %ld\n", PTR_ERR(nop->reset)); - if (needs_reset) - return -EPROBE_DEFER; + if (needs_reset && PTR_ERR(nop->reset) == -ENODEV) + return -EPROBE_DEFER; + } + + } else { + nop->reset_reg = devm_regulator_get(&pdev->dev, "reset"); + if (IS_ERR(nop->reset_reg)) { + dev_dbg(&pdev->dev, "Error getting reset regulator: %ld\n", + PTR_ERR(nop->reset_reg)); + if (needs_reset) + return -EPROBE_DEFER; + } } nop->dev = &pdev->dev;