hcu5.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. /*
  2. *(C) Copyright 2005-2007 Netstal Maschinen AG
  3. * Niklaus Giger (Niklaus.Giger@netstal.com)
  4. *
  5. * This source code is free software; you can redistribute it
  6. * and/or modify it in source code form under the terms of the GNU
  7. * General Public License as published by the Free Software
  8. * Foundation; either version 2 of the License, or (at your option)
  9. * any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  19. */
  20. #include <common.h>
  21. #include <asm/processor.h>
  22. #include <ppc440.h>
  23. #include <asm/mmu.h>
  24. DECLARE_GLOBAL_DATA_PTR;
  25. void sysLedSet(u32 value);
  26. extern flash_info_t flash_info[CFG_MAX_FLASH_BANKS];
  27. #undef BOOTSTRAP_OPTION_A_ACTIVE
  28. #define SDR0_CP440 0x0180
  29. #define SYSTEM_RESET 0x30000000
  30. #define CHIP_RESET 0x20000000
  31. #define SDR0_ECID0 0x0080
  32. #define SDR0_ECID1 0x0081
  33. #define SDR0_ECID2 0x0082
  34. #define SDR0_ECID3 0x0083
  35. #define SYS_IO_ADDRESS 0xcce00000
  36. #define DEFAULT_ETH_ADDR "ethaddr"
  37. /* ethaddr for first or etha1ddr for second ethernet */
  38. enum {
  39. /* HW_GENERATION_HCU1 is no longer supported */
  40. HW_GENERATION_HCU2 = 0x10,
  41. HW_GENERATION_HCU3 = 0x10,
  42. HW_GENERATION_HCU4 = 0x20,
  43. HW_GENERATION_HCU5 = 0x30,
  44. HW_GENERATION_MCU = 0x08,
  45. HW_GENERATION_MCU20 = 0x0a,
  46. HW_GENERATION_MCU25 = 0x09,
  47. };
  48. /*
  49. * This function is run very early, out of flash, and before devices are
  50. * initialized. It is called by lib_ppc/board.c:board_init_f by virtue
  51. * of being in the init_sequence array.
  52. *
  53. * The SDRAM has been initialized already -- start.S:start called
  54. * init.S:init_sdram early on -- but it is not yet being used for
  55. * anything, not even stack. So be careful.
  56. */
  57. int board_early_init_f(void)
  58. {
  59. u32 reg;
  60. #ifdef BOOTSTRAP_OPTION_A_ACTIVE
  61. /* Booting with Bootstrap Option A
  62. * First boot, with CPR0_ICFG_RLI_MASK == 0
  63. * no we setup varios boot strapping register,
  64. * then we do reset the PPC440 using a chip reset
  65. * Unfortunately, we cannot use this option, as Nto1 is not set
  66. * with Bootstrap Option A and cannot be changed later on by SW
  67. * There are no other possible boostrap options with a 8 bit ROM
  68. * See Errata (Version 1.04) CHIP_9
  69. */
  70. u32 cpr0icfg;
  71. u32 dbcr;
  72. mfcpr(CPR0_ICFG, cpr0icfg);
  73. if (!(cpr0icfg & CPR0_ICFG_RLI_MASK)) {
  74. mtcpr(CPR0_MALD, 0x02000000);
  75. mtcpr(CPR0_OPBD, 0x02000000);
  76. mtcpr(CPR0_PERD, 0x05000000); /* 1:5 */
  77. mtcpr(CPR0_PLLC, 0x40000238);
  78. mtcpr(CPR0_PLLD, 0x01010414);
  79. mtcpr(CPR0_PRIMAD, 0x01000000);
  80. mtcpr(CPR0_PRIMBD, 0x01000000);
  81. mtcpr(CPR0_SPCID, 0x03000000);
  82. mtsdr(SDR0_PFC0, 0x00003E00); /* [CTE] = 0 */
  83. mtsdr(SDR0_CP440, 0x0EAAEA02); /* [Nto1] = 1*/
  84. mtcpr(CPR0_ICFG, cpr0icfg | CPR0_ICFG_RLI_MASK);
  85. /*
  86. * Initiate system reset in debug control register DBCR
  87. */
  88. dbcr = mfspr(dbcr0);
  89. mtspr(dbcr0, dbcr | CHIP_RESET);
  90. }
  91. mtsdr(SDR0_CP440, 0x0EAAEA02); /* [Nto1] = 1*/
  92. #endif
  93. mtdcr(ebccfga, xbcfg);
  94. mtdcr(ebccfgd, 0xb8400000);
  95. /*--------------------------------------------------------------------
  96. * Setup the GPIO pins
  97. *-------------------------------------------------------------------*/
  98. /* test-only: take GPIO init from pcs440ep ???? in config file */
  99. out32(GPIO0_OR, 0x00000000);
  100. out32(GPIO0_TCR, 0x7C2FF1CF);
  101. out32(GPIO0_OSRL, 0x40055000);
  102. out32(GPIO0_OSRH, 0x00000000);
  103. out32(GPIO0_TSRL, 0x40055000);
  104. out32(GPIO0_TSRH, 0x00000400);
  105. out32(GPIO0_ISR1L, 0x40000000);
  106. out32(GPIO0_ISR1H, 0x00000000);
  107. out32(GPIO0_ISR2L, 0x00000000);
  108. out32(GPIO0_ISR2H, 0x00000000);
  109. out32(GPIO0_ISR3L, 0x00000000);
  110. out32(GPIO0_ISR3H, 0x00000000);
  111. out32(GPIO1_OR, 0x00000000);
  112. out32(GPIO1_TCR, 0xC6007FFF);
  113. out32(GPIO1_OSRL, 0x00140000);
  114. out32(GPIO1_OSRH, 0x00000000);
  115. out32(GPIO1_TSRL, 0x00000000);
  116. out32(GPIO1_TSRH, 0x00000000);
  117. out32(GPIO1_ISR1L, 0x05415555);
  118. out32(GPIO1_ISR1H, 0x40000000);
  119. out32(GPIO1_ISR2L, 0x00000000);
  120. out32(GPIO1_ISR2H, 0x00000000);
  121. out32(GPIO1_ISR3L, 0x00000000);
  122. out32(GPIO1_ISR3H, 0x00000000);
  123. /*--------------------------------------------------------------------
  124. * Setup the interrupt controller polarities, triggers, etc.
  125. *-------------------------------------------------------------------*/
  126. mtdcr(uic0sr, 0xffffffff); /* clear all */
  127. mtdcr(uic0er, 0x00000000); /* disable all */
  128. mtdcr(uic0cr, 0x00000005); /* ATI & UIC1 crit are critical */
  129. mtdcr(uic0pr, 0xfffff7ff); /* per ref-board manual */
  130. mtdcr(uic0tr, 0x00000000); /* per ref-board manual */
  131. mtdcr(uic0vr, 0x00000000); /* int31 highest, base=0x000 */
  132. mtdcr(uic0sr, 0xffffffff); /* clear all */
  133. mtdcr(uic1sr, 0xffffffff); /* clear all */
  134. mtdcr(uic1er, 0x00000000); /* disable all */
  135. mtdcr(uic1cr, 0x00000000); /* all non-critical */
  136. mtdcr(uic1pr, 0xffffffff); /* per ref-board manual */
  137. mtdcr(uic1tr, 0x00000000); /* per ref-board manual */
  138. mtdcr(uic1vr, 0x00000000); /* int31 highest, base=0x000 */
  139. mtdcr(uic1sr, 0xffffffff); /* clear all */
  140. mtdcr(uic2sr, 0xffffffff); /* clear all */
  141. mtdcr(uic2er, 0x00000000); /* disable all */
  142. mtdcr(uic2cr, 0x00000000); /* all non-critical */
  143. mtdcr(uic2pr, 0xffffffff); /* per ref-board manual */
  144. mtdcr(uic2tr, 0x00000000); /* per ref-board manual */
  145. mtdcr(uic2vr, 0x00000000); /* int31 highest, base=0x000 */
  146. mtdcr(uic2sr, 0xffffffff); /* clear all */
  147. mtsdr(sdr_pfc0, 0x00003E00); /* Pin function: */
  148. mtsdr(sdr_pfc1, 0x00848000); /* Pin function: UART0 has 4 pins */
  149. /* PCI arbiter enabled */
  150. mfsdr(sdr_pci0, reg);
  151. mtsdr(sdr_pci0, 0x80000000 | reg);
  152. pci_pre_init(0);
  153. /* setup BOOT FLASH */
  154. mtsdr(SDR0_CUST0, 0xC0082350);
  155. return 0;
  156. }
  157. int board_pre_init(void)
  158. {
  159. return board_early_init_f();
  160. }
  161. int checkboard(void)
  162. {
  163. unsigned int j;
  164. u16 *hwVersReg = (u16 *) HCU_HW_VERSION_REGISTER;
  165. u16 *boardVersReg = (u16 *) HCU_CPLD_VERSION_REGISTER;
  166. u16 generation = *boardVersReg & 0xf0;
  167. u16 index = *boardVersReg & 0x0f;
  168. u32 ecid0, ecid1, ecid2, ecid3;
  169. printf("Netstal Maschinen AG: ");
  170. if (generation == HW_GENERATION_HCU3)
  171. printf("HCU3: index %d", index);
  172. else if (generation == HW_GENERATION_HCU4)
  173. printf("HCU4: index %d", index);
  174. else if (generation == HW_GENERATION_HCU5)
  175. printf("HCU5: index %d", index);
  176. printf(" HW 0x%02x\n", *hwVersReg & 0xff);
  177. mfsdr(SDR0_ECID0, ecid0);
  178. mfsdr(SDR0_ECID1, ecid1);
  179. mfsdr(SDR0_ECID2, ecid2);
  180. mfsdr(SDR0_ECID3, ecid3);
  181. printf("Chip ID 0x%x 0x%x 0x%x 0x%x\n", ecid0, ecid1, ecid2, ecid3);
  182. for (j = 0;j < 6; j++) {
  183. sysLedSet(1 << j);
  184. udelay(200 * 1000);
  185. }
  186. return 0;
  187. }
  188. u32 sysLedGet(void)
  189. {
  190. return in16(SYS_IO_ADDRESS) & 0x3f;
  191. }
  192. void sysLedSet(u32 value /* value to place in LEDs */)
  193. {
  194. out16(SYS_IO_ADDRESS, value);
  195. }
  196. /*---------------------------------------------------------------------------+
  197. * getSerialNr
  198. *---------------------------------------------------------------------------*/
  199. static u32 getSerialNr(void)
  200. {
  201. u32 *serial = (u32 *)CFG_FLASH_BASE;
  202. if (*serial == 0xffffffff)
  203. return get_ticks();
  204. return *serial;
  205. }
  206. /*---------------------------------------------------------------------------+
  207. * misc_init_r.
  208. *---------------------------------------------------------------------------*/
  209. int misc_init_r(void)
  210. {
  211. char *s = getenv(DEFAULT_ETH_ADDR);
  212. char *e;
  213. int i;
  214. u32 serial = getSerialNr();
  215. unsigned long usb2d0cr = 0;
  216. unsigned long usb2phy0cr, usb2h0cr = 0;
  217. unsigned long sdr0_pfc1;
  218. for (i = 0; i < 6; ++i) {
  219. gd->bd->bi_enetaddr[i] = s ? simple_strtoul(s, &e, 16) : 0;
  220. if (s)
  221. s = (*e) ? e + 1 : e;
  222. }
  223. if (gd->bd->bi_enetaddr[3] == 0 &&
  224. gd->bd->bi_enetaddr[4] == 0 &&
  225. gd->bd->bi_enetaddr[5] == 0) {
  226. char ethaddr[22];
  227. /* Must be in sync with CONFIG_ETHADDR */
  228. gd->bd->bi_enetaddr[0] = 0x00;
  229. gd->bd->bi_enetaddr[1] = 0x60;
  230. gd->bd->bi_enetaddr[2] = 0x13;
  231. gd->bd->bi_enetaddr[3] = (serial >> 16) & 0xff;
  232. gd->bd->bi_enetaddr[4] = (serial >> 8) & 0xff;
  233. /* byte[5].bit 0 must be zero */
  234. gd->bd->bi_enetaddr[5] = (serial >> 0) & 0xfe;
  235. sprintf(ethaddr, "%02X:%02X:%02X:%02X:%02X:%02X\0",
  236. gd->bd->bi_enetaddr[0], gd->bd->bi_enetaddr[1],
  237. gd->bd->bi_enetaddr[2], gd->bd->bi_enetaddr[3],
  238. gd->bd->bi_enetaddr[4], gd->bd->bi_enetaddr[5]) ;
  239. printf("%s: Setting eth %s serial 0x%x\n", __FUNCTION__,
  240. ethaddr, serial);
  241. setenv(DEFAULT_ETH_ADDR, ethaddr);
  242. }
  243. #ifdef CFG_ENV_IS_IN_FLASH
  244. /* Monitor protection ON by default */
  245. (void)flash_protect(FLAG_PROTECT_SET,
  246. -CFG_MONITOR_LEN,
  247. 0xffffffff,
  248. &flash_info[0]);
  249. /* Env protection ON by default */
  250. (void)flash_protect(FLAG_PROTECT_SET,
  251. CFG_ENV_ADDR_REDUND,
  252. CFG_ENV_ADDR_REDUND + 2*CFG_ENV_SECT_SIZE - 1,
  253. &flash_info[0]);
  254. #endif
  255. /*
  256. * USB stuff...
  257. */
  258. /* SDR Setting */
  259. mfsdr(SDR0_PFC1, sdr0_pfc1);
  260. mfsdr(SDR0_USB2D0CR, usb2d0cr);
  261. mfsdr(SDR0_USB2PHY0CR, usb2phy0cr);
  262. mfsdr(SDR0_USB2H0CR, usb2h0cr);
  263. usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_XOCLK_MASK;
  264. usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_XOCLK_EXTERNAL; /*0*/
  265. usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_WDINT_MASK;
  266. usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_WDINT_16BIT_30MHZ; /*1*/
  267. usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DVBUS_MASK;
  268. usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DVBUS_PURDIS; /*0*/
  269. usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DWNSTR_MASK;
  270. usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DWNSTR_HOST; /*1*/
  271. usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_UTMICN_MASK;
  272. usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_UTMICN_HOST; /*1*/
  273. /* An 8-bit/60MHz interface is the only possible alternative
  274. when connecting the Device to the PHY */
  275. usb2h0cr = usb2h0cr &~SDR0_USB2H0CR_WDINT_MASK;
  276. usb2h0cr = usb2h0cr | SDR0_USB2H0CR_WDINT_16BIT_30MHZ; /*1*/
  277. /* To enable the USB 2.0 Device function through the UTMI interface */
  278. usb2d0cr = usb2d0cr &~SDR0_USB2D0CR_USB2DEV_EBC_SEL_MASK;
  279. usb2d0cr = usb2d0cr | SDR0_USB2D0CR_USB2DEV_SELECTION; /*1*/
  280. sdr0_pfc1 = sdr0_pfc1 &~SDR0_PFC1_UES_MASK;
  281. sdr0_pfc1 = sdr0_pfc1 | SDR0_PFC1_UES_USB2D_SEL; /*0*/
  282. mtsdr(SDR0_PFC1, sdr0_pfc1);
  283. mtsdr(SDR0_USB2D0CR, usb2d0cr);
  284. mtsdr(SDR0_USB2PHY0CR, usb2phy0cr);
  285. mtsdr(SDR0_USB2H0CR, usb2h0cr);
  286. /*clear resets*/
  287. udelay(1000);
  288. mtsdr(SDR0_SRST1, 0x00000000);
  289. udelay(1000);
  290. mtsdr(SDR0_SRST0, 0x00000000);
  291. printf("USB: Host(int phy) Device(ext phy)\n");
  292. return 0;
  293. }
  294. /*************************************************************************
  295. * pci_pre_init
  296. *
  297. * This routine is called just prior to registering the hose and gives
  298. * the board the opportunity to check things. Returning a value of zero
  299. * indicates that things are bad & PCI initialization should be aborted.
  300. *
  301. * Different boards may wish to customize the pci controller structure
  302. * (add regions, override default access routines, etc) or perform
  303. * certain pre-initialization actions.
  304. *
  305. ************************************************************************/
  306. #if defined(CONFIG_PCI)
  307. int pci_pre_init(struct pci_controller *hose)
  308. {
  309. unsigned long addr;
  310. /*-------------------------------------------------------------------+
  311. * As of errata version 0.4, CHIP_8: Incorrect Write to DDR SDRAM.
  312. * Workaround: Disable write pipelining to DDR SDRAM by setting
  313. * PLB0_ACR[WRP] = 0.
  314. *-------------------------------------------------------------------*/
  315. /*-------------------------------------------------------------------+
  316. | Set priority for all PLB3 devices to 0.
  317. | Set PLB3 arbiter to fair mode.
  318. +-------------------------------------------------------------------*/
  319. mfsdr(sdr_amp1, addr);
  320. mtsdr(sdr_amp1, (addr & 0x000000FF) | 0x0000FF00);
  321. addr = mfdcr(plb3_acr);
  322. /* mtdcr(plb3_acr, addr & ~plb1_acr_wrp_mask); */ /* ngngng */
  323. mtdcr(plb3_acr, addr | 0x80000000); /* Sequoia */
  324. /*-------------------------------------------------------------------+
  325. | Set priority for all PLB4 devices to 0.
  326. +-------------------------------------------------------------------*/
  327. mfsdr(sdr_amp0, addr);
  328. mtsdr(sdr_amp0, (addr & 0x000000FF) | 0x0000FF00);
  329. addr = mfdcr(plb4_acr) | 0xa0000000; /* Was 0x8---- */
  330. /* mtdcr(plb4_acr, addr & ~plb1_acr_wrp_mask); */ /* ngngng */
  331. mtdcr(plb4_acr, addr); /* Sequoia */
  332. /*-------------------------------------------------------------------+
  333. | Set Nebula PLB4 arbiter to fair mode.
  334. +-------------------------------------------------------------------*/
  335. /* Segment0 */
  336. addr = (mfdcr(plb0_acr) & ~plb0_acr_ppm_mask) | plb0_acr_ppm_fair;
  337. addr = (addr & ~plb0_acr_hbu_mask) | plb0_acr_hbu_enabled;
  338. addr = (addr & ~plb0_acr_rdp_mask) | plb0_acr_rdp_4deep;
  339. /* addr = (addr & ~plb0_acr_wrp_mask); */ /* ngngng */
  340. addr = (addr & ~plb0_acr_wrp_mask) | plb0_acr_wrp_2deep; /* Sequoia */
  341. /* mtdcr(plb0_acr, addr); */ /* Sequoia */
  342. mtdcr(plb0_acr, 0); /* PATCH HAB: WRITE PIPELINING OFF */
  343. /* Segment1 */
  344. addr = (mfdcr(plb1_acr) & ~plb1_acr_ppm_mask) | plb1_acr_ppm_fair;
  345. addr = (addr & ~plb1_acr_hbu_mask) | plb1_acr_hbu_enabled;
  346. addr = (addr & ~plb1_acr_rdp_mask) | plb1_acr_rdp_4deep;
  347. addr = (addr & ~plb1_acr_wrp_mask) ;
  348. /* mtdcr(plb1_acr, addr); */ /* Sequoia */
  349. mtdcr(plb1_acr, 0); /* PATCH HAB: WRITE PIPELINING OFF */
  350. return 1;
  351. }
  352. #endif /* defined(CONFIG_PCI) */
  353. /*************************************************************************
  354. * pci_target_init
  355. *
  356. * The bootstrap configuration provides default settings for the pci
  357. * inbound map (PIM). But the bootstrap config choices are limited and
  358. * may not be sufficient for a given board.
  359. *
  360. ************************************************************************/
  361. #if defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT)
  362. void pci_target_init(struct pci_controller *hose)
  363. {
  364. /*-------------------------------------------------------------+
  365. * Set up Direct MMIO registers
  366. *-------------------------------------------------------------*/
  367. /*-------------------------------------------------------------+
  368. | PowerPC440EPX PCI Master configuration.
  369. | Map one 1Gig range of PLB/processor addresses to PCI memory space.
  370. | PLB address 0xA0000000-0xDFFFFFFF ==> PCI address
  371. | 0xA0000000-0xDFFFFFFF
  372. | Use byte reversed out routines to handle endianess.
  373. | Make this region non-prefetchable.
  374. +-------------------------------------------------------------*/
  375. /* PMM0 Mask/Attribute - disabled b4 setting */
  376. out32r(PCIX0_PMM0MA, 0x00000000);
  377. out32r(PCIX0_PMM0LA, CFG_PCI_MEMBASE); /* PMM0 Local Address */
  378. /* PMM0 PCI Low Address */
  379. out32r(PCIX0_PMM0PCILA, CFG_PCI_MEMBASE);
  380. out32r(PCIX0_PMM0PCIHA, 0x00000000); /* PMM0 PCI High Address */
  381. /* 512M + No prefetching, and enable region */
  382. out32r(PCIX0_PMM0MA, 0xE0000001);
  383. /* PMM0 Mask/Attribute - disabled b4 setting */
  384. out32r(PCIX0_PMM1MA, 0x00000000);
  385. out32r(PCIX0_PMM1LA, CFG_PCI_MEMBASE2); /* PMM0 Local Address */
  386. /* PMM0 PCI Low Address */
  387. out32r(PCIX0_PMM1PCILA, CFG_PCI_MEMBASE2);
  388. out32r(PCIX0_PMM1PCIHA, 0x00000000); /* PMM0 PCI High Address */
  389. /* 512M + No prefetching, and enable region */
  390. out32r(PCIX0_PMM1MA, 0xE0000001);
  391. out32r(PCIX0_PTM1MS, 0x00000001); /* Memory Size/Attribute */
  392. out32r(PCIX0_PTM1LA, 0); /* Local Addr. Reg */
  393. out32r(PCIX0_PTM2MS, 0); /* Memory Size/Attribute */
  394. out32r(PCIX0_PTM2LA, 0); /* Local Addr. Reg */
  395. /*------------------------------------------------------------------+
  396. * Set up Configuration registers
  397. *------------------------------------------------------------------*/
  398. /* Program the board's subsystem id/vendor id */
  399. pci_write_config_word(0, PCI_SUBSYSTEM_VENDOR_ID,
  400. CFG_PCI_SUBSYS_VENDORID);
  401. pci_write_config_word(0, PCI_SUBSYSTEM_ID, CFG_PCI_SUBSYS_ID);
  402. /* Configure command register as bus master */
  403. pci_write_config_word(0, PCI_COMMAND, PCI_COMMAND_MASTER);
  404. /* 240nS PCI clock */
  405. pci_write_config_word(0, PCI_LATENCY_TIMER, 1);
  406. /* No error reporting */
  407. pci_write_config_word(0, PCI_ERREN, 0);
  408. pci_write_config_dword(0, PCI_BRDGOPT2, 0x00000101);
  409. }
  410. #endif /* defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT) */
  411. /*************************************************************************
  412. * pci_master_init
  413. *
  414. ************************************************************************/
  415. #if defined(CONFIG_PCI) && defined(CFG_PCI_MASTER_INIT)
  416. void pci_master_init(struct pci_controller *hose)
  417. {
  418. unsigned short temp_short;
  419. /*---------------------------------------------------------------+
  420. | Write the PowerPC440 EP PCI Configuration regs.
  421. | Enable PowerPC440 EP to be a master on the PCI bus (PMM).
  422. | Enable PowerPC440 EP to act as a PCI memory target (PTM).
  423. +--------------------------------------------------------------*/
  424. pci_read_config_word(0, PCI_COMMAND, &temp_short);
  425. pci_write_config_word(0, PCI_COMMAND,
  426. temp_short | PCI_COMMAND_MASTER |
  427. PCI_COMMAND_MEMORY);
  428. }
  429. #endif
  430. /* defined(CONFIG_PCI) && defined(CFG_PCI_MASTER_INIT) */
  431. /*************************************************************************
  432. * is_pci_host
  433. *
  434. * This routine is called to determine if a pci scan should be
  435. * performed. With various hardware environments (especially cPCI and
  436. * PPMC) it's insufficient to depend on the state of the arbiter enable
  437. * bit in the strap register, or generic host/adapter assumptions.
  438. *
  439. * Rather than hard-code a bad assumption in the general 440 code, the
  440. * 440 pci code requires the board to decide at runtime.
  441. *
  442. * Return 0 for adapter mode, non-zero for host (monarch) mode.
  443. *
  444. *
  445. ************************************************************************/
  446. #if defined(CONFIG_PCI)
  447. int is_pci_host(struct pci_controller *hose)
  448. {
  449. return 1;
  450. }
  451. #endif /* defined(CONFIG_PCI) */