mpc8536ds.c 16 KB

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