aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2007-12-19 22:54:57 -0500
committerPaul Mackerras <paulus@samba.org>2007-12-20 00:18:11 -0500
commit549beb9ba3b03345cbd8e1233825d5b197a3f9f7 (patch)
treec192ba6cdfa13e9888d9e5f534d2862127d412cb /arch/powerpc/kernel
parent24f8c827f9b8ab2c8644f7ab85a1b1d58fc0fcf7 (diff)
[POWERPC] Merge 32 and 64 bits pcibios_enable_device
This merge the two implementations, based on the previously fixed up 32 bits one. The pcibios_enable_device_hook in ppc_md is now available for ppc64 use. Also remove the new unused "initial" parameter from it and fixup users. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r--arch/powerpc/kernel/pci-common.c38
-rw-r--r--arch/powerpc/kernel/pci_32.c37
-rw-r--r--arch/powerpc/kernel/pci_64.c30
3 files changed, 38 insertions, 67 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}
1128EXPORT_SYMBOL_GPL(pcibios_claim_one_bus); 1128EXPORT_SYMBOL_GPL(pcibios_claim_one_bus);
1129#endif /* CONFIG_HOTPLUG */ 1129#endif /* CONFIG_HOTPLUG */
1130
1131int 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
521int 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
558static struct pci_controller* 521static struct pci_controller*
559pci_bus_to_hose(int bus) 522pci_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
437subsys_initcall(pcibios_init); 437subsys_initcall(pcibios_init);
438 438
439int 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
471int pcibios_unmap_io_space(struct pci_bus *bus) 441int pcibios_unmap_io_space(struct pci_bus *bus)