2 * File: include/asm-blackfin/mach-bf533/mem_init.h
12 * Copyright 2004-2006 Analog Devices Inc.
14 * Bugs: Enter bugs at http://blackfin.uclinux.org/
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2, or (at your option)
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; see the file COPYING.
28 * If not, write to the Free Software Foundation,
29 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #if (CONFIG_MEM_MT48LC16M16A2TG_75 || CONFIG_MEM_MT48LC64M4A2FB_7E || \
33 CONFIG_MEM_MT48LC32M16A2TG_75 || CONFIG_MEM_GENERIC_BOARD)
34 #if (CONFIG_SCLK_HZ > 119402985)
35 #define SDRAM_tRP TRP_2
36 #define SDRAM_tRP_num 2
37 #define SDRAM_tRAS TRAS_7
38 #define SDRAM_tRAS_num 7
39 #define SDRAM_tRCD TRCD_2
40 #define SDRAM_tWR TWR_2
42 #if (CONFIG_SCLK_HZ > 104477612) && (CONFIG_SCLK_HZ <= 119402985)
43 #define SDRAM_tRP TRP_2
44 #define SDRAM_tRP_num 2
45 #define SDRAM_tRAS TRAS_6
46 #define SDRAM_tRAS_num 6
47 #define SDRAM_tRCD TRCD_2
48 #define SDRAM_tWR TWR_2
50 #if (CONFIG_SCLK_HZ > 8955223) && (CONFIG_SCLK_HZ <= 104477612)
51 #define SDRAM_tRP TRP_2
52 #define SDRAM_tRP_num 2
53 #define SDRAM_tRAS TRAS_5
54 #define SDRAM_tRAS_num 5
55 #define SDRAM_tRCD TRCD_2
56 #define SDRAM_tWR TWR_2
58 #if (CONFIG_SCLK_HZ > 74626866) && (CONFIG_SCLK_HZ <= 89552239)
59 #define SDRAM_tRP TRP_2
60 #define SDRAM_tRP_num 2
61 #define SDRAM_tRAS TRAS_4
62 #define SDRAM_tRAS_num 4
63 #define SDRAM_tRCD TRCD_2
64 #define SDRAM_tWR TWR_2
66 #if (CONFIG_SCLK_HZ > 66666667) && (CONFIG_SCLK_HZ <= 74626866)
67 #define SDRAM_tRP TRP_2
68 #define SDRAM_tRP_num 2
69 #define SDRAM_tRAS TRAS_3
70 #define SDRAM_tRAS_num 3
71 #define SDRAM_tRCD TRCD_2
72 #define SDRAM_tWR TWR_2
74 #if (CONFIG_SCLK_HZ > 59701493) && (CONFIG_SCLK_HZ <= 66666667)
75 #define SDRAM_tRP TRP_1
76 #define SDRAM_tRP_num 1
77 #define SDRAM_tRAS TRAS_4
78 #define SDRAM_tRAS_num 3
79 #define SDRAM_tRCD TRCD_1
80 #define SDRAM_tWR TWR_2
82 #if (CONFIG_SCLK_HZ > 44776119) && (CONFIG_SCLK_HZ <= 59701493)
83 #define SDRAM_tRP TRP_1
84 #define SDRAM_tRP_num 1
85 #define SDRAM_tRAS TRAS_3
86 #define SDRAM_tRAS_num 3
87 #define SDRAM_tRCD TRCD_1
88 #define SDRAM_tWR TWR_2
90 #if (CONFIG_SCLK_HZ > 29850746) && (CONFIG_SCLK_HZ <= 44776119)
91 #define SDRAM_tRP TRP_1
92 #define SDRAM_tRP_num 1
93 #define SDRAM_tRAS TRAS_2
94 #define SDRAM_tRAS_num 2
95 #define SDRAM_tRCD TRCD_1
96 #define SDRAM_tWR TWR_2
98 #if (CONFIG_SCLK_HZ <= 29850746)
99 #define SDRAM_tRP TRP_1
100 #define SDRAM_tRP_num 1
101 #define SDRAM_tRAS TRAS_1
102 #define SDRAM_tRAS_num 1
103 #define SDRAM_tRCD TRCD_1
104 #define SDRAM_tWR TWR_2
108 #if (CONFIG_MEM_MT48LC16M16A2TG_75)
109 /*SDRAM INFORMATION: */
110 #define SDRAM_Tref 64 /* Refresh period in milliseconds */
111 #define SDRAM_NRA 8192 /* Number of row addresses in SDRAM */
112 #define SDRAM_CL CL_3
115 #if (CONFIG_MEM_MT48LC64M4A2FB_7E)
116 /*SDRAM INFORMATION: */
117 #define SDRAM_Tref 64 /* Refresh period in milliseconds */
118 #define SDRAM_NRA 8192 /* Number of row addresses in SDRAM */
119 #define SDRAM_CL CL_3
122 #if (CONFIG_MEM_MT48LC32M16A2TG_75)
123 /*SDRAM INFORMATION: */
124 #define SDRAM_Tref 64 /* Refresh period in milliseconds */
125 #define SDRAM_NRA 8192 /* Number of row addresses in SDRAM */
126 #define SDRAM_CL CL_3
129 #if (CONFIG_MEM_GENERIC_BOARD)
130 /*SDRAM INFORMATION: Modify this for your board */
131 #define SDRAM_Tref 64 /* Refresh period in milliseconds */
132 #define SDRAM_NRA 8192 /* Number of row addresses in SDRAM */
133 #define SDRAM_CL CL_3
136 #if (CONFIG_MEM_SIZE == 128)
137 #define SDRAM_SIZE EBSZ_128
139 #if (CONFIG_MEM_SIZE == 64)
140 #define SDRAM_SIZE EBSZ_64
142 #if (CONFIG_MEM_SIZE == 32)
143 #define SDRAM_SIZE EBSZ_32
145 #if (CONFIG_MEM_SIZE == 16)
146 #define SDRAM_SIZE EBSZ_16
148 #if (CONFIG_MEM_ADD_WIDTH == 11)
149 #define SDRAM_WIDTH EBCAW_11
151 #if (CONFIG_MEM_ADD_WIDTH == 10)
152 #define SDRAM_WIDTH EBCAW_10
154 #if (CONFIG_MEM_ADD_WIDTH == 9)
155 #define SDRAM_WIDTH EBCAW_9
157 #if (CONFIG_MEM_ADD_WIDTH == 8)
158 #define SDRAM_WIDTH EBCAW_8
161 #define mem_SDBCTL (SDRAM_WIDTH | SDRAM_SIZE | EBE)
163 /* Equation from section 17 (p17-46) of BF533 HRM */
164 #define mem_SDRRC (((CONFIG_SCLK_HZ / 1000) * SDRAM_Tref) / SDRAM_NRA) - (SDRAM_tRAS_num + SDRAM_tRP_num)
166 /* Enable SCLK Out */
167 #define mem_SDGCTL (SCTLE | SDRAM_CL | SDRAM_tRAS | SDRAM_tRP | SDRAM_tRCD | SDRAM_tWR | PSS)
169 #if defined CONFIG_CLKIN_HALF
175 #if defined CONFIG_PLL_BYPASS
181 /***************************************Currently Not Being Used *********************************/
182 #define flash_EBIU_AMBCTL_WAT ((CONFIG_FLASH_SPEED_BWAT * 4) / (4000000000 / CONFIG_SCLK_HZ)) + 1
183 #define flash_EBIU_AMBCTL_RAT ((CONFIG_FLASH_SPEED_BRAT * 4) / (4000000000 / CONFIG_SCLK_HZ)) + 1
184 #define flash_EBIU_AMBCTL_HT ((CONFIG_FLASH_SPEED_BHT * 4) / (4000000000 / CONFIG_SCLK_HZ))
185 #define flash_EBIU_AMBCTL_ST ((CONFIG_FLASH_SPEED_BST * 4) / (4000000000 / CONFIG_SCLK_HZ)) + 1
186 #define flash_EBIU_AMBCTL_TT ((CONFIG_FLASH_SPEED_BTT * 4) / (4000000000 / CONFIG_SCLK_HZ)) + 1
188 #if (flash_EBIU_AMBCTL_TT > 3)
189 #define flash_EBIU_AMBCTL0_TT B0TT_4
191 #if (flash_EBIU_AMBCTL_TT == 3)
192 #define flash_EBIU_AMBCTL0_TT B0TT_3
194 #if (flash_EBIU_AMBCTL_TT == 2)
195 #define flash_EBIU_AMBCTL0_TT B0TT_2
197 #if (flash_EBIU_AMBCTL_TT < 2)
198 #define flash_EBIU_AMBCTL0_TT B0TT_1
201 #if (flash_EBIU_AMBCTL_ST > 3)
202 #define flash_EBIU_AMBCTL0_ST B0ST_4
204 #if (flash_EBIU_AMBCTL_ST == 3)
205 #define flash_EBIU_AMBCTL0_ST B0ST_3
207 #if (flash_EBIU_AMBCTL_ST == 2)
208 #define flash_EBIU_AMBCTL0_ST B0ST_2
210 #if (flash_EBIU_AMBCTL_ST < 2)
211 #define flash_EBIU_AMBCTL0_ST B0ST_1
214 #if (flash_EBIU_AMBCTL_HT > 2)
215 #define flash_EBIU_AMBCTL0_HT B0HT_3
217 #if (flash_EBIU_AMBCTL_HT == 2)
218 #define flash_EBIU_AMBCTL0_HT B0HT_2
220 #if (flash_EBIU_AMBCTL_HT == 1)
221 #define flash_EBIU_AMBCTL0_HT B0HT_1
223 #if (flash_EBIU_AMBCTL_HT == 0 && CONFIG_FLASH_SPEED_BHT == 0)
224 #define flash_EBIU_AMBCTL0_HT B0HT_0
226 #if (flash_EBIU_AMBCTL_HT == 0 && CONFIG_FLASH_SPEED_BHT != 0)
227 #define flash_EBIU_AMBCTL0_HT B0HT_1
230 #if (flash_EBIU_AMBCTL_WAT > 14)
231 #define flash_EBIU_AMBCTL0_WAT B0WAT_15
233 #if (flash_EBIU_AMBCTL_WAT == 14)
234 #define flash_EBIU_AMBCTL0_WAT B0WAT_14
236 #if (flash_EBIU_AMBCTL_WAT == 13)
237 #define flash_EBIU_AMBCTL0_WAT B0WAT_13
239 #if (flash_EBIU_AMBCTL_WAT == 12)
240 #define flash_EBIU_AMBCTL0_WAT B0WAT_12
242 #if (flash_EBIU_AMBCTL_WAT == 11)
243 #define flash_EBIU_AMBCTL0_WAT B0WAT_11
245 #if (flash_EBIU_AMBCTL_WAT == 10)
246 #define flash_EBIU_AMBCTL0_WAT B0WAT_10
248 #if (flash_EBIU_AMBCTL_WAT == 9)
249 #define flash_EBIU_AMBCTL0_WAT B0WAT_9
251 #if (flash_EBIU_AMBCTL_WAT == 8)
252 #define flash_EBIU_AMBCTL0_WAT B0WAT_8
254 #if (flash_EBIU_AMBCTL_WAT == 7)
255 #define flash_EBIU_AMBCTL0_WAT B0WAT_7
257 #if (flash_EBIU_AMBCTL_WAT == 6)
258 #define flash_EBIU_AMBCTL0_WAT B0WAT_6
260 #if (flash_EBIU_AMBCTL_WAT == 5)
261 #define flash_EBIU_AMBCTL0_WAT B0WAT_5
263 #if (flash_EBIU_AMBCTL_WAT == 4)
264 #define flash_EBIU_AMBCTL0_WAT B0WAT_4
266 #if (flash_EBIU_AMBCTL_WAT == 3)
267 #define flash_EBIU_AMBCTL0_WAT B0WAT_3
269 #if (flash_EBIU_AMBCTL_WAT == 2)
270 #define flash_EBIU_AMBCTL0_WAT B0WAT_2
272 #if (flash_EBIU_AMBCTL_WAT == 1)
273 #define flash_EBIU_AMBCTL0_WAT B0WAT_1
276 #if (flash_EBIU_AMBCTL_RAT > 14)
277 #define flash_EBIU_AMBCTL0_RAT B0RAT_15
279 #if (flash_EBIU_AMBCTL_RAT == 14)
280 #define flash_EBIU_AMBCTL0_RAT B0RAT_14
282 #if (flash_EBIU_AMBCTL_RAT == 13)
283 #define flash_EBIU_AMBCTL0_RAT B0RAT_13
285 #if (flash_EBIU_AMBCTL_RAT == 12)
286 #define flash_EBIU_AMBCTL0_RAT B0RAT_12
288 #if (flash_EBIU_AMBCTL_RAT == 11)
289 #define flash_EBIU_AMBCTL0_RAT B0RAT_11
291 #if (flash_EBIU_AMBCTL_RAT == 10)
292 #define flash_EBIU_AMBCTL0_RAT B0RAT_10
294 #if (flash_EBIU_AMBCTL_RAT == 9)
295 #define flash_EBIU_AMBCTL0_RAT B0RAT_9
297 #if (flash_EBIU_AMBCTL_RAT == 8)
298 #define flash_EBIU_AMBCTL0_RAT B0RAT_8
300 #if (flash_EBIU_AMBCTL_RAT == 7)
301 #define flash_EBIU_AMBCTL0_RAT B0RAT_7
303 #if (flash_EBIU_AMBCTL_RAT == 6)
304 #define flash_EBIU_AMBCTL0_RAT B0RAT_6
306 #if (flash_EBIU_AMBCTL_RAT == 5)
307 #define flash_EBIU_AMBCTL0_RAT B0RAT_5
309 #if (flash_EBIU_AMBCTL_RAT == 4)
310 #define flash_EBIU_AMBCTL0_RAT B0RAT_4
312 #if (flash_EBIU_AMBCTL_RAT == 3)
313 #define flash_EBIU_AMBCTL0_RAT B0RAT_3
315 #if (flash_EBIU_AMBCTL_RAT == 2)
316 #define flash_EBIU_AMBCTL0_RAT B0RAT_2
318 #if (flash_EBIU_AMBCTL_RAT == 1)
319 #define flash_EBIU_AMBCTL0_RAT B0RAT_1
322 #define flash_EBIU_AMBCTL0 \
323 (flash_EBIU_AMBCTL0_WAT | flash_EBIU_AMBCTL0_RAT | flash_EBIU_AMBCTL0_HT | \
324 flash_EBIU_AMBCTL0_ST | flash_EBIU_AMBCTL0_TT | CONFIG_FLASH_SPEED_RDYEN)