aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/hotplug.c119
-rw-r--r--drivers/pci/hotplug/cpci_hotplug.h2
-rw-r--r--drivers/pci/hotplug/cpci_hotplug_core.c429
-rw-r--r--drivers/pci/hotplug/cpci_hotplug_pci.c483
-rw-r--r--drivers/pci/hotplug/ibmphp.h2
-rw-r--r--drivers/pci/hotplug/ibmphp_hpc.c6
-rw-r--r--drivers/pci/hotplug/ibmphp_pci.c7
-rw-r--r--drivers/pci/hotplug/pci_hotplug.h2
-rw-r--r--drivers/pci/hotplug/pciehp.h1
-rw-r--r--drivers/pci/hotplug/pciehp_core.c25
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c156
-rw-r--r--drivers/pci/hotplug/pcihp_skeleton.c2
-rw-r--r--drivers/pci/hotplug/shpchp_core.c2
-rw-r--r--drivers/pci/hotplug/shpchp_ctrl.c30
-rw-r--r--drivers/pci/hotplug/shpchprm_acpi.c4
-rw-r--r--drivers/pci/msi.c6
-rw-r--r--drivers/pci/pci-acpi.c2
-rw-r--r--drivers/pci/pci-driver.c11
-rw-r--r--drivers/pci/pci-sysfs.c94
-rw-r--r--drivers/pci/pci.c20
-rw-r--r--drivers/pci/pci.h27
-rw-r--r--drivers/pci/pci.ids1
-rw-r--r--drivers/pci/pcie/portdrv_bus.c3
-rw-r--r--drivers/pci/probe.c3
-rw-r--r--drivers/pci/proc.c1
-rw-r--r--drivers/pci/quirks.c61
26 files changed, 545 insertions, 954 deletions
diff --git a/drivers/pci/hotplug.c b/drivers/pci/hotplug.c
index 021d0f76bc4c..3903f8c559b6 100644
--- a/drivers/pci/hotplug.c
+++ b/drivers/pci/hotplug.c
@@ -52,116 +52,17 @@ int pci_hotplug (struct device *dev, char **envp, int num_envp,
52 if ((buffer_size - length <= 0) || (i >= num_envp)) 52 if ((buffer_size - length <= 0) || (i >= num_envp))
53 return -ENOMEM; 53 return -ENOMEM;
54 54
55 envp[i++] = scratch;
56 length += scnprintf (scratch, buffer_size - length,
57 "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x\n",
58 pdev->vendor, pdev->device,
59 pdev->subsystem_vendor, pdev->subsystem_device,
60 (u8)(pdev->class >> 16), (u8)(pdev->class >> 8),
61 (u8)(pdev->class));
62 if ((buffer_size - length <= 0) || (i >= num_envp))
63 return -ENOMEM;
64
55 envp[i] = NULL; 65 envp[i] = NULL;
56 66
57 return 0; 67 return 0;
58} 68}
59
60static int pci_visit_bus (struct pci_visit * fn, struct pci_bus_wrapped *wrapped_bus, struct pci_dev_wrapped *wrapped_parent)
61{
62 struct list_head *ln;
63 struct pci_dev *dev;
64 struct pci_dev_wrapped wrapped_dev;
65 int result = 0;
66
67 pr_debug("PCI: Scanning bus %04x:%02x\n", pci_domain_nr(wrapped_bus->bus),
68 wrapped_bus->bus->number);
69
70 if (fn->pre_visit_pci_bus) {
71 result = fn->pre_visit_pci_bus(wrapped_bus, wrapped_parent);
72 if (result)
73 return result;
74 }
75
76 ln = wrapped_bus->bus->devices.next;
77 while (ln != &wrapped_bus->bus->devices) {
78 dev = pci_dev_b(ln);
79 ln = ln->next;
80
81 memset(&wrapped_dev, 0, sizeof(struct pci_dev_wrapped));
82 wrapped_dev.dev = dev;
83
84 result = pci_visit_dev(fn, &wrapped_dev, wrapped_bus);
85 if (result)
86 return result;
87 }
88
89 if (fn->post_visit_pci_bus)
90 result = fn->post_visit_pci_bus(wrapped_bus, wrapped_parent);
91
92 return result;
93}
94
95static int pci_visit_bridge (struct pci_visit * fn,
96 struct pci_dev_wrapped *wrapped_dev,
97 struct pci_bus_wrapped *wrapped_parent)
98{
99 struct pci_bus *bus;
100 struct pci_bus_wrapped wrapped_bus;
101 int result = 0;
102
103 pr_debug("PCI: Scanning bridge %s\n", pci_name(wrapped_dev->dev));
104
105 if (fn->visit_pci_dev) {
106 result = fn->visit_pci_dev(wrapped_dev, wrapped_parent);
107 if (result)
108 return result;
109 }
110
111 bus = wrapped_dev->dev->subordinate;
112 if (bus) {
113 memset(&wrapped_bus, 0, sizeof(struct pci_bus_wrapped));
114 wrapped_bus.bus = bus;
115
116 result = pci_visit_bus(fn, &wrapped_bus, wrapped_dev);
117 }
118 return result;
119}
120
121/**
122 * pci_visit_dev - scans the pci buses.
123 * @fn: callback functions that are called while visiting
124 * @wrapped_dev: the device to scan
125 * @wrapped_parent: the bus where @wrapped_dev is connected to
126 *
127 * Every bus and every function is presented to a custom
128 * function that can act upon it.
129 */
130int pci_visit_dev(struct pci_visit *fn, struct pci_dev_wrapped *wrapped_dev,
131 struct pci_bus_wrapped *wrapped_parent)
132{
133 struct pci_dev* dev = wrapped_dev ? wrapped_dev->dev : NULL;
134 int result = 0;
135
136 if (!dev)
137 return 0;
138
139 if (fn->pre_visit_pci_dev) {
140 result = fn->pre_visit_pci_dev(wrapped_dev, wrapped_parent);
141 if (result)
142 return result;
143 }
144
145 switch (dev->class >> 8) {
146 case PCI_CLASS_BRIDGE_PCI:
147 result = pci_visit_bridge(fn, wrapped_dev,
148 wrapped_parent);
149 if (result)
150 return result;
151 break;
152 default:
153 pr_debug("PCI: Scanning device %s\n", pci_name(dev));
154 if (fn->visit_pci_dev) {
155 result = fn->visit_pci_dev (wrapped_dev,
156 wrapped_parent);
157 if (result)
158 return result;
159 }
160 }
161
162 if (fn->post_visit_pci_dev)
163 result = fn->post_visit_pci_dev(wrapped_dev, wrapped_parent);
164
165 return result;
166}
167EXPORT_SYMBOL(pci_visit_dev);
diff --git a/drivers/pci/hotplug/cpci_hotplug.h b/drivers/pci/hotplug/cpci_hotplug.h
index 3ddd75937a40..d9769b30be9a 100644
--- a/drivers/pci/hotplug/cpci_hotplug.h
+++ b/drivers/pci/hotplug/cpci_hotplug.h
@@ -31,7 +31,7 @@
31#include <linux/types.h> 31#include <linux/types.h>
32#include <linux/pci.h> 32#include <linux/pci.h>
33 33
34/* PICMG 2.12 R2.0 HS CSR bits: */ 34/* PICMG 2.1 R2.0 HS CSR bits: */
35#define HS_CSR_INS 0x0080 35#define HS_CSR_INS 0x0080
36#define HS_CSR_EXT 0x0040 36#define HS_CSR_EXT 0x0040
37#define HS_CSR_PI 0x0030 37#define HS_CSR_PI 0x0030
diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c
index ed243605dc7b..30af105271a2 100644
--- a/drivers/pci/hotplug/cpci_hotplug_core.c
+++ b/drivers/pci/hotplug/cpci_hotplug_core.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * CompactPCI Hot Plug Driver 2 * CompactPCI Hot Plug Driver
3 * 3 *
4 * Copyright (C) 2002 SOMA Networks, Inc. 4 * Copyright (C) 2002,2005 SOMA Networks, Inc.
5 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com) 5 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
6 * Copyright (C) 2001 IBM Corp. 6 * Copyright (C) 2001 IBM Corp.
7 * 7 *
@@ -33,11 +33,11 @@
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/interrupt.h> 34#include <linux/interrupt.h>
35#include <linux/smp_lock.h> 35#include <linux/smp_lock.h>
36#include <asm/atomic.h>
36#include <linux/delay.h> 37#include <linux/delay.h>
37#include "pci_hotplug.h" 38#include "pci_hotplug.h"
38#include "cpci_hotplug.h" 39#include "cpci_hotplug.h"
39 40
40#define DRIVER_VERSION "0.2"
41#define DRIVER_AUTHOR "Scott Murray <scottm@somanetworks.com>" 41#define DRIVER_AUTHOR "Scott Murray <scottm@somanetworks.com>"
42#define DRIVER_DESC "CompactPCI Hot Plug Core" 42#define DRIVER_DESC "CompactPCI Hot Plug Core"
43 43
@@ -45,18 +45,19 @@
45 45
46#define dbg(format, arg...) \ 46#define dbg(format, arg...) \
47 do { \ 47 do { \
48 if(cpci_debug) \ 48 if (cpci_debug) \
49 printk (KERN_DEBUG "%s: " format "\n", \ 49 printk (KERN_DEBUG "%s: " format "\n", \
50 MY_NAME , ## arg); \ 50 MY_NAME , ## arg); \
51 } while(0) 51 } while (0)
52#define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg) 52#define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg)
53#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg) 53#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg)
54#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) 54#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg)
55 55
56/* local variables */ 56/* local variables */
57static spinlock_t list_lock; 57static DECLARE_RWSEM(list_rwsem);
58static LIST_HEAD(slot_list); 58static LIST_HEAD(slot_list);
59static int slots; 59static int slots;
60static atomic_t extracting;
60int cpci_debug; 61int cpci_debug;
61static struct cpci_hp_controller *controller; 62static struct cpci_hp_controller *controller;
62static struct semaphore event_semaphore; /* mutex for process loop (up if something to process) */ 63static struct semaphore event_semaphore; /* mutex for process loop (up if something to process) */
@@ -68,6 +69,8 @@ static int disable_slot(struct hotplug_slot *slot);
68static int set_attention_status(struct hotplug_slot *slot, u8 value); 69static int set_attention_status(struct hotplug_slot *slot, u8 value);
69static int get_power_status(struct hotplug_slot *slot, u8 * value); 70static int get_power_status(struct hotplug_slot *slot, u8 * value);
70static int get_attention_status(struct hotplug_slot *slot, u8 * value); 71static int get_attention_status(struct hotplug_slot *slot, u8 * value);
72static int get_adapter_status(struct hotplug_slot *slot, u8 * value);
73static int get_latch_status(struct hotplug_slot *slot, u8 * value);
71 74
72static struct hotplug_slot_ops cpci_hotplug_slot_ops = { 75static struct hotplug_slot_ops cpci_hotplug_slot_ops = {
73 .owner = THIS_MODULE, 76 .owner = THIS_MODULE,
@@ -76,6 +79,8 @@ static struct hotplug_slot_ops cpci_hotplug_slot_ops = {
76 .set_attention_status = set_attention_status, 79 .set_attention_status = set_attention_status,
77 .get_power_status = get_power_status, 80 .get_power_status = get_power_status,
78 .get_attention_status = get_attention_status, 81 .get_attention_status = get_attention_status,
82 .get_adapter_status = get_adapter_status,
83 .get_latch_status = get_latch_status,
79}; 84};
80 85
81static int 86static int
@@ -106,10 +111,8 @@ enable_slot(struct hotplug_slot *hotplug_slot)
106 111
107 dbg("%s - physical_slot = %s", __FUNCTION__, hotplug_slot->name); 112 dbg("%s - physical_slot = %s", __FUNCTION__, hotplug_slot->name);
108 113
109 if(controller->ops->set_power) { 114 if (controller->ops->set_power)
110 retval = controller->ops->set_power(slot, 1); 115 retval = controller->ops->set_power(slot, 1);
111 }
112
113 return retval; 116 return retval;
114} 117}
115 118
@@ -121,35 +124,41 @@ disable_slot(struct hotplug_slot *hotplug_slot)
121 124
122 dbg("%s - physical_slot = %s", __FUNCTION__, hotplug_slot->name); 125 dbg("%s - physical_slot = %s", __FUNCTION__, hotplug_slot->name);
123 126
127 down_write(&list_rwsem);
128
124 /* Unconfigure device */ 129 /* Unconfigure device */
125 dbg("%s - unconfiguring slot %s", 130 dbg("%s - unconfiguring slot %s",
126 __FUNCTION__, slot->hotplug_slot->name); 131 __FUNCTION__, slot->hotplug_slot->name);
127 if((retval = cpci_unconfigure_slot(slot))) { 132 if ((retval = cpci_unconfigure_slot(slot))) {
128 err("%s - could not unconfigure slot %s", 133 err("%s - could not unconfigure slot %s",
129 __FUNCTION__, slot->hotplug_slot->name); 134 __FUNCTION__, slot->hotplug_slot->name);
130 return retval; 135 goto disable_error;
131 } 136 }
132 dbg("%s - finished unconfiguring slot %s", 137 dbg("%s - finished unconfiguring slot %s",
133 __FUNCTION__, slot->hotplug_slot->name); 138 __FUNCTION__, slot->hotplug_slot->name);
134 139
135 /* Clear EXT (by setting it) */ 140 /* Clear EXT (by setting it) */
136 if(cpci_clear_ext(slot)) { 141 if (cpci_clear_ext(slot)) {
137 err("%s - could not clear EXT for slot %s", 142 err("%s - could not clear EXT for slot %s",
138 __FUNCTION__, slot->hotplug_slot->name); 143 __FUNCTION__, slot->hotplug_slot->name);
139 retval = -ENODEV; 144 retval = -ENODEV;
145 goto disable_error;
140 } 146 }
141 cpci_led_on(slot); 147 cpci_led_on(slot);
142 148
143 if(controller->ops->set_power) { 149 if (controller->ops->set_power)
144 retval = controller->ops->set_power(slot, 0); 150 if ((retval = controller->ops->set_power(slot, 0)))
145 } 151 goto disable_error;
146 152
147 if(update_adapter_status(slot->hotplug_slot, 0)) { 153 if (update_adapter_status(slot->hotplug_slot, 0))
148 warn("failure to update adapter file"); 154 warn("failure to update adapter file");
149 }
150
151 slot->extracting = 0;
152 155
156 if (slot->extracting) {
157 slot->extracting = 0;
158 atomic_dec(&extracting);
159 }
160disable_error:
161 up_write(&list_rwsem);
153 return retval; 162 return retval;
154} 163}
155 164
@@ -158,9 +167,8 @@ cpci_get_power_status(struct slot *slot)
158{ 167{
159 u8 power = 1; 168 u8 power = 1;
160 169
161 if(controller->ops->get_power) { 170 if (controller->ops->get_power)
162 power = controller->ops->get_power(slot); 171 power = controller->ops->get_power(slot);
163 }
164 return power; 172 return power;
165} 173}
166 174
@@ -188,6 +196,20 @@ set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
188 return cpci_set_attention_status(hotplug_slot->private, status); 196 return cpci_set_attention_status(hotplug_slot->private, status);
189} 197}
190 198
199static int
200get_adapter_status(struct hotplug_slot *hotplug_slot, u8 * value)
201{
202 *value = hotplug_slot->info->adapter_status;
203 return 0;
204}
205
206static int
207get_latch_status(struct hotplug_slot *hotplug_slot, u8 * value)
208{
209 *value = hotplug_slot->info->latch_status;
210 return 0;
211}
212
191static void release_slot(struct hotplug_slot *hotplug_slot) 213static void release_slot(struct hotplug_slot *hotplug_slot)
192{ 214{
193 struct slot *slot = hotplug_slot->private; 215 struct slot *slot = hotplug_slot->private;
@@ -195,6 +217,8 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
195 kfree(slot->hotplug_slot->info); 217 kfree(slot->hotplug_slot->info);
196 kfree(slot->hotplug_slot->name); 218 kfree(slot->hotplug_slot->name);
197 kfree(slot->hotplug_slot); 219 kfree(slot->hotplug_slot);
220 if (slot->dev)
221 pci_dev_put(slot->dev);
198 kfree(slot); 222 kfree(slot);
199} 223}
200 224
@@ -216,9 +240,8 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
216 int status = -ENOMEM; 240 int status = -ENOMEM;
217 int i; 241 int i;
218 242
219 if(!(controller && bus)) { 243 if (!(controller && bus))
220 return -ENODEV; 244 return -ENODEV;
221 }
222 245
223 /* 246 /*
224 * Create a structure for each slot, and register that slot 247 * Create a structure for each slot, and register that slot
@@ -273,10 +296,10 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
273 } 296 }
274 297
275 /* Add slot to our internal list */ 298 /* Add slot to our internal list */
276 spin_lock(&list_lock); 299 down_write(&list_rwsem);
277 list_add(&slot->slot_list, &slot_list); 300 list_add(&slot->slot_list, &slot_list);
278 slots++; 301 slots++;
279 spin_unlock(&list_lock); 302 up_write(&list_rwsem);
280 } 303 }
281 return 0; 304 return 0;
282error_name: 305error_name:
@@ -295,32 +318,30 @@ int
295cpci_hp_unregister_bus(struct pci_bus *bus) 318cpci_hp_unregister_bus(struct pci_bus *bus)
296{ 319{
297 struct slot *slot; 320 struct slot *slot;
298 struct list_head *tmp; 321 struct slot *tmp;
299 struct list_head *next; 322 int status = 0;
300 int status;
301 323
302 spin_lock(&list_lock); 324 down_write(&list_rwsem);
303 if(!slots) { 325 if (!slots) {
304 spin_unlock(&list_lock); 326 up_write(&list_rwsem);
305 return -1; 327 return -1;
306 } 328 }
307 list_for_each_safe(tmp, next, &slot_list) { 329 list_for_each_entry_safe(slot, tmp, &slot_list, slot_list) {
308 slot = list_entry(tmp, struct slot, slot_list); 330 if (slot->bus == bus) {
309 if(slot->bus == bus) { 331 list_del(&slot->slot_list);
332 slots--;
333
310 dbg("deregistering slot %s", slot->hotplug_slot->name); 334 dbg("deregistering slot %s", slot->hotplug_slot->name);
311 status = pci_hp_deregister(slot->hotplug_slot); 335 status = pci_hp_deregister(slot->hotplug_slot);
312 if(status) { 336 if (status) {
313 err("pci_hp_deregister failed with error %d", 337 err("pci_hp_deregister failed with error %d",
314 status); 338 status);
315 return status; 339 break;
316 } 340 }
317
318 list_del(&slot->slot_list);
319 slots--;
320 } 341 }
321 } 342 }
322 spin_unlock(&list_lock); 343 up_write(&list_rwsem);
323 return 0; 344 return status;
324} 345}
325 346
326/* This is the interrupt mode interrupt handler */ 347/* This is the interrupt mode interrupt handler */
@@ -330,7 +351,7 @@ cpci_hp_intr(int irq, void *data, struct pt_regs *regs)
330 dbg("entered cpci_hp_intr"); 351 dbg("entered cpci_hp_intr");
331 352
332 /* Check to see if it was our interrupt */ 353 /* Check to see if it was our interrupt */
333 if((controller->irq_flags & SA_SHIRQ) && 354 if ((controller->irq_flags & SA_SHIRQ) &&
334 !controller->ops->check_irq(controller->dev_id)) { 355 !controller->ops->check_irq(controller->dev_id)) {
335 dbg("exited cpci_hp_intr, not our interrupt"); 356 dbg("exited cpci_hp_intr, not our interrupt");
336 return IRQ_NONE; 357 return IRQ_NONE;
@@ -347,46 +368,38 @@ cpci_hp_intr(int irq, void *data, struct pt_regs *regs)
347} 368}
348 369
349/* 370/*
350 * According to PICMG 2.12 R2.0, section 6.3.2, upon 371 * According to PICMG 2.1 R2.0, section 6.3.2, upon
351 * initialization, the system driver shall clear the 372 * initialization, the system driver shall clear the
352 * INS bits of the cold-inserted devices. 373 * INS bits of the cold-inserted devices.
353 */ 374 */
354static int 375static int
355init_slots(void) 376init_slots(int clear_ins)
356{ 377{
357 struct slot *slot; 378 struct slot *slot;
358 struct list_head *tmp;
359 struct pci_dev* dev; 379 struct pci_dev* dev;
360 380
361 dbg("%s - enter", __FUNCTION__); 381 dbg("%s - enter", __FUNCTION__);
362 spin_lock(&list_lock); 382 down_read(&list_rwsem);
363 if(!slots) { 383 if (!slots) {
364 spin_unlock(&list_lock); 384 up_read(&list_rwsem);
365 return -1; 385 return -1;
366 } 386 }
367 list_for_each(tmp, &slot_list) { 387 list_for_each_entry(slot, &slot_list, slot_list) {
368 slot = list_entry(tmp, struct slot, slot_list);
369 dbg("%s - looking at slot %s", 388 dbg("%s - looking at slot %s",
370 __FUNCTION__, slot->hotplug_slot->name); 389 __FUNCTION__, slot->hotplug_slot->name);
371 if(cpci_check_and_clear_ins(slot)) { 390 if (clear_ins && cpci_check_and_clear_ins(slot))
372 dbg("%s - cleared INS for slot %s", 391 dbg("%s - cleared INS for slot %s",
373 __FUNCTION__, slot->hotplug_slot->name); 392 __FUNCTION__, slot->hotplug_slot->name);
374 dev = pci_find_slot(slot->bus->number, PCI_DEVFN(slot->number, 0)); 393 dev = pci_get_slot(slot->bus, PCI_DEVFN(slot->number, 0));
375 if(dev) { 394 if (dev) {
376 if(update_adapter_status(slot->hotplug_slot, 1)) { 395 if (update_adapter_status(slot->hotplug_slot, 1))
377 warn("failure to update adapter file"); 396 warn("failure to update adapter file");
378 } 397 if (update_latch_status(slot->hotplug_slot, 1))
379 if(update_latch_status(slot->hotplug_slot, 1)) { 398 warn("failure to update latch file");
380 warn("failure to update latch file"); 399 slot->dev = dev;
381 }
382 slot->dev = dev;
383 } else {
384 err("%s - no driver attached to device in slot %s",
385 __FUNCTION__, slot->hotplug_slot->name);
386 }
387 } 400 }
388 } 401 }
389 spin_unlock(&list_lock); 402 up_read(&list_rwsem);
390 dbg("%s - exit", __FUNCTION__); 403 dbg("%s - exit", __FUNCTION__);
391 return 0; 404 return 0;
392} 405}
@@ -395,27 +408,28 @@ static int
395check_slots(void) 408check_slots(void)
396{ 409{
397 struct slot *slot; 410 struct slot *slot;
398 struct list_head *tmp;
399 int extracted; 411 int extracted;
400 int inserted; 412 int inserted;
413 u16 hs_csr;
401 414
402 spin_lock(&list_lock); 415 down_read(&list_rwsem);
403 if(!slots) { 416 if (!slots) {
404 spin_unlock(&list_lock); 417 up_read(&list_rwsem);
405 err("no slots registered, shutting down"); 418 err("no slots registered, shutting down");
406 return -1; 419 return -1;
407 } 420 }
408 extracted = inserted = 0; 421 extracted = inserted = 0;
409 list_for_each(tmp, &slot_list) { 422 list_for_each_entry(slot, &slot_list, slot_list) {
410 slot = list_entry(tmp, struct slot, slot_list);
411 dbg("%s - looking at slot %s", 423 dbg("%s - looking at slot %s",
412 __FUNCTION__, slot->hotplug_slot->name); 424 __FUNCTION__, slot->hotplug_slot->name);
413 if(cpci_check_and_clear_ins(slot)) { 425 if (cpci_check_and_clear_ins(slot)) {
414 u16 hs_csr; 426 /*
415 427 * Some broken hardware (e.g. PLX 9054AB) asserts
416 /* Some broken hardware (e.g. PLX 9054AB) asserts ENUM# twice... */ 428 * ENUM# twice...
417 if(slot->dev) { 429 */
418 warn("slot %s already inserted", slot->hotplug_slot->name); 430 if (slot->dev) {
431 warn("slot %s already inserted",
432 slot->hotplug_slot->name);
419 inserted++; 433 inserted++;
420 continue; 434 continue;
421 } 435 }
@@ -432,7 +446,7 @@ check_slots(void)
432 /* Configure device */ 446 /* Configure device */
433 dbg("%s - configuring slot %s", 447 dbg("%s - configuring slot %s",
434 __FUNCTION__, slot->hotplug_slot->name); 448 __FUNCTION__, slot->hotplug_slot->name);
435 if(cpci_configure_slot(slot)) { 449 if (cpci_configure_slot(slot)) {
436 err("%s - could not configure slot %s", 450 err("%s - could not configure slot %s",
437 __FUNCTION__, slot->hotplug_slot->name); 451 __FUNCTION__, slot->hotplug_slot->name);
438 continue; 452 continue;
@@ -445,13 +459,11 @@ check_slots(void)
445 dbg("%s - slot %s HS_CSR (2) = %04x", 459 dbg("%s - slot %s HS_CSR (2) = %04x",
446 __FUNCTION__, slot->hotplug_slot->name, hs_csr); 460 __FUNCTION__, slot->hotplug_slot->name, hs_csr);
447 461
448 if(update_latch_status(slot->hotplug_slot, 1)) { 462 if (update_latch_status(slot->hotplug_slot, 1))
449 warn("failure to update latch file"); 463 warn("failure to update latch file");
450 }
451 464
452 if(update_adapter_status(slot->hotplug_slot, 1)) { 465 if (update_adapter_status(slot->hotplug_slot, 1))
453 warn("failure to update adapter file"); 466 warn("failure to update adapter file");
454 }
455 467
456 cpci_led_off(slot); 468 cpci_led_off(slot);
457 469
@@ -461,9 +473,7 @@ check_slots(void)
461 __FUNCTION__, slot->hotplug_slot->name, hs_csr); 473 __FUNCTION__, slot->hotplug_slot->name, hs_csr);
462 474
463 inserted++; 475 inserted++;
464 } else if(cpci_check_ext(slot)) { 476 } else if (cpci_check_ext(slot)) {
465 u16 hs_csr;
466
467 /* Process extraction request */ 477 /* Process extraction request */
468 dbg("%s - slot %s extracted", 478 dbg("%s - slot %s extracted",
469 __FUNCTION__, slot->hotplug_slot->name); 479 __FUNCTION__, slot->hotplug_slot->name);
@@ -473,23 +483,40 @@ check_slots(void)
473 dbg("%s - slot %s HS_CSR = %04x", 483 dbg("%s - slot %s HS_CSR = %04x",
474 __FUNCTION__, slot->hotplug_slot->name, hs_csr); 484 __FUNCTION__, slot->hotplug_slot->name, hs_csr);
475 485
476 if(!slot->extracting) { 486 if (!slot->extracting) {
477 if(update_latch_status(slot->hotplug_slot, 0)) { 487 if (update_latch_status(slot->hotplug_slot, 0)) {
478 warn("failure to update latch file"); 488 warn("failure to update latch file");
479 } 489 }
480 slot->extracting = 1; 490 slot->extracting = 1;
491 atomic_inc(&extracting);
481 } 492 }
482 extracted++; 493 extracted++;
494 } else if (slot->extracting) {
495 hs_csr = cpci_get_hs_csr(slot);
496 if (hs_csr == 0xffff) {
497 /*
498 * Hmmm, we're likely hosed at this point, should we
499 * bother trying to tell the driver or not?
500 */
501 err("card in slot %s was improperly removed",
502 slot->hotplug_slot->name);
503 if (update_adapter_status(slot->hotplug_slot, 0))
504 warn("failure to update adapter file");
505 slot->extracting = 0;
506 atomic_dec(&extracting);
507 }
483 } 508 }
484 } 509 }
485 spin_unlock(&list_lock); 510 up_read(&list_rwsem);
486 if(inserted || extracted) { 511 dbg("inserted=%d, extracted=%d, extracting=%d",
512 inserted, extracted, atomic_read(&extracting));
513 if (inserted || extracted)
487 return extracted; 514 return extracted;
488 } 515 else if (!atomic_read(&extracting)) {
489 else {
490 err("cannot find ENUM# source, shutting down"); 516 err("cannot find ENUM# source, shutting down");
491 return -1; 517 return -1;
492 } 518 }
519 return 0;
493} 520}
494 521
495/* This is the interrupt mode worker thread body */ 522/* This is the interrupt mode worker thread body */
@@ -497,54 +524,37 @@ static int
497event_thread(void *data) 524event_thread(void *data)
498{ 525{
499 int rc; 526 int rc;
500 struct slot *slot;
501 struct list_head *tmp;
502 527
503 lock_kernel(); 528 lock_kernel();
504 daemonize("cpci_hp_eventd"); 529 daemonize("cpci_hp_eventd");
505 unlock_kernel(); 530 unlock_kernel();
506 531
507 dbg("%s - event thread started", __FUNCTION__); 532 dbg("%s - event thread started", __FUNCTION__);
508 while(1) { 533 while (1) {
509 dbg("event thread sleeping"); 534 dbg("event thread sleeping");
510 down_interruptible(&event_semaphore); 535 down_interruptible(&event_semaphore);
511 dbg("event thread woken, thread_finished = %d", 536 dbg("event thread woken, thread_finished = %d",
512 thread_finished); 537 thread_finished);
513 if(thread_finished || signal_pending(current)) 538 if (thread_finished || signal_pending(current))
514 break; 539 break;
515 while(controller->ops->query_enum()) { 540 do {
516 rc = check_slots(); 541 rc = check_slots();
517 if (rc > 0) 542 if (rc > 0) {
518 /* Give userspace a chance to handle extraction */ 543 /* Give userspace a chance to handle extraction */
519 msleep(500); 544 msleep(500);
520 else if (rc < 0) { 545 } else if (rc < 0) {
521 dbg("%s - error checking slots", __FUNCTION__); 546 dbg("%s - error checking slots", __FUNCTION__);
522 thread_finished = 1; 547 thread_finished = 1;
523 break; 548 break;
524 } 549 }
525 } 550 } while (atomic_read(&extracting) && !thread_finished);
526 /* Check for someone yanking out a board */ 551 if (thread_finished)
527 list_for_each(tmp, &slot_list) { 552 break;
528 slot = list_entry(tmp, struct slot, slot_list);
529 if(slot->extracting) {
530 /*
531 * Hmmm, we're likely hosed at this point, should we
532 * bother trying to tell the driver or not?
533 */
534 err("card in slot %s was improperly removed",
535 slot->hotplug_slot->name);
536 if(update_adapter_status(slot->hotplug_slot, 0)) {
537 warn("failure to update adapter file");
538 }
539 slot->extracting = 0;
540 }
541 }
542 553
543 /* Re-enable ENUM# interrupt */ 554 /* Re-enable ENUM# interrupt */
544 dbg("%s - re-enabling irq", __FUNCTION__); 555 dbg("%s - re-enabling irq", __FUNCTION__);
545 controller->ops->enable_irq(); 556 controller->ops->enable_irq();
546 } 557 }
547
548 dbg("%s - event thread signals exit", __FUNCTION__); 558 dbg("%s - event thread signals exit", __FUNCTION__);
549 up(&thread_exit); 559 up(&thread_exit);
550 return 0; 560 return 0;
@@ -555,45 +565,27 @@ static int
555poll_thread(void *data) 565poll_thread(void *data)
556{ 566{
557 int rc; 567 int rc;
558 struct slot *slot;
559 struct list_head *tmp;
560 568
561 lock_kernel(); 569 lock_kernel();
562 daemonize("cpci_hp_polld"); 570 daemonize("cpci_hp_polld");
563 unlock_kernel(); 571 unlock_kernel();
564 572
565 while(1) { 573 while (1) {
566 if(thread_finished || signal_pending(current)) 574 if (thread_finished || signal_pending(current))
567 break; 575 break;
568 576 if (controller->ops->query_enum()) {
569 while(controller->ops->query_enum()) { 577 do {
570 rc = check_slots(); 578 rc = check_slots();
571 if(rc > 0) 579 if (rc > 0) {
572 /* Give userspace a chance to handle extraction */ 580 /* Give userspace a chance to handle extraction */
573 msleep(500); 581 msleep(500);
574 else if (rc < 0) { 582 } else if (rc < 0) {
575 dbg("%s - error checking slots", __FUNCTION__); 583 dbg("%s - error checking slots", __FUNCTION__);
576 thread_finished = 1; 584 thread_finished = 1;
577 break; 585 break;
578 }
579 }
580 /* Check for someone yanking out a board */
581 list_for_each(tmp, &slot_list) {
582 slot = list_entry(tmp, struct slot, slot_list);
583 if(slot->extracting) {
584 /*
585 * Hmmm, we're likely hosed at this point, should we
586 * bother trying to tell the driver or not?
587 */
588 err("card in slot %s was improperly removed",
589 slot->hotplug_slot->name);
590 if(update_adapter_status(slot->hotplug_slot, 0)) {
591 warn("failure to update adapter file");
592 } 586 }
593 slot->extracting = 0; 587 } while (atomic_read(&extracting) && !thread_finished);
594 }
595 } 588 }
596
597 msleep(100); 589 msleep(100);
598 } 590 }
599 dbg("poll thread signals exit"); 591 dbg("poll thread signals exit");
@@ -611,12 +603,11 @@ cpci_start_thread(void)
611 init_MUTEX_LOCKED(&thread_exit); 603 init_MUTEX_LOCKED(&thread_exit);
612 thread_finished = 0; 604 thread_finished = 0;
613 605
614 if(controller->irq) { 606 if (controller->irq)
615 pid = kernel_thread(event_thread, NULL, 0); 607 pid = kernel_thread(event_thread, NULL, 0);
616 } else { 608 else
617 pid = kernel_thread(poll_thread, NULL, 0); 609 pid = kernel_thread(poll_thread, NULL, 0);
618 } 610 if (pid < 0) {
619 if(pid < 0) {
620 err("Can't start up our thread"); 611 err("Can't start up our thread");
621 return -1; 612 return -1;
622 } 613 }
@@ -629,9 +620,8 @@ cpci_stop_thread(void)
629{ 620{
630 thread_finished = 1; 621 thread_finished = 1;
631 dbg("thread finish command given"); 622 dbg("thread finish command given");
632 if(controller->irq) { 623 if (controller->irq)
633 up(&event_semaphore); 624 up(&event_semaphore);
634 }
635 dbg("wait for thread to exit"); 625 dbg("wait for thread to exit");
636 down(&thread_exit); 626 down(&thread_exit);
637} 627}
@@ -641,42 +631,67 @@ cpci_hp_register_controller(struct cpci_hp_controller *new_controller)
641{ 631{
642 int status = 0; 632 int status = 0;
643 633
644 if(!controller) { 634 if (controller)
645 controller = new_controller; 635 return -1;
646 if(controller->irq) { 636 if (!(new_controller && new_controller->ops))
647 if(request_irq(controller->irq, 637 return -EINVAL;
648 cpci_hp_intr, 638 if (new_controller->irq) {
649 controller->irq_flags, 639 if (!(new_controller->ops->enable_irq &&
650 MY_NAME, controller->dev_id)) { 640 new_controller->ops->disable_irq))
651 err("Can't get irq %d for the hotplug cPCI controller", controller->irq); 641 status = -EINVAL;
652 status = -ENODEV; 642 if (request_irq(new_controller->irq,
653 } 643 cpci_hp_intr,
654 dbg("%s - acquired controller irq %d", __FUNCTION__, 644 new_controller->irq_flags,
655 controller->irq); 645 MY_NAME,
646 new_controller->dev_id)) {
647 err("Can't get irq %d for the hotplug cPCI controller",
648 new_controller->irq);
649 status = -ENODEV;
656 } 650 }
657 } else { 651 dbg("%s - acquired controller irq %d",
658 err("cPCI hotplug controller already registered"); 652 __FUNCTION__, new_controller->irq);
659 status = -1;
660 } 653 }
654 if (!status)
655 controller = new_controller;
661 return status; 656 return status;
662} 657}
663 658
659static void
660cleanup_slots(void)
661{
662 struct slot *slot;
663 struct slot *tmp;
664
665 /*
666 * Unregister all of our slots with the pci_hotplug subsystem,
667 * and free up all memory that we had allocated.
668 */
669 down_write(&list_rwsem);
670 if (!slots)
671 goto cleanup_null;
672 list_for_each_entry_safe(slot, tmp, &slot_list, slot_list) {
673 list_del(&slot->slot_list);
674 pci_hp_deregister(slot->hotplug_slot);
675 }
676cleanup_null:
677 up_write(&list_rwsem);
678 return;
679}
680
664int 681int
665cpci_hp_unregister_controller(struct cpci_hp_controller *old_controller) 682cpci_hp_unregister_controller(struct cpci_hp_controller *old_controller)
666{ 683{
667 int status = 0; 684 int status = 0;
668 685
669 if(controller) { 686 if (controller) {
670 if(!thread_finished) { 687 if (!thread_finished)
671 cpci_stop_thread(); 688 cpci_stop_thread();
672 } 689 if (controller->irq)
673 if(controller->irq) {
674 free_irq(controller->irq, controller->dev_id); 690 free_irq(controller->irq, controller->dev_id);
675 }
676 controller = NULL; 691 controller = NULL;
677 } else { 692 cleanup_slots();
693 } else
678 status = -ENODEV; 694 status = -ENODEV;
679 }
680 return status; 695 return status;
681} 696}
682 697
@@ -687,32 +702,28 @@ cpci_hp_start(void)
687 int status; 702 int status;
688 703
689 dbg("%s - enter", __FUNCTION__); 704 dbg("%s - enter", __FUNCTION__);
690 if(!controller) { 705 if (!controller)
691 return -ENODEV; 706 return -ENODEV;
692 }
693 707
694 spin_lock(&list_lock); 708 down_read(&list_rwsem);
695 if(!slots) { 709 if (list_empty(&slot_list)) {
696 spin_unlock(&list_lock); 710 up_read(&list_rwsem);
697 return -ENODEV; 711 return -ENODEV;
698 } 712 }
699 spin_unlock(&list_lock); 713 up_read(&list_rwsem);
700 714
701 if(first) { 715 status = init_slots(first);
702 status = init_slots(); 716 if (first)
703 if(status) {
704 return status;
705 }
706 first = 0; 717 first = 0;
707 } 718 if (status)
719 return status;
708 720
709 status = cpci_start_thread(); 721 status = cpci_start_thread();
710 if(status) { 722 if (status)
711 return status; 723 return status;
712 }
713 dbg("%s - thread started", __FUNCTION__); 724 dbg("%s - thread started", __FUNCTION__);
714 725
715 if(controller->irq) { 726 if (controller->irq) {
716 /* Start enum interrupt processing */ 727 /* Start enum interrupt processing */
717 dbg("%s - enabling irq", __FUNCTION__); 728 dbg("%s - enabling irq", __FUNCTION__);
718 controller->ops->enable_irq(); 729 controller->ops->enable_irq();
@@ -724,11 +735,9 @@ cpci_hp_start(void)
724int 735int
725cpci_hp_stop(void) 736cpci_hp_stop(void)
726{ 737{
727 if(!controller) { 738 if (!controller)
728 return -ENODEV; 739 return -ENODEV;
729 } 740 if (controller->irq) {
730
731 if(controller->irq) {
732 /* Stop enum interrupt processing */ 741 /* Stop enum interrupt processing */
733 dbg("%s - disabling irq", __FUNCTION__); 742 dbg("%s - disabling irq", __FUNCTION__);
734 controller->ops->disable_irq(); 743 controller->ops->disable_irq();
@@ -737,41 +746,10 @@ cpci_hp_stop(void)
737 return 0; 746 return 0;
738} 747}
739 748
740static void __exit
741cleanup_slots(void)
742{
743 struct list_head *tmp;
744 struct slot *slot;
745
746 /*
747 * Unregister all of our slots with the pci_hotplug subsystem,
748 * and free up all memory that we had allocated.
749 */
750 spin_lock(&list_lock);
751 if(!slots) {
752 goto null_cleanup;
753 }
754 list_for_each(tmp, &slot_list) {
755 slot = list_entry(tmp, struct slot, slot_list);
756 list_del(&slot->slot_list);
757 pci_hp_deregister(slot->hotplug_slot);
758 kfree(slot->hotplug_slot->info);
759 kfree(slot->hotplug_slot->name);
760 kfree(slot->hotplug_slot);
761 kfree(slot);
762 }
763 null_cleanup:
764 spin_unlock(&list_lock);
765 return;
766}
767
768int __init 749int __init
769cpci_hotplug_init(int debug) 750cpci_hotplug_init(int debug)
770{ 751{
771 spin_lock_init(&list_lock);
772 cpci_debug = debug; 752 cpci_debug = debug;
773
774 info(DRIVER_DESC " version: " DRIVER_VERSION);
775 return 0; 753 return 0;
776} 754}
777 755
@@ -781,7 +759,8 @@ cpci_hotplug_exit(void)
781 /* 759 /*
782 * Clean everything up. 760 * Clean everything up.
783 */ 761 */
784 cleanup_slots(); 762 cpci_hp_stop();
763 cpci_hp_unregister_controller(controller);
785} 764}
786 765
787EXPORT_SYMBOL_GPL(cpci_hp_register_controller); 766EXPORT_SYMBOL_GPL(cpci_hp_register_controller);
diff --git a/drivers/pci/hotplug/cpci_hotplug_pci.c b/drivers/pci/hotplug/cpci_hotplug_pci.c
index 2e969616f298..225b5e551dd6 100644
--- a/drivers/pci/hotplug/cpci_hotplug_pci.c
+++ b/drivers/pci/hotplug/cpci_hotplug_pci.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * CompactPCI Hot Plug Driver PCI functions 2 * CompactPCI Hot Plug Driver PCI functions
3 * 3 *
4 * Copyright (C) 2002 by SOMA Networks, Inc. 4 * Copyright (C) 2002,2005 by SOMA Networks, Inc.
5 * 5 *
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
@@ -32,20 +32,16 @@
32#include "pci_hotplug.h" 32#include "pci_hotplug.h"
33#include "cpci_hotplug.h" 33#include "cpci_hotplug.h"
34 34
35#if !defined(MODULE)
36#define MY_NAME "cpci_hotplug" 35#define MY_NAME "cpci_hotplug"
37#else
38#define MY_NAME THIS_MODULE->name
39#endif
40 36
41extern int cpci_debug; 37extern int cpci_debug;
42 38
43#define dbg(format, arg...) \ 39#define dbg(format, arg...) \
44 do { \ 40 do { \
45 if(cpci_debug) \ 41 if (cpci_debug) \
46 printk (KERN_DEBUG "%s: " format "\n", \ 42 printk (KERN_DEBUG "%s: " format "\n", \
47 MY_NAME , ## arg); \ 43 MY_NAME , ## arg); \
48 } while(0) 44 } while (0)
49#define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg) 45#define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg)
50#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg) 46#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg)
51#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) 47#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg)
@@ -61,16 +57,15 @@ u8 cpci_get_attention_status(struct slot* slot)
61 hs_cap = pci_bus_find_capability(slot->bus, 57 hs_cap = pci_bus_find_capability(slot->bus,
62 slot->devfn, 58 slot->devfn,
63 PCI_CAP_ID_CHSWP); 59 PCI_CAP_ID_CHSWP);
64 if(!hs_cap) { 60 if (!hs_cap)
65 return 0; 61 return 0;
66 }
67 62
68 if(pci_bus_read_config_word(slot->bus, 63 if (pci_bus_read_config_word(slot->bus,
69 slot->devfn, 64 slot->devfn,
70 hs_cap + 2, 65 hs_cap + 2,
71 &hs_csr)) { 66 &hs_csr))
72 return 0; 67 return 0;
73 } 68
74 return hs_csr & 0x0008 ? 1 : 0; 69 return hs_csr & 0x0008 ? 1 : 0;
75} 70}
76 71
@@ -82,27 +77,22 @@ int cpci_set_attention_status(struct slot* slot, int status)
82 hs_cap = pci_bus_find_capability(slot->bus, 77 hs_cap = pci_bus_find_capability(slot->bus,
83 slot->devfn, 78 slot->devfn,
84 PCI_CAP_ID_CHSWP); 79 PCI_CAP_ID_CHSWP);
85 if(!hs_cap) { 80 if (!hs_cap)
86 return 0; 81 return 0;
87 } 82 if (pci_bus_read_config_word(slot->bus,
88
89 if(pci_bus_read_config_word(slot->bus,
90 slot->devfn, 83 slot->devfn,
91 hs_cap + 2, 84 hs_cap + 2,
92 &hs_csr)) { 85 &hs_csr))
93 return 0; 86 return 0;
94 } 87 if (status)
95 if(status) {
96 hs_csr |= HS_CSR_LOO; 88 hs_csr |= HS_CSR_LOO;
97 } else { 89 else
98 hs_csr &= ~HS_CSR_LOO; 90 hs_csr &= ~HS_CSR_LOO;
99 } 91 if (pci_bus_write_config_word(slot->bus,
100 if(pci_bus_write_config_word(slot->bus,
101 slot->devfn, 92 slot->devfn,
102 hs_cap + 2, 93 hs_cap + 2,
103 hs_csr)) { 94 hs_csr))
104 return 0; 95 return 0;
105 }
106 return 1; 96 return 1;
107} 97}
108 98
@@ -114,51 +104,16 @@ u16 cpci_get_hs_csr(struct slot* slot)
114 hs_cap = pci_bus_find_capability(slot->bus, 104 hs_cap = pci_bus_find_capability(slot->bus,
115 slot->devfn, 105 slot->devfn,
116 PCI_CAP_ID_CHSWP); 106 PCI_CAP_ID_CHSWP);
117 if(!hs_cap) { 107 if (!hs_cap)
118 return 0xFFFF; 108 return 0xFFFF;
119 } 109 if (pci_bus_read_config_word(slot->bus,
120
121 if(pci_bus_read_config_word(slot->bus,
122 slot->devfn, 110 slot->devfn,
123 hs_cap + 2, 111 hs_cap + 2,
124 &hs_csr)) { 112 &hs_csr))
125 return 0xFFFF; 113 return 0xFFFF;
126 }
127 return hs_csr; 114 return hs_csr;
128} 115}
129 116
130#if 0
131u16 cpci_set_hs_csr(struct slot* slot, u16 hs_csr)
132{
133 int hs_cap;
134 u16 new_hs_csr;
135
136 hs_cap = pci_bus_find_capability(slot->bus,
137 slot->devfn,
138 PCI_CAP_ID_CHSWP);
139 if(!hs_cap) {
140 return 0xFFFF;
141 }
142
143 /* Write out the new value */
144 if(pci_bus_write_config_word(slot->bus,
145 slot->devfn,
146 hs_cap + 2,
147 hs_csr)) {
148 return 0xFFFF;
149 }
150
151 /* Read back what we just wrote out */
152 if(pci_bus_read_config_word(slot->bus,
153 slot->devfn,
154 hs_cap + 2,
155 &new_hs_csr)) {
156 return 0xFFFF;
157 }
158 return new_hs_csr;
159}
160#endif
161
162int cpci_check_and_clear_ins(struct slot* slot) 117int cpci_check_and_clear_ins(struct slot* slot)
163{ 118{
164 int hs_cap; 119 int hs_cap;
@@ -168,24 +123,22 @@ int cpci_check_and_clear_ins(struct slot* slot)
168 hs_cap = pci_bus_find_capability(slot->bus, 123 hs_cap = pci_bus_find_capability(slot->bus,
169 slot->devfn, 124 slot->devfn,
170 PCI_CAP_ID_CHSWP); 125 PCI_CAP_ID_CHSWP);
171 if(!hs_cap) { 126 if (!hs_cap)
172 return 0; 127 return 0;
173 } 128 if (pci_bus_read_config_word(slot->bus,
174 if(pci_bus_read_config_word(slot->bus,
175 slot->devfn, 129 slot->devfn,
176 hs_cap + 2, 130 hs_cap + 2,
177 &hs_csr)) { 131 &hs_csr))
178 return 0; 132 return 0;
179 } 133 if (hs_csr & HS_CSR_INS) {
180 if(hs_csr & HS_CSR_INS) {
181 /* Clear INS (by setting it) */ 134 /* Clear INS (by setting it) */
182 if(pci_bus_write_config_word(slot->bus, 135 if (pci_bus_write_config_word(slot->bus,
183 slot->devfn, 136 slot->devfn,
184 hs_cap + 2, 137 hs_cap + 2,
185 hs_csr)) { 138 hs_csr))
186 ins = 0; 139 ins = 0;
187 } 140 else
188 ins = 1; 141 ins = 1;
189 } 142 }
190 return ins; 143 return ins;
191} 144}
@@ -199,18 +152,15 @@ int cpci_check_ext(struct slot* slot)
199 hs_cap = pci_bus_find_capability(slot->bus, 152 hs_cap = pci_bus_find_capability(slot->bus,
200 slot->devfn, 153 slot->devfn,
201 PCI_CAP_ID_CHSWP); 154 PCI_CAP_ID_CHSWP);
202 if(!hs_cap) { 155 if (!hs_cap)
203 return 0; 156 return 0;
204 } 157 if (pci_bus_read_config_word(slot->bus,
205 if(pci_bus_read_config_word(slot->bus,
206 slot->devfn, 158 slot->devfn,
207 hs_cap + 2, 159 hs_cap + 2,
208 &hs_csr)) { 160 &hs_csr))
209 return 0; 161 return 0;
210 } 162 if (hs_csr & HS_CSR_EXT)
211 if(hs_csr & HS_CSR_EXT) {
212 ext = 1; 163 ext = 1;
213 }
214 return ext; 164 return ext;
215} 165}
216 166
@@ -222,23 +172,20 @@ int cpci_clear_ext(struct slot* slot)
222 hs_cap = pci_bus_find_capability(slot->bus, 172 hs_cap = pci_bus_find_capability(slot->bus,
223 slot->devfn, 173 slot->devfn,
224 PCI_CAP_ID_CHSWP); 174 PCI_CAP_ID_CHSWP);
225 if(!hs_cap) { 175 if (!hs_cap)
226 return -ENODEV; 176 return -ENODEV;
227 } 177 if (pci_bus_read_config_word(slot->bus,
228 if(pci_bus_read_config_word(slot->bus,
229 slot->devfn, 178 slot->devfn,
230 hs_cap + 2, 179 hs_cap + 2,
231 &hs_csr)) { 180 &hs_csr))
232 return -ENODEV; 181 return -ENODEV;
233 } 182 if (hs_csr & HS_CSR_EXT) {
234 if(hs_csr & HS_CSR_EXT) {
235 /* Clear EXT (by setting it) */ 183 /* Clear EXT (by setting it) */
236 if(pci_bus_write_config_word(slot->bus, 184 if (pci_bus_write_config_word(slot->bus,
237 slot->devfn, 185 slot->devfn,
238 hs_cap + 2, 186 hs_cap + 2,
239 hs_csr)) { 187 hs_csr))
240 return -ENODEV; 188 return -ENODEV;
241 }
242 } 189 }
243 return 0; 190 return 0;
244} 191}
@@ -251,19 +198,16 @@ int cpci_led_on(struct slot* slot)
251 hs_cap = pci_bus_find_capability(slot->bus, 198 hs_cap = pci_bus_find_capability(slot->bus,
252 slot->devfn, 199 slot->devfn,
253 PCI_CAP_ID_CHSWP); 200 PCI_CAP_ID_CHSWP);
254 if(!hs_cap) { 201 if (!hs_cap)
255 return -ENODEV; 202 return -ENODEV;
256 } 203 if (pci_bus_read_config_word(slot->bus,
257 if(pci_bus_read_config_word(slot->bus,
258 slot->devfn, 204 slot->devfn,
259 hs_cap + 2, 205 hs_cap + 2,
260 &hs_csr)) { 206 &hs_csr))
261 return -ENODEV; 207 return -ENODEV;
262 } 208 if ((hs_csr & HS_CSR_LOO) != HS_CSR_LOO) {
263 if((hs_csr & HS_CSR_LOO) != HS_CSR_LOO) {
264 /* Set LOO */
265 hs_csr |= HS_CSR_LOO; 209 hs_csr |= HS_CSR_LOO;
266 if(pci_bus_write_config_word(slot->bus, 210 if (pci_bus_write_config_word(slot->bus,
267 slot->devfn, 211 slot->devfn,
268 hs_cap + 2, 212 hs_cap + 2,
269 hs_csr)) { 213 hs_csr)) {
@@ -283,19 +227,16 @@ int cpci_led_off(struct slot* slot)
283 hs_cap = pci_bus_find_capability(slot->bus, 227 hs_cap = pci_bus_find_capability(slot->bus,
284 slot->devfn, 228 slot->devfn,
285 PCI_CAP_ID_CHSWP); 229 PCI_CAP_ID_CHSWP);
286 if(!hs_cap) { 230 if (!hs_cap)
287 return -ENODEV; 231 return -ENODEV;
288 } 232 if (pci_bus_read_config_word(slot->bus,
289 if(pci_bus_read_config_word(slot->bus,
290 slot->devfn, 233 slot->devfn,
291 hs_cap + 2, 234 hs_cap + 2,
292 &hs_csr)) { 235 &hs_csr))
293 return -ENODEV; 236 return -ENODEV;
294 } 237 if (hs_csr & HS_CSR_LOO) {
295 if(hs_csr & HS_CSR_LOO) {
296 /* Clear LOO */
297 hs_csr &= ~HS_CSR_LOO; 238 hs_csr &= ~HS_CSR_LOO;
298 if(pci_bus_write_config_word(slot->bus, 239 if (pci_bus_write_config_word(slot->bus,
299 slot->devfn, 240 slot->devfn,
300 hs_cap + 2, 241 hs_cap + 2,
301 hs_csr)) { 242 hs_csr)) {
@@ -312,268 +253,21 @@ int cpci_led_off(struct slot* slot)
312 * Device configuration functions 253 * Device configuration functions
313 */ 254 */
314 255
315static int cpci_configure_dev(struct pci_bus *bus, struct pci_dev *dev)
316{
317 u8 irq_pin;
318 int r;
319
320 dbg("%s - enter", __FUNCTION__);
321
322 /* NOTE: device already setup from prior scan */
323
324 /* FIXME: How would we know if we need to enable the expansion ROM? */
325 pci_write_config_word(dev, PCI_ROM_ADDRESS, 0x00L);
326
327 /* Assign resources */
328 dbg("assigning resources for %02x:%02x.%x",
329 dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
330 for (r = 0; r < 6; r++) {
331 struct resource *res = dev->resource + r;
332 if(res->flags)
333 pci_assign_resource(dev, r);
334 }
335 dbg("finished assigning resources for %02x:%02x.%x",
336 dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
337
338 /* Does this function have an interrupt at all? */
339 dbg("checking for function interrupt");
340 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &irq_pin);
341 if(irq_pin) {
342 dbg("function uses interrupt pin %d", irq_pin);
343 }
344
345 /*
346 * Need to explicitly set irq field to 0 so that it'll get assigned
347 * by the pcibios platform dependent code called by pci_enable_device.
348 */
349 dev->irq = 0;
350
351 dbg("enabling device");
352 pci_enable_device(dev); /* XXX check return */
353 dbg("now dev->irq = %d", dev->irq);
354 if(irq_pin && dev->irq) {
355 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
356 }
357
358 /* Can't use pci_insert_device at the moment, do it manually for now */
359 pci_proc_attach_device(dev);
360 dbg("notifying drivers");
361 //pci_announce_device_to_drivers(dev);
362 dbg("%s - exit", __FUNCTION__);
363 return 0;
364}
365
366static int cpci_configure_bridge(struct pci_bus* bus, struct pci_dev* dev)
367{
368 int rc;
369 struct pci_bus* child;
370 struct resource* r;
371 u8 max, n;
372 u16 command;
373
374 dbg("%s - enter", __FUNCTION__);
375
376 /* Do basic bridge initialization */
377 rc = pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x40);
378 if(rc) {
379 printk(KERN_ERR "%s - write of PCI_LATENCY_TIMER failed\n", __FUNCTION__);
380 }
381 rc = pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER, 0x40);
382 if(rc) {
383 printk(KERN_ERR "%s - write of PCI_SEC_LATENCY_TIMER failed\n", __FUNCTION__);
384 }
385 rc = pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, L1_CACHE_BYTES / 4);
386 if(rc) {
387 printk(KERN_ERR "%s - write of PCI_CACHE_LINE_SIZE failed\n", __FUNCTION__);
388 }
389
390 /*
391 * Set parent bridge's subordinate field so that configuration space
392 * access will work in pci_scan_bridge and friends.
393 */
394 max = pci_max_busnr();
395 bus->subordinate = max + 1;
396 pci_write_config_byte(bus->self, PCI_SUBORDINATE_BUS, max + 1);
397
398 /* Scan behind bridge */
399 n = pci_scan_bridge(bus, dev, max, 2);
400 child = pci_find_bus(0, max + 1);
401 if (!child)
402 return -ENODEV;
403 pci_proc_attach_bus(child);
404
405 /*
406 * Update parent bridge's subordinate field if there were more bridges
407 * behind the bridge that was scanned.
408 */
409 if(n > max) {
410 bus->subordinate = n;
411 pci_write_config_byte(bus->self, PCI_SUBORDINATE_BUS, n);
412 }
413
414 /*
415 * Update the bridge resources of the bridge to accommodate devices
416 * behind it.
417 */
418 pci_bus_size_bridges(child);
419 pci_bus_assign_resources(child);
420
421 /* Enable resource mapping via command register */
422 command = PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE | PCI_COMMAND_PARITY | PCI_COMMAND_SERR;
423 r = child->resource[0];
424 if(r && r->start) {
425 command |= PCI_COMMAND_IO;
426 }
427 r = child->resource[1];
428 if(r && r->start) {
429 command |= PCI_COMMAND_MEMORY;
430 }
431 r = child->resource[2];
432 if(r && r->start) {
433 command |= PCI_COMMAND_MEMORY;
434 }
435 rc = pci_write_config_word(dev, PCI_COMMAND, command);
436 if(rc) {
437 err("Error setting command register");
438 return rc;
439 }
440
441 /* Set bridge control register */
442 command = PCI_BRIDGE_CTL_PARITY | PCI_BRIDGE_CTL_SERR | PCI_BRIDGE_CTL_NO_ISA;
443 rc = pci_write_config_word(dev, PCI_BRIDGE_CONTROL, command);
444 if(rc) {
445 err("Error setting bridge control register");
446 return rc;
447 }
448 dbg("%s - exit", __FUNCTION__);
449 return 0;
450}
451
452static int configure_visit_pci_dev(struct pci_dev_wrapped *wrapped_dev,
453 struct pci_bus_wrapped *wrapped_bus)
454{
455 int rc;
456 struct pci_dev *dev = wrapped_dev->dev;
457 struct pci_bus *bus = wrapped_bus->bus;
458 struct slot* slot;
459
460 dbg("%s - enter", __FUNCTION__);
461
462 /*
463 * We need to fix up the hotplug representation with the Linux
464 * representation.
465 */
466 if(wrapped_dev->data) {
467 slot = (struct slot*) wrapped_dev->data;
468 slot->dev = dev;
469 }
470
471 /* If it's a bridge, scan behind it for devices */
472 if(dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
473 rc = cpci_configure_bridge(bus, dev);
474 if(rc)
475 return rc;
476 }
477
478 /* Actually configure device */
479 if(dev) {
480 rc = cpci_configure_dev(bus, dev);
481 if(rc)
482 return rc;
483 }
484 dbg("%s - exit", __FUNCTION__);
485 return 0;
486}
487
488static int unconfigure_visit_pci_dev_phase2(struct pci_dev_wrapped *wrapped_dev,
489 struct pci_bus_wrapped *wrapped_bus)
490{
491 struct pci_dev *dev = wrapped_dev->dev;
492 struct slot* slot;
493
494 dbg("%s - enter", __FUNCTION__);
495 if(!dev)
496 return -ENODEV;
497
498 /* Remove the Linux representation */
499 if(pci_remove_device_safe(dev)) {
500 err("Could not remove device\n");
501 return -1;
502 }
503
504 /*
505 * Now remove the hotplug representation.
506 */
507 if(wrapped_dev->data) {
508 slot = (struct slot*) wrapped_dev->data;
509 slot->dev = NULL;
510 } else {
511 dbg("No hotplug representation for %02x:%02x.%x",
512 dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
513 }
514 dbg("%s - exit", __FUNCTION__);
515 return 0;
516}
517
518static int unconfigure_visit_pci_bus_phase2(struct pci_bus_wrapped *wrapped_bus,
519 struct pci_dev_wrapped *wrapped_dev)
520{
521 struct pci_bus *bus = wrapped_bus->bus;
522 struct pci_bus *parent = bus->self->bus;
523
524 dbg("%s - enter", __FUNCTION__);
525
526 /* The cleanup code for proc entries regarding buses should be in the kernel... */
527 if(bus->procdir)
528 dbg("detach_pci_bus %s", bus->procdir->name);
529 pci_proc_detach_bus(bus);
530
531 /* The cleanup code should live in the kernel... */
532 bus->self->subordinate = NULL;
533
534 /* unlink from parent bus */
535 list_del(&bus->node);
536
537 /* Now, remove */
538 if(bus)
539 kfree(bus);
540
541 /* Update parent's subordinate field */
542 if(parent) {
543 u8 n = pci_bus_max_busnr(parent);
544 if(n < parent->subordinate) {
545 parent->subordinate = n;
546 pci_write_config_byte(parent->self, PCI_SUBORDINATE_BUS, n);
547 }
548 }
549 dbg("%s - exit", __FUNCTION__);
550 return 0;
551}
552
553static struct pci_visit configure_functions = {
554 .visit_pci_dev = configure_visit_pci_dev,
555};
556
557static struct pci_visit unconfigure_functions_phase2 = {
558 .post_visit_pci_bus = unconfigure_visit_pci_bus_phase2,
559 .post_visit_pci_dev = unconfigure_visit_pci_dev_phase2
560};
561
562
563int cpci_configure_slot(struct slot* slot) 256int cpci_configure_slot(struct slot* slot)
564{ 257{
565 int rc = 0; 258 unsigned char busnr;
259 struct pci_bus *child;
566 260
567 dbg("%s - enter", __FUNCTION__); 261 dbg("%s - enter", __FUNCTION__);
568 262
569 if(slot->dev == NULL) { 263 if (slot->dev == NULL) {
570 dbg("pci_dev null, finding %02x:%02x:%x", 264 dbg("pci_dev null, finding %02x:%02x:%x",
571 slot->bus->number, PCI_SLOT(slot->devfn), PCI_FUNC(slot->devfn)); 265 slot->bus->number, PCI_SLOT(slot->devfn), PCI_FUNC(slot->devfn));
572 slot->dev = pci_find_slot(slot->bus->number, slot->devfn); 266 slot->dev = pci_get_slot(slot->bus, slot->devfn);
573 } 267 }
574 268
575 /* Still NULL? Well then scan for it! */ 269 /* Still NULL? Well then scan for it! */
576 if(slot->dev == NULL) { 270 if (slot->dev == NULL) {
577 int n; 271 int n;
578 dbg("pci_dev still null"); 272 dbg("pci_dev still null");
579 273
@@ -583,79 +277,50 @@ int cpci_configure_slot(struct slot* slot)
583 */ 277 */
584 n = pci_scan_slot(slot->bus, slot->devfn); 278 n = pci_scan_slot(slot->bus, slot->devfn);
585 dbg("%s: pci_scan_slot returned %d", __FUNCTION__, n); 279 dbg("%s: pci_scan_slot returned %d", __FUNCTION__, n);
586 if(n > 0) 280 if (n > 0)
587 pci_bus_add_devices(slot->bus); 281 pci_bus_add_devices(slot->bus);
588 slot->dev = pci_find_slot(slot->bus->number, slot->devfn); 282 slot->dev = pci_get_slot(slot->bus, slot->devfn);
589 if(slot->dev == NULL) { 283 if (slot->dev == NULL) {
590 err("Could not find PCI device for slot %02x", slot->number); 284 err("Could not find PCI device for slot %02x", slot->number);
591 return 0; 285 return 1;
592 } 286 }
593 } 287 }
594 dbg("slot->dev = %p", slot->dev); 288
595 if(slot->dev) { 289 if (slot->dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
596 struct pci_dev *dev; 290 pci_read_config_byte(slot->dev, PCI_SECONDARY_BUS, &busnr);
597 struct pci_dev_wrapped wrapped_dev; 291 child = pci_add_new_bus(slot->dev->bus, slot->dev, busnr);
598 struct pci_bus_wrapped wrapped_bus; 292 pci_do_scan_bus(child);
599 int i; 293 pci_bus_size_bridges(child);
600
601 memset(&wrapped_dev, 0, sizeof (struct pci_dev_wrapped));
602 memset(&wrapped_bus, 0, sizeof (struct pci_bus_wrapped));
603
604 for (i = 0; i < 8; i++) {
605 dev = pci_find_slot(slot->bus->number,
606 PCI_DEVFN(PCI_SLOT(slot->dev->devfn), i));
607 if(!dev)
608 continue;
609 wrapped_dev.dev = dev;
610 wrapped_bus.bus = slot->dev->bus;
611 if(i)
612 wrapped_dev.data = NULL;
613 else
614 wrapped_dev.data = (void*) slot;
615 rc = pci_visit_dev(&configure_functions, &wrapped_dev, &wrapped_bus);
616 }
617 } 294 }
618 295
619 dbg("%s - exit, rc = %d", __FUNCTION__, rc); 296 pci_bus_assign_resources(slot->dev->bus);
620 return rc; 297
298 dbg("%s - exit", __FUNCTION__);
299 return 0;
621} 300}
622 301
623int cpci_unconfigure_slot(struct slot* slot) 302int cpci_unconfigure_slot(struct slot* slot)
624{ 303{
625 int rc = 0;
626 int i; 304 int i;
627 struct pci_dev_wrapped wrapped_dev;
628 struct pci_bus_wrapped wrapped_bus;
629 struct pci_dev *dev; 305 struct pci_dev *dev;
630 306
631 dbg("%s - enter", __FUNCTION__); 307 dbg("%s - enter", __FUNCTION__);
632 308 if (!slot->dev) {
633 if(!slot->dev) {
634 err("No device for slot %02x\n", slot->number); 309 err("No device for slot %02x\n", slot->number);
635 return -ENODEV; 310 return -ENODEV;
636 } 311 }
637 312
638 memset(&wrapped_dev, 0, sizeof (struct pci_dev_wrapped));
639 memset(&wrapped_bus, 0, sizeof (struct pci_bus_wrapped));
640
641 for (i = 0; i < 8; i++) { 313 for (i = 0; i < 8; i++) {
642 dev = pci_find_slot(slot->bus->number, 314 dev = pci_get_slot(slot->bus,
643 PCI_DEVFN(PCI_SLOT(slot->devfn), i)); 315 PCI_DEVFN(PCI_SLOT(slot->devfn), i));
644 if(dev) { 316 if (dev) {
645 wrapped_dev.dev = dev; 317 pci_remove_bus_device(dev);
646 wrapped_bus.bus = dev->bus; 318 pci_dev_put(dev);
647 if(i)
648 wrapped_dev.data = NULL;
649 else
650 wrapped_dev.data = (void*) slot;
651 dbg("%s - unconfigure phase 2", __FUNCTION__);
652 rc = pci_visit_dev(&unconfigure_functions_phase2,
653 &wrapped_dev,
654 &wrapped_bus);
655 if(rc)
656 break;
657 } 319 }
658 } 320 }
659 dbg("%s - exit, rc = %d", __FUNCTION__, rc); 321 pci_dev_put(slot->dev);
660 return rc; 322 slot->dev = NULL;
323
324 dbg("%s - exit", __FUNCTION__);
325 return 0;
661} 326}
diff --git a/drivers/pci/hotplug/ibmphp.h b/drivers/pci/hotplug/ibmphp.h
index 5bc039da647f..c22e0284d7b1 100644
--- a/drivers/pci/hotplug/ibmphp.h
+++ b/drivers/pci/hotplug/ibmphp.h
@@ -196,7 +196,7 @@ struct ebda_hpc_bus {
196 196
197 197
198/******************************************************************** 198/********************************************************************
199* THREE TYPE OF HOT PLUG CONTROLER * 199* THREE TYPE OF HOT PLUG CONTROLLER *
200********************************************************************/ 200********************************************************************/
201 201
202struct isa_ctlr_access { 202struct isa_ctlr_access {
diff --git a/drivers/pci/hotplug/ibmphp_hpc.c b/drivers/pci/hotplug/ibmphp_hpc.c
index 6894b548c8ca..1a3eb8d3d4cb 100644
--- a/drivers/pci/hotplug/ibmphp_hpc.c
+++ b/drivers/pci/hotplug/ibmphp_hpc.c
@@ -64,7 +64,7 @@ static int to_debug = FALSE;
64#define WPG_I2C_OR 0x2000 // I2C OR operation 64#define WPG_I2C_OR 0x2000 // I2C OR operation
65 65
66//---------------------------------------------------------------------------- 66//----------------------------------------------------------------------------
67// Command set for I2C Master Operation Setup Regisetr 67// Command set for I2C Master Operation Setup Register
68//---------------------------------------------------------------------------- 68//----------------------------------------------------------------------------
69#define WPG_READATADDR_MASK 0x00010000 // read,bytes,I2C shifted,index 69#define WPG_READATADDR_MASK 0x00010000 // read,bytes,I2C shifted,index
70#define WPG_WRITEATADDR_MASK 0x40010000 // write,bytes,I2C shifted,index 70#define WPG_WRITEATADDR_MASK 0x40010000 // write,bytes,I2C shifted,index
@@ -835,7 +835,7 @@ static void poll_hpc (void)
835 if (ibmphp_shutdown) 835 if (ibmphp_shutdown)
836 break; 836 break;
837 837
838 /* try to get the lock to do some kind of harware access */ 838 /* try to get the lock to do some kind of hardware access */
839 down (&semOperations); 839 down (&semOperations);
840 840
841 switch (poll_state) { 841 switch (poll_state) {
@@ -906,7 +906,7 @@ static void poll_hpc (void)
906 poll_state = POLL_LATCH_REGISTER; 906 poll_state = POLL_LATCH_REGISTER;
907 break; 907 break;
908 } 908 }
909 /* give up the harware semaphore */ 909 /* give up the hardware semaphore */
910 up (&semOperations); 910 up (&semOperations);
911 /* sleep for a short time just for good measure */ 911 /* sleep for a short time just for good measure */
912 msleep(100); 912 msleep(100);
diff --git a/drivers/pci/hotplug/ibmphp_pci.c b/drivers/pci/hotplug/ibmphp_pci.c
index 2335fac65fb4..8122fe734aa7 100644
--- a/drivers/pci/hotplug/ibmphp_pci.c
+++ b/drivers/pci/hotplug/ibmphp_pci.c
@@ -1308,10 +1308,10 @@ static int unconfigure_boot_device (u8 busno, u8 device, u8 function)
1308 /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */ 1308 /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */
1309 } else { 1309 } else {
1310 /* This is Memory */ 1310 /* This is Memory */
1311 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1312 if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) { 1311 if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) {
1313 /* pfmem */ 1312 /* pfmem */
1314 debug ("start address of pfmem is %x\n", start_address); 1313 debug ("start address of pfmem is %x\n", start_address);
1314 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1315 1315
1316 if (ibmphp_find_resource (bus, start_address, &pfmem, PFMEM) < 0) { 1316 if (ibmphp_find_resource (bus, start_address, &pfmem, PFMEM) < 0) {
1317 err ("cannot find corresponding PFMEM resource to remove\n"); 1317 err ("cannot find corresponding PFMEM resource to remove\n");
@@ -1325,6 +1325,8 @@ static int unconfigure_boot_device (u8 busno, u8 device, u8 function)
1325 } else { 1325 } else {
1326 /* regular memory */ 1326 /* regular memory */
1327 debug ("start address of mem is %x\n", start_address); 1327 debug ("start address of mem is %x\n", start_address);
1328 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1329
1328 if (ibmphp_find_resource (bus, start_address, &mem, MEM) < 0) { 1330 if (ibmphp_find_resource (bus, start_address, &mem, MEM) < 0) {
1329 err ("cannot find corresponding MEM resource to remove\n"); 1331 err ("cannot find corresponding MEM resource to remove\n");
1330 return -EIO; 1332 return -EIO;
@@ -1422,9 +1424,9 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function)
1422 /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */ 1424 /* ????????? DO WE NEED TO WRITE ANYTHING INTO THE PCI CONFIG SPACE BACK ?????????? */
1423 } else { 1425 } else {
1424 /* This is Memory */ 1426 /* This is Memory */
1425 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1426 if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) { 1427 if (start_address & PCI_BASE_ADDRESS_MEM_PREFETCH) {
1427 /* pfmem */ 1428 /* pfmem */
1429 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1428 if (ibmphp_find_resource (bus, start_address, &pfmem, PFMEM) < 0) { 1430 if (ibmphp_find_resource (bus, start_address, &pfmem, PFMEM) < 0) {
1429 err ("cannot find corresponding PFMEM resource to remove\n"); 1431 err ("cannot find corresponding PFMEM resource to remove\n");
1430 return -EINVAL; 1432 return -EINVAL;
@@ -1436,6 +1438,7 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function)
1436 } 1438 }
1437 } else { 1439 } else {
1438 /* regular memory */ 1440 /* regular memory */
1441 start_address &= PCI_BASE_ADDRESS_MEM_MASK;
1439 if (ibmphp_find_resource (bus, start_address, &mem, MEM) < 0) { 1442 if (ibmphp_find_resource (bus, start_address, &mem, MEM) < 0) {
1440 err ("cannot find corresponding MEM resource to remove\n"); 1443 err ("cannot find corresponding MEM resource to remove\n");
1441 return -EINVAL; 1444 return -EINVAL;
diff --git a/drivers/pci/hotplug/pci_hotplug.h b/drivers/pci/hotplug/pci_hotplug.h
index 57ace325168d..88d44f7fef29 100644
--- a/drivers/pci/hotplug/pci_hotplug.h
+++ b/drivers/pci/hotplug/pci_hotplug.h
@@ -150,7 +150,7 @@ struct hotplug_slot_info {
150 * @name: the name of the slot being registered. This string must 150 * @name: the name of the slot being registered. This string must
151 * be unique amoung slots registered on this system. 151 * be unique amoung slots registered on this system.
152 * @ops: pointer to the &struct hotplug_slot_ops to be used for this slot 152 * @ops: pointer to the &struct hotplug_slot_ops to be used for this slot
153 * @info: pointer to the &struct hotplug_slot_info for the inital values for 153 * @info: pointer to the &struct hotplug_slot_info for the initial values for
154 * this slot. 154 * this slot.
155 * @release: called during pci_hp_deregister to free memory allocated in a 155 * @release: called during pci_hp_deregister to free memory allocated in a
156 * hotplug_slot structure. 156 * hotplug_slot structure.
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index f313121d5141..46b294a12418 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -130,6 +130,7 @@ struct controller {
130 u8 slot_bus; /* Bus where the slots handled by this controller sit */ 130 u8 slot_bus; /* Bus where the slots handled by this controller sit */
131 u8 ctrlcap; 131 u8 ctrlcap;
132 u16 vendor_id; 132 u16 vendor_id;
133 u8 cap_base;
133}; 134};
134 135
135struct irq_mapping { 136struct irq_mapping {
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 72baf749e65e..df4915dbc321 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -90,6 +90,22 @@ static struct hotplug_slot_ops pciehp_hotplug_slot_ops = {
90 .get_cur_bus_speed = get_cur_bus_speed, 90 .get_cur_bus_speed = get_cur_bus_speed,
91}; 91};
92 92
93/**
94 * release_slot - free up the memory used by a slot
95 * @hotplug_slot: slot to free
96 */
97static void release_slot(struct hotplug_slot *hotplug_slot)
98{
99 struct slot *slot = hotplug_slot->private;
100
101 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
102
103 kfree(slot->hotplug_slot->info);
104 kfree(slot->hotplug_slot->name);
105 kfree(slot->hotplug_slot);
106 kfree(slot);
107}
108
93static int init_slots(struct controller *ctrl) 109static int init_slots(struct controller *ctrl)
94{ 110{
95 struct slot *new_slot; 111 struct slot *new_slot;
@@ -139,7 +155,8 @@ static int init_slots(struct controller *ctrl)
139 155
140 /* register this slot with the hotplug pci core */ 156 /* register this slot with the hotplug pci core */
141 new_slot->hotplug_slot->private = new_slot; 157 new_slot->hotplug_slot->private = new_slot;
142 make_slot_name (new_slot->hotplug_slot->name, SLOT_NAME_SIZE, new_slot); 158 new_slot->hotplug_slot->release = &release_slot;
159 make_slot_name(new_slot->hotplug_slot->name, SLOT_NAME_SIZE, new_slot);
143 new_slot->hotplug_slot->ops = &pciehp_hotplug_slot_ops; 160 new_slot->hotplug_slot->ops = &pciehp_hotplug_slot_ops;
144 161
145 new_slot->hpc_ops->get_power_status(new_slot, &(new_slot->hotplug_slot->info->power_status)); 162 new_slot->hpc_ops->get_power_status(new_slot, &(new_slot->hotplug_slot->info->power_status));
@@ -188,10 +205,6 @@ static int cleanup_slots (struct controller * ctrl)
188 while (old_slot) { 205 while (old_slot) {
189 next_slot = old_slot->next; 206 next_slot = old_slot->next;
190 pci_hp_deregister (old_slot->hotplug_slot); 207 pci_hp_deregister (old_slot->hotplug_slot);
191 kfree(old_slot->hotplug_slot->info);
192 kfree(old_slot->hotplug_slot->name);
193 kfree(old_slot->hotplug_slot);
194 kfree(old_slot);
195 old_slot = next_slot; 208 old_slot = next_slot;
196 } 209 }
197 210
@@ -594,7 +607,7 @@ static int pciehp_resume (struct pcie_device *dev)
594static struct pcie_port_service_id port_pci_ids[] = { { 607static struct pcie_port_service_id port_pci_ids[] = { {
595 .vendor = PCI_ANY_ID, 608 .vendor = PCI_ANY_ID,
596 .device = PCI_ANY_ID, 609 .device = PCI_ANY_ID,
597 .port_type = PCIE_RC_PORT, 610 .port_type = PCIE_ANY_PORT,
598 .service_type = PCIE_PORT_SERVICE_HP, 611 .service_type = PCIE_PORT_SERVICE_HP,
599 .driver_data = 0, 612 .driver_data = 0,
600 }, { /* end: all zeroes */ } 613 }, { /* end: all zeroes */ }
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 9e70c4681f77..1cda30bd6e47 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -109,20 +109,20 @@ enum ctrl_offsets {
109}; 109};
110static int pcie_cap_base = 0; /* Base of the PCI Express capability item structure */ 110static int pcie_cap_base = 0; /* Base of the PCI Express capability item structure */
111 111
112#define PCIE_CAP_ID ( pcie_cap_base + PCIECAPID ) 112#define PCIE_CAP_ID(cb) ( cb + PCIECAPID )
113#define NXT_CAP_PTR ( pcie_cap_base + NXTCAPPTR ) 113#define NXT_CAP_PTR(cb) ( cb + NXTCAPPTR )
114#define CAP_REG ( pcie_cap_base + CAPREG ) 114#define CAP_REG(cb) ( cb + CAPREG )
115#define DEV_CAP ( pcie_cap_base + DEVCAP ) 115#define DEV_CAP(cb) ( cb + DEVCAP )
116#define DEV_CTRL ( pcie_cap_base + DEVCTRL ) 116#define DEV_CTRL(cb) ( cb + DEVCTRL )
117#define DEV_STATUS ( pcie_cap_base + DEVSTATUS ) 117#define DEV_STATUS(cb) ( cb + DEVSTATUS )
118#define LNK_CAP ( pcie_cap_base + LNKCAP ) 118#define LNK_CAP(cb) ( cb + LNKCAP )
119#define LNK_CTRL ( pcie_cap_base + LNKCTRL ) 119#define LNK_CTRL(cb) ( cb + LNKCTRL )
120#define LNK_STATUS ( pcie_cap_base + LNKSTATUS ) 120#define LNK_STATUS(cb) ( cb + LNKSTATUS )
121#define SLOT_CAP ( pcie_cap_base + SLOTCAP ) 121#define SLOT_CAP(cb) ( cb + SLOTCAP )
122#define SLOT_CTRL ( pcie_cap_base + SLOTCTRL ) 122#define SLOT_CTRL(cb) ( cb + SLOTCTRL )
123#define SLOT_STATUS ( pcie_cap_base + SLOTSTATUS ) 123#define SLOT_STATUS(cb) ( cb + SLOTSTATUS )
124#define ROOT_CTRL ( pcie_cap_base + ROOTCTRL ) 124#define ROOT_CTRL(cb) ( cb + ROOTCTRL )
125#define ROOT_STATUS ( pcie_cap_base + ROOTSTATUS ) 125#define ROOT_STATUS(cb) ( cb + ROOTSTATUS )
126 126
127#define hp_register_read_word(pdev, reg , value) \ 127#define hp_register_read_word(pdev, reg , value) \
128 pci_read_config_word(pdev, reg, &value) 128 pci_read_config_word(pdev, reg, &value)
@@ -303,7 +303,7 @@ static int pcie_write_cmd(struct slot *slot, u16 cmd)
303 return -1; 303 return -1;
304 } 304 }
305 305
306 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 306 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(slot->ctrl->cap_base), slot_status);
307 if (retval) { 307 if (retval) {
308 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 308 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
309 return retval; 309 return retval;
@@ -317,7 +317,7 @@ static int pcie_write_cmd(struct slot *slot, u16 cmd)
317 } 317 }
318 318
319 dbg("%s: Before hp_register_write_word SLOT_CTRL %x\n", __FUNCTION__, cmd); 319 dbg("%s: Before hp_register_write_word SLOT_CTRL %x\n", __FUNCTION__, cmd);
320 retval = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL, cmd | CMD_CMPL_INTR_ENABLE); 320 retval = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), cmd | CMD_CMPL_INTR_ENABLE);
321 if (retval) { 321 if (retval) {
322 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 322 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__);
323 return retval; 323 return retval;
@@ -342,7 +342,7 @@ static int hpc_check_lnk_status(struct controller *ctrl)
342 return -1; 342 return -1;
343 } 343 }
344 344
345 retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS, lnk_status); 345 retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS(ctrl->cap_base), lnk_status);
346 346
347 if (retval) { 347 if (retval) {
348 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__); 348 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__);
@@ -376,14 +376,14 @@ static int hpc_get_attention_status(struct slot *slot, u8 *status)
376 return -1; 376 return -1;
377 } 377 }
378 378
379 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 379 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
380 380
381 if (retval) { 381 if (retval) {
382 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 382 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
383 return retval; 383 return retval;
384 } 384 }
385 385
386 dbg("%s: SLOT_CTRL %x, value read %x\n", __FUNCTION__,SLOT_CTRL, slot_ctrl); 386 dbg("%s: SLOT_CTRL %x, value read %x\n", __FUNCTION__,SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
387 387
388 atten_led_state = (slot_ctrl & ATTN_LED_CTRL) >> 6; 388 atten_led_state = (slot_ctrl & ATTN_LED_CTRL) >> 6;
389 389
@@ -423,13 +423,13 @@ static int hpc_get_power_status(struct slot * slot, u8 *status)
423 return -1; 423 return -1;
424 } 424 }
425 425
426 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 426 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
427 427
428 if (retval) { 428 if (retval) {
429 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 429 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
430 return retval; 430 return retval;
431 } 431 }
432 dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL, slot_ctrl); 432 dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
433 433
434 pwr_state = (slot_ctrl & PWR_CTRL) >> 10; 434 pwr_state = (slot_ctrl & PWR_CTRL) >> 10;
435 435
@@ -463,7 +463,7 @@ static int hpc_get_latch_status(struct slot *slot, u8 *status)
463 return -1; 463 return -1;
464 } 464 }
465 465
466 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 466 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(slot->ctrl->cap_base), slot_status);
467 467
468 if (retval) { 468 if (retval) {
469 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 469 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
@@ -490,7 +490,7 @@ static int hpc_get_adapter_status(struct slot *slot, u8 *status)
490 return -1; 490 return -1;
491 } 491 }
492 492
493 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 493 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(slot->ctrl->cap_base), slot_status);
494 494
495 if (retval) { 495 if (retval) {
496 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 496 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
@@ -518,7 +518,7 @@ static int hpc_query_power_fault(struct slot * slot)
518 return -1; 518 return -1;
519 } 519 }
520 520
521 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 521 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(slot->ctrl->cap_base), slot_status);
522 522
523 if (retval) { 523 if (retval) {
524 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 524 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
@@ -549,7 +549,7 @@ static int hpc_set_attention_status(struct slot *slot, u8 value)
549 err("%s: Invalid HPC slot number!\n", __FUNCTION__); 549 err("%s: Invalid HPC slot number!\n", __FUNCTION__);
550 return -1; 550 return -1;
551 } 551 }
552 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 552 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
553 553
554 if (rc) { 554 if (rc) {
555 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 555 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
@@ -574,7 +574,7 @@ static int hpc_set_attention_status(struct slot *slot, u8 value)
574 slot_cmd = slot_cmd | HP_INTR_ENABLE; 574 slot_cmd = slot_cmd | HP_INTR_ENABLE;
575 575
576 pcie_write_cmd(slot, slot_cmd); 576 pcie_write_cmd(slot, slot_cmd);
577 dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__, SLOT_CTRL, slot_cmd); 577 dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd);
578 578
579 return rc; 579 return rc;
580} 580}
@@ -598,7 +598,7 @@ static void hpc_set_green_led_on(struct slot *slot)
598 return ; 598 return ;
599 } 599 }
600 600
601 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 601 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
602 602
603 if (rc) { 603 if (rc) {
604 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 604 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
@@ -611,7 +611,7 @@ static void hpc_set_green_led_on(struct slot *slot)
611 611
612 pcie_write_cmd(slot, slot_cmd); 612 pcie_write_cmd(slot, slot_cmd);
613 613
614 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL, slot_cmd); 614 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd);
615 return; 615 return;
616} 616}
617 617
@@ -633,7 +633,7 @@ static void hpc_set_green_led_off(struct slot *slot)
633 return ; 633 return ;
634 } 634 }
635 635
636 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 636 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
637 637
638 if (rc) { 638 if (rc) {
639 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 639 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
@@ -646,7 +646,7 @@ static void hpc_set_green_led_off(struct slot *slot)
646 if (!pciehp_poll_mode) 646 if (!pciehp_poll_mode)
647 slot_cmd = slot_cmd | HP_INTR_ENABLE; 647 slot_cmd = slot_cmd | HP_INTR_ENABLE;
648 pcie_write_cmd(slot, slot_cmd); 648 pcie_write_cmd(slot, slot_cmd);
649 dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__, SLOT_CTRL, slot_cmd); 649 dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd);
650 650
651 return; 651 return;
652} 652}
@@ -669,7 +669,7 @@ static void hpc_set_green_led_blink(struct slot *slot)
669 return ; 669 return ;
670 } 670 }
671 671
672 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 672 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
673 673
674 if (rc) { 674 if (rc) {
675 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 675 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
@@ -683,7 +683,7 @@ static void hpc_set_green_led_blink(struct slot *slot)
683 slot_cmd = slot_cmd | HP_INTR_ENABLE; 683 slot_cmd = slot_cmd | HP_INTR_ENABLE;
684 pcie_write_cmd(slot, slot_cmd); 684 pcie_write_cmd(slot, slot_cmd);
685 685
686 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL, slot_cmd); 686 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd);
687 return; 687 return;
688} 688}
689 689
@@ -707,7 +707,7 @@ int pcie_get_ctlr_slot_config(struct controller *ctrl,
707 *first_device_num = 0; 707 *first_device_num = 0;
708 *num_ctlr_slots = 1; 708 *num_ctlr_slots = 1;
709 709
710 rc = hp_register_read_dword(php_ctlr->pci_dev, SLOT_CAP, slot_cap); 710 rc = hp_register_read_dword(php_ctlr->pci_dev, SLOT_CAP(ctrl->cap_base), slot_cap);
711 711
712 if (rc) { 712 if (rc) {
713 err("%s : hp_register_read_dword SLOT_CAP failed\n", __FUNCTION__); 713 err("%s : hp_register_read_dword SLOT_CAP failed\n", __FUNCTION__);
@@ -793,13 +793,13 @@ static int hpc_power_on_slot(struct slot * slot)
793 return -1; 793 return -1;
794 } 794 }
795 795
796 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 796 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
797 797
798 if (retval) { 798 if (retval) {
799 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 799 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
800 return retval; 800 return retval;
801 } 801 }
802 dbg("%s: SLOT_CTRL %x, value read %xn", __FUNCTION__, SLOT_CTRL, 802 dbg("%s: SLOT_CTRL %x, value read %xn", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base),
803 slot_ctrl); 803 slot_ctrl);
804 804
805 slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_ON; 805 slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_ON;
@@ -813,7 +813,7 @@ static int hpc_power_on_slot(struct slot * slot)
813 err("%s: Write %x command failed!\n", __FUNCTION__, slot_cmd); 813 err("%s: Write %x command failed!\n", __FUNCTION__, slot_cmd);
814 return -1; 814 return -1;
815 } 815 }
816 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL, slot_cmd); 816 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd);
817 817
818 DBG_LEAVE_ROUTINE 818 DBG_LEAVE_ROUTINE
819 819
@@ -842,13 +842,13 @@ static int hpc_power_off_slot(struct slot * slot)
842 err("%s: Invalid HPC slot number!\n", __FUNCTION__); 842 err("%s: Invalid HPC slot number!\n", __FUNCTION__);
843 return -1; 843 return -1;
844 } 844 }
845 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 845 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
846 846
847 if (retval) { 847 if (retval) {
848 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 848 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
849 return retval; 849 return retval;
850 } 850 }
851 dbg("%s: SLOT_CTRL %x, value read %x\n", __FUNCTION__, SLOT_CTRL, 851 dbg("%s: SLOT_CTRL %x, value read %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base),
852 slot_ctrl); 852 slot_ctrl);
853 853
854 slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_OFF; 854 slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_OFF;
@@ -862,7 +862,7 @@ static int hpc_power_off_slot(struct slot * slot)
862 err("%s: Write command failed!\n", __FUNCTION__); 862 err("%s: Write command failed!\n", __FUNCTION__);
863 return -1; 863 return -1;
864 } 864 }
865 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL, slot_cmd); 865 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd);
866 866
867 DBG_LEAVE_ROUTINE 867 DBG_LEAVE_ROUTINE
868 868
@@ -900,7 +900,7 @@ static irqreturn_t pcie_isr(int IRQ, void *dev_id, struct pt_regs *regs)
900 return IRQ_NONE; 900 return IRQ_NONE;
901 } 901 }
902 902
903 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 903 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status);
904 if (rc) { 904 if (rc) {
905 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 905 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
906 return IRQ_NONE; 906 return IRQ_NONE;
@@ -918,7 +918,7 @@ static irqreturn_t pcie_isr(int IRQ, void *dev_id, struct pt_regs *regs)
918 dbg("%s: intr_loc %x\n", __FUNCTION__, intr_loc); 918 dbg("%s: intr_loc %x\n", __FUNCTION__, intr_loc);
919 /* Mask Hot-plug Interrupt Enable */ 919 /* Mask Hot-plug Interrupt Enable */
920 if (!pciehp_poll_mode) { 920 if (!pciehp_poll_mode) {
921 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, temp_word); 921 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word);
922 if (rc) { 922 if (rc) {
923 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 923 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
924 return IRQ_NONE; 924 return IRQ_NONE;
@@ -928,14 +928,14 @@ static irqreturn_t pcie_isr(int IRQ, void *dev_id, struct pt_regs *regs)
928 dbg("%s: hp_register_read_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word); 928 dbg("%s: hp_register_read_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word);
929 temp_word = (temp_word & ~HP_INTR_ENABLE & ~CMD_CMPL_INTR_ENABLE) | 0x00; 929 temp_word = (temp_word & ~HP_INTR_ENABLE & ~CMD_CMPL_INTR_ENABLE) | 0x00;
930 930
931 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL, temp_word); 931 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word);
932 if (rc) { 932 if (rc) {
933 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 933 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__);
934 return IRQ_NONE; 934 return IRQ_NONE;
935 } 935 }
936 dbg("%s: hp_register_write_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word); 936 dbg("%s: hp_register_write_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word);
937 937
938 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 938 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status);
939 if (rc) { 939 if (rc) {
940 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 940 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
941 return IRQ_NONE; 941 return IRQ_NONE;
@@ -944,7 +944,7 @@ static irqreturn_t pcie_isr(int IRQ, void *dev_id, struct pt_regs *regs)
944 944
945 /* Clear command complete interrupt caused by this write */ 945 /* Clear command complete interrupt caused by this write */
946 temp_word = 0x1f; 946 temp_word = 0x1f;
947 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS, temp_word); 947 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word);
948 if (rc) { 948 if (rc) {
949 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 949 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__);
950 return IRQ_NONE; 950 return IRQ_NONE;
@@ -975,14 +975,14 @@ static irqreturn_t pcie_isr(int IRQ, void *dev_id, struct pt_regs *regs)
975 975
976 /* Clear all events after serving them */ 976 /* Clear all events after serving them */
977 temp_word = 0x1F; 977 temp_word = 0x1F;
978 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS, temp_word); 978 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word);
979 if (rc) { 979 if (rc) {
980 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 980 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__);
981 return IRQ_NONE; 981 return IRQ_NONE;
982 } 982 }
983 /* Unmask Hot-plug Interrupt Enable */ 983 /* Unmask Hot-plug Interrupt Enable */
984 if (!pciehp_poll_mode) { 984 if (!pciehp_poll_mode) {
985 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, temp_word); 985 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word);
986 if (rc) { 986 if (rc) {
987 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 987 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
988 return IRQ_NONE; 988 return IRQ_NONE;
@@ -992,14 +992,14 @@ static irqreturn_t pcie_isr(int IRQ, void *dev_id, struct pt_regs *regs)
992 dbg("%s: hp_register_read_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word); 992 dbg("%s: hp_register_read_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word);
993 temp_word = (temp_word & ~HP_INTR_ENABLE) | HP_INTR_ENABLE; 993 temp_word = (temp_word & ~HP_INTR_ENABLE) | HP_INTR_ENABLE;
994 994
995 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL, temp_word); 995 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word);
996 if (rc) { 996 if (rc) {
997 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 997 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__);
998 return IRQ_NONE; 998 return IRQ_NONE;
999 } 999 }
1000 dbg("%s: hp_register_write_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word); 1000 dbg("%s: hp_register_write_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word);
1001 1001
1002 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 1002 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status);
1003 if (rc) { 1003 if (rc) {
1004 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1004 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
1005 return IRQ_NONE; 1005 return IRQ_NONE;
@@ -1008,7 +1008,7 @@ static irqreturn_t pcie_isr(int IRQ, void *dev_id, struct pt_regs *regs)
1008 1008
1009 /* Clear command complete interrupt caused by this write */ 1009 /* Clear command complete interrupt caused by this write */
1010 temp_word = 0x1F; 1010 temp_word = 0x1F;
1011 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS, temp_word); 1011 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word);
1012 if (rc) { 1012 if (rc) {
1013 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 1013 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__);
1014 return IRQ_NONE; 1014 return IRQ_NONE;
@@ -1038,7 +1038,7 @@ static int hpc_get_max_lnk_speed (struct slot *slot, enum pci_bus_speed *value)
1038 return -1; 1038 return -1;
1039 } 1039 }
1040 1040
1041 retval = hp_register_read_dword(php_ctlr->pci_dev, LNK_CAP, lnk_cap); 1041 retval = hp_register_read_dword(php_ctlr->pci_dev, LNK_CAP(slot->ctrl->cap_base), lnk_cap);
1042 1042
1043 if (retval) { 1043 if (retval) {
1044 err("%s : hp_register_read_dword LNK_CAP failed\n", __FUNCTION__); 1044 err("%s : hp_register_read_dword LNK_CAP failed\n", __FUNCTION__);
@@ -1079,7 +1079,7 @@ static int hpc_get_max_lnk_width (struct slot *slot, enum pcie_link_width *value
1079 return -1; 1079 return -1;
1080 } 1080 }
1081 1081
1082 retval = hp_register_read_dword(php_ctlr->pci_dev, LNK_CAP, lnk_cap); 1082 retval = hp_register_read_dword(php_ctlr->pci_dev, LNK_CAP(slot->ctrl->cap_base), lnk_cap);
1083 1083
1084 if (retval) { 1084 if (retval) {
1085 err("%s : hp_register_read_dword LNK_CAP failed\n", __FUNCTION__); 1085 err("%s : hp_register_read_dword LNK_CAP failed\n", __FUNCTION__);
@@ -1141,7 +1141,7 @@ static int hpc_get_cur_lnk_speed (struct slot *slot, enum pci_bus_speed *value)
1141 return -1; 1141 return -1;
1142 } 1142 }
1143 1143
1144 retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS, lnk_status); 1144 retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS(slot->ctrl->cap_base), lnk_status);
1145 1145
1146 if (retval) { 1146 if (retval) {
1147 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__); 1147 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__);
@@ -1182,7 +1182,7 @@ static int hpc_get_cur_lnk_width (struct slot *slot, enum pcie_link_width *value
1182 return -1; 1182 return -1;
1183 } 1183 }
1184 1184
1185 retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS, lnk_status); 1185 retval = hp_register_read_word(php_ctlr->pci_dev, LNK_STATUS(slot->ctrl->cap_base), lnk_status);
1186 1186
1187 if (retval) { 1187 if (retval) {
1188 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__); 1188 err("%s : hp_register_read_word LNK_STATUS failed\n", __FUNCTION__);
@@ -1292,47 +1292,48 @@ int pcie_init(struct controller * ctrl,
1292 goto abort_free_ctlr; 1292 goto abort_free_ctlr;
1293 } 1293 }
1294 1294
1295 pcie_cap_base = cap_base; 1295 ctrl->cap_base = cap_base;
1296 1296
1297 dbg("%s: pcie_cap_base %x\n", __FUNCTION__, pcie_cap_base); 1297 dbg("%s: pcie_cap_base %x\n", __FUNCTION__, pcie_cap_base);
1298 1298
1299 rc = hp_register_read_word(pdev, CAP_REG, cap_reg); 1299 rc = hp_register_read_word(pdev, CAP_REG(ctrl->cap_base), cap_reg);
1300 if (rc) { 1300 if (rc) {
1301 err("%s : hp_register_read_word CAP_REG failed\n", __FUNCTION__); 1301 err("%s : hp_register_read_word CAP_REG failed\n", __FUNCTION__);
1302 goto abort_free_ctlr; 1302 goto abort_free_ctlr;
1303 } 1303 }
1304 dbg("%s: CAP_REG offset %x cap_reg %x\n", __FUNCTION__, CAP_REG, cap_reg); 1304 dbg("%s: CAP_REG offset %x cap_reg %x\n", __FUNCTION__, CAP_REG(ctrl->cap_base), cap_reg);
1305 1305
1306 if (((cap_reg & SLOT_IMPL) == 0) || ((cap_reg & DEV_PORT_TYPE) != 0x0040)){ 1306 if (((cap_reg & SLOT_IMPL) == 0) || (((cap_reg & DEV_PORT_TYPE) != 0x0040)
1307 && ((cap_reg & DEV_PORT_TYPE) != 0x0060))) {
1307 dbg("%s : This is not a root port or the port is not connected to a slot\n", __FUNCTION__); 1308 dbg("%s : This is not a root port or the port is not connected to a slot\n", __FUNCTION__);
1308 goto abort_free_ctlr; 1309 goto abort_free_ctlr;
1309 } 1310 }
1310 1311
1311 rc = hp_register_read_dword(php_ctlr->pci_dev, SLOT_CAP, slot_cap); 1312 rc = hp_register_read_dword(php_ctlr->pci_dev, SLOT_CAP(ctrl->cap_base), slot_cap);
1312 if (rc) { 1313 if (rc) {
1313 err("%s : hp_register_read_word CAP_REG failed\n", __FUNCTION__); 1314 err("%s : hp_register_read_word CAP_REG failed\n", __FUNCTION__);
1314 goto abort_free_ctlr; 1315 goto abort_free_ctlr;
1315 } 1316 }
1316 dbg("%s: SLOT_CAP offset %x slot_cap %x\n", __FUNCTION__, SLOT_CAP, slot_cap); 1317 dbg("%s: SLOT_CAP offset %x slot_cap %x\n", __FUNCTION__, SLOT_CAP(ctrl->cap_base), slot_cap);
1317 1318
1318 if (!(slot_cap & HP_CAP)) { 1319 if (!(slot_cap & HP_CAP)) {
1319 dbg("%s : This slot is not hot-plug capable\n", __FUNCTION__); 1320 dbg("%s : This slot is not hot-plug capable\n", __FUNCTION__);
1320 goto abort_free_ctlr; 1321 goto abort_free_ctlr;
1321 } 1322 }
1322 /* For debugging purpose */ 1323 /* For debugging purpose */
1323 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 1324 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status);
1324 if (rc) { 1325 if (rc) {
1325 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1326 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
1326 goto abort_free_ctlr; 1327 goto abort_free_ctlr;
1327 } 1328 }
1328 dbg("%s: SLOT_STATUS offset %x slot_status %x\n", __FUNCTION__, SLOT_STATUS, slot_status); 1329 dbg("%s: SLOT_STATUS offset %x slot_status %x\n", __FUNCTION__, SLOT_STATUS(ctrl->cap_base), slot_status);
1329 1330
1330 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL, slot_ctrl); 1331 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), slot_ctrl);
1331 if (rc) { 1332 if (rc) {
1332 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 1333 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
1333 goto abort_free_ctlr; 1334 goto abort_free_ctlr;
1334 } 1335 }
1335 dbg("%s: SLOT_CTRL offset %x slot_ctrl %x\n", __FUNCTION__, SLOT_CTRL, slot_ctrl); 1336 dbg("%s: SLOT_CTRL offset %x slot_ctrl %x\n", __FUNCTION__, SLOT_CTRL(ctrl->cap_base), slot_ctrl);
1336 1337
1337 if (first) { 1338 if (first) {
1338 spin_lock_init(&hpc_event_lock); 1339 spin_lock_init(&hpc_event_lock);
@@ -1372,36 +1373,37 @@ int pcie_init(struct controller * ctrl,
1372 php_ctlr->num_slots = 1; 1373 php_ctlr->num_slots = 1;
1373 1374
1374 /* Mask Hot-plug Interrupt Enable */ 1375 /* Mask Hot-plug Interrupt Enable */
1375 rc = hp_register_read_word(pdev, SLOT_CTRL, temp_word); 1376 rc = hp_register_read_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word);
1376 if (rc) { 1377 if (rc) {
1377 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 1378 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
1378 goto abort_free_ctlr; 1379 goto abort_free_ctlr;
1379 } 1380 }
1380 1381
1381 dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL, temp_word); 1382 dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL(ctrl->cap_base), temp_word);
1382 temp_word = (temp_word & ~HP_INTR_ENABLE & ~CMD_CMPL_INTR_ENABLE) | 0x00; 1383 temp_word = (temp_word & ~HP_INTR_ENABLE & ~CMD_CMPL_INTR_ENABLE) | 0x00;
1383 1384
1384 rc = hp_register_write_word(pdev, SLOT_CTRL, temp_word); 1385 rc = hp_register_write_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word);
1385 if (rc) { 1386 if (rc) {
1386 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 1387 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__);
1387 goto abort_free_ctlr; 1388 goto abort_free_ctlr;
1388 } 1389 }
1389 dbg("%s : Mask HPIE hp_register_write_word SLOT_CTRL %x\n", __FUNCTION__, temp_word); 1390 dbg("%s : Mask HPIE hp_register_write_word SLOT_CTRL %x\n", __FUNCTION__, temp_word);
1390 1391
1391 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 1392 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status);
1392 if (rc) { 1393 if (rc) {
1393 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1394 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
1394 goto abort_free_ctlr; 1395 goto abort_free_ctlr;
1395 } 1396 }
1396 dbg("%s: Mask HPIE SLOT_STATUS offset %x reads slot_status %x\n", __FUNCTION__, SLOT_STATUS, slot_status); 1397 dbg("%s: Mask HPIE SLOT_STATUS offset %x reads slot_status %x\n", __FUNCTION__, SLOT_STATUS(ctrl->cap_base)
1398 , slot_status);
1397 1399
1398 temp_word = 0x1F; /* Clear all events */ 1400 temp_word = 0x1F; /* Clear all events */
1399 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS, temp_word); 1401 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word);
1400 if (rc) { 1402 if (rc) {
1401 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 1403 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__);
1402 goto abort_free_ctlr; 1404 goto abort_free_ctlr;
1403 } 1405 }
1404 dbg("%s: SLOT_STATUS offset %x writes slot_status %x\n", __FUNCTION__, SLOT_STATUS, temp_word); 1406 dbg("%s: SLOT_STATUS offset %x writes slot_status %x\n", __FUNCTION__, SLOT_STATUS(ctrl->cap_base), temp_word);
1405 1407
1406 if (pciehp_poll_mode) {/* Install interrupt polling code */ 1408 if (pciehp_poll_mode) {/* Install interrupt polling code */
1407 /* Install and start the interrupt polling timer */ 1409 /* Install and start the interrupt polling timer */
@@ -1417,12 +1419,12 @@ int pcie_init(struct controller * ctrl,
1417 } 1419 }
1418 } 1420 }
1419 1421
1420 rc = hp_register_read_word(pdev, SLOT_CTRL, temp_word); 1422 rc = hp_register_read_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word);
1421 if (rc) { 1423 if (rc) {
1422 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 1424 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
1423 goto abort_free_ctlr; 1425 goto abort_free_ctlr;
1424 } 1426 }
1425 dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL, temp_word); 1427 dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL(ctrl->cap_base), temp_word);
1426 dbg("%s: slot_cap %x\n", __FUNCTION__, slot_cap); 1428 dbg("%s: slot_cap %x\n", __FUNCTION__, slot_cap);
1427 1429
1428 intr_enable = intr_enable | PRSN_DETECT_ENABLE; 1430 intr_enable = intr_enable | PRSN_DETECT_ENABLE;
@@ -1446,27 +1448,27 @@ int pcie_init(struct controller * ctrl,
1446 dbg("%s: temp_word %x\n", __FUNCTION__, temp_word); 1448 dbg("%s: temp_word %x\n", __FUNCTION__, temp_word);
1447 1449
1448 /* Unmask Hot-plug Interrupt Enable for the interrupt notification mechanism case */ 1450 /* Unmask Hot-plug Interrupt Enable for the interrupt notification mechanism case */
1449 rc = hp_register_write_word(pdev, SLOT_CTRL, temp_word); 1451 rc = hp_register_write_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word);
1450 if (rc) { 1452 if (rc) {
1451 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 1453 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__);
1452 goto abort_free_ctlr; 1454 goto abort_free_ctlr;
1453 } 1455 }
1454 dbg("%s : Unmask HPIE hp_register_write_word SLOT_CTRL with %x\n", __FUNCTION__, temp_word); 1456 dbg("%s : Unmask HPIE hp_register_write_word SLOT_CTRL with %x\n", __FUNCTION__, temp_word);
1455 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS, slot_status); 1457 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status);
1456 if (rc) { 1458 if (rc) {
1457 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1459 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
1458 goto abort_free_ctlr; 1460 goto abort_free_ctlr;
1459 } 1461 }
1460 dbg("%s: Unmask HPIE SLOT_STATUS offset %x reads slot_status %x\n", __FUNCTION__, 1462 dbg("%s: Unmask HPIE SLOT_STATUS offset %x reads slot_status %x\n", __FUNCTION__,
1461 SLOT_STATUS, slot_status); 1463 SLOT_STATUS(ctrl->cap_base), slot_status);
1462 1464
1463 temp_word = 0x1F; /* Clear all events */ 1465 temp_word = 0x1F; /* Clear all events */
1464 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS, temp_word); 1466 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word);
1465 if (rc) { 1467 if (rc) {
1466 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 1468 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__);
1467 goto abort_free_ctlr; 1469 goto abort_free_ctlr;
1468 } 1470 }
1469 dbg("%s: SLOT_STATUS offset %x writes slot_status %x\n", __FUNCTION__, SLOT_STATUS, temp_word); 1471 dbg("%s: SLOT_STATUS offset %x writes slot_status %x\n", __FUNCTION__, SLOT_STATUS(ctrl->cap_base), temp_word);
1470 1472
1471 /* Add this HPC instance into the HPC list */ 1473 /* Add this HPC instance into the HPC list */
1472 spin_lock(&list_lock); 1474 spin_lock(&list_lock);
diff --git a/drivers/pci/hotplug/pcihp_skeleton.c b/drivers/pci/hotplug/pcihp_skeleton.c
index 6605d6bda529..3194d51c6ec9 100644
--- a/drivers/pci/hotplug/pcihp_skeleton.c
+++ b/drivers/pci/hotplug/pcihp_skeleton.c
@@ -297,7 +297,7 @@ static int __init init_slots(void)
297 hotplug_slot->ops = &skel_hotplug_slot_ops; 297 hotplug_slot->ops = &skel_hotplug_slot_ops;
298 298
299 /* 299 /*
300 * Initilize the slot info structure with some known 300 * Initialize the slot info structure with some known
301 * good values. 301 * good values.
302 */ 302 */
303 info->power_status = get_power_status(slot); 303 info->power_status = get_power_status(slot);
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
index f0c53f850aed..a70a5c5705f2 100644
--- a/drivers/pci/hotplug/shpchp_core.c
+++ b/drivers/pci/hotplug/shpchp_core.c
@@ -95,7 +95,7 @@ static struct hotplug_slot_ops shpchp_hotplug_slot_ops = {
95 */ 95 */
96static void release_slot(struct hotplug_slot *hotplug_slot) 96static void release_slot(struct hotplug_slot *hotplug_slot)
97{ 97{
98 struct slot *slot = (struct slot *)hotplug_slot->private; 98 struct slot *slot = hotplug_slot->private;
99 99
100 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name); 100 dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
101 101
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
index 9f90eb8e6ecd..490a9553a062 100644
--- a/drivers/pci/hotplug/shpchp_ctrl.c
+++ b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -1885,7 +1885,7 @@ int shpchp_enable_slot (struct slot *p_slot)
1885 func = shpchp_slot_find(p_slot->bus, p_slot->device, 0); 1885 func = shpchp_slot_find(p_slot->bus, p_slot->device, 0);
1886 if (!func) { 1886 if (!func) {
1887 dbg("%s: Error! slot NULL\n", __FUNCTION__); 1887 dbg("%s: Error! slot NULL\n", __FUNCTION__);
1888 return 1; 1888 return -ENODEV;
1889 } 1889 }
1890 1890
1891 /* Check to see if (latch closed, card present, power off) */ 1891 /* Check to see if (latch closed, card present, power off) */
@@ -1894,19 +1894,19 @@ int shpchp_enable_slot (struct slot *p_slot)
1894 if (rc || !getstatus) { 1894 if (rc || !getstatus) {
1895 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); 1895 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number);
1896 up(&p_slot->ctrl->crit_sect); 1896 up(&p_slot->ctrl->crit_sect);
1897 return 1; 1897 return -ENODEV;
1898 } 1898 }
1899 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 1899 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
1900 if (rc || getstatus) { 1900 if (rc || getstatus) {
1901 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); 1901 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number);
1902 up(&p_slot->ctrl->crit_sect); 1902 up(&p_slot->ctrl->crit_sect);
1903 return 1; 1903 return -ENODEV;
1904 } 1904 }
1905 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 1905 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
1906 if (rc || getstatus) { 1906 if (rc || getstatus) {
1907 info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number); 1907 info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number);
1908 up(&p_slot->ctrl->crit_sect); 1908 up(&p_slot->ctrl->crit_sect);
1909 return 1; 1909 return -ENODEV;
1910 } 1910 }
1911 up(&p_slot->ctrl->crit_sect); 1911 up(&p_slot->ctrl->crit_sect);
1912 1912
@@ -1914,7 +1914,7 @@ int shpchp_enable_slot (struct slot *p_slot)
1914 1914
1915 func = shpchp_slot_create(p_slot->bus); 1915 func = shpchp_slot_create(p_slot->bus);
1916 if (func == NULL) 1916 if (func == NULL)
1917 return 1; 1917 return -ENOMEM;
1918 1918
1919 func->bus = p_slot->bus; 1919 func->bus = p_slot->bus;
1920 func->device = p_slot->device; 1920 func->device = p_slot->device;
@@ -1939,7 +1939,7 @@ int shpchp_enable_slot (struct slot *p_slot)
1939 /* Setup slot structure with entry for empty slot */ 1939 /* Setup slot structure with entry for empty slot */
1940 func = shpchp_slot_create(p_slot->bus); 1940 func = shpchp_slot_create(p_slot->bus);
1941 if (func == NULL) 1941 if (func == NULL)
1942 return (1); /* Out of memory */ 1942 return -ENOMEM; /* Out of memory */
1943 1943
1944 func->bus = p_slot->bus; 1944 func->bus = p_slot->bus;
1945 func->device = p_slot->device; 1945 func->device = p_slot->device;
@@ -1972,7 +1972,7 @@ int shpchp_disable_slot (struct slot *p_slot)
1972 struct pci_func *func; 1972 struct pci_func *func;
1973 1973
1974 if (!p_slot->ctrl) 1974 if (!p_slot->ctrl)
1975 return 1; 1975 return -ENODEV;
1976 1976
1977 pci_bus = p_slot->ctrl->pci_dev->subordinate; 1977 pci_bus = p_slot->ctrl->pci_dev->subordinate;
1978 1978
@@ -1983,19 +1983,19 @@ int shpchp_disable_slot (struct slot *p_slot)
1983 if (ret || !getstatus) { 1983 if (ret || !getstatus) {
1984 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); 1984 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number);
1985 up(&p_slot->ctrl->crit_sect); 1985 up(&p_slot->ctrl->crit_sect);
1986 return 1; 1986 return -ENODEV;
1987 } 1987 }
1988 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 1988 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
1989 if (ret || getstatus) { 1989 if (ret || getstatus) {
1990 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); 1990 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number);
1991 up(&p_slot->ctrl->crit_sect); 1991 up(&p_slot->ctrl->crit_sect);
1992 return 1; 1992 return -ENODEV;
1993 } 1993 }
1994 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 1994 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
1995 if (ret || !getstatus) { 1995 if (ret || !getstatus) {
1996 info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number); 1996 info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number);
1997 up(&p_slot->ctrl->crit_sect); 1997 up(&p_slot->ctrl->crit_sect);
1998 return 1; 1998 return -ENODEV;
1999 } 1999 }
2000 up(&p_slot->ctrl->crit_sect); 2000 up(&p_slot->ctrl->crit_sect);
2001 2001
@@ -2011,7 +2011,7 @@ int shpchp_disable_slot (struct slot *p_slot)
2011 /* Check the Class Code */ 2011 /* Check the Class Code */
2012 rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code); 2012 rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code);
2013 if (rc) 2013 if (rc)
2014 return rc; 2014 return -ENODEV;
2015 2015
2016 if (class_code == PCI_BASE_CLASS_DISPLAY) { 2016 if (class_code == PCI_BASE_CLASS_DISPLAY) {
2017 /* Display/Video adapter (not supported) */ 2017 /* Display/Video adapter (not supported) */
@@ -2020,13 +2020,13 @@ int shpchp_disable_slot (struct slot *p_slot)
2020 /* See if it's a bridge */ 2020 /* See if it's a bridge */
2021 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type); 2021 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
2022 if (rc) 2022 if (rc)
2023 return rc; 2023 return -ENODEV;
2024 2024
2025 /* If it's a bridge, check the VGA Enable bit */ 2025 /* If it's a bridge, check the VGA Enable bit */
2026 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { 2026 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
2027 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_BRIDGE_CONTROL, &BCR); 2027 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_BRIDGE_CONTROL, &BCR);
2028 if (rc) 2028 if (rc)
2029 return rc; 2029 return -ENODEV;
2030 2030
2031 /* If the VGA Enable bit is set, remove isn't supported */ 2031 /* If the VGA Enable bit is set, remove isn't supported */
2032 if (BCR & PCI_BRIDGE_CTL_VGA) { 2032 if (BCR & PCI_BRIDGE_CTL_VGA) {
@@ -2042,12 +2042,12 @@ int shpchp_disable_slot (struct slot *p_slot)
2042 if ((func != NULL) && !rc) { 2042 if ((func != NULL) && !rc) {
2043 rc = remove_board(func, p_slot->ctrl); 2043 rc = remove_board(func, p_slot->ctrl);
2044 } else if (!rc) 2044 } else if (!rc)
2045 rc = 1; 2045 rc = -ENODEV;
2046 2046
2047 if (p_slot) 2047 if (p_slot)
2048 update_slot_info(p_slot); 2048 update_slot_info(p_slot);
2049 2049
2050 return(rc); 2050 return rc;
2051} 2051}
2052 2052
2053 2053
diff --git a/drivers/pci/hotplug/shpchprm_acpi.c b/drivers/pci/hotplug/shpchprm_acpi.c
index 243a51d88b86..7957cdc72cd0 100644
--- a/drivers/pci/hotplug/shpchprm_acpi.c
+++ b/drivers/pci/hotplug/shpchprm_acpi.c
@@ -1626,7 +1626,7 @@ int shpchprm_set_hpp(
1626 pci_bus->number = func->bus; 1626 pci_bus->number = func->bus;
1627 devfn = PCI_DEVFN(func->device, func->function); 1627 devfn = PCI_DEVFN(func->device, func->function);
1628 1628
1629 ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->bus); 1629 ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->slot_bus);
1630 1630
1631 if (ab) { 1631 if (ab) {
1632 if (ab->_hpp) { 1632 if (ab->_hpp) {
@@ -1681,7 +1681,7 @@ void shpchprm_enable_card(
1681 | PCI_COMMAND_IO | PCI_COMMAND_MEMORY; 1681 | PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
1682 bcmd = bcommand = bcommand | PCI_BRIDGE_CTL_NO_ISA; 1682 bcmd = bcommand = bcommand | PCI_BRIDGE_CTL_NO_ISA;
1683 1683
1684 ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->bus); 1684 ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->slot_bus);
1685 if (ab) { 1685 if (ab) {
1686 if (ab->_hpp) { 1686 if (ab->_hpp) {
1687 if (ab->_hpp->enable_perr) { 1687 if (ab->_hpp->enable_perr) {
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 22ecd3b058be..30206ac43c44 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -522,7 +522,7 @@ void pci_scan_msi_device(struct pci_dev *dev)
522 * msi_capability_init - configure device's MSI capability structure 522 * msi_capability_init - configure device's MSI capability structure
523 * @dev: pointer to the pci_dev data structure of MSI device function 523 * @dev: pointer to the pci_dev data structure of MSI device function
524 * 524 *
525 * Setup the MSI capability structure of device funtion with a single 525 * Setup the MSI capability structure of device function with a single
526 * MSI vector, regardless of device function is capable of handling 526 * MSI vector, regardless of device function is capable of handling
527 * multiple messages. A return of zero indicates the successful setup 527 * multiple messages. A return of zero indicates the successful setup
528 * of an entry zero with the new MSI vector or non-zero for otherwise. 528 * of an entry zero with the new MSI vector or non-zero for otherwise.
@@ -599,7 +599,7 @@ static int msi_capability_init(struct pci_dev *dev)
599 * msix_capability_init - configure device's MSI-X capability 599 * msix_capability_init - configure device's MSI-X capability
600 * @dev: pointer to the pci_dev data structure of MSI-X device function 600 * @dev: pointer to the pci_dev data structure of MSI-X device function
601 * 601 *
602 * Setup the MSI-X capability structure of device funtion with a 602 * Setup the MSI-X capability structure of device function with a
603 * single MSI-X vector. A return of zero indicates the successful setup of 603 * single MSI-X vector. A return of zero indicates the successful setup of
604 * requested MSI-X entries with allocated vectors or non-zero for otherwise. 604 * requested MSI-X entries with allocated vectors or non-zero for otherwise.
605 **/ 605 **/
@@ -1074,7 +1074,7 @@ void pci_disable_msix(struct pci_dev* dev)
1074 * msi_remove_pci_irq_vectors - reclaim MSI(X) vectors to unused state 1074 * msi_remove_pci_irq_vectors - reclaim MSI(X) vectors to unused state
1075 * @dev: pointer to the pci_dev data structure of MSI(X) device function 1075 * @dev: pointer to the pci_dev data structure of MSI(X) device function
1076 * 1076 *
1077 * Being called during hotplug remove, from which the device funciton 1077 * Being called during hotplug remove, from which the device function
1078 * is hot-removed. All previous assigned MSI/MSI-X vectors, if 1078 * is hot-removed. All previous assigned MSI/MSI-X vectors, if
1079 * allocated for this device function, are reclaimed to unused state, 1079 * allocated for this device function, are reclaimed to unused state,
1080 * which may be used later on. 1080 * which may be used later on.
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 968eb32f292d..bc01d34e2634 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -19,7 +19,7 @@
19 19
20static u32 ctrlset_buf[3] = {0, 0, 0}; 20static u32 ctrlset_buf[3] = {0, 0, 0};
21static u32 global_ctrlsets = 0; 21static u32 global_ctrlsets = 0;
22u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40, 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66}; 22static u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40, 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66};
23 23
24static acpi_status 24static acpi_status
25acpi_query_osc ( 25acpi_query_osc (
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 37b7961efc44..fe98553c978f 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -318,6 +318,14 @@ static int pci_device_resume(struct device * dev)
318 return 0; 318 return 0;
319} 319}
320 320
321static void pci_device_shutdown(struct device *dev)
322{
323 struct pci_dev *pci_dev = to_pci_dev(dev);
324 struct pci_driver *drv = pci_dev->driver;
325
326 if (drv && drv->shutdown)
327 drv->shutdown(pci_dev);
328}
321 329
322#define kobj_to_pci_driver(obj) container_of(obj, struct device_driver, kobj) 330#define kobj_to_pci_driver(obj) container_of(obj, struct device_driver, kobj)
323#define attr_to_driver_attribute(obj) container_of(obj, struct driver_attribute, attr) 331#define attr_to_driver_attribute(obj) container_of(obj, struct driver_attribute, attr)
@@ -373,7 +381,7 @@ pci_populate_driver_dir(struct pci_driver *drv)
373 * 381 *
374 * Adds the driver structure to the list of registered drivers. 382 * Adds the driver structure to the list of registered drivers.
375 * Returns a negative value on error, otherwise 0. 383 * Returns a negative value on error, otherwise 0.
376 * If no error occured, the driver remains registered even if 384 * If no error occurred, the driver remains registered even if
377 * no device was claimed during registration. 385 * no device was claimed during registration.
378 */ 386 */
379int pci_register_driver(struct pci_driver *drv) 387int pci_register_driver(struct pci_driver *drv)
@@ -385,6 +393,7 @@ int pci_register_driver(struct pci_driver *drv)
385 drv->driver.bus = &pci_bus_type; 393 drv->driver.bus = &pci_bus_type;
386 drv->driver.probe = pci_device_probe; 394 drv->driver.probe = pci_device_probe;
387 drv->driver.remove = pci_device_remove; 395 drv->driver.remove = pci_device_remove;
396 drv->driver.shutdown = pci_device_shutdown,
388 drv->driver.owner = drv->owner; 397 drv->driver.owner = drv->owner;
389 drv->driver.kobj.ktype = &pci_driver_kobj_type; 398 drv->driver.kobj.ktype = &pci_driver_kobj_type;
390 pci_init_dynids(&drv->dynids); 399 pci_init_dynids(&drv->dynids);
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index d57ae71d32b1..6ca0061137a6 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -73,6 +73,17 @@ resource_show(struct device * dev, char * buf)
73 return (str - buf); 73 return (str - buf);
74} 74}
75 75
76static ssize_t modalias_show(struct device *dev, char *buf)
77{
78 struct pci_dev *pci_dev = to_pci_dev(dev);
79
80 return sprintf(buf, "pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x\n",
81 pci_dev->vendor, pci_dev->device,
82 pci_dev->subsystem_vendor, pci_dev->subsystem_device,
83 (u8)(pci_dev->class >> 16), (u8)(pci_dev->class >> 8),
84 (u8)(pci_dev->class));
85}
86
76struct device_attribute pci_dev_attrs[] = { 87struct device_attribute pci_dev_attrs[] = {
77 __ATTR_RO(resource), 88 __ATTR_RO(resource),
78 __ATTR_RO(vendor), 89 __ATTR_RO(vendor),
@@ -82,6 +93,7 @@ struct device_attribute pci_dev_attrs[] = {
82 __ATTR_RO(class), 93 __ATTR_RO(class),
83 __ATTR_RO(irq), 94 __ATTR_RO(irq),
84 __ATTR_RO(local_cpus), 95 __ATTR_RO(local_cpus),
96 __ATTR_RO(modalias),
85 __ATTR_NULL, 97 __ATTR_NULL,
86}; 98};
87 99
@@ -91,6 +103,7 @@ pci_read_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
91 struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj)); 103 struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj));
92 unsigned int size = 64; 104 unsigned int size = 64;
93 loff_t init_off = off; 105 loff_t init_off = off;
106 u8 *data = (u8*) buf;
94 107
95 /* Several chips lock up trying to read undefined config space */ 108 /* Several chips lock up trying to read undefined config space */
96 if (capable(CAP_SYS_ADMIN)) { 109 if (capable(CAP_SYS_ADMIN)) {
@@ -108,30 +121,47 @@ pci_read_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
108 size = count; 121 size = count;
109 } 122 }
110 123
111 while (off & 3) { 124 if ((off & 1) && size) {
112 unsigned char val; 125 u8 val;
113 pci_read_config_byte(dev, off, &val); 126 pci_read_config_byte(dev, off, &val);
114 buf[off - init_off] = val; 127 data[off - init_off] = val;
115 off++; 128 off++;
116 if (--size == 0) 129 size--;
117 break; 130 }
131
132 if ((off & 3) && size > 2) {
133 u16 val;
134 pci_read_config_word(dev, off, &val);
135 data[off - init_off] = val & 0xff;
136 data[off - init_off + 1] = (val >> 8) & 0xff;
137 off += 2;
138 size -= 2;
118 } 139 }
119 140
120 while (size > 3) { 141 while (size > 3) {
121 unsigned int val; 142 u32 val;
122 pci_read_config_dword(dev, off, &val); 143 pci_read_config_dword(dev, off, &val);
123 buf[off - init_off] = val & 0xff; 144 data[off - init_off] = val & 0xff;
124 buf[off - init_off + 1] = (val >> 8) & 0xff; 145 data[off - init_off + 1] = (val >> 8) & 0xff;
125 buf[off - init_off + 2] = (val >> 16) & 0xff; 146 data[off - init_off + 2] = (val >> 16) & 0xff;
126 buf[off - init_off + 3] = (val >> 24) & 0xff; 147 data[off - init_off + 3] = (val >> 24) & 0xff;
127 off += 4; 148 off += 4;
128 size -= 4; 149 size -= 4;
129 } 150 }
130 151
131 while (size > 0) { 152 if (size >= 2) {
132 unsigned char val; 153 u16 val;
154 pci_read_config_word(dev, off, &val);
155 data[off - init_off] = val & 0xff;
156 data[off - init_off + 1] = (val >> 8) & 0xff;
157 off += 2;
158 size -= 2;
159 }
160
161 if (size > 0) {
162 u8 val;
133 pci_read_config_byte(dev, off, &val); 163 pci_read_config_byte(dev, off, &val);
134 buf[off - init_off] = val; 164 data[off - init_off] = val;
135 off++; 165 off++;
136 --size; 166 --size;
137 } 167 }
@@ -145,6 +175,7 @@ pci_write_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
145 struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj)); 175 struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj));
146 unsigned int size = count; 176 unsigned int size = count;
147 loff_t init_off = off; 177 loff_t init_off = off;
178 u8 *data = (u8*) buf;
148 179
149 if (off > dev->cfg_size) 180 if (off > dev->cfg_size)
150 return 0; 181 return 0;
@@ -152,26 +183,41 @@ pci_write_config(struct kobject *kobj, char *buf, loff_t off, size_t count)
152 size = dev->cfg_size - off; 183 size = dev->cfg_size - off;
153 count = size; 184 count = size;
154 } 185 }
155 186
156 while (off & 3) { 187 if ((off & 1) && size) {
157 pci_write_config_byte(dev, off, buf[off - init_off]); 188 pci_write_config_byte(dev, off, data[off - init_off]);
158 off++; 189 off++;
159 if (--size == 0) 190 size--;
160 break;
161 } 191 }
192
193 if ((off & 3) && size > 2) {
194 u16 val = data[off - init_off];
195 val |= (u16) data[off - init_off + 1] << 8;
196 pci_write_config_word(dev, off, val);
197 off += 2;
198 size -= 2;
199 }
162 200
163 while (size > 3) { 201 while (size > 3) {
164 unsigned int val = buf[off - init_off]; 202 u32 val = data[off - init_off];
165 val |= (unsigned int) buf[off - init_off + 1] << 8; 203 val |= (u32) data[off - init_off + 1] << 8;
166 val |= (unsigned int) buf[off - init_off + 2] << 16; 204 val |= (u32) data[off - init_off + 2] << 16;
167 val |= (unsigned int) buf[off - init_off + 3] << 24; 205 val |= (u32) data[off - init_off + 3] << 24;
168 pci_write_config_dword(dev, off, val); 206 pci_write_config_dword(dev, off, val);
169 off += 4; 207 off += 4;
170 size -= 4; 208 size -= 4;
171 } 209 }
210
211 if (size >= 2) {
212 u16 val = data[off - init_off];
213 val |= (u16) data[off - init_off + 1] << 8;
214 pci_write_config_word(dev, off, val);
215 off += 2;
216 size -= 2;
217 }
172 218
173 while (size > 0) { 219 if (size) {
174 pci_write_config_byte(dev, off, buf[off - init_off]); 220 pci_write_config_byte(dev, off, data[off - init_off]);
175 off++; 221 off++;
176 --size; 222 --size;
177 } 223 }
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index bfbff8335268..f04b9ffe4153 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -16,6 +16,7 @@
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/spinlock.h> 17#include <linux/spinlock.h>
18#include <asm/dma.h> /* isa_dma_bridge_buggy */ 18#include <asm/dma.h> /* isa_dma_bridge_buggy */
19#include "pci.h"
19 20
20 21
21/** 22/**
@@ -398,10 +399,10 @@ pci_enable_device(struct pci_dev *dev)
398{ 399{
399 int err; 400 int err;
400 401
401 dev->is_enabled = 1;
402 if ((err = pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1))) 402 if ((err = pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1)))
403 return err; 403 return err;
404 pci_fixup_device(pci_fixup_enable, dev); 404 pci_fixup_device(pci_fixup_enable, dev);
405 dev->is_enabled = 1;
405 return 0; 406 return 0;
406} 407}
407 408
@@ -427,16 +428,15 @@ pci_disable_device(struct pci_dev *dev)
427{ 428{
428 u16 pci_command; 429 u16 pci_command;
429 430
430 dev->is_enabled = 0;
431 dev->is_busmaster = 0;
432
433 pci_read_config_word(dev, PCI_COMMAND, &pci_command); 431 pci_read_config_word(dev, PCI_COMMAND, &pci_command);
434 if (pci_command & PCI_COMMAND_MASTER) { 432 if (pci_command & PCI_COMMAND_MASTER) {
435 pci_command &= ~PCI_COMMAND_MASTER; 433 pci_command &= ~PCI_COMMAND_MASTER;
436 pci_write_config_word(dev, PCI_COMMAND, pci_command); 434 pci_write_config_word(dev, PCI_COMMAND, pci_command);
437 } 435 }
436 dev->is_busmaster = 0;
438 437
439 pcibios_disable_device(dev); 438 pcibios_disable_device(dev);
439 dev->is_enabled = 0;
440} 440}
441 441
442/** 442/**
@@ -749,17 +749,6 @@ pci_set_dma_mask(struct pci_dev *dev, u64 mask)
749} 749}
750 750
751int 751int
752pci_dac_set_dma_mask(struct pci_dev *dev, u64 mask)
753{
754 if (!pci_dac_dma_supported(dev, mask))
755 return -EIO;
756
757 dev->dma_mask = mask;
758
759 return 0;
760}
761
762int
763pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask) 752pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)
764{ 753{
765 if (!pci_dma_supported(dev, mask)) 754 if (!pci_dma_supported(dev, mask))
@@ -821,7 +810,6 @@ EXPORT_SYMBOL(pci_set_master);
821EXPORT_SYMBOL(pci_set_mwi); 810EXPORT_SYMBOL(pci_set_mwi);
822EXPORT_SYMBOL(pci_clear_mwi); 811EXPORT_SYMBOL(pci_clear_mwi);
823EXPORT_SYMBOL(pci_set_dma_mask); 812EXPORT_SYMBOL(pci_set_dma_mask);
824EXPORT_SYMBOL(pci_dac_set_dma_mask);
825EXPORT_SYMBOL(pci_set_consistent_dma_mask); 813EXPORT_SYMBOL(pci_set_consistent_dma_mask);
826EXPORT_SYMBOL(pci_assign_resource); 814EXPORT_SYMBOL(pci_assign_resource);
827EXPORT_SYMBOL(pci_find_parent_resource); 815EXPORT_SYMBOL(pci_find_parent_resource);
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 79cdc16c52c8..744da0d4ae5f 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -32,33 +32,6 @@ extern unsigned char pci_max_busnr(void);
32extern unsigned char pci_bus_max_busnr(struct pci_bus *bus); 32extern unsigned char pci_bus_max_busnr(struct pci_bus *bus);
33extern int pci_bus_find_capability (struct pci_bus *bus, unsigned int devfn, int cap); 33extern int pci_bus_find_capability (struct pci_bus *bus, unsigned int devfn, int cap);
34 34
35struct pci_dev_wrapped {
36 struct pci_dev *dev;
37 void *data;
38};
39
40struct pci_bus_wrapped {
41 struct pci_bus *bus;
42 void *data;
43};
44
45struct pci_visit {
46 int (* pre_visit_pci_bus) (struct pci_bus_wrapped *,
47 struct pci_dev_wrapped *);
48 int (* post_visit_pci_bus) (struct pci_bus_wrapped *,
49 struct pci_dev_wrapped *);
50
51 int (* pre_visit_pci_dev) (struct pci_dev_wrapped *,
52 struct pci_bus_wrapped *);
53 int (* visit_pci_dev) (struct pci_dev_wrapped *,
54 struct pci_bus_wrapped *);
55 int (* post_visit_pci_dev) (struct pci_dev_wrapped *,
56 struct pci_bus_wrapped *);
57};
58
59extern int pci_visit_dev(struct pci_visit *fn,
60 struct pci_dev_wrapped *wrapped_dev,
61 struct pci_bus_wrapped *wrapped_parent);
62extern void pci_remove_legacy_files(struct pci_bus *bus); 35extern void pci_remove_legacy_files(struct pci_bus *bus);
63 36
64/* Lock for read/write access to pci device and bus lists */ 37/* Lock for read/write access to pci device and bus lists */
diff --git a/drivers/pci/pci.ids b/drivers/pci/pci.ids
index 93481b41b613..1d2ef1e2ffc6 100644
--- a/drivers/pci/pci.ids
+++ b/drivers/pci/pci.ids
@@ -7173,6 +7173,7 @@
7173 080f Sentry5 DDR/SDR RAM Controller 7173 080f Sentry5 DDR/SDR RAM Controller
7174 0811 Sentry5 External Interface Core 7174 0811 Sentry5 External Interface Core
7175 0816 BCM3302 Sentry5 MIPS32 CPU 7175 0816 BCM3302 Sentry5 MIPS32 CPU
7176 1600 NetXtreme BCM5752 Gigabit Ethernet PCI Express
7176 1644 NetXtreme BCM5700 Gigabit Ethernet 7177 1644 NetXtreme BCM5700 Gigabit Ethernet
7177 1014 0277 Broadcom Vigil B5700 1000Base-T 7178 1014 0277 Broadcom Vigil B5700 1000Base-T
7178 1028 00d1 Broadcom BCM5700 7179 1028 00d1 Broadcom BCM5700
diff --git a/drivers/pci/pcie/portdrv_bus.c b/drivers/pci/pcie/portdrv_bus.c
index 4037a3e568de..3e84b501e6a4 100644
--- a/drivers/pci/pcie/portdrv_bus.c
+++ b/drivers/pci/pcie/portdrv_bus.c
@@ -39,7 +39,8 @@ static int pcie_port_bus_match(struct device *dev, struct device_driver *drv)
39 driver->id_table->vendor != pciedev->id.vendor) || 39 driver->id_table->vendor != pciedev->id.vendor) ||
40 (driver->id_table->device != PCI_ANY_ID && 40 (driver->id_table->device != PCI_ANY_ID &&
41 driver->id_table->device != pciedev->id.device) || 41 driver->id_table->device != pciedev->id.device) ||
42 driver->id_table->port_type != pciedev->id.port_type || 42 (driver->id_table->port_type != PCIE_ANY_PORT &&
43 driver->id_table->port_type != pciedev->id.port_type) ||
43 driver->id_table->service_type != pciedev->id.service_type ) 44 driver->id_table->service_type != pciedev->id.service_type )
44 return 0; 45 return 0;
45 46
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 6f0edadd132c..fd48b201eb53 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -9,6 +9,7 @@
9#include <linux/slab.h> 9#include <linux/slab.h>
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/cpumask.h> 11#include <linux/cpumask.h>
12#include "pci.h"
12 13
13#define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */ 14#define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */
14#define CARDBUS_RESERVE_BUSNR 3 15#define CARDBUS_RESERVE_BUSNR 3
@@ -124,7 +125,7 @@ static inline unsigned int pci_calc_resource_flags(unsigned int flags)
124/* 125/*
125 * Find the extent of a PCI decode.. 126 * Find the extent of a PCI decode..
126 */ 127 */
127static u32 pci_size(u32 base, u32 maxbase, unsigned long mask) 128static u32 pci_size(u32 base, u32 maxbase, u32 mask)
128{ 129{
129 u32 size = mask & maxbase; /* Find the significant bits */ 130 u32 size = mask & maxbase; /* Find the significant bits */
130 if (!size) 131 if (!size)
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index 84cc4f620d8d..e68bbfb1e7c3 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -15,6 +15,7 @@
15 15
16#include <asm/uaccess.h> 16#include <asm/uaccess.h>
17#include <asm/byteorder.h> 17#include <asm/byteorder.h>
18#include "pci.h"
18 19
19static int proc_initialized; /* = 0 */ 20static int proc_initialized; /* = 0 */
20 21
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 15a398051682..968033fd29f0 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -18,6 +18,8 @@
18#include <linux/pci.h> 18#include <linux/pci.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/delay.h> 20#include <linux/delay.h>
21#include <linux/acpi.h>
22#include "pci.h"
21 23
22/* Deal with broken BIOS'es that neglect to enable passive release, 24/* Deal with broken BIOS'es that neglect to enable passive release,
23 which can cause problems in combination with the 82441FX/PPro MTRRs */ 25 which can cause problems in combination with the 82441FX/PPro MTRRs */
@@ -328,6 +330,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12,
328DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0, quirk_ich4_lpc_acpi ); 330DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0, quirk_ich4_lpc_acpi );
329DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12, quirk_ich4_lpc_acpi ); 331DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12, quirk_ich4_lpc_acpi );
330DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, quirk_ich4_lpc_acpi ); 332DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, quirk_ich4_lpc_acpi );
333DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_1, quirk_ich4_lpc_acpi );
331 334
332/* 335/*
333 * VIA ACPI: One IO region pointed to by longword at 336 * VIA ACPI: One IO region pointed to by longword at
@@ -453,24 +456,16 @@ static void __init quirk_amd_8131_ioapic(struct pci_dev *dev)
453} 456}
454DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_APIC, quirk_amd_8131_ioapic ); 457DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_APIC, quirk_amd_8131_ioapic );
455 458
459static void __init quirk_svw_msi(struct pci_dev *dev)
460{
461 pci_msi_quirk = 1;
462 printk(KERN_WARNING "PCI: MSI quirk detected. pci_msi_quirk set.\n");
463}
464DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_GCNB_LE, quirk_svw_msi );
456#endif /* CONFIG_X86_IO_APIC */ 465#endif /* CONFIG_X86_IO_APIC */
457 466
458 467
459/* 468/*
460 * Via 686A/B: The PCI_INTERRUPT_LINE register for the on-chip
461 * devices, USB0/1, AC97, MC97, and ACPI, has an unusual feature:
462 * when written, it makes an internal connection to the PIC.
463 * For these devices, this register is defined to be 4 bits wide.
464 * Normally this is fine. However for IO-APIC motherboards, or
465 * non-x86 architectures (yes Via exists on PPC among other places),
466 * we must mask the PCI_INTERRUPT_LINE value versus 0xf to get
467 * interrupts delivered properly.
468 *
469 * TODO: When we have device-specific interrupt routers,
470 * quirk_via_irqpic will go away from quirks.
471 */
472
473/*
474 * FIXME: it is questionable that quirk_via_acpi 469 * FIXME: it is questionable that quirk_via_acpi
475 * is needed. It shows up as an ISA bridge, and does not 470 * is needed. It shows up as an ISA bridge, and does not
476 * support the PCI_INTERRUPT_LINE register at all. Therefore 471 * support the PCI_INTERRUPT_LINE register at all. Therefore
@@ -493,6 +488,31 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3, quirk_vi
493DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4, quirk_via_acpi ); 488DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4, quirk_via_acpi );
494 489
495/* 490/*
491 * Via 686A/B: The PCI_INTERRUPT_LINE register for the on-chip
492 * devices, USB0/1, AC97, MC97, and ACPI, has an unusual feature:
493 * when written, it makes an internal connection to the PIC.
494 * For these devices, this register is defined to be 4 bits wide.
495 * Normally this is fine. However for IO-APIC motherboards, or
496 * non-x86 architectures (yes Via exists on PPC among other places),
497 * we must mask the PCI_INTERRUPT_LINE value versus 0xf to get
498 * interrupts delivered properly.
499 */
500static void quirk_via_irq(struct pci_dev *dev)
501{
502 u8 irq, new_irq;
503
504 new_irq = dev->irq & 0xf;
505 pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq);
506 if (new_irq != irq) {
507 printk(KERN_INFO "PCI: Via IRQ fixup for %s, from %d to %d\n",
508 pci_name(dev), irq, new_irq);
509 udelay(15); /* unknown if delay really needed */
510 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, new_irq);
511 }
512}
513DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_ANY_ID, quirk_via_irq);
514
515/*
496 * PIIX3 USB: We have to disable USB interrupts that are 516 * PIIX3 USB: We have to disable USB interrupts that are
497 * hardwired to PIRQD# and may be shared with an 517 * hardwired to PIRQD# and may be shared with an
498 * external device. 518 * external device.
@@ -681,19 +701,6 @@ static void __init quirk_disable_pxb(struct pci_dev *pdev)
681} 701}
682DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, quirk_disable_pxb ); 702DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, quirk_disable_pxb );
683 703
684/*
685 * VIA northbridges care about PCI_INTERRUPT_LINE
686 */
687int via_interrupt_line_quirk;
688
689static void __devinit quirk_via_bridge(struct pci_dev *pdev)
690{
691 if(pdev->devfn == 0) {
692 printk(KERN_INFO "PCI: Via IRQ fixup\n");
693 via_interrupt_line_quirk = 1;
694 }
695}
696DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_ANY_ID, quirk_via_bridge );
697 704
698/* 705/*
699 * Serverworks CSB5 IDE does not fully support native mode 706 * Serverworks CSB5 IDE does not fully support native mode