GMII/MII
BCM5718 Programmer’s Guide
Broadcom
®
January 29, 2016 • 5718-PG108-R
Page 205
// 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
MII_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 = MII_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
PHY Loopback Configuration
External PHY Loopback
10Base-T
- Write 0x0100 to PHY register 00h // Force 10Base-T, full duplex
- Write 0x1000 to PHY register 1Eh // Force link (required for 10Base-T)
- Set MAC register 0x400[3:2] = 01b // Set MII
- Set MAC register 0x400[1] = 0 // Force full-duplex operation
100Base-TX
- Write 0x2100 to PHY register 00h // Force 100Base-TX, full duplex
- Write 0x1000 to PHY register 1Eh // Force link (required for 100Base-TX)
- Set MAC register 0x400[3:2] = 01b // Set MII
- Set MAC register 0x400[1] = 0 // Force full-duplex operation
1000Base-T
- Write 0x1B00 to PHY register 09h // Enable 1000Base-T master mode
- Write 0x8400 to PHY register 18h // Enable external loopback mode
- Write 0x1000 to PHY register 1Eh // Force link (optional for 1000Base-T)
- Write 0x0140 to PHY register 00h // Force 1000Base-T operation
- Set MAC register 0x400[3:2] = 10b // Set GMII
- Set MAC register 0x400[1] = 0 // Force full-duplex operation
Internal PHY Loopback
---------------------
10Base-T
- Write 0x4100 to PHY register 00h // Force 10Base-T, full duplex, internal loopback
- Write 0x1000 to PHY register 1Eh // Force link (required for 100Base-TX)
- Set MAC register 0x400[3:2] = 01b // Set MII
- Set MAC register 0x400[1] = 0 // Force full-duplex operation