aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/pci-common.c
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/pci-common.c
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/pci-common.c')
-rw-r--r--arch/powerpc/kernel/pci-common.c38
1 files changed, 38 insertions, 0 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