From patchwork Wed Aug 14 13:58:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 2844616 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 F3028BF546 for ; Wed, 14 Aug 2013 14:40:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3937420510 for ; Wed, 14 Aug 2013 14:40:08 +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 7CA90204A2 for ; Wed, 14 Aug 2013 14:40:06 +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 1V9bco-00089C-Px; Wed, 14 Aug 2013 14:00:35 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V9bcF-0001ty-1c; Wed, 14 Aug 2013 13:59:59 +0000 Received: from devils.ext.ti.com ([198.47.26.153]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V9bbF-0001jo-Go for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2013 13:58:59 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id r7EDwMbV012615; Wed, 14 Aug 2013 08:58:22 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r7EDwMfB006393; Wed, 14 Aug 2013 08:58:22 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.2.342.3; Wed, 14 Aug 2013 08:58:22 -0500 Received: from localhost.localdomain (h114-147.vpn.ti.com [172.24.114.147]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r7EDwFvU032460; Wed, 14 Aug 2013 08:58:20 -0500 From: Roger Quadros To: , , Subject: [PATCH 2/9] usb: phy: nop: Don't use regulator framework for RESET line Date: Wed, 14 Aug 2013 16:58:06 +0300 Message-ID: <1376488693-31659-3-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1376488693-31659-1-git-send-email-rogerq@ti.com> References: <1376488693-31659-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-20130814_095858_331379_36C54092 X-CRM114-Status: GOOD ( 16.92 ) X-Spam-Score: -9.7 (---------) Cc: devicetree@vger.kernel.org, linux-usb@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=-7.0 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 Modelling the RESET line as a regulator supply wasn't a good idea as it kind of abuses the regulator framework and also makes adaptation code more complex. Instead, manage the RESET gpio line directly in the driver. Update the device tree binding information. This also makes us easy to migrate to a dedicated GPIO RESET controller whenever it becomes available. Signed-off-by: Roger Quadros Acked-by: Philipp Zabel --- .../devicetree/bindings/usb/usb-nop-xceiv.txt | 7 +-- drivers/usb/phy/phy-nop.c | 48 ++++++++++++-------- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt b/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt index d7e2726..5535f3b 100644 --- a/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt +++ b/Documentation/devicetree/bindings/usb/usb-nop-xceiv.txt @@ -15,7 +15,7 @@ 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. +- reset-gpios: Should specify the GPIO for reset. Example: @@ -25,10 +25,9 @@ Example: clocks = <&osc 0>; clock-names = "main_clk"; vcc-supply = <&hsusb1_vcc_regulator>; - reset-supply = <&hsusb1_reset_regulator>; + reset-gpios = <&gpio1 7>; }; 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 GPIO 7 controls RESET. diff --git a/drivers/usb/phy/phy-nop.c b/drivers/usb/phy/phy-nop.c index 55445e5d..af5e1a6 100644 --- a/drivers/usb/phy/phy-nop.c +++ b/drivers/usb/phy/phy-nop.c @@ -35,6 +35,9 @@ #include #include #include +#include +#include +#include struct nop_usb_xceiv { struct usb_phy phy; @@ -42,6 +45,7 @@ struct nop_usb_xceiv { struct clk *clk; struct regulator *vcc; struct regulator *reset; + int gpio_reset; }; static struct platform_device *pd; @@ -70,6 +74,15 @@ static int nop_set_suspend(struct usb_phy *x, int suspend) return 0; } +static void nop_gpio_reset(int gpio, int state) +{ + if (gpio_is_valid(gpio)) + gpio_set_value(gpio, state); + + if (state) + usleep_range(10000, 20000); +} + static int nop_init(struct usb_phy *phy) { struct nop_usb_xceiv *nop = dev_get_drvdata(phy->dev); @@ -82,11 +95,8 @@ static int nop_init(struct usb_phy *phy) if (!IS_ERR(nop->clk)) clk_enable(nop->clk); - if (!IS_ERR(nop->reset)) { - /* De-assert RESET */ - if (regulator_enable(nop->reset)) - dev_err(phy->dev, "Failed to de-assert reset\n"); - } + /* De-assert RESET */ + nop_gpio_reset(nop->gpio_reset, 1); return 0; } @@ -95,11 +105,8 @@ static void nop_shutdown(struct usb_phy *phy) { struct nop_usb_xceiv *nop = dev_get_drvdata(phy->dev); - if (!IS_ERR(nop->reset)) { - /* Assert RESET */ - if (regulator_disable(nop->reset)) - dev_err(phy->dev, "Failed to assert reset\n"); - } + /* Assert RESET */ + nop_gpio_reset(nop->gpio_reset, 0); if (!IS_ERR(nop->clk)) clk_disable(nop->clk); @@ -148,7 +155,6 @@ static int nop_usb_xceiv_probe(struct platform_device *pdev) int err; u32 clk_rate = 0; bool needs_vcc = false; - bool needs_reset = false; nop = devm_kzalloc(&pdev->dev, sizeof(*nop), GFP_KERNEL); if (!nop) @@ -166,13 +172,15 @@ 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"); + nop->gpio_reset = of_get_named_gpio(node, "reset-gpios", 0); + if (nop->gpio_reset == -EPROBE_DEFER) + return -EPROBE_DEFER; } else if (pdata) { type = pdata->type; clk_rate = pdata->clk_rate; needs_vcc = pdata->needs_vcc; - needs_reset = pdata->needs_reset; + nop->gpio_reset = pdata->gpio_reset; } nop->clk = devm_clk_get(&pdev->dev, "main_clk"); @@ -205,12 +213,14 @@ 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", - PTR_ERR(nop->reset)); - if (needs_reset) - return -EPROBE_DEFER; + if (gpio_is_valid(nop->gpio_reset)) { + err = devm_gpio_request_one(dev, nop->gpio_reset, + GPIOF_OUT_INIT_HIGH, dev_name(dev)); + if (err) { + dev_err(dev, "Error requesting RESET GPIO %d\n", + nop->gpio_reset); + return err; + } } nop->dev = &pdev->dev;