Software Drivers
Main Page | Data Structures | File List | Data Fields | Globals

xlltemac.c File Reference


Detailed Description

The XLlTemac driver. Functions in this file are the minimum required functions for this driver. See xlltemac.h for a detailed description of the driver.

 MODIFICATION HISTORY:

 Ver   Who  Date     Changes
 ----- ---- -------- -------------------------------------------------------
 1.00a jvb  11/10/06 First release
 1.00b drg  02/08/08 Added MGT check to the reset routine
 2.00a wsy  08/08/08 Added extended VLAN and multicast features
 


Functions

int XLlTemac_CfgInitialize (XLlTemac *InstancePtr, XLlTemac_Config *CfgPtr, u32 EffectiveAddress)
void XLlTemac_Start (XLlTemac *InstancePtr)
void XLlTemac_Stop (XLlTemac *InstancePtr)
void XLlTemac_Reset (XLlTemac *InstancePtr, int HardCoreAction)
int XLlTemac_SetMacAddress (XLlTemac *InstancePtr, void *AddressPtr)
void XLlTemac_GetMacAddress (XLlTemac *InstancePtr, void *AddressPtr)
int XLlTemac_SetOptions (XLlTemac *InstancePtr, u32 Options)
int XLlTemac_ClearOptions (XLlTemac *InstancePtr, u32 Options)
u32 XLlTemac_GetOptions (XLlTemac *InstancePtr)
u16 XLlTemac_GetOperatingSpeed (XLlTemac *InstancePtr)
void XLlTemac_SetOperatingSpeed (XLlTemac *InstancePtr, u16 Speed)
void XLlTemac_PhySetMdioDivisor (XLlTemac *InstancePtr, u8 Divisor)


Function Documentation

int XLlTemac_CfgInitialize XLlTemac InstancePtr,
XLlTemac_Config CfgPtr,
u32  EffectiveAddress
 

XLlTemac_CfgInitialize initializes a TEMAC channel along with the InstancePtr that references it. Each TEMAC channel is treated as a separate device from the point of view of this driver.

The PHY is setup independently from the TEMAC. Use the MII or whatever other interface may be present for setup.

Parameters:
InstancePtr references the memory instance to be associated with the TEMAC channel upon initialization.
CfgPtr references the structure holding the hardware configuration for the TEMAC channel to initialize.
EffectiveAddress is the processor address used to access the base address of the TEMAC channel. In systems with an MMU and virtual memory, EffectiveAddress is the virtual address mapped to the physical in ConfigPtr->Config.BaseAddress. In systems without an active MMU, EffectiveAddress should be set to the same value as ConfigPtr->Config.BaseAddress.
Returns:
XLlTemac_CfgInitialize returns XST_SUCCESS.
Note:
This routine accesses the hard TEMAC registers through a shared interface between both channels of the TEMAC. Becuase of this, the application/OS code must provide mutual exclusive access to this routine with any of the other routines in this TEMAC driverr.

int XLlTemac_ClearOptions XLlTemac InstancePtr,
u32  Options
 

XLlTemac_ClearOptions clears the options, Options for the TEMAC channel, specified by InstancePtr. The TEMAC channel should be stopped with XLlTemac_Stop() before changing options.

Parameters:
InstancePtr references the TEMAC channel on which to operate.
Options is a bitmask of OR'd XTE_*_OPTION values for options to clear. Options not specified are not affected.
Returns:
On successful completion, XLlTemac_ClearOptions returns XST_SUCCESS. Otherwise, if the device has not been stopped, XLlTemac_ClearOptions returns XST_DEVICE_IS_STARTED.
Note:
See xlltemac.h for a description of the available options.
This routine accesses the hard TEMAC registers through a shared interface between both channels of the TEMAC. Becuase of this, the application/OS code must provide mutual exclusive access to this routine with any of the other routines in this TEMAC driverr.

void XLlTemac_GetMacAddress XLlTemac InstancePtr,
void *  AddressPtr
 

XLlTemac_GetMacAddress gets the MAC address for the TEMAC channel, specified by InstancePtr into the memory buffer specified by AddressPtr.

Parameters:
InstancePtr references the TEMAC channel on which to operate.
AddressPtr references the memory buffer to store the retrieved MAC address. This memory buffer must be at least 6 bytes in length.
Returns:
N/A
Note:
This routine accesses the hard TEMAC registers through a shared interface between both channels of the TEMAC. Becuase of this, the application/OS code must provide mutual exclusive access to this routine with any of the other routines in this TEMAC driver. This routine also supports the extended/new VLAN and multicast mode. The XTE_RAF_NEWFNCENBL_MASK bit dictats which offset will be configured.

u16 XLlTemac_GetOperatingSpeed XLlTemac InstancePtr  ) 
 

XLlTemac_GetOperatingSpeed gets the current operating link speed. This may be the value set by XLlTemac_SetOperatingSpeed() or a hardware default.

Parameters:
InstancePtr references the TEMAC channel on which to operate.
Returns:
XLlTemac_GetOperatingSpeed returns the link speed in units of megabits per second.
Note:
This routine accesses the hard TEMAC registers through a shared interface between both channels of the TEMAC. Becuase of this, the application/OS code must provide mutual exclusive access to this routine with any of the other routines in this TEMAC driverr.

u32 XLlTemac_GetOptions XLlTemac InstancePtr  ) 
 

XLlTemac_GetOptions returns the current option settings.

Parameters:
InstancePtr references the TEMAC channel on which to operate.
Returns:
XLlTemac_GetOptions returns a bitmask of XTE_*_OPTION constants, each bit specifying an option that is currently active.
Note:
See xlltemac.h for a description of the available options.

void XLlTemac_PhySetMdioDivisor XLlTemac InstancePtr,
u8  Divisor
 

XLlTemac_PhySetMdioDivisor sets the MDIO clock divisor in the TEMAC channel, specified by InstancePtr to the value, Divisor. This function must be called once after each reset prior to accessing MII PHY registers.

From the Virtex-4 Embedded Tri-Mode Ethernet MAC User's Guide, the following equation governs the MDIO clock to the PHY:

              f[HOSTCLK]
   f[MDC] = -----------------
            (1 + Divisor) * 2
 

where f[HOSTCLK] is the bus clock frequency in MHz, and f[MDC] is the MDIO clock frequency in MHz to the PHY. Typically, f[MDC] should not exceed 2.5 MHz. Some PHYs can tolerate faster speeds which means faster access.

Parameters:
InstancePtr references the TEMAC channel on which to operate.
Divisor is the divisor value to set within the range of 0 to XTE_MC_CLK_DVD_MAX.
Note:
This routine accesses the hard TEMAC registers through a shared interface between both channels of the TEMAC. Becuase of this, the application/OS code must provide mutual exclusive access to this routine with any of the other routines in this TEMAC driverr.

void XLlTemac_Reset XLlTemac InstancePtr,
int  HardCoreAction
 

XLlTemac_Reset performs a reset of the TEMAC channel, specified by InstancePtr, or both channels if HardCoreAction is set to XTE_RESET_HARD.

XLlTemac_Reset also resets the TEMAC channel's options to their default values.

The calling software is responsible for re-configuring the TEMAC channel (if necessary) and restarting the MAC after the reset.

Parameters:
InstancePtr references the TEMAC channel on which to operate.
HardCoreAction describes how XLlTemac_Reset should treat the hard core block of the TEMAC.

If XTE_RESET_HARD is set to XTE_RESET_HARD, then XLlTemac_Reset asserts the reset signal to the hard core block which will reset both channels of the TEMAC. This, of course, will bork any activity that may be occuring on the other channel. So, be careful here.

Otherwise, XLlTemac_Reset resets just the transmitter and receiver of this TEMAC channel.

Note:
This routine accesses the hard TEMAC registers through a shared interface between both channels of the TEMAC. Becuase of this, the application/OS code must provide mutual exclusive access to this routine with any of the other routines in this TEMAC driverr.

int XLlTemac_SetMacAddress XLlTemac InstancePtr,
void *  AddressPtr
 

XLlTemac_SetMacAddress sets the MAC address for the TEMAC channel, specified by InstancePtr to the MAC address specified by AddressPtr. The TEMAC channel must be stopped before calling this function.

Parameters:
InstancePtr references the TEMAC channel on which to operate.
AddressPtr is a reference to the 6-byte MAC address to set.
Returns:
On successful completion, XLlTemac_SetMacAddress returns XST_SUCCESS. Otherwise, if the TEMAC channel has not stopped, XLlTemac_SetMacAddress returns XST_DEVICE_IS_STARTED.
Note:
This routine accesses the hard TEMAC registers through a shared interface between both channels of the TEMAC. Becuase of this, the application/OS code must provide mutual exclusive access to this routine with any of the other routines in this TEMAC driver. This routine also supports the extended/new VLAN and multicast mode. The XTE_RAF_NEWFNCENBL_MASK bit dictats which offset will be configured.

void XLlTemac_SetOperatingSpeed XLlTemac InstancePtr,
u16  Speed
 

XLlTemac_SetOperatingSpeed sets the current operating link speed. For any traffic to be passed, this speed must match the current MII/GMII/SGMII/RGMII link speed.

Parameters:
InstancePtr references the TEMAC channel on which to operate.
Speed is the speed to set in units of Mbps. Valid values are 10, 100, or 1000. XLlTemac_SetOperatingSpeed ignores invalid values.
Note:
This routine accesses the hard TEMAC registers through a shared interface between both channels of the TEMAC. Becuase of this, the application/OS code must provide mutual exclusive access to this routine with any of the other routines in this TEMAC driverr.

int XLlTemac_SetOptions XLlTemac InstancePtr,
u32  Options
 

XLlTemac_SetOptions enables the options, Options for the TEMAC channel, specified by InstancePtr. The TEMAC channel should be stopped with XLlTemac_Stop() before changing options.

Parameters:
InstancePtr references the TEMAC channel on which to operate.
Options is a bitmask of OR'd XTE_*_OPTION values for options to set. Options not specified are not affected.
Returns:
On successful completion, XLlTemac_SetOptions returns XST_SUCCESS. Otherwise, if the device has not been stopped, XLlTemac_SetOptions returns XST_DEVICE_IS_STARTED.
Note:
See xlltemac.h for a description of the available options.
This routine accesses the hard TEMAC registers through a shared interface between both channels of the TEMAC. Becuase of this, the application/OS code must provide mutual exclusive access to this routine with any of the other routines in this TEMAC driverr.

void XLlTemac_Start XLlTemac InstancePtr  ) 
 

XLlTemac_Start starts the TEMAC channel as follows:

  • Enable transmitter if XTE_TRANSMIT_ENABLE_OPTION is set
  • Enable receiver if XTE_RECEIVER_ENABLE_OPTION is set

Parameters:
InstancePtr references the TEMAC channel on which to operate.
Returns:
N/A
Note:
This routine accesses the hard TEMAC registers through a shared interface between both channels of the TEMAC. Becuase of this, the application/OS code must provide mutual exclusive access to this routine with any of the other routines in this TEMAC driverr.

void XLlTemac_Stop XLlTemac InstancePtr  ) 
 

XLlTemac_Stop gracefully stops the TEMAC channel as follows:

  • Disable all interrupts from this device
  • Disable the receiver

XLlTemac_Stop does not modify any of the current device options.

Since the transmitter is not disabled, frames currently in internal buffers or in process by a DMA engine are allowed to be transmitted.

Parameters:
InstancePtr references the TEMAC channel on which to operate.
Returns:
N/A
Note:
This routine accesses the hard TEMAC registers through a shared interface between both channels of the TEMAC. Becuase of this, the application/OS code must provide mutual exclusive access to this routine with any of the other routines in this TEMAC driverr.