1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#include <common.h>
26#include <libfdt.h>
27#include <fdt_support.h>
28#include <ppc4xx.h>
29#include <asm/gpio.h>
30#include <asm/processor.h>
31#include <asm/io.h>
32#include <asm/bitops.h>
33
34DECLARE_GLOBAL_DATA_PTR;
35
36#if !defined(CONFIG_SYS_NO_FLASH)
37extern flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];
38#endif
39
40extern void __ft_board_setup(void *blob, bd_t *bd);
41ulong flash_get_size(ulong base, int banknum);
42
43static inline u32 get_async_pci_freq(void)
44{
45 if (in_8((void *)(CONFIG_SYS_BCSR_BASE + 5)) &
46 CONFIG_SYS_BCSR5_PCI66EN)
47 return 66666666;
48 else
49 return 33333333;
50}
51
52int board_early_init_f(void)
53{
54 u32 sdr0_cust0;
55 u32 sdr0_pfc1, sdr0_pfc2;
56 u32 reg;
57
58 mtdcr(EBC0_CFGADDR, EBC0_CFG);
59 mtdcr(EBC0_CFGDATA, 0xb8400000);
60
61
62
63
64 mtdcr(UIC0SR, 0xffffffff);
65 mtdcr(UIC0ER, 0x00000000);
66 mtdcr(UIC0CR, 0x00000005);
67 mtdcr(UIC0PR, 0xfffff7ff);
68 mtdcr(UIC0TR, 0x00000000);
69 mtdcr(UIC0VR, 0x00000000);
70 mtdcr(UIC0SR, 0xffffffff);
71
72 mtdcr(UIC1SR, 0xffffffff);
73 mtdcr(UIC1ER, 0x00000000);
74 mtdcr(UIC1CR, 0x00000000);
75 mtdcr(UIC1PR, 0xffffffff);
76 mtdcr(UIC1TR, 0x00000000);
77 mtdcr(UIC1VR, 0x00000000);
78 mtdcr(UIC1SR, 0xffffffff);
79
80 mtdcr(UIC2SR, 0xffffffff);
81 mtdcr(UIC2ER, 0x00000000);
82 mtdcr(UIC2CR, 0x00000000);
83 mtdcr(UIC2PR, 0xffffffff);
84 mtdcr(UIC2TR, 0x00000000);
85 mtdcr(UIC2VR, 0x00000000);
86 mtdcr(UIC2SR, 0xffffffff);
87
88
89 ppc4xx_pci_sync_clock_config(get_async_pci_freq());
90
91
92 out_8((u8 *) CONFIG_SYS_BCSR_BASE + 0x04, 0x00);
93
94
95 out_8((u8 *) CONFIG_SYS_BCSR_BASE + 0x07, 0x00);
96
97
98 out_8((u8 *) CONFIG_SYS_BCSR_BASE + 0x08, 0x00);
99
100
101 out_8((u8 *) CONFIG_SYS_BCSR_BASE + 0x09, 0x20);
102
103
104 mfsdr(SDR0_PFC1, sdr0_pfc1);
105 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_SELECT_MASK) |
106 SDR0_PFC1_SELECT_CONFIG_4;
107#ifdef CONFIG_I2C_MULTI_BUS
108 sdr0_pfc1 |= ((sdr0_pfc1 & ~SDR0_PFC1_SIS_MASK) | SDR0_PFC1_SIS_IIC1_SEL);
109#endif
110
111 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0IM_MASK) | SDR0_PFC1_U0IM_4PINS;
112 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0ME_MASK) | SDR0_PFC1_U0ME_CTS_RTS;
113 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U1ME_MASK) | SDR0_PFC1_U1ME_CTS_RTS;
114
115 mfsdr(SDR0_PFC2, sdr0_pfc2);
116 sdr0_pfc2 = (sdr0_pfc2 & ~SDR0_PFC2_SELECT_MASK) |
117 SDR0_PFC2_SELECT_CONFIG_4;
118 mtsdr(SDR0_PFC2, sdr0_pfc2);
119 mtsdr(SDR0_PFC1, sdr0_pfc1);
120
121
122 mfsdr(SDR0_PCI0, reg);
123 mtsdr(SDR0_PCI0, 0x80000000 | reg);
124
125
126 mfsdr(SDR0_CUST0, sdr0_cust0);
127 sdr0_cust0 = SDR0_CUST0_MUX_NDFC_SEL |
128 SDR0_CUST0_NDFC_ENABLE |
129 SDR0_CUST0_NDFC_BW_8_BIT |
130 SDR0_CUST0_NDFC_ARE_MASK |
131 (0x80000000 >> (28 + CONFIG_SYS_NAND_CS));
132 mtsdr(SDR0_CUST0, sdr0_cust0);
133
134 return 0;
135}
136
137int misc_init_r(void)
138{
139#if !defined(CONFIG_SYS_NO_FLASH)
140 uint pbcr;
141 int size_val = 0;
142#endif
143#ifdef CONFIG_440EPX
144 unsigned long usb2d0cr = 0;
145 unsigned long usb2phy0cr, usb2h0cr = 0;
146 unsigned long sdr0_pfc1;
147 char *act = getenv("usbact");
148#endif
149 u32 reg;
150
151#if !defined(CONFIG_SYS_NO_FLASH)
152
153
154
155 gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
156 gd->bd->bi_flashoffset = 0;
157
158#if defined(CONFIG_NAND_U_BOOT) || defined(CONFIG_NAND_SPL)
159 mtdcr(EBC0_CFGADDR, PB3CR);
160#else
161 mtdcr(EBC0_CFGADDR, PB0CR);
162#endif
163 pbcr = mfdcr(EBC0_CFGDATA);
164 size_val = ffs(gd->bd->bi_flashsize) - 21;
165 pbcr = (pbcr & 0x0001ffff) | gd->bd->bi_flashstart | (size_val << 17);
166#if defined(CONFIG_NAND_U_BOOT) || defined(CONFIG_NAND_SPL)
167 mtdcr(EBC0_CFGADDR, PB3CR);
168#else
169 mtdcr(EBC0_CFGADDR, PB0CR);
170#endif
171 mtdcr(EBC0_CFGDATA, pbcr);
172
173
174
175
176 flash_get_size(gd->bd->bi_flashstart, 0);
177
178#ifdef CONFIG_ENV_IS_IN_FLASH
179
180 (void)flash_protect(FLAG_PROTECT_SET,
181 -CONFIG_SYS_MONITOR_LEN,
182 0xffffffff,
183 &flash_info[0]);
184
185
186 (void)flash_protect(FLAG_PROTECT_SET,
187 CONFIG_ENV_ADDR_REDUND,
188 CONFIG_ENV_ADDR_REDUND + 2*CONFIG_ENV_SECT_SIZE - 1,
189 &flash_info[0]);
190#endif
191#endif
192
193
194
195
196#ifdef CONFIG_440EPX
197 if (act == NULL || strcmp(act, "hostdev") == 0) {
198
199 mfsdr(SDR0_PFC1, sdr0_pfc1);
200 mfsdr(SDR0_USB2D0CR, usb2d0cr);
201 mfsdr(SDR0_USB2PHY0CR, usb2phy0cr);
202 mfsdr(SDR0_USB2H0CR, usb2h0cr);
203
204 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_XOCLK_MASK;
205 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_XOCLK_EXTERNAL;
206 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_WDINT_MASK;
207 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_WDINT_16BIT_30MHZ;
208 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DVBUS_MASK;
209 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DVBUS_PURDIS;
210 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DWNSTR_MASK;
211 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DWNSTR_HOST;
212 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_UTMICN_MASK;
213 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_UTMICN_HOST;
214
215
216
217
218
219 usb2h0cr = usb2h0cr &~SDR0_USB2H0CR_WDINT_MASK;
220 usb2h0cr = usb2h0cr | SDR0_USB2H0CR_WDINT_16BIT_30MHZ;
221
222
223
224
225
226 usb2d0cr = usb2d0cr &~SDR0_USB2D0CR_USB2DEV_EBC_SEL_MASK;
227 usb2d0cr = usb2d0cr | SDR0_USB2D0CR_USB2DEV_SELECTION;
228
229 sdr0_pfc1 = sdr0_pfc1 &~SDR0_PFC1_UES_MASK;
230 sdr0_pfc1 = sdr0_pfc1 | SDR0_PFC1_UES_USB2D_SEL;
231
232 mtsdr(SDR0_PFC1, sdr0_pfc1);
233 mtsdr(SDR0_USB2D0CR, usb2d0cr);
234 mtsdr(SDR0_USB2PHY0CR, usb2phy0cr);
235 mtsdr(SDR0_USB2H0CR, usb2h0cr);
236
237
238 udelay (1000);
239 mtsdr(SDR0_SRST1, 0x00000000);
240 udelay (1000);
241 mtsdr(SDR0_SRST0, 0x00000000);
242
243 printf("USB: Host(int phy) Device(ext phy)\n");
244
245 } else if (strcmp(act, "dev") == 0) {
246
247 mfsdr(SDR0_USB2PHY0CR, usb2phy0cr);
248
249 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_XOCLK_MASK;
250 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_XOCLK_EXTERNAL;
251 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DVBUS_MASK;
252 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DVBUS_PURDIS;
253 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DWNSTR_MASK;
254 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DWNSTR_HOST;
255 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_UTMICN_MASK;
256 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_UTMICN_HOST;
257 mtsdr(SDR0_USB2PHY0CR, usb2phy0cr);
258
259 udelay (1000);
260 mtsdr(SDR0_SRST1, 0x672c6000);
261
262 udelay (1000);
263 mtsdr(SDR0_SRST0, 0x00000080);
264
265 udelay (1000);
266 mtsdr(SDR0_SRST1, 0x60206000);
267
268 *(unsigned int *)(0xe0000350) = 0x00000001;
269
270 udelay (1000);
271 mtsdr(SDR0_SRST1, 0x60306000);
272
273
274
275 mfsdr(SDR0_USB2PHY0CR, usb2phy0cr);
276 mfsdr(SDR0_USB2H0CR, usb2h0cr);
277 mfsdr(SDR0_USB2D0CR, usb2d0cr);
278 mfsdr(SDR0_PFC1, sdr0_pfc1);
279
280 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_XOCLK_MASK;
281 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_XOCLK_EXTERNAL;
282 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_WDINT_MASK;
283 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_WDINT_8BIT_60MHZ;
284 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DVBUS_MASK;
285 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DVBUS_PUREN;
286 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DWNSTR_MASK;
287 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DWNSTR_DEV;
288 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_UTMICN_MASK;
289 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_UTMICN_DEV;
290
291 usb2h0cr = usb2h0cr &~SDR0_USB2H0CR_WDINT_MASK;
292 usb2h0cr = usb2h0cr | SDR0_USB2H0CR_WDINT_8BIT_60MHZ;
293
294 usb2d0cr = usb2d0cr &~SDR0_USB2D0CR_USB2DEV_EBC_SEL_MASK;
295 usb2d0cr = usb2d0cr | SDR0_USB2D0CR_EBC_SELECTION;
296
297 sdr0_pfc1 = sdr0_pfc1 &~SDR0_PFC1_UES_MASK;
298 sdr0_pfc1 = sdr0_pfc1 | SDR0_PFC1_UES_EBCHR_SEL;
299
300 mtsdr(SDR0_USB2H0CR, usb2h0cr);
301 mtsdr(SDR0_USB2PHY0CR, usb2phy0cr);
302 mtsdr(SDR0_USB2D0CR, usb2d0cr);
303 mtsdr(SDR0_PFC1, sdr0_pfc1);
304
305
306 udelay (1000);
307 mtsdr(SDR0_SRST1, 0x00000000);
308 udelay (1000);
309 mtsdr(SDR0_SRST0, 0x00000000);
310
311 printf("USB: Device(int phy)\n");
312 }
313#endif
314
315 mfsdr(SDR0_SRST1, reg);
316 reg &= ~(SDR0_SRST1_CRYP0 | SDR0_SRST1_KASU0);
317 mtsdr(SDR0_SRST1, reg);
318
319
320
321
322
323
324 reg = mfdcr(PLB4_ACR) & ~PLB4_ACR_WRP;
325 mtdcr(PLB4_ACR, reg);
326
327 return 0;
328}
329
330int checkboard(void)
331{
332 char *s = getenv("serial#");
333 u8 rev;
334 u32 clock = get_async_pci_freq();
335
336#ifdef CONFIG_440EPX
337 printf("Board: Sequoia - AMCC PPC440EPx Evaluation Board");
338#else
339 printf("Board: Rainier - AMCC PPC440GRx Evaluation Board");
340#endif
341
342 rev = in_8((void *)(CONFIG_SYS_BCSR_BASE + 0));
343 printf(", Rev. %X, PCI-Async=%d MHz", rev, clock / 1000000);
344
345 if (s != NULL) {
346 puts(", serial# ");
347 puts(s);
348 }
349 putc('\n');
350
351
352
353
354
355 if (ppc4xx_pci_sync_clock_config(clock)) {
356 printf("ERROR: PCI clocking incorrect (async=%d "
357 "sync=%ld)!\n", clock, get_PCI_freq());
358 }
359
360 return (0);
361}
362
363#if defined(CONFIG_PCI) && defined(CONFIG_PCI_PNP)
364
365
366
367void sequoia_pci_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
368{
369 pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, VECNUM_EIRQ2);
370}
371#endif
372
373
374
375
376
377
378
379
380
381
382
383
384#if defined(CONFIG_PCI)
385int pci_pre_init(struct pci_controller *hose)
386{
387 unsigned long addr;
388
389
390
391
392
393 mfsdr(SD0_AMP1, addr);
394 mtsdr(SD0_AMP1, (addr & 0x000000FF) | 0x0000FF00);
395 addr = mfdcr(PLB3_ACR);
396 mtdcr(PLB3_ACR, addr | 0x80000000);
397
398
399
400
401 mfsdr(SD0_AMP0, addr);
402 mtsdr(SD0_AMP0, (addr & 0x000000FF) | 0x0000FF00);
403 addr = mfdcr(PLB4_ACR) | 0xa0000000;
404 mtdcr(PLB4_ACR, addr);
405
406
407
408
409
410 addr = (mfdcr(PLB0_ACR) & ~PLB0_ACR_PPM_MASK) | PLB0_ACR_PPM_FAIR;
411 addr = (addr & ~PLB0_ACR_HBU_MASK) | PLB0_ACR_HBU_ENABLED;
412 addr = (addr & ~PLB0_ACR_RDP_MASK) | PLB0_ACR_RDP_4DEEP;
413 addr = (addr & ~PLB0_ACR_WRP_MASK) | PLB0_ACR_WRP_2DEEP;
414 mtdcr(PLB0_ACR, addr);
415
416
417 addr = (mfdcr(PLB1_ACR) & ~PLB1_ACR_PPM_MASK) | PLB1_ACR_PPM_FAIR;
418 addr = (addr & ~PLB1_ACR_HBU_MASK) | PLB1_ACR_HBU_ENABLED;
419 addr = (addr & ~PLB1_ACR_RDP_MASK) | PLB1_ACR_RDP_4DEEP;
420 addr = (addr & ~PLB1_ACR_WRP_MASK) | PLB1_ACR_WRP_2DEEP;
421 mtdcr(PLB1_ACR, addr);
422
423#ifdef CONFIG_PCI_PNP
424 hose->fixup_irq = sequoia_pci_fixup_irq;
425#endif
426 return 1;
427}
428#endif
429
430
431
432
433
434
435
436
437#if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_TARGET_INIT)
438void pci_target_init(struct pci_controller *hose)
439{
440
441
442
443
444
445
446
447
448
449
450
451 out32r(PCIL0_PMM0MA, 0x00000000);
452
453 out32r(PCIL0_PMM0LA, CONFIG_SYS_PCI_MEMBASE);
454 out32r(PCIL0_PMM0PCILA, CONFIG_SYS_PCI_MEMBASE);
455 out32r(PCIL0_PMM0PCIHA, 0x00000000);
456 out32r(PCIL0_PMM0MA, 0xE0000001);
457
458
459 out32r(PCIL0_PMM1MA, 0x00000000);
460
461 out32r(PCIL0_PMM1LA, CONFIG_SYS_PCI_MEMBASE2);
462 out32r(PCIL0_PMM1PCILA, CONFIG_SYS_PCI_MEMBASE2);
463 out32r(PCIL0_PMM1PCIHA, 0x00000000);
464 out32r(PCIL0_PMM1MA, 0xE0000001);
465
466
467 out32r(PCIL0_PTM1MS, 0x00000001);
468 out32r(PCIL0_PTM1LA, 0);
469 out32r(PCIL0_PTM2MS, 0);
470 out32r(PCIL0_PTM2LA, 0);
471
472
473
474
475
476
477 pci_write_config_word(0, PCI_SUBSYSTEM_VENDOR_ID,
478 CONFIG_SYS_PCI_SUBSYS_VENDORID);
479 pci_write_config_word(0, PCI_SUBSYSTEM_ID, CONFIG_SYS_PCI_SUBSYS_ID);
480
481
482 pci_write_config_word(0, PCI_COMMAND, PCI_COMMAND_MASTER);
483
484
485 pci_write_config_word(0, PCI_LATENCY_TIMER, 1);
486
487
488 pci_write_config_word(0, PCI_ERREN, 0);
489
490 pci_write_config_dword(0, PCI_BRDGOPT2, 0x00000101);
491
492}
493#endif
494
495#if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT)
496void pci_master_init(struct pci_controller *hose)
497{
498 unsigned short temp_short;
499
500
501
502
503
504
505 pci_read_config_word(0, PCI_COMMAND, &temp_short);
506 pci_write_config_word(0, PCI_COMMAND,
507 temp_short | PCI_COMMAND_MASTER |
508 PCI_COMMAND_MEMORY);
509}
510#endif
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525#if defined(CONFIG_PCI)
526int is_pci_host(struct pci_controller *hose)
527{
528
529 return (1);
530}
531#endif
532
533#if defined(CONFIG_POST)
534
535
536
537
538int post_hotkeys_pressed(void)
539{
540 return 0;
541}
542#endif
543
544#if defined(CONFIG_NAND_U_BOOT) || defined(CONFIG_SYS_RAMBOOT)
545
546
547
548
549void ft_board_setup(void *blob, bd_t *bd)
550{
551 int rc;
552 int len;
553 int nodeoffset;
554 struct fdt_property *prop;
555 u32 *reg;
556 char path[32];
557
558
559 __ft_board_setup(blob, bd);
560
561
562 strcpy(path, "/plb/opb/ebc/nor_flash@0,0");
563 nodeoffset = fdt_path_offset(blob, path);
564 prop = fdt_get_property_w(blob, nodeoffset, "reg", &len);
565 if (prop == NULL) {
566 printf("Unable to update NOR chip select for NAND booting\n");
567 return;
568 }
569 reg = (u32 *)&prop->data[0];
570 reg[0] = 3;
571 rc = fdt_find_and_setprop(blob, path, "reg", reg, 3 * sizeof(u32), 1);
572 if (rc) {
573 printf("Unable to update property NOR mappings, err=%s\n",
574 fdt_strerror(rc));
575 return;
576 }
577
578
579 strcpy(path, "/plb/opb/ebc/ndfc@3,0");
580 nodeoffset = fdt_path_offset(blob, path);
581 prop = fdt_get_property_w(blob, nodeoffset, "reg", &len);
582 if (prop == NULL) {
583 printf("Unable to update NDFC chip select for NAND booting\n");
584 return;
585 }
586 reg = (u32 *)&prop->data[0];
587 reg[0] = 0;
588 rc = fdt_find_and_setprop(blob, path, "reg", reg, 3 * sizeof(u32), 1);
589 if (rc) {
590 printf("Unable to update property NDFC mappings, err=%s\n",
591 fdt_strerror(rc));
592 return;
593 }
594}
595#endif
596