diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2009-08-28 04:58:16 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-09-02 01:45:53 -0400 |
commit | 0ed2c722c650513ba4bce868c7a052e576c060e2 (patch) | |
tree | 6b679585a9c2afa871f81dc9da90af9b79c49c02 | |
parent | c5b20d3926dfc9616265b8ff5967cb7a476f9344 (diff) |
powerpc/pci: Merge ppc32 and ppc64 versions of phb_scan()
The two versions are doing almost exactly the same thing. No need to
maintain them as separate files. This patch also has the side effect
of making the PCI device tree scanning code available to 32 bit powerpc
machines, but no board ports actually make use of this feature at this
point.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Kumar Gala <galak@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r-- | arch/powerpc/include/asm/pci.h | 2 | ||||
-rw-r--r-- | arch/powerpc/include/asm/ppc-pci.h | 1 | ||||
-rw-r--r-- | arch/powerpc/kernel/of_platform.c | 2 | ||||
-rw-r--r-- | arch/powerpc/kernel/pci-common.c | 49 | ||||
-rw-r--r-- | arch/powerpc/kernel/pci_32.c | 25 | ||||
-rw-r--r-- | arch/powerpc/kernel/pci_64.c | 46 | ||||
-rw-r--r-- | arch/powerpc/platforms/pseries/pci_dlpar.c | 2 |
7 files changed, 61 insertions, 66 deletions
diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h index b856a837b4a3..7aca4839387b 100644 --- a/arch/powerpc/include/asm/pci.h +++ b/arch/powerpc/include/asm/pci.h | |||
@@ -233,6 +233,8 @@ extern void pci_resource_to_user(const struct pci_dev *dev, int bar, | |||
233 | 233 | ||
234 | extern void pcibios_setup_bus_devices(struct pci_bus *bus); | 234 | extern void pcibios_setup_bus_devices(struct pci_bus *bus); |
235 | extern void pcibios_setup_bus_self(struct pci_bus *bus); | 235 | extern void pcibios_setup_bus_self(struct pci_bus *bus); |
236 | extern void pcibios_setup_phb_io_space(struct pci_controller *hose); | ||
237 | extern void pcibios_scan_phb(struct pci_controller *hose, void *sysdata); | ||
236 | 238 | ||
237 | #endif /* __KERNEL__ */ | 239 | #endif /* __KERNEL__ */ |
238 | #endif /* __ASM_POWERPC_PCI_H */ | 240 | #endif /* __ASM_POWERPC_PCI_H */ |
diff --git a/arch/powerpc/include/asm/ppc-pci.h b/arch/powerpc/include/asm/ppc-pci.h index 854ab713f56c..2828f9d0f66d 100644 --- a/arch/powerpc/include/asm/ppc-pci.h +++ b/arch/powerpc/include/asm/ppc-pci.h | |||
@@ -39,7 +39,6 @@ void *traverse_pci_devices(struct device_node *start, traverse_func pre, | |||
39 | 39 | ||
40 | extern void pci_devs_phb_init(void); | 40 | extern void pci_devs_phb_init(void); |
41 | extern void pci_devs_phb_init_dynamic(struct pci_controller *phb); | 41 | extern void pci_devs_phb_init_dynamic(struct pci_controller *phb); |
42 | extern void scan_phb(struct pci_controller *hose); | ||
43 | 42 | ||
44 | /* From rtas_pci.h */ | 43 | /* From rtas_pci.h */ |
45 | extern void init_pci_config_tokens (void); | 44 | extern void init_pci_config_tokens (void); |
diff --git a/arch/powerpc/kernel/of_platform.c b/arch/powerpc/kernel/of_platform.c index 87df428e3588..1a4fc0d11a03 100644 --- a/arch/powerpc/kernel/of_platform.c +++ b/arch/powerpc/kernel/of_platform.c | |||
@@ -276,7 +276,7 @@ static int __devinit of_pci_phb_probe(struct of_device *dev, | |||
276 | #endif /* CONFIG_EEH */ | 276 | #endif /* CONFIG_EEH */ |
277 | 277 | ||
278 | /* Scan the bus */ | 278 | /* Scan the bus */ |
279 | scan_phb(phb); | 279 | pcibios_scan_phb(phb, dev->node); |
280 | if (phb->bus == NULL) | 280 | if (phb->bus == NULL) |
281 | return -ENXIO; | 281 | return -ENXIO; |
282 | 282 | ||
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 8f84a9a8428e..e9f4840096b3 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c | |||
@@ -1688,3 +1688,52 @@ int early_find_capability(struct pci_controller *hose, int bus, int devfn, | |||
1688 | { | 1688 | { |
1689 | return pci_bus_find_capability(fake_pci_bus(hose, bus), devfn, cap); | 1689 | return pci_bus_find_capability(fake_pci_bus(hose, bus), devfn, cap); |
1690 | } | 1690 | } |
1691 | |||
1692 | /** | ||
1693 | * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus | ||
1694 | * @hose: Pointer to the PCI host controller instance structure | ||
1695 | * @sysdata: value to use for sysdata pointer. ppc32 and ppc64 differ here | ||
1696 | * | ||
1697 | * Note: the 'data' pointer is a temporary measure. As 32 and 64 bit | ||
1698 | * pci code gets merged, this parameter should become unnecessary because | ||
1699 | * both will use the same value. | ||
1700 | */ | ||
1701 | void __devinit pcibios_scan_phb(struct pci_controller *hose, void *sysdata) | ||
1702 | { | ||
1703 | struct pci_bus *bus; | ||
1704 | struct device_node *node = hose->dn; | ||
1705 | int mode; | ||
1706 | |||
1707 | pr_debug("PCI: Scanning PHB %s\n", | ||
1708 | node ? node->full_name : "<NO NAME>"); | ||
1709 | |||
1710 | /* Create an empty bus for the toplevel */ | ||
1711 | bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, | ||
1712 | sysdata); | ||
1713 | if (bus == NULL) { | ||
1714 | pr_err("Failed to create bus for PCI domain %04x\n", | ||
1715 | hose->global_number); | ||
1716 | return; | ||
1717 | } | ||
1718 | bus->secondary = hose->first_busno; | ||
1719 | hose->bus = bus; | ||
1720 | |||
1721 | /* Get some IO space for the new PHB */ | ||
1722 | pcibios_setup_phb_io_space(hose); | ||
1723 | |||
1724 | /* Wire up PHB bus resources */ | ||
1725 | pcibios_setup_phb_resources(hose); | ||
1726 | |||
1727 | /* Get probe mode and perform scan */ | ||
1728 | mode = PCI_PROBE_NORMAL; | ||
1729 | if (node && ppc_md.pci_probe_mode) | ||
1730 | mode = ppc_md.pci_probe_mode(bus); | ||
1731 | pr_debug(" probe mode: %d\n", mode); | ||
1732 | if (mode == PCI_PROBE_DEVTREE) { | ||
1733 | bus->subordinate = hose->last_busno; | ||
1734 | of_scan_bus(node, bus); | ||
1735 | } | ||
1736 | |||
1737 | if (mode == PCI_PROBE_NORMAL) | ||
1738 | hose->last_busno = bus->subordinate = pci_scan_child_bus(bus); | ||
1739 | } | ||
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c index 8cf15d961c38..c13668cf36d9 100644 --- a/arch/powerpc/kernel/pci_32.c +++ b/arch/powerpc/kernel/pci_32.c | |||
@@ -354,36 +354,15 @@ pci_create_OF_bus_map(void) | |||
354 | } | 354 | } |
355 | } | 355 | } |
356 | 356 | ||
357 | static void __devinit pcibios_scan_phb(struct pci_controller *hose) | 357 | void __devinit pcibios_setup_phb_io_space(struct pci_controller *hose) |
358 | { | 358 | { |
359 | struct pci_bus *bus; | ||
360 | struct device_node *node = hose->dn; | ||
361 | unsigned long io_offset; | 359 | unsigned long io_offset; |
362 | struct resource *res = &hose->io_resource; | 360 | struct resource *res = &hose->io_resource; |
363 | 361 | ||
364 | pr_debug("PCI: Scanning PHB %s\n", | ||
365 | node ? node->full_name : "<NO NAME>"); | ||
366 | |||
367 | /* Create an empty bus for the toplevel */ | ||
368 | bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, hose); | ||
369 | if (bus == NULL) { | ||
370 | printk(KERN_ERR "Failed to create bus for PCI domain %04x\n", | ||
371 | hose->global_number); | ||
372 | return; | ||
373 | } | ||
374 | bus->secondary = hose->first_busno; | ||
375 | hose->bus = bus; | ||
376 | |||
377 | /* Fixup IO space offset */ | 362 | /* Fixup IO space offset */ |
378 | io_offset = (unsigned long)hose->io_base_virt - isa_io_base; | 363 | io_offset = (unsigned long)hose->io_base_virt - isa_io_base; |
379 | res->start = (res->start + io_offset) & 0xffffffffu; | 364 | res->start = (res->start + io_offset) & 0xffffffffu; |
380 | res->end = (res->end + io_offset) & 0xffffffffu; | 365 | res->end = (res->end + io_offset) & 0xffffffffu; |
381 | |||
382 | /* Wire up PHB bus resources */ | ||
383 | pcibios_setup_phb_resources(hose); | ||
384 | |||
385 | /* Scan children */ | ||
386 | hose->last_busno = bus->subordinate = pci_scan_child_bus(bus); | ||
387 | } | 366 | } |
388 | 367 | ||
389 | static int __init pcibios_init(void) | 368 | static int __init pcibios_init(void) |
@@ -401,7 +380,7 @@ static int __init pcibios_init(void) | |||
401 | if (pci_assign_all_buses) | 380 | if (pci_assign_all_buses) |
402 | hose->first_busno = next_busno; | 381 | hose->first_busno = next_busno; |
403 | hose->last_busno = 0xff; | 382 | hose->last_busno = 0xff; |
404 | pcibios_scan_phb(hose); | 383 | pcibios_scan_phb(hose, hose); |
405 | pci_bus_add_devices(hose->bus); | 384 | pci_bus_add_devices(hose->bus); |
406 | if (pci_assign_all_buses || next_busno <= hose->last_busno) | 385 | if (pci_assign_all_buses || next_busno <= hose->last_busno) |
407 | next_busno = hose->last_busno + pcibios_assign_bus_offset; | 386 | next_busno = hose->last_busno + pcibios_assign_bus_offset; |
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c index 4d5b4ced7e45..ba949a2c93ac 100644 --- a/arch/powerpc/kernel/pci_64.c +++ b/arch/powerpc/kernel/pci_64.c | |||
@@ -43,45 +43,6 @@ unsigned long pci_probe_only = 1; | |||
43 | unsigned long pci_io_base = ISA_IO_BASE; | 43 | unsigned long pci_io_base = ISA_IO_BASE; |
44 | EXPORT_SYMBOL(pci_io_base); | 44 | EXPORT_SYMBOL(pci_io_base); |
45 | 45 | ||
46 | void __devinit scan_phb(struct pci_controller *hose) | ||
47 | { | ||
48 | struct pci_bus *bus; | ||
49 | struct device_node *node = hose->dn; | ||
50 | int mode; | ||
51 | |||
52 | pr_debug("PCI: Scanning PHB %s\n", | ||
53 | node ? node->full_name : "<NO NAME>"); | ||
54 | |||
55 | /* Create an empty bus for the toplevel */ | ||
56 | bus = pci_create_bus(hose->parent, hose->first_busno, hose->ops, node); | ||
57 | if (bus == NULL) { | ||
58 | printk(KERN_ERR "Failed to create bus for PCI domain %04x\n", | ||
59 | hose->global_number); | ||
60 | return; | ||
61 | } | ||
62 | bus->secondary = hose->first_busno; | ||
63 | hose->bus = bus; | ||
64 | |||
65 | /* Get some IO space for the new PHB */ | ||
66 | pcibios_map_io_space(bus); | ||
67 | |||
68 | /* Wire up PHB bus resources */ | ||
69 | pcibios_setup_phb_resources(hose); | ||
70 | |||
71 | /* Get probe mode and perform scan */ | ||
72 | mode = PCI_PROBE_NORMAL; | ||
73 | if (node && ppc_md.pci_probe_mode) | ||
74 | mode = ppc_md.pci_probe_mode(bus); | ||
75 | pr_debug(" probe mode: %d\n", mode); | ||
76 | if (mode == PCI_PROBE_DEVTREE) { | ||
77 | bus->subordinate = hose->last_busno; | ||
78 | of_scan_bus(node, bus); | ||
79 | } | ||
80 | |||
81 | if (mode == PCI_PROBE_NORMAL) | ||
82 | hose->last_busno = bus->subordinate = pci_scan_child_bus(bus); | ||
83 | } | ||
84 | |||
85 | static int __init pcibios_init(void) | 46 | static int __init pcibios_init(void) |
86 | { | 47 | { |
87 | struct pci_controller *hose, *tmp; | 48 | struct pci_controller *hose, *tmp; |
@@ -103,7 +64,7 @@ static int __init pcibios_init(void) | |||
103 | 64 | ||
104 | /* Scan all of the recorded PCI controllers. */ | 65 | /* Scan all of the recorded PCI controllers. */ |
105 | list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { | 66 | list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { |
106 | scan_phb(hose); | 67 | pcibios_scan_phb(hose, hose->dn); |
107 | pci_bus_add_devices(hose->bus); | 68 | pci_bus_add_devices(hose->bus); |
108 | } | 69 | } |
109 | 70 | ||
@@ -237,6 +198,11 @@ int __devinit pcibios_map_io_space(struct pci_bus *bus) | |||
237 | } | 198 | } |
238 | EXPORT_SYMBOL_GPL(pcibios_map_io_space); | 199 | EXPORT_SYMBOL_GPL(pcibios_map_io_space); |
239 | 200 | ||
201 | void __devinit pcibios_setup_phb_io_space(struct pci_controller *hose) | ||
202 | { | ||
203 | pcibios_map_io_space(hose->bus); | ||
204 | } | ||
205 | |||
240 | #define IOBASE_BRIDGE_NUMBER 0 | 206 | #define IOBASE_BRIDGE_NUMBER 0 |
241 | #define IOBASE_MEMORY 1 | 207 | #define IOBASE_MEMORY 1 |
242 | #define IOBASE_IO 2 | 208 | #define IOBASE_IO 2 |
diff --git a/arch/powerpc/platforms/pseries/pci_dlpar.c b/arch/powerpc/platforms/pseries/pci_dlpar.c index ad152a0e3946..b6fa3e4b51b5 100644 --- a/arch/powerpc/platforms/pseries/pci_dlpar.c +++ b/arch/powerpc/platforms/pseries/pci_dlpar.c | |||
@@ -151,7 +151,7 @@ struct pci_controller * __devinit init_phb_dynamic(struct device_node *dn) | |||
151 | if (dn->child) | 151 | if (dn->child) |
152 | eeh_add_device_tree_early(dn); | 152 | eeh_add_device_tree_early(dn); |
153 | 153 | ||
154 | scan_phb(phb); | 154 | pcibios_scan_phb(phb, dn); |
155 | pcibios_finish_adding_to_bus(phb->bus); | 155 | pcibios_finish_adding_to_bus(phb->bus); |
156 | 156 | ||
157 | return phb; | 157 | return phb; |