The EMAC drivers provided for VxWorks 5.x are not directly compatible with auto-negotiable PHYs. The OPB Ethernet v1.02a documentation states, "It is the responsibility of the software to ensure that this mode matches the PHY, if the PHY is operating in auto-negotiation mode."
How can I do this?
You can access the PHY through the management interface, then set or clear the EMAC options that control the core's full-duplex operation using the level "1" interface for the EMAC drivers. Sample code for this operation is as follows:
The PhyAddr is a factor of the board design, but is usually 0. The Unit
is associated with the order in which VxWorks loaded an EMAC instance.
For designs that have a single EMAC, the Unit should be 0.
void SetDuplex(int PhyAddr, int Unit)
XEmac *MacPtr = XEmacEndAdapter_GetDriver(Unit);
if (MacPtr == NULL)
return; /* VxWorks hasn't loaded this unit */
Options = XEmac_GetOptions(MacPtr);
/* Check PHY's MII control register */
XEmac_PhyRead(MacPtr, PhyAddr, 0, &Data);
if (Data & 0x0100)
/* Operating in full duplex */
XEmac_SetOptions(MacPtr, Options & XEM_FDUPLEX_OPTION);
/* Operating in half-duplex */
XEmac_SetOptions(MacPtr, Options & ~XEM_FDUPLEX_OPTION);
The constants used to check the data should be the same for all PHYs that follow MII standards.