Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * PCI handling of I2O controller |
| 3 | * |
| 4 | * Copyright (C) 1999-2002 Red Hat Software |
| 5 | * |
| 6 | * Written by Alan Cox, Building Number Three Ltd |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License as published by the |
| 10 | * Free Software Foundation; either version 2 of the License, or (at your |
| 11 | * option) any later version. |
| 12 | * |
| 13 | * A lot of the I2O message side code from this is taken from the Red |
| 14 | * Creek RCPCI45 adapter driver by Red Creek Communications |
| 15 | * |
| 16 | * Fixes/additions: |
| 17 | * Philipp Rumpf |
| 18 | * Juha Sievänen <Juha.Sievanen@cs.Helsinki.FI> |
| 19 | * Auvo Häkkinen <Auvo.Hakkinen@cs.Helsinki.FI> |
| 20 | * Deepak Saxena <deepak@plexity.net> |
| 21 | * Boji T Kannanthanam <boji.t.kannanthanam@intel.com> |
| 22 | * Alan Cox <alan@redhat.com>: |
| 23 | * Ported to Linux 2.5. |
| 24 | * Markus Lidel <Markus.Lidel@shadowconnect.com>: |
| 25 | * Minor fixes for 2.6. |
| 26 | * Markus Lidel <Markus.Lidel@shadowconnect.com>: |
| 27 | * Support for sysfs included. |
| 28 | */ |
| 29 | |
| 30 | #include <linux/pci.h> |
| 31 | #include <linux/interrupt.h> |
| 32 | #include <linux/i2o.h> |
Markus Lidel | 9e87545 | 2005-06-23 22:02:21 -0700 | [diff] [blame] | 33 | #include "core.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
| 35 | /* PCI device id table for all I2O controllers */ |
| 36 | static struct pci_device_id __devinitdata i2o_pci_ids[] = { |
| 37 | {PCI_DEVICE_CLASS(PCI_CLASS_INTELLIGENT_I2O << 8, 0xffff00)}, |
| 38 | {PCI_DEVICE(PCI_VENDOR_ID_DPT, 0xa511)}, |
Markus Lidel | 61fbfa8 | 2005-06-23 22:02:11 -0700 | [diff] [blame] | 39 | {.vendor = PCI_VENDOR_ID_INTEL,.device = 0x1962, |
| 40 | .subvendor = PCI_VENDOR_ID_PROMISE,.subdevice = PCI_ANY_ID}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | {0} |
| 42 | }; |
| 43 | |
| 44 | /** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | * i2o_pci_free - Frees the DMA memory for the I2O controller |
| 46 | * @c: I2O controller to free |
| 47 | * |
| 48 | * Remove all allocated DMA memory and unmap memory IO regions. If MTRR |
| 49 | * is enabled, also remove it again. |
| 50 | */ |
| 51 | static void i2o_pci_free(struct i2o_controller *c) |
| 52 | { |
| 53 | struct device *dev; |
| 54 | |
| 55 | dev = &c->pdev->dev; |
| 56 | |
| 57 | i2o_dma_free(dev, &c->out_queue); |
| 58 | i2o_dma_free(dev, &c->status_block); |
Markus Lidel | f88e119 | 2005-06-23 22:02:14 -0700 | [diff] [blame] | 59 | kfree(c->lct); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | i2o_dma_free(dev, &c->dlct); |
| 61 | i2o_dma_free(dev, &c->hrt); |
| 62 | i2o_dma_free(dev, &c->status); |
| 63 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | if (c->raptor && c->in_queue.virt) |
| 65 | iounmap(c->in_queue.virt); |
| 66 | |
| 67 | if (c->base.virt) |
| 68 | iounmap(c->base.virt); |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * i2o_pci_alloc - Allocate DMA memory, map IO memory for I2O controller |
| 73 | * @c: I2O controller |
| 74 | * |
| 75 | * Allocate DMA memory for a PCI (or in theory AGP) I2O controller. All |
| 76 | * IO mappings are also done here. If MTRR is enabled, also do add memory |
| 77 | * regions here. |
| 78 | * |
| 79 | * Returns 0 on success or negative error code on failure. |
| 80 | */ |
| 81 | static int __devinit i2o_pci_alloc(struct i2o_controller *c) |
| 82 | { |
| 83 | struct pci_dev *pdev = c->pdev; |
| 84 | struct device *dev = &pdev->dev; |
| 85 | int i; |
| 86 | |
| 87 | for (i = 0; i < 6; i++) { |
| 88 | /* Skip I/O spaces */ |
| 89 | if (!(pci_resource_flags(pdev, i) & IORESOURCE_IO)) { |
| 90 | if (!c->base.phys) { |
| 91 | c->base.phys = pci_resource_start(pdev, i); |
| 92 | c->base.len = pci_resource_len(pdev, i); |
| 93 | |
| 94 | /* |
| 95 | * If we know what card it is, set the size |
| 96 | * correctly. Code is taken from dpt_i2o.c |
| 97 | */ |
| 98 | if (pdev->device == 0xa501) { |
| 99 | if (pdev->subsystem_device >= 0xc032 && |
| 100 | pdev->subsystem_device <= 0xc03b) { |
| 101 | if (c->base.len > 0x400000) |
| 102 | c->base.len = 0x400000; |
| 103 | } else { |
| 104 | if (c->base.len > 0x100000) |
| 105 | c->base.len = 0x100000; |
| 106 | } |
| 107 | } |
| 108 | if (!c->raptor) |
| 109 | break; |
| 110 | } else { |
| 111 | c->in_queue.phys = pci_resource_start(pdev, i); |
| 112 | c->in_queue.len = pci_resource_len(pdev, i); |
| 113 | break; |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | if (i == 6) { |
| 119 | printk(KERN_ERR "%s: I2O controller has no memory regions" |
| 120 | " defined.\n", c->name); |
| 121 | i2o_pci_free(c); |
| 122 | return -EINVAL; |
| 123 | } |
| 124 | |
| 125 | /* Map the I2O controller */ |
| 126 | if (c->raptor) { |
| 127 | printk(KERN_INFO "%s: PCI I2O controller\n", c->name); |
| 128 | printk(KERN_INFO " BAR0 at 0x%08lX size=%ld\n", |
| 129 | (unsigned long)c->base.phys, (unsigned long)c->base.len); |
| 130 | printk(KERN_INFO " BAR1 at 0x%08lX size=%ld\n", |
| 131 | (unsigned long)c->in_queue.phys, |
| 132 | (unsigned long)c->in_queue.len); |
| 133 | } else |
| 134 | printk(KERN_INFO "%s: PCI I2O controller at %08lX size=%ld\n", |
| 135 | c->name, (unsigned long)c->base.phys, |
| 136 | (unsigned long)c->base.len); |
| 137 | |
Markus Lidel | 61fbfa8 | 2005-06-23 22:02:11 -0700 | [diff] [blame] | 138 | c->base.virt = ioremap_nocache(c->base.phys, c->base.len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | if (!c->base.virt) { |
| 140 | printk(KERN_ERR "%s: Unable to map controller.\n", c->name); |
| 141 | return -ENOMEM; |
| 142 | } |
| 143 | |
| 144 | if (c->raptor) { |
Markus Lidel | 61fbfa8 | 2005-06-23 22:02:11 -0700 | [diff] [blame] | 145 | c->in_queue.virt = |
| 146 | ioremap_nocache(c->in_queue.phys, c->in_queue.len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | if (!c->in_queue.virt) { |
| 148 | printk(KERN_ERR "%s: Unable to map controller.\n", |
| 149 | c->name); |
| 150 | i2o_pci_free(c); |
| 151 | return -ENOMEM; |
| 152 | } |
| 153 | } else |
| 154 | c->in_queue = c->base; |
| 155 | |
Markus Lidel | f10378f | 2005-06-23 22:02:16 -0700 | [diff] [blame] | 156 | c->irq_status = c->base.virt + I2O_IRQ_STATUS; |
Markus Lidel | f88e119 | 2005-06-23 22:02:14 -0700 | [diff] [blame] | 157 | c->irq_mask = c->base.virt + I2O_IRQ_MASK; |
| 158 | c->in_port = c->base.virt + I2O_IN_PORT; |
| 159 | c->out_port = c->base.virt + I2O_OUT_PORT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | if (i2o_dma_alloc(dev, &c->status, 8, GFP_KERNEL)) { |
| 162 | i2o_pci_free(c); |
| 163 | return -ENOMEM; |
| 164 | } |
| 165 | |
| 166 | if (i2o_dma_alloc(dev, &c->hrt, sizeof(i2o_hrt), GFP_KERNEL)) { |
| 167 | i2o_pci_free(c); |
| 168 | return -ENOMEM; |
| 169 | } |
| 170 | |
| 171 | if (i2o_dma_alloc(dev, &c->dlct, 8192, GFP_KERNEL)) { |
| 172 | i2o_pci_free(c); |
| 173 | return -ENOMEM; |
| 174 | } |
| 175 | |
| 176 | if (i2o_dma_alloc(dev, &c->status_block, sizeof(i2o_status_block), |
| 177 | GFP_KERNEL)) { |
| 178 | i2o_pci_free(c); |
| 179 | return -ENOMEM; |
| 180 | } |
| 181 | |
Markus Lidel | f33213e | 2005-06-23 22:02:23 -0700 | [diff] [blame] | 182 | if (i2o_dma_alloc |
| 183 | (dev, &c->out_queue, |
| 184 | I2O_MAX_OUTBOUND_MSG_FRAMES * I2O_OUTBOUND_MSG_FRAME_SIZE * |
| 185 | sizeof(u32), GFP_KERNEL)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | i2o_pci_free(c); |
| 187 | return -ENOMEM; |
| 188 | } |
| 189 | |
| 190 | pci_set_drvdata(pdev, c); |
| 191 | |
| 192 | return 0; |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * i2o_pci_interrupt - Interrupt handler for I2O controller |
| 197 | * @irq: interrupt line |
| 198 | * @dev_id: pointer to the I2O controller |
| 199 | * @r: pointer to registers |
| 200 | * |
| 201 | * Handle an interrupt from a PCI based I2O controller. This turns out |
| 202 | * to be rather simple. We keep the controller pointer in the cookie. |
| 203 | */ |
| 204 | static irqreturn_t i2o_pci_interrupt(int irq, void *dev_id, struct pt_regs *r) |
| 205 | { |
| 206 | struct i2o_controller *c = dev_id; |
Markus Lidel | f10378f | 2005-06-23 22:02:16 -0700 | [diff] [blame] | 207 | u32 m; |
| 208 | irqreturn_t rc = IRQ_NONE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | |
Markus Lidel | f10378f | 2005-06-23 22:02:16 -0700 | [diff] [blame] | 210 | while (readl(c->irq_status) & I2O_IRQ_OUTBOUND_POST) { |
| 211 | m = readl(c->out_port); |
| 212 | if (m == I2O_QUEUE_EMPTY) { |
| 213 | /* |
| 214 | * Old 960 steppings had a bug in the I2O unit that |
| 215 | * caused the queue to appear empty when it wasn't. |
| 216 | */ |
| 217 | m = readl(c->out_port); |
| 218 | if (unlikely(m == I2O_QUEUE_EMPTY)) |
| 219 | break; |
| 220 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | /* dispatch it */ |
Markus Lidel | f10378f | 2005-06-23 22:02:16 -0700 | [diff] [blame] | 223 | if (i2o_driver_dispatch(c, m)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | /* flush it if result != 0 */ |
Markus Lidel | f10378f | 2005-06-23 22:02:16 -0700 | [diff] [blame] | 225 | i2o_flush_reply(c, m); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | |
Markus Lidel | f10378f | 2005-06-23 22:02:16 -0700 | [diff] [blame] | 227 | rc = IRQ_HANDLED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | } |
Markus Lidel | f88e119 | 2005-06-23 22:02:14 -0700 | [diff] [blame] | 229 | |
Markus Lidel | f10378f | 2005-06-23 22:02:16 -0700 | [diff] [blame] | 230 | return rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | /** |
| 234 | * i2o_pci_irq_enable - Allocate interrupt for I2O controller |
| 235 | * |
| 236 | * Allocate an interrupt for the I2O controller, and activate interrupts |
| 237 | * on the I2O controller. |
| 238 | * |
| 239 | * Returns 0 on success or negative error code on failure. |
| 240 | */ |
| 241 | static int i2o_pci_irq_enable(struct i2o_controller *c) |
| 242 | { |
| 243 | struct pci_dev *pdev = c->pdev; |
| 244 | int rc; |
| 245 | |
Markus Lidel | f88e119 | 2005-06-23 22:02:14 -0700 | [diff] [blame] | 246 | writel(0xffffffff, c->irq_mask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | |
| 248 | if (pdev->irq) { |
| 249 | rc = request_irq(pdev->irq, i2o_pci_interrupt, SA_SHIRQ, |
| 250 | c->name, c); |
| 251 | if (rc < 0) { |
| 252 | printk(KERN_ERR "%s: unable to allocate interrupt %d." |
| 253 | "\n", c->name, pdev->irq); |
| 254 | return rc; |
| 255 | } |
| 256 | } |
| 257 | |
Markus Lidel | f88e119 | 2005-06-23 22:02:14 -0700 | [diff] [blame] | 258 | writel(0x00000000, c->irq_mask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | |
| 260 | printk(KERN_INFO "%s: Installed at IRQ %d\n", c->name, pdev->irq); |
| 261 | |
| 262 | return 0; |
| 263 | } |
| 264 | |
| 265 | /** |
| 266 | * i2o_pci_irq_disable - Free interrupt for I2O controller |
| 267 | * @c: I2O controller |
| 268 | * |
| 269 | * Disable interrupts in I2O controller and then free interrupt. |
| 270 | */ |
| 271 | static void i2o_pci_irq_disable(struct i2o_controller *c) |
| 272 | { |
Markus Lidel | f88e119 | 2005-06-23 22:02:14 -0700 | [diff] [blame] | 273 | writel(0xffffffff, c->irq_mask); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | |
| 275 | if (c->pdev->irq > 0) |
| 276 | free_irq(c->pdev->irq, c); |
| 277 | } |
| 278 | |
| 279 | /** |
| 280 | * i2o_pci_probe - Probe the PCI device for an I2O controller |
| 281 | * @dev: PCI device to test |
| 282 | * @id: id which matched with the PCI device id table |
| 283 | * |
| 284 | * Probe the PCI device for any device which is a memory of the |
| 285 | * Intelligent, I2O class or an Adaptec Zero Channel Controller. We |
| 286 | * attempt to set up each such device and register it with the core. |
| 287 | * |
| 288 | * Returns 0 on success or negative error code on failure. |
| 289 | */ |
| 290 | static int __devinit i2o_pci_probe(struct pci_dev *pdev, |
| 291 | const struct pci_device_id *id) |
| 292 | { |
| 293 | struct i2o_controller *c; |
| 294 | int rc; |
Markus Lidel | 61fbfa8 | 2005-06-23 22:02:11 -0700 | [diff] [blame] | 295 | struct pci_dev *i960 = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | |
| 297 | printk(KERN_INFO "i2o: Checking for PCI I2O controllers...\n"); |
| 298 | |
| 299 | if ((pdev->class & 0xff) > 1) { |
Markus Lidel | 61fbfa8 | 2005-06-23 22:02:11 -0700 | [diff] [blame] | 300 | printk(KERN_WARNING "i2o: %s does not support I2O 1.5 " |
| 301 | "(skipping).\n", pci_name(pdev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | return -ENODEV; |
| 303 | } |
| 304 | |
| 305 | if ((rc = pci_enable_device(pdev))) { |
Markus Lidel | 61fbfa8 | 2005-06-23 22:02:11 -0700 | [diff] [blame] | 306 | printk(KERN_WARNING "i2o: couldn't enable device %s\n", |
| 307 | pci_name(pdev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | return rc; |
| 309 | } |
| 310 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) { |
Markus Lidel | 61fbfa8 | 2005-06-23 22:02:11 -0700 | [diff] [blame] | 312 | printk(KERN_WARNING "i2o: no suitable DMA found for %s\n", |
| 313 | pci_name(pdev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | rc = -ENODEV; |
| 315 | goto disable; |
| 316 | } |
| 317 | |
| 318 | pci_set_master(pdev); |
| 319 | |
| 320 | c = i2o_iop_alloc(); |
| 321 | if (IS_ERR(c)) { |
Markus Lidel | 61fbfa8 | 2005-06-23 22:02:11 -0700 | [diff] [blame] | 322 | printk(KERN_ERR "i2o: couldn't allocate memory for %s\n", |
| 323 | pci_name(pdev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | rc = PTR_ERR(c); |
| 325 | goto disable; |
Markus Lidel | 61fbfa8 | 2005-06-23 22:02:11 -0700 | [diff] [blame] | 326 | } else |
| 327 | printk(KERN_INFO "%s: controller found (%s)\n", c->name, |
| 328 | pci_name(pdev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | |
| 330 | c->pdev = pdev; |
Markus Lidel | f88e119 | 2005-06-23 22:02:14 -0700 | [diff] [blame] | 331 | c->device.parent = get_device(&pdev->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | |
| 333 | /* Cards that fall apart if you hit them with large I/O loads... */ |
| 334 | if (pdev->vendor == PCI_VENDOR_ID_NCR && pdev->device == 0x0630) { |
| 335 | c->short_req = 1; |
| 336 | printk(KERN_INFO "%s: Symbios FC920 workarounds activated.\n", |
| 337 | c->name); |
| 338 | } |
| 339 | |
| 340 | if (pdev->subsystem_vendor == PCI_VENDOR_ID_PROMISE) { |
Markus Lidel | 61fbfa8 | 2005-06-23 22:02:11 -0700 | [diff] [blame] | 341 | /* |
| 342 | * Expose the ship behind i960 for initialization, or it will |
| 343 | * failed |
| 344 | */ |
| 345 | i960 = |
| 346 | pci_find_slot(c->pdev->bus->number, |
| 347 | PCI_DEVFN(PCI_SLOT(c->pdev->devfn), 0)); |
| 348 | |
| 349 | if (i960) |
| 350 | pci_write_config_word(i960, 0x42, 0); |
| 351 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | c->promise = 1; |
Markus Lidel | 718c318 | 2005-06-23 22:02:24 -0700 | [diff] [blame^] | 353 | c->limit_sectors = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | } |
| 355 | |
Markus Lidel | b2aaee3 | 2005-06-23 22:02:19 -0700 | [diff] [blame] | 356 | if (pdev->subsystem_vendor == PCI_VENDOR_ID_DPT) |
| 357 | c->adaptec = 1; |
| 358 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | /* Cards that go bananas if you quiesce them before you reset them. */ |
| 360 | if (pdev->vendor == PCI_VENDOR_ID_DPT) { |
| 361 | c->no_quiesce = 1; |
| 362 | if (pdev->device == 0xa511) |
| 363 | c->raptor = 1; |
Markus Lidel | b2aaee3 | 2005-06-23 22:02:19 -0700 | [diff] [blame] | 364 | |
| 365 | if (pdev->subsystem_device == 0xc05a) { |
| 366 | c->limit_sectors = 1; |
| 367 | printk(KERN_INFO |
| 368 | "%s: limit sectors per request to %d\n", c->name, |
| 369 | I2O_MAX_SECTORS_LIMITED); |
| 370 | } |
| 371 | #ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64 |
| 372 | if (sizeof(dma_addr_t) > 4) { |
| 373 | if (pci_set_dma_mask(pdev, DMA_64BIT_MASK)) |
| 374 | printk(KERN_INFO "%s: 64-bit DMA unavailable\n", |
| 375 | c->name); |
| 376 | else { |
| 377 | c->pae_support = 1; |
| 378 | printk(KERN_INFO "%s: using 64-bit DMA\n", |
| 379 | c->name); |
| 380 | } |
| 381 | } |
| 382 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | if ((rc = i2o_pci_alloc(c))) { |
| 386 | printk(KERN_ERR "%s: DMA / IO allocation for I2O controller " |
| 387 | " failed\n", c->name); |
| 388 | goto free_controller; |
| 389 | } |
| 390 | |
| 391 | if (i2o_pci_irq_enable(c)) { |
| 392 | printk(KERN_ERR "%s: unable to enable interrupts for I2O " |
| 393 | "controller\n", c->name); |
| 394 | goto free_pci; |
| 395 | } |
| 396 | |
| 397 | if ((rc = i2o_iop_add(c))) |
| 398 | goto uninstall; |
| 399 | |
Markus Lidel | 9e87545 | 2005-06-23 22:02:21 -0700 | [diff] [blame] | 400 | get_device(&c->device); |
| 401 | |
Markus Lidel | 61fbfa8 | 2005-06-23 22:02:11 -0700 | [diff] [blame] | 402 | if (i960) |
| 403 | pci_write_config_word(i960, 0x42, 0x03ff); |
| 404 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | return 0; |
| 406 | |
| 407 | uninstall: |
| 408 | i2o_pci_irq_disable(c); |
| 409 | |
| 410 | free_pci: |
| 411 | i2o_pci_free(c); |
| 412 | |
| 413 | free_controller: |
| 414 | i2o_iop_free(c); |
Markus Lidel | f88e119 | 2005-06-23 22:02:14 -0700 | [diff] [blame] | 415 | put_device(c->device.parent); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | |
| 417 | disable: |
| 418 | pci_disable_device(pdev); |
| 419 | |
| 420 | return rc; |
| 421 | } |
| 422 | |
| 423 | /** |
| 424 | * i2o_pci_remove - Removes a I2O controller from the system |
| 425 | * pdev: I2O controller which should be removed |
| 426 | * |
| 427 | * Reset the I2O controller, disable interrupts and remove all allocated |
| 428 | * resources. |
| 429 | */ |
| 430 | static void __devexit i2o_pci_remove(struct pci_dev *pdev) |
| 431 | { |
| 432 | struct i2o_controller *c; |
| 433 | c = pci_get_drvdata(pdev); |
| 434 | |
| 435 | i2o_iop_remove(c); |
| 436 | i2o_pci_irq_disable(c); |
| 437 | i2o_pci_free(c); |
| 438 | |
Markus Lidel | f88e119 | 2005-06-23 22:02:14 -0700 | [diff] [blame] | 439 | pci_disable_device(pdev); |
| 440 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | printk(KERN_INFO "%s: Controller removed.\n", c->name); |
| 442 | |
Markus Lidel | f88e119 | 2005-06-23 22:02:14 -0700 | [diff] [blame] | 443 | put_device(c->device.parent); |
| 444 | put_device(&c->device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | }; |
| 446 | |
| 447 | /* PCI driver for I2O controller */ |
| 448 | static struct pci_driver i2o_pci_driver = { |
Markus Lidel | f88e119 | 2005-06-23 22:02:14 -0700 | [diff] [blame] | 449 | .name = "PCI_I2O", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | .id_table = i2o_pci_ids, |
| 451 | .probe = i2o_pci_probe, |
| 452 | .remove = __devexit_p(i2o_pci_remove), |
| 453 | }; |
| 454 | |
| 455 | /** |
| 456 | * i2o_pci_init - registers I2O PCI driver in PCI subsystem |
| 457 | * |
| 458 | * Returns > 0 on success or negative error code on failure. |
| 459 | */ |
| 460 | int __init i2o_pci_init(void) |
| 461 | { |
| 462 | return pci_register_driver(&i2o_pci_driver); |
| 463 | }; |
| 464 | |
| 465 | /** |
| 466 | * i2o_pci_exit - unregisters I2O PCI driver from PCI subsystem |
| 467 | */ |
| 468 | void __exit i2o_pci_exit(void) |
| 469 | { |
| 470 | pci_unregister_driver(&i2o_pci_driver); |
| 471 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | MODULE_DEVICE_TABLE(pci, i2o_pci_ids); |