/**
 * \file   plat_utils.h
 *
 *  \brief 
 *
*/
/*
 * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
 */

#ifndef _PLAT_UTILS_H
#define _PLAT_UTILS_H
/* ========================================================================== */
/*                             Include Files                                  */
/* ========================================================================== */

/* ========================================================================== */
/*                           Macros & Typedefs                                */
/* ========================================================================== */
#define FAIL            -1
#define SUCCESS         0


#define SPI_CH_FLASH			0
#define SPI_CH_PICCOLO			1
#define SPI_CH_STELLARIS		2

#define SPI_CH_HVS882			0

#define AM335X_BOARD_TYPE_UNKNOWN 	0
#define AM335X_BOARD_TYPE_IDK		1
#define AM335X_BOARD_TYPE_ICE		2
#define AM335X_BOARD_TYPE_ICE_V2	3
#define AM335X_BOARD_TYPE_IARD		4		//GD Aggiunto tipo di scheda IARD

#define EEPROM_MAGIC_NUM 			(0xEE3355AA)
#define ICE_V2_BOARD_NAME   		"A335_ICE2"
#define ICE_BOARD_NAME   			"A335_ICE"
#define IDK_BASE_BOARD_NAME   		"A33515BB"
#define IDK_DAUGHTER_BOARD_NAME   	"A335IAMC"

#define ICSS_SWITCH		0
#define CPSW_SWITCH		1

/* ========================================================================== */
/*                         Structures and Enums                               */
/* ========================================================================== */

/* ========================================================================== */
/*                            Global Variables Declarations                   */
/* ========================================================================== */

/* ========================================================================== */
/*                          Function Declarations                             */
/* ========================================================================== */
/**
 * \brief   Routine to get ARM core frequency 
 *
 *
 * \return  None.
 *
 **/
unsigned int UTILsGetArmClockRate();
/**
 * \brief   This API returns the device name 
 *
 *
 * \return  None.
 *
 **/
char * UTILsGetDevName();
/**
 * \brief   This API returns the SoC revision in string format  
 *
 *
 * \return  None.
 *
 **/
char * UTILsGetChipRevision();
/**
 * \brief   Routine which initiates data read from HVS data over SPI
 *
 *
 * \return  Returns the bitwise representation of digital input (one byte)
 *
 **/
unsigned short UTILsReadHVS(void);
/**
 * \brief   Routine to get the last read HVS (Digital input)data
 *
 *
 * \return  Returns the bitwise representation of digital input (one byte).
 *
 **/
unsigned short UTILsReadHVS2(void);
/**
 * \brief   Intializes ICSS IP
 *
 *
 * \return  None.
 *
 **/
void UTILsICSSInit(void);

/**
 * \brief   Powerups PWM IP
 *
 *
 * \return  None.
 *
 **/
void UTILsPowerPWM(void);


/**
 * \brief   Routine to set the ref clock for Timer2
 *
 *
 * \return  None.
 *
 **/
void UTILsTimer2Init(void);

/**
 * \brief   Routine to force baord type
 *
 * \param   type    takes the following values
 *           AM335X_BOARD_TYPE_UNKNOWN 
 *           AM335X_BOARD_TYPE_IDK 
 *           AM335X_BOARD_TYPE_ICE 
 *           AM335X_BOARD_TYPE_ICE_V2*
 * \return  None.
 *
 **/
//GD void UTILsSetBoardType(unsigned char type);

/**
 * \brief   Return the current the baord ( detected )
 *
 *
 *
 * \return   AM335X_BOARD_TYPE_UNKNOWN 
 *           AM335X_BOARD_TYPE_IDK 
 *           AM335X_BOARD_TYPE_ICE 
 *           AM335X_BOARD_TYPE_ICE_V2	
 *
 **/
unsigned char UTILsGetBoardType(void);

/**
 * \brief   Routine to detect the current baord type (ICE/IDK/ICE V2)
 *
 *
 *
 * \return   AM335X_BOARD_TYPE_UNKNOWN 
 *           AM335X_BOARD_TYPE_IDK 
 *           AM335X_BOARD_TYPE_ICE 
 *           AM335X_BOARD_TYPE_ICE_V2	
 *
 **/
int UTILsDetectBoardType();

/**
 * \brief   Rotuine to reset both PHYs
 *
 *
 * \return  None.
 **/
void UTILsResetPhys();

/**
 * \brief   Intialize ports for ICSS /CPSW swicthes
 *
 * \param   swicthType - ICSS/CPSW     
 *
 *
 * \return  None.
 *
 **/
void UTILsInitCpswIcssPorts(unsigned char swicthType);




#endif /*_PLAT_UTILS_H*/
