/******************************************************************************
 * FILE PURPOSE:    ESWITCH Driver support Source Code
 ******************************************************************************
 * FILE NAME:       eswitchConfig.c
 *
 * DESCRIPTION:     ESWITCH Configuration parameter for PUSH mechanism
 * 
 * REVISION HISTORY:
 *   19th NOV. 03 - PSP TII  
 *    8th Dec. 03 - PSP TII  

 *
 * (C) Copyright 2003, Texas Instruments, Inc
 *******************************************************************************/
#include "eswitchConfig.h"
extern unsigned int eswitch_cpu_freq;
void get_eswitch_config_info(ESWITCH_CONFIG **p_eswitch_config)
{
  (*p_eswitch_config)->CpuFrequency = eswitch_cpu_freq;  
  (*p_eswitch_config)->EswitchFrequency = eswitch_cpu_freq/2;
  (*p_eswitch_config)->ResetBase  =  AVALANCHE_RESET_CONTROL_BASE /*0xa8611600*/;
  (*p_eswitch_config)->EswitchResetBit= AVALANCHE_ESWITCH_RESET_BIT/*27*/;
  (*p_eswitch_config)->Cpmac0ResetBit = AVALANCHE_LOW_CPMAC_RESET_BIT /*17*/;
  (*p_eswitch_config)->Cpmac1ResetBit = AVALANCHE_HIGH_CPMAC_RESET_BIT/*21*/;
  (*p_eswitch_config)->MdioResetBit   = AVALANCHE_MDIO_RESET_BIT/*22*/;
  (*p_eswitch_config)->Phy0ResetBit   = AVALANCHE_LOW_EPHY_RESET_BIT/*26*/;
  (*p_eswitch_config)->Phy1ResetBit   = AVALANCHE_HIGH_EPHY_RESET_BIT/*28*/;
  (*p_eswitch_config)->HdmaResetBit   = AVALANCHE_HDMA_RESET_BIT/*13*/;
  (*p_eswitch_config)->Cpmac0IntBit   = 19;  /* TO be defined in titan.h*/
  (*p_eswitch_config)->Cpmac1IntBit   = 33;
  (*p_eswitch_config)->EswitchIntBit  = 27;
  (*p_eswitch_config)->EswitchBase    = AVALANCHE_ESWITCH_BASE /*0xa8640000*/;
  (*p_eswitch_config)->EswitchBufferSize     = 64;
  (*p_eswitch_config)->EswitchHostBufCount   = 0;
  (*p_eswitch_config)->EswitchDefaultCamSize = 4;
  (*p_eswitch_config)->EswitchOverFlowCount  = 200;
  (*p_eswitch_config)->EswitchOverFlowSize   = 256;
  (*p_eswitch_config)->EswitchSize   = 0x20000; /* TS to check Eswitch Size */
  return;
}

/*************************************************************************************************************
 *      eswitchConfig
 *      
 * 	Returns:
 *		An error code.
 *	Parms:
 *		HalDev   The HAL device    ( Name of this parameter shouldn't change for the MACRO 
 *                                           cpswhalPushBin(key,val) HalFunc->Control(HalDev,key,SETBIN,val))
 *					     
 *		HalFunc  The HAL Functions ( Name of this parameter shouldn't change for the MACRO 
 *                                           cpswhalPushBin(key,val) HalFunc->Control(HalDev,key,SETBIN,val))
 *		
 *              Config   The configuration parameter
 *
 *	This function shuts down the adapter.  
 *
 *************************************************************************************************************/

int eswitchConfig(HAL_DEVICE *HalDev, HAL_FUNCTIONS *HalFunc, ESWITCH_CONFIG *Config)
{
  int sts = 0;  
  sts |= cpswhalPushBin(hcCpuFrequency, Config->CpuFrequency );
  sts |= cpswhalPushBin(hcEswitchFrequency , Config->EswitchFrequency );
  sts |= cpswhalPushBin(hcResetBase        , Config->ResetBase  );
  sts |= cpswhalPushBin(hcEswitchResetBit, Config->EswitchResetBit);
  sts |= cpswhalPushBin(hcCpmac0ResetBit , Config->Cpmac0ResetBit );
  sts |= cpswhalPushBin(hcCpmac1ResetBit , Config->Cpmac1ResetBit );
  sts |= cpswhalPushBin(hcMdioResetBit   , Config->MdioResetBit   );
  sts |= cpswhalPushBin(hcPhy0ResetBit   , Config->Phy0ResetBit   );
  sts |= cpswhalPushBin(hcPhy1ResetBit   , Config->Phy1ResetBit   );
  sts |= cpswhalPushBin(hcHdmaResetBit   , Config->HdmaResetBit   );
  sts |= cpswhalPushBin(hcCpmac0IntBit   , Config->Cpmac0IntBit   );
  sts |= cpswhalPushBin(hcCpmac1IntBit   , Config->Cpmac1IntBit   );
  sts |= cpswhalPushBin(hcEswitchIntBit  , Config->EswitchIntBit  );
  sts |= cpswhalPushBin(hcEswitchBase           , Config->EswitchBase    );
  sts |= cpswhalPushBin(hcEswitchBufferSize     , Config->EswitchBufferSize     );
  sts |= cpswhalPushBin(hcEswitchHostBufCount   , Config->EswitchHostBufCount   );
  sts |= cpswhalPushBin(hcEswitchDefaultCamSize , Config->EswitchDefaultCamSize );
  sts |= cpswhalPushBin(hcEswitchOverFlowCount  , Config->EswitchOverFlowCount  );
  sts |= cpswhalPushBin(hcEswitchOverFlowSize   , Config->EswitchOverFlowSize   );
  return(sts);
}

