[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Some thoughts on ethernet.c




On Thu, 4 Jul 2002, Jarkko Tuomi wrote:
...
> ---
>
> There also seems to be a bug in e100_receive_mdio_bit()
> 
> *R_NETWORK_MGM_CTRL = 0;
> bit = IO_EXTRACT(R_NETWORK_STAT, mdio, *R_NETWORK_STAT);
> udelay(1);
> 
> What happens is that the PHY is told to output a bit, and Etrax reads it
> right away. It depends on the PHY whether the data line has enought time to
> settle or not. On our board this resulted in plain garbage to be read back
> most of the time. Moving the udelay call where it should be solved the
> problem.
> 
> *R_NETWORK_MGM_CTRL = 0;
> udelay(1);
> bit = IO_EXTRACT(R_NETWORK_STAT, mdio, *R_NETWORK_STAT);
> 
> Those looking for near-real-time performance might also want to make the
> delay shorter, just check your PHY datasheet.
> 
> ---

According to the IEEE Std 802.3, the PHY should output its data in
response to the positive edge of mdc, with a maximum delay of 300 ns.
In the code excerpt above, the "*R_NETWORK_MGM_CTRL = 0;" generates
a negative edge on mdc. This has been preceded by a positive edge
"*R_NETWORK_MGM_CTRL = 4;" followed by an "udelay(1);"  

Therefore, I think that the original code is correct. The suggested
modification is also OK, since the PHY should hold the data until the next
positive edge on mdc. Why the original code didn't work on Jarkko's board
I could not say. Is there something in between the ETRAX 100LX and the PHY
that adds delay ?

Per Zander