sequoia.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  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. mfsdr(SDR0_SRST1, reg); /* enable security/kasumi engines */
  289. reg &= ~(SDR0_SRST1_CRYP0 | SDR0_SRST1_KASU0);
  290. mtsdr(SDR0_SRST1, reg);
  291. /*
  292. * Clear PLB4A0_ACR[WRP]
  293. * This fix will make the MAL burst disabling patch for the Linux
  294. * EMAC driver obsolete.
  295. */
  296. reg = mfdcr(plb4_acr) & ~PLB4_ACR_WRP;
  297. mtdcr(plb4_acr, reg);
  298. return 0;
  299. }
  300. int checkboard(void)
  301. {
  302. char *s = getenv("serial#");
  303. u8 rev;
  304. u8 val;
  305. #ifdef CONFIG_440EPX
  306. printf("Board: Sequoia - AMCC PPC440EPx Evaluation Board");
  307. #else
  308. printf("Board: Rainier - AMCC PPC440GRx Evaluation Board");
  309. #endif
  310. rev = in8(CFG_BCSR_BASE + 0);
  311. val = in8(CFG_BCSR_BASE + 5) & 0x01;
  312. printf(", Rev. %X, PCI=%d MHz", rev, val ? 66 : 33);
  313. if (s != NULL) {
  314. puts(", serial# ");
  315. puts(s);
  316. }
  317. putc('\n');
  318. return (0);
  319. }
  320. #if defined(CFG_DRAM_TEST)
  321. int testdram(void)
  322. {
  323. unsigned long *mem = (unsigned long *)0;
  324. const unsigned long kend = (1024 / sizeof(unsigned long));
  325. unsigned long k, n;
  326. mtmsr(0);
  327. for (k = 0; k < CFG_MBYTES_SDRAM;
  328. ++k, mem += (1024 / sizeof(unsigned long))) {
  329. if ((k & 1023) == 0) {
  330. printf("%3d MB\r", k / 1024);
  331. }
  332. memset(mem, 0xaaaaaaaa, 1024);
  333. for (n = 0; n < kend; ++n) {
  334. if (mem[n] != 0xaaaaaaaa) {
  335. printf("SDRAM test fails at: %08x\n",
  336. (uint) & mem[n]);
  337. return 1;
  338. }
  339. }
  340. memset(mem, 0x55555555, 1024);
  341. for (n = 0; n < kend; ++n) {
  342. if (mem[n] != 0x55555555) {
  343. printf("SDRAM test fails at: %08x\n",
  344. (uint) & mem[n]);
  345. return 1;
  346. }
  347. }
  348. }
  349. printf("SDRAM test passes\n");
  350. return 0;
  351. }
  352. #endif
  353. /*************************************************************************
  354. * pci_pre_init
  355. *
  356. * This routine is called just prior to registering the hose and gives
  357. * the board the opportunity to check things. Returning a value of zero
  358. * indicates that things are bad & PCI initialization should be aborted.
  359. *
  360. * Different boards may wish to customize the pci controller structure
  361. * (add regions, override default access routines, etc) or perform
  362. * certain pre-initialization actions.
  363. *
  364. ************************************************************************/
  365. #if defined(CONFIG_PCI) && defined(CFG_PCI_PRE_INIT)
  366. int pci_pre_init(struct pci_controller *hose)
  367. {
  368. unsigned long addr;
  369. #if 0
  370. /*--------------------------------------------------------------------------+
  371. * Cactus is always configured as the host & requires the
  372. * PCI arbiter to be enabled ???
  373. *--------------------------------------------------------------------------*/
  374. unsigned long strap;
  375. mfsdr(sdr_sdstp1, strap);
  376. if ((strap & SDR0_SDSTP1_PAE_MASK) == 0) {
  377. printf("PCI: SDR0_STRP1[PAE] not set.\n");
  378. printf("PCI: Configuration aborted.\n");
  379. return 0;
  380. }
  381. #endif
  382. /*-------------------------------------------------------------------------+
  383. | Set priority for all PLB3 devices to 0.
  384. | Set PLB3 arbiter to fair mode.
  385. +-------------------------------------------------------------------------*/
  386. mfsdr(sdr_amp1, addr);
  387. mtsdr(sdr_amp1, (addr & 0x000000FF) | 0x0000FF00);
  388. addr = mfdcr(plb3_acr);
  389. mtdcr(plb3_acr, addr | 0x80000000);
  390. /*-------------------------------------------------------------------------+
  391. | Set priority for all PLB4 devices to 0.
  392. +-------------------------------------------------------------------------*/
  393. mfsdr(sdr_amp0, addr);
  394. mtsdr(sdr_amp0, (addr & 0x000000FF) | 0x0000FF00);
  395. addr = mfdcr(plb4_acr) | 0xa0000000; /* Was 0x8---- */
  396. mtdcr(plb4_acr, addr);
  397. /*-------------------------------------------------------------------------+
  398. | Set Nebula PLB4 arbiter to fair mode.
  399. +-------------------------------------------------------------------------*/
  400. /* Segment0 */
  401. addr = (mfdcr(plb0_acr) & ~plb0_acr_ppm_mask) | plb0_acr_ppm_fair;
  402. addr = (addr & ~plb0_acr_hbu_mask) | plb0_acr_hbu_enabled;
  403. addr = (addr & ~plb0_acr_rdp_mask) | plb0_acr_rdp_4deep;
  404. addr = (addr & ~plb0_acr_wrp_mask) | plb0_acr_wrp_2deep;
  405. mtdcr(plb0_acr, addr);
  406. /* Segment1 */
  407. addr = (mfdcr(plb1_acr) & ~plb1_acr_ppm_mask) | plb1_acr_ppm_fair;
  408. addr = (addr & ~plb1_acr_hbu_mask) | plb1_acr_hbu_enabled;
  409. addr = (addr & ~plb1_acr_rdp_mask) | plb1_acr_rdp_4deep;
  410. addr = (addr & ~plb1_acr_wrp_mask) | plb1_acr_wrp_2deep;
  411. mtdcr(plb1_acr, addr);
  412. return 1;
  413. }
  414. #endif /* defined(CONFIG_PCI) && defined(CFG_PCI_PRE_INIT) */
  415. /*************************************************************************
  416. * pci_target_init
  417. *
  418. * The bootstrap configuration provides default settings for the pci
  419. * inbound map (PIM). But the bootstrap config choices are limited and
  420. * may not be sufficient for a given board.
  421. *
  422. ************************************************************************/
  423. #if defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT)
  424. void pci_target_init(struct pci_controller *hose)
  425. {
  426. /*--------------------------------------------------------------------------+
  427. * Set up Direct MMIO registers
  428. *--------------------------------------------------------------------------*/
  429. /*--------------------------------------------------------------------------+
  430. | PowerPC440EPX PCI Master configuration.
  431. | Map one 1Gig range of PLB/processor addresses to PCI memory space.
  432. | PLB address 0xA0000000-0xDFFFFFFF ==> PCI address 0xA0000000-0xDFFFFFFF
  433. | Use byte reversed out routines to handle endianess.
  434. | Make this region non-prefetchable.
  435. +--------------------------------------------------------------------------*/
  436. out32r(PCIX0_PMM0MA, 0x00000000); /* PMM0 Mask/Attribute - disabled b4 setting */
  437. out32r(PCIX0_PMM0LA, CFG_PCI_MEMBASE); /* PMM0 Local Address */
  438. out32r(PCIX0_PMM0PCILA, CFG_PCI_MEMBASE); /* PMM0 PCI Low Address */
  439. out32r(PCIX0_PMM0PCIHA, 0x00000000); /* PMM0 PCI High Address */
  440. out32r(PCIX0_PMM0MA, 0xE0000001); /* 512M + No prefetching, and enable region */
  441. out32r(PCIX0_PMM1MA, 0x00000000); /* PMM0 Mask/Attribute - disabled b4 setting */
  442. out32r(PCIX0_PMM1LA, CFG_PCI_MEMBASE2); /* PMM0 Local Address */
  443. out32r(PCIX0_PMM1PCILA, CFG_PCI_MEMBASE2); /* PMM0 PCI Low Address */
  444. out32r(PCIX0_PMM1PCIHA, 0x00000000); /* PMM0 PCI High Address */
  445. out32r(PCIX0_PMM1MA, 0xE0000001); /* 512M + No prefetching, and enable region */
  446. out32r(PCIX0_PTM1MS, 0x00000001); /* Memory Size/Attribute */
  447. out32r(PCIX0_PTM1LA, 0); /* Local Addr. Reg */
  448. out32r(PCIX0_PTM2MS, 0); /* Memory Size/Attribute */
  449. out32r(PCIX0_PTM2LA, 0); /* Local Addr. Reg */
  450. /*--------------------------------------------------------------------------+
  451. * Set up Configuration registers
  452. *--------------------------------------------------------------------------*/
  453. /* Program the board's subsystem id/vendor id */
  454. pci_write_config_word(0, PCI_SUBSYSTEM_VENDOR_ID,
  455. CFG_PCI_SUBSYS_VENDORID);
  456. pci_write_config_word(0, PCI_SUBSYSTEM_ID, CFG_PCI_SUBSYS_ID);
  457. /* Configure command register as bus master */
  458. pci_write_config_word(0, PCI_COMMAND, PCI_COMMAND_MASTER);
  459. /* 240nS PCI clock */
  460. pci_write_config_word(0, PCI_LATENCY_TIMER, 1);
  461. /* No error reporting */
  462. pci_write_config_word(0, PCI_ERREN, 0);
  463. pci_write_config_dword(0, PCI_BRDGOPT2, 0x00000101);
  464. }
  465. #endif /* defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT) */
  466. /*************************************************************************
  467. * pci_master_init
  468. *
  469. ************************************************************************/
  470. #if defined(CONFIG_PCI) && defined(CFG_PCI_MASTER_INIT)
  471. void pci_master_init(struct pci_controller *hose)
  472. {
  473. unsigned short temp_short;
  474. /*--------------------------------------------------------------------------+
  475. | Write the PowerPC440 EP PCI Configuration regs.
  476. | Enable PowerPC440 EP to be a master on the PCI bus (PMM).
  477. | Enable PowerPC440 EP to act as a PCI memory target (PTM).
  478. +--------------------------------------------------------------------------*/
  479. pci_read_config_word(0, PCI_COMMAND, &temp_short);
  480. pci_write_config_word(0, PCI_COMMAND,
  481. temp_short | PCI_COMMAND_MASTER |
  482. PCI_COMMAND_MEMORY);
  483. }
  484. #endif /* defined(CONFIG_PCI) && defined(CFG_PCI_MASTER_INIT) */
  485. /*************************************************************************
  486. * is_pci_host
  487. *
  488. * This routine is called to determine if a pci scan should be
  489. * performed. With various hardware environments (especially cPCI and
  490. * PPMC) it's insufficient to depend on the state of the arbiter enable
  491. * bit in the strap register, or generic host/adapter assumptions.
  492. *
  493. * Rather than hard-code a bad assumption in the general 440 code, the
  494. * 440 pci code requires the board to decide at runtime.
  495. *
  496. * Return 0 for adapter mode, non-zero for host (monarch) mode.
  497. *
  498. *
  499. ************************************************************************/
  500. #if defined(CONFIG_PCI)
  501. int is_pci_host(struct pci_controller *hose)
  502. {
  503. /* Cactus is always configured as host. */
  504. return (1);
  505. }
  506. #endif /* defined(CONFIG_PCI) */
  507. #if defined(CONFIG_POST)
  508. /*
  509. * Returns 1 if keys pressed to start the power-on long-running tests
  510. * Called from board_init_f().
  511. */
  512. int post_hotkeys_pressed(void)
  513. {
  514. return 0; /* No hotkeys supported */
  515. }
  516. #endif /* CONFIG_POST */