SMI Component API
The module module_ethernet_smi is written to support SMI independently of the MII interface. Typically, Ethernet PHYs are configured on reset automatically, but the SMI interface may be useful for setting and testing register values dynamically.
There are two ways to interface SMI: using a pair of 1-bit ports, or using a single multi-bit port.
Configuration Defines
These defines can either be set in ethernet_conf.h or smi_conf.h from within your application directory.
SMI_COMBINE_MDC_MDIO
This define should be set to 1 if you want to combine MDC and MDIO onto a single bit port.
SMI_MDC_BIT
This defines the bit number on the shared port where the MDC line is. Only define this if you have a port that drives both MDC and MDIO.
SMI_MDIO_BIT
This defines the bit number on the shared port where the MDIO line is. Only define this if you have a port that drives both MDC and MDIO.
Data Structures
-
smi_interface_t
Structure containing resources required for the SMI ethernet phy interface.
This structure can be filled in two ways. One indicate that the SMI interface is connected using two 1-bit port, the other indicates that the interface is connected using a single multi-bit port.
If used with two 1-bit ports, set the phy_address, p_smi_mdio and p_smi_mdc as normal.
If SMI_COMBINE_MDC_MDIO is 1 then p_smi_mdio is ommited and p_mdc is assumbed to multibit port containing both mdio and mdc.
Structure Members:
-
int phy_address
Address of PHY, typically 0 or 0x1F.
-
port p_smi_mdio
MDIO port.
-
port p_smi_mdc
MDC port.
-
Phy API
-
void smi_init(smi_interface_t &smi)
Function that configures the SMI ports.
No clock block is needed. Note that there is no deinit function.
Parameters
smi
structure containing the clock and data ports for SMI.
-
void eth_phy_config(int eth100, smi_interface_t &smi)
Function that configures the Ethernet PHY explicitly to set to autonegotiate.
Parameters
If
eth100 is non-zero, 100BaseT is advertised to the link peer Full duplex is always advertised
smi
structure that defines the ports to use for SMI
-
void eth_phy_config_noauto(int eth100, smi_interface_t &smi)
Function that configures the Ethernet PHY to not autonegotiate.
Parameters
If
eth100 is non-zero, it is set to 100, else to 10 Mbits/s
smi
structure that defines the ports to use for SMI
-
void eth_phy_loopback(int enable, smi_interface_t &smi)
Function that can enable or disable loopback in the phy.
Parameters
enable
boolean; set to 1 to enable loopback, or 0 to disable loopback.
smi
structure containing the ports
-
int eth_phy_id(smi_interface_t &smi)
Function that returns the PHY identification.
Parameters
smi
structure containing the ports
Returns
the 32-bit identifier.
-
int smi_check_link_state(smi_interface_t &smi)
Function that polls whether the link is alive.
Parameters
smi
structure containing the ports
Returns
non-zero if the link is alive; zero otherwise.