mpc8360erdk.c 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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 <spd.h>
  21. #include <miiphy.h>
  22. #include <asm/io.h>
  23. #include <asm/mmu.h>
  24. #include <pci.h>
  25. #include <libfdt.h>
  26. const qe_iop_conf_t qe_iop_conf_tab[] = {
  27. /* MDIO */
  28. {0, 1, 3, 0, 2}, /* MDIO */
  29. {0, 2, 1, 0, 1}, /* MDC */
  30. /* UCC1 - UEC (Gigabit) */
  31. {0, 3, 1, 0, 1}, /* TxD0 */
  32. {0, 4, 1, 0, 1}, /* TxD1 */
  33. {0, 5, 1, 0, 1}, /* TxD2 */
  34. {0, 6, 1, 0, 1}, /* TxD3 */
  35. {0, 9, 2, 0, 1}, /* RxD0 */
  36. {0, 10, 2, 0, 1}, /* RxD1 */
  37. {0, 11, 2, 0, 1}, /* RxD2 */
  38. {0, 12, 2, 0, 1}, /* RxD3 */
  39. {0, 7, 1, 0, 1}, /* TX_EN */
  40. {0, 8, 1, 0, 1}, /* TX_ER */
  41. {0, 15, 2, 0, 1}, /* RX_DV */
  42. {0, 0, 2, 0, 1}, /* RX_CLK */
  43. {2, 9, 1, 0, 3}, /* GTX_CLK - CLK10 */
  44. {2, 8, 2, 0, 1}, /* GTX125 - CLK9 */
  45. /* UCC2 - UEC (Gigabit) */
  46. {0, 17, 1, 0, 1}, /* TxD0 */
  47. {0, 18, 1, 0, 1}, /* TxD1 */
  48. {0, 19, 1, 0, 1}, /* TxD2 */
  49. {0, 20, 1, 0, 1}, /* TxD3 */
  50. {0, 23, 2, 0, 1}, /* RxD0 */
  51. {0, 24, 2, 0, 1}, /* RxD1 */
  52. {0, 25, 2, 0, 1}, /* RxD2 */
  53. {0, 26, 2, 0, 1}, /* RxD3 */
  54. {0, 21, 1, 0, 1}, /* TX_EN */
  55. {0, 22, 1, 0, 1}, /* TX_ER */
  56. {0, 29, 2, 0, 1}, /* RX_DV */
  57. {0, 31, 2, 0, 1}, /* RX_CLK */
  58. {2, 2, 1, 0, 2}, /* GTX_CLK - CLK10 */
  59. {2, 3, 2, 0, 1}, /* GTX125 - CLK4 */
  60. /* UCC7 - UEC */
  61. {4, 0, 1, 0, 1}, /* TxD0 */
  62. {4, 1, 1, 0, 1}, /* TxD1 */
  63. {4, 2, 1, 0, 1}, /* TxD2 */
  64. {4, 3, 1, 0, 1}, /* TxD3 */
  65. {4, 6, 2, 0, 1}, /* RxD0 */
  66. {4, 7, 2, 0, 1}, /* RxD1 */
  67. {4, 8, 2, 0, 1}, /* RxD2 */
  68. {4, 9, 2, 0, 1}, /* RxD3 */
  69. {4, 4, 1, 0, 1}, /* TX_EN */
  70. {4, 5, 1, 0, 1}, /* TX_ER */
  71. {4, 12, 2, 0, 1}, /* RX_DV */
  72. {4, 13, 2, 0, 1}, /* RX_ER */
  73. {4, 10, 2, 0, 1}, /* COL */
  74. {4, 11, 2, 0, 1}, /* CRS */
  75. {2, 18, 2, 0, 1}, /* TX_CLK - CLK19 */
  76. {2, 19, 2, 0, 1}, /* RX_CLK - CLK20 */
  77. /* UCC4 - UEC */
  78. {1, 14, 1, 0, 1}, /* TxD0 */
  79. {1, 15, 1, 0, 1}, /* TxD1 */
  80. {1, 16, 1, 0, 1}, /* TxD2 */
  81. {1, 17, 1, 0, 1}, /* TxD3 */
  82. {1, 20, 2, 0, 1}, /* RxD0 */
  83. {1, 21, 2, 0, 1}, /* RxD1 */
  84. {1, 22, 2, 0, 1}, /* RxD2 */
  85. {1, 23, 2, 0, 1}, /* RxD3 */
  86. {1, 18, 1, 0, 1}, /* TX_EN */
  87. {1, 19, 1, 0, 2}, /* TX_ER */
  88. {1, 26, 2, 0, 1}, /* RX_DV */
  89. {1, 27, 2, 0, 1}, /* RX_ER */
  90. {1, 24, 2, 0, 1}, /* COL */
  91. {1, 25, 2, 0, 1}, /* CRS */
  92. {2, 6, 2, 0, 1}, /* TX_CLK - CLK7 */
  93. {2, 7, 2, 0, 1}, /* RX_CLK - CLK8 */
  94. /* PCI1 */
  95. {5, 4, 2, 0, 3}, /* PCI_M66EN */
  96. {5, 5, 1, 0, 3}, /* PCI_INTA */
  97. {5, 6, 1, 0, 3}, /* PCI_RSTO */
  98. {5, 7, 3, 0, 3}, /* PCI_C_BE0 */
  99. {5, 8, 3, 0, 3}, /* PCI_C_BE1 */
  100. {5, 9, 3, 0, 3}, /* PCI_C_BE2 */
  101. {5, 10, 3, 0, 3}, /* PCI_C_BE3 */
  102. {5, 11, 3, 0, 3}, /* PCI_PAR */
  103. {5, 12, 3, 0, 3}, /* PCI_FRAME */
  104. {5, 13, 3, 0, 3}, /* PCI_TRDY */
  105. {5, 14, 3, 0, 3}, /* PCI_IRDY */
  106. {5, 15, 3, 0, 3}, /* PCI_STOP */
  107. {5, 16, 3, 0, 3}, /* PCI_DEVSEL */
  108. {5, 17, 0, 0, 0}, /* PCI_IDSEL */
  109. {5, 18, 3, 0, 3}, /* PCI_SERR */
  110. {5, 19, 3, 0, 3}, /* PCI_PERR */
  111. {5, 20, 3, 0, 3}, /* PCI_REQ0 */
  112. {5, 21, 2, 0, 3}, /* PCI_REQ1 */
  113. {5, 22, 2, 0, 3}, /* PCI_GNT2 */
  114. {5, 23, 3, 0, 3}, /* PCI_GNT0 */
  115. {5, 24, 1, 0, 3}, /* PCI_GNT1 */
  116. {5, 25, 1, 0, 3}, /* PCI_GNT2 */
  117. {5, 26, 0, 0, 0}, /* PCI_CLK0 */
  118. {5, 27, 0, 0, 0}, /* PCI_CLK1 */
  119. {5, 28, 0, 0, 0}, /* PCI_CLK2 */
  120. {5, 29, 0, 0, 3}, /* PCI_SYNC_OUT */
  121. {6, 0, 3, 0, 3}, /* PCI_AD0 */
  122. {6, 1, 3, 0, 3}, /* PCI_AD1 */
  123. {6, 2, 3, 0, 3}, /* PCI_AD2 */
  124. {6, 3, 3, 0, 3}, /* PCI_AD3 */
  125. {6, 4, 3, 0, 3}, /* PCI_AD4 */
  126. {6, 5, 3, 0, 3}, /* PCI_AD5 */
  127. {6, 6, 3, 0, 3}, /* PCI_AD6 */
  128. {6, 7, 3, 0, 3}, /* PCI_AD7 */
  129. {6, 8, 3, 0, 3}, /* PCI_AD8 */
  130. {6, 9, 3, 0, 3}, /* PCI_AD9 */
  131. {6, 10, 3, 0, 3}, /* PCI_AD10 */
  132. {6, 11, 3, 0, 3}, /* PCI_AD11 */
  133. {6, 12, 3, 0, 3}, /* PCI_AD12 */
  134. {6, 13, 3, 0, 3}, /* PCI_AD13 */
  135. {6, 14, 3, 0, 3}, /* PCI_AD14 */
  136. {6, 15, 3, 0, 3}, /* PCI_AD15 */
  137. {6, 16, 3, 0, 3}, /* PCI_AD16 */
  138. {6, 17, 3, 0, 3}, /* PCI_AD17 */
  139. {6, 18, 3, 0, 3}, /* PCI_AD18 */
  140. {6, 19, 3, 0, 3}, /* PCI_AD19 */
  141. {6, 20, 3, 0, 3}, /* PCI_AD20 */
  142. {6, 21, 3, 0, 3}, /* PCI_AD21 */
  143. {6, 22, 3, 0, 3}, /* PCI_AD22 */
  144. {6, 23, 3, 0, 3}, /* PCI_AD23 */
  145. {6, 24, 3, 0, 3}, /* PCI_AD24 */
  146. {6, 25, 3, 0, 3}, /* PCI_AD25 */
  147. {6, 26, 3, 0, 3}, /* PCI_AD26 */
  148. {6, 27, 3, 0, 3}, /* PCI_AD27 */
  149. {6, 28, 3, 0, 3}, /* PCI_AD28 */
  150. {6, 29, 3, 0, 3}, /* PCI_AD29 */
  151. {6, 30, 3, 0, 3}, /* PCI_AD30 */
  152. {6, 31, 3, 0, 3}, /* PCI_AD31 */
  153. /* NAND */
  154. {4, 18, 2, 0, 0}, /* NAND_RYnBY */
  155. /* DUART - UART2 */
  156. {5, 0, 1, 0, 2}, /* UART2_SOUT */
  157. {5, 2, 1, 0, 1}, /* UART2_RTS */
  158. {5, 3, 2, 0, 2}, /* UART2_SIN */
  159. {5, 1, 2, 0, 3}, /* UART2_CTS */
  160. /* UCC5 - UART3 */
  161. {3, 0, 1, 0, 1}, /* UART3_TX */
  162. {3, 4, 1, 0, 1}, /* UART3_RTS */
  163. {3, 6, 2, 0, 1}, /* UART3_RX */
  164. {3, 12, 2, 0, 0}, /* UART3_CTS */
  165. {3, 13, 2, 0, 0}, /* UCC5_CD */
  166. /* UCC6 - UART4 */
  167. {3, 14, 1, 0, 1}, /* UART4_TX */
  168. {3, 18, 1, 0, 1}, /* UART4_RTS */
  169. {3, 20, 2, 0, 1}, /* UART4_RX */
  170. {3, 26, 2, 0, 0}, /* UART4_CTS */
  171. {3, 27, 2, 0, 0}, /* UCC6_CD */
  172. /* Fujitsu MB86277 (MINT) graphics controller */
  173. {0, 30, 1, 0, 0}, /* nSRESET_GRAPHICS */
  174. {1, 5, 1, 0, 0}, /* nXRST_GRAPHICS */
  175. {1, 7, 1, 0, 0}, /* LVDS_BKLT_CTR */
  176. {2, 16, 1, 0, 0}, /* LVDS_BKLT_EN */
  177. /* END of table */
  178. {0, 0, 0, 0, QE_IOP_TAB_END},
  179. };
  180. int board_early_init_f(void)
  181. {
  182. return 0;
  183. }
  184. int board_early_init_r(void)
  185. {
  186. void *reg = (void *)(CFG_IMMR + 0x14a8);
  187. u32 val;
  188. /*
  189. * Because of errata in the UCCs, we have to write to the reserved
  190. * registers to slow the clocks down.
  191. */
  192. val = in_be32(reg);
  193. /* UCC1 */
  194. val |= 0x00003000;
  195. /* UCC2 */
  196. val |= 0x0c000000;
  197. out_be32(reg, val);
  198. return 0;
  199. }
  200. int fixed_sdram(void)
  201. {
  202. volatile immap_t *im = (immap_t *)CFG_IMMR;
  203. u32 msize = 0;
  204. u32 ddr_size;
  205. u32 ddr_size_log2;
  206. msize = CFG_DDR_SIZE;
  207. for (ddr_size = msize << 20, ddr_size_log2 = 0;
  208. (ddr_size > 1); ddr_size = ddr_size >> 1, ddr_size_log2++) {
  209. if (ddr_size & 1)
  210. return -1;
  211. }
  212. im->sysconf.ddrlaw[0].ar =
  213. LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
  214. im->ddr.csbnds[0].csbnds = CFG_DDR_CS0_BNDS;
  215. im->ddr.cs_config[0] = CFG_DDR_CS0_CONFIG;
  216. im->ddr.timing_cfg_0 = CFG_DDR_TIMING_0;
  217. im->ddr.timing_cfg_1 = CFG_DDR_TIMING_1;
  218. im->ddr.timing_cfg_2 = CFG_DDR_TIMING_2;
  219. im->ddr.timing_cfg_3 = CFG_DDR_TIMING_3;
  220. im->ddr.sdram_cfg = CFG_DDR_SDRAM_CFG;
  221. im->ddr.sdram_cfg2 = CFG_DDR_SDRAM_CFG2;
  222. im->ddr.sdram_mode = CFG_DDR_MODE;
  223. im->ddr.sdram_mode2 = CFG_DDR_MODE2;
  224. im->ddr.sdram_interval = CFG_DDR_INTERVAL;
  225. im->ddr.sdram_clk_cntl = CFG_DDR_CLK_CNTL;
  226. udelay(200);
  227. im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
  228. return msize;
  229. }
  230. long int initdram(int board_type)
  231. {
  232. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
  233. extern void ddr_enable_ecc(unsigned int dram_size);
  234. #endif
  235. volatile immap_t *im = (immap_t *)CFG_IMMR;
  236. u32 msize = 0;
  237. if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32)im)
  238. return -1;
  239. /* DDR SDRAM - Main SODIMM */
  240. im->sysconf.ddrlaw[0].bar = CFG_DDR_BASE & LAWBAR_BAR;
  241. msize = fixed_sdram();
  242. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
  243. /*
  244. * Initialize DDR ECC byte
  245. */
  246. ddr_enable_ecc(msize * 1024 * 1024);
  247. #endif
  248. /* return total bus SDRAM size(bytes) -- DDR */
  249. return (msize * 1024 * 1024);
  250. }
  251. int checkboard(void)
  252. {
  253. puts("Board: Freescale/Logic MPC8360ERDK\n");
  254. return 0;
  255. }
  256. static struct pci_region pci_regions[] = {
  257. {
  258. .bus_start = CFG_PCI1_MEM_BASE,
  259. .phys_start = CFG_PCI1_MEM_PHYS,
  260. .size = CFG_PCI1_MEM_SIZE,
  261. .flags = PCI_REGION_MEM | PCI_REGION_PREFETCH,
  262. },
  263. {
  264. .bus_start = CFG_PCI1_MMIO_BASE,
  265. .phys_start = CFG_PCI1_MMIO_PHYS,
  266. .size = CFG_PCI1_MMIO_SIZE,
  267. .flags = PCI_REGION_MEM,
  268. },
  269. {
  270. .bus_start = CFG_PCI1_IO_BASE,
  271. .phys_start = CFG_PCI1_IO_PHYS,
  272. .size = CFG_PCI1_IO_SIZE,
  273. .flags = PCI_REGION_IO,
  274. },
  275. };
  276. void pci_init_board(void)
  277. {
  278. volatile immap_t *immr = (volatile immap_t *)CFG_IMMR;
  279. volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
  280. volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
  281. struct pci_region *reg[] = { pci_regions, };
  282. #if defined(PCI_33M)
  283. clk->occr = OCCR_PCICOE0 | OCCR_PCICOE1 | OCCR_PCICOE2 |
  284. OCCR_PCICD0 | OCCR_PCICD1 | OCCR_PCICD2 | OCCR_PCICR;
  285. printf("PCI clock is 33MHz\n");
  286. #else
  287. clk->occr = OCCR_PCICOE0 | OCCR_PCICOE1 | OCCR_PCICOE2;
  288. printf("PCI clock is 66MHz\n");
  289. #endif
  290. udelay(2000);
  291. /* Configure PCI Local Access Windows */
  292. pci_law[0].bar = CFG_PCI1_MEM_PHYS & LAWBAR_BAR;
  293. pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
  294. pci_law[1].bar = CFG_PCI1_IO_PHYS & LAWBAR_BAR;
  295. pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
  296. mpc83xx_pci_init(1, reg, 0);
  297. }
  298. #if defined(CONFIG_OF_BOARD_SETUP)
  299. void ft_board_setup(void *blob, bd_t *bd)
  300. {
  301. ft_cpu_setup(blob, bd);
  302. ft_pci_setup(blob, bd);
  303. }
  304. #endif