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