sequoia.c 18 KB

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