mpc8544ds.c 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  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 <tsec.h>
  36. #include <netdev.h>
  37. #include "../common/sgmii_riser.h"
  38. int checkboard (void)
  39. {
  40. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  41. volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
  42. volatile ccsr_local_ecm_t *ecm = (void *)(CONFIG_SYS_MPC85xx_ECM_ADDR);
  43. u8 vboot;
  44. u8 *pixis_base = (u8 *)PIXIS_BASE;
  45. if ((uint)&gur->porpllsr != 0xe00e0000) {
  46. printf("immap size error %lx\n",(ulong)&gur->porpllsr);
  47. }
  48. printf ("Board: MPC8544DS, Sys ID: 0x%02x, "
  49. "Sys Ver: 0x%02x, FPGA Ver: 0x%02x, ",
  50. in_8(pixis_base + PIXIS_ID), in_8(pixis_base + PIXIS_VER),
  51. in_8(pixis_base + PIXIS_PVER));
  52. vboot = in_8(pixis_base + PIXIS_VBOOT);
  53. if (vboot & PIXIS_VBOOT_FMAP)
  54. printf ("vBank: %d\n", ((vboot & PIXIS_VBOOT_FBANK) >> 6));
  55. else
  56. puts ("Promjet\n");
  57. lbc->ltesr = 0xffffffff; /* Clear LBC error interrupts */
  58. lbc->lteir = 0xffffffff; /* Enable LBC error interrupts */
  59. ecm->eedr = 0xffffffff; /* Clear ecm errors */
  60. ecm->eeer = 0xffffffff; /* Enable ecm errors */
  61. return 0;
  62. }
  63. phys_size_t
  64. initdram(int board_type)
  65. {
  66. long dram_size = 0;
  67. puts("Initializing\n");
  68. dram_size = fsl_ddr_sdram();
  69. dram_size = setup_ddr_tlbs(dram_size / 0x100000);
  70. dram_size *= 0x100000;
  71. puts(" DDR: ");
  72. return dram_size;
  73. }
  74. #ifdef CONFIG_PCI1
  75. static struct pci_controller pci1_hose;
  76. #endif
  77. #ifdef CONFIG_PCIE1
  78. static struct pci_controller pcie1_hose;
  79. #endif
  80. #ifdef CONFIG_PCIE2
  81. static struct pci_controller pcie2_hose;
  82. #endif
  83. #ifdef CONFIG_PCIE3
  84. static struct pci_controller pcie3_hose;
  85. #endif
  86. void pci_init_board(void)
  87. {
  88. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  89. struct fsl_pci_info pci_info[4];
  90. u32 devdisr, pordevsr, io_sel;
  91. u32 porpllsr, pci_agent, pci_speed, pci_32, pci_arb, pci_clk_sel;
  92. int first_free_busno = 0;
  93. int num = 0;
  94. int pcie_ep, pcie_configured;
  95. devdisr = in_be32(&gur->devdisr);
  96. pordevsr = in_be32(&gur->pordevsr);
  97. porpllsr = in_be32(&gur->porpllsr);
  98. io_sel = (pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19;
  99. debug (" pci_init_board: devdisr=%x, io_sel=%x\n", devdisr, io_sel);
  100. if (io_sel & 1) {
  101. if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII1_DIS))
  102. printf("eTSEC1 is in sgmii mode.\n");
  103. if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII3_DIS))
  104. printf("eTSEC3 is in sgmii mode.\n");
  105. }
  106. puts("\n");
  107. #ifdef CONFIG_PCIE3
  108. pcie_configured = is_serdes_configured(PCIE3);
  109. if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE3)){
  110. SET_STD_PCIE_INFO(pci_info[num], 3);
  111. pcie_ep = fsl_setup_hose(&pcie3_hose, pci_info[num].regs);
  112. #ifdef CONFIG_SYS_PCIE3_MEM_BUS2
  113. /* outbound memory */
  114. pci_set_region(&pcie3_hose.regions[0],
  115. CONFIG_SYS_PCIE3_MEM_BUS2,
  116. CONFIG_SYS_PCIE3_MEM_PHYS2,
  117. CONFIG_SYS_PCIE3_MEM_SIZE2,
  118. PCI_REGION_MEM);
  119. pcie3_hose.region_count = 1;
  120. #endif
  121. printf("PCIE3: connected to ULI as %s (base addr %lx)\n",
  122. pcie_ep ? "Endpoint" : "Root Complex",
  123. pci_info[num].regs);
  124. first_free_busno = fsl_pci_init_port(&pci_info[num++],
  125. &pcie3_hose, first_free_busno);
  126. /*
  127. * Activate ULI1575 legacy chip by performing a fake
  128. * memory access. Needed to make ULI RTC work.
  129. */
  130. in_be32((u32 *)CONFIG_SYS_PCIE3_MEM_BUS);
  131. } else {
  132. printf("PCIE3: disabled\n");
  133. }
  134. puts("\n");
  135. #else
  136. setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE3); /* disable */
  137. #endif
  138. #ifdef CONFIG_PCIE1
  139. pcie_configured = is_serdes_configured(PCIE1);
  140. if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
  141. SET_STD_PCIE_INFO(pci_info[num], 1);
  142. pcie_ep = fsl_setup_hose(&pcie1_hose, pci_info[num].regs);
  143. #ifdef CONFIG_SYS_PCIE1_MEM_BUS2
  144. /* outbound memory */
  145. pci_set_region(&pcie1_hose.regions[0],
  146. CONFIG_SYS_PCIE1_MEM_BUS2,
  147. CONFIG_SYS_PCIE1_MEM_PHYS2,
  148. CONFIG_SYS_PCIE1_MEM_SIZE2,
  149. PCI_REGION_MEM);
  150. pcie1_hose.region_count = 1;
  151. #endif
  152. printf("PCIE1: connected to Slot 2 as %s (base addr %lx)\n",
  153. pcie_ep ? "Endpoint" : "Root Complex",
  154. pci_info[num].regs);
  155. first_free_busno = fsl_pci_init_port(&pci_info[num++],
  156. &pcie1_hose, first_free_busno);
  157. } else {
  158. printf("PCIE1: disabled\n");
  159. }
  160. puts("\n");
  161. #else
  162. setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE); /* disable */
  163. #endif
  164. #ifdef CONFIG_PCIE2
  165. pcie_configured = is_serdes_configured(PCIE2);
  166. if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE2)){
  167. SET_STD_PCIE_INFO(pci_info[num], 2);
  168. pcie_ep = fsl_setup_hose(&pcie2_hose, pci_info[num].regs);
  169. #ifdef CONFIG_SYS_PCIE2_MEM_BUS2
  170. /* outbound memory */
  171. pci_set_region(&pcie2_hose.regions[0],
  172. CONFIG_SYS_PCIE2_MEM_BUS2,
  173. CONFIG_SYS_PCIE2_MEM_PHYS2,
  174. CONFIG_SYS_PCIE2_MEM_SIZE2,
  175. PCI_REGION_MEM);
  176. pcie2_hose.region_count = 1;
  177. #endif
  178. printf("PCIE2: connected to Slot 1 as %s (base addr %lx)\n",
  179. pcie_ep ? "Endpoint" : "Root Complex",
  180. pci_info[num].regs);
  181. first_free_busno = fsl_pci_init_port(&pci_info[num++],
  182. &pcie2_hose, first_free_busno);
  183. } else {
  184. printf("PCIE2: disabled\n");
  185. }
  186. puts("\n");
  187. #else
  188. setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE2); /* disable */
  189. #endif
  190. #ifdef CONFIG_PCI1
  191. pci_speed = 66666000;
  192. pci_32 = 1;
  193. pci_arb = pordevsr & MPC85xx_PORDEVSR_PCI1_ARB;
  194. pci_clk_sel = porpllsr & MPC85xx_PORDEVSR_PCI1_SPD;
  195. if (!(devdisr & MPC85xx_DEVDISR_PCI1)) {
  196. SET_STD_PCI_INFO(pci_info[num], 1);
  197. pci_agent = fsl_setup_hose(&pci1_hose, pci_info[num].regs);
  198. printf("PCI: %d bit, %s MHz, %s, %s, %s (base address %lx)\n",
  199. (pci_32) ? 32 : 64,
  200. (pci_speed == 33333000) ? "33" :
  201. (pci_speed == 66666000) ? "66" : "unknown",
  202. pci_clk_sel ? "sync" : "async",
  203. pci_agent ? "agent" : "host",
  204. pci_arb ? "arbiter" : "external-arbiter",
  205. pci_info[num].regs);
  206. first_free_busno = fsl_pci_init_port(&pci_info[num++],
  207. &pci1_hose, first_free_busno);
  208. } else {
  209. printf("PCI: disabled\n");
  210. }
  211. puts("\n");
  212. #else
  213. setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCI1); /* disable */
  214. #endif
  215. }
  216. int last_stage_init(void)
  217. {
  218. return 0;
  219. }
  220. unsigned long
  221. get_board_sys_clk(ulong dummy)
  222. {
  223. u8 i, go_bit, rd_clks;
  224. ulong val = 0;
  225. u8 *pixis_base = (u8 *)PIXIS_BASE;
  226. go_bit = in_8(pixis_base + PIXIS_VCTL);
  227. go_bit &= 0x01;
  228. rd_clks = in_8(pixis_base + PIXIS_VCFGEN0);
  229. rd_clks &= 0x1C;
  230. /*
  231. * Only if both go bit and the SCLK bit in VCFGEN0 are set
  232. * should we be using the AUX register. Remember, we also set the
  233. * GO bit to boot from the alternate bank on the on-board flash
  234. */
  235. if (go_bit) {
  236. if (rd_clks == 0x1c)
  237. i = in_8(pixis_base + PIXIS_AUX);
  238. else
  239. i = in_8(pixis_base + PIXIS_SPD);
  240. } else {
  241. i = in_8(pixis_base + PIXIS_SPD);
  242. }
  243. i &= 0x07;
  244. switch (i) {
  245. case 0:
  246. val = 33333333;
  247. break;
  248. case 1:
  249. val = 40000000;
  250. break;
  251. case 2:
  252. val = 50000000;
  253. break;
  254. case 3:
  255. val = 66666666;
  256. break;
  257. case 4:
  258. val = 83000000;
  259. break;
  260. case 5:
  261. val = 100000000;
  262. break;
  263. case 6:
  264. val = 133333333;
  265. break;
  266. case 7:
  267. val = 166666666;
  268. break;
  269. }
  270. return val;
  271. }
  272. int board_eth_init(bd_t *bis)
  273. {
  274. #ifdef CONFIG_TSEC_ENET
  275. struct tsec_info_struct tsec_info[2];
  276. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  277. uint io_sel = (gur->pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19;
  278. int num = 0;
  279. #ifdef CONFIG_TSEC1
  280. SET_STD_TSEC_INFO(tsec_info[num], 1);
  281. if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII1_DIS))
  282. tsec_info[num].flags |= TSEC_SGMII;
  283. num++;
  284. #endif
  285. #ifdef CONFIG_TSEC3
  286. SET_STD_TSEC_INFO(tsec_info[num], 3);
  287. if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII3_DIS))
  288. tsec_info[num].flags |= TSEC_SGMII;
  289. num++;
  290. #endif
  291. if (!num) {
  292. printf("No TSECs initialized\n");
  293. return 0;
  294. }
  295. if (io_sel & 1)
  296. fsl_sgmii_riser_init(tsec_info, num);
  297. tsec_eth_init(bis, tsec_info, num);
  298. #endif
  299. return pci_eth_init(bis);
  300. }
  301. #if defined(CONFIG_OF_BOARD_SETUP)
  302. void ft_board_setup(void *blob, bd_t *bd)
  303. {
  304. ft_cpu_setup(blob, bd);
  305. FT_FSL_PCI_SETUP;
  306. #ifdef CONFIG_FSL_SGMII_RISER
  307. fsl_sgmii_riser_fdt_fixup(blob);
  308. #endif
  309. }
  310. #endif