From patchwork Mon Jul 1 11:44:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas KANDAGATLA X-Patchwork-Id: 256097 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4679B2C0327 for ; Mon, 1 Jul 2013 21:50:26 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753988Ab3GALt6 (ORCPT ); Mon, 1 Jul 2013 07:49:58 -0400 Received: from eu1sys200aog103.obsmtp.com ([207.126.144.115]:39585 "EHLO eu1sys200aog103.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753242Ab3GALt5 (ORCPT ); Mon, 1 Jul 2013 07:49:57 -0400 Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob103.postini.com ([207.126.147.11]) with SMTP ID DSNKUdFs3BkaLAqhEfzlUaknkwdhLtuXGMBU@postini.com; Mon, 01 Jul 2013 11:49:56 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id DC294108; Mon, 1 Jul 2013 11:49:47 +0000 (GMT) Received: from mail7.sgp.st.com (unknown [164.129.223.81]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 5E9B24CD2; Mon, 1 Jul 2013 11:49:21 +0000 (GMT) Received: from localhost (king.bri.st.com [10.65.51.59]) by mail7.sgp.st.com (MOS 4.3.3-GA) with ESMTP id BGV13298 (AUTH srinivak); Mon, 1 Jul 2013 13:49:46 +0200 From: Srinivas KANDAGATLA To: netdev@vger.kernel.org Cc: Giuseppe Cavallaro , Grant Likely , Rob Herring , Rob Landley , devicetree-discuss@lists.ozlabs.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH RFC 3/3] dt:net:stmmac: Add dt specific phy reset callback support. Date: Mon, 1 Jul 2013 12:44:05 +0100 Message-Id: <1372679045-13183-1-git-send-email-srinivas.kandagatla@st.com> X-Mailer: git-send-email 1.7.6.5 In-Reply-To: <1372678962-12959-1-git-send-email-srinivas.kandagatla@st.com> References: <1372678962-12959-1-git-send-email-srinivas.kandagatla@st.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Srinivas Kandagatla This patch adds phy reset callback support for stmmac driver via device trees. It adds three new properties to gmac device tree bindings to define the reset signal via gpio. With this patch users can conveniently pass reset gpio number with pre, pulse and post delay in micro secs via DTs. active low: _________ ____________ | | | | |_______________| active high: ________________ | | | | ________| |___________ Signed-off-by: Srinivas Kandagatla --- Documentation/devicetree/bindings/net/stmmac.txt | 6 ++++ drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 31 +++++++++++++++++++++ 2 files changed, 37 insertions(+), 0 deletions(-) diff --git a/Documentation/devicetree/bindings/net/stmmac.txt b/Documentation/devicetree/bindings/net/stmmac.txt index e1ddfcc..261c563 100644 --- a/Documentation/devicetree/bindings/net/stmmac.txt +++ b/Documentation/devicetree/bindings/net/stmmac.txt @@ -13,6 +13,12 @@ Required properties: - phy-mode: String, operation mode of the PHY interface. Supported values are: "mii", "rmii", "gmii", "rgmii". - snps,phy-addr phy address to connect to. +- snps,reset-gpio gpio number for phy reset. +- snps,reset-active-low boolean flag to indicate if phy reset is active low. +- snps,reset-delays-us is triplet of delays + The 1st cell is reset pre-delay in micro seconds. + The 2nd cell is reset pulse in micro seconds. + The 3rd cell is reset post-delay in micro seconds. - snps,pbl Programmable Burst Length - snps,fixed-burst Program the DMA to use the fixed burst mode - snps,mixed-burst Program the DMA to use the mixed burst mode diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index cc15039..677ed16 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -27,6 +27,9 @@ #include #include #include +#include +#include + #include #include "stmmac.h" @@ -131,6 +134,34 @@ static int stmmac_mdio_reset(struct mii_bus *bus) struct net_device *ndev = bus->priv; struct stmmac_priv *priv = netdev_priv(ndev); unsigned int mii_address = priv->hw->mii.addr; + struct device *dev = priv->device; + + if (dev->of_node) { + int reset_gpio, active_low; + struct device_node *np = dev->of_node; + u32 delays[3] = {0,}; + + if (!np) + return 0; + + reset_gpio = of_get_named_gpio(np, "snps,reset-gpio", 0); + if (reset_gpio < 0) + return 0; + + active_low = of_property_read_bool(np, + "snps,reset-active-low"); + of_property_read_u32_array(np, + "snps,reset-delays-us", delays, 3); + + gpio_request(reset_gpio, "mdio-reset"); + gpio_direction_output(reset_gpio, active_low ? 1 : 0); + udelay(delays[0]); + gpio_set_value(reset_gpio, active_low ? 0 : 1); + udelay(delays[1]); + gpio_set_value(reset_gpio, active_low ? 1 : 0); + udelay(delays[2]); + gpio_free(reset_gpio); + } if (priv->plat->mdio_bus_data->phy_reset) { pr_debug("stmmac_mdio_reset: calling phy_reset\n");