aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
authorSrinivas Kandagatla <srinivas.kandagatla@st.com>2013-07-04 05:35:48 -0400
committerDavid S. Miller <davem@davemloft.net>2013-07-04 17:34:17 -0400
commit0e0764715d8116484d808f5b3985ca043080788e (patch)
tree9f486c6604183917901e5385e0391943d0999e1b /drivers/net/ethernet
parent25c83b5c2e82560406d5265f42cd147f1eb441d0 (diff)
dt:net:stmmac: Add dt specific phy reset callback support.
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: _________ ____________ <pre-delay> |<pulse-delay> |<post-delay> | | |_______________| active high: ________________ <pre-delay> |<pulse-delay> |<post-delay> | | ________| |___________ Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c48
1 files changed, 46 insertions, 2 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index cc15039eaa47..fe7bc9903867 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -27,6 +27,9 @@
27#include <linux/mii.h> 27#include <linux/mii.h>
28#include <linux/phy.h> 28#include <linux/phy.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30#include <linux/of.h>
31#include <linux/of_gpio.h>
32
30#include <asm/io.h> 33#include <asm/io.h>
31 34
32#include "stmmac.h" 35#include "stmmac.h"
@@ -131,10 +134,46 @@ static int stmmac_mdio_reset(struct mii_bus *bus)
131 struct net_device *ndev = bus->priv; 134 struct net_device *ndev = bus->priv;
132 struct stmmac_priv *priv = netdev_priv(ndev); 135 struct stmmac_priv *priv = netdev_priv(ndev);
133 unsigned int mii_address = priv->hw->mii.addr; 136 unsigned int mii_address = priv->hw->mii.addr;
137 struct stmmac_mdio_bus_data *data = priv->plat->mdio_bus_data;
138
139#ifdef CONFIG_OF
140 if (priv->device->of_node) {
141 int reset_gpio, active_low;
142
143 if (data->reset_gpio < 0) {
144 struct device_node *np = priv->device->of_node;
145 if (!np)
146 return 0;
147
148 data->reset_gpio = of_get_named_gpio(np,
149 "snps,reset-gpio", 0);
150 if (data->reset_gpio < 0)
151 return 0;
152
153 data->active_low = of_property_read_bool(np,
154 "snps,reset-active-low");
155 of_property_read_u32_array(np,
156 "snps,reset-delays-us", data->delays, 3);
157 }
158
159 reset_gpio = data->reset_gpio;
160 active_low = data->active_low;
161
162 if (!gpio_request(reset_gpio, "mdio-reset")) {
163 gpio_direction_output(reset_gpio, active_low ? 1 : 0);
164 udelay(data->delays[0]);
165 gpio_set_value(reset_gpio, active_low ? 0 : 1);
166 udelay(data->delays[1]);
167 gpio_set_value(reset_gpio, active_low ? 1 : 0);
168 udelay(data->delays[2]);
169 gpio_free(reset_gpio);
170 }
171 }
172#endif
134 173
135 if (priv->plat->mdio_bus_data->phy_reset) { 174 if (data->phy_reset) {
136 pr_debug("stmmac_mdio_reset: calling phy_reset\n"); 175 pr_debug("stmmac_mdio_reset: calling phy_reset\n");
137 priv->plat->mdio_bus_data->phy_reset(priv->plat->bsp_priv); 176 data->phy_reset(priv->plat->bsp_priv);
138 } 177 }
139 178
140 /* This is a workaround for problems with the STE101P PHY. 179 /* This is a workaround for problems with the STE101P PHY.
@@ -172,6 +211,11 @@ int stmmac_mdio_register(struct net_device *ndev)
172 else 211 else
173 irqlist = priv->mii_irq; 212 irqlist = priv->mii_irq;
174 213
214#ifdef CONFIG_OF
215 if (priv->device->of_node)
216 mdio_bus_data->reset_gpio = -1;
217#endif
218
175 new_bus->name = "stmmac"; 219 new_bus->name = "stmmac";
176 new_bus->read = &stmmac_mdio_read; 220 new_bus->read = &stmmac_mdio_read;
177 new_bus->write = &stmmac_mdio_write; 221 new_bus->write = &stmmac_mdio_write;