4xx_pci.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  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. /*-----------------------------------------------------------------------------+
  95. * pci_init. Initializes the 405GP PCI Configuration regs.
  96. *-----------------------------------------------------------------------------*/
  97. void pci_405gp_init(struct pci_controller *hose)
  98. {
  99. int i, reg_num = 0;
  100. bd_t *bd = gd->bd;
  101. unsigned short temp_short;
  102. unsigned long ptmpcila[2] = {CONFIG_SYS_PCI_PTM1PCI, CONFIG_SYS_PCI_PTM2PCI};
  103. #if defined(CONFIG_CPCI405) || defined(CONFIG_PMC405)
  104. char *ptmla_str, *ptmms_str;
  105. #endif
  106. unsigned long ptmla[2] = {CONFIG_SYS_PCI_PTM1LA, CONFIG_SYS_PCI_PTM2LA};
  107. unsigned long ptmms[2] = {CONFIG_SYS_PCI_PTM1MS, CONFIG_SYS_PCI_PTM2MS};
  108. #if defined(CONFIG_PIP405) || defined (CONFIG_MIP405)
  109. unsigned long pmmla[3] = {0x80000000, 0xA0000000, 0};
  110. unsigned long pmmma[3] = {0xE0000001, 0xE0000001, 0};
  111. unsigned long pmmpcila[3] = {0x80000000, 0x00000000, 0};
  112. unsigned long pmmpciha[3] = {0x00000000, 0x00000000, 0};
  113. #else
  114. unsigned long pmmla[3] = {0x80000000, 0,0};
  115. unsigned long pmmma[3] = {0xC0000001, 0,0};
  116. unsigned long pmmpcila[3] = {0x80000000, 0,0};
  117. unsigned long pmmpciha[3] = {0x00000000, 0,0};
  118. #endif
  119. #ifdef CONFIG_PCI_PNP
  120. #if (CONFIG_PCI_HOST == PCI_HOST_AUTO)
  121. char *s;
  122. #endif
  123. #endif
  124. #if defined(CONFIG_CPCI405) || defined(CONFIG_PMC405)
  125. ptmla_str = getenv("ptm1la");
  126. ptmms_str = getenv("ptm1ms");
  127. if(NULL != ptmla_str && NULL != ptmms_str ) {
  128. ptmla[0] = simple_strtoul (ptmla_str, NULL, 16);
  129. ptmms[0] = simple_strtoul (ptmms_str, NULL, 16);
  130. }
  131. ptmla_str = getenv("ptm2la");
  132. ptmms_str = getenv("ptm2ms");
  133. if(NULL != ptmla_str && NULL != ptmms_str ) {
  134. ptmla[1] = simple_strtoul (ptmla_str, NULL, 16);
  135. ptmms[1] = simple_strtoul (ptmms_str, NULL, 16);
  136. }
  137. #endif
  138. /*
  139. * Register the hose
  140. */
  141. hose->first_busno = 0;
  142. hose->last_busno = 0xff;
  143. /* ISA/PCI I/O space */
  144. pci_set_region(hose->regions + reg_num++,
  145. MIN_PCI_PCI_IOADDR,
  146. MIN_PLB_PCI_IOADDR,
  147. 0x10000,
  148. PCI_REGION_IO);
  149. /* PCI I/O space */
  150. pci_set_region(hose->regions + reg_num++,
  151. 0x00800000,
  152. 0xe8800000,
  153. 0x03800000,
  154. PCI_REGION_IO);
  155. reg_num = 2;
  156. /* Memory spaces */
  157. for (i=0; i<2; i++)
  158. if (ptmms[i] & 1)
  159. {
  160. if (!i) hose->pci_fb = hose->regions + reg_num;
  161. pci_set_region(hose->regions + reg_num++,
  162. ptmpcila[i], ptmla[i],
  163. ~(ptmms[i] & 0xfffff000) + 1,
  164. PCI_REGION_MEM |
  165. PCI_REGION_SYS_MEMORY);
  166. }
  167. /* PCI memory spaces */
  168. for (i=0; i<3; i++)
  169. if (pmmma[i] & 1)
  170. {
  171. pci_set_region(hose->regions + reg_num++,
  172. pmmpcila[i], pmmla[i],
  173. ~(pmmma[i] & 0xfffff000) + 1,
  174. PCI_REGION_MEM);
  175. }
  176. hose->region_count = reg_num;
  177. pci_setup_indirect(hose,
  178. PCICFGADR,
  179. PCICFGDATA);
  180. if (hose->pci_fb)
  181. pciauto_region_init(hose->pci_fb);
  182. /* Let board change/modify hose & do initial checks */
  183. if (pci_pre_init (hose) == 0) {
  184. printf("PCI: Board-specific initialization failed.\n");
  185. printf("PCI: Configuration aborted.\n");
  186. return;
  187. }
  188. pci_register_hose(hose);
  189. /*--------------------------------------------------------------------------+
  190. * 405GP PCI Master configuration.
  191. * Map one 512 MB range of PLB/processor addresses to PCI memory space.
  192. * PLB address 0x80000000-0xBFFFFFFF ==> PCI address 0x80000000-0xBFFFFFFF
  193. * Use byte reversed out routines to handle endianess.
  194. *--------------------------------------------------------------------------*/
  195. out32r(PMM0MA, (pmmma[0]&~0x1)); /* disable, configure PMMxLA, PMMxPCILA first */
  196. out32r(PMM0LA, pmmla[0]);
  197. out32r(PMM0PCILA, pmmpcila[0]);
  198. out32r(PMM0PCIHA, pmmpciha[0]);
  199. out32r(PMM0MA, pmmma[0]);
  200. /*--------------------------------------------------------------------------+
  201. * PMM1 is not used. Initialize them to zero.
  202. *--------------------------------------------------------------------------*/
  203. out32r(PMM1MA, (pmmma[1]&~0x1));
  204. out32r(PMM1LA, pmmla[1]);
  205. out32r(PMM1PCILA, pmmpcila[1]);
  206. out32r(PMM1PCIHA, pmmpciha[1]);
  207. out32r(PMM1MA, pmmma[1]);
  208. /*--------------------------------------------------------------------------+
  209. * PMM2 is not used. Initialize them to zero.
  210. *--------------------------------------------------------------------------*/
  211. out32r(PMM2MA, (pmmma[2]&~0x1));
  212. out32r(PMM2LA, pmmla[2]);
  213. out32r(PMM2PCILA, pmmpcila[2]);
  214. out32r(PMM2PCIHA, pmmpciha[2]);
  215. out32r(PMM2MA, pmmma[2]);
  216. /*--------------------------------------------------------------------------+
  217. * 405GP PCI Target configuration. (PTM1)
  218. * Note: PTM1MS is hardwire enabled but we set the enable bit anyway.
  219. *--------------------------------------------------------------------------*/
  220. out32r(PTM1LA, ptmla[0]); /* insert address */
  221. out32r(PTM1MS, ptmms[0]); /* insert size, enable bit is 1 */
  222. pci_write_config_dword(PCIDEVID_405GP, PCI_BASE_ADDRESS_1, ptmpcila[0]);
  223. /*--------------------------------------------------------------------------+
  224. * 405GP PCI Target configuration. (PTM2)
  225. *--------------------------------------------------------------------------*/
  226. out32r(PTM2LA, ptmla[1]); /* insert address */
  227. pci_write_config_dword(PCIDEVID_405GP, PCI_BASE_ADDRESS_2, ptmpcila[1]);
  228. if (ptmms[1] == 0)
  229. {
  230. out32r(PTM2MS, 0x00000001); /* set enable bit */
  231. pci_write_config_dword(PCIDEVID_405GP, PCI_BASE_ADDRESS_2, 0x00000000);
  232. out32r(PTM2MS, 0x00000000); /* disable */
  233. }
  234. else
  235. {
  236. out32r(PTM2MS, ptmms[1]); /* insert size, enable bit is 1 */
  237. }
  238. /*
  239. * Insert Subsystem Vendor and Device ID
  240. */
  241. pci_write_config_word(PCIDEVID_405GP, PCI_SUBSYSTEM_VENDOR_ID, CONFIG_SYS_PCI_SUBSYS_VENDORID);
  242. #ifdef CONFIG_CPCI405
  243. if (mfdcr(strap) & PSR_PCI_ARBIT_EN)
  244. pci_write_config_word(PCIDEVID_405GP, PCI_SUBSYSTEM_ID, CONFIG_SYS_PCI_SUBSYS_DEVICEID);
  245. else
  246. pci_write_config_word(PCIDEVID_405GP, PCI_SUBSYSTEM_ID, CONFIG_SYS_PCI_SUBSYS_DEVICEID2);
  247. #else
  248. pci_write_config_word(PCIDEVID_405GP, PCI_SUBSYSTEM_ID, CONFIG_SYS_PCI_SUBSYS_DEVICEID);
  249. #endif
  250. /*
  251. * Insert Class-code
  252. */
  253. #ifdef CONFIG_SYS_PCI_CLASSCODE
  254. pci_write_config_word(PCIDEVID_405GP, PCI_CLASS_SUB_CODE, CONFIG_SYS_PCI_CLASSCODE);
  255. #endif /* CONFIG_SYS_PCI_CLASSCODE */
  256. /*--------------------------------------------------------------------------+
  257. * If PCI speed = 66MHz, set 66MHz capable bit.
  258. *--------------------------------------------------------------------------*/
  259. if (bd->bi_pci_busfreq >= 66000000) {
  260. pci_read_config_word(PCIDEVID_405GP, PCI_STATUS, &temp_short);
  261. pci_write_config_word(PCIDEVID_405GP,PCI_STATUS,(temp_short|PCI_STATUS_66MHZ));
  262. }
  263. #if (CONFIG_PCI_HOST != PCI_HOST_ADAPTER)
  264. #if (CONFIG_PCI_HOST == PCI_HOST_AUTO)
  265. if ((mfdcr(strap) & PSR_PCI_ARBIT_EN) ||
  266. (((s = getenv("pciscan")) != NULL) && (strcmp(s, "yes") == 0)))
  267. #endif
  268. {
  269. /*--------------------------------------------------------------------------+
  270. * Write the 405GP PCI Configuration regs.
  271. * Enable 405GP to be a master on the PCI bus (PMM).
  272. * Enable 405GP to act as a PCI memory target (PTM).
  273. *--------------------------------------------------------------------------*/
  274. pci_read_config_word(PCIDEVID_405GP, PCI_COMMAND, &temp_short);
  275. pci_write_config_word(PCIDEVID_405GP, PCI_COMMAND, temp_short |
  276. PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
  277. }
  278. #endif
  279. #if defined(CONFIG_405EP) /* on ppc405ep vendor id is not set */
  280. pci_write_config_word(PCIDEVID_405GP, PCI_VENDOR_ID, 0x1014); /* IBM */
  281. #endif
  282. /*
  283. * Set HCE bit (Host Configuration Enabled)
  284. */
  285. pci_read_config_word(PCIDEVID_405GP, PCIBRDGOPT2, &temp_short);
  286. pci_write_config_word(PCIDEVID_405GP, PCIBRDGOPT2, (temp_short | 0x0001));
  287. #ifdef CONFIG_PCI_PNP
  288. /*--------------------------------------------------------------------------+
  289. * Scan the PCI bus and configure devices found.
  290. *--------------------------------------------------------------------------*/
  291. #if (CONFIG_PCI_HOST == PCI_HOST_AUTO)
  292. if ((mfdcr(strap) & PSR_PCI_ARBIT_EN) ||
  293. (((s = getenv("pciscan")) != NULL) && (strcmp(s, "yes") == 0)))
  294. #endif
  295. {
  296. #ifdef CONFIG_PCI_SCAN_SHOW
  297. printf("PCI: Bus Dev VenId DevId Class Int\n");
  298. #endif
  299. hose->last_busno = pci_hose_scan(hose);
  300. }
  301. #endif /* CONFIG_PCI_PNP */
  302. }
  303. /*
  304. * drivers/pci/pci.c skips every host bridge but the 405GP since it could
  305. * be set as an Adapter.
  306. *
  307. * I (Andrew May) don't know what we should do here, but I don't want
  308. * the auto setup of a PCI device disabling what is done pci_405gp_init
  309. * as has happened before.
  310. */
  311. void pci_405gp_setup_bridge(struct pci_controller *hose, pci_dev_t dev,
  312. struct pci_config_table *entry)
  313. {
  314. #ifdef DEBUG
  315. printf("405gp_setup_bridge\n");
  316. #endif
  317. }
  318. /*
  319. *
  320. */
  321. void pci_405gp_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
  322. {
  323. unsigned char int_line = 0xff;
  324. /*
  325. * Write pci interrupt line register (cpci405 specific)
  326. */
  327. switch (PCI_DEV(dev) & 0x03)
  328. {
  329. case 0:
  330. int_line = 27 + 2;
  331. break;
  332. case 1:
  333. int_line = 27 + 3;
  334. break;
  335. case 2:
  336. int_line = 27 + 0;
  337. break;
  338. case 3:
  339. int_line = 27 + 1;
  340. break;
  341. }
  342. pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, int_line);
  343. }
  344. void pci_405gp_setup_vga(struct pci_controller *hose, pci_dev_t dev,
  345. struct pci_config_table *entry)
  346. {
  347. unsigned int cmdstat = 0;
  348. pciauto_setup_device(hose, dev, 6, hose->pci_mem, hose->pci_prefetch, hose->pci_io);
  349. /* always enable io space on vga boards */
  350. pci_hose_read_config_dword(hose, dev, PCI_COMMAND, &cmdstat);
  351. cmdstat |= PCI_COMMAND_IO;
  352. pci_hose_write_config_dword(hose, dev, PCI_COMMAND, cmdstat);
  353. }
  354. #if !(defined(CONFIG_PIP405) || defined (CONFIG_MIP405)) && !(defined (CONFIG_SC3))
  355. /*
  356. *As is these functs get called out of flash Not a horrible
  357. *thing, but something to keep in mind. (no statics?)
  358. */
  359. static struct pci_config_table pci_405gp_config_table[] = {
  360. /*if VendID is 0 it terminates the table search (ie Walnut)*/
  361. #ifdef CONFIG_SYS_PCI_SUBSYS_VENDORID
  362. {CONFIG_SYS_PCI_SUBSYS_VENDORID, PCI_ANY_ID, PCI_CLASS_BRIDGE_HOST,
  363. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, pci_405gp_setup_bridge},
  364. #endif
  365. {PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA,
  366. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, pci_405gp_setup_vga},
  367. {PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_NOT_DEFINED_VGA,
  368. PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, pci_405gp_setup_vga},
  369. { }
  370. };
  371. static struct pci_controller hose = {
  372. fixup_irq: pci_405gp_fixup_irq,
  373. config_table: pci_405gp_config_table,
  374. };
  375. void pci_init_board(void)
  376. {
  377. /*we want the ptrs to RAM not flash (ie don't use init list)*/
  378. hose.fixup_irq = pci_405gp_fixup_irq;
  379. hose.config_table = pci_405gp_config_table;
  380. pci_405gp_init(&hose);
  381. }
  382. #endif
  383. #endif /* CONFIG_405GP */
  384. /*-----------------------------------------------------------------------------+
  385. * CONFIG_440
  386. *-----------------------------------------------------------------------------*/
  387. #if defined(CONFIG_440)
  388. static struct pci_controller ppc440_hose = {0};
  389. int pci_440_init (struct pci_controller *hose)
  390. {
  391. int reg_num = 0;
  392. #ifndef CONFIG_DISABLE_PISE_TEST
  393. /*--------------------------------------------------------------------------+
  394. * The PCI initialization sequence enable bit must be set ... if not abort
  395. * pci setup since updating the bit requires chip reset.
  396. *--------------------------------------------------------------------------*/
  397. #if defined(CONFIG_440GX) || defined(CONFIG_440SP) || defined(CONFIG_440SPE)
  398. unsigned long strap;
  399. mfsdr(sdr_sdstp1,strap);
  400. if ((strap & SDR0_SDSTP1_PISE_MASK) == 0) {
  401. printf("PCI: SDR0_STRP1[PISE] not set.\n");
  402. printf("PCI: Configuration aborted.\n");
  403. return -1;
  404. }
  405. #elif defined(CONFIG_440GP)
  406. unsigned long strap;
  407. strap = mfdcr(cpc0_strp1);
  408. if ((strap & CPC0_STRP1_PISE_MASK) == 0) {
  409. printf("PCI: CPC0_STRP1[PISE] not set.\n");
  410. printf("PCI: Configuration aborted.\n");
  411. return -1;
  412. }
  413. #endif
  414. #endif /* CONFIG_DISABLE_PISE_TEST */
  415. /*--------------------------------------------------------------------------+
  416. * PCI controller init
  417. *--------------------------------------------------------------------------*/
  418. hose->first_busno = 0;
  419. hose->last_busno = 0;
  420. /* PCI I/O space */
  421. pci_set_region(hose->regions + reg_num++,
  422. 0x00000000,
  423. PCIX0_IOBASE,
  424. 0x10000,
  425. PCI_REGION_IO);
  426. /* PCI memory space */
  427. pci_set_region(hose->regions + reg_num++,
  428. CONFIG_SYS_PCI_TARGBASE,
  429. CONFIG_SYS_PCI_MEMBASE,
  430. #ifdef CONFIG_SYS_PCI_MEMSIZE
  431. CONFIG_SYS_PCI_MEMSIZE,
  432. #else
  433. 0x10000000,
  434. #endif
  435. PCI_REGION_MEM );
  436. #if defined(CONFIG_PCI_SYS_MEM_BUS) && defined(CONFIG_PCI_SYS_MEM_PHYS) && \
  437. defined(CONFIG_PCI_SYS_MEM_SIZE)
  438. /* System memory space */
  439. pci_set_region(hose->regions + reg_num++,
  440. CONFIG_PCI_SYS_MEM_BUS,
  441. CONFIG_PCI_SYS_MEM_PHYS,
  442. CONFIG_PCI_SYS_MEM_SIZE,
  443. PCI_REGION_MEM | PCI_REGION_SYS_MEMORY );
  444. #endif
  445. hose->region_count = reg_num;
  446. pci_setup_indirect(hose, PCIX0_CFGADR, PCIX0_CFGDATA);
  447. /* Let board change/modify hose & do initial checks */
  448. if (pci_pre_init (hose) == 0) {
  449. printf("PCI: Board-specific initialization failed.\n");
  450. printf("PCI: Configuration aborted.\n");
  451. return -1;
  452. }
  453. pci_register_hose( hose );
  454. /*--------------------------------------------------------------------------+
  455. * PCI target init
  456. *--------------------------------------------------------------------------*/
  457. #if defined(CONFIG_SYS_PCI_TARGET_INIT)
  458. pci_target_init(hose); /* Let board setup pci target */
  459. #else
  460. out16r( PCIX0_SBSYSVID, CONFIG_SYS_PCI_SUBSYS_VENDORID );
  461. out16r( PCIX0_SBSYSID, CONFIG_SYS_PCI_SUBSYS_ID );
  462. out16r( PCIX0_CLS, 0x00060000 ); /* Bridge, host bridge */
  463. #endif
  464. #if defined(CONFIG_440GX) || defined(CONFIG_440SPE) || \
  465. defined(CONFIG_460EX) || defined(CONFIG_460GT)
  466. out32r( PCIX0_BRDGOPT1, 0x04000060 ); /* PLB Rq pri highest */
  467. out32r( PCIX0_BRDGOPT2, in32(PCIX0_BRDGOPT2) | 0x83 ); /* Enable host config, clear Timeout, ensure int src1 */
  468. #elif defined(PCIX0_BRDGOPT1)
  469. out32r( PCIX0_BRDGOPT1, 0x10000060 ); /* PLB Rq pri highest */
  470. out32r( PCIX0_BRDGOPT2, in32(PCIX0_BRDGOPT2) | 1 ); /* Enable host config */
  471. #endif
  472. /*--------------------------------------------------------------------------+
  473. * PCI master init: default is one 256MB region for PCI memory:
  474. * 0x3_00000000 - 0x3_0FFFFFFF ==> CONFIG_SYS_PCI_MEMBASE
  475. *--------------------------------------------------------------------------*/
  476. #if defined(CONFIG_SYS_PCI_MASTER_INIT)
  477. pci_master_init(hose); /* Let board setup pci master */
  478. #else
  479. out32r( PCIX0_POM0SA, 0 ); /* disable */
  480. out32r( PCIX0_POM1SA, 0 ); /* disable */
  481. out32r( PCIX0_POM2SA, 0 ); /* disable */
  482. #if defined(CONFIG_440SPE) || \
  483. defined(CONFIG_460EX) || defined(CONFIG_460GT)
  484. out32r( PCIX0_POM0LAL, 0x10000000 );
  485. out32r( PCIX0_POM0LAH, 0x0000000c );
  486. #else
  487. out32r( PCIX0_POM0LAL, 0x00000000 );
  488. out32r( PCIX0_POM0LAH, 0x00000003 );
  489. #endif
  490. out32r( PCIX0_POM0PCIAL, CONFIG_SYS_PCI_MEMBASE );
  491. out32r( PCIX0_POM0PCIAH, 0x00000000 );
  492. out32r( PCIX0_POM0SA, 0xf0000001 ); /* 256MB, enabled */
  493. out32r( PCIX0_STS, in32r( PCIX0_STS ) & ~0x0000fff8 );
  494. #endif
  495. /*--------------------------------------------------------------------------+
  496. * PCI host configuration -- we don't make any assumptions here ... the
  497. * _board_must_indicate_ what to do -- there's just too many runtime
  498. * scenarios in environments like cPCI, PPMC, etc. to make a determination
  499. * based on hard-coded values or state of arbiter enable.
  500. *--------------------------------------------------------------------------*/
  501. if (is_pci_host(hose)) {
  502. #ifdef CONFIG_PCI_SCAN_SHOW
  503. printf("PCI: Bus Dev VenId DevId Class Int\n");
  504. #endif
  505. #if !defined(CONFIG_440EP) && !defined(CONFIG_440GR) && \
  506. !defined(CONFIG_440EPX) && !defined(CONFIG_440GRX)
  507. out16r( PCIX0_CMD, in16r( PCIX0_CMD ) | PCI_COMMAND_MASTER);
  508. #endif
  509. hose->last_busno = pci_hose_scan(hose);
  510. }
  511. return hose->last_busno;
  512. }
  513. void pci_init_board(void)
  514. {
  515. int busno;
  516. busno = pci_440_init (&ppc440_hose);
  517. #if (defined(CONFIG_440SPE) || \
  518. defined(CONFIG_460EX) || defined(CONFIG_460GT)) && \
  519. !defined(CONFIG_PCI_DISABLE_PCIE)
  520. pcie_setup_hoses(busno + 1);
  521. #endif
  522. }
  523. #endif /* CONFIG_440 */
  524. #if defined(CONFIG_405EX)
  525. void pci_init_board(void)
  526. {
  527. #ifdef CONFIG_PCI_SCAN_SHOW
  528. printf("PCI: Bus Dev VenId DevId Class Int\n");
  529. #endif
  530. pcie_setup_hoses(0);
  531. }
  532. #endif /* CONFIG_405EX */
  533. #endif /* CONFIG_PCI */