mpc8536ds.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  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. int first_free_busno=0;
  133. void
  134. pci_init_board(void)
  135. {
  136. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  137. uint devdisr = gur->devdisr;
  138. uint sdrs2_io_sel =
  139. (gur->pordevsr & MPC85xx_PORDEVSR_SRDS2_IO_SEL) >> 27;
  140. uint io_sel = (gur->pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19;
  141. uint host_agent = (gur->porbmsr & MPC85xx_PORBMSR_HA) >> 16;
  142. debug(" pci_init_board: devdisr=%x, sdrs2_io_sel=%x, io_sel=%x,\
  143. host_agent=%x\n", devdisr, sdrs2_io_sel, io_sel, host_agent);
  144. if (sdrs2_io_sel == 7)
  145. printf(" Serdes2 disalbed\n");
  146. else if (sdrs2_io_sel == 4) {
  147. printf(" eTSEC1 is in sgmii mode.\n");
  148. printf(" eTSEC3 is in sgmii mode.\n");
  149. } else if (sdrs2_io_sel == 6)
  150. printf(" eTSEC1 is in sgmii mode.\n");
  151. #ifdef CONFIG_PCIE3
  152. {
  153. volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE3_ADDR;
  154. extern void fsl_pci_init(struct pci_controller *hose);
  155. struct pci_controller *hose = &pcie3_hose;
  156. int pcie_ep = (host_agent == 1);
  157. int pcie_configured = (io_sel == 7);
  158. if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
  159. printf ("\n PCIE3 connected to Slot3 as %s (base address %x)",
  160. pcie_ep ? "End Point" : "Root Complex",
  161. (uint)pci);
  162. if (pci->pme_msg_det) {
  163. pci->pme_msg_det = 0xffffffff;
  164. debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det);
  165. }
  166. printf ("\n");
  167. /* inbound */
  168. pci_set_region(hose->regions + 0,
  169. CONFIG_SYS_PCI_MEMORY_BUS,
  170. CONFIG_SYS_PCI_MEMORY_PHYS,
  171. CONFIG_SYS_PCI_MEMORY_SIZE,
  172. PCI_REGION_MEM | PCI_REGION_MEMORY);
  173. /* outbound memory */
  174. pci_set_region(hose->regions + 1,
  175. CONFIG_SYS_PCIE3_MEM_BASE,
  176. CONFIG_SYS_PCIE3_MEM_PHYS,
  177. CONFIG_SYS_PCIE3_MEM_SIZE,
  178. PCI_REGION_MEM);
  179. /* outbound io */
  180. pci_set_region(hose->regions + 2,
  181. CONFIG_SYS_PCIE3_IO_BASE,
  182. CONFIG_SYS_PCIE3_IO_PHYS,
  183. CONFIG_SYS_PCIE3_IO_SIZE,
  184. PCI_REGION_IO);
  185. hose->region_count = 3;
  186. hose->first_busno=first_free_busno;
  187. pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data);
  188. fsl_pci_init(hose);
  189. first_free_busno=hose->last_busno+1;
  190. printf (" PCIE3 on bus %02x - %02x\n",
  191. hose->first_busno,hose->last_busno);
  192. } else {
  193. printf (" PCIE3: disabled\n");
  194. }
  195. }
  196. #else
  197. gur->devdisr |= MPC85xx_DEVDISR_PCIE3; /* disable */
  198. #endif
  199. #ifdef CONFIG_PCIE1
  200. {
  201. volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE1_ADDR;
  202. extern void fsl_pci_init(struct pci_controller *hose);
  203. struct pci_controller *hose = &pcie1_hose;
  204. int pcie_ep = (host_agent == 5);
  205. int pcie_configured = (io_sel == 2 || io_sel == 3
  206. || io_sel == 5 || io_sel == 7);
  207. if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
  208. printf ("\n PCIE1 connected to Slot1 as %s (base address %x)",
  209. pcie_ep ? "End Point" : "Root Complex",
  210. (uint)pci);
  211. if (pci->pme_msg_det) {
  212. pci->pme_msg_det = 0xffffffff;
  213. debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det);
  214. }
  215. printf ("\n");
  216. /* inbound */
  217. pci_set_region(hose->regions + 0,
  218. CONFIG_SYS_PCI_MEMORY_BUS,
  219. CONFIG_SYS_PCI_MEMORY_PHYS,
  220. CONFIG_SYS_PCI_MEMORY_SIZE,
  221. PCI_REGION_MEM | PCI_REGION_MEMORY);
  222. /* outbound memory */
  223. pci_set_region(hose->regions + 1,
  224. CONFIG_SYS_PCIE1_MEM_BASE,
  225. CONFIG_SYS_PCIE1_MEM_PHYS,
  226. CONFIG_SYS_PCIE1_MEM_SIZE,
  227. PCI_REGION_MEM);
  228. /* outbound io */
  229. pci_set_region(hose->regions + 2,
  230. CONFIG_SYS_PCIE1_IO_BASE,
  231. CONFIG_SYS_PCIE1_IO_PHYS,
  232. CONFIG_SYS_PCIE1_IO_SIZE,
  233. PCI_REGION_IO);
  234. hose->region_count = 3;
  235. #ifdef CONFIG_SYS_PCIE1_MEM_BASE2
  236. /* outbound memory */
  237. pci_set_region(hose->regions + 3,
  238. CONFIG_SYS_PCIE1_MEM_BASE2,
  239. CONFIG_SYS_PCIE1_MEM_PHYS2,
  240. CONFIG_SYS_PCIE1_MEM_SIZE2,
  241. PCI_REGION_MEM);
  242. hose->region_count++;
  243. #endif
  244. hose->first_busno=first_free_busno;
  245. pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data);
  246. fsl_pci_init(hose);
  247. first_free_busno=hose->last_busno+1;
  248. printf(" PCIE1 on bus %02x - %02x\n",
  249. hose->first_busno,hose->last_busno);
  250. } else {
  251. printf (" PCIE1: disabled\n");
  252. }
  253. }
  254. #else
  255. gur->devdisr |= MPC85xx_DEVDISR_PCIE; /* disable */
  256. #endif
  257. #ifdef CONFIG_PCIE2
  258. {
  259. volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE2_ADDR;
  260. extern void fsl_pci_init(struct pci_controller *hose);
  261. struct pci_controller *hose = &pcie2_hose;
  262. int pcie_ep = (host_agent == 3);
  263. int pcie_configured = (io_sel == 5 || io_sel == 7);
  264. if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
  265. printf ("\n PCIE2 connected to Slot 2 as %s (base address %x)",
  266. pcie_ep ? "End Point" : "Root Complex",
  267. (uint)pci);
  268. if (pci->pme_msg_det) {
  269. pci->pme_msg_det = 0xffffffff;
  270. debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det);
  271. }
  272. printf ("\n");
  273. /* inbound */
  274. pci_set_region(hose->regions + 0,
  275. CONFIG_SYS_PCI_MEMORY_BUS,
  276. CONFIG_SYS_PCI_MEMORY_PHYS,
  277. CONFIG_SYS_PCI_MEMORY_SIZE,
  278. PCI_REGION_MEM | PCI_REGION_MEMORY);
  279. /* outbound memory */
  280. pci_set_region(hose->regions + 1,
  281. CONFIG_SYS_PCIE2_MEM_BASE,
  282. CONFIG_SYS_PCIE2_MEM_PHYS,
  283. CONFIG_SYS_PCIE2_MEM_SIZE,
  284. PCI_REGION_MEM);
  285. /* outbound io */
  286. pci_set_region(hose->regions + 2,
  287. CONFIG_SYS_PCIE2_IO_BASE,
  288. CONFIG_SYS_PCIE2_IO_PHYS,
  289. CONFIG_SYS_PCIE2_IO_SIZE,
  290. PCI_REGION_IO);
  291. hose->region_count = 3;
  292. #ifdef CONFIG_SYS_PCIE2_MEM_BASE2
  293. /* outbound memory */
  294. pci_set_region(hose->regions + 3,
  295. CONFIG_SYS_PCIE2_MEM_BASE2,
  296. CONFIG_SYS_PCIE2_MEM_PHYS2,
  297. CONFIG_SYS_PCIE2_MEM_SIZE2,
  298. PCI_REGION_MEM);
  299. hose->region_count++;
  300. #endif
  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 (" PCIE2 on bus %02x - %02x\n",
  306. hose->first_busno,hose->last_busno);
  307. } else {
  308. printf (" PCIE2: disabled\n");
  309. }
  310. }
  311. #else
  312. gur->devdisr |= MPC85xx_DEVDISR_PCIE2; /* disable */
  313. #endif
  314. #ifdef CONFIG_PCI1
  315. {
  316. volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCI1_ADDR;
  317. extern void fsl_pci_init(struct pci_controller *hose);
  318. struct pci_controller *hose = &pci1_hose;
  319. uint pci_agent = (host_agent == 6);
  320. uint pci_speed = 66666000; /*get_clock_freq (); PCI PSPEED in [4:5] */
  321. uint pci_32 = 1;
  322. uint pci_arb = gur->pordevsr & MPC85xx_PORDEVSR_PCI1_ARB; /* PORDEVSR[14] */
  323. uint pci_clk_sel = gur->porpllsr & MPC85xx_PORDEVSR_PCI1_SPD; /* PORPLLSR[16] */
  324. if (!(devdisr & MPC85xx_DEVDISR_PCI1)) {
  325. printf ("\n PCI: %d bit, %s MHz, %s, %s, %s (base address %x)\n",
  326. (pci_32) ? 32 : 64,
  327. (pci_speed == 33333000) ? "33" :
  328. (pci_speed == 66666000) ? "66" : "unknown",
  329. pci_clk_sel ? "sync" : "async",
  330. pci_agent ? "agent" : "host",
  331. pci_arb ? "arbiter" : "external-arbiter",
  332. (uint)pci
  333. );
  334. /* inbound */
  335. pci_set_region(hose->regions + 0,
  336. CONFIG_SYS_PCI_MEMORY_BUS,
  337. CONFIG_SYS_PCI_MEMORY_PHYS,
  338. CONFIG_SYS_PCI_MEMORY_SIZE,
  339. PCI_REGION_MEM | PCI_REGION_MEMORY);
  340. /* outbound memory */
  341. pci_set_region(hose->regions + 1,
  342. CONFIG_SYS_PCI1_MEM_BASE,
  343. CONFIG_SYS_PCI1_MEM_PHYS,
  344. CONFIG_SYS_PCI1_MEM_SIZE,
  345. PCI_REGION_MEM);
  346. /* outbound io */
  347. pci_set_region(hose->regions + 2,
  348. CONFIG_SYS_PCI1_IO_BASE,
  349. CONFIG_SYS_PCI1_IO_PHYS,
  350. CONFIG_SYS_PCI1_IO_SIZE,
  351. PCI_REGION_IO);
  352. hose->region_count = 3;
  353. #ifdef CONFIG_SYS_PCI1_MEM_BASE2
  354. /* outbound memory */
  355. pci_set_region(hose->regions + 3,
  356. CONFIG_SYS_PCI1_MEM_BASE2,
  357. CONFIG_SYS_PCI1_MEM_PHYS2,
  358. CONFIG_SYS_PCI1_MEM_SIZE2,
  359. PCI_REGION_MEM);
  360. hose->region_count++;
  361. #endif
  362. hose->first_busno=first_free_busno;
  363. pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data);
  364. fsl_pci_init(hose);
  365. first_free_busno=hose->last_busno+1;
  366. printf ("PCI on bus %02x - %02x\n",
  367. hose->first_busno,hose->last_busno);
  368. } else {
  369. printf (" PCI: disabled\n");
  370. }
  371. }
  372. #else
  373. gur->devdisr |= MPC85xx_DEVDISR_PCI1; /* disable */
  374. #endif
  375. }
  376. int board_early_init_r(void)
  377. {
  378. const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
  379. const u8 flash_esel = 1;
  380. /*
  381. * Remap Boot flash + PROMJET region to caching-inhibited
  382. * so that flash can be erased properly.
  383. */
  384. /* Flush d-cache and invalidate i-cache of any FLASH data */
  385. flush_dcache();
  386. invalidate_icache();
  387. /* invalidate existing TLB entry for flash + promjet */
  388. disable_tlb(flash_esel);
  389. set_tlb(1, flashbase, flashbase, /* tlb, epn, rpn */
  390. MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, /* perms, wimge */
  391. 0, flash_esel, BOOKE_PAGESZ_256M, 1); /* ts, esel, tsize, iprot */
  392. return 0;
  393. }
  394. #ifdef CONFIG_GET_CLK_FROM_ICS307
  395. /* decode S[0-2] to Output Divider (OD) */
  396. static unsigned char
  397. ics307_S_to_OD[] = {
  398. 10, 2, 8, 4, 5, 7, 3, 6
  399. };
  400. /* Calculate frequency being generated by ICS307-02 clock chip based upon
  401. * the control bytes being programmed into it. */
  402. /* XXX: This function should probably go into a common library */
  403. static unsigned long
  404. ics307_clk_freq (unsigned char cw0, unsigned char cw1, unsigned char cw2)
  405. {
  406. const unsigned long long InputFrequency = CONFIG_ICS307_REFCLK_HZ;
  407. unsigned long VDW = ((cw1 << 1) & 0x1FE) + ((cw2 >> 7) & 1);
  408. unsigned long RDW = cw2 & 0x7F;
  409. unsigned long OD = ics307_S_to_OD[cw0 & 0x7];
  410. unsigned long freq;
  411. /* CLK1Frequency = InputFrequency * 2 * (VDW + 8) / ((RDW + 2) * OD) */
  412. /* cw0: C1 C0 TTL F1 F0 S2 S1 S0
  413. * cw1: V8 V7 V6 V5 V4 V3 V2 V1
  414. * cw2: V0 R6 R5 R4 R3 R2 R1 R0
  415. *
  416. * R6:R0 = Reference Divider Word (RDW)
  417. * V8:V0 = VCO Divider Word (VDW)
  418. * S2:S0 = Output Divider Select (OD)
  419. * F1:F0 = Function of CLK2 Output
  420. * TTL = duty cycle
  421. * C1:C0 = internal load capacitance for cyrstal
  422. */
  423. /* Adding 1 to get a "nicely" rounded number, but this needs
  424. * more tweaking to get a "properly" rounded number. */
  425. freq = 1 + (InputFrequency * 2 * (VDW + 8) / ((RDW + 2) * OD));
  426. debug("ICS307: CW[0-2]: %02X %02X %02X => %u Hz\n", cw0, cw1, cw2,
  427. freq);
  428. return freq;
  429. }
  430. unsigned long
  431. get_board_sys_clk(ulong dummy)
  432. {
  433. return ics307_clk_freq (
  434. in8(PIXIS_BASE + PIXIS_VSYSCLK0),
  435. in8(PIXIS_BASE + PIXIS_VSYSCLK1),
  436. in8(PIXIS_BASE + PIXIS_VSYSCLK2)
  437. );
  438. }
  439. unsigned long
  440. get_board_ddr_clk(ulong dummy)
  441. {
  442. return ics307_clk_freq (
  443. in8(PIXIS_BASE + PIXIS_VDDRCLK0),
  444. in8(PIXIS_BASE + PIXIS_VDDRCLK1),
  445. in8(PIXIS_BASE + PIXIS_VDDRCLK2)
  446. );
  447. }
  448. #else
  449. unsigned long
  450. get_board_sys_clk(ulong dummy)
  451. {
  452. u8 i;
  453. ulong val = 0;
  454. i = in8(PIXIS_BASE + PIXIS_SPD);
  455. i &= 0x07;
  456. switch (i) {
  457. case 0:
  458. val = 33333333;
  459. break;
  460. case 1:
  461. val = 40000000;
  462. break;
  463. case 2:
  464. val = 50000000;
  465. break;
  466. case 3:
  467. val = 66666666;
  468. break;
  469. case 4:
  470. val = 83333333;
  471. break;
  472. case 5:
  473. val = 100000000;
  474. break;
  475. case 6:
  476. val = 133333333;
  477. break;
  478. case 7:
  479. val = 166666666;
  480. break;
  481. }
  482. return val;
  483. }
  484. unsigned long
  485. get_board_ddr_clk(ulong dummy)
  486. {
  487. u8 i;
  488. ulong val = 0;
  489. i = in8(PIXIS_BASE + PIXIS_SPD);
  490. i &= 0x38;
  491. i >>= 3;
  492. switch (i) {
  493. case 0:
  494. val = 33333333;
  495. break;
  496. case 1:
  497. val = 40000000;
  498. break;
  499. case 2:
  500. val = 50000000;
  501. break;
  502. case 3:
  503. val = 66666666;
  504. break;
  505. case 4:
  506. val = 83333333;
  507. break;
  508. case 5:
  509. val = 100000000;
  510. break;
  511. case 6:
  512. val = 133333333;
  513. break;
  514. case 7:
  515. val = 166666666;
  516. break;
  517. }
  518. return val;
  519. }
  520. #endif
  521. int is_sata_supported(void)
  522. {
  523. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  524. uint devdisr = gur->devdisr;
  525. uint sdrs2_io_sel =
  526. (gur->pordevsr & MPC85xx_PORDEVSR_SRDS2_IO_SEL) >> 27;
  527. if (sdrs2_io_sel & 0x04)
  528. return 0;
  529. return 1;
  530. }
  531. int board_eth_init(bd_t *bis)
  532. {
  533. #ifdef CONFIG_TSEC_ENET
  534. struct tsec_info_struct tsec_info[2];
  535. volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
  536. int num = 0;
  537. uint sdrs2_io_sel =
  538. (gur->pordevsr & MPC85xx_PORDEVSR_SRDS2_IO_SEL) >> 27;
  539. #ifdef CONFIG_TSEC1
  540. SET_STD_TSEC_INFO(tsec_info[num], 1);
  541. if ((sdrs2_io_sel == 4) || (sdrs2_io_sel == 6)) {
  542. tsec_info[num].phyaddr = 0;
  543. tsec_info[num].flags |= TSEC_SGMII;
  544. }
  545. num++;
  546. #endif
  547. #ifdef CONFIG_TSEC3
  548. SET_STD_TSEC_INFO(tsec_info[num], 3);
  549. if (sdrs2_io_sel == 4) {
  550. tsec_info[num].phyaddr = 1;
  551. tsec_info[num].flags |= TSEC_SGMII;
  552. }
  553. num++;
  554. #endif
  555. if (!num) {
  556. printf("No TSECs initialized\n");
  557. return 0;
  558. }
  559. if ((sdrs2_io_sel == 4) || (sdrs2_io_sel == 6))
  560. fsl_sgmii_riser_init(tsec_info, num);
  561. tsec_eth_init(bis, tsec_info, num);
  562. #endif
  563. return pci_eth_init(bis);
  564. }
  565. #if defined(CONFIG_OF_BOARD_SETUP)
  566. void
  567. ft_board_setup(void *blob, bd_t *bd)
  568. {
  569. int node, tmp[2];
  570. const char *path;
  571. ft_cpu_setup(blob, bd);
  572. node = fdt_path_offset(blob, "/aliases");
  573. tmp[0] = 0;
  574. if (node >= 0) {
  575. #ifdef CONFIG_PCI1
  576. path = fdt_getprop(blob, node, "pci0", NULL);
  577. if (path) {
  578. tmp[1] = pci1_hose.last_busno - pci1_hose.first_busno;
  579. do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1);
  580. }
  581. #endif
  582. #ifdef CONFIG_PCIE2
  583. path = fdt_getprop(blob, node, "pci1", NULL);
  584. if (path) {
  585. tmp[1] = pcie2_hose.last_busno - pcie2_hose.first_busno;
  586. do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1);
  587. }
  588. #endif
  589. #ifdef CONFIG_PCIE1
  590. path = fdt_getprop(blob, node, "pci2", NULL);
  591. if (path) {
  592. tmp[1] = pcie1_hose.last_busno - pcie1_hose.first_busno;
  593. do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1);
  594. }
  595. #endif
  596. #ifdef CONFIG_PCIE3
  597. path = fdt_getprop(blob, node, "pci3", NULL);
  598. if (path) {
  599. tmp[1] = pcie3_hose.last_busno - pcie3_hose.first_busno;
  600. do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1);
  601. }
  602. #endif
  603. }
  604. }
  605. #endif