gdppc440etx.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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. * See file CREDITS for list of people who contributed to this
  10. * project.
  11. *
  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.
  16. *
  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.
  21. *
  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,
  25. * MA 02111-1307 USA
  26. */
  27. #include <common.h>
  28. #include <ppc4xx.h>
  29. #include <asm/processor.h>
  30. #include <asm/io.h>
  31. #include <asm/4xx_pci.h>
  32. DECLARE_GLOBAL_DATA_PTR;
  33. /* info for FLASH chips */
  34. extern flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];
  35. int board_early_init_f(void)
  36. {
  37. register uint reg;
  38. /*
  39. * Setup the external bus controller/chip selects
  40. */
  41. mfebc(EBC0_CFG, reg);
  42. mtebc(EBC0_CFG, reg | 0x04000000); /* Set ATC */
  43. /*
  44. * Setup the GPIO pins
  45. */
  46. /* setup Address lines for flash size 64Meg. */
  47. out32(GPIO0_OSRL, in32(GPIO0_OSRL) | 0x54000000);
  48. out32(GPIO0_TSRL, in32(GPIO0_TSRL) | 0x54000000);
  49. out32(GPIO0_ISR1L, in32(GPIO0_ISR1L) | 0x54000000);
  50. /* setup emac */
  51. out32(GPIO0_TCR, in32(GPIO0_TCR) | 0xC080);
  52. out32(GPIO0_TSRL, in32(GPIO0_TSRL) | 0x40);
  53. out32(GPIO0_ISR1L, in32(GPIO0_ISR1L) | 0x55);
  54. out32(GPIO0_OSRH, in32(GPIO0_OSRH) | 0x50004000);
  55. out32(GPIO0_ISR1H, in32(GPIO0_ISR1H) | 0x00440000);
  56. /* UART0 and UART1*/
  57. out32(GPIO1_TCR, in32(GPIO1_TCR) | 0x16000000);
  58. out32(GPIO1_OSRL, in32(GPIO1_OSRL) | 0x02180000);
  59. out32(GPIO1_ISR1L, in32(GPIO1_ISR1L) | 0x00400000);
  60. out32(GPIO1_ISR2L, in32(GPIO1_ISR2L) | 0x04010000);
  61. /* disable boot-eeprom WP */
  62. out32(GPIO0_OSRL, in32(GPIO0_OSRL) & ~0x00C00000);
  63. out32(GPIO0_TSRL, in32(GPIO0_TSRL) & ~0x00C00000);
  64. out32(GPIO0_ISR1L, in32(GPIO0_ISR1L) & ~0x00C00000);
  65. out32(GPIO0_TCR, in32(GPIO0_TCR) | 0x08000000);
  66. out32(GPIO0_OR, in32(GPIO0_OR) & ~0x08000000);
  67. /* external interrupts IRQ0...3 */
  68. out32(GPIO1_TCR, in32(GPIO1_TCR) & ~0x00f00000);
  69. out32(GPIO1_TSRL, in32(GPIO1_TSRL) & ~0x00005500);
  70. out32(GPIO1_ISR1L, in32(GPIO1_ISR1L) | 0x00005500);
  71. /*
  72. * Setup the interrupt controller polarities, triggers, etc.
  73. */
  74. mtdcr(UIC0SR, 0xffffffff); /* clear all */
  75. mtdcr(UIC0ER, 0x00000000); /* disable all */
  76. mtdcr(UIC0CR, 0x00000009); /* ATI & UIC1 crit are critical */
  77. mtdcr(UIC0PR, 0xfffffe13); /* per ref-board manual */
  78. mtdcr(UIC0TR, 0x01c00008); /* per ref-board manual */
  79. mtdcr(UIC0VR, 0x00000001); /* int31 highest, base=0x000 */
  80. mtdcr(UIC0SR, 0xffffffff); /* clear all */
  81. mtdcr(UIC1SR, 0xffffffff); /* clear all */
  82. mtdcr(UIC1ER, 0x00000000); /* disable all */
  83. mtdcr(UIC1CR, 0x00000000); /* all non-critical */
  84. mtdcr(UIC1PR, 0xffffe0ff); /* per ref-board manual */
  85. mtdcr(UIC1TR, 0x00ffc000); /* per ref-board manual */
  86. mtdcr(UIC1VR, 0x00000001); /* int31 highest, base=0x000 */
  87. mtdcr(UIC1SR, 0xffffffff); /* clear all */
  88. /*
  89. * Setup other serial configuration
  90. */
  91. mfsdr(SDR0_PCI0, reg);
  92. mtsdr(SDR0_PCI0, 0x80000000 | reg); /* PCI arbiter enabled */
  93. mtsdr(SDR0_PFC0, 0x00003e00); /* Pin function */
  94. mtsdr(SDR0_PFC1, 0x00048000); /* Pin function: UART0 has 4 pins */
  95. return 0;
  96. }
  97. int misc_init_r(void)
  98. {
  99. uint pbcr;
  100. int size_val;
  101. uint sz;
  102. /* Re-do sizing to get full correct info */
  103. mfebc(PB0CR, pbcr);
  104. if (gd->bd->bi_flashsize > 0x08000000)
  105. panic("Max. flash banksize is 128 MB!\n");
  106. for (sz = gd->bd->bi_flashsize, size_val = 7;
  107. ((sz & 0x08000000) == 0) && (size_val > 0); --size_val)
  108. sz <<= 1;
  109. pbcr = (pbcr & 0x0001ffff) | gd->bd->bi_flashstart | (size_val << 17);
  110. mtebc(PB0CR, pbcr);
  111. /* adjust flash start and offset */
  112. gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
  113. gd->bd->bi_flashoffset = 0;
  114. /* Monitor protection ON by default */
  115. (void)flash_protect(FLAG_PROTECT_SET,
  116. -CONFIG_SYS_MONITOR_LEN,
  117. 0xffffffff,
  118. &flash_info[0]);
  119. return 0;
  120. }
  121. int checkboard(void)
  122. {
  123. char *s = getenv("serial#");
  124. printf("Board: GDPPC440ETX - G&D PPC440EP/GR ETX-module");
  125. if (s != NULL) {
  126. puts(", serial# ");
  127. puts(s);
  128. }
  129. putc('\n');
  130. return 0;
  131. }
  132. /*
  133. * Override weak pci_pre_init()
  134. */
  135. #if defined(CONFIG_PCI)
  136. int pci_pre_init(struct pci_controller *hose)
  137. {
  138. /* First call common code */
  139. __pci_pre_init(hose);
  140. /* enable 66 MHz ext. Clock */
  141. out32(GPIO1_TCR, in32(GPIO1_TCR) | 0x00008000);
  142. out32(GPIO1_OR, in32(GPIO1_OR) | 0x00008000);
  143. return 1;
  144. }
  145. #endif /* defined(CONFIG_PCI) */
  146. /*
  147. * pci_master_init
  148. *
  149. */
  150. #if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT)
  151. void pci_master_init(struct pci_controller *hose)
  152. {
  153. unsigned short temp_short;
  154. /*
  155. * Write the PowerPC440 EP PCI Configuration regs.
  156. * Enable PowerPC440 EP to be a master on the PCI bus (PMM).
  157. * Enable PowerPC440 EP to act as a PCI memory target (PTM).
  158. */
  159. pci_read_config_word(0, PCI_COMMAND, &temp_short);
  160. pci_write_config_word(0, PCI_COMMAND,
  161. temp_short | PCI_COMMAND_MASTER |
  162. PCI_COMMAND_MEMORY);
  163. }
  164. #endif /* defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT) */