@@ -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
@@ -27,6 +27,9 @@
#include <linux/mii.h>
#include <linux/phy.h>
#include <linux/slab.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+
#include <asm/io.h>
#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");