mpc8641hpcn.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. /*
  2. * Copyright 2006, 2007, 2010-2011 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 checkboard(void)
  35. {
  36. u8 vboot;
  37. u8 *pixis_base = (u8 *)PIXIS_BASE;
  38. printf ("Board: MPC8641HPCN, Sys ID: 0x%02x, "
  39. "Sys Ver: 0x%02x, FPGA Ver: 0x%02x, ",
  40. in_8(pixis_base + PIXIS_ID), in_8(pixis_base + PIXIS_VER),
  41. in_8(pixis_base + PIXIS_PVER));
  42. vboot = in_8(pixis_base + PIXIS_VBOOT);
  43. if (vboot & PIXIS_VBOOT_FMAP)
  44. printf ("vBank: %d\n", ((vboot & PIXIS_VBOOT_FBANK) >> 6));
  45. else
  46. puts ("Promjet\n");
  47. return 0;
  48. }
  49. phys_size_t
  50. initdram(int board_type)
  51. {
  52. phys_size_t dram_size = 0;
  53. #if defined(CONFIG_SPD_EEPROM)
  54. dram_size = fsl_ddr_sdram();
  55. #else
  56. dram_size = fixed_sdram();
  57. #endif
  58. setup_ddr_bat(dram_size);
  59. debug(" DDR: ");
  60. return dram_size;
  61. }
  62. #if !defined(CONFIG_SPD_EEPROM)
  63. /*
  64. * Fixed sdram init -- doesn't use serial presence detect.
  65. */
  66. phys_size_t
  67. fixed_sdram(void)
  68. {
  69. #if !defined(CONFIG_SYS_RAMBOOT)
  70. volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
  71. volatile ccsr_ddr_t *ddr = &immap->im_ddr1;
  72. ddr->cs0_bnds = CONFIG_SYS_DDR_CS0_BNDS;
  73. ddr->cs0_config = CONFIG_SYS_DDR_CS0_CONFIG;
  74. ddr->timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
  75. ddr->timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
  76. ddr->timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
  77. ddr->timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
  78. ddr->sdram_mode = CONFIG_SYS_DDR_MODE_1;
  79. ddr->sdram_mode_2 = CONFIG_SYS_DDR_MODE_2;
  80. ddr->sdram_interval = CONFIG_SYS_DDR_INTERVAL;
  81. ddr->sdram_data_init = CONFIG_SYS_DDR_DATA_INIT;
  82. ddr->sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CTRL;
  83. ddr->sdram_ocd_cntl = CONFIG_SYS_DDR_OCD_CTRL;
  84. ddr->sdram_ocd_status = CONFIG_SYS_DDR_OCD_STATUS;
  85. #if defined (CONFIG_DDR_ECC)
  86. ddr->err_disable = 0x0000008D;
  87. ddr->err_sbe = 0x00ff0000;
  88. #endif
  89. asm("sync;isync");
  90. udelay(500);
  91. #if defined (CONFIG_DDR_ECC)
  92. /* Enable ECC checking */
  93. ddr->sdram_cfg = (CONFIG_SYS_DDR_CONTROL | 0x20000000);
  94. #else
  95. ddr->sdram_cfg = CONFIG_SYS_DDR_CONTROL;
  96. ddr->sdram_cfg_2 = CONFIG_SYS_DDR_CONTROL2;
  97. #endif
  98. asm("sync; isync");
  99. udelay(500);
  100. #endif
  101. return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
  102. }
  103. #endif /* !defined(CONFIG_SPD_EEPROM) */
  104. void pci_init_board(void)
  105. {
  106. fsl_pcie_init_board(0);
  107. #ifdef CONFIG_PCIE1
  108. /*
  109. * Activate ULI1575 legacy chip by performing a fake
  110. * memory access. Needed to make ULI RTC work.
  111. */
  112. in_be32((unsigned *) ((char *)(CONFIG_SYS_PCIE1_MEM_VIRT
  113. + CONFIG_SYS_PCIE1_MEM_SIZE - 0x1000000)));
  114. #endif /* CONFIG_PCIE1 */
  115. }
  116. #if defined(CONFIG_OF_BOARD_SETUP)
  117. void
  118. ft_board_setup(void *blob, bd_t *bd)
  119. {
  120. int off;
  121. u64 *tmp;
  122. u32 *addrcells;
  123. ft_cpu_setup(blob, bd);
  124. FT_FSL_PCI_SETUP;
  125. /*
  126. * Warn if it looks like the device tree doesn't match u-boot.
  127. * This is just an estimation, based on the location of CCSR,
  128. * which is defined by the "reg" property in the soc node.
  129. */
  130. off = fdt_path_offset(blob, "/soc8641");
  131. addrcells = (u32 *)fdt_getprop(blob, 0, "#address-cells", NULL);
  132. tmp = (u64 *)fdt_getprop(blob, off, "reg", NULL);
  133. if (tmp) {
  134. u64 addr;
  135. if (addrcells && (*addrcells == 1))
  136. addr = *(u32 *)tmp;
  137. else
  138. addr = *tmp;
  139. if (addr != CONFIG_SYS_CCSRBAR_PHYS)
  140. printf("WARNING: The CCSRBAR address in your .dts "
  141. "does not match the address of the CCSR "
  142. "in u-boot. This means your .dts might "
  143. "be old.\n");
  144. }
  145. }
  146. #endif
  147. /*
  148. * get_board_sys_clk
  149. * Reads the FPGA on board for CONFIG_SYS_CLK_FREQ
  150. */
  151. unsigned long
  152. get_board_sys_clk(ulong dummy)
  153. {
  154. u8 i, go_bit, rd_clks;
  155. ulong val = 0;
  156. u8 *pixis_base = (u8 *)PIXIS_BASE;
  157. go_bit = in_8(pixis_base + PIXIS_VCTL);
  158. go_bit &= 0x01;
  159. rd_clks = in_8(pixis_base + PIXIS_VCFGEN0);
  160. rd_clks &= 0x1C;
  161. /*
  162. * Only if both go bit and the SCLK bit in VCFGEN0 are set
  163. * should we be using the AUX register. Remember, we also set the
  164. * GO bit to boot from the alternate bank on the on-board flash
  165. */
  166. if (go_bit) {
  167. if (rd_clks == 0x1c)
  168. i = in_8(pixis_base + PIXIS_AUX);
  169. else
  170. i = in_8(pixis_base + PIXIS_SPD);
  171. } else {
  172. i = in_8(pixis_base + PIXIS_SPD);
  173. }
  174. i &= 0x07;
  175. switch (i) {
  176. case 0:
  177. val = 33000000;
  178. break;
  179. case 1:
  180. val = 40000000;
  181. break;
  182. case 2:
  183. val = 50000000;
  184. break;
  185. case 3:
  186. val = 66000000;
  187. break;
  188. case 4:
  189. val = 83000000;
  190. break;
  191. case 5:
  192. val = 100000000;
  193. break;
  194. case 6:
  195. val = 134000000;
  196. break;
  197. case 7:
  198. val = 166000000;
  199. break;
  200. }
  201. return val;
  202. }
  203. int board_eth_init(bd_t *bis)
  204. {
  205. /* Initialize TSECs */
  206. cpu_eth_init(bis);
  207. return pci_eth_init(bis);
  208. }
  209. void board_reset(void)
  210. {
  211. u8 *pixis_base = (u8 *)PIXIS_BASE;
  212. out_8(pixis_base + PIXIS_RST, 0);
  213. while (1)
  214. ;
  215. }