Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
PHY component (KSZ8081RNA)

Driver for the ksz8081rna component.

This driver provides access to the main features of the PHY.

Dependencies

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
#define ETH_PHY_TIMEOUT   10

Referenced by ethernet_phy_reset().

uint8_t ethernet_phy_auto_negotiate ( Gmac *  p_gmac,
uint8_t  uc_phy_addr 
)
static uint8_t ethernet_phy_find_valid ( Gmac *  p_gmac,
uint8_t  uc_phy_addr,
uint8_t  uc_start_addr 
)
static

Find a valid PHY Address ( from addrStart to 31 ).

Parameters
p_gmacPointer to the GMAC instance.
uc_phy_addrPHY address.
uc_start_addrStart address of the PHY to be searched.
Returns
0xFF when no valid PHY address is found.

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.

Parameters
p_gmacPointer to the GMAC instance.
uc_phy_addrPHY address.
ul_mckGMAC 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 gmac_low_level_init().

uint8_t ethernet_phy_reset ( Gmac *  p_gmac,
uint8_t  uc_phy_addr 
)

Issue a SW reset to reset all registers of the PHY.

Parameters
p_gmacPointer to the GMAC instance.
uc_phy_addrPHY 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.

Parameters
p_gmacPointer to the GMAC instance.
uc_phy_addrPHY address.
uc_apply_setting_flagSet 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 gmac_low_level_init().