From patchwork Thu Jan 24 16:07:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 2033481 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id A893BDF264 for ; Thu, 24 Jan 2013 16:11:22 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TyPM2-0006Vs-GM; Thu, 24 Jan 2013 16:08:42 +0000 Received: from moutng.kundenserver.de ([212.227.126.187]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TyPLD-0005rR-EK for linux-arm-kernel@lists.infradead.org; Thu, 24 Jan 2013 16:07:53 +0000 Received: from axis700.grange (dslb-094-221-098-036.pools.arcor-ip.net [94.221.98.36]) by mrelayeu.kundenserver.de (node=mrbap1) with ESMTP (Nemesis) id 0MdXQK-1UNbhD3wpo-00PkCg; Thu, 24 Jan 2013 17:07:44 +0100 Received: from 6a.grange (6a.grange [192.168.1.11]) by axis700.grange (Postfix) with ESMTPS id 72E5540B98; Thu, 24 Jan 2013 17:07:43 +0100 (CET) Received: from lyakh by 6a.grange with local (Exim 4.72) (envelope-from ) id 1TyPL5-0002y4-67; Thu, 24 Jan 2013 17:07:43 +0100 From: Guennadi Liakhovetski To: linux-sh@vger.kernel.org Subject: [PATCH/RFC 2/3] ethernet: add a PHY reset GPIO DT binding to sh_eth Date: Thu, 24 Jan 2013 17:07:32 +0100 Message-Id: <1359043653-11374-3-git-send-email-g.liakhovetski@gmx.de> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1359043653-11374-1-git-send-email-g.liakhovetski@gmx.de> References: <1359043653-11374-1-git-send-email-g.liakhovetski@gmx.de> X-Provags-ID: V02:K0:UiPW7DNkOzigMZchvklYdSjUt6FA70IREjplLS9M02B ITgrP/y7VBgED2BjuxccS1RF0dPG7rAdIstOQ5VY1MsNt8ym8O W9aVoiQY5l+NmCumDm5cKavKX03uHT77oPvuDSodX6uG7tQOtI Qt3/90xww6u8QLP4sArOw46zH7uVKPcWYOKQalyS3zKInHt99F 7mqmw0+U7o+9bcDz2D+vXYpLKujEaB9uhJABCfGJ3BPBHRzI8I HpZq8hwPCONYF7dMp6EZkFImMJcVWDxct8mMEuMhArcFbHhVJE CDwQxQ81pWAU4oASVa4brn8mS4QI36hK6JBJCuJRpxgCV83rqL BJGGPl7jPXkU90ZUVspXlpUChbXgxIw92eS88tQMRghcvTW7J6 7OjSwzuOhq0MQ== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130124_110751_722540_D5BDCC15 X-CRM114-Status: GOOD ( 13.49 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [212.227.126.187 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (g.liakhovetski[at]gmx.de) -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: netdev@vger.kernel.org, devicetree-discuss@lists.ozlabs.org, Magnus Damm , Simon Horman , Guennadi Liakhovetski , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org If an ethernet PHY can be reset by a GPIO, it can be specified in DT. Add a binding and code to parse it, request the GPIO and take the PHY out of reset. Signed-off-by: Guennadi Liakhovetski Cc: devicetree-discuss@lists.ozlabs.org Cc: netdev@vger.kernel.org --- Documentation/devicetree/bindings/net/sh_ether.txt | 2 ++ drivers/net/ethernet/renesas/sh_eth.c | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletions(-) diff --git a/Documentation/devicetree/bindings/net/sh_ether.txt b/Documentation/devicetree/bindings/net/sh_ether.txt index c11e45d..edaf683 100644 --- a/Documentation/devicetree/bindings/net/sh_ether.txt +++ b/Documentation/devicetree/bindings/net/sh_ether.txt @@ -12,6 +12,7 @@ Required properties: - interrupts: Interrupt mapping for the sh_eth interrupt sources (vector id). - phy-mode: String, operation mode of the PHY interface. +- phy-reset-gpios: PHY reset GPIO tuple - sh-eth,edmac-endian: String, endian of sh_eth dmac. - sh-eth,register-type: String, register type of sh_eth. Please select "gigabit", "fast-sh4" or @@ -37,6 +38,7 @@ Example (armadillo800eva): reg = <0xe9a00000 0x800>, <0xe9a01800 0x800>; interrupts = <0x500>; phy-mode = "mii"; + phy-reset-gpios = <&gpio 18 0>; sh-eth,edmac-endian = "little"; sh-eth,register-type = "gigabit"; sh-eth,phy-id = <0>; diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 1f64848..06035a2 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -20,6 +20,7 @@ * the file called "COPYING". */ +#include #include #include #include @@ -33,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -2376,10 +2378,11 @@ sh_eth_of_get_register_type(struct device_node *np) static struct sh_eth_plat_data * sh_eth_parse_dt(struct device *dev, struct net_device *ndev) { - int ret; + int ret, gpio; const char *of_str; struct device_node *np = dev->of_node; struct sh_eth_plat_data *pdata; + enum of_gpio_flags flags; pdata = devm_kzalloc(dev, sizeof(struct sh_eth_plat_data), GFP_KERNEL); @@ -2420,6 +2423,10 @@ sh_eth_parse_dt(struct device *dev, struct net_device *ndev) else pdata->needs_init = 0; + gpio = of_get_named_gpio_flags(np, "phy-reset-gpios", 0, &flags); + if (gpio_is_valid(gpio) && !devm_gpio_request(dev, gpio, NULL)) + gpio_direction_output(gpio, !!(flags & OF_GPIO_ACTIVE_LOW)); + #ifdef CONFIG_OF_NET if (!is_valid_ether_addr(ndev->dev_addr)) { const char *macaddr = of_get_mac_address(np);