diff options
Diffstat (limited to 'arch/i386/pci/i386.c')
-rw-r--r-- | arch/i386/pci/i386.c | 73 |
1 files changed, 43 insertions, 30 deletions
diff --git a/arch/i386/pci/i386.c b/arch/i386/pci/i386.c index 10154a2cac68..43005f044424 100644 --- a/arch/i386/pci/i386.c +++ b/arch/i386/pci/i386.c | |||
@@ -104,16 +104,24 @@ static void __init pcibios_allocate_bus_resources(struct list_head *bus_list) | |||
104 | /* Depth-First Search on bus tree */ | 104 | /* Depth-First Search on bus tree */ |
105 | list_for_each_entry(bus, bus_list, node) { | 105 | list_for_each_entry(bus, bus_list, node) { |
106 | if ((dev = bus->self)) { | 106 | if ((dev = bus->self)) { |
107 | for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) { | 107 | for (idx = PCI_BRIDGE_RESOURCES; |
108 | idx < PCI_NUM_RESOURCES; idx++) { | ||
108 | r = &dev->resource[idx]; | 109 | r = &dev->resource[idx]; |
109 | if (!r->flags) | 110 | if (!r->flags) |
110 | continue; | 111 | continue; |
111 | pr = pci_find_parent_resource(dev, r); | 112 | pr = pci_find_parent_resource(dev, r); |
112 | if (!r->start || !pr || request_resource(pr, r) < 0) { | 113 | if (!r->start || !pr || |
113 | printk(KERN_ERR "PCI: Cannot allocate resource region %d of bridge %s\n", idx, pci_name(dev)); | 114 | request_resource(pr, r) < 0) { |
114 | /* Something is wrong with the region. | 115 | printk(KERN_ERR "PCI: Cannot allocate " |
115 | Invalidate the resource to prevent child | 116 | "resource region %d " |
116 | resource allocations in this range. */ | 117 | "of bridge %s\n", |
118 | idx, pci_name(dev)); | ||
119 | /* | ||
120 | * Something is wrong with the region. | ||
121 | * Invalidate the resource to prevent | ||
122 | * child resource allocations in this | ||
123 | * range. | ||
124 | */ | ||
117 | r->flags = 0; | 125 | r->flags = 0; |
118 | } | 126 | } |
119 | } | 127 | } |
@@ -131,7 +139,7 @@ static void __init pcibios_allocate_resources(int pass) | |||
131 | 139 | ||
132 | for_each_pci_dev(dev) { | 140 | for_each_pci_dev(dev) { |
133 | pci_read_config_word(dev, PCI_COMMAND, &command); | 141 | pci_read_config_word(dev, PCI_COMMAND, &command); |
134 | for(idx = 0; idx < 6; idx++) { | 142 | for (idx = 0; idx < PCI_ROM_RESOURCE; idx++) { |
135 | r = &dev->resource[idx]; | 143 | r = &dev->resource[idx]; |
136 | if (r->parent) /* Already allocated */ | 144 | if (r->parent) /* Already allocated */ |
137 | continue; | 145 | continue; |
@@ -142,11 +150,15 @@ static void __init pcibios_allocate_resources(int pass) | |||
142 | else | 150 | else |
143 | disabled = !(command & PCI_COMMAND_MEMORY); | 151 | disabled = !(command & PCI_COMMAND_MEMORY); |
144 | if (pass == disabled) { | 152 | if (pass == disabled) { |
145 | DBG("PCI: Resource %08lx-%08lx (f=%lx, d=%d, p=%d)\n", | 153 | DBG("PCI: Resource %08lx-%08lx " |
154 | "(f=%lx, d=%d, p=%d)\n", | ||
146 | r->start, r->end, r->flags, disabled, pass); | 155 | r->start, r->end, r->flags, disabled, pass); |
147 | pr = pci_find_parent_resource(dev, r); | 156 | pr = pci_find_parent_resource(dev, r); |
148 | if (!pr || request_resource(pr, r) < 0) { | 157 | if (!pr || request_resource(pr, r) < 0) { |
149 | printk(KERN_ERR "PCI: Cannot allocate resource region %d of device %s\n", idx, pci_name(dev)); | 158 | printk(KERN_ERR "PCI: Cannot allocate " |
159 | "resource region %d " | ||
160 | "of device %s\n", | ||
161 | idx, pci_name(dev)); | ||
150 | /* We'll assign a new address later */ | 162 | /* We'll assign a new address later */ |
151 | r->end -= r->start; | 163 | r->end -= r->start; |
152 | r->start = 0; | 164 | r->start = 0; |
@@ -156,12 +168,16 @@ static void __init pcibios_allocate_resources(int pass) | |||
156 | if (!pass) { | 168 | if (!pass) { |
157 | r = &dev->resource[PCI_ROM_RESOURCE]; | 169 | r = &dev->resource[PCI_ROM_RESOURCE]; |
158 | if (r->flags & IORESOURCE_ROM_ENABLE) { | 170 | if (r->flags & IORESOURCE_ROM_ENABLE) { |
159 | /* Turn the ROM off, leave the resource region, but keep it unregistered. */ | 171 | /* Turn the ROM off, leave the resource region, |
172 | * but keep it unregistered. */ | ||
160 | u32 reg; | 173 | u32 reg; |
161 | DBG("PCI: Switching off ROM of %s\n", pci_name(dev)); | 174 | DBG("PCI: Switching off ROM of %s\n", |
175 | pci_name(dev)); | ||
162 | r->flags &= ~IORESOURCE_ROM_ENABLE; | 176 | r->flags &= ~IORESOURCE_ROM_ENABLE; |
163 | pci_read_config_dword(dev, dev->rom_base_reg, ®); | 177 | pci_read_config_dword(dev, |
164 | pci_write_config_dword(dev, dev->rom_base_reg, reg & ~PCI_ROM_ADDRESS_ENABLE); | 178 | dev->rom_base_reg, ®); |
179 | pci_write_config_dword(dev, dev->rom_base_reg, | ||
180 | reg & ~PCI_ROM_ADDRESS_ENABLE); | ||
165 | } | 181 | } |
166 | } | 182 | } |
167 | } | 183 | } |
@@ -173,9 +189,11 @@ static int __init pcibios_assign_resources(void) | |||
173 | struct resource *r, *pr; | 189 | struct resource *r, *pr; |
174 | 190 | ||
175 | if (!(pci_probe & PCI_ASSIGN_ROMS)) { | 191 | if (!(pci_probe & PCI_ASSIGN_ROMS)) { |
176 | /* Try to use BIOS settings for ROMs, otherwise let | 192 | /* |
177 | pci_assign_unassigned_resources() allocate the new | 193 | * Try to use BIOS settings for ROMs, otherwise let |
178 | addresses. */ | 194 | * pci_assign_unassigned_resources() allocate the new |
195 | * addresses. | ||
196 | */ | ||
179 | for_each_pci_dev(dev) { | 197 | for_each_pci_dev(dev) { |
180 | r = &dev->resource[PCI_ROM_RESOURCE]; | 198 | r = &dev->resource[PCI_ROM_RESOURCE]; |
181 | if (!r->flags || !r->start) | 199 | if (!r->flags || !r->start) |
@@ -215,9 +233,9 @@ int pcibios_enable_resources(struct pci_dev *dev, int mask) | |||
215 | 233 | ||
216 | pci_read_config_word(dev, PCI_COMMAND, &cmd); | 234 | pci_read_config_word(dev, PCI_COMMAND, &cmd); |
217 | old_cmd = cmd; | 235 | old_cmd = cmd; |
218 | for(idx = 0; idx < PCI_NUM_RESOURCES; idx++) { | 236 | for (idx = 0; idx < PCI_NUM_RESOURCES; idx++) { |
219 | /* Only set up the requested stuff */ | 237 | /* Only set up the requested stuff */ |
220 | if (!(mask & (1<<idx))) | 238 | if (!(mask & (1 << idx))) |
221 | continue; | 239 | continue; |
222 | 240 | ||
223 | r = &dev->resource[idx]; | 241 | r = &dev->resource[idx]; |
@@ -227,7 +245,9 @@ int pcibios_enable_resources(struct pci_dev *dev, int mask) | |||
227 | (!(r->flags & IORESOURCE_ROM_ENABLE))) | 245 | (!(r->flags & IORESOURCE_ROM_ENABLE))) |
228 | continue; | 246 | continue; |
229 | if (!r->start && r->end) { | 247 | if (!r->start && r->end) { |
230 | printk(KERN_ERR "PCI: Device %s not available because of resource collisions\n", pci_name(dev)); | 248 | printk(KERN_ERR "PCI: Device %s not available " |
249 | "because of resource collisions\n", | ||
250 | pci_name(dev)); | ||
231 | return -EINVAL; | 251 | return -EINVAL; |
232 | } | 252 | } |
233 | if (r->flags & IORESOURCE_IO) | 253 | if (r->flags & IORESOURCE_IO) |
@@ -236,21 +256,13 @@ int pcibios_enable_resources(struct pci_dev *dev, int mask) | |||
236 | cmd |= PCI_COMMAND_MEMORY; | 256 | cmd |= PCI_COMMAND_MEMORY; |
237 | } | 257 | } |
238 | if (cmd != old_cmd) { | 258 | if (cmd != old_cmd) { |
239 | printk("PCI: Enabling device %s (%04x -> %04x)\n", pci_name(dev), old_cmd, cmd); | 259 | printk("PCI: Enabling device %s (%04x -> %04x)\n", |
260 | pci_name(dev), old_cmd, cmd); | ||
240 | pci_write_config_word(dev, PCI_COMMAND, cmd); | 261 | pci_write_config_word(dev, PCI_COMMAND, cmd); |
241 | } | 262 | } |
242 | return 0; | 263 | return 0; |
243 | } | 264 | } |
244 | 265 | ||
245 | void pcibios_disable_resources(struct pci_dev *dev) | ||
246 | { | ||
247 | u16 cmd; | ||
248 | |||
249 | pci_read_config_word(dev, PCI_COMMAND, &cmd); | ||
250 | cmd &= ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY); | ||
251 | pci_write_config_word(dev, PCI_COMMAND, cmd); | ||
252 | } | ||
253 | |||
254 | /* | 266 | /* |
255 | * If we set up a device for bus mastering, we need to check the latency | 267 | * If we set up a device for bus mastering, we need to check the latency |
256 | * timer as certain crappy BIOSes forget to set it properly. | 268 | * timer as certain crappy BIOSes forget to set it properly. |
@@ -267,7 +279,8 @@ void pcibios_set_master(struct pci_dev *dev) | |||
267 | lat = pcibios_max_latency; | 279 | lat = pcibios_max_latency; |
268 | else | 280 | else |
269 | return; | 281 | return; |
270 | printk(KERN_DEBUG "PCI: Setting latency timer of device %s to %d\n", pci_name(dev), lat); | 282 | printk(KERN_DEBUG "PCI: Setting latency timer of device %s to %d\n", |
283 | pci_name(dev), lat); | ||
271 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat); | 284 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat); |
272 | } | 285 | } |
273 | 286 | ||