diff options
author | Kumar Gala <galak@kernel.crashing.org> | 2007-06-27 02:17:57 -0400 |
---|---|---|
committer | Kumar Gala <galak@kernel.crashing.org> | 2007-06-29 02:58:37 -0400 |
commit | 5516b540e98de6f7474a4e7149470ad6a0bbc54a (patch) | |
tree | 9eb57336d892eb8c0e76584285030868df82f626 | |
parent | 6a506238b33efd93e60c1585d654b37e292183de (diff) |
[POWERPC] Use global_number in ppc32 pci_controller
Make the pci_controller struct use global_number for the PHB domain number
instead of index to match what ppc64 does and reuse its pci_domain_nr code.
Introduced a pci-common.c to handle shared code between ppc32 & ppc64.
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
-rw-r--r-- | arch/powerpc/kernel/Makefile | 2 | ||||
-rw-r--r-- | arch/powerpc/kernel/pci-common.c | 53 | ||||
-rw-r--r-- | arch/powerpc/kernel/pci_32.c | 6 | ||||
-rw-r--r-- | arch/powerpc/kernel/pci_64.c | 16 | ||||
-rw-r--r-- | arch/powerpc/platforms/52xx/efika.c | 4 | ||||
-rw-r--r-- | arch/powerpc/platforms/chrp/pci.c | 4 | ||||
-rw-r--r-- | include/asm-powerpc/pci-bridge.h | 2 | ||||
-rw-r--r-- | include/asm-powerpc/pci.h | 7 |
8 files changed, 64 insertions, 30 deletions
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index eb6a33e90d7e..42c42ecad00c 100644 --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile | |||
@@ -68,7 +68,7 @@ obj-$(CONFIG_MODULES) += $(module-y) | |||
68 | 68 | ||
69 | pci64-$(CONFIG_PPC64) += pci_64.o pci_dn.o isa-bridge.o | 69 | pci64-$(CONFIG_PPC64) += pci_64.o pci_dn.o isa-bridge.o |
70 | pci32-$(CONFIG_PPC32) := pci_32.o | 70 | pci32-$(CONFIG_PPC32) := pci_32.o |
71 | obj-$(CONFIG_PCI) += $(pci64-y) $(pci32-y) | 71 | obj-$(CONFIG_PCI) += $(pci64-y) $(pci32-y) pci-common.o |
72 | obj-$(CONFIG_PCI_MSI) += msi.o | 72 | obj-$(CONFIG_PCI_MSI) += msi.o |
73 | kexec-$(CONFIG_PPC64) := machine_kexec_64.o | 73 | kexec-$(CONFIG_PPC64) := machine_kexec_64.o |
74 | kexec-$(CONFIG_PPC32) := machine_kexec_32.o | 74 | kexec-$(CONFIG_PPC32) := machine_kexec_32.o |
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c new file mode 100644 index 000000000000..3ca8cfb99dc2 --- /dev/null +++ b/arch/powerpc/kernel/pci-common.c | |||
@@ -0,0 +1,53 @@ | |||
1 | /* | ||
2 | * Contains common pci routines for ALL ppc platform | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License | ||
6 | * as published by the Free Software Foundation; either version | ||
7 | * 2 of the License, or (at your option) any later version. | ||
8 | */ | ||
9 | |||
10 | #undef DEBUG | ||
11 | |||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/pci.h> | ||
14 | #include <linux/string.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/bootmem.h> | ||
17 | #include <linux/mm.h> | ||
18 | #include <linux/list.h> | ||
19 | #include <linux/syscalls.h> | ||
20 | #include <linux/irq.h> | ||
21 | #include <linux/vmalloc.h> | ||
22 | |||
23 | #include <asm/processor.h> | ||
24 | #include <asm/io.h> | ||
25 | #include <asm/prom.h> | ||
26 | #include <asm/pci-bridge.h> | ||
27 | #include <asm/byteorder.h> | ||
28 | #include <asm/machdep.h> | ||
29 | #include <asm/ppc-pci.h> | ||
30 | #include <asm/firmware.h> | ||
31 | |||
32 | #ifdef DEBUG | ||
33 | #include <asm/udbg.h> | ||
34 | #define DBG(fmt...) printk(fmt) | ||
35 | #else | ||
36 | #define DBG(fmt...) | ||
37 | #endif | ||
38 | |||
39 | /* | ||
40 | * Return the domain number for this bus. | ||
41 | */ | ||
42 | int pci_domain_nr(struct pci_bus *bus) | ||
43 | { | ||
44 | if (firmware_has_feature(FW_FEATURE_ISERIES)) | ||
45 | return 0; | ||
46 | else { | ||
47 | struct pci_controller *hose = pci_bus_to_host(bus); | ||
48 | |||
49 | return hose->global_number; | ||
50 | } | ||
51 | } | ||
52 | |||
53 | EXPORT_SYMBOL(pci_domain_nr); | ||
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c index 2d4a1c4f4e31..56deb316efd3 100644 --- a/arch/powerpc/kernel/pci_32.c +++ b/arch/powerpc/kernel/pci_32.c | |||
@@ -620,7 +620,7 @@ pcibios_alloc_controller(void) | |||
620 | *hose_tail = hose; | 620 | *hose_tail = hose; |
621 | hose_tail = &hose->next; | 621 | hose_tail = &hose->next; |
622 | 622 | ||
623 | hose->index = next_controller_index++; | 623 | hose->global_number = next_controller_index++; |
624 | 624 | ||
625 | return hose; | 625 | return hose; |
626 | } | 626 | } |
@@ -1336,7 +1336,7 @@ void __init pcibios_fixup_bus(struct pci_bus *bus) | |||
1336 | if (!res->flags) { | 1336 | if (!res->flags) { |
1337 | if (io_offset) | 1337 | if (io_offset) |
1338 | printk(KERN_ERR "I/O resource not set for host" | 1338 | printk(KERN_ERR "I/O resource not set for host" |
1339 | " bridge %d\n", hose->index); | 1339 | " bridge %d\n", hose->global_number); |
1340 | res->start = 0; | 1340 | res->start = 0; |
1341 | res->end = IO_SPACE_LIMIT; | 1341 | res->end = IO_SPACE_LIMIT; |
1342 | res->flags = IORESOURCE_IO; | 1342 | res->flags = IORESOURCE_IO; |
@@ -1350,7 +1350,7 @@ void __init pcibios_fixup_bus(struct pci_bus *bus) | |||
1350 | if (i > 0) | 1350 | if (i > 0) |
1351 | continue; | 1351 | continue; |
1352 | printk(KERN_ERR "Memory resource not set for " | 1352 | printk(KERN_ERR "Memory resource not set for " |
1353 | "host bridge %d\n", hose->index); | 1353 | "host bridge %d\n", hose->global_number); |
1354 | res->start = hose->pci_mem_offset; | 1354 | res->start = hose->pci_mem_offset; |
1355 | res->end = ~0U; | 1355 | res->end = ~0U; |
1356 | res->flags = IORESOURCE_MEM; | 1356 | res->flags = IORESOURCE_MEM; |
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c index 9fa2ecb8c1e4..57bdcd88f04a 100644 --- a/arch/powerpc/kernel/pci_64.c +++ b/arch/powerpc/kernel/pci_64.c | |||
@@ -636,22 +636,6 @@ int pcibios_enable_device(struct pci_dev *dev, int mask) | |||
636 | return 0; | 636 | return 0; |
637 | } | 637 | } |
638 | 638 | ||
639 | /* | ||
640 | * Return the domain number for this bus. | ||
641 | */ | ||
642 | int pci_domain_nr(struct pci_bus *bus) | ||
643 | { | ||
644 | if (firmware_has_feature(FW_FEATURE_ISERIES)) | ||
645 | return 0; | ||
646 | else { | ||
647 | struct pci_controller *hose = pci_bus_to_host(bus); | ||
648 | |||
649 | return hose->global_number; | ||
650 | } | ||
651 | } | ||
652 | |||
653 | EXPORT_SYMBOL(pci_domain_nr); | ||
654 | |||
655 | /* Decide whether to display the domain number in /proc */ | 639 | /* Decide whether to display the domain number in /proc */ |
656 | int pci_proc_domain(struct pci_bus *bus) | 640 | int pci_proc_domain(struct pci_bus *bus) |
657 | { | 641 | { |
diff --git a/arch/powerpc/platforms/52xx/efika.c b/arch/powerpc/platforms/52xx/efika.c index 4cb441975ff7..010be5c082d5 100644 --- a/arch/powerpc/platforms/52xx/efika.c +++ b/arch/powerpc/platforms/52xx/efika.c | |||
@@ -54,7 +54,7 @@ static int rtas_read_config(struct pci_bus *bus, unsigned int devfn, int offset, | |||
54 | struct pci_controller *hose = bus->sysdata; | 54 | struct pci_controller *hose = bus->sysdata; |
55 | unsigned long addr = (offset & 0xff) | ((devfn & 0xff) << 8) | 55 | unsigned long addr = (offset & 0xff) | ((devfn & 0xff) << 8) |
56 | | (((bus->number - hose->first_busno) & 0xff) << 16) | 56 | | (((bus->number - hose->first_busno) & 0xff) << 16) |
57 | | (hose->index << 24); | 57 | | (hose->global_number << 24); |
58 | int ret = -1; | 58 | int ret = -1; |
59 | int rval; | 59 | int rval; |
60 | 60 | ||
@@ -69,7 +69,7 @@ static int rtas_write_config(struct pci_bus *bus, unsigned int devfn, | |||
69 | struct pci_controller *hose = bus->sysdata; | 69 | struct pci_controller *hose = bus->sysdata; |
70 | unsigned long addr = (offset & 0xff) | ((devfn & 0xff) << 8) | 70 | unsigned long addr = (offset & 0xff) | ((devfn & 0xff) << 8) |
71 | | (((bus->number - hose->first_busno) & 0xff) << 16) | 71 | | (((bus->number - hose->first_busno) & 0xff) << 16) |
72 | | (hose->index << 24); | 72 | | (hose->global_number << 24); |
73 | int rval; | 73 | int rval; |
74 | 74 | ||
75 | rval = rtas_call(rtas_token("write-pci-config"), 3, 1, NULL, | 75 | rval = rtas_call(rtas_token("write-pci-config"), 3, 1, NULL, |
diff --git a/arch/powerpc/platforms/chrp/pci.c b/arch/powerpc/platforms/chrp/pci.c index d32fedc991d3..d8408632b1a9 100644 --- a/arch/powerpc/platforms/chrp/pci.c +++ b/arch/powerpc/platforms/chrp/pci.c | |||
@@ -99,7 +99,7 @@ int rtas_read_config(struct pci_bus *bus, unsigned int devfn, int offset, | |||
99 | struct pci_controller *hose = bus->sysdata; | 99 | struct pci_controller *hose = bus->sysdata; |
100 | unsigned long addr = (offset & 0xff) | ((devfn & 0xff) << 8) | 100 | unsigned long addr = (offset & 0xff) | ((devfn & 0xff) << 8) |
101 | | (((bus->number - hose->first_busno) & 0xff) << 16) | 101 | | (((bus->number - hose->first_busno) & 0xff) << 16) |
102 | | (hose->index << 24); | 102 | | (hose->global_number << 24); |
103 | int ret = -1; | 103 | int ret = -1; |
104 | int rval; | 104 | int rval; |
105 | 105 | ||
@@ -114,7 +114,7 @@ int rtas_write_config(struct pci_bus *bus, unsigned int devfn, int offset, | |||
114 | struct pci_controller *hose = bus->sysdata; | 114 | struct pci_controller *hose = bus->sysdata; |
115 | unsigned long addr = (offset & 0xff) | ((devfn & 0xff) << 8) | 115 | unsigned long addr = (offset & 0xff) | ((devfn & 0xff) << 8) |
116 | | (((bus->number - hose->first_busno) & 0xff) << 16) | 116 | | (((bus->number - hose->first_busno) & 0xff) << 16) |
117 | | (hose->index << 24); | 117 | | (hose->global_number << 24); |
118 | int rval; | 118 | int rval; |
119 | 119 | ||
120 | rval = rtas_call(rtas_token("write-pci-config"), 3, 1, NULL, | 120 | rval = rtas_call(rtas_token("write-pci-config"), 3, 1, NULL, |
diff --git a/include/asm-powerpc/pci-bridge.h b/include/asm-powerpc/pci-bridge.h index e2b2b6b7b6b8..80cfb4a75053 100644 --- a/include/asm-powerpc/pci-bridge.h +++ b/include/asm-powerpc/pci-bridge.h | |||
@@ -21,7 +21,6 @@ extern struct pci_controller* pci_bus_to_hose(int bus); | |||
21 | struct pci_controller { | 21 | struct pci_controller { |
22 | struct pci_bus *bus; | 22 | struct pci_bus *bus; |
23 | void *arch_data; | 23 | void *arch_data; |
24 | int index; /* PCI domain number */ | ||
25 | struct pci_controller *next; | 24 | struct pci_controller *next; |
26 | struct device *parent; | 25 | struct device *parent; |
27 | 26 | ||
@@ -60,6 +59,7 @@ struct pci_controller { | |||
60 | */ | 59 | */ |
61 | struct resource io_resource; | 60 | struct resource io_resource; |
62 | struct resource mem_resources[3]; | 61 | struct resource mem_resources[3]; |
62 | int global_number; /* PCI domain number */ | ||
63 | }; | 63 | }; |
64 | 64 | ||
65 | static inline struct pci_controller *pci_bus_to_host(struct pci_bus *bus) | 65 | static inline struct pci_controller *pci_bus_to_host(struct pci_bus *bus) |
diff --git a/include/asm-powerpc/pci.h b/include/asm-powerpc/pci.h index 93e3752df6b7..0cd3e77efd20 100644 --- a/include/asm-powerpc/pci.h +++ b/include/asm-powerpc/pci.h | |||
@@ -107,8 +107,6 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev, | |||
107 | #define get_pci_dma_ops() NULL | 107 | #define get_pci_dma_ops() NULL |
108 | #endif | 108 | #endif |
109 | 109 | ||
110 | extern int pci_domain_nr(struct pci_bus *bus); | ||
111 | |||
112 | /* Decide whether to display the domain number in /proc */ | 110 | /* Decide whether to display the domain number in /proc */ |
113 | extern int pci_proc_domain(struct pci_bus *bus); | 111 | extern int pci_proc_domain(struct pci_bus *bus); |
114 | 112 | ||
@@ -130,9 +128,6 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev, | |||
130 | */ | 128 | */ |
131 | #define pci_dac_dma_supported(pci_dev, mask) (0) | 129 | #define pci_dac_dma_supported(pci_dev, mask) (0) |
132 | 130 | ||
133 | /* Return the index of the PCI controller for device PDEV. */ | ||
134 | #define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index | ||
135 | |||
136 | /* Set the name of the bus as it appears in /proc/bus/pci */ | 131 | /* Set the name of the bus as it appears in /proc/bus/pci */ |
137 | static inline int pci_proc_domain(struct pci_bus *bus) | 132 | static inline int pci_proc_domain(struct pci_bus *bus) |
138 | { | 133 | { |
@@ -141,6 +136,8 @@ static inline int pci_proc_domain(struct pci_bus *bus) | |||
141 | 136 | ||
142 | #endif /* CONFIG_PPC64 */ | 137 | #endif /* CONFIG_PPC64 */ |
143 | 138 | ||
139 | extern int pci_domain_nr(struct pci_bus *bus); | ||
140 | |||
144 | struct vm_area_struct; | 141 | struct vm_area_struct; |
145 | /* Map a range of PCI memory or I/O space for a device into user space */ | 142 | /* Map a range of PCI memory or I/O space for a device into user space */ |
146 | int pci_mmap_page_range(struct pci_dev *pdev, struct vm_area_struct *vma, | 143 | int pci_mmap_page_range(struct pci_dev *pdev, struct vm_area_struct *vma, |