diff options
| -rw-r--r-- | arch/powerpc/kernel/pci-common.c | 38 | ||||
| -rw-r--r-- | arch/powerpc/kernel/pci_32.c | 37 | ||||
| -rw-r--r-- | arch/powerpc/kernel/pci_64.c | 30 | ||||
| -rw-r--r-- | arch/powerpc/platforms/powermac/pci.c | 22 | ||||
| -rw-r--r-- | arch/powerpc/platforms/powermac/pmac.h | 2 | ||||
| -rw-r--r-- | include/asm-powerpc/machdep.h | 10 |
6 files changed, 53 insertions, 86 deletions
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index f706b7e83d7e..8935661d12d0 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c | |||
| @@ -1127,3 +1127,41 @@ void __devinit pcibios_claim_one_bus(struct pci_bus *bus) | |||
| 1127 | } | 1127 | } |
| 1128 | EXPORT_SYMBOL_GPL(pcibios_claim_one_bus); | 1128 | EXPORT_SYMBOL_GPL(pcibios_claim_one_bus); |
| 1129 | #endif /* CONFIG_HOTPLUG */ | 1129 | #endif /* CONFIG_HOTPLUG */ |
| 1130 | |||
| 1131 | int pcibios_enable_device(struct pci_dev *dev, int mask) | ||
| 1132 | { | ||
| 1133 | u16 cmd, old_cmd; | ||
| 1134 | int idx; | ||
| 1135 | struct resource *r; | ||
| 1136 | |||
| 1137 | if (ppc_md.pcibios_enable_device_hook) | ||
| 1138 | if (ppc_md.pcibios_enable_device_hook(dev)) | ||
| 1139 | return -EINVAL; | ||
| 1140 | |||
| 1141 | pci_read_config_word(dev, PCI_COMMAND, &cmd); | ||
| 1142 | old_cmd = cmd; | ||
| 1143 | for (idx = 0; idx < PCI_NUM_RESOURCES; idx++) { | ||
| 1144 | /* Only set up the requested stuff */ | ||
| 1145 | if (!(mask & (1 << idx))) | ||
| 1146 | continue; | ||
| 1147 | r = &dev->resource[idx]; | ||
| 1148 | if (!(r->flags & (IORESOURCE_IO | IORESOURCE_MEM))) | ||
| 1149 | continue; | ||
| 1150 | if (r->flags & IORESOURCE_UNSET) { | ||
| 1151 | printk(KERN_ERR "PCI: Device %s not available because" | ||
| 1152 | " of resource collisions\n", pci_name(dev)); | ||
| 1153 | return -EINVAL; | ||
| 1154 | } | ||
| 1155 | if (r->flags & IORESOURCE_IO) | ||
| 1156 | cmd |= PCI_COMMAND_IO; | ||
| 1157 | if (r->flags & IORESOURCE_MEM) | ||
| 1158 | cmd |= PCI_COMMAND_MEMORY; | ||
| 1159 | } | ||
| 1160 | if (cmd != old_cmd) { | ||
| 1161 | printk("PCI: Enabling device %s (%04x -> %04x)\n", | ||
| 1162 | pci_name(dev), old_cmd, cmd); | ||
| 1163 | pci_write_config_word(dev, PCI_COMMAND, cmd); | ||
| 1164 | } | ||
| 1165 | return 0; | ||
| 1166 | } | ||
| 1167 | |||
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c index 12b74fd098ee..37cb7b944319 100644 --- a/arch/powerpc/kernel/pci_32.c +++ b/arch/powerpc/kernel/pci_32.c | |||
| @@ -518,43 +518,6 @@ pcibios_update_irq(struct pci_dev *dev, int irq) | |||
| 518 | /* XXX FIXME - update OF device tree node interrupt property */ | 518 | /* XXX FIXME - update OF device tree node interrupt property */ |
| 519 | } | 519 | } |
| 520 | 520 | ||
| 521 | int pcibios_enable_device(struct pci_dev *dev, int mask) | ||
| 522 | { | ||
| 523 | u16 cmd, old_cmd; | ||
| 524 | int idx; | ||
| 525 | struct resource *r; | ||
| 526 | |||
| 527 | if (ppc_md.pcibios_enable_device_hook) | ||
| 528 | if (ppc_md.pcibios_enable_device_hook(dev, 0)) | ||
| 529 | return -EINVAL; | ||
| 530 | |||
| 531 | pci_read_config_word(dev, PCI_COMMAND, &cmd); | ||
| 532 | old_cmd = cmd; | ||
| 533 | for (idx = 0; idx < PCI_NUM_RESOURCES; idx++) { | ||
| 534 | /* Only set up the requested stuff */ | ||
| 535 | if (!(mask & (1 << idx))) | ||
| 536 | continue; | ||
| 537 | r = &dev->resource[idx]; | ||
| 538 | if (!(r->flags & (IORESOURCE_IO | IORESOURCE_MEM))) | ||
| 539 | continue; | ||
| 540 | if (r->flags & IORESOURCE_UNSET) { | ||
| 541 | printk(KERN_ERR "PCI: Device %s not available because" | ||
| 542 | " of resource collisions\n", pci_name(dev)); | ||
| 543 | return -EINVAL; | ||
| 544 | } | ||
| 545 | if (r->flags & IORESOURCE_IO) | ||
| 546 | cmd |= PCI_COMMAND_IO; | ||
| 547 | if (r->flags & IORESOURCE_MEM) | ||
| 548 | cmd |= PCI_COMMAND_MEMORY; | ||
| 549 | } | ||
| 550 | if (cmd != old_cmd) { | ||
| 551 | printk("PCI: Enabling device %s (%04x -> %04x)\n", | ||
| 552 | pci_name(dev), old_cmd, cmd); | ||
| 553 | pci_write_config_word(dev, PCI_COMMAND, cmd); | ||
| 554 | } | ||
| 555 | return 0; | ||
| 556 | } | ||
| 557 | |||
| 558 | static struct pci_controller* | 521 | static struct pci_controller* |
| 559 | pci_bus_to_hose(int bus) | 522 | pci_bus_to_hose(int bus) |
| 560 | { | 523 | { |
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c index 2ec040b314d4..5949bbabd7fb 100644 --- a/arch/powerpc/kernel/pci_64.c +++ b/arch/powerpc/kernel/pci_64.c | |||
| @@ -436,36 +436,6 @@ static int __init pcibios_init(void) | |||
| 436 | 436 | ||
| 437 | subsys_initcall(pcibios_init); | 437 | subsys_initcall(pcibios_init); |
| 438 | 438 | ||
| 439 | int pcibios_enable_device(struct pci_dev *dev, int mask) | ||
| 440 | { | ||
| 441 | u16 cmd, oldcmd; | ||
| 442 | int i; | ||
| 443 | |||
| 444 | pci_read_config_word(dev, PCI_COMMAND, &cmd); | ||
| 445 | oldcmd = cmd; | ||
| 446 | |||
| 447 | for (i = 0; i < PCI_NUM_RESOURCES; i++) { | ||
| 448 | struct resource *res = &dev->resource[i]; | ||
| 449 | |||
| 450 | /* Only set up the requested stuff */ | ||
| 451 | if (!(mask & (1<<i))) | ||
| 452 | continue; | ||
| 453 | |||
| 454 | if (res->flags & IORESOURCE_IO) | ||
| 455 | cmd |= PCI_COMMAND_IO; | ||
| 456 | if (res->flags & IORESOURCE_MEM) | ||
| 457 | cmd |= PCI_COMMAND_MEMORY; | ||
| 458 | } | ||
| 459 | |||
| 460 | if (cmd != oldcmd) { | ||
| 461 | printk(KERN_DEBUG "PCI: Enabling device: (%s), cmd %x\n", | ||
| 462 | pci_name(dev), cmd); | ||
| 463 | /* Enable the appropriate bits in the PCI command register. */ | ||
| 464 | pci_write_config_word(dev, PCI_COMMAND, cmd); | ||
| 465 | } | ||
| 466 | return 0; | ||
| 467 | } | ||
| 468 | |||
| 469 | #ifdef CONFIG_HOTPLUG | 439 | #ifdef CONFIG_HOTPLUG |
| 470 | 440 | ||
| 471 | int pcibios_unmap_io_space(struct pci_bus *bus) | 441 | int pcibios_unmap_io_space(struct pci_bus *bus) |
diff --git a/arch/powerpc/platforms/powermac/pci.c b/arch/powerpc/platforms/powermac/pci.c index 6bbf3c881711..1e51a8ee2b7d 100644 --- a/arch/powerpc/platforms/powermac/pci.c +++ b/arch/powerpc/platforms/powermac/pci.c | |||
| @@ -1058,8 +1058,7 @@ void __init pmac_pci_init(void) | |||
| 1058 | #endif | 1058 | #endif |
| 1059 | } | 1059 | } |
| 1060 | 1060 | ||
| 1061 | int | 1061 | int pmac_pci_enable_device_hook(struct pci_dev *dev) |
| 1062 | pmac_pci_enable_device_hook(struct pci_dev *dev, int initial) | ||
| 1063 | { | 1062 | { |
| 1064 | struct device_node* node; | 1063 | struct device_node* node; |
| 1065 | int updatecfg = 0; | 1064 | int updatecfg = 0; |
| @@ -1101,26 +1100,25 @@ pmac_pci_enable_device_hook(struct pci_dev *dev, int initial) | |||
| 1101 | updatecfg = 1; | 1100 | updatecfg = 1; |
| 1102 | } | 1101 | } |
| 1103 | 1102 | ||
| 1103 | /* | ||
| 1104 | * Fixup various header fields on 32 bits. We don't do that on | ||
| 1105 | * 64 bits as some of these have strange values behind the HT | ||
| 1106 | * bridge and we must not, for example, enable MWI or set the | ||
| 1107 | * cache line size on them. | ||
| 1108 | */ | ||
| 1109 | #ifdef CONFIG_PPC32 | ||
| 1104 | if (updatecfg) { | 1110 | if (updatecfg) { |
| 1105 | u16 cmd; | 1111 | u16 cmd; |
| 1106 | 1112 | ||
| 1107 | /* | ||
| 1108 | * Make sure PCI is correctly configured | ||
| 1109 | * | ||
| 1110 | * We use old pci_bios versions of the function since, by | ||
| 1111 | * default, gmac is not powered up, and so will be absent | ||
| 1112 | * from the kernel initial PCI lookup. | ||
| 1113 | * | ||
| 1114 | * Should be replaced by 2.4 new PCI mechanisms and really | ||
| 1115 | * register the device. | ||
| 1116 | */ | ||
| 1117 | pci_read_config_word(dev, PCI_COMMAND, &cmd); | 1113 | pci_read_config_word(dev, PCI_COMMAND, &cmd); |
| 1118 | cmd |= PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | 1114 | cmd |= PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
| 1119 | | PCI_COMMAND_INVALIDATE; | 1115 | | PCI_COMMAND_INVALIDATE; |
| 1120 | pci_write_config_word(dev, PCI_COMMAND, cmd); | 1116 | pci_write_config_word(dev, PCI_COMMAND, cmd); |
| 1121 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 16); | 1117 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 16); |
| 1118 | |||
| 1122 | pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, | 1119 | pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, |
| 1123 | L1_CACHE_BYTES >> 2); | 1120 | L1_CACHE_BYTES >> 2); |
| 1121 | #endif | ||
| 1124 | } | 1122 | } |
| 1125 | 1123 | ||
| 1126 | return 0; | 1124 | return 0; |
diff --git a/arch/powerpc/platforms/powermac/pmac.h b/arch/powerpc/platforms/powermac/pmac.h index fcde070f7054..b3abaaf61eb4 100644 --- a/arch/powerpc/platforms/powermac/pmac.h +++ b/arch/powerpc/platforms/powermac/pmac.h | |||
| @@ -26,7 +26,7 @@ extern void pmac_pci_init(void); | |||
| 26 | extern void pmac_nvram_update(void); | 26 | extern void pmac_nvram_update(void); |
| 27 | extern unsigned char pmac_nvram_read_byte(int addr); | 27 | extern unsigned char pmac_nvram_read_byte(int addr); |
| 28 | extern void pmac_nvram_write_byte(int addr, unsigned char val); | 28 | extern void pmac_nvram_write_byte(int addr, unsigned char val); |
| 29 | extern int pmac_pci_enable_device_hook(struct pci_dev *dev, int initial); | 29 | extern int pmac_pci_enable_device_hook(struct pci_dev *dev); |
| 30 | extern void pmac_pcibios_after_init(void); | 30 | extern void pmac_pcibios_after_init(void); |
| 31 | extern int of_show_percpuinfo(struct seq_file *m, int i); | 31 | extern int of_show_percpuinfo(struct seq_file *m, int i); |
| 32 | 32 | ||
diff --git a/include/asm-powerpc/machdep.h b/include/asm-powerpc/machdep.h index ed9103148690..79c704ed5381 100644 --- a/include/asm-powerpc/machdep.h +++ b/include/asm-powerpc/machdep.h | |||
| @@ -204,12 +204,6 @@ struct machdep_calls { | |||
| 204 | /* | 204 | /* |
| 205 | * optional PCI "hooks" | 205 | * optional PCI "hooks" |
| 206 | */ | 206 | */ |
| 207 | |||
| 208 | /* Called when pci_enable_device() is called (initial=0) or | ||
| 209 | * when a device with no assigned resource is found (initial=1). | ||
| 210 | * Returns 0 to allow assignment/enabling of the device. */ | ||
| 211 | int (*pcibios_enable_device_hook)(struct pci_dev *, int initial); | ||
| 212 | |||
| 213 | /* Called in indirect_* to avoid touching devices */ | 207 | /* Called in indirect_* to avoid touching devices */ |
| 214 | int (*pci_exclude_device)(struct pci_controller *, unsigned char, unsigned char); | 208 | int (*pci_exclude_device)(struct pci_controller *, unsigned char, unsigned char); |
| 215 | 209 | ||
| @@ -225,6 +219,10 @@ struct machdep_calls { | |||
| 225 | /* Called for each PCI bus in the system when it's probed */ | 219 | /* Called for each PCI bus in the system when it's probed */ |
| 226 | void (*pcibios_fixup_bus)(struct pci_bus *); | 220 | void (*pcibios_fixup_bus)(struct pci_bus *); |
| 227 | 221 | ||
| 222 | /* Called when pci_enable_device() is called. Returns 0 to | ||
| 223 | * allow assignment/enabling of the device. */ | ||
| 224 | int (*pcibios_enable_device_hook)(struct pci_dev *); | ||
| 225 | |||
| 228 | /* Called to shutdown machine specific hardware not already controlled | 226 | /* Called to shutdown machine specific hardware not already controlled |
| 229 | * by other drivers. | 227 | * by other drivers. |
| 230 | */ | 228 | */ |
