mpc8544ds.c 12 KB

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