tizen 2.4 release
[profile/mobile/platform/kernel/u-boot-tm1.git] / arch / arm / include / asm / arch-sc8825 / sdram_drvapi.h
1 /******************************************************************************
2  ** File Name:      sdram_drvapi.h                                            *
3  ** Author:         Nick.zhao                                                 *
4  ** DATE:           01/03/2005                                                *
5  ** Copyright:      2005 Spreatrum, Incoporated. All Rights Reserved.         *
6  ** Description:                                                              *
7  ******************************************************************************/
8 #ifndef _SDRAM_DRVAPI_H_
9 #define _SDRAM_DRVAPI_H_
10 #ifdef   __cplusplus
11 extern   "C"
12 {
13 #endif
14 #include "sci_types.h"
15 /******************************************************************************
16                           Macro define
17 ******************************************************************************/
18 /******************************************************************************
19                           Struct define
20 ******************************************************************************/
21 typedef struct
22 {
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;
34
35 /* The SDRAM size parameters supports */
36 #define     SDRAM_8M        0
37 #define     SDRAM_16M       1
38 #define     SDRAM_32M       2
39 #define     SDRAM_64M       3
40 #define     SDRAM_128M      4
41 #define     SDRAM_256M      5
42
43
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
48
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
53
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
59
60 #define     DATA_WIDTH_16           0           //16 bit sdram
61 #define     DATA_WIDTH_32           1           //32 bit sdram
62
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
69
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
73
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)
82
83 #define     SDR_SDRAM               0
84 #define     DDR_SDRAM               1
85
86 /* The sdram configuration struct */
87 typedef struct _SDRAM_CFG_INFO
88 {
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;
98
99 /******************************************************************************/
100 //  Description:   Intialize SDRAM parameters
101 //  Parameter:
102 //      pPara    the address of SDRAM parameters
103 //  Return:
104 //      NULL
105 /******************************************************************************/
106 PUBLIC void SDRAM_InitPara (SDRAM_TIMING_PARA_T_PTR timing_ptr);
107
108 /******************************************************************************/
109 //  Description:   Change SDRAM controller settings
110 //  Parameter:
111 //      ahb_clk    the AHB clk
112 //  Return:
113 //      NULL
114 /******************************************************************************/
115 void SDRAM_SetParam (uint32 ahb_clk);
116
117 /*****************************************************************************/
118 //  Description:    This function get sdram config pointer
119 //  Author:         nick.zhao
120 //  Note:
121 /*****************************************************************************/
122 PUBLIC SDRAM_CFG_INFO_T_PTR SDRAM_GetCfg (void);
123
124 /*****************************************************************************/
125 //  Description:    This function get sdram timing parameter pointer
126 //  Author:         Liangwen.Zhen
127 //  Note:
128 /*****************************************************************************/
129 PUBLIC SDRAM_TIMING_PARA_T_PTR SDRAM_GetTimingPara (void);
130
131 /*****************************************************************************/
132 //  Description:    This function can be defined by user if needed. It will be called
133 //                  before the SDRAM initialization.
134 //  Author:         nick.zhao
135 //  Note:
136 /*****************************************************************************/
137 PUBLIC void Userdef_before_sdram_init (void);
138
139 /*****************************************************************************/
140 //  Description:    This function can be defined by user if needed. It will be called
141 //                  after the SDRAM initialization.
142 //  Author:         nick.zhao
143 //  Note:
144 /*****************************************************************************/
145 PUBLIC void Userdef_after_sdram_init (void);
146
147 #ifdef   __cplusplus
148 }
149 #endif
150 #endif // _SDRAM_DRVAPI_H_
151