sequoia.c 18 KB

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