blob: fad895b3191d0445320584a7b62ce15e164cc0b4 [file] [log] [blame]
wdenkc6097192002-11-03 00:24:07 +00001/*-----------------------------------------------------------------------------+
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
72#include <common.h>
73#include <command.h>
wdenkc6097192002-11-03 00:24:07 +000074#if !defined(CONFIG_440)
75#include <405gp_pci.h>
76#endif
77#include <asm/processor.h>
78#include <pci.h>
79
Wolfgang Denk6405a152006-03-31 18:32:53 +020080DECLARE_GLOBAL_DATA_PTR;
81
stroese434979e2003-05-23 11:18:02 +000082#if defined(CONFIG_405GP) || defined(CONFIG_405EP)
wdenkc6097192002-11-03 00:24:07 +000083
84#ifdef CONFIG_PCI
85
Stefan Roese1c671a92006-01-18 20:03:15 +010086#if defined(CONFIG_PMC405)
87ushort pmc405_pci_subsys_deviceid(void);
88#endif
89
wdenkc6097192002-11-03 00:24:07 +000090/*#define DEBUG*/
91
92/*-----------------------------------------------------------------------------+
93 * pci_init. Initializes the 405GP PCI Configuration regs.
94 *-----------------------------------------------------------------------------*/
95void pci_405gp_init(struct pci_controller *hose)
96{
wdenkc6097192002-11-03 00:24:07 +000097 int i, reg_num = 0;
98 bd_t *bd = gd->bd;
99
100 unsigned short temp_short;
101 unsigned long ptmpcila[2] = {CFG_PCI_PTM1PCI, CFG_PCI_PTM2PCI};
stroesed7c1bbd2004-12-16 18:15:52 +0000102#if defined(CONFIG_CPCI405) || defined(CONFIG_PMC405)
stroesec4b78982005-04-20 06:52:40 +0000103 char *ptmla_str, *ptmms_str;
Stefan Roese1c671a92006-01-18 20:03:15 +0100104#endif
wdenkc6097192002-11-03 00:24:07 +0000105 unsigned long ptmla[2] = {CFG_PCI_PTM1LA, CFG_PCI_PTM2LA};
106 unsigned long ptmms[2] = {CFG_PCI_PTM1MS, CFG_PCI_PTM2MS};
wdenkc6097192002-11-03 00:24:07 +0000107#if defined(CONFIG_PIP405) || defined (CONFIG_MIP405)
108 unsigned long pmmla[3] = {0x80000000, 0xA0000000, 0};
109 unsigned long pmmma[3] = {0xE0000001, 0xE0000001, 0};
110 unsigned long pmmpcila[3] = {0x80000000, 0x00000000, 0};
111 unsigned long pmmpciha[3] = {0x00000000, 0x00000000, 0};
112#else
113 unsigned long pmmla[3] = {0x80000000, 0,0};
114 unsigned long pmmma[3] = {0xC0000001, 0,0};
115 unsigned long pmmpcila[3] = {0x80000000, 0,0};
116 unsigned long pmmpciha[3] = {0x00000000, 0,0};
117#endif
stroesed7c1bbd2004-12-16 18:15:52 +0000118#ifdef CONFIG_PCI_PNP
119#if (CONFIG_PCI_HOST == PCI_HOST_AUTO)
120 char *s;
121#endif
122#endif
wdenkc6097192002-11-03 00:24:07 +0000123
stroesec4b78982005-04-20 06:52:40 +0000124#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
132 ptmla_str = getenv("ptm2la");
133 ptmms_str = getenv("ptm2ms");
134 if(NULL != ptmla_str && NULL != ptmms_str ) {
135 ptmla[1] = simple_strtoul (ptmla_str, NULL, 16);
136 ptmms[1] = simple_strtoul (ptmms_str, NULL, 16);
137 }
138#endif
139
wdenkc6097192002-11-03 00:24:07 +0000140 /*
141 * Register the hose
142 */
143 hose->first_busno = 0;
144 hose->last_busno = 0xff;
145
146 /* ISA/PCI I/O space */
147 pci_set_region(hose->regions + reg_num++,
148 MIN_PCI_PCI_IOADDR,
149 MIN_PLB_PCI_IOADDR,
150 0x10000,
151 PCI_REGION_IO);
152
153 /* PCI I/O space */
154 pci_set_region(hose->regions + reg_num++,
155 0x00800000,
156 0xe8800000,
157 0x03800000,
158 PCI_REGION_IO);
159
160 reg_num = 2;
161
162 /* Memory spaces */
163 for (i=0; i<2; i++)
164 if (ptmms[i] & 1)
165 {
166 if (!i) hose->pci_fb = hose->regions + reg_num;
167
168 pci_set_region(hose->regions + reg_num++,
169 ptmpcila[i], ptmla[i],
170 ~(ptmms[i] & 0xfffff000) + 1,
171 PCI_REGION_MEM |
172 PCI_REGION_MEMORY);
173 }
174
175 /* PCI memory spaces */
176 for (i=0; i<3; i++)
177 if (pmmma[i] & 1)
178 {
179 pci_set_region(hose->regions + reg_num++,
180 pmmpcila[i], pmmla[i],
181 ~(pmmma[i] & 0xfffff000) + 1,
182 PCI_REGION_MEM);
183 }
184
185 hose->region_count = reg_num;
186
187 pci_setup_indirect(hose,
188 PCICFGADR,
189 PCICFGDATA);
190
191 if (hose->pci_fb)
192 pciauto_region_init(hose->pci_fb);
193
194 pci_register_hose(hose);
195
196 /*--------------------------------------------------------------------------+
197 * 405GP PCI Master configuration.
198 * Map one 512 MB range of PLB/processor addresses to PCI memory space.
199 * PLB address 0x80000000-0xBFFFFFFF ==> PCI address 0x80000000-0xBFFFFFFF
200 * Use byte reversed out routines to handle endianess.
201 *--------------------------------------------------------------------------*/
wdenke39c2842003-06-04 15:05:30 +0000202 out32r(PMM0MA, (pmmma[0]&~0x1)); /* disable, configure PMMxLA, PMMxPCILA first */
wdenkc6097192002-11-03 00:24:07 +0000203 out32r(PMM0LA, pmmla[0]);
204 out32r(PMM0PCILA, pmmpcila[0]);
205 out32r(PMM0PCIHA, pmmpciha[0]);
206 out32r(PMM0MA, pmmma[0]);
207
208 /*--------------------------------------------------------------------------+
209 * PMM1 is not used. Initialize them to zero.
210 *--------------------------------------------------------------------------*/
wdenke39c2842003-06-04 15:05:30 +0000211 out32r(PMM1MA, (pmmma[1]&~0x1));
wdenkc6097192002-11-03 00:24:07 +0000212 out32r(PMM1LA, pmmla[1]);
213 out32r(PMM1PCILA, pmmpcila[1]);
214 out32r(PMM1PCIHA, pmmpciha[1]);
215 out32r(PMM1MA, pmmma[1]);
216
217 /*--------------------------------------------------------------------------+
218 * PMM2 is not used. Initialize them to zero.
219 *--------------------------------------------------------------------------*/
wdenk57b2d802003-06-27 21:31:46 +0000220 out32r(PMM2MA, (pmmma[2]&~0x1));
wdenkc6097192002-11-03 00:24:07 +0000221 out32r(PMM2LA, pmmla[2]);
222 out32r(PMM2PCILA, pmmpcila[2]);
223 out32r(PMM2PCIHA, pmmpciha[2]);
224 out32r(PMM2MA, pmmma[2]);
225
226 /*--------------------------------------------------------------------------+
227 * 405GP PCI Target configuration. (PTM1)
228 * Note: PTM1MS is hardwire enabled but we set the enable bit anyway.
229 *--------------------------------------------------------------------------*/
230 out32r(PTM1LA, ptmla[0]); /* insert address */
231 out32r(PTM1MS, ptmms[0]); /* insert size, enable bit is 1 */
wdenk6fcda222003-10-22 09:00:28 +0000232 pci_write_config_dword(PCIDEVID_405GP, PCI_BASE_ADDRESS_1, ptmpcila[0]);
wdenkc6097192002-11-03 00:24:07 +0000233
234 /*--------------------------------------------------------------------------+
235 * 405GP PCI Target configuration. (PTM2)
236 *--------------------------------------------------------------------------*/
237 out32r(PTM2LA, ptmla[1]); /* insert address */
wdenk6fcda222003-10-22 09:00:28 +0000238 pci_write_config_dword(PCIDEVID_405GP, PCI_BASE_ADDRESS_2, ptmpcila[1]);
239
wdenkc6097192002-11-03 00:24:07 +0000240 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 /*
252 * Insert Subsystem Vendor and Device ID
253 */
254 pci_write_config_word(PCIDEVID_405GP, PCI_SUBSYSTEM_VENDOR_ID, CFG_PCI_SUBSYS_VENDORID);
255#ifdef CONFIG_CPCI405
256 if (mfdcr(strap) & PSR_PCI_ARBIT_EN)
257 pci_write_config_word(PCIDEVID_405GP, PCI_SUBSYSTEM_ID, CFG_PCI_SUBSYS_DEVICEID);
258 else
259 pci_write_config_word(PCIDEVID_405GP, PCI_SUBSYSTEM_ID, CFG_PCI_SUBSYS_DEVICEID2);
260#else
261 pci_write_config_word(PCIDEVID_405GP, PCI_SUBSYSTEM_ID, CFG_PCI_SUBSYS_DEVICEID);
262#endif
263
264 /*
265 * Insert Class-code
266 */
267#ifdef CFG_PCI_CLASSCODE
268 pci_write_config_word(PCIDEVID_405GP, PCI_CLASS_SUB_CODE, CFG_PCI_CLASSCODE);
269#endif /* CFG_PCI_CLASSCODE */
270
271 /*--------------------------------------------------------------------------+
272 * If PCI speed = 66Mhz, set 66Mhz capable bit.
273 *--------------------------------------------------------------------------*/
274 if (bd->bi_pci_busfreq >= 66000000) {
275 pci_read_config_word(PCIDEVID_405GP, PCI_STATUS, &temp_short);
276 pci_write_config_word(PCIDEVID_405GP,PCI_STATUS,(temp_short|PCI_STATUS_66MHZ));
277 }
278
279#if (CONFIG_PCI_HOST != PCI_HOST_ADAPTER)
wdenk6fcda222003-10-22 09:00:28 +0000280#if (CONFIG_PCI_HOST == PCI_HOST_AUTO)
stroesed7c1bbd2004-12-16 18:15:52 +0000281 if ((mfdcr(strap) & PSR_PCI_ARBIT_EN) ||
282 (((s = getenv("pciscan")) != NULL) && (strcmp(s, "yes") == 0)))
wdenkc6097192002-11-03 00:24:07 +0000283#endif
284 {
285 /*--------------------------------------------------------------------------+
286 * Write the 405GP PCI Configuration regs.
287 * Enable 405GP to be a master on the PCI bus (PMM).
288 * Enable 405GP to act as a PCI memory target (PTM).
289 *--------------------------------------------------------------------------*/
290 pci_read_config_word(PCIDEVID_405GP, PCI_COMMAND, &temp_short);
291 pci_write_config_word(PCIDEVID_405GP, PCI_COMMAND, temp_short |
292 PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
293 }
294#endif
295
stroese79435e32003-09-12 08:52:09 +0000296#if defined(CONFIG_405EP) /* on ppc405ep vendor id is not set */
297 pci_write_config_word(PCIDEVID_405GP, PCI_VENDOR_ID, 0x1014); /* IBM */
298#endif
299
wdenkc6097192002-11-03 00:24:07 +0000300 /*
301 * Set HCE bit (Host Configuration Enabled)
302 */
303 pci_read_config_word(PCIDEVID_405GP, PCIBRDGOPT2, &temp_short);
304 pci_write_config_word(PCIDEVID_405GP, PCIBRDGOPT2, (temp_short | 0x0001));
305
306#ifdef CONFIG_PCI_PNP
307 /*--------------------------------------------------------------------------+
308 * Scan the PCI bus and configure devices found.
309 *--------------------------------------------------------------------------*/
310#if (CONFIG_PCI_HOST == PCI_HOST_AUTO)
stroesed7c1bbd2004-12-16 18:15:52 +0000311 if ((mfdcr(strap) & PSR_PCI_ARBIT_EN) ||
312 (((s = getenv("pciscan")) != NULL) && (strcmp(s, "yes") == 0)))
wdenkc6097192002-11-03 00:24:07 +0000313#endif
314 {
315#ifdef CONFIG_PCI_SCAN_SHOW
316 printf("PCI: Bus Dev VenId DevId Class Int\n");
317#endif
318
319 hose->last_busno = pci_hose_scan(hose);
320 }
321#endif /* CONFIG_PCI_PNP */
322
323}
324
325/*
326 * drivers/pci.c skips every host bridge but the 405GP since it could
327 * be set as an Adapter.
328 *
329 * I (Andrew May) don't know what we should do here, but I don't want
330 * the auto setup of a PCI device disabling what is done pci_405gp_init
331 * as has happened before.
332 */
333void pci_405gp_setup_bridge(struct pci_controller *hose, pci_dev_t dev,
334 struct pci_config_table *entry)
335{
336#ifdef DEBUG
wdenk57b2d802003-06-27 21:31:46 +0000337 printf("405gp_setup_bridge\n");
wdenkc6097192002-11-03 00:24:07 +0000338#endif
339}
340
341/*
342 *
343 */
344
345void pci_405gp_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
346{
347 unsigned char int_line = 0xff;
348
349 /*
350 * Write pci interrupt line register (cpci405 specific)
351 */
352 switch (PCI_DEV(dev) & 0x03)
353 {
354 case 0:
355 int_line = 27 + 2;
356 break;
357 case 1:
358 int_line = 27 + 3;
359 break;
360 case 2:
361 int_line = 27 + 0;
362 break;
363 case 3:
364 int_line = 27 + 1;
365 break;
366 }
367
368 pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, int_line);
369}
370
371void pci_405gp_setup_vga(struct pci_controller *hose, pci_dev_t dev,
372 struct pci_config_table *entry)
373{
374 unsigned int cmdstat = 0;
375
Stefan Roesec6d58782006-03-13 09:43:01 +0100376 pciauto_setup_device(hose, dev, 6, hose->pci_mem, hose->pci_prefetch, hose->pci_io);
wdenkc6097192002-11-03 00:24:07 +0000377
378 /* always enable io space on vga boards */
379 pci_hose_read_config_dword(hose, dev, PCI_COMMAND, &cmdstat);
380 cmdstat |= PCI_COMMAND_IO;
381 pci_hose_write_config_dword(hose, dev, PCI_COMMAND, cmdstat);
382}
383
384#if !(defined(CONFIG_PIP405) || defined (CONFIG_MIP405))
385
386/*
387 *As is these functs get called out of flash Not a horrible
388 *thing, but something to keep in mind. (no statics?)
389 */
390static struct pci_config_table pci_405gp_config_table[] = {
391/*if VendID is 0 it terminates the table search (ie Walnut)*/
wdenkc35ba4e2004-03-14 22:25:36 +0000392#ifdef CFG_PCI_SUBSYS_VENDORID
wdenkc6097192002-11-03 00:24:07 +0000393 {CFG_PCI_SUBSYS_VENDORID, PCI_ANY_ID, PCI_CLASS_BRIDGE_HOST,
394 PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, pci_405gp_setup_bridge},
395#endif
396 {PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA,
397 PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, pci_405gp_setup_vga},
398
399 {PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_NOT_DEFINED_VGA,
400 PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, pci_405gp_setup_vga},
401
402 { }
403};
404
405static struct pci_controller hose = {
406 fixup_irq: pci_405gp_fixup_irq,
407 config_table: pci_405gp_config_table,
408};
409
stroesef5dd4102003-02-14 11:21:23 +0000410void pci_init_board(void)
wdenkc6097192002-11-03 00:24:07 +0000411{
412 /*we want the ptrs to RAM not flash (ie don't use init list)*/
413 hose.fixup_irq = pci_405gp_fixup_irq;
414 hose.config_table = pci_405gp_config_table;
415 pci_405gp_init(&hose);
416}
417
418#endif
419
420#endif /* CONFIG_PCI */
421
422#endif /* CONFIG_405GP */
423
424/*-----------------------------------------------------------------------------+
425 * CONFIG_440
426 *-----------------------------------------------------------------------------*/
427#if defined(CONFIG_440) && defined(CONFIG_PCI)
428
429static struct pci_controller ppc440_hose = {0};
430
431
432void pci_440_init (struct pci_controller *hose)
433{
434 int reg_num = 0;
wdenkc6097192002-11-03 00:24:07 +0000435
Stefan Roesec443fe92005-11-22 13:20:42 +0100436#ifndef CONFIG_DISABLE_PISE_TEST
wdenkc6097192002-11-03 00:24:07 +0000437 /*--------------------------------------------------------------------------+
438 * The PCI initialization sequence enable bit must be set ... if not abort
wdenk56ed43e2004-02-22 23:46:08 +0000439 * pci setup since updating the bit requires chip reset.
wdenkc6097192002-11-03 00:24:07 +0000440 *--------------------------------------------------------------------------*/
Stefan Roese99644742005-11-29 18:18:21 +0100441#if defined(CONFIG_440GX) || defined(CONFIG_440SP)
Stefan Roesec443fe92005-11-22 13:20:42 +0100442 unsigned long strap;
443
wdenk56ed43e2004-02-22 23:46:08 +0000444 mfsdr(sdr_sdstp1,strap);
Stefan Roese99644742005-11-29 18:18:21 +0100445 if ((strap & SDR0_SDSTP1_PISE_MASK) == 0) {
wdenk56ed43e2004-02-22 23:46:08 +0000446 printf("PCI: SDR0_STRP1[PISE] not set.\n");
447 printf("PCI: Configuration aborted.\n");
448 return;
449 }
Stefan Roesec443fe92005-11-22 13:20:42 +0100450#elif defined(CONFIG_440GP)
451 unsigned long strap;
452
wdenk56ed43e2004-02-22 23:46:08 +0000453 strap = mfdcr(cpc0_strp1);
Stefan Roese99644742005-11-29 18:18:21 +0100454 if ((strap & CPC0_STRP1_PISE_MASK) == 0) {
wdenk56ed43e2004-02-22 23:46:08 +0000455 printf("PCI: CPC0_STRP1[PISE] not set.\n");
456 printf("PCI: Configuration aborted.\n");
457 return;
458 }
459#endif
Stefan Roesec443fe92005-11-22 13:20:42 +0100460#endif /* CONFIG_DISABLE_PISE_TEST */
461
wdenkc6097192002-11-03 00:24:07 +0000462 /*--------------------------------------------------------------------------+
463 * PCI controller init
464 *--------------------------------------------------------------------------*/
465 hose->first_busno = 0;
466 hose->last_busno = 0xff;
467
468 pci_set_region(hose->regions + reg_num++,
469 0x00000000,
Stefan Roese99644742005-11-29 18:18:21 +0100470 PCIX0_IOBASE,
471 0x10000,
472 PCI_REGION_IO);
wdenkc6097192002-11-03 00:24:07 +0000473
474 pci_set_region(hose->regions + reg_num++,
475 CFG_PCI_TARGBASE,
Stefan Roese99644742005-11-29 18:18:21 +0100476 CFG_PCI_MEMBASE,
477 0x10000000,
478 PCI_REGION_MEM );
wdenkc6097192002-11-03 00:24:07 +0000479 hose->region_count = reg_num;
480
481 pci_setup_indirect(hose, PCIX0_CFGADR, PCIX0_CFGDATA);
482
483#if defined(CFG_PCI_PRE_INIT)
Stefan Roese99644742005-11-29 18:18:21 +0100484 /* Let board change/modify hose & do initial checks */
485 if (pci_pre_init (hose) == 0) {
486 printf("PCI: Board-specific initialization failed.\n");
487 printf("PCI: Configuration aborted.\n");
488 return;
489 }
wdenkc6097192002-11-03 00:24:07 +0000490#endif
491
492 pci_register_hose( hose );
493
494 /*--------------------------------------------------------------------------+
495 * PCI target init
496 *--------------------------------------------------------------------------*/
497#if defined(CFG_PCI_TARGET_INIT)
498 pci_target_init(hose); /* Let board setup pci target */
499#else
Stefan Roese99644742005-11-29 18:18:21 +0100500 out16r( PCIX0_SBSYSVID, CFG_PCI_SUBSYS_VENDORID );
501 out16r( PCIX0_SBSYSID, CFG_PCI_SUBSYS_ID );
502 out16r( PCIX0_CLS, 0x00060000 ); /* Bridge, host bridge */
wdenkc6097192002-11-03 00:24:07 +0000503#endif
504
Stefan Roeseb30f2a12005-08-08 12:42:22 +0200505#if defined(CONFIG_440GX)
wdenk56ed43e2004-02-22 23:46:08 +0000506 out32r( PCIX0_BRDGOPT1, 0x04000060 ); /* PLB Rq pri highest */
507 out32r( PCIX0_BRDGOPT2, in32(PCIX0_BRDGOPT2) | 0x83 ); /* Enable host config, clear Timeout, ensure int src1 */
Stefan Roese326c9712005-08-01 16:41:48 +0200508#elif defined(PCIX0_BRDGOPT1)
wdenk56ed43e2004-02-22 23:46:08 +0000509 out32r( PCIX0_BRDGOPT1, 0x10000060 ); /* PLB Rq pri highest */
510 out32r( PCIX0_BRDGOPT2, in32(PCIX0_BRDGOPT2) | 1 ); /* Enable host config */
511#endif
wdenkc6097192002-11-03 00:24:07 +0000512
513 /*--------------------------------------------------------------------------+
514 * PCI master init: default is one 256MB region for PCI memory:
515 * 0x3_00000000 - 0x3_0FFFFFFF ==> CFG_PCI_MEMBASE
516 *--------------------------------------------------------------------------*/
517#if defined(CFG_PCI_MASTER_INIT)
518 pci_master_init(hose); /* Let board setup pci master */
519#else
520 out32r( PCIX0_POM0SA, 0 ); /* disable */
521 out32r( PCIX0_POM1SA, 0 ); /* disable */
522 out32r( PCIX0_POM2SA, 0 ); /* disable */
523 out32r( PCIX0_POM0LAL, 0x00000000 );
524 out32r( PCIX0_POM0LAH, 0x00000003 );
525 out32r( PCIX0_POM0PCIAL, CFG_PCI_MEMBASE );
526 out32r( PCIX0_POM0PCIAH, 0x00000000 );
527 out32r( PCIX0_POM0SA, 0xf0000001 ); /* 256MB, enabled */
Stefan Roese99644742005-11-29 18:18:21 +0100528 out32r( PCIX0_STS, in32r( PCIX0_STS ) & ~0x0000fff8 );
wdenkc6097192002-11-03 00:24:07 +0000529#endif
530
531 /*--------------------------------------------------------------------------+
532 * PCI host configuration -- we don't make any assumptions here ... the
Stefan Roese99644742005-11-29 18:18:21 +0100533 * _board_must_indicate_ what to do -- there's just too many runtime
534 * scenarios in environments like cPCI, PPMC, etc. to make a determination
535 * based on hard-coded values or state of arbiter enable.
wdenkc6097192002-11-03 00:24:07 +0000536 *--------------------------------------------------------------------------*/
Stefan Roese99644742005-11-29 18:18:21 +0100537 if (is_pci_host(hose)) {
wdenkc6097192002-11-03 00:24:07 +0000538#ifdef CONFIG_PCI_SCAN_SHOW
Stefan Roese99644742005-11-29 18:18:21 +0100539 printf("PCI: Bus Dev VenId DevId Class Int\n");
wdenkc6097192002-11-03 00:24:07 +0000540#endif
Stefan Roeseb30f2a12005-08-08 12:42:22 +0200541#if !defined(CONFIG_440EP) && !defined(CONFIG_440GR)
Stefan Roese99644742005-11-29 18:18:21 +0100542 out16r( PCIX0_CMD, in16r( PCIX0_CMD ) | PCI_COMMAND_MASTER);
Stefan Roese326c9712005-08-01 16:41:48 +0200543#endif
Stefan Roese99644742005-11-29 18:18:21 +0100544 hose->last_busno = pci_hose_scan(hose);
545 }
wdenkc6097192002-11-03 00:24:07 +0000546}
547
548
stroesef5dd4102003-02-14 11:21:23 +0000549void pci_init_board(void)
wdenkc6097192002-11-03 00:24:07 +0000550{
551 pci_440_init (&ppc440_hose);
552}
553
554#endif /* CONFIG_440 & CONFIG_PCI */