2 * File: include/asm-blackfin/mach-bf561/mem_init.h
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2, or (at your option)
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; see the file COPYING.
27 * If not, write to the Free Software Foundation,
28 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #if (CONFIG_MEM_MT48LC16M16A2TG_75 || CONFIG_MEM_MT48LC64M4A2FB_7E || CONFIG_MEM_GENERIC_BOARD || CONFIG_MEM_MT48LC8M32B2B5_7)
32 #if (CONFIG_SCLK_HZ > 119402985)
33 #define SDRAM_tRP TRP_2
34 #define SDRAM_tRP_num 2
35 #define SDRAM_tRAS TRAS_7
36 #define SDRAM_tRAS_num 7
37 #define SDRAM_tRCD TRCD_2
38 #define SDRAM_tWR TWR_2
40 #if (CONFIG_SCLK_HZ > 104477612) && (CONFIG_SCLK_HZ <= 119402985)
41 #define SDRAM_tRP TRP_2
42 #define SDRAM_tRP_num 2
43 #define SDRAM_tRAS TRAS_6
44 #define SDRAM_tRAS_num 6
45 #define SDRAM_tRCD TRCD_2
46 #define SDRAM_tWR TWR_2
48 #if (CONFIG_SCLK_HZ > 89552239) && (CONFIG_SCLK_HZ <= 104477612)
49 #define SDRAM_tRP TRP_2
50 #define SDRAM_tRP_num 2
51 #define SDRAM_tRAS TRAS_5
52 #define SDRAM_tRAS_num 5
53 #define SDRAM_tRCD TRCD_2
54 #define SDRAM_tWR TWR_2
56 #if (CONFIG_SCLK_HZ > 74626866) && (CONFIG_SCLK_HZ <= 89552239)
57 #define SDRAM_tRP TRP_2
58 #define SDRAM_tRP_num 2
59 #define SDRAM_tRAS TRAS_4
60 #define SDRAM_tRAS_num 4
61 #define SDRAM_tRCD TRCD_2
62 #define SDRAM_tWR TWR_2
64 #if (CONFIG_SCLK_HZ > 66666667) && (CONFIG_SCLK_HZ <= 74626866)
65 #define SDRAM_tRP TRP_2
66 #define SDRAM_tRP_num 2
67 #define SDRAM_tRAS TRAS_3
68 #define SDRAM_tRAS_num 3
69 #define SDRAM_tRCD TRCD_2
70 #define SDRAM_tWR TWR_2
72 #if (CONFIG_SCLK_HZ > 59701493) && (CONFIG_SCLK_HZ <= 66666667)
73 #define SDRAM_tRP TRP_1
74 #define SDRAM_tRP_num 1
75 #define SDRAM_tRAS TRAS_4
76 #define SDRAM_tRAS_num 3
77 #define SDRAM_tRCD TRCD_1
78 #define SDRAM_tWR TWR_2
80 #if (CONFIG_SCLK_HZ > 44776119) && (CONFIG_SCLK_HZ <= 59701493)
81 #define SDRAM_tRP TRP_1
82 #define SDRAM_tRP_num 1
83 #define SDRAM_tRAS TRAS_3
84 #define SDRAM_tRAS_num 3
85 #define SDRAM_tRCD TRCD_1
86 #define SDRAM_tWR TWR_2
88 #if (CONFIG_SCLK_HZ > 29850746) && (CONFIG_SCLK_HZ <= 44776119)
89 #define SDRAM_tRP TRP_1
90 #define SDRAM_tRP_num 1
91 #define SDRAM_tRAS TRAS_2
92 #define SDRAM_tRAS_num 2
93 #define SDRAM_tRCD TRCD_1
94 #define SDRAM_tWR TWR_2
96 #if (CONFIG_SCLK_HZ <= 29850746)
97 #define SDRAM_tRP TRP_1
98 #define SDRAM_tRP_num 1
99 #define SDRAM_tRAS TRAS_1
100 #define SDRAM_tRAS_num 1
101 #define SDRAM_tRCD TRCD_1
102 #define SDRAM_tWR TWR_2
106 #if (CONFIG_MEM_MT48LC16M16A2TG_75)
107 /*SDRAM INFORMATION: */
108 #define SDRAM_Tref 64 /* Refresh period in milliseconds */
109 #define SDRAM_NRA 8192 /* Number of row addresses in SDRAM */
110 #define SDRAM_CL CL_3
113 #if (CONFIG_MEM_MT48LC64M4A2FB_7E)
114 /*SDRAM INFORMATION: */
115 #define SDRAM_Tref 64 /* Refresh period in milliseconds */
116 #define SDRAM_NRA 8192 /* Number of row addresses in SDRAM */
117 #define SDRAM_CL CL_3
120 #if (CONFIG_MEM_MT48LC8M32B2B5_7)
121 /*SDRAM INFORMATION: */
122 #define SDRAM_Tref 64 /* Refresh period in milliseconds */
123 #define SDRAM_NRA 4096 /* Number of row addresses in SDRAM */
124 #define SDRAM_CL CL_3
127 #if (CONFIG_MEM_GENERIC_BOARD)
128 /*SDRAM INFORMATION: Modify this for your board */
129 #define SDRAM_Tref 64 /* Refresh period in milliseconds */
130 #define SDRAM_NRA 8192 /* Number of row addresses in SDRAM */
131 #define SDRAM_CL CL_3
134 /* Equation from section 17 (p17-46) of BF533 HRM */
135 #define mem_SDRRC (((CONFIG_SCLK_HZ / 1000) * SDRAM_Tref) / SDRAM_NRA) - (SDRAM_tRAS_num + SDRAM_tRP_num)
137 /* Enable SCLK Out */
138 #define mem_SDGCTL (SCTLE | SDRAM_CL | SDRAM_tRAS | SDRAM_tRP | SDRAM_tRCD | SDRAM_tWR | PSS)
140 #if defined CONFIG_CLKIN_HALF
146 #if defined CONFIG_PLL_BYPASS
152 /***************************************Currently Not Being Used *********************************/
153 #define flash_EBIU_AMBCTL_WAT ((CONFIG_FLASH_SPEED_BWAT * 4) / (4000000000 / CONFIG_SCLK_HZ)) + 1
154 #define flash_EBIU_AMBCTL_RAT ((CONFIG_FLASH_SPEED_BRAT * 4) / (4000000000 / CONFIG_SCLK_HZ)) + 1
155 #define flash_EBIU_AMBCTL_HT ((CONFIG_FLASH_SPEED_BHT * 4) / (4000000000 / CONFIG_SCLK_HZ))
156 #define flash_EBIU_AMBCTL_ST ((CONFIG_FLASH_SPEED_BST * 4) / (4000000000 / CONFIG_SCLK_HZ)) + 1
157 #define flash_EBIU_AMBCTL_TT ((CONFIG_FLASH_SPEED_BTT * 4) / (4000000000 / CONFIG_SCLK_HZ)) + 1
159 #if (flash_EBIU_AMBCTL_TT > 3)
160 #define flash_EBIU_AMBCTL0_TT B0TT_4
162 #if (flash_EBIU_AMBCTL_TT == 3)
163 #define flash_EBIU_AMBCTL0_TT B0TT_3
165 #if (flash_EBIU_AMBCTL_TT == 2)
166 #define flash_EBIU_AMBCTL0_TT B0TT_2
168 #if (flash_EBIU_AMBCTL_TT < 2)
169 #define flash_EBIU_AMBCTL0_TT B0TT_1
172 #if (flash_EBIU_AMBCTL_ST > 3)
173 #define flash_EBIU_AMBCTL0_ST B0ST_4
175 #if (flash_EBIU_AMBCTL_ST == 3)
176 #define flash_EBIU_AMBCTL0_ST B0ST_3
178 #if (flash_EBIU_AMBCTL_ST == 2)
179 #define flash_EBIU_AMBCTL0_ST B0ST_2
181 #if (flash_EBIU_AMBCTL_ST < 2)
182 #define flash_EBIU_AMBCTL0_ST B0ST_1
185 #if (flash_EBIU_AMBCTL_HT > 2)
186 #define flash_EBIU_AMBCTL0_HT B0HT_3
188 #if (flash_EBIU_AMBCTL_HT == 2)
189 #define flash_EBIU_AMBCTL0_HT B0HT_2
191 #if (flash_EBIU_AMBCTL_HT == 1)
192 #define flash_EBIU_AMBCTL0_HT B0HT_1
194 #if (flash_EBIU_AMBCTL_HT == 0 && CONFIG_FLASH_SPEED_BHT == 0)
195 #define flash_EBIU_AMBCTL0_HT B0HT_0
197 #if (flash_EBIU_AMBCTL_HT == 0 && CONFIG_FLASH_SPEED_BHT != 0)
198 #define flash_EBIU_AMBCTL0_HT B0HT_1
201 #if (flash_EBIU_AMBCTL_WAT > 14)
202 #define flash_EBIU_AMBCTL0_WAT B0WAT_15
204 #if (flash_EBIU_AMBCTL_WAT == 14)
205 #define flash_EBIU_AMBCTL0_WAT B0WAT_14
207 #if (flash_EBIU_AMBCTL_WAT == 13)
208 #define flash_EBIU_AMBCTL0_WAT B0WAT_13
210 #if (flash_EBIU_AMBCTL_WAT == 12)
211 #define flash_EBIU_AMBCTL0_WAT B0WAT_12
213 #if (flash_EBIU_AMBCTL_WAT == 11)
214 #define flash_EBIU_AMBCTL0_WAT B0WAT_11
216 #if (flash_EBIU_AMBCTL_WAT == 10)
217 #define flash_EBIU_AMBCTL0_WAT B0WAT_10
219 #if (flash_EBIU_AMBCTL_WAT == 9)
220 #define flash_EBIU_AMBCTL0_WAT B0WAT_9
222 #if (flash_EBIU_AMBCTL_WAT == 8)
223 #define flash_EBIU_AMBCTL0_WAT B0WAT_8
225 #if (flash_EBIU_AMBCTL_WAT == 7)
226 #define flash_EBIU_AMBCTL0_WAT B0WAT_7
228 #if (flash_EBIU_AMBCTL_WAT == 6)
229 #define flash_EBIU_AMBCTL0_WAT B0WAT_6
231 #if (flash_EBIU_AMBCTL_WAT == 5)
232 #define flash_EBIU_AMBCTL0_WAT B0WAT_5
234 #if (flash_EBIU_AMBCTL_WAT == 4)
235 #define flash_EBIU_AMBCTL0_WAT B0WAT_4
237 #if (flash_EBIU_AMBCTL_WAT == 3)
238 #define flash_EBIU_AMBCTL0_WAT B0WAT_3
240 #if (flash_EBIU_AMBCTL_WAT == 2)
241 #define flash_EBIU_AMBCTL0_WAT B0WAT_2
243 #if (flash_EBIU_AMBCTL_WAT == 1)
244 #define flash_EBIU_AMBCTL0_WAT B0WAT_1
247 #if (flash_EBIU_AMBCTL_RAT > 14)
248 #define flash_EBIU_AMBCTL0_RAT B0RAT_15
250 #if (flash_EBIU_AMBCTL_RAT == 14)
251 #define flash_EBIU_AMBCTL0_RAT B0RAT_14
253 #if (flash_EBIU_AMBCTL_RAT == 13)
254 #define flash_EBIU_AMBCTL0_RAT B0RAT_13
256 #if (flash_EBIU_AMBCTL_RAT == 12)
257 #define flash_EBIU_AMBCTL0_RAT B0RAT_12
259 #if (flash_EBIU_AMBCTL_RAT == 11)
260 #define flash_EBIU_AMBCTL0_RAT B0RAT_11
262 #if (flash_EBIU_AMBCTL_RAT == 10)
263 #define flash_EBIU_AMBCTL0_RAT B0RAT_10
265 #if (flash_EBIU_AMBCTL_RAT == 9)
266 #define flash_EBIU_AMBCTL0_RAT B0RAT_9
268 #if (flash_EBIU_AMBCTL_RAT == 8)
269 #define flash_EBIU_AMBCTL0_RAT B0RAT_8
271 #if (flash_EBIU_AMBCTL_RAT == 7)
272 #define flash_EBIU_AMBCTL0_RAT B0RAT_7
274 #if (flash_EBIU_AMBCTL_RAT == 6)
275 #define flash_EBIU_AMBCTL0_RAT B0RAT_6
277 #if (flash_EBIU_AMBCTL_RAT == 5)
278 #define flash_EBIU_AMBCTL0_RAT B0RAT_5
280 #if (flash_EBIU_AMBCTL_RAT == 4)
281 #define flash_EBIU_AMBCTL0_RAT B0RAT_4
283 #if (flash_EBIU_AMBCTL_RAT == 3)
284 #define flash_EBIU_AMBCTL0_RAT B0RAT_3
286 #if (flash_EBIU_AMBCTL_RAT == 2)
287 #define flash_EBIU_AMBCTL0_RAT B0RAT_2
289 #if (flash_EBIU_AMBCTL_RAT == 1)
290 #define flash_EBIU_AMBCTL0_RAT B0RAT_1
293 #define flash_EBIU_AMBCTL0 \
294 (flash_EBIU_AMBCTL0_WAT | flash_EBIU_AMBCTL0_RAT | flash_EBIU_AMBCTL0_HT | \
295 flash_EBIU_AMBCTL0_ST | flash_EBIU_AMBCTL0_TT | CONFIG_FLASH_SPEED_RDYEN)