1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#include <common.h>
17#include <74xx_7xx.h>
18#include <config.h>
19#include <version.h>
20#include <asm/processor.h>
21#include <tsi108.h>
22
23DECLARE_GLOBAL_DATA_PTR;
24
25extern void mpicInit (int verbose);
26
27
28
29
30
31typedef struct {
32 ulong upper;
33 ulong lower;
34} PB2OCN_LUT_ENTRY;
35
36PB2OCN_LUT_ENTRY pb2ocn_lut1[32] = {
37
38 {0x00000000, 0x00000201},
39 {0x00000000, 0x00000201},
40 {0x00000000, 0x00000201},
41 {0x00000000, 0x00000201},
42 {0x00000000, 0x00000201},
43 {0x00000000, 0x00000201},
44 {0x00000000, 0x00000201},
45 {0x00000000, 0x00000201},
46
47
48 {0x00000000, 0x00000201},
49 {0x00000000, 0x00000201},
50 {0x00000000, 0x00000201},
51 {0x00000000, 0x00000201},
52 {0x00000000, 0x00000201},
53 {0x00000000, 0x00000201},
54 {0x00000000, 0x00000201},
55 {0x00000000, 0x00000201},
56
57
58 {0x00000000, 0x00000201},
59 {0x00000000, 0x00000201},
60 {0x00000000, 0x00000201},
61 {0x00000000, 0x00000201},
62 {0x00000000, 0x00000201},
63 {0x00000000, 0x00000201},
64 {0x00000000, 0x00000201},
65 {0x00000000, 0x00000201},
66
67 {0x00000000, 0x00000201},
68 {0x00000000, 0x00000201},
69 {0x00000000, 0x00000241},
70 {0x00000000, 0x00000201},
71
72 {0x00000000, 0x02000240},
73 {0x00000000, 0x01000240},
74 {0x00000000, 0x03000240},
75 {0x00000000, 0x00000240}
76};
77
78#ifdef CONFIG_SYS_CLK_SPREAD
79typedef struct {
80 ulong ctrl0;
81 ulong ctrl1;
82} PLL_CTRL_SET;
83
84
85
86
87
88
89
90
91static PLL_CTRL_SET pll0_config[8] = {
92 {0x00000000, 0x00000000},
93 {0x00000000, 0x00000000},
94 {0x00430044, 0x00000043},
95 {0x005c0044, 0x00000039},
96 {0x005c0044, 0x00000039},
97 {0x004a0044, 0x00000040},
98 {0x005c0044, 0x00000039},
99 {0x004f0044, 0x0000003e}
100};
101#endif
102
103
104
105
106
107static int pb_clk_sel[8] = { 0, 0, 183, 100, 133, 167, 200, 233 };
108
109
110
111
112
113
114unsigned long get_board_bus_clk (void)
115{
116 ulong i;
117
118
119 i = in32(CONFIG_SYS_TSI108_CSR_BASE + TSI108_CLK_REG_OFFSET + CG_PWRUP_STATUS);
120 i = (i >> 16) & 0x07;
121
122 return pb_clk_sel[i] * 1000000;
123}
124
125
126
127
128
129
130
131int board_early_init_f (void)
132{
133 ulong i;
134
135 gd->mem_clk = 0;
136 i = in32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_CLK_REG_OFFSET +
137 CG_PWRUP_STATUS);
138 i = (i >> 20) & 0x07;
139 switch (i) {
140 case 0:
141 printf ("Using external clock\n");
142 break;
143 case 1:
144 gd->mem_clk = gd->bus_clk;
145 break;
146 case 4:
147 case 5:
148 case 6:
149 gd->mem_clk = pb_clk_sel[i] * 1000000;
150 break;
151 default:
152 printf ("Invalid DDR2 clock setting\n");
153 return -1;
154 }
155 printf ("BUS: %lu MHz\n", get_board_bus_clk() / 1000000);
156 printf ("MEM: %lu MHz\n", gd->mem_clk / 1000000);
157 return 0;
158}
159
160
161
162
163
164
165int board_early_init_r (void)
166{
167 ulong temp, i;
168 ulong reg_val;
169 volatile ulong *reg_ptr;
170
171 reg_ptr =
172 (ulong *) (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PB_REG_OFFSET + 0x900);
173
174 for (i = 0; i < 32; i++) {
175 *reg_ptr++ = 0x00000201;
176 *reg_ptr++ = 0x00;
177 }
178
179 __asm__ __volatile__ ("eieio");
180 __asm__ __volatile__ ("sync");
181
182
183
184 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PB_REG_OFFSET + PB_OCN_BAR2,
185 0x80000001);
186 __asm__ __volatile__ ("sync");
187
188
189
190
191
192 temp = in32(CONFIG_SYS_TSI108_CSR_BASE + TSI108_PB_REG_OFFSET + PB_OCN_BAR2);
193 __asm__ __volatile__ ("sync");
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210 reg_ptr =
211 (ulong *) (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PB_REG_OFFSET + 0x800);
212
213 for (i = 0; i < 32; i++) {
214 *reg_ptr++ = pb2ocn_lut1[i].lower;
215 *reg_ptr++ = pb2ocn_lut1[i].upper;
216 }
217
218 __asm__ __volatile__ ("sync");
219
220
221
222 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B0_ADDR,
223 0x00000000);
224 __asm__ __volatile__ ("sync");
225
226 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B1_ADDR,
227 0x00100000);
228 __asm__ __volatile__ ("sync");
229
230 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B2_ADDR,
231 0x00200000);
232 __asm__ __volatile__ ("sync");
233
234 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B3_ADDR,
235 0x00300000);
236 __asm__ __volatile__ ("sync");
237
238
239
240 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B0_MASK,
241 0xFFF00000);
242 __asm__ __volatile__ ("sync");
243
244 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B1_MASK,
245 0xFFF00000);
246 __asm__ __volatile__ ("sync");
247
248 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B2_MASK,
249 0xFFF00000);
250 __asm__ __volatile__ ("sync");
251
252 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B3_MASK,
253 0xFFF00000);
254 __asm__ __volatile__ ("sync");
255
256
257
258 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B0_CTRL0,
259 0x7FFC44C2);
260 __asm__ __volatile__ ("sync");
261
262 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B1_CTRL0,
263 0x7FFC44C0);
264 __asm__ __volatile__ ("sync");
265
266 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B2_CTRL0,
267 0x7FFC44C0);
268 __asm__ __volatile__ ("sync");
269
270 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B3_CTRL0,
271 0x7FFC44C2);
272 __asm__ __volatile__ ("sync");
273
274
275
276 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B0_CTRL1,
277 0x7C0F2000);
278 __asm__ __volatile__ ("sync");
279
280 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B1_CTRL1,
281 0x7C0F2000);
282 __asm__ __volatile__ ("sync");
283
284 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B2_CTRL1,
285 0x7C0F2000);
286 __asm__ __volatile__ ("sync");
287
288 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B3_CTRL1,
289 0x7C0F2000);
290 __asm__ __volatile__ ("sync");
291
292
293
294
295
296 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PB_REG_OFFSET + PB_OCN_BAR1,
297 0xE0000011);
298 __asm__ __volatile__ ("sync");
299
300
301
302
303
304 temp = in32(CONFIG_SYS_TSI108_CSR_BASE + TSI108_PB_REG_OFFSET + PB_OCN_BAR1);
305 __asm__ __volatile__ ("sync");
306
307
308
309
310
311
312
313
314
315
316
317
318
319 env_init ();
320
321#ifndef DISABLE_PBM
322
323
324
325
326
327
328 temp = get_cpu_type ();
329
330 if ((CPU_750FX == temp) || (CPU_750GX == temp))
331 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PB_REG_OFFSET + PB_MCMD,
332 0x00009955);
333#endif
334
335#ifdef CONFIG_PCI
336
337
338
339
340
341 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET +
342 PCI_PFAB_BAR0_UPPER, 0);
343 __asm__ __volatile__ ("sync");
344
345 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_PFAB_BAR0,
346 0xFB000001);
347 __asm__ __volatile__ ("sync");
348
349
350
351 temp = in32(CONFIG_SYS_TSI108_CSR_BASE +
352 TSI108_PCI_REG_OFFSET + PCI_PCIX_STAT);
353
354 temp &= ~0xFF00;
355
356 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_PCIX_STAT,
357 temp);
358
359
360
361 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_PFAB_IO_UPPER,
362 0);
363 __asm__ __volatile__ ("sync");
364
365
366
367
368
369 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_PFAB_IO,
370 0x00000001);
371 __asm__ __volatile__ ("sync");
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394 reg_ptr =
395 (ulong *) (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + 0x500);
396
397#ifdef DISABLE_PBM
398
399
400
401
402
403
404 reg_val = 0x00000004;
405
406 for (i = 0; i < 32; i++) {
407 *reg_ptr++ = reg_val;
408 *reg_ptr++ = 0;
409 }
410
411
412 reg_val = 0x00007500;
413#else
414
415 reg_val = 0x00000002;
416
417 for (i = 0; i < 32; i++) {
418 *reg_ptr++ = reg_val;
419
420 *reg_ptr++ = 0x40000000;
421
422 reg_val += 0x01000000;
423 }
424
425
426 reg_val = 0x00007100;
427#endif
428
429 __asm__ __volatile__ ("eieio");
430 __asm__ __volatile__ ("sync");
431
432 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_P2O_PAGE_SIZES,
433 reg_val);
434 __asm__ __volatile__ ("sync");
435
436
437
438
439
440 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_P2O_BAR2,
441 0x00000000);
442 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_P2O_BAR2_UPPER,
443 0x00000000);
444 __asm__ __volatile__ ("sync");
445
446#ifndef DISABLE_PBM
447
448
449
450
451
452
453
454
455
456
457
458
459 reg_ptr =
460 (ulong *) (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + 0x600);
461
462 reg_val = 0x00000004;
463
464 for (i = 0; i < 32; i++) {
465 *reg_ptr++ = reg_val;
466
467
468 *reg_ptr++ = 0;
469
470
471 reg_val += 0x01000000;
472 }
473
474 __asm__ __volatile__ ("eieio");
475 __asm__ __volatile__ ("sync");
476
477
478
479 reg_val =
480 in32(CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET +
481 PCI_P2O_PAGE_SIZES);
482 reg_val &= ~0x00FF;
483 reg_val |= 0x0071;
484 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_P2O_PAGE_SIZES,
485 reg_val);
486 __asm__ __volatile__ ("sync");
487
488
489
490 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_P2O_BAR3_UPPER,
491 0x00000000);
492 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_P2O_BAR3,
493 0x20000000);
494 __asm__ __volatile__ ("sync");
495
496#endif
497
498#ifdef ENABLE_PCI_CSR_BAR
499
500
501 reg_val = in32(CONFIG_SYS_TSI108_CSR_BASE +
502 TSI108_PCI_REG_OFFSET + PCI_MISC_CSR);
503 reg_val |= 0x02;
504 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_MISC_CSR,
505 reg_val);
506 __asm__ __volatile__ ("sync");
507
508 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_P2O_BAR0_UPPER,
509 0x00000000);
510 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_P2O_BAR0,
511 CONFIG_SYS_TSI108_CSR_BASE);
512 __asm__ __volatile__ ("sync");
513
514#endif
515
516
517
518
519
520 reg_val = in32(CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_CSR);
521 reg_val |= 0x06;
522 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_CSR, reg_val);
523 __asm__ __volatile__ ("sync");
524
525#endif
526
527
528
529
530
531
532
533
534
535
536 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_MPIC_REG_OFFSET + MPIC_CSR(0), 0x02);
537 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_MPIC_REG_OFFSET + MPIC_CSR(1), 0x02);
538 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_MPIC_REG_OFFSET + MPIC_CSR(2), 0x02);
539 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_MPIC_REG_OFFSET + MPIC_CSR(3), 0x02);
540 __asm__ __volatile__ ("sync");
541
542
543
544
545
546
547 reg_val = mfmsr ();
548 mtmsr(reg_val | MSR_ME);
549
550 return 0;
551}
552
553
554
555
556
557
558unsigned long get_l2cr (void)
559{
560 unsigned long l2controlreg;
561 asm volatile ("mfspr %0, 1017":"=r" (l2controlreg):);
562 return l2controlreg;
563}
564
565
566
567
568
569
570
571
572int misc_init_r (void)
573{
574#ifdef CONFIG_SYS_CLK_SPREAD
575 ulong i;
576
577
578 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_CLK_REG_OFFSET + CG_PLL0_CTRL0, 0);
579 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_CLK_REG_OFFSET + CG_PLL1_CTRL0, 0);
580
581
582
583
584
585 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_CLK_REG_OFFSET + CG_PLL1_CTRL0,
586 0x002e0044);
587 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_CLK_REG_OFFSET + CG_PLL1_CTRL1,
588 0x00000039);
589
590
591
592 i = in32(CONFIG_SYS_TSI108_CSR_BASE + TSI108_CLK_REG_OFFSET + CG_PWRUP_STATUS);
593 i = (i >> 16) & 0x07;
594
595 out32 (CONFIG_SYS_TSI108_CSR_BASE +
596 TSI108_CLK_REG_OFFSET + CG_PLL0_CTRL0, pll0_config[i].ctrl0);
597 out32 (CONFIG_SYS_TSI108_CSR_BASE +
598 TSI108_CLK_REG_OFFSET + CG_PLL0_CTRL1, pll0_config[i].ctrl1);
599
600
601 udelay (1000);
602 out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_CLK_REG_OFFSET + CG_PLL1_CTRL0,
603 0x802e0044);
604 out32 (CONFIG_SYS_TSI108_CSR_BASE +
605 TSI108_CLK_REG_OFFSET + CG_PLL0_CTRL0,
606 0x80000000 | pll0_config[i].ctrl0);
607#endif
608
609#ifdef CONFIG_SYS_L2
610 l2cache_enable ();
611#endif
612 printf ("BUS: %lu MHz\n", gd->bus_clk / 1000000);
613 printf ("MEM: %lu MHz\n", gd->mem_clk / 1000000);
614
615
616
617
618
619
620
621
622 printf ("CACHE: ");
623 switch (get_cpu_type()) {
624 case CPU_7447A:
625 printf ("L1 Instruction cache - 32KB 8-way");
626 (get_hid0 () & (1 << 15)) ? printf (" ENABLED\n") :
627 printf (" DISABLED\n");
628 printf ("L1 Data cache - 32KB 8-way");
629 (get_hid0 () & (1 << 14)) ? printf (" ENABLED\n") :
630 printf (" DISABLED\n");
631 printf ("Unified L2 cache - 512KB 8-way");
632 (get_l2cr () & (1 << 31)) ? printf (" ENABLED\n") :
633 printf (" DISABLED\n");
634 printf ("\n");
635 break;
636
637 case CPU_7448:
638 printf ("L1 Instruction cache - 32KB 8-way");
639 (get_hid0 () & (1 << 15)) ? printf (" ENABLED\n") :
640 printf (" DISABLED\n");
641 printf ("L1 Data cache - 32KB 8-way");
642 (get_hid0 () & (1 << 14)) ? printf (" ENABLED\n") :
643 printf (" DISABLED\n");
644 printf ("Unified L2 cache - 1MB 8-way");
645 (get_l2cr () & (1 << 31)) ? printf (" ENABLED\n") :
646 printf (" DISABLED\n");
647 break;
648 default:
649 break;
650 }
651 return 0;
652}
653