[PATCH 1/1] phy: phy_update_status wait auto neg done when enabled

Sascha Hauer s.hauer at pengutronix.de
Wed Nov 14 03:05:28 EST 2012


On Tue, Nov 13, 2012 at 10:14:05PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> if the autoneg was start by the hw wait it to be finished
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> ---
>  drivers/net/phy/phy.c |   26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 0c2e602..43738c2 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -28,6 +28,25 @@
>  #define PHY_AN_TIMEOUT	10
>  
>  static int genphy_config_init(struct phy_device *phydev);
> +static int phy_aneg_done(struct phy_device *phydev);
> +
> +static int phy_wait_aneg_read_status(struct phy_device *dev, struct phy_driver *drv)
> +{
> +	int ret;
> +
> +	if (AUTONEG_ENABLE != dev->autoneg)
> +		return 0;
> +
> +	ret = phy_aneg_done(dev);
> +	if (ret)
> +		return ret;
> +
> +	/*
> +	 * re-read the status as the aneg may not be finished
> +	 * when we read it the first time
> +	 */
> +	return drv->read_status(dev);
> +}
>  
>  int phy_update_status(struct phy_device *dev)
>  {
> @@ -35,11 +54,18 @@ int phy_update_status(struct phy_device *dev)
>  	struct eth_device *edev = dev->attached_dev;
>  	int ret;
>  	int oldspeed = dev->speed, oldduplex = dev->duplex;
> +	int old_link = dev->link;
>  
>  	ret = drv->read_status(dev);
>  	if (ret)
>  		return ret;
>  
> +	if (dev->link && !old_link) {
> +		ret = phy_wait_aneg_read_status(dev, drv);
> +		if (ret)
> +			return ret;
> +	}

This does not help. dev->link is false after reset, so we never get into
phy_wait_aneg_read_status() which waits for a link.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list