blob: 08781a1fb96d6859426d43d849eeec7b87ec8856 [file] [log] [blame]
Wolfgang Denk46263f22013-07-28 22:12:45 +02001/*
Wolfgang Denk1b387ef2013-09-17 11:24:06 +02002 * SPDX-License-Identifier: GPL-2.0 IBM-pibs
wdenkc6097192002-11-03 00:24:07 +00003 *
4 * File Name: 405gp_pci.c
5 *
6 * Function: Initialization code for the 405GP PCI Configuration regs.
7 *
8 * Author: Mark Game
9 *
10 * Change Activity-
11 *
12 * Date Description of Change BY
13 * --------- --------------------- ---
14 * 09-Sep-98 Created MCG
15 * 02-Nov-98 Removed External arbiter selected message JWB
16 * 27-Nov-98 Zero out PTMBAR2 and disable in PTM2MS JWB
17 * 04-Jan-99 Zero out other unused PMM and PTM regs. Change bus scan MCG
18 * from (0 to n) to (1 to n).
19 * 17-May-99 Port to Walnut JWB
20 * 17-Jun-99 Updated for VGA support JWB
21 * 21-Jun-99 Updated to allow SRAM region to be a target from PCI bus JWB
22 * 19-Jul-99 Updated for 405GP pass 1 errata #26 (Low PCI subsequent MCG
23 * target latency timer values are not supported).
24 * Should be fixed in pass 2.
25 * 09-Sep-99 Removed use of PTM2 since the SRAM region no longer needs JWB
26 * to be a PCI target. Zero out PTMBAR2 and disable in PTM2MS.
27 * 10-Dec-99 Updated PCI_Write_CFG_Reg for pass2 errata #6 JWB
28 * 11-Jan-00 Ensure PMMxMAs disabled before setting PMMxLAs. This is not
29 * really required after a reset since PMMxMAs are already
Wolfgang Denk53677ef2008-05-20 16:00:29 +020030 * disabled but is a good practice nonetheless. JWB
wdenkc6097192002-11-03 00:24:07 +000031 * 12-Jun-01 stefan.roese@esd-electronics.com
32 * - PCI host/adapter handling reworked
33 * 09-Jul-01 stefan.roese@esd-electronics.com
34 * - PCI host now configures from device 0 (not 1) to max_dev,
35 * (host configures itself)
36 * - On CPCI-405 pci base address and size is generated from
37 * SDRAM and FLASH size (CFG regs not used anymore)
38 * - Some minor changes for CPCI-405-A (adapter version)
39 * 14-Sep-01 stefan.roese@esd-electronics.com
40 * - CONFIG_PCI_SCAN_SHOW added to print pci devices upon startup
41 * 28-Sep-01 stefan.roese@esd-electronics.com
42 * - Changed pci master configuration for linux compatibility
43 * (no need for bios_fixup() anymore)
44 * 26-Feb-02 stefan.roese@esd-electronics.com
45 * - Bug fixed in pci configuration (Andrew May)
46 * - Removed pci class code init for CPCI405 board
47 * 15-May-02 stefan.roese@esd-electronics.com
48 * - New vga device handling
49 * 29-May-02 stefan.roese@esd-electronics.com
50 * - PCI class code init added (if defined)
51 *----------------------------------------------------------------------------*/
52
53#include <common.h>
54#include <command.h>
Stefan Roese3048bcb2007-10-03 15:01:02 +020055#include <asm/4xx_pci.h>
wdenkc6097192002-11-03 00:24:07 +000056#include <asm/processor.h>
Stefan Roese10954932009-11-12 12:00:49 +010057#include <asm/io.h>
wdenkc6097192002-11-03 00:24:07 +000058#include <pci.h>
59
Matthias Fuchs5a1c9ff2007-06-24 17:23:41 +020060#ifdef CONFIG_PCI
61
Wolfgang Denkd87080b2006-03-31 18:32:53 +020062DECLARE_GLOBAL_DATA_PTR;
63
Stefan Roesea760b022009-11-12 16:41:09 +010064#if defined(CONFIG_405GP) || defined(CONFIG_405EP)
65
66#if defined(CONFIG_PMC405)
67ushort pmc405_pci_subsys_deviceid(void);
68#endif
69
70/*#define DEBUG*/
71
Matthias Fuchs5a1c9ff2007-06-24 17:23:41 +020072/*
73 * Board-specific pci initialization
74 * Platform code can reimplement pci_pre_init() if needed
75 */
76int __pci_pre_init(struct pci_controller *hose)
77{
Stefan Roesea760b022009-11-12 16:41:09 +010078#if defined(CONFIG_405EP)
Matthias Fuchs123f1022009-07-08 13:43:55 +020079 /*
80 * Enable the internal PCI arbiter by default.
81 *
82 * On 405EP CPUs the internal arbiter can be controlled
83 * by the I2C strapping EEPROM. If you want to do so
84 * or if you want to disable the arbiter pci_pre_init()
85 * must be reimplemented without enabling the arbiter.
86 * The arbiter is enabled in this place because of
87 * compatibility reasons.
88 */
Stefan Roesed1c3b272009-09-09 16:25:29 +020089 mtdcr(CPC0_PCI, mfdcr(CPC0_PCI) | CPC0_PCI_ARBIT_EN);
Matthias Fuchs123f1022009-07-08 13:43:55 +020090#endif /* CONFIG_405EP */
91
Matthias Fuchs5a1c9ff2007-06-24 17:23:41 +020092 return 1;
93}
Stefan Roesea760b022009-11-12 16:41:09 +010094int pci_pre_init(struct pci_controller *hose)
95 __attribute__((weak, alias("__pci_pre_init")));
wdenkc6097192002-11-03 00:24:07 +000096
Matthias Fuchsd0a13642009-07-03 16:06:06 +020097int __is_pci_host(struct pci_controller *hose)
98{
99#if defined(CONFIG_405GP)
Stefan Roesed1c3b272009-09-09 16:25:29 +0200100 if (mfdcr(CPC0_PSR) & PSR_PCI_ARBIT_EN)
Matthias Fuchsd0a13642009-07-03 16:06:06 +0200101 return 1;
102#elif defined (CONFIG_405EP)
Stefan Roesed1c3b272009-09-09 16:25:29 +0200103 if (mfdcr(CPC0_PCI) & CPC0_PCI_ARBIT_EN)
Matthias Fuchsd0a13642009-07-03 16:06:06 +0200104 return 1;
105#endif
106 return 0;
107}
108int is_pci_host(struct pci_controller *hose) __attribute__((weak, alias("__is_pci_host")));
109
wdenkc6097192002-11-03 00:24:07 +0000110/*-----------------------------------------------------------------------------+
111 * pci_init. Initializes the 405GP PCI Configuration regs.
112 *-----------------------------------------------------------------------------*/
113void pci_405gp_init(struct pci_controller *hose)
114{
wdenkc6097192002-11-03 00:24:07 +0000115 int i, reg_num = 0;
116 bd_t *bd = gd->bd;
117
118 unsigned short temp_short;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200119 unsigned long ptmpcila[2] = {CONFIG_SYS_PCI_PTM1PCI, CONFIG_SYS_PCI_PTM2PCI};
Matthias Fuchs99bcf142009-09-07 17:00:40 +0200120#if defined(CONFIG_PCI_4xx_PTM_OVERWRITE)
stroesefddae7b2005-04-20 06:52:40 +0000121 char *ptmla_str, *ptmms_str;
Stefan Roese2076d0a2006-01-18 20:03:15 +0100122#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200123 unsigned long ptmla[2] = {CONFIG_SYS_PCI_PTM1LA, CONFIG_SYS_PCI_PTM2LA};
124 unsigned long ptmms[2] = {CONFIG_SYS_PCI_PTM1MS, CONFIG_SYS_PCI_PTM2MS};
wdenkc6097192002-11-03 00:24:07 +0000125#if defined(CONFIG_PIP405) || defined (CONFIG_MIP405)
126 unsigned long pmmla[3] = {0x80000000, 0xA0000000, 0};
127 unsigned long pmmma[3] = {0xE0000001, 0xE0000001, 0};
128 unsigned long pmmpcila[3] = {0x80000000, 0x00000000, 0};
129 unsigned long pmmpciha[3] = {0x00000000, 0x00000000, 0};
130#else
131 unsigned long pmmla[3] = {0x80000000, 0,0};
132 unsigned long pmmma[3] = {0xC0000001, 0,0};
133 unsigned long pmmpcila[3] = {0x80000000, 0,0};
134 unsigned long pmmpciha[3] = {0x00000000, 0,0};
135#endif
stroese5e746fc2004-12-16 18:15:52 +0000136#ifdef CONFIG_PCI_PNP
137#if (CONFIG_PCI_HOST == PCI_HOST_AUTO)
138 char *s;
139#endif
140#endif
wdenkc6097192002-11-03 00:24:07 +0000141
Matthias Fuchs99bcf142009-09-07 17:00:40 +0200142#if defined(CONFIG_PCI_4xx_PTM_OVERWRITE)
stroesefddae7b2005-04-20 06:52:40 +0000143 ptmla_str = getenv("ptm1la");
144 ptmms_str = getenv("ptm1ms");
145 if(NULL != ptmla_str && NULL != ptmms_str ) {
146 ptmla[0] = simple_strtoul (ptmla_str, NULL, 16);
147 ptmms[0] = simple_strtoul (ptmms_str, NULL, 16);
148 }
149
150 ptmla_str = getenv("ptm2la");
151 ptmms_str = getenv("ptm2ms");
152 if(NULL != ptmla_str && NULL != ptmms_str ) {
153 ptmla[1] = simple_strtoul (ptmla_str, NULL, 16);
154 ptmms[1] = simple_strtoul (ptmms_str, NULL, 16);
155 }
156#endif
157
wdenkc6097192002-11-03 00:24:07 +0000158 /*
159 * Register the hose
160 */
161 hose->first_busno = 0;
162 hose->last_busno = 0xff;
163
164 /* ISA/PCI I/O space */
165 pci_set_region(hose->regions + reg_num++,
166 MIN_PCI_PCI_IOADDR,
167 MIN_PLB_PCI_IOADDR,
168 0x10000,
169 PCI_REGION_IO);
170
171 /* PCI I/O space */
172 pci_set_region(hose->regions + reg_num++,
173 0x00800000,
174 0xe8800000,
175 0x03800000,
176 PCI_REGION_IO);
177
178 reg_num = 2;
179
180 /* Memory spaces */
181 for (i=0; i<2; i++)
182 if (ptmms[i] & 1)
183 {
184 if (!i) hose->pci_fb = hose->regions + reg_num;
185
186 pci_set_region(hose->regions + reg_num++,
187 ptmpcila[i], ptmla[i],
188 ~(ptmms[i] & 0xfffff000) + 1,
189 PCI_REGION_MEM |
Kumar Galaff4e66e2009-02-06 09:49:31 -0600190 PCI_REGION_SYS_MEMORY);
wdenkc6097192002-11-03 00:24:07 +0000191 }
192
193 /* PCI memory spaces */
194 for (i=0; i<3; i++)
195 if (pmmma[i] & 1)
196 {
197 pci_set_region(hose->regions + reg_num++,
198 pmmpcila[i], pmmla[i],
199 ~(pmmma[i] & 0xfffff000) + 1,
200 PCI_REGION_MEM);
201 }
202
203 hose->region_count = reg_num;
204
205 pci_setup_indirect(hose,
206 PCICFGADR,
207 PCICFGDATA);
208
209 if (hose->pci_fb)
210 pciauto_region_init(hose->pci_fb);
211
Matthias Fuchs5a1c9ff2007-06-24 17:23:41 +0200212 /* Let board change/modify hose & do initial checks */
Stefan Roesea760b022009-11-12 16:41:09 +0100213 if (pci_pre_init(hose) == 0) {
Matthias Fuchs5a1c9ff2007-06-24 17:23:41 +0200214 printf("PCI: Board-specific initialization failed.\n");
215 printf("PCI: Configuration aborted.\n");
216 return;
217 }
218
wdenkc6097192002-11-03 00:24:07 +0000219 pci_register_hose(hose);
220
221 /*--------------------------------------------------------------------------+
222 * 405GP PCI Master configuration.
223 * Map one 512 MB range of PLB/processor addresses to PCI memory space.
224 * PLB address 0x80000000-0xBFFFFFFF ==> PCI address 0x80000000-0xBFFFFFFF
225 * Use byte reversed out routines to handle endianess.
226 *--------------------------------------------------------------------------*/
wdenkf3e0de62003-06-04 15:05:30 +0000227 out32r(PMM0MA, (pmmma[0]&~0x1)); /* disable, configure PMMxLA, PMMxPCILA first */
wdenkc6097192002-11-03 00:24:07 +0000228 out32r(PMM0LA, pmmla[0]);
229 out32r(PMM0PCILA, pmmpcila[0]);
230 out32r(PMM0PCIHA, pmmpciha[0]);
231 out32r(PMM0MA, pmmma[0]);
232
233 /*--------------------------------------------------------------------------+
234 * PMM1 is not used. Initialize them to zero.
235 *--------------------------------------------------------------------------*/
wdenkf3e0de62003-06-04 15:05:30 +0000236 out32r(PMM1MA, (pmmma[1]&~0x1));
wdenkc6097192002-11-03 00:24:07 +0000237 out32r(PMM1LA, pmmla[1]);
238 out32r(PMM1PCILA, pmmpcila[1]);
239 out32r(PMM1PCIHA, pmmpciha[1]);
240 out32r(PMM1MA, pmmma[1]);
241
242 /*--------------------------------------------------------------------------+
243 * PMM2 is not used. Initialize them to zero.
244 *--------------------------------------------------------------------------*/
wdenk8bde7f72003-06-27 21:31:46 +0000245 out32r(PMM2MA, (pmmma[2]&~0x1));
wdenkc6097192002-11-03 00:24:07 +0000246 out32r(PMM2LA, pmmla[2]);
247 out32r(PMM2PCILA, pmmpcila[2]);
248 out32r(PMM2PCIHA, pmmpciha[2]);
249 out32r(PMM2MA, pmmma[2]);
250
251 /*--------------------------------------------------------------------------+
252 * 405GP PCI Target configuration. (PTM1)
253 * Note: PTM1MS is hardwire enabled but we set the enable bit anyway.
254 *--------------------------------------------------------------------------*/
255 out32r(PTM1LA, ptmla[0]); /* insert address */
256 out32r(PTM1MS, ptmms[0]); /* insert size, enable bit is 1 */
wdenk4654af22003-10-22 09:00:28 +0000257 pci_write_config_dword(PCIDEVID_405GP, PCI_BASE_ADDRESS_1, ptmpcila[0]);
wdenkc6097192002-11-03 00:24:07 +0000258
259 /*--------------------------------------------------------------------------+
260 * 405GP PCI Target configuration. (PTM2)
261 *--------------------------------------------------------------------------*/
262 out32r(PTM2LA, ptmla[1]); /* insert address */
wdenk4654af22003-10-22 09:00:28 +0000263 pci_write_config_dword(PCIDEVID_405GP, PCI_BASE_ADDRESS_2, ptmpcila[1]);
264
wdenkc6097192002-11-03 00:24:07 +0000265 if (ptmms[1] == 0)
266 {
267 out32r(PTM2MS, 0x00000001); /* set enable bit */
268 pci_write_config_dword(PCIDEVID_405GP, PCI_BASE_ADDRESS_2, 0x00000000);
269 out32r(PTM2MS, 0x00000000); /* disable */
270 }
271 else
272 {
273 out32r(PTM2MS, ptmms[1]); /* insert size, enable bit is 1 */
274 }
275
276 /*
277 * Insert Subsystem Vendor and Device ID
278 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200279 pci_write_config_word(PCIDEVID_405GP, PCI_SUBSYSTEM_VENDOR_ID, CONFIG_SYS_PCI_SUBSYS_VENDORID);
wdenkc6097192002-11-03 00:24:07 +0000280#ifdef CONFIG_CPCI405
Matthias Fuchsd0a13642009-07-03 16:06:06 +0200281 if (is_pci_host(hose))
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200282 pci_write_config_word(PCIDEVID_405GP, PCI_SUBSYSTEM_ID, CONFIG_SYS_PCI_SUBSYS_DEVICEID);
wdenkc6097192002-11-03 00:24:07 +0000283 else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200284 pci_write_config_word(PCIDEVID_405GP, PCI_SUBSYSTEM_ID, CONFIG_SYS_PCI_SUBSYS_DEVICEID2);
wdenkc6097192002-11-03 00:24:07 +0000285#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200286 pci_write_config_word(PCIDEVID_405GP, PCI_SUBSYSTEM_ID, CONFIG_SYS_PCI_SUBSYS_DEVICEID);
wdenkc6097192002-11-03 00:24:07 +0000287#endif
288
289 /*
290 * Insert Class-code
291 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200292#ifdef CONFIG_SYS_PCI_CLASSCODE
293 pci_write_config_word(PCIDEVID_405GP, PCI_CLASS_SUB_CODE, CONFIG_SYS_PCI_CLASSCODE);
294#endif /* CONFIG_SYS_PCI_CLASSCODE */
wdenkc6097192002-11-03 00:24:07 +0000295
296 /*--------------------------------------------------------------------------+
Wolfgang Denk8ed44d92008-10-19 02:35:50 +0200297 * If PCI speed = 66MHz, set 66MHz capable bit.
wdenkc6097192002-11-03 00:24:07 +0000298 *--------------------------------------------------------------------------*/
299 if (bd->bi_pci_busfreq >= 66000000) {
300 pci_read_config_word(PCIDEVID_405GP, PCI_STATUS, &temp_short);
301 pci_write_config_word(PCIDEVID_405GP,PCI_STATUS,(temp_short|PCI_STATUS_66MHZ));
302 }
303
304#if (CONFIG_PCI_HOST != PCI_HOST_ADAPTER)
wdenk4654af22003-10-22 09:00:28 +0000305#if (CONFIG_PCI_HOST == PCI_HOST_AUTO)
Matthias Fuchsd0a13642009-07-03 16:06:06 +0200306 if (is_pci_host(hose) ||
stroese5e746fc2004-12-16 18:15:52 +0000307 (((s = getenv("pciscan")) != NULL) && (strcmp(s, "yes") == 0)))
wdenkc6097192002-11-03 00:24:07 +0000308#endif
309 {
310 /*--------------------------------------------------------------------------+
311 * Write the 405GP PCI Configuration regs.
312 * Enable 405GP to be a master on the PCI bus (PMM).
313 * Enable 405GP to act as a PCI memory target (PTM).
314 *--------------------------------------------------------------------------*/
315 pci_read_config_word(PCIDEVID_405GP, PCI_COMMAND, &temp_short);
316 pci_write_config_word(PCIDEVID_405GP, PCI_COMMAND, temp_short |
317 PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
318 }
319#endif
320
Matthias Fuchs632e9b62009-07-08 15:31:57 +0200321#if defined(CONFIG_405EP)
322 /*
323 * on ppc405ep vendor/device id is not set
324 * The user manual says 0x1014 (IBM) / 0x0156 (405GP!)
325 * are the correct values.
326 */
327 pci_write_config_word(PCIDEVID_405GP, PCI_VENDOR_ID, PCI_VENDOR_ID_IBM);
328 pci_write_config_word(PCIDEVID_405GP,
329 PCI_DEVICE_ID, PCI_DEVICE_ID_IBM_405GP);
stroese428c5632003-09-12 08:52:09 +0000330#endif
331
wdenkc6097192002-11-03 00:24:07 +0000332 /*
333 * Set HCE bit (Host Configuration Enabled)
334 */
335 pci_read_config_word(PCIDEVID_405GP, PCIBRDGOPT2, &temp_short);
336 pci_write_config_word(PCIDEVID_405GP, PCIBRDGOPT2, (temp_short | 0x0001));
337
338#ifdef CONFIG_PCI_PNP
339 /*--------------------------------------------------------------------------+
340 * Scan the PCI bus and configure devices found.
341 *--------------------------------------------------------------------------*/
342#if (CONFIG_PCI_HOST == PCI_HOST_AUTO)
Matthias Fuchsd0a13642009-07-03 16:06:06 +0200343 if (is_pci_host(hose) ||
stroese5e746fc2004-12-16 18:15:52 +0000344 (((s = getenv("pciscan")) != NULL) && (strcmp(s, "yes") == 0)))
wdenkc6097192002-11-03 00:24:07 +0000345#endif
346 {
347#ifdef CONFIG_PCI_SCAN_SHOW
348 printf("PCI: Bus Dev VenId DevId Class Int\n");
349#endif
wdenkc6097192002-11-03 00:24:07 +0000350 hose->last_busno = pci_hose_scan(hose);
351 }
352#endif /* CONFIG_PCI_PNP */
353
354}
355
356/*
Marcel Ziswiler7817cb22007-12-30 03:30:46 +0100357 * drivers/pci/pci.c skips every host bridge but the 405GP since it could
wdenkc6097192002-11-03 00:24:07 +0000358 * be set as an Adapter.
359 *
360 * I (Andrew May) don't know what we should do here, but I don't want
361 * the auto setup of a PCI device disabling what is done pci_405gp_init
362 * as has happened before.
363 */
364void pci_405gp_setup_bridge(struct pci_controller *hose, pci_dev_t dev,
365 struct pci_config_table *entry)
366{
367#ifdef DEBUG
wdenk8bde7f72003-06-27 21:31:46 +0000368 printf("405gp_setup_bridge\n");
wdenkc6097192002-11-03 00:24:07 +0000369#endif
370}
371
372/*
373 *
374 */
375
376void pci_405gp_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
377{
378 unsigned char int_line = 0xff;
379
380 /*
381 * Write pci interrupt line register (cpci405 specific)
382 */
383 switch (PCI_DEV(dev) & 0x03)
384 {
385 case 0:
386 int_line = 27 + 2;
387 break;
388 case 1:
389 int_line = 27 + 3;
390 break;
391 case 2:
392 int_line = 27 + 0;
393 break;
394 case 3:
395 int_line = 27 + 1;
396 break;
397 }
398
399 pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, int_line);
400}
401
402void pci_405gp_setup_vga(struct pci_controller *hose, pci_dev_t dev,
403 struct pci_config_table *entry)
404{
405 unsigned int cmdstat = 0;
406
Stefan Roesef3fecfe2006-03-13 09:43:01 +0100407 pciauto_setup_device(hose, dev, 6, hose->pci_mem, hose->pci_prefetch, hose->pci_io);
wdenkc6097192002-11-03 00:24:07 +0000408
409 /* always enable io space on vga boards */
410 pci_hose_read_config_dword(hose, dev, PCI_COMMAND, &cmdstat);
411 cmdstat |= PCI_COMMAND_IO;
412 pci_hose_write_config_dword(hose, dev, PCI_COMMAND, cmdstat);
413}
414
Wolfgang Denk9045f332007-06-08 10:24:58 +0200415#if !(defined(CONFIG_PIP405) || defined (CONFIG_MIP405)) && !(defined (CONFIG_SC3))
wdenkc6097192002-11-03 00:24:07 +0000416
417/*
418 *As is these functs get called out of flash Not a horrible
419 *thing, but something to keep in mind. (no statics?)
420 */
421static struct pci_config_table pci_405gp_config_table[] = {
422/*if VendID is 0 it terminates the table search (ie Walnut)*/
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200423#ifdef CONFIG_SYS_PCI_SUBSYS_VENDORID
424 {CONFIG_SYS_PCI_SUBSYS_VENDORID, PCI_ANY_ID, PCI_CLASS_BRIDGE_HOST,
wdenkc6097192002-11-03 00:24:07 +0000425 PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, pci_405gp_setup_bridge},
426#endif
427 {PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA,
428 PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, pci_405gp_setup_vga},
429
430 {PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_NOT_DEFINED_VGA,
431 PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, pci_405gp_setup_vga},
432
433 { }
434};
435
436static struct pci_controller hose = {
437 fixup_irq: pci_405gp_fixup_irq,
438 config_table: pci_405gp_config_table,
439};
440
stroesead10dd92003-02-14 11:21:23 +0000441void pci_init_board(void)
wdenkc6097192002-11-03 00:24:07 +0000442{
443 /*we want the ptrs to RAM not flash (ie don't use init list)*/
444 hose.fixup_irq = pci_405gp_fixup_irq;
445 hose.config_table = pci_405gp_config_table;
446 pci_405gp_init(&hose);
447}
448
449#endif
450
wdenkc6097192002-11-03 00:24:07 +0000451#endif /* CONFIG_405GP */
452
453/*-----------------------------------------------------------------------------+
454 * CONFIG_440
455 *-----------------------------------------------------------------------------*/
Matthias Fuchs5a1c9ff2007-06-24 17:23:41 +0200456#if defined(CONFIG_440)
wdenkc6097192002-11-03 00:24:07 +0000457
Stefan Roesedb643772010-05-21 15:06:19 +0200458#if defined(CONFIG_SYS_PCI_MASTER_INIT) || defined(CONFIG_SYS_PCI_TARGET_INIT)
wdenkc6097192002-11-03 00:24:07 +0000459static struct pci_controller ppc440_hose = {0};
Stefan Roesedb643772010-05-21 15:06:19 +0200460#endif
wdenkc6097192002-11-03 00:24:07 +0000461
Stefan Roese9a81c612009-10-29 16:54:52 +0100462/*
463 * This routine is called to determine if a pci scan should be
464 * performed. With various hardware environments (especially cPCI and
465 * PPMC) it's insufficient to depend on the state of the arbiter enable
466 * bit in the strap register, or generic host/adapter assumptions.
467 *
468 * Rather than hard-code a bad assumption in the general 440 code, the
469 * 440 pci code requires the board to decide at runtime.
470 *
471 * Return 0 for adapter mode, non-zero for host (monarch) mode.
472 *
473 * Weak default implementation: "Normal" boards implement the PCI
474 * host functionality. This can be overridden for PCI adapter boards.
475 */
476int __is_pci_host(struct pci_controller *hose)
477{
478 return 1;
479}
480int is_pci_host(struct pci_controller *hose)
481 __attribute__((weak, alias("__is_pci_host")));
wdenkc6097192002-11-03 00:24:07 +0000482
Stefan Roese10954932009-11-12 12:00:49 +0100483#if defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
484 defined(CONFIG_440GR) || defined(CONFIG_440GRX)
Stefan Roesea760b022009-11-12 16:41:09 +0100485
486#if defined(CONFIG_SYS_PCI_TARGET_INIT)
487/*
488 * pci_target_init
489 *
490 * The bootstrap configuration provides default settings for the pci
491 * inbound map (PIM). But the bootstrap config choices are limited and
492 * may not be sufficient for a given board.
493 */
Stefan Roese10954932009-11-12 12:00:49 +0100494void __pci_target_init(struct pci_controller *hose)
495{
496 /*
497 * Set up Direct MMIO registers
498 */
499
500 /*
501 * PowerPC440 EP PCI Master configuration.
502 * Map one 1Gig range of PLB/processor addresses to PCI memory space.
503 * PLB address 0xA0000000-0xDFFFFFFF ==> PCI address 0xA0000000-0xDFFFFFFF
504 * Use byte reversed out routines to handle endianess.
505 * Make this region non-prefetchable.
506 */
507 /* PMM0 Mask/Attribute - disabled b4 setting */
508 out_le32((void *)PCIL0_PMM0MA, 0x00000000);
509 /* PMM0 Local Address */
510 out_le32((void *)PCIL0_PMM0LA, CONFIG_SYS_PCI_MEMBASE);
511 /* PMM0 PCI Low Address */
512 out_le32((void *)PCIL0_PMM0PCILA, CONFIG_SYS_PCI_MEMBASE);
513 /* PMM0 PCI High Address */
514 out_le32((void *)PCIL0_PMM0PCIHA, 0x00000000);
515 /* 512M + No prefetching, and enable region */
516 out_le32((void *)PCIL0_PMM0MA, 0xE0000001);
517
518 /* PMM1 Mask/Attribute - disabled b4 setting */
519 out_le32((void *)PCIL0_PMM1MA, 0x00000000);
520 /* PMM1 Local Address */
521 out_le32((void *)PCIL0_PMM1LA, CONFIG_SYS_PCI_MEMBASE2);
522 /* PMM1 PCI Low Address */
523 out_le32((void *)PCIL0_PMM1PCILA, CONFIG_SYS_PCI_MEMBASE2);
524 /* PMM1 PCI High Address */
525 out_le32((void *)PCIL0_PMM1PCIHA, 0x00000000);
526 /* 512M + No prefetching, and enable region */
527 out_le32((void *)PCIL0_PMM1MA, 0xE0000001);
528
529 out_le32((void *)PCIL0_PTM1MS, 0x00000001); /* Memory Size/Attribute */
530 out_le32((void *)PCIL0_PTM1LA, 0); /* Local Addr. Reg */
531 out_le32((void *)PCIL0_PTM2MS, 0); /* Memory Size/Attribute */
532 out_le32((void *)PCIL0_PTM2LA, 0); /* Local Addr. Reg */
533
534 /*
535 * Set up Configuration registers
536 */
537
538 /* Program the board's subsystem id/vendor id */
539 pci_write_config_word(0, PCI_SUBSYSTEM_VENDOR_ID,
540 CONFIG_SYS_PCI_SUBSYS_VENDORID);
541 pci_write_config_word(0, PCI_SUBSYSTEM_ID, CONFIG_SYS_PCI_SUBSYS_ID);
542
543 /* Configure command register as bus master */
544 pci_write_config_word(0, PCI_COMMAND, PCI_COMMAND_MASTER);
545
546 /* 240nS PCI clock */
547 pci_write_config_word(0, PCI_LATENCY_TIMER, 1);
548
549 /* No error reporting */
550 pci_write_config_word(0, PCI_ERREN, 0);
551
552 pci_write_config_dword(0, PCI_BRDGOPT2, 0x00000101);
553}
Stefan Roesea760b022009-11-12 16:41:09 +0100554#endif /* CONFIG_SYS_PCI_TARGET_INIT */
555
556/*
557 * pci_pre_init
558 *
559 * This routine is called just prior to registering the hose and gives
560 * the board the opportunity to check things. Returning a value of zero
561 * indicates that things are bad & PCI initialization should be aborted.
562 *
563 * Different boards may wish to customize the pci controller structure
564 * (add regions, override default access routines, etc) or perform
565 * certain pre-initialization actions.
566 *
567 */
568int __pci_pre_init(struct pci_controller *hose)
569{
570 u32 reg;
571
572 /*
573 * Set priority for all PLB3 devices to 0.
574 * Set PLB3 arbiter to fair mode.
575 */
Stefan Roese5e7abce2010-09-11 09:31:43 +0200576 mfsdr(SDR0_AMP1, reg);
577 mtsdr(SDR0_AMP1, (reg & 0x000000FF) | 0x0000FF00);
578 reg = mfdcr(PLB3A0_ACR);
579 mtdcr(PLB3A0_ACR, reg | 0x80000000);
Stefan Roesea760b022009-11-12 16:41:09 +0100580
581 /*
582 * Set priority for all PLB4 devices to 0.
583 */
Stefan Roese5e7abce2010-09-11 09:31:43 +0200584 mfsdr(SDR0_AMP0, reg);
585 mtsdr(SDR0_AMP0, (reg & 0x000000FF) | 0x0000FF00);
586 reg = mfdcr(PLB4A0_ACR) | 0xa0000000;
587 mtdcr(PLB4A0_ACR, reg);
Stefan Roesea760b022009-11-12 16:41:09 +0100588
589 /*
590 * Set Nebula PLB4 arbiter to fair mode.
591 */
592 /* Segment0 */
Stefan Roese5e7abce2010-09-11 09:31:43 +0200593 reg = (mfdcr(PLB4A0_ACR) & ~PLB4Ax_ACR_PPM_MASK) | PLB4Ax_ACR_PPM_FAIR;
594 reg = (reg & ~PLB4Ax_ACR_HBU_MASK) | PLB4Ax_ACR_HBU_ENABLED;
595 reg = (reg & ~PLB4Ax_ACR_RDP_MASK) | PLB4Ax_ACR_RDP_4DEEP;
596 reg = (reg & ~PLB4Ax_ACR_WRP_MASK) | PLB4Ax_ACR_WRP_2DEEP;
597 mtdcr(PLB4A0_ACR, reg);
Stefan Roesea760b022009-11-12 16:41:09 +0100598
599 /* Segment1 */
Stefan Roese5e7abce2010-09-11 09:31:43 +0200600 reg = (mfdcr(PLB4A1_ACR) & ~PLB4Ax_ACR_PPM_MASK) | PLB4Ax_ACR_PPM_FAIR;
601 reg = (reg & ~PLB4Ax_ACR_HBU_MASK) | PLB4Ax_ACR_HBU_ENABLED;
602 reg = (reg & ~PLB4Ax_ACR_RDP_MASK) | PLB4Ax_ACR_RDP_4DEEP;
603 reg = (reg & ~PLB4Ax_ACR_WRP_MASK) | PLB4Ax_ACR_WRP_2DEEP;
604 mtdcr(PLB4A1_ACR, reg);
Stefan Roesea760b022009-11-12 16:41:09 +0100605
606#if defined(CONFIG_SYS_PCI_BOARD_FIXUP_IRQ)
607 hose->fixup_irq = board_pci_fixup_irq;
608#endif
609
610 return 1;
611}
612
Stefan Roese10954932009-11-12 12:00:49 +0100613#else /* defined(CONFIG_440EP) ... */
Stefan Roesea760b022009-11-12 16:41:09 +0100614
615#if defined(CONFIG_SYS_PCI_TARGET_INIT)
Stefan Roese10954932009-11-12 12:00:49 +0100616void __pci_target_init(struct pci_controller * hose)
617{
618 /*
619 * Disable everything
620 */
621 out_le32((void *)PCIL0_PIM0SA, 0); /* disable */
622 out_le32((void *)PCIL0_PIM1SA, 0); /* disable */
623 out_le32((void *)PCIL0_PIM2SA, 0); /* disable */
624 out_le32((void *)PCIL0_EROMBA, 0); /* disable expansion rom */
625
626 /*
627 * Map all of SDRAM to PCI address 0x0000_0000. Note that the 440
628 * strapping options do not support sizes such as 128/256 MB.
629 */
630 out_le32((void *)PCIL0_PIM0LAL, CONFIG_SYS_SDRAM_BASE);
631 out_le32((void *)PCIL0_PIM0LAH, 0);
632 out_le32((void *)PCIL0_PIM0SA, ~(gd->ram_size - 1) | 1);
633 out_le32((void *)PCIL0_BAR0, 0);
634
635 /*
636 * Program the board's subsystem id/vendor id
637 */
638 out_le16((void *)PCIL0_SBSYSVID, CONFIG_SYS_PCI_SUBSYS_VENDORID);
639 out_le16((void *)PCIL0_SBSYSID, CONFIG_SYS_PCI_SUBSYS_DEVICEID);
640
641 out_le16((void *)PCIL0_CMD, in_le16((void *)PCIL0_CMD) |
642 PCI_COMMAND_MEMORY);
643}
Stefan Roesea760b022009-11-12 16:41:09 +0100644#endif /* CONFIG_SYS_PCI_TARGET_INIT */
645
646int __pci_pre_init(struct pci_controller *hose)
647{
648 /*
649 * This board is always configured as the host & requires the
650 * PCI arbiter to be enabled.
651 */
652 if (!pci_arbiter_enabled()) {
653 printf("PCI: PCI Arbiter disabled!\n");
654 return 0;
655 }
656
657 return 1;
658}
659
Stefan Roese10954932009-11-12 12:00:49 +0100660#endif /* defined(CONFIG_440EP) ... */
Stefan Roesea760b022009-11-12 16:41:09 +0100661
662#if defined(CONFIG_SYS_PCI_TARGET_INIT)
Stefan Roese10954932009-11-12 12:00:49 +0100663void pci_target_init(struct pci_controller * hose)
664 __attribute__((weak, alias("__pci_target_init")));
Stefan Roesea760b022009-11-12 16:41:09 +0100665#endif /* CONFIG_SYS_PCI_TARGET_INIT */
Stefan Roese10954932009-11-12 12:00:49 +0100666
Stefan Roesea760b022009-11-12 16:41:09 +0100667int pci_pre_init(struct pci_controller *hose)
668 __attribute__((weak, alias("__pci_pre_init")));
Stefan Roese10954932009-11-12 12:00:49 +0100669
Stefan Roese6c700492009-11-12 17:19:37 +0100670#if defined(CONFIG_SYS_PCI_MASTER_INIT)
671void __pci_master_init(struct pci_controller *hose)
672{
673 u16 reg;
674
675 /*
676 * Write the PowerPC440 EP PCI Configuration regs.
677 * Enable PowerPC440 EP to be a master on the PCI bus (PMM).
678 * Enable PowerPC440 EP to act as a PCI memory target (PTM).
679 */
680 pci_read_config_word(0, PCI_COMMAND, &reg);
681 pci_write_config_word(0, PCI_COMMAND, reg |
682 PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
683}
684void pci_master_init(struct pci_controller *hose)
685 __attribute__((weak, alias("__pci_master_init")));
686#endif /* CONFIG_SYS_PCI_MASTER_INIT */
687
Stefan Roesedb643772010-05-21 15:06:19 +0200688#if defined(CONFIG_SYS_PCI_MASTER_INIT) || defined(CONFIG_SYS_PCI_TARGET_INIT)
Wolfgang Denke5d5ed42011-10-29 09:38:31 +0000689static int pci_440_init (struct pci_controller *hose)
wdenkc6097192002-11-03 00:24:07 +0000690{
691 int reg_num = 0;
wdenkc6097192002-11-03 00:24:07 +0000692
Stefan Roese5568e612005-11-22 13:20:42 +0100693#ifndef CONFIG_DISABLE_PISE_TEST
wdenkc6097192002-11-03 00:24:07 +0000694 /*--------------------------------------------------------------------------+
695 * The PCI initialization sequence enable bit must be set ... if not abort
wdenk3c74e322004-02-22 23:46:08 +0000696 * pci setup since updating the bit requires chip reset.
wdenkc6097192002-11-03 00:24:07 +0000697 *--------------------------------------------------------------------------*/
Marian Balakowicz6c5879f2006-06-30 16:30:46 +0200698#if defined(CONFIG_440GX) || defined(CONFIG_440SP) || defined(CONFIG_440SPE)
Stefan Roese5568e612005-11-22 13:20:42 +0100699 unsigned long strap;
700
Stefan Roesed1c3b272009-09-09 16:25:29 +0200701 mfsdr(SDR0_SDSTP1,strap);
Stefan Roese6e7fb6e2005-11-29 18:18:21 +0100702 if ((strap & SDR0_SDSTP1_PISE_MASK) == 0) {
wdenk3c74e322004-02-22 23:46:08 +0000703 printf("PCI: SDR0_STRP1[PISE] not set.\n");
704 printf("PCI: Configuration aborted.\n");
Grzegorz Bernacki7f191392007-09-07 18:20:23 +0200705 return -1;
wdenk3c74e322004-02-22 23:46:08 +0000706 }
Stefan Roese5568e612005-11-22 13:20:42 +0100707#elif defined(CONFIG_440GP)
708 unsigned long strap;
709
Stefan Roesed1c3b272009-09-09 16:25:29 +0200710 strap = mfdcr(CPC0_STRP1);
Stefan Roese6e7fb6e2005-11-29 18:18:21 +0100711 if ((strap & CPC0_STRP1_PISE_MASK) == 0) {
wdenk3c74e322004-02-22 23:46:08 +0000712 printf("PCI: CPC0_STRP1[PISE] not set.\n");
713 printf("PCI: Configuration aborted.\n");
Grzegorz Bernacki7f191392007-09-07 18:20:23 +0200714 return -1;
wdenk3c74e322004-02-22 23:46:08 +0000715 }
716#endif
Stefan Roese5568e612005-11-22 13:20:42 +0100717#endif /* CONFIG_DISABLE_PISE_TEST */
718
wdenkc6097192002-11-03 00:24:07 +0000719 /*--------------------------------------------------------------------------+
720 * PCI controller init
721 *--------------------------------------------------------------------------*/
722 hose->first_busno = 0;
Grzegorz Bernacki7f191392007-09-07 18:20:23 +0200723 hose->last_busno = 0;
wdenkc6097192002-11-03 00:24:07 +0000724
Marian Balakowiczfbb0b552006-07-04 00:55:47 +0200725 /* PCI I/O space */
wdenkc6097192002-11-03 00:24:07 +0000726 pci_set_region(hose->regions + reg_num++,
727 0x00000000,
Niklaus Gigerddc922f2009-10-04 20:04:20 +0200728 PCIL0_IOBASE,
Stefan Roese6e7fb6e2005-11-29 18:18:21 +0100729 0x10000,
730 PCI_REGION_IO);
wdenkc6097192002-11-03 00:24:07 +0000731
Marian Balakowiczfbb0b552006-07-04 00:55:47 +0200732 /* PCI memory space */
wdenkc6097192002-11-03 00:24:07 +0000733 pci_set_region(hose->regions + reg_num++,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200734 CONFIG_SYS_PCI_TARGBASE,
735 CONFIG_SYS_PCI_MEMBASE,
736#ifdef CONFIG_SYS_PCI_MEMSIZE
737 CONFIG_SYS_PCI_MEMSIZE,
Stefan Roese899620c2006-08-15 14:22:35 +0200738#else
Stefan Roese6e7fb6e2005-11-29 18:18:21 +0100739 0x10000000,
Stefan Roese899620c2006-08-15 14:22:35 +0200740#endif
Stefan Roese6e7fb6e2005-11-29 18:18:21 +0100741 PCI_REGION_MEM );
Marian Balakowiczfbb0b552006-07-04 00:55:47 +0200742
743#if defined(CONFIG_PCI_SYS_MEM_BUS) && defined(CONFIG_PCI_SYS_MEM_PHYS) && \
744 defined(CONFIG_PCI_SYS_MEM_SIZE)
745 /* System memory space */
746 pci_set_region(hose->regions + reg_num++,
747 CONFIG_PCI_SYS_MEM_BUS,
748 CONFIG_PCI_SYS_MEM_PHYS,
749 CONFIG_PCI_SYS_MEM_SIZE,
Kumar Galaff4e66e2009-02-06 09:49:31 -0600750 PCI_REGION_MEM | PCI_REGION_SYS_MEMORY );
Marian Balakowiczfbb0b552006-07-04 00:55:47 +0200751#endif
752
wdenkc6097192002-11-03 00:24:07 +0000753 hose->region_count = reg_num;
754
Niklaus Gigerddc922f2009-10-04 20:04:20 +0200755 pci_setup_indirect(hose, PCIL0_CFGADR, PCIL0_CFGDATA);
wdenkc6097192002-11-03 00:24:07 +0000756
Stefan Roese6e7fb6e2005-11-29 18:18:21 +0100757 /* Let board change/modify hose & do initial checks */
Stefan Roesea760b022009-11-12 16:41:09 +0100758 if (pci_pre_init(hose) == 0) {
Stefan Roese6e7fb6e2005-11-29 18:18:21 +0100759 printf("PCI: Board-specific initialization failed.\n");
760 printf("PCI: Configuration aborted.\n");
Grzegorz Bernacki7f191392007-09-07 18:20:23 +0200761 return -1;
Stefan Roese6e7fb6e2005-11-29 18:18:21 +0100762 }
wdenkc6097192002-11-03 00:24:07 +0000763
764 pci_register_hose( hose );
765
766 /*--------------------------------------------------------------------------+
767 * PCI target init
768 *--------------------------------------------------------------------------*/
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200769#if defined(CONFIG_SYS_PCI_TARGET_INIT)
wdenkc6097192002-11-03 00:24:07 +0000770 pci_target_init(hose); /* Let board setup pci target */
771#else
Niklaus Gigerddc922f2009-10-04 20:04:20 +0200772 out16r( PCIL0_SBSYSVID, CONFIG_SYS_PCI_SUBSYS_VENDORID );
773 out16r( PCIL0_SBSYSID, CONFIG_SYS_PCI_SUBSYS_ID );
774 out16r( PCIL0_CLS, 0x00060000 ); /* Bridge, host bridge */
wdenkc6097192002-11-03 00:24:07 +0000775#endif
776
Stefan Roese8ac41e32008-03-11 15:05:26 +0100777#if defined(CONFIG_440GX) || defined(CONFIG_440SPE) || \
778 defined(CONFIG_460EX) || defined(CONFIG_460GT)
Niklaus Gigerddc922f2009-10-04 20:04:20 +0200779 out32r( PCIL0_BRDGOPT1, 0x04000060 ); /* PLB Rq pri highest */
780 out32r( PCIL0_BRDGOPT2, in32(PCIL0_BRDGOPT2) | 0x83 ); /* Enable host config, clear Timeout, ensure int src1 */
781#elif defined(PCIL0_BRDGOPT1)
782 out32r( PCIL0_BRDGOPT1, 0x10000060 ); /* PLB Rq pri highest */
783 out32r( PCIL0_BRDGOPT2, in32(PCIL0_BRDGOPT2) | 1 ); /* Enable host config */
wdenk3c74e322004-02-22 23:46:08 +0000784#endif
wdenkc6097192002-11-03 00:24:07 +0000785
786 /*--------------------------------------------------------------------------+
787 * PCI master init: default is one 256MB region for PCI memory:
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200788 * 0x3_00000000 - 0x3_0FFFFFFF ==> CONFIG_SYS_PCI_MEMBASE
wdenkc6097192002-11-03 00:24:07 +0000789 *--------------------------------------------------------------------------*/
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200790#if defined(CONFIG_SYS_PCI_MASTER_INIT)
wdenkc6097192002-11-03 00:24:07 +0000791 pci_master_init(hose); /* Let board setup pci master */
792#else
Niklaus Gigerddc922f2009-10-04 20:04:20 +0200793 out32r( PCIL0_POM0SA, 0 ); /* disable */
794 out32r( PCIL0_POM1SA, 0 ); /* disable */
795 out32r( PCIL0_POM2SA, 0 ); /* disable */
Anatolij Gustschinf8853d12009-03-20 12:45:50 +0100796#if defined(CONFIG_440SPE)
Niklaus Gigerddc922f2009-10-04 20:04:20 +0200797 out32r( PCIL0_POM0LAL, 0x10000000 );
798 out32r( PCIL0_POM0LAH, 0x0000000c );
Anatolij Gustschinf8853d12009-03-20 12:45:50 +0100799#elif defined(CONFIG_460EX) || defined(CONFIG_460GT)
Niklaus Gigerddc922f2009-10-04 20:04:20 +0200800 out32r( PCIL0_POM0LAL, 0x20000000 );
801 out32r( PCIL0_POM0LAH, 0x0000000c );
Marian Balakowicz6c5879f2006-06-30 16:30:46 +0200802#else
Niklaus Gigerddc922f2009-10-04 20:04:20 +0200803 out32r( PCIL0_POM0LAL, 0x00000000 );
804 out32r( PCIL0_POM0LAH, 0x00000003 );
Marian Balakowicz6c5879f2006-06-30 16:30:46 +0200805#endif
Niklaus Gigerddc922f2009-10-04 20:04:20 +0200806 out32r( PCIL0_POM0PCIAL, CONFIG_SYS_PCI_MEMBASE );
807 out32r( PCIL0_POM0PCIAH, 0x00000000 );
808 out32r( PCIL0_POM0SA, 0xf0000001 ); /* 256MB, enabled */
809 out32r( PCIL0_STS, in32r( PCIL0_STS ) & ~0x0000fff8 );
wdenkc6097192002-11-03 00:24:07 +0000810#endif
811
812 /*--------------------------------------------------------------------------+
813 * PCI host configuration -- we don't make any assumptions here ... the
Stefan Roese6e7fb6e2005-11-29 18:18:21 +0100814 * _board_must_indicate_ what to do -- there's just too many runtime
815 * scenarios in environments like cPCI, PPMC, etc. to make a determination
816 * based on hard-coded values or state of arbiter enable.
wdenkc6097192002-11-03 00:24:07 +0000817 *--------------------------------------------------------------------------*/
Stefan Roese6e7fb6e2005-11-29 18:18:21 +0100818 if (is_pci_host(hose)) {
wdenkc6097192002-11-03 00:24:07 +0000819#ifdef CONFIG_PCI_SCAN_SHOW
Stefan Roese6e7fb6e2005-11-29 18:18:21 +0100820 printf("PCI: Bus Dev VenId DevId Class Int\n");
wdenkc6097192002-11-03 00:24:07 +0000821#endif
Stefan Roese887e2ec2006-09-07 11:51:23 +0200822#if !defined(CONFIG_440EP) && !defined(CONFIG_440GR) && \
823 !defined(CONFIG_440EPX) && !defined(CONFIG_440GRX)
Niklaus Gigerddc922f2009-10-04 20:04:20 +0200824 out16r( PCIL0_CMD, in16r( PCIL0_CMD ) | PCI_COMMAND_MASTER);
Stefan Roesec157d8e2005-08-01 16:41:48 +0200825#endif
Stefan Roese6e7fb6e2005-11-29 18:18:21 +0100826 hose->last_busno = pci_hose_scan(hose);
827 }
Grzegorz Bernacki7f191392007-09-07 18:20:23 +0200828 return hose->last_busno;
wdenkc6097192002-11-03 00:24:07 +0000829}
Stefan Roesedb643772010-05-21 15:06:19 +0200830#endif
wdenkc6097192002-11-03 00:24:07 +0000831
stroesead10dd92003-02-14 11:21:23 +0000832void pci_init_board(void)
wdenkc6097192002-11-03 00:24:07 +0000833{
Stefan Roesedb643772010-05-21 15:06:19 +0200834 int busno = 0;
Grzegorz Bernacki7f191392007-09-07 18:20:23 +0200835
Stefan Roesedb643772010-05-21 15:06:19 +0200836 /*
837 * Only init PCI when either master or target functionality
838 * is selected.
839 */
840#if defined(CONFIG_SYS_PCI_MASTER_INIT) || defined(CONFIG_SYS_PCI_TARGET_INIT)
Wolfgang Denke5d5ed42011-10-29 09:38:31 +0000841 busno = pci_440_init(&ppc440_hose);
842 if (busno < 0)
843 return;
Stefan Roesedb643772010-05-21 15:06:19 +0200844#endif
Dirk Eibach59d1bda2009-02-03 15:15:21 +0100845#if (defined(CONFIG_440SPE) || \
846 defined(CONFIG_460EX) || defined(CONFIG_460GT)) && \
847 !defined(CONFIG_PCI_DISABLE_PCIE)
Grzegorz Bernacki7f191392007-09-07 18:20:23 +0200848 pcie_setup_hoses(busno + 1);
Rafal Jaworowski692519b2006-08-10 12:43:17 +0200849#endif
wdenkc6097192002-11-03 00:24:07 +0000850}
851
Matthias Fuchs5a1c9ff2007-06-24 17:23:41 +0200852#endif /* CONFIG_440 */
Stefan Roese1d7b8742007-10-05 17:09:36 +0200853
854#if defined(CONFIG_405EX)
855void pci_init_board(void)
856{
857#ifdef CONFIG_PCI_SCAN_SHOW
858 printf("PCI: Bus Dev VenId DevId Class Int\n");
859#endif
860 pcie_setup_hoses(0);
861}
862#endif /* CONFIG_405EX */
863
Matthias Fuchs5a1c9ff2007-06-24 17:23:41 +0200864#endif /* CONFIG_PCI */