gdppc440etx.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * (C) Copyright 2008
  3. * Dirk Eibach, Guntermann & Drunck GmbH, eibach@gdsys.de
  4. *
  5. * Based on board/amcc/yosemite/yosemite.c
  6. * (C) Copyright 2006-2007
  7. * Stefan Roese, DENX Software Engineering, sr@denx.de.
  8. *
  9. * SPDX-License-Identifier: GPL-2.0+
  10. */
  11. #include <common.h>
  12. #include <asm/ppc4xx.h>
  13. #include <asm/processor.h>
  14. #include <asm/io.h>
  15. #include <asm/4xx_pci.h>
  16. DECLARE_GLOBAL_DATA_PTR;
  17. /* info for FLASH chips */
  18. extern flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];
  19. int board_early_init_f(void)
  20. {
  21. register uint reg;
  22. /*
  23. * Setup the external bus controller/chip selects
  24. */
  25. mfebc(EBC0_CFG, reg);
  26. mtebc(EBC0_CFG, reg | 0x04000000); /* Set ATC */
  27. /*
  28. * Setup the GPIO pins
  29. */
  30. /* setup Address lines for flash size 64Meg. */
  31. out32(GPIO0_OSRL, in32(GPIO0_OSRL) | 0x54000000);
  32. out32(GPIO0_TSRL, in32(GPIO0_TSRL) | 0x54000000);
  33. out32(GPIO0_ISR1L, in32(GPIO0_ISR1L) | 0x54000000);
  34. /* setup emac */
  35. out32(GPIO0_TCR, in32(GPIO0_TCR) | 0xC080);
  36. out32(GPIO0_TSRL, in32(GPIO0_TSRL) | 0x40);
  37. out32(GPIO0_ISR1L, in32(GPIO0_ISR1L) | 0x55);
  38. out32(GPIO0_OSRH, in32(GPIO0_OSRH) | 0x50004000);
  39. out32(GPIO0_ISR1H, in32(GPIO0_ISR1H) | 0x00440000);
  40. /* UART0 and UART1*/
  41. out32(GPIO1_TCR, in32(GPIO1_TCR) | 0x16000000);
  42. out32(GPIO1_OSRL, in32(GPIO1_OSRL) | 0x02180000);
  43. out32(GPIO1_ISR1L, in32(GPIO1_ISR1L) | 0x00400000);
  44. out32(GPIO1_ISR2L, in32(GPIO1_ISR2L) | 0x04010000);
  45. /* disable boot-eeprom WP */
  46. out32(GPIO0_OSRL, in32(GPIO0_OSRL) & ~0x00C00000);
  47. out32(GPIO0_TSRL, in32(GPIO0_TSRL) & ~0x00C00000);
  48. out32(GPIO0_ISR1L, in32(GPIO0_ISR1L) & ~0x00C00000);
  49. out32(GPIO0_TCR, in32(GPIO0_TCR) | 0x08000000);
  50. out32(GPIO0_OR, in32(GPIO0_OR) & ~0x08000000);
  51. /* external interrupts IRQ0...3 */
  52. out32(GPIO1_TCR, in32(GPIO1_TCR) & ~0x00f00000);
  53. out32(GPIO1_TSRL, in32(GPIO1_TSRL) & ~0x00005500);
  54. out32(GPIO1_ISR1L, in32(GPIO1_ISR1L) | 0x00005500);
  55. /*
  56. * Setup the interrupt controller polarities, triggers, etc.
  57. */
  58. mtdcr(UIC0SR, 0xffffffff); /* clear all */
  59. mtdcr(UIC0ER, 0x00000000); /* disable all */
  60. mtdcr(UIC0CR, 0x00000009); /* ATI & UIC1 crit are critical */
  61. mtdcr(UIC0PR, 0xfffffe13); /* per ref-board manual */
  62. mtdcr(UIC0TR, 0x01c00008); /* per ref-board manual */
  63. mtdcr(UIC0VR, 0x00000001); /* int31 highest, base=0x000 */
  64. mtdcr(UIC0SR, 0xffffffff); /* clear all */
  65. mtdcr(UIC1SR, 0xffffffff); /* clear all */
  66. mtdcr(UIC1ER, 0x00000000); /* disable all */
  67. mtdcr(UIC1CR, 0x00000000); /* all non-critical */
  68. mtdcr(UIC1PR, 0xffffe0ff); /* per ref-board manual */
  69. mtdcr(UIC1TR, 0x00ffc000); /* per ref-board manual */
  70. mtdcr(UIC1VR, 0x00000001); /* int31 highest, base=0x000 */
  71. mtdcr(UIC1SR, 0xffffffff); /* clear all */
  72. /*
  73. * Setup other serial configuration
  74. */
  75. mfsdr(SDR0_PCI0, reg);
  76. mtsdr(SDR0_PCI0, 0x80000000 | reg); /* PCI arbiter enabled */
  77. mtsdr(SDR0_PFC0, 0x00003e00); /* Pin function */
  78. mtsdr(SDR0_PFC1, 0x00048000); /* Pin function: UART0 has 4 pins */
  79. return 0;
  80. }
  81. int misc_init_r(void)
  82. {
  83. uint pbcr;
  84. int size_val;
  85. uint sz;
  86. /* Re-do sizing to get full correct info */
  87. mfebc(PB0CR, pbcr);
  88. if (gd->bd->bi_flashsize > 0x08000000)
  89. panic("Max. flash banksize is 128 MB!\n");
  90. for (sz = gd->bd->bi_flashsize, size_val = 7;
  91. ((sz & 0x08000000) == 0) && (size_val > 0); --size_val)
  92. sz <<= 1;
  93. pbcr = (pbcr & 0x0001ffff) | gd->bd->bi_flashstart | (size_val << 17);
  94. mtebc(PB0CR, pbcr);
  95. /* adjust flash start and offset */
  96. gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
  97. gd->bd->bi_flashoffset = 0;
  98. /* Monitor protection ON by default */
  99. (void)flash_protect(FLAG_PROTECT_SET,
  100. -CONFIG_SYS_MONITOR_LEN,
  101. 0xffffffff,
  102. &flash_info[0]);
  103. return 0;
  104. }
  105. int checkboard(void)
  106. {
  107. char buf[64];
  108. int i = getenv_f("serial#", buf, sizeof(buf));
  109. printf("Board: GDPPC440ETX - G&D PPC440EP/GR ETX-module");
  110. if (i > 0) {
  111. puts(", serial# ");
  112. puts(buf);
  113. }
  114. putc('\n');
  115. return 0;
  116. }
  117. /*
  118. * Override weak pci_pre_init()
  119. */
  120. #if defined(CONFIG_PCI)
  121. int pci_pre_init(struct pci_controller *hose)
  122. {
  123. /* First call common code */
  124. __pci_pre_init(hose);
  125. /* enable 66 MHz ext. Clock */
  126. out32(GPIO1_TCR, in32(GPIO1_TCR) | 0x00008000);
  127. out32(GPIO1_OR, in32(GPIO1_OR) | 0x00008000);
  128. return 1;
  129. }
  130. #endif /* defined(CONFIG_PCI) */