blob: 0227a72ae989c1722b82688fcf2e7f1534999a3c [file] [log] [blame]
Wolfgang Denk52744b42013-07-28 22:12:45 +02001/*
Wolfgang Denk815c9672013-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 Denka1be4762008-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 Roeseca8725f2007-10-03 15:01:02 +020055#include <asm/4xx_pci.h>
wdenkc6097192002-11-03 00:24:07 +000056#include <asm/processor.h>
Stefan Roese8e538be2009-11-12 12:00:49 +010057#include <asm/io.h>
wdenkc6097192002-11-03 00:24:07 +000058#include <pci.h>
Simon Glass76135792017-05-17 08:23:05 -060059#include <asm/ppc4xx.h>
wdenkc6097192002-11-03 00:24:07 +000060
Matthias Fuchs0d364e42007-06-24 17:23:41 +020061#ifdef CONFIG_PCI
62
Wolfgang Denk6405a152006-03-31 18:32:53 +020063DECLARE_GLOBAL_DATA_PTR;
64
Stefan Roese5d8033e2009-11-12 16:41:09 +010065#if defined(CONFIG_405GP) || defined(CONFIG_405EP)
66
Stefan Roese5d8033e2009-11-12 16:41:09 +010067/*#define DEBUG*/
68
Matthias Fuchs0d364e42007-06-24 17:23:41 +020069/*
70 * Board-specific pci initialization
71 * Platform code can reimplement pci_pre_init() if needed
72 */
73int __pci_pre_init(struct pci_controller *hose)
74{
Stefan Roese5d8033e2009-11-12 16:41:09 +010075#if defined(CONFIG_405EP)
Matthias Fuchs5b499832009-07-08 13:43:55 +020076 /*
77 * Enable the internal PCI arbiter by default.
78 *
79 * On 405EP CPUs the internal arbiter can be controlled
80 * by the I2C strapping EEPROM. If you want to do so
81 * or if you want to disable the arbiter pci_pre_init()
82 * must be reimplemented without enabling the arbiter.
83 * The arbiter is enabled in this place because of
84 * compatibility reasons.
85 */
Stefan Roese918010a2009-09-09 16:25:29 +020086 mtdcr(CPC0_PCI, mfdcr(CPC0_PCI) | CPC0_PCI_ARBIT_EN);
Matthias Fuchs5b499832009-07-08 13:43:55 +020087#endif /* CONFIG_405EP */
88
Matthias Fuchs0d364e42007-06-24 17:23:41 +020089 return 1;
90}
Stefan Roese5d8033e2009-11-12 16:41:09 +010091int pci_pre_init(struct pci_controller *hose)
92 __attribute__((weak, alias("__pci_pre_init")));
wdenkc6097192002-11-03 00:24:07 +000093
Matthias Fuchs2d52e712009-07-03 16:06:06 +020094int __is_pci_host(struct pci_controller *hose)
95{
96#if defined(CONFIG_405GP)
Stefan Roese918010a2009-09-09 16:25:29 +020097 if (mfdcr(CPC0_PSR) & PSR_PCI_ARBIT_EN)
Matthias Fuchs2d52e712009-07-03 16:06:06 +020098 return 1;
99#elif defined (CONFIG_405EP)
Stefan Roese918010a2009-09-09 16:25:29 +0200100 if (mfdcr(CPC0_PCI) & CPC0_PCI_ARBIT_EN)
Matthias Fuchs2d52e712009-07-03 16:06:06 +0200101 return 1;
102#endif
103 return 0;
104}
105int is_pci_host(struct pci_controller *hose) __attribute__((weak, alias("__is_pci_host")));
106
wdenkc6097192002-11-03 00:24:07 +0000107/*-----------------------------------------------------------------------------+
108 * pci_init. Initializes the 405GP PCI Configuration regs.
109 *-----------------------------------------------------------------------------*/
110void pci_405gp_init(struct pci_controller *hose)
111{
wdenkc6097192002-11-03 00:24:07 +0000112 int i, reg_num = 0;
113 bd_t *bd = gd->bd;
114
115 unsigned short temp_short;
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200116 unsigned long ptmpcila[2] = {CONFIG_SYS_PCI_PTM1PCI, CONFIG_SYS_PCI_PTM2PCI};
Matthias Fuchse9a57662009-09-07 17:00:40 +0200117#if defined(CONFIG_PCI_4xx_PTM_OVERWRITE)
stroesec4b78982005-04-20 06:52:40 +0000118 char *ptmla_str, *ptmms_str;
Stefan Roese1c671a92006-01-18 20:03:15 +0100119#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200120 unsigned long ptmla[2] = {CONFIG_SYS_PCI_PTM1LA, CONFIG_SYS_PCI_PTM2LA};
121 unsigned long ptmms[2] = {CONFIG_SYS_PCI_PTM1MS, CONFIG_SYS_PCI_PTM2MS};
Tom Rini45ae6732016-09-19 21:55:34 -0400122#if defined(CONFIG_PIP405) || defined(CONFIG_TARGET_MIP405) \
123 || defined(CONFIG_TARGET_MIP405T)
wdenkc6097192002-11-03 00:24:07 +0000124 unsigned long pmmla[3] = {0x80000000, 0xA0000000, 0};
125 unsigned long pmmma[3] = {0xE0000001, 0xE0000001, 0};
126 unsigned long pmmpcila[3] = {0x80000000, 0x00000000, 0};
127 unsigned long pmmpciha[3] = {0x00000000, 0x00000000, 0};
128#else
129 unsigned long pmmla[3] = {0x80000000, 0,0};
130 unsigned long pmmma[3] = {0xC0000001, 0,0};
131 unsigned long pmmpcila[3] = {0x80000000, 0,0};
132 unsigned long pmmpciha[3] = {0x00000000, 0,0};
133#endif
stroesed7c1bbd2004-12-16 18:15:52 +0000134#ifdef CONFIG_PCI_PNP
135#if (CONFIG_PCI_HOST == PCI_HOST_AUTO)
136 char *s;
137#endif
138#endif
wdenkc6097192002-11-03 00:24:07 +0000139
Matthias Fuchse9a57662009-09-07 17:00:40 +0200140#if defined(CONFIG_PCI_4xx_PTM_OVERWRITE)
stroesec4b78982005-04-20 06:52:40 +0000141 ptmla_str = getenv("ptm1la");
142 ptmms_str = getenv("ptm1ms");
143 if(NULL != ptmla_str && NULL != ptmms_str ) {
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200144 ptmla[0] = simple_strtoul (ptmla_str, NULL, 16);
stroesec4b78982005-04-20 06:52:40 +0000145 ptmms[0] = simple_strtoul (ptmms_str, NULL, 16);
146 }
147
148 ptmla_str = getenv("ptm2la");
149 ptmms_str = getenv("ptm2ms");
150 if(NULL != ptmla_str && NULL != ptmms_str ) {
Wolfgang Denkec7fbf52013-10-04 17:43:24 +0200151 ptmla[1] = simple_strtoul (ptmla_str, NULL, 16);
stroesec4b78982005-04-20 06:52:40 +0000152 ptmms[1] = simple_strtoul (ptmms_str, NULL, 16);
153 }
154#endif
155
wdenkc6097192002-11-03 00:24:07 +0000156 /*
157 * Register the hose
158 */
159 hose->first_busno = 0;
160 hose->last_busno = 0xff;
161
162 /* ISA/PCI I/O space */
163 pci_set_region(hose->regions + reg_num++,
164 MIN_PCI_PCI_IOADDR,
165 MIN_PLB_PCI_IOADDR,
166 0x10000,
167 PCI_REGION_IO);
168
169 /* PCI I/O space */
170 pci_set_region(hose->regions + reg_num++,
171 0x00800000,
172 0xe8800000,
173 0x03800000,
174 PCI_REGION_IO);
175
176 reg_num = 2;
177
178 /* Memory spaces */
179 for (i=0; i<2; i++)
180 if (ptmms[i] & 1)
181 {
182 if (!i) hose->pci_fb = hose->regions + reg_num;
183
184 pci_set_region(hose->regions + reg_num++,
185 ptmpcila[i], ptmla[i],
186 ~(ptmms[i] & 0xfffff000) + 1,
187 PCI_REGION_MEM |
Kumar Galaefa1f1d2009-02-06 09:49:31 -0600188 PCI_REGION_SYS_MEMORY);
wdenkc6097192002-11-03 00:24:07 +0000189 }
190
191 /* PCI memory spaces */
192 for (i=0; i<3; i++)
193 if (pmmma[i] & 1)
194 {
195 pci_set_region(hose->regions + reg_num++,
196 pmmpcila[i], pmmla[i],
197 ~(pmmma[i] & 0xfffff000) + 1,
198 PCI_REGION_MEM);
199 }
200
201 hose->region_count = reg_num;
202
203 pci_setup_indirect(hose,
204 PCICFGADR,
205 PCICFGDATA);
206
207 if (hose->pci_fb)
208 pciauto_region_init(hose->pci_fb);
209
Matthias Fuchs0d364e42007-06-24 17:23:41 +0200210 /* Let board change/modify hose & do initial checks */
Stefan Roese5d8033e2009-11-12 16:41:09 +0100211 if (pci_pre_init(hose) == 0) {
Matthias Fuchs0d364e42007-06-24 17:23:41 +0200212 printf("PCI: Board-specific initialization failed.\n");
213 printf("PCI: Configuration aborted.\n");
214 return;
215 }
216
wdenkc6097192002-11-03 00:24:07 +0000217 pci_register_hose(hose);
218
219 /*--------------------------------------------------------------------------+
220 * 405GP PCI Master configuration.
221 * Map one 512 MB range of PLB/processor addresses to PCI memory space.
222 * PLB address 0x80000000-0xBFFFFFFF ==> PCI address 0x80000000-0xBFFFFFFF
223 * Use byte reversed out routines to handle endianess.
224 *--------------------------------------------------------------------------*/
wdenke39c2842003-06-04 15:05:30 +0000225 out32r(PMM0MA, (pmmma[0]&~0x1)); /* disable, configure PMMxLA, PMMxPCILA first */
wdenkc6097192002-11-03 00:24:07 +0000226 out32r(PMM0LA, pmmla[0]);
227 out32r(PMM0PCILA, pmmpcila[0]);
228 out32r(PMM0PCIHA, pmmpciha[0]);
229 out32r(PMM0MA, pmmma[0]);
230
231 /*--------------------------------------------------------------------------+
232 * PMM1 is not used. Initialize them to zero.
233 *--------------------------------------------------------------------------*/
wdenke39c2842003-06-04 15:05:30 +0000234 out32r(PMM1MA, (pmmma[1]&~0x1));
wdenkc6097192002-11-03 00:24:07 +0000235 out32r(PMM1LA, pmmla[1]);
236 out32r(PMM1PCILA, pmmpcila[1]);
237 out32r(PMM1PCIHA, pmmpciha[1]);
238 out32r(PMM1MA, pmmma[1]);
239
240 /*--------------------------------------------------------------------------+
241 * PMM2 is not used. Initialize them to zero.
242 *--------------------------------------------------------------------------*/
wdenk57b2d802003-06-27 21:31:46 +0000243 out32r(PMM2MA, (pmmma[2]&~0x1));
wdenkc6097192002-11-03 00:24:07 +0000244 out32r(PMM2LA, pmmla[2]);
245 out32r(PMM2PCILA, pmmpcila[2]);
246 out32r(PMM2PCIHA, pmmpciha[2]);
247 out32r(PMM2MA, pmmma[2]);
248
249 /*--------------------------------------------------------------------------+
250 * 405GP PCI Target configuration. (PTM1)
251 * Note: PTM1MS is hardwire enabled but we set the enable bit anyway.
252 *--------------------------------------------------------------------------*/
253 out32r(PTM1LA, ptmla[0]); /* insert address */
254 out32r(PTM1MS, ptmms[0]); /* insert size, enable bit is 1 */
wdenk6fcda222003-10-22 09:00:28 +0000255 pci_write_config_dword(PCIDEVID_405GP, PCI_BASE_ADDRESS_1, ptmpcila[0]);
wdenkc6097192002-11-03 00:24:07 +0000256
257 /*--------------------------------------------------------------------------+
258 * 405GP PCI Target configuration. (PTM2)
259 *--------------------------------------------------------------------------*/
260 out32r(PTM2LA, ptmla[1]); /* insert address */
wdenk6fcda222003-10-22 09:00:28 +0000261 pci_write_config_dword(PCIDEVID_405GP, PCI_BASE_ADDRESS_2, ptmpcila[1]);
262
wdenkc6097192002-11-03 00:24:07 +0000263 if (ptmms[1] == 0)
264 {
265 out32r(PTM2MS, 0x00000001); /* set enable bit */
266 pci_write_config_dword(PCIDEVID_405GP, PCI_BASE_ADDRESS_2, 0x00000000);
267 out32r(PTM2MS, 0x00000000); /* disable */
268 }
269 else
270 {
271 out32r(PTM2MS, ptmms[1]); /* insert size, enable bit is 1 */
272 }
273
274 /*
275 * Insert Subsystem Vendor and Device ID
276 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200277 pci_write_config_word(PCIDEVID_405GP, PCI_SUBSYSTEM_VENDOR_ID, CONFIG_SYS_PCI_SUBSYS_VENDORID);
wdenkc6097192002-11-03 00:24:07 +0000278#ifdef CONFIG_CPCI405
Matthias Fuchs2d52e712009-07-03 16:06:06 +0200279 if (is_pci_host(hose))
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200280 pci_write_config_word(PCIDEVID_405GP, PCI_SUBSYSTEM_ID, CONFIG_SYS_PCI_SUBSYS_DEVICEID);
wdenkc6097192002-11-03 00:24:07 +0000281 else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200282 pci_write_config_word(PCIDEVID_405GP, PCI_SUBSYSTEM_ID, CONFIG_SYS_PCI_SUBSYS_DEVICEID2);
wdenkc6097192002-11-03 00:24:07 +0000283#else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200284 pci_write_config_word(PCIDEVID_405GP, PCI_SUBSYSTEM_ID, CONFIG_SYS_PCI_SUBSYS_DEVICEID);
wdenkc6097192002-11-03 00:24:07 +0000285#endif
286
287 /*
288 * Insert Class-code
289 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200290#ifdef CONFIG_SYS_PCI_CLASSCODE
291 pci_write_config_word(PCIDEVID_405GP, PCI_CLASS_SUB_CODE, CONFIG_SYS_PCI_CLASSCODE);
292#endif /* CONFIG_SYS_PCI_CLASSCODE */
wdenkc6097192002-11-03 00:24:07 +0000293
294 /*--------------------------------------------------------------------------+
Wolfgang Denkaf0501a2008-10-19 02:35:50 +0200295 * If PCI speed = 66MHz, set 66MHz capable bit.
wdenkc6097192002-11-03 00:24:07 +0000296 *--------------------------------------------------------------------------*/
297 if (bd->bi_pci_busfreq >= 66000000) {
298 pci_read_config_word(PCIDEVID_405GP, PCI_STATUS, &temp_short);
299 pci_write_config_word(PCIDEVID_405GP,PCI_STATUS,(temp_short|PCI_STATUS_66MHZ));
300 }
301
302#if (CONFIG_PCI_HOST != PCI_HOST_ADAPTER)
wdenk6fcda222003-10-22 09:00:28 +0000303#if (CONFIG_PCI_HOST == PCI_HOST_AUTO)
Matthias Fuchs2d52e712009-07-03 16:06:06 +0200304 if (is_pci_host(hose) ||
stroesed7c1bbd2004-12-16 18:15:52 +0000305 (((s = getenv("pciscan")) != NULL) && (strcmp(s, "yes") == 0)))
wdenkc6097192002-11-03 00:24:07 +0000306#endif
307 {
308 /*--------------------------------------------------------------------------+
309 * Write the 405GP PCI Configuration regs.
310 * Enable 405GP to be a master on the PCI bus (PMM).
311 * Enable 405GP to act as a PCI memory target (PTM).
312 *--------------------------------------------------------------------------*/
313 pci_read_config_word(PCIDEVID_405GP, PCI_COMMAND, &temp_short);
314 pci_write_config_word(PCIDEVID_405GP, PCI_COMMAND, temp_short |
315 PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
316 }
317#endif
318
Matthias Fuchsa5e80fe2009-07-08 15:31:57 +0200319#if defined(CONFIG_405EP)
320 /*
321 * on ppc405ep vendor/device id is not set
322 * The user manual says 0x1014 (IBM) / 0x0156 (405GP!)
323 * are the correct values.
324 */
325 pci_write_config_word(PCIDEVID_405GP, PCI_VENDOR_ID, PCI_VENDOR_ID_IBM);
326 pci_write_config_word(PCIDEVID_405GP,
327 PCI_DEVICE_ID, PCI_DEVICE_ID_IBM_405GP);
stroese79435e32003-09-12 08:52:09 +0000328#endif
329
wdenkc6097192002-11-03 00:24:07 +0000330 /*
331 * Set HCE bit (Host Configuration Enabled)
332 */
333 pci_read_config_word(PCIDEVID_405GP, PCIBRDGOPT2, &temp_short);
334 pci_write_config_word(PCIDEVID_405GP, PCIBRDGOPT2, (temp_short | 0x0001));
335
336#ifdef CONFIG_PCI_PNP
337 /*--------------------------------------------------------------------------+
338 * Scan the PCI bus and configure devices found.
339 *--------------------------------------------------------------------------*/
340#if (CONFIG_PCI_HOST == PCI_HOST_AUTO)
Matthias Fuchs2d52e712009-07-03 16:06:06 +0200341 if (is_pci_host(hose) ||
stroesed7c1bbd2004-12-16 18:15:52 +0000342 (((s = getenv("pciscan")) != NULL) && (strcmp(s, "yes") == 0)))
wdenkc6097192002-11-03 00:24:07 +0000343#endif
344 {
345#ifdef CONFIG_PCI_SCAN_SHOW
346 printf("PCI: Bus Dev VenId DevId Class Int\n");
347#endif
wdenkc6097192002-11-03 00:24:07 +0000348 hose->last_busno = pci_hose_scan(hose);
349 }
350#endif /* CONFIG_PCI_PNP */
351
352}
353
354/*
Marcel Ziswileraea68562007-12-30 03:30:46 +0100355 * drivers/pci/pci.c skips every host bridge but the 405GP since it could
wdenkc6097192002-11-03 00:24:07 +0000356 * be set as an Adapter.
357 *
358 * I (Andrew May) don't know what we should do here, but I don't want
359 * the auto setup of a PCI device disabling what is done pci_405gp_init
360 * as has happened before.
361 */
362void pci_405gp_setup_bridge(struct pci_controller *hose, pci_dev_t dev,
363 struct pci_config_table *entry)
364{
365#ifdef DEBUG
wdenk57b2d802003-06-27 21:31:46 +0000366 printf("405gp_setup_bridge\n");
wdenkc6097192002-11-03 00:24:07 +0000367#endif
368}
369
370/*
371 *
372 */
373
374void pci_405gp_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
375{
376 unsigned char int_line = 0xff;
377
378 /*
379 * Write pci interrupt line register (cpci405 specific)
380 */
381 switch (PCI_DEV(dev) & 0x03)
382 {
383 case 0:
384 int_line = 27 + 2;
385 break;
386 case 1:
387 int_line = 27 + 3;
388 break;
389 case 2:
390 int_line = 27 + 0;
391 break;
392 case 3:
393 int_line = 27 + 1;
394 break;
395 }
396
397 pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, int_line);
398}
399
400void pci_405gp_setup_vga(struct pci_controller *hose, pci_dev_t dev,
401 struct pci_config_table *entry)
402{
403 unsigned int cmdstat = 0;
404
Stefan Roesec6d58782006-03-13 09:43:01 +0100405 pciauto_setup_device(hose, dev, 6, hose->pci_mem, hose->pci_prefetch, hose->pci_io);
wdenkc6097192002-11-03 00:24:07 +0000406
407 /* always enable io space on vga boards */
408 pci_hose_read_config_dword(hose, dev, PCI_COMMAND, &cmdstat);
409 cmdstat |= PCI_COMMAND_IO;
410 pci_hose_write_config_dword(hose, dev, PCI_COMMAND, cmdstat);
411}
412
Tom Rini45ae6732016-09-19 21:55:34 -0400413#if !(defined(CONFIG_PIP405) || defined(CONFIG_TARGET_MIP405) \
414 || defined(CONFIG_TARGET_MIP405T))
wdenkc6097192002-11-03 00:24:07 +0000415
416/*
417 *As is these functs get called out of flash Not a horrible
418 *thing, but something to keep in mind. (no statics?)
419 */
420static struct pci_config_table pci_405gp_config_table[] = {
421/*if VendID is 0 it terminates the table search (ie Walnut)*/
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200422#ifdef CONFIG_SYS_PCI_SUBSYS_VENDORID
423 {CONFIG_SYS_PCI_SUBSYS_VENDORID, PCI_ANY_ID, PCI_CLASS_BRIDGE_HOST,
wdenkc6097192002-11-03 00:24:07 +0000424 PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, pci_405gp_setup_bridge},
425#endif
426 {PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA,
427 PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, pci_405gp_setup_vga},
428
429 {PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_NOT_DEFINED_VGA,
430 PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, pci_405gp_setup_vga},
431
432 { }
433};
434
435static struct pci_controller hose = {
436 fixup_irq: pci_405gp_fixup_irq,
437 config_table: pci_405gp_config_table,
438};
439
stroesef5dd4102003-02-14 11:21:23 +0000440void pci_init_board(void)
wdenkc6097192002-11-03 00:24:07 +0000441{
442 /*we want the ptrs to RAM not flash (ie don't use init list)*/
443 hose.fixup_irq = pci_405gp_fixup_irq;
444 hose.config_table = pci_405gp_config_table;
445 pci_405gp_init(&hose);
446}
447
448#endif
449
wdenkc6097192002-11-03 00:24:07 +0000450#endif /* CONFIG_405GP */
451
452/*-----------------------------------------------------------------------------+
453 * CONFIG_440
454 *-----------------------------------------------------------------------------*/
Matthias Fuchs0d364e42007-06-24 17:23:41 +0200455#if defined(CONFIG_440)
wdenkc6097192002-11-03 00:24:07 +0000456
Stefan Roeseeb08f6d2010-05-21 15:06:19 +0200457#if defined(CONFIG_SYS_PCI_MASTER_INIT) || defined(CONFIG_SYS_PCI_TARGET_INIT)
wdenkc6097192002-11-03 00:24:07 +0000458static struct pci_controller ppc440_hose = {0};
Stefan Roeseeb08f6d2010-05-21 15:06:19 +0200459#endif
wdenkc6097192002-11-03 00:24:07 +0000460
Stefan Roese4698fc92009-10-29 16:54:52 +0100461/*
462 * This routine is called to determine if a pci scan should be
463 * performed. With various hardware environments (especially cPCI and
464 * PPMC) it's insufficient to depend on the state of the arbiter enable
465 * bit in the strap register, or generic host/adapter assumptions.
466 *
467 * Rather than hard-code a bad assumption in the general 440 code, the
468 * 440 pci code requires the board to decide at runtime.
469 *
470 * Return 0 for adapter mode, non-zero for host (monarch) mode.
471 *
472 * Weak default implementation: "Normal" boards implement the PCI
473 * host functionality. This can be overridden for PCI adapter boards.
474 */
475int __is_pci_host(struct pci_controller *hose)
476{
477 return 1;
478}
479int is_pci_host(struct pci_controller *hose)
480 __attribute__((weak, alias("__is_pci_host")));
wdenkc6097192002-11-03 00:24:07 +0000481
Stefan Roese5d8033e2009-11-12 16:41:09 +0100482#if defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
483 defined(CONFIG_440GR) || defined(CONFIG_440GRX)
484
485#if defined(CONFIG_SYS_PCI_TARGET_INIT)
Stefan Roese8e538be2009-11-12 12:00:49 +0100486/*
Stefan Roese5d8033e2009-11-12 16:41:09 +0100487 * pci_target_init
Stefan Roese8e538be2009-11-12 12:00:49 +0100488 *
Stefan Roese5d8033e2009-11-12 16:41:09 +0100489 * The bootstrap configuration provides default settings for the pci
490 * inbound map (PIM). But the bootstrap config choices are limited and
491 * may not be sufficient for a given board.
Stefan Roese8e538be2009-11-12 12:00:49 +0100492 */
Stefan Roese8e538be2009-11-12 12:00:49 +0100493void __pci_target_init(struct pci_controller *hose)
494{
495 /*
496 * Set up Direct MMIO registers
497 */
498
499 /*
500 * PowerPC440 EP PCI Master configuration.
501 * Map one 1Gig range of PLB/processor addresses to PCI memory space.
502 * PLB address 0xA0000000-0xDFFFFFFF ==> PCI address 0xA0000000-0xDFFFFFFF
503 * Use byte reversed out routines to handle endianess.
504 * Make this region non-prefetchable.
505 */
506 /* PMM0 Mask/Attribute - disabled b4 setting */
507 out_le32((void *)PCIL0_PMM0MA, 0x00000000);
508 /* PMM0 Local Address */
509 out_le32((void *)PCIL0_PMM0LA, CONFIG_SYS_PCI_MEMBASE);
510 /* PMM0 PCI Low Address */
511 out_le32((void *)PCIL0_PMM0PCILA, CONFIG_SYS_PCI_MEMBASE);
512 /* PMM0 PCI High Address */
513 out_le32((void *)PCIL0_PMM0PCIHA, 0x00000000);
514 /* 512M + No prefetching, and enable region */
515 out_le32((void *)PCIL0_PMM0MA, 0xE0000001);
516
517 /* PMM1 Mask/Attribute - disabled b4 setting */
518 out_le32((void *)PCIL0_PMM1MA, 0x00000000);
519 /* PMM1 Local Address */
520 out_le32((void *)PCIL0_PMM1LA, CONFIG_SYS_PCI_MEMBASE2);
521 /* PMM1 PCI Low Address */
522 out_le32((void *)PCIL0_PMM1PCILA, CONFIG_SYS_PCI_MEMBASE2);
523 /* PMM1 PCI High Address */
524 out_le32((void *)PCIL0_PMM1PCIHA, 0x00000000);
525 /* 512M + No prefetching, and enable region */
526 out_le32((void *)PCIL0_PMM1MA, 0xE0000001);
527
528 out_le32((void *)PCIL0_PTM1MS, 0x00000001); /* Memory Size/Attribute */
529 out_le32((void *)PCIL0_PTM1LA, 0); /* Local Addr. Reg */
530 out_le32((void *)PCIL0_PTM2MS, 0); /* Memory Size/Attribute */
531 out_le32((void *)PCIL0_PTM2LA, 0); /* Local Addr. Reg */
532
533 /*
534 * Set up Configuration registers
535 */
536
537 /* Program the board's subsystem id/vendor id */
538 pci_write_config_word(0, PCI_SUBSYSTEM_VENDOR_ID,
539 CONFIG_SYS_PCI_SUBSYS_VENDORID);
540 pci_write_config_word(0, PCI_SUBSYSTEM_ID, CONFIG_SYS_PCI_SUBSYS_ID);
541
542 /* Configure command register as bus master */
543 pci_write_config_word(0, PCI_COMMAND, PCI_COMMAND_MASTER);
544
545 /* 240nS PCI clock */
546 pci_write_config_word(0, PCI_LATENCY_TIMER, 1);
547
548 /* No error reporting */
549 pci_write_config_word(0, PCI_ERREN, 0);
550
551 pci_write_config_dword(0, PCI_BRDGOPT2, 0x00000101);
552}
Stefan Roese5d8033e2009-11-12 16:41:09 +0100553#endif /* CONFIG_SYS_PCI_TARGET_INIT */
554
555/*
556 * pci_pre_init
557 *
558 * This routine is called just prior to registering the hose and gives
559 * the board the opportunity to check things. Returning a value of zero
560 * indicates that things are bad & PCI initialization should be aborted.
561 *
562 * Different boards may wish to customize the pci controller structure
563 * (add regions, override default access routines, etc) or perform
564 * certain pre-initialization actions.
565 *
566 */
567int __pci_pre_init(struct pci_controller *hose)
568{
569 u32 reg;
570
571 /*
572 * Set priority for all PLB3 devices to 0.
573 * Set PLB3 arbiter to fair mode.
574 */
Stefan Roese95ca5fa2010-09-11 09:31:43 +0200575 mfsdr(SDR0_AMP1, reg);
576 mtsdr(SDR0_AMP1, (reg & 0x000000FF) | 0x0000FF00);
577 reg = mfdcr(PLB3A0_ACR);
578 mtdcr(PLB3A0_ACR, reg | 0x80000000);
Stefan Roese5d8033e2009-11-12 16:41:09 +0100579
580 /*
581 * Set priority for all PLB4 devices to 0.
582 */
Stefan Roese95ca5fa2010-09-11 09:31:43 +0200583 mfsdr(SDR0_AMP0, reg);
584 mtsdr(SDR0_AMP0, (reg & 0x000000FF) | 0x0000FF00);
585 reg = mfdcr(PLB4A0_ACR) | 0xa0000000;
586 mtdcr(PLB4A0_ACR, reg);
Stefan Roese5d8033e2009-11-12 16:41:09 +0100587
588 /*
589 * Set Nebula PLB4 arbiter to fair mode.
590 */
591 /* Segment0 */
Stefan Roese95ca5fa2010-09-11 09:31:43 +0200592 reg = (mfdcr(PLB4A0_ACR) & ~PLB4Ax_ACR_PPM_MASK) | PLB4Ax_ACR_PPM_FAIR;
593 reg = (reg & ~PLB4Ax_ACR_HBU_MASK) | PLB4Ax_ACR_HBU_ENABLED;
594 reg = (reg & ~PLB4Ax_ACR_RDP_MASK) | PLB4Ax_ACR_RDP_4DEEP;
595 reg = (reg & ~PLB4Ax_ACR_WRP_MASK) | PLB4Ax_ACR_WRP_2DEEP;
596 mtdcr(PLB4A0_ACR, reg);
Stefan Roese5d8033e2009-11-12 16:41:09 +0100597
598 /* Segment1 */
Stefan Roese95ca5fa2010-09-11 09:31:43 +0200599 reg = (mfdcr(PLB4A1_ACR) & ~PLB4Ax_ACR_PPM_MASK) | PLB4Ax_ACR_PPM_FAIR;
600 reg = (reg & ~PLB4Ax_ACR_HBU_MASK) | PLB4Ax_ACR_HBU_ENABLED;
601 reg = (reg & ~PLB4Ax_ACR_RDP_MASK) | PLB4Ax_ACR_RDP_4DEEP;
602 reg = (reg & ~PLB4Ax_ACR_WRP_MASK) | PLB4Ax_ACR_WRP_2DEEP;
603 mtdcr(PLB4A1_ACR, reg);
Stefan Roese5d8033e2009-11-12 16:41:09 +0100604
605#if defined(CONFIG_SYS_PCI_BOARD_FIXUP_IRQ)
606 hose->fixup_irq = board_pci_fixup_irq;
607#endif
608
609 return 1;
610}
611
Stefan Roese8e538be2009-11-12 12:00:49 +0100612#else /* defined(CONFIG_440EP) ... */
Stefan Roese5d8033e2009-11-12 16:41:09 +0100613
614#if defined(CONFIG_SYS_PCI_TARGET_INIT)
Stefan Roese8e538be2009-11-12 12:00:49 +0100615void __pci_target_init(struct pci_controller * hose)
616{
617 /*
618 * Disable everything
619 */
620 out_le32((void *)PCIL0_PIM0SA, 0); /* disable */
621 out_le32((void *)PCIL0_PIM1SA, 0); /* disable */
622 out_le32((void *)PCIL0_PIM2SA, 0); /* disable */
623 out_le32((void *)PCIL0_EROMBA, 0); /* disable expansion rom */
624
625 /*
626 * Map all of SDRAM to PCI address 0x0000_0000. Note that the 440
627 * strapping options do not support sizes such as 128/256 MB.
628 */
629 out_le32((void *)PCIL0_PIM0LAL, CONFIG_SYS_SDRAM_BASE);
630 out_le32((void *)PCIL0_PIM0LAH, 0);
631 out_le32((void *)PCIL0_PIM0SA, ~(gd->ram_size - 1) | 1);
632 out_le32((void *)PCIL0_BAR0, 0);
633
634 /*
635 * Program the board's subsystem id/vendor id
636 */
637 out_le16((void *)PCIL0_SBSYSVID, CONFIG_SYS_PCI_SUBSYS_VENDORID);
638 out_le16((void *)PCIL0_SBSYSID, CONFIG_SYS_PCI_SUBSYS_DEVICEID);
639
640 out_le16((void *)PCIL0_CMD, in_le16((void *)PCIL0_CMD) |
641 PCI_COMMAND_MEMORY);
642}
Stefan Roese5d8033e2009-11-12 16:41:09 +0100643#endif /* CONFIG_SYS_PCI_TARGET_INIT */
644
645int __pci_pre_init(struct pci_controller *hose)
646{
647 /*
648 * This board is always configured as the host & requires the
649 * PCI arbiter to be enabled.
650 */
651 if (!pci_arbiter_enabled()) {
652 printf("PCI: PCI Arbiter disabled!\n");
653 return 0;
654 }
655
656 return 1;
657}
658
Stefan Roese8e538be2009-11-12 12:00:49 +0100659#endif /* defined(CONFIG_440EP) ... */
Stefan Roese5d8033e2009-11-12 16:41:09 +0100660
661#if defined(CONFIG_SYS_PCI_TARGET_INIT)
Stefan Roese8e538be2009-11-12 12:00:49 +0100662void pci_target_init(struct pci_controller * hose)
663 __attribute__((weak, alias("__pci_target_init")));
Stefan Roese5d8033e2009-11-12 16:41:09 +0100664#endif /* CONFIG_SYS_PCI_TARGET_INIT */
Stefan Roese8e538be2009-11-12 12:00:49 +0100665
Stefan Roese5d8033e2009-11-12 16:41:09 +0100666int pci_pre_init(struct pci_controller *hose)
667 __attribute__((weak, alias("__pci_pre_init")));
Stefan Roese8e538be2009-11-12 12:00:49 +0100668
Stefan Roese2ea8b712009-11-12 17:19:37 +0100669#if defined(CONFIG_SYS_PCI_MASTER_INIT)
670void __pci_master_init(struct pci_controller *hose)
671{
672 u16 reg;
673
674 /*
675 * Write the PowerPC440 EP PCI Configuration regs.
676 * Enable PowerPC440 EP to be a master on the PCI bus (PMM).
677 * Enable PowerPC440 EP to act as a PCI memory target (PTM).
678 */
679 pci_read_config_word(0, PCI_COMMAND, &reg);
680 pci_write_config_word(0, PCI_COMMAND, reg |
681 PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
682}
683void pci_master_init(struct pci_controller *hose)
684 __attribute__((weak, alias("__pci_master_init")));
685#endif /* CONFIG_SYS_PCI_MASTER_INIT */
686
Stefan Roeseeb08f6d2010-05-21 15:06:19 +0200687#if defined(CONFIG_SYS_PCI_MASTER_INIT) || defined(CONFIG_SYS_PCI_TARGET_INIT)
Wolfgang Denk96ea2b92011-10-29 09:38:31 +0000688static int pci_440_init (struct pci_controller *hose)
wdenkc6097192002-11-03 00:24:07 +0000689{
690 int reg_num = 0;
wdenkc6097192002-11-03 00:24:07 +0000691
Stefan Roesec443fe92005-11-22 13:20:42 +0100692#ifndef CONFIG_DISABLE_PISE_TEST
wdenkc6097192002-11-03 00:24:07 +0000693 /*--------------------------------------------------------------------------+
694 * The PCI initialization sequence enable bit must be set ... if not abort
wdenk56ed43e2004-02-22 23:46:08 +0000695 * pci setup since updating the bit requires chip reset.
wdenkc6097192002-11-03 00:24:07 +0000696 *--------------------------------------------------------------------------*/
Marian Balakowicz49d0eee2006-06-30 16:30:46 +0200697#if defined(CONFIG_440GX) || defined(CONFIG_440SP) || defined(CONFIG_440SPE)
Stefan Roesec443fe92005-11-22 13:20:42 +0100698 unsigned long strap;
699
Stefan Roese918010a2009-09-09 16:25:29 +0200700 mfsdr(SDR0_SDSTP1,strap);
Stefan Roese99644742005-11-29 18:18:21 +0100701 if ((strap & SDR0_SDSTP1_PISE_MASK) == 0) {
wdenk56ed43e2004-02-22 23:46:08 +0000702 printf("PCI: SDR0_STRP1[PISE] not set.\n");
703 printf("PCI: Configuration aborted.\n");
Grzegorz Bernackid2f21332007-09-07 18:20:23 +0200704 return -1;
wdenk56ed43e2004-02-22 23:46:08 +0000705 }
Stefan Roesec443fe92005-11-22 13:20:42 +0100706#elif defined(CONFIG_440GP)
707 unsigned long strap;
708
Stefan Roese918010a2009-09-09 16:25:29 +0200709 strap = mfdcr(CPC0_STRP1);
Stefan Roese99644742005-11-29 18:18:21 +0100710 if ((strap & CPC0_STRP1_PISE_MASK) == 0) {
wdenk56ed43e2004-02-22 23:46:08 +0000711 printf("PCI: CPC0_STRP1[PISE] not set.\n");
712 printf("PCI: Configuration aborted.\n");
Grzegorz Bernackid2f21332007-09-07 18:20:23 +0200713 return -1;
wdenk56ed43e2004-02-22 23:46:08 +0000714 }
715#endif
Stefan Roesec443fe92005-11-22 13:20:42 +0100716#endif /* CONFIG_DISABLE_PISE_TEST */
717
wdenkc6097192002-11-03 00:24:07 +0000718 /*--------------------------------------------------------------------------+
719 * PCI controller init
720 *--------------------------------------------------------------------------*/
721 hose->first_busno = 0;
Grzegorz Bernackid2f21332007-09-07 18:20:23 +0200722 hose->last_busno = 0;
wdenkc6097192002-11-03 00:24:07 +0000723
Marian Balakowicz9aa6d722006-07-04 00:55:47 +0200724 /* PCI I/O space */
wdenkc6097192002-11-03 00:24:07 +0000725 pci_set_region(hose->regions + reg_num++,
726 0x00000000,
Niklaus Giger728bd0a2009-10-04 20:04:20 +0200727 PCIL0_IOBASE,
Stefan Roese99644742005-11-29 18:18:21 +0100728 0x10000,
729 PCI_REGION_IO);
wdenkc6097192002-11-03 00:24:07 +0000730
Marian Balakowicz9aa6d722006-07-04 00:55:47 +0200731 /* PCI memory space */
wdenkc6097192002-11-03 00:24:07 +0000732 pci_set_region(hose->regions + reg_num++,
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200733 CONFIG_SYS_PCI_TARGBASE,
734 CONFIG_SYS_PCI_MEMBASE,
735#ifdef CONFIG_SYS_PCI_MEMSIZE
736 CONFIG_SYS_PCI_MEMSIZE,
Stefan Roese49639682006-08-15 14:22:35 +0200737#else
Stefan Roese99644742005-11-29 18:18:21 +0100738 0x10000000,
Stefan Roese49639682006-08-15 14:22:35 +0200739#endif
Stefan Roese99644742005-11-29 18:18:21 +0100740 PCI_REGION_MEM );
Marian Balakowicz9aa6d722006-07-04 00:55:47 +0200741
742#if defined(CONFIG_PCI_SYS_MEM_BUS) && defined(CONFIG_PCI_SYS_MEM_PHYS) && \
743 defined(CONFIG_PCI_SYS_MEM_SIZE)
744 /* System memory space */
745 pci_set_region(hose->regions + reg_num++,
746 CONFIG_PCI_SYS_MEM_BUS,
747 CONFIG_PCI_SYS_MEM_PHYS,
748 CONFIG_PCI_SYS_MEM_SIZE,
Kumar Galaefa1f1d2009-02-06 09:49:31 -0600749 PCI_REGION_MEM | PCI_REGION_SYS_MEMORY );
Marian Balakowicz9aa6d722006-07-04 00:55:47 +0200750#endif
751
wdenkc6097192002-11-03 00:24:07 +0000752 hose->region_count = reg_num;
753
Niklaus Giger728bd0a2009-10-04 20:04:20 +0200754 pci_setup_indirect(hose, PCIL0_CFGADR, PCIL0_CFGDATA);
wdenkc6097192002-11-03 00:24:07 +0000755
Stefan Roese99644742005-11-29 18:18:21 +0100756 /* Let board change/modify hose & do initial checks */
Stefan Roese5d8033e2009-11-12 16:41:09 +0100757 if (pci_pre_init(hose) == 0) {
Stefan Roese99644742005-11-29 18:18:21 +0100758 printf("PCI: Board-specific initialization failed.\n");
759 printf("PCI: Configuration aborted.\n");
Grzegorz Bernackid2f21332007-09-07 18:20:23 +0200760 return -1;
Stefan Roese99644742005-11-29 18:18:21 +0100761 }
wdenkc6097192002-11-03 00:24:07 +0000762
763 pci_register_hose( hose );
764
765 /*--------------------------------------------------------------------------+
766 * PCI target init
767 *--------------------------------------------------------------------------*/
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200768#if defined(CONFIG_SYS_PCI_TARGET_INIT)
wdenkc6097192002-11-03 00:24:07 +0000769 pci_target_init(hose); /* Let board setup pci target */
770#else
Niklaus Giger728bd0a2009-10-04 20:04:20 +0200771 out16r( PCIL0_SBSYSVID, CONFIG_SYS_PCI_SUBSYS_VENDORID );
772 out16r( PCIL0_SBSYSID, CONFIG_SYS_PCI_SUBSYS_ID );
773 out16r( PCIL0_CLS, 0x00060000 ); /* Bridge, host bridge */
wdenkc6097192002-11-03 00:24:07 +0000774#endif
775
Stefan Roesebdd13d12008-03-11 15:05:26 +0100776#if defined(CONFIG_440GX) || defined(CONFIG_440SPE) || \
777 defined(CONFIG_460EX) || defined(CONFIG_460GT)
Niklaus Giger728bd0a2009-10-04 20:04:20 +0200778 out32r( PCIL0_BRDGOPT1, 0x04000060 ); /* PLB Rq pri highest */
779 out32r( PCIL0_BRDGOPT2, in32(PCIL0_BRDGOPT2) | 0x83 ); /* Enable host config, clear Timeout, ensure int src1 */
780#elif defined(PCIL0_BRDGOPT1)
781 out32r( PCIL0_BRDGOPT1, 0x10000060 ); /* PLB Rq pri highest */
782 out32r( PCIL0_BRDGOPT2, in32(PCIL0_BRDGOPT2) | 1 ); /* Enable host config */
wdenk56ed43e2004-02-22 23:46:08 +0000783#endif
wdenkc6097192002-11-03 00:24:07 +0000784
785 /*--------------------------------------------------------------------------+
786 * PCI master init: default is one 256MB region for PCI memory:
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200787 * 0x3_00000000 - 0x3_0FFFFFFF ==> CONFIG_SYS_PCI_MEMBASE
wdenkc6097192002-11-03 00:24:07 +0000788 *--------------------------------------------------------------------------*/
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200789#if defined(CONFIG_SYS_PCI_MASTER_INIT)
wdenkc6097192002-11-03 00:24:07 +0000790 pci_master_init(hose); /* Let board setup pci master */
791#else
Niklaus Giger728bd0a2009-10-04 20:04:20 +0200792 out32r( PCIL0_POM0SA, 0 ); /* disable */
793 out32r( PCIL0_POM1SA, 0 ); /* disable */
794 out32r( PCIL0_POM2SA, 0 ); /* disable */
Anatolij Gustschin035796f2009-03-20 12:45:50 +0100795#if defined(CONFIG_440SPE)
Niklaus Giger728bd0a2009-10-04 20:04:20 +0200796 out32r( PCIL0_POM0LAL, 0x10000000 );
797 out32r( PCIL0_POM0LAH, 0x0000000c );
Anatolij Gustschin035796f2009-03-20 12:45:50 +0100798#elif defined(CONFIG_460EX) || defined(CONFIG_460GT)
Niklaus Giger728bd0a2009-10-04 20:04:20 +0200799 out32r( PCIL0_POM0LAL, 0x20000000 );
800 out32r( PCIL0_POM0LAH, 0x0000000c );
Marian Balakowicz49d0eee2006-06-30 16:30:46 +0200801#else
Niklaus Giger728bd0a2009-10-04 20:04:20 +0200802 out32r( PCIL0_POM0LAL, 0x00000000 );
803 out32r( PCIL0_POM0LAH, 0x00000003 );
Marian Balakowicz49d0eee2006-06-30 16:30:46 +0200804#endif
Niklaus Giger728bd0a2009-10-04 20:04:20 +0200805 out32r( PCIL0_POM0PCIAL, CONFIG_SYS_PCI_MEMBASE );
806 out32r( PCIL0_POM0PCIAH, 0x00000000 );
807 out32r( PCIL0_POM0SA, 0xf0000001 ); /* 256MB, enabled */
808 out32r( PCIL0_STS, in32r( PCIL0_STS ) & ~0x0000fff8 );
wdenkc6097192002-11-03 00:24:07 +0000809#endif
810
811 /*--------------------------------------------------------------------------+
812 * PCI host configuration -- we don't make any assumptions here ... the
Stefan Roese99644742005-11-29 18:18:21 +0100813 * _board_must_indicate_ what to do -- there's just too many runtime
814 * scenarios in environments like cPCI, PPMC, etc. to make a determination
815 * based on hard-coded values or state of arbiter enable.
wdenkc6097192002-11-03 00:24:07 +0000816 *--------------------------------------------------------------------------*/
Stefan Roese99644742005-11-29 18:18:21 +0100817 if (is_pci_host(hose)) {
wdenkc6097192002-11-03 00:24:07 +0000818#ifdef CONFIG_PCI_SCAN_SHOW
Stefan Roese99644742005-11-29 18:18:21 +0100819 printf("PCI: Bus Dev VenId DevId Class Int\n");
wdenkc6097192002-11-03 00:24:07 +0000820#endif
Stefan Roese42fbddd2006-09-07 11:51:23 +0200821#if !defined(CONFIG_440EP) && !defined(CONFIG_440GR) && \
822 !defined(CONFIG_440EPX) && !defined(CONFIG_440GRX)
Niklaus Giger728bd0a2009-10-04 20:04:20 +0200823 out16r( PCIL0_CMD, in16r( PCIL0_CMD ) | PCI_COMMAND_MASTER);
Stefan Roese326c9712005-08-01 16:41:48 +0200824#endif
Stefan Roese99644742005-11-29 18:18:21 +0100825 hose->last_busno = pci_hose_scan(hose);
826 }
Grzegorz Bernackid2f21332007-09-07 18:20:23 +0200827 return hose->last_busno;
wdenkc6097192002-11-03 00:24:07 +0000828}
Stefan Roeseeb08f6d2010-05-21 15:06:19 +0200829#endif
wdenkc6097192002-11-03 00:24:07 +0000830
stroesef5dd4102003-02-14 11:21:23 +0000831void pci_init_board(void)
wdenkc6097192002-11-03 00:24:07 +0000832{
Stefan Roeseeb08f6d2010-05-21 15:06:19 +0200833 int busno = 0;
Grzegorz Bernackid2f21332007-09-07 18:20:23 +0200834
Stefan Roeseeb08f6d2010-05-21 15:06:19 +0200835 /*
836 * Only init PCI when either master or target functionality
837 * is selected.
838 */
839#if defined(CONFIG_SYS_PCI_MASTER_INIT) || defined(CONFIG_SYS_PCI_TARGET_INIT)
Wolfgang Denk96ea2b92011-10-29 09:38:31 +0000840 busno = pci_440_init(&ppc440_hose);
841 if (busno < 0)
842 return;
Stefan Roeseeb08f6d2010-05-21 15:06:19 +0200843#endif
Dirk Eibach6bb88a02009-02-03 15:15:21 +0100844#if (defined(CONFIG_440SPE) || \
845 defined(CONFIG_460EX) || defined(CONFIG_460GT)) && \
846 !defined(CONFIG_PCI_DISABLE_PCIE)
Grzegorz Bernackid2f21332007-09-07 18:20:23 +0200847 pcie_setup_hoses(busno + 1);
Rafal Jaworowskia2e7ef02006-08-10 12:43:17 +0200848#endif
wdenkc6097192002-11-03 00:24:07 +0000849}
850
Matthias Fuchs0d364e42007-06-24 17:23:41 +0200851#endif /* CONFIG_440 */
Stefan Roese136681f2007-10-05 17:09:36 +0200852
853#if defined(CONFIG_405EX)
854void pci_init_board(void)
855{
856#ifdef CONFIG_PCI_SCAN_SHOW
857 printf("PCI: Bus Dev VenId DevId Class Int\n");
858#endif
859 pcie_setup_hoses(0);
860}
861#endif /* CONFIG_405EX */
862
Matthias Fuchs0d364e42007-06-24 17:23:41 +0200863#endif /* CONFIG_PCI */