⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 txc_envoy_pin_real.c

📁 TranSwitch Envoy CE2 & Envoy CE4 设备驱动及编程指南
💻 C
📖 第 1 页 / 共 2 页
字号:
/*--------------------------------------------------------------------------

  *******                           ****
     *     *****     **    *    *  *       *    *   *  *****   ****   *    *
     *     *    *   *  *   **   *  *       *    *   *    *    *    *  *    *
     *     *    *  *    *  * *  *   ****   *    *   *    *    *       ******
     *     *****   ******  *  * *       *  * ** *   *    *    *       *    *
     *     *   *   *    *  *   **  *    *  **  **   *    *    *    *  *    *
     *     *    *  *    *  *    *   ****   *    *   *    *     ****   *    *

                        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_pin_real.c

   Description:  Device Pin-Status Retrieve and Device Pin-Status 
                 configuration 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_pin_real.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                         **
 ****************************************************************************/
static void GetMacPortRangePin(TXC_U16BIT handle, TXC_U16BIT port, 
            TXC_U16BIT * start, TXC_U16BIT * end, TXC_U16BIT * inc);
    
/****************************************************************************
 **                                  Code                                  **
 ****************************************************************************/



/* ========================================================================= */

/*             DEVICE-PIN STATUS AND PIN-CONFIGURATION FUNCTIONS             */


/*---------------------------------------------------------------------------*


   FUNCTION:  ENVOY_RtrvDeviceExPinReal
                                                                             
   DESCRIPTION: This function actually processess the ENVOY_DeviceExPinRtrv
                                                                             
   INPUTS:                                                                    
                                                                             
   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_RtrvDeviceExPinReal(TXC_U16BIT handle, 
           ENVOY_DEV_EXT_PIN_STRUCT *deviceExtPinDataPtr)

{
    TXC_U16BIT error;
    TXC_BATCH_REG_ACCESS_32BIT_STRUCT batchData;
    TXC_REG_ACCESS_32BIT_STRUCT regData[2];
    TXC_REG_32              *baseAddr;
    ENVOY_HOST_PIN_RMONCTRL_STRUCT *pinCfgPtr;
    TXC_REG_32  tmpdata;

    /* First, fill the batch platform header. This function requires 4
       registers to be read */
    memset (&regData[0], 0, (sizeof(TXC_REG_ACCESS_32BIT_STRUCT)));
    batchData.regDataPtr = &regData[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);
    pinCfgPtr = (ENVOY_HOST_PIN_RMONCTRL_STRUCT *) (baseAddr + ENVOY_HOST_PIN_OFFSET);

    regData[0].addr = (TXC_REG_32 *) &(pinCfgPtr->pinReg);

    /* MAC address is six bytes */
    regData[0].mask = 0xF00FF;

    /* Read the registers and return the data */    
    error = TXC_BatchReg32BitRead (&batchData);
    if (error != TXC_NO_ERR)
    {
        return error;
    }

    tmpdata = (regData[0].data) & 0x3;
    switch (tmpdata)
    {
        case 0:
            deviceExtPinDataPtr->ports0to7Mode = ENVOY_DEV_PIN_MODE_OFF;
            break;

        case 1:
            deviceExtPinDataPtr->ports0to7Mode = ENVOY_DEV_PIN_MODE_1_GMII;
            break;

        case 2:
            deviceExtPinDataPtr->ports0to7Mode = ENVOY_DEV_PIN_MODE_2_ESMII;
            break;

        case 3:
            deviceExtPinDataPtr->ports0to7Mode = ENVOY_DEV_PIN_MODE_8_SMII;
            break;

        default:  /* should never happen */
            break;
    }

    tmpdata = (regData[0].data >> 2) & 0x3;
    switch (tmpdata)
    {
        case 0:
            deviceExtPinDataPtr->ports8to15Mode = ENVOY_DEV_PIN_MODE_OFF;
            break;

        case 1:
            deviceExtPinDataPtr->ports8to15Mode = ENVOY_DEV_PIN_MODE_1_GMII;
            break;

        case 2:
            deviceExtPinDataPtr->ports8to15Mode = ENVOY_DEV_PIN_MODE_2_ESMII;
            break;

        case 3:
            deviceExtPinDataPtr->ports8to15Mode = ENVOY_DEV_PIN_MODE_8_SMII;
            break;

        default:  /* should never happen */
            break;
    }

    tmpdata = (regData[0].data >> 4) & 0x3;
    switch (tmpdata)
    {
        case 0:
            deviceExtPinDataPtr->ports16to23Mode = ENVOY_DEV_PIN_MODE_OFF;
            break;

        case 1:
            deviceExtPinDataPtr->ports16to23Mode = ENVOY_DEV_PIN_MODE_1_GMII;
            break;

        case 2:
            deviceExtPinDataPtr->ports16to23Mode = ENVOY_DEV_PIN_MODE_2_ESMII;
            break;

        case 3:
            deviceExtPinDataPtr->ports16to23Mode = ENVOY_DEV_PIN_MODE_8_SMII;
            break;

        default:  /* should never happen */
            break;
    }

    tmpdata = (regData[0].data >> 6) & 0x3;
    switch (tmpdata)
    {
        case 0:
            deviceExtPinDataPtr->ports24to31Mode = ENVOY_DEV_PIN_MODE_OFF;
            break;

        case 1:
            deviceExtPinDataPtr->ports24to31Mode = ENVOY_DEV_PIN_MODE_1_GMII;
            break;

        case 2:
            deviceExtPinDataPtr->ports24to31Mode = ENVOY_DEV_PIN_MODE_2_ESMII;
            break;

        case 3:
            deviceExtPinDataPtr->ports24to31Mode = ENVOY_DEV_PIN_MODE_8_SMII;
            break;

        default:  /* should never happen */
            break;
    }


    tmpdata = (regData[0].data >> 16) & 0x1;
    switch (tmpdata)
    {
        case 0:
            deviceExtPinDataPtr->spi3InputMode = ENVOY_DEV_PIN_SPI3_PHY_MODE;
            break;

        case 1:
            deviceExtPinDataPtr->spi3InputMode = ENVOY_DEV_PIN_SPI3_LINK_MODE;
            break;

        default:  /* should never happen */
            break;
    }

    tmpdata = (regData[0].data >> 17) & 0x1;
    switch (tmpdata)
    {
        case 0:
            deviceExtPinDataPtr->spi3OutputMode = ENVOY_DEV_PIN_SPI3_PHY_MODE;
            break;

        case 1:
            deviceExtPinDataPtr->spi3OutputMode = ENVOY_DEV_PIN_SPI3_LINK_MODE;
            break;

        default:  /* should never happen */
            break;
    }

    tmpdata = (regData[0].data >> 18) & 0x3;
    switch (tmpdata)
    {
        case 0:
            deviceExtPinDataPtr->spi3WidthMode = ENVOY_DEV_PIN_SPI3_32_BITS;
            break;

        case 1:
            deviceExtPinDataPtr->spi3WidthMode = ENVOY_DEV_PIN_SPI3_16_BITS;
            break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -