mpc8641hpcn.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. /*
  2. * Copyright 2006, 2007, 2010 Freescale Semiconductor.
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #include <common.h>
  23. #include <pci.h>
  24. #include <asm/processor.h>
  25. #include <asm/immap_86xx.h>
  26. #include <asm/fsl_pci.h>
  27. #include <asm/fsl_ddr_sdram.h>
  28. #include <asm/fsl_serdes.h>
  29. #include <asm/io.h>
  30. #include <libfdt.h>
  31. #include <fdt_support.h>
  32. #include <netdev.h>
  33. phys_size_t fixed_sdram(void);
  34. int board_early_init_f(void)
  35. {
  36. return 0;
  37. }
  38. int checkboard(void)
  39. {
  40. u8 vboot;
  41. u8 *pixis_base = (u8 *)PIXIS_BASE;
  42. printf ("Board: MPC8641HPCN, Sys ID: 0x%02x, "
  43. "Sys Ver: 0x%02x, FPGA Ver: 0x%02x, ",
  44. in_8(pixis_base + PIXIS_ID), in_8(pixis_base + PIXIS_VER),
  45. in_8(pixis_base + PIXIS_PVER));
  46. vboot = in_8(pixis_base + PIXIS_VBOOT);
  47. if (vboot & PIXIS_VBOOT_FMAP)
  48. printf ("vBank: %d\n", ((vboot & PIXIS_VBOOT_FBANK) >> 6));
  49. else
  50. puts ("Promjet\n");
  51. #ifdef CONFIG_PHYS_64BIT
  52. printf (" 36-bit physical address map\n");
  53. #endif
  54. return 0;
  55. }
  56. phys_size_t
  57. initdram(int board_type)
  58. {
  59. phys_size_t dram_size = 0;
  60. #if defined(CONFIG_SPD_EEPROM)
  61. dram_size = fsl_ddr_sdram();
  62. #else
  63. dram_size = fixed_sdram();
  64. #endif
  65. setup_ddr_bat(dram_size);
  66. puts(" DDR: ");
  67. return dram_size;
  68. }
  69. #if !defined(CONFIG_SPD_EEPROM)
  70. /*
  71. * Fixed sdram init -- doesn't use serial presence detect.
  72. */
  73. phys_size_t
  74. fixed_sdram(void)
  75. {
  76. #if !defined(CONFIG_SYS_RAMBOOT)
  77. volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
  78. volatile ccsr_ddr_t *ddr = &immap->im_ddr1;
  79. ddr->cs0_bnds = CONFIG_SYS_DDR_CS0_BNDS;
  80. ddr->cs0_config = CONFIG_SYS_DDR_CS0_CONFIG;
  81. ddr->timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
  82. ddr->timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
  83. ddr->timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
  84. ddr->timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
  85. ddr->sdram_mode = CONFIG_SYS_DDR_MODE_1;
  86. ddr->sdram_mode_2 = CONFIG_SYS_DDR_MODE_2;
  87. ddr->sdram_interval = CONFIG_SYS_DDR_INTERVAL;
  88. ddr->sdram_data_init = CONFIG_SYS_DDR_DATA_INIT;
  89. ddr->sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CTRL;
  90. ddr->sdram_ocd_cntl = CONFIG_SYS_DDR_OCD_CTRL;
  91. ddr->sdram_ocd_status = CONFIG_SYS_DDR_OCD_STATUS;
  92. #if defined (CONFIG_DDR_ECC)
  93. ddr->err_disable = 0x0000008D;
  94. ddr->err_sbe = 0x00ff0000;
  95. #endif
  96. asm("sync;isync");
  97. udelay(500);
  98. #if defined (CONFIG_DDR_ECC)
  99. /* Enable ECC checking */
  100. ddr->sdram_cfg = (CONFIG_SYS_DDR_CONTROL | 0x20000000);
  101. #else
  102. ddr->sdram_cfg = CONFIG_SYS_DDR_CONTROL;
  103. ddr->sdram_cfg_2 = CONFIG_SYS_DDR_CONTROL2;
  104. #endif
  105. asm("sync; isync");
  106. udelay(500);
  107. #endif
  108. return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
  109. }
  110. #endif /* !defined(CONFIG_SPD_EEPROM) */
  111. #if defined(CONFIG_PCI)
  112. static struct pci_controller pcie1_hose;
  113. #endif /* CONFIG_PCI */
  114. #ifdef CONFIG_PCIE2
  115. static struct pci_controller pcie2_hose;
  116. #endif /* CONFIG_PCIE2 */
  117. int first_free_busno = 0;
  118. void pci_init_board(void)
  119. {
  120. struct fsl_pci_info pci_info[2];
  121. int pcie_ep;
  122. int num = 0;
  123. #ifdef CONFIG_PCIE1
  124. volatile immap_t *immap = (immap_t *) CONFIG_SYS_CCSRBAR;
  125. volatile ccsr_gur_t *gur = &immap->im_gur;
  126. uint devdisr = in_be32(&gur->devdisr);
  127. int pcie_configured = is_serdes_configured(PCIE1);
  128. if (pcie_configured && !(devdisr & MPC86xx_DEVDISR_PCIEX1)) {
  129. SET_STD_PCIE_INFO(pci_info[num], 1);
  130. pcie_ep = fsl_setup_hose(&pcie1_hose, pci_info[num].regs);
  131. printf("PCIE1: connected to ULI as %s (base addr %lx)\n",
  132. pcie_ep ? "Endpoint" : "Root Complex",
  133. pci_info[num].regs);
  134. first_free_busno = fsl_pci_init_port(&pci_info[num++],
  135. &pcie1_hose, first_free_busno);
  136. /*
  137. * Activate ULI1575 legacy chip by performing a fake
  138. * memory access. Needed to make ULI RTC work.
  139. */
  140. in_be32((unsigned *) ((char *)(CONFIG_SYS_PCIE1_MEM_VIRT
  141. + CONFIG_SYS_PCIE1_MEM_SIZE - 0x1000000)));
  142. } else {
  143. puts("PCIE1: disabled\n");
  144. }
  145. #else
  146. puts("PCIE1: disabled\n");
  147. #endif /* CONFIG_PCIE1 */
  148. #ifdef CONFIG_PCIE2
  149. SET_STD_PCIE_INFO(pci_info[num], 2);
  150. pcie_ep = fsl_setup_hose(&pcie2_hose, pci_info[num].regs);
  151. printf("PCIE2: connected as %s (base addr %lx)\n",
  152. pcie_ep ? "Endpoint" : "Root Complex",
  153. pci_info[num].regs);
  154. first_free_busno = fsl_pci_init_port(&pci_info[num++],
  155. &pcie2_hose, first_free_busno);
  156. #else
  157. puts("PCIE2: disabled\n");
  158. #endif /* CONFIG_PCIE2 */
  159. }
  160. #if defined(CONFIG_OF_BOARD_SETUP)
  161. void
  162. ft_board_setup(void *blob, bd_t *bd)
  163. {
  164. int off;
  165. u64 *tmp;
  166. u32 *addrcells;
  167. ft_cpu_setup(blob, bd);
  168. FT_FSL_PCI_SETUP;
  169. /*
  170. * Warn if it looks like the device tree doesn't match u-boot.
  171. * This is just an estimation, based on the location of CCSR,
  172. * which is defined by the "reg" property in the soc node.
  173. */
  174. off = fdt_path_offset(blob, "/soc8641");
  175. addrcells = (u32 *)fdt_getprop(blob, 0, "#address-cells", NULL);
  176. tmp = (u64 *)fdt_getprop(blob, off, "reg", NULL);
  177. if (tmp) {
  178. u64 addr;
  179. if (addrcells && (*addrcells == 1))
  180. addr = *(u32 *)tmp;
  181. else
  182. addr = *tmp;
  183. if (addr != CONFIG_SYS_CCSRBAR_PHYS)
  184. printf("WARNING: The CCSRBAR address in your .dts "
  185. "does not match the address of the CCSR "
  186. "in u-boot. This means your .dts might "
  187. "be old.\n");
  188. }
  189. }
  190. #endif
  191. /*
  192. * get_board_sys_clk
  193. * Reads the FPGA on board for CONFIG_SYS_CLK_FREQ
  194. */
  195. unsigned long
  196. get_board_sys_clk(ulong dummy)
  197. {
  198. u8 i, go_bit, rd_clks;
  199. ulong val = 0;
  200. u8 *pixis_base = (u8 *)PIXIS_BASE;
  201. go_bit = in_8(pixis_base + PIXIS_VCTL);
  202. go_bit &= 0x01;
  203. rd_clks = in_8(pixis_base + PIXIS_VCFGEN0);
  204. rd_clks &= 0x1C;
  205. /*
  206. * Only if both go bit and the SCLK bit in VCFGEN0 are set
  207. * should we be using the AUX register. Remember, we also set the
  208. * GO bit to boot from the alternate bank on the on-board flash
  209. */
  210. if (go_bit) {
  211. if (rd_clks == 0x1c)
  212. i = in_8(pixis_base + PIXIS_AUX);
  213. else
  214. i = in_8(pixis_base + PIXIS_SPD);
  215. } else {
  216. i = in_8(pixis_base + PIXIS_SPD);
  217. }
  218. i &= 0x07;
  219. switch (i) {
  220. case 0:
  221. val = 33000000;
  222. break;
  223. case 1:
  224. val = 40000000;
  225. break;
  226. case 2:
  227. val = 50000000;
  228. break;
  229. case 3:
  230. val = 66000000;
  231. break;
  232. case 4:
  233. val = 83000000;
  234. break;
  235. case 5:
  236. val = 100000000;
  237. break;
  238. case 6:
  239. val = 134000000;
  240. break;
  241. case 7:
  242. val = 166000000;
  243. break;
  244. }
  245. return val;
  246. }
  247. int board_eth_init(bd_t *bis)
  248. {
  249. /* Initialize TSECs */
  250. cpu_eth_init(bis);
  251. return pci_eth_init(bis);
  252. }
  253. void board_reset(void)
  254. {
  255. u8 *pixis_base = (u8 *)PIXIS_BASE;
  256. out_8(pixis_base + PIXIS_RST, 0);
  257. while (1)
  258. ;
  259. }
  260. #ifdef CONFIG_MP
  261. extern void cpu_mp_lmb_reserve(struct lmb *lmb);
  262. void board_lmb_reserve(struct lmb *lmb)
  263. {
  264. cpu_mp_lmb_reserve(lmb);
  265. }
  266. #endif