diff options
| author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2011-04-10 21:20:25 -0400 |
|---|---|---|
| committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2011-06-07 19:08:35 -0400 |
| commit | 72bdee79f89ffc9ce425611cdaf88d28a96b8b66 (patch) | |
| tree | 7b73aa0003ab4a05f799e8e86e01d6064a8167c1 /arch/microblaze | |
| parent | 98d9f30c820d509145757e6ecbc36013aa02f7bc (diff) | |
microblaze/pci: Remove powermac originated cruft
The whole business with re-assigning all bus numbers, creating
an OF bus "map" etc... is ancient powermac stuff that you really
don't care about on microblaze.
Similarly pci_device_from_OF_node() is unused and by getting rid
of it we can get rid of a whole lot of code otherwise unused on
this architecture
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Michal Simek <monstr@monstr.eu>
Diffstat (limited to 'arch/microblaze')
| -rw-r--r-- | arch/microblaze/include/asm/pci-bridge.h | 3 | ||||
| -rw-r--r-- | arch/microblaze/include/asm/pci.h | 3 | ||||
| -rw-r--r-- | arch/microblaze/pci/pci_32.c | 272 |
3 files changed, 3 insertions, 275 deletions
diff --git a/arch/microblaze/include/asm/pci-bridge.h b/arch/microblaze/include/asm/pci-bridge.h index 728f8d6a59a4..6bddc0701a07 100644 --- a/arch/microblaze/include/asm/pci-bridge.h +++ b/arch/microblaze/include/asm/pci-bridge.h | |||
| @@ -19,9 +19,6 @@ enum { | |||
| 19 | */ | 19 | */ |
| 20 | PCI_REASSIGN_ALL_RSRC = 0x00000001, | 20 | PCI_REASSIGN_ALL_RSRC = 0x00000001, |
| 21 | 21 | ||
| 22 | /* Re-assign all bus numbers */ | ||
| 23 | PCI_REASSIGN_ALL_BUS = 0x00000002, | ||
| 24 | |||
| 25 | /* Do not try to assign, just use existing setup */ | 22 | /* Do not try to assign, just use existing setup */ |
| 26 | PCI_PROBE_ONLY = 0x00000004, | 23 | PCI_PROBE_ONLY = 0x00000004, |
| 27 | 24 | ||
diff --git a/arch/microblaze/include/asm/pci.h b/arch/microblaze/include/asm/pci.h index ba65cf472544..1dd9d6b1e275 100644 --- a/arch/microblaze/include/asm/pci.h +++ b/arch/microblaze/include/asm/pci.h | |||
| @@ -40,8 +40,7 @@ struct pci_dev; | |||
| 40 | * Set this to 1 if you want the kernel to re-assign all PCI | 40 | * Set this to 1 if you want the kernel to re-assign all PCI |
| 41 | * bus numbers (don't do that on ppc64 yet !) | 41 | * bus numbers (don't do that on ppc64 yet !) |
| 42 | */ | 42 | */ |
| 43 | #define pcibios_assign_all_busses() \ | 43 | #define pcibios_assign_all_busses() 0 |
| 44 | (pci_has_flag(PCI_REASSIGN_ALL_BUS)) | ||
| 45 | 44 | ||
| 46 | static inline void pcibios_set_master(struct pci_dev *dev) | 45 | static inline void pcibios_set_master(struct pci_dev *dev) |
| 47 | { | 46 | { |
diff --git a/arch/microblaze/pci/pci_32.c b/arch/microblaze/pci/pci_32.c index 2fa95069e6ba..ab3c4d40a82c 100644 --- a/arch/microblaze/pci/pci_32.c +++ b/arch/microblaze/pci/pci_32.c | |||
| @@ -28,261 +28,8 @@ | |||
| 28 | 28 | ||
| 29 | unsigned long isa_io_base; | 29 | unsigned long isa_io_base; |
| 30 | unsigned long pci_dram_offset; | 30 | unsigned long pci_dram_offset; |
| 31 | int pcibios_assign_bus_offset = 1; | ||
| 32 | |||
| 33 | static u8 *pci_to_OF_bus_map; | ||
| 34 | |||
| 35 | /* By default, we don't re-assign bus numbers. We do this only on | ||
| 36 | * some pmacs | ||
| 37 | */ | ||
| 38 | static int pci_assign_all_buses; | ||
| 39 | |||
| 40 | static int pci_bus_count; | 31 | static int pci_bus_count; |
| 41 | 32 | ||
| 42 | /* | ||
| 43 | * Functions below are used on OpenFirmware machines. | ||
| 44 | */ | ||
| 45 | static void | ||
| 46 | make_one_node_map(struct device_node *node, u8 pci_bus) | ||
| 47 | { | ||
| 48 | const int *bus_range; | ||
| 49 | int len; | ||
| 50 | |||
| 51 | if (pci_bus >= pci_bus_count) | ||
| 52 | return; | ||
| 53 | bus_range = of_get_property(node, "bus-range", &len); | ||
| 54 | if (bus_range == NULL || len < 2 * sizeof(int)) { | ||
| 55 | printk(KERN_WARNING "Can't get bus-range for %s, " | ||
| 56 | "assuming it starts at 0\n", node->full_name); | ||
| 57 | pci_to_OF_bus_map[pci_bus] = 0; | ||
| 58 | } else | ||
| 59 | pci_to_OF_bus_map[pci_bus] = bus_range[0]; | ||
| 60 | |||
| 61 | for_each_child_of_node(node, node) { | ||
| 62 | struct pci_dev *dev; | ||
| 63 | const unsigned int *class_code, *reg; | ||
| 64 | |||
| 65 | class_code = of_get_property(node, "class-code", NULL); | ||
| 66 | if (!class_code || | ||
| 67 | ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI && | ||
| 68 | (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) | ||
| 69 | continue; | ||
| 70 | reg = of_get_property(node, "reg", NULL); | ||
| 71 | if (!reg) | ||
| 72 | continue; | ||
| 73 | dev = pci_get_bus_and_slot(pci_bus, ((reg[0] >> 8) & 0xff)); | ||
| 74 | if (!dev || !dev->subordinate) { | ||
| 75 | pci_dev_put(dev); | ||
| 76 | continue; | ||
| 77 | } | ||
| 78 | make_one_node_map(node, dev->subordinate->number); | ||
| 79 | pci_dev_put(dev); | ||
| 80 | } | ||
| 81 | } | ||
| 82 | |||
| 83 | void | ||
| 84 | pcibios_make_OF_bus_map(void) | ||
| 85 | { | ||
| 86 | int i; | ||
| 87 | struct pci_controller *hose, *tmp; | ||
| 88 | struct property *map_prop; | ||
| 89 | struct device_node *dn; | ||
| 90 | |||
| 91 | pci_to_OF_bus_map = kmalloc(pci_bus_count, GFP_KERNEL); | ||
| 92 | if (!pci_to_OF_bus_map) { | ||
| 93 | printk(KERN_ERR "Can't allocate OF bus map !\n"); | ||
| 94 | return; | ||
| 95 | } | ||
| 96 | |||
| 97 | /* We fill the bus map with invalid values, that helps | ||
| 98 | * debugging. | ||
| 99 | */ | ||
| 100 | for (i = 0; i < pci_bus_count; i++) | ||
| 101 | pci_to_OF_bus_map[i] = 0xff; | ||
| 102 | |||
| 103 | /* For each hose, we begin searching bridges */ | ||
| 104 | list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { | ||
| 105 | struct device_node *node = hose->dn; | ||
| 106 | |||
| 107 | if (!node) | ||
| 108 | continue; | ||
| 109 | make_one_node_map(node, hose->first_busno); | ||
| 110 | } | ||
| 111 | dn = of_find_node_by_path("/"); | ||
| 112 | map_prop = of_find_property(dn, "pci-OF-bus-map", NULL); | ||
| 113 | if (map_prop) { | ||
| 114 | BUG_ON(pci_bus_count > map_prop->length); | ||
| 115 | memcpy(map_prop->value, pci_to_OF_bus_map, pci_bus_count); | ||
| 116 | } | ||
| 117 | of_node_put(dn); | ||
| 118 | #ifdef DEBUG | ||
| 119 | printk(KERN_INFO "PCI->OF bus map:\n"); | ||
| 120 | for (i = 0; i < pci_bus_count; i++) { | ||
| 121 | if (pci_to_OF_bus_map[i] == 0xff) | ||
| 122 | continue; | ||
| 123 | printk(KERN_INFO "%d -> %d\n", i, pci_to_OF_bus_map[i]); | ||
| 124 | } | ||
| 125 | #endif | ||
| 126 | } | ||
| 127 | |||
| 128 | typedef int (*pci_OF_scan_iterator)(struct device_node *node, void *data); | ||
| 129 | |||
| 130 | static struct device_node *scan_OF_pci_childs(struct device_node *parent, | ||
| 131 | pci_OF_scan_iterator filter, void *data) | ||
| 132 | { | ||
| 133 | struct device_node *node; | ||
| 134 | struct device_node *sub_node; | ||
| 135 | |||
| 136 | for_each_child_of_node(parent, node) { | ||
| 137 | const unsigned int *class_code; | ||
| 138 | |||
| 139 | if (filter(node, data)) { | ||
| 140 | of_node_put(node); | ||
| 141 | return node; | ||
| 142 | } | ||
| 143 | |||
| 144 | /* For PCI<->PCI bridges or CardBus bridges, we go down | ||
| 145 | * Note: some OFs create a parent node "multifunc-device" as | ||
| 146 | * a fake root for all functions of a multi-function device, | ||
| 147 | * we go down them as well. | ||
| 148 | */ | ||
| 149 | class_code = of_get_property(node, "class-code", NULL); | ||
| 150 | if ((!class_code || | ||
| 151 | ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI && | ||
| 152 | (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) && | ||
| 153 | strcmp(node->name, "multifunc-device")) | ||
| 154 | continue; | ||
| 155 | sub_node = scan_OF_pci_childs(node, filter, data); | ||
| 156 | if (sub_node) { | ||
| 157 | of_node_put(node); | ||
| 158 | return sub_node; | ||
| 159 | } | ||
| 160 | } | ||
| 161 | return NULL; | ||
| 162 | } | ||
| 163 | |||
| 164 | static struct device_node *scan_OF_for_pci_dev(struct device_node *parent, | ||
| 165 | unsigned int devfn) | ||
| 166 | { | ||
| 167 | struct device_node *np, *cnp; | ||
| 168 | const u32 *reg; | ||
| 169 | unsigned int psize; | ||
| 170 | |||
| 171 | for_each_child_of_node(parent, np) { | ||
| 172 | reg = of_get_property(np, "reg", &psize); | ||
| 173 | if (reg && psize >= 4 && ((reg[0] >> 8) & 0xff) == devfn) | ||
| 174 | return np; | ||
| 175 | |||
| 176 | /* Note: some OFs create a parent node "multifunc-device" as | ||
| 177 | * a fake root for all functions of a multi-function device, | ||
| 178 | * we go down them as well. */ | ||
| 179 | if (!strcmp(np->name, "multifunc-device")) { | ||
| 180 | cnp = scan_OF_for_pci_dev(np, devfn); | ||
| 181 | if (cnp) | ||
| 182 | return cnp; | ||
| 183 | } | ||
| 184 | } | ||
| 185 | return NULL; | ||
| 186 | } | ||
| 187 | |||
| 188 | |||
| 189 | static struct device_node *scan_OF_for_pci_bus(struct pci_bus *bus) | ||
| 190 | { | ||
| 191 | struct device_node *parent, *np; | ||
| 192 | |||
| 193 | /* Are we a root bus ? */ | ||
| 194 | if (bus->self == NULL || bus->parent == NULL) { | ||
| 195 | struct pci_controller *hose = pci_bus_to_host(bus); | ||
| 196 | if (hose == NULL) | ||
| 197 | return NULL; | ||
| 198 | return of_node_get(hose->dn); | ||
| 199 | } | ||
| 200 | |||
| 201 | /* not a root bus, we need to get our parent */ | ||
| 202 | parent = scan_OF_for_pci_bus(bus->parent); | ||
| 203 | if (parent == NULL) | ||
| 204 | return NULL; | ||
| 205 | |||
| 206 | /* now iterate for children for a match */ | ||
| 207 | np = scan_OF_for_pci_dev(parent, bus->self->devfn); | ||
| 208 | of_node_put(parent); | ||
| 209 | |||
| 210 | return np; | ||
| 211 | } | ||
| 212 | |||
| 213 | static int | ||
| 214 | find_OF_pci_device_filter(struct device_node *node, void *data) | ||
| 215 | { | ||
| 216 | return ((void *)node == data); | ||
| 217 | } | ||
| 218 | |||
| 219 | /* | ||
| 220 | * Returns the PCI device matching a given OF node | ||
| 221 | */ | ||
| 222 | int | ||
| 223 | pci_device_from_OF_node(struct device_node *node, u8 *bus, u8 *devfn) | ||
| 224 | { | ||
| 225 | const unsigned int *reg; | ||
| 226 | struct pci_controller *hose; | ||
| 227 | struct pci_dev *dev = NULL; | ||
| 228 | |||
| 229 | /* Make sure it's really a PCI device */ | ||
| 230 | hose = pci_find_hose_for_OF_device(node); | ||
| 231 | if (!hose || !hose->dn) | ||
| 232 | return -ENODEV; | ||
| 233 | if (!scan_OF_pci_childs(hose->dn, | ||
| 234 | find_OF_pci_device_filter, (void *)node)) | ||
| 235 | return -ENODEV; | ||
| 236 | reg = of_get_property(node, "reg", NULL); | ||
| 237 | if (!reg) | ||
| 238 | return -ENODEV; | ||
| 239 | *bus = (reg[0] >> 16) & 0xff; | ||
| 240 | *devfn = ((reg[0] >> 8) & 0xff); | ||
| 241 | |||
| 242 | /* Ok, here we need some tweak. If we have already renumbered | ||
| 243 | * all busses, we can't rely on the OF bus number any more. | ||
| 244 | * the pci_to_OF_bus_map is not enough as several PCI busses | ||
| 245 | * may match the same OF bus number. | ||
| 246 | */ | ||
| 247 | if (!pci_to_OF_bus_map) | ||
| 248 | return 0; | ||
| 249 | |||
| 250 | for_each_pci_dev(dev) | ||
| 251 | if (pci_to_OF_bus_map[dev->bus->number] == *bus && | ||
| 252 | dev->devfn == *devfn) { | ||
| 253 | *bus = dev->bus->number; | ||
| 254 | pci_dev_put(dev); | ||
| 255 | return 0; | ||
| 256 | } | ||
| 257 | |||
| 258 | return -ENODEV; | ||
| 259 | } | ||
| 260 | EXPORT_SYMBOL(pci_device_from_OF_node); | ||
| 261 | |||
| 262 | /* We create the "pci-OF-bus-map" property now so it appears in the | ||
| 263 | * /proc device tree | ||
| 264 | */ | ||
| 265 | void __init | ||
| 266 | pci_create_OF_bus_map(void) | ||
| 267 | { | ||
| 268 | struct property *of_prop; | ||
| 269 | struct device_node *dn; | ||
| 270 | |||
| 271 | of_prop = (struct property *) alloc_bootmem(sizeof(struct property) + \ | ||
| 272 | 256); | ||
| 273 | if (!of_prop) | ||
| 274 | return; | ||
| 275 | dn = of_find_node_by_path("/"); | ||
| 276 | if (dn) { | ||
| 277 | memset(of_prop, -1, sizeof(struct property) + 256); | ||
| 278 | of_prop->name = "pci-OF-bus-map"; | ||
| 279 | of_prop->length = 256; | ||
| 280 | of_prop->value = &of_prop[1]; | ||
| 281 | prom_add_property(dn, of_prop); | ||
| 282 | of_node_put(dn); | ||
| 283 | } | ||
| 284 | } | ||
| 285 | |||
| 286 | struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus) | 33 | struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus) |
| 287 | { | 34 | { |
| 288 | struct pci_controller *hose = bus->sysdata; | 35 | struct pci_controller *hose = bus->sysdata; |
| @@ -329,32 +76,17 @@ static int __init pcibios_init(void) | |||
| 329 | 76 | ||
| 330 | printk(KERN_INFO "PCI: Probing PCI hardware\n"); | 77 | printk(KERN_INFO "PCI: Probing PCI hardware\n"); |
| 331 | 78 | ||
| 332 | if (pci_flags & PCI_REASSIGN_ALL_BUS) { | ||
| 333 | printk(KERN_INFO "setting pci_asign_all_busses\n"); | ||
| 334 | pci_assign_all_buses = 1; | ||
| 335 | } | ||
| 336 | |||
| 337 | /* Scan all of the recorded PCI controllers. */ | 79 | /* Scan all of the recorded PCI controllers. */ |
| 338 | list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { | 80 | list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { |
| 339 | if (pci_assign_all_buses) | ||
| 340 | hose->first_busno = next_busno; | ||
| 341 | hose->last_busno = 0xff; | 81 | hose->last_busno = 0xff; |
| 342 | pcibios_scan_phb(hose); | 82 | pcibios_scan_phb(hose); |
| 343 | printk(KERN_INFO "calling pci_bus_add_devices()\n"); | 83 | printk(KERN_INFO "calling pci_bus_add_devices()\n"); |
| 344 | pci_bus_add_devices(hose->bus); | 84 | pci_bus_add_devices(hose->bus); |
| 345 | if (pci_assign_all_buses || next_busno <= hose->last_busno) | 85 | if (next_busno <= hose->last_busno) |
| 346 | next_busno = hose->last_busno + \ | 86 | next_busno = hose->last_busno + 1; |
| 347 | pcibios_assign_bus_offset; | ||
| 348 | } | 87 | } |
| 349 | pci_bus_count = next_busno; | 88 | pci_bus_count = next_busno; |
| 350 | 89 | ||
| 351 | /* OpenFirmware based machines need a map of OF bus | ||
| 352 | * numbers vs. kernel bus numbers since we may have to | ||
| 353 | * remap them. | ||
| 354 | */ | ||
| 355 | if (pci_assign_all_buses) | ||
| 356 | pcibios_make_OF_bus_map(); | ||
| 357 | |||
| 358 | /* Call common code to handle resource allocation */ | 90 | /* Call common code to handle resource allocation */ |
| 359 | pcibios_resource_survey(); | 91 | pcibios_resource_survey(); |
| 360 | 92 | ||
