📄 txc_envoy_mgmt_port_real.c
字号:
/*--------------------------------------------------------------------------
******* ****
* ***** ** * * * * * * ***** **** * *
* * * * * ** * * * * * * * * * *
* * * * * * * * **** * * * * * ******
* ***** ****** * * * * * ** * * * * * *
* * * * * * ** * * ** ** * * * * * *
* * * * * * * **** * * * * **** * *
Proprietary and Confidential
This program is made available only to customers and prospective customers
of TranSwitch Corporation under license and may be used only with TranSwitch
semi-conductor products.
Copyright(c) 2004 TranSwitch Inc.
--------------------------------------------------------------------------
******* ** ** ** ** ******** ** **
******* *** ** ** ** ********** ** **
** ** * ** ** ** ** ** ** **
***** ** * ** ** ** ** ** * *
***** ** * ** ** ** ** ** **
** ** * ** ** ** ** ** **
******* ** *** **** ********** **
******* ** ** ** ******** **
--------------------------------------------------------------------------
TranSwitch Envoy-CE2/CE4
Device Driver
--------------------------------------------------------------------------
Workfile: txc_envoy_mac_real.c
Description: Physical layer for the management port functions.
--------------------------------------------------------------------------
Revision History
--------------------------------------------------------------------------
Rev # Date Author Description
----- ------ ------- -----------
0.5.0 6/03/04 F. Giannella Initial release (beta)
*--------------------------------------------------------------------------*/
/****************************************************************************
** Include Files **
****************************************************************************/
#include "txc_envoy_api.h"
/* do nothing if this driver is in virtual mode */
#ifndef TXC_ENVOY_VIRTUAL_DEVICE_MODE
#include "txc_envoy_mgmt_port_support.h"
#include "txc_envoy_database.h"
#include "txc_hw_platform.h"
#include "txc_envoy_mem_map.h"
#include <string.h>
/****************************************************************************
** Static Functions **
****************************************************************************/
/****************************************************************************
** Static/Global Variables **
****************************************************************************/
/****************************************************************************
** Code **
****************************************************************************/
/* in process below */
/************************************************************************************/
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
/************************************************************************************
FUNCTION: ENVOY_MgmtPortResetReal
DESCRIPTION: This function actually processess the TXC_ENVOY_MgmtPortReset
INPUTS: Same as TXC_ENVOY_MgmtPortReset
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_MgmtPortResetReal(TXC_U16BIT handle)
{
TXC_U16BIT error = TXC_NO_ERR;
TXC_BATCH_REG_ACCESS_32BIT_STRUCT batchData;
TXC_REG_ACCESS_32BIT_STRUCT regData[1];
TXC_REG_32 * baseAddr;
ENVOY_HOST_RESET_STRUCT * mgmPortResetRegPtr;
/* First, fill the batch platform header. This function requires 1
register to be written */
memset (®Data[0], 0, (sizeof(TXC_REG_ACCESS_32BIT_STRUCT) ) );
batchData.regDataPtr = ®Data[0];
batchData.writeVerifyFlag = TXC_WRITE_VERIFY_FLAG;
batchData.semId = ENVOY_DbGetSemId();
batchData.regCount = 1;
/* determine the base address of the device */
baseAddr = (TXC_REG_32 *) ENVOY_DbGetDeviceAddr (handle);
/* Setup the data and masks for the MII Mgmt address and control register*/
regData[0].mask = 0x10;
regData[0].data = 0x10;
mgmPortResetRegPtr = (ENVOY_HOST_RESET_STRUCT *) (baseAddr + ENVOY_HOST_RESET_OFFSET);
/* Setup the addresses to write the MAC MII Management registers */
regData[0].addr = (TXC_REG_32 *) &(mgmPortResetRegPtr->resetModuleReg);
error = TXC_BatchReg32BitWrite (&batchData);
regData[0].data = 0x0; /* remove the management port from reset */
error = TXC_BatchReg32BitWrite (&batchData);
return error;
}
/************************************************************************************/
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
/************************************************************************************
FUNCTION: ENVOY_SetMgmtPortConfigReal
DESCRIPTION: This function actually processess the TXC_ENVOY_MgmtPortConfigSet
INPUTS: Same as TXC_ENVOY_MgmtPortConfigSet
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_SetMgmtPortConfigReal(TXC_U16BIT handle,
ENVOY_MGMT_PORT_CFG_STRUCT *mgmtPortDataPtr)
{
TXC_U16BIT error = TXC_NO_ERR;
TXC_BATCH_REG_ACCESS_32BIT_STRUCT batchData;
TXC_REG_ACCESS_32BIT_STRUCT regData[1];
TXC_REG_32 * baseAddr;
ENVOY_MGMT_PORT_STRUCT * mgmClockDivideRegPtr;
/* First, fill the batch platform header. This function requires 1
register to be written */
memset (®Data[0], 0, (sizeof(TXC_REG_ACCESS_32BIT_STRUCT) ) );
batchData.regDataPtr = ®Data[0];
batchData.writeVerifyFlag = TXC_WRITE_VERIFY_FLAG;
batchData.semId = ENVOY_DbGetSemId();
batchData.regCount = 1;
/* determine the base address of the device */
baseAddr = (TXC_REG_32 *) ENVOY_DbGetDeviceAddr (handle);
/* Setup the data and masks for the MII Mgmt address and control register*/
regData[0].mask = 0x7;
switch (mgmtPortDataPtr->mgmtClockDivideMode)
{
case ENVOY_MGMT_PORT_CLK_DIV4:
regData[0].data = 0;
break;
case ENVOY_MGMT_PORT_CLK_DIV6:
regData[0].data = 2;
break;
case ENVOY_MGMT_PORT_CLK_DIV8:
regData[0].data = 3;
break;
case ENVOY_MGMT_PORT_CLK_DIV10:
regData[0].data = 4;
break;
case ENVOY_MGMT_PORT_CLK_DIV14:
regData[0].data = 5;
break;
case ENVOY_MGMT_PORT_CLK_DIV20:
regData[0].data = 6;
break;
case ENVOY_MGMT_PORT_CLK_DIV28:
regData[0].data = 7;
break;
default:
break;
}
mgmClockDivideRegPtr = (ENVOY_MGMT_PORT_STRUCT *) (baseAddr + ENVOY_MGMT_PORT_OFFSET);
/* Setup the addresses to write the MAC MII Management registers */
regData[0].addr = (TXC_REG_32 *) &(mgmClockDivideRegPtr->mIIMgmtCfg);
error = TXC_BatchReg32BitWrite (&batchData);
return error;
}
/************************************************************************************/
/*||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||*/
/************************************************************************************
FUNCTION: ENVOY_GetMgmtPortConfigReal
DESCRIPTION: This function actually processess the TXC_ENVOY_MgmtPortConfigGet
API function.
INPUTS: Same as TXC_ENVOY_MgmtPortConfigGet
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_GetMgmtPortConfigReal(TXC_U16BIT handle,
ENVOY_MGMT_PORT_CFG_STRUCT *mgmtPortDataPtr)
{
TXC_U16BIT error;
TXC_BATCH_REG_ACCESS_32BIT_STRUCT batchData;
TXC_REG_ACCESS_32BIT_STRUCT regData[1];
TXC_REG_32 *baseAddr;
ENVOY_MGMT_PORT_STRUCT * mgmClockDivideRegPtr;
/* First, fill the batch platform header. This function requires 5
registers to be read */
memset (®Data[0], 0, (sizeof(TXC_REG_ACCESS_32BIT_STRUCT) ) );
batchData.regDataPtr = ®Data[0];
batchData.writeVerifyFlag = TXC_WRITE_VERIFY_FLAG;
batchData.semId = ENVOY_DbGetSemId();
batchData.regCount = 1;
/* determine the base address of the device */
baseAddr = (TXC_REG_32 *) ENVOY_DbGetDeviceAddr (handle);
mgmClockDivideRegPtr = (ENVOY_MGMT_PORT_STRUCT *) (baseAddr + ENVOY_MGMT_PORT_OFFSET);
/* Setup the addresses and masks to read */
regData[0].addr = (TXC_REG_32 *) &(mgmClockDivideRegPtr->mIIMgmtCfg);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -