mpc8360erdk.c 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. /*
  2. * Copyright (C) 2006 Freescale Semiconductor, Inc.
  3. * Dave Liu <daveliu@freescale.com>
  4. *
  5. * Copyright (C) 2007 Logic Product Development, Inc.
  6. * Peter Barada <peterb@logicpd.com>
  7. *
  8. * Copyright (C) 2007 MontaVista Software, Inc.
  9. * Anton Vorontsov <avorontsov@ru.mvista.com>
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. */
  16. #include <common.h>
  17. #include <ioports.h>
  18. #include <mpc83xx.h>
  19. #include <i2c.h>
  20. #include <miiphy.h>
  21. #include <asm/io.h>
  22. #include <asm/mmu.h>
  23. #include <pci.h>
  24. #include <libfdt.h>
  25. const qe_iop_conf_t qe_iop_conf_tab[] = {
  26. /* MDIO */
  27. {0, 1, 3, 0, 2}, /* MDIO */
  28. {0, 2, 1, 0, 1}, /* MDC */
  29. /* UCC1 - UEC (Gigabit) */
  30. {0, 3, 1, 0, 1}, /* TxD0 */
  31. {0, 4, 1, 0, 1}, /* TxD1 */
  32. {0, 5, 1, 0, 1}, /* TxD2 */
  33. {0, 6, 1, 0, 1}, /* TxD3 */
  34. {0, 9, 2, 0, 1}, /* RxD0 */
  35. {0, 10, 2, 0, 1}, /* RxD1 */
  36. {0, 11, 2, 0, 1}, /* RxD2 */
  37. {0, 12, 2, 0, 1}, /* RxD3 */
  38. {0, 7, 1, 0, 1}, /* TX_EN */
  39. {0, 8, 1, 0, 1}, /* TX_ER */
  40. {0, 15, 2, 0, 1}, /* RX_DV */
  41. {0, 0, 2, 0, 1}, /* RX_CLK */
  42. {2, 9, 1, 0, 3}, /* GTX_CLK - CLK10 */
  43. {2, 8, 2, 0, 1}, /* GTX125 - CLK9 */
  44. /* UCC2 - UEC (Gigabit) */
  45. {0, 17, 1, 0, 1}, /* TxD0 */
  46. {0, 18, 1, 0, 1}, /* TxD1 */
  47. {0, 19, 1, 0, 1}, /* TxD2 */
  48. {0, 20, 1, 0, 1}, /* TxD3 */
  49. {0, 23, 2, 0, 1}, /* RxD0 */
  50. {0, 24, 2, 0, 1}, /* RxD1 */
  51. {0, 25, 2, 0, 1}, /* RxD2 */
  52. {0, 26, 2, 0, 1}, /* RxD3 */
  53. {0, 21, 1, 0, 1}, /* TX_EN */
  54. {0, 22, 1, 0, 1}, /* TX_ER */
  55. {0, 29, 2, 0, 1}, /* RX_DV */
  56. {0, 31, 2, 0, 1}, /* RX_CLK */
  57. {2, 2, 1, 0, 2}, /* GTX_CLK - CLK10 */
  58. {2, 3, 2, 0, 1}, /* GTX125 - CLK4 */
  59. /* UCC7 - UEC */
  60. {4, 0, 1, 0, 1}, /* TxD0 */
  61. {4, 1, 1, 0, 1}, /* TxD1 */
  62. {4, 2, 1, 0, 1}, /* TxD2 */
  63. {4, 3, 1, 0, 1}, /* TxD3 */
  64. {4, 6, 2, 0, 1}, /* RxD0 */
  65. {4, 7, 2, 0, 1}, /* RxD1 */
  66. {4, 8, 2, 0, 1}, /* RxD2 */
  67. {4, 9, 2, 0, 1}, /* RxD3 */
  68. {4, 4, 1, 0, 1}, /* TX_EN */
  69. {4, 5, 1, 0, 1}, /* TX_ER */
  70. {4, 12, 2, 0, 1}, /* RX_DV */
  71. {4, 13, 2, 0, 1}, /* RX_ER */
  72. {4, 10, 2, 0, 1}, /* COL */
  73. {4, 11, 2, 0, 1}, /* CRS */
  74. {2, 18, 2, 0, 1}, /* TX_CLK - CLK19 */
  75. {2, 19, 2, 0, 1}, /* RX_CLK - CLK20 */
  76. /* UCC4 - UEC */
  77. {1, 14, 1, 0, 1}, /* TxD0 */
  78. {1, 15, 1, 0, 1}, /* TxD1 */
  79. {1, 16, 1, 0, 1}, /* TxD2 */
  80. {1, 17, 1, 0, 1}, /* TxD3 */
  81. {1, 20, 2, 0, 1}, /* RxD0 */
  82. {1, 21, 2, 0, 1}, /* RxD1 */
  83. {1, 22, 2, 0, 1}, /* RxD2 */
  84. {1, 23, 2, 0, 1}, /* RxD3 */
  85. {1, 18, 1, 0, 1}, /* TX_EN */
  86. {1, 19, 1, 0, 2}, /* TX_ER */
  87. {1, 26, 2, 0, 1}, /* RX_DV */
  88. {1, 27, 2, 0, 1}, /* RX_ER */
  89. {1, 24, 2, 0, 1}, /* COL */
  90. {1, 25, 2, 0, 1}, /* CRS */
  91. {2, 6, 2, 0, 1}, /* TX_CLK - CLK7 */
  92. {2, 7, 2, 0, 1}, /* RX_CLK - CLK8 */
  93. /* PCI1 */
  94. {5, 4, 2, 0, 3}, /* PCI_M66EN */
  95. {5, 5, 1, 0, 3}, /* PCI_INTA */
  96. {5, 6, 1, 0, 3}, /* PCI_RSTO */
  97. {5, 7, 3, 0, 3}, /* PCI_C_BE0 */
  98. {5, 8, 3, 0, 3}, /* PCI_C_BE1 */
  99. {5, 9, 3, 0, 3}, /* PCI_C_BE2 */
  100. {5, 10, 3, 0, 3}, /* PCI_C_BE3 */
  101. {5, 11, 3, 0, 3}, /* PCI_PAR */
  102. {5, 12, 3, 0, 3}, /* PCI_FRAME */
  103. {5, 13, 3, 0, 3}, /* PCI_TRDY */
  104. {5, 14, 3, 0, 3}, /* PCI_IRDY */
  105. {5, 15, 3, 0, 3}, /* PCI_STOP */
  106. {5, 16, 3, 0, 3}, /* PCI_DEVSEL */
  107. {5, 17, 0, 0, 0}, /* PCI_IDSEL */
  108. {5, 18, 3, 0, 3}, /* PCI_SERR */
  109. {5, 19, 3, 0, 3}, /* PCI_PERR */
  110. {5, 20, 3, 0, 3}, /* PCI_REQ0 */
  111. {5, 21, 2, 0, 3}, /* PCI_REQ1 */
  112. {5, 22, 2, 0, 3}, /* PCI_GNT2 */
  113. {5, 23, 3, 0, 3}, /* PCI_GNT0 */
  114. {5, 24, 1, 0, 3}, /* PCI_GNT1 */
  115. {5, 25, 1, 0, 3}, /* PCI_GNT2 */
  116. {5, 26, 0, 0, 0}, /* PCI_CLK0 */
  117. {5, 27, 0, 0, 0}, /* PCI_CLK1 */
  118. {5, 28, 0, 0, 0}, /* PCI_CLK2 */
  119. {5, 29, 0, 0, 3}, /* PCI_SYNC_OUT */
  120. {6, 0, 3, 0, 3}, /* PCI_AD0 */
  121. {6, 1, 3, 0, 3}, /* PCI_AD1 */
  122. {6, 2, 3, 0, 3}, /* PCI_AD2 */
  123. {6, 3, 3, 0, 3}, /* PCI_AD3 */
  124. {6, 4, 3, 0, 3}, /* PCI_AD4 */
  125. {6, 5, 3, 0, 3}, /* PCI_AD5 */
  126. {6, 6, 3, 0, 3}, /* PCI_AD6 */
  127. {6, 7, 3, 0, 3}, /* PCI_AD7 */
  128. {6, 8, 3, 0, 3}, /* PCI_AD8 */
  129. {6, 9, 3, 0, 3}, /* PCI_AD9 */
  130. {6, 10, 3, 0, 3}, /* PCI_AD10 */
  131. {6, 11, 3, 0, 3}, /* PCI_AD11 */
  132. {6, 12, 3, 0, 3}, /* PCI_AD12 */
  133. {6, 13, 3, 0, 3}, /* PCI_AD13 */
  134. {6, 14, 3, 0, 3}, /* PCI_AD14 */
  135. {6, 15, 3, 0, 3}, /* PCI_AD15 */
  136. {6, 16, 3, 0, 3}, /* PCI_AD16 */
  137. {6, 17, 3, 0, 3}, /* PCI_AD17 */
  138. {6, 18, 3, 0, 3}, /* PCI_AD18 */
  139. {6, 19, 3, 0, 3}, /* PCI_AD19 */
  140. {6, 20, 3, 0, 3}, /* PCI_AD20 */
  141. {6, 21, 3, 0, 3}, /* PCI_AD21 */
  142. {6, 22, 3, 0, 3}, /* PCI_AD22 */
  143. {6, 23, 3, 0, 3}, /* PCI_AD23 */
  144. {6, 24, 3, 0, 3}, /* PCI_AD24 */
  145. {6, 25, 3, 0, 3}, /* PCI_AD25 */
  146. {6, 26, 3, 0, 3}, /* PCI_AD26 */
  147. {6, 27, 3, 0, 3}, /* PCI_AD27 */
  148. {6, 28, 3, 0, 3}, /* PCI_AD28 */
  149. {6, 29, 3, 0, 3}, /* PCI_AD29 */
  150. {6, 30, 3, 0, 3}, /* PCI_AD30 */
  151. {6, 31, 3, 0, 3}, /* PCI_AD31 */
  152. /* NAND */
  153. {4, 18, 2, 0, 0}, /* NAND_RYnBY */
  154. /* DUART - UART2 */
  155. {5, 0, 1, 0, 2}, /* UART2_SOUT */
  156. {5, 2, 1, 0, 1}, /* UART2_RTS */
  157. {5, 3, 2, 0, 2}, /* UART2_SIN */
  158. {5, 1, 2, 0, 3}, /* UART2_CTS */
  159. /* UCC5 - UART3 */
  160. {3, 0, 1, 0, 1}, /* UART3_TX */
  161. {3, 4, 1, 0, 1}, /* UART3_RTS */
  162. {3, 6, 2, 0, 1}, /* UART3_RX */
  163. {3, 12, 2, 0, 0}, /* UART3_CTS */
  164. {3, 13, 2, 0, 0}, /* UCC5_CD */
  165. /* UCC6 - UART4 */
  166. {3, 14, 1, 0, 1}, /* UART4_TX */
  167. {3, 18, 1, 0, 1}, /* UART4_RTS */
  168. {3, 20, 2, 0, 1}, /* UART4_RX */
  169. {3, 26, 2, 0, 0}, /* UART4_CTS */
  170. {3, 27, 2, 0, 0}, /* UCC6_CD */
  171. /* Fujitsu MB86277 (MINT) graphics controller */
  172. {0, 30, 1, 0, 0}, /* nSRESET_GRAPHICS */
  173. {1, 5, 1, 0, 0}, /* nXRST_GRAPHICS */
  174. {1, 7, 1, 0, 0}, /* LVDS_BKLT_CTR */
  175. {2, 16, 1, 0, 0}, /* LVDS_BKLT_EN */
  176. /* AD7843 ADC/Touchscreen controller */
  177. {4, 14, 1, 0, 0}, /* SPI_nCS0 */
  178. {4, 28, 3, 0, 3}, /* SPI_MOSI */
  179. {4, 29, 3, 0, 3}, /* SPI_MISO */
  180. {4, 30, 3, 0, 3}, /* SPI_CLK */
  181. /* Freescale QUICC Engine USB Host Controller (FHCI) */
  182. {1, 2, 1, 0, 3}, /* USBOE */
  183. {1, 3, 1, 0, 3}, /* USBTP */
  184. {1, 8, 1, 0, 1}, /* USBTN */
  185. {1, 9, 2, 1, 3}, /* USBRP */
  186. {1, 10, 2, 0, 3}, /* USBRXD */
  187. {1, 11, 2, 1, 3}, /* USBRN */
  188. {2, 20, 2, 0, 1}, /* CLK21 */
  189. {4, 20, 1, 0, 0}, /* SPEED */
  190. {4, 21, 1, 0, 0}, /* SUSPND */
  191. /* END of table */
  192. {0, 0, 0, 0, QE_IOP_TAB_END},
  193. };
  194. int board_early_init_f(void)
  195. {
  196. return 0;
  197. }
  198. int board_early_init_r(void)
  199. {
  200. void *reg = (void *)(CONFIG_SYS_IMMR + 0x14a8);
  201. u32 val;
  202. /*
  203. * Because of errata in the UCCs, we have to write to the reserved
  204. * registers to slow the clocks down.
  205. */
  206. val = in_be32(reg);
  207. /* UCC1 */
  208. val |= 0x00003000;
  209. /* UCC2 */
  210. val |= 0x0c000000;
  211. out_be32(reg, val);
  212. return 0;
  213. }
  214. int fixed_sdram(void)
  215. {
  216. volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
  217. u32 msize = 0;
  218. u32 ddr_size;
  219. u32 ddr_size_log2;
  220. msize = CONFIG_SYS_DDR_SIZE;
  221. for (ddr_size = msize << 20, ddr_size_log2 = 0;
  222. (ddr_size > 1); ddr_size = ddr_size >> 1, ddr_size_log2++) {
  223. if (ddr_size & 1)
  224. return -1;
  225. }
  226. im->sysconf.ddrlaw[0].ar =
  227. LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
  228. im->ddr.csbnds[0].csbnds = CONFIG_SYS_DDR_CS0_BNDS;
  229. im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG;
  230. im->ddr.timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
  231. im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
  232. im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
  233. im->ddr.timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
  234. im->ddr.sdram_cfg = CONFIG_SYS_DDR_SDRAM_CFG;
  235. im->ddr.sdram_cfg2 = CONFIG_SYS_DDR_SDRAM_CFG2;
  236. im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE;
  237. im->ddr.sdram_mode2 = CONFIG_SYS_DDR_MODE2;
  238. im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL;
  239. im->ddr.sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CNTL;
  240. udelay(200);
  241. im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
  242. return msize;
  243. }
  244. phys_size_t initdram(int board_type)
  245. {
  246. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
  247. extern void ddr_enable_ecc(unsigned int dram_size);
  248. #endif
  249. volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
  250. u32 msize = 0;
  251. if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32)im)
  252. return -1;
  253. /* DDR SDRAM - Main SODIMM */
  254. im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_BASE & LAWBAR_BAR;
  255. msize = fixed_sdram();
  256. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
  257. /*
  258. * Initialize DDR ECC byte
  259. */
  260. ddr_enable_ecc(msize * 1024 * 1024);
  261. #endif
  262. /* return total bus SDRAM size(bytes) -- DDR */
  263. return (msize * 1024 * 1024);
  264. }
  265. int checkboard(void)
  266. {
  267. puts("Board: Freescale/Logic MPC8360ERDK\n");
  268. return 0;
  269. }
  270. static struct pci_region pci_regions[] = {
  271. {
  272. .bus_start = CONFIG_SYS_PCI1_MEM_BASE,
  273. .phys_start = CONFIG_SYS_PCI1_MEM_PHYS,
  274. .size = CONFIG_SYS_PCI1_MEM_SIZE,
  275. .flags = PCI_REGION_MEM | PCI_REGION_PREFETCH,
  276. },
  277. {
  278. .bus_start = CONFIG_SYS_PCI1_MMIO_BASE,
  279. .phys_start = CONFIG_SYS_PCI1_MMIO_PHYS,
  280. .size = CONFIG_SYS_PCI1_MMIO_SIZE,
  281. .flags = PCI_REGION_MEM,
  282. },
  283. {
  284. .bus_start = CONFIG_SYS_PCI1_IO_BASE,
  285. .phys_start = CONFIG_SYS_PCI1_IO_PHYS,
  286. .size = CONFIG_SYS_PCI1_IO_SIZE,
  287. .flags = PCI_REGION_IO,
  288. },
  289. };
  290. void pci_init_board(void)
  291. {
  292. volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
  293. volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
  294. volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
  295. struct pci_region *reg[] = { pci_regions, };
  296. #if defined(PCI_33M)
  297. clk->occr = OCCR_PCICOE0 | OCCR_PCICOE1 | OCCR_PCICOE2 |
  298. OCCR_PCICD0 | OCCR_PCICD1 | OCCR_PCICD2 | OCCR_PCICR;
  299. printf("PCI clock is 33MHz\n");
  300. #else
  301. clk->occr = OCCR_PCICOE0 | OCCR_PCICOE1 | OCCR_PCICOE2;
  302. printf("PCI clock is 66MHz\n");
  303. #endif
  304. udelay(2000);
  305. /* Configure PCI Local Access Windows */
  306. pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
  307. pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
  308. pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
  309. pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
  310. mpc83xx_pci_init(1, reg, 0);
  311. }
  312. #if defined(CONFIG_OF_BOARD_SETUP)
  313. void ft_board_setup(void *blob, bd_t *bd)
  314. {
  315. ft_cpu_setup(blob, bd);
  316. ft_pci_setup(blob, bd);
  317. }
  318. #endif