mpc8641hpcn.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. /*
  2. * Copyright 2004 Freescale Semiconductor.
  3. * Jeff Brown (jeffrey@freescale.com)
  4. * Srikanth Srinivasan (srikanth.srinivasan@freescale.com)
  5. *
  6. * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com>
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  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. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #include <common.h>
  27. #include <pci.h>
  28. #include <asm/processor.h>
  29. #include <asm/immap_86xx.h>
  30. #include <spd.h>
  31. #if defined(CONFIG_OF_FLAT_TREE)
  32. #include <ft_build.h>
  33. extern void ft_cpu_setup(void *blob, bd_t *bd);
  34. #endif
  35. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
  36. extern void ddr_enable_ecc(unsigned int dram_size);
  37. #endif
  38. extern long int spd_sdram(void);
  39. void local_bus_init(void);
  40. void sdram_init(void);
  41. long int fixed_sdram(void);
  42. int board_early_init_f (void)
  43. {
  44. return 0;
  45. }
  46. int checkboard (void)
  47. {
  48. puts("Board: MPC8641HPCN\n");
  49. #ifdef CONFIG_PCI
  50. /* Sri: Note that at this point we will only test on PCI1
  51. */
  52. volatile immap_t *immap = (immap_t *) CFG_CCSRBAR;
  53. volatile ccsr_gur_t *gur = &immap->im_gur;
  54. volatile ccsr_pex_t *pex1 = &immap->im_pex1;
  55. uint devdisr = gur->devdisr;
  56. uint io_sel = (gur->pordevsr & MPC86xx_PORDEVSR_IO_SEL) >> 16;
  57. uint host1_agent = (gur->porbmsr & MPC86xx_PORBMSR_HA) >> 17;
  58. uint pex1_agent = (host1_agent == 0) || (host1_agent == 1);
  59. if ((io_sel==2 || io_sel==3 || io_sel==5 || io_sel==6 || io_sel==7 || io_sel==0xF ) && !(devdisr & MPC86xx_DEVDISR_PCIEX1)){
  60. debug ("PCI-EXPRESS 1: %s \n",
  61. pex1_agent ? "Agent" : "Host");
  62. debug("0x%08x=0x%08x ", &pex1->pme_msg_det,pex1->pme_msg_det);
  63. if (pex1->pme_msg_det) {
  64. pex1->pme_msg_det = 0xffffffff;
  65. debug (" with errors. Clearing. Now 0x%08x",pex1->pme_msg_det);
  66. }
  67. debug ("\n");
  68. } else {
  69. printf ("PCI-EXPRESS 1: Disabled\n");
  70. }
  71. #else
  72. printf("PCI-EXPRESS1: Disabled\n");
  73. #endif
  74. /*
  75. * Initialize local bus.
  76. */
  77. local_bus_init();
  78. return 0;
  79. }
  80. long int
  81. initdram(int board_type)
  82. {
  83. long dram_size = 0;
  84. extern long spd_sdram (void);
  85. #if defined(CONFIG_SPD_EEPROM)
  86. dram_size = spd_sdram ();
  87. #else
  88. dram_size = fixed_sdram ();
  89. #endif
  90. #if defined(CFG_RAMBOOT)
  91. puts(" DDR: ");
  92. return dram_size;
  93. #endif
  94. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
  95. /*
  96. * Initialize and enable DDR ECC.
  97. */
  98. ddr_enable_ecc(dram_size);
  99. #endif
  100. /*
  101. * Initialize SDRAM. Currently HPCN doesn't have
  102. * SDRAM but we'll leave this here for now
  103. * in case someone changes their mind
  104. */
  105. #if !defined(CONFIG_MPC8641HPCN)
  106. // sdram_init();
  107. #endif
  108. puts(" DDR: ");
  109. return dram_size;
  110. }
  111. /*
  112. * Initialize Local Bus
  113. */
  114. void
  115. local_bus_init(void)
  116. {
  117. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  118. volatile ccsr_lbc_t *lbc = &immap->im_lbc;
  119. uint clkdiv;
  120. uint lbc_hz;
  121. sys_info_t sysinfo;
  122. /*
  123. * Errata LBC11.
  124. * Fix Local Bus clock glitch when DLL is enabled.
  125. *
  126. * If localbus freq is < 66Mhz, DLL bypass mode must be used.
  127. * If localbus freq is > 133Mhz, DLL can be safely enabled.
  128. * Between 66 and 133, the DLL is enabled with an override workaround.
  129. */
  130. get_sys_info(&sysinfo);
  131. clkdiv = lbc->lcrr & 0x0f;
  132. lbc_hz = sysinfo.freqSystemBus / 1000000 / clkdiv;
  133. }
  134. #if defined(CFG_DRAM_TEST)
  135. int testdram (void)
  136. {
  137. uint *pstart = (uint *) CFG_MEMTEST_START;
  138. uint *pend = (uint *) CFG_MEMTEST_END;
  139. uint *p;
  140. printf("SDRAM test phase 1:\n");
  141. for (p = pstart; p < pend; p++)
  142. *p = 0xaaaaaaaa;
  143. for (p = pstart; p < pend; p++) {
  144. if (*p != 0xaaaaaaaa) {
  145. printf ("SDRAM test fails at: %08x\n", (uint) p);
  146. return 1;
  147. }
  148. }
  149. printf("SDRAM test phase 2:\n");
  150. for (p = pstart; p < pend; p++)
  151. *p = 0x55555555;
  152. for (p = pstart; p < pend; p++) {
  153. if (*p != 0x55555555) {
  154. printf ("SDRAM test fails at: %08x\n", (uint) p);
  155. return 1;
  156. }
  157. }
  158. printf("SDRAM test passed.\n");
  159. return 0;
  160. }
  161. #endif
  162. #if !defined(CONFIG_SPD_EEPROM)
  163. /*************************************************************************
  164. * fixed sdram init -- doesn't use serial presence detect.
  165. ************************************************************************/
  166. long int fixed_sdram (void)
  167. {
  168. #if !defined(CFG_RAMBOOT)
  169. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  170. volatile ccsr_ddr_t *ddr= &immap->im_ddr1;
  171. ddr->cs0_bnds = CFG_DDR_CS0_BNDS;
  172. ddr->cs0_config = CFG_DDR_CS0_CONFIG;
  173. ddr->ext_refrec = CFG_DDR_EXT_REFRESH;
  174. ddr->timing_cfg_0 = CFG_DDR_TIMING_0;
  175. ddr->timing_cfg_1 = CFG_DDR_TIMING_1;
  176. ddr->timing_cfg_2 = CFG_DDR_TIMING_2;
  177. ddr->sdram_mode_1 = CFG_DDR_MODE_1;
  178. ddr->sdram_mode_2 = CFG_DDR_MODE_2;
  179. ddr->sdram_interval = CFG_DDR_INTERVAL;
  180. ddr->sdram_data_init = CFG_DDR_DATA_INIT;
  181. ddr->sdram_clk_cntl = CFG_DDR_CLK_CTRL;
  182. ddr->sdram_ocd_cntl = CFG_DDR_OCD_CTRL;
  183. ddr->sdram_ocd_status = CFG_DDR_OCD_STATUS;
  184. #if defined (CONFIG_DDR_ECC)
  185. ddr->err_disable = 0x0000008D;
  186. ddr->err_sbe = 0x00ff0000;
  187. #endif
  188. asm("sync;isync");
  189. udelay(500);
  190. #if defined (CONFIG_DDR_ECC)
  191. /* Enable ECC checking */
  192. ddr->sdram_cfg_1 = (CFG_DDR_CONTROL | 0x20000000);
  193. #else
  194. ddr->sdram_cfg_1 = CFG_DDR_CONTROL;
  195. ddr->sdram_cfg_2 = CFG_DDR_CONTROL2;
  196. #endif
  197. asm("sync; isync");
  198. udelay(500);
  199. #endif
  200. return CFG_SDRAM_SIZE * 1024 * 1024;
  201. }
  202. #endif /* !defined(CONFIG_SPD_EEPROM) */
  203. #if defined(CONFIG_PCI)
  204. /*
  205. * Initialize PCI Devices, report devices found.
  206. */
  207. #ifndef CONFIG_PCI_PNP
  208. static struct pci_config_table pci_fsl86xxads_config_table[] = {
  209. { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
  210. PCI_IDSEL_NUMBER, PCI_ANY_ID,
  211. pci_cfgfunc_config_device, { PCI_ENET0_IOADDR,
  212. PCI_ENET0_MEMADDR,
  213. PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER
  214. } },
  215. { }
  216. };
  217. #endif
  218. static struct pci_controller hose = {
  219. #ifndef CONFIG_PCI_PNP
  220. config_table: pci_mpc86xxcts_config_table,
  221. #endif
  222. };
  223. #endif /* CONFIG_PCI */
  224. void
  225. pci_init_board(void)
  226. {
  227. #ifdef CONFIG_PCI
  228. extern void pci_mpc86xx_init(struct pci_controller *hose);
  229. pci_mpc86xx_init(&hose);
  230. #endif /* CONFIG_PCI */
  231. }
  232. #if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP)
  233. void
  234. ft_board_setup(void *blob, bd_t *bd)
  235. {
  236. u32 *p;
  237. int len;
  238. ft_cpu_setup(blob, bd);
  239. p = ft_get_prop(blob, "/memory/reg", &len);
  240. if (p != NULL) {
  241. *p++ = cpu_to_be32(bd->bi_memstart);
  242. *p = cpu_to_be32(bd->bi_memsize);
  243. }
  244. }
  245. #endif
  246. void
  247. after_reloc(ulong dest_addr)
  248. {
  249. DECLARE_GLOBAL_DATA_PTR;
  250. /* now, jump to the main U-Boot board init code */
  251. board_init_r ((gd_t *)gd, dest_addr);
  252. /* NOTREACHED */
  253. }