aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc/kernel/leon_pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sparc/kernel/leon_pci.c')
-rw-r--r--arch/sparc/kernel/leon_pci.c62
1 files changed, 21 insertions, 41 deletions
diff --git a/arch/sparc/kernel/leon_pci.c b/arch/sparc/kernel/leon_pci.c
index 15b59169c535..e5e5ff6b9a5c 100644
--- a/arch/sparc/kernel/leon_pci.c
+++ b/arch/sparc/kernel/leon_pci.c
@@ -60,50 +60,30 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)
60 pci_bus_add_devices(root_bus); 60 pci_bus_add_devices(root_bus);
61} 61}
62 62
63void pcibios_fixup_bus(struct pci_bus *pbus) 63int pcibios_enable_device(struct pci_dev *dev, int mask)
64{ 64{
65 struct pci_dev *dev; 65 u16 cmd, oldcmd;
66 int i, has_io, has_mem; 66 int i;
67 u16 cmd;
68 67
69 list_for_each_entry(dev, &pbus->devices, bus_list) { 68 pci_read_config_word(dev, PCI_COMMAND, &cmd);
70 /* 69 oldcmd = cmd;
71 * We can not rely on that the bootloader has enabled I/O 70
72 * or memory access to PCI devices. Instead we enable it here 71 for (i = 0; i < PCI_NUM_RESOURCES; i++) {
73 * if the device has BARs of respective type. 72 struct resource *res = &dev->resource[i];
74 */ 73
75 has_io = has_mem = 0; 74 /* Only set up the requested stuff */
76 for (i = 0; i < PCI_ROM_RESOURCE; i++) { 75 if (!(mask & (1<<i)))
77 unsigned long f = dev->resource[i].flags; 76 continue;
78 if (f & IORESOURCE_IO) 77
79 has_io = 1; 78 if (res->flags & IORESOURCE_IO)
80 else if (f & IORESOURCE_MEM)
81 has_mem = 1;
82 }
83 /* ROM BARs are mapped into 32-bit memory space */
84 if (dev->resource[PCI_ROM_RESOURCE].end != 0) {
85 dev->resource[PCI_ROM_RESOURCE].flags |=
86 IORESOURCE_ROM_ENABLE;
87 has_mem = 1;
88 }
89 pci_bus_read_config_word(pbus, dev->devfn, PCI_COMMAND, &cmd);
90 if (has_io && !(cmd & PCI_COMMAND_IO)) {
91#ifdef CONFIG_PCI_DEBUG
92 printk(KERN_INFO "LEONPCI: Enabling I/O for dev %s\n",
93 pci_name(dev));
94#endif
95 cmd |= PCI_COMMAND_IO; 79 cmd |= PCI_COMMAND_IO;
96 pci_bus_write_config_word(pbus, dev->devfn, PCI_COMMAND, 80 if (res->flags & IORESOURCE_MEM)
97 cmd);
98 }
99 if (has_mem && !(cmd & PCI_COMMAND_MEMORY)) {
100#ifdef CONFIG_PCI_DEBUG
101 printk(KERN_INFO "LEONPCI: Enabling MEMORY for dev"
102 "%s\n", pci_name(dev));
103#endif
104 cmd |= PCI_COMMAND_MEMORY; 81 cmd |= PCI_COMMAND_MEMORY;
105 pci_bus_write_config_word(pbus, dev->devfn, PCI_COMMAND,
106 cmd);
107 }
108 } 82 }
83
84 if (cmd != oldcmd) {
85 pci_info(dev, "enabling device (%04x -> %04x)\n", oldcmd, cmd);
86 pci_write_config_word(dev, PCI_COMMAND, cmd);
87 }
88 return 0;
109} 89}