The following steps are performed by the application software or device driver to initialize the MDIO device:
- Configure the PREAMBLE and CLKDIV bits in the MDIO Control register (MDIO_CONTROL).
- Enable the MDIO module by setting the ENABLE bit in MDIO_CONTROL.
- The MDIO PHY alive status register (MDIO_ALIVE) can be read in polling fashion until a PHY connected to the system responded, and the MDIO PHY link status register (MDIO_LINK) can determine whether this PHY already has a link.
- Setup the appropriate PHY addresses in the MDIO user PHY select register (MDIO_USERPHYSEL0/1), and set the LINKINTENB bit to enable a link change event interrupt if desirable.
- If an interrupt on general MDIO register access is desired, set the corresponding bit in the MDIO user command complete interrupt mask set register (MDIO_USERINTMASKSET) to use the MDIO user access register (MDIO_USERACCESS0/1). Since only one PHY is used in this device, the application software can use one MDIO_USERACCESS0/1 to trigger a completion interrupt; the other MDIO_USERACCESS0/1 is not setup.