Commit 4e18a8a1 authored by David S. Miller's avatar David S. Miller

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: default avatarDavid S. Miller <davem@davemloft.net>
parents a5148626 fead5b1b
...@@ -24,9 +24,9 @@ ...@@ -24,9 +24,9 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/iopoll.h> #include <linux/iopoll.h>
#include <linux/mii.h> #include <linux/mii.h>
#include <linux/of.h>
#include <linux/of_mdio.h> #include <linux/of_mdio.h>
#include <linux/phy.h> #include <linux/phy.h>
#include <linux/property.h>
#include <linux/slab.h> #include <linux/slab.h>
#include "dwxgmac2.h" #include "dwxgmac2.h"
...@@ -247,17 +247,11 @@ int stmmac_mdio_reset(struct mii_bus *bus) ...@@ -247,17 +247,11 @@ int stmmac_mdio_reset(struct mii_bus *bus)
struct net_device *ndev = bus->priv; struct net_device *ndev = bus->priv;
struct stmmac_priv *priv = netdev_priv(ndev); struct stmmac_priv *priv = netdev_priv(ndev);
unsigned int mii_address = priv->hw->mii.addr; unsigned int mii_address = priv->hw->mii.addr;
struct stmmac_mdio_bus_data *data = priv->plat->mdio_bus_data;
#ifdef CONFIG_OF #ifdef CONFIG_OF
if (priv->device->of_node) { if (priv->device->of_node) {
struct gpio_desc *reset_gpio; struct gpio_desc *reset_gpio;
u32 delays[3];
if (data->reset_gpio < 0) {
struct device_node *np = priv->device->of_node;
if (!np)
return 0;
reset_gpio = devm_gpiod_get_optional(priv->device, reset_gpio = devm_gpiod_get_optional(priv->device,
"snps,reset", "snps,reset",
...@@ -265,32 +259,23 @@ int stmmac_mdio_reset(struct mii_bus *bus) ...@@ -265,32 +259,23 @@ int stmmac_mdio_reset(struct mii_bus *bus)
if (IS_ERR(reset_gpio)) if (IS_ERR(reset_gpio))
return PTR_ERR(reset_gpio); return PTR_ERR(reset_gpio);
of_property_read_u32_array(np, device_property_read_u32_array(priv->device,
"snps,reset-delays-us", data->delays, 3); "snps,reset-delays-us",
} else { delays, ARRAY_SIZE(delays));
reset_gpio = gpio_to_desc(data->reset_gpio);
gpiod_direction_output(reset_gpio, 0);
}
if (data->delays[0]) if (delays[0])
msleep(DIV_ROUND_UP(data->delays[0], 1000)); msleep(DIV_ROUND_UP(delays[0], 1000));
gpiod_set_value_cansleep(reset_gpio, 1); gpiod_set_value_cansleep(reset_gpio, 1);
if (data->delays[1]) if (delays[1])
msleep(DIV_ROUND_UP(data->delays[1], 1000)); msleep(DIV_ROUND_UP(delays[1], 1000));
gpiod_set_value_cansleep(reset_gpio, 0); gpiod_set_value_cansleep(reset_gpio, 0);
if (data->delays[2]) if (delays[2])
msleep(DIV_ROUND_UP(data->delays[2], 1000)); msleep(DIV_ROUND_UP(delays[2], 1000));
} }
#endif #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. /* This is a workaround for problems with the STE101P PHY.
* It doesn't complete its reset until at least one clock cycle * 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 * 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) ...@@ -327,11 +312,6 @@ int stmmac_mdio_register(struct net_device *ndev)
if (mdio_bus_data->irqs) if (mdio_bus_data->irqs)
memcpy(new_bus->irq, mdio_bus_data->irqs, sizeof(new_bus->irq)); 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"; new_bus->name = "stmmac";
if (priv->plat->has_xgmac) { if (priv->plat->has_xgmac) {
......
...@@ -73,7 +73,6 @@ static void common_default_data(struct plat_stmmacenet_data *plat) ...@@ -73,7 +73,6 @@ static void common_default_data(struct plat_stmmacenet_data *plat)
plat->has_gmac = 1; plat->has_gmac = 1;
plat->force_sf_dma_mode = 1; plat->force_sf_dma_mode = 1;
plat->mdio_bus_data->phy_reset = NULL;
plat->mdio_bus_data->phy_mask = 0; plat->mdio_bus_data->phy_mask = 0;
/* Set default value for multicast hash bins */ /* Set default value for multicast hash bins */
......
...@@ -92,14 +92,9 @@ ...@@ -92,14 +92,9 @@
/* Platfrom data for platform device structure's platform_data field */ /* Platfrom data for platform device structure's platform_data field */
struct stmmac_mdio_bus_data { struct stmmac_mdio_bus_data {
int (*phy_reset)(void *priv);
unsigned int phy_mask; unsigned int phy_mask;
int *irqs; int *irqs;
int probed_phy_irq; int probed_phy_irq;
#ifdef CONFIG_OF
int reset_gpio;
u32 delays[3];
#endif
}; };
struct stmmac_dma_cfg { struct stmmac_dma_cfg {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment