3 * Larry Johnson, lrj@acm.org
6 * Stefan Roese, DENX Software Engineering, sr@denx.de.
9 * Jacqueline Pira-Ferriol, AMCC/IBM, jpira-ferriol@fr.ibm.com
10 * Alain Saurel, AMCC/IBM, alain.saurel@fr.ibm.com
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 #include <asm/processor.h>
30 #include <asm-ppc/io.h>
34 DECLARE_GLOBAL_DATA_PTR;
36 extern flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
38 ulong flash_get_size(ulong base, int banknum);
40 int board_early_init_f(void)
42 u32 sdr0_pfc1, sdr0_pfc2;
47 mtdcr(ebccfga, xbcfg);
48 mtdcr(ebccfgd, 0xb8400000);
50 /*--------------------------------------------------------------------
56 * Pin Source I/O value Function
57 * ------ ------ --- ----- ---------------------------------
58 * GPIO00 Alt1 I/O x PerAddr07
59 * GPIO01 Alt1 I/O x PerAddr06
60 * GPIO02 Alt1 I/O x PerAddr05
61 * GPIO03 GPIO x x GPIO03 to expansion bus connector
62 * GPIO04 GPIO x x GPIO04 to expansion bus connector
63 * GPIO05 GPIO x x GPIO05 to expansion bus connector
64 * GPIO06 Alt1 O x PerCS1 (2nd NOR flash)
65 * GPIO07 Alt1 O x PerCS2 (CPLD)
66 * GPIO08 Alt1 O x PerCS3 to expansion bus connector
67 * GPIO09 Alt1 O x PerCS4 to expansion bus connector
68 * GPIO10 Alt1 O x PerCS5 to expansion bus connector
69 * GPIO11 Alt1 I x PerErr
70 * GPIO12 GPIO O 0 ATMega !Reset
71 * GPIO13 GPIO O 1 SPI Atmega !SS
72 * GPIO14 GPIO O 1 Write protect EEPROM #1 (0xA8)
73 * GPIO15 GPIO O 0 CPU Run LED !On
74 * GPIO16 Alt1 O x GMC1TxD0
75 * GPIO17 Alt1 O x GMC1TxD1
76 * GPIO18 Alt1 O x GMC1TxD2
77 * GPIO19 Alt1 O x GMC1TxD3
78 * GPIO20 Alt1 O x RejectPkt0
79 * GPIO21 Alt1 O x RejectPkt1
80 * GPIO22 GPIO I x PGOOD_DDR
81 * GPIO23 Alt1 O x SCPD0
82 * GPIO24 Alt1 O x GMC0TxD2
83 * GPIO25 Alt1 O x GMC0TxD3
84 * GPIO26 GPIO? I/O x IIC0SDA (selected in SDR0_PFC4)
85 * GPIO27 GPIO O 0 PHY #0 1000BASE-X
86 * GPIO28 GPIO O 0 PHY #1 1000BASE-X
87 * GPIO29 GPIO I x Test jumper !Present
88 * GPIO30 GPIO I x SFP module #0 !Present
89 * GPIO31 GPIO I x SFP module #1 !Present
91 * GPIO32 GPIO O 1 SFP module #0 Tx !Enable
92 * GPIO33 GPIO O 1 SFP module #1 Tx !Enable
93 * GPIO34 Alt2 I x !UART1_CTS
94 * GPIO35 Alt2 O x !UART1_RTS
95 * GPIO36 Alt1 I x !UART0_CTS
96 * GPIO37 Alt1 O x !UART0_RTS
97 * GPIO38 Alt2 O x UART1_Tx
98 * GPIO39 Alt2 I x UART1_Rx
99 * GPIO40 Alt1 I x IRQ0 (Ethernet 0)
100 * GPIO41 Alt1 I x IRQ1 (Ethernet 1)
101 * GPIO42 Alt1 I x IRQ2 (PCI interrupt)
102 * GPIO43 Alt1 I x IRQ3 (System Alert from CPLD)
103 * GPIO44 xxxx x x (grounded through pulldown)
104 * GPIO45 GPIO O 0 PHY #0 Enable
105 * GPIO46 GPIO O 0 PHY #1 Enable
106 * GPIO47 GPIO I x Reset switch !Pressed
107 * GPIO48 GPIO I x Shutdown switch !Pressed
108 * GPIO49 xxxx x x (reserved for trace port)
112 * GPIO63 xxxx x x (reserved for trace port)
113 *-------------------------------------------------------------------*/
115 out_be32((u32 *) GPIO0_OR, 0x00060000);
116 out_be32((u32 *) GPIO1_OR, 0xC0000000);
118 out_be32((u32 *) GPIO0_OSRL, 0x54055400);
119 out_be32((u32 *) GPIO0_OSRH, 0x55015000);
120 out_be32((u32 *) GPIO1_OSRL, 0x02180000);
121 out_be32((u32 *) GPIO1_OSRH, 0x00000000);
123 out_be32((u32 *) GPIO0_TSRL, 0x54055500);
124 out_be32((u32 *) GPIO0_TSRH, 0x00015000);
125 out_be32((u32 *) GPIO1_TSRL, 0x00000000);
126 out_be32((u32 *) GPIO1_TSRH, 0x00000000);
128 out_be32((u32 *) GPIO0_TCR, 0x000FF0D8);
129 out_be32((u32 *) GPIO1_TCR, 0xD6060000);
131 out_be32((u32 *) GPIO0_ISR1L, 0x54000100);
132 out_be32((u32 *) GPIO0_ISR1H, 0x00500000);
133 out_be32((u32 *) GPIO1_ISR1L, 0x00405500);
134 out_be32((u32 *) GPIO1_ISR1H, 0x00000000);
136 out_be32((u32 *) GPIO0_ISR2L, 0x00000000);
137 out_be32((u32 *) GPIO0_ISR2H, 0x00000000);
138 out_be32((u32 *) GPIO1_ISR2L, 0x04010000);
139 out_be32((u32 *) GPIO1_ISR2H, 0x00000000);
141 out_be32((u32 *) GPIO0_ISR3L, 0x00000000);
142 out_be32((u32 *) GPIO0_ISR3H, 0x00000000);
143 out_be32((u32 *) GPIO1_ISR3L, 0x00000000);
144 out_be32((u32 *) GPIO1_ISR3H, 0x00000000);
146 /*--------------------------------------------------------------------
147 * Setup the interrupt controller polarities, triggers, etc.
148 *-------------------------------------------------------------------*/
149 mtdcr(uic0sr, 0xffffffff); /* clear all */
150 mtdcr(uic0er, 0x00000000); /* disable all */
151 mtdcr(uic0cr, 0x00000005); /* ATI & UIC1 crit are critical */
152 mtdcr(uic0pr, 0xfffff7ff); /* per ref-board manual */
153 mtdcr(uic0tr, 0x00000000); /* per ref-board manual */
154 mtdcr(uic0vr, 0x00000000); /* int31 highest, base=0x000 */
155 mtdcr(uic0sr, 0xffffffff); /* clear all */
157 mtdcr(uic1sr, 0xffffffff); /* clear all */
158 mtdcr(uic1er, 0x00000000); /* disable all */
159 mtdcr(uic1cr, 0x00000000); /* all non-critical */
160 mtdcr(uic1pr, 0xffffffff); /* per ref-board manual */
161 mtdcr(uic1tr, 0x00000000); /* per ref-board manual */
162 mtdcr(uic1vr, 0x00000000); /* int31 highest, base=0x000 */
163 mtdcr(uic1sr, 0xffffffff); /* clear all */
165 mtdcr(uic2sr, 0xffffffff); /* clear all */
166 mtdcr(uic2er, 0x00000000); /* disable all */
167 mtdcr(uic2cr, 0x00000000); /* all non-critical */
168 mtdcr(uic2pr, 0xffffffff); /* per ref-board manual */
169 mtdcr(uic2tr, 0x00000000); /* per ref-board manual */
170 mtdcr(uic2vr, 0x00000000); /* int31 highest, base=0x000 */
171 mtdcr(uic2sr, 0xffffffff); /* clear all */
173 /* take sim card reader and CF controller out of reset */
174 out_8((u8 *) CFG_CPLD_BASE + 0x04, 0x80);
176 /* Configure the two Ethernet PHYs. For each PHY, configure for fiber
177 * if the SFP module is present, and for copper if it is not present.
179 gpio0_ir = in_be32((u32 *) GPIO0_IR);
180 for (eth = 0; eth < 2; ++eth) {
181 if (gpio0_ir & (0x00000001 << (1 - eth))) {
182 /* SFP module not present: configure PHY for copper. */
183 /* Set PHY to autonegotate 10 MB, 100MB, or 1 GB */
184 out_8((u8 *) CFG_CPLD_BASE + 0x06,
185 in_8((u8 *) CFG_CPLD_BASE + 0x06) |
188 /* SFP module present: configure PHY for fiber and
190 out_be32((u32 *) GPIO0_OR, in_be32((u32 *) GPIO0_OR) |
191 (0x00000001 << (4 - eth)));
192 out_be32((u32 *) GPIO1_OR, in_be32((u32 *) GPIO1_OR) &
193 ~(0x00000001 << (31 - eth)));
196 /* enable Ethernet: set GPIO45 and GPIO46 to 1 */
197 out_be32((u32 *) GPIO1_OR, in_be32((u32 *) GPIO1_OR) | 0x00060000);
199 /* select Ethernet pins */
200 mfsdr(SDR0_PFC1, sdr0_pfc1);
201 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_SELECT_MASK) |
202 SDR0_PFC1_SELECT_CONFIG_4;
203 mfsdr(SDR0_PFC2, sdr0_pfc2);
204 sdr0_pfc2 = (sdr0_pfc2 & ~SDR0_PFC2_SELECT_MASK) |
205 SDR0_PFC2_SELECT_CONFIG_4;
206 mtsdr(SDR0_PFC2, sdr0_pfc2);
207 mtsdr(SDR0_PFC1, sdr0_pfc1);
209 /* PCI arbiter enabled */
210 mfsdr(sdr_pci0, reg);
211 mtsdr(sdr_pci0, 0x80000000 | reg);
216 static int man_data_read(unsigned int addr)
219 * Read an octet of data from address "addr" in the manufacturer's
220 * information serial EEPROM, or -1 on error.
224 if (0 != i2c_probe(MAN_DATA_EEPROM_ADDR) ||
225 0 != i2c_read(MAN_DATA_EEPROM_ADDR, addr, 1, data, 1)) {
226 debug("man_data_read(0x%02X) failed\n", addr);
229 debug("man_info_read(0x%02X) returned 0x%02X\n", addr, data[0]);
233 static unsigned int man_data_field_addr(unsigned int const field)
236 * The manufacturer's information serial EEPROM contains a sequence of
237 * zero-delimited fields. Return the starting address of field "field",
242 if (0 == field || 'A' != man_data_read(0) || '\0' != man_data_read(1))
243 /* Only format "A" is currently supported */
246 for (addr = 2, i = 1; i < field && addr < 256; ++addr) {
247 if ('\0' == man_data_read(addr))
250 return (addr < 256) ? addr : 0;
253 static char *man_data_read_field(char s[], unsigned const field,
254 unsigned const length)
257 * Place the null-terminated contents of field "field" of length
258 * "length" from the manufacturer's information serial EEPROM into
259 * string "s[length + 1]" and return a pointer to s, or return 0 on
260 * error. In either case the original contents of s[] is not preserved.
264 addr = man_data_field_addr(field);
265 if (0 == addr || addr + length >= 255)
268 for (i = 0; i < length; ++i) {
269 int const c = man_data_read(addr++);
276 if (0 != man_data_read(addr))
283 static void set_serial_number(void)
286 * If the environmental variable "serial#" is not set, try to set it
287 * from the manufacturer's information serial EEPROM.
289 char s[MAN_SERIAL_NO_LENGTH + 1];
291 if (0 == getenv("serial#") &&
292 0 != man_data_read_field(s, MAN_SERIAL_NO_FIELD,
293 MAN_SERIAL_NO_LENGTH))
294 setenv("serial#", s);
297 static void set_mac_addresses(void)
300 * If the environmental variables "ethaddr" and/or "eth1addr" are not
301 * set, try to set them from the manufacturer's information serial
304 char s[MAN_MAC_ADDR_LENGTH + 1];
306 if (0 != getenv("ethaddr") && 0 != getenv("eth1addr"))
309 if (0 == man_data_read_field(s, MAN_MAC_ADDR_FIELD,
310 MAN_MAC_ADDR_LENGTH))
313 if (0 == getenv("ethaddr"))
314 setenv("ethaddr", s);
316 if (0 == getenv("eth1addr")) {
317 ++s[MAN_MAC_ADDR_LENGTH - 1];
318 setenv("eth1addr", s);
322 /*---------------------------------------------------------------------------+
324 +---------------------------------------------------------------------------*/
325 int misc_init_r(void)
330 unsigned long usb2d0cr = 0;
331 unsigned long usb2phy0cr, usb2h0cr = 0;
332 unsigned long sdr0_pfc1;
333 char *act = getenv("usbact");
339 /* Re-do sizing to get full correct info */
341 /* adjust flash start and offset */
342 gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
343 gd->bd->bi_flashoffset = 0;
345 mtdcr(ebccfga, pb0cr);
346 pbcr = mfdcr(ebccfgd);
347 switch (gd->bd->bi_flashsize) {
373 pbcr = (pbcr & 0x0001ffff) | gd->bd->bi_flashstart | (size_val << 17);
374 mtdcr(ebccfga, pb0cr);
375 mtdcr(ebccfgd, pbcr);
378 * Re-check to get correct base address
380 flash_get_size(gd->bd->bi_flashstart, 0);
382 /* Monitor protection ON by default */
383 (void)flash_protect(FLAG_PROTECT_SET, -CFG_MONITOR_LEN, 0xffffffff,
386 /* Env protection ON by default */
387 (void)flash_protect(FLAG_PROTECT_SET,
389 CFG_ENV_ADDR_REDUND + 2 * CFG_ENV_SECT_SIZE - 1,
395 if (act == NULL || strcmp(act, "hostdev") == 0) {
397 mfsdr(SDR0_PFC1, sdr0_pfc1);
398 mfsdr(SDR0_USB2D0CR, usb2d0cr);
399 mfsdr(SDR0_USB2PHY0CR, usb2phy0cr);
400 mfsdr(SDR0_USB2H0CR, usb2h0cr);
402 usb2phy0cr = usb2phy0cr & ~SDR0_USB2PHY0CR_XOCLK_MASK;
403 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_XOCLK_EXTERNAL; /*0 */
404 usb2phy0cr = usb2phy0cr & ~SDR0_USB2PHY0CR_WDINT_MASK;
405 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_WDINT_16BIT_30MHZ; /*1 */
406 usb2phy0cr = usb2phy0cr & ~SDR0_USB2PHY0CR_DVBUS_MASK;
407 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DVBUS_PURDIS; /*0 */
408 usb2phy0cr = usb2phy0cr & ~SDR0_USB2PHY0CR_DWNSTR_MASK;
409 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DWNSTR_HOST; /*1 */
410 usb2phy0cr = usb2phy0cr & ~SDR0_USB2PHY0CR_UTMICN_MASK;
411 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_UTMICN_HOST; /*1 */
413 /* An 8-bit/60MHz interface is the only possible alternative
414 when connecting the Device to the PHY */
415 usb2h0cr = usb2h0cr & ~SDR0_USB2H0CR_WDINT_MASK;
416 usb2h0cr = usb2h0cr | SDR0_USB2H0CR_WDINT_16BIT_30MHZ; /*1 */
418 /* To enable the USB 2.0 Device function through the UTMI interface */
419 usb2d0cr = usb2d0cr & ~SDR0_USB2D0CR_USB2DEV_EBC_SEL_MASK;
420 usb2d0cr = usb2d0cr | SDR0_USB2D0CR_USB2DEV_SELECTION; /*1 */
422 sdr0_pfc1 = sdr0_pfc1 & ~SDR0_PFC1_UES_MASK;
423 sdr0_pfc1 = sdr0_pfc1 | SDR0_PFC1_UES_USB2D_SEL; /*0 */
425 mtsdr(SDR0_PFC1, sdr0_pfc1);
426 mtsdr(SDR0_USB2D0CR, usb2d0cr);
427 mtsdr(SDR0_USB2PHY0CR, usb2phy0cr);
428 mtsdr(SDR0_USB2H0CR, usb2h0cr);
432 mtsdr(SDR0_SRST1, 0x00000000);
434 mtsdr(SDR0_SRST0, 0x00000000);
436 printf("USB: Host(int phy) Device(ext phy)\n");
438 } else if (strcmp(act, "dev") == 0) {
439 /*-------------------PATCH-------------------------------*/
440 mfsdr(SDR0_USB2PHY0CR, usb2phy0cr);
442 usb2phy0cr = usb2phy0cr & ~SDR0_USB2PHY0CR_XOCLK_MASK;
443 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_XOCLK_EXTERNAL; /*0 */
444 usb2phy0cr = usb2phy0cr & ~SDR0_USB2PHY0CR_DVBUS_MASK;
445 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DVBUS_PURDIS; /*0 */
446 usb2phy0cr = usb2phy0cr & ~SDR0_USB2PHY0CR_DWNSTR_MASK;
447 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DWNSTR_HOST; /*1 */
448 usb2phy0cr = usb2phy0cr & ~SDR0_USB2PHY0CR_UTMICN_MASK;
449 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_UTMICN_HOST; /*1 */
450 mtsdr(SDR0_USB2PHY0CR, usb2phy0cr);
453 mtsdr(SDR0_SRST1, 0x672c6000);
456 mtsdr(SDR0_SRST0, 0x00000080);
459 mtsdr(SDR0_SRST1, 0x60206000);
461 *(unsigned int *)(0xe0000350) = 0x00000001;
464 mtsdr(SDR0_SRST1, 0x60306000);
465 /*-------------------PATCH-------------------------------*/
468 mfsdr(SDR0_USB2PHY0CR, usb2phy0cr);
469 mfsdr(SDR0_USB2H0CR, usb2h0cr);
470 mfsdr(SDR0_USB2D0CR, usb2d0cr);
471 mfsdr(SDR0_PFC1, sdr0_pfc1);
473 usb2phy0cr = usb2phy0cr & ~SDR0_USB2PHY0CR_XOCLK_MASK;
474 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_XOCLK_EXTERNAL; /*0 */
475 usb2phy0cr = usb2phy0cr & ~SDR0_USB2PHY0CR_WDINT_MASK;
476 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_WDINT_8BIT_60MHZ; /*0 */
477 usb2phy0cr = usb2phy0cr & ~SDR0_USB2PHY0CR_DVBUS_MASK;
478 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DVBUS_PUREN; /*1 */
479 usb2phy0cr = usb2phy0cr & ~SDR0_USB2PHY0CR_DWNSTR_MASK;
480 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DWNSTR_DEV; /*0 */
481 usb2phy0cr = usb2phy0cr & ~SDR0_USB2PHY0CR_UTMICN_MASK;
482 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_UTMICN_DEV; /*0 */
484 usb2h0cr = usb2h0cr & ~SDR0_USB2H0CR_WDINT_MASK;
485 usb2h0cr = usb2h0cr | SDR0_USB2H0CR_WDINT_8BIT_60MHZ; /*0 */
487 usb2d0cr = usb2d0cr & ~SDR0_USB2D0CR_USB2DEV_EBC_SEL_MASK;
488 usb2d0cr = usb2d0cr | SDR0_USB2D0CR_EBC_SELECTION; /*0 */
490 sdr0_pfc1 = sdr0_pfc1 & ~SDR0_PFC1_UES_MASK;
491 sdr0_pfc1 = sdr0_pfc1 | SDR0_PFC1_UES_EBCHR_SEL; /*1 */
493 mtsdr(SDR0_USB2H0CR, usb2h0cr);
494 mtsdr(SDR0_USB2PHY0CR, usb2phy0cr);
495 mtsdr(SDR0_USB2D0CR, usb2d0cr);
496 mtsdr(SDR0_PFC1, sdr0_pfc1);
500 mtsdr(SDR0_SRST1, 0x00000000);
502 mtsdr(SDR0_SRST0, 0x00000000);
504 printf("USB: Device(int phy)\n");
507 mfsdr(SDR0_SRST1, reg); /* enable security/kasumi engines */
508 reg &= ~(SDR0_SRST1_CRYP0 | SDR0_SRST1_KASU0);
509 mtsdr(SDR0_SRST1, reg);
512 * Clear PLB4A0_ACR[WRP]
513 * This fix will make the MAL burst disabling patch for the Linux
514 * EMAC driver obsolete.
516 reg = mfdcr(plb4_acr) & ~PLB4_ACR_WRP;
517 mtdcr(plb4_acr, reg);
526 char const *const s = getenv("serial#");
527 u8 const rev = in_8((u8 *) CFG_CPLD_BASE + 0);
528 u32 const gpio0_or = in_be32((u32 *) GPIO0_OR);
530 printf("Board: Korat, Rev. %X", rev);
532 printf(", serial# %s", s);
534 printf(", Ethernet PHY 0: ");
535 if (gpio0_or & 0x00000010)
541 if (gpio0_or & 0x00000008)
550 #if defined(CFG_DRAM_TEST)
553 unsigned long *mem = (unsigned long *)0;
554 const unsigned long kend = (1024 / sizeof(unsigned long));
559 /* TODO: find correct size of SDRAM */
560 for (k = 0; k < CFG_MBYTES_SDRAM;
561 ++k, mem += (1024 / sizeof(unsigned long))) {
563 printf("%3d MB\r", k / 1024);
565 memset(mem, 0xaaaaaaaa, 1024);
566 for (n = 0; n < kend; ++n) {
567 if (mem[n] != 0xaaaaaaaa) {
568 printf("SDRAM test fails at: %08x\n",
574 memset(mem, 0x55555555, 1024);
575 for (n = 0; n < kend; ++n) {
576 if (mem[n] != 0x55555555) {
577 printf("SDRAM test fails at: %08x\n",
583 printf("SDRAM test passes\n");
586 #endif /* defined(CFG_DRAM_TEST) */
588 /*************************************************************************
591 * This routine is called just prior to registering the hose and gives
592 * the board the opportunity to check things. Returning a value of zero
593 * indicates that things are bad & PCI initialization should be aborted.
595 * Different boards may wish to customize the pci controller structure
596 * (add regions, override default access routines, etc) or perform
597 * certain pre-initialization actions.
599 ************************************************************************/
600 #if defined(CONFIG_PCI)
601 int pci_pre_init(struct pci_controller *hose)
605 /*-------------------------------------------------------------------------+
606 | Set priority for all PLB3 devices to 0.
607 | Set PLB3 arbiter to fair mode.
608 +-------------------------------------------------------------------------*/
609 mfsdr(sdr_amp1, addr);
610 mtsdr(sdr_amp1, (addr & 0x000000FF) | 0x0000FF00);
611 addr = mfdcr(plb3_acr);
612 mtdcr(plb3_acr, addr | 0x80000000);
614 /*-------------------------------------------------------------------------+
615 | Set priority for all PLB4 devices to 0.
616 +-------------------------------------------------------------------------*/
617 mfsdr(sdr_amp0, addr);
618 mtsdr(sdr_amp0, (addr & 0x000000FF) | 0x0000FF00);
619 addr = mfdcr(plb4_acr) | 0xa0000000; /* Was 0x8---- */
620 mtdcr(plb4_acr, addr);
622 /*-------------------------------------------------------------------------+
623 | Set Nebula PLB4 arbiter to fair mode.
624 +-------------------------------------------------------------------------*/
626 addr = (mfdcr(plb0_acr) & ~plb0_acr_ppm_mask) | plb0_acr_ppm_fair;
627 addr = (addr & ~plb0_acr_hbu_mask) | plb0_acr_hbu_enabled;
628 addr = (addr & ~plb0_acr_rdp_mask) | plb0_acr_rdp_4deep;
629 addr = (addr & ~plb0_acr_wrp_mask) | plb0_acr_wrp_2deep;
630 mtdcr(plb0_acr, addr);
633 addr = (mfdcr(plb1_acr) & ~plb1_acr_ppm_mask) | plb1_acr_ppm_fair;
634 addr = (addr & ~plb1_acr_hbu_mask) | plb1_acr_hbu_enabled;
635 addr = (addr & ~plb1_acr_rdp_mask) | plb1_acr_rdp_4deep;
636 addr = (addr & ~plb1_acr_wrp_mask) | plb1_acr_wrp_2deep;
637 mtdcr(plb1_acr, addr);
641 #endif /* defined(CONFIG_PCI) */
643 /*************************************************************************
646 * The bootstrap configuration provides default settings for the pci
647 * inbound map (PIM). But the bootstrap config choices are limited and
648 * may not be sufficient for a given board.
650 ************************************************************************/
651 #if defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT)
652 void pci_target_init(struct pci_controller *hose)
654 /*--------------------------------------------------------------------------+
655 * Set up Direct MMIO registers
656 *--------------------------------------------------------------------------*/
657 /*--------------------------------------------------------------------------+
658 | PowerPC440EPX PCI Master configuration.
659 | Map one 1Gig range of PLB/processor addresses to PCI memory space.
660 | PLB address 0xA0000000-0xDFFFFFFF ==> PCI address 0xA0000000-0xDFFFFFFF
661 | Use byte reversed out routines to handle endianess.
662 | Make this region non-prefetchable.
663 +--------------------------------------------------------------------------*/
664 out32r(PCIX0_PMM0MA, 0x00000000); /* PMM0 Mask/Attribute - disabled b4 setting */
665 out32r(PCIX0_PMM0LA, CFG_PCI_MEMBASE); /* PMM0 Local Address */
666 out32r(PCIX0_PMM0PCILA, CFG_PCI_MEMBASE); /* PMM0 PCI Low Address */
667 out32r(PCIX0_PMM0PCIHA, 0x00000000); /* PMM0 PCI High Address */
668 out32r(PCIX0_PMM0MA, 0xE0000001); /* 512M + No prefetching, and enable region */
670 out32r(PCIX0_PMM1MA, 0x00000000); /* PMM0 Mask/Attribute - disabled b4 setting */
671 out32r(PCIX0_PMM1LA, CFG_PCI_MEMBASE2); /* PMM0 Local Address */
672 out32r(PCIX0_PMM1PCILA, CFG_PCI_MEMBASE2); /* PMM0 PCI Low Address */
673 out32r(PCIX0_PMM1PCIHA, 0x00000000); /* PMM0 PCI High Address */
674 out32r(PCIX0_PMM1MA, 0xE0000001); /* 512M + No prefetching, and enable region */
676 out32r(PCIX0_PTM1MS, 0x00000001); /* Memory Size/Attribute */
677 out32r(PCIX0_PTM1LA, 0); /* Local Addr. Reg */
678 out32r(PCIX0_PTM2MS, 0); /* Memory Size/Attribute */
679 out32r(PCIX0_PTM2LA, 0); /* Local Addr. Reg */
681 /*--------------------------------------------------------------------------+
682 * Set up Configuration registers
683 *--------------------------------------------------------------------------*/
685 /* Program the board's subsystem id/vendor id */
686 pci_write_config_word(0, PCI_SUBSYSTEM_VENDOR_ID,
687 CFG_PCI_SUBSYS_VENDORID);
688 pci_write_config_word(0, PCI_SUBSYSTEM_ID, CFG_PCI_SUBSYS_ID);
690 /* Configure command register as bus master */
691 pci_write_config_word(0, PCI_COMMAND, PCI_COMMAND_MASTER);
693 /* 240nS PCI clock */
694 pci_write_config_word(0, PCI_LATENCY_TIMER, 1);
696 /* No error reporting */
697 pci_write_config_word(0, PCI_ERREN, 0);
699 pci_write_config_dword(0, PCI_BRDGOPT2, 0x00000101);
701 /*--------------------------------------------------------------------------+
702 * Set up Configuration registers for on-board NEC uPD720101 USB controller
703 *--------------------------------------------------------------------------*/
704 pci_write_config_dword(PCI_BDF(0x0, 0xC, 0x0), 0xE4, 0x00000020);
706 #endif /* defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT) */
708 /*************************************************************************
711 ************************************************************************/
712 #if defined(CONFIG_PCI) && defined(CFG_PCI_MASTER_INIT)
713 void pci_master_init(struct pci_controller *hose)
715 unsigned short temp_short;
717 /*--------------------------------------------------------------------------+
718 | Write the PowerPC440 EP PCI Configuration regs.
719 | Enable PowerPC440 EP to be a master on the PCI bus (PMM).
720 | Enable PowerPC440 EP to act as a PCI memory target (PTM).
721 +--------------------------------------------------------------------------*/
722 pci_read_config_word(0, PCI_COMMAND, &temp_short);
723 pci_write_config_word(0, PCI_COMMAND,
724 temp_short | PCI_COMMAND_MASTER |
729 /*************************************************************************
732 * This routine is called to determine if a pci scan should be
733 * performed. With various hardware environments (especially cPCI and
734 * PPMC) it's insufficient to depend on the state of the arbiter enable
735 * bit in the strap register, or generic host/adapter assumptions.
737 * Rather than hard-code a bad assumption in the general 440 code, the
738 * 440 pci code requires the board to decide at runtime.
740 * Return 0 for adapter mode, non-zero for host (monarch) mode.
743 ************************************************************************/
744 #if defined(CONFIG_PCI)
745 int is_pci_host(struct pci_controller *hose)
747 /* Korat is always configured as host. */
752 #if defined(CONFIG_POST)
754 * Returns 1 if keys pressed to start the power-on long-running tests
755 * Called from board_init_f().
757 int post_hotkeys_pressed(void)
759 return 0; /* No hotkeys supported */