mpc8544ds.c 7.8 KB

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