mpc8536ds.c 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2008-2012 Freescale Semiconductor, Inc.
  4. */
  5. #include <common.h>
  6. #include <command.h>
  7. #include <pci.h>
  8. #include <asm/processor.h>
  9. #include <asm/mmu.h>
  10. #include <asm/cache.h>
  11. #include <asm/immap_85xx.h>
  12. #include <asm/fsl_pci.h>
  13. #include <fsl_ddr_sdram.h>
  14. #include <asm/io.h>
  15. #include <asm/fsl_serdes.h>
  16. #include <spd.h>
  17. #include <miiphy.h>
  18. #include <linux/libfdt.h>
  19. #include <spd_sdram.h>
  20. #include <fdt_support.h>
  21. #include <fsl_mdio.h>
  22. #include <tsec.h>
  23. #include <netdev.h>
  24. #include <sata.h>
  25. #include "../common/sgmii_riser.h"
  26. int board_early_init_f (void)
  27. {
  28. #ifdef CONFIG_MMC
  29. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  30. setbits_be32(&gur->pmuxcr,
  31. (MPC85xx_PMUXCR_SDHC_CD |
  32. MPC85xx_PMUXCR_SDHC_WP));
  33. /* The MPC8536DS board insert the SDHC_WP pin for erratum NMG_eSDHC118,
  34. * however, this erratum only applies to MPC8536 Rev1.0.
  35. * So set SDHC_WP to active-low when use MPC8536 Rev1.1 and greater.*/
  36. if ((((SVR_MAJ(get_svr()) & 0x7) == 0x1) &&
  37. (SVR_MIN(get_svr()) >= 0x1))
  38. || (SVR_MAJ(get_svr() & 0x7) > 0x1))
  39. setbits_be32(&gur->gencfgr, MPC85xx_GENCFGR_SDHC_WP_INV);
  40. #endif
  41. return 0;
  42. }
  43. int checkboard (void)
  44. {
  45. u8 vboot;
  46. u8 *pixis_base = (u8 *)PIXIS_BASE;
  47. printf("Board: MPC8536DS Sys ID: 0x%02x, "
  48. "Sys Ver: 0x%02x, FPGA Ver: 0x%02x, ",
  49. in_8(pixis_base + PIXIS_ID), in_8(pixis_base + PIXIS_VER),
  50. in_8(pixis_base + PIXIS_PVER));
  51. vboot = in_8(pixis_base + PIXIS_VBOOT);
  52. switch ((vboot & PIXIS_VBOOT_LBMAP) >> 5) {
  53. case PIXIS_VBOOT_LBMAP_NOR0:
  54. puts ("vBank: 0\n");
  55. break;
  56. case PIXIS_VBOOT_LBMAP_NOR1:
  57. puts ("vBank: 1\n");
  58. break;
  59. case PIXIS_VBOOT_LBMAP_NOR2:
  60. puts ("vBank: 2\n");
  61. break;
  62. case PIXIS_VBOOT_LBMAP_NOR3:
  63. puts ("vBank: 3\n");
  64. break;
  65. case PIXIS_VBOOT_LBMAP_PJET:
  66. puts ("Promjet\n");
  67. break;
  68. case PIXIS_VBOOT_LBMAP_NAND:
  69. puts ("NAND\n");
  70. break;
  71. }
  72. return 0;
  73. }
  74. #if !defined(CONFIG_SPD_EEPROM)
  75. /*
  76. * Fixed sdram init -- doesn't use serial presence detect.
  77. */
  78. phys_size_t fixed_sdram (void)
  79. {
  80. volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
  81. struct ccsr_ddr __iomem *ddr = &immap->im_ddr;
  82. uint d_init;
  83. ddr->cs0_bnds = CONFIG_SYS_DDR_CS0_BNDS;
  84. ddr->cs0_config = CONFIG_SYS_DDR_CS0_CONFIG;
  85. ddr->timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
  86. ddr->timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
  87. ddr->timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
  88. ddr->timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
  89. ddr->sdram_mode = CONFIG_SYS_DDR_MODE_1;
  90. ddr->sdram_mode_2 = CONFIG_SYS_DDR_MODE_2;
  91. ddr->sdram_interval = CONFIG_SYS_DDR_INTERVAL;
  92. ddr->sdram_data_init = CONFIG_SYS_DDR_DATA_INIT;
  93. ddr->sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CTRL;
  94. ddr->sdram_cfg_2 = CONFIG_SYS_DDR_CONTROL2;
  95. #if defined (CONFIG_DDR_ECC)
  96. ddr->err_int_en = CONFIG_SYS_DDR_ERR_INT_EN;
  97. ddr->err_disable = CONFIG_SYS_DDR_ERR_DIS;
  98. ddr->err_sbe = CONFIG_SYS_DDR_SBE;
  99. #endif
  100. asm("sync;isync");
  101. udelay(500);
  102. ddr->sdram_cfg = CONFIG_SYS_DDR_CONTROL;
  103. #if defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
  104. d_init = 1;
  105. debug("DDR - 1st controller: memory initializing\n");
  106. /*
  107. * Poll until memory is initialized.
  108. * 512 Meg at 400 might hit this 200 times or so.
  109. */
  110. while ((ddr->sdram_cfg_2 & (d_init << 4)) != 0) {
  111. udelay(1000);
  112. }
  113. debug("DDR: memory initialized\n\n");
  114. asm("sync; isync");
  115. udelay(500);
  116. #endif
  117. return 512 * 1024 * 1024;
  118. }
  119. #endif
  120. #ifdef CONFIG_PCI1
  121. static struct pci_controller pci1_hose;
  122. #endif
  123. #ifdef CONFIG_PCI
  124. void pci_init_board(void)
  125. {
  126. ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  127. struct fsl_pci_info pci_info;
  128. u32 devdisr, pordevsr;
  129. u32 porpllsr, pci_agent, pci_speed, pci_32, pci_arb, pci_clk_sel;
  130. int first_free_busno;
  131. first_free_busno = fsl_pcie_init_board(0);
  132. #ifdef CONFIG_PCI1
  133. devdisr = in_be32(&gur->devdisr);
  134. pordevsr = in_be32(&gur->pordevsr);
  135. porpllsr = in_be32(&gur->porpllsr);
  136. pci_speed = 66666000;
  137. pci_32 = 1;
  138. pci_arb = pordevsr & MPC85xx_PORDEVSR_PCI1_ARB;
  139. pci_clk_sel = porpllsr & MPC85xx_PORDEVSR_PCI1_SPD;
  140. if (!(devdisr & MPC85xx_DEVDISR_PCI1)) {
  141. SET_STD_PCI_INFO(pci_info, 1);
  142. set_next_law(pci_info.mem_phys,
  143. law_size_bits(pci_info.mem_size), pci_info.law);
  144. set_next_law(pci_info.io_phys,
  145. law_size_bits(pci_info.io_size), pci_info.law);
  146. pci_agent = fsl_setup_hose(&pci1_hose, pci_info.regs);
  147. printf("PCI: %d bit, %s MHz, %s, %s, %s (base address %lx)\n",
  148. (pci_32) ? 32 : 64,
  149. (pci_speed == 33333000) ? "33" :
  150. (pci_speed == 66666000) ? "66" : "unknown",
  151. pci_clk_sel ? "sync" : "async",
  152. pci_agent ? "agent" : "host",
  153. pci_arb ? "arbiter" : "external-arbiter",
  154. pci_info.regs);
  155. first_free_busno = fsl_pci_init_port(&pci_info,
  156. &pci1_hose, first_free_busno);
  157. } else {
  158. printf("PCI: disabled\n");
  159. }
  160. puts("\n");
  161. #else
  162. setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCI1); /* disable */
  163. #endif
  164. }
  165. #endif
  166. int board_early_init_r(void)
  167. {
  168. const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
  169. int flash_esel = find_tlb_idx((void *)flashbase, 1);
  170. /*
  171. * Remap Boot flash + PROMJET region to caching-inhibited
  172. * so that flash can be erased properly.
  173. */
  174. /* Flush d-cache and invalidate i-cache of any FLASH data */
  175. flush_dcache();
  176. invalidate_icache();
  177. if (flash_esel == -1) {
  178. /* very unlikely unless something is messed up */
  179. puts("Error: Could not find TLB for FLASH BASE\n");
  180. flash_esel = 1; /* give our best effort to continue */
  181. } else {
  182. /* invalidate existing TLB entry for flash + promjet */
  183. disable_tlb(flash_esel);
  184. }
  185. set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS, /* tlb, epn, rpn */
  186. MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, /* perms, wimge */
  187. 0, flash_esel, BOOKE_PAGESZ_256M, 1); /* ts, esel, tsize, iprot */
  188. return 0;
  189. }
  190. int board_eth_init(bd_t *bis)
  191. {
  192. #ifdef CONFIG_TSEC_ENET
  193. struct fsl_pq_mdio_info mdio_info;
  194. struct tsec_info_struct tsec_info[2];
  195. int num = 0;
  196. #ifdef CONFIG_TSEC1
  197. SET_STD_TSEC_INFO(tsec_info[num], 1);
  198. if (is_serdes_configured(SGMII_TSEC1)) {
  199. puts("eTSEC1 is in sgmii mode.\n");
  200. tsec_info[num].phyaddr = 0;
  201. tsec_info[num].flags |= TSEC_SGMII;
  202. }
  203. num++;
  204. #endif
  205. #ifdef CONFIG_TSEC3
  206. SET_STD_TSEC_INFO(tsec_info[num], 3);
  207. if (is_serdes_configured(SGMII_TSEC3)) {
  208. puts("eTSEC3 is in sgmii mode.\n");
  209. tsec_info[num].phyaddr = 1;
  210. tsec_info[num].flags |= TSEC_SGMII;
  211. }
  212. num++;
  213. #endif
  214. if (!num) {
  215. printf("No TSECs initialized\n");
  216. return 0;
  217. }
  218. #ifdef CONFIG_FSL_SGMII_RISER
  219. if (is_serdes_configured(SGMII_TSEC1) ||
  220. is_serdes_configured(SGMII_TSEC3)) {
  221. fsl_sgmii_riser_init(tsec_info, num);
  222. }
  223. #endif
  224. mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR;
  225. mdio_info.name = DEFAULT_MII_NAME;
  226. fsl_pq_mdio_init(bis, &mdio_info);
  227. tsec_eth_init(bis, tsec_info, num);
  228. #endif
  229. return pci_eth_init(bis);
  230. }
  231. #if defined(CONFIG_OF_BOARD_SETUP)
  232. int ft_board_setup(void *blob, bd_t *bd)
  233. {
  234. ft_cpu_setup(blob, bd);
  235. FT_FSL_PCI_SETUP;
  236. #ifdef CONFIG_FSL_SGMII_RISER
  237. fsl_sgmii_riser_fdt_fixup(blob);
  238. #endif
  239. #ifdef CONFIG_HAS_FSL_MPH_USB
  240. fsl_fdt_fixup_dr_usb(blob, bd);
  241. #endif
  242. return 0;
  243. }
  244. #endif