| Start/ | End/ | |||
| True | False | - | Line | Source |
| 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 | |||
| 8 | * | |||
| 9 | * Recent Changes | |||
| 10 | * Split the set up function into multiple functions | |||
| 11 | * Use pci_set_master | |||
| 12 | * Fix misreporting of I/O v MMIO problems | |||
| 13 | * Initial fixups for simplex devices | |||
| 14 | */ | |||
| 15 | ||||
| 16 | /* | |||
| 17 | * This module provides support for automatic detection and | |||
| 18 | * configuration of all PCI IDE interfaces present in a system. | |||
| 19 | */ | |||
| 20 | ||||
| 21 | #include <linux/config.h> | |||
| 22 | #include <linux/module.h> | |||
| 23 | #include <linux/types.h> | |||
| 24 | #include <linux/kernel.h> | |||
| 25 | #include <linux/pci.h> | |||
| 26 | #include <linux/init.h> | |||
| 27 | #include <linux/timer.h> | |||
| 28 | #include <linux/mm.h> | |||
| 29 | #include <linux/interrupt.h> | |||
| 30 | #include <linux/ide.h> | |||
| 31 | #include <linux/dma-mapping.h> | |||
| 32 | ||||
| 33 | #include <asm/io.h> | |||
| 34 | #include <asm/irq.h> | |||
| 35 | ||||
| 36 | ||||
| 37 | /** | |||
| 38 | * ide_match_hwif - match a PCI IDE against an ide_hwif | |||
| 39 | * @io_base: I/O base of device | |||
| 40 | * @bootable: set if its bootable | |||
| 41 | * @name: name of device | |||
| 42 | * | |||
| 43 | * Match a PCI IDE port against an entry in ide_hwifs[], | |||
| 44 | * based on io_base port if possible. Return the matching hwif, | |||
| 45 | * or a new hwif. If we find an error (clashing, out of devices, etc) | |||
| 46 | * return NULL | |||
| 47 | * | |||
| 48 | * FIXME: we need to handle mmio matches here too | |||
| 49 | */ | |||
| 50 | ||||
| 12 | 0 | 51 | static ide_hwif_t *ide_match_hwif(unsigned long io_base, u8 bootable, const char *name) | |
| 52 | { | |||
| 53 | int h; | |||
| 54 | ide_hwif_t *hwif; | |||
| 55 | ||||
| 56 | /* | |||
| 57 | * Look for a hwif with matching io_base specified using | |||
| 58 | * parameters to ide_setup(). | |||
| 59 | */ | |||
| 120 | 12 | 60 | for (h = 0; h < MAX_HWIFS; ++h) { | |
| 61 | hwif = &ide_hwifs[h]; | |||
| 12 | 108 | 62 | if (hwif->io_ports[IDE_DATA_OFFSET] == io_base) { | |
| 0 | 12 | - | 63 | if (hwif->chipset == ide_forced) |
| 0 | - | 64 | return hwif; /* a perfect match */ | |
| 65 | } | |||
| 66 | } | |||
| 67 | /* | |||
| 68 | * Look for a hwif with matching io_base default value. | |||
| 69 | * If chipset is "ide_unknown", then claim that hwif slot. | |||
| 70 | * Otherwise, some other chipset has already claimed it.. :( | |||
| 71 | */ | |||
| 18 | 0 | - | 72 | for (h = 0; h < MAX_HWIFS; ++h) { |
| 73 | hwif = &ide_hwifs[h]; | |||
| 12 | 6 | 74 | if (hwif->io_ports[IDE_DATA_OFFSET] == io_base) { | |
| 12 | 0 | - | 75 | if (hwif->chipset == ide_unknown) |
| 12 | 76 | return hwif; /* match */ | ||
| 77 | printk(KERN_ERR "%s: port 0x%04lx already claimed by %s\n", | |||
| 78 | name, io_base, hwif->name); | |||
| 0 | - | 79 | return NULL; /* already claimed */ | |
| 80 | } | |||
| 81 | } | |||
| 82 | /* | |||
| 83 | * Okay, there is no hwif matching our io_base, | |||
| 84 | * so we'll just claim an unassigned slot. | |||
| 85 | * Give preference to claiming other slots before claiming ide0/ide1, | |||
| 86 | * just in case there's another interface yet-to-be-scanned | |||
| 87 | * which uses ports 1f0/170 (the ide0/ide1 defaults). | |||
| 88 | * | |||
| 89 | * Unless there is a bootable card that does not use the standard | |||
| 90 | * ports 1f0/170 (the ide0/ide1 defaults). The (bootable) flag. | |||
| 91 | */ | |||
| 0 | 0 | - | 92 | if (bootable) { |
| 0 | 0 | - | 93 | for (h = 0; h < MAX_HWIFS; ++h) { |
| 94 | hwif = &ide_hwifs[h]; | |||
| 0 | 0 | - | 95 | if (hwif->chipset == ide_unknown) |
| 0 | - | 96 | return hwif; /* pick an unused entry */ | |
| 97 | } | |||
| 98 | } else { | |||
| 0 | 0 | - | 99 | for (h = 2; h < MAX_HWIFS; ++h) { |
| 100 | hwif = ide_hwifs + h; | |||
| 0 | 0 | - | 101 | if (hwif->chipset == ide_unknown) |
| 0 | - | 102 | return hwif; /* pick an unused entry */ | |
| 103 | } | |||
| 104 | } | |||
| 0 | 0 | - | 105 | for (h = 0; h < 2; ++h) { |
| 106 | hwif = ide_hwifs + h; | |||
| 0 | 0 | - | 107 | if (hwif->chipset == ide_unknown) |
| 0 | - | 108 | return hwif; /* pick an unused entry */ | |
| 109 | } | |||
| 110 | printk(KERN_ERR "%s: too many IDE interfaces, no room in table\n", name); | |||
| 0 | - | 111 | return NULL; | |
| 112 | } | |||
| 113 | ||||
| 114 | /** | |||
| 115 | * ide_setup_pci_baseregs - place a PCI IDE controller native | |||
| 116 | * @dev: PCI device of interface to switch native | |||
| 117 | * @name: Name of interface | |||
| 118 | * | |||
| 119 | * We attempt to place the PCI interface into PCI native mode. If | |||
| 120 | * we succeed the BARs are ok and the controller is in PCI mode. | |||
| 121 | * Returns 0 on success or an errno code. | |||
| 122 | * | |||
| 123 | * FIXME: if we program the interface and then fail to set the BARS | |||
| 124 | * we don't switch it back to legacy mode. Do we actually care ?? | |||
| 125 | */ | |||
| 126 | ||||
| 0 | 0 | - | 127 | static int ide_setup_pci_baseregs (struct pci_dev *dev, const char *name) |
| 128 | { | |||
| 129 | u8 progif = 0; | |||
| 130 | ||||
| 131 | /* | |||
| 132 | * Place both IDE interfaces into PCI "native" mode: | |||
| 133 | */ | |||
| 134 | if (pci_read_config_byte(dev, PCI_CLASS_PROG, &progif) || | |||
| 0 | 0 | - | 135 | (progif & 5) != 5) { |
| 0 | - | 135 | T || _ | |
| 0 | - | 135 | F || T | |
| 0 | - | 135 | F || F | |
| 0 | 0 | - | 136 | if ((progif & 0xa) != 0xa) { |
| 137 | printk(KERN_INFO "%s: device not capable of full " | |||
| 138 | "native PCI mode\n", name); | |||
| 0 | - | 139 | return -EOPNOTSUPP; | |
| 140 | } | |||
| 141 | printk("%s: placing both ports into native PCI mode\n", name); | |||
| 142 | (void) pci_write_config_byte(dev, PCI_CLASS_PROG, progif|5); | |||
| 143 | if (pci_read_config_byte(dev, PCI_CLASS_PROG, &progif) || | |||
| 0 | 0 | - | 144 | (progif & 5) != 5) { |
| 0 | - | 144 | T || _ | |
| 0 | - | 144 | F || T | |
| 0 | - | 144 | F || F | |
| 145 | printk(KERN_ERR "%s: rewrite of PROGIF failed, wanted " | |||
| 146 | "0x%04x, got 0x%04x\n", | |||
| 147 | name, progif|5, progif); | |||
| 0 | - | 148 | return -EOPNOTSUPP; | |
| 149 | } | |||
| 150 | } | |||
| 0 | - | 151 | return 0; | |
| 152 | } | |||
| 153 | ||||
| 154 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | |||
| 155 | ||||
| 156 | #ifdef CONFIG_BLK_DEV_IDEDMA_FORCED | |||
| 157 | /* | |||
| 158 | * Long lost data from 2.0.34 that is now in 2.0.39 | |||
| 159 | * | |||
| 160 | * This was used in ./drivers/block/triton.c to do DMA Base address setup | |||
| 161 | * when PnP failed. Oh the things we forget. I believe this was part | |||
| 162 | * of SFF-8038i that has been withdrawn from public access... :-(( | |||
| 163 | */ | |||
| 164 | #define DEFAULT_BMIBA 0xe800 /* in case BIOS did not init it */ | |||
| 165 | #define DEFAULT_BMCRBA 0xcc00 /* VIA's default value */ | |||
| 166 | #define DEFAULT_BMALIBA 0xd400 /* ALI's default value */ | |||
| 167 | #endif /* CONFIG_BLK_DEV_IDEDMA_FORCED */ | |||
| 168 | ||||
| 169 | /** | |||
| 170 | * ide_get_or_set_dma_base - setup BMIBA | |||
| 171 | * @hwif: Interface | |||
| 172 | * | |||
| 173 | * Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space: | |||
| 174 | * If need be we set up the DMA base. Where a device has a partner that | |||
| 175 | * is already in DMA mode we check and enforce IDE simplex rules. | |||
| 176 | */ | |||
| 177 | ||||
| 12 | 0 | 178 | static unsigned long ide_get_or_set_dma_base (ide_hwif_t *hwif) | |
| 179 | { | |||
| 180 | unsigned long dma_base = 0; | |||
| 181 | struct pci_dev *dev = hwif->pci_dev; | |||
| 182 | ||||
| 183 | #ifdef CONFIG_BLK_DEV_IDEDMA_FORCED | |||
| 184 | int second_chance = 0; | |||
| 185 | ||||
| 186 | second_chance_to_dma: | |||
| 187 | #endif /* CONFIG_BLK_DEV_IDEDMA_FORCED */ | |||
| 188 | ||||
| 0 | 12 | - | 189 | if (hwif->mmio) |
| 0 | - | 190 | return hwif->dma_base; | |
| 191 | ||||
| 6 | 6 | 192 | if (hwif->mate && hwif->mate->dma_base) { | |
| 6 | 192 | T && T | ||
| 0 | - | 192 | T && F | |
| 6 | 192 | F && _ | ||
| 193 | dma_base = hwif->mate->dma_base - (hwif->channel ? 0 : 8); | |||
| 6 | 0 | - | 193 | ternary-?: hwif -> channel |
| 194 | } else { | |||
| 195 | dma_base = pci_resource_start(dev, 4); | |||
| 0 | 6 | - | 196 | if (!dma_base) { |
| 197 | printk(KERN_ERR "%s: dma_base is invalid\n", | |||
| 198 | hwif->cds->name); | |||
| 199 | } | |||
| 200 | } | |||
| 201 | ||||
| 202 | #ifdef CONFIG_BLK_DEV_IDEDMA_FORCED | |||
| 203 | /* FIXME - should use pci_assign_resource surely */ | |||
| 204 | if ((!dma_base) && (!second_chance)) { | |||
| 205 | unsigned long set_bmiba = 0; | |||
| 206 | second_chance++; | |||
| 207 | switch(dev->vendor) { | |||
| 208 | case PCI_VENDOR_ID_AL: | |||
| 209 | set_bmiba = DEFAULT_BMALIBA; break; | |||
| 210 | case PCI_VENDOR_ID_VIA: | |||
| 211 | set_bmiba = DEFAULT_BMCRBA; break; | |||
| 212 | case PCI_VENDOR_ID_INTEL: | |||
| 213 | set_bmiba = DEFAULT_BMIBA; break; | |||
| 214 | default: | |||
| 215 | return dma_base; | |||
| 216 | } | |||
| 217 | pci_write_config_dword(dev, 0x20, set_bmiba|1); | |||
| 218 | goto second_chance_to_dma; | |||
| 219 | } | |||
| 220 | #endif /* CONFIG_BLK_DEV_IDEDMA_FORCED */ | |||
| 221 | ||||
| 12 | 0 | - | 222 | if (dma_base) { |
| 223 | u8 simplex_stat = 0; | |||
| 224 | dma_base += hwif->channel ? 8 : 0; | |||
| 6 | 6 | 224 | ternary-?: hwif -> channel | |
| 225 | ||||
| 226 | switch(dev->device) { | |||
| 0 | - | 227 | case PCI_DEVICE_ID_AL_M5219: | |
| 0 | - | 228 | case PCI_DEVICE_ID_AL_M5229: | |
| 0 | - | 229 | case PCI_DEVICE_ID_AMD_VIPER_7409: | |
| 0 | - | 230 | case PCI_DEVICE_ID_CMD_643: | |
| 0 | - | 231 | case PCI_DEVICE_ID_SERVERWORKS_CSB5IDE: | |
| 0 | - | 232 | case PCI_DEVICE_ID_REVOLUTION: | |
| 233 | simplex_stat = hwif->INB(dma_base + 2); | |||
| 234 | hwif->OUTB((simplex_stat&0x60),(dma_base + 2)); | |||
| 235 | simplex_stat = hwif->INB(dma_base + 2); | |||
| 0 | 0 | - | 236 | if (simplex_stat & 0x80) { |
| 237 | printk(KERN_INFO "%s: simplex device: " | |||
| 238 | "DMA forced\n", | |||
| 239 | hwif->cds->name); | |||
| 240 | } | |||
| 0 | - | 241 | break; | |
| 12 | 242 | default: | ||
| 243 | /* | |||
| 244 | * If the device claims "simplex" DMA, | |||
| 245 | * this means only one of the two interfaces | |||
| 246 | * can be trusted with DMA at any point in time. | |||
| 247 | * So we should enable DMA only on one of the | |||
| 248 | * two interfaces. | |||
| 249 | */ | |||
| 250 | simplex_stat = hwif->INB(dma_base + 2); | |||
| 0 | 12 | - | 251 | if (simplex_stat & 0x80) { |
| 252 | /* simplex device? */ | |||
| 253 | /* | |||
| 254 | * At this point we haven't probed the drives so we can't make the | |||
| 255 | * appropriate decision. Really we should defer this problem | |||
| 256 | * until we tune the drive then try to grab DMA ownership if we want | |||
| 257 | * to be the DMA end. This has to be become dynamic to handle hot | |||
| 258 | * plug. | |||
| 259 | */ | |||
| 0 | 0 | - | 260 | if (hwif->mate && hwif->mate->dma_base) { |
| 0 | - | 260 | T && T | |
| 0 | - | 260 | T && F | |
| 0 | - | 260 | F && _ | |
| 261 | printk(KERN_INFO "%s: simplex device: " | |||
| 262 | "DMA disabled\n", | |||
| 263 | hwif->cds->name); | |||
| 264 | dma_base = 0; | |||
| 265 | } | |||
| 266 | } | |||
| 267 | } | |||
| 268 | } | |||
| 12 | 269 | return dma_base; | ||
| 270 | } | |||
| 271 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ | |||
| 272 | ||||
| 6 | 6 | 273 | void ide_setup_pci_noise (struct pci_dev *dev, ide_pci_device_t *d) | |
| 274 | { | |||
| 275 | printk(KERN_INFO "%s: IDE controller at PCI slot %s\n", | |||
| 276 | d->name, pci_name(dev)); | |||
| 277 | } | |||
| 278 | ||||
| 279 | EXPORT_SYMBOL_GPL(ide_setup_pci_noise); | |||
| 280 | ||||
| 281 | ||||
| 282 | /** | |||
| 283 | * ide_pci_enable - do PCI enables | |||
| 284 | * @dev: PCI device | |||
| 285 | * @d: IDE pci device data | |||
| 286 | * | |||
| 287 | * Enable the IDE PCI device. We attempt to enable the device in full | |||
| 288 | * but if that fails then we only need BAR4 so we will enable that. | |||
| 289 | * | |||
| 290 | * Returns zero on success or an error code | |||
| 291 | */ | |||
| 292 | ||||
| 6 | 0 | 293 | static int ide_pci_enable(struct pci_dev *dev, ide_pci_device_t *d) | |
| 294 | { | |||
| 295 | int ret; | |||
| 296 | ||||
| 0 | 6 | - | 297 | if (pci_enable_device(dev)) { |
| 298 | ret = pci_enable_device_bars(dev, 1 << 4); | |||
| 0 | 0 | - | 299 | if (ret < 0) { |
| 300 | printk(KERN_WARNING "%s: (ide_setup_pci_device:) " | |||
| 301 | "Could not enable device.\n", d->name); | |||
| 0 | - | 302 | goto out; | |
| 303 | } | |||
| 304 | printk(KERN_WARNING "%s: BIOS configuration fixed.\n", d->name); | |||
| 305 | } | |||
| 306 | ||||
| 307 | /* | |||
| 308 | * assume all devices can do 32-bit dma for now. we can add a | |||
| 309 | * dma mask field to the ide_pci_device_t if we need it (or let | |||
| 310 | * lower level driver set the dma mask) | |||
| 311 | */ | |||
| 312 | ret = pci_set_dma_mask(dev, DMA_32BIT_MASK); | |||
| 0 | 6 | - | 313 | if (ret < 0) { |
| 314 | printk(KERN_ERR "%s: can't set dma mask\n", d->name); | |||
| 0 | - | 315 | goto out; | |
| 316 | } | |||
| 317 | ||||
| 318 | /* FIXME: Temporary - until we put in the hotplug interface logic | |||
| 319 | Check that the bits we want are not in use by someone else. */ | |||
| 320 | ret = pci_request_region(dev, 4, "ide_tmp"); | |||
| 0 | 6 | - | 321 | if (ret < 0) |
| 0 | - | 322 | goto out; | |
| 323 | ||||
| 324 | pci_release_region(dev, 4); | |||
| 325 | out: | |||
| 6 | 326 | return ret; | ||
| 327 | } | |||
| 328 | ||||
| 329 | /** | |||
| 330 | * ide_pci_configure - configure an unconfigured device | |||
| 331 | * @dev: PCI device | |||
| 332 | * @d: IDE pci device data | |||
| 333 | * | |||
| 334 | * Enable and configure the PCI device we have been passed. | |||
| 335 | * Returns zero on success or an error code. | |||
| 336 | */ | |||
| 337 | ||||
| 0 | 0 | - | 338 | static int ide_pci_configure(struct pci_dev *dev, ide_pci_device_t *d) |
| 339 | { | |||
| 340 | u16 pcicmd = 0; | |||
| 341 | /* | |||
| 342 | * PnP BIOS was *supposed* to have setup this device, but we | |||
| 343 | * can do it ourselves, so long as the BIOS has assigned an IRQ | |||
| 344 | * (or possibly the device is using a "legacy header" for IRQs). | |||
| 345 | * Maybe the user deliberately *disabled* the device, | |||
| 346 | * but we'll eventually ignore it again if no drives respond. | |||
| 347 | */ | |||
| 0 | 0 | - | 348 | if (ide_setup_pci_baseregs(dev, d->name) || pci_write_config_word(dev, PCI_COMMAND, pcicmd|PCI_COMMAND_IO)) |
| 0 | - | 348 | T || _ | |
| 0 | - | 348 | F || T | |
| 0 | - | 348 | F || F | |
| 349 | { | |||
| 350 | printk(KERN_INFO "%s: device disabled (BIOS)\n", d->name); | |||
| 0 | - | 351 | return -ENODEV; | |
| 352 | } | |||
| 0 | 0 | - | 353 | if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd)) { |
| 354 | printk(KERN_ERR "%s: error accessing PCI regs\n", d->name); | |||
| 0 | - | 355 | return -EIO; | |
| 356 | } | |||
| 0 | 0 | - | 357 | if (!(pcicmd & PCI_COMMAND_IO)) { |
| 358 | printk(KERN_ERR "%s: unable to enable IDE controller\n", d->name); | |||
| 0 | - | 359 | return -ENXIO; | |
| 360 | } | |||
| 0 | - | 361 | return 0; | |
| 362 | } | |||
| 363 | ||||
| 364 | /** | |||
| 365 | * ide_pci_check_iomem - check a register is I/O | |||
| 366 | * @dev: pci device | |||
| 367 | * @d: ide_pci_device | |||
| 368 | * @bar: bar number | |||
| 369 | * | |||
| 370 | * Checks if a BAR is configured and points to MMIO space. If so | |||
| 371 | * print an error and return an error code. Otherwise return 0 | |||
| 372 | */ | |||
| 373 | ||||
| 24 | 0 | 374 | static int ide_pci_check_iomem(struct pci_dev *dev, ide_pci_device_t *d, int bar) | |
| 375 | { | |||
| 376 | ulong flags = pci_resource_flags(dev, bar); | |||
| 377 | ||||
| 378 | /* Unconfigured ? */ | |||
| 24 | 0 | - | 379 | if (!flags || pci_resource_len(dev, bar) == 0) |
| 24 | 379 | T || _ | ||
| 0 | - | 379 | F || T | |
| 0 | - | 379 | F || F | |
| 0 | 0 | - | 379 | ternary-?: ( ( ( ( dev ) ) -> resource [ ( ( b.. |
| 24 | 380 | return 0; | ||
| 381 | ||||
| 382 | /* I/O space */ | |||
| 0 | 0 | - | 383 | if(flags & PCI_BASE_ADDRESS_IO_MASK) |
| 0 | - | 384 | return 0; | |
| 385 | ||||
| 386 | /* Bad */ | |||
| 387 | printk(KERN_ERR "%s: IO baseregs (BIOS) are reported " | |||
| 388 | "as MEM, report to " | |||
| 389 | "<andre@linux-ide.org>.\n", d->name); | |||
| 0 | - | 390 | return -EINVAL; | |
| 391 | } | |||
| 392 | ||||
| 393 | /** | |||
| 394 | * ide_hwif_configure - configure an IDE interface | |||
| 395 | * @dev: PCI device holding interface | |||
| 396 | * @d: IDE pci data | |||
| 397 | * @mate: Paired interface if any | |||
| 398 | * | |||
| 399 | * Perform the initial set up for the hardware interface structure. This | |||
| 400 | * is done per interface port rather than per PCI device. There may be | |||
| 401 | * more than one port per device. | |||
| 402 | * | |||
| 403 | * Returns the new hardware interface structure, or NULL on a failure | |||
| 404 | */ | |||
| 405 | ||||
| 12 | 0 | 406 | static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, ide_pci_device_t *d, ide_hwif_t *mate, int port, int irq) | |
| 407 | { | |||
| 408 | unsigned long ctl = 0, base = 0; | |||
| 409 | ide_hwif_t *hwif; | |||
| 410 | ||||
| 12 | 0 | - | 411 | if ((d->flags & IDEPCI_FLAG_ISA_PORTS) == 0) { |
| 412 | /* Possibly we should fail if these checks report true */ | |||
| 413 | ide_pci_check_iomem(dev, d, 2*port); | |||
| 414 | ide_pci_check_iomem(dev, d, 2*port+1); | |||
| 415 | ||||
| 416 | ctl = pci_resource_start(dev, 2*port+1); | |||
| 417 | base = pci_resource_start(dev, 2*port); | |||
| 0 | 12 | - | 418 | if ((ctl && !base) || (base && !ctl)) { |
| 0 | - | 418 | (T && T) || (_ && _) | |
| 0 | - | 418 | (T && F) || (T && T) | |
| 0 | - | 418 | (F && _) || (T && T) | |
| 0 | - | 418 | (T && F) || (T && F) | |
| 0 | - | 418 | (T && F) || (F && _) | |
| 0 | - | 418 | (F && _) || (T && F) | |
| 12 | 418 | (F && _) || (F && _) | ||
| 419 | printk(KERN_ERR "%s: inconsistent baseregs (BIOS) " | |||
| 420 | "for port %d, skipping\n", d->name, port); | |||
| 0 | - | 421 | return NULL; | |
| 422 | } | |||
| 423 | } | |||
| 12 | 0 | - | 424 | if (!ctl) |
| 425 | { | |||
| 426 | /* Use default values */ | |||
| 427 | ctl = port ? 0x374 : 0x3f4; | |||
| 6 | 6 | 427 | ternary-?: port | |
| 428 | base = port ? 0x170 : 0x1f0; | |||
| 6 | 6 | 428 | ternary-?: port | |
| 429 | } | |||
| 0 | 12 | - | 430 | if ((hwif = ide_match_hwif(base, d->bootable, d->name)) == NULL) |
| 0 | - | 431 | return NULL; /* no room in ide_hwifs[] */ | |
| 432 | if (hwif->io_ports[IDE_DATA_OFFSET] != base || | |||
| 0 | 12 | - | 433 | hwif->io_ports[IDE_CONTROL_OFFSET] != (ctl | 2)) { |
| 0 | - | 433 | T || _ | |
| 0 | - | 433 | F || T | |
| 12 | 433 | F || F | ||
| 434 | memset(&hwif->hw, 0, sizeof(hwif->hw)); | |||
| 435 | #ifndef IDE_ARCH_OBSOLETE_INIT | |||
| 436 | ide_std_init_ports(&hwif->hw, base, (ctl | 2)); | |||
| 437 | hwif->hw.io_ports[IDE_IRQ_OFFSET] = 0; | |||
| 438 | #else | |||
| 439 | ide_init_hwif_ports(&hwif->hw, base, (ctl | 2), NULL); | |||
| 440 | #endif | |||
| 441 | memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->io_ports)); | |||
| 442 | hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET]; | |||
| 443 | } | |||
| 444 | hwif->chipset = ide_pci; | |||
| 445 | hwif->pci_dev = dev; | |||
| 446 | hwif->cds = (struct ide_pci_device_s *) d; | |||
| 447 | hwif->channel = port; | |||
| 448 | ||||
| 12 | 0 | - | 449 | if (!hwif->irq) |
| 450 | hwif->irq = irq; | |||
| 6 | 6 | 451 | if (mate) { | |
| 452 | hwif->mate = mate; | |||
| 453 | mate->mate = hwif; | |||
| 454 | } | |||
| 12 | 455 | return hwif; | ||
| 456 | } | |||
| 457 | ||||
| 458 | /** | |||
| 459 | * ide_hwif_setup_dma - configure DMA interface | |||
| 460 | * @dev: PCI device | |||
| 461 | * @d: IDE pci data | |||
| 462 | * @hwif: Hardware interface we are configuring | |||
| 463 | * | |||
| 464 | * Set up the DMA base for the interface. Enable the master bits as | |||
| 465 | * necessary and attempt to bring the device DMA into a ready to use | |||
| 466 | * state | |||
| 467 | */ | |||
| 468 | ||||
| 469 | #ifndef CONFIG_BLK_DEV_IDEDMA_PCI | |||
| 470 | static void ide_hwif_setup_dma(struct pci_dev *dev, ide_pci_device_t *d, ide_hwif_t *hwif) | |||
| 471 | { | |||
| 472 | } | |||
| 473 | #else | |||
| 12 | 12 | 474 | static void ide_hwif_setup_dma(struct pci_dev *dev, ide_pci_device_t *d, ide_hwif_t *hwif) | |
| 475 | { | |||
| 476 | u16 pcicmd; | |||
| 477 | pci_read_config_word(dev, PCI_COMMAND, &pcicmd); | |||
| 478 | ||||
| 479 | if ((d->autodma == AUTODMA) || | |||
| 480 | ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && | |||
| 12 | 0 | - | 481 | (dev->class & 0x80))) { |
| 0 | - | 481 | (T) || (_ && (_)) | |
| 12 | 481 | (F) || (T && (T)) | ||
| 0 | - | 481 | (F) || (T && (F)) | |
| 0 | - | 481 | (F) || (F && (_)) | |