diff options
author | David S. Miller <davem@davemloft.net> | 2019-06-16 13:53:41 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-06-16 13:55:29 -0700 |
commit | 4e18a8a149d5577a171ddc5fe80cc715041b193d (patch) | |
tree | 0c4548f093eb88427d8c17bae8af3f2c29f132ab /drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | |
parent | a51486266c3ba8e035a47fa96df67f274fe0c7d0 (diff) | |
parent | fead5b1b5838ba2f231d76e1b8ed31a4e9449382 (diff) | |
download | linux-4e18a8a149d5577a171ddc5fe80cc715041b193d.tar.bz2 |
Merge branch 'stmmac-cleanups-for-stmmac_mdio_reset'
Martin Blumenstingl says:
====================
stmmac: cleanups for stmmac_mdio_reset
This is a successor to my previous series "stmmac: honor the GPIO flags
for the PHY reset GPIO" from [0]. It contains only the "cleanup"
patches from that series plus some additional cleanups on top.
I broke out the actual GPIO flag handling into a separate patch which
is already part of net-next: "net: stmmac: use GPIO descriptors in
stmmac_mdio_reset" from [1]
I have build and runtime tested this on my ARM Meson8b Odroid-C1.
[0] https://patchwork.kernel.org/cover/10983801/
[1] https://patchwork.ozlabs.org/patch/1114798/
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c')
-rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 52 |
1 files changed, 16 insertions, 36 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index f1c39dd048e7..14aa3ee14082 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -24,9 +24,9 @@ #include <linux/io.h> #include <linux/iopoll.h> #include <linux/mii.h> -#include <linux/of.h> #include <linux/of_mdio.h> #include <linux/phy.h> +#include <linux/property.h> #include <linux/slab.h> #include "dwxgmac2.h" @@ -247,50 +247,35 @@ 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 stmmac_mdio_bus_data *data = priv->plat->mdio_bus_data; #ifdef CONFIG_OF if (priv->device->of_node) { struct gpio_desc *reset_gpio; + u32 delays[3]; - if (data->reset_gpio < 0) { - struct device_node *np = priv->device->of_node; + reset_gpio = devm_gpiod_get_optional(priv->device, + "snps,reset", + GPIOD_OUT_LOW); + if (IS_ERR(reset_gpio)) + return PTR_ERR(reset_gpio); - if (!np) - return 0; + device_property_read_u32_array(priv->device, + "snps,reset-delays-us", + delays, ARRAY_SIZE(delays)); - reset_gpio = devm_gpiod_get_optional(priv->device, - "snps,reset", - GPIOD_OUT_LOW); - if (IS_ERR(reset_gpio)) - return PTR_ERR(reset_gpio); - - of_property_read_u32_array(np, - "snps,reset-delays-us", data->delays, 3); - } else { - reset_gpio = gpio_to_desc(data->reset_gpio); - - gpiod_direction_output(reset_gpio, 0); - } - - if (data->delays[0]) - msleep(DIV_ROUND_UP(data->delays[0], 1000)); + if (delays[0]) + msleep(DIV_ROUND_UP(delays[0], 1000)); gpiod_set_value_cansleep(reset_gpio, 1); - if (data->delays[1]) - msleep(DIV_ROUND_UP(data->delays[1], 1000)); + if (delays[1]) + msleep(DIV_ROUND_UP(delays[1], 1000)); gpiod_set_value_cansleep(reset_gpio, 0); - if (data->delays[2]) - msleep(DIV_ROUND_UP(data->delays[2], 1000)); + if (delays[2]) + msleep(DIV_ROUND_UP(delays[2], 1000)); } #endif - if (data->phy_reset) { - netdev_dbg(ndev, "stmmac_mdio_reset: calling phy_reset\n"); - data->phy_reset(priv->plat->bsp_priv); - } - /* This is a workaround for problems with the STE101P PHY. * It doesn't complete its reset until at least one clock cycle * on MDC, so perform a dummy mdio read. To be updated for GMAC4 @@ -327,11 +312,6 @@ int stmmac_mdio_register(struct net_device *ndev) if (mdio_bus_data->irqs) memcpy(new_bus->irq, mdio_bus_data->irqs, sizeof(new_bus->irq)); -#ifdef CONFIG_OF - if (priv->device->of_node) - mdio_bus_data->reset_gpio = -1; -#endif - new_bus->name = "stmmac"; if (priv->plat->has_xgmac) { |