mpc8536ds.c 16 KB

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