public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/2] More rework on at91_emac
@ 2010-10-07  7:44 Andreas Bießmann
  2010-10-07  7:44 ` [U-Boot] [PATCH 1/2] drivers/net/at91_emac.c: increase timeout for autonegotiation Andreas Bießmann
  2010-10-07  7:44 ` [U-Boot] [PATCH 2/2] drivers/net/at91_emac.c: change return values Andreas Bießmann
  0 siblings, 2 replies; 8+ messages in thread
From: Andreas Bießmann @ 2010-10-07  7:44 UTC (permalink / raw)
  To: u-boot

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(-)

-- 
1.7.3.1

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/2] drivers/net/at91_emac.c: increase timeout for autonegotiation
  2010-10-07  7:44 [U-Boot] [PATCH 0/2] More rework on at91_emac Andreas Bießmann
@ 2010-10-07  7:44 ` Andreas Bießmann
  2010-10-07  8:12   ` Reinhard Meyer
  2010-10-12  6:33   ` Ben Warren
  2010-10-07  7:44 ` [U-Boot] [PATCH 2/2] drivers/net/at91_emac.c: change return values Andreas Bießmann
  1 sibling, 2 replies; 8+ messages in thread
From: Andreas Bießmann @ 2010-10-07  7:44 UTC (permalink / raw)
  To: u-boot

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 <andreas.devel@googlemail.com>
---
 drivers/net/at91_emac.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/at91_emac.c b/drivers/net/at91_emac.c
index ca2b16b..4626398 100644
--- a/drivers/net/at91_emac.c
+++ b/drivers/net/at91_emac.c
@@ -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)
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/2] drivers/net/at91_emac.c: change return values
  2010-10-07  7:44 [U-Boot] [PATCH 0/2] More rework on at91_emac Andreas Bießmann
  2010-10-07  7:44 ` [U-Boot] [PATCH 1/2] drivers/net/at91_emac.c: increase timeout for autonegotiation Andreas Bießmann
@ 2010-10-07  7:44 ` Andreas Bießmann
  2010-10-12  6:33   ` Ben Warren
  1 sibling, 1 reply; 8+ messages in thread
From: Andreas Bießmann @ 2010-10-07  7:44 UTC (permalink / raw)
  To: u-boot

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 <andreas.devel@googlemail.com>
---
 drivers/net/at91_emac.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/net/at91_emac.c b/drivers/net/at91_emac.c
index 4626398..4e5685c 100644
--- a/drivers/net/at91_emac.c
+++ b/drivers/net/at91_emac.c
@@ -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);
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/2] drivers/net/at91_emac.c: increase timeout for autonegotiation
  2010-10-07  7:44 ` [U-Boot] [PATCH 1/2] drivers/net/at91_emac.c: increase timeout for autonegotiation Andreas Bießmann
@ 2010-10-07  8:12   ` Reinhard Meyer
  2010-10-07  8:20     ` Reinhard Meyer
  2010-10-12  6:33   ` Ben Warren
  1 sibling, 1 reply; 8+ messages in thread
From: Reinhard Meyer @ 2010-10-07  8:12 UTC (permalink / raw)
  To: u-boot

Dear 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.

> @@ -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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/2] drivers/net/at91_emac.c: increase timeout for autonegotiation
  2010-10-07  8:12   ` Reinhard Meyer
@ 2010-10-07  8:20     ` Reinhard Meyer
  0 siblings, 0 replies; 8+ messages in thread
From: Reinhard Meyer @ 2010-10-07  8:20 UTC (permalink / raw)
  To: u-boot

> Dear 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.
> 
>> @@ -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 ;)

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/2] drivers/net/at91_emac.c: increase timeout for autonegotiation
  2010-10-07  7:44 ` [U-Boot] [PATCH 1/2] drivers/net/at91_emac.c: increase timeout for autonegotiation Andreas Bießmann
  2010-10-07  8:12   ` Reinhard Meyer
@ 2010-10-12  6:33   ` Ben Warren
  2010-10-12  6:45     ` Reinhard Meyer
  1 sibling, 1 reply; 8+ messages in thread
From: Ben Warren @ 2010-10-12  6:33 UTC (permalink / raw)
  To: u-boot

  Hi Andreas,

On 10/7/2010 12:44 AM, Andreas Bie?mann wrote:
> 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<andreas.devel@googlemail.com>
> ---
>   drivers/net/at91_emac.c |    2 +-
>   1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/net/at91_emac.c b/drivers/net/at91_emac.c
> index ca2b16b..4626398 100644
> --- a/drivers/net/at91_emac.c
> +++ b/drivers/net/at91_emac.c
> @@ -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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/2] drivers/net/at91_emac.c: change return values
  2010-10-07  7:44 ` [U-Boot] [PATCH 2/2] drivers/net/at91_emac.c: change return values Andreas Bießmann
@ 2010-10-12  6:33   ` Ben Warren
  0 siblings, 0 replies; 8+ messages in thread
From: Ben Warren @ 2010-10-12  6:33 UTC (permalink / raw)
  To: u-boot

  HI Andreas,

On 10/7/2010 12:44 AM, Andreas Bie?mann wrote:
> 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<andreas.devel@googlemail.com>
> ---
>   drivers/net/at91_emac.c |   18 +++++++++---------
>   1 files changed, 9 insertions(+), 9 deletions(-)
Applied to net repo.

thanks,
Ben

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/2] drivers/net/at91_emac.c: increase timeout for autonegotiation
  2010-10-12  6:33   ` Ben Warren
@ 2010-10-12  6:45     ` Reinhard Meyer
  0 siblings, 0 replies; 8+ messages in thread
From: Reinhard Meyer @ 2010-10-12  6:45 UTC (permalink / raw)
  To: u-boot

Dear Ben Warren,
> Applied to net repo.

OOPS, I already caught them in the AT91 repo and they are on the way to mainstream already.

Reinhard

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-10-12  6:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-07  7:44 [U-Boot] [PATCH 0/2] More rework on at91_emac Andreas Bießmann
2010-10-07  7:44 ` [U-Boot] [PATCH 1/2] drivers/net/at91_emac.c: increase timeout for autonegotiation Andreas Bießmann
2010-10-07  8:12   ` Reinhard Meyer
2010-10-07  8:20     ` Reinhard Meyer
2010-10-12  6:33   ` Ben Warren
2010-10-12  6:45     ` Reinhard Meyer
2010-10-07  7:44 ` [U-Boot] [PATCH 2/2] drivers/net/at91_emac.c: change return values Andreas Bießmann
2010-10-12  6:33   ` Ben Warren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox