/**
 * cpsw_common.h
 * 
 *
 * Copyright (c) 2012 Texas Instruments Incorporated ALL RIGHTS RESERVED
 *
*/
#ifndef _CPSW_COMMON_H_
#define _CPSW_COMMON_H_

#include <xdc/std.h>

#include "cpsw_ctl.h"

#include "cpsw_ioctl.h"       /* Data structures required by Ioctls */
#include "cpsw_init_cfg.h"    /* Init time static config params */
#include "cpsw_miimdio.h"

#include <stdio.h>

/*
 * Peripheral register structures
 */ 

#define CPSW3G_BASEADDR     			(0x4A100800U)//(0x4A100000U)
#define MDIO_BASEADDR				    (0x4A100800U)
#define CPSW_3GSS_S_BASEADDR			(0x4A100900U)


/* Interrupt number to the ARM CPU */
#define CPSW_RX_PULSE_INTNUM			        41
#define CPSW_RX_THRESH_PULSE_INTNUM		    40
#define CPSW_TX_PULSE_INTNUM			        42
#define CPSW_MISC_PULSE_INTNUM		        43



/**-----------------------------------------------------------------------------
 * EMAC Descriptor section
 */
#define _CPSW_DSC_BASE_ADDR         	0x4A102000 //CPPI RAM ;0x02D00000  /*0X02C82000U;0x01c82000u*/
#define _CPSW_DSC_SIZE                  8192
#define _CPSW_DSC_ENTRY_SIZE        	16
#define _CPSW_DSC_ENTRY_COUNT       	(_CPSW_DSC_SIZE/_CPSW_DSC_ENTRY_SIZE)

#define _CPSW_DSC_BASE_ADDR_L2       0x40300000 //0x4A102000  /* Put descriptors in last half of L2- */
#define _CPSW_DSC_BASE_ADDR_DDR      0x80000000//0x4A102000  /* Same as DDR2 */

/** 
 * @brief 
 *  EMAC Buffer descriptor format.
 *
 * @details
 *  The following is the format of a single buffer descriptor
 *  on the EMAC.
 */
typedef struct _CPSW_Desc
{
   /**
    * @brief        Pointer to next descriptor in chain.
    */                
  struct _CPSW_Desc *pNext;
   /**
    * @brief        Pointer to data buffer.
    */                
  Uint8             *pBuffer;   
   /**
    * @brief        Buffer Offset(MSW) and Length(LSW).
    */                
  Uint32            BufOffLen;  
   /**
    * @brief        Packet Flags(MSW) and Length(LSW).
    */                
  Uint32            PktFlgLen; 
} CPSW_Desc;


#define CPU_TO_HW(addr)    		(addr)
#define HW_TO_CPU(addr)    		(addr)

typedef void*       Handle;	

#endif /* _CPSW_COMMON_H_ */
