GMII/MII
BCM5718 Programmer’s Guide
Broadcom
®
January 29, 2016 • 5718-PG108-R
Page 207
----------------------------------------------------
Configure Auto-MDIX (Cable pair swapping for 10/100)
----------------------------------------------------
// Read Misc Control Register (PHY 18h, Shadow 7)
phy_write(0x18, 0x7007);
val16 = phy_read(0x18)
//Set Force Auto MDIX Mode (Phy 18h, Shadow 7, bit 9)
val16 |= (1 << 9);
// Write Misc control Register (set write enable bit)
phy_write(0x18, val16 | (1 << 15));
// Enable Auto MDIX Crossover (Phy 10h, bit 14)
val16 = phy_read(0x10);
val16 &= ~(1 << 14);
phy_write(0x10, val16);
---------------------------------------------------------------------
Autonegotiation (10/100/1000 speed with half and full duplex support)
---------------------------------------------------------------------
uint16_t gig = 0, anar = 0;
// Reset PHY
// Enable auto-MDIX
// Force loopback
// Select pause and asymmetric pause advertisement for Ethernet
anar = (1 << 11) | (1 << 10) | (00001b << 0);
// Select 10/100 half/full duplex advertisement
anar |= (1 << 8) | (1 << 7) | (1 << 6) | (1 << 5);
// Enable 10/100 autoneg advertisement
phy_write(0x04, anar);
// Select 1000Mb full-duplex operation
gig = (1 << 9);
// Advertise full-duplex operation
phy_write(0x09, gig);
// Enable and restart autonoegotiation
phy_write(0x00, ((1 << 12) | (1 << 9)));
--------------------
10Base-T Half-Duplex
--------------------
uint16_t bmcr = 0;