mpc8360erdk.c 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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. /* END of table */
  177. {0, 0, 0, 0, QE_IOP_TAB_END},
  178. };
  179. int board_early_init_f(void)
  180. {
  181. return 0;
  182. }
  183. int board_early_init_r(void)
  184. {
  185. void *reg = (void *)(CFG_IMMR + 0x14a8);
  186. u32 val;
  187. /*
  188. * Because of errata in the UCCs, we have to write to the reserved
  189. * registers to slow the clocks down.
  190. */
  191. val = in_be32(reg);
  192. /* UCC1 */
  193. val |= 0x00003000;
  194. /* UCC2 */
  195. val |= 0x0c000000;
  196. out_be32(reg, val);
  197. return 0;
  198. }
  199. int fixed_sdram(void)
  200. {
  201. volatile immap_t *im = (immap_t *)CFG_IMMR;
  202. u32 msize = 0;
  203. u32 ddr_size;
  204. u32 ddr_size_log2;
  205. msize = CFG_DDR_SIZE;
  206. for (ddr_size = msize << 20, ddr_size_log2 = 0;
  207. (ddr_size > 1); ddr_size = ddr_size >> 1, ddr_size_log2++) {
  208. if (ddr_size & 1)
  209. return -1;
  210. }
  211. im->sysconf.ddrlaw[0].ar =
  212. LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
  213. im->ddr.csbnds[0].csbnds = CFG_DDR_CS0_BNDS;
  214. im->ddr.cs_config[0] = CFG_DDR_CS0_CONFIG;
  215. im->ddr.timing_cfg_0 = CFG_DDR_TIMING_0;
  216. im->ddr.timing_cfg_1 = CFG_DDR_TIMING_1;
  217. im->ddr.timing_cfg_2 = CFG_DDR_TIMING_2;
  218. im->ddr.timing_cfg_3 = CFG_DDR_TIMING_3;
  219. im->ddr.sdram_cfg = CFG_DDR_SDRAM_CFG;
  220. im->ddr.sdram_cfg2 = CFG_DDR_SDRAM_CFG2;
  221. im->ddr.sdram_mode = CFG_DDR_MODE;
  222. im->ddr.sdram_mode2 = CFG_DDR_MODE2;
  223. im->ddr.sdram_interval = CFG_DDR_INTERVAL;
  224. im->ddr.sdram_clk_cntl = CFG_DDR_CLK_CNTL;
  225. udelay(200);
  226. im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
  227. return msize;
  228. }
  229. long int initdram(int board_type)
  230. {
  231. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
  232. extern void ddr_enable_ecc(unsigned int dram_size);
  233. #endif
  234. volatile immap_t *im = (immap_t *)CFG_IMMR;
  235. u32 msize = 0;
  236. if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32)im)
  237. return -1;
  238. /* DDR SDRAM - Main SODIMM */
  239. im->sysconf.ddrlaw[0].bar = CFG_DDR_BASE & LAWBAR_BAR;
  240. msize = fixed_sdram();
  241. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
  242. /*
  243. * Initialize DDR ECC byte
  244. */
  245. ddr_enable_ecc(msize * 1024 * 1024);
  246. #endif
  247. /* return total bus SDRAM size(bytes) -- DDR */
  248. return (msize * 1024 * 1024);
  249. }
  250. int checkboard(void)
  251. {
  252. puts("Board: Freescale/Logic MPC8360ERDK\n");
  253. return 0;
  254. }
  255. static struct pci_region pci_regions[] = {
  256. {
  257. .bus_start = CFG_PCI1_MEM_BASE,
  258. .phys_start = CFG_PCI1_MEM_PHYS,
  259. .size = CFG_PCI1_MEM_SIZE,
  260. .flags = PCI_REGION_MEM | PCI_REGION_PREFETCH,
  261. },
  262. {
  263. .bus_start = CFG_PCI1_MMIO_BASE,
  264. .phys_start = CFG_PCI1_MMIO_PHYS,
  265. .size = CFG_PCI1_MMIO_SIZE,
  266. .flags = PCI_REGION_MEM,
  267. },
  268. {
  269. .bus_start = CFG_PCI1_IO_BASE,
  270. .phys_start = CFG_PCI1_IO_PHYS,
  271. .size = CFG_PCI1_IO_SIZE,
  272. .flags = PCI_REGION_IO,
  273. },
  274. };
  275. void pci_init_board(void)
  276. {
  277. volatile immap_t *immr = (volatile immap_t *)CFG_IMMR;
  278. volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
  279. volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
  280. struct pci_region *reg[] = { pci_regions, };
  281. #if defined(PCI_33M)
  282. clk->occr = OCCR_PCICOE0 | OCCR_PCICOE1 | OCCR_PCICOE2 |
  283. OCCR_PCICD0 | OCCR_PCICD1 | OCCR_PCICD2 | OCCR_PCICR;
  284. printf("PCI clock is 33MHz\n");
  285. #else
  286. clk->occr = OCCR_PCICOE0 | OCCR_PCICOE1 | OCCR_PCICOE2;
  287. printf("PCI clock is 66MHz\n");
  288. #endif
  289. udelay(2000);
  290. /* Configure PCI Local Access Windows */
  291. pci_law[0].bar = CFG_PCI1_MEM_PHYS & LAWBAR_BAR;
  292. pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
  293. pci_law[1].bar = CFG_PCI1_IO_PHYS & LAWBAR_BAR;
  294. pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
  295. mpc83xx_pci_init(1, reg, 0);
  296. }
  297. #if defined(CONFIG_OF_BOARD_SETUP)
  298. void ft_board_setup(void *blob, bd_t *bd)
  299. {
  300. ft_cpu_setup(blob, bd);
  301. ft_pci_setup(blob, bd);
  302. }
  303. #endif