#ifndef __IOP_SYSINT_H__
#define __IOP_SYSINT_H__

/*
 * Various delays.  Times are in microseconds
 */
#define PPC_PLL_RESET_TIME  15
#define PPC_PLL_LOCK_TIME   150
#define DSK_PLL_LOCK_TIME   4	/* spec says 500 cclk, 4us is a little more */

#define SYS_CLOCK_FAST_TIME 4115
#define SYS_CLOCK_SLOW_TIME 6173
#define FXCLK_SWITCH_DELAY_CYCLES 64
#define DSK_RESET_DELAY_CYCLES 200

#define DSK_PLL_RESET_TIME  1
#define FXCLK_SWITCH_TIME   1

// AI PLL values
#define AIPLL_GC_CLKR 0
#define AIPLL_GC_CLKF 63
#define AIPLL_GC_CLKO_0 281
//#define AIPLL_EXACT_CLKR 24
//#define AIPLL_EXACT_CLKF 1535
//#define AIPLL_EXACT_CLKO_0 270
#define AIPLL_EXACT_CLKR 14
#define AIPLL_EXACT_CLKF 1023
#define AIPLL_EXACT_CLKO_0 300
//ASG #define AIPLLEXT1_GC_CLKF 1233
//ASG #define AIPLLEXT1_GC_CLKR 42
//ASG #define AIPLLEXT1_GC_CLKO_0 126
//ASG #define AIPLLEXT1_GC_FASTEN 0
//ASG #define AIPLLEXT2_EXACT_CLKF 511
//ASG #define AIPLLEXT2_EXACT_CLKR 14
//ASG #define AIPLLEXT2_EXACT_CLKO_0 150 
//ASG #define AIPLLEXT2_EXACT_FASTEN 0

// IO strength settings

 /* Hollywood settings */
#define IO_STRENGTH_0   0x65244a
#define IO_STRENGTH_1   0x46a024 

/* Bollywood settings */
/* 0518 setting */
//#define IO_STRENGTH_0_B   0x6d244a 
//#define IO_STRENGTH_1_B   0x46a024

/* Set one of these to 1 to enable corresponding 
 * values for IO_STRENGTHs.
 */
#define IOSTR_BWD_051808   0
#define IOSTR_BWD_052108   0
#define IOSTR_BWD_052708   1

#if IOSTR_BWD_051808
#define IO_STRENGTH_0_VI_B    3
#define IO_STRENGTH_0_DI_B    3 
#define IO_STRENGTH_0_EXI0_B  2
#define IO_STRENGTH_0_EXI1_B  2  
#define IO_STRENGTH_0_EXI2_B  2
#define IO_STRENGTH_0_SI_B    1
#define IO_STRENGTH_0_AIS_B   1
#define IO_STRENGTH_0_AI_B    2

#define IO_STRENGTH_1_LCA_B   0
#define IO_STRENGTH_1_SDI_B   2
#define IO_STRENGTH_1_GLV_B   1
#define IO_STRENGTH_1_GIO_B   5
#define IO_STRENGTH_1_FLA_B   2
#define IO_STRENGTH_1_NLC_B   0
#define IO_STRENGTH_1_PLC_B   0
#define IO_STRENGTH_1_NPI_B   4
#define IO_STRENGTH_1_PPI_B   4
#endif /* 1== IOSTR_BWD_051808? */

#if IOSTR_BWD_052108
#define IO_STRENGTH_0_VI_B    1
#define IO_STRENGTH_0_DI_B    2 
#define IO_STRENGTH_0_EXI0_B  2
#define IO_STRENGTH_0_EXI1_B  2  
#define IO_STRENGTH_0_EXI2_B  2
#define IO_STRENGTH_0_SI_B    1
#define IO_STRENGTH_0_AIS_B   1
#define IO_STRENGTH_0_AI_B    1

#define IO_STRENGTH_1_LCA_B   0
#define IO_STRENGTH_1_SDI_B   2
#define IO_STRENGTH_1_GLV_B   1
#define IO_STRENGTH_1_GIO_B   5
/* #define IO_STRENGTH_1_FLA_B   1 */
#define IO_STRENGTH_1_FLA_B   2  /* No change */
#define IO_STRENGTH_1_NLC_B   0
#define IO_STRENGTH_1_PLC_B   0
#define IO_STRENGTH_1_NPI_B   3
#define IO_STRENGTH_1_PPI_B   3
#endif /* 1== IOSTR_BWD_052108? */

#if IOSTR_BWD_052708
#define IO_STRENGTH_0_VI_B    1
#define IO_STRENGTH_0_DI_B    2 
#define IO_STRENGTH_0_EXI0_B  2
#define IO_STRENGTH_0_EXI1_B  2  
#define IO_STRENGTH_0_EXI2_B  2
#define IO_STRENGTH_0_SI_B    1
#define IO_STRENGTH_0_AIS_B   1
#define IO_STRENGTH_0_AI_B    1

#define IO_STRENGTH_1_LCA_B   0
#define IO_STRENGTH_1_SDI_B   2
#define IO_STRENGTH_1_GLV_B   1
#define IO_STRENGTH_1_GIO_B   5
#define IO_STRENGTH_1_FLA_B   2  /* No change */
#define IO_STRENGTH_1_NLC_B   0
#define IO_STRENGTH_1_PLC_B   0
#define IO_STRENGTH_1_NPI_B   2
#define IO_STRENGTH_1_PPI_B   2
#endif /* 1== IOSTR_BWD_052708 */

#define MAX_FLUSH_COUNT 100
extern enum sysClkSpeed_e sysSpeed;
extern enum sysMode_e sysMode;

void writeDDRMemReg(u32 index, u32 data);
u32 readDDRMemReg(u32 index);
void writeSeqMemReg(u32 index, u32 data);
u32 readSeqMemReg(u32 index);
u32 readACRReg(u32 index);
void writeACRReg(u32 index, u32 data);
void init_USB_PLL(void);
void initLoMem_common(u32 hollywoodId, u32 ddrVendorId);
#endif // __IOP_SYSINT_H__
