hcu5.c 18 KB

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