diff options
author | Andreas Bießmann <andreas.devel@googlemail.com> | 2010-09-07 19:10:34 +0200 |
---|---|---|
committer | Reinhard Meyer <u-boot@emk-elektronik.de> | 2010-10-05 16:58:55 +0200 |
commit | 38bda019e484c459e0d7a2ffb7be124bca14f586 (patch) | |
tree | 245d4a06a7305a1cf7c3e879df84b83558822643 /drivers | |
parent | 4b8d77bb93168e4cbaa2d0f040732de540ad5ea2 (diff) | |
download | bootable_bootloader_goldelico_gta04-38bda019e484c459e0d7a2ffb7be124bca14f586.zip bootable_bootloader_goldelico_gta04-38bda019e484c459e0d7a2ffb7be124bca14f586.tar.gz bootable_bootloader_goldelico_gta04-38bda019e484c459e0d7a2ffb7be124bca14f586.tar.bz2 |
at91_emac.c: poll for IDLE when writing PHY
This patch replaces the unnecessary waiting in at91emac_read() and
at91emac_write() by checking the IDLE flag.
Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/at91_emac.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/net/at91_emac.c b/drivers/net/at91_emac.c index 009a275..ca2b16b 100644 --- a/drivers/net/at91_emac.c +++ b/drivers/net/at91_emac.c @@ -127,13 +127,19 @@ void at91emac_DisableMDIO(at91_emac_t *at91mac) int at91emac_read(at91_emac_t *at91mac, unsigned char addr, unsigned char reg, unsigned short *value) { + unsigned long netstat; at91emac_EnableMDIO(at91mac); writel(AT91_EMAC_MAN_HIGH | AT91_EMAC_MAN_RW_R | AT91_EMAC_MAN_REGA(reg) | AT91_EMAC_MAN_CODE_802_3 | AT91_EMAC_MAN_PHYA(addr), &at91mac->man); - udelay(10000); + + do { + netstat = readl(&at91mac->sr); + DEBUG_AT91PHY("poll SR %08lx\n", netstat); + } while (!(netstat & AT91_EMAC_SR_IDLE)); + *value = readl(&at91mac->man) & AT91_EMAC_MAN_DATA_MASK; at91emac_DisableMDIO(at91mac); @@ -146,6 +152,7 @@ int at91emac_read(at91_emac_t *at91mac, unsigned char addr, int at91emac_write(at91_emac_t *at91mac, unsigned char addr, unsigned char reg, unsigned short value) { + unsigned long netstat; DEBUG_AT91PHY("AT91PHY write %x REG(%d)=%x\n", at91mac, reg, &value) at91emac_EnableMDIO(at91mac); @@ -154,9 +161,14 @@ int at91emac_write(at91_emac_t *at91mac, unsigned char addr, AT91_EMAC_MAN_REGA(reg) | AT91_EMAC_MAN_CODE_802_3 | AT91_EMAC_MAN_PHYA(addr) | (value & AT91_EMAC_MAN_DATA_MASK), &at91mac->man); - udelay(10000); + + do { + netstat = readl(&at91mac->sr); + DEBUG_AT91PHY("poll SR %08lx\n", netstat); + } while (!(netstat & AT91_EMAC_SR_IDLE)); at91emac_DisableMDIO(at91mac); + return 0; } |