mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 21:38:32 +08:00
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>
This commit is contained in:
commit
4e18a8a149
@ -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) {
|
||||
|
@ -73,7 +73,6 @@ static void common_default_data(struct plat_stmmacenet_data *plat)
|
||||
plat->has_gmac = 1;
|
||||
plat->force_sf_dma_mode = 1;
|
||||
|
||||
plat->mdio_bus_data->phy_reset = NULL;
|
||||
plat->mdio_bus_data->phy_mask = 0;
|
||||
|
||||
/* Set default value for multicast hash bins */
|
||||
|
@ -92,14 +92,9 @@
|
||||
/* Platfrom data for platform device structure's platform_data field */
|
||||
|
||||
struct stmmac_mdio_bus_data {
|
||||
int (*phy_reset)(void *priv);
|
||||
unsigned int phy_mask;
|
||||
int *irqs;
|
||||
int probed_phy_irq;
|
||||
#ifdef CONFIG_OF
|
||||
int reset_gpio;
|
||||
u32 delays[3];
|
||||
#endif
|
||||
};
|
||||
|
||||
struct stmmac_dma_cfg {
|
||||
|
Loading…
Reference in New Issue
Block a user