mpc8536ds.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. /*
  2. * Copyright 2008 Freescale Semiconductor.
  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/cache.h>
  28. #include <asm/immap_85xx.h>
  29. #include <asm/immap_fsl_pci.h>
  30. #include <asm/fsl_ddr_sdram.h>
  31. #include <asm/io.h>
  32. #include <spd.h>
  33. #include <miiphy.h>
  34. #include <libfdt.h>
  35. #include <spd_sdram.h>
  36. #include <fdt_support.h>
  37. #include <tsec.h>
  38. #include <netdev.h>
  39. #include "../common/pixis.h"
  40. #include "../common/sgmii_riser.h"
  41. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
  42. extern void ddr_enable_ecc(unsigned int dram_size);
  43. #endif
  44. phys_size_t fixed_sdram(void);
  45. int checkboard (void)
  46. {
  47. printf ("Board: MPC8536DS, System ID: 0x%02x, "
  48. "System Version: 0x%02x, FPGA Version: 0x%02x\n",
  49. in8(PIXIS_BASE + PIXIS_ID), in8(PIXIS_BASE + PIXIS_VER),
  50. in8(PIXIS_BASE + PIXIS_PVER));
  51. return 0;
  52. }
  53. phys_size_t
  54. initdram(int board_type)
  55. {
  56. phys_size_t dram_size = 0;
  57. puts("Initializing....");
  58. #ifdef CONFIG_SPD_EEPROM
  59. dram_size = fsl_ddr_sdram();
  60. dram_size = setup_ddr_tlbs(dram_size / 0x100000);
  61. dram_size *= 0x100000;
  62. #else
  63. dram_size = fixed_sdram();
  64. #endif
  65. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
  66. /*
  67. * Initialize and enable DDR ECC.
  68. */
  69. ddr_enable_ecc(dram_size);
  70. #endif
  71. puts(" DDR: ");
  72. return dram_size;
  73. }
  74. #if !defined(CONFIG_SPD_EEPROM)
  75. /*
  76. * Fixed sdram init -- doesn't use serial presence detect.
  77. */
  78. phys_size_t fixed_sdram (void)
  79. {
  80. volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
  81. volatile ccsr_ddr_t *ddr= &immap->im_ddr;
  82. uint d_init;
  83. ddr->cs0_bnds = CONFIG_SYS_DDR_CS0_BNDS;
  84. ddr->cs0_config = CONFIG_SYS_DDR_CS0_CONFIG;
  85. ddr->timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
  86. ddr->timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
  87. ddr->timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
  88. ddr->timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
  89. ddr->sdram_mode = CONFIG_SYS_DDR_MODE_1;
  90. ddr->sdram_mode_2 = CONFIG_SYS_DDR_MODE_2;
  91. ddr->sdram_interval = CONFIG_SYS_DDR_INTERVAL;
  92. ddr->sdram_data_init = CONFIG_SYS_DDR_DATA_INIT;
  93. ddr->sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CTRL;
  94. ddr->sdram_cfg_2 = CONFIG_SYS_DDR_CONTROL2;
  95. #if defined (CONFIG_DDR_ECC)
  96. ddr->err_int_en = CONFIG_SYS_DDR_ERR_INT_EN;
  97. ddr->err_disable = CONFIG_SYS_DDR_ERR_DIS;
  98. ddr->err_sbe = CONFIG_SYS_DDR_SBE;
  99. #endif
  100. asm("sync;isync");
  101. udelay(500);
  102. ddr->sdram_cfg = CONFIG_SYS_DDR_CONTROL;
  103. #if defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
  104. d_init = 1;
  105. debug("DDR - 1st controller: memory initializing\n");
  106. /*
  107. * Poll until memory is initialized.
  108. * 512 Meg at 400 might hit this 200 times or so.
  109. */
  110. while ((ddr->sdram_cfg_2 & (d_init << 4)) != 0) {
  111. udelay(1000);
  112. }
  113. debug("DDR: memory initialized\n\n");
  114. asm("sync; isync");
  115. udelay(500);
  116. #endif
  117. return 512 * 1024 * 1024;
  118. }
  119. #endif
  120. #ifdef CONFIG_PCI1
  121. static struct pci_controller pci1_hose;
  122. #endif
  123. #ifdef CONFIG_PCIE1
  124. static struct pci_controller pcie1_hose;
  125. #endif
  126. #ifdef CONFIG_PCIE2
  127. static struct pci_controller pcie2_hose;
  128. #endif
  129. #ifdef CONFIG_PCIE3
  130. static struct pci_controller pcie3_hose;
  131. #endif
  132. extern int fsl_pci_setup_inbound_windows(struct pci_region *r);
  133. extern void fsl_pci_init(struct pci_controller *hose);
  134. int first_free_busno=0;
  135. void
  136. pci_init_board(void)
  137. {
  138. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  139. uint devdisr = gur->devdisr;
  140. uint sdrs2_io_sel =
  141. (gur->pordevsr & MPC85xx_PORDEVSR_SRDS2_IO_SEL) >> 27;
  142. uint io_sel = (gur->pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19;
  143. uint host_agent = (gur->porbmsr & MPC85xx_PORBMSR_HA) >> 16;
  144. debug(" pci_init_board: devdisr=%x, sdrs2_io_sel=%x, io_sel=%x,\
  145. host_agent=%x\n", devdisr, sdrs2_io_sel, io_sel, host_agent);
  146. if (sdrs2_io_sel == 7)
  147. printf(" Serdes2 disalbed\n");
  148. else if (sdrs2_io_sel == 4) {
  149. printf(" eTSEC1 is in sgmii mode.\n");
  150. printf(" eTSEC3 is in sgmii mode.\n");
  151. } else if (sdrs2_io_sel == 6)
  152. printf(" eTSEC1 is in sgmii mode.\n");
  153. #ifdef CONFIG_PCIE3
  154. {
  155. volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE3_ADDR;
  156. struct pci_controller *hose = &pcie3_hose;
  157. int pcie_ep = (host_agent == 1);
  158. int pcie_configured = (io_sel == 7);
  159. struct pci_region *r = hose->regions;
  160. if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
  161. printf ("\n PCIE3 connected to Slot3 as %s (base address %x)",
  162. pcie_ep ? "End Point" : "Root Complex",
  163. (uint)pci);
  164. if (pci->pme_msg_det) {
  165. pci->pme_msg_det = 0xffffffff;
  166. debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det);
  167. }
  168. printf ("\n");
  169. /* inbound */
  170. r += fsl_pci_setup_inbound_windows(r);
  171. /* outbound memory */
  172. pci_set_region(r++,
  173. CONFIG_SYS_PCIE3_MEM_BASE,
  174. CONFIG_SYS_PCIE3_MEM_PHYS,
  175. CONFIG_SYS_PCIE3_MEM_SIZE,
  176. PCI_REGION_MEM);
  177. /* outbound io */
  178. pci_set_region(r++,
  179. CONFIG_SYS_PCIE3_IO_BASE,
  180. CONFIG_SYS_PCIE3_IO_PHYS,
  181. CONFIG_SYS_PCIE3_IO_SIZE,
  182. PCI_REGION_IO);
  183. hose->region_count = r - hose->regions;
  184. hose->first_busno=first_free_busno;
  185. pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data);
  186. fsl_pci_init(hose);
  187. first_free_busno=hose->last_busno+1;
  188. printf (" PCIE3 on bus %02x - %02x\n",
  189. hose->first_busno,hose->last_busno);
  190. } else {
  191. printf (" PCIE3: disabled\n");
  192. }
  193. }
  194. #else
  195. gur->devdisr |= MPC85xx_DEVDISR_PCIE3; /* disable */
  196. #endif
  197. #ifdef CONFIG_PCIE1
  198. {
  199. volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE1_ADDR;
  200. struct pci_controller *hose = &pcie1_hose;
  201. int pcie_ep = (host_agent == 5);
  202. int pcie_configured = (io_sel == 2 || io_sel == 3
  203. || io_sel == 5 || io_sel == 7);
  204. struct pci_region *r = hose->regions;
  205. if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
  206. printf ("\n PCIE1 connected to Slot1 as %s (base address %x)",
  207. pcie_ep ? "End Point" : "Root Complex",
  208. (uint)pci);
  209. if (pci->pme_msg_det) {
  210. pci->pme_msg_det = 0xffffffff;
  211. debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det);
  212. }
  213. printf ("\n");
  214. /* inbound */
  215. r += fsl_pci_setup_inbound_windows(r);
  216. /* outbound memory */
  217. pci_set_region(r++,
  218. CONFIG_SYS_PCIE1_MEM_BASE,
  219. CONFIG_SYS_PCIE1_MEM_PHYS,
  220. CONFIG_SYS_PCIE1_MEM_SIZE,
  221. PCI_REGION_MEM);
  222. /* outbound io */
  223. pci_set_region(r++,
  224. CONFIG_SYS_PCIE1_IO_BASE,
  225. CONFIG_SYS_PCIE1_IO_PHYS,
  226. CONFIG_SYS_PCIE1_IO_SIZE,
  227. PCI_REGION_IO);
  228. #ifdef CONFIG_SYS_PCIE1_MEM_BASE2
  229. /* outbound memory */
  230. pci_set_region(r++,
  231. CONFIG_SYS_PCIE1_MEM_BASE2,
  232. CONFIG_SYS_PCIE1_MEM_PHYS2,
  233. CONFIG_SYS_PCIE1_MEM_SIZE2,
  234. PCI_REGION_MEM);
  235. #endif
  236. hose->region_count = r - hose->regions;
  237. hose->first_busno=first_free_busno;
  238. pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data);
  239. fsl_pci_init(hose);
  240. first_free_busno=hose->last_busno+1;
  241. printf(" PCIE1 on bus %02x - %02x\n",
  242. hose->first_busno,hose->last_busno);
  243. } else {
  244. printf (" PCIE1: disabled\n");
  245. }
  246. }
  247. #else
  248. gur->devdisr |= MPC85xx_DEVDISR_PCIE; /* disable */
  249. #endif
  250. #ifdef CONFIG_PCIE2
  251. {
  252. volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE2_ADDR;
  253. struct pci_controller *hose = &pcie2_hose;
  254. int pcie_ep = (host_agent == 3);
  255. int pcie_configured = (io_sel == 5 || io_sel == 7);
  256. struct pci_region *r = hose->regions;
  257. if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
  258. printf ("\n PCIE2 connected to Slot 2 as %s (base address %x)",
  259. pcie_ep ? "End Point" : "Root Complex",
  260. (uint)pci);
  261. if (pci->pme_msg_det) {
  262. pci->pme_msg_det = 0xffffffff;
  263. debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det);
  264. }
  265. printf ("\n");
  266. /* inbound */
  267. r += fsl_pci_setup_inbound_windows(r);
  268. /* outbound memory */
  269. pci_set_region(r++,
  270. CONFIG_SYS_PCIE2_MEM_BASE,
  271. CONFIG_SYS_PCIE2_MEM_PHYS,
  272. CONFIG_SYS_PCIE2_MEM_SIZE,
  273. PCI_REGION_MEM);
  274. /* outbound io */
  275. pci_set_region(r++,
  276. CONFIG_SYS_PCIE2_IO_BASE,
  277. CONFIG_SYS_PCIE2_IO_PHYS,
  278. CONFIG_SYS_PCIE2_IO_SIZE,
  279. PCI_REGION_IO);
  280. #ifdef CONFIG_SYS_PCIE2_MEM_BASE2
  281. /* outbound memory */
  282. pci_set_region(r++,
  283. CONFIG_SYS_PCIE2_MEM_BASE2,
  284. CONFIG_SYS_PCIE2_MEM_PHYS2,
  285. CONFIG_SYS_PCIE2_MEM_SIZE2,
  286. PCI_REGION_MEM);
  287. #endif
  288. hose->region_count = r - hose->regions;
  289. hose->first_busno=first_free_busno;
  290. pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data);
  291. fsl_pci_init(hose);
  292. first_free_busno=hose->last_busno+1;
  293. printf (" PCIE2 on bus %02x - %02x\n",
  294. hose->first_busno,hose->last_busno);
  295. } else {
  296. printf (" PCIE2: disabled\n");
  297. }
  298. }
  299. #else
  300. gur->devdisr |= MPC85xx_DEVDISR_PCIE2; /* disable */
  301. #endif
  302. #ifdef CONFIG_PCI1
  303. {
  304. volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCI1_ADDR;
  305. struct pci_controller *hose = &pci1_hose;
  306. struct pci_region *r = hose->regions;
  307. uint pci_agent = (host_agent == 6);
  308. uint pci_speed = 66666000; /*get_clock_freq (); PCI PSPEED in [4:5] */
  309. uint pci_32 = 1;
  310. uint pci_arb = gur->pordevsr & MPC85xx_PORDEVSR_PCI1_ARB; /* PORDEVSR[14] */
  311. uint pci_clk_sel = gur->porpllsr & MPC85xx_PORDEVSR_PCI1_SPD; /* PORPLLSR[16] */
  312. if (!(devdisr & MPC85xx_DEVDISR_PCI1)) {
  313. printf ("\n PCI: %d bit, %s MHz, %s, %s, %s (base address %x)\n",
  314. (pci_32) ? 32 : 64,
  315. (pci_speed == 33333000) ? "33" :
  316. (pci_speed == 66666000) ? "66" : "unknown",
  317. pci_clk_sel ? "sync" : "async",
  318. pci_agent ? "agent" : "host",
  319. pci_arb ? "arbiter" : "external-arbiter",
  320. (uint)pci
  321. );
  322. /* inbound */
  323. r += fsl_pci_setup_inbound_windows(r);
  324. /* outbound memory */
  325. pci_set_region(r++,
  326. CONFIG_SYS_PCI1_MEM_BASE,
  327. CONFIG_SYS_PCI1_MEM_PHYS,
  328. CONFIG_SYS_PCI1_MEM_SIZE,
  329. PCI_REGION_MEM);
  330. /* outbound io */
  331. pci_set_region(r++,
  332. CONFIG_SYS_PCI1_IO_BASE,
  333. CONFIG_SYS_PCI1_IO_PHYS,
  334. CONFIG_SYS_PCI1_IO_SIZE,
  335. PCI_REGION_IO);
  336. #ifdef CONFIG_SYS_PCI1_MEM_BASE2
  337. /* outbound memory */
  338. pci_set_region(r++,
  339. CONFIG_SYS_PCI1_MEM_BASE2,
  340. CONFIG_SYS_PCI1_MEM_PHYS2,
  341. CONFIG_SYS_PCI1_MEM_SIZE2,
  342. PCI_REGION_MEM);
  343. #endif
  344. hose->region_count = r - hose->regions;
  345. hose->first_busno=first_free_busno;
  346. pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data);
  347. fsl_pci_init(hose);
  348. first_free_busno=hose->last_busno+1;
  349. printf ("PCI on bus %02x - %02x\n",
  350. hose->first_busno,hose->last_busno);
  351. } else {
  352. printf (" PCI: disabled\n");
  353. }
  354. }
  355. #else
  356. gur->devdisr |= MPC85xx_DEVDISR_PCI1; /* disable */
  357. #endif
  358. }
  359. int board_early_init_r(void)
  360. {
  361. const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
  362. const u8 flash_esel = 1;
  363. /*
  364. * Remap Boot flash + PROMJET region to caching-inhibited
  365. * so that flash can be erased properly.
  366. */
  367. /* Flush d-cache and invalidate i-cache of any FLASH data */
  368. flush_dcache();
  369. invalidate_icache();
  370. /* invalidate existing TLB entry for flash + promjet */
  371. disable_tlb(flash_esel);
  372. set_tlb(1, flashbase, flashbase, /* tlb, epn, rpn */
  373. MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, /* perms, wimge */
  374. 0, flash_esel, BOOKE_PAGESZ_256M, 1); /* ts, esel, tsize, iprot */
  375. return 0;
  376. }
  377. #ifdef CONFIG_GET_CLK_FROM_ICS307
  378. /* decode S[0-2] to Output Divider (OD) */
  379. static unsigned char
  380. ics307_S_to_OD[] = {
  381. 10, 2, 8, 4, 5, 7, 3, 6
  382. };
  383. /* Calculate frequency being generated by ICS307-02 clock chip based upon
  384. * the control bytes being programmed into it. */
  385. /* XXX: This function should probably go into a common library */
  386. static unsigned long
  387. ics307_clk_freq (unsigned char cw0, unsigned char cw1, unsigned char cw2)
  388. {
  389. const unsigned long long InputFrequency = CONFIG_ICS307_REFCLK_HZ;
  390. unsigned long VDW = ((cw1 << 1) & 0x1FE) + ((cw2 >> 7) & 1);
  391. unsigned long RDW = cw2 & 0x7F;
  392. unsigned long OD = ics307_S_to_OD[cw0 & 0x7];
  393. unsigned long freq;
  394. /* CLK1Frequency = InputFrequency * 2 * (VDW + 8) / ((RDW + 2) * OD) */
  395. /* cw0: C1 C0 TTL F1 F0 S2 S1 S0
  396. * cw1: V8 V7 V6 V5 V4 V3 V2 V1
  397. * cw2: V0 R6 R5 R4 R3 R2 R1 R0
  398. *
  399. * R6:R0 = Reference Divider Word (RDW)
  400. * V8:V0 = VCO Divider Word (VDW)
  401. * S2:S0 = Output Divider Select (OD)
  402. * F1:F0 = Function of CLK2 Output
  403. * TTL = duty cycle
  404. * C1:C0 = internal load capacitance for cyrstal
  405. */
  406. /* Adding 1 to get a "nicely" rounded number, but this needs
  407. * more tweaking to get a "properly" rounded number. */
  408. freq = 1 + (InputFrequency * 2 * (VDW + 8) / ((RDW + 2) * OD));
  409. debug("ICS307: CW[0-2]: %02X %02X %02X => %u Hz\n", cw0, cw1, cw2,
  410. freq);
  411. return freq;
  412. }
  413. unsigned long
  414. get_board_sys_clk(ulong dummy)
  415. {
  416. return ics307_clk_freq (
  417. in8(PIXIS_BASE + PIXIS_VSYSCLK0),
  418. in8(PIXIS_BASE + PIXIS_VSYSCLK1),
  419. in8(PIXIS_BASE + PIXIS_VSYSCLK2)
  420. );
  421. }
  422. unsigned long
  423. get_board_ddr_clk(ulong dummy)
  424. {
  425. return ics307_clk_freq (
  426. in8(PIXIS_BASE + PIXIS_VDDRCLK0),
  427. in8(PIXIS_BASE + PIXIS_VDDRCLK1),
  428. in8(PIXIS_BASE + PIXIS_VDDRCLK2)
  429. );
  430. }
  431. #else
  432. unsigned long
  433. get_board_sys_clk(ulong dummy)
  434. {
  435. u8 i;
  436. ulong val = 0;
  437. i = in8(PIXIS_BASE + PIXIS_SPD);
  438. i &= 0x07;
  439. switch (i) {
  440. case 0:
  441. val = 33333333;
  442. break;
  443. case 1:
  444. val = 40000000;
  445. break;
  446. case 2:
  447. val = 50000000;
  448. break;
  449. case 3:
  450. val = 66666666;
  451. break;
  452. case 4:
  453. val = 83333333;
  454. break;
  455. case 5:
  456. val = 100000000;
  457. break;
  458. case 6:
  459. val = 133333333;
  460. break;
  461. case 7:
  462. val = 166666666;
  463. break;
  464. }
  465. return val;
  466. }
  467. unsigned long
  468. get_board_ddr_clk(ulong dummy)
  469. {
  470. u8 i;
  471. ulong val = 0;
  472. i = in8(PIXIS_BASE + PIXIS_SPD);
  473. i &= 0x38;
  474. i >>= 3;
  475. switch (i) {
  476. case 0:
  477. val = 33333333;
  478. break;
  479. case 1:
  480. val = 40000000;
  481. break;
  482. case 2:
  483. val = 50000000;
  484. break;
  485. case 3:
  486. val = 66666666;
  487. break;
  488. case 4:
  489. val = 83333333;
  490. break;
  491. case 5:
  492. val = 100000000;
  493. break;
  494. case 6:
  495. val = 133333333;
  496. break;
  497. case 7:
  498. val = 166666666;
  499. break;
  500. }
  501. return val;
  502. }
  503. #endif
  504. int is_sata_supported(void)
  505. {
  506. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  507. uint sdrs2_io_sel =
  508. (gur->pordevsr & MPC85xx_PORDEVSR_SRDS2_IO_SEL) >> 27;
  509. if (sdrs2_io_sel & 0x04)
  510. return 0;
  511. return 1;
  512. }
  513. int board_eth_init(bd_t *bis)
  514. {
  515. #ifdef CONFIG_TSEC_ENET
  516. struct tsec_info_struct tsec_info[2];
  517. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  518. int num = 0;
  519. uint sdrs2_io_sel =
  520. (gur->pordevsr & MPC85xx_PORDEVSR_SRDS2_IO_SEL) >> 27;
  521. #ifdef CONFIG_TSEC1
  522. SET_STD_TSEC_INFO(tsec_info[num], 1);
  523. if ((sdrs2_io_sel == 4) || (sdrs2_io_sel == 6)) {
  524. tsec_info[num].phyaddr = 0;
  525. tsec_info[num].flags |= TSEC_SGMII;
  526. }
  527. num++;
  528. #endif
  529. #ifdef CONFIG_TSEC3
  530. SET_STD_TSEC_INFO(tsec_info[num], 3);
  531. if (sdrs2_io_sel == 4) {
  532. tsec_info[num].phyaddr = 1;
  533. tsec_info[num].flags |= TSEC_SGMII;
  534. }
  535. num++;
  536. #endif
  537. if (!num) {
  538. printf("No TSECs initialized\n");
  539. return 0;
  540. }
  541. if ((sdrs2_io_sel == 4) || (sdrs2_io_sel == 6))
  542. fsl_sgmii_riser_init(tsec_info, num);
  543. tsec_eth_init(bis, tsec_info, num);
  544. #endif
  545. return pci_eth_init(bis);
  546. }
  547. #if defined(CONFIG_OF_BOARD_SETUP)
  548. extern void ft_fsl_pci_setup(void *blob, const char *pci_alias,
  549. struct pci_controller *hose);
  550. void ft_board_setup(void *blob, bd_t *bd)
  551. {
  552. ft_cpu_setup(blob, bd);
  553. #ifdef CONFIG_PCI1
  554. ft_fsl_pci_setup(blob, "pci0", &pci1_hose);
  555. #endif
  556. #ifdef CONFIG_PCIE2
  557. ft_fsl_pci_setup(blob, "pci1", &pcie2_hose);
  558. #endif
  559. #ifdef CONFIG_PCIE2
  560. ft_fsl_pci_setup(blob, "pci2", &pcie1_hose);
  561. #endif
  562. #ifdef CONFIG_PCIE1
  563. ft_fsl_pci_setup(blob, "pci3", &pcie3_hose);
  564. #endif
  565. }
  566. #endif