mpc8544ds.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2007,2009-2010 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/immap_85xx.h>
  11. #include <asm/fsl_pci.h>
  12. #include <fsl_ddr_sdram.h>
  13. #include <asm/fsl_serdes.h>
  14. #include <asm/io.h>
  15. #include <miiphy.h>
  16. #include <linux/libfdt.h>
  17. #include <fdt_support.h>
  18. #include <fsl_mdio.h>
  19. #include <tsec.h>
  20. #include <netdev.h>
  21. #include "../common/sgmii_riser.h"
  22. int checkboard (void)
  23. {
  24. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  25. volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
  26. volatile ccsr_local_ecm_t *ecm = (void *)(CONFIG_SYS_MPC85xx_ECM_ADDR);
  27. u8 vboot;
  28. u8 *pixis_base = (u8 *)PIXIS_BASE;
  29. if ((uint)&gur->porpllsr != 0xe00e0000) {
  30. printf("immap size error %lx\n",(ulong)&gur->porpllsr);
  31. }
  32. printf ("Board: MPC8544DS, Sys ID: 0x%02x, "
  33. "Sys Ver: 0x%02x, FPGA Ver: 0x%02x, ",
  34. in_8(pixis_base + PIXIS_ID), in_8(pixis_base + PIXIS_VER),
  35. in_8(pixis_base + PIXIS_PVER));
  36. vboot = in_8(pixis_base + PIXIS_VBOOT);
  37. if (vboot & PIXIS_VBOOT_FMAP)
  38. printf ("vBank: %d\n", ((vboot & PIXIS_VBOOT_FBANK) >> 6));
  39. else
  40. puts ("Promjet\n");
  41. lbc->ltesr = 0xffffffff; /* Clear LBC error interrupts */
  42. lbc->lteir = 0xffffffff; /* Enable LBC error interrupts */
  43. ecm->eedr = 0xffffffff; /* Clear ecm errors */
  44. ecm->eeer = 0xffffffff; /* Enable ecm errors */
  45. return 0;
  46. }
  47. #ifdef CONFIG_PCI1
  48. static struct pci_controller pci1_hose;
  49. #endif
  50. #ifdef CONFIG_PCIE3
  51. static struct pci_controller pcie3_hose;
  52. #endif
  53. void pci_init_board(void)
  54. {
  55. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  56. struct fsl_pci_info pci_info;
  57. u32 devdisr, pordevsr, io_sel;
  58. u32 porpllsr, pci_agent, pci_speed, pci_32, pci_arb, pci_clk_sel;
  59. int first_free_busno = 0;
  60. int pcie_ep, pcie_configured;
  61. devdisr = in_be32(&gur->devdisr);
  62. pordevsr = in_be32(&gur->pordevsr);
  63. porpllsr = in_be32(&gur->porpllsr);
  64. io_sel = (pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19;
  65. debug (" pci_init_board: devdisr=%x, io_sel=%x\n", devdisr, io_sel);
  66. puts("\n");
  67. #ifdef CONFIG_PCIE3
  68. pcie_configured = is_serdes_configured(PCIE3);
  69. if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE3)){
  70. /* contains both PCIE3 MEM & IO space */
  71. set_next_law(CONFIG_SYS_PCIE3_MEM_PHYS, LAW_SIZE_4M,
  72. LAW_TRGT_IF_PCIE_3);
  73. SET_STD_PCIE_INFO(pci_info, 3);
  74. pcie_ep = fsl_setup_hose(&pcie3_hose, pci_info.regs);
  75. /* outbound memory */
  76. pci_set_region(&pcie3_hose.regions[0],
  77. CONFIG_SYS_PCIE3_MEM_BUS2,
  78. CONFIG_SYS_PCIE3_MEM_PHYS2,
  79. CONFIG_SYS_PCIE3_MEM_SIZE2,
  80. PCI_REGION_MEM);
  81. pcie3_hose.region_count = 1;
  82. printf("PCIE3: connected to ULI as %s (base addr %lx)\n",
  83. pcie_ep ? "Endpoint" : "Root Complex",
  84. pci_info.regs);
  85. first_free_busno = fsl_pci_init_port(&pci_info,
  86. &pcie3_hose, first_free_busno);
  87. /*
  88. * Activate ULI1575 legacy chip by performing a fake
  89. * memory access. Needed to make ULI RTC work.
  90. */
  91. in_be32((u32 *)CONFIG_SYS_PCIE3_MEM_BUS);
  92. } else {
  93. printf("PCIE3: disabled\n");
  94. }
  95. puts("\n");
  96. #else
  97. setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE3); /* disable */
  98. #endif
  99. #ifdef CONFIG_PCIE1
  100. SET_STD_PCIE_INFO(pci_info, 1);
  101. first_free_busno = fsl_pcie_init_ctrl(first_free_busno, devdisr, PCIE1, &pci_info);
  102. #else
  103. setbits_be32(&gur->devdisr, _DEVDISR_PCIE1); /* disable */
  104. #endif
  105. #ifdef CONFIG_PCIE2
  106. SET_STD_PCIE_INFO(pci_info, 2);
  107. first_free_busno = fsl_pcie_init_ctrl(first_free_busno, devdisr, PCIE2, &pci_info);
  108. #else
  109. setbits_be32(&gur->devdisr, _DEVDISR_PCIE2); /* disable */
  110. #endif
  111. #ifdef CONFIG_PCI1
  112. pci_speed = 66666000;
  113. pci_32 = 1;
  114. pci_arb = pordevsr & MPC85xx_PORDEVSR_PCI1_ARB;
  115. pci_clk_sel = porpllsr & MPC85xx_PORDEVSR_PCI1_SPD;
  116. if (!(devdisr & MPC85xx_DEVDISR_PCI1)) {
  117. SET_STD_PCI_INFO(pci_info, 1);
  118. set_next_law(pci_info.mem_phys,
  119. law_size_bits(pci_info.mem_size), pci_info.law);
  120. set_next_law(pci_info.io_phys,
  121. law_size_bits(pci_info.io_size), pci_info.law);
  122. pci_agent = fsl_setup_hose(&pci1_hose, pci_info.regs);
  123. printf("PCI: %d bit, %s MHz, %s, %s, %s (base address %lx)\n",
  124. (pci_32) ? 32 : 64,
  125. (pci_speed == 33333000) ? "33" :
  126. (pci_speed == 66666000) ? "66" : "unknown",
  127. pci_clk_sel ? "sync" : "async",
  128. pci_agent ? "agent" : "host",
  129. pci_arb ? "arbiter" : "external-arbiter",
  130. pci_info.regs);
  131. first_free_busno = fsl_pci_init_port(&pci_info,
  132. &pci1_hose, first_free_busno);
  133. } else {
  134. printf("PCI: disabled\n");
  135. }
  136. puts("\n");
  137. #else
  138. setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCI1); /* disable */
  139. #endif
  140. }
  141. int last_stage_init(void)
  142. {
  143. return 0;
  144. }
  145. unsigned long
  146. get_board_sys_clk(ulong dummy)
  147. {
  148. u8 i, go_bit, rd_clks;
  149. ulong val = 0;
  150. u8 *pixis_base = (u8 *)PIXIS_BASE;
  151. go_bit = in_8(pixis_base + PIXIS_VCTL);
  152. go_bit &= 0x01;
  153. rd_clks = in_8(pixis_base + PIXIS_VCFGEN0);
  154. rd_clks &= 0x1C;
  155. /*
  156. * Only if both go bit and the SCLK bit in VCFGEN0 are set
  157. * should we be using the AUX register. Remember, we also set the
  158. * GO bit to boot from the alternate bank on the on-board flash
  159. */
  160. if (go_bit) {
  161. if (rd_clks == 0x1c)
  162. i = in_8(pixis_base + PIXIS_AUX);
  163. else
  164. i = in_8(pixis_base + PIXIS_SPD);
  165. } else {
  166. i = in_8(pixis_base + PIXIS_SPD);
  167. }
  168. i &= 0x07;
  169. switch (i) {
  170. case 0:
  171. val = 33333333;
  172. break;
  173. case 1:
  174. val = 40000000;
  175. break;
  176. case 2:
  177. val = 50000000;
  178. break;
  179. case 3:
  180. val = 66666666;
  181. break;
  182. case 4:
  183. val = 83000000;
  184. break;
  185. case 5:
  186. val = 100000000;
  187. break;
  188. case 6:
  189. val = 133333333;
  190. break;
  191. case 7:
  192. val = 166666666;
  193. break;
  194. }
  195. return val;
  196. }
  197. #define MIIM_CIS8204_SLED_CON 0x1b
  198. #define MIIM_CIS8204_SLEDCON_INIT 0x1115
  199. /*
  200. * Hack to write all 4 PHYs with the LED values
  201. */
  202. int board_phy_config(struct phy_device *phydev)
  203. {
  204. static int do_once;
  205. uint phyid;
  206. struct mii_dev *bus = phydev->bus;
  207. if (phydev->drv->config)
  208. phydev->drv->config(phydev);
  209. if (do_once)
  210. return 0;
  211. for (phyid = 0; phyid < 4; phyid++)
  212. bus->write(bus, phyid, MDIO_DEVAD_NONE, MIIM_CIS8204_SLED_CON,
  213. MIIM_CIS8204_SLEDCON_INIT);
  214. do_once = 1;
  215. return 0;
  216. }
  217. int board_eth_init(bd_t *bis)
  218. {
  219. #ifdef CONFIG_TSEC_ENET
  220. struct fsl_pq_mdio_info mdio_info;
  221. struct tsec_info_struct tsec_info[2];
  222. int num = 0;
  223. #ifdef CONFIG_TSEC1
  224. SET_STD_TSEC_INFO(tsec_info[num], 1);
  225. if (is_serdes_configured(SGMII_TSEC1)) {
  226. puts("eTSEC1 is in sgmii mode.\n");
  227. tsec_info[num].flags |= TSEC_SGMII;
  228. }
  229. num++;
  230. #endif
  231. #ifdef CONFIG_TSEC3
  232. SET_STD_TSEC_INFO(tsec_info[num], 3);
  233. if (is_serdes_configured(SGMII_TSEC3)) {
  234. puts("eTSEC3 is in sgmii mode.\n");
  235. tsec_info[num].flags |= TSEC_SGMII;
  236. }
  237. num++;
  238. #endif
  239. if (!num) {
  240. printf("No TSECs initialized\n");
  241. return 0;
  242. }
  243. if (is_serdes_configured(SGMII_TSEC1) ||
  244. is_serdes_configured(SGMII_TSEC3)) {
  245. fsl_sgmii_riser_init(tsec_info, num);
  246. }
  247. mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR;
  248. mdio_info.name = DEFAULT_MII_NAME;
  249. fsl_pq_mdio_init(bis, &mdio_info);
  250. tsec_eth_init(bis, tsec_info, num);
  251. #endif
  252. return pci_eth_init(bis);
  253. }
  254. #if defined(CONFIG_OF_BOARD_SETUP)
  255. int ft_board_setup(void *blob, bd_t *bd)
  256. {
  257. ft_cpu_setup(blob, bd);
  258. FT_FSL_PCI_SETUP;
  259. #ifdef CONFIG_FSL_SGMII_RISER
  260. fsl_sgmii_riser_fdt_fixup(blob);
  261. #endif
  262. return 0;
  263. }
  264. #endif