More rework on at91_emac
Subsystems (2)
cover More rework on at91_emac
This series does some more rework on at91_emac driver. Reinhard, I know your position to merge at91_emac and macb driver and also favor this. But for now I'd like to get some cleanups in the at91/at91rm9200 mess. Therefore these patches are needed to get at least at91rm9200ek working with at91 code.
Andreas Bie?mann (2):
drivers/net/at91_emac.c: increase timeout for autonegotiation drivers/net/at91_emac.c: change return values
drivers/net/at91_emac.c | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-)
Signature · 1 line
1.7.3.1
PATCH 1/2 drivers/net/at91_emac.c: increase timeout for autonegotiation
This patch increases timeout for autonegotiation from 1 second to 3 seconds. Some boards (e.g. at91rm9200ek) did not negotiate within 1 second.
--- drivers/net/at91_emac.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/at91_emac.c +1 -1
@@ -220,7 +220,7 @@ static int at91emac_phy_reset(struct eth_device *netdev)at91emac_write (emac,CONFIG_DRIVER_AT91EMAC_PHYADDR ,MII_BMCR , (BMCR_ANENABLE |BMCR_ANRESTART )); -for (i =0 ; i <100000 /100 ; i++) { +for (i =0 ; i <30000 ; i++) {at91emac_read (emac,CONFIG_DRIVER_AT91EMAC_PHYADDR ,MII_BMSR , &status);if (status &BMSR_ANEGCOMPLETE )
Signature · 1 line
1.7.3.1
PATCH 1/2 drivers/net/at91_emac.c: increase timeout for autonegotiation
Dear Andreas Bie?mann,
drivers/net/at91_emac.c static int at91emac_phy_reset(struct eth_device *netdev) · line 226
Quoted 12 lines
This patch increases timeout for autonegotiation from 1 second to 3 seconds. Some boards (e.g. at91rm9200ek) did not negotiate within 1 second.
drivers/net/at91_emac.c +1
-1@@ -220,7 +220,7 @@ static int at91emac_phy_reset(struct eth_device *netdev)at91emac_write (emac,CONFIG_DRIVER_AT91EMAC_PHYADDR ,MII_BMCR , (BMCR_ANENABLE |BMCR_ANRESTART )); -for (i =0 ; i <100000 /100 ; i++) { +for (i =0 ; i <30000 ; i++) {at91emac_read (emac,CONFIG_DRIVER_AT91EMAC_PHYADDR ,MII_BMSR , &status);if (status &BMSR_ANEGCOMPLETE )
You might want to change the timeout to use the timer like here, otherwise such looped timeouts are subject to toolchain version and cache and optimisation and cpu clock and whatever ;)
/*
* Wait for the XTAL oscillator to become ready
*/
static int enc_clock_wait(enc_dev_t *enc)
{
uint64_t etime;
/* one second timeout */
etime = get_ticks() + get_tbclk();
/*
* Wait for CLKRDY to become set (i.e., check that we can
* communicate with the ENC)
*/
do
{
if (enc_r8(enc, CTL_REG_ESTAT) & ENC_ESTAT_CLKRDY)
return 0;
} while (get_ticks() <= etime);
printf("%s: timeout waiting for CLKRDY\n", enc->dev->name);
return -1;
}Reinhard
PATCH 1/2 drivers/net/at91_emac.c: increase timeout for autonegotiation
Quoted 8 lines
Dear Andreas Bie?mann,
Quoted 7 lines
This patch increases timeout for autonegotiation from 1 second to 3 seconds. Some boards (e.g. at91rm9200ek) did not negotiate within 1 second.
drivers/net/at91_emac.c +0
-0@@ -220,7 +220,7 @@ static int at91emac_phy_reset(struct eth_device *netdev)at91emac_write (emac,CONFIG_DRIVER_AT91EMAC_PHYADDR ,MII_BMCR , (BMCR_ANENABLE |BMCR_ANRESTART ));
Quoted 9 lines
drivers/net/at91_emac.c static int at91emac_phy_reset(struct eth_device *netdev) · line 226
Quoted 5 lines
drivers/net/at91_emac.c +1
-1-for (i =0 ; i <100000 /100 ; i++) { +for (i =0 ; i <30000 ; i++) {at91emac_read (emac,CONFIG_DRIVER_AT91EMAC_PHYADDR ,MII_BMSR , &status);if (status &BMSR_ANEGCOMPLETE )You might want to change the timeout to use the timer like here, otherwise such looped timeouts are subject to toolchain version and cache and optimisation and cpu clock and whatever ;)
Ok, the patch did not show the udelay(100) in the next line:) With AT91 timer frequency, udelay(100) is quite exact, so the loop will work fine. Nevertheless the other timeout mechanism is more accurate and better to read (I think).
Reinhard
Ben Warren
AppliedPATCH 1/2 drivers/net/at91_emac.c: increase timeout for autonegotiation
In reply to Andreas BießmannHi Andreas,
Quoted 13 lines · Andreas Bie?mann
This patch increases timeout for autonegotiation from 1 second to 3 seconds. Some boards (e.g. at91rm9200ek) did not negotiate within 1 second.
Signed-off-by Andreas Bie?mann<[email protected]>--- drivers/net/at91_emac.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/net/at91_emac.c +0
-0
drivers/net/at91_emac.c static int at91emac_phy_reset(struct eth_device *netdev) · line 226
Quoted 8 lines
drivers/net/at91_emac.c +1
-1@@ -220,7 +220,7 @@ static int at91emac_phy_reset(struct eth_device *netdev)at91emac_write (emac,CONFIG_DRIVER_AT91EMAC_PHYADDR ,MII_BMCR , (BMCR_ANENABLE |BMCR_ANRESTART )); -for (i =0 ; i<100000 /100 ; i++) { +for (i =0 ; i<30000 ; i++) {at91emac_read (emac,CONFIG_DRIVER_AT91EMAC_PHYADDR ,MII_BMSR ,&status);if (status&BMSR_ANEGCOMPLETE )
Applied to net repo.
thanks,
Ben
PATCH 1/2 drivers/net/at91_emac.c: increase timeout for autonegotiation
Dear Ben Warren,
Quoted 1 line
Applied to net repo.
OOPS, I already caught them in the AT91 repo and they are on the way to mainstream already.
Reinhard
PATCH 2/2 drivers/net/at91_emac.c: change return values
In reply to Andreas BießmannSome return values pretended correct pass. This patch changes them according to README.drivers.net. This patch changes e.g. command 'dhcp' to stop after errorneous autonegotiation.
--- drivers/net/at91_emac.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-)
drivers/net/at91_emac.c +9 -9
@@ -233,7 +233,7 @@ static int at91emac_phy_reset(struct eth_device *netdev) }else {printf ("%s: Autonegotiation timed out (status=0x%04x)\n" , netdev->name, status); -return 1 ; +return -1 ; }return 0 ; }
@@ -252,7 +252,7 @@ static int at91emac_phy_init(struct eth_device *netdev) MII_PHYSID1, &phy_id);if (phy_id ==0xffff ) {printf ("%s: No PHY present\n" , netdev->name); -return 1 ; +return -1 ; } at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR,
@@ -261,7 +261,7 @@ static int at91emac_phy_init(struct eth_device *netdev)if (!(status &BMSR_LSTATUS )) {/* Try to re-negotiate if we don't have link already. */ if (at91emac_phy_reset (netdev)) -return 2 ; +return -2 ;for (i =0 ; i <100000 /100 ; i++) { at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR,
@@ -273,7 +273,7 @@ static int at91emac_phy_init(struct eth_device *netdev) }if (!(status &BMSR_LSTATUS )) {VERBOSEP ("%s: link down\n" , netdev->name); -return 3 ; +return -3 ; }else {at91emac_read (emac,CONFIG_DRIVER_AT91EMAC_PHYADDR ,MII_ADVERTISE , &adv);
@@ -298,7 +298,7 @@ int at91emac_UpdateLinkSpeed(at91_emac_t *emac)at91emac_read (emac,CONFIG_DRIVER_AT91EMAC_PHYADDR ,MII_BMSR , &stat1);if (!(stat1 &BMSR_LSTATUS ))/* link status up? */ -return 1 ; +return -1 ;if (stat1 &BMSR_100FULL ) {/*set Emac for 100BaseTX and Full Duplex */
@@ -333,7 +333,7 @@ int at91emac_UpdateLinkSpeed(at91_emac_t *emac) &emac->cfg);return 0 ; } -return 1 ; +return 0 ; }static int at91emac_init (struct eth_device *netdev,bd_t *bd)
@@ -399,7 +399,7 @@ static int at91emac_init(struct eth_device *netdev, bd_t *bd)at91emac_UpdateLinkSpeed (emac);return 0 ; } -return 1 ; +return -1 ; }static void at91emac_halt (struct eth_device *netdev)
@@ -501,11 +501,11 @@ int at91emac_register(bd_t *bis, unsigned long iobase) iobase =AT91_EMAC_BASE ; emac =malloc (sizeof (*emac)+512 );if (emac ==NULL ) -return 1 ; +return -1 ; dev =malloc (sizeof (*dev));if (dev ==NULL ) {free (emac); -return 1 ; +return -1 ; }/* alignment as per Errata (64 bytes) is insufficient! */ emacfix = (emac_device *) (((unsigned long ) emac +0x1ff ) &0xFFFFFE00 );
Signature · 1 line
1.7.3.1
Ben Warren
AppliedPATCH 2/2 drivers/net/at91_emac.c: change return values
HI Andreas,
Quoted 8 lines · Andreas Bie?mann
Some return values pretended correct pass. This patch changes them according to README.drivers.net. This patch changes e.g. command 'dhcp' to stop after errorneous autonegotiation.
Signed-off-by Andreas Bie?mann<[email protected]>--- drivers/net/at91_emac.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-)
Applied to net repo.
thanks,
Ben