sequoia.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. /*
  2. * (C) Copyright 2006
  3. * Stefan Roese, DENX Software Engineering, sr@denx.de.
  4. *
  5. * (C) Copyright 2006
  6. * Jacqueline Pira-Ferriol, AMCC/IBM, jpira-ferriol@fr.ibm.com
  7. * Alain Saurel, AMCC/IBM, alain.saurel@fr.ibm.com
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #include <common.h>
  25. #include <asm/processor.h>
  26. #include <ppc440.h>
  27. #include "sequoia.h"
  28. DECLARE_GLOBAL_DATA_PTR;
  29. extern flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
  30. ulong flash_get_size (ulong base, int banknum);
  31. int board_early_init_f(void)
  32. {
  33. u32 sdr0_cust0;
  34. u32 sdr0_pfc1, sdr0_pfc2;
  35. u32 reg;
  36. mtdcr(ebccfga, xbcfg);
  37. mtdcr(ebccfgd, 0xb8400000);
  38. /*--------------------------------------------------------------------
  39. * Setup the GPIO pins
  40. *-------------------------------------------------------------------*/
  41. /* test-only: take GPIO init from pcs440ep ???? in config file */
  42. out32(GPIO0_OR, 0x00000000);
  43. out32(GPIO0_TCR, 0x0000000f);
  44. out32(GPIO0_OSRL, 0x50015400);
  45. out32(GPIO0_OSRH, 0x550050aa);
  46. out32(GPIO0_TSRL, 0x50015400);
  47. out32(GPIO0_TSRH, 0x55005000);
  48. out32(GPIO0_ISR1L, 0x50000000);
  49. out32(GPIO0_ISR1H, 0x00000000);
  50. out32(GPIO0_ISR2L, 0x00000000);
  51. out32(GPIO0_ISR2H, 0x00000100);
  52. out32(GPIO0_ISR3L, 0x00000000);
  53. out32(GPIO0_ISR3H, 0x00000000);
  54. out32(GPIO1_OR, 0x00000000);
  55. out32(GPIO1_TCR, 0xc2000000);
  56. out32(GPIO1_OSRL, 0x5c280000);
  57. out32(GPIO1_OSRH, 0x00000000);
  58. out32(GPIO1_TSRL, 0x0c000000);
  59. out32(GPIO1_TSRH, 0x00000000);
  60. out32(GPIO1_ISR1L, 0x00005550);
  61. out32(GPIO1_ISR1H, 0x00000000);
  62. out32(GPIO1_ISR2L, 0x00050000);
  63. out32(GPIO1_ISR2H, 0x00000000);
  64. out32(GPIO1_ISR3L, 0x01400000);
  65. out32(GPIO1_ISR3H, 0x00000000);
  66. /*--------------------------------------------------------------------
  67. * Setup the interrupt controller polarities, triggers, etc.
  68. *-------------------------------------------------------------------*/
  69. mtdcr(uic0sr, 0xffffffff); /* clear all */
  70. mtdcr(uic0er, 0x00000000); /* disable all */
  71. mtdcr(uic0cr, 0x00000005); /* ATI & UIC1 crit are critical */
  72. mtdcr(uic0pr, 0xfffff7ff); /* per ref-board manual */
  73. mtdcr(uic0tr, 0x00000000); /* per ref-board manual */
  74. mtdcr(uic0vr, 0x00000000); /* int31 highest, base=0x000 */
  75. mtdcr(uic0sr, 0xffffffff); /* clear all */
  76. mtdcr(uic1sr, 0xffffffff); /* clear all */
  77. mtdcr(uic1er, 0x00000000); /* disable all */
  78. mtdcr(uic1cr, 0x00000000); /* all non-critical */
  79. mtdcr(uic1pr, 0xffffffff); /* per ref-board manual */
  80. mtdcr(uic1tr, 0x00000000); /* per ref-board manual */
  81. mtdcr(uic1vr, 0x00000000); /* int31 highest, base=0x000 */
  82. mtdcr(uic1sr, 0xffffffff); /* clear all */
  83. mtdcr(uic2sr, 0xffffffff); /* clear all */
  84. mtdcr(uic2er, 0x00000000); /* disable all */
  85. mtdcr(uic2cr, 0x00000000); /* all non-critical */
  86. mtdcr(uic2pr, 0xffffffff); /* per ref-board manual */
  87. mtdcr(uic2tr, 0x00000000); /* per ref-board manual */
  88. mtdcr(uic2vr, 0x00000000); /* int31 highest, base=0x000 */
  89. mtdcr(uic2sr, 0xffffffff); /* clear all */
  90. /* 50MHz tmrclk */
  91. *(unsigned char *)(CFG_BCSR_BASE | 0x04) = 0x00;
  92. /* clear write protects */
  93. *(unsigned char *)(CFG_BCSR_BASE | 0x07) = 0x00;
  94. /* enable Ethernet */
  95. *(unsigned char *)(CFG_BCSR_BASE | 0x08) = 0x00;
  96. /* enable USB device */
  97. *(unsigned char *)(CFG_BCSR_BASE | 0x09) = 0x20;
  98. /* select Ethernet pins */
  99. mfsdr(SDR0_PFC1, sdr0_pfc1);
  100. sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_SELECT_MASK) | SDR0_PFC1_SELECT_CONFIG_4;
  101. mfsdr(SDR0_PFC2, sdr0_pfc2);
  102. sdr0_pfc2 = (sdr0_pfc2 & ~SDR0_PFC2_SELECT_MASK) | SDR0_PFC2_SELECT_CONFIG_4;
  103. mtsdr(SDR0_PFC2, sdr0_pfc2);
  104. mtsdr(SDR0_PFC1, sdr0_pfc1);
  105. /* PCI arbiter enabled */
  106. mfsdr(sdr_pci0, reg);
  107. mtsdr(sdr_pci0, 0x80000000 | reg);
  108. /* setup NAND FLASH */
  109. mfsdr(SDR0_CUST0, sdr0_cust0);
  110. sdr0_cust0 = SDR0_CUST0_MUX_NDFC_SEL |
  111. SDR0_CUST0_NDFC_ENABLE |
  112. SDR0_CUST0_NDFC_BW_8_BIT |
  113. SDR0_CUST0_NDFC_ARE_MASK |
  114. (0x80000000 >> (28 + CFG_NAND_CS));
  115. mtsdr(SDR0_CUST0, sdr0_cust0);
  116. return 0;
  117. }
  118. /*---------------------------------------------------------------------------+
  119. | misc_init_r.
  120. +---------------------------------------------------------------------------*/
  121. int misc_init_r(void)
  122. {
  123. uint pbcr;
  124. int size_val = 0;
  125. u32 reg;
  126. #ifdef CONFIG_440EPX
  127. unsigned long usb2d0cr = 0;
  128. unsigned long usb2phy0cr, usb2h0cr = 0;
  129. unsigned long sdr0_pfc1;
  130. char *act = getenv("usbact");
  131. #endif
  132. /*
  133. * FLASH stuff...
  134. */
  135. /* Re-do sizing to get full correct info */
  136. /* adjust flash start and offset */
  137. gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
  138. gd->bd->bi_flashoffset = 0;
  139. #if defined(CONFIG_NAND_U_BOOT) || defined(CONFIG_NAND_SPL)
  140. mtdcr(ebccfga, pb3cr);
  141. #else
  142. mtdcr(ebccfga, pb0cr);
  143. #endif
  144. pbcr = mfdcr(ebccfgd);
  145. switch (gd->bd->bi_flashsize) {
  146. case 1 << 20:
  147. size_val = 0;
  148. break;
  149. case 2 << 20:
  150. size_val = 1;
  151. break;
  152. case 4 << 20:
  153. size_val = 2;
  154. break;
  155. case 8 << 20:
  156. size_val = 3;
  157. break;
  158. case 16 << 20:
  159. size_val = 4;
  160. break;
  161. case 32 << 20:
  162. size_val = 5;
  163. break;
  164. case 64 << 20:
  165. size_val = 6;
  166. break;
  167. case 128 << 20:
  168. size_val = 7;
  169. break;
  170. }
  171. pbcr = (pbcr & 0x0001ffff) | gd->bd->bi_flashstart | (size_val << 17);
  172. #if defined(CONFIG_NAND_U_BOOT) || defined(CONFIG_NAND_SPL)
  173. mtdcr(ebccfga, pb3cr);
  174. #else
  175. mtdcr(ebccfga, pb0cr);
  176. #endif
  177. mtdcr(ebccfgd, pbcr);
  178. /*
  179. * Re-check to get correct base address
  180. */
  181. flash_get_size(gd->bd->bi_flashstart, 0);
  182. #ifdef CFG_ENV_IS_IN_FLASH
  183. /* Monitor protection ON by default */
  184. (void)flash_protect(FLAG_PROTECT_SET,
  185. -CFG_MONITOR_LEN,
  186. 0xffffffff,
  187. &flash_info[0]);
  188. /* Env protection ON by default */
  189. (void)flash_protect(FLAG_PROTECT_SET,
  190. CFG_ENV_ADDR_REDUND,
  191. CFG_ENV_ADDR_REDUND + 2*CFG_ENV_SECT_SIZE - 1,
  192. &flash_info[0]);
  193. #endif
  194. /*
  195. * USB suff...
  196. */
  197. #ifdef CONFIG_440EPX
  198. if (act == NULL || strcmp(act, "hostdev") == 0) {
  199. /* SDR Setting */
  200. mfsdr(SDR0_PFC1, sdr0_pfc1);
  201. mfsdr(SDR0_USB0, usb2d0cr);
  202. mfsdr(SDR0_USB2PHY0CR, usb2phy0cr);
  203. mfsdr(SDR0_USB2H0CR, usb2h0cr);
  204. usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_XOCLK_MASK;
  205. usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_XOCLK_EXTERNAL; /*0*/
  206. usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_WDINT_MASK;
  207. usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_WDINT_16BIT_30MHZ; /*1*/
  208. usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DVBUS_MASK;
  209. usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DVBUS_PURDIS; /*0*/
  210. usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DWNSTR_MASK;
  211. usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DWNSTR_HOST; /*1*/
  212. usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_UTMICN_MASK;
  213. usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_UTMICN_HOST; /*1*/
  214. /* An 8-bit/60MHz interface is the only possible alternative
  215. when connecting the Device to the PHY */
  216. usb2h0cr = usb2h0cr &~SDR0_USB2H0CR_WDINT_MASK;
  217. usb2h0cr = usb2h0cr | SDR0_USB2H0CR_WDINT_16BIT_30MHZ; /*1*/
  218. /* To enable the USB 2.0 Device function through the UTMI interface */
  219. usb2d0cr = usb2d0cr &~SDR0_USB2D0CR_USB2DEV_EBC_SEL_MASK;
  220. usb2d0cr = usb2d0cr | SDR0_USB2D0CR_USB2DEV_SELECTION; /*1*/
  221. sdr0_pfc1 = sdr0_pfc1 &~SDR0_PFC1_UES_MASK;
  222. sdr0_pfc1 = sdr0_pfc1 | SDR0_PFC1_UES_USB2D_SEL; /*0*/
  223. mtsdr(SDR0_PFC1, sdr0_pfc1);
  224. mtsdr(SDR0_USB0, usb2d0cr);
  225. mtsdr(SDR0_USB2PHY0CR, usb2phy0cr);
  226. mtsdr(SDR0_USB2H0CR, usb2h0cr);
  227. /*clear resets*/
  228. udelay (1000);
  229. mtsdr(SDR0_SRST1, 0x00000000);
  230. udelay (1000);
  231. mtsdr(SDR0_SRST0, 0x00000000);
  232. printf("USB: Host(int phy) Device(ext phy)\n");
  233. } else if (strcmp(act, "dev") == 0) {
  234. /*-------------------PATCH-------------------------------*/
  235. mfsdr(SDR0_USB2PHY0CR, usb2phy0cr);
  236. usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_XOCLK_MASK;
  237. usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_XOCLK_EXTERNAL; /*0*/
  238. usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DVBUS_MASK;
  239. usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DVBUS_PURDIS; /*0*/
  240. usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DWNSTR_MASK;
  241. usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DWNSTR_HOST; /*1*/
  242. usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_UTMICN_MASK;
  243. usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_UTMICN_HOST; /*1*/
  244. mtsdr(SDR0_USB2PHY0CR, usb2phy0cr);
  245. udelay (1000);
  246. mtsdr(SDR0_SRST1, 0x672c6000);
  247. udelay (1000);
  248. mtsdr(SDR0_SRST0, 0x00000080);
  249. udelay (1000);
  250. mtsdr(SDR0_SRST1, 0x60206000);
  251. *(unsigned int *)(0xe0000350) = 0x00000001;
  252. udelay (1000);
  253. mtsdr(SDR0_SRST1, 0x60306000);
  254. /*-------------------PATCH-------------------------------*/
  255. /* SDR Setting */
  256. mfsdr(SDR0_USB2PHY0CR, usb2phy0cr);
  257. mfsdr(SDR0_USB2H0CR, usb2h0cr);
  258. mfsdr(SDR0_USB0, usb2d0cr);
  259. mfsdr(SDR0_PFC1, sdr0_pfc1);
  260. usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_XOCLK_MASK;
  261. usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_XOCLK_EXTERNAL; /*0*/
  262. usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_WDINT_MASK;
  263. usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_WDINT_8BIT_60MHZ; /*0*/
  264. usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DVBUS_MASK;
  265. usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DVBUS_PUREN; /*1*/
  266. usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DWNSTR_MASK;
  267. usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DWNSTR_DEV; /*0*/
  268. usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_UTMICN_MASK;
  269. usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_UTMICN_DEV; /*0*/
  270. usb2h0cr = usb2h0cr &~SDR0_USB2H0CR_WDINT_MASK;
  271. usb2h0cr = usb2h0cr | SDR0_USB2H0CR_WDINT_8BIT_60MHZ; /*0*/
  272. usb2d0cr = usb2d0cr &~SDR0_USB2D0CR_USB2DEV_EBC_SEL_MASK;
  273. usb2d0cr = usb2d0cr | SDR0_USB2D0CR_EBC_SELECTION; /*0*/
  274. sdr0_pfc1 = sdr0_pfc1 &~SDR0_PFC1_UES_MASK;
  275. sdr0_pfc1 = sdr0_pfc1 | SDR0_PFC1_UES_EBCHR_SEL; /*1*/
  276. mtsdr(SDR0_USB2H0CR, usb2h0cr);
  277. mtsdr(SDR0_USB2PHY0CR, usb2phy0cr);
  278. mtsdr(SDR0_USB0, usb2d0cr);
  279. mtsdr(SDR0_PFC1, sdr0_pfc1);
  280. /*clear resets*/
  281. udelay (1000);
  282. mtsdr(SDR0_SRST1, 0x00000000);
  283. udelay (1000);
  284. mtsdr(SDR0_SRST0, 0x00000000);
  285. printf("USB: Device(int phy)\n");
  286. }
  287. #endif /* CONFIG_440EPX */
  288. /*
  289. * Clear PLB4A0_ACR[WRP]
  290. * This fix will make the MAL burst disabling patch for the Linux
  291. * EMAC driver obsolete.
  292. */
  293. reg = mfdcr(plb4_acr) & ~PLB4_ACR_WRP;
  294. mtdcr(plb4_acr, reg);
  295. return 0;
  296. }
  297. int checkboard(void)
  298. {
  299. char *s = getenv("serial#");
  300. #ifdef CONFIG_440EPX
  301. printf("Board: Sequoia - AMCC PPC440EPx Evaluation Board");
  302. #else
  303. printf("Board: Rainier - AMCC PPC440GRx Evaluation Board");
  304. #endif
  305. if (s != NULL) {
  306. puts(", serial# ");
  307. puts(s);
  308. }
  309. putc('\n');
  310. return (0);
  311. }
  312. #if defined(CFG_DRAM_TEST)
  313. int testdram(void)
  314. {
  315. unsigned long *mem = (unsigned long *)0;
  316. const unsigned long kend = (1024 / sizeof(unsigned long));
  317. unsigned long k, n;
  318. mtmsr(0);
  319. for (k = 0; k < CFG_MBYTES_SDRAM;
  320. ++k, mem += (1024 / sizeof(unsigned long))) {
  321. if ((k & 1023) == 0) {
  322. printf("%3d MB\r", k / 1024);
  323. }
  324. memset(mem, 0xaaaaaaaa, 1024);
  325. for (n = 0; n < kend; ++n) {
  326. if (mem[n] != 0xaaaaaaaa) {
  327. printf("SDRAM test fails at: %08x\n",
  328. (uint) & mem[n]);
  329. return 1;
  330. }
  331. }
  332. memset(mem, 0x55555555, 1024);
  333. for (n = 0; n < kend; ++n) {
  334. if (mem[n] != 0x55555555) {
  335. printf("SDRAM test fails at: %08x\n",
  336. (uint) & mem[n]);
  337. return 1;
  338. }
  339. }
  340. }
  341. printf("SDRAM test passes\n");
  342. return 0;
  343. }
  344. #endif
  345. /*************************************************************************
  346. * pci_pre_init
  347. *
  348. * This routine is called just prior to registering the hose and gives
  349. * the board the opportunity to check things. Returning a value of zero
  350. * indicates that things are bad & PCI initialization should be aborted.
  351. *
  352. * Different boards may wish to customize the pci controller structure
  353. * (add regions, override default access routines, etc) or perform
  354. * certain pre-initialization actions.
  355. *
  356. ************************************************************************/
  357. #if defined(CONFIG_PCI) && defined(CFG_PCI_PRE_INIT)
  358. int pci_pre_init(struct pci_controller *hose)
  359. {
  360. unsigned long addr;
  361. #if 0
  362. /*--------------------------------------------------------------------------+
  363. * Cactus is always configured as the host & requires the
  364. * PCI arbiter to be enabled ???
  365. *--------------------------------------------------------------------------*/
  366. unsigned long strap;
  367. mfsdr(sdr_sdstp1, strap);
  368. if ((strap & SDR0_SDSTP1_PAE_MASK) == 0) {
  369. printf("PCI: SDR0_STRP1[PAE] not set.\n");
  370. printf("PCI: Configuration aborted.\n");
  371. return 0;
  372. }
  373. #endif
  374. /*-------------------------------------------------------------------------+
  375. | Set priority for all PLB3 devices to 0.
  376. | Set PLB3 arbiter to fair mode.
  377. +-------------------------------------------------------------------------*/
  378. mfsdr(sdr_amp1, addr);
  379. mtsdr(sdr_amp1, (addr & 0x000000FF) | 0x0000FF00);
  380. addr = mfdcr(plb3_acr);
  381. mtdcr(plb3_acr, addr | 0x80000000);
  382. /*-------------------------------------------------------------------------+
  383. | Set priority for all PLB4 devices to 0.
  384. +-------------------------------------------------------------------------*/
  385. mfsdr(sdr_amp0, addr);
  386. mtsdr(sdr_amp0, (addr & 0x000000FF) | 0x0000FF00);
  387. addr = mfdcr(plb4_acr) | 0xa0000000; /* Was 0x8---- */
  388. mtdcr(plb4_acr, addr);
  389. /*-------------------------------------------------------------------------+
  390. | Set Nebula PLB4 arbiter to fair mode.
  391. +-------------------------------------------------------------------------*/
  392. /* Segment0 */
  393. addr = (mfdcr(plb0_acr) & ~plb0_acr_ppm_mask) | plb0_acr_ppm_fair;
  394. addr = (addr & ~plb0_acr_hbu_mask) | plb0_acr_hbu_enabled;
  395. addr = (addr & ~plb0_acr_rdp_mask) | plb0_acr_rdp_4deep;
  396. addr = (addr & ~plb0_acr_wrp_mask) | plb0_acr_wrp_2deep;
  397. mtdcr(plb0_acr, addr);
  398. /* Segment1 */
  399. addr = (mfdcr(plb1_acr) & ~plb1_acr_ppm_mask) | plb1_acr_ppm_fair;
  400. addr = (addr & ~plb1_acr_hbu_mask) | plb1_acr_hbu_enabled;
  401. addr = (addr & ~plb1_acr_rdp_mask) | plb1_acr_rdp_4deep;
  402. addr = (addr & ~plb1_acr_wrp_mask) | plb1_acr_wrp_2deep;
  403. mtdcr(plb1_acr, addr);
  404. return 1;
  405. }
  406. #endif /* defined(CONFIG_PCI) && defined(CFG_PCI_PRE_INIT) */
  407. /*************************************************************************
  408. * pci_target_init
  409. *
  410. * The bootstrap configuration provides default settings for the pci
  411. * inbound map (PIM). But the bootstrap config choices are limited and
  412. * may not be sufficient for a given board.
  413. *
  414. ************************************************************************/
  415. #if defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT)
  416. void pci_target_init(struct pci_controller *hose)
  417. {
  418. /*--------------------------------------------------------------------------+
  419. * Set up Direct MMIO registers
  420. *--------------------------------------------------------------------------*/
  421. /*--------------------------------------------------------------------------+
  422. | PowerPC440EPX PCI Master configuration.
  423. | Map one 1Gig range of PLB/processor addresses to PCI memory space.
  424. | PLB address 0xA0000000-0xDFFFFFFF ==> PCI address 0xA0000000-0xDFFFFFFF
  425. | Use byte reversed out routines to handle endianess.
  426. | Make this region non-prefetchable.
  427. +--------------------------------------------------------------------------*/
  428. out32r(PCIX0_PMM0MA, 0x00000000); /* PMM0 Mask/Attribute - disabled b4 setting */
  429. out32r(PCIX0_PMM0LA, CFG_PCI_MEMBASE); /* PMM0 Local Address */
  430. out32r(PCIX0_PMM0PCILA, CFG_PCI_MEMBASE); /* PMM0 PCI Low Address */
  431. out32r(PCIX0_PMM0PCIHA, 0x00000000); /* PMM0 PCI High Address */
  432. out32r(PCIX0_PMM0MA, 0xE0000001); /* 512M + No prefetching, and enable region */
  433. out32r(PCIX0_PMM1MA, 0x00000000); /* PMM0 Mask/Attribute - disabled b4 setting */
  434. out32r(PCIX0_PMM1LA, CFG_PCI_MEMBASE2); /* PMM0 Local Address */
  435. out32r(PCIX0_PMM1PCILA, CFG_PCI_MEMBASE2); /* PMM0 PCI Low Address */
  436. out32r(PCIX0_PMM1PCIHA, 0x00000000); /* PMM0 PCI High Address */
  437. out32r(PCIX0_PMM1MA, 0xE0000001); /* 512M + No prefetching, and enable region */
  438. out32r(PCIX0_PTM1MS, 0x00000001); /* Memory Size/Attribute */
  439. out32r(PCIX0_PTM1LA, 0); /* Local Addr. Reg */
  440. out32r(PCIX0_PTM2MS, 0); /* Memory Size/Attribute */
  441. out32r(PCIX0_PTM2LA, 0); /* Local Addr. Reg */
  442. /*--------------------------------------------------------------------------+
  443. * Set up Configuration registers
  444. *--------------------------------------------------------------------------*/
  445. /* Program the board's subsystem id/vendor id */
  446. pci_write_config_word(0, PCI_SUBSYSTEM_VENDOR_ID,
  447. CFG_PCI_SUBSYS_VENDORID);
  448. pci_write_config_word(0, PCI_SUBSYSTEM_ID, CFG_PCI_SUBSYS_ID);
  449. /* Configure command register as bus master */
  450. pci_write_config_word(0, PCI_COMMAND, PCI_COMMAND_MASTER);
  451. /* 240nS PCI clock */
  452. pci_write_config_word(0, PCI_LATENCY_TIMER, 1);
  453. /* No error reporting */
  454. pci_write_config_word(0, PCI_ERREN, 0);
  455. pci_write_config_dword(0, PCI_BRDGOPT2, 0x00000101);
  456. }
  457. #endif /* defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT) */
  458. /*************************************************************************
  459. * pci_master_init
  460. *
  461. ************************************************************************/
  462. #if defined(CONFIG_PCI) && defined(CFG_PCI_MASTER_INIT)
  463. void pci_master_init(struct pci_controller *hose)
  464. {
  465. unsigned short temp_short;
  466. /*--------------------------------------------------------------------------+
  467. | Write the PowerPC440 EP PCI Configuration regs.
  468. | Enable PowerPC440 EP to be a master on the PCI bus (PMM).
  469. | Enable PowerPC440 EP to act as a PCI memory target (PTM).
  470. +--------------------------------------------------------------------------*/
  471. pci_read_config_word(0, PCI_COMMAND, &temp_short);
  472. pci_write_config_word(0, PCI_COMMAND,
  473. temp_short | PCI_COMMAND_MASTER |
  474. PCI_COMMAND_MEMORY);
  475. }
  476. #endif /* defined(CONFIG_PCI) && defined(CFG_PCI_MASTER_INIT) */
  477. /*************************************************************************
  478. * is_pci_host
  479. *
  480. * This routine is called to determine if a pci scan should be
  481. * performed. With various hardware environments (especially cPCI and
  482. * PPMC) it's insufficient to depend on the state of the arbiter enable
  483. * bit in the strap register, or generic host/adapter assumptions.
  484. *
  485. * Rather than hard-code a bad assumption in the general 440 code, the
  486. * 440 pci code requires the board to decide at runtime.
  487. *
  488. * Return 0 for adapter mode, non-zero for host (monarch) mode.
  489. *
  490. *
  491. ************************************************************************/
  492. #if defined(CONFIG_PCI)
  493. int is_pci_host(struct pci_controller *hose)
  494. {
  495. /* Cactus is always configured as host. */
  496. return (1);
  497. }
  498. #endif /* defined(CONFIG_PCI) */