blob: 9817f63723dd592d933c0dcf9de53b6a51805b8d [file] [log] [blame]
Jon Loeligerb809b3e2006-06-17 17:52:48 -05001/*
John Rigby5b70a092008-10-07 13:00:18 -06002 * MPC83xx/85xx/86xx PCI/PCIE support routing.
Jon Loeligerb809b3e2006-06-17 17:52:48 -05003 *
John Rigby5b70a092008-10-07 13:00:18 -06004 * Copyright 2007,2008 Freescale Semiconductor, Inc
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +08005 *
Jon Loeligerb809b3e2006-06-17 17:52:48 -05006 * Initial author: Xianghua Xiao <x.xiao@freescale.com>
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +08007 * Recode: ZHANG WEI <wei.zhang@freescale.com>
8 * Rewrite the routing for Frescale PCI and PCI Express
9 * Roy Zang <tie-fei.zang@freescale.com>
Jon Loeligerb809b3e2006-06-17 17:52:48 -050010 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 */
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +080016#include <linux/kernel.h>
Jon Loeligerb809b3e2006-06-17 17:52:48 -050017#include <linux/pci.h>
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +080018#include <linux/delay.h>
19#include <linux/string.h>
20#include <linux/init.h>
21#include <linux/bootmem.h>
Jon Loeligerb809b3e2006-06-17 17:52:48 -050022
Jon Loeligerb809b3e2006-06-17 17:52:48 -050023#include <asm/io.h>
24#include <asm/prom.h>
Jon Loeligerb809b3e2006-06-17 17:52:48 -050025#include <asm/pci-bridge.h>
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +080026#include <asm/machdep.h>
Jon Loeligerb809b3e2006-06-17 17:52:48 -050027#include <sysdev/fsl_soc.h>
Roy Zang55c44992007-07-10 18:44:34 +080028#include <sysdev/fsl_pci.h>
Jon Loeligerb809b3e2006-06-17 17:52:48 -050029
John Rigby76fe1ff2008-06-26 11:07:57 -060030#if defined(CONFIG_PPC_85xx) || defined(CONFIG_PPC_86xx)
Trent Piephoa097a782009-01-06 22:37:53 -060031static int __init setup_one_atmu(struct ccsr_pci __iomem *pci,
32 unsigned int index, const struct resource *res,
33 resource_size_t offset)
34{
35 resource_size_t pci_addr = res->start - offset;
36 resource_size_t phys_addr = res->start;
37 resource_size_t size = res->end - res->start + 1;
38 u32 flags = 0x80044000; /* enable & mem R/W */
39 unsigned int i;
40
41 pr_debug("PCI MEM resource start 0x%016llx, size 0x%016llx.\n",
42 (u64)res->start, (u64)size);
43
Trent Piepho565f3762008-12-17 11:43:26 -080044 if (res->flags & IORESOURCE_PREFETCH)
45 flags |= 0x10000000; /* enable relaxed ordering */
46
Trent Piephoa097a782009-01-06 22:37:53 -060047 for (i = 0; size > 0; i++) {
48 unsigned int bits = min(__ilog2(size),
49 __ffs(pci_addr | phys_addr));
50
51 if (index + i >= 5)
52 return -1;
53
54 out_be32(&pci->pow[index + i].potar, pci_addr >> 12);
55 out_be32(&pci->pow[index + i].potear, (u64)pci_addr >> 44);
56 out_be32(&pci->pow[index + i].powbar, phys_addr >> 12);
57 out_be32(&pci->pow[index + i].powar, flags | (bits - 1));
58
59 pci_addr += (resource_size_t)1U << bits;
60 phys_addr += (resource_size_t)1U << bits;
61 size -= (resource_size_t)1U << bits;
62 }
63
64 return i;
65}
66
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +080067/* atmu setup for fsl pci/pcie controller */
Anton Vorontsovc9dadff2008-12-29 19:40:32 +030068static void __init setup_pci_atmu(struct pci_controller *hose,
69 struct resource *rsrc)
Jon Loeligerb809b3e2006-06-17 17:52:48 -050070{
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +080071 struct ccsr_pci __iomem *pci;
Trent Piephoa097a782009-01-06 22:37:53 -060072 int i, j, n;
Jon Loeligerb809b3e2006-06-17 17:52:48 -050073
Kumar Gala72b122c2008-01-14 17:02:19 -060074 pr_debug("PCI memory map start 0x%016llx, size 0x%016llx\n",
75 (u64)rsrc->start, (u64)rsrc->end - (u64)rsrc->start + 1);
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +080076 pci = ioremap(rsrc->start, rsrc->end - rsrc->start + 1);
Trent Piephoa097a782009-01-06 22:37:53 -060077 if (!pci) {
78 dev_err(hose->parent, "Unable to map ATMU registers\n");
79 return;
80 }
Jon Loeligerb809b3e2006-06-17 17:52:48 -050081
Trent Piephoa097a782009-01-06 22:37:53 -060082 /* Disable all windows (except powar0 since it's ignored) */
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +080083 for(i = 1; i < 5; i++)
84 out_be32(&pci->pow[i].powar, 0);
85 for(i = 0; i < 3; i++)
86 out_be32(&pci->piw[i].piwar, 0);
Jon Loeligerb809b3e2006-06-17 17:52:48 -050087
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +080088 /* Setup outbound MEM window */
Trent Piephoa097a782009-01-06 22:37:53 -060089 for(i = 0, j = 1; i < 3; i++) {
90 if (!(hose->mem_resources[i].flags & IORESOURCE_MEM))
91 continue;
92
93 n = setup_one_atmu(pci, j, &hose->mem_resources[i],
94 hose->pci_mem_offset);
95
96 if (n < 0 || j >= 5) {
97 pr_err("Ran out of outbound PCI ATMUs for resource %d!\n", i);
98 hose->mem_resources[i].flags |= IORESOURCE_DISABLED;
99 } else
100 j += n;
101 }
Jon Loeligerb809b3e2006-06-17 17:52:48 -0500102
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +0800103 /* Setup outbound IO window */
Trent Piephoa097a782009-01-06 22:37:53 -0600104 if (hose->io_resource.flags & IORESOURCE_IO) {
105 if (j >= 5) {
106 pr_err("Ran out of outbound PCI ATMUs for IO resource\n");
107 } else {
108 pr_debug("PCI IO resource start 0x%016llx, size 0x%016llx, "
109 "phy base 0x%016llx.\n",
110 (u64)hose->io_resource.start,
111 (u64)hose->io_resource.end - (u64)hose->io_resource.start + 1,
112 (u64)hose->io_base_phys);
113 out_be32(&pci->pow[j].potar, (hose->io_resource.start >> 12));
114 out_be32(&pci->pow[j].potear, 0);
115 out_be32(&pci->pow[j].powbar, (hose->io_base_phys >> 12));
116 /* Enable, IO R/W */
117 out_be32(&pci->pow[j].powar, 0x80088000
118 | (__ilog2(hose->io_resource.end
119 - hose->io_resource.start + 1) - 1));
120 }
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +0800121 }
Jon Loeligerb809b3e2006-06-17 17:52:48 -0500122
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +0800123 /* Setup 2G inbound Memory Window @ 1 */
124 out_be32(&pci->piw[2].pitar, 0x00000000);
125 out_be32(&pci->piw[2].piwbar,0x00000000);
126 out_be32(&pci->piw[2].piwar, PIWAR_2G);
Trent Piephoa097a782009-01-06 22:37:53 -0600127
128 iounmap(pci);
Jon Loeligerb809b3e2006-06-17 17:52:48 -0500129}
130
Anton Vorontsovc9dadff2008-12-29 19:40:32 +0300131static void __init setup_pci_cmd(struct pci_controller *hose)
Jon Loeligerb809b3e2006-06-17 17:52:48 -0500132{
Jon Loeligerb809b3e2006-06-17 17:52:48 -0500133 u16 cmd;
Kumar Galaeb12af42007-07-20 16:29:09 -0500134 int cap_x;
135
Jon Loeligerb809b3e2006-06-17 17:52:48 -0500136 early_read_config_word(hose, 0, 0, PCI_COMMAND, &cmd);
137 cmd |= PCI_COMMAND_SERR | PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +0800138 | PCI_COMMAND_IO;
Jon Loeligerb809b3e2006-06-17 17:52:48 -0500139 early_write_config_word(hose, 0, 0, PCI_COMMAND, cmd);
Kumar Galaeb12af42007-07-20 16:29:09 -0500140
141 cap_x = early_find_capability(hose, 0, 0, PCI_CAP_ID_PCIX);
142 if (cap_x) {
143 int pci_x_cmd = cap_x + PCI_X_CMD;
144 cmd = PCI_X_CMD_MAX_SPLIT | PCI_X_CMD_MAX_READ
145 | PCI_X_CMD_ERO | PCI_X_CMD_DPERR_E;
146 early_write_config_word(hose, 0, 0, pci_x_cmd, cmd);
147 } else {
148 early_write_config_byte(hose, 0, 0, PCI_LATENCY_TIMER, 0x80);
149 }
Kumar Gala9ad494f2006-06-28 00:37:45 -0500150}
151
Anton Vorontsov692d1032008-05-23 17:41:02 +0400152static void __init setup_pci_pcsrbar(struct pci_controller *hose)
Jason Jin34e36c12008-05-23 16:32:46 +0800153{
Anton Vorontsov692d1032008-05-23 17:41:02 +0400154#ifdef CONFIG_PCI_MSI
Jason Jin34e36c12008-05-23 16:32:46 +0800155 phys_addr_t immr_base;
156
157 immr_base = get_immrbase();
158 early_write_config_dword(hose, 0, 0, PCI_BASE_ADDRESS_0, immr_base);
Jason Jin34e36c12008-05-23 16:32:46 +0800159#endif
Anton Vorontsov692d1032008-05-23 17:41:02 +0400160}
Jason Jin34e36c12008-05-23 16:32:46 +0800161
Kumar Gala72b122c2008-01-14 17:02:19 -0600162static int fsl_pcie_bus_fixup;
Zhang Wei20243c72007-06-26 18:22:40 -0500163
Kumar Gala72b122c2008-01-14 17:02:19 -0600164static void __init quirk_fsl_pcie_header(struct pci_dev *dev)
165{
Kumar Gala957ecff2007-07-11 13:31:58 -0500166 /* if we aren't a PCIe don't bother */
167 if (!pci_find_capability(dev, PCI_CAP_ID_EXP))
168 return ;
169
Kumar Gala72b122c2008-01-14 17:02:19 -0600170 dev->class = PCI_CLASS_BRIDGE_PCI << 8;
171 fsl_pcie_bus_fixup = 1;
172 return ;
Zhang Wei20243c72007-06-26 18:22:40 -0500173}
174
Anton Vorontsovc9dadff2008-12-29 19:40:32 +0300175static int __init fsl_pcie_check_link(struct pci_controller *hose)
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +0800176{
Kumar Gala2fce12252007-10-03 23:37:33 -0500177 u32 val;
178 early_read_config_dword(hose, 0, 0, PCIE_LTSSM, &val);
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +0800179 if (val < PCIE_LTSSM_L0)
180 return 1;
181 return 0;
182}
Zhang Wei20243c72007-06-26 18:22:40 -0500183
Kumar Gala6c0a11c2007-07-19 15:29:53 -0500184void fsl_pcibios_fixup_bus(struct pci_bus *bus)
185{
186 struct pci_controller *hose = (struct pci_controller *) bus->sysdata;
187 int i;
188
Kumar Gala72b122c2008-01-14 17:02:19 -0600189 if ((bus->parent == hose->bus) &&
190 ((fsl_pcie_bus_fixup &&
191 early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP)) ||
192 (hose->indirect_type & PPC_INDIRECT_TYPE_NO_PCIE_LINK)))
193 {
194 for (i = 0; i < 4; ++i) {
195 struct resource *res = bus->resource[i];
196 struct resource *par = bus->parent->resource[i];
197 if (res) {
198 res->start = 0;
199 res->end = 0;
200 res->flags = 0;
201 }
202 if (res && par) {
203 res->start = par->start;
204 res->end = par->end;
205 res->flags = par->flags;
206 }
Kumar Gala6c0a11c2007-07-19 15:29:53 -0500207 }
208 }
209}
210
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +0800211int __init fsl_add_bridge(struct device_node *dev, int is_primary)
Jon Loeligerb809b3e2006-06-17 17:52:48 -0500212{
213 int len;
214 struct pci_controller *hose;
215 struct resource rsrc;
Jeremy Kerr8efca492006-07-12 15:39:42 +1000216 const int *bus_range;
Jon Loeligerb809b3e2006-06-17 17:52:48 -0500217
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +0800218 pr_debug("Adding PCI host bridge %s\n", dev->full_name);
Jon Loeligerb809b3e2006-06-17 17:52:48 -0500219
220 /* Fetch host bridge registers address */
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +0800221 if (of_address_to_resource(dev, 0, &rsrc)) {
222 printk(KERN_WARNING "Can't get pci register base!");
223 return -ENOMEM;
224 }
Jon Loeligerb809b3e2006-06-17 17:52:48 -0500225
226 /* Get bus range if any */
Stephen Rothwelle2eb6392007-04-03 22:26:41 +1000227 bus_range = of_get_property(dev, "bus-range", &len);
Jon Loeligerb809b3e2006-06-17 17:52:48 -0500228 if (bus_range == NULL || len < 2 * sizeof(int))
229 printk(KERN_WARNING "Can't get bus-range for %s, assume"
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +0800230 " bus 0\n", dev->full_name);
Jon Loeligerb809b3e2006-06-17 17:52:48 -0500231
Josh Boyer7fe519c2008-12-11 09:46:44 +0000232 ppc_pci_add_flags(PPC_PCI_REASSIGN_ALL_BUS);
Kumar Galadbf84712007-06-27 01:56:50 -0500233 hose = pcibios_alloc_controller(dev);
Jon Loeligerb809b3e2006-06-17 17:52:48 -0500234 if (!hose)
235 return -ENOMEM;
Kumar Galadbf84712007-06-27 01:56:50 -0500236
Jon Loeligerb809b3e2006-06-17 17:52:48 -0500237 hose->first_busno = bus_range ? bus_range[0] : 0x0;
Zhang Weibf7c0362007-05-22 11:38:26 +0800238 hose->last_busno = bus_range ? bus_range[1] : 0xff;
Jon Loeligerb809b3e2006-06-17 17:52:48 -0500239
Kumar Gala2e56ff22007-07-19 16:07:35 -0500240 setup_indirect_pci(hose, rsrc.start, rsrc.start + 0x4,
241 PPC_INDIRECT_TYPE_BIG_ENDIAN);
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +0800242 setup_pci_cmd(hose);
Jon Loeligerb809b3e2006-06-17 17:52:48 -0500243
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +0800244 /* check PCI express link status */
Kumar Gala957ecff2007-07-11 13:31:58 -0500245 if (early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP)) {
Kumar Gala7659c032007-07-25 00:29:53 -0500246 hose->indirect_type |= PPC_INDIRECT_TYPE_EXT_REG |
Kumar Gala957ecff2007-07-11 13:31:58 -0500247 PPC_INDIRECT_TYPE_SURPRESS_PRIMARY_BUS;
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +0800248 if (fsl_pcie_check_link(hose))
Kumar Gala957ecff2007-07-11 13:31:58 -0500249 hose->indirect_type |= PPC_INDIRECT_TYPE_NO_PCIE_LINK;
250 }
Zhang Weie4725c22007-06-25 15:21:10 -0500251
joe@perches.comdf3c9012007-11-20 12:47:55 +1100252 printk(KERN_INFO "Found FSL PCI host bridge at 0x%016llx. "
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +0800253 "Firmware bus number: %d->%d\n",
254 (unsigned long long)rsrc.start, hose->first_busno,
255 hose->last_busno);
Jon Loeligerb809b3e2006-06-17 17:52:48 -0500256
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +0800257 pr_debug(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n",
Jon Loeligerb809b3e2006-06-17 17:52:48 -0500258 hose, hose->cfg_addr, hose->cfg_data);
259
260 /* Interpret the "ranges" property */
261 /* This also maps the I/O region and sets isa_io/mem_base */
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +0800262 pci_process_bridge_OF_ranges(hose, dev, is_primary);
Jon Loeligerb809b3e2006-06-17 17:52:48 -0500263
264 /* Setup PEX window registers */
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +0800265 setup_pci_atmu(hose, &rsrc);
Jon Loeligerb809b3e2006-06-17 17:52:48 -0500266
Jason Jin34e36c12008-05-23 16:32:46 +0800267 /* Setup PEXCSRBAR */
Jason Jin34e36c12008-05-23 16:32:46 +0800268 setup_pci_pcsrbar(hose);
Jon Loeligerb809b3e2006-06-17 17:52:48 -0500269 return 0;
270}
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +0800271
Kumar Gala72b122c2008-01-14 17:02:19 -0600272DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8548E, quirk_fsl_pcie_header);
273DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8548, quirk_fsl_pcie_header);
274DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8543E, quirk_fsl_pcie_header);
275DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8543, quirk_fsl_pcie_header);
276DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8547E, quirk_fsl_pcie_header);
277DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8545E, quirk_fsl_pcie_header);
278DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8545, quirk_fsl_pcie_header);
279DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8568E, quirk_fsl_pcie_header);
280DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8568, quirk_fsl_pcie_header);
281DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8567E, quirk_fsl_pcie_header);
282DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8567, quirk_fsl_pcie_header);
283DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8533E, quirk_fsl_pcie_header);
284DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8533, quirk_fsl_pcie_header);
285DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8544E, quirk_fsl_pcie_header);
286DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8544, quirk_fsl_pcie_header);
287DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8572E, quirk_fsl_pcie_header);
288DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8572, quirk_fsl_pcie_header);
Kumar Gala2f3804e2008-07-02 01:36:15 -0500289DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8536E, quirk_fsl_pcie_header);
290DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8536, quirk_fsl_pcie_header);
Kumar Gala72b122c2008-01-14 17:02:19 -0600291DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8641, quirk_fsl_pcie_header);
292DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8641D, quirk_fsl_pcie_header);
293DECLARE_PCI_FIXUP_HEADER(0x1957, PCI_DEVICE_ID_MPC8610, quirk_fsl_pcie_header);
John Rigby76fe1ff2008-06-26 11:07:57 -0600294#endif /* CONFIG_PPC_85xx || CONFIG_PPC_86xx */
295
John Rigby35225802008-10-07 15:13:18 -0600296#if defined(CONFIG_PPC_83xx) || defined(CONFIG_PPC_MPC512x)
John Rigby76fe1ff2008-06-26 11:07:57 -0600297int __init mpc83xx_add_bridge(struct device_node *dev)
298{
299 int len;
300 struct pci_controller *hose;
John Rigby5b70a092008-10-07 13:00:18 -0600301 struct resource rsrc_reg;
302 struct resource rsrc_cfg;
John Rigby76fe1ff2008-06-26 11:07:57 -0600303 const int *bus_range;
John Rigby5b70a092008-10-07 13:00:18 -0600304 int primary;
John Rigby76fe1ff2008-06-26 11:07:57 -0600305
306 pr_debug("Adding PCI host bridge %s\n", dev->full_name);
307
308 /* Fetch host bridge registers address */
John Rigby5b70a092008-10-07 13:00:18 -0600309 if (of_address_to_resource(dev, 0, &rsrc_reg)) {
310 printk(KERN_WARNING "Can't get pci register base!\n");
311 return -ENOMEM;
312 }
313
314 memset(&rsrc_cfg, 0, sizeof(rsrc_cfg));
315
316 if (of_address_to_resource(dev, 1, &rsrc_cfg)) {
317 printk(KERN_WARNING
318 "No pci config register base in dev tree, "
319 "using default\n");
320 /*
321 * MPC83xx supports up to two host controllers
322 * one at 0x8500 has config space registers at 0x8300
323 * one at 0x8600 has config space registers at 0x8380
324 */
325 if ((rsrc_reg.start & 0xfffff) == 0x8500)
326 rsrc_cfg.start = (rsrc_reg.start & 0xfff00000) + 0x8300;
327 else if ((rsrc_reg.start & 0xfffff) == 0x8600)
328 rsrc_cfg.start = (rsrc_reg.start & 0xfff00000) + 0x8380;
329 }
330 /*
331 * Controller at offset 0x8500 is primary
332 */
333 if ((rsrc_reg.start & 0xfffff) == 0x8500)
334 primary = 1;
335 else
336 primary = 0;
John Rigby76fe1ff2008-06-26 11:07:57 -0600337
338 /* Get bus range if any */
339 bus_range = of_get_property(dev, "bus-range", &len);
340 if (bus_range == NULL || len < 2 * sizeof(int)) {
341 printk(KERN_WARNING "Can't get bus-range for %s, assume"
342 " bus 0\n", dev->full_name);
343 }
344
Josh Boyer7fe519c2008-12-11 09:46:44 +0000345 ppc_pci_add_flags(PPC_PCI_REASSIGN_ALL_BUS);
John Rigby76fe1ff2008-06-26 11:07:57 -0600346 hose = pcibios_alloc_controller(dev);
347 if (!hose)
348 return -ENOMEM;
349
350 hose->first_busno = bus_range ? bus_range[0] : 0;
351 hose->last_busno = bus_range ? bus_range[1] : 0xff;
352
John Rigby5b70a092008-10-07 13:00:18 -0600353 setup_indirect_pci(hose, rsrc_cfg.start, rsrc_cfg.start + 4, 0);
John Rigby76fe1ff2008-06-26 11:07:57 -0600354
John Rigby35225802008-10-07 15:13:18 -0600355 printk(KERN_INFO "Found FSL PCI host bridge at 0x%016llx. "
John Rigby76fe1ff2008-06-26 11:07:57 -0600356 "Firmware bus number: %d->%d\n",
John Rigby5b70a092008-10-07 13:00:18 -0600357 (unsigned long long)rsrc_reg.start, hose->first_busno,
John Rigby76fe1ff2008-06-26 11:07:57 -0600358 hose->last_busno);
359
360 pr_debug(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n",
361 hose, hose->cfg_addr, hose->cfg_data);
362
363 /* Interpret the "ranges" property */
364 /* This also maps the I/O region and sets isa_io/mem_base */
365 pci_process_bridge_OF_ranges(hose, dev, primary);
366
367 return 0;
368}
369#endif /* CONFIG_PPC_83xx */