mpc8544ds.c 12 KB

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