Driver for the ksz8081rna component.
This driver provides access to the main features of the PHY.
This driver depends on the following modules:
Macros | |
#define | ETH_PHY_MAX_ADDR 31 |
#define | ETH_PHY_RETRY_MAX 1000000 |
#define | ETH_PHY_TIMEOUT 10 |
Functions | |
uint8_t | ethernet_phy_auto_negotiate (Gmac *p_gmac, uint8_t uc_phy_addr) |
Issue an auto negotiation of the PHY. More... | |
static uint8_t | ethernet_phy_find_valid (Gmac *p_gmac, uint8_t uc_phy_addr, uint8_t uc_start_addr) |
Find a valid PHY Address ( from addrStart to 31 ). More... | |
uint8_t | ethernet_phy_init (Gmac *p_gmac, uint8_t uc_phy_addr, uint32_t mck) |
Perform a HW initialization to the PHY and set up clocks. More... | |
uint8_t | ethernet_phy_reset (Gmac *p_gmac, uint8_t uc_phy_addr) |
Issue a SW reset to reset all registers of the PHY. More... | |
uint8_t | ethernet_phy_set_link (Gmac *p_gmac, uint8_t uc_phy_addr, uint8_t uc_apply_setting_flag) |
Get the Link & speed settings, and automatically set up the GMAC with the settings. More... | |
#define ETH_PHY_MAX_ADDR 31 |
Referenced by ethernet_phy_find_valid().
#define ETH_PHY_RETRY_MAX 1000000 |
Referenced by ethernet_phy_auto_negotiate().
#define ETH_PHY_TIMEOUT 10 |
Referenced by ethernet_phy_reset().
uint8_t ethernet_phy_auto_negotiate | ( | Gmac * | p_gmac, |
uint8_t | uc_phy_addr | ||
) |
Issue an auto negotiation of the PHY.
p_gmac | Pointer to the GMAC instance. |
uc_phy_addr | PHY address. |
Return GMAC_OK if successfully, GMAC_TIMEOUT if timeout.
References ETH_PHY_MODE, ETH_PHY_RETRY_MAX, gmac_enable_full_duplex(), gmac_enable_management(), gmac_enable_receive(), gmac_enable_transmit(), GMAC_OK, gmac_phy_read(), gmac_phy_write(), gmac_select_mii_mode(), gmac_set_speed(), GMAC_TIMEOUT, GMII_100TX_FDX, GMII_100TX_HDX, GMII_10_FDX, GMII_10_HDX, GMII_AN_IEEE_802_3, GMII_ANAR, GMII_ANLPAR, GMII_AUTONEG, GMII_AUTONEG_COMP, GMII_BMCR, GMII_BMSR, GMII_DUPLEX_MODE, GMII_ISOLATE, GMII_LOOPBACK, GMII_POWER_DOWN, GMII_RESTART_AUTONEG, and GMII_SPEED_SELECT.
Referenced by run_gmac_link_test().
|
static |
Find a valid PHY Address ( from addrStart to 31 ).
p_gmac | Pointer to the GMAC instance. |
uc_phy_addr | PHY address. |
uc_start_addr | Start address of the PHY to be searched. |
References ETH_PHY_MAX_ADDR, gmac_enable_management(), gmac_phy_read(), GMII_BMSR, GMII_OUI_MSB, and GMII_PHYID1.
Referenced by ethernet_phy_init().
uint8_t ethernet_phy_init | ( | Gmac * | p_gmac, |
uint8_t | uc_phy_addr, | ||
uint32_t | mck | ||
) |
Perform a HW initialization to the PHY and set up clocks.
This should be called only once to initialize the PHY pre-settings. The PHY address is the reset status of CRS, RXD[3:0] (the emacPins' pullups). The COL pin is used to select MII mode on reset (pulled up for Reduced MII). The RXDV pin is used to select test mode on reset (pulled up for test mode). The above pins should be predefined for corresponding settings in resetPins. The GMAC peripheral pins are configured after the reset is done.
p_gmac | Pointer to the GMAC instance. |
uc_phy_addr | PHY address. |
ul_mck | GMAC MCK. |
Return GMAC_OK if successfully, GMAC_TIMEOUT if timeout.
References ethernet_phy_find_valid(), ethernet_phy_reset(), GMAC_OK, gmac_set_mdc_clock(), PIN_GMAC_INT_MASK, PIN_GMAC_INT_PIO, PIN_GMAC_MASK, PIN_GMAC_PERIPH, PIN_GMAC_PIO, PIN_GMAC_RESET_MASK, PIN_GMAC_RESET_PIO, PIO_PULLUP, pio_set_input(), pio_set_output(), and pio_set_peripheral().
Referenced by run_gmac_link_test().
uint8_t ethernet_phy_reset | ( | Gmac * | p_gmac, |
uint8_t | uc_phy_addr | ||
) |
Issue a SW reset to reset all registers of the PHY.
p_gmac | Pointer to the GMAC instance. |
uc_phy_addr | PHY address. |
GMAC_OK if successfully, GMAC_TIMEOUT if timeout.
References ETH_PHY_TIMEOUT, gmac_enable_management(), GMAC_OK, gmac_phy_read(), gmac_phy_write(), GMAC_TIMEOUT, GMII_BMCR, and GMII_RESET.
Referenced by ethernet_phy_init().
uint8_t ethernet_phy_set_link | ( | Gmac * | p_gmac, |
uint8_t | uc_phy_addr, | ||
uint8_t | uc_apply_setting_flag | ||
) |
Get the Link & speed settings, and automatically set up the GMAC with the settings.
p_gmac | Pointer to the GMAC instance. |
uc_phy_addr | PHY address. |
uc_apply_setting_flag | Set to 0 to not apply the PHY configurations, else to apply. |
Return GMAC_OK if successfully, GMAC_TIMEOUT if timeout.
References gmac_enable_full_duplex(), gmac_enable_management(), GMAC_INVALID, GMAC_OK, gmac_phy_read(), gmac_set_speed(), GMII_100BASE_TX_FD, GMII_100BASE_TX_HD, GMII_10BASE_T_FD, GMII_10BASE_T_HD, GMII_BMSR, GMII_LINK_STATUS, GMII_OMI_100BASE_TX_FD, GMII_OMI_100BASE_TX_HD, GMII_OMI_10BASE_T_FD, GMII_OMI_10BASE_T_HD, and GMII_PCR1.
Referenced by run_gmac_link_test().