1 /******************************************************************************
2 ** File Name: sdram_drvapi.h *
5 ** Copyright: 2005 Spreatrum, Incoporated. All Rights Reserved. *
7 ******************************************************************************/
8 #ifndef _SDRAM_DRVAPI_H_
9 #define _SDRAM_DRVAPI_H_
14 #include "sci_types.h"
15 /******************************************************************************
17 ******************************************************************************/
18 /******************************************************************************
20 ******************************************************************************/
23 uint32 row_ref_max; //ROW_REFRESH_TIME,Refresh interval time , ns, tREF-max = 7800 ns
24 uint32 row_pre_min; //ROW_PRECHARGE_TIME , ns, tRP-min = 27 ns.
25 uint32 rcd_min; //T_RCD,ACTIVE to READ or WRITE delay , ns, tRCD-min = 27 ns
26 uint32 wr_min; //T_WR ,WRITE recovery time , ns, tWR-min = 15 ns.
27 uint32 rfc_min; //T_RFC, AUTO REFRESH command period , ns, tRFC-min = 80 ns.
28 uint32 xsr_min; //T_XSR , ns, tXSR-min = 120 ns.
29 uint32 ras_min; //T_RAS_MIN , row active time, ns, tRAS-min = 50ns
30 uint32 rrd_min; //T_RRD
31 uint32 mrd_min; //T_MRD , 2 cycles, tMRD-min = 2 cycles.
32 uint32 wtr_min; //T_WTR , 1 cycle
33 } SDRAM_TIMING_PARA_T, *SDRAM_TIMING_PARA_T_PTR;
35 /* The SDRAM size parameters supports */
44 #define BK_MODE_1 0 //1 bank sdram
45 #define BK_MODE_2 1 //2 bank sdram
46 #define BK_MODE_4 2 //4 bank sdram
47 #define BK_MODE_8 3 //8 bank sdram
49 #define ROW_MODE_11 0 // 11 row sdram
50 #define ROW_MODE_12 1 // 12 row sdram
51 #define ROW_MODE_13 2 // 13 row sdram
52 #define ROW_MODE_14 3 // 14 row sdram
54 #define COL_MODE_8 0 //8 column sdram
55 #define COL_MODE_9 1 //9 column sdram
56 #define COL_MODE_10 2 //10 column sdram
57 #define COL_MODE_11 3 //11 column sdram
58 #define COL_MODE_12 4 //12 column sdram
60 #define DATA_WIDTH_16 0 //16 bit sdram
61 #define DATA_WIDTH_32 1 //32 bit sdram
63 #define BURST_LEN_1 0 // 1 words burst
64 #define BURST_LEN_2 1 // 2 words burst
65 #define BURST_LEN_4 2 // 4 words burst
66 #define BURST_LEN_8 3 // 8 words burst
67 #define BURST_LEN_16 4 // 16 words burst
68 #define BURST_LEN_FULLPAGE 7 // full page burst
70 #define CAS_LATENCY_1 1 // 1 cycle cas latency
71 #define CAS_LATENCY_2 2 // 2 cycle cas latency
72 #define CAS_LATENCY_3 3 // 3 cycle cas latency
74 /* Extend mode register value supports*/
75 #define SDRAM_EXT_MODE_INVALID 0xffffffff
76 #define EXT_MODE_PASR_ALL 0
77 #define EXT_MODE_DS_HALF 1
78 #define EXT_MODE_DS_FULL 0
79 #define EXT_MODE_DS_QUARTER 2
80 #define EXT_MODE_FLAG 1
81 #define SDRAM_EXT_MODE_REG ((EXT_MODE_FLAG<<15) | (EXT_MODE_DS_FULL<<5) | EXT_MODE_PASR_ALL)
86 /* The sdram configuration struct */
87 typedef struct _SDRAM_CFG_INFO
89 uint32 bank_mode; //Can only be set as BK_MODE_1,BK_MODE_2,BK_MODE_4,BK_MODE_8
90 uint32 row_mode; //Can only be set as ROW_MODE_11,ROW_MODE_12,ROW_MODE_13
91 uint32 col_mode; //Can only be set as COL_MODE_8,COL_MODE_9,COL_MODE_10,COL_MODE_11,COL_MODE_12
92 uint32 data_width; //Can only be set as DATA_WIDTH_16,DATA_WIDTH_32
93 uint32 burst_length; //Can only be set as BURST_LEN_2,BURST_LEN_4,BURST_LEN_8,BURST_LEN_16,BURST_LEN_FULLPAGE
94 uint32 cas_latency; //Can only be set as CAS_LATENCY_1,CAS_LATENCY_2,CAS_LATENCY_3
95 uint32 ext_mode_val; //User can config extend mode register in SDRAM.
96 uint32 sdram_type; //DDR or SDR
97 } SDRAM_CFG_INFO_T, *SDRAM_CFG_INFO_T_PTR;
99 /******************************************************************************/
100 // Description: Intialize SDRAM parameters
102 // pPara the address of SDRAM parameters
105 /******************************************************************************/
106 PUBLIC void SDRAM_InitPara (SDRAM_TIMING_PARA_T_PTR timing_ptr);
108 /******************************************************************************/
109 // Description: Change SDRAM controller settings
111 // ahb_clk the AHB clk
114 /******************************************************************************/
115 void SDRAM_SetParam (uint32 ahb_clk);
117 /*****************************************************************************/
118 // Description: This function get sdram config pointer
121 /*****************************************************************************/
122 PUBLIC SDRAM_CFG_INFO_T_PTR SDRAM_GetCfg (void);
124 /*****************************************************************************/
125 // Description: This function get sdram timing parameter pointer
126 // Author: Liangwen.Zhen
128 /*****************************************************************************/
129 PUBLIC SDRAM_TIMING_PARA_T_PTR SDRAM_GetTimingPara (void);
131 /*****************************************************************************/
132 // Description: This function can be defined by user if needed. It will be called
133 // before the SDRAM initialization.
136 /*****************************************************************************/
137 PUBLIC void Userdef_before_sdram_init (void);
139 /*****************************************************************************/
140 // Description: This function can be defined by user if needed. It will be called
141 // after the SDRAM initialization.
144 /*****************************************************************************/
145 PUBLIC void Userdef_after_sdram_init (void);
150 #endif // _SDRAM_DRVAPI_H_