makalu.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. /*
  2. * (C) Copyright 2007
  3. * Stefan Roese, DENX Software Engineering, sr@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <ppc4xx.h>
  25. #include <ppc405.h>
  26. #include <libfdt.h>
  27. #include <asm/processor.h>
  28. #include <asm-ppc/io.h>
  29. #if defined(CONFIG_PCI)
  30. #include <pci.h>
  31. #include <asm/4xx_pcie.h>
  32. #endif
  33. DECLARE_GLOBAL_DATA_PTR;
  34. extern flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
  35. /*
  36. * Board early initialization function
  37. */
  38. int board_early_init_f (void)
  39. {
  40. /*--------------------------------------------------------------------+
  41. | Interrupt controller setup for the AMCC 405EX(r) PINE evaluation board.
  42. +--------------------------------------------------------------------+
  43. +---------------------------------------------------------------------+
  44. |Interrupt| Source | Pol. | Sensi.| Crit. |
  45. +---------+-----------------------------------+-------+-------+-------+
  46. | IRQ 00 | UART0 | High | Level | Non |
  47. | IRQ 01 | UART1 | High | Level | Non |
  48. | IRQ 02 | IIC0 | High | Level | Non |
  49. | IRQ 03 | TBD | High | Level | Non |
  50. | IRQ 04 | TBD | High | Level | Non |
  51. | IRQ 05 | EBM | High | Level | Non |
  52. | IRQ 06 | BGI | High | Level | Non |
  53. | IRQ 07 | IIC1 | Rising| Edge | Non |
  54. | IRQ 08 | SPI | High | Lvl/ed| Non |
  55. | IRQ 09 | External IRQ 0 - (PCI-Express) | pgm H | Pgm | Non |
  56. | IRQ 10 | MAL TX EOB | High | Level | Non |
  57. | IRQ 11 | MAL RX EOB | High | Level | Non |
  58. | IRQ 12 | DMA Channel 0 FIFO Full | High | Level | Non |
  59. | IRQ 13 | DMA Channel 0 Stat FIFO | High | Level | Non |
  60. | IRQ 14 | DMA Channel 1 FIFO Full | High | Level | Non |
  61. | IRQ 15 | DMA Channel 1 Stat FIFO | High | Level | Non |
  62. | IRQ 16 | PCIE0 AL | high | Level | Non |
  63. | IRQ 17 | PCIE0 VPD access | rising| Edge | Non |
  64. | IRQ 18 | PCIE0 hot reset request | rising| Edge | Non |
  65. | IRQ 19 | PCIE0 hot reset request | faling| Edge | Non |
  66. | IRQ 20 | PCIE0 TCR | High | Level | Non |
  67. | IRQ 21 | PCIE0 MSI level0 | High | Level | Non |
  68. | IRQ 22 | PCIE0 MSI level1 | High | Level | Non |
  69. | IRQ 23 | Security EIP-94 | High | Level | Non |
  70. | IRQ 24 | EMAC0 interrupt | High | Level | Non |
  71. | IRQ 25 | EMAC1 interrupt | High | Level | Non |
  72. | IRQ 26 | PCIE0 MSI level2 | High | Level | Non |
  73. | IRQ 27 | External IRQ 4 | pgm H | Pgm | Non |
  74. | IRQ 28 | UIC2 Non-critical Int. | High | Level | Non |
  75. | IRQ 29 | UIC2 Critical Interrupt | High | Level | Crit. |
  76. | IRQ 30 | UIC1 Non-critical Int. | High | Level | Non |
  77. | IRQ 31 | UIC1 Critical Interrupt | High | Level | Crit. |
  78. |----------------------------------------------------------------------
  79. | IRQ 32 | MAL Serr | High | Level | Non |
  80. | IRQ 33 | MAL Txde | High | Level | Non |
  81. | IRQ 34 | MAL Rxde | High | Level | Non |
  82. | IRQ 35 | PCIE0 bus master VC0 |falling| Edge | Non |
  83. | IRQ 36 | PCIE0 DCR Error | High | Level | Non |
  84. | IRQ 37 | EBC | High |Lvl Edg| Non |
  85. | IRQ 38 | NDFC | High | Level | Non |
  86. | IRQ 39 | GPT Compare Timer 8 | Risin | Edge | Non |
  87. | IRQ 40 | GPT Compare Timer 9 | Risin | Edge | Non |
  88. | IRQ 41 | PCIE1 AL | high | Level | Non |
  89. | IRQ 42 | PCIE1 VPD access | rising| edge | Non |
  90. | IRQ 43 | PCIE1 hot reset request | rising| Edge | Non |
  91. | IRQ 44 | PCIE1 hot reset request | faling| Edge | Non |
  92. | IRQ 45 | PCIE1 TCR | High | Level | Non |
  93. | IRQ 46 | PCIE1 bus master VC0 |falling| Edge | Non |
  94. | IRQ 47 | GPT Compare Timer 3 | Risin | Edge | Non |
  95. | IRQ 48 | GPT Compare Timer 4 | Risin | Edge | Non |
  96. | IRQ 49 | Ext. IRQ 7 |pgm/Fal|pgm/Lvl| Non |
  97. | IRQ 50 | Ext. IRQ 8 - |pgm (H)|pgm/Lvl| Non |
  98. | IRQ 51 | Ext. IRQ 9 |pgm (H)|pgm/Lvl| Non |
  99. | IRQ 52 | GPT Compare Timer 5 | high | Edge | Non |
  100. | IRQ 53 | GPT Compare Timer 6 | high | Edge | Non |
  101. | IRQ 54 | GPT Compare Timer 7 | high | Edge | Non |
  102. | IRQ 55 | Serial ROM | High | Level | Non |
  103. | IRQ 56 | GPT Decrement Pulse | High | Level | Non |
  104. | IRQ 57 | Ext. IRQ 2 |pgm/Fal|pgm/Lvl| Non |
  105. | IRQ 58 | Ext. IRQ 5 |pgm/Fal|pgm/Lvl| Non |
  106. | IRQ 59 | Ext. IRQ 6 |pgm/Fal|pgm/Lvl| Non |
  107. | IRQ 60 | EMAC0 Wake-up | High | Level | Non |
  108. | IRQ 61 | Ext. IRQ 1 |pgm/Fal|pgm/Lvl| Non |
  109. | IRQ 62 | EMAC1 Wake-up | High | Level | Non |
  110. |----------------------------------------------------------------------
  111. | IRQ 64 | PE0 AL | High | Level | Non |
  112. | IRQ 65 | PE0 VPD Access | Risin | Edge | Non |
  113. | IRQ 66 | PE0 Hot Reset Request | Risin | Edge | Non |
  114. | IRQ 67 | PE0 Hot Reset Request | Falli | Edge | Non |
  115. | IRQ 68 | PE0 TCR | High | Level | Non |
  116. | IRQ 69 | PE0 BusMaster VCO | Falli | Edge | Non |
  117. | IRQ 70 | PE0 DCR Error | High | Level | Non |
  118. | IRQ 71 | Reserved | N/A | N/A | Non |
  119. | IRQ 72 | PE1 AL | High | Level | Non |
  120. | IRQ 73 | PE1 VPD Access | Risin | Edge | Non |
  121. | IRQ 74 | PE1 Hot Reset Request | Risin | Edge | Non |
  122. | IRQ 75 | PE1 Hot Reset Request | Falli | Edge | Non |
  123. | IRQ 76 | PE1 TCR | High | Level | Non |
  124. | IRQ 77 | PE1 BusMaster VCO | Falli | Edge | Non |
  125. | IRQ 78 | PE1 DCR Error | High | Level | Non |
  126. | IRQ 79 | Reserved | N/A | N/A | Non |
  127. | IRQ 80 | PE2 AL | High | Level | Non |
  128. | IRQ 81 | PE2 VPD Access | Risin | Edge | Non |
  129. | IRQ 82 | PE2 Hot Reset Request | Risin | Edge | Non |
  130. | IRQ 83 | PE2 Hot Reset Request | Falli | Edge | Non |
  131. | IRQ 84 | PE2 TCR | High | Level | Non |
  132. | IRQ 85 | PE2 BusMaster VCO | Falli | Edge | Non |
  133. | IRQ 86 | PE2 DCR Error | High | Level | Non |
  134. | IRQ 87 | Reserved | N/A | N/A | Non |
  135. | IRQ 88 | External IRQ(5) | Progr | Progr | Non |
  136. | IRQ 89 | External IRQ 4 - Ethernet | Progr | Progr | Non |
  137. | IRQ 90 | External IRQ 3 - PCI-X | Progr | Progr | Non |
  138. | IRQ 91 | External IRQ 2 - PCI-X | Progr | Progr | Non |
  139. | IRQ 92 | External IRQ 1 - PCI-X | Progr | Progr | Non |
  140. | IRQ 93 | External IRQ 0 - PCI-X | Progr | Progr | Non |
  141. | IRQ 94 | Reserved | N/A | N/A | Non |
  142. | IRQ 95 | Reserved | N/A | N/A | Non |
  143. |---------------------------------------------------------------------
  144. +---------+-----------------------------------+-------+-------+------*/
  145. /*--------------------------------------------------------------------+
  146. | Initialise UIC registers. Clear all interrupts. Disable all
  147. | interrupts.
  148. | Set critical interrupt values. Set interrupt polarities. Set
  149. | interrupt trigger levels. Make bit 0 High priority. Clear all
  150. | interrupts again.
  151. +-------------------------------------------------------------------*/
  152. mtdcr (uic2sr, 0xffffffff); /* Clear all interrupts */
  153. mtdcr (uic2er, 0x00000000); /* disable all interrupts */
  154. mtdcr (uic2cr, 0x00000000); /* Set Critical / Non Critical interrupts */
  155. mtdcr (uic2pr, 0xf7ffffff); /* Set Interrupt Polarities */
  156. mtdcr (uic2tr, 0x01e1fff8); /* Set Interrupt Trigger Levels */
  157. mtdcr (uic2vr, 0x00000001); /* Set Vect base=0,INT31 Highest priority */
  158. mtdcr (uic2sr, 0x00000000); /* clear all interrupts */
  159. mtdcr (uic2sr, 0xffffffff); /* clear all interrupts */
  160. mtdcr (uic1sr, 0xffffffff); /* Clear all interrupts */
  161. mtdcr (uic1er, 0x00000000); /* disable all interrupts */
  162. mtdcr (uic1cr, 0x00000000); /* Set Critical / Non Critical interrupts */
  163. mtdcr (uic1pr, 0xfffac785); /* Set Interrupt Polarities */
  164. mtdcr (uic1tr, 0x001d0040); /* Set Interrupt Trigger Levels */
  165. mtdcr (uic1vr, 0x00000001); /* Set Vect base=0,INT31 Highest priority */
  166. mtdcr (uic1sr, 0x00000000); /* clear all interrupts */
  167. mtdcr (uic1sr, 0xffffffff); /* clear all interrupts */
  168. mtdcr (uic0sr, 0xffffffff); /* Clear all interrupts */
  169. mtdcr (uic0er, 0x0000000a); /* Disable all interrupts */
  170. /* Except cascade UIC0 and UIC1 */
  171. mtdcr (uic0cr, 0x00000000); /* Set Critical / Non Critical interrupts */
  172. mtdcr (uic0pr, 0xffbfefef); /* Set Interrupt Polarities */
  173. mtdcr (uic0tr, 0x00007000); /* Set Interrupt Trigger Levels */
  174. mtdcr (uic0vr, 0x00000001); /* Set Vect base=0,INT31 Highest priority */
  175. mtdcr (uic0sr, 0x00000000); /* clear all interrupts */
  176. mtdcr (uic0sr, 0xffffffff); /* clear all interrupts */
  177. /*
  178. * Note: Some cores are still in reset when the chip starts, so
  179. * take them out of reset
  180. */
  181. mtsdr(SDR0_SRST, 0);
  182. return 0;
  183. }
  184. int misc_init_r(void)
  185. {
  186. #ifdef CFG_ENV_IS_IN_FLASH
  187. /* Monitor protection ON by default */
  188. flash_protect(FLAG_PROTECT_SET,
  189. -CFG_MONITOR_LEN,
  190. 0xffffffff,
  191. &flash_info[0]);
  192. #endif
  193. return 0;
  194. }
  195. int checkboard (void)
  196. {
  197. char *s = getenv("serial#");
  198. printf("Board: Makalu - AMCC PPC405EX Evaluation Board");
  199. if (s != NULL) {
  200. puts(", serial# ");
  201. puts(s);
  202. }
  203. putc('\n');
  204. return (0);
  205. }
  206. /*************************************************************************
  207. * pci_pre_init
  208. *
  209. * This routine is called just prior to registering the hose and gives
  210. * the board the opportunity to check things. Returning a value of zero
  211. * indicates that things are bad & PCI initialization should be aborted.
  212. *
  213. * Different boards may wish to customize the pci controller structure
  214. * (add regions, override default access routines, etc) or perform
  215. * certain pre-initialization actions.
  216. *
  217. ************************************************************************/
  218. #if defined(CONFIG_PCI)
  219. int pci_pre_init(struct pci_controller * hose )
  220. {
  221. return 0;
  222. }
  223. #endif /* defined(CONFIG_PCI) */
  224. /*************************************************************************
  225. * pci_target_init
  226. *
  227. * The bootstrap configuration provides default settings for the pci
  228. * inbound map (PIM). But the bootstrap config choices are limited and
  229. * may not be sufficient for a given board.
  230. *
  231. ************************************************************************/
  232. #if defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT)
  233. void pci_target_init(struct pci_controller * hose )
  234. {
  235. /*-------------------------------------------------------------------+
  236. * Disable everything
  237. *-------------------------------------------------------------------*/
  238. out32r( PCIX0_PIM0SA, 0 ); /* disable */
  239. out32r( PCIX0_PIM1SA, 0 ); /* disable */
  240. out32r( PCIX0_PIM2SA, 0 ); /* disable */
  241. out32r( PCIX0_EROMBA, 0 ); /* disable expansion rom */
  242. /*-------------------------------------------------------------------+
  243. * Map all of SDRAM to PCI address 0x0000_0000. Note that the 440
  244. * strapping options to not support sizes such as 128/256 MB.
  245. *-------------------------------------------------------------------*/
  246. out32r( PCIX0_PIM0LAL, CFG_SDRAM_BASE );
  247. out32r( PCIX0_PIM0LAH, 0 );
  248. out32r( PCIX0_PIM0SA, ~(gd->ram_size - 1) | 1 );
  249. out32r( PCIX0_BAR0, 0 );
  250. /*-------------------------------------------------------------------+
  251. * Program the board's subsystem id/vendor id
  252. *-------------------------------------------------------------------*/
  253. out16r( PCIX0_SBSYSVID, CFG_PCI_SUBSYS_VENDORID );
  254. out16r( PCIX0_SBSYSID, CFG_PCI_SUBSYS_DEVICEID );
  255. out16r( PCIX0_CMD, in16r(PCIX0_CMD) | PCI_COMMAND_MEMORY );
  256. }
  257. #endif /* defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT) */
  258. #ifdef CONFIG_PCI
  259. static struct pci_controller pcie_hose[2] = {{0},{0}};
  260. void pcie_setup_hoses(int busno)
  261. {
  262. struct pci_controller *hose;
  263. int i, bus;
  264. int ret = 0;
  265. bus = busno;
  266. char *env;
  267. unsigned int delay;
  268. for (i = 0; i < 2; i++) {
  269. if (is_end_point(i)) {
  270. printf("PCIE%d: will be configured as endpoint\n", i);
  271. ret = ppc4xx_init_pcie_endport(i);
  272. } else {
  273. printf("PCIE%d: will be configured as root-complex\n", i);
  274. ret = ppc4xx_init_pcie_rootport(i);
  275. }
  276. if (ret) {
  277. printf("PCIE%d: initialization failed\n", i);
  278. continue;
  279. }
  280. hose = &pcie_hose[i];
  281. hose->first_busno = bus;
  282. hose->last_busno = bus;
  283. hose->current_busno = bus;
  284. /* setup mem resource */
  285. pci_set_region(hose->regions + 0,
  286. CFG_PCIE_MEMBASE + i * CFG_PCIE_MEMSIZE,
  287. CFG_PCIE_MEMBASE + i * CFG_PCIE_MEMSIZE,
  288. CFG_PCIE_MEMSIZE,
  289. PCI_REGION_MEM);
  290. hose->region_count = 1;
  291. pci_register_hose(hose);
  292. if (is_end_point(i)) {
  293. ppc4xx_setup_pcie_endpoint(hose, i);
  294. /*
  295. * Reson for no scanning is endpoint can not generate
  296. * upstream configuration accesses.
  297. */
  298. } else {
  299. ppc4xx_setup_pcie_rootpoint(hose, i);
  300. env = getenv ("pciscandelay");
  301. if (env != NULL) {
  302. delay = simple_strtoul(env, NULL, 10);
  303. if (delay > 5)
  304. printf("Warning, expect noticable delay before "
  305. "PCIe scan due to 'pciscandelay' value!\n");
  306. mdelay(delay * 1000);
  307. }
  308. /*
  309. * Config access can only go down stream
  310. */
  311. hose->last_busno = pci_hose_scan(hose);
  312. bus = hose->last_busno + 1;
  313. }
  314. }
  315. }
  316. #endif
  317. #if defined(CONFIG_POST)
  318. /*
  319. * Returns 1 if keys pressed to start the power-on long-running tests
  320. * Called from board_init_f().
  321. */
  322. int post_hotkeys_pressed(void)
  323. {
  324. return 0; /* No hotkeys supported */
  325. }
  326. #endif /* CONFIG_POST */
  327. #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
  328. void ft_board_setup(void *blob, bd_t *bd)
  329. {
  330. u32 val[4];
  331. int rc;
  332. ft_cpu_setup(blob, bd);
  333. /* Fixup NOR mapping */
  334. val[0] = 0; /* chip select number */
  335. val[1] = 0; /* always 0 */
  336. val[2] = gd->bd->bi_flashstart;
  337. val[3] = gd->bd->bi_flashsize;
  338. rc = fdt_find_and_setprop(blob, "/plb/opb/ebc", "ranges",
  339. val, sizeof(val), 1);
  340. if (rc)
  341. printf("Unable to update property NOR mapping, err=%s\n",
  342. fdt_strerror(rc));
  343. }
  344. #endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */