diff options
Diffstat (limited to 'drivers/ide/setup-pci.c')
-rw-r--r-- | drivers/ide/setup-pci.c | 68 |
1 files changed, 40 insertions, 28 deletions
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index 3d101f73f910..fff567bcedbe 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c | |||
@@ -147,6 +147,7 @@ static int ide_setup_pci_baseregs (struct pci_dev *dev, const char *name) | |||
147 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | 147 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI |
148 | /** | 148 | /** |
149 | * ide_get_or_set_dma_base - setup BMIBA | 149 | * ide_get_or_set_dma_base - setup BMIBA |
150 | * @d: IDE pci device data | ||
150 | * @hwif: Interface | 151 | * @hwif: Interface |
151 | * | 152 | * |
152 | * Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space. | 153 | * Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space. |
@@ -154,7 +155,7 @@ static int ide_setup_pci_baseregs (struct pci_dev *dev, const char *name) | |||
154 | * and enforce IDE simplex rules. | 155 | * and enforce IDE simplex rules. |
155 | */ | 156 | */ |
156 | 157 | ||
157 | static unsigned long ide_get_or_set_dma_base (ide_hwif_t *hwif) | 158 | static unsigned long ide_get_or_set_dma_base(ide_pci_device_t *d, ide_hwif_t *hwif) |
158 | { | 159 | { |
159 | unsigned long dma_base = 0; | 160 | unsigned long dma_base = 0; |
160 | struct pci_dev *dev = hwif->pci_dev; | 161 | struct pci_dev *dev = hwif->pci_dev; |
@@ -165,14 +166,15 @@ static unsigned long ide_get_or_set_dma_base (ide_hwif_t *hwif) | |||
165 | if (hwif->mate && hwif->mate->dma_base) { | 166 | if (hwif->mate && hwif->mate->dma_base) { |
166 | dma_base = hwif->mate->dma_base - (hwif->channel ? 0 : 8); | 167 | dma_base = hwif->mate->dma_base - (hwif->channel ? 0 : 8); |
167 | } else { | 168 | } else { |
168 | dma_base = pci_resource_start(dev, 4); | 169 | u8 baridx = (d->host_flags & IDE_HFLAG_CS5520) ? 2 : 4; |
169 | if (!dma_base) { | 170 | |
170 | printk(KERN_ERR "%s: dma_base is invalid\n", | 171 | dma_base = pci_resource_start(dev, baridx); |
171 | hwif->cds->name); | 172 | |
172 | } | 173 | if (dma_base == 0) |
174 | printk(KERN_ERR "%s: DMA base is invalid\n", d->name); | ||
173 | } | 175 | } |
174 | 176 | ||
175 | if (dma_base) { | 177 | if ((d->host_flags & IDE_HFLAG_CS5520) == 0 && dma_base) { |
176 | u8 simplex_stat = 0; | 178 | u8 simplex_stat = 0; |
177 | dma_base += hwif->channel ? 8 : 0; | 179 | dma_base += hwif->channel ? 8 : 0; |
178 | 180 | ||
@@ -183,13 +185,13 @@ static unsigned long ide_get_or_set_dma_base (ide_hwif_t *hwif) | |||
183 | case PCI_DEVICE_ID_CMD_643: | 185 | case PCI_DEVICE_ID_CMD_643: |
184 | case PCI_DEVICE_ID_SERVERWORKS_CSB5IDE: | 186 | case PCI_DEVICE_ID_SERVERWORKS_CSB5IDE: |
185 | case PCI_DEVICE_ID_REVOLUTION: | 187 | case PCI_DEVICE_ID_REVOLUTION: |
186 | simplex_stat = hwif->INB(dma_base + 2); | 188 | simplex_stat = inb(dma_base + 2); |
187 | hwif->OUTB((simplex_stat&0x60),(dma_base + 2)); | 189 | outb(simplex_stat & 0x60, dma_base + 2); |
188 | simplex_stat = hwif->INB(dma_base + 2); | 190 | simplex_stat = inb(dma_base + 2); |
189 | if (simplex_stat & 0x80) { | 191 | if (simplex_stat & 0x80) { |
190 | printk(KERN_INFO "%s: simplex device: " | 192 | printk(KERN_INFO "%s: simplex device: " |
191 | "DMA forced\n", | 193 | "DMA forced\n", |
192 | hwif->cds->name); | 194 | d->name); |
193 | } | 195 | } |
194 | break; | 196 | break; |
195 | default: | 197 | default: |
@@ -212,8 +214,8 @@ static unsigned long ide_get_or_set_dma_base (ide_hwif_t *hwif) | |||
212 | */ | 214 | */ |
213 | if (hwif->mate && hwif->mate->dma_base) { | 215 | if (hwif->mate && hwif->mate->dma_base) { |
214 | printk(KERN_INFO "%s: simplex device: " | 216 | printk(KERN_INFO "%s: simplex device: " |
215 | "DMA disabled\n", | 217 | "DMA disabled\n", |
216 | hwif->cds->name); | 218 | d->name); |
217 | dma_base = 0; | 219 | dma_base = 0; |
218 | } | 220 | } |
219 | } | 221 | } |
@@ -360,6 +362,7 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, ide_pci_device_t *d, | |||
360 | { | 362 | { |
361 | unsigned long ctl = 0, base = 0; | 363 | unsigned long ctl = 0, base = 0; |
362 | ide_hwif_t *hwif; | 364 | ide_hwif_t *hwif; |
365 | u8 bootable = (d->host_flags & IDE_HFLAG_BOOTABLE) ? 1 : 0; | ||
363 | 366 | ||
364 | if ((d->host_flags & IDE_HFLAG_ISA_PORTS) == 0) { | 367 | if ((d->host_flags & IDE_HFLAG_ISA_PORTS) == 0) { |
365 | /* Possibly we should fail if these checks report true */ | 368 | /* Possibly we should fail if these checks report true */ |
@@ -380,7 +383,7 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, ide_pci_device_t *d, | |||
380 | ctl = port ? 0x374 : 0x3f4; | 383 | ctl = port ? 0x374 : 0x3f4; |
381 | base = port ? 0x170 : 0x1f0; | 384 | base = port ? 0x170 : 0x1f0; |
382 | } | 385 | } |
383 | if ((hwif = ide_match_hwif(base, d->bootable, d->name)) == NULL) | 386 | if ((hwif = ide_match_hwif(base, bootable, d->name)) == NULL) |
384 | return NULL; /* no room in ide_hwifs[] */ | 387 | return NULL; /* no room in ide_hwifs[] */ |
385 | if (hwif->io_ports[IDE_DATA_OFFSET] != base || | 388 | if (hwif->io_ports[IDE_DATA_OFFSET] != base || |
386 | hwif->io_ports[IDE_CONTROL_OFFSET] != (ctl | 2)) { | 389 | hwif->io_ports[IDE_CONTROL_OFFSET] != (ctl | 2)) { |
@@ -427,12 +430,13 @@ static void ide_hwif_setup_dma(struct pci_dev *dev, ide_pci_device_t *d, ide_hwi | |||
427 | static void ide_hwif_setup_dma(struct pci_dev *dev, ide_pci_device_t *d, ide_hwif_t *hwif) | 430 | static void ide_hwif_setup_dma(struct pci_dev *dev, ide_pci_device_t *d, ide_hwif_t *hwif) |
428 | { | 431 | { |
429 | u16 pcicmd; | 432 | u16 pcicmd; |
433 | |||
430 | pci_read_config_word(dev, PCI_COMMAND, &pcicmd); | 434 | pci_read_config_word(dev, PCI_COMMAND, &pcicmd); |
431 | 435 | ||
432 | if ((d->autodma == AUTODMA) || | 436 | if ((d->host_flags & IDE_HFLAG_NO_AUTODMA) == 0 || |
433 | ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && | 437 | ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && |
434 | (dev->class & 0x80))) { | 438 | (dev->class & 0x80))) { |
435 | unsigned long dma_base = ide_get_or_set_dma_base(hwif); | 439 | unsigned long dma_base = ide_get_or_set_dma_base(d, hwif); |
436 | if (dma_base && !(pcicmd & PCI_COMMAND_MASTER)) { | 440 | if (dma_base && !(pcicmd & PCI_COMMAND_MASTER)) { |
437 | /* | 441 | /* |
438 | * Set up BM-DMA capability | 442 | * Set up BM-DMA capability |
@@ -474,7 +478,6 @@ static void ide_hwif_setup_dma(struct pci_dev *dev, ide_pci_device_t *d, ide_hwi | |||
474 | static int ide_setup_pci_controller(struct pci_dev *dev, ide_pci_device_t *d, int noisy, int *config) | 478 | static int ide_setup_pci_controller(struct pci_dev *dev, ide_pci_device_t *d, int noisy, int *config) |
475 | { | 479 | { |
476 | int ret; | 480 | int ret; |
477 | u32 class_rev; | ||
478 | u16 pcicmd; | 481 | u16 pcicmd; |
479 | 482 | ||
480 | if (noisy) | 483 | if (noisy) |
@@ -497,10 +500,9 @@ static int ide_setup_pci_controller(struct pci_dev *dev, ide_pci_device_t *d, in | |||
497 | printk(KERN_INFO "%s: device enabled (Linux)\n", d->name); | 500 | printk(KERN_INFO "%s: device enabled (Linux)\n", d->name); |
498 | } | 501 | } |
499 | 502 | ||
500 | pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev); | ||
501 | class_rev &= 0xff; | ||
502 | if (noisy) | 503 | if (noisy) |
503 | printk(KERN_INFO "%s: chipset revision %d\n", d->name, class_rev); | 504 | printk(KERN_INFO "%s: chipset revision %d\n", |
505 | d->name, dev->revision); | ||
504 | out: | 506 | out: |
505 | return ret; | 507 | return ret; |
506 | } | 508 | } |
@@ -557,17 +559,27 @@ void ide_pci_setup_ports(struct pci_dev *dev, ide_pci_device_t *d, int pciirq, a | |||
557 | if (d->init_iops) | 559 | if (d->init_iops) |
558 | d->init_iops(hwif); | 560 | d->init_iops(hwif); |
559 | 561 | ||
560 | if (d->autodma == NODMA) | 562 | if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0) |
561 | goto bypass_legacy_dma; | ||
562 | |||
563 | if(d->init_setup_dma) | ||
564 | d->init_setup_dma(dev, d, hwif); | ||
565 | else | ||
566 | ide_hwif_setup_dma(dev, d, hwif); | 563 | ide_hwif_setup_dma(dev, d, hwif); |
567 | bypass_legacy_dma: | 564 | |
565 | if ((d->host_flags & IDE_HFLAG_LEGACY_IRQS) && hwif->irq == 0) | ||
566 | hwif->irq = port ? 15 : 14; | ||
567 | |||
568 | hwif->host_flags = d->host_flags; | 568 | hwif->host_flags = d->host_flags; |
569 | hwif->pio_mask = d->pio_mask; | 569 | hwif->pio_mask = d->pio_mask; |
570 | 570 | ||
571 | if ((d->host_flags & IDE_HFLAG_SERIALIZE) && hwif->mate) | ||
572 | hwif->mate->serialized = hwif->serialized = 1; | ||
573 | |||
574 | if (hwif->dma_base) { | ||
575 | hwif->swdma_mask = d->swdma_mask; | ||
576 | hwif->mwdma_mask = d->mwdma_mask; | ||
577 | hwif->ultra_mask = d->udma_mask; | ||
578 | } | ||
579 | |||
580 | hwif->drives[0].autotune = 1; | ||
581 | hwif->drives[1].autotune = 1; | ||
582 | |||
571 | if (d->init_hwif) | 583 | if (d->init_hwif) |
572 | /* Call chipset-specific routine | 584 | /* Call chipset-specific routine |
573 | * for each enabled hwif | 585 | * for each enabled hwif |