Programmer’s Guide BCM5722
10/15/07
Broadcom Corporation
Document 5722-PG101-R GMII/MII Page 154
// If auto-polling is enabled, turn it back on
If (AutoPolling_Enabled == TRUE) then
Begin
Mi_Mode.PortPolling = 1
End
// Now return the value that we read (lower 16 bits of reg)
Return (Value32 & 0xffff)
Writing 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 26 set to indicate a PHY write.
// Set bit 29 to indicate the start of a MDIO transaction
// The lower 16 bits equal the value we want to write to the PHY register
Value32 = ((PhyAddress << 21) | (PhyRegOffset << 16) | RegValue | 0x24000000)
// 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 – can’t write PHY
Procedure (Print Error Message)
Value32 = 0
End
// If auto-polling is enabled, turn it back on
If (AutoPolling_Enabled == TRUE) Then
Begin
Mi_Mode.PortPolling = 1
End