mpc8544ds.c 12 KB

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