mpc8544ds.c 12 KB

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