Re: via-rhine and MMIO

Jeff Garzik (jgarzik@mandrakesoft.com)
Tue, 30 Oct 2001 04:12:07 -0500


Martin Eriksson wrote:
> (drivers/net/via-rhine.c)
> ...
> /* Reload the station address from the EEPROM. */
> writeb(0x20, ioaddr + MACRegEEcsr);
> /* Typically 2 cycles to reload. */
> for (i = 0; i < 150; i++)
> if (! (readb(ioaddr + MACRegEEcsr) & 0x20))
> break;
> ...
>
> If I run this code when I'm using MMIO, I get a hardware adress of
> "ff:ff:ff:ff:ff:ff" instead of the right one (and everything craps up). But
> when I comment out this part all is fine. So what's it needed for anyway?

On init all NIC drivers should get the MAC address from the NIC's
EEPROM, and store it in dev->dev_addr[].

If the MAC address is changed by the user in Windows, or in a previous
driver invocation, you want to change it back to the default. Obtaining
the address from EEPROM is the only way to do this on most cards. Since
the via-rhine apparently doesn't support this directly, it does the next
best thing: kick the h/w to reload the EEPROM into chip registers, and
then read the MAC address from the chip registers.

WRT the above code, you should add a check to see if '150' is enough of
a wait. MMIO is faster and would affect that loop. Maybe you want to
schedule_timeout before reading MACRegEEcsr to delay a little bit.

-- 
Jeff Garzik      | Only so many songs can be sung
Building 1024    | with two lips, two lungs, and one tongue.
MandrakeSoft     |         - nomeansno

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/