1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <common.h>
25#include <ioports.h>
26#include <mpc8260.h>
27
28
29
30
31
32
33
34
35const iop_conf_t iop_conf_tab[4][32] = {
36
37
38 {
39 { 0, 0, 0, 1, 0, 0 },
40 { 0, 0, 0, 1, 0, 0 },
41 { 0, 0, 0, 1, 0, 0 },
42 { 0, 0, 0, 1, 0, 0 },
43 { 0, 0, 0, 1, 0, 0 },
44 { 0, 0, 0, 1, 0, 0 },
45 { 0, 0, 0, 1, 0, 0 },
46 { 0, 0, 0, 1, 0, 0 },
47 { 0, 0, 0, 1, 0, 0 },
48 { 0, 0, 0, 1, 0, 0 },
49 { 0, 0, 0, 1, 0, 0 },
50 { 0, 0, 0, 1, 0, 0 },
51 { 0, 0, 0, 1, 0, 0 },
52 { 0, 0, 0, 1, 0, 0 },
53 { 0, 0, 0, 1, 0, 0 },
54 { 0, 0, 0, 1, 0, 0 },
55 { 0, 0, 0, 1, 0, 0 },
56 { 0, 0, 0, 1, 0, 0 },
57 { 0, 0, 0, 1, 0, 0 },
58 { 0, 0, 0, 1, 0, 0 },
59 { 0, 0, 0, 1, 0, 0 },
60 { 0, 0, 0, 1, 0, 0 },
61 { 1, 1, 0, 1, 0, 0 },
62 { 1, 1, 0, 0, 0, 0 },
63 { 0, 0, 0, 1, 0, 0 },
64 { 0, 0, 0, 1, 0, 0 },
65 { 0, 0, 0, 1, 0, 0 },
66 { 0, 0, 0, 1, 0, 0 },
67 { 0, 0, 0, 1, 0, 0 },
68 { 0, 0, 0, 1, 0, 0 },
69 { 0, 0, 0, 1, 0, 0 },
70 { 0, 0, 0, 1, 0, 0 }
71 },
72
73
74 {
75 { 1, 1, 0, 1, 0, 0 },
76 { 1, 1, 0, 0, 0, 0 },
77 { 1, 1, 1, 1, 0, 0 },
78 { 1, 1, 0, 0, 0, 0 },
79 { 1, 1, 0, 0, 0, 0 },
80 { 1, 1, 0, 0, 0, 0 },
81 { 1, 1, 0, 1, 0, 0 },
82 { 1, 1, 0, 1, 0, 0 },
83 { 1, 1, 0, 1, 0, 0 },
84 { 1, 1, 0, 1, 0, 0 },
85 { 1, 1, 0, 0, 0, 0 },
86 { 1, 1, 0, 0, 0, 0 },
87 { 1, 1, 0, 0, 0, 0 },
88 { 1, 1, 0, 0, 0, 0 },
89 { 0, 0, 0, 0, 0, 0 },
90 { 0, 0, 0, 0, 0, 0 },
91 { 0, 0, 0, 0, 0, 0 },
92 { 0, 0, 0, 0, 0, 0 },
93 { 0, 0, 0, 0, 0, 0 },
94 { 0, 0, 0, 0, 0, 0 },
95 { 0, 0, 0, 0, 0, 0 },
96 { 0, 0, 0, 0, 0, 0 },
97 { 0, 0, 0, 0, 0, 0 },
98 { 0, 0, 0, 0, 0, 0 },
99 { 0, 0, 0, 0, 0, 0 },
100 { 0, 0, 0, 0, 0, 0 },
101 { 0, 0, 0, 0, 0, 0 },
102 { 0, 0, 0, 0, 0, 0 },
103 { 0, 0, 0, 0, 0, 0 },
104 { 0, 0, 0, 0, 0, 0 },
105 { 0, 0, 0, 0, 0, 0 },
106 { 0, 0, 0, 0, 0, 0 }
107 },
108
109
110 {
111 { 0, 0, 0, 1, 0, 0 },
112 { 0, 0, 0, 1, 0, 0 },
113 { 1, 1, 1, 0, 0, 0 },
114 { 0, 0, 0, 1, 0, 0 },
115 { 0, 0, 0, 1, 0, 0 },
116 { 0, 0, 0, 1, 0, 0 },
117 { 0, 0, 0, 1, 0, 0 },
118 { 0, 0, 0, 1, 0, 0 },
119 { 0, 1, 0, 1, 0, 0 },
120 { 0, 1, 0, 0, 0, 0 },
121 { 1, 1, 0, 0, 0, 0 },
122 { 1, 1, 0, 0, 0, 0 },
123 { 1, 1, 0, 0, 0, 0 },
124 { 1, 1, 0, 0, 0, 0 },
125 { 0, 0, 0, 1, 0, 0 },
126 { 0, 0, 0, 1, 0, 0 },
127 { 0, 0, 0, 1, 0, 0 },
128 { 1, 1, 0, 0, 0, 0 },
129 { 0, 0, 0, 1, 0, 0 },
130 { 0, 0, 0, 1, 0, 0 },
131 { 0, 0, 0, 1, 0, 0 },
132 { 0, 0, 0, 1, 0, 0 },
133 { 0, 0, 0, 1, 0, 0 },
134 { 0, 0, 0, 1, 0, 0 },
135 { 0, 0, 0, 1, 0, 0 },
136 { 0, 0, 0, 1, 0, 0 },
137 { 0, 0, 0, 1, 0, 0 },
138 { 0, 0, 0, 1, 0, 0 },
139 { 0, 0, 0, 1, 0, 0 },
140 { 0, 0, 0, 1, 0, 1 },
141 { 0, 0, 0, 1, 0, 0 },
142 { 0, 0, 0, 1, 0, 0 },
143 },
144
145
146 {
147 { 1, 1, 0, 0, 0, 0 },
148 { 1, 1, 1, 1, 0, 0 },
149 { 1, 1, 0, 1, 0, 0 },
150 { 0, 0, 0, 1, 0, 0 },
151 { 0, 0, 0, 1, 0, 0 },
152 { 0, 0, 0, 1, 0, 0 },
153 { 0, 0, 0, 1, 0, 0 },
154 { 0, 0, 0, 1, 0, 0 },
155 { 0, 0, 0, 1, 0, 0 },
156 { 0, 0, 0, 1, 0, 0 },
157 { 0, 0, 0, 1, 0, 0 },
158 { 0, 0, 0, 1, 0, 0 },
159 { 0, 0, 0, 1, 0, 0 },
160 { 0, 0, 0, 1, 0, 0 },
161 { 0, 1, 0, 0, 0, 0 },
162 { 0, 1, 0, 1, 0, 0 },
163#if defined(CONFIG_SOFT_I2C)
164 { 1, 0, 0, 1, 1, 1 },
165 { 1, 0, 0, 1, 1, 1 },
166#else
167#if defined(CONFIG_HARD_I2C)
168 { 1, 1, 1, 0, 1, 0 },
169 { 1, 1, 1, 0, 1, 0 },
170#else
171 { 0, 1, 1, 0, 1, 0 },
172 { 0, 1, 1, 0, 1, 0 },
173#endif
174#endif
175 { 0, 0, 0, 0, 0, 0 },
176 { 0, 0, 0, 0, 0, 0 },
177 { 0, 0, 0, 0, 0, 0 },
178 { 0, 0, 0, 0, 0, 0 },
179 { 1, 1, 0, 1, 0, 0 },
180 { 1, 1, 0, 0, 0, 0 },
181 { 0, 0, 0, 1, 0, 1 },
182 { 0, 0, 0, 1, 0, 1 },
183 { 0, 0, 0, 1, 0, 1 },
184 { 0, 0, 0, 1, 0, 1 },
185 { 0, 0, 0, 0, 0, 0 },
186 { 0, 0, 0, 0, 0, 0 },
187 { 0, 0, 0, 0, 0, 0 },
188 { 0, 0, 0, 0, 0, 0 }
189 }
190};
191
192
193
194
195
196int checkboard (void)
197{
198 char buf[64];
199 int i = getenv_f("serial#", buf, sizeof(buf));
200
201 puts ("Board: ");
202
203 if (i < 0 || strncmp(buf, "TQM82", 5)) {
204 puts ("### No HW ID - assuming TQM8260\n");
205 return (0);
206 }
207
208 puts (buf);
209 putc ('\n');
210
211 return 0;
212}
213
214
215
216
217
218
219
220
221
222
223static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
224 ulong orx, volatile uchar * base)
225{
226 volatile uchar c = 0xff;
227 volatile uint *sdmr_ptr;
228 volatile uint *orx_ptr;
229 ulong maxsize, size;
230 int i;
231
232
233
234
235
236
237 maxsize = (1 + (~orx | 0x7fff)) / 2;
238
239
240
241
242 sdmr_ptr = base ? &memctl->memc_lsdmr : &memctl->memc_psdmr;
243 orx_ptr = base ? &memctl->memc_or2 : &memctl->memc_or1;
244
245 *orx_ptr = orx;
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267 *sdmr_ptr = sdmr | PSDMR_OP_PREA;
268 *base = c;
269
270 *sdmr_ptr = sdmr | PSDMR_OP_CBRR;
271 for (i = 0; i < 8; i++)
272 *base = c;
273
274 *sdmr_ptr = sdmr | PSDMR_OP_MRW;
275 *(base + CONFIG_SYS_MRS_OFFS) = c;
276
277 *sdmr_ptr = sdmr | PSDMR_OP_NORM | PSDMR_RFEN;
278 *base = c;
279
280 size = get_ram_size((long *)base, maxsize);
281 *orx_ptr = orx | ~(size - 1);
282
283 return (size);
284}
285
286phys_size_t initdram (int board_type)
287{
288 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
289 volatile memctl8260_t *memctl = &immap->im_memctl;
290
291#ifndef CONFIG_SYS_RAMBOOT
292 long size8, size9;
293#endif
294 long psize, lsize;
295
296 psize = 16 * 1024 * 1024;
297 lsize = 0;
298
299 memctl->memc_psrt = CONFIG_SYS_PSRT;
300 memctl->memc_mptpr = CONFIG_SYS_MPTPR;
301
302#if 0
303#define prt_br_or(brX,orX) do { \
304 ulong start = memctl->memc_ ## brX & 0xFFFF8000; \
305 ulong sizem = ~memctl->memc_ ## orX | 0x00007FFF; \
306 printf ("\n" \
307 #brX " 0x%08x " #orX " 0x%08x " \
308 "==> 0x%08lx ... 0x%08lx = %ld MB\n", \
309 memctl->memc_ ## brX, memctl->memc_ ## orX, \
310 start, start+sizem, (sizem+1)>>20); \
311 } while (0)
312 prt_br_or (br0, or0);
313 prt_br_or (br1, or1);
314 prt_br_or (br2, or2);
315 prt_br_or (br3, or3);
316#endif
317
318#ifndef CONFIG_SYS_RAMBOOT
319
320
321 size8 = try_init (memctl, CONFIG_SYS_PSDMR_8COL, CONFIG_SYS_OR1_8COL,
322 (uchar *) CONFIG_SYS_SDRAM_BASE);
323 size9 = try_init (memctl, CONFIG_SYS_PSDMR_9COL, CONFIG_SYS_OR1_9COL,
324 (uchar *) CONFIG_SYS_SDRAM_BASE);
325
326 if (size8 < size9) {
327 psize = size9;
328 printf ("(60x:9COL - %ld MB, ", psize >> 20);
329 } else {
330 psize = try_init (memctl, CONFIG_SYS_PSDMR_8COL, CONFIG_SYS_OR1_8COL,
331 (uchar *) CONFIG_SYS_SDRAM_BASE);
332 printf ("(60x:8COL - %ld MB, ", psize >> 20);
333 }
334
335
336
337#ifdef CONFIG_SYS_INIT_LOCAL_SDRAM
338 memctl->memc_lsrt = CONFIG_SYS_LSRT;
339 size8 = try_init (memctl, CONFIG_SYS_LSDMR_8COL, CONFIG_SYS_OR2_8COL,
340 (uchar *) SDRAM_BASE2_PRELIM);
341 size9 = try_init (memctl, CONFIG_SYS_LSDMR_9COL, CONFIG_SYS_OR2_9COL,
342 (uchar *) SDRAM_BASE2_PRELIM);
343
344 if (size8 < size9) {
345 lsize = size9;
346 printf ("Local:9COL - %ld MB) using ", lsize >> 20);
347 } else {
348 lsize = try_init (memctl, CONFIG_SYS_LSDMR_8COL, CONFIG_SYS_OR2_8COL,
349 (uchar *) SDRAM_BASE2_PRELIM);
350 printf ("Local:8COL - %ld MB) using ", lsize >> 20);
351 }
352
353#if 0
354
355
356
357 memctl->memc_br2 = (CONFIG_SYS_BR2_PRELIM & ~BRx_BA_MSK) |
358 (CONFIG_SYS_SDRAM_BASE + psize);
359#endif
360#endif
361#endif
362
363 icache_enable ();
364
365 return (psize);
366}
367
368
369