[OpenWrt-Devel] [PATCH 1/3] ag71xx: replace fixed PHY reset wait time in ar7240sw_setup

John Crispin blogic at openwrt.org
Fri Dec 5 03:57:47 EST 2014


(i got attacked by the cat :) and she did manage to hit the "send"
button before i finished typing)

Hi,

just added this to my local tree, images are building, the ar71xx
network stuff scares me and i want to test this for a few boards
before pushing. i might not manage to do so today

	John

On 05/12/2014 09:55, John Crispin wrote:
> Hi,
> 
> just added this to my local tree, images are building, the ar71xx 
> network stuff scares me and i want to test this for a few b
> 
> On 05/12/2014 07:36, Heiner Kallweit wrote:
>> Replace the fixed wait time of 1s with polling for BMCR_RESET to 
>> be cleared on all PHYs.
>> 
>> Signed-off-by: Heiner Kallweit <hkallweit1 at gmail.com> --- 
>> .../net/ethernet/atheros/ag71xx/ag71xx_ar7240.c    | 29 
>> +++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 
>> deletion(-)
>> 
>> diff --git 
>> a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c
>>
>> 
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c
>> 
>> 
index d4ccc02..0a6d0ca 100644
>> --- 
>> a/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c
>>
>>
>> 
+++
b/target/linux/ar71xx/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_ar7240.c
>> @@ -618,6 +618,31 @@ static void ar7240sw_setup(struct ar7240sw 
>> *as) ar7240sw_reg_rmw(mii, AR7240_REG_SERVICE_TAG, 
>> AR7240_SERVICE_TAG_M, 0); }
>> 
>> +/* inspired by phy_poll_reset in drivers/net/phy/phy_device.c */
>> +static int +ar7240sw_phy_poll_reset(struct mii_bus *bus) +{ + 
>> const unsigned int sleep_msecs = 20; +	int ret, elapsed, i; + + 
>> for (elapsed = sleep_msecs; elapsed <= 600; +	     elapsed += 
>> sleep_msecs) { +		msleep(sleep_msecs); +		for (i = 0; i < 
>> AR7240_NUM_PHYS; i++) { +			ret = ar7240sw_phy_read(bus, i, 
>> MII_BMCR); +			if (ret < 0) +				return ret; +			if (ret & 
>> BMCR_RESET) +				break; +			if (i == AR7240_NUM_PHYS - 1) { + 
>> usleep_range(1000, 2000); +				return 0; +			} +		} +	} +	return 
>> -ETIMEDOUT; +} + static int ar7240sw_reset(struct ar7240sw *as) {
>> struct mii_bus *mii = as->mii_bus; @@ -646,7 +671,9 @@ static int
>> ar7240sw_reset(struct ar7240sw *as) ar7240sw_phy_write(mii, i,
>> MII_BMCR, BMCR_RESET | BMCR_ANENABLE); } -	msleep(1000); +	ret =
>> ar7240sw_phy_poll_reset(mii); +	if (ret) +		return ret;
>> 
>> ar7240sw_setup(as); return ret;
>> 
> _______________________________________________ openwrt-devel 
> mailing list openwrt-devel at lists.openwrt.org 
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
> 
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list