hcu5.c 18 KB

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