BCM5722 Programmer’s Guide
10/15/07
Broadcom Corporation
Page 153 GMII/MII Document 5722-PG101-R
LINK STATUS CHANGE INDICATIONS
It is often desirable for host software to know when the status of the Ethernet link has changed. To generate an interrupt to
the host when link status changes, software should set the Ethernet_MAC_Event_Enable.Link_State_Changed bit (see
“Ethernet MAC Event Enable Register (Offset 0x408)” on page 247) and the Mode_Control.Interrupt_on_MAC_Attention bit
(see “Mode Control Register (Offset 0x6800)” on page 333). With this configuration, the
Ethernet_MAC_Status.Link_State_Changed bit and Link_State_Changed bit in the status block (see “Status Block” on
page 53) will be set when the link has changed state.
CONFIGURING THE GMII/MII PHY
GMII/MII transceivers (PHYs) contain registers that a software driver can manipulate to change parameters in the PHY.
These parameters include the link speed or duplex that the PHY is currently running at, or the speed/duplex options that the
PHY advertises during the auto-negotiation process. NIC device drivers will typically access PHY registers during the driver
initialization process in order to configure the PHYs speed/duplex or to examine the results of the auto-negotiation process.
For more information about PHY registers, see “Transceiver Registers” on page 414.
The integrated PHY registers are accessed via a process called MDIO. The integrated PHY is connected to the BCM5722
Ethernet controller through an internal MDIO bus (MDIO and MDC pins). Software accesses PHY’s registers via MDIO
through the BCM5722’s MI_Communication register (see “MI Communication Register (Offset 0x44C)” on page 251). The
following example code describes accessing the PHY registers through the MI_Communication registers of the BCM5722
Ethernet controller.
Reading a PHY Register
// If auto-polling is enabled, temporarily disable it
If (AutoPolling_Enabled == TRUE) Then
Begin
Mi_Mode.PortPolling = 0
End
// Setup the value that we are going to write to MI Communication register
// Set bit 27 to indicate a PHY read.
// Set bit 29 to indicate the start of a MDIO transaction
Value32 = ((PhyAddress << 21) | (PhyRegOffset << 16) | 0x28000000)
// Write value to MI communication register
Mi_Communication_Register = Value32
// Now read back MI Communication register until the start bit
// has been cleared or we have timed out (>5000 reads)
Loopcount = 5000
While (LoopCount > 0)
Begin
Value32 = Mi_Communication_Register
If (!(Value32 | 0x20000000)) then BREAK loop
Else Loopcount--
End
// Print message if error
If (Value32 | 0x20000000) then
Begin
// It a debug case – cannot read PHY
Procedure (Print Error Message)
Value32 = 0
End