korat.c 18 KB

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