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

#ifndef _PLAT_MCSPI_H
#define _PLAT_MCSPI_H
/* ========================================================================== */
/*                             Include Files                                  */
/* ========================================================================== */
#include "stdio.h"
#include "hw_types.h"
#include "mcspi.h"
/* ========================================================================== */
/*                           Macros & Typedefs                                */
/* ========================================================================== */
#define MCSPI_INSTANCE_0		0
#define MCSPI_INSTANCE_1		1

#define MCSPI_OUT_FREQ                   (24000000u)
#define MCSPI_IN_CLK                     (48000000u)

#define MCSPI_INST_FLASH_ICE	    MCSPI_INSTANCE_0
#define MCSPI_INST_HVS882_ICE       MCSPI_INSTANCE_1
#define MCSPI_FLAH_CH_ICE	        MCSPI_CHANNEL_0
#define MCSPI_HVS882_CH_ICE	        MCSPI_CHANNEL_0

#define MCSPI_INST_FLASH_ICE_V2	    MCSPI_INSTANCE_0
#define MCSPI_INST_HVS882_ICE_V2    MCSPI_INSTANCE_0
#define MCSPI_FLAH_CH_ICE_V2	    MCSPI_CHANNEL_0
#define MCSPI_HVS882_CH_ICE_V2      MCSPI_CHANNEL_1

#define MCSPI_INST_FLASH_IDK	    MCSPI_INSTANCE_1
#define MCSPI_INST_HVS882_IDK       MCSPI_INSTANCE_1
#define MCSPI_FLAH_CH_IDK	        MCSPI_CHANNEL_0
#define MCSPI_HVS882_CH_IDK	        MCSPI_CHANNEL_1
/* ========================================================================== */
/*                         Structures and Enums                               */
/* ========================================================================== */

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


/* ========================================================================== */
/*                          Function Declarations                             */
/* ========================================================================== */
/**
 * \brief   This function will configure the McSPI pins for AM335x
 *
 * \param   spiId        [IN]   SPI Instance number
 *
 *
 * \return  None.
 *
 **/
int McSPIPinMuxConfig(int spiId);
/**
 * \brief   McSPI clock configuration
 *
 * \param   spiId        [IN]   SPI Instance number
 *
 *
 * \return  None.
 *
 **/
void McSPIModuleClkConfig(int spiId);

/**
 * \brief   McSPI cycle operation
 *
 * \param   spiId   [IN]        mcspi Instance number
 * \param   buf     [IN/OUT]    buffer which hold data
 * \param   len     [IN]        lenth of the data to be written/read
 * \param   chNum   [IN]        mcspi channel number 
 
 *
 *
 * \return  None.
 *
 **/
void McSPICycle(int spiId, unsigned char *buf,
                unsigned short len, unsigned int chNum);

/**
 * \brief   Routine to get base address of specified McSPI instance
 *
 * \param   spiId        [IN]   SPI Instance number
 *
 * \return  Base address if spiId is valid, else 0.
 *
 **/
unsigned int McSPIGetBaseAddress(int spiId);


#endif  //_PLAT_MCSPI_H
