mpc8544ds.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. /*
  2. * Copyright 2007 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/pixis.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 ccsr_lbc_t *lbc = (void *)(CONFIG_SYS_MPC85xx_LBC_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. int first_free_busno=0;
  87. void
  88. pci_init_board(void)
  89. {
  90. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  91. uint devdisr = gur->devdisr;
  92. uint io_sel = (gur->pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19;
  93. uint host_agent = (gur->porbmsr & MPC85xx_PORBMSR_HA) >> 16;
  94. debug (" pci_init_board: devdisr=%x, io_sel=%x, host_agent=%x\n",
  95. devdisr, io_sel, host_agent);
  96. if (io_sel & 1) {
  97. if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII1_DIS))
  98. printf (" eTSEC1 is in sgmii mode.\n");
  99. if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII3_DIS))
  100. printf (" eTSEC3 is in sgmii mode.\n");
  101. }
  102. #ifdef CONFIG_PCIE3
  103. {
  104. volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE3_ADDR;
  105. struct pci_controller *hose = &pcie3_hose;
  106. int pcie_ep = (host_agent == 1);
  107. int pcie_configured = io_sel >= 6;
  108. struct pci_region *r = hose->regions;
  109. if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
  110. printf ("\n PCIE3 connected to ULI as %s (base address %x)",
  111. pcie_ep ? "End Point" : "Root Complex",
  112. (uint)pci);
  113. if (pci->pme_msg_det) {
  114. pci->pme_msg_det = 0xffffffff;
  115. debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det);
  116. }
  117. printf ("\n");
  118. /* outbound memory */
  119. pci_set_region(r++,
  120. CONFIG_SYS_PCIE3_MEM_BUS,
  121. CONFIG_SYS_PCIE3_MEM_PHYS,
  122. CONFIG_SYS_PCIE3_MEM_SIZE,
  123. PCI_REGION_MEM);
  124. /* outbound io */
  125. pci_set_region(r++,
  126. CONFIG_SYS_PCIE3_IO_BUS,
  127. CONFIG_SYS_PCIE3_IO_PHYS,
  128. CONFIG_SYS_PCIE3_IO_SIZE,
  129. PCI_REGION_IO);
  130. #ifdef CONFIG_SYS_PCIE3_MEM_BUS2
  131. /* outbound memory */
  132. pci_set_region(r++,
  133. CONFIG_SYS_PCIE3_MEM_BUS2,
  134. CONFIG_SYS_PCIE3_MEM_PHYS2,
  135. CONFIG_SYS_PCIE3_MEM_SIZE2,
  136. PCI_REGION_MEM);
  137. #endif
  138. hose->region_count = r - hose->regions;
  139. hose->first_busno=first_free_busno;
  140. fsl_pci_init(hose, (u32)&pci->cfg_addr, (u32)&pci->cfg_data);
  141. first_free_busno=hose->last_busno+1;
  142. printf (" PCIE3 on bus %02x - %02x\n",
  143. hose->first_busno,hose->last_busno);
  144. /*
  145. * Activate ULI1575 legacy chip by performing a fake
  146. * memory access. Needed to make ULI RTC work.
  147. */
  148. in_be32((u32 *)CONFIG_SYS_PCIE3_MEM_BUS);
  149. } else {
  150. printf (" PCIE3: disabled\n");
  151. }
  152. }
  153. #else
  154. gur->devdisr |= MPC85xx_DEVDISR_PCIE3; /* disable */
  155. #endif
  156. #ifdef CONFIG_PCIE1
  157. {
  158. volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE1_ADDR;
  159. struct pci_controller *hose = &pcie1_hose;
  160. int pcie_ep = (host_agent == 5);
  161. int pcie_configured = io_sel >= 2;
  162. struct pci_region *r = hose->regions;
  163. if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
  164. printf ("\n PCIE1 connected to Slot2 as %s (base address %x)",
  165. pcie_ep ? "End Point" : "Root Complex",
  166. (uint)pci);
  167. if (pci->pme_msg_det) {
  168. pci->pme_msg_det = 0xffffffff;
  169. debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det);
  170. }
  171. printf ("\n");
  172. /* outbound memory */
  173. pci_set_region(r++,
  174. CONFIG_SYS_PCIE1_MEM_BUS,
  175. CONFIG_SYS_PCIE1_MEM_PHYS,
  176. CONFIG_SYS_PCIE1_MEM_SIZE,
  177. PCI_REGION_MEM);
  178. /* outbound io */
  179. pci_set_region(r++,
  180. CONFIG_SYS_PCIE1_IO_BUS,
  181. CONFIG_SYS_PCIE1_IO_PHYS,
  182. CONFIG_SYS_PCIE1_IO_SIZE,
  183. PCI_REGION_IO);
  184. #ifdef CONFIG_SYS_PCIE1_MEM_BUS2
  185. /* outbound memory */
  186. pci_set_region(r++,
  187. CONFIG_SYS_PCIE1_MEM_BUS2,
  188. CONFIG_SYS_PCIE1_MEM_PHYS2,
  189. CONFIG_SYS_PCIE1_MEM_SIZE2,
  190. PCI_REGION_MEM);
  191. #endif
  192. hose->region_count = r - hose->regions;
  193. hose->first_busno=first_free_busno;
  194. fsl_pci_init(hose, (u32)&pci->cfg_addr, (u32)&pci->cfg_data);
  195. first_free_busno=hose->last_busno+1;
  196. printf(" PCIE1 on bus %02x - %02x\n",
  197. hose->first_busno,hose->last_busno);
  198. } else {
  199. printf (" PCIE1: disabled\n");
  200. }
  201. }
  202. #else
  203. gur->devdisr |= MPC85xx_DEVDISR_PCIE; /* disable */
  204. #endif
  205. #ifdef CONFIG_PCIE2
  206. {
  207. volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE2_ADDR;
  208. struct pci_controller *hose = &pcie2_hose;
  209. int pcie_ep = (host_agent == 3);
  210. int pcie_configured = io_sel >= 4;
  211. struct pci_region *r = hose->regions;
  212. if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
  213. printf ("\n PCIE2 connected to Slot 1 as %s (base address %x)",
  214. pcie_ep ? "End Point" : "Root Complex",
  215. (uint)pci);
  216. if (pci->pme_msg_det) {
  217. pci->pme_msg_det = 0xffffffff;
  218. debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det);
  219. }
  220. printf ("\n");
  221. /* outbound memory */
  222. pci_set_region(r++,
  223. CONFIG_SYS_PCIE2_MEM_BUS,
  224. CONFIG_SYS_PCIE2_MEM_PHYS,
  225. CONFIG_SYS_PCIE2_MEM_SIZE,
  226. PCI_REGION_MEM);
  227. /* outbound io */
  228. pci_set_region(r++,
  229. CONFIG_SYS_PCIE2_IO_BUS,
  230. CONFIG_SYS_PCIE2_IO_PHYS,
  231. CONFIG_SYS_PCIE2_IO_SIZE,
  232. PCI_REGION_IO);
  233. #ifdef CONFIG_SYS_PCIE2_MEM_BUS2
  234. /* outbound memory */
  235. pci_set_region(r++,
  236. CONFIG_SYS_PCIE2_MEM_BUS2,
  237. CONFIG_SYS_PCIE2_MEM_PHYS2,
  238. CONFIG_SYS_PCIE2_MEM_SIZE2,
  239. PCI_REGION_MEM);
  240. #endif
  241. hose->region_count = r - hose->regions;
  242. hose->first_busno=first_free_busno;
  243. fsl_pci_init(hose, (u32)&pci->cfg_addr, (u32)&pci->cfg_data);
  244. first_free_busno=hose->last_busno+1;
  245. printf (" PCIE2 on bus %02x - %02x\n",
  246. hose->first_busno,hose->last_busno);
  247. } else {
  248. printf (" PCIE2: disabled\n");
  249. }
  250. }
  251. #else
  252. gur->devdisr |= MPC85xx_DEVDISR_PCIE2; /* disable */
  253. #endif
  254. #ifdef CONFIG_PCI1
  255. {
  256. volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCI1_ADDR;
  257. struct pci_controller *hose = &pci1_hose;
  258. struct pci_region *r = hose->regions;
  259. uint pci_agent = (host_agent == 6);
  260. uint pci_speed = 66666000; /*get_clock_freq (); PCI PSPEED in [4:5] */
  261. uint pci_32 = 1;
  262. uint pci_arb = gur->pordevsr & MPC85xx_PORDEVSR_PCI1_ARB; /* PORDEVSR[14] */
  263. uint pci_clk_sel = gur->porpllsr & MPC85xx_PORDEVSR_PCI1_SPD; /* PORPLLSR[16] */
  264. if (!(devdisr & MPC85xx_DEVDISR_PCI1)) {
  265. printf ("\n PCI: %d bit, %s MHz, %s, %s, %s (base address %x)\n",
  266. (pci_32) ? 32 : 64,
  267. (pci_speed == 33333000) ? "33" :
  268. (pci_speed == 66666000) ? "66" : "unknown",
  269. pci_clk_sel ? "sync" : "async",
  270. pci_agent ? "agent" : "host",
  271. pci_arb ? "arbiter" : "external-arbiter",
  272. (uint)pci
  273. );
  274. /* outbound memory */
  275. pci_set_region(r++,
  276. CONFIG_SYS_PCI1_MEM_BUS,
  277. CONFIG_SYS_PCI1_MEM_PHYS,
  278. CONFIG_SYS_PCI1_MEM_SIZE,
  279. PCI_REGION_MEM);
  280. /* outbound io */
  281. pci_set_region(r++,
  282. CONFIG_SYS_PCI1_IO_BUS,
  283. CONFIG_SYS_PCI1_IO_PHYS,
  284. CONFIG_SYS_PCI1_IO_SIZE,
  285. PCI_REGION_IO);
  286. #ifdef CONFIG_SYS_PCIE3_MEM_BUS2
  287. /* outbound memory */
  288. pci_set_region(r++,
  289. CONFIG_SYS_PCIE3_MEM_BUS2,
  290. CONFIG_SYS_PCIE3_MEM_PHYS2,
  291. CONFIG_SYS_PCIE3_MEM_SIZE2,
  292. PCI_REGION_MEM);
  293. #endif
  294. hose->region_count = r - hose->regions;
  295. hose->first_busno=first_free_busno;
  296. fsl_pci_init(hose, (u32)&pci->cfg_addr, (u32)&pci->cfg_data);
  297. first_free_busno=hose->last_busno+1;
  298. printf ("PCI on bus %02x - %02x\n",
  299. hose->first_busno,hose->last_busno);
  300. } else {
  301. printf (" PCI: disabled\n");
  302. }
  303. }
  304. #else
  305. gur->devdisr |= MPC85xx_DEVDISR_PCI1; /* disable */
  306. #endif
  307. }
  308. int last_stage_init(void)
  309. {
  310. return 0;
  311. }
  312. unsigned long
  313. get_board_sys_clk(ulong dummy)
  314. {
  315. u8 i, go_bit, rd_clks;
  316. ulong val = 0;
  317. u8 *pixis_base = (u8 *)PIXIS_BASE;
  318. go_bit = in_8(pixis_base + PIXIS_VCTL);
  319. go_bit &= 0x01;
  320. rd_clks = in_8(pixis_base + PIXIS_VCFGEN0);
  321. rd_clks &= 0x1C;
  322. /*
  323. * Only if both go bit and the SCLK bit in VCFGEN0 are set
  324. * should we be using the AUX register. Remember, we also set the
  325. * GO bit to boot from the alternate bank on the on-board flash
  326. */
  327. if (go_bit) {
  328. if (rd_clks == 0x1c)
  329. i = in_8(pixis_base + PIXIS_AUX);
  330. else
  331. i = in_8(pixis_base + PIXIS_SPD);
  332. } else {
  333. i = in_8(pixis_base + PIXIS_SPD);
  334. }
  335. i &= 0x07;
  336. switch (i) {
  337. case 0:
  338. val = 33333333;
  339. break;
  340. case 1:
  341. val = 40000000;
  342. break;
  343. case 2:
  344. val = 50000000;
  345. break;
  346. case 3:
  347. val = 66666666;
  348. break;
  349. case 4:
  350. val = 83000000;
  351. break;
  352. case 5:
  353. val = 100000000;
  354. break;
  355. case 6:
  356. val = 133333333;
  357. break;
  358. case 7:
  359. val = 166666666;
  360. break;
  361. }
  362. return val;
  363. }
  364. int board_eth_init(bd_t *bis)
  365. {
  366. #ifdef CONFIG_TSEC_ENET
  367. struct tsec_info_struct tsec_info[2];
  368. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  369. uint io_sel = (gur->pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19;
  370. int num = 0;
  371. #ifdef CONFIG_TSEC1
  372. SET_STD_TSEC_INFO(tsec_info[num], 1);
  373. if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII1_DIS))
  374. tsec_info[num].flags |= TSEC_SGMII;
  375. num++;
  376. #endif
  377. #ifdef CONFIG_TSEC3
  378. SET_STD_TSEC_INFO(tsec_info[num], 3);
  379. if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII3_DIS))
  380. tsec_info[num].flags |= TSEC_SGMII;
  381. num++;
  382. #endif
  383. if (!num) {
  384. printf("No TSECs initialized\n");
  385. return 0;
  386. }
  387. if (io_sel & 1)
  388. fsl_sgmii_riser_init(tsec_info, num);
  389. tsec_eth_init(bis, tsec_info, num);
  390. #endif
  391. return pci_eth_init(bis);
  392. }
  393. #if defined(CONFIG_OF_BOARD_SETUP)
  394. void ft_board_setup(void *blob, bd_t *bd)
  395. {
  396. ft_cpu_setup(blob, bd);
  397. #ifdef CONFIG_PCI1
  398. ft_fsl_pci_setup(blob, "pci0", &pci1_hose);
  399. #endif
  400. #ifdef CONFIG_PCIE2
  401. ft_fsl_pci_setup(blob, "pci1", &pcie1_hose);
  402. #endif
  403. #ifdef CONFIG_PCIE1
  404. ft_fsl_pci_setup(blob, "pci2", &pcie3_hose);
  405. #endif
  406. #ifdef CONFIG_PCIE3
  407. ft_fsl_pci_setup(blob, "pci3", &pcie2_hose);
  408. #endif
  409. #ifdef CONFIG_FSL_SGMII_RISER
  410. fsl_sgmii_riser_fdt_fixup(blob);
  411. #endif
  412. }
  413. #endif