📄 txc_envoy_pin_real.c
字号:
case 2:
deviceExtPinDataPtr->spi3WidthMode = ENVOY_DEV_PIN_SPI3_8_BITS;
break;
default: /* should never happen */
deviceExtPinDataPtr->spi3WidthMode = ENVOY_DEV_PIN_SPI3_WIDTH_MODE_ENUM_ERR;
break;
}
return error;
}
/*--------------------------------------------------------------------------*
FUNCTION: ENVOY_SetEthernetPortConfigReal
DESCRIPTION: This function actually processess the ENVOY_EthernetPortConfigSet
INPUTS: Same as ENVOY_EthernetPortConfigSet
RETURNS: TXC_NO_ERR or an appropriate specific error code listed in
appendix.
CAVEATS: The hardware default on the interface comes up in GPSI mode,
which is not recommended for use.
REVISION HISTORY:
Rev # Date Author Description
----- ------- ------------ ----------------------
0.5.0 6/03/04 F. Giannella Initial release (beta)
*--------------------------------------------------------------------------*/
TXC_U16BIT ENVOY_SetEthernetPortConfigReal (TXC_U16BIT handle, TXC_U16BIT port,
ENVOY_DEV_ETHERNET_MODE_STRUCT * ethernetPortModeDataPtr)
{
TXC_U16BIT error = TXC_NO_ERR;
TXC_BATCH_REG_ACCESS_32BIT_STRUCT batchData;
/* TXC_REG_ACCESS_32BIT_STRUCT regData[6]; */
TXC_REG_ACCESS_32BIT_STRUCT regData[2];
TXC_REG_32 *baseAddr;
TXC_REG_32 *portAddr;
TXC_U16BIT portIdx;
TXC_U16BIT endPort;
TXC_U16BIT startPort;
TXC_U16BIT portInc;
ENVOY_MAC_CONFIG_STRUCT *macCfgPtr; /* in mem_map.h: registers 0x4004 and 0x4038 */
/* First, fill the batch platform header. This function requires 1
register to be written among two possible registers 0x4004 and 0x4038, depending on the entry value*/
batchData.regDataPtr = ®Data[0];
batchData.writeVerifyFlag = TXC_WRITE_VERIFY_FLAG;
batchData.semId = ENVOY_DbGetSemId();
/* batchData.regCount = 4; */
memset ( (char *)regData, 0, sizeof(regData) );
/* determine if one MAC port is being configured or all ports */
GetMacPortRangePin(handle, port, &startPort, &endPort, &portInc);
/* determine the base address of the device */
baseAddr = (TXC_REG_32 *) ENVOY_DbGetDeviceAddr (handle);
regData[0].mask = 0x300;
switch (ethernetPortModeDataPtr->ethernetPortMode)
{
case ENVOY_PORT_GMII_MODE: /* GMII port in byte-wide mode, ("full" GMII mode port). */
batchData.regCount = 1; /* Note: this mode can only be set if the associated port */
regData[0].data = 0x200; /* is within an octal range having the pin configuration */
break; /* equal to ENVOY_DEV_PIN_MODE_1_GMII */
case ENVOY_PORT_SMII_OR_MII_PHY_MODE: /* Port in PHY mode which is either a GMII port in nibble */
batchData.regCount = 2; /* wide mode (MII port), or an SMII port. */
regData[0].data = 0x100; /* Note: in case this port is within an octal range having */
regData[1].mask = 0x1000000; /* the pin configuration equal to ENVOY_DEV_PIN_MODE_1_GMII,*/
regData[1].data = 0x1000000; /* setting a port to this mode should only be performed if */
break; /* the attached PHY device has configured it in MII mode. */
case ENVOY_PORT_SMII_OR_MII_MAC_TO_MAC_MODE: /* Port in MAC-to-MAC mode which is either a GMII port in */
batchData.regCount = 2; /* nibble-wide mode (MII port), or an SMII port. */
regData[0].data = 0x100; /* Note1: in case this port is within an octal range having */
regData[1].mask = 0x1000000; /* the pin configuration equal to ENVOY_DEV_PIN_MODE_1_GMII,*/
regData[1].data = 0x0; /* setting a port to this mode should only be performed if */
break; /* the attached PHY device has configured it as an MII port.*/
/* Note2: Since in MAC-to-MAC mode, the port configuration */
/* reverts to pre-defined settings of 100 Mb/s, Full Duplex.*/
default:
error = TXC_INVALID_PARM_ERR; /* should never occur */
break;
} /* end of switch */
/* loop thru all ports setting up the MAC interface parameters */
for (portIdx = startPort; portIdx < endPort; )
{
portAddr = baseAddr + macCfgOffset[portIdx];
macCfgPtr = (ENVOY_MAC_CONFIG_STRUCT *) portAddr;
/* Setup the addresses to write the MAC interface config */
regData[0].addr = (TXC_REG_32 *) &(macCfgPtr->cfg2Reg);
regData[1].addr = (TXC_REG_32 *) &(macCfgPtr->ifaceCtrlReg); /* relevant only if batchData.regCount = 2 */
error = TXC_BatchReg32BitWrite (&batchData);
if (error != TXC_NO_ERR)
return(error);
portIdx = portIdx + portInc;
}
return error;
}
/*--------------------------------------------------------------------------*
FUNCTION: ENVOY_GetEthernetPortConfigReal
DESCRIPTION: This function actually processess the ENVOY_EthernetPortConfigRealGet
INPUTS: Same as ENVOY_EthernetPortConfigRealGet
RETURNS: TXC_NO_ERR or an appropriate specific error code listed in appendix.
CAVEATS: None.
REVISION HISTORY:
Rev # Date Author Description
----- ------- ------------ ----------------------
0.5.0 6/03/04 F. Giannella Initial release (beta)
*--------------------------------------------------------------------------*/
TXC_U16BIT ENVOY_GetEthernetPortConfigReal(TXC_U16BIT handle, TXC_U16BIT port,
ENVOY_DEV_ETHERNET_MODE_STRUCT *ethernetPortModeDataPtr)
{
TXC_U16BIT error;
TXC_BATCH_REG_ACCESS_32BIT_STRUCT batchData;
TXC_REG_ACCESS_32BIT_STRUCT regData[6];
/* TXC_REG_32 *baseAddr, tmpdata; */
TXC_REG_32 *baseAddr;
/* TXC_REG_32 *mgmtAddr; */
ENVOY_MAC_CONFIG_STRUCT *macCfgPtr;
TXC_REG_32 tmpdata1, tmpdata2;
/* First, fill the batch platform header. This function requires 4
registers to be read */
memset (®Data[0], 0, (4 * sizeof(TXC_REG_ACCESS_32BIT_STRUCT) ) );
batchData.regDataPtr = ®Data[0];
batchData.writeVerifyFlag = TXC_WRITE_VERIFY_FLAG;
batchData.semId = ENVOY_DbGetSemId();
batchData.regCount = 2; /* need to read two registers: 0x4004 and 0x4038 */
/* determine the base address of the device */
baseAddr = (TXC_REG_32 *) ENVOY_DbGetDeviceAddr (handle);
macCfgPtr = (ENVOY_MAC_CONFIG_STRUCT *) (baseAddr+macCfgOffset[port] );
/* Setup the addresses and masks to read for MAC interface */
regData[0].addr = (TXC_REG_32 *) &(macCfgPtr->cfg2Reg); /* reg 0x4004 */
regData[1].addr = (TXC_REG_32 *) &(macCfgPtr->ifaceCtrlReg); /* reg 0x4038 */
/* iface mode: bits 9:8 of register 0x4004 */
regData[0].mask = 0x300;
/* PHY mode: bit 24 of register 0x4038 */
regData[1].mask = 0x1000000;
/* Read the registers and return the data */
error = TXC_BatchReg32BitRead (&batchData);
if (error == TXC_NO_ERR)
{
/* Parse the data read */
tmpdata1 = (regData[0].data >> 8) & 0x3;
if (tmpdata1 == ENVOY_MAC_GMII_MODE) /* "full" GMII port */
{
ethernetPortModeDataPtr->ethernetPortMode = ENVOY_PORT_GMII_MODE;
}
else if (tmpdata1 == ENVOY_MAC_SMII_OR_MII_MODE) /* either MII or SMII port */
{
tmpdata2 = (regData[1].data >> 24) & 0x1;
if (tmpdata2 == TXC_TRUE)
{
ethernetPortModeDataPtr->ethernetPortMode = ENVOY_PORT_SMII_OR_MII_PHY_MODE;
}
else
{
ethernetPortModeDataPtr->ethernetPortMode = ENVOY_PORT_SMII_OR_MII_MAC_TO_MAC_MODE;
}
}
else if (tmpdata1 == ENVOY_MAC_MODE_OFF)
{
ethernetPortModeDataPtr->ethernetPortMode = ENVOY_PORT_MODE_OFF;
}
else
{
error = TXC_INVALID_PARM_ERR; /* value from iface field was either "00" or "11" */
}
}
return error;
}
/*--------------------------------------------------------------------------*
FUNCTION: GetMacPortRangePin
DESCRIPTION: This local function determines the range of ports to process
based on device type. For Envoy-CE2, only ports 0 and 8 can
be programmed for GMII. For Envoy-CE4 only ports 0, 8, 16 and
24 can be programmed for GMII. FG - to do : tighten the range.
INPUTS: handle, port
RETURNS: start port, end port and increment.
CAVEATS: None.
REVISION HISTORY:
Rev # Date Author Description
----- ------- ------------ ----------------------
0.5.0 6/03/04 F. Giannella Initial release (beta)
*--------------------------------------------------------------------------*/
static void GetMacPortRangePin(TXC_U16BIT handle, TXC_U16BIT port, TXC_U16BIT * start, TXC_U16BIT * end, TXC_U16BIT * inc)
{
TXC_U16BIT deviceType;
/* First, get the device type. */
deviceType = ENVOY_DbGetDeviceType (handle);
if ((deviceType != ENVOY_CE2) && (deviceType != ENVOY_CE4) )
return;
/* determine if one MAC port is being accessed */
if (port == ENVOY_MAC_ALL_PORTS)
{
if (deviceType == ENVOY_CE2)
{
*start = 0;
*end = ENVOY_CE2_MAX_MAC_PORTS;
*inc = 1;
}
else /* that is, deviceType == ENVOY_CE4 */
{
*start = 0;
*end = ENVOY_CE4_MAX_MAC_PORTS;
*inc = 1;
}
}
else
{
*start = port;
*end = port + 1;
*inc = 1;
}
}
#endif
/****************************************************************************
** End of Module **
****************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -