4xx_pci.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. /*-----------------------------------------------------------------------------+
  2. *
  3. * This source code has been made available to you by IBM on an AS-IS
  4. * basis. Anyone receiving this source is licensed under IBM
  5. * copyrights to use it in any way he or she deems fit, including
  6. * copying it, modifying it, compiling it, and redistributing it either
  7. * with or without modifications. No license under IBM patents or
  8. * patent applications is to be implied by the copyright license.
  9. *
  10. * Any user of this software should understand that IBM cannot provide
  11. * technical support for this software and will not be responsible for
  12. * any consequences resulting from the use of this software.
  13. *
  14. * Any person who transfers this source code or any derivative work
  15. * must include the IBM copyright notice, this paragraph, and the
  16. * preceding two paragraphs in the transferred software.
  17. *
  18. * COPYRIGHT I B M CORPORATION 1995
  19. * LICENSED MATERIAL - PROGRAM PROPERTY OF I B M
  20. *-----------------------------------------------------------------------------*/
  21. /*----------------------------------------------------------------------------+
  22. *
  23. * File Name: 405gp_pci.c
  24. *
  25. * Function: Initialization code for the 405GP PCI Configuration regs.
  26. *
  27. * Author: Mark Game
  28. *
  29. * Change Activity-
  30. *
  31. * Date Description of Change BY
  32. * --------- --------------------- ---
  33. * 09-Sep-98 Created MCG
  34. * 02-Nov-98 Removed External arbiter selected message JWB
  35. * 27-Nov-98 Zero out PTMBAR2 and disable in PTM2MS JWB
  36. * 04-Jan-99 Zero out other unused PMM and PTM regs. Change bus scan MCG
  37. * from (0 to n) to (1 to n).
  38. * 17-May-99 Port to Walnut JWB
  39. * 17-Jun-99 Updated for VGA support JWB
  40. * 21-Jun-99 Updated to allow SRAM region to be a target from PCI bus JWB
  41. * 19-Jul-99 Updated for 405GP pass 1 errata #26 (Low PCI subsequent MCG
  42. * target latency timer values are not supported).
  43. * Should be fixed in pass 2.
  44. * 09-Sep-99 Removed use of PTM2 since the SRAM region no longer needs JWB
  45. * to be a PCI target. Zero out PTMBAR2 and disable in PTM2MS.
  46. * 10-Dec-99 Updated PCI_Write_CFG_Reg for pass2 errata #6 JWB
  47. * 11-Jan-00 Ensure PMMxMAs disabled before setting PMMxLAs. This is not
  48. * really required after a reset since PMMxMAs are already
  49. * disabled but is a good practice nonetheless. JWB
  50. * 12-Jun-01 stefan.roese@esd-electronics.com
  51. * - PCI host/adapter handling reworked
  52. * 09-Jul-01 stefan.roese@esd-electronics.com
  53. * - PCI host now configures from device 0 (not 1) to max_dev,
  54. * (host configures itself)
  55. * - On CPCI-405 pci base address and size is generated from
  56. * SDRAM and FLASH size (CFG regs not used anymore)
  57. * - Some minor changes for CPCI-405-A (adapter version)
  58. * 14-Sep-01 stefan.roese@esd-electronics.com
  59. * - CONFIG_PCI_SCAN_SHOW added to print pci devices upon startup
  60. * 28-Sep-01 stefan.roese@esd-electronics.com
  61. * - Changed pci master configuration for linux compatibility
  62. * (no need for bios_fixup() anymore)
  63. * 26-Feb-02 stefan.roese@esd-electronics.com
  64. * - Bug fixed in pci configuration (Andrew May)
  65. * - Removed pci class code init for CPCI405 board
  66. * 15-May-02 stefan.roese@esd-electronics.com
  67. * - New vga device handling
  68. * 29-May-02 stefan.roese@esd-electronics.com
  69. * - PCI class code init added (if defined)
  70. *----------------------------------------------------------------------------*/
  71. #include <common.h>
  72. #include <command.h>
  73. #if !defined(CONFIG_440)
  74. #include <asm/4xx_pci.h>
  75. #endif
  76. #include <asm/processor.h>
  77. #include <pci.h>
  78. #ifdef CONFIG_PCI
  79. DECLARE_GLOBAL_DATA_PTR;
  80. /*
  81. * Board-specific pci initialization
  82. * Platform code can reimplement pci_pre_init() if needed
  83. */
  84. int __pci_pre_init(struct pci_controller *hose)
  85. {
  86. return 1;
  87. }
  88. int pci_pre_init(struct pci_controller *hose) __attribute__((weak, alias("__pci_pre_init")));
  89. #if defined(CONFIG_405GP) || defined(CONFIG_405EP)
  90. #if defined(CONFIG_PMC405)
  91. ushort pmc405_pci_subsys_deviceid(void);
  92. #endif
  93. /*#define DEBUG*/
  94. int __is_pci_host(struct pci_controller *hose)
  95. {
  96. #if defined(CONFIG_405GP)
  97. if (mfdcr(strap) & PSR_PCI_ARBIT_EN)
  98. return 1;
  99. #elif defined (CONFIG_405EP)
  100. if (mfdcr(cpc0_pci) & CPC0_PCI_ARBIT_EN)
  101. return 1;
  102. #endif
  103. return 0;
  104. }
  105. int is_pci_host(struct pci_controller *hose) __attribute__((weak, alias("__is_pci_host")));
  106. /*-----------------------------------------------------------------------------+
  107. * pci_init. Initializes the 405GP PCI Configuration regs.
  108. *-----------------------------------------------------------------------------*/
  109. void pci_405gp_init(struct pci_controller *hose)
  110. {
  111. int i, reg_num = 0;
  112. bd_t *bd = gd->bd;
  113. unsigned short temp_short;
  114. unsigned long ptmpcila[2] = {CONFIG_SYS_PCI_PTM1PCI, CONFIG_SYS_PCI_PTM2PCI};
  115. #if defined(CONFIG_CPCI405) || defined(CONFIG_PMC405)
  116. char *ptmla_str, *ptmms_str;
  117. #endif
  118. unsigned long ptmla[2] = {CONFIG_SYS_PCI_PTM1LA, CONFIG_SYS_PCI_PTM2LA};
  119. unsigned long ptmms[2] = {CONFIG_SYS_PCI_PTM1MS, CONFIG_SYS_PCI_PTM2MS};
  120. #if defined(CONFIG_PIP405) || defined (CONFIG_MIP405)
  121. unsigned long pmmla[3] = {0x80000000, 0xA0000000, 0};
  122. unsigned long pmmma[3] = {0xE0000001, 0xE0000001, 0};
  123. unsigned long pmmpcila[3] = {0x80000000, 0x00000000, 0};
  124. unsigned long pmmpciha[3] = {0x00000000, 0x00000000, 0};
  125. #else
  126. unsigned long pmmla[3] = {0x80000000, 0,0};
  127. unsigned long pmmma[3] = {0xC0000001, 0,0};
  128. unsigned long pmmpcila[3] = {0x80000000, 0,0};
  129. unsigned long pmmpciha[3] = {0x00000000, 0,0};
  130. #endif
  131. #ifdef CONFIG_PCI_PNP
  132. #if (CONFIG_PCI_HOST == PCI_HOST_AUTO)
  133. char *s;
  134. #endif
  135. #endif
  136. #if defined(CONFIG_CPCI405) || defined(CONFIG_PMC405)
  137. ptmla_str = getenv("ptm1la");
  138. ptmms_str = getenv("ptm1ms");
  139. if(NULL != ptmla_str && NULL != ptmms_str ) {
  140. ptmla[0] = simple_strtoul (ptmla_str, NULL, 16);
  141. ptmms[0] = simple_strtoul (ptmms_str, NULL, 16);
  142. }
  143. ptmla_str = getenv("ptm2la");
  144. ptmms_str = getenv("ptm2ms");
  145. if(NULL != ptmla_str && NULL != ptmms_str ) {
  146. ptmla[1] = simple_strtoul (ptmla_str, NULL, 16);
  147. ptmms[1] = simple_strtoul (ptmms_str, NULL, 16);
  148. }
  149. #endif
  150. /*
  151. * Register the hose
  152. */
  153. hose->first_busno = 0;
  154. hose->last_busno = 0xff;
  155. /* ISA/PCI I/O space */
  156. pci_set_region(hose->regions + reg_num++,
  157. MIN_PCI_PCI_IOADDR,
  158. MIN_PLB_PCI_IOADDR,
  159. 0x10000,
  160. PCI_REGION_IO);
  161. /* PCI I/O space */
  162. pci_set_region(hose->regions + reg_num++,
  163. 0x00800000,
  164. 0xe8800000,
  165. 0x03800000,
  166. PCI_REGION_IO);
  167. reg_num = 2;
  168. /* Memory spaces */
  169. for (i=0; i<2; i++)
  170. if (ptmms[i] & 1)
  171. {
  172. if (!i) hose->pci_fb = hose->regions + reg_num;
  173. pci_set_region(hose->regions + reg_num++,
  174. ptmpcila[i], ptmla[i],
  175. ~(ptmms[i] & 0xfffff000) + 1,
  176. PCI_REGION_MEM |
  177. PCI_REGION_SYS_MEMORY);
  178. }
  179. /* PCI memory spaces */
  180. for (i=0; i<3; i++)
  181. if (pmmma[i] & 1)
  182. {
  183. pci_set_region(hose->regions + reg_num++,
  184. pmmpcila[i], pmmla[i],
  185. ~(pmmma[i] & 0xfffff000) + 1,
  186. PCI_REGION_MEM);
  187. }
  188. hose->region_count = reg_num;
  189. pci_setup_indirect(hose,
  190. PCICFGADR,
  191. PCICFGDATA);
  192. if (hose->pci_fb)
  193. pciauto_region_init(hose->pci_fb);
  194. /* Let board change/modify hose & do initial checks */
  195. if (pci_pre_init (hose) == 0) {
  196. printf("PCI: Board-specific initialization failed.\n");
  197. printf("PCI: Configuration aborted.\n");
  198. return;
  199. }
  200. pci_register_hose(hose);
  201. /*--------------------------------------------------------------------------+
  202. * 405GP PCI Master configuration.
  203. * Map one 512 MB range of PLB/processor addresses to PCI memory space.
  204. * PLB address 0x80000000-0xBFFFFFFF ==> PCI address 0x80000000-0xBFFFFFFF
  205. * Use byte reversed out routines to handle endianess.
  206. *--------------------------------------------------------------------------*/
  207. out32r(PMM0MA, (pmmma[0]&~0x1)); /* disable, configure PMMxLA, PMMxPCILA first */
  208. out32r(PMM0LA, pmmla[0]);
  209. out32r(PMM0PCILA, pmmpcila[0]);
  210. out32r(PMM0PCIHA, pmmpciha[0]);
  211. out32r(PMM0MA, pmmma[0]);
  212. /*--------------------------------------------------------------------------+
  213. * PMM1 is not used. Initialize them to zero.
  214. *--------------------------------------------------------------------------*/
  215. out32r(PMM1MA, (pmmma[1]&~0x1));
  216. out32r(PMM1LA, pmmla[1]);
  217. out32r(PMM1PCILA, pmmpcila[1]);
  218. out32r(PMM1PCIHA, pmmpciha[1]);
  219. out32r(PMM1MA, pmmma[1]);
  220. /*--------------------------------------------------------------------------+
  221. * PMM2 is not used. Initialize them to zero.
  222. *--------------------------------------------------------------------------*/
  223. out32r(PMM2MA, (pmmma[2]&~0x1));
  224. out32r(PMM2LA, pmmla[2]);
  225. out32r(PMM2PCILA, pmmpcila[2]);
  226. out32r(PMM2PCIHA, pmmpciha[2]);
  227. out32r(PMM2MA, pmmma[2]);
  228. /*--------------------------------------------------------------------------+
  229. * 405GP PCI Target configuration. (PTM1)
  230. * Note: PTM1MS is hardwire enabled but we set the enable bit anyway.
  231. *--------------------------------------------------------------------------*/
  232. out32r(PTM1LA, ptmla[0]); /* insert address */
  233. out32r(PTM1MS, ptmms[0]); /* insert size, enable bit is 1 */
  234. pci_write_config_dword(PCIDEVID_405GP, PCI_BASE_ADDRESS_1, ptmpcila[0]);
  235. /*--------------------------------------------------------------------------+
  236. * 405GP PCI Target configuration. (PTM2)
  237. *--------------------------------------------------------------------------*/
  238. out32r(PTM2LA, ptmla[1]); /* insert address */
  239. pci_write_config_dword(PCIDEVID_405GP, PCI_BASE_ADDRESS_2, ptmpcila[1]);
  240. if (ptmms[1] == 0)
  241. {
  242. out32r(PTM2MS, 0x00000001); /* set enable bit */
  243. pci_write_config_dword(PCIDEVID_405GP, PCI_BASE_ADDRESS_2, 0x00000000);
  244. out32r(PTM2MS, 0x00000000); /* disable */
  245. }
  246. else
  247. {
  248. out32r(PTM2MS, ptmms[1]); /* insert size, enable bit is 1 */
  249. }
  250. /*
  251. * Insert Subsystem Vendor and Device ID
  252. */
  253. pci_write_config_word(PCIDEVID_405GP, PCI_SUBSYSTEM_VENDOR_ID, CONFIG_SYS_PCI_SUBSYS_VENDORID);
  254. #ifdef CONFIG_CPCI405
  255. if (is_pci_host(hose))
  256. pci_write_config_word(PCIDEVID_405GP, PCI_SUBSYSTEM_ID, CONFIG_SYS_PCI_SUBSYS_DEVICEID);
  257. else
  258. pci_write_config_word(PCIDEVID_405GP, PCI_SUBSYSTEM_ID, CONFIG_SYS_PCI_SUBSYS_DEVICEID2);
  259. #else
  260. pci_write_config_word(PCIDEVID_405GP, PCI_SUBSYSTEM_ID, CONFIG_SYS_PCI_SUBSYS_DEVICEID);
  261. #endif
  262. /*
  263. * Insert Class-code
  264. */
  265. #ifdef CONFIG_SYS_PCI_CLASSCODE
  266. pci_write_config_word(PCIDEVID_405GP, PCI_CLASS_SUB_CODE, CONFIG_SYS_PCI_CLASSCODE);
  267. #endif /* CONFIG_SYS_PCI_CLASSCODE */
  268. /*--------------------------------------------------------------------------+
  269. * If PCI speed = 66MHz, set 66MHz capable bit.
  270. *--------------------------------------------------------------------------*/
  271. if (bd->bi_pci_busfreq >= 66000000) {
  272. pci_read_config_word(PCIDEVID_405GP, PCI_STATUS, &temp_short);
  273. pci_write_config_word(PCIDEVID_405GP,PCI_STATUS,(temp_short|PCI_STATUS_66MHZ));
  274. }
  275. #if (CONFIG_PCI_HOST != PCI_HOST_ADAPTER)
  276. #if (CONFIG_PCI_HOST == PCI_HOST_AUTO)
  277. if (is_pci_host(hose) ||
  278. (((s = getenv("pciscan")) != NULL) && (strcmp(s, "yes") == 0)))
  279. #endif
  280. {
  281. /*--------------------------------------------------------------------------+
  282. * Write the 405GP PCI Configuration regs.
  283. * Enable 405GP to be a master on the PCI bus (PMM).
  284. * Enable 405GP to act as a PCI memory target (PTM).
  285. *--------------------------------------------------------------------------*/
  286. pci_read_config_word(PCIDEVID_405GP, PCI_COMMAND, &temp_short);
  287. pci_write_config_word(PCIDEVID_405GP, PCI_COMMAND, temp_short |
  288. PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
  289. }
  290. #endif
  291. #if defined(CONFIG_405EP) /* on ppc405ep vendor id is not set */
  292. pci_write_config_word(PCIDEVID_405GP, PCI_VENDOR_ID, 0x1014); /* IBM */
  293. #endif
  294. /*
  295. * Set HCE bit (Host Configuration Enabled)
  296. */
  297. pci_read_config_word(PCIDEVID_405GP, PCIBRDGOPT2, &temp_short);
  298. pci_write_config_word(PCIDEVID_405GP, PCIBRDGOPT2, (temp_short | 0x0001));
  299. #ifdef CONFIG_PCI_PNP
  300. /*--------------------------------------------------------------------------+
  301. * Scan the PCI bus and configure devices found.
  302. *--------------------------------------------------------------------------*/
  303. #if (CONFIG_PCI_HOST == PCI_HOST_AUTO)
  304. if (is_pci_host(hose) ||
  305. (((s = getenv("pciscan")) != NULL) && (strcmp(s, "yes") == 0)))
  306. #endif
  307. {
  308. #ifdef CONFIG_PCI_SCAN_SHOW
  309. printf("PCI: Bus Dev VenId DevId Class Int\n");
  310. #endif
  311. hose->last_busno = pci_hose_scan(hose);
  312. }
  313. #endif /* CONFIG_PCI_PNP */
  314. }
  315. /*
  316. * drivers/pci/pci.c skips every host bridge but the 405GP since it could
  317. * be set as an Adapter.
  318. *
  319. * I (Andrew May) don't know what we should do here, but I don't want
  320. * the auto setup of a PCI device disabling what is done pci_405gp_init
  321. * as has happened before.
  322. */
  323. void pci_405gp_setup_bridge(struct pci_controller *hose, pci_dev_t dev,
  324. struct pci_config_table *entry)
  325. {
  326. #ifdef DEBUG
  327. printf("405gp_setup_bridge\n");
  328. #endif
  329. }
  330. /*
  331. *
  332. */
  333. void pci_405gp_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
  334. {
  335. unsigned char int_line = 0xff;
  336. /*
  337. * Write pci interrupt line register (cpci405 specific)
  338. */
  339. switch (PCI_DEV(dev) & 0x03)
  340. {
  341. case 0:
  342. int_line = 27 + 2;
  343. break;
  344. case 1:
  345. int_line = 27 + 3;
  346. break;
  347. case 2:
  348. int_line = 27 + 0;
  349. break;
  350. case 3:
  351. int_line = 27 + 1;
  352. break;
  353. }
  354. pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, int_line);
  355. }
  356. void pci_405gp_setup_vga(struct pci_controller *hose, pci_dev_t dev,
  357. struct pci_config_table *entry)
  358. {
  359. unsigned int cmdstat = 0;
  360. pciauto_setup_device(hose, dev, 6, hose->pci_mem, hose->pci_prefetch, hose->pci_io);
  361. /* always enable io space on vga boards */
  362. pci_hose_read_config_dword(hose, dev, PCI_COMMAND, &cmdstat);
  363. cmdstat |= PCI_COMMAND_IO;
  364. pci_hose_write_config_dword(hose, dev, PCI_COMMAND, cmdstat);
  365. }
  366. #if !(defined(CONFIG_PIP405) || defined (CONFIG_MIP405)) && !(defined (CONFIG_SC3))
  367. /*
  368. *As is these functs get called out of flash Not a horrible
  369. *thing, but something to keep in mind. (no statics?)
  370. */
  371. static struct pci_config_table pci_405gp_config_table[] = {
  372. /*if VendID is 0 it terminates the table search (ie Walnut)*/
  373. #ifdef CONFIG_SYS_PCI_SUBSYS_VENDORID
  374. {CONFIG_SYS_PCI_SUBSYS_VENDORID, PCI_ANY_ID, PCI_CLASS_BRIDGE_HOST,
  375. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, pci_405gp_setup_bridge},
  376. #endif
  377. {PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA,
  378. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, pci_405gp_setup_vga},
  379. {PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_NOT_DEFINED_VGA,
  380. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, pci_405gp_setup_vga},
  381. { }
  382. };
  383. static struct pci_controller hose = {
  384. fixup_irq: pci_405gp_fixup_irq,
  385. config_table: pci_405gp_config_table,
  386. };
  387. void pci_init_board(void)
  388. {
  389. /*we want the ptrs to RAM not flash (ie don't use init list)*/
  390. hose.fixup_irq = pci_405gp_fixup_irq;
  391. hose.config_table = pci_405gp_config_table;
  392. pci_405gp_init(&hose);
  393. }
  394. #endif
  395. #endif /* CONFIG_405GP */
  396. /*-----------------------------------------------------------------------------+
  397. * CONFIG_440
  398. *-----------------------------------------------------------------------------*/
  399. #if defined(CONFIG_440)
  400. static struct pci_controller ppc440_hose = {0};
  401. int pci_440_init (struct pci_controller *hose)
  402. {
  403. int reg_num = 0;
  404. #ifndef CONFIG_DISABLE_PISE_TEST
  405. /*--------------------------------------------------------------------------+
  406. * The PCI initialization sequence enable bit must be set ... if not abort
  407. * pci setup since updating the bit requires chip reset.
  408. *--------------------------------------------------------------------------*/
  409. #if defined(CONFIG_440GX) || defined(CONFIG_440SP) || defined(CONFIG_440SPE)
  410. unsigned long strap;
  411. mfsdr(sdr_sdstp1,strap);
  412. if ((strap & SDR0_SDSTP1_PISE_MASK) == 0) {
  413. printf("PCI: SDR0_STRP1[PISE] not set.\n");
  414. printf("PCI: Configuration aborted.\n");
  415. return -1;
  416. }
  417. #elif defined(CONFIG_440GP)
  418. unsigned long strap;
  419. strap = mfdcr(cpc0_strp1);
  420. if ((strap & CPC0_STRP1_PISE_MASK) == 0) {
  421. printf("PCI: CPC0_STRP1[PISE] not set.\n");
  422. printf("PCI: Configuration aborted.\n");
  423. return -1;
  424. }
  425. #endif
  426. #endif /* CONFIG_DISABLE_PISE_TEST */
  427. /*--------------------------------------------------------------------------+
  428. * PCI controller init
  429. *--------------------------------------------------------------------------*/
  430. hose->first_busno = 0;
  431. hose->last_busno = 0;
  432. /* PCI I/O space */
  433. pci_set_region(hose->regions + reg_num++,
  434. 0x00000000,
  435. PCIX0_IOBASE,
  436. 0x10000,
  437. PCI_REGION_IO);
  438. /* PCI memory space */
  439. pci_set_region(hose->regions + reg_num++,
  440. CONFIG_SYS_PCI_TARGBASE,
  441. CONFIG_SYS_PCI_MEMBASE,
  442. #ifdef CONFIG_SYS_PCI_MEMSIZE
  443. CONFIG_SYS_PCI_MEMSIZE,
  444. #else
  445. 0x10000000,
  446. #endif
  447. PCI_REGION_MEM );
  448. #if defined(CONFIG_PCI_SYS_MEM_BUS) && defined(CONFIG_PCI_SYS_MEM_PHYS) && \
  449. defined(CONFIG_PCI_SYS_MEM_SIZE)
  450. /* System memory space */
  451. pci_set_region(hose->regions + reg_num++,
  452. CONFIG_PCI_SYS_MEM_BUS,
  453. CONFIG_PCI_SYS_MEM_PHYS,
  454. CONFIG_PCI_SYS_MEM_SIZE,
  455. PCI_REGION_MEM | PCI_REGION_SYS_MEMORY );
  456. #endif
  457. hose->region_count = reg_num;
  458. pci_setup_indirect(hose, PCIX0_CFGADR, PCIX0_CFGDATA);
  459. /* Let board change/modify hose & do initial checks */
  460. if (pci_pre_init (hose) == 0) {
  461. printf("PCI: Board-specific initialization failed.\n");
  462. printf("PCI: Configuration aborted.\n");
  463. return -1;
  464. }
  465. pci_register_hose( hose );
  466. /*--------------------------------------------------------------------------+
  467. * PCI target init
  468. *--------------------------------------------------------------------------*/
  469. #if defined(CONFIG_SYS_PCI_TARGET_INIT)
  470. pci_target_init(hose); /* Let board setup pci target */
  471. #else
  472. out16r( PCIX0_SBSYSVID, CONFIG_SYS_PCI_SUBSYS_VENDORID );
  473. out16r( PCIX0_SBSYSID, CONFIG_SYS_PCI_SUBSYS_ID );
  474. out16r( PCIX0_CLS, 0x00060000 ); /* Bridge, host bridge */
  475. #endif
  476. #if defined(CONFIG_440GX) || defined(CONFIG_440SPE) || \
  477. defined(CONFIG_460EX) || defined(CONFIG_460GT)
  478. out32r( PCIX0_BRDGOPT1, 0x04000060 ); /* PLB Rq pri highest */
  479. out32r( PCIX0_BRDGOPT2, in32(PCIX0_BRDGOPT2) | 0x83 ); /* Enable host config, clear Timeout, ensure int src1 */
  480. #elif defined(PCIX0_BRDGOPT1)
  481. out32r( PCIX0_BRDGOPT1, 0x10000060 ); /* PLB Rq pri highest */
  482. out32r( PCIX0_BRDGOPT2, in32(PCIX0_BRDGOPT2) | 1 ); /* Enable host config */
  483. #endif
  484. /*--------------------------------------------------------------------------+
  485. * PCI master init: default is one 256MB region for PCI memory:
  486. * 0x3_00000000 - 0x3_0FFFFFFF ==> CONFIG_SYS_PCI_MEMBASE
  487. *--------------------------------------------------------------------------*/
  488. #if defined(CONFIG_SYS_PCI_MASTER_INIT)
  489. pci_master_init(hose); /* Let board setup pci master */
  490. #else
  491. out32r( PCIX0_POM0SA, 0 ); /* disable */
  492. out32r( PCIX0_POM1SA, 0 ); /* disable */
  493. out32r( PCIX0_POM2SA, 0 ); /* disable */
  494. #if defined(CONFIG_440SPE)
  495. out32r( PCIX0_POM0LAL, 0x10000000 );
  496. out32r( PCIX0_POM0LAH, 0x0000000c );
  497. #elif defined(CONFIG_460EX) || defined(CONFIG_460GT)
  498. out32r( PCIX0_POM0LAL, 0x20000000 );
  499. out32r( PCIX0_POM0LAH, 0x0000000c );
  500. #else
  501. out32r( PCIX0_POM0LAL, 0x00000000 );
  502. out32r( PCIX0_POM0LAH, 0x00000003 );
  503. #endif
  504. out32r( PCIX0_POM0PCIAL, CONFIG_SYS_PCI_MEMBASE );
  505. out32r( PCIX0_POM0PCIAH, 0x00000000 );
  506. out32r( PCIX0_POM0SA, 0xf0000001 ); /* 256MB, enabled */
  507. out32r( PCIX0_STS, in32r( PCIX0_STS ) & ~0x0000fff8 );
  508. #endif
  509. /*--------------------------------------------------------------------------+
  510. * PCI host configuration -- we don't make any assumptions here ... the
  511. * _board_must_indicate_ what to do -- there's just too many runtime
  512. * scenarios in environments like cPCI, PPMC, etc. to make a determination
  513. * based on hard-coded values or state of arbiter enable.
  514. *--------------------------------------------------------------------------*/
  515. if (is_pci_host(hose)) {
  516. #ifdef CONFIG_PCI_SCAN_SHOW
  517. printf("PCI: Bus Dev VenId DevId Class Int\n");
  518. #endif
  519. #if !defined(CONFIG_440EP) && !defined(CONFIG_440GR) && \
  520. !defined(CONFIG_440EPX) && !defined(CONFIG_440GRX)
  521. out16r( PCIX0_CMD, in16r( PCIX0_CMD ) | PCI_COMMAND_MASTER);
  522. #endif
  523. hose->last_busno = pci_hose_scan(hose);
  524. }
  525. return hose->last_busno;
  526. }
  527. void pci_init_board(void)
  528. {
  529. int busno;
  530. busno = pci_440_init (&ppc440_hose);
  531. #if (defined(CONFIG_440SPE) || \
  532. defined(CONFIG_460EX) || defined(CONFIG_460GT)) && \
  533. !defined(CONFIG_PCI_DISABLE_PCIE)
  534. pcie_setup_hoses(busno + 1);
  535. #endif
  536. }
  537. #endif /* CONFIG_440 */
  538. #if defined(CONFIG_405EX)
  539. void pci_init_board(void)
  540. {
  541. #ifdef CONFIG_PCI_SCAN_SHOW
  542. printf("PCI: Bus Dev VenId DevId Class Int\n");
  543. #endif
  544. pcie_setup_hoses(0);
  545. }
  546. #endif /* CONFIG_405EX */
  547. #endif /* CONFIG_PCI */