blob: 6c925b7975f9c5b1848736af469c1c72585cf495 [file] [log] [blame]
Benjamin Herrenschmidt5738ec62007-12-21 15:39:22 +11001/*
2 * PCI / PCI-X / PCI-Express support for 4xx parts
3 *
4 * Copyright 2007 Ben. Herrenschmidt <benh@kernel.crashing.org>, IBM Corp.
5 *
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +11006 * Most PCI Express code is coming from Stefan Roese implementation for
7 * arch/ppc in the Denx tree, slightly reworked by me.
8 *
9 * Copyright 2007 DENX Software Engineering, Stefan Roese <sr@denx.de>
10 *
11 * Some of that comes itself from a previous implementation for 440SPE only
12 * by Roland Dreier:
13 *
14 * Copyright (c) 2005 Cisco Systems. All rights reserved.
15 * Roland Dreier <rolandd@cisco.com>
16 *
Benjamin Herrenschmidt5738ec62007-12-21 15:39:22 +110017 */
18
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +110019#undef DEBUG
20
Benjamin Herrenschmidt5738ec62007-12-21 15:39:22 +110021#include <linux/kernel.h>
22#include <linux/pci.h>
23#include <linux/init.h>
24#include <linux/of.h>
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +110025#include <linux/bootmem.h>
26#include <linux/delay.h>
Benjamin Herrenschmidt5738ec62007-12-21 15:39:22 +110027
28#include <asm/io.h>
29#include <asm/pci-bridge.h>
30#include <asm/machdep.h>
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +110031#include <asm/dcr.h>
32#include <asm/dcr-regs.h>
Benjamin Herrenschmidt5738ec62007-12-21 15:39:22 +110033
34#include "ppc4xx_pci.h"
35
36static int dma_offset_set;
37
38/* Move that to a useable header */
39extern unsigned long total_memory;
40
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +110041#define U64_TO_U32_LOW(val) ((u32)((val) & 0x00000000ffffffffULL))
42#define U64_TO_U32_HIGH(val) ((u32)((val) >> 32))
43
44#ifdef CONFIG_RESOURCES_64BIT
45#define RES_TO_U32_LOW(val) U64_TO_U32_LOW(val)
46#define RES_TO_U32_HIGH(val) U64_TO_U32_HIGH(val)
47#else
48#define RES_TO_U32_LOW(val) (val)
49#define RES_TO_U32_HIGH(val) (0)
50#endif
51
Stefan Roeseaccf5ef2007-12-21 15:39:38 +110052static inline int ppc440spe_revA(void)
53{
54 /* Catch both 440SPe variants, with and without RAID6 support */
55 if ((mfspr(SPRN_PVR) & 0xffefffff) == 0x53421890)
56 return 1;
57 else
58 return 0;
59}
60
Benjamin Herrenschmidtc839e0e2007-12-21 15:39:23 +110061static void fixup_ppc4xx_pci_bridge(struct pci_dev *dev)
62{
63 struct pci_controller *hose;
64 int i;
65
66 if (dev->devfn != 0 || dev->bus->self != NULL)
67 return;
68
69 hose = pci_bus_to_host(dev->bus);
70 if (hose == NULL)
71 return;
72
73 if (!of_device_is_compatible(hose->dn, "ibm,plb-pciex") &&
74 !of_device_is_compatible(hose->dn, "ibm,plb-pcix") &&
75 !of_device_is_compatible(hose->dn, "ibm,plb-pci"))
76 return;
77
78 /* Hide the PCI host BARs from the kernel as their content doesn't
79 * fit well in the resource management
80 */
81 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
82 dev->resource[i].start = dev->resource[i].end = 0;
83 dev->resource[i].flags = 0;
84 }
85
86 printk(KERN_INFO "PCI: Hiding 4xx host bridge resources %s\n",
87 pci_name(dev));
88}
89DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, fixup_ppc4xx_pci_bridge);
90
Benjamin Herrenschmidt5738ec62007-12-21 15:39:22 +110091static int __init ppc4xx_parse_dma_ranges(struct pci_controller *hose,
92 void __iomem *reg,
93 struct resource *res)
94{
95 u64 size;
96 const u32 *ranges;
97 int rlen;
98 int pna = of_n_addr_cells(hose->dn);
99 int np = pna + 5;
100
101 /* Default */
102 res->start = 0;
103 res->end = size = 0x80000000;
104 res->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
105
106 /* Get dma-ranges property */
107 ranges = of_get_property(hose->dn, "dma-ranges", &rlen);
108 if (ranges == NULL)
109 goto out;
110
111 /* Walk it */
112 while ((rlen -= np * 4) >= 0) {
113 u32 pci_space = ranges[0];
114 u64 pci_addr = of_read_number(ranges + 1, 2);
115 u64 cpu_addr = of_translate_dma_address(hose->dn, ranges + 3);
116 size = of_read_number(ranges + pna + 3, 2);
117 ranges += np;
118 if (cpu_addr == OF_BAD_ADDR || size == 0)
119 continue;
120
121 /* We only care about memory */
122 if ((pci_space & 0x03000000) != 0x02000000)
123 continue;
124
125 /* We currently only support memory at 0, and pci_addr
126 * within 32 bits space
127 */
128 if (cpu_addr != 0 || pci_addr > 0xffffffff) {
129 printk(KERN_WARNING "%s: Ignored unsupported dma range"
130 " 0x%016llx...0x%016llx -> 0x%016llx\n",
131 hose->dn->full_name,
132 pci_addr, pci_addr + size - 1, cpu_addr);
133 continue;
134 }
135
136 /* Check if not prefetchable */
137 if (!(pci_space & 0x40000000))
138 res->flags &= ~IORESOURCE_PREFETCH;
139
140
141 /* Use that */
142 res->start = pci_addr;
143#ifndef CONFIG_RESOURCES_64BIT
144 /* Beware of 32 bits resources */
145 if ((pci_addr + size) > 0x100000000ull)
146 res->end = 0xffffffff;
147 else
148#endif
149 res->end = res->start + size - 1;
150 break;
151 }
152
153 /* We only support one global DMA offset */
154 if (dma_offset_set && pci_dram_offset != res->start) {
155 printk(KERN_ERR "%s: dma-ranges(s) mismatch\n",
156 hose->dn->full_name);
157 return -ENXIO;
158 }
159
160 /* Check that we can fit all of memory as we don't support
161 * DMA bounce buffers
162 */
163 if (size < total_memory) {
164 printk(KERN_ERR "%s: dma-ranges too small "
165 "(size=%llx total_memory=%lx)\n",
166 hose->dn->full_name, size, total_memory);
167 return -ENXIO;
168 }
169
170 /* Check we are a power of 2 size and that base is a multiple of size*/
171 if (!is_power_of_2(size) ||
172 (res->start & (size - 1)) != 0) {
173 printk(KERN_ERR "%s: dma-ranges unaligned\n",
174 hose->dn->full_name);
175 return -ENXIO;
176 }
177
178 /* Check that we are fully contained within 32 bits space */
179 if (res->end > 0xffffffff) {
180 printk(KERN_ERR "%s: dma-ranges outside of 32 bits space\n",
181 hose->dn->full_name);
182 return -ENXIO;
183 }
184 out:
185 dma_offset_set = 1;
186 pci_dram_offset = res->start;
187
188 printk(KERN_INFO "4xx PCI DMA offset set to 0x%08lx\n",
189 pci_dram_offset);
190 return 0;
191}
192
193/*
194 * 4xx PCI 2.x part
195 */
Benjamin Herrenschmidtc839e0e2007-12-21 15:39:23 +1100196
197static void __init ppc4xx_configure_pci_PMMs(struct pci_controller *hose,
198 void __iomem *reg)
199{
200 u32 la, ma, pcila, pciha;
201 int i, j;
202
203 /* Setup outbound memory windows */
204 for (i = j = 0; i < 3; i++) {
205 struct resource *res = &hose->mem_resources[i];
206
207 /* we only care about memory windows */
208 if (!(res->flags & IORESOURCE_MEM))
209 continue;
210 if (j > 2) {
211 printk(KERN_WARNING "%s: Too many ranges\n",
212 hose->dn->full_name);
213 break;
214 }
215
216 /* Calculate register values */
217 la = res->start;
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100218 pciha = RES_TO_U32_HIGH(res->start - hose->pci_mem_offset);
219 pcila = RES_TO_U32_LOW(res->start - hose->pci_mem_offset);
Benjamin Herrenschmidtc839e0e2007-12-21 15:39:23 +1100220
221 ma = res->end + 1 - res->start;
222 if (!is_power_of_2(ma) || ma < 0x1000 || ma > 0xffffffffu) {
223 printk(KERN_WARNING "%s: Resource out of range\n",
224 hose->dn->full_name);
225 continue;
226 }
227 ma = (0xffffffffu << ilog2(ma)) | 0x1;
228 if (res->flags & IORESOURCE_PREFETCH)
229 ma |= 0x2;
230
231 /* Program register values */
232 writel(la, reg + PCIL0_PMM0LA + (0x10 * j));
233 writel(pcila, reg + PCIL0_PMM0PCILA + (0x10 * j));
234 writel(pciha, reg + PCIL0_PMM0PCIHA + (0x10 * j));
235 writel(ma, reg + PCIL0_PMM0MA + (0x10 * j));
236 j++;
237 }
238}
239
240static void __init ppc4xx_configure_pci_PTMs(struct pci_controller *hose,
241 void __iomem *reg,
242 const struct resource *res)
243{
244 resource_size_t size = res->end - res->start + 1;
245 u32 sa;
246
247 /* Calculate window size */
248 sa = (0xffffffffu << ilog2(size)) | 1;
249 sa |= 0x1;
250
251 /* RAM is always at 0 local for now */
252 writel(0, reg + PCIL0_PTM1LA);
253 writel(sa, reg + PCIL0_PTM1MS);
254
255 /* Map on PCI side */
256 early_write_config_dword(hose, hose->first_busno, 0,
257 PCI_BASE_ADDRESS_1, res->start);
258 early_write_config_dword(hose, hose->first_busno, 0,
259 PCI_BASE_ADDRESS_2, 0x00000000);
260 early_write_config_word(hose, hose->first_busno, 0,
261 PCI_COMMAND, 0x0006);
262}
263
Benjamin Herrenschmidt5738ec62007-12-21 15:39:22 +1100264static void __init ppc4xx_probe_pci_bridge(struct device_node *np)
265{
266 /* NYI */
Benjamin Herrenschmidtc839e0e2007-12-21 15:39:23 +1100267 struct resource rsrc_cfg;
268 struct resource rsrc_reg;
269 struct resource dma_window;
270 struct pci_controller *hose = NULL;
271 void __iomem *reg = NULL;
272 const int *bus_range;
273 int primary = 0;
274
275 /* Fetch config space registers address */
276 if (of_address_to_resource(np, 0, &rsrc_cfg)) {
277 printk(KERN_ERR "%s:Can't get PCI config register base !",
278 np->full_name);
279 return;
280 }
281 /* Fetch host bridge internal registers address */
282 if (of_address_to_resource(np, 3, &rsrc_reg)) {
283 printk(KERN_ERR "%s: Can't get PCI internal register base !",
284 np->full_name);
285 return;
286 }
287
288 /* Check if primary bridge */
289 if (of_get_property(np, "primary", NULL))
290 primary = 1;
291
292 /* Get bus range if any */
293 bus_range = of_get_property(np, "bus-range", NULL);
294
295 /* Map registers */
296 reg = ioremap(rsrc_reg.start, rsrc_reg.end + 1 - rsrc_reg.start);
297 if (reg == NULL) {
298 printk(KERN_ERR "%s: Can't map registers !", np->full_name);
299 goto fail;
300 }
301
302 /* Allocate the host controller data structure */
303 hose = pcibios_alloc_controller(np);
304 if (!hose)
305 goto fail;
306
307 hose->first_busno = bus_range ? bus_range[0] : 0x0;
308 hose->last_busno = bus_range ? bus_range[1] : 0xff;
309
310 /* Setup config space */
311 setup_indirect_pci(hose, rsrc_cfg.start, rsrc_cfg.start + 0x4, 0);
312
313 /* Disable all windows */
314 writel(0, reg + PCIL0_PMM0MA);
315 writel(0, reg + PCIL0_PMM1MA);
316 writel(0, reg + PCIL0_PMM2MA);
317 writel(0, reg + PCIL0_PTM1MS);
318 writel(0, reg + PCIL0_PTM2MS);
319
320 /* Parse outbound mapping resources */
321 pci_process_bridge_OF_ranges(hose, np, primary);
322
323 /* Parse inbound mapping resources */
324 if (ppc4xx_parse_dma_ranges(hose, reg, &dma_window) != 0)
325 goto fail;
326
327 /* Configure outbound ranges POMs */
328 ppc4xx_configure_pci_PMMs(hose, reg);
329
330 /* Configure inbound ranges PIMs */
331 ppc4xx_configure_pci_PTMs(hose, reg, &dma_window);
332
333 /* We don't need the registers anymore */
334 iounmap(reg);
335 return;
336
337 fail:
338 if (hose)
339 pcibios_free_controller(hose);
340 if (reg)
341 iounmap(reg);
Benjamin Herrenschmidt5738ec62007-12-21 15:39:22 +1100342}
343
344/*
345 * 4xx PCI-X part
346 */
347
348static void __init ppc4xx_configure_pcix_POMs(struct pci_controller *hose,
349 void __iomem *reg)
350{
351 u32 lah, lal, pciah, pcial, sa;
352 int i, j;
353
354 /* Setup outbound memory windows */
355 for (i = j = 0; i < 3; i++) {
356 struct resource *res = &hose->mem_resources[i];
357
358 /* we only care about memory windows */
359 if (!(res->flags & IORESOURCE_MEM))
360 continue;
361 if (j > 1) {
362 printk(KERN_WARNING "%s: Too many ranges\n",
363 hose->dn->full_name);
364 break;
365 }
366
367 /* Calculate register values */
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100368 lah = RES_TO_U32_HIGH(res->start);
369 lal = RES_TO_U32_LOW(res->start);
370 pciah = RES_TO_U32_HIGH(res->start - hose->pci_mem_offset);
371 pcial = RES_TO_U32_LOW(res->start - hose->pci_mem_offset);
Benjamin Herrenschmidt5738ec62007-12-21 15:39:22 +1100372 sa = res->end + 1 - res->start;
373 if (!is_power_of_2(sa) || sa < 0x100000 ||
374 sa > 0xffffffffu) {
375 printk(KERN_WARNING "%s: Resource out of range\n",
376 hose->dn->full_name);
377 continue;
378 }
379 sa = (0xffffffffu << ilog2(sa)) | 0x1;
380
381 /* Program register values */
382 if (j == 0) {
383 writel(lah, reg + PCIX0_POM0LAH);
384 writel(lal, reg + PCIX0_POM0LAL);
385 writel(pciah, reg + PCIX0_POM0PCIAH);
386 writel(pcial, reg + PCIX0_POM0PCIAL);
387 writel(sa, reg + PCIX0_POM0SA);
388 } else {
389 writel(lah, reg + PCIX0_POM1LAH);
390 writel(lal, reg + PCIX0_POM1LAL);
391 writel(pciah, reg + PCIX0_POM1PCIAH);
392 writel(pcial, reg + PCIX0_POM1PCIAL);
393 writel(sa, reg + PCIX0_POM1SA);
394 }
395 j++;
396 }
397}
398
399static void __init ppc4xx_configure_pcix_PIMs(struct pci_controller *hose,
400 void __iomem *reg,
401 const struct resource *res,
402 int big_pim,
403 int enable_msi_hole)
404{
405 resource_size_t size = res->end - res->start + 1;
406 u32 sa;
407
408 /* RAM is always at 0 */
409 writel(0x00000000, reg + PCIX0_PIM0LAH);
410 writel(0x00000000, reg + PCIX0_PIM0LAL);
411
412 /* Calculate window size */
413 sa = (0xffffffffu << ilog2(size)) | 1;
414 sa |= 0x1;
415 if (res->flags & IORESOURCE_PREFETCH)
416 sa |= 0x2;
417 if (enable_msi_hole)
418 sa |= 0x4;
419 writel(sa, reg + PCIX0_PIM0SA);
420 if (big_pim)
421 writel(0xffffffff, reg + PCIX0_PIM0SAH);
422
423 /* Map on PCI side */
424 writel(0x00000000, reg + PCIX0_BAR0H);
425 writel(res->start, reg + PCIX0_BAR0L);
426 writew(0x0006, reg + PCIX0_COMMAND);
427}
428
429static void __init ppc4xx_probe_pcix_bridge(struct device_node *np)
430{
431 struct resource rsrc_cfg;
432 struct resource rsrc_reg;
433 struct resource dma_window;
434 struct pci_controller *hose = NULL;
435 void __iomem *reg = NULL;
436 const int *bus_range;
437 int big_pim = 0, msi = 0, primary = 0;
438
439 /* Fetch config space registers address */
440 if (of_address_to_resource(np, 0, &rsrc_cfg)) {
441 printk(KERN_ERR "%s:Can't get PCI-X config register base !",
442 np->full_name);
443 return;
444 }
445 /* Fetch host bridge internal registers address */
446 if (of_address_to_resource(np, 3, &rsrc_reg)) {
447 printk(KERN_ERR "%s: Can't get PCI-X internal register base !",
448 np->full_name);
449 return;
450 }
451
452 /* Check if it supports large PIMs (440GX) */
453 if (of_get_property(np, "large-inbound-windows", NULL))
454 big_pim = 1;
455
456 /* Check if we should enable MSIs inbound hole */
457 if (of_get_property(np, "enable-msi-hole", NULL))
458 msi = 1;
459
460 /* Check if primary bridge */
461 if (of_get_property(np, "primary", NULL))
462 primary = 1;
463
464 /* Get bus range if any */
465 bus_range = of_get_property(np, "bus-range", NULL);
466
467 /* Map registers */
468 reg = ioremap(rsrc_reg.start, rsrc_reg.end + 1 - rsrc_reg.start);
469 if (reg == NULL) {
470 printk(KERN_ERR "%s: Can't map registers !", np->full_name);
471 goto fail;
472 }
473
474 /* Allocate the host controller data structure */
475 hose = pcibios_alloc_controller(np);
476 if (!hose)
477 goto fail;
478
479 hose->first_busno = bus_range ? bus_range[0] : 0x0;
480 hose->last_busno = bus_range ? bus_range[1] : 0xff;
481
482 /* Setup config space */
483 setup_indirect_pci(hose, rsrc_cfg.start, rsrc_cfg.start + 0x4, 0);
484
485 /* Disable all windows */
486 writel(0, reg + PCIX0_POM0SA);
487 writel(0, reg + PCIX0_POM1SA);
488 writel(0, reg + PCIX0_POM2SA);
489 writel(0, reg + PCIX0_PIM0SA);
490 writel(0, reg + PCIX0_PIM1SA);
491 writel(0, reg + PCIX0_PIM2SA);
492 if (big_pim) {
493 writel(0, reg + PCIX0_PIM0SAH);
494 writel(0, reg + PCIX0_PIM2SAH);
495 }
496
497 /* Parse outbound mapping resources */
498 pci_process_bridge_OF_ranges(hose, np, primary);
499
500 /* Parse inbound mapping resources */
501 if (ppc4xx_parse_dma_ranges(hose, reg, &dma_window) != 0)
502 goto fail;
503
504 /* Configure outbound ranges POMs */
505 ppc4xx_configure_pcix_POMs(hose, reg);
506
507 /* Configure inbound ranges PIMs */
508 ppc4xx_configure_pcix_PIMs(hose, reg, &dma_window, big_pim, msi);
509
510 /* We don't need the registers anymore */
511 iounmap(reg);
512 return;
513
514 fail:
515 if (hose)
516 pcibios_free_controller(hose);
517 if (reg)
518 iounmap(reg);
519}
520
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100521#ifdef CONFIG_PPC4xx_PCI_EXPRESS
522
Benjamin Herrenschmidt5738ec62007-12-21 15:39:22 +1100523/*
524 * 4xx PCI-Express part
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100525 *
526 * We support 3 parts currently based on the compatible property:
527 *
Stefan Roeseaccf5ef2007-12-21 15:39:38 +1100528 * ibm,plb-pciex-440spe
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100529 * ibm,plb-pciex-405ex
Stefan Roese66b7e502008-02-24 08:08:27 +1100530 * ibm,plb-pciex-460ex
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100531 *
532 * Anything else will be rejected for now as they are all subtly
533 * different unfortunately.
534 *
Benjamin Herrenschmidt5738ec62007-12-21 15:39:22 +1100535 */
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100536
Stefan Roese78994e22007-12-31 16:41:15 +1100537#define MAX_PCIE_BUS_MAPPED 0x40
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100538
539struct ppc4xx_pciex_port
540{
541 struct pci_controller *hose;
542 struct device_node *node;
543 unsigned int index;
544 int endpoint;
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +1100545 int link;
546 int has_ibpre;
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100547 unsigned int sdr_base;
548 dcr_host_t dcrs;
549 struct resource cfg_space;
550 struct resource utl_regs;
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +1100551 void __iomem *utl_base;
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100552};
553
554static struct ppc4xx_pciex_port *ppc4xx_pciex_ports;
555static unsigned int ppc4xx_pciex_port_count;
556
557struct ppc4xx_pciex_hwops
558{
559 int (*core_init)(struct device_node *np);
560 int (*port_init_hw)(struct ppc4xx_pciex_port *port);
561 int (*setup_utl)(struct ppc4xx_pciex_port *port);
562};
563
564static struct ppc4xx_pciex_hwops *ppc4xx_pciex_hwops;
565
566#ifdef CONFIG_44x
567
568/* Check various reset bits of the 440SPe PCIe core */
569static int __init ppc440spe_pciex_check_reset(struct device_node *np)
570{
571 u32 valPE0, valPE1, valPE2;
572 int err = 0;
573
574 /* SDR0_PEGPLLLCT1 reset */
575 if (!(mfdcri(SDR0, PESDR0_PLLLCT1) & 0x01000000)) {
576 /*
577 * the PCIe core was probably already initialised
578 * by firmware - let's re-reset RCSSET regs
579 *
580 * -- Shouldn't we also re-reset the whole thing ? -- BenH
581 */
582 pr_debug("PCIE: SDR0_PLLLCT1 already reset.\n");
583 mtdcri(SDR0, PESDR0_440SPE_RCSSET, 0x01010000);
584 mtdcri(SDR0, PESDR1_440SPE_RCSSET, 0x01010000);
585 mtdcri(SDR0, PESDR2_440SPE_RCSSET, 0x01010000);
586 }
587
588 valPE0 = mfdcri(SDR0, PESDR0_440SPE_RCSSET);
589 valPE1 = mfdcri(SDR0, PESDR1_440SPE_RCSSET);
590 valPE2 = mfdcri(SDR0, PESDR2_440SPE_RCSSET);
591
592 /* SDR0_PExRCSSET rstgu */
593 if (!(valPE0 & 0x01000000) ||
594 !(valPE1 & 0x01000000) ||
595 !(valPE2 & 0x01000000)) {
596 printk(KERN_INFO "PCIE: SDR0_PExRCSSET rstgu error\n");
597 err = -1;
598 }
599
600 /* SDR0_PExRCSSET rstdl */
601 if (!(valPE0 & 0x00010000) ||
602 !(valPE1 & 0x00010000) ||
603 !(valPE2 & 0x00010000)) {
604 printk(KERN_INFO "PCIE: SDR0_PExRCSSET rstdl error\n");
605 err = -1;
606 }
607
608 /* SDR0_PExRCSSET rstpyn */
609 if ((valPE0 & 0x00001000) ||
610 (valPE1 & 0x00001000) ||
611 (valPE2 & 0x00001000)) {
612 printk(KERN_INFO "PCIE: SDR0_PExRCSSET rstpyn error\n");
613 err = -1;
614 }
615
616 /* SDR0_PExRCSSET hldplb */
617 if ((valPE0 & 0x10000000) ||
618 (valPE1 & 0x10000000) ||
619 (valPE2 & 0x10000000)) {
620 printk(KERN_INFO "PCIE: SDR0_PExRCSSET hldplb error\n");
621 err = -1;
622 }
623
624 /* SDR0_PExRCSSET rdy */
625 if ((valPE0 & 0x00100000) ||
626 (valPE1 & 0x00100000) ||
627 (valPE2 & 0x00100000)) {
628 printk(KERN_INFO "PCIE: SDR0_PExRCSSET rdy error\n");
629 err = -1;
630 }
631
632 /* SDR0_PExRCSSET shutdown */
633 if ((valPE0 & 0x00000100) ||
634 (valPE1 & 0x00000100) ||
635 (valPE2 & 0x00000100)) {
636 printk(KERN_INFO "PCIE: SDR0_PExRCSSET shutdown error\n");
637 err = -1;
638 }
639
640 return err;
641}
642
643/* Global PCIe core initializations for 440SPe core */
644static int __init ppc440spe_pciex_core_init(struct device_node *np)
645{
646 int time_out = 20;
647
648 /* Set PLL clock receiver to LVPECL */
Valentine Barshak6e42b212008-03-07 01:34:52 +1100649 dcri_clrset(SDR0, PESDR0_PLLLCT1, 0, 1 << 28);
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100650
651 /* Shouldn't we do all the calibration stuff etc... here ? */
652 if (ppc440spe_pciex_check_reset(np))
653 return -ENXIO;
654
655 if (!(mfdcri(SDR0, PESDR0_PLLLCT2) & 0x10000)) {
656 printk(KERN_INFO "PCIE: PESDR_PLLCT2 resistance calibration "
657 "failed (0x%08x)\n",
658 mfdcri(SDR0, PESDR0_PLLLCT2));
659 return -1;
660 }
661
662 /* De-assert reset of PCIe PLL, wait for lock */
Valentine Barshak6e42b212008-03-07 01:34:52 +1100663 dcri_clrset(SDR0, PESDR0_PLLLCT1, 1 << 24, 0);
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100664 udelay(3);
665
666 while (time_out) {
667 if (!(mfdcri(SDR0, PESDR0_PLLLCT3) & 0x10000000)) {
668 time_out--;
669 udelay(1);
670 } else
671 break;
672 }
673 if (!time_out) {
674 printk(KERN_INFO "PCIE: VCO output not locked\n");
675 return -1;
676 }
677
678 pr_debug("PCIE initialization OK\n");
679
680 return 3;
681}
682
683static int ppc440spe_pciex_init_port_hw(struct ppc4xx_pciex_port *port)
684{
685 u32 val = 1 << 24;
686
687 if (port->endpoint)
688 val = PTYPE_LEGACY_ENDPOINT << 20;
689 else
690 val = PTYPE_ROOT_PORT << 20;
691
692 if (port->index == 0)
693 val |= LNKW_X8 << 12;
694 else
695 val |= LNKW_X4 << 12;
696
697 mtdcri(SDR0, port->sdr_base + PESDRn_DLPSET, val);
698 mtdcri(SDR0, port->sdr_base + PESDRn_UTLSET1, 0x20222222);
Stefan Roeseaccf5ef2007-12-21 15:39:38 +1100699 if (ppc440spe_revA())
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100700 mtdcri(SDR0, port->sdr_base + PESDRn_UTLSET2, 0x11000000);
701 mtdcri(SDR0, port->sdr_base + PESDRn_440SPE_HSSL0SET1, 0x35000000);
702 mtdcri(SDR0, port->sdr_base + PESDRn_440SPE_HSSL1SET1, 0x35000000);
703 mtdcri(SDR0, port->sdr_base + PESDRn_440SPE_HSSL2SET1, 0x35000000);
704 mtdcri(SDR0, port->sdr_base + PESDRn_440SPE_HSSL3SET1, 0x35000000);
705 if (port->index == 0) {
706 mtdcri(SDR0, port->sdr_base + PESDRn_440SPE_HSSL4SET1,
707 0x35000000);
708 mtdcri(SDR0, port->sdr_base + PESDRn_440SPE_HSSL5SET1,
709 0x35000000);
710 mtdcri(SDR0, port->sdr_base + PESDRn_440SPE_HSSL6SET1,
711 0x35000000);
712 mtdcri(SDR0, port->sdr_base + PESDRn_440SPE_HSSL7SET1,
713 0x35000000);
714 }
Valentine Barshak6e42b212008-03-07 01:34:52 +1100715 dcri_clrset(SDR0, port->sdr_base + PESDRn_RCSSET,
716 (1 << 24) | (1 << 16), 1 << 12);
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100717
718 return 0;
719}
720
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +1100721static int ppc440speA_pciex_init_port_hw(struct ppc4xx_pciex_port *port)
722{
723 return ppc440spe_pciex_init_port_hw(port);
724}
725
726static int ppc440speB_pciex_init_port_hw(struct ppc4xx_pciex_port *port)
727{
728 int rc = ppc440spe_pciex_init_port_hw(port);
729
730 port->has_ibpre = 1;
731
732 return rc;
733}
734
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100735static int ppc440speA_pciex_init_utl(struct ppc4xx_pciex_port *port)
736{
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100737 /* XXX Check what that value means... I hate magic */
738 dcr_write(port->dcrs, DCRO_PEGPL_SPECIAL, 0x68782800);
739
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100740 /*
741 * Set buffer allocations and then assert VRB and TXE.
742 */
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +1100743 out_be32(port->utl_base + PEUTL_OUTTR, 0x08000000);
744 out_be32(port->utl_base + PEUTL_INTR, 0x02000000);
745 out_be32(port->utl_base + PEUTL_OPDBSZ, 0x10000000);
746 out_be32(port->utl_base + PEUTL_PBBSZ, 0x53000000);
747 out_be32(port->utl_base + PEUTL_IPHBSZ, 0x08000000);
748 out_be32(port->utl_base + PEUTL_IPDBSZ, 0x10000000);
749 out_be32(port->utl_base + PEUTL_RCIRQEN, 0x00f00000);
750 out_be32(port->utl_base + PEUTL_PCTL, 0x80800066);
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100751
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +1100752 return 0;
753}
754
755static int ppc440speB_pciex_init_utl(struct ppc4xx_pciex_port *port)
756{
757 /* Report CRS to the operating system */
758 out_be32(port->utl_base + PEUTL_PBCTL, 0x08000000);
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100759
760 return 0;
761}
762
763static struct ppc4xx_pciex_hwops ppc440speA_pcie_hwops __initdata =
764{
765 .core_init = ppc440spe_pciex_core_init,
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +1100766 .port_init_hw = ppc440speA_pciex_init_port_hw,
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100767 .setup_utl = ppc440speA_pciex_init_utl,
768};
769
770static struct ppc4xx_pciex_hwops ppc440speB_pcie_hwops __initdata =
771{
772 .core_init = ppc440spe_pciex_core_init,
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +1100773 .port_init_hw = ppc440speB_pciex_init_port_hw,
774 .setup_utl = ppc440speB_pciex_init_utl,
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100775};
776
Stefan Roese66b7e502008-02-24 08:08:27 +1100777static int __init ppc460ex_pciex_core_init(struct device_node *np)
778{
779 /* Nothing to do, return 2 ports */
780 return 2;
781}
782
783static int ppc460ex_pciex_init_port_hw(struct ppc4xx_pciex_port *port)
784{
785 u32 val;
786 u32 utlset1;
787
788 if (port->endpoint) {
789 val = PTYPE_LEGACY_ENDPOINT << 20;
790 utlset1 = 0x20222222;
791 } else {
792 val = PTYPE_ROOT_PORT << 20;
793 utlset1 = 0x21222222;
794 }
795
796 if (port->index == 0) {
797 val |= LNKW_X1 << 12;
798 } else {
799 val |= LNKW_X4 << 12;
800 utlset1 |= 0x00101101;
801 }
802
803 mtdcri(SDR0, port->sdr_base + PESDRn_DLPSET, val);
804 mtdcri(SDR0, port->sdr_base + PESDRn_UTLSET1, utlset1);
805 mtdcri(SDR0, port->sdr_base + PESDRn_UTLSET2, 0x01210000);
806
807 switch (port->index) {
808 case 0:
809 mtdcri(SDR0, PESDR0_460EX_L0CDRCTL, 0x00003230);
810 mtdcri(SDR0, PESDR0_460EX_L0DRV, 0x00000136);
811 mtdcri(SDR0, PESDR0_460EX_L0CLK, 0x00000006);
812
813 mtdcri(SDR0, PESDR0_460EX_PHY_CTL_RST,0x10000000);
814 break;
815
816 case 1:
817 mtdcri(SDR0, PESDR1_460EX_L0CDRCTL, 0x00003230);
818 mtdcri(SDR0, PESDR1_460EX_L1CDRCTL, 0x00003230);
819 mtdcri(SDR0, PESDR1_460EX_L2CDRCTL, 0x00003230);
820 mtdcri(SDR0, PESDR1_460EX_L3CDRCTL, 0x00003230);
821 mtdcri(SDR0, PESDR1_460EX_L0DRV, 0x00000136);
822 mtdcri(SDR0, PESDR1_460EX_L1DRV, 0x00000136);
823 mtdcri(SDR0, PESDR1_460EX_L2DRV, 0x00000136);
824 mtdcri(SDR0, PESDR1_460EX_L3DRV, 0x00000136);
825 mtdcri(SDR0, PESDR1_460EX_L0CLK, 0x00000006);
826 mtdcri(SDR0, PESDR1_460EX_L1CLK, 0x00000006);
827 mtdcri(SDR0, PESDR1_460EX_L2CLK, 0x00000006);
828 mtdcri(SDR0, PESDR1_460EX_L3CLK, 0x00000006);
829
830 mtdcri(SDR0, PESDR1_460EX_PHY_CTL_RST,0x10000000);
831 break;
832 }
833
834 mtdcri(SDR0, port->sdr_base + PESDRn_RCSSET,
835 mfdcri(SDR0, port->sdr_base + PESDRn_RCSSET) |
836 (PESDRx_RCSSET_RSTGU | PESDRx_RCSSET_RSTPYN));
837
838 /* Poll for PHY reset */
839 /* XXX FIXME add timeout */
840 switch (port->index) {
841 case 0:
842 while (!(mfdcri(SDR0, PESDR0_460EX_RSTSTA) & 0x1))
843 udelay(10);
844 break;
845 case 1:
846 while (!(mfdcri(SDR0, PESDR1_460EX_RSTSTA) & 0x1))
847 udelay(10);
848 break;
849 }
850
851 mtdcri(SDR0, port->sdr_base + PESDRn_RCSSET,
852 (mfdcri(SDR0, port->sdr_base + PESDRn_RCSSET) &
853 ~(PESDRx_RCSSET_RSTGU | PESDRx_RCSSET_RSTDL)) |
854 PESDRx_RCSSET_RSTPYN);
855
856 port->has_ibpre = 1;
857
858 return 0;
859}
860
861static int ppc460ex_pciex_init_utl(struct ppc4xx_pciex_port *port)
862{
863 dcr_write(port->dcrs, DCRO_PEGPL_SPECIAL, 0x0);
864
865 /*
866 * Set buffer allocations and then assert VRB and TXE.
867 */
868 out_be32(port->utl_base + PEUTL_PBCTL, 0x0800000c);
869 out_be32(port->utl_base + PEUTL_OUTTR, 0x08000000);
870 out_be32(port->utl_base + PEUTL_INTR, 0x02000000);
871 out_be32(port->utl_base + PEUTL_OPDBSZ, 0x04000000);
872 out_be32(port->utl_base + PEUTL_PBBSZ, 0x00000000);
873 out_be32(port->utl_base + PEUTL_IPHBSZ, 0x02000000);
874 out_be32(port->utl_base + PEUTL_IPDBSZ, 0x04000000);
875 out_be32(port->utl_base + PEUTL_RCIRQEN,0x00f00000);
876 out_be32(port->utl_base + PEUTL_PCTL, 0x80800066);
877
878 return 0;
879}
880
881static struct ppc4xx_pciex_hwops ppc460ex_pcie_hwops __initdata =
882{
883 .core_init = ppc460ex_pciex_core_init,
884 .port_init_hw = ppc460ex_pciex_init_port_hw,
885 .setup_utl = ppc460ex_pciex_init_utl,
886};
887
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100888#endif /* CONFIG_44x */
889
890#ifdef CONFIG_40x
891
892static int __init ppc405ex_pciex_core_init(struct device_node *np)
893{
894 /* Nothing to do, return 2 ports */
895 return 2;
896}
897
898static void ppc405ex_pcie_phy_reset(struct ppc4xx_pciex_port *port)
899{
900 /* Assert the PE0_PHY reset */
901 mtdcri(SDR0, port->sdr_base + PESDRn_RCSSET, 0x01010000);
902 msleep(1);
903
904 /* deassert the PE0_hotreset */
905 if (port->endpoint)
906 mtdcri(SDR0, port->sdr_base + PESDRn_RCSSET, 0x01111000);
907 else
908 mtdcri(SDR0, port->sdr_base + PESDRn_RCSSET, 0x01101000);
909
910 /* poll for phy !reset */
911 /* XXX FIXME add timeout */
912 while (!(mfdcri(SDR0, port->sdr_base + PESDRn_405EX_PHYSTA) & 0x00001000))
913 ;
914
915 /* deassert the PE0_gpl_utl_reset */
916 mtdcri(SDR0, port->sdr_base + PESDRn_RCSSET, 0x00101000);
917}
918
919static int ppc405ex_pciex_init_port_hw(struct ppc4xx_pciex_port *port)
920{
921 u32 val;
922
923 if (port->endpoint)
924 val = PTYPE_LEGACY_ENDPOINT;
925 else
926 val = PTYPE_ROOT_PORT;
927
928 mtdcri(SDR0, port->sdr_base + PESDRn_DLPSET,
929 1 << 24 | val << 20 | LNKW_X1 << 12);
930
931 mtdcri(SDR0, port->sdr_base + PESDRn_UTLSET1, 0x00000000);
932 mtdcri(SDR0, port->sdr_base + PESDRn_UTLSET2, 0x01010000);
933 mtdcri(SDR0, port->sdr_base + PESDRn_405EX_PHYSET1, 0x720F0000);
934 mtdcri(SDR0, port->sdr_base + PESDRn_405EX_PHYSET2, 0x70600003);
935
936 /*
937 * Only reset the PHY when no link is currently established.
938 * This is for the Atheros PCIe board which has problems to establish
939 * the link (again) after this PHY reset. All other currently tested
940 * PCIe boards don't show this problem.
941 * This has to be re-tested and fixed in a later release!
942 */
943#if 0 /* XXX FIXME: Not resetting the PHY will leave all resources
944 * configured as done previously by U-Boot. Then Linux will currently
945 * not reassign them. So the PHY reset is now done always. This will
946 * lead to problems with the Atheros PCIe board again.
947 */
948 val = mfdcri(SDR0, port->sdr_base + PESDRn_LOOP);
949 if (!(val & 0x00001000))
950 ppc405ex_pcie_phy_reset(port);
951#else
952 ppc405ex_pcie_phy_reset(port);
953#endif
954
955 dcr_write(port->dcrs, DCRO_PEGPL_CFG, 0x10000000); /* guarded on */
956
Stefan Roese55aaf6e2007-12-07 20:34:34 +1100957 port->has_ibpre = 1;
958
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100959 return 0;
960}
961
962static int ppc405ex_pciex_init_utl(struct ppc4xx_pciex_port *port)
963{
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100964 dcr_write(port->dcrs, DCRO_PEGPL_SPECIAL, 0x0);
965
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100966 /*
967 * Set buffer allocations and then assert VRB and TXE.
968 */
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +1100969 out_be32(port->utl_base + PEUTL_OUTTR, 0x02000000);
970 out_be32(port->utl_base + PEUTL_INTR, 0x02000000);
971 out_be32(port->utl_base + PEUTL_OPDBSZ, 0x04000000);
972 out_be32(port->utl_base + PEUTL_PBBSZ, 0x21000000);
973 out_be32(port->utl_base + PEUTL_IPHBSZ, 0x02000000);
974 out_be32(port->utl_base + PEUTL_IPDBSZ, 0x04000000);
975 out_be32(port->utl_base + PEUTL_RCIRQEN, 0x00f00000);
976 out_be32(port->utl_base + PEUTL_PCTL, 0x80800066);
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100977
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +1100978 out_be32(port->utl_base + PEUTL_PBCTL, 0x08000000);
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +1100979
980 return 0;
981}
982
983static struct ppc4xx_pciex_hwops ppc405ex_pcie_hwops __initdata =
984{
985 .core_init = ppc405ex_pciex_core_init,
986 .port_init_hw = ppc405ex_pciex_init_port_hw,
987 .setup_utl = ppc405ex_pciex_init_utl,
988};
989
990#endif /* CONFIG_40x */
991
992
993/* Check that the core has been initied and if not, do it */
994static int __init ppc4xx_pciex_check_core_init(struct device_node *np)
995{
996 static int core_init;
997 int count = -ENODEV;
998
999 if (core_init++)
1000 return 0;
1001
1002#ifdef CONFIG_44x
Stefan Roeseaccf5ef2007-12-21 15:39:38 +11001003 if (of_device_is_compatible(np, "ibm,plb-pciex-440spe")) {
1004 if (ppc440spe_revA())
1005 ppc4xx_pciex_hwops = &ppc440speA_pcie_hwops;
1006 else
1007 ppc4xx_pciex_hwops = &ppc440speB_pcie_hwops;
1008 }
Stefan Roese66b7e502008-02-24 08:08:27 +11001009 if (of_device_is_compatible(np, "ibm,plb-pciex-460ex"))
1010 ppc4xx_pciex_hwops = &ppc460ex_pcie_hwops;
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +11001011#endif /* CONFIG_44x */
1012#ifdef CONFIG_40x
1013 if (of_device_is_compatible(np, "ibm,plb-pciex-405ex"))
1014 ppc4xx_pciex_hwops = &ppc405ex_pcie_hwops;
1015#endif
1016 if (ppc4xx_pciex_hwops == NULL) {
1017 printk(KERN_WARNING "PCIE: unknown host type %s\n",
1018 np->full_name);
1019 return -ENODEV;
1020 }
1021
1022 count = ppc4xx_pciex_hwops->core_init(np);
1023 if (count > 0) {
1024 ppc4xx_pciex_ports =
1025 kzalloc(count * sizeof(struct ppc4xx_pciex_port),
1026 GFP_KERNEL);
1027 if (ppc4xx_pciex_ports) {
1028 ppc4xx_pciex_port_count = count;
1029 return 0;
1030 }
1031 printk(KERN_WARNING "PCIE: failed to allocate ports array\n");
1032 return -ENOMEM;
1033 }
1034 return -ENODEV;
1035}
1036
1037static void __init ppc4xx_pciex_port_init_mapping(struct ppc4xx_pciex_port *port)
1038{
1039 /* We map PCI Express configuration based on the reg property */
1040 dcr_write(port->dcrs, DCRO_PEGPL_CFGBAH,
1041 RES_TO_U32_HIGH(port->cfg_space.start));
1042 dcr_write(port->dcrs, DCRO_PEGPL_CFGBAL,
1043 RES_TO_U32_LOW(port->cfg_space.start));
1044
1045 /* XXX FIXME: Use size from reg property. For now, map 512M */
1046 dcr_write(port->dcrs, DCRO_PEGPL_CFGMSK, 0xe0000001);
1047
1048 /* We map UTL registers based on the reg property */
1049 dcr_write(port->dcrs, DCRO_PEGPL_REGBAH,
1050 RES_TO_U32_HIGH(port->utl_regs.start));
1051 dcr_write(port->dcrs, DCRO_PEGPL_REGBAL,
1052 RES_TO_U32_LOW(port->utl_regs.start));
1053
1054 /* XXX FIXME: Use size from reg property */
1055 dcr_write(port->dcrs, DCRO_PEGPL_REGMSK, 0x00007001);
1056
1057 /* Disable all other outbound windows */
1058 dcr_write(port->dcrs, DCRO_PEGPL_OMR1MSKL, 0);
1059 dcr_write(port->dcrs, DCRO_PEGPL_OMR2MSKL, 0);
1060 dcr_write(port->dcrs, DCRO_PEGPL_OMR3MSKL, 0);
1061 dcr_write(port->dcrs, DCRO_PEGPL_MSGMSK, 0);
1062}
1063
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +11001064static int __init ppc4xx_pciex_wait_on_sdr(struct ppc4xx_pciex_port *port,
1065 unsigned int sdr_offset,
1066 unsigned int mask,
1067 unsigned int value,
1068 int timeout_ms)
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +11001069{
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +11001070 u32 val;
1071
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +11001072 while(timeout_ms--) {
1073 val = mfdcri(SDR0, port->sdr_base + sdr_offset);
1074 if ((val & mask) == value) {
1075 pr_debug("PCIE%d: Wait on SDR %x success with tm %d (%08x)\n",
1076 port->index, sdr_offset, timeout_ms, val);
1077 return 0;
1078 }
1079 msleep(1);
1080 }
1081 return -1;
1082}
1083
1084static int __init ppc4xx_pciex_port_init(struct ppc4xx_pciex_port *port)
1085{
1086 int rc = 0;
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +11001087
1088 /* Init HW */
1089 if (ppc4xx_pciex_hwops->port_init_hw)
1090 rc = ppc4xx_pciex_hwops->port_init_hw(port);
1091 if (rc != 0)
1092 return rc;
1093
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +11001094 printk(KERN_INFO "PCIE%d: Checking link...\n",
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +11001095 port->index);
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +11001096
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +11001097 /* Wait for reset to complete */
1098 if (ppc4xx_pciex_wait_on_sdr(port, PESDRn_RCSSTS, 1 << 20, 0, 10)) {
1099 printk(KERN_WARNING "PCIE%d: PGRST failed\n",
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +11001100 port->index);
1101 return -1;
1102 }
1103
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +11001104 /* Check for card presence detect if supported, if not, just wait for
1105 * link unconditionally.
1106 *
1107 * note that we don't fail if there is no link, we just filter out
1108 * config space accesses. That way, it will be easier to implement
1109 * hotplug later on.
1110 */
1111 if (!port->has_ibpre ||
1112 !ppc4xx_pciex_wait_on_sdr(port, PESDRn_LOOP,
1113 1 << 28, 1 << 28, 100)) {
1114 printk(KERN_INFO
1115 "PCIE%d: Device detected, waiting for link...\n",
1116 port->index);
1117 if (ppc4xx_pciex_wait_on_sdr(port, PESDRn_LOOP,
1118 0x1000, 0x1000, 2000))
1119 printk(KERN_WARNING
1120 "PCIE%d: Link up failed\n", port->index);
1121 else {
1122 printk(KERN_INFO
1123 "PCIE%d: link is up !\n", port->index);
1124 port->link = 1;
1125 }
1126 } else
1127 printk(KERN_INFO "PCIE%d: No device detected.\n", port->index);
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +11001128
1129 /*
1130 * Initialize mapping: disable all regions and configure
1131 * CFG and REG regions based on resources in the device tree
1132 */
1133 ppc4xx_pciex_port_init_mapping(port);
1134
1135 /*
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +11001136 * Map UTL
1137 */
1138 port->utl_base = ioremap(port->utl_regs.start, 0x100);
1139 BUG_ON(port->utl_base == NULL);
1140
1141 /*
1142 * Setup UTL registers --BenH.
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +11001143 */
1144 if (ppc4xx_pciex_hwops->setup_utl)
1145 ppc4xx_pciex_hwops->setup_utl(port);
1146
1147 /*
1148 * Check for VC0 active and assert RDY.
1149 */
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +11001150 if (port->link &&
1151 ppc4xx_pciex_wait_on_sdr(port, PESDRn_RCSSTS,
1152 1 << 16, 1 << 16, 5000)) {
1153 printk(KERN_INFO "PCIE%d: VC0 not active\n", port->index);
1154 port->link = 0;
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +11001155 }
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +11001156
Valentine Barshak6e42b212008-03-07 01:34:52 +11001157 dcri_clrset(SDR0, port->sdr_base + PESDRn_RCSSET, 0, 1 << 20);
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +11001158 msleep(100);
1159
1160 return 0;
1161}
1162
1163static int ppc4xx_pciex_validate_bdf(struct ppc4xx_pciex_port *port,
1164 struct pci_bus *bus,
1165 unsigned int devfn)
1166{
1167 static int message;
1168
1169 /* Endpoint can not generate upstream(remote) config cycles */
1170 if (port->endpoint && bus->number != port->hose->first_busno)
1171 return PCIBIOS_DEVICE_NOT_FOUND;
1172
1173 /* Check we are within the mapped range */
1174 if (bus->number > port->hose->last_busno) {
1175 if (!message) {
1176 printk(KERN_WARNING "Warning! Probing bus %u"
1177 " out of range !\n", bus->number);
1178 message++;
1179 }
1180 return PCIBIOS_DEVICE_NOT_FOUND;
1181 }
1182
1183 /* The root complex has only one device / function */
1184 if (bus->number == port->hose->first_busno && devfn != 0)
1185 return PCIBIOS_DEVICE_NOT_FOUND;
1186
1187 /* The other side of the RC has only one device as well */
1188 if (bus->number == (port->hose->first_busno + 1) &&
1189 PCI_SLOT(devfn) != 0)
1190 return PCIBIOS_DEVICE_NOT_FOUND;
1191
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +11001192 /* Check if we have a link */
1193 if ((bus->number != port->hose->first_busno) && !port->link)
1194 return PCIBIOS_DEVICE_NOT_FOUND;
1195
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +11001196 return 0;
1197}
1198
1199static void __iomem *ppc4xx_pciex_get_config_base(struct ppc4xx_pciex_port *port,
1200 struct pci_bus *bus,
1201 unsigned int devfn)
1202{
1203 int relbus;
1204
1205 /* Remove the casts when we finally remove the stupid volatile
1206 * in struct pci_controller
1207 */
1208 if (bus->number == port->hose->first_busno)
1209 return (void __iomem *)port->hose->cfg_addr;
1210
1211 relbus = bus->number - (port->hose->first_busno + 1);
1212 return (void __iomem *)port->hose->cfg_data +
1213 ((relbus << 20) | (devfn << 12));
1214}
1215
1216static int ppc4xx_pciex_read_config(struct pci_bus *bus, unsigned int devfn,
1217 int offset, int len, u32 *val)
1218{
1219 struct pci_controller *hose = (struct pci_controller *) bus->sysdata;
1220 struct ppc4xx_pciex_port *port =
1221 &ppc4xx_pciex_ports[hose->indirect_type];
1222 void __iomem *addr;
1223 u32 gpl_cfg;
1224
1225 BUG_ON(hose != port->hose);
1226
1227 if (ppc4xx_pciex_validate_bdf(port, bus, devfn) != 0)
1228 return PCIBIOS_DEVICE_NOT_FOUND;
1229
1230 addr = ppc4xx_pciex_get_config_base(port, bus, devfn);
1231
1232 /*
1233 * Reading from configuration space of non-existing device can
1234 * generate transaction errors. For the read duration we suppress
1235 * assertion of machine check exceptions to avoid those.
1236 */
1237 gpl_cfg = dcr_read(port->dcrs, DCRO_PEGPL_CFG);
1238 dcr_write(port->dcrs, DCRO_PEGPL_CFG, gpl_cfg | GPL_DMER_MASK_DISA);
1239
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +11001240 /* Make sure no CRS is recorded */
1241 out_be32(port->utl_base + PEUTL_RCSTA, 0x00040000);
1242
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +11001243 switch (len) {
1244 case 1:
1245 *val = in_8((u8 *)(addr + offset));
1246 break;
1247 case 2:
1248 *val = in_le16((u16 *)(addr + offset));
1249 break;
1250 default:
1251 *val = in_le32((u32 *)(addr + offset));
1252 break;
1253 }
1254
1255 pr_debug("pcie-config-read: bus=%3d [%3d..%3d] devfn=0x%04x"
1256 " offset=0x%04x len=%d, addr=0x%p val=0x%08x\n",
1257 bus->number, hose->first_busno, hose->last_busno,
1258 devfn, offset, len, addr + offset, *val);
1259
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +11001260 /* Check for CRS (440SPe rev B does that for us but heh ..) */
1261 if (in_be32(port->utl_base + PEUTL_RCSTA) & 0x00040000) {
1262 pr_debug("Got CRS !\n");
1263 if (len != 4 || offset != 0)
1264 return PCIBIOS_DEVICE_NOT_FOUND;
1265 *val = 0xffff0001;
1266 }
1267
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +11001268 dcr_write(port->dcrs, DCRO_PEGPL_CFG, gpl_cfg);
1269
1270 return PCIBIOS_SUCCESSFUL;
1271}
1272
1273static int ppc4xx_pciex_write_config(struct pci_bus *bus, unsigned int devfn,
1274 int offset, int len, u32 val)
1275{
1276 struct pci_controller *hose = (struct pci_controller *) bus->sysdata;
1277 struct ppc4xx_pciex_port *port =
1278 &ppc4xx_pciex_ports[hose->indirect_type];
1279 void __iomem *addr;
1280 u32 gpl_cfg;
1281
1282 if (ppc4xx_pciex_validate_bdf(port, bus, devfn) != 0)
1283 return PCIBIOS_DEVICE_NOT_FOUND;
1284
1285 addr = ppc4xx_pciex_get_config_base(port, bus, devfn);
1286
1287 /*
1288 * Reading from configuration space of non-existing device can
1289 * generate transaction errors. For the read duration we suppress
1290 * assertion of machine check exceptions to avoid those.
1291 */
1292 gpl_cfg = dcr_read(port->dcrs, DCRO_PEGPL_CFG);
1293 dcr_write(port->dcrs, DCRO_PEGPL_CFG, gpl_cfg | GPL_DMER_MASK_DISA);
1294
1295 pr_debug("pcie-config-write: bus=%3d [%3d..%3d] devfn=0x%04x"
1296 " offset=0x%04x len=%d, addr=0x%p val=0x%08x\n",
1297 bus->number, hose->first_busno, hose->last_busno,
1298 devfn, offset, len, addr + offset, val);
1299
1300 switch (len) {
1301 case 1:
1302 out_8((u8 *)(addr + offset), val);
1303 break;
1304 case 2:
1305 out_le16((u16 *)(addr + offset), val);
1306 break;
1307 default:
1308 out_le32((u32 *)(addr + offset), val);
1309 break;
1310 }
1311
1312 dcr_write(port->dcrs, DCRO_PEGPL_CFG, gpl_cfg);
1313
1314 return PCIBIOS_SUCCESSFUL;
1315}
1316
1317static struct pci_ops ppc4xx_pciex_pci_ops =
1318{
1319 .read = ppc4xx_pciex_read_config,
1320 .write = ppc4xx_pciex_write_config,
1321};
1322
1323static void __init ppc4xx_configure_pciex_POMs(struct ppc4xx_pciex_port *port,
1324 struct pci_controller *hose,
1325 void __iomem *mbase)
1326{
1327 u32 lah, lal, pciah, pcial, sa;
1328 int i, j;
1329
1330 /* Setup outbound memory windows */
1331 for (i = j = 0; i < 3; i++) {
1332 struct resource *res = &hose->mem_resources[i];
1333
1334 /* we only care about memory windows */
1335 if (!(res->flags & IORESOURCE_MEM))
1336 continue;
1337 if (j > 1) {
1338 printk(KERN_WARNING "%s: Too many ranges\n",
1339 port->node->full_name);
1340 break;
1341 }
1342
1343 /* Calculate register values */
1344 lah = RES_TO_U32_HIGH(res->start);
1345 lal = RES_TO_U32_LOW(res->start);
1346 pciah = RES_TO_U32_HIGH(res->start - hose->pci_mem_offset);
1347 pcial = RES_TO_U32_LOW(res->start - hose->pci_mem_offset);
1348 sa = res->end + 1 - res->start;
1349 if (!is_power_of_2(sa) || sa < 0x100000 ||
1350 sa > 0xffffffffu) {
1351 printk(KERN_WARNING "%s: Resource out of range\n",
1352 port->node->full_name);
1353 continue;
1354 }
1355 sa = (0xffffffffu << ilog2(sa)) | 0x1;
1356
1357 /* Program register values */
1358 switch (j) {
1359 case 0:
1360 out_le32(mbase + PECFG_POM0LAH, pciah);
1361 out_le32(mbase + PECFG_POM0LAL, pcial);
1362 dcr_write(port->dcrs, DCRO_PEGPL_OMR1BAH, lah);
1363 dcr_write(port->dcrs, DCRO_PEGPL_OMR1BAL, lal);
1364 dcr_write(port->dcrs, DCRO_PEGPL_OMR1MSKH, 0x7fffffff);
1365 dcr_write(port->dcrs, DCRO_PEGPL_OMR1MSKL, sa | 3);
1366 break;
1367 case 1:
1368 out_le32(mbase + PECFG_POM1LAH, pciah);
1369 out_le32(mbase + PECFG_POM1LAL, pcial);
1370 dcr_write(port->dcrs, DCRO_PEGPL_OMR2BAH, lah);
1371 dcr_write(port->dcrs, DCRO_PEGPL_OMR2BAL, lal);
1372 dcr_write(port->dcrs, DCRO_PEGPL_OMR2MSKH, 0x7fffffff);
1373 dcr_write(port->dcrs, DCRO_PEGPL_OMR2MSKL, sa | 3);
1374 break;
1375 }
1376 j++;
1377 }
1378
1379 /* Configure IO, always 64K starting at 0 */
1380 if (hose->io_resource.flags & IORESOURCE_IO) {
1381 lah = RES_TO_U32_HIGH(hose->io_base_phys);
1382 lal = RES_TO_U32_LOW(hose->io_base_phys);
1383 out_le32(mbase + PECFG_POM2LAH, 0);
1384 out_le32(mbase + PECFG_POM2LAL, 0);
1385 dcr_write(port->dcrs, DCRO_PEGPL_OMR3BAH, lah);
1386 dcr_write(port->dcrs, DCRO_PEGPL_OMR3BAL, lal);
1387 dcr_write(port->dcrs, DCRO_PEGPL_OMR3MSKH, 0x7fffffff);
1388 dcr_write(port->dcrs, DCRO_PEGPL_OMR3MSKL, 0xffff0000 | 3);
1389 }
1390}
1391
1392static void __init ppc4xx_configure_pciex_PIMs(struct ppc4xx_pciex_port *port,
1393 struct pci_controller *hose,
1394 void __iomem *mbase,
1395 struct resource *res)
1396{
1397 resource_size_t size = res->end - res->start + 1;
1398 u64 sa;
1399
1400 /* Calculate window size */
1401 sa = (0xffffffffffffffffull << ilog2(size));;
1402 if (res->flags & IORESOURCE_PREFETCH)
1403 sa |= 0x8;
1404
1405 out_le32(mbase + PECFG_BAR0HMPA, RES_TO_U32_HIGH(sa));
1406 out_le32(mbase + PECFG_BAR0LMPA, RES_TO_U32_LOW(sa));
1407
1408 /* The setup of the split looks weird to me ... let's see if it works */
1409 out_le32(mbase + PECFG_PIM0LAL, 0x00000000);
1410 out_le32(mbase + PECFG_PIM0LAH, 0x00000000);
1411 out_le32(mbase + PECFG_PIM1LAL, 0x00000000);
1412 out_le32(mbase + PECFG_PIM1LAH, 0x00000000);
1413 out_le32(mbase + PECFG_PIM01SAH, 0xffff0000);
1414 out_le32(mbase + PECFG_PIM01SAL, 0x00000000);
1415
1416 /* Enable inbound mapping */
1417 out_le32(mbase + PECFG_PIMEN, 0x1);
1418
1419 out_le32(mbase + PCI_BASE_ADDRESS_0, RES_TO_U32_LOW(res->start));
1420 out_le32(mbase + PCI_BASE_ADDRESS_1, RES_TO_U32_HIGH(res->start));
1421
1422 /* Enable I/O, Mem, and Busmaster cycles */
1423 out_le16(mbase + PCI_COMMAND,
1424 in_le16(mbase + PCI_COMMAND) |
1425 PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
1426}
1427
1428static void __init ppc4xx_pciex_port_setup_hose(struct ppc4xx_pciex_port *port)
1429{
1430 struct resource dma_window;
1431 struct pci_controller *hose = NULL;
1432 const int *bus_range;
1433 int primary = 0, busses;
1434 void __iomem *mbase = NULL, *cfg_data = NULL;
1435
1436 /* XXX FIXME: Handle endpoint mode properly */
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +11001437 if (port->endpoint) {
1438 printk(KERN_WARNING "PCIE%d: Port in endpoint mode !\n",
1439 port->index);
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +11001440 return;
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +11001441 }
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +11001442
1443 /* Check if primary bridge */
1444 if (of_get_property(port->node, "primary", NULL))
1445 primary = 1;
1446
1447 /* Get bus range if any */
1448 bus_range = of_get_property(port->node, "bus-range", NULL);
1449
1450 /* Allocate the host controller data structure */
1451 hose = pcibios_alloc_controller(port->node);
1452 if (!hose)
1453 goto fail;
1454
1455 /* We stick the port number in "indirect_type" so the config space
1456 * ops can retrieve the port data structure easily
1457 */
1458 hose->indirect_type = port->index;
1459
1460 /* Get bus range */
1461 hose->first_busno = bus_range ? bus_range[0] : 0x0;
1462 hose->last_busno = bus_range ? bus_range[1] : 0xff;
1463
1464 /* Because of how big mapping the config space is (1M per bus), we
1465 * limit how many busses we support. In the long run, we could replace
1466 * that with something akin to kmap_atomic instead. We set aside 1 bus
1467 * for the host itself too.
1468 */
1469 busses = hose->last_busno - hose->first_busno; /* This is off by 1 */
1470 if (busses > MAX_PCIE_BUS_MAPPED) {
1471 busses = MAX_PCIE_BUS_MAPPED;
1472 hose->last_busno = hose->first_busno + busses;
1473 }
1474
1475 /* We map the external config space in cfg_data and the host config
1476 * space in cfg_addr. External space is 1M per bus, internal space
1477 * is 4K
1478 */
1479 cfg_data = ioremap(port->cfg_space.start +
1480 (hose->first_busno + 1) * 0x100000,
1481 busses * 0x100000);
1482 mbase = ioremap(port->cfg_space.start + 0x10000000, 0x1000);
1483 if (cfg_data == NULL || mbase == NULL) {
1484 printk(KERN_ERR "%s: Can't map config space !",
1485 port->node->full_name);
1486 goto fail;
1487 }
1488
1489 hose->cfg_data = cfg_data;
1490 hose->cfg_addr = mbase;
1491
1492 pr_debug("PCIE %s, bus %d..%d\n", port->node->full_name,
1493 hose->first_busno, hose->last_busno);
1494 pr_debug(" config space mapped at: root @0x%p, other @0x%p\n",
1495 hose->cfg_addr, hose->cfg_data);
1496
1497 /* Setup config space */
1498 hose->ops = &ppc4xx_pciex_pci_ops;
1499 port->hose = hose;
1500 mbase = (void __iomem *)hose->cfg_addr;
1501
1502 /*
1503 * Set bus numbers on our root port
1504 */
1505 out_8(mbase + PCI_PRIMARY_BUS, hose->first_busno);
1506 out_8(mbase + PCI_SECONDARY_BUS, hose->first_busno + 1);
1507 out_8(mbase + PCI_SUBORDINATE_BUS, hose->last_busno);
1508
1509 /*
1510 * OMRs are already reset, also disable PIMs
1511 */
1512 out_le32(mbase + PECFG_PIMEN, 0);
1513
1514 /* Parse outbound mapping resources */
1515 pci_process_bridge_OF_ranges(hose, port->node, primary);
1516
1517 /* Parse inbound mapping resources */
1518 if (ppc4xx_parse_dma_ranges(hose, mbase, &dma_window) != 0)
1519 goto fail;
1520
1521 /* Configure outbound ranges POMs */
1522 ppc4xx_configure_pciex_POMs(port, hose, mbase);
1523
1524 /* Configure inbound ranges PIMs */
1525 ppc4xx_configure_pciex_PIMs(port, hose, mbase, &dma_window);
1526
1527 /* The root complex doesn't show up if we don't set some vendor
1528 * and device IDs into it. Those are the same bogus one that the
1529 * initial code in arch/ppc add. We might want to change that.
1530 */
1531 out_le16(mbase + 0x200, 0xaaa0 + port->index);
1532 out_le16(mbase + 0x202, 0xbed0 + port->index);
1533
1534 /* Set Class Code to PCI-PCI bridge and Revision Id to 1 */
1535 out_le32(mbase + 0x208, 0x06040001);
1536
1537 printk(KERN_INFO "PCIE%d: successfully set as root-complex\n",
1538 port->index);
1539 return;
1540 fail:
1541 if (hose)
1542 pcibios_free_controller(hose);
1543 if (cfg_data)
1544 iounmap(cfg_data);
1545 if (mbase)
1546 iounmap(mbase);
1547}
1548
Benjamin Herrenschmidt5738ec62007-12-21 15:39:22 +11001549static void __init ppc4xx_probe_pciex_bridge(struct device_node *np)
1550{
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +11001551 struct ppc4xx_pciex_port *port;
1552 const u32 *pval;
1553 int portno;
1554 unsigned int dcrs;
1555
1556 /* First, proceed to core initialization as we assume there's
1557 * only one PCIe core in the system
1558 */
1559 if (ppc4xx_pciex_check_core_init(np))
1560 return;
1561
1562 /* Get the port number from the device-tree */
1563 pval = of_get_property(np, "port", NULL);
1564 if (pval == NULL) {
1565 printk(KERN_ERR "PCIE: Can't find port number for %s\n",
1566 np->full_name);
1567 return;
1568 }
1569 portno = *pval;
1570 if (portno >= ppc4xx_pciex_port_count) {
1571 printk(KERN_ERR "PCIE: port number out of range for %s\n",
1572 np->full_name);
1573 return;
1574 }
1575 port = &ppc4xx_pciex_ports[portno];
1576 port->index = portno;
1577 port->node = of_node_get(np);
1578 pval = of_get_property(np, "sdr-base", NULL);
1579 if (pval == NULL) {
1580 printk(KERN_ERR "PCIE: missing sdr-base for %s\n",
1581 np->full_name);
1582 return;
1583 }
1584 port->sdr_base = *pval;
1585
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +11001586 /* XXX Currently, we only support root complex mode */
1587 port->endpoint = 0;
1588
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +11001589 /* Fetch config space registers address */
1590 if (of_address_to_resource(np, 0, &port->cfg_space)) {
1591 printk(KERN_ERR "%s: Can't get PCI-E config space !",
1592 np->full_name);
1593 return;
1594 }
1595 /* Fetch host bridge internal registers address */
1596 if (of_address_to_resource(np, 1, &port->utl_regs)) {
1597 printk(KERN_ERR "%s: Can't get UTL register base !",
1598 np->full_name);
1599 return;
1600 }
1601
1602 /* Map DCRs */
1603 dcrs = dcr_resource_start(np, 0);
1604 if (dcrs == 0) {
1605 printk(KERN_ERR "%s: Can't get DCR register base !",
1606 np->full_name);
1607 return;
1608 }
1609 port->dcrs = dcr_map(np, dcrs, dcr_resource_len(np, 0));
1610
1611 /* Initialize the port specific registers */
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +11001612 if (ppc4xx_pciex_port_init(port)) {
1613 printk(KERN_WARNING "PCIE%d: Port init failed\n", port->index);
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +11001614 return;
Benjamin Herrenschmidt035ee422007-12-21 15:39:36 +11001615 }
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +11001616
1617 /* Setup the linux hose data structure */
1618 ppc4xx_pciex_port_setup_hose(port);
Benjamin Herrenschmidt5738ec62007-12-21 15:39:22 +11001619}
1620
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +11001621#endif /* CONFIG_PPC4xx_PCI_EXPRESS */
1622
Benjamin Herrenschmidt5738ec62007-12-21 15:39:22 +11001623static int __init ppc4xx_pci_find_bridges(void)
1624{
1625 struct device_node *np;
1626
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +11001627#ifdef CONFIG_PPC4xx_PCI_EXPRESS
Benjamin Herrenschmidt5738ec62007-12-21 15:39:22 +11001628 for_each_compatible_node(np, NULL, "ibm,plb-pciex")
1629 ppc4xx_probe_pciex_bridge(np);
Benjamin Herrenschmidta2d2e1e2007-12-21 15:39:24 +11001630#endif
Benjamin Herrenschmidt5738ec62007-12-21 15:39:22 +11001631 for_each_compatible_node(np, NULL, "ibm,plb-pcix")
1632 ppc4xx_probe_pcix_bridge(np);
1633 for_each_compatible_node(np, NULL, "ibm,plb-pci")
1634 ppc4xx_probe_pci_bridge(np);
1635
1636 return 0;
1637}
1638arch_initcall(ppc4xx_pci_find_bridges);
1639