2 * PCI / PCI-X / PCI-Express support for 4xx parts
4 * Copyright 2007 Ben. Herrenschmidt <benh@kernel.crashing.org>, IBM Corp.
6 * Most PCI Express code is coming from Stefan Roese implementation for
7 * arch/ppc in the Denx tree, slightly reworked by me.
9 * Copyright 2007 DENX Software Engineering, Stefan Roese <sr@denx.de>
11 * Some of that comes itself from a previous implementation for 440SPE only
14 * Copyright (c) 2005 Cisco Systems. All rights reserved.
15 * Roland Dreier <rolandd@cisco.com>
21 #include <linux/kernel.h>
22 #include <linux/pci.h>
23 #include <linux/init.h>
25 #include <linux/bootmem.h>
26 #include <linux/delay.h>
29 #include <asm/pci-bridge.h>
30 #include <asm/machdep.h>
32 #include <asm/dcr-regs.h>
34 #include "ppc4xx_pci.h"
36 static int dma_offset_set;
38 /* Move that to a useable header */
39 extern unsigned long total_memory;
41 #define U64_TO_U32_LOW(val) ((u32)((val) & 0x00000000ffffffffULL))
42 #define U64_TO_U32_HIGH(val) ((u32)((val) >> 32))
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)
48 #define RES_TO_U32_LOW(val) (val)
49 #define RES_TO_U32_HIGH(val) (0)
52 static void fixup_ppc4xx_pci_bridge(struct pci_dev *dev)
54 struct pci_controller *hose;
57 if (dev->devfn != 0 || dev->bus->self != NULL)
60 hose = pci_bus_to_host(dev->bus);
64 if (!of_device_is_compatible(hose->dn, "ibm,plb-pciex") &&
65 !of_device_is_compatible(hose->dn, "ibm,plb-pcix") &&
66 !of_device_is_compatible(hose->dn, "ibm,plb-pci"))
69 /* Hide the PCI host BARs from the kernel as their content doesn't
70 * fit well in the resource management
72 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
73 dev->resource[i].start = dev->resource[i].end = 0;
74 dev->resource[i].flags = 0;
77 printk(KERN_INFO "PCI: Hiding 4xx host bridge resources %s\n",
80 DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, fixup_ppc4xx_pci_bridge);
82 static int __init ppc4xx_parse_dma_ranges(struct pci_controller *hose,
89 int pna = of_n_addr_cells(hose->dn);
94 res->end = size = 0x80000000;
95 res->flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
97 /* Get dma-ranges property */
98 ranges = of_get_property(hose->dn, "dma-ranges", &rlen);
103 while ((rlen -= np * 4) >= 0) {
104 u32 pci_space = ranges[0];
105 u64 pci_addr = of_read_number(ranges + 1, 2);
106 u64 cpu_addr = of_translate_dma_address(hose->dn, ranges + 3);
107 size = of_read_number(ranges + pna + 3, 2);
109 if (cpu_addr == OF_BAD_ADDR || size == 0)
112 /* We only care about memory */
113 if ((pci_space & 0x03000000) != 0x02000000)
116 /* We currently only support memory at 0, and pci_addr
117 * within 32 bits space
119 if (cpu_addr != 0 || pci_addr > 0xffffffff) {
120 printk(KERN_WARNING "%s: Ignored unsupported dma range"
121 " 0x%016llx...0x%016llx -> 0x%016llx\n",
123 pci_addr, pci_addr + size - 1, cpu_addr);
127 /* Check if not prefetchable */
128 if (!(pci_space & 0x40000000))
129 res->flags &= ~IORESOURCE_PREFETCH;
133 res->start = pci_addr;
134 #ifndef CONFIG_RESOURCES_64BIT
135 /* Beware of 32 bits resources */
136 if ((pci_addr + size) > 0x100000000ull)
137 res->end = 0xffffffff;
140 res->end = res->start + size - 1;
144 /* We only support one global DMA offset */
145 if (dma_offset_set && pci_dram_offset != res->start) {
146 printk(KERN_ERR "%s: dma-ranges(s) mismatch\n",
147 hose->dn->full_name);
151 /* Check that we can fit all of memory as we don't support
154 if (size < total_memory) {
155 printk(KERN_ERR "%s: dma-ranges too small "
156 "(size=%llx total_memory=%lx)\n",
157 hose->dn->full_name, size, total_memory);
161 /* Check we are a power of 2 size and that base is a multiple of size*/
162 if (!is_power_of_2(size) ||
163 (res->start & (size - 1)) != 0) {
164 printk(KERN_ERR "%s: dma-ranges unaligned\n",
165 hose->dn->full_name);
169 /* Check that we are fully contained within 32 bits space */
170 if (res->end > 0xffffffff) {
171 printk(KERN_ERR "%s: dma-ranges outside of 32 bits space\n",
172 hose->dn->full_name);
177 pci_dram_offset = res->start;
179 printk(KERN_INFO "4xx PCI DMA offset set to 0x%08lx\n",
188 static void __init ppc4xx_configure_pci_PMMs(struct pci_controller *hose,
191 u32 la, ma, pcila, pciha;
194 /* Setup outbound memory windows */
195 for (i = j = 0; i < 3; i++) {
196 struct resource *res = &hose->mem_resources[i];
198 /* we only care about memory windows */
199 if (!(res->flags & IORESOURCE_MEM))
202 printk(KERN_WARNING "%s: Too many ranges\n",
203 hose->dn->full_name);
207 /* Calculate register values */
209 pciha = RES_TO_U32_HIGH(res->start - hose->pci_mem_offset);
210 pcila = RES_TO_U32_LOW(res->start - hose->pci_mem_offset);
212 ma = res->end + 1 - res->start;
213 if (!is_power_of_2(ma) || ma < 0x1000 || ma > 0xffffffffu) {
214 printk(KERN_WARNING "%s: Resource out of range\n",
215 hose->dn->full_name);
218 ma = (0xffffffffu << ilog2(ma)) | 0x1;
219 if (res->flags & IORESOURCE_PREFETCH)
222 /* Program register values */
223 writel(la, reg + PCIL0_PMM0LA + (0x10 * j));
224 writel(pcila, reg + PCIL0_PMM0PCILA + (0x10 * j));
225 writel(pciha, reg + PCIL0_PMM0PCIHA + (0x10 * j));
226 writel(ma, reg + PCIL0_PMM0MA + (0x10 * j));
231 static void __init ppc4xx_configure_pci_PTMs(struct pci_controller *hose,
233 const struct resource *res)
235 resource_size_t size = res->end - res->start + 1;
238 /* Calculate window size */
239 sa = (0xffffffffu << ilog2(size)) | 1;
242 /* RAM is always at 0 local for now */
243 writel(0, reg + PCIL0_PTM1LA);
244 writel(sa, reg + PCIL0_PTM1MS);
246 /* Map on PCI side */
247 early_write_config_dword(hose, hose->first_busno, 0,
248 PCI_BASE_ADDRESS_1, res->start);
249 early_write_config_dword(hose, hose->first_busno, 0,
250 PCI_BASE_ADDRESS_2, 0x00000000);
251 early_write_config_word(hose, hose->first_busno, 0,
252 PCI_COMMAND, 0x0006);
255 static void __init ppc4xx_probe_pci_bridge(struct device_node *np)
258 struct resource rsrc_cfg;
259 struct resource rsrc_reg;
260 struct resource dma_window;
261 struct pci_controller *hose = NULL;
262 void __iomem *reg = NULL;
263 const int *bus_range;
266 /* Fetch config space registers address */
267 if (of_address_to_resource(np, 0, &rsrc_cfg)) {
268 printk(KERN_ERR "%s:Can't get PCI config register base !",
272 /* Fetch host bridge internal registers address */
273 if (of_address_to_resource(np, 3, &rsrc_reg)) {
274 printk(KERN_ERR "%s: Can't get PCI internal register base !",
279 /* Check if primary bridge */
280 if (of_get_property(np, "primary", NULL))
283 /* Get bus range if any */
284 bus_range = of_get_property(np, "bus-range", NULL);
287 reg = ioremap(rsrc_reg.start, rsrc_reg.end + 1 - rsrc_reg.start);
289 printk(KERN_ERR "%s: Can't map registers !", np->full_name);
293 /* Allocate the host controller data structure */
294 hose = pcibios_alloc_controller(np);
298 hose->first_busno = bus_range ? bus_range[0] : 0x0;
299 hose->last_busno = bus_range ? bus_range[1] : 0xff;
301 /* Setup config space */
302 setup_indirect_pci(hose, rsrc_cfg.start, rsrc_cfg.start + 0x4, 0);
304 /* Disable all windows */
305 writel(0, reg + PCIL0_PMM0MA);
306 writel(0, reg + PCIL0_PMM1MA);
307 writel(0, reg + PCIL0_PMM2MA);
308 writel(0, reg + PCIL0_PTM1MS);
309 writel(0, reg + PCIL0_PTM2MS);
311 /* Parse outbound mapping resources */
312 pci_process_bridge_OF_ranges(hose, np, primary);
314 /* Parse inbound mapping resources */
315 if (ppc4xx_parse_dma_ranges(hose, reg, &dma_window) != 0)
318 /* Configure outbound ranges POMs */
319 ppc4xx_configure_pci_PMMs(hose, reg);
321 /* Configure inbound ranges PIMs */
322 ppc4xx_configure_pci_PTMs(hose, reg, &dma_window);
324 /* We don't need the registers anymore */
330 pcibios_free_controller(hose);
339 static void __init ppc4xx_configure_pcix_POMs(struct pci_controller *hose,
342 u32 lah, lal, pciah, pcial, sa;
345 /* Setup outbound memory windows */
346 for (i = j = 0; i < 3; i++) {
347 struct resource *res = &hose->mem_resources[i];
349 /* we only care about memory windows */
350 if (!(res->flags & IORESOURCE_MEM))
353 printk(KERN_WARNING "%s: Too many ranges\n",
354 hose->dn->full_name);
358 /* Calculate register values */
359 lah = RES_TO_U32_HIGH(res->start);
360 lal = RES_TO_U32_LOW(res->start);
361 pciah = RES_TO_U32_HIGH(res->start - hose->pci_mem_offset);
362 pcial = RES_TO_U32_LOW(res->start - hose->pci_mem_offset);
363 sa = res->end + 1 - res->start;
364 if (!is_power_of_2(sa) || sa < 0x100000 ||
366 printk(KERN_WARNING "%s: Resource out of range\n",
367 hose->dn->full_name);
370 sa = (0xffffffffu << ilog2(sa)) | 0x1;
372 /* Program register values */
374 writel(lah, reg + PCIX0_POM0LAH);
375 writel(lal, reg + PCIX0_POM0LAL);
376 writel(pciah, reg + PCIX0_POM0PCIAH);
377 writel(pcial, reg + PCIX0_POM0PCIAL);
378 writel(sa, reg + PCIX0_POM0SA);
380 writel(lah, reg + PCIX0_POM1LAH);
381 writel(lal, reg + PCIX0_POM1LAL);
382 writel(pciah, reg + PCIX0_POM1PCIAH);
383 writel(pcial, reg + PCIX0_POM1PCIAL);
384 writel(sa, reg + PCIX0_POM1SA);
390 static void __init ppc4xx_configure_pcix_PIMs(struct pci_controller *hose,
392 const struct resource *res,
396 resource_size_t size = res->end - res->start + 1;
399 /* RAM is always at 0 */
400 writel(0x00000000, reg + PCIX0_PIM0LAH);
401 writel(0x00000000, reg + PCIX0_PIM0LAL);
403 /* Calculate window size */
404 sa = (0xffffffffu << ilog2(size)) | 1;
406 if (res->flags & IORESOURCE_PREFETCH)
410 writel(sa, reg + PCIX0_PIM0SA);
412 writel(0xffffffff, reg + PCIX0_PIM0SAH);
414 /* Map on PCI side */
415 writel(0x00000000, reg + PCIX0_BAR0H);
416 writel(res->start, reg + PCIX0_BAR0L);
417 writew(0x0006, reg + PCIX0_COMMAND);
420 static void __init ppc4xx_probe_pcix_bridge(struct device_node *np)
422 struct resource rsrc_cfg;
423 struct resource rsrc_reg;
424 struct resource dma_window;
425 struct pci_controller *hose = NULL;
426 void __iomem *reg = NULL;
427 const int *bus_range;
428 int big_pim = 0, msi = 0, primary = 0;
430 /* Fetch config space registers address */
431 if (of_address_to_resource(np, 0, &rsrc_cfg)) {
432 printk(KERN_ERR "%s:Can't get PCI-X config register base !",
436 /* Fetch host bridge internal registers address */
437 if (of_address_to_resource(np, 3, &rsrc_reg)) {
438 printk(KERN_ERR "%s: Can't get PCI-X internal register base !",
443 /* Check if it supports large PIMs (440GX) */
444 if (of_get_property(np, "large-inbound-windows", NULL))
447 /* Check if we should enable MSIs inbound hole */
448 if (of_get_property(np, "enable-msi-hole", NULL))
451 /* Check if primary bridge */
452 if (of_get_property(np, "primary", NULL))
455 /* Get bus range if any */
456 bus_range = of_get_property(np, "bus-range", NULL);
459 reg = ioremap(rsrc_reg.start, rsrc_reg.end + 1 - rsrc_reg.start);
461 printk(KERN_ERR "%s: Can't map registers !", np->full_name);
465 /* Allocate the host controller data structure */
466 hose = pcibios_alloc_controller(np);
470 hose->first_busno = bus_range ? bus_range[0] : 0x0;
471 hose->last_busno = bus_range ? bus_range[1] : 0xff;
473 /* Setup config space */
474 setup_indirect_pci(hose, rsrc_cfg.start, rsrc_cfg.start + 0x4, 0);
476 /* Disable all windows */
477 writel(0, reg + PCIX0_POM0SA);
478 writel(0, reg + PCIX0_POM1SA);
479 writel(0, reg + PCIX0_POM2SA);
480 writel(0, reg + PCIX0_PIM0SA);
481 writel(0, reg + PCIX0_PIM1SA);
482 writel(0, reg + PCIX0_PIM2SA);
484 writel(0, reg + PCIX0_PIM0SAH);
485 writel(0, reg + PCIX0_PIM2SAH);
488 /* Parse outbound mapping resources */
489 pci_process_bridge_OF_ranges(hose, np, primary);
491 /* Parse inbound mapping resources */
492 if (ppc4xx_parse_dma_ranges(hose, reg, &dma_window) != 0)
495 /* Configure outbound ranges POMs */
496 ppc4xx_configure_pcix_POMs(hose, reg);
498 /* Configure inbound ranges PIMs */
499 ppc4xx_configure_pcix_PIMs(hose, reg, &dma_window, big_pim, msi);
501 /* We don't need the registers anymore */
507 pcibios_free_controller(hose);
512 #ifdef CONFIG_PPC4xx_PCI_EXPRESS
515 * 4xx PCI-Express part
517 * We support 3 parts currently based on the compatible property:
519 * ibm,plb-pciex-440speA
520 * ibm,plb-pciex-440speB
521 * ibm,plb-pciex-405ex
523 * Anything else will be rejected for now as they are all subtly
524 * different unfortunately.
528 #define MAX_PCIE_BUS_MAPPED 0x10
530 struct ppc4xx_pciex_port
532 struct pci_controller *hose;
533 struct device_node *node;
538 unsigned int sdr_base;
540 struct resource cfg_space;
541 struct resource utl_regs;
542 void __iomem *utl_base;
545 static struct ppc4xx_pciex_port *ppc4xx_pciex_ports;
546 static unsigned int ppc4xx_pciex_port_count;
548 struct ppc4xx_pciex_hwops
550 int (*core_init)(struct device_node *np);
551 int (*port_init_hw)(struct ppc4xx_pciex_port *port);
552 int (*setup_utl)(struct ppc4xx_pciex_port *port);
555 static struct ppc4xx_pciex_hwops *ppc4xx_pciex_hwops;
559 /* Check various reset bits of the 440SPe PCIe core */
560 static int __init ppc440spe_pciex_check_reset(struct device_node *np)
562 u32 valPE0, valPE1, valPE2;
565 /* SDR0_PEGPLLLCT1 reset */
566 if (!(mfdcri(SDR0, PESDR0_PLLLCT1) & 0x01000000)) {
568 * the PCIe core was probably already initialised
569 * by firmware - let's re-reset RCSSET regs
571 * -- Shouldn't we also re-reset the whole thing ? -- BenH
573 pr_debug("PCIE: SDR0_PLLLCT1 already reset.\n");
574 mtdcri(SDR0, PESDR0_440SPE_RCSSET, 0x01010000);
575 mtdcri(SDR0, PESDR1_440SPE_RCSSET, 0x01010000);
576 mtdcri(SDR0, PESDR2_440SPE_RCSSET, 0x01010000);
579 valPE0 = mfdcri(SDR0, PESDR0_440SPE_RCSSET);
580 valPE1 = mfdcri(SDR0, PESDR1_440SPE_RCSSET);
581 valPE2 = mfdcri(SDR0, PESDR2_440SPE_RCSSET);
583 /* SDR0_PExRCSSET rstgu */
584 if (!(valPE0 & 0x01000000) ||
585 !(valPE1 & 0x01000000) ||
586 !(valPE2 & 0x01000000)) {
587 printk(KERN_INFO "PCIE: SDR0_PExRCSSET rstgu error\n");
591 /* SDR0_PExRCSSET rstdl */
592 if (!(valPE0 & 0x00010000) ||
593 !(valPE1 & 0x00010000) ||
594 !(valPE2 & 0x00010000)) {
595 printk(KERN_INFO "PCIE: SDR0_PExRCSSET rstdl error\n");
599 /* SDR0_PExRCSSET rstpyn */
600 if ((valPE0 & 0x00001000) ||
601 (valPE1 & 0x00001000) ||
602 (valPE2 & 0x00001000)) {
603 printk(KERN_INFO "PCIE: SDR0_PExRCSSET rstpyn error\n");
607 /* SDR0_PExRCSSET hldplb */
608 if ((valPE0 & 0x10000000) ||
609 (valPE1 & 0x10000000) ||
610 (valPE2 & 0x10000000)) {
611 printk(KERN_INFO "PCIE: SDR0_PExRCSSET hldplb error\n");
615 /* SDR0_PExRCSSET rdy */
616 if ((valPE0 & 0x00100000) ||
617 (valPE1 & 0x00100000) ||
618 (valPE2 & 0x00100000)) {
619 printk(KERN_INFO "PCIE: SDR0_PExRCSSET rdy error\n");
623 /* SDR0_PExRCSSET shutdown */
624 if ((valPE0 & 0x00000100) ||
625 (valPE1 & 0x00000100) ||
626 (valPE2 & 0x00000100)) {
627 printk(KERN_INFO "PCIE: SDR0_PExRCSSET shutdown error\n");
634 /* Global PCIe core initializations for 440SPe core */
635 static int __init ppc440spe_pciex_core_init(struct device_node *np)
639 /* Set PLL clock receiver to LVPECL */
640 mtdcri(SDR0, PESDR0_PLLLCT1, mfdcri(SDR0, PESDR0_PLLLCT1) | 1 << 28);
642 /* Shouldn't we do all the calibration stuff etc... here ? */
643 if (ppc440spe_pciex_check_reset(np))
646 if (!(mfdcri(SDR0, PESDR0_PLLLCT2) & 0x10000)) {
647 printk(KERN_INFO "PCIE: PESDR_PLLCT2 resistance calibration "
649 mfdcri(SDR0, PESDR0_PLLLCT2));
653 /* De-assert reset of PCIe PLL, wait for lock */
654 mtdcri(SDR0, PESDR0_PLLLCT1,
655 mfdcri(SDR0, PESDR0_PLLLCT1) & ~(1 << 24));
659 if (!(mfdcri(SDR0, PESDR0_PLLLCT3) & 0x10000000)) {
666 printk(KERN_INFO "PCIE: VCO output not locked\n");
670 pr_debug("PCIE initialization OK\n");
675 static int ppc440spe_pciex_init_port_hw(struct ppc4xx_pciex_port *port)
680 val = PTYPE_LEGACY_ENDPOINT << 20;
682 val = PTYPE_ROOT_PORT << 20;
684 if (port->index == 0)
685 val |= LNKW_X8 << 12;
687 val |= LNKW_X4 << 12;
689 mtdcri(SDR0, port->sdr_base + PESDRn_DLPSET, val);
690 mtdcri(SDR0, port->sdr_base + PESDRn_UTLSET1, 0x20222222);
691 if (of_device_is_compatible(port->node, "ibm,plb-pciex-440speA"))
692 mtdcri(SDR0, port->sdr_base + PESDRn_UTLSET2, 0x11000000);
693 mtdcri(SDR0, port->sdr_base + PESDRn_440SPE_HSSL0SET1, 0x35000000);
694 mtdcri(SDR0, port->sdr_base + PESDRn_440SPE_HSSL1SET1, 0x35000000);
695 mtdcri(SDR0, port->sdr_base + PESDRn_440SPE_HSSL2SET1, 0x35000000);
696 mtdcri(SDR0, port->sdr_base + PESDRn_440SPE_HSSL3SET1, 0x35000000);
697 if (port->index == 0) {
698 mtdcri(SDR0, port->sdr_base + PESDRn_440SPE_HSSL4SET1,
700 mtdcri(SDR0, port->sdr_base + PESDRn_440SPE_HSSL5SET1,
702 mtdcri(SDR0, port->sdr_base + PESDRn_440SPE_HSSL6SET1,
704 mtdcri(SDR0, port->sdr_base + PESDRn_440SPE_HSSL7SET1,
707 val = mfdcri(SDR0, port->sdr_base + PESDRn_RCSSET);
708 mtdcri(SDR0, port->sdr_base + PESDRn_RCSSET,
709 (val & ~(1 << 24 | 1 << 16)) | 1 << 12);
714 static int ppc440speA_pciex_init_port_hw(struct ppc4xx_pciex_port *port)
716 return ppc440spe_pciex_init_port_hw(port);
719 static int ppc440speB_pciex_init_port_hw(struct ppc4xx_pciex_port *port)
721 int rc = ppc440spe_pciex_init_port_hw(port);
728 static int ppc440speA_pciex_init_utl(struct ppc4xx_pciex_port *port)
730 /* XXX Check what that value means... I hate magic */
731 dcr_write(port->dcrs, DCRO_PEGPL_SPECIAL, 0x68782800);
734 * Set buffer allocations and then assert VRB and TXE.
736 out_be32(port->utl_base + PEUTL_OUTTR, 0x08000000);
737 out_be32(port->utl_base + PEUTL_INTR, 0x02000000);
738 out_be32(port->utl_base + PEUTL_OPDBSZ, 0x10000000);
739 out_be32(port->utl_base + PEUTL_PBBSZ, 0x53000000);
740 out_be32(port->utl_base + PEUTL_IPHBSZ, 0x08000000);
741 out_be32(port->utl_base + PEUTL_IPDBSZ, 0x10000000);
742 out_be32(port->utl_base + PEUTL_RCIRQEN, 0x00f00000);
743 out_be32(port->utl_base + PEUTL_PCTL, 0x80800066);
748 static int ppc440speB_pciex_init_utl(struct ppc4xx_pciex_port *port)
750 /* Report CRS to the operating system */
751 out_be32(port->utl_base + PEUTL_PBCTL, 0x08000000);
756 static struct ppc4xx_pciex_hwops ppc440speA_pcie_hwops __initdata =
758 .core_init = ppc440spe_pciex_core_init,
759 .port_init_hw = ppc440speA_pciex_init_port_hw,
760 .setup_utl = ppc440speA_pciex_init_utl,
763 static struct ppc4xx_pciex_hwops ppc440speB_pcie_hwops __initdata =
765 .core_init = ppc440spe_pciex_core_init,
766 .port_init_hw = ppc440speB_pciex_init_port_hw,
767 .setup_utl = ppc440speB_pciex_init_utl,
771 #endif /* CONFIG_44x */
775 static int __init ppc405ex_pciex_core_init(struct device_node *np)
777 /* Nothing to do, return 2 ports */
781 static void ppc405ex_pcie_phy_reset(struct ppc4xx_pciex_port *port)
783 /* Assert the PE0_PHY reset */
784 mtdcri(SDR0, port->sdr_base + PESDRn_RCSSET, 0x01010000);
787 /* deassert the PE0_hotreset */
789 mtdcri(SDR0, port->sdr_base + PESDRn_RCSSET, 0x01111000);
791 mtdcri(SDR0, port->sdr_base + PESDRn_RCSSET, 0x01101000);
793 /* poll for phy !reset */
794 /* XXX FIXME add timeout */
795 while (!(mfdcri(SDR0, port->sdr_base + PESDRn_405EX_PHYSTA) & 0x00001000))
798 /* deassert the PE0_gpl_utl_reset */
799 mtdcri(SDR0, port->sdr_base + PESDRn_RCSSET, 0x00101000);
802 static int ppc405ex_pciex_init_port_hw(struct ppc4xx_pciex_port *port)
807 val = PTYPE_LEGACY_ENDPOINT;
809 val = PTYPE_ROOT_PORT;
811 mtdcri(SDR0, port->sdr_base + PESDRn_DLPSET,
812 1 << 24 | val << 20 | LNKW_X1 << 12);
814 mtdcri(SDR0, port->sdr_base + PESDRn_UTLSET1, 0x00000000);
815 mtdcri(SDR0, port->sdr_base + PESDRn_UTLSET2, 0x01010000);
816 mtdcri(SDR0, port->sdr_base + PESDRn_405EX_PHYSET1, 0x720F0000);
817 mtdcri(SDR0, port->sdr_base + PESDRn_405EX_PHYSET2, 0x70600003);
820 * Only reset the PHY when no link is currently established.
821 * This is for the Atheros PCIe board which has problems to establish
822 * the link (again) after this PHY reset. All other currently tested
823 * PCIe boards don't show this problem.
824 * This has to be re-tested and fixed in a later release!
826 #if 0 /* XXX FIXME: Not resetting the PHY will leave all resources
827 * configured as done previously by U-Boot. Then Linux will currently
828 * not reassign them. So the PHY reset is now done always. This will
829 * lead to problems with the Atheros PCIe board again.
831 val = mfdcri(SDR0, port->sdr_base + PESDRn_LOOP);
832 if (!(val & 0x00001000))
833 ppc405ex_pcie_phy_reset(port);
835 ppc405ex_pcie_phy_reset(port);
838 dcr_write(port->dcrs, DCRO_PEGPL_CFG, 0x10000000); /* guarded on */
843 static int ppc405ex_pciex_init_utl(struct ppc4xx_pciex_port *port)
845 dcr_write(port->dcrs, DCRO_PEGPL_SPECIAL, 0x0);
848 * Set buffer allocations and then assert VRB and TXE.
850 out_be32(port->utl_base + PEUTL_OUTTR, 0x02000000);
851 out_be32(port->utl_base + PEUTL_INTR, 0x02000000);
852 out_be32(port->utl_base + PEUTL_OPDBSZ, 0x04000000);
853 out_be32(port->utl_base + PEUTL_PBBSZ, 0x21000000);
854 out_be32(port->utl_base + PEUTL_IPHBSZ, 0x02000000);
855 out_be32(port->utl_base + PEUTL_IPDBSZ, 0x04000000);
856 out_be32(port->utl_base + PEUTL_RCIRQEN, 0x00f00000);
857 out_be32(port->utl_base + PEUTL_PCTL, 0x80800066);
859 out_be32(port->utl_base + PEUTL_PBCTL, 0x08000000);
864 static struct ppc4xx_pciex_hwops ppc405ex_pcie_hwops __initdata =
866 .core_init = ppc405ex_pciex_core_init,
867 .port_init_hw = ppc405ex_pciex_init_port_hw,
868 .setup_utl = ppc405ex_pciex_init_utl,
871 #endif /* CONFIG_40x */
874 /* Check that the core has been initied and if not, do it */
875 static int __init ppc4xx_pciex_check_core_init(struct device_node *np)
877 static int core_init;
884 if (of_device_is_compatible(np, "ibm,plb-pciex-440speA"))
885 ppc4xx_pciex_hwops = &ppc440speA_pcie_hwops;
886 else if (of_device_is_compatible(np, "ibm,plb-pciex-440speB"))
887 ppc4xx_pciex_hwops = &ppc440speB_pcie_hwops;
888 #endif /* CONFIG_44x */
890 if (of_device_is_compatible(np, "ibm,plb-pciex-405ex"))
891 ppc4xx_pciex_hwops = &ppc405ex_pcie_hwops;
893 if (ppc4xx_pciex_hwops == NULL) {
894 printk(KERN_WARNING "PCIE: unknown host type %s\n",
899 count = ppc4xx_pciex_hwops->core_init(np);
902 kzalloc(count * sizeof(struct ppc4xx_pciex_port),
904 if (ppc4xx_pciex_ports) {
905 ppc4xx_pciex_port_count = count;
908 printk(KERN_WARNING "PCIE: failed to allocate ports array\n");
914 static void __init ppc4xx_pciex_port_init_mapping(struct ppc4xx_pciex_port *port)
916 /* We map PCI Express configuration based on the reg property */
917 dcr_write(port->dcrs, DCRO_PEGPL_CFGBAH,
918 RES_TO_U32_HIGH(port->cfg_space.start));
919 dcr_write(port->dcrs, DCRO_PEGPL_CFGBAL,
920 RES_TO_U32_LOW(port->cfg_space.start));
922 /* XXX FIXME: Use size from reg property. For now, map 512M */
923 dcr_write(port->dcrs, DCRO_PEGPL_CFGMSK, 0xe0000001);
925 /* We map UTL registers based on the reg property */
926 dcr_write(port->dcrs, DCRO_PEGPL_REGBAH,
927 RES_TO_U32_HIGH(port->utl_regs.start));
928 dcr_write(port->dcrs, DCRO_PEGPL_REGBAL,
929 RES_TO_U32_LOW(port->utl_regs.start));
931 /* XXX FIXME: Use size from reg property */
932 dcr_write(port->dcrs, DCRO_PEGPL_REGMSK, 0x00007001);
934 /* Disable all other outbound windows */
935 dcr_write(port->dcrs, DCRO_PEGPL_OMR1MSKL, 0);
936 dcr_write(port->dcrs, DCRO_PEGPL_OMR2MSKL, 0);
937 dcr_write(port->dcrs, DCRO_PEGPL_OMR3MSKL, 0);
938 dcr_write(port->dcrs, DCRO_PEGPL_MSGMSK, 0);
941 static int __init ppc4xx_pciex_wait_on_sdr(struct ppc4xx_pciex_port *port,
942 unsigned int sdr_offset,
949 while(timeout_ms--) {
950 val = mfdcri(SDR0, port->sdr_base + sdr_offset);
951 if ((val & mask) == value) {
952 pr_debug("PCIE%d: Wait on SDR %x success with tm %d (%08x)\n",
953 port->index, sdr_offset, timeout_ms, val);
961 static int __init ppc4xx_pciex_port_init(struct ppc4xx_pciex_port *port)
966 if (ppc4xx_pciex_hwops->port_init_hw)
967 rc = ppc4xx_pciex_hwops->port_init_hw(port);
971 printk(KERN_INFO "PCIE%d: Checking link...\n",
974 /* Wait for reset to complete */
975 if (ppc4xx_pciex_wait_on_sdr(port, PESDRn_RCSSTS, 1 << 20, 0, 10)) {
976 printk(KERN_WARNING "PCIE%d: PGRST failed\n",
981 /* Check for card presence detect if supported, if not, just wait for
982 * link unconditionally.
984 * note that we don't fail if there is no link, we just filter out
985 * config space accesses. That way, it will be easier to implement
988 if (!port->has_ibpre ||
989 !ppc4xx_pciex_wait_on_sdr(port, PESDRn_LOOP,
990 1 << 28, 1 << 28, 100)) {
992 "PCIE%d: Device detected, waiting for link...\n",
994 if (ppc4xx_pciex_wait_on_sdr(port, PESDRn_LOOP,
995 0x1000, 0x1000, 2000))
997 "PCIE%d: Link up failed\n", port->index);
1000 "PCIE%d: link is up !\n", port->index);
1004 printk(KERN_INFO "PCIE%d: No device detected.\n", port->index);
1007 * Initialize mapping: disable all regions and configure
1008 * CFG and REG regions based on resources in the device tree
1010 ppc4xx_pciex_port_init_mapping(port);
1015 port->utl_base = ioremap(port->utl_regs.start, 0x100);
1016 BUG_ON(port->utl_base == NULL);
1019 * Setup UTL registers --BenH.
1021 if (ppc4xx_pciex_hwops->setup_utl)
1022 ppc4xx_pciex_hwops->setup_utl(port);
1025 * Check for VC0 active and assert RDY.
1028 ppc4xx_pciex_wait_on_sdr(port, PESDRn_RCSSTS,
1029 1 << 16, 1 << 16, 5000)) {
1030 printk(KERN_INFO "PCIE%d: VC0 not active\n", port->index);
1034 mtdcri(SDR0, port->sdr_base + PESDRn_RCSSET,
1035 mfdcri(SDR0, port->sdr_base + PESDRn_RCSSET) | 1 << 20);
1041 static int ppc4xx_pciex_validate_bdf(struct ppc4xx_pciex_port *port,
1042 struct pci_bus *bus,
1047 /* Endpoint can not generate upstream(remote) config cycles */
1048 if (port->endpoint && bus->number != port->hose->first_busno)
1049 return PCIBIOS_DEVICE_NOT_FOUND;
1051 /* Check we are within the mapped range */
1052 if (bus->number > port->hose->last_busno) {
1054 printk(KERN_WARNING "Warning! Probing bus %u"
1055 " out of range !\n", bus->number);
1058 return PCIBIOS_DEVICE_NOT_FOUND;
1061 /* The root complex has only one device / function */
1062 if (bus->number == port->hose->first_busno && devfn != 0)
1063 return PCIBIOS_DEVICE_NOT_FOUND;
1065 /* The other side of the RC has only one device as well */
1066 if (bus->number == (port->hose->first_busno + 1) &&
1067 PCI_SLOT(devfn) != 0)
1068 return PCIBIOS_DEVICE_NOT_FOUND;
1070 /* Check if we have a link */
1071 if ((bus->number != port->hose->first_busno) && !port->link)
1072 return PCIBIOS_DEVICE_NOT_FOUND;
1077 static void __iomem *ppc4xx_pciex_get_config_base(struct ppc4xx_pciex_port *port,
1078 struct pci_bus *bus,
1083 /* Remove the casts when we finally remove the stupid volatile
1084 * in struct pci_controller
1086 if (bus->number == port->hose->first_busno)
1087 return (void __iomem *)port->hose->cfg_addr;
1089 relbus = bus->number - (port->hose->first_busno + 1);
1090 return (void __iomem *)port->hose->cfg_data +
1091 ((relbus << 20) | (devfn << 12));
1094 static int ppc4xx_pciex_read_config(struct pci_bus *bus, unsigned int devfn,
1095 int offset, int len, u32 *val)
1097 struct pci_controller *hose = (struct pci_controller *) bus->sysdata;
1098 struct ppc4xx_pciex_port *port =
1099 &ppc4xx_pciex_ports[hose->indirect_type];
1103 BUG_ON(hose != port->hose);
1105 if (ppc4xx_pciex_validate_bdf(port, bus, devfn) != 0)
1106 return PCIBIOS_DEVICE_NOT_FOUND;
1108 addr = ppc4xx_pciex_get_config_base(port, bus, devfn);
1111 * Reading from configuration space of non-existing device can
1112 * generate transaction errors. For the read duration we suppress
1113 * assertion of machine check exceptions to avoid those.
1115 gpl_cfg = dcr_read(port->dcrs, DCRO_PEGPL_CFG);
1116 dcr_write(port->dcrs, DCRO_PEGPL_CFG, gpl_cfg | GPL_DMER_MASK_DISA);
1118 /* Make sure no CRS is recorded */
1119 out_be32(port->utl_base + PEUTL_RCSTA, 0x00040000);
1123 *val = in_8((u8 *)(addr + offset));
1126 *val = in_le16((u16 *)(addr + offset));
1129 *val = in_le32((u32 *)(addr + offset));
1133 pr_debug("pcie-config-read: bus=%3d [%3d..%3d] devfn=0x%04x"
1134 " offset=0x%04x len=%d, addr=0x%p val=0x%08x\n",
1135 bus->number, hose->first_busno, hose->last_busno,
1136 devfn, offset, len, addr + offset, *val);
1138 /* Check for CRS (440SPe rev B does that for us but heh ..) */
1139 if (in_be32(port->utl_base + PEUTL_RCSTA) & 0x00040000) {
1140 pr_debug("Got CRS !\n");
1141 if (len != 4 || offset != 0)
1142 return PCIBIOS_DEVICE_NOT_FOUND;
1146 dcr_write(port->dcrs, DCRO_PEGPL_CFG, gpl_cfg);
1148 return PCIBIOS_SUCCESSFUL;
1151 static int ppc4xx_pciex_write_config(struct pci_bus *bus, unsigned int devfn,
1152 int offset, int len, u32 val)
1154 struct pci_controller *hose = (struct pci_controller *) bus->sysdata;
1155 struct ppc4xx_pciex_port *port =
1156 &ppc4xx_pciex_ports[hose->indirect_type];
1160 if (ppc4xx_pciex_validate_bdf(port, bus, devfn) != 0)
1161 return PCIBIOS_DEVICE_NOT_FOUND;
1163 addr = ppc4xx_pciex_get_config_base(port, bus, devfn);
1166 * Reading from configuration space of non-existing device can
1167 * generate transaction errors. For the read duration we suppress
1168 * assertion of machine check exceptions to avoid those.
1170 gpl_cfg = dcr_read(port->dcrs, DCRO_PEGPL_CFG);
1171 dcr_write(port->dcrs, DCRO_PEGPL_CFG, gpl_cfg | GPL_DMER_MASK_DISA);
1173 pr_debug("pcie-config-write: bus=%3d [%3d..%3d] devfn=0x%04x"
1174 " offset=0x%04x len=%d, addr=0x%p val=0x%08x\n",
1175 bus->number, hose->first_busno, hose->last_busno,
1176 devfn, offset, len, addr + offset, val);
1180 out_8((u8 *)(addr + offset), val);
1183 out_le16((u16 *)(addr + offset), val);
1186 out_le32((u32 *)(addr + offset), val);
1190 dcr_write(port->dcrs, DCRO_PEGPL_CFG, gpl_cfg);
1192 return PCIBIOS_SUCCESSFUL;
1195 static struct pci_ops ppc4xx_pciex_pci_ops =
1197 .read = ppc4xx_pciex_read_config,
1198 .write = ppc4xx_pciex_write_config,
1201 static void __init ppc4xx_configure_pciex_POMs(struct ppc4xx_pciex_port *port,
1202 struct pci_controller *hose,
1203 void __iomem *mbase)
1205 u32 lah, lal, pciah, pcial, sa;
1208 /* Setup outbound memory windows */
1209 for (i = j = 0; i < 3; i++) {
1210 struct resource *res = &hose->mem_resources[i];
1212 /* we only care about memory windows */
1213 if (!(res->flags & IORESOURCE_MEM))
1216 printk(KERN_WARNING "%s: Too many ranges\n",
1217 port->node->full_name);
1221 /* Calculate register values */
1222 lah = RES_TO_U32_HIGH(res->start);
1223 lal = RES_TO_U32_LOW(res->start);
1224 pciah = RES_TO_U32_HIGH(res->start - hose->pci_mem_offset);
1225 pcial = RES_TO_U32_LOW(res->start - hose->pci_mem_offset);
1226 sa = res->end + 1 - res->start;
1227 if (!is_power_of_2(sa) || sa < 0x100000 ||
1229 printk(KERN_WARNING "%s: Resource out of range\n",
1230 port->node->full_name);
1233 sa = (0xffffffffu << ilog2(sa)) | 0x1;
1235 /* Program register values */
1238 out_le32(mbase + PECFG_POM0LAH, pciah);
1239 out_le32(mbase + PECFG_POM0LAL, pcial);
1240 dcr_write(port->dcrs, DCRO_PEGPL_OMR1BAH, lah);
1241 dcr_write(port->dcrs, DCRO_PEGPL_OMR1BAL, lal);
1242 dcr_write(port->dcrs, DCRO_PEGPL_OMR1MSKH, 0x7fffffff);
1243 dcr_write(port->dcrs, DCRO_PEGPL_OMR1MSKL, sa | 3);
1246 out_le32(mbase + PECFG_POM1LAH, pciah);
1247 out_le32(mbase + PECFG_POM1LAL, pcial);
1248 dcr_write(port->dcrs, DCRO_PEGPL_OMR2BAH, lah);
1249 dcr_write(port->dcrs, DCRO_PEGPL_OMR2BAL, lal);
1250 dcr_write(port->dcrs, DCRO_PEGPL_OMR2MSKH, 0x7fffffff);
1251 dcr_write(port->dcrs, DCRO_PEGPL_OMR2MSKL, sa | 3);
1257 /* Configure IO, always 64K starting at 0 */
1258 if (hose->io_resource.flags & IORESOURCE_IO) {
1259 lah = RES_TO_U32_HIGH(hose->io_base_phys);
1260 lal = RES_TO_U32_LOW(hose->io_base_phys);
1261 out_le32(mbase + PECFG_POM2LAH, 0);
1262 out_le32(mbase + PECFG_POM2LAL, 0);
1263 dcr_write(port->dcrs, DCRO_PEGPL_OMR3BAH, lah);
1264 dcr_write(port->dcrs, DCRO_PEGPL_OMR3BAL, lal);
1265 dcr_write(port->dcrs, DCRO_PEGPL_OMR3MSKH, 0x7fffffff);
1266 dcr_write(port->dcrs, DCRO_PEGPL_OMR3MSKL, 0xffff0000 | 3);
1270 static void __init ppc4xx_configure_pciex_PIMs(struct ppc4xx_pciex_port *port,
1271 struct pci_controller *hose,
1272 void __iomem *mbase,
1273 struct resource *res)
1275 resource_size_t size = res->end - res->start + 1;
1278 /* Calculate window size */
1279 sa = (0xffffffffffffffffull << ilog2(size));;
1280 if (res->flags & IORESOURCE_PREFETCH)
1283 out_le32(mbase + PECFG_BAR0HMPA, RES_TO_U32_HIGH(sa));
1284 out_le32(mbase + PECFG_BAR0LMPA, RES_TO_U32_LOW(sa));
1286 /* The setup of the split looks weird to me ... let's see if it works */
1287 out_le32(mbase + PECFG_PIM0LAL, 0x00000000);
1288 out_le32(mbase + PECFG_PIM0LAH, 0x00000000);
1289 out_le32(mbase + PECFG_PIM1LAL, 0x00000000);
1290 out_le32(mbase + PECFG_PIM1LAH, 0x00000000);
1291 out_le32(mbase + PECFG_PIM01SAH, 0xffff0000);
1292 out_le32(mbase + PECFG_PIM01SAL, 0x00000000);
1294 /* Enable inbound mapping */
1295 out_le32(mbase + PECFG_PIMEN, 0x1);
1297 out_le32(mbase + PCI_BASE_ADDRESS_0, RES_TO_U32_LOW(res->start));
1298 out_le32(mbase + PCI_BASE_ADDRESS_1, RES_TO_U32_HIGH(res->start));
1300 /* Enable I/O, Mem, and Busmaster cycles */
1301 out_le16(mbase + PCI_COMMAND,
1302 in_le16(mbase + PCI_COMMAND) |
1303 PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
1306 static void __init ppc4xx_pciex_port_setup_hose(struct ppc4xx_pciex_port *port)
1308 struct resource dma_window;
1309 struct pci_controller *hose = NULL;
1310 const int *bus_range;
1311 int primary = 0, busses;
1312 void __iomem *mbase = NULL, *cfg_data = NULL;
1314 /* XXX FIXME: Handle endpoint mode properly */
1315 if (port->endpoint) {
1316 printk(KERN_WARNING "PCIE%d: Port in endpoint mode !\n",
1321 /* Check if primary bridge */
1322 if (of_get_property(port->node, "primary", NULL))
1325 /* Get bus range if any */
1326 bus_range = of_get_property(port->node, "bus-range", NULL);
1328 /* Allocate the host controller data structure */
1329 hose = pcibios_alloc_controller(port->node);
1333 /* We stick the port number in "indirect_type" so the config space
1334 * ops can retrieve the port data structure easily
1336 hose->indirect_type = port->index;
1339 hose->first_busno = bus_range ? bus_range[0] : 0x0;
1340 hose->last_busno = bus_range ? bus_range[1] : 0xff;
1342 /* Because of how big mapping the config space is (1M per bus), we
1343 * limit how many busses we support. In the long run, we could replace
1344 * that with something akin to kmap_atomic instead. We set aside 1 bus
1345 * for the host itself too.
1347 busses = hose->last_busno - hose->first_busno; /* This is off by 1 */
1348 if (busses > MAX_PCIE_BUS_MAPPED) {
1349 busses = MAX_PCIE_BUS_MAPPED;
1350 hose->last_busno = hose->first_busno + busses;
1353 /* We map the external config space in cfg_data and the host config
1354 * space in cfg_addr. External space is 1M per bus, internal space
1357 cfg_data = ioremap(port->cfg_space.start +
1358 (hose->first_busno + 1) * 0x100000,
1360 mbase = ioremap(port->cfg_space.start + 0x10000000, 0x1000);
1361 if (cfg_data == NULL || mbase == NULL) {
1362 printk(KERN_ERR "%s: Can't map config space !",
1363 port->node->full_name);
1367 hose->cfg_data = cfg_data;
1368 hose->cfg_addr = mbase;
1370 pr_debug("PCIE %s, bus %d..%d\n", port->node->full_name,
1371 hose->first_busno, hose->last_busno);
1372 pr_debug(" config space mapped at: root @0x%p, other @0x%p\n",
1373 hose->cfg_addr, hose->cfg_data);
1375 /* Setup config space */
1376 hose->ops = &ppc4xx_pciex_pci_ops;
1378 mbase = (void __iomem *)hose->cfg_addr;
1381 * Set bus numbers on our root port
1383 out_8(mbase + PCI_PRIMARY_BUS, hose->first_busno);
1384 out_8(mbase + PCI_SECONDARY_BUS, hose->first_busno + 1);
1385 out_8(mbase + PCI_SUBORDINATE_BUS, hose->last_busno);
1388 * OMRs are already reset, also disable PIMs
1390 out_le32(mbase + PECFG_PIMEN, 0);
1392 /* Parse outbound mapping resources */
1393 pci_process_bridge_OF_ranges(hose, port->node, primary);
1395 /* Parse inbound mapping resources */
1396 if (ppc4xx_parse_dma_ranges(hose, mbase, &dma_window) != 0)
1399 /* Configure outbound ranges POMs */
1400 ppc4xx_configure_pciex_POMs(port, hose, mbase);
1402 /* Configure inbound ranges PIMs */
1403 ppc4xx_configure_pciex_PIMs(port, hose, mbase, &dma_window);
1405 /* The root complex doesn't show up if we don't set some vendor
1406 * and device IDs into it. Those are the same bogus one that the
1407 * initial code in arch/ppc add. We might want to change that.
1409 out_le16(mbase + 0x200, 0xaaa0 + port->index);
1410 out_le16(mbase + 0x202, 0xbed0 + port->index);
1412 /* Set Class Code to PCI-PCI bridge and Revision Id to 1 */
1413 out_le32(mbase + 0x208, 0x06040001);
1415 printk(KERN_INFO "PCIE%d: successfully set as root-complex\n",
1420 pcibios_free_controller(hose);
1427 static void __init ppc4xx_probe_pciex_bridge(struct device_node *np)
1429 struct ppc4xx_pciex_port *port;
1434 /* First, proceed to core initialization as we assume there's
1435 * only one PCIe core in the system
1437 if (ppc4xx_pciex_check_core_init(np))
1440 /* Get the port number from the device-tree */
1441 pval = of_get_property(np, "port", NULL);
1443 printk(KERN_ERR "PCIE: Can't find port number for %s\n",
1448 if (portno >= ppc4xx_pciex_port_count) {
1449 printk(KERN_ERR "PCIE: port number out of range for %s\n",
1453 port = &ppc4xx_pciex_ports[portno];
1454 port->index = portno;
1455 port->node = of_node_get(np);
1456 pval = of_get_property(np, "sdr-base", NULL);
1458 printk(KERN_ERR "PCIE: missing sdr-base for %s\n",
1462 port->sdr_base = *pval;
1464 /* XXX Currently, we only support root complex mode */
1467 /* Fetch config space registers address */
1468 if (of_address_to_resource(np, 0, &port->cfg_space)) {
1469 printk(KERN_ERR "%s: Can't get PCI-E config space !",
1473 /* Fetch host bridge internal registers address */
1474 if (of_address_to_resource(np, 1, &port->utl_regs)) {
1475 printk(KERN_ERR "%s: Can't get UTL register base !",
1481 dcrs = dcr_resource_start(np, 0);
1483 printk(KERN_ERR "%s: Can't get DCR register base !",
1487 port->dcrs = dcr_map(np, dcrs, dcr_resource_len(np, 0));
1489 /* Initialize the port specific registers */
1490 if (ppc4xx_pciex_port_init(port)) {
1491 printk(KERN_WARNING "PCIE%d: Port init failed\n", port->index);
1495 /* Setup the linux hose data structure */
1496 ppc4xx_pciex_port_setup_hose(port);
1499 #endif /* CONFIG_PPC4xx_PCI_EXPRESS */
1501 static int __init ppc4xx_pci_find_bridges(void)
1503 struct device_node *np;
1505 #ifdef CONFIG_PPC4xx_PCI_EXPRESS
1506 for_each_compatible_node(np, NULL, "ibm,plb-pciex")
1507 ppc4xx_probe_pciex_bridge(np);
1509 for_each_compatible_node(np, NULL, "ibm,plb-pcix")
1510 ppc4xx_probe_pcix_bridge(np);
1511 for_each_compatible_node(np, NULL, "ibm,plb-pci")
1512 ppc4xx_probe_pci_bridge(np);
1516 arch_initcall(ppc4xx_pci_find_bridges);