gdppc440etx.c 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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. DECLARE_GLOBAL_DATA_PTR;
  32. /* info for FLASH chips */
  33. extern flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];
  34. int board_early_init_f(void)
  35. {
  36. register uint reg;
  37. /*
  38. * Setup the external bus controller/chip selects
  39. */
  40. mfebc(EBC0_CFG, reg);
  41. mtebc(EBC0_CFG, reg | 0x04000000); /* Set ATC */
  42. /*
  43. * Setup the GPIO pins
  44. */
  45. /* setup Address lines for flash size 64Meg. */
  46. out32(GPIO0_OSRL, in32(GPIO0_OSRL) | 0x54000000);
  47. out32(GPIO0_TSRL, in32(GPIO0_TSRL) | 0x54000000);
  48. out32(GPIO0_ISR1L, in32(GPIO0_ISR1L) | 0x54000000);
  49. /* setup emac */
  50. out32(GPIO0_TCR, in32(GPIO0_TCR) | 0xC080);
  51. out32(GPIO0_TSRL, in32(GPIO0_TSRL) | 0x40);
  52. out32(GPIO0_ISR1L, in32(GPIO0_ISR1L) | 0x55);
  53. out32(GPIO0_OSRH, in32(GPIO0_OSRH) | 0x50004000);
  54. out32(GPIO0_ISR1H, in32(GPIO0_ISR1H) | 0x00440000);
  55. /* UART0 and UART1*/
  56. out32(GPIO1_TCR, in32(GPIO1_TCR) | 0x16000000);
  57. out32(GPIO1_OSRL, in32(GPIO1_OSRL) | 0x02180000);
  58. out32(GPIO1_ISR1L, in32(GPIO1_ISR1L) | 0x00400000);
  59. out32(GPIO1_ISR2L, in32(GPIO1_ISR2L) | 0x04010000);
  60. /* disable boot-eeprom WP */
  61. out32(GPIO0_OSRL, in32(GPIO0_OSRL) & ~0x00C00000);
  62. out32(GPIO0_TSRL, in32(GPIO0_TSRL) & ~0x00C00000);
  63. out32(GPIO0_ISR1L, in32(GPIO0_ISR1L) & ~0x00C00000);
  64. out32(GPIO0_TCR, in32(GPIO0_TCR) | 0x08000000);
  65. out32(GPIO0_OR, in32(GPIO0_OR) & ~0x08000000);
  66. /* external interrupts IRQ0...3 */
  67. out32(GPIO1_TCR, in32(GPIO1_TCR) & ~0x00f00000);
  68. out32(GPIO1_TSRL, in32(GPIO1_TSRL) & ~0x00005500);
  69. out32(GPIO1_ISR1L, in32(GPIO1_ISR1L) | 0x00005500);
  70. /*
  71. * Setup the interrupt controller polarities, triggers, etc.
  72. */
  73. mtdcr(UIC0SR, 0xffffffff); /* clear all */
  74. mtdcr(UIC0ER, 0x00000000); /* disable all */
  75. mtdcr(UIC0CR, 0x00000009); /* ATI & UIC1 crit are critical */
  76. mtdcr(UIC0PR, 0xfffffe13); /* per ref-board manual */
  77. mtdcr(UIC0TR, 0x01c00008); /* per ref-board manual */
  78. mtdcr(UIC0VR, 0x00000001); /* int31 highest, base=0x000 */
  79. mtdcr(UIC0SR, 0xffffffff); /* clear all */
  80. mtdcr(UIC1SR, 0xffffffff); /* clear all */
  81. mtdcr(UIC1ER, 0x00000000); /* disable all */
  82. mtdcr(UIC1CR, 0x00000000); /* all non-critical */
  83. mtdcr(UIC1PR, 0xffffe0ff); /* per ref-board manual */
  84. mtdcr(UIC1TR, 0x00ffc000); /* per ref-board manual */
  85. mtdcr(UIC1VR, 0x00000001); /* int31 highest, base=0x000 */
  86. mtdcr(UIC1SR, 0xffffffff); /* clear all */
  87. /*
  88. * Setup other serial configuration
  89. */
  90. mfsdr(SDR0_PCI0, reg);
  91. mtsdr(SDR0_PCI0, 0x80000000 | reg); /* PCI arbiter enabled */
  92. mtsdr(SDR0_PFC0, 0x00003e00); /* Pin function */
  93. mtsdr(SDR0_PFC1, 0x00048000); /* Pin function: UART0 has 4 pins */
  94. return 0;
  95. }
  96. int misc_init_r(void)
  97. {
  98. uint pbcr;
  99. int size_val;
  100. uint sz;
  101. /* Re-do sizing to get full correct info */
  102. mfebc(PB0CR, pbcr);
  103. if (gd->bd->bi_flashsize > 0x08000000)
  104. panic("Max. flash banksize is 128 MB!\n");
  105. for (sz = gd->bd->bi_flashsize, size_val = 7;
  106. ((sz & 0x08000000) == 0) && (size_val > 0); --size_val)
  107. sz <<= 1;
  108. pbcr = (pbcr & 0x0001ffff) | gd->bd->bi_flashstart | (size_val << 17);
  109. mtebc(PB0CR, pbcr);
  110. /* adjust flash start and offset */
  111. gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
  112. gd->bd->bi_flashoffset = 0;
  113. /* Monitor protection ON by default */
  114. (void)flash_protect(FLAG_PROTECT_SET,
  115. -CONFIG_SYS_MONITOR_LEN,
  116. 0xffffffff,
  117. &flash_info[0]);
  118. return 0;
  119. }
  120. int checkboard(void)
  121. {
  122. char *s = getenv("serial#");
  123. printf("Board: GDPPC440ETX - G&D PPC440EP/GR ETX-module");
  124. if (s != NULL) {
  125. puts(", serial# ");
  126. puts(s);
  127. }
  128. putc('\n');
  129. return 0;
  130. }
  131. /*
  132. * pci_pre_init
  133. *
  134. * This routine is called just prior to registering the hose and gives
  135. * the board the opportunity to check things. Returning a value of zero
  136. * indicates that things are bad & PCI initialization should be aborted.
  137. *
  138. * Different boards may wish to customize the pci controller structure
  139. * (add regions, override default access routines, etc) or perform
  140. * certain pre-initialization actions.
  141. *
  142. */
  143. #if defined(CONFIG_PCI)
  144. int pci_pre_init(struct pci_controller *hose)
  145. {
  146. unsigned long addr;
  147. /*
  148. * Set priority for all PLB3 devices to 0.
  149. * Set PLB3 arbiter to fair mode.
  150. */
  151. mfsdr(SD0_AMP1, addr);
  152. mtsdr(SD0_AMP1, (addr & 0x000000FF) | 0x0000FF00);
  153. addr = mfdcr(PLB3_ACR);
  154. mtdcr(PLB3_ACR, addr | 0x80000000);
  155. /*
  156. * Set priority for all PLB4 devices to 0.
  157. */
  158. mfsdr(SD0_AMP0, addr);
  159. mtsdr(SD0_AMP0, (addr & 0x000000FF) | 0x0000FF00);
  160. addr = mfdcr(PLB4_ACR) | 0xa0000000; /* Was 0x8---- */
  161. mtdcr(PLB4_ACR, addr);
  162. /*
  163. * Set Nebula PLB4 arbiter to fair mode.
  164. */
  165. /* Segment0 */
  166. addr = (mfdcr(PLB0_ACR) & ~PLB0_ACR_PPM_MASK) | PLB0_ACR_PPM_FAIR;
  167. addr = (addr & ~PLB0_ACR_HBU_MASK) | PLB0_ACR_HBU_ENABLED;
  168. addr = (addr & ~PLB0_ACR_RDP_MASK) | PLB0_ACR_RDP_4DEEP;
  169. addr = (addr & ~PLB0_ACR_WRP_MASK) | PLB0_ACR_WRP_2DEEP;
  170. mtdcr(PLB0_ACR, addr);
  171. /* Segment1 */
  172. addr = (mfdcr(PLB1_ACR) & ~PLB1_ACR_PPM_MASK) | PLB1_ACR_PPM_FAIR;
  173. addr = (addr & ~PLB1_ACR_HBU_MASK) | PLB1_ACR_HBU_ENABLED;
  174. addr = (addr & ~PLB1_ACR_RDP_MASK) | PLB1_ACR_RDP_4DEEP;
  175. addr = (addr & ~PLB1_ACR_WRP_MASK) | PLB1_ACR_WRP_2DEEP;
  176. mtdcr(PLB1_ACR, addr);
  177. /* enable 66 MHz ext. Clock */
  178. out32(GPIO1_TCR, in32(GPIO1_TCR) | 0x00008000);
  179. out32(GPIO1_OR, in32(GPIO1_OR) | 0x00008000);
  180. return 1;
  181. }
  182. #endif /* defined(CONFIG_PCI) */
  183. /*
  184. * pci_target_init
  185. *
  186. * The bootstrap configuration provides default settings for the pci
  187. * inbound map (PIM). But the bootstrap config choices are limited and
  188. * may not be sufficient for a given board.
  189. *
  190. */
  191. #if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_TARGET_INIT)
  192. void pci_target_init(struct pci_controller *hose)
  193. {
  194. /*
  195. * Set up Direct MMIO registers
  196. */
  197. /*
  198. * PowerPC440 EP PCI Master configuration.
  199. * Map one 1Gig range of PLB/processor addresses to PCI memory space.
  200. * PLB address 0xA0000000-0xDFFFFFFF
  201. * ==> PCI address 0xA0000000-0xDFFFFFFF
  202. * Use byte reversed out routines to handle endianess.
  203. * Make this region non-prefetchable.
  204. */
  205. out32r(PCIL0_PMM0MA, 0x00000000); /* disabled b4 setting */
  206. out32r(PCIL0_PMM0LA, CONFIG_SYS_PCI_MEMBASE);
  207. out32r(PCIL0_PMM0PCILA, CONFIG_SYS_PCI_MEMBASE);
  208. out32r(PCIL0_PMM0PCIHA, 0x00000000);
  209. out32r(PCIL0_PMM0MA, 0xE0000001); /* 512M, no prefetch, enable region */
  210. out32r(PCIL0_PMM1MA, 0x00000000); /* disabled b4 setting */
  211. out32r(PCIL0_PMM1LA, CONFIG_SYS_PCI_MEMBASE2);
  212. out32r(PCIL0_PMM1PCILA, CONFIG_SYS_PCI_MEMBASE2);
  213. out32r(PCIL0_PMM1PCIHA, 0x00000000);
  214. out32r(PCIL0_PMM1MA, 0xE0000001); /* 512M, no prefetch, enable region */
  215. out32r(PCIL0_PTM1MS, 0x00000001);
  216. out32r(PCIL0_PTM1LA, 0);
  217. out32r(PCIL0_PTM2MS, 0);
  218. out32r(PCIL0_PTM2LA, 0);
  219. /*
  220. * Set up Configuration registers
  221. */
  222. /* Program the board's subsystem id/vendor id */
  223. pci_write_config_word(0, PCI_SUBSYSTEM_VENDOR_ID,
  224. CONFIG_SYS_PCI_SUBSYS_VENDORID);
  225. pci_write_config_word(0, PCI_SUBSYSTEM_ID, CONFIG_SYS_PCI_SUBSYS_ID);
  226. /* Configure command register as bus master */
  227. pci_write_config_word(0, PCI_COMMAND, PCI_COMMAND_MASTER);
  228. /* 240nS PCI clock */
  229. pci_write_config_word(0, PCI_LATENCY_TIMER, 1);
  230. /* No error reporting */
  231. pci_write_config_word(0, PCI_ERREN, 0);
  232. pci_write_config_dword(0, PCI_BRDGOPT2, 0x00000101);
  233. }
  234. #endif /* defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_TARGET_INIT) */
  235. /*
  236. * pci_master_init
  237. *
  238. */
  239. #if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT)
  240. void pci_master_init(struct pci_controller *hose)
  241. {
  242. unsigned short temp_short;
  243. /*
  244. * Write the PowerPC440 EP PCI Configuration regs.
  245. * Enable PowerPC440 EP to be a master on the PCI bus (PMM).
  246. * Enable PowerPC440 EP to act as a PCI memory target (PTM).
  247. */
  248. pci_read_config_word(0, PCI_COMMAND, &temp_short);
  249. pci_write_config_word(0, PCI_COMMAND,
  250. temp_short | PCI_COMMAND_MASTER |
  251. PCI_COMMAND_MEMORY);
  252. }
  253. #endif /* defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT) */
  254. /*
  255. * is_pci_host
  256. *
  257. * This routine is called to determine if a pci scan should be
  258. * performed. With various hardware environments (especially cPCI and
  259. * PPMC) it's insufficient to depend on the state of the arbiter enable
  260. * bit in the strap register, or generic host/adapter assumptions.
  261. *
  262. * Rather than hard-code a bad assumption in the general 440 code, the
  263. * 440 pci code requires the board to decide at runtime.
  264. *
  265. * Return 0 for adapter mode, non-zero for host (monarch) mode.
  266. *
  267. *
  268. */
  269. #if defined(CONFIG_PCI)
  270. int is_pci_host(struct pci_controller *hose)
  271. {
  272. return 1;
  273. }
  274. #endif /* defined(CONFIG_PCI) */