change source file mode to 0644 instead of 0755
[profile/mobile/platform/kernel/u-boot-tm1.git] / arch / arm / cpu / armv7 / sc8810 / sdram_prod.c
1 /******************************************************************************
2  ** File Name:      sdram_prod.c                                              *
3  ** Author:                                                                   *
4  ** DATE:           04/18/2008                                                *
5  ** Copyright:      2008 Spreadtrum, Incoporated. All Rights Reserved.        *
6  ** Description:    This file defines the product configurable parameters of  * 
7  **                 SDRAM module                                              *
8  **                                                                           *
9  ******************************************************************************
10
11  ******************************************************************************
12  **                        Edit History                                       *
13  ** ------------------------------------------------------------------------- *
14  ** DATE           NAME             DESCRIPTION                               *
15  ** 04/18/2008                          Create.                                           *
16  ******************************************************************************/
17
18 /**---------------------------------------------------------------------------*
19  **                         Dependencies                                      *
20  **---------------------------------------------------------------------------*/ 
21 #include <asm/arch/sci_types.h>
22 #include <asm/arch/sdram_cfg.h>
23
24 /**---------------------------------------------------------------------------*
25  **                         Debugging Flag                                    *
26  **---------------------------------------------------------------------------*/
27  
28
29
30 /**---------------------------------------------------------------------------*
31  **                         Compiler Flag                                     *
32  **---------------------------------------------------------------------------*/
33 #ifdef   __cplusplus
34     extern   "C" 
35     {
36 #endif
37
38 /*********************************************************************************/
39 //             Macro Definition
40 /*********************************************************************************/
41 // Feature
42 #if defined (BB_DRAM_TYPE_32MB_16BIT)
43 #define SDRAM_ROW_MODE          ROW_MODE_13
44 #define SDRAM_COL_MODE          COL_MODE_9
45 #define SDRAM_DATA_WIDTH        DATA_WIDTH_16
46 #define SDRAM_SIZE                      SDRAM_32M
47
48 #elif defined(BB_DRAM_TYPE_32MB_32BIT_13R)
49 #define SDRAM_ROW_MODE          ROW_MODE_13             
50 #define SDRAM_COL_MODE          COL_MODE_8              
51 #define SDRAM_DATA_WIDTH        DATA_WIDTH_32
52 #define SDRAM_SIZE                      SDRAM_32M
53
54 #elif defined(BB_DRAM_TYPE_32MB_32BIT_12R)
55 #define SDRAM_ROW_MODE          ROW_MODE_12             
56 #define SDRAM_COL_MODE          COL_MODE_9              
57 #define SDRAM_DATA_WIDTH        DATA_WIDTH_32
58 #define SDRAM_SIZE                      SDRAM_32M
59
60 #elif defined(BB_DRAM_TYPE_64MB_16BIT)
61 #define SDRAM_ROW_MODE          ROW_MODE_13
62 #define SDRAM_COL_MODE          COL_MODE_10
63 #define SDRAM_DATA_WIDTH        DATA_WIDTH_16
64 #define SDRAM_SIZE                      SDRAM_64M
65
66 #elif defined(BB_DRAM_TYPE_64MB_32BIT)
67 #define SDRAM_ROW_MODE          ROW_MODE_13
68 #define SDRAM_COL_MODE          COL_MODE_9
69 #define SDRAM_DATA_WIDTH        DATA_WIDTH_32
70 #define SDRAM_SIZE                      SDRAM_64M
71
72 #elif defined(BB_DRAM_TYPE_128MB_16BIT)
73 #define SDRAM_ROW_MODE          ROW_MODE_14
74 #define SDRAM_COL_MODE          COL_MODE_10
75 #define SDRAM_DATA_WIDTH        DATA_WIDTH_16
76 #define SDRAM_SIZE                      SDRAM_128M
77
78 #elif defined(BB_DRAM_TYPE_128MB_32BIT)
79 #define SDRAM_ROW_MODE          ROW_MODE_13
80 #define SDRAM_COL_MODE          COL_MODE_10
81 #define SDRAM_DATA_WIDTH        DATA_WIDTH_32
82 #define SDRAM_SIZE                      SDRAM_128M
83
84 #elif defined(BB_DRAM_TYPE_256MB_32BIT)
85 #define SDRAM_ROW_MODE          ROW_MODE_14
86 #define SDRAM_COL_MODE          COL_MODE_10
87 #define SDRAM_DATA_WIDTH        DATA_WIDTH_32
88 #define SDRAM_SIZE                      SDRAM_256M
89
90 #else
91 #error do not select size and bit width for SDRAM
92 #endif
93
94 #define BK_MODE                 BK_MODE_4
95
96 #if defined(PLATFORM_SC8800H)
97 #define BURST_LEN               BURST_LEN_8
98 #elif defined(PLATFORM_SC6800H)
99 #define BURST_LEN               BURST_LEN_2
100 #elif defined(PLATFORM_SC8800G)
101 #define BURST_LEN               BURST_LEN_2
102 #elif defined(CONFIG_SC8810)
103 #define BURST_LEN               BURST_LEN_2
104 #else
105 #error do not select burst len for SDRAM
106 #endif
107
108 #define CAS_LATENCY     CAS_LATENCY_3
109
110 // Include Product config
111 #include "sdram_cfg.c"
112
113 /**---------------------------------------------------------------------------*
114  **                         Local Variables                                   *
115  **---------------------------------------------------------------------------*/
116 #ifdef CONFIG_SP8810 // for 8810&6820
117 LOCAL CONST EMC_PARAM_T s_emc_parm = 
118 {
119     // clock
120     1000000000,         // arm_clk 1G
121      400000000,         // emc_clk 400M
122      
123     // driver strength
124     2,                                          // dqs_drv
125     2,                                          // dat_drv
126     0,                                          // ctl_drv
127     2,                                          // clk_drv
128     
129     // clk wr
130     12,                                         // clk_wr 
131     0x818,                              // value read from 0x20000174
132
133         //set cs map to external memory
134     7 ,                //set cs map to 2G bit
135 };
136 #else  // for openphone
137 LOCAL CONST EMC_PARAM_T s_emc_parm = 
138 {
139     // clock
140      850000000,         // arm_clk 850M
141      333000000,         // emc_clk 333M
142      
143     // driver strength
144     1,                                          // dqs_drv
145     1,                                          // dat_drv
146     0,                                          // ctl_drv
147     2,                                          // clk_drv
148     
149     // clk wr
150     18,                                         // clk_wr 
151     0x81c,                              // value read from 0x20000174
152 };
153 #endif
154
155 /*******************************************************************************/
156 //   sdram_parameters[] is used to config SDRAM controller according to variable
157 //sdram. The unit is ns. The end of array is marked with 0xffffffff at the last element. 
158 /*******************************************************************************/
159 LOCAL CONST SDRAM_TIMING_PARA_T s_sdram_timing_param =
160 //  ms    ns   ns    ns            ns    ns       ns    ns  clk   clk
161 //  tREF, tRP, tRCD, tWR/tRDL/tDPL,tRFC,tXSR,     tRAS,tRRD,tMRD, tWTR(wtr is only for ddr)
162     {64,   30,  30,   20,          110, 150,      60,  20,  2,    2   };
163
164 /*******************************************************************************/
165 //   sdram_cofig_info is used to config sdram controller when to init sdram
166 /*******************************************************************************/
167 LOCAL CONST SDRAM_CFG_INFO_T s_sdram_config_info =
168 {
169         BK_MODE,
170         SDRAM_ROW_MODE,
171         SDRAM_COL_MODE,
172         SDRAM_DATA_WIDTH,              
173         BURST_LEN,
174         CAS_LATENCY,
175         SDRAM_EXT_MODE_VALUE,
176         SDR_SDRAM
177 };
178
179 /**---------------------------------------------------------------------------*
180  **                     Public Function Prototypes                            *
181  **---------------------------------------------------------------------------*/
182 PUBLIC EMC_PARAM_T_PTR EMC_GetPara(void)
183 {
184   return (EMC_PARAM_T_PTR)&s_emc_parm;
185 }
186
187
188 /*****************************************************************************/
189 //  Description:    This function get sdram config pointer
190 //  Author:         nick.zhao
191 //  Note:           
192 /*****************************************************************************/
193 PUBLIC SDRAM_CFG_INFO_T_PTR SDRAM_GetCfg(void)
194 {
195   return (SDRAM_CFG_INFO_T_PTR)&s_sdram_config_info;
196 }
197
198 /*****************************************************************************/
199 //  Description:    This function get sdram timing parameter pointer
200 //  Author:         Liangwen.Zhen
201 //  Note:           
202 /*****************************************************************************/
203 PUBLIC SDRAM_TIMING_PARA_T_PTR SDRAM_GetTimingPara(void)
204 {
205         return (SDRAM_TIMING_PARA_T_PTR)&s_sdram_timing_param;
206 }
207
208 /*****************************************************************************/
209 //  Description:    This function can be defined by user if needed. It will be called
210 //                  before the SDRAM initialization.
211 //  Author:         nick.zhao
212 //  Note:           
213 /*****************************************************************************/
214 PUBLIC void Userdef_before_sdram_init(void)
215 {
216    return;
217 }
218 /*****************************************************************************/
219 //  Description:    This function can be defined by user if needed. It will be called
220 //                  after the SDRAM initialization.
221 //  Author:         nick.zhao
222 //  Note:           
223 /*****************************************************************************/
224 PUBLIC void Userdef_after_sdram_init(void)
225 {
226    return;
227 }
228
229 /**---------------------------------------------------------------------------*
230  **                         Compiler Flag                                     *
231  **---------------------------------------------------------------------------*/
232 #ifdef   __cplusplus
233     }
234
235 #endif
236
237