net: sh_eth: Initialize PHY in probe() once

Reset and initialize the PHY once in the probe() function rather than
doing it over and over again is start() function. This requires us to
keep the clock enabled while the driver is in use. This significantly
reduces the time between transfers as the PHY doesn't have to restart
autonegotiation between transfers, which takes forever.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
This commit is contained in:
Marek Vasut 2019-03-30 07:22:09 +01:00 committed by Marek Vasut
parent 317d13ac63
commit 4a45e93ff3

View file

@ -769,19 +769,9 @@ static int sh_ether_start(struct udevice *dev)
struct sh_eth_dev *eth = &priv->shdev; struct sh_eth_dev *eth = &priv->shdev;
int ret; int ret;
ret = clk_enable(&priv->clk);
if (ret)
return ret;
ret = sh_eth_init_common(eth, pdata->enetaddr); ret = sh_eth_init_common(eth, pdata->enetaddr);
if (ret) if (ret)
goto err_clk; return ret;
ret = sh_eth_phy_config(dev);
if (ret) {
printf(SHETHER_NAME ": phy config timeout\n");
goto err_start;
}
ret = sh_eth_start_common(eth); ret = sh_eth_start_common(eth);
if (ret) if (ret)
@ -792,17 +782,17 @@ static int sh_ether_start(struct udevice *dev)
err_start: err_start:
sh_eth_tx_desc_free(eth); sh_eth_tx_desc_free(eth);
sh_eth_rx_desc_free(eth); sh_eth_rx_desc_free(eth);
err_clk:
clk_disable(&priv->clk);
return ret; return ret;
} }
static void sh_ether_stop(struct udevice *dev) static void sh_ether_stop(struct udevice *dev)
{ {
struct sh_ether_priv *priv = dev_get_priv(dev); struct sh_ether_priv *priv = dev_get_priv(dev);
struct sh_eth_dev *eth = &priv->shdev;
struct sh_eth_info *port_info = &eth->port_info[eth->port];
phy_shutdown(port_info->phydev);
sh_eth_stop(&priv->shdev); sh_eth_stop(&priv->shdev);
clk_disable(&priv->clk);
} }
static int sh_ether_probe(struct udevice *udev) static int sh_ether_probe(struct udevice *udev)
@ -853,8 +843,20 @@ static int sh_ether_probe(struct udevice *udev)
eth->port_info[eth->port].iobase = eth->port_info[eth->port].iobase =
(void __iomem *)(BASE_IO_ADDR + 0x800 * eth->port); (void __iomem *)(BASE_IO_ADDR + 0x800 * eth->port);
ret = clk_enable(&priv->clk);
if (ret)
goto err_mdio_register;
ret = sh_eth_phy_config(udev);
if (ret) {
printf(SHETHER_NAME ": phy config timeout\n");
goto err_phy_config;
}
return 0; return 0;
err_phy_config:
clk_disable(&priv->clk);
err_mdio_register: err_mdio_register:
mdio_free(mdiodev); mdio_free(mdiodev);
return ret; return ret;
@ -866,6 +868,7 @@ static int sh_ether_remove(struct udevice *udev)
struct sh_eth_dev *eth = &priv->shdev; struct sh_eth_dev *eth = &priv->shdev;
struct sh_eth_info *port_info = &eth->port_info[eth->port]; struct sh_eth_info *port_info = &eth->port_info[eth->port];
clk_disable(&priv->clk);
free(port_info->phydev); free(port_info->phydev);
mdio_unregister(priv->bus); mdio_unregister(priv->bus);
mdio_free(priv->bus); mdio_free(priv->bus);