Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/drivers/ide/setup-pci.c Version 1.10 2002/08/19 |
| 3 | * |
| 4 | * Copyright (c) 1998-2000 Andre Hedrick <andre@linux-ide.org> |
| 5 | * |
| 6 | * Copyright (c) 1995-1998 Mark Lord |
| 7 | * May be copied or modified under the terms of the GNU General Public License |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | */ |
| 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <linux/module.h> |
| 11 | #include <linux/types.h> |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/pci.h> |
| 14 | #include <linux/init.h> |
| 15 | #include <linux/timer.h> |
| 16 | #include <linux/mm.h> |
| 17 | #include <linux/interrupt.h> |
| 18 | #include <linux/ide.h> |
| 19 | #include <linux/dma-mapping.h> |
| 20 | |
| 21 | #include <asm/io.h> |
| 22 | #include <asm/irq.h> |
| 23 | |
| 24 | |
| 25 | /** |
| 26 | * ide_match_hwif - match a PCI IDE against an ide_hwif |
| 27 | * @io_base: I/O base of device |
| 28 | * @bootable: set if its bootable |
| 29 | * @name: name of device |
| 30 | * |
| 31 | * Match a PCI IDE port against an entry in ide_hwifs[], |
| 32 | * based on io_base port if possible. Return the matching hwif, |
| 33 | * or a new hwif. If we find an error (clashing, out of devices, etc) |
| 34 | * return NULL |
| 35 | * |
| 36 | * FIXME: we need to handle mmio matches here too |
| 37 | */ |
| 38 | |
| 39 | static ide_hwif_t *ide_match_hwif(unsigned long io_base, u8 bootable, const char *name) |
| 40 | { |
| 41 | int h; |
| 42 | ide_hwif_t *hwif; |
| 43 | |
| 44 | /* |
| 45 | * Look for a hwif with matching io_base specified using |
| 46 | * parameters to ide_setup(). |
| 47 | */ |
| 48 | for (h = 0; h < MAX_HWIFS; ++h) { |
| 49 | hwif = &ide_hwifs[h]; |
| 50 | if (hwif->io_ports[IDE_DATA_OFFSET] == io_base) { |
| 51 | if (hwif->chipset == ide_forced) |
| 52 | return hwif; /* a perfect match */ |
| 53 | } |
| 54 | } |
| 55 | /* |
| 56 | * Look for a hwif with matching io_base default value. |
| 57 | * If chipset is "ide_unknown", then claim that hwif slot. |
| 58 | * Otherwise, some other chipset has already claimed it.. :( |
| 59 | */ |
| 60 | for (h = 0; h < MAX_HWIFS; ++h) { |
| 61 | hwif = &ide_hwifs[h]; |
| 62 | if (hwif->io_ports[IDE_DATA_OFFSET] == io_base) { |
| 63 | if (hwif->chipset == ide_unknown) |
| 64 | return hwif; /* match */ |
| 65 | printk(KERN_ERR "%s: port 0x%04lx already claimed by %s\n", |
| 66 | name, io_base, hwif->name); |
| 67 | return NULL; /* already claimed */ |
| 68 | } |
| 69 | } |
| 70 | /* |
| 71 | * Okay, there is no hwif matching our io_base, |
| 72 | * so we'll just claim an unassigned slot. |
| 73 | * Give preference to claiming other slots before claiming ide0/ide1, |
| 74 | * just in case there's another interface yet-to-be-scanned |
| 75 | * which uses ports 1f0/170 (the ide0/ide1 defaults). |
| 76 | * |
| 77 | * Unless there is a bootable card that does not use the standard |
| 78 | * ports 1f0/170 (the ide0/ide1 defaults). The (bootable) flag. |
| 79 | */ |
| 80 | if (bootable) { |
| 81 | for (h = 0; h < MAX_HWIFS; ++h) { |
| 82 | hwif = &ide_hwifs[h]; |
| 83 | if (hwif->chipset == ide_unknown) |
| 84 | return hwif; /* pick an unused entry */ |
| 85 | } |
| 86 | } else { |
| 87 | for (h = 2; h < MAX_HWIFS; ++h) { |
| 88 | hwif = ide_hwifs + h; |
| 89 | if (hwif->chipset == ide_unknown) |
| 90 | return hwif; /* pick an unused entry */ |
| 91 | } |
| 92 | } |
Matt Mackall | 83d7dbc | 2006-10-03 01:14:16 -0700 | [diff] [blame] | 93 | for (h = 0; h < 2 && h < MAX_HWIFS; ++h) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | hwif = ide_hwifs + h; |
| 95 | if (hwif->chipset == ide_unknown) |
| 96 | return hwif; /* pick an unused entry */ |
| 97 | } |
| 98 | printk(KERN_ERR "%s: too many IDE interfaces, no room in table\n", name); |
| 99 | return NULL; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * ide_setup_pci_baseregs - place a PCI IDE controller native |
| 104 | * @dev: PCI device of interface to switch native |
| 105 | * @name: Name of interface |
| 106 | * |
| 107 | * We attempt to place the PCI interface into PCI native mode. If |
| 108 | * we succeed the BARs are ok and the controller is in PCI mode. |
| 109 | * Returns 0 on success or an errno code. |
| 110 | * |
| 111 | * FIXME: if we program the interface and then fail to set the BARS |
| 112 | * we don't switch it back to legacy mode. Do we actually care ?? |
| 113 | */ |
| 114 | |
| 115 | static int ide_setup_pci_baseregs (struct pci_dev *dev, const char *name) |
| 116 | { |
| 117 | u8 progif = 0; |
| 118 | |
| 119 | /* |
| 120 | * Place both IDE interfaces into PCI "native" mode: |
| 121 | */ |
| 122 | if (pci_read_config_byte(dev, PCI_CLASS_PROG, &progif) || |
| 123 | (progif & 5) != 5) { |
| 124 | if ((progif & 0xa) != 0xa) { |
| 125 | printk(KERN_INFO "%s: device not capable of full " |
| 126 | "native PCI mode\n", name); |
| 127 | return -EOPNOTSUPP; |
| 128 | } |
| 129 | printk("%s: placing both ports into native PCI mode\n", name); |
| 130 | (void) pci_write_config_byte(dev, PCI_CLASS_PROG, progif|5); |
| 131 | if (pci_read_config_byte(dev, PCI_CLASS_PROG, &progif) || |
| 132 | (progif & 5) != 5) { |
| 133 | printk(KERN_ERR "%s: rewrite of PROGIF failed, wanted " |
| 134 | "0x%04x, got 0x%04x\n", |
| 135 | name, progif|5, progif); |
| 136 | return -EOPNOTSUPP; |
| 137 | } |
| 138 | } |
| 139 | return 0; |
| 140 | } |
| 141 | |
| 142 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI |
Bartlomiej Zolnierkiewicz | 8ac2b42 | 2008-02-01 23:09:30 +0100 | [diff] [blame] | 143 | static void ide_pci_clear_simplex(unsigned long dma_base, const char *name) |
| 144 | { |
| 145 | u8 dma_stat = inb(dma_base + 2); |
| 146 | |
| 147 | outb(dma_stat & 0x60, dma_base + 2); |
| 148 | dma_stat = inb(dma_base + 2); |
| 149 | if (dma_stat & 0x80) |
| 150 | printk(KERN_INFO "%s: simplex device: DMA forced\n", name); |
| 151 | } |
| 152 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | /** |
| 154 | * ide_get_or_set_dma_base - setup BMIBA |
Bartlomiej Zolnierkiewicz | 039788e | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 155 | * @d: IDE port info |
| 156 | * @hwif: IDE interface |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | * |
Bartlomiej Zolnierkiewicz | c58e79d | 2007-10-16 22:29:56 +0200 | [diff] [blame] | 158 | * Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space. |
| 159 | * Where a device has a partner that is already in DMA mode we check |
| 160 | * and enforce IDE simplex rules. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | */ |
| 162 | |
Bartlomiej Zolnierkiewicz | 8562043 | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 163 | static unsigned long ide_get_or_set_dma_base(const struct ide_port_info *d, ide_hwif_t *hwif) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | { |
Bartlomiej Zolnierkiewicz | 3650165 | 2008-02-01 23:09:31 +0100 | [diff] [blame^] | 165 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
| 166 | unsigned long dma_base = 0; |
Bartlomiej Zolnierkiewicz | 8ac2b42 | 2008-02-01 23:09:30 +0100 | [diff] [blame] | 167 | u8 dma_stat = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | if (hwif->mmio) |
| 170 | return hwif->dma_base; |
| 171 | |
| 172 | if (hwif->mate && hwif->mate->dma_base) { |
| 173 | dma_base = hwif->mate->dma_base - (hwif->channel ? 0 : 8); |
| 174 | } else { |
Bartlomiej Zolnierkiewicz | 9ffcf36 | 2007-10-19 00:30:07 +0200 | [diff] [blame] | 175 | u8 baridx = (d->host_flags & IDE_HFLAG_CS5520) ? 2 : 4; |
| 176 | |
| 177 | dma_base = pci_resource_start(dev, baridx); |
| 178 | |
Bartlomiej Zolnierkiewicz | aea5d37 | 2008-01-26 20:12:59 +0100 | [diff] [blame] | 179 | if (dma_base == 0) { |
Bartlomiej Zolnierkiewicz | 9ffcf36 | 2007-10-19 00:30:07 +0200 | [diff] [blame] | 180 | printk(KERN_ERR "%s: DMA base is invalid\n", d->name); |
Bartlomiej Zolnierkiewicz | aea5d37 | 2008-01-26 20:12:59 +0100 | [diff] [blame] | 181 | return 0; |
| 182 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | } |
| 184 | |
Bartlomiej Zolnierkiewicz | aea5d37 | 2008-01-26 20:12:59 +0100 | [diff] [blame] | 185 | if (hwif->channel) |
| 186 | dma_base += 8; |
| 187 | |
Bartlomiej Zolnierkiewicz | 8ac2b42 | 2008-02-01 23:09:30 +0100 | [diff] [blame] | 188 | if (d->host_flags & IDE_HFLAG_CS5520) |
| 189 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | |
Bartlomiej Zolnierkiewicz | 8ac2b42 | 2008-02-01 23:09:30 +0100 | [diff] [blame] | 191 | if (d->host_flags & IDE_HFLAG_CLEAR_SIMPLEX) { |
| 192 | ide_pci_clear_simplex(dma_base, d->name); |
| 193 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | } |
Bartlomiej Zolnierkiewicz | 8ac2b42 | 2008-02-01 23:09:30 +0100 | [diff] [blame] | 195 | |
| 196 | /* |
| 197 | * If the device claims "simplex" DMA, this means that only one of |
| 198 | * the two interfaces can be trusted with DMA at any point in time |
| 199 | * (so we should enable DMA only on one of the two interfaces). |
| 200 | * |
| 201 | * FIXME: At this point we haven't probed the drives so we can't make |
| 202 | * the appropriate decision. Really we should defer this problem until |
| 203 | * we tune the drive then try to grab DMA ownership if we want to be |
| 204 | * the DMA end. This has to be become dynamic to handle hot-plug. |
| 205 | */ |
| 206 | dma_stat = hwif->INB(dma_base + 2); |
| 207 | if ((dma_stat & 0x80) && hwif->mate && hwif->mate->dma_base) { |
| 208 | printk(KERN_INFO "%s: simplex device: DMA disabled\n", d->name); |
| 209 | dma_base = 0; |
| 210 | } |
| 211 | out: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | return dma_base; |
| 213 | } |
| 214 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ |
| 215 | |
Bartlomiej Zolnierkiewicz | 8562043 | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 216 | void ide_setup_pci_noise(struct pci_dev *dev, const struct ide_port_info *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | { |
Bartlomiej Zolnierkiewicz | bde07e5 | 2007-10-20 00:32:36 +0200 | [diff] [blame] | 218 | printk(KERN_INFO "%s: IDE controller (0x%04x:0x%04x rev 0x%02x) at " |
| 219 | " PCI slot %s\n", d->name, dev->vendor, dev->device, |
| 220 | dev->revision, pci_name(dev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | EXPORT_SYMBOL_GPL(ide_setup_pci_noise); |
| 224 | |
| 225 | |
| 226 | /** |
| 227 | * ide_pci_enable - do PCI enables |
| 228 | * @dev: PCI device |
Bartlomiej Zolnierkiewicz | 039788e | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 229 | * @d: IDE port info |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | * |
| 231 | * Enable the IDE PCI device. We attempt to enable the device in full |
| 232 | * but if that fails then we only need BAR4 so we will enable that. |
| 233 | * |
| 234 | * Returns zero on success or an error code |
| 235 | */ |
Bartlomiej Zolnierkiewicz | 039788e | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 236 | |
Bartlomiej Zolnierkiewicz | 8562043 | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 237 | static int ide_pci_enable(struct pci_dev *dev, const struct ide_port_info *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | { |
| 239 | int ret; |
| 240 | |
| 241 | if (pci_enable_device(dev)) { |
| 242 | ret = pci_enable_device_bars(dev, 1 << 4); |
| 243 | if (ret < 0) { |
| 244 | printk(KERN_WARNING "%s: (ide_setup_pci_device:) " |
| 245 | "Could not enable device.\n", d->name); |
| 246 | goto out; |
| 247 | } |
| 248 | printk(KERN_WARNING "%s: BIOS configuration fixed.\n", d->name); |
| 249 | } |
| 250 | |
| 251 | /* |
Bartlomiej Zolnierkiewicz | 039788e | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 252 | * assume all devices can do 32-bit DMA for now, we can add |
| 253 | * a DMA mask field to the struct ide_port_info if we need it |
| 254 | * (or let lower level driver set the DMA mask) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | */ |
| 256 | ret = pci_set_dma_mask(dev, DMA_32BIT_MASK); |
| 257 | if (ret < 0) { |
| 258 | printk(KERN_ERR "%s: can't set dma mask\n", d->name); |
| 259 | goto out; |
| 260 | } |
| 261 | |
| 262 | /* FIXME: Temporary - until we put in the hotplug interface logic |
| 263 | Check that the bits we want are not in use by someone else. */ |
| 264 | ret = pci_request_region(dev, 4, "ide_tmp"); |
| 265 | if (ret < 0) |
| 266 | goto out; |
| 267 | |
| 268 | pci_release_region(dev, 4); |
| 269 | out: |
| 270 | return ret; |
| 271 | } |
| 272 | |
| 273 | /** |
| 274 | * ide_pci_configure - configure an unconfigured device |
| 275 | * @dev: PCI device |
Bartlomiej Zolnierkiewicz | 039788e | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 276 | * @d: IDE port info |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | * |
| 278 | * Enable and configure the PCI device we have been passed. |
| 279 | * Returns zero on success or an error code. |
| 280 | */ |
Bartlomiej Zolnierkiewicz | 039788e | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 281 | |
Bartlomiej Zolnierkiewicz | 8562043 | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 282 | static int ide_pci_configure(struct pci_dev *dev, const struct ide_port_info *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | { |
| 284 | u16 pcicmd = 0; |
| 285 | /* |
| 286 | * PnP BIOS was *supposed* to have setup this device, but we |
| 287 | * can do it ourselves, so long as the BIOS has assigned an IRQ |
| 288 | * (or possibly the device is using a "legacy header" for IRQs). |
| 289 | * Maybe the user deliberately *disabled* the device, |
| 290 | * but we'll eventually ignore it again if no drives respond. |
| 291 | */ |
| 292 | if (ide_setup_pci_baseregs(dev, d->name) || pci_write_config_word(dev, PCI_COMMAND, pcicmd|PCI_COMMAND_IO)) |
| 293 | { |
| 294 | printk(KERN_INFO "%s: device disabled (BIOS)\n", d->name); |
| 295 | return -ENODEV; |
| 296 | } |
| 297 | if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd)) { |
| 298 | printk(KERN_ERR "%s: error accessing PCI regs\n", d->name); |
| 299 | return -EIO; |
| 300 | } |
| 301 | if (!(pcicmd & PCI_COMMAND_IO)) { |
| 302 | printk(KERN_ERR "%s: unable to enable IDE controller\n", d->name); |
| 303 | return -ENXIO; |
| 304 | } |
| 305 | return 0; |
| 306 | } |
| 307 | |
| 308 | /** |
| 309 | * ide_pci_check_iomem - check a register is I/O |
Bartlomiej Zolnierkiewicz | 039788e | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 310 | * @dev: PCI device |
| 311 | * @d: IDE port info |
| 312 | * @bar: BAR number |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | * |
| 314 | * Checks if a BAR is configured and points to MMIO space. If so |
| 315 | * print an error and return an error code. Otherwise return 0 |
| 316 | */ |
Bartlomiej Zolnierkiewicz | 039788e | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 317 | |
Bartlomiej Zolnierkiewicz | 8562043 | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 318 | static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info *d, int bar) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | { |
| 320 | ulong flags = pci_resource_flags(dev, bar); |
| 321 | |
| 322 | /* Unconfigured ? */ |
| 323 | if (!flags || pci_resource_len(dev, bar) == 0) |
| 324 | return 0; |
| 325 | |
| 326 | /* I/O space */ |
| 327 | if(flags & PCI_BASE_ADDRESS_IO_MASK) |
| 328 | return 0; |
| 329 | |
| 330 | /* Bad */ |
| 331 | printk(KERN_ERR "%s: IO baseregs (BIOS) are reported " |
| 332 | "as MEM, report to " |
| 333 | "<andre@linux-ide.org>.\n", d->name); |
| 334 | return -EINVAL; |
| 335 | } |
| 336 | |
| 337 | /** |
| 338 | * ide_hwif_configure - configure an IDE interface |
| 339 | * @dev: PCI device holding interface |
Bartlomiej Zolnierkiewicz | 039788e | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 340 | * @d: IDE port info |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | * @mate: Paired interface if any |
| 342 | * |
| 343 | * Perform the initial set up for the hardware interface structure. This |
| 344 | * is done per interface port rather than per PCI device. There may be |
| 345 | * more than one port per device. |
| 346 | * |
| 347 | * Returns the new hardware interface structure, or NULL on a failure |
| 348 | */ |
Bartlomiej Zolnierkiewicz | 039788e | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 349 | |
Bartlomiej Zolnierkiewicz | 8562043 | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 350 | static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, const struct ide_port_info *d, ide_hwif_t *mate, int port, int irq) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | { |
| 352 | unsigned long ctl = 0, base = 0; |
| 353 | ide_hwif_t *hwif; |
Bartlomiej Zolnierkiewicz | 7cab14a | 2007-10-19 00:30:06 +0200 | [diff] [blame] | 354 | u8 bootable = (d->host_flags & IDE_HFLAG_BOOTABLE) ? 1 : 0; |
Bartlomiej Zolnierkiewicz | 79127c3 | 2008-01-26 20:13:08 +0100 | [diff] [blame] | 355 | u8 oldnoprobe = 0; |
| 356 | struct hw_regs_s hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | |
Bartlomiej Zolnierkiewicz | a5d8c5c | 2007-07-20 01:11:55 +0200 | [diff] [blame] | 358 | if ((d->host_flags & IDE_HFLAG_ISA_PORTS) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | /* Possibly we should fail if these checks report true */ |
| 360 | ide_pci_check_iomem(dev, d, 2*port); |
| 361 | ide_pci_check_iomem(dev, d, 2*port+1); |
| 362 | |
| 363 | ctl = pci_resource_start(dev, 2*port+1); |
| 364 | base = pci_resource_start(dev, 2*port); |
| 365 | if ((ctl && !base) || (base && !ctl)) { |
| 366 | printk(KERN_ERR "%s: inconsistent baseregs (BIOS) " |
| 367 | "for port %d, skipping\n", d->name, port); |
| 368 | return NULL; |
| 369 | } |
| 370 | } |
| 371 | if (!ctl) |
| 372 | { |
| 373 | /* Use default values */ |
| 374 | ctl = port ? 0x374 : 0x3f4; |
| 375 | base = port ? 0x170 : 0x1f0; |
| 376 | } |
Bartlomiej Zolnierkiewicz | 7cab14a | 2007-10-19 00:30:06 +0200 | [diff] [blame] | 377 | if ((hwif = ide_match_hwif(base, bootable, d->name)) == NULL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | return NULL; /* no room in ide_hwifs[] */ |
Bartlomiej Zolnierkiewicz | 9239b33 | 2007-10-20 00:32:33 +0200 | [diff] [blame] | 379 | |
Bartlomiej Zolnierkiewicz | 79127c3 | 2008-01-26 20:13:08 +0100 | [diff] [blame] | 380 | memset(&hw, 0, sizeof(hw)); |
| 381 | hw.irq = hwif->irq ? hwif->irq : irq; |
| 382 | hw.dev = &dev->dev; |
| 383 | hw.chipset = d->chipset ? d->chipset : ide_pci; |
| 384 | ide_std_init_ports(&hw, base, ctl | 2); |
| 385 | |
| 386 | if (hwif->io_ports[IDE_DATA_OFFSET] == base && |
| 387 | hwif->io_ports[IDE_CONTROL_OFFSET] == (ctl | 2)) |
| 388 | oldnoprobe = hwif->noprobe; |
| 389 | |
| 390 | ide_init_port_hw(hwif, &hw); |
| 391 | |
| 392 | hwif->noprobe = oldnoprobe; |
| 393 | |
Bartlomiej Zolnierkiewicz | 3650165 | 2008-02-01 23:09:31 +0100 | [diff] [blame^] | 394 | hwif->dev = &dev->dev; |
Bartlomiej Zolnierkiewicz | 039788e | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 395 | hwif->cds = d; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | hwif->channel = port; |
| 397 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | if (mate) { |
| 399 | hwif->mate = mate; |
| 400 | mate->mate = hwif; |
| 401 | } |
| 402 | return hwif; |
| 403 | } |
| 404 | |
| 405 | /** |
| 406 | * ide_hwif_setup_dma - configure DMA interface |
| 407 | * @dev: PCI device |
Bartlomiej Zolnierkiewicz | 039788e | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 408 | * @d: IDE port info |
| 409 | * @hwif: IDE interface |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | * |
| 411 | * Set up the DMA base for the interface. Enable the master bits as |
| 412 | * necessary and attempt to bring the device DMA into a ready to use |
| 413 | * state |
| 414 | */ |
Bartlomiej Zolnierkiewicz | 039788e | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 415 | |
Bartlomiej Zolnierkiewicz | 8562043 | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 416 | static void ide_hwif_setup_dma(struct pci_dev *dev, const struct ide_port_info *d, ide_hwif_t *hwif) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | { |
Bartlomiej Zolnierkiewicz | 039788e | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 418 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | u16 pcicmd; |
Bartlomiej Zolnierkiewicz | 47b6878 | 2007-10-19 00:30:06 +0200 | [diff] [blame] | 420 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | pci_read_config_word(dev, PCI_COMMAND, &pcicmd); |
| 422 | |
Bartlomiej Zolnierkiewicz | 47b6878 | 2007-10-19 00:30:06 +0200 | [diff] [blame] | 423 | if ((d->host_flags & IDE_HFLAG_NO_AUTODMA) == 0 || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && |
| 425 | (dev->class & 0x80))) { |
Bartlomiej Zolnierkiewicz | 9ffcf36 | 2007-10-19 00:30:07 +0200 | [diff] [blame] | 426 | unsigned long dma_base = ide_get_or_set_dma_base(d, hwif); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | if (dma_base && !(pcicmd & PCI_COMMAND_MASTER)) { |
| 428 | /* |
| 429 | * Set up BM-DMA capability |
| 430 | * (PnP BIOS should have done this) |
| 431 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | pci_set_master(dev); |
| 433 | if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd) || !(pcicmd & PCI_COMMAND_MASTER)) { |
| 434 | printk(KERN_ERR "%s: %s error updating PCICMD\n", |
| 435 | hwif->name, d->name); |
| 436 | dma_base = 0; |
| 437 | } |
| 438 | } |
| 439 | if (dma_base) { |
| 440 | if (d->init_dma) { |
| 441 | d->init_dma(hwif, dma_base); |
| 442 | } else { |
Sergei Shtylyov | ecf32796 | 2008-02-01 23:09:30 +0100 | [diff] [blame] | 443 | ide_setup_dma(hwif, dma_base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 444 | } |
| 445 | } else { |
| 446 | printk(KERN_INFO "%s: %s Bus-Master DMA disabled " |
| 447 | "(BIOS)\n", hwif->name, d->name); |
| 448 | } |
| 449 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI*/ |
Bartlomiej Zolnierkiewicz | 039788e | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 451 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | |
| 453 | /** |
| 454 | * ide_setup_pci_controller - set up IDE PCI |
| 455 | * @dev: PCI device |
Bartlomiej Zolnierkiewicz | 039788e | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 456 | * @d: IDE port info |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | * @noisy: verbose flag |
| 458 | * @config: returned as 1 if we configured the hardware |
| 459 | * |
| 460 | * Set up the PCI and controller side of the IDE interface. This brings |
| 461 | * up the PCI side of the device, checks that the device is enabled |
| 462 | * and enables it if need be |
| 463 | */ |
Bartlomiej Zolnierkiewicz | 039788e | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 464 | |
Bartlomiej Zolnierkiewicz | 8562043 | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 465 | static int ide_setup_pci_controller(struct pci_dev *dev, const struct ide_port_info *d, int noisy, int *config) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | { |
| 467 | int ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | u16 pcicmd; |
| 469 | |
| 470 | if (noisy) |
| 471 | ide_setup_pci_noise(dev, d); |
| 472 | |
| 473 | ret = ide_pci_enable(dev, d); |
| 474 | if (ret < 0) |
| 475 | goto out; |
| 476 | |
| 477 | ret = pci_read_config_word(dev, PCI_COMMAND, &pcicmd); |
| 478 | if (ret < 0) { |
| 479 | printk(KERN_ERR "%s: error accessing PCI regs\n", d->name); |
| 480 | goto out; |
| 481 | } |
| 482 | if (!(pcicmd & PCI_COMMAND_IO)) { /* is device disabled? */ |
| 483 | ret = ide_pci_configure(dev, d); |
| 484 | if (ret < 0) |
| 485 | goto out; |
| 486 | *config = 1; |
| 487 | printk(KERN_INFO "%s: device enabled (Linux)\n", d->name); |
| 488 | } |
| 489 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | out: |
| 491 | return ret; |
| 492 | } |
| 493 | |
| 494 | /** |
| 495 | * ide_pci_setup_ports - configure ports/devices on PCI IDE |
| 496 | * @dev: PCI device |
Bartlomiej Zolnierkiewicz | 039788e | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 497 | * @d: IDE port info |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | * @pciirq: IRQ line |
Bartlomiej Zolnierkiewicz | 8447d9d | 2007-10-20 00:32:31 +0200 | [diff] [blame] | 499 | * @idx: ATA index table to update |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | * |
| 501 | * Scan the interfaces attached to this device and do any |
| 502 | * necessary per port setup. Attach the devices and ask the |
| 503 | * generic DMA layer to do its work for us. |
| 504 | * |
| 505 | * Normally called automaticall from do_ide_pci_setup_device, |
| 506 | * but is also used directly as a helper function by some controllers |
| 507 | * where the chipset setup is not the default PCI IDE one. |
| 508 | */ |
Bartlomiej Zolnierkiewicz | 8447d9d | 2007-10-20 00:32:31 +0200 | [diff] [blame] | 509 | |
Bartlomiej Zolnierkiewicz | 8562043 | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 510 | void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, int pciirq, u8 *idx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | { |
Bartlomiej Zolnierkiewicz | a5d8c5c | 2007-07-20 01:11:55 +0200 | [diff] [blame] | 512 | int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | ide_hwif_t *hwif, *mate = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 | u8 tmp; |
| 515 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | /* |
| 517 | * Set up the IDE ports |
| 518 | */ |
Bartlomiej Zolnierkiewicz | cf6e854 | 2007-10-20 00:32:29 +0200 | [diff] [blame] | 519 | |
Bartlomiej Zolnierkiewicz | a5d8c5c | 2007-07-20 01:11:55 +0200 | [diff] [blame] | 520 | for (port = 0; port < channels; ++port) { |
Bartlomiej Zolnierkiewicz | 8562043 | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 521 | const ide_pci_enablebit_t *e = &(d->enablebits[port]); |
| 522 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | if (e->reg && (pci_read_config_byte(dev, e->reg, &tmp) || |
Bartlomiej Zolnierkiewicz | cf6e854 | 2007-10-20 00:32:29 +0200 | [diff] [blame] | 524 | (tmp & e->mask) != e->val)) { |
| 525 | printk(KERN_INFO "%s: IDE port disabled\n", d->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | continue; /* port not enabled */ |
Bartlomiej Zolnierkiewicz | cf6e854 | 2007-10-20 00:32:29 +0200 | [diff] [blame] | 527 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | if ((hwif = ide_hwif_configure(dev, d, mate, port, pciirq)) == NULL) |
| 530 | continue; |
| 531 | |
Bartlomiej Zolnierkiewicz | 8447d9d | 2007-10-20 00:32:31 +0200 | [diff] [blame] | 532 | *(idx + port) = hwif->index; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | if (d->init_iops) |
| 535 | d->init_iops(hwif); |
| 536 | |
Bartlomiej Zolnierkiewicz | 9ffcf36 | 2007-10-19 00:30:07 +0200 | [diff] [blame] | 537 | if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | ide_hwif_setup_dma(dev, d, hwif); |
Bartlomiej Zolnierkiewicz | 9ffcf36 | 2007-10-19 00:30:07 +0200 | [diff] [blame] | 539 | |
Bartlomiej Zolnierkiewicz | 8acf28c | 2007-10-20 00:32:30 +0200 | [diff] [blame] | 540 | if ((!hwif->irq && (d->host_flags & IDE_HFLAG_LEGACY_IRQS)) || |
| 541 | (d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS)) |
Bartlomiej Zolnierkiewicz | 3985ee3 | 2007-10-19 00:30:11 +0200 | [diff] [blame] | 542 | hwif->irq = port ? 15 : 14; |
| 543 | |
Bartlomiej Zolnierkiewicz | 6a824c9 | 2007-07-20 01:11:58 +0200 | [diff] [blame] | 544 | hwif->host_flags = d->host_flags; |
Bartlomiej Zolnierkiewicz | 4099d14 | 2007-07-20 01:11:59 +0200 | [diff] [blame] | 545 | hwif->pio_mask = d->pio_mask; |
Bartlomiej Zolnierkiewicz | 6a824c9 | 2007-07-20 01:11:58 +0200 | [diff] [blame] | 546 | |
Bartlomiej Zolnierkiewicz | 1c51361 | 2007-10-19 00:30:10 +0200 | [diff] [blame] | 547 | if ((d->host_flags & IDE_HFLAG_SERIALIZE) && hwif->mate) |
| 548 | hwif->mate->serialized = hwif->serialized = 1; |
| 549 | |
Bartlomiej Zolnierkiewicz | caea760 | 2007-10-20 00:32:30 +0200 | [diff] [blame] | 550 | if (d->host_flags & IDE_HFLAG_IO_32BIT) { |
| 551 | hwif->drives[0].io_32bit = 1; |
| 552 | hwif->drives[1].io_32bit = 1; |
| 553 | } |
| 554 | |
| 555 | if (d->host_flags & IDE_HFLAG_UNMASK_IRQS) { |
| 556 | hwif->drives[0].unmask = 1; |
| 557 | hwif->drives[1].unmask = 1; |
| 558 | } |
| 559 | |
Bartlomiej Zolnierkiewicz | 5f8b6c3 | 2007-10-19 00:30:07 +0200 | [diff] [blame] | 560 | if (hwif->dma_base) { |
| 561 | hwif->swdma_mask = d->swdma_mask; |
| 562 | hwif->mwdma_mask = d->mwdma_mask; |
| 563 | hwif->ultra_mask = d->udma_mask; |
| 564 | } |
| 565 | |
Bartlomiej Zolnierkiewicz | 85ad93a | 2007-10-19 00:30:12 +0200 | [diff] [blame] | 566 | hwif->drives[0].autotune = 1; |
| 567 | hwif->drives[1].autotune = 1; |
| 568 | |
Bartlomiej Zolnierkiewicz | 272a370 | 2007-10-20 00:32:30 +0200 | [diff] [blame] | 569 | if (d->host_flags & IDE_HFLAG_RQSIZE_256) |
| 570 | hwif->rqsize = 256; |
| 571 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 572 | if (d->init_hwif) |
| 573 | /* Call chipset-specific routine |
| 574 | * for each enabled hwif |
| 575 | */ |
| 576 | d->init_hwif(hwif); |
| 577 | |
| 578 | mate = hwif; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 580 | } |
| 581 | |
| 582 | EXPORT_SYMBOL_GPL(ide_pci_setup_ports); |
| 583 | |
| 584 | /* |
| 585 | * ide_setup_pci_device() looks at the primary/secondary interfaces |
| 586 | * on a PCI IDE device and, if they are enabled, prepares the IDE driver |
| 587 | * for use with them. This generic code works for most PCI chipsets. |
| 588 | * |
| 589 | * One thing that is not standardized is the location of the |
| 590 | * primary/secondary interface "enable/disable" bits. For chipsets that |
Bartlomiej Zolnierkiewicz | 039788e | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 591 | * we "know" about, this information is in the struct ide_port_info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | * for all other chipsets, we just assume both interfaces are enabled. |
| 593 | */ |
Bartlomiej Zolnierkiewicz | 039788e | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 594 | static int do_ide_setup_pci_device(struct pci_dev *dev, |
Bartlomiej Zolnierkiewicz | 8562043 | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 595 | const struct ide_port_info *d, |
Bartlomiej Zolnierkiewicz | 8447d9d | 2007-10-20 00:32:31 +0200 | [diff] [blame] | 596 | u8 *idx, u8 noisy) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | int tried_config = 0; |
| 599 | int pciirq, ret; |
| 600 | |
| 601 | ret = ide_setup_pci_controller(dev, d, noisy, &tried_config); |
| 602 | if (ret < 0) |
| 603 | goto out; |
| 604 | |
| 605 | /* |
| 606 | * Can we trust the reported IRQ? |
| 607 | */ |
| 608 | pciirq = dev->irq; |
| 609 | |
| 610 | /* Is it an "IDE storage" device in non-PCI mode? */ |
| 611 | if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && (dev->class & 5) != 5) { |
| 612 | if (noisy) |
| 613 | printk(KERN_INFO "%s: not 100%% native mode: " |
| 614 | "will probe irqs later\n", d->name); |
| 615 | /* |
| 616 | * This allows offboard ide-pci cards the enable a BIOS, |
| 617 | * verify interrupt settings of split-mirror pci-config |
| 618 | * space, place chipset into init-mode, and/or preserve |
| 619 | * an interrupt if the card is not native ide support. |
| 620 | */ |
| 621 | ret = d->init_chipset ? d->init_chipset(dev, d->name) : 0; |
| 622 | if (ret < 0) |
| 623 | goto out; |
| 624 | pciirq = ret; |
| 625 | } else if (tried_config) { |
| 626 | if (noisy) |
| 627 | printk(KERN_INFO "%s: will probe irqs later\n", d->name); |
| 628 | pciirq = 0; |
| 629 | } else if (!pciirq) { |
| 630 | if (noisy) |
| 631 | printk(KERN_WARNING "%s: bad irq (%d): will probe later\n", |
| 632 | d->name, pciirq); |
| 633 | pciirq = 0; |
| 634 | } else { |
| 635 | if (d->init_chipset) { |
| 636 | ret = d->init_chipset(dev, d->name); |
| 637 | if (ret < 0) |
| 638 | goto out; |
| 639 | } |
| 640 | if (noisy) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | printk(KERN_INFO "%s: 100%% native mode on irq %d\n", |
| 642 | d->name, pciirq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | } |
| 644 | |
| 645 | /* FIXME: silent failure can happen */ |
| 646 | |
Bartlomiej Zolnierkiewicz | 8447d9d | 2007-10-20 00:32:31 +0200 | [diff] [blame] | 647 | ide_pci_setup_ports(dev, d, pciirq, idx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 648 | out: |
| 649 | return ret; |
| 650 | } |
| 651 | |
Bartlomiej Zolnierkiewicz | 8562043 | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 652 | int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | { |
Bartlomiej Zolnierkiewicz | 8447d9d | 2007-10-20 00:32:31 +0200 | [diff] [blame] | 654 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | int ret; |
| 656 | |
Bartlomiej Zolnierkiewicz | 8447d9d | 2007-10-20 00:32:31 +0200 | [diff] [blame] | 657 | ret = do_ide_setup_pci_device(dev, d, &idx[0], 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | |
Bartlomiej Zolnierkiewicz | 8447d9d | 2007-10-20 00:32:31 +0200 | [diff] [blame] | 659 | if (ret >= 0) |
| 660 | ide_device_add(idx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 661 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | return ret; |
| 663 | } |
| 664 | |
| 665 | EXPORT_SYMBOL_GPL(ide_setup_pci_device); |
| 666 | |
| 667 | int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2, |
Bartlomiej Zolnierkiewicz | 8562043 | 2007-10-20 00:32:34 +0200 | [diff] [blame] | 668 | const struct ide_port_info *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 669 | { |
| 670 | struct pci_dev *pdev[] = { dev1, dev2 }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | int ret, i; |
Bartlomiej Zolnierkiewicz | 8447d9d | 2007-10-20 00:32:31 +0200 | [diff] [blame] | 672 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | |
| 674 | for (i = 0; i < 2; i++) { |
Bartlomiej Zolnierkiewicz | 8447d9d | 2007-10-20 00:32:31 +0200 | [diff] [blame] | 675 | ret = do_ide_setup_pci_device(pdev[i], d, &idx[i*2], !i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | /* |
| 677 | * FIXME: Mom, mom, they stole me the helper function to undo |
| 678 | * do_ide_setup_pci_device() on the first device! |
| 679 | */ |
| 680 | if (ret < 0) |
| 681 | goto out; |
| 682 | } |
| 683 | |
Bartlomiej Zolnierkiewicz | 8447d9d | 2007-10-20 00:32:31 +0200 | [diff] [blame] | 684 | ide_device_add(idx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | out: |
| 686 | return ret; |
| 687 | } |
| 688 | |
| 689 | EXPORT_SYMBOL_GPL(ide_setup_pci_devices); |