2 * (C) Copyright 2005-2007
5 * SPDX-License-Identifier: GPL-2.0+
9 #include <asm/processor.h>
10 #include <asm/ppc4xx-gpio.h>
11 #include <spd_sdram.h>
12 #include <asm/ppc440.h>
15 void ext_bus_cntlr_init(void);
16 void configure_ppc440ep_pins(void);
17 int is_nand_selected(void);
19 /*************************************************************************
21 * Bamboo has one bank onboard sdram (plus DIMM)
23 * Fixed memory is composed of :
24 * MT46V16M16TG-75 from Micron (x 2), 256Mb, 16 M x16, DDR266,
25 * 13 row add bits, 10 column add bits (but 12 row used only).
26 * ECC device: MT46V16M8TG-75 from Micron (x 1), 128Mb, x8, DDR266,
27 * 12 row add bits, 10 column add bits.
28 * Prepare a subset (only the used ones) of SPD data
30 * Note : if the ECC is enabled (SDRAM_ECC_ENABLE) the size of
31 * the corresponding bank is divided by 2 due to number of Row addresses
32 * 12 in the ECC module
34 * Assumes: 64 MB, ECC, non-registered
37 ************************************************************************/
38 const unsigned char cfg_simulate_spd_eeprom[128] = {
39 0x80, /* number of SPD bytes used: 128 */
40 0x08, /* total number bytes in SPD device = 256 */
43 0x0C, /* num Row Addr: 12 */
45 0x0D, /* num Row Addr: 13 */
47 0x09, /* numColAddr: 9 */
48 0x01, /* numBanks: 1 */
49 0x20, /* Module data width: 32 bits */
50 0x00, /* Module data width continued: +0 */
52 0x75, /* SDRAM Cycle Time (cas latency 2.5) = 7.5 ns */
53 0x00, /* SDRAM Access from clock */
55 0x02, /* ECC ON : 02 OFF : 00 */
57 0x00, /* ECC ON : 02 OFF : 00 */
59 0x82, /* refresh Rate Type: Normal (7.8us) + Self refresh */
65 0x0C, /* casBit (2,2.5) */
68 0x00, /* not registered: 0 registered : 0x02*/
70 0xA0, /* SDRAM Cycle Time (cas latency 2) = 10 ns */
72 0x00, /* SDRAM Cycle Time (cas latency 1.5) = N.A */
74 0x50, /* tRpNs = 20 ns */
76 0x50, /* tRcdNs = 20 ns */
79 0x08, /* bankSizeID: 32MB */
81 0x10, /* bankSizeID: 64MB */
182 { /* GPIO Alternate1 Alternate2 Alternate3 */
185 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_0 -> EBC_ADDR(7) DMA_REQ(2) */
186 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_1 -> EBC_ADDR(6) DMA_ACK(2) */
187 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_2 -> EBC_ADDR(5) DMA_EOT/TC(2) */
188 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_3 -> EBC_ADDR(4) DMA_REQ(3) */
189 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_4 -> EBC_ADDR(3) DMA_ACK(3) */
190 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_5 ................. */
191 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_6 -> EBC_CS_N(1) */
192 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_7 -> EBC_CS_N(2) */
193 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_8 -> EBC_CS_N(3) */
194 { GPIO0_BASE, GPIO_DIS, GPIO_ALT1 }, /* GPIO0_9 -> EBC_CS_N(4) */
195 { GPIO0_BASE, GPIO_OUT, GPIO_ALT1 }, /* GPIO0_10 -> EBC_CS_N(5) */
196 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_11 -> EBC_BUS_ERR */
197 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_12 -> ZII_p0Rxd(0) */
198 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_13 -> ZII_p0Rxd(1) */
199 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_14 -> ZII_p0Rxd(2) */
200 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_15 -> ZII_p0Rxd(3) */
201 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_16 -> ZII_p0Txd(0) */
202 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_17 -> ZII_p0Txd(1) */
203 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_18 -> ZII_p0Txd(2) */
204 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_19 -> ZII_p0Txd(3) */
205 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_20 -> ZII_p0Rx_er */
206 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_21 -> ZII_p0Rx_dv */
207 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_22 -> ZII_p0RxCrs */
208 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_23 -> ZII_p0Tx_er */
209 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_24 -> ZII_p0Tx_en */
210 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_25 -> ZII_p0Col */
211 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_26 -> USB2D_RXVALID */
212 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_27 -> EXT_EBC_REQ USB2D_RXERROR */
213 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_28 -> USB2D_TXVALID */
214 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_29 -> EBC_EXT_HDLA USB2D_PAD_SUSPNDM */
215 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_30 -> EBC_EXT_ACK USB2D_XCVRSELECT */
216 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_31 -> EBC_EXR_BUSREQ USB2D_TERMSELECT */
220 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_0 -> USB2D_OPMODE0 */
221 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_1 -> USB2D_OPMODE1 */
222 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_2 -> UART0_DCD_N UART1_DSR_CTS_N UART2_SOUT */
223 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_3 -> UART0_8PIN_DSR_N UART1_RTS_DTR_N UART2_SIN */
224 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_4 -> UART0_8PIN_CTS_N UART3_SIN */
225 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_5 -> UART0_RTS_N */
226 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_6 -> UART0_DTR_N UART1_SOUT */
227 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_7 -> UART0_RI_N UART1_SIN */
228 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_8 -> UIC_IRQ(0) */
229 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_9 -> UIC_IRQ(1) */
230 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_10 -> UIC_IRQ(2) */
231 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_11 -> UIC_IRQ(3) */
232 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_12 -> UIC_IRQ(4) DMA_ACK(1) */
233 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_13 -> UIC_IRQ(6) DMA_EOT/TC(1) */
234 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_14 -> UIC_IRQ(7) DMA_REQ(0) */
235 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_15 -> UIC_IRQ(8) DMA_ACK(0) */
236 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_16 -> UIC_IRQ(9) DMA_EOT/TC(0) */
237 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_17 -> - */
238 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_18 -> | */
239 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_19 -> | */
240 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_20 -> | */
241 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_21 -> | */
242 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_22 -> | */
243 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_23 -> \ Can be unselected thru TraceSelect Bit */
244 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_24 -> / in PowerPC440EP Chip */
245 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_25 -> | */
246 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_26 -> | */
247 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_27 -> | */
248 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_28 -> | */
249 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_29 -> | */
250 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_30 -> | */
251 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_31 -> - */
256 /*----------------------------------------------------------------------------+
257 | EBC Devices Characteristics
258 | Peripheral Bank Access Parameters - EBC0_BnAP
259 | Peripheral Bank Configuration Register - EBC0_BnCR
260 +----------------------------------------------------------------------------*/
262 #define EBC0_BNAP_SMALL_FLASH \
263 EBC0_BNAP_BME_DISABLED | \
264 EBC0_BNAP_TWT_ENCODE(6) | \
265 EBC0_BNAP_CSN_ENCODE(0) | \
266 EBC0_BNAP_OEN_ENCODE(1) | \
267 EBC0_BNAP_WBN_ENCODE(1) | \
268 EBC0_BNAP_WBF_ENCODE(3) | \
269 EBC0_BNAP_TH_ENCODE(1) | \
270 EBC0_BNAP_RE_ENABLED | \
271 EBC0_BNAP_SOR_DELAYED | \
272 EBC0_BNAP_BEM_WRITEONLY | \
273 EBC0_BNAP_PEN_DISABLED
275 #define EBC0_BNCR_SMALL_FLASH_CS0 \
276 EBC0_BNCR_BAS_ENCODE(0xFFF00000) | \
281 #define EBC0_BNCR_SMALL_FLASH_CS4 \
282 EBC0_BNCR_BAS_ENCODE(0x87F00000) | \
287 /* Large Flash or SRAM */
288 #define EBC0_BNAP_LARGE_FLASH_OR_SRAM \
289 EBC0_BNAP_BME_DISABLED | \
290 EBC0_BNAP_TWT_ENCODE(8) | \
291 EBC0_BNAP_CSN_ENCODE(0) | \
292 EBC0_BNAP_OEN_ENCODE(1) | \
293 EBC0_BNAP_WBN_ENCODE(1) | \
294 EBC0_BNAP_WBF_ENCODE(1) | \
295 EBC0_BNAP_TH_ENCODE(2) | \
296 EBC0_BNAP_SOR_DELAYED | \
298 EBC0_BNAP_PEN_DISABLED
300 #define EBC0_BNCR_LARGE_FLASH_OR_SRAM_CS0 \
301 EBC0_BNCR_BAS_ENCODE(0xFF800000) | \
307 #define EBC0_BNCR_LARGE_FLASH_OR_SRAM_CS4 \
308 EBC0_BNCR_BAS_ENCODE(0x87800000) | \
314 #define EBC0_BNAP_NVRAM_FPGA \
315 EBC0_BNAP_BME_DISABLED | \
316 EBC0_BNAP_TWT_ENCODE(9) | \
317 EBC0_BNAP_CSN_ENCODE(0) | \
318 EBC0_BNAP_OEN_ENCODE(1) | \
319 EBC0_BNAP_WBN_ENCODE(1) | \
320 EBC0_BNAP_WBF_ENCODE(0) | \
321 EBC0_BNAP_TH_ENCODE(2) | \
322 EBC0_BNAP_RE_ENABLED | \
323 EBC0_BNAP_SOR_DELAYED | \
324 EBC0_BNAP_BEM_WRITEONLY | \
325 EBC0_BNAP_PEN_DISABLED
327 #define EBC0_BNCR_NVRAM_FPGA_CS5 \
328 EBC0_BNCR_BAS_ENCODE(0x80000000) | \
334 #define EBC0_BNAP_NAND_FLASH \
335 EBC0_BNAP_BME_DISABLED | \
336 EBC0_BNAP_TWT_ENCODE(3) | \
337 EBC0_BNAP_CSN_ENCODE(0) | \
338 EBC0_BNAP_OEN_ENCODE(0) | \
339 EBC0_BNAP_WBN_ENCODE(0) | \
340 EBC0_BNAP_WBF_ENCODE(0) | \
341 EBC0_BNAP_TH_ENCODE(1) | \
342 EBC0_BNAP_RE_ENABLED | \
343 EBC0_BNAP_SOR_NOT_DELAYED | \
345 EBC0_BNAP_PEN_DISABLED
348 #define EBC0_BNCR_NAND_FLASH_CS0 0xB8400000
351 #define EBC0_BNCR_NAND_FLASH_CS1 \
352 EBC0_BNCR_BAS_ENCODE(0x90000000) | \
357 #define EBC0_BNCR_NAND_FLASH_CS2 \
358 EBC0_BNCR_BAS_ENCODE(0x94000000) | \
364 #define EBC0_BNCR_NAND_FLASH_CS3 \
365 EBC0_BNCR_BAS_ENCODE(0x94000000) | \
370 int board_early_init_f(void)
372 ext_bus_cntlr_init();
374 /*--------------------------------------------------------------------
375 * Setup the interrupt controller polarities, triggers, etc.
376 *-------------------------------------------------------------------*/
377 mtdcr(UIC0SR, 0xffffffff); /* clear all */
378 mtdcr(UIC0ER, 0x00000000); /* disable all */
379 mtdcr(UIC0CR, 0x00000009); /* ATI & UIC1 crit are critical */
380 mtdcr(UIC0PR, 0xfffffe13); /* per ref-board manual */
381 mtdcr(UIC0TR, 0x01c00008); /* per ref-board manual */
382 mtdcr(UIC0VR, 0x00000001); /* int31 highest, base=0x000 */
383 mtdcr(UIC0SR, 0xffffffff); /* clear all */
385 mtdcr(UIC1SR, 0xffffffff); /* clear all */
386 mtdcr(UIC1ER, 0x00000000); /* disable all */
387 mtdcr(UIC1CR, 0x00000000); /* all non-critical */
388 mtdcr(UIC1PR, 0xffffe0ff); /* per ref-board manual */
389 mtdcr(UIC1TR, 0x00ffc000); /* per ref-board manual */
390 mtdcr(UIC1VR, 0x00000001); /* int31 highest, base=0x000 */
391 mtdcr(UIC1SR, 0xffffffff); /* clear all */
393 /*--------------------------------------------------------------------
394 * Setup the GPIO pins
395 *-------------------------------------------------------------------*/
396 out32(GPIO0_OSRL, 0x00000400);
397 out32(GPIO0_OSRH, 0x00000000);
398 out32(GPIO0_TSRL, 0x00000400);
399 out32(GPIO0_TSRH, 0x00000000);
400 out32(GPIO0_ISR1L, 0x00000000);
401 out32(GPIO0_ISR1H, 0x00000000);
402 out32(GPIO0_ISR2L, 0x00000000);
403 out32(GPIO0_ISR2H, 0x00000000);
404 out32(GPIO0_ISR3L, 0x00000000);
405 out32(GPIO0_ISR3H, 0x00000000);
407 out32(GPIO1_OSRL, 0x0C380000);
408 out32(GPIO1_OSRH, 0x00000000);
409 out32(GPIO1_TSRL, 0x0C380000);
410 out32(GPIO1_TSRH, 0x00000000);
411 out32(GPIO1_ISR1L, 0x0FC30000);
412 out32(GPIO1_ISR1H, 0x00000000);
413 out32(GPIO1_ISR2L, 0x0C010000);
414 out32(GPIO1_ISR2H, 0x00000000);
415 out32(GPIO1_ISR3L, 0x01400000);
416 out32(GPIO1_ISR3H, 0x00000000);
418 configure_ppc440ep_pins();
426 int i = getenv_f("serial#", buf, sizeof(buf));
428 printf("Board: Bamboo - AMCC PPC440EP Evaluation Board");
439 phys_size_t initdram(void)
444 /*----------------------------------------------------------------------------+
445 | is_powerpc440ep_pass1.
446 +----------------------------------------------------------------------------*/
447 int is_powerpc440ep_pass1(void)
453 if (pvr == PVR_POWERPC_440EP_PASS1)
455 else if (pvr == PVR_POWERPC_440EP_PASS2)
458 printf("brdutil error 3\n");
466 /*----------------------------------------------------------------------------+
468 +----------------------------------------------------------------------------*/
469 int is_nand_selected(void)
471 #ifdef CONFIG_BAMBOO_NAND
478 /*----------------------------------------------------------------------------+
479 | config_on_ebc_cs4_is_small_flash => from EPLD
480 +----------------------------------------------------------------------------*/
481 unsigned char config_on_ebc_cs4_is_small_flash(void)
483 /* Not implemented yet => returns constant value */
487 /*----------------------------------------------------------------------------+
488 | Ext_bus_cntlr_init.
489 | Initialize the external bus controller
490 +----------------------------------------------------------------------------*/
491 void ext_bus_cntlr_init(void)
493 unsigned long sdr0_pstrp0, sdr0_sdstp1;
494 unsigned long bootstrap_settings, boot_selection, ebc_boot_size;
495 int computed_boot_device = BOOT_DEVICE_UNKNOWN;
496 unsigned long ebc0_cs0_bnap_value = 0, ebc0_cs0_bncr_value = 0;
497 unsigned long ebc0_cs1_bnap_value = 0, ebc0_cs1_bncr_value = 0;
498 unsigned long ebc0_cs2_bnap_value = 0, ebc0_cs2_bncr_value = 0;
499 unsigned long ebc0_cs3_bnap_value = 0, ebc0_cs3_bncr_value = 0;
500 unsigned long ebc0_cs4_bnap_value = 0, ebc0_cs4_bncr_value = 0;
503 /*-------------------------------------------------------------------------+
505 | PART 1 : Initialize EBC Bank 5
506 | ==============================
507 | Bank5 is always associated to the NVRAM/EPLD.
508 | It has to be initialized prior to other banks settings computation since
509 | some board registers values may be needed
511 +-------------------------------------------------------------------------*/
513 mtebc(PB5AP, EBC0_BNAP_NVRAM_FPGA);
514 mtebc(PB5CR, EBC0_BNCR_NVRAM_FPGA_CS5);
516 /*-------------------------------------------------------------------------+
518 | PART 2 : Determine which boot device was selected
519 | =========================================
521 | Read Pin Strap Register in PPC440EP
522 | In case of boot from IIC, read Serial Device Strap Register1
524 | Result can either be :
525 | - Boot from EBC 8bits => SMALL FLASH
526 | - Boot from EBC 16bits => Large Flash or SRAM
527 | - Boot from NAND Flash
530 +-------------------------------------------------------------------------*/
531 /* Read Pin Strap Register in PPC440EP */
532 mfsdr(SDR0_PINSTP, sdr0_pstrp0);
533 bootstrap_settings = sdr0_pstrp0 & SDR0_PSTRP0_BOOTSTRAP_MASK;
535 /*-------------------------------------------------------------------------+
537 +-------------------------------------------------------------------------*/
538 if (is_powerpc440ep_pass1() == true) {
539 switch(bootstrap_settings) {
540 case SDR0_PSTRP0_BOOTSTRAP_SETTINGS0:
541 /* Default Strap Settings 0 : CPU 400 - PLB 133 - Boot EBC 8 bit 33MHz */
542 /* Boot from Small Flash */
543 computed_boot_device = BOOT_FROM_SMALL_FLASH;
545 case SDR0_PSTRP0_BOOTSTRAP_SETTINGS1:
546 /* Default Strap Settings 1 : CPU 533 - PLB 133 - Boot PCI 66MHz */
548 computed_boot_device = BOOT_FROM_PCI;
551 case SDR0_PSTRP0_BOOTSTRAP_SETTINGS2:
552 /* Default Strap Settings 2 : CPU 500 - PLB 100 - Boot NDFC16 66MHz */
553 /* Boot from Nand Flash */
554 computed_boot_device = BOOT_FROM_NAND_FLASH0;
557 case SDR0_PSTRP0_BOOTSTRAP_SETTINGS3:
558 /* Default Strap Settings 3 : CPU 333 - PLB 133 - Boot EBC 8 bit 66MHz */
559 /* Boot from Small Flash */
560 computed_boot_device = BOOT_FROM_SMALL_FLASH;
563 case SDR0_PSTRP0_BOOTSTRAP_IIC_A8_EN:
564 case SDR0_PSTRP0_BOOTSTRAP_IIC_A4_EN:
565 /* Boot Settings in IIC EEprom address 0xA8 or 0xA4 */
566 /* Read Serial Device Strap Register1 in PPC440EP */
567 mfsdr(SDR0_SDSTP1, sdr0_sdstp1);
568 boot_selection = sdr0_sdstp1 & SDR0_SDSTP1_BOOT_SEL_MASK;
569 ebc_boot_size = sdr0_sdstp1 & SDR0_SDSTP1_EBC_ROM_BS_MASK;
571 switch(boot_selection) {
572 case SDR0_SDSTP1_BOOT_SEL_EBC:
573 switch(ebc_boot_size) {
574 case SDR0_SDSTP1_EBC_ROM_BS_16BIT:
575 computed_boot_device = BOOT_FROM_LARGE_FLASH_OR_SRAM;
577 case SDR0_SDSTP1_EBC_ROM_BS_8BIT:
578 computed_boot_device = BOOT_FROM_SMALL_FLASH;
583 case SDR0_SDSTP1_BOOT_SEL_PCI:
584 computed_boot_device = BOOT_FROM_PCI;
587 case SDR0_SDSTP1_BOOT_SEL_NDFC:
588 computed_boot_device = BOOT_FROM_NAND_FLASH0;
595 /*-------------------------------------------------------------------------+
597 +-------------------------------------------------------------------------*/
599 switch(bootstrap_settings) {
600 case SDR0_PSTRP0_BOOTSTRAP_SETTINGS0:
601 /* Default Strap Settings 0 : CPU 400 - PLB 133 - Boot EBC 8 bit 33MHz */
602 /* Boot from Small Flash */
603 computed_boot_device = BOOT_FROM_SMALL_FLASH;
605 case SDR0_PSTRP0_BOOTSTRAP_SETTINGS1:
606 /* Default Strap Settings 1 : CPU 333 - PLB 133 - Boot PCI 66MHz */
608 computed_boot_device = BOOT_FROM_PCI;
611 case SDR0_PSTRP0_BOOTSTRAP_SETTINGS2:
612 /* Default Strap Settings 2 : CPU 400 - PLB 100 - Boot NDFC16 33MHz */
613 /* Boot from Nand Flash */
614 computed_boot_device = BOOT_FROM_NAND_FLASH0;
617 case SDR0_PSTRP0_BOOTSTRAP_SETTINGS3:
618 /* Default Strap Settings 3 : CPU 400 - PLB 100 - Boot EBC 16 bit 33MHz */
619 /* Boot from Large Flash or SRAM */
620 computed_boot_device = BOOT_FROM_LARGE_FLASH_OR_SRAM;
623 case SDR0_PSTRP0_BOOTSTRAP_SETTINGS4:
624 /* Default Strap Settings 4 : CPU 333 - PLB 133 - Boot EBC 16 bit 66MHz */
625 /* Boot from Large Flash or SRAM */
626 computed_boot_device = BOOT_FROM_LARGE_FLASH_OR_SRAM;
629 case SDR0_PSTRP0_BOOTSTRAP_SETTINGS6:
630 /* Default Strap Settings 6 : CPU 400 - PLB 100 - Boot PCI 33MHz */
632 computed_boot_device = BOOT_FROM_PCI;
635 case SDR0_PSTRP0_BOOTSTRAP_IIC_A8_EN:
636 case SDR0_PSTRP0_BOOTSTRAP_IIC_A4_EN:
637 /* Default Strap Settings 5-7 */
638 /* Boot Settings in IIC EEprom address 0xA8 or 0xA4 */
639 /* Read Serial Device Strap Register1 in PPC440EP */
640 mfsdr(SDR0_SDSTP1, sdr0_sdstp1);
641 boot_selection = sdr0_sdstp1 & SDR0_SDSTP1_BOOT_SEL_MASK;
642 ebc_boot_size = sdr0_sdstp1 & SDR0_SDSTP1_EBC_ROM_BS_MASK;
644 switch(boot_selection) {
645 case SDR0_SDSTP1_BOOT_SEL_EBC:
646 switch(ebc_boot_size) {
647 case SDR0_SDSTP1_EBC_ROM_BS_16BIT:
648 computed_boot_device = BOOT_FROM_LARGE_FLASH_OR_SRAM;
650 case SDR0_SDSTP1_EBC_ROM_BS_8BIT:
651 computed_boot_device = BOOT_FROM_SMALL_FLASH;
656 case SDR0_SDSTP1_BOOT_SEL_PCI:
657 computed_boot_device = BOOT_FROM_PCI;
660 case SDR0_SDSTP1_BOOT_SEL_NDFC:
661 computed_boot_device = BOOT_FROM_NAND_FLASH0;
668 /*-------------------------------------------------------------------------+
670 | PART 3 : Compute EBC settings depending on selected boot device
671 | ====== ======================================================
673 | Resulting EBC init will be among following configurations :
675 | - Boot from EBC 8bits => boot from SMALL FLASH selected
676 | EBC-CS0 = Small Flash
677 | EBC-CS1,2,3 = NAND Flash or
678 | Exp.Slot depending on Soft Config
679 | EBC-CS4 = SRAM/Large Flash or
680 | Large Flash/SRAM depending on jumpers
681 | EBC-CS5 = NVRAM / EPLD
683 | - Boot from EBC 16bits => boot from Large Flash or SRAM selected
684 | EBC-CS0 = SRAM/Large Flash or
685 | Large Flash/SRAM depending on jumpers
686 | EBC-CS1,2,3 = NAND Flash or
687 | Exp.Slot depending on Software Configuration
688 | EBC-CS4 = Small Flash
689 | EBC-CS5 = NVRAM / EPLD
691 | - Boot from NAND Flash
692 | EBC-CS0 = NAND Flash0
693 | EBC-CS1,2,3 = NAND Flash1
694 | EBC-CS4 = SRAM/Large Flash or
695 | Large Flash/SRAM depending on jumpers
696 | EBC-CS5 = NVRAM / EPLD
700 | EBC-CS1,2,3 = NAND Flash or
701 | Exp.Slot depending on Software Configuration
702 | EBC-CS4 = SRAM/Large Flash or
703 | Large Flash/SRAM or
704 | Small Flash depending on jumpers
705 | EBC-CS5 = NVRAM / EPLD
707 +-------------------------------------------------------------------------*/
709 switch(computed_boot_device) {
710 /*------------------------------------------------------------------------- */
711 case BOOT_FROM_SMALL_FLASH:
712 /*------------------------------------------------------------------------- */
713 ebc0_cs0_bnap_value = EBC0_BNAP_SMALL_FLASH;
714 ebc0_cs0_bncr_value = EBC0_BNCR_SMALL_FLASH_CS0;
715 if ((is_nand_selected()) == true) {
717 ebc0_cs1_bnap_value = EBC0_BNAP_NAND_FLASH;
718 ebc0_cs1_bncr_value = EBC0_BNCR_NAND_FLASH_CS1;
719 ebc0_cs2_bnap_value = EBC0_BNAP_NAND_FLASH;
720 ebc0_cs2_bncr_value = EBC0_BNCR_NAND_FLASH_CS2;
721 ebc0_cs3_bnap_value = 0;
722 ebc0_cs3_bncr_value = 0;
725 ebc0_cs1_bnap_value = 0;
726 ebc0_cs1_bncr_value = 0;
727 ebc0_cs2_bnap_value = 0;
728 ebc0_cs2_bncr_value = 0;
729 ebc0_cs3_bnap_value = 0;
730 ebc0_cs3_bncr_value = 0;
732 ebc0_cs4_bnap_value = EBC0_BNAP_LARGE_FLASH_OR_SRAM;
733 ebc0_cs4_bncr_value = EBC0_BNCR_LARGE_FLASH_OR_SRAM_CS4;
737 /*------------------------------------------------------------------------- */
738 case BOOT_FROM_LARGE_FLASH_OR_SRAM:
739 /*------------------------------------------------------------------------- */
740 ebc0_cs0_bnap_value = EBC0_BNAP_LARGE_FLASH_OR_SRAM;
741 ebc0_cs0_bncr_value = EBC0_BNCR_LARGE_FLASH_OR_SRAM_CS0;
742 if ((is_nand_selected()) == true) {
744 ebc0_cs1_bnap_value = EBC0_BNAP_NAND_FLASH;
745 ebc0_cs1_bncr_value = EBC0_BNCR_NAND_FLASH_CS1;
746 ebc0_cs2_bnap_value = 0;
747 ebc0_cs2_bncr_value = 0;
748 ebc0_cs3_bnap_value = 0;
749 ebc0_cs3_bncr_value = 0;
752 ebc0_cs1_bnap_value = 0;
753 ebc0_cs1_bncr_value = 0;
754 ebc0_cs2_bnap_value = 0;
755 ebc0_cs2_bncr_value = 0;
756 ebc0_cs3_bnap_value = 0;
757 ebc0_cs3_bncr_value = 0;
759 ebc0_cs4_bnap_value = EBC0_BNAP_SMALL_FLASH;
760 ebc0_cs4_bncr_value = EBC0_BNCR_SMALL_FLASH_CS4;
764 /*------------------------------------------------------------------------- */
765 case BOOT_FROM_NAND_FLASH0:
766 /*------------------------------------------------------------------------- */
767 ebc0_cs0_bnap_value = EBC0_BNAP_NAND_FLASH;
768 ebc0_cs0_bncr_value = EBC0_BNCR_NAND_FLASH_CS1;
770 ebc0_cs1_bnap_value = 0;
771 ebc0_cs1_bncr_value = 0;
772 ebc0_cs2_bnap_value = 0;
773 ebc0_cs2_bncr_value = 0;
774 ebc0_cs3_bnap_value = 0;
775 ebc0_cs3_bncr_value = 0;
777 /* Large Flash or SRAM */
778 ebc0_cs4_bnap_value = EBC0_BNAP_LARGE_FLASH_OR_SRAM;
779 ebc0_cs4_bncr_value = EBC0_BNCR_LARGE_FLASH_OR_SRAM_CS4;
783 /*------------------------------------------------------------------------- */
785 /*------------------------------------------------------------------------- */
786 ebc0_cs0_bnap_value = 0;
787 ebc0_cs0_bncr_value = 0;
789 if ((is_nand_selected()) == true) {
791 ebc0_cs1_bnap_value = EBC0_BNAP_NAND_FLASH;
792 ebc0_cs1_bncr_value = EBC0_BNCR_NAND_FLASH_CS1;
793 ebc0_cs2_bnap_value = 0;
794 ebc0_cs2_bncr_value = 0;
795 ebc0_cs3_bnap_value = 0;
796 ebc0_cs3_bncr_value = 0;
799 ebc0_cs1_bnap_value = 0;
800 ebc0_cs1_bncr_value = 0;
801 ebc0_cs2_bnap_value = 0;
802 ebc0_cs2_bncr_value = 0;
803 ebc0_cs3_bnap_value = 0;
804 ebc0_cs3_bncr_value = 0;
807 if ((config_on_ebc_cs4_is_small_flash()) == true) {
809 ebc0_cs4_bnap_value = EBC0_BNAP_SMALL_FLASH;
810 ebc0_cs4_bncr_value = EBC0_BNCR_SMALL_FLASH_CS4;
812 /* Large Flash or SRAM */
813 ebc0_cs4_bnap_value = EBC0_BNAP_LARGE_FLASH_OR_SRAM;
814 ebc0_cs4_bncr_value = EBC0_BNCR_LARGE_FLASH_OR_SRAM_CS4;
819 /*------------------------------------------------------------------------- */
820 case BOOT_DEVICE_UNKNOWN:
821 /*------------------------------------------------------------------------- */
828 /*-------------------------------------------------------------------------+
829 | Initialize EBC CONFIG
830 +-------------------------------------------------------------------------*/
831 mtdcr(EBC0_CFGADDR, EBC0_CFG);
832 mtdcr(EBC0_CFGDATA, EBC0_CFG_EBTC_DRIVEN |
833 EBC0_CFG_PTD_ENABLED |
834 EBC0_CFG_RTC_2048PERCLK |
837 EBC0_CFG_CSTC_DRIVEN |
840 EBC0_CFG_PME_DISABLED |
841 EBC0_CFG_PMT_ENCODE(0) );
843 /*-------------------------------------------------------------------------+
844 | Initialize EBC Bank 0-4
845 +-------------------------------------------------------------------------*/
847 mtebc(PB0AP, ebc0_cs0_bnap_value);
848 mtebc(PB0CR, ebc0_cs0_bncr_value);
850 mtebc(PB1AP, ebc0_cs1_bnap_value);
851 mtebc(PB1CR, ebc0_cs1_bncr_value);
853 mtebc(PB2AP, ebc0_cs2_bnap_value);
854 mtebc(PB2CR, ebc0_cs2_bncr_value);
856 mtebc(PB3AP, ebc0_cs3_bnap_value);
857 mtebc(PB3CR, ebc0_cs3_bncr_value);
859 mtebc(PB4AP, ebc0_cs4_bnap_value);
860 mtebc(PB4CR, ebc0_cs4_bncr_value);
866 /*----------------------------------------------------------------------------+
867 | get_uart_configuration.
868 +----------------------------------------------------------------------------*/
869 uart_config_nb_t get_uart_configuration(void)
874 /*----------------------------------------------------------------------------+
875 | set_phy_configuration_through_fpga => to EPLD
876 +----------------------------------------------------------------------------*/
877 void set_phy_configuration_through_fpga(zmii_config_t config)
880 unsigned long fpga_selection_reg;
882 fpga_selection_reg = in8(FPGA_SELECTION_1_REG) & ~FPGA_SEL_1_REG_PHY_MASK;
886 case ZMII_CONFIGURATION_IS_MII:
887 fpga_selection_reg = fpga_selection_reg | FPGA_SEL_1_REG_MII;
889 case ZMII_CONFIGURATION_IS_RMII:
890 fpga_selection_reg = fpga_selection_reg | FPGA_SEL_1_REG_RMII;
892 case ZMII_CONFIGURATION_IS_SMII:
893 fpga_selection_reg = fpga_selection_reg | FPGA_SEL_1_REG_SMII;
895 case ZMII_CONFIGURATION_UNKNOWN:
899 out8(FPGA_SELECTION_1_REG,fpga_selection_reg);
903 /*----------------------------------------------------------------------------+
904 | scp_selection_in_fpga.
905 +----------------------------------------------------------------------------*/
906 void scp_selection_in_fpga(void)
908 unsigned long fpga_selection_2_reg;
910 fpga_selection_2_reg = in8(FPGA_SELECTION_2_REG) & ~FPGA_SEL2_REG_IIC1_SCP_SEL_MASK;
911 fpga_selection_2_reg |= FPGA_SEL2_REG_SEL_SCP;
912 out8(FPGA_SELECTION_2_REG,fpga_selection_2_reg);
915 /*----------------------------------------------------------------------------+
916 | iic1_selection_in_fpga.
917 +----------------------------------------------------------------------------*/
918 void iic1_selection_in_fpga(void)
920 unsigned long fpga_selection_2_reg;
922 fpga_selection_2_reg = in8(FPGA_SELECTION_2_REG) & ~FPGA_SEL2_REG_IIC1_SCP_SEL_MASK;
923 fpga_selection_2_reg |= FPGA_SEL2_REG_SEL_IIC1;
924 out8(FPGA_SELECTION_2_REG,fpga_selection_2_reg);
927 /*----------------------------------------------------------------------------+
928 | dma_a_b_selection_in_fpga.
929 +----------------------------------------------------------------------------*/
930 void dma_a_b_selection_in_fpga(void)
932 unsigned long fpga_selection_2_reg;
934 fpga_selection_2_reg = in8(FPGA_SELECTION_2_REG) | FPGA_SEL2_REG_SEL_DMA_A_B;
935 out8(FPGA_SELECTION_2_REG,fpga_selection_2_reg);
938 /*----------------------------------------------------------------------------+
939 | dma_a_b_unselect_in_fpga.
940 +----------------------------------------------------------------------------*/
941 void dma_a_b_unselect_in_fpga(void)
943 unsigned long fpga_selection_2_reg;
945 fpga_selection_2_reg = in8(FPGA_SELECTION_2_REG) & ~FPGA_SEL2_REG_SEL_DMA_A_B;
946 out8(FPGA_SELECTION_2_REG,fpga_selection_2_reg);
949 /*----------------------------------------------------------------------------+
950 | dma_c_d_selection_in_fpga.
951 +----------------------------------------------------------------------------*/
952 void dma_c_d_selection_in_fpga(void)
954 unsigned long fpga_selection_2_reg;
956 fpga_selection_2_reg = in8(FPGA_SELECTION_2_REG) | FPGA_SEL2_REG_SEL_DMA_C_D;
957 out8(FPGA_SELECTION_2_REG,fpga_selection_2_reg);
960 /*----------------------------------------------------------------------------+
961 | dma_c_d_unselect_in_fpga.
962 +----------------------------------------------------------------------------*/
963 void dma_c_d_unselect_in_fpga(void)
965 unsigned long fpga_selection_2_reg;
967 fpga_selection_2_reg = in8(FPGA_SELECTION_2_REG) & ~FPGA_SEL2_REG_SEL_DMA_C_D;
968 out8(FPGA_SELECTION_2_REG,fpga_selection_2_reg);
971 /*----------------------------------------------------------------------------+
972 | usb2_device_selection_in_fpga.
973 +----------------------------------------------------------------------------*/
974 void usb2_device_selection_in_fpga(void)
976 unsigned long fpga_selection_1_reg;
978 fpga_selection_1_reg = in8(FPGA_SELECTION_1_REG) | FPGA_SEL_1_REG_USB2_DEV_SEL;
979 out8(FPGA_SELECTION_1_REG,fpga_selection_1_reg);
982 /*----------------------------------------------------------------------------+
983 | usb2_device_reset_through_fpga.
984 +----------------------------------------------------------------------------*/
985 void usb2_device_reset_through_fpga(void)
987 /* Perform soft Reset pulse */
988 unsigned long fpga_reset_reg;
991 fpga_reset_reg = in8(FPGA_RESET_REG);
992 out8(FPGA_RESET_REG,fpga_reset_reg | FPGA_RESET_REG_RESET_USB20_DEV);
993 for (i=0; i<500; i++)
995 out8(FPGA_RESET_REG,fpga_reset_reg);
998 /*----------------------------------------------------------------------------+
999 | usb2_host_selection_in_fpga.
1000 +----------------------------------------------------------------------------*/
1001 void usb2_host_selection_in_fpga(void)
1003 unsigned long fpga_selection_1_reg;
1005 fpga_selection_1_reg = in8(FPGA_SELECTION_1_REG) | FPGA_SEL_1_REG_USB2_HOST_SEL;
1006 out8(FPGA_SELECTION_1_REG,fpga_selection_1_reg);
1009 /*----------------------------------------------------------------------------+
1010 | ndfc_selection_in_fpga.
1011 +----------------------------------------------------------------------------*/
1012 void ndfc_selection_in_fpga(void)
1014 unsigned long fpga_selection_1_reg;
1016 fpga_selection_1_reg = in8(FPGA_SELECTION_1_REG) &~FPGA_SEL_1_REG_NF_SELEC_MASK;
1017 fpga_selection_1_reg |= FPGA_SEL_1_REG_NF0_SEL_BY_NFCS1;
1018 fpga_selection_1_reg |= FPGA_SEL_1_REG_NF1_SEL_BY_NFCS2;
1019 out8(FPGA_SELECTION_1_REG,fpga_selection_1_reg);
1022 /*----------------------------------------------------------------------------+
1023 | uart_selection_in_fpga.
1024 +----------------------------------------------------------------------------*/
1025 void uart_selection_in_fpga(uart_config_nb_t uart_config)
1028 unsigned char fpga_selection_3_reg;
1030 /* Read FPGA Reagister */
1031 fpga_selection_3_reg = in8(FPGA_SELECTION_3_REG);
1033 switch (uart_config)
1036 /* ----------------------------------------------------------------------- */
1037 /* L1 configuration: UART0 = 8 pins */
1038 /* ----------------------------------------------------------------------- */
1039 /* Configure FPGA */
1040 fpga_selection_3_reg = fpga_selection_3_reg & ~FPGA_SEL3_REG_SEL_UART_CONFIG_MASK;
1041 fpga_selection_3_reg = fpga_selection_3_reg | FPGA_SEL3_REG_SEL_UART_CONFIG1;
1042 out8(FPGA_SELECTION_3_REG, fpga_selection_3_reg);
1047 /* ----------------------------------------------------------------------- */
1048 /* L2 configuration: UART0 = 4 pins */
1049 /* UART1 = 4 pins */
1050 /* ----------------------------------------------------------------------- */
1051 /* Configure FPGA */
1052 fpga_selection_3_reg = fpga_selection_3_reg & ~FPGA_SEL3_REG_SEL_UART_CONFIG_MASK;
1053 fpga_selection_3_reg = fpga_selection_3_reg | FPGA_SEL3_REG_SEL_UART_CONFIG2;
1054 out8(FPGA_SELECTION_3_REG, fpga_selection_3_reg);
1059 /* ----------------------------------------------------------------------- */
1060 /* L3 configuration: UART0 = 4 pins */
1061 /* UART1 = 2 pins */
1062 /* UART2 = 2 pins */
1063 /* ----------------------------------------------------------------------- */
1064 /* Configure FPGA */
1065 fpga_selection_3_reg = fpga_selection_3_reg & ~FPGA_SEL3_REG_SEL_UART_CONFIG_MASK;
1066 fpga_selection_3_reg = fpga_selection_3_reg | FPGA_SEL3_REG_SEL_UART_CONFIG3;
1067 out8(FPGA_SELECTION_3_REG, fpga_selection_3_reg);
1071 /* Configure FPGA */
1072 fpga_selection_3_reg = fpga_selection_3_reg & ~FPGA_SEL3_REG_SEL_UART_CONFIG_MASK;
1073 fpga_selection_3_reg = fpga_selection_3_reg | FPGA_SEL3_REG_SEL_UART_CONFIG4;
1074 out8(FPGA_SELECTION_3_REG, fpga_selection_3_reg);
1079 /* Unsupported UART configuration number */
1088 /*----------------------------------------------------------------------------+
1090 +----------------------------------------------------------------------------*/
1091 void init_default_gpio(gpio_param_s (*gpio_tab)[GPIO_MAX])
1096 for(i=0; i<GPIO_MAX; i++)
1098 gpio_tab[GPIO0][i].add = GPIO0_BASE;
1099 gpio_tab[GPIO0][i].in_out = GPIO_DIS;
1100 gpio_tab[GPIO0][i].alt_nb = GPIO_SEL;
1104 for(i=0; i<GPIO_MAX; i++)
1106 gpio_tab[GPIO1][i].add = GPIO1_BASE;
1107 gpio_tab[GPIO1][i].in_out = GPIO_DIS;
1108 gpio_tab[GPIO1][i].alt_nb = GPIO_SEL;
1111 /* EBC_CS_N(5) - GPIO0_10 */
1112 gpio_tab[GPIO0][10].in_out = GPIO_OUT;
1113 gpio_tab[GPIO0][10].alt_nb = GPIO_ALT1;
1115 /* EBC_CS_N(4) - GPIO0_9 */
1116 gpio_tab[GPIO0][9].in_out = GPIO_OUT;
1117 gpio_tab[GPIO0][9].alt_nb = GPIO_ALT1;
1120 /*----------------------------------------------------------------------------+
1122 +------------------------------------------------------------------------------
1124 | Set UART Configuration in PowerPC440EP
1126 | +---------------------------------------------------------------------+
1127 | | Configuartion | Connector | Nb of pins | Pins | Associated |
1128 | | Number | Port Name | available | naming | CORE |
1129 | +-----------------+---------------+------------+--------+-------------+
1130 | | L1 | Port_A | 8 | UART | UART core 0 |
1131 | +-----------------+---------------+------------+--------+-------------+
1132 | | L2 | Port_A | 4 | UART1 | UART core 0 |
1133 | | (L2D) | Port_B | 4 | UART2 | UART core 1 |
1134 | +-----------------+---------------+------------+--------+-------------+
1135 | | L3 | Port_A | 4 | UART1 | UART core 0 |
1136 | | (L3D) | Port_B | 2 | UART2 | UART core 1 |
1137 | | | Port_C | 2 | UART3 | UART core 2 |
1138 | +-----------------+---------------+------------+--------+-------------+
1139 | | | Port_A | 2 | UART1 | UART core 0 |
1140 | | L4 | Port_B | 2 | UART2 | UART core 1 |
1141 | | (L4D) | Port_C | 2 | UART3 | UART core 2 |
1142 | | | Port_D | 2 | UART4 | UART core 3 |
1143 | +-----------------+---------------+------------+--------+-------------+
1147 | +------------------------------------------------------------------------------+
1148 | | GPIO | Aternate 1 | I/O | Alternate 2 | I/O | Alternate 3 | I/O |
1149 | +---------+------------------+-----+-----------------+-----+-------------+-----+
1150 | | GPIO1_2 | UART0_DCD_N | I | UART1_DSR_CTS_N | I | UART2_SOUT | O |
1151 | | GPIO1_3 | UART0_8PIN_DSR_N | I | UART1_RTS_DTR_N | O | UART2_SIN | I |
1152 | | GPIO1_4 | UART0_8PIN_CTS_N | I | NA | NA | UART3_SIN | I |
1153 | | GPIO1_5 | UART0_RTS_N | O | NA | NA | UART3_SOUT | O |
1154 | | GPIO1_6 | UART0_DTR_N | O | UART1_SOUT | O | NA | NA |
1155 | | GPIO1_7 | UART0_RI_N | I | UART1_SIN | I | NA | NA |
1156 | +------------------------------------------------------------------------------+
1159 +----------------------------------------------------------------------------*/
1161 void update_uart_ios(uart_config_nb_t uart_config, gpio_param_s (*gpio_tab)[GPIO_MAX])
1163 switch (uart_config)
1166 /* ----------------------------------------------------------------------- */
1167 /* L1 configuration: UART0 = 8 pins */
1168 /* ----------------------------------------------------------------------- */
1169 /* Update GPIO Configuration Table */
1170 gpio_tab[GPIO1][2].in_out = GPIO_IN;
1171 gpio_tab[GPIO1][2].alt_nb = GPIO_ALT1;
1173 gpio_tab[GPIO1][3].in_out = GPIO_IN;
1174 gpio_tab[GPIO1][3].alt_nb = GPIO_ALT1;
1176 gpio_tab[GPIO1][4].in_out = GPIO_IN;
1177 gpio_tab[GPIO1][4].alt_nb = GPIO_ALT1;
1179 gpio_tab[GPIO1][5].in_out = GPIO_OUT;
1180 gpio_tab[GPIO1][5].alt_nb = GPIO_ALT1;
1182 gpio_tab[GPIO1][6].in_out = GPIO_OUT;
1183 gpio_tab[GPIO1][6].alt_nb = GPIO_ALT1;
1185 gpio_tab[GPIO1][7].in_out = GPIO_IN;
1186 gpio_tab[GPIO1][7].alt_nb = GPIO_ALT1;
1191 /* ----------------------------------------------------------------------- */
1192 /* L2 configuration: UART0 = 4 pins */
1193 /* UART1 = 4 pins */
1194 /* ----------------------------------------------------------------------- */
1195 /* Update GPIO Configuration Table */
1196 gpio_tab[GPIO1][2].in_out = GPIO_IN;
1197 gpio_tab[GPIO1][2].alt_nb = GPIO_ALT2;
1199 gpio_tab[GPIO1][3].in_out = GPIO_OUT;
1200 gpio_tab[GPIO1][3].alt_nb = GPIO_ALT2;
1202 gpio_tab[GPIO1][4].in_out = GPIO_IN;
1203 gpio_tab[GPIO1][4].alt_nb = GPIO_ALT1;
1205 gpio_tab[GPIO1][5].in_out = GPIO_OUT;
1206 gpio_tab[GPIO1][5].alt_nb = GPIO_ALT1;
1208 gpio_tab[GPIO1][6].in_out = GPIO_OUT;
1209 gpio_tab[GPIO1][6].alt_nb = GPIO_ALT2;
1211 gpio_tab[GPIO1][7].in_out = GPIO_IN;
1212 gpio_tab[GPIO1][7].alt_nb = GPIO_ALT2;
1217 /* ----------------------------------------------------------------------- */
1218 /* L3 configuration: UART0 = 4 pins */
1219 /* UART1 = 2 pins */
1220 /* UART2 = 2 pins */
1221 /* ----------------------------------------------------------------------- */
1222 /* Update GPIO Configuration Table */
1223 gpio_tab[GPIO1][2].in_out = GPIO_OUT;
1224 gpio_tab[GPIO1][2].alt_nb = GPIO_ALT3;
1226 gpio_tab[GPIO1][3].in_out = GPIO_IN;
1227 gpio_tab[GPIO1][3].alt_nb = GPIO_ALT3;
1229 gpio_tab[GPIO1][4].in_out = GPIO_IN;
1230 gpio_tab[GPIO1][4].alt_nb = GPIO_ALT1;
1232 gpio_tab[GPIO1][5].in_out = GPIO_OUT;
1233 gpio_tab[GPIO1][5].alt_nb = GPIO_ALT1;
1235 gpio_tab[GPIO1][6].in_out = GPIO_OUT;
1236 gpio_tab[GPIO1][6].alt_nb = GPIO_ALT2;
1238 gpio_tab[GPIO1][7].in_out = GPIO_IN;
1239 gpio_tab[GPIO1][7].alt_nb = GPIO_ALT2;
1244 /* ----------------------------------------------------------------------- */
1245 /* L4 configuration: UART0 = 2 pins */
1246 /* UART1 = 2 pins */
1247 /* UART2 = 2 pins */
1248 /* UART3 = 2 pins */
1249 /* ----------------------------------------------------------------------- */
1250 /* Update GPIO Configuration Table */
1251 gpio_tab[GPIO1][2].in_out = GPIO_OUT;
1252 gpio_tab[GPIO1][2].alt_nb = GPIO_ALT3;
1254 gpio_tab[GPIO1][3].in_out = GPIO_IN;
1255 gpio_tab[GPIO1][3].alt_nb = GPIO_ALT3;
1257 gpio_tab[GPIO1][4].in_out = GPIO_IN;
1258 gpio_tab[GPIO1][4].alt_nb = GPIO_ALT3;
1260 gpio_tab[GPIO1][5].in_out = GPIO_OUT;
1261 gpio_tab[GPIO1][5].alt_nb = GPIO_ALT3;
1263 gpio_tab[GPIO1][6].in_out = GPIO_OUT;
1264 gpio_tab[GPIO1][6].alt_nb = GPIO_ALT2;
1266 gpio_tab[GPIO1][7].in_out = GPIO_IN;
1267 gpio_tab[GPIO1][7].alt_nb = GPIO_ALT2;
1272 /* Unsupported UART configuration number */
1273 printf("ERROR - Unsupported UART configuration number.\n\n");
1280 /* Set input Selection Register on Alt_Receive for UART Input Core */
1281 out32(GPIO1_IS1L, (in32(GPIO1_IS1L) | 0x0FC30000));
1282 out32(GPIO1_IS2L, (in32(GPIO1_IS2L) | 0x0C030000));
1283 out32(GPIO1_IS3L, (in32(GPIO1_IS3L) | 0x03C00000));
1286 /*----------------------------------------------------------------------------+
1287 | update_ndfc_ios(void).
1288 +----------------------------------------------------------------------------*/
1289 void update_ndfc_ios(gpio_param_s (*gpio_tab)[GPIO_MAX])
1291 /* Update GPIO Configuration Table */
1292 gpio_tab[GPIO0][6].in_out = GPIO_OUT; /* EBC_CS_N(1) */
1293 gpio_tab[GPIO0][6].alt_nb = GPIO_ALT1;
1295 gpio_tab[GPIO0][7].in_out = GPIO_OUT; /* EBC_CS_N(2) */
1296 gpio_tab[GPIO0][7].alt_nb = GPIO_ALT1;
1299 gpio_tab[GPIO0][7].in_out = GPIO_OUT; /* EBC_CS_N(3) */
1300 gpio_tab[GPIO0][7].alt_nb = GPIO_ALT1;
1304 /*----------------------------------------------------------------------------+
1305 | update_zii_ios(void).
1306 +----------------------------------------------------------------------------*/
1307 void update_zii_ios(gpio_param_s (*gpio_tab)[GPIO_MAX])
1309 /* Update GPIO Configuration Table */
1310 gpio_tab[GPIO0][12].in_out = GPIO_IN; /* ZII_p0Rxd(0) */
1311 gpio_tab[GPIO0][12].alt_nb = GPIO_ALT1;
1313 gpio_tab[GPIO0][13].in_out = GPIO_IN; /* ZII_p0Rxd(1) */
1314 gpio_tab[GPIO0][13].alt_nb = GPIO_ALT1;
1316 gpio_tab[GPIO0][14].in_out = GPIO_IN; /* ZII_p0Rxd(2) */
1317 gpio_tab[GPIO0][14].alt_nb = GPIO_ALT1;
1319 gpio_tab[GPIO0][15].in_out = GPIO_IN; /* ZII_p0Rxd(3) */
1320 gpio_tab[GPIO0][15].alt_nb = GPIO_ALT1;
1322 gpio_tab[GPIO0][16].in_out = GPIO_OUT; /* ZII_p0Txd(0) */
1323 gpio_tab[GPIO0][16].alt_nb = GPIO_ALT1;
1325 gpio_tab[GPIO0][17].in_out = GPIO_OUT; /* ZII_p0Txd(1) */
1326 gpio_tab[GPIO0][17].alt_nb = GPIO_ALT1;
1328 gpio_tab[GPIO0][18].in_out = GPIO_OUT; /* ZII_p0Txd(2) */
1329 gpio_tab[GPIO0][18].alt_nb = GPIO_ALT1;
1331 gpio_tab[GPIO0][19].in_out = GPIO_OUT; /* ZII_p0Txd(3) */
1332 gpio_tab[GPIO0][19].alt_nb = GPIO_ALT1;
1334 gpio_tab[GPIO0][20].in_out = GPIO_IN; /* ZII_p0Rx_er */
1335 gpio_tab[GPIO0][20].alt_nb = GPIO_ALT1;
1337 gpio_tab[GPIO0][21].in_out = GPIO_IN; /* ZII_p0Rx_dv */
1338 gpio_tab[GPIO0][21].alt_nb = GPIO_ALT1;
1340 gpio_tab[GPIO0][22].in_out = GPIO_IN; /* ZII_p0Crs */
1341 gpio_tab[GPIO0][22].alt_nb = GPIO_ALT1;
1343 gpio_tab[GPIO0][23].in_out = GPIO_OUT; /* ZII_p0Tx_er */
1344 gpio_tab[GPIO0][23].alt_nb = GPIO_ALT1;
1346 gpio_tab[GPIO0][24].in_out = GPIO_OUT; /* ZII_p0Tx_en */
1347 gpio_tab[GPIO0][24].alt_nb = GPIO_ALT1;
1349 gpio_tab[GPIO0][25].in_out = GPIO_IN; /* ZII_p0Col */
1350 gpio_tab[GPIO0][25].alt_nb = GPIO_ALT1;
1354 /*----------------------------------------------------------------------------+
1355 | update_uic_0_3_irq_ios().
1356 +----------------------------------------------------------------------------*/
1357 void update_uic_0_3_irq_ios(gpio_param_s (*gpio_tab)[GPIO_MAX])
1359 gpio_tab[GPIO1][8].in_out = GPIO_IN; /* UIC_IRQ(0) */
1360 gpio_tab[GPIO1][8].alt_nb = GPIO_ALT1;
1362 gpio_tab[GPIO1][9].in_out = GPIO_IN; /* UIC_IRQ(1) */
1363 gpio_tab[GPIO1][9].alt_nb = GPIO_ALT1;
1365 gpio_tab[GPIO1][10].in_out = GPIO_IN; /* UIC_IRQ(2) */
1366 gpio_tab[GPIO1][10].alt_nb = GPIO_ALT1;
1368 gpio_tab[GPIO1][11].in_out = GPIO_IN; /* UIC_IRQ(3) */
1369 gpio_tab[GPIO1][11].alt_nb = GPIO_ALT1;
1372 /*----------------------------------------------------------------------------+
1373 | update_uic_4_9_irq_ios().
1374 +----------------------------------------------------------------------------*/
1375 void update_uic_4_9_irq_ios(gpio_param_s (*gpio_tab)[GPIO_MAX])
1377 gpio_tab[GPIO1][12].in_out = GPIO_IN; /* UIC_IRQ(4) */
1378 gpio_tab[GPIO1][12].alt_nb = GPIO_ALT1;
1380 gpio_tab[GPIO1][13].in_out = GPIO_IN; /* UIC_IRQ(6) */
1381 gpio_tab[GPIO1][13].alt_nb = GPIO_ALT1;
1383 gpio_tab[GPIO1][14].in_out = GPIO_IN; /* UIC_IRQ(7) */
1384 gpio_tab[GPIO1][14].alt_nb = GPIO_ALT1;
1386 gpio_tab[GPIO1][15].in_out = GPIO_IN; /* UIC_IRQ(8) */
1387 gpio_tab[GPIO1][15].alt_nb = GPIO_ALT1;
1389 gpio_tab[GPIO1][16].in_out = GPIO_IN; /* UIC_IRQ(9) */
1390 gpio_tab[GPIO1][16].alt_nb = GPIO_ALT1;
1393 /*----------------------------------------------------------------------------+
1394 | update_dma_a_b_ios().
1395 +----------------------------------------------------------------------------*/
1396 void update_dma_a_b_ios(gpio_param_s (*gpio_tab)[GPIO_MAX])
1398 gpio_tab[GPIO1][12].in_out = GPIO_OUT; /* DMA_ACK(1) */
1399 gpio_tab[GPIO1][12].alt_nb = GPIO_ALT2;
1401 gpio_tab[GPIO1][13].in_out = GPIO_BI; /* DMA_EOT/TC(1) */
1402 gpio_tab[GPIO1][13].alt_nb = GPIO_ALT2;
1404 gpio_tab[GPIO1][14].in_out = GPIO_IN; /* DMA_REQ(0) */
1405 gpio_tab[GPIO1][14].alt_nb = GPIO_ALT2;
1407 gpio_tab[GPIO1][15].in_out = GPIO_OUT; /* DMA_ACK(0) */
1408 gpio_tab[GPIO1][15].alt_nb = GPIO_ALT2;
1410 gpio_tab[GPIO1][16].in_out = GPIO_BI; /* DMA_EOT/TC(0) */
1411 gpio_tab[GPIO1][16].alt_nb = GPIO_ALT2;
1414 /*----------------------------------------------------------------------------+
1415 | update_dma_c_d_ios().
1416 +----------------------------------------------------------------------------*/
1417 void update_dma_c_d_ios(gpio_param_s (*gpio_tab)[GPIO_MAX])
1419 gpio_tab[GPIO0][0].in_out = GPIO_IN; /* DMA_REQ(2) */
1420 gpio_tab[GPIO0][0].alt_nb = GPIO_ALT2;
1422 gpio_tab[GPIO0][1].in_out = GPIO_OUT; /* DMA_ACK(2) */
1423 gpio_tab[GPIO0][1].alt_nb = GPIO_ALT2;
1425 gpio_tab[GPIO0][2].in_out = GPIO_BI; /* DMA_EOT/TC(2) */
1426 gpio_tab[GPIO0][2].alt_nb = GPIO_ALT2;
1428 gpio_tab[GPIO0][3].in_out = GPIO_IN; /* DMA_REQ(3) */
1429 gpio_tab[GPIO0][3].alt_nb = GPIO_ALT2;
1431 gpio_tab[GPIO0][4].in_out = GPIO_OUT; /* DMA_ACK(3) */
1432 gpio_tab[GPIO0][4].alt_nb = GPIO_ALT2;
1434 gpio_tab[GPIO0][5].in_out = GPIO_BI; /* DMA_EOT/TC(3) */
1435 gpio_tab[GPIO0][5].alt_nb = GPIO_ALT2;
1439 /*----------------------------------------------------------------------------+
1440 | update_ebc_master_ios().
1441 +----------------------------------------------------------------------------*/
1442 void update_ebc_master_ios(gpio_param_s (*gpio_tab)[GPIO_MAX])
1444 gpio_tab[GPIO0][27].in_out = GPIO_IN; /* EXT_EBC_REQ */
1445 gpio_tab[GPIO0][27].alt_nb = GPIO_ALT1;
1447 gpio_tab[GPIO0][29].in_out = GPIO_OUT; /* EBC_EXT_HDLA */
1448 gpio_tab[GPIO0][29].alt_nb = GPIO_ALT1;
1450 gpio_tab[GPIO0][30].in_out = GPIO_OUT; /* EBC_EXT_ACK */
1451 gpio_tab[GPIO0][30].alt_nb = GPIO_ALT1;
1453 gpio_tab[GPIO0][31].in_out = GPIO_OUT; /* EBC_EXR_BUSREQ */
1454 gpio_tab[GPIO0][31].alt_nb = GPIO_ALT1;
1457 /*----------------------------------------------------------------------------+
1458 | update_usb2_device_ios().
1459 +----------------------------------------------------------------------------*/
1460 void update_usb2_device_ios(gpio_param_s (*gpio_tab)[GPIO_MAX])
1462 gpio_tab[GPIO0][26].in_out = GPIO_IN; /* USB2D_RXVALID */
1463 gpio_tab[GPIO0][26].alt_nb = GPIO_ALT2;
1465 gpio_tab[GPIO0][27].in_out = GPIO_IN; /* USB2D_RXERROR */
1466 gpio_tab[GPIO0][27].alt_nb = GPIO_ALT2;
1468 gpio_tab[GPIO0][28].in_out = GPIO_OUT; /* USB2D_TXVALID */
1469 gpio_tab[GPIO0][28].alt_nb = GPIO_ALT2;
1471 gpio_tab[GPIO0][29].in_out = GPIO_OUT; /* USB2D_PAD_SUSPNDM */
1472 gpio_tab[GPIO0][29].alt_nb = GPIO_ALT2;
1474 gpio_tab[GPIO0][30].in_out = GPIO_OUT; /* USB2D_XCVRSELECT */
1475 gpio_tab[GPIO0][30].alt_nb = GPIO_ALT2;
1477 gpio_tab[GPIO0][31].in_out = GPIO_OUT; /* USB2D_TERMSELECT */
1478 gpio_tab[GPIO0][31].alt_nb = GPIO_ALT2;
1480 gpio_tab[GPIO1][0].in_out = GPIO_OUT; /* USB2D_OPMODE0 */
1481 gpio_tab[GPIO1][0].alt_nb = GPIO_ALT1;
1483 gpio_tab[GPIO1][1].in_out = GPIO_OUT; /* USB2D_OPMODE1 */
1484 gpio_tab[GPIO1][1].alt_nb = GPIO_ALT1;
1488 /*----------------------------------------------------------------------------+
1489 | update_pci_patch_ios().
1490 +----------------------------------------------------------------------------*/
1491 void update_pci_patch_ios(gpio_param_s (*gpio_tab)[GPIO_MAX])
1493 gpio_tab[GPIO0][29].in_out = GPIO_OUT; /* EBC_EXT_HDLA */
1494 gpio_tab[GPIO0][29].alt_nb = GPIO_ALT1;
1497 /*----------------------------------------------------------------------------+
1498 | set_chip_gpio_configuration(unsigned char gpio_core,
1499 | gpio_param_s (*gpio_tab)[GPIO_MAX])
1500 | Put the core impacted by clock modification and sharing in reset.
1501 | Config the select registers to resolve the sharing depending of the config.
1502 | Configure the GPIO registers.
1504 +----------------------------------------------------------------------------*/
1505 void set_chip_gpio_configuration(unsigned char gpio_core, gpio_param_s (*gpio_tab)[GPIO_MAX])
1507 unsigned char i=0, j=0, reg_offset = 0;
1508 unsigned long gpio_reg, gpio_core_add;
1510 /* GPIO config of the GPIOs 0 to 31 */
1511 for (i=0; i<GPIO_MAX; i++, j++)
1513 if (i == GPIO_MAX/2)
1519 gpio_core_add = gpio_tab[gpio_core][i].add;
1521 if ( (gpio_tab[gpio_core][i].in_out == GPIO_IN) ||
1522 (gpio_tab[gpio_core][i].in_out == GPIO_BI ))
1524 switch (gpio_tab[gpio_core][i].alt_nb)
1530 gpio_reg = in32(GPIO_IS1(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
1531 gpio_reg = gpio_reg | (GPIO_IN_SEL >> (j*2));
1532 out32(GPIO_IS1(gpio_core_add+reg_offset), gpio_reg);
1536 gpio_reg = in32(GPIO_IS2(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
1537 gpio_reg = gpio_reg | (GPIO_IN_SEL >> (j*2));
1538 out32(GPIO_IS2(gpio_core_add+reg_offset), gpio_reg);
1542 gpio_reg = in32(GPIO_IS3(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
1543 gpio_reg = gpio_reg | (GPIO_IN_SEL >> (j*2));
1544 out32(GPIO_IS3(gpio_core_add+reg_offset), gpio_reg);
1548 if ( (gpio_tab[gpio_core][i].in_out == GPIO_OUT) ||
1549 (gpio_tab[gpio_core][i].in_out == GPIO_BI ))
1552 switch (gpio_tab[gpio_core][i].alt_nb)
1557 gpio_reg = in32(GPIO_OS(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
1558 gpio_reg = gpio_reg | (GPIO_ALT1_SEL >> (j*2));
1559 out32(GPIO_OS(gpio_core_add+reg_offset), gpio_reg);
1560 gpio_reg = in32(GPIO_TS(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
1561 gpio_reg = gpio_reg | (GPIO_ALT1_SEL >> (j*2));
1562 out32(GPIO_TS(gpio_core_add+reg_offset), gpio_reg);
1565 gpio_reg = in32(GPIO_OS(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
1566 gpio_reg = gpio_reg | (GPIO_ALT2_SEL >> (j*2));
1567 out32(GPIO_OS(gpio_core_add+reg_offset), gpio_reg);
1568 gpio_reg = in32(GPIO_TS(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
1569 gpio_reg = gpio_reg | (GPIO_ALT2_SEL >> (j*2));
1570 out32(GPIO_TS(gpio_core_add+reg_offset), gpio_reg);
1573 gpio_reg = in32(GPIO_OS(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
1574 gpio_reg = gpio_reg | (GPIO_ALT3_SEL >> (j*2));
1575 out32(GPIO_OS(gpio_core_add+reg_offset), gpio_reg);
1576 gpio_reg = in32(GPIO_TS(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
1577 gpio_reg = gpio_reg | (GPIO_ALT3_SEL >> (j*2));
1578 out32(GPIO_TS(gpio_core_add+reg_offset), gpio_reg);
1585 /*----------------------------------------------------------------------------+
1586 | force_bup_core_selection.
1587 +----------------------------------------------------------------------------*/
1588 void force_bup_core_selection(core_selection_t *core_select_P, config_validity_t *config_val_P)
1590 /* Pointer invalid */
1591 if (core_select_P == NULL)
1593 printf("Configuration invalid pointer 1\n");
1599 *(core_select_P+UART_CORE0) = CORE_SELECTED;
1600 *(core_select_P+UART_CORE1) = CORE_SELECTED;
1601 *(core_select_P+UART_CORE2) = CORE_SELECTED;
1602 *(core_select_P+UART_CORE3) = CORE_SELECTED;
1604 /* RMII Selection */
1605 *(core_select_P+RMII_SEL) = CORE_SELECTED;
1607 /* External Interrupt 0-9 selection */
1608 *(core_select_P+UIC_0_3) = CORE_SELECTED;
1609 *(core_select_P+UIC_4_9) = CORE_SELECTED;
1611 *(core_select_P+SCP_CORE) = CORE_SELECTED;
1612 *(core_select_P+DMA_CHANNEL_CD) = CORE_SELECTED;
1613 *(core_select_P+PACKET_REJ_FUNC_AVAIL) = CORE_SELECTED;
1614 *(core_select_P+USB1_DEVICE) = CORE_SELECTED;
1616 if (is_nand_selected()) {
1617 *(core_select_P+NAND_FLASH) = CORE_SELECTED;
1620 *config_val_P = CONFIG_IS_VALID;
1624 /*----------------------------------------------------------------------------+
1625 | configure_ppc440ep_pins.
1626 +----------------------------------------------------------------------------*/
1627 void configure_ppc440ep_pins(void)
1629 uart_config_nb_t uart_configuration;
1630 config_validity_t config_val = CONFIG_IS_INVALID;
1632 /* Create Core Selection Table */
1633 core_selection_t ppc440ep_core_selection[MAX_CORE_SELECT_NB] =
1635 CORE_NOT_SELECTED, /* IIC_CORE, */
1636 CORE_NOT_SELECTED, /* SPC_CORE, */
1637 CORE_NOT_SELECTED, /* DMA_CHANNEL_AB, */
1638 CORE_NOT_SELECTED, /* UIC_4_9, */
1639 CORE_NOT_SELECTED, /* USB2_HOST, */
1640 CORE_NOT_SELECTED, /* DMA_CHANNEL_CD, */
1641 CORE_NOT_SELECTED, /* USB2_DEVICE, */
1642 CORE_NOT_SELECTED, /* PACKET_REJ_FUNC_AVAIL, */
1643 CORE_NOT_SELECTED, /* USB1_DEVICE, */
1644 CORE_NOT_SELECTED, /* EBC_MASTER, */
1645 CORE_NOT_SELECTED, /* NAND_FLASH, */
1646 CORE_NOT_SELECTED, /* UART_CORE0, */
1647 CORE_NOT_SELECTED, /* UART_CORE1, */
1648 CORE_NOT_SELECTED, /* UART_CORE2, */
1649 CORE_NOT_SELECTED, /* UART_CORE3, */
1650 CORE_NOT_SELECTED, /* MII_SEL, */
1651 CORE_NOT_SELECTED, /* RMII_SEL, */
1652 CORE_NOT_SELECTED, /* SMII_SEL, */
1653 CORE_NOT_SELECTED, /* PACKET_REJ_FUNC_EN */
1654 CORE_NOT_SELECTED, /* UIC_0_3 */
1655 CORE_NOT_SELECTED, /* USB1_HOST */
1656 CORE_NOT_SELECTED /* PCI_PATCH */
1659 gpio_param_s gpio_tab[GPIO_GROUP_MAX][GPIO_MAX];
1661 /* Table Default Initialisation + FPGA Access */
1662 init_default_gpio(gpio_tab);
1663 set_chip_gpio_configuration(GPIO0, gpio_tab);
1664 set_chip_gpio_configuration(GPIO1, gpio_tab);
1667 force_bup_core_selection(ppc440ep_core_selection, &config_val);
1668 #if 0 /* test-only */
1669 /* If we are running PIBS 1, force known configuration */
1670 update_core_selection_table(ppc440ep_core_selection, &config_val);
1673 /*----------------------------------------------------------------------------+
1674 | SDR + ios table update + fpga initialization
1675 +----------------------------------------------------------------------------*/
1676 unsigned long sdr0_pfc1 = 0;
1677 unsigned long sdr0_usb0 = 0;
1678 unsigned long sdr0_mfr = 0;
1680 /* PCI Always selected */
1683 if (ppc440ep_core_selection[IIC_CORE] == CORE_SELECTED)
1685 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_SIS_MASK) | SDR0_PFC1_SIS_IIC1_SEL;
1686 iic1_selection_in_fpga();
1690 if (ppc440ep_core_selection[SCP_CORE] == CORE_SELECTED)
1692 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_SIS_MASK) | SDR0_PFC1_SIS_SCP_SEL;
1693 scp_selection_in_fpga();
1696 /* UIC 0:3 Selection */
1697 if (ppc440ep_core_selection[UIC_0_3] == CORE_SELECTED)
1699 update_uic_0_3_irq_ios(gpio_tab);
1700 dma_a_b_unselect_in_fpga();
1703 /* UIC 4:9 Selection */
1704 if (ppc440ep_core_selection[UIC_4_9] == CORE_SELECTED)
1706 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_DIS_MASK) | SDR0_PFC1_DIS_UICIRQ5_SEL;
1707 update_uic_4_9_irq_ios(gpio_tab);
1710 /* DMA AB Selection */
1711 if (ppc440ep_core_selection[DMA_CHANNEL_AB] == CORE_SELECTED)
1713 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_DIS_MASK) | SDR0_PFC1_DIS_DMAR_SEL;
1714 update_dma_a_b_ios(gpio_tab);
1715 dma_a_b_selection_in_fpga();
1718 /* DMA CD Selection */
1719 if (ppc440ep_core_selection[DMA_CHANNEL_CD] == CORE_SELECTED)
1721 update_dma_c_d_ios(gpio_tab);
1722 dma_c_d_selection_in_fpga();
1725 /* EBC Master Selection */
1726 if (ppc440ep_core_selection[EBC_MASTER] == CORE_SELECTED)
1728 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_ERE_MASK) | SDR0_PFC1_ERE_EXTR_SEL;
1729 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_UES_MASK) | SDR0_PFC1_UES_EBCHR_SEL;
1730 update_ebc_master_ios(gpio_tab);
1733 /* PCI Patch Enable */
1734 if (ppc440ep_core_selection[PCI_PATCH] == CORE_SELECTED)
1736 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_UES_MASK) | SDR0_PFC1_UES_EBCHR_SEL;
1737 update_pci_patch_ios(gpio_tab);
1740 /* USB2 Host Selection - Not Implemented in PowerPC 440EP Pass1 */
1741 if (ppc440ep_core_selection[USB2_HOST] == CORE_SELECTED)
1743 /* Not Implemented in PowerPC 440EP Pass1-Pass2 */
1744 printf("Invalid configuration => USB2 Host selected\n");
1747 /*usb2_host_selection_in_fpga(); */
1750 /* USB2.0 Device Selection */
1751 if (ppc440ep_core_selection[USB2_DEVICE] == CORE_SELECTED)
1753 update_usb2_device_ios(gpio_tab);
1754 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_UES_MASK) | SDR0_PFC1_UES_USB2D_SEL;
1755 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_UPR_MASK) | SDR0_PFC1_UPR_DISABLE;
1757 mfsdr(SDR0_USB0, sdr0_usb0);
1758 sdr0_usb0 = sdr0_usb0 &~SDR0_USB0_USB_DEVSEL_MASK;
1759 sdr0_usb0 = sdr0_usb0 | SDR0_USB0_USB20D_DEVSEL;
1760 mtsdr(SDR0_USB0, sdr0_usb0);
1762 usb2_device_selection_in_fpga();
1765 /* USB1.1 Device Selection */
1766 if (ppc440ep_core_selection[USB1_DEVICE] == CORE_SELECTED)
1768 mfsdr(SDR0_USB0, sdr0_usb0);
1769 sdr0_usb0 = sdr0_usb0 &~SDR0_USB0_USB_DEVSEL_MASK;
1770 sdr0_usb0 = sdr0_usb0 | SDR0_USB0_USB11D_DEVSEL;
1771 mtsdr(SDR0_USB0, sdr0_usb0);
1774 /* USB1.1 Host Selection */
1775 if (ppc440ep_core_selection[USB1_HOST] == CORE_SELECTED)
1777 mfsdr(SDR0_USB0, sdr0_usb0);
1778 sdr0_usb0 = sdr0_usb0 &~SDR0_USB0_LEEN_MASK;
1779 sdr0_usb0 = sdr0_usb0 | SDR0_USB0_LEEN_ENABLE;
1780 mtsdr(SDR0_USB0, sdr0_usb0);
1783 /* NAND Flash Selection */
1784 if (ppc440ep_core_selection[NAND_FLASH] == CORE_SELECTED)
1786 update_ndfc_ios(gpio_tab);
1787 mtsdr(SDR0_CUST0, SDR0_CUST0_MUX_NDFC_SEL |
1788 SDR0_CUST0_NDFC_ENABLE |
1789 SDR0_CUST0_NDFC_BW_8_BIT |
1790 SDR0_CUST0_NDFC_ARE_MASK |
1791 SDR0_CUST0_CHIPSELGAT_EN1 |
1792 SDR0_CUST0_CHIPSELGAT_EN2);
1793 ndfc_selection_in_fpga();
1797 /* Set Mux on EMAC */
1798 mtsdr(SDR0_CUST0, SDR0_CUST0_MUX_EMAC_SEL);
1802 if (ppc440ep_core_selection[MII_SEL] == CORE_SELECTED)
1804 update_zii_ios(gpio_tab);
1805 mfsdr(SDR0_MFR, sdr0_mfr);
1806 sdr0_mfr = (sdr0_mfr & ~SDR0_MFR_ZMII_MODE_MASK) | SDR0_MFR_ZMII_MODE_MII;
1807 mtsdr(SDR0_MFR, sdr0_mfr);
1809 set_phy_configuration_through_fpga(ZMII_CONFIGURATION_IS_MII);
1812 /* RMII Selection */
1813 if (ppc440ep_core_selection[RMII_SEL] == CORE_SELECTED)
1815 update_zii_ios(gpio_tab);
1816 mfsdr(SDR0_MFR, sdr0_mfr);
1817 sdr0_mfr = (sdr0_mfr & ~SDR0_MFR_ZMII_MODE_MASK) | SDR0_MFR_ZMII_MODE_RMII_10M;
1818 mtsdr(SDR0_MFR, sdr0_mfr);
1820 set_phy_configuration_through_fpga(ZMII_CONFIGURATION_IS_RMII);
1823 /* SMII Selection */
1824 if (ppc440ep_core_selection[SMII_SEL] == CORE_SELECTED)
1826 update_zii_ios(gpio_tab);
1827 mfsdr(SDR0_MFR, sdr0_mfr);
1828 sdr0_mfr = (sdr0_mfr & ~SDR0_MFR_ZMII_MODE_MASK) | SDR0_MFR_ZMII_MODE_SMII;
1829 mtsdr(SDR0_MFR, sdr0_mfr);
1831 set_phy_configuration_through_fpga(ZMII_CONFIGURATION_IS_SMII);
1834 /* UART Selection */
1835 uart_configuration = get_uart_configuration();
1836 switch (uart_configuration)
1838 case L1: /* L1 Selection */
1839 /* UART0 8 pins Only */
1840 /*sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0ME_MASK) | SDR0_PFC1_U0ME_DSR_DTR; */
1841 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0ME_MASK) |SDR0_PFC1_U0ME_CTS_RTS; /* Chip Pb */
1842 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0IM_MASK) | SDR0_PFC1_U0IM_8PINS;
1844 case L2: /* L2 Selection */
1845 /* UART0 and UART1 4 pins */
1846 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0ME_MASK) | SDR0_PFC1_U1ME_DSR_DTR;
1847 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0IM_MASK) | SDR0_PFC1_U0IM_4PINS;
1848 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U1ME_MASK) | SDR0_PFC1_U1ME_DSR_DTR;
1850 case L3: /* L3 Selection */
1851 /* UART0 4 pins, UART1 and UART2 2 pins */
1852 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0ME_MASK) | SDR0_PFC1_U1ME_DSR_DTR;
1853 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0IM_MASK) | SDR0_PFC1_U0IM_4PINS;
1854 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U1ME_MASK) | SDR0_PFC1_U1ME_DSR_DTR;
1856 case L4: /* L4 Selection */
1857 /* UART0, UART1, UART2 and UART3 2 pins */
1858 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0ME_MASK) | SDR0_PFC1_U0ME_DSR_DTR;
1859 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0IM_MASK) | SDR0_PFC1_U0IM_4PINS;
1860 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U1ME_MASK) | SDR0_PFC1_U1ME_DSR_DTR;
1863 update_uart_ios(uart_configuration, gpio_tab);
1865 /* UART Selection in all cases */
1866 uart_selection_in_fpga(uart_configuration);
1868 /* Packet Reject Function Available */
1869 if (ppc440ep_core_selection[PACKET_REJ_FUNC_AVAIL] == CORE_SELECTED)
1871 /* Set UPR Bit in SDR0_PFC1 Register */
1872 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_UPR_MASK) | SDR0_PFC1_UPR_ENABLE;
1875 /* Packet Reject Function Enable */
1876 if (ppc440ep_core_selection[PACKET_REJ_FUNC_EN] == CORE_SELECTED)
1878 mfsdr(SDR0_MFR, sdr0_mfr);
1879 sdr0_mfr = (sdr0_mfr & ~SDR0_MFR_PKT_REJ_MASK) | SDR0_MFR_PKT_REJ_EN;;
1880 mtsdr(SDR0_MFR, sdr0_mfr);
1883 /* Perform effective access to hardware */
1884 mtsdr(SDR0_PFC1, sdr0_pfc1);
1885 set_chip_gpio_configuration(GPIO0, gpio_tab);
1886 set_chip_gpio_configuration(GPIO1, gpio_tab);
1888 /* USB2.0 Device Reset must be done after GPIO setting */
1889 if (ppc440ep_core_selection[USB2_DEVICE] == CORE_SELECTED)
1890 usb2_device_reset_through_fpga();