mpc8544ds.c 8.9 KB

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