aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/net/stmmac.txt6
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c48
-rw-r--r--include/linux/stmmac.h4
3 files changed, 56 insertions, 2 deletions
diff --git a/Documentation/devicetree/bindings/net/stmmac.txt b/Documentation/devicetree/bindings/net/stmmac.txt
index e1ddfcc46a4e..261c563b5f06 100644
--- a/Documentation/devicetree/bindings/net/stmmac.txt
+++ b/Documentation/devicetree/bindings/net/stmmac.txt
@@ -13,6 +13,12 @@ Required properties:
13- phy-mode: String, operation mode of the PHY interface. 13- phy-mode: String, operation mode of the PHY interface.
14 Supported values are: "mii", "rmii", "gmii", "rgmii". 14 Supported values are: "mii", "rmii", "gmii", "rgmii".
15- snps,phy-addr phy address to connect to. 15- snps,phy-addr phy address to connect to.
16- snps,reset-gpio gpio number for phy reset.
17- snps,reset-active-low boolean flag to indicate if phy reset is active low.
18- snps,reset-delays-us is triplet of delays
19 The 1st cell is reset pre-delay in micro seconds.
20 The 2nd cell is reset pulse in micro seconds.
21 The 3rd cell is reset post-delay in micro seconds.
16- snps,pbl Programmable Burst Length 22- snps,pbl Programmable Burst Length
17- snps,fixed-burst Program the DMA to use the fixed burst mode 23- snps,fixed-burst Program the DMA to use the fixed burst mode
18- snps,mixed-burst Program the DMA to use the mixed burst mode 24- 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 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;
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index c1b3ed3fb787..9e495d31516e 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -80,6 +80,10 @@ struct stmmac_mdio_bus_data {
80 unsigned int phy_mask; 80 unsigned int phy_mask;
81 int *irqs; 81 int *irqs;
82 int probed_phy_irq; 82 int probed_phy_irq;
83#ifdef CONFIG_OF
84 int reset_gpio, active_low;
85 u32 delays[3];
86#endif
83}; 87};
84 88
85struct stmmac_dma_cfg { 89struct stmmac_dma_cfg {