2 * U-boot - mem_init.h Header file for memory initialization
4 * Copyright (c) 2005 blackfin.uclinux.org
6 * See file CREDITS for list of people who contributed to this
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 #if ( CONFIG_MEM_MT48LC16M16A2TG_75 || CONFIG_MEM_MT48LC64M4A2FB_7E )
26 #if ( CONFIG_SCLK_HZ > 119402985 )
27 #define SDRAM_tRP TRP_2
28 #define SDRAM_tRP_num 2
29 #define SDRAM_tRAS TRAS_7
30 #define SDRAM_tRAS_num 7
31 #define SDRAM_tRCD TRCD_2
32 #define SDRAM_tWR TWR_2
34 #if ( CONFIG_SCLK_HZ > 104477612 ) && ( CONFIG_SCLK_HZ <= 119402985 )
35 #define SDRAM_tRP TRP_2
36 #define SDRAM_tRP_num 2
37 #define SDRAM_tRAS TRAS_6
38 #define SDRAM_tRAS_num 6
39 #define SDRAM_tRCD TRCD_2
40 #define SDRAM_tWR TWR_2
42 #if ( CONFIG_SCLK_HZ > 89552239 ) && ( CONFIG_SCLK_HZ <= 104477612 )
43 #define SDRAM_tRP TRP_2
44 #define SDRAM_tRP_num 2
45 #define SDRAM_tRAS TRAS_5
46 #define SDRAM_tRAS_num 5
47 #define SDRAM_tRCD TRCD_2
48 #define SDRAM_tWR TWR_2
50 #if ( CONFIG_SCLK_HZ > 74626866 ) && ( CONFIG_SCLK_HZ <= 89552239 )
51 #define SDRAM_tRP TRP_2
52 #define SDRAM_tRP_num 2
53 #define SDRAM_tRAS TRAS_4
54 #define SDRAM_tRAS_num 4
55 #define SDRAM_tRCD TRCD_2
56 #define SDRAM_tWR TWR_2
58 #if ( CONFIG_SCLK_HZ > 66666667 ) && ( CONFIG_SCLK_HZ <= 74626866 )
59 #define SDRAM_tRP TRP_2
60 #define SDRAM_tRP_num 2
61 #define SDRAM_tRAS TRAS_3
62 #define SDRAM_tRAS_num 3
63 #define SDRAM_tRCD TRCD_2
64 #define SDRAM_tWR TWR_2
66 #if ( CONFIG_SCLK_HZ > 59701493 ) && ( CONFIG_SCLK_HZ <= 66666667 )
67 #define SDRAM_tRP TRP_1
68 #define SDRAM_tRP_num 1
69 #define SDRAM_tRAS TRAS_4
70 #define SDRAM_tRAS_num 3
71 #define SDRAM_tRCD TRCD_1
72 #define SDRAM_tWR TWR_2
74 #if ( CONFIG_SCLK_HZ > 44776119 ) && ( CONFIG_SCLK_HZ <= 59701493 )
75 #define SDRAM_tRP TRP_1
76 #define SDRAM_tRP_num 1
77 #define SDRAM_tRAS TRAS_3
78 #define SDRAM_tRAS_num 3
79 #define SDRAM_tRCD TRCD_1
80 #define SDRAM_tWR TWR_2
82 #if ( CONFIG_SCLK_HZ > 29850746 ) && ( CONFIG_SCLK_HZ <= 44776119 )
83 #define SDRAM_tRP TRP_1
84 #define SDRAM_tRP_num 1
85 #define SDRAM_tRAS TRAS_2
86 #define SDRAM_tRAS_num 2
87 #define SDRAM_tRCD TRCD_1
88 #define SDRAM_tWR TWR_2
90 #if ( CONFIG_SCLK_HZ <= 29850746 )
91 #define SDRAM_tRP TRP_1
92 #define SDRAM_tRP_num 1
93 #define SDRAM_tRAS TRAS_1
94 #define SDRAM_tRAS_num 1
95 #define SDRAM_tRCD TRCD_1
96 #define SDRAM_tWR TWR_2
100 #if (CONFIG_MEM_MT48LC16M16A2TG_75)
101 /*SDRAM INFORMATION: */
102 #define SDRAM_Tref 64 /* Refresh period in milliseconds */
103 #define SDRAM_NRA 8192 /* Number of row addresses in SDRAM */
104 #define SDRAM_CL CL_3
107 #if (CONFIG_MEM_MT48LC64M4A2FB_7E)
108 /*SDRAM INFORMATION: */
109 #define SDRAM_Tref 64 /* Refresh period in milliseconds */
110 #define SDRAM_NRA 8192 /* Number of row addresses in SDRAM */
111 #define SDRAM_CL CL_2
114 #if ( CONFIG_MEM_SIZE == 128 )
115 #define SDRAM_SIZE EBSZ_128
117 #if ( CONFIG_MEM_SIZE == 64 )
118 #define SDRAM_SIZE EBSZ_64
120 #if ( CONFIG_MEM_SIZE == 32 )
121 #define SDRAM_SIZE EBSZ_32
123 #if ( CONFIG_MEM_SIZE == 16 )
124 #define SDRAM_SIZE EBSZ_16
126 #if ( CONFIG_MEM_ADD_WDTH == 11 )
127 #define SDRAM_WIDTH EBCAW_11
129 #if ( CONFIG_MEM_ADD_WDTH == 10 )
130 #define SDRAM_WIDTH EBCAW_10
132 #if ( CONFIG_MEM_ADD_WDTH == 9 )
133 #define SDRAM_WIDTH EBCAW_9
135 #if ( CONFIG_MEM_ADD_WDTH == 8 )
136 #define SDRAM_WIDTH EBCAW_8
139 #define mem_SDBCTL SDRAM_WIDTH | SDRAM_SIZE | EBE
141 /* Equation from section 17 (p17-46) of BF533 HRM */
142 #define mem_SDRRC ((( CONFIG_SCLK_HZ / 1000) * SDRAM_Tref) / SDRAM_NRA) - (SDRAM_tRAS_num + SDRAM_tRP_num)
144 /* Enable SCLK Out */
145 #define mem_SDGCTL ( SCTLE | SDRAM_CL | SDRAM_tRAS | SDRAM_tRP | SDRAM_tRCD | SDRAM_tWR | PSS )
147 #define flash_EBIU_AMBCTL_WAT ( ( CONFIG_FLASH_SPEED_BWAT * 4 ) / ( 4000000000 / CONFIG_SCLK_HZ ) ) + 1
148 #define flash_EBIU_AMBCTL_RAT ( ( CONFIG_FLASH_SPEED_BRAT * 4 ) / ( 4000000000 / CONFIG_SCLK_HZ ) ) + 1
149 #define flash_EBIU_AMBCTL_HT ( ( CONFIG_FLASH_SPEED_BHT * 4 ) / ( 4000000000 / CONFIG_SCLK_HZ ) )
150 #define flash_EBIU_AMBCTL_ST ( ( CONFIG_FLASH_SPEED_BST * 4 ) / ( 4000000000 / CONFIG_SCLK_HZ ) ) + 1
151 #define flash_EBIU_AMBCTL_TT ( ( CONFIG_FLASH_SPEED_BTT * 4 ) / ( 4000000000 / CONFIG_SCLK_HZ ) ) + 1
153 #if (flash_EBIU_AMBCTL_TT > 3 )
154 #define flash_EBIU_AMBCTL0_TT B0TT_4
156 #if (flash_EBIU_AMBCTL_TT == 3 )
157 #define flash_EBIU_AMBCTL0_TT B0TT_3
159 #if (flash_EBIU_AMBCTL_TT == 2 )
160 #define flash_EBIU_AMBCTL0_TT B0TT_2
162 #if (flash_EBIU_AMBCTL_TT < 2 )
163 #define flash_EBIU_AMBCTL0_TT B0TT_1
166 #if (flash_EBIU_AMBCTL_ST > 3 )
167 #define flash_EBIU_AMBCTL0_ST B0ST_4
169 #if (flash_EBIU_AMBCTL_ST == 3 )
170 #define flash_EBIU_AMBCTL0_ST B0ST_3
172 #if (flash_EBIU_AMBCTL_ST == 2 )
173 #define flash_EBIU_AMBCTL0_ST B0ST_2
175 #if (flash_EBIU_AMBCTL_ST < 2 )
176 #define flash_EBIU_AMBCTL0_ST B0ST_1
179 #if (flash_EBIU_AMBCTL_HT > 2 )
180 #define flash_EBIU_AMBCTL0_HT B0HT_3
182 #if (flash_EBIU_AMBCTL_HT == 2 )
183 #define flash_EBIU_AMBCTL0_HT B0HT_2
185 #if (flash_EBIU_AMBCTL_HT == 1 )
186 #define flash_EBIU_AMBCTL0_HT B0HT_1
188 #if (flash_EBIU_AMBCTL_HT == 0 && CONFIG_FLASH_SPEED_BHT == 0)
189 #define flash_EBIU_AMBCTL0_HT B0HT_0
191 #if (flash_EBIU_AMBCTL_HT == 0 && CONFIG_FLASH_SPEED_BHT != 0)
192 #define flash_EBIU_AMBCTL0_HT B0HT_1
195 #if (flash_EBIU_AMBCTL_WAT > 14)
196 #define flash_EBIU_AMBCTL0_WAT B0WAT_15
198 #if (flash_EBIU_AMBCTL_WAT == 14)
199 #define flash_EBIU_AMBCTL0_WAT B0WAT_14
201 #if (flash_EBIU_AMBCTL_WAT == 13)
202 #define flash_EBIU_AMBCTL0_WAT B0WAT_13
204 #if (flash_EBIU_AMBCTL_WAT == 12)
205 #define flash_EBIU_AMBCTL0_WAT B0WAT_12
207 #if (flash_EBIU_AMBCTL_WAT == 11)
208 #define flash_EBIU_AMBCTL0_WAT B0WAT_11
210 #if (flash_EBIU_AMBCTL_WAT == 10)
211 #define flash_EBIU_AMBCTL0_WAT B0WAT_10
213 #if (flash_EBIU_AMBCTL_WAT == 9)
214 #define flash_EBIU_AMBCTL0_WAT B0WAT_9
216 #if (flash_EBIU_AMBCTL_WAT == 8)
217 #define flash_EBIU_AMBCTL0_WAT B0WAT_8
219 #if (flash_EBIU_AMBCTL_WAT == 7)
220 #define flash_EBIU_AMBCTL0_WAT B0WAT_7
222 #if (flash_EBIU_AMBCTL_WAT == 6)
223 #define flash_EBIU_AMBCTL0_WAT B0WAT_6
225 #if (flash_EBIU_AMBCTL_WAT == 5)
226 #define flash_EBIU_AMBCTL0_WAT B0WAT_5
228 #if (flash_EBIU_AMBCTL_WAT == 4)
229 #define flash_EBIU_AMBCTL0_WAT B0WAT_4
231 #if (flash_EBIU_AMBCTL_WAT == 3)
232 #define flash_EBIU_AMBCTL0_WAT B0WAT_3
234 #if (flash_EBIU_AMBCTL_WAT == 2)
235 #define flash_EBIU_AMBCTL0_WAT B0WAT_2
237 #if (flash_EBIU_AMBCTL_WAT == 1)
238 #define flash_EBIU_AMBCTL0_WAT B0WAT_1
241 #if (flash_EBIU_AMBCTL_RAT > 14)
242 #define flash_EBIU_AMBCTL0_RAT B0RAT_15
244 #if (flash_EBIU_AMBCTL_RAT == 14)
245 #define flash_EBIU_AMBCTL0_RAT B0RAT_14
247 #if (flash_EBIU_AMBCTL_RAT == 13)
248 #define flash_EBIU_AMBCTL0_RAT B0RAT_13
250 #if (flash_EBIU_AMBCTL_RAT == 12)
251 #define flash_EBIU_AMBCTL0_RAT B0RAT_12
253 #if (flash_EBIU_AMBCTL_RAT == 11)
254 #define flash_EBIU_AMBCTL0_RAT B0RAT_11
256 #if (flash_EBIU_AMBCTL_RAT == 10)
257 #define flash_EBIU_AMBCTL0_RAT B0RAT_10
259 #if (flash_EBIU_AMBCTL_RAT == 9)
260 #define flash_EBIU_AMBCTL0_RAT B0RAT_9
262 #if (flash_EBIU_AMBCTL_RAT == 8)
263 #define flash_EBIU_AMBCTL0_RAT B0RAT_8
265 #if (flash_EBIU_AMBCTL_RAT == 7)
266 #define flash_EBIU_AMBCTL0_RAT B0RAT_7
268 #if (flash_EBIU_AMBCTL_RAT == 6)
269 #define flash_EBIU_AMBCTL0_RAT B0RAT_6
271 #if (flash_EBIU_AMBCTL_RAT == 5)
272 #define flash_EBIU_AMBCTL0_RAT B0RAT_5
274 #if (flash_EBIU_AMBCTL_RAT == 4)
275 #define flash_EBIU_AMBCTL0_RAT B0RAT_4
277 #if (flash_EBIU_AMBCTL_RAT == 3)
278 #define flash_EBIU_AMBCTL0_RAT B0RAT_3
280 #if (flash_EBIU_AMBCTL_RAT == 2)
281 #define flash_EBIU_AMBCTL0_RAT B0RAT_2
283 #if (flash_EBIU_AMBCTL_RAT == 1)
284 #define flash_EBIU_AMBCTL0_RAT B0RAT_1
287 #define flash_EBIU_AMBCTL0 flash_EBIU_AMBCTL0_WAT | flash_EBIU_AMBCTL0_RAT | flash_EBIU_AMBCTL0_HT | flash_EBIU_AMBCTL0_ST | flash_EBIU_AMBCTL0_TT | CONFIG_FLASH_SPEED_RDYEN