diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2007-10-18 18:30:07 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2007-10-18 18:30:07 -0400 |
commit | 9ffcf364f9d0aca3ea79e9987c368eb75925460e (patch) | |
tree | 2916b96c1c020acd5ce19aa07fce0d6790567916 /drivers/ide/setup-pci.c | |
parent | 47b687882c02f802dd5bbe1227effe006820246e (diff) |
ide: remove ->init_setup_dma from ide_pci_device_t (take 2)
* Make ide_pci_device_t.host_flags u32 and add IDE_HFLAG_CS5520 host flag.
* Pass ide_pci_device_t *d to setup-pci.c::ide_get_or_set_dma_base()
and use d->name instead of hwif->cds->name.
* Set IDE_HFLAG_CS5520 host flag in cs5520 host driver and use it in
ide_get_or_set_dma_base() to find out which PCI BAR to use, remove no longer
needed cs5520.c::cs5520_init_setup_dma() and ide_pci_device_t.init_setup_dma.
This fixes PCI bus-mastering not being checked for CS5510/CS5520 hosts.
v2:
* It is wrong to check simplex bits on CS5510/CS5520 as v1 did.
(Noticed by Alan).
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/setup-pci.c')
-rw-r--r-- | drivers/ide/setup-pci.c | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index 26061fe1b712..479add4af499 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 | ||
@@ -188,8 +190,8 @@ static unsigned long ide_get_or_set_dma_base (ide_hwif_t *hwif) | |||
188 | simplex_stat = hwif->INB(dma_base + 2); | 190 | simplex_stat = hwif->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 | } |
@@ -434,7 +436,7 @@ static void ide_hwif_setup_dma(struct pci_dev *dev, ide_pci_device_t *d, ide_hwi | |||
434 | if ((d->host_flags & IDE_HFLAG_NO_AUTODMA) == 0 || | 436 | if ((d->host_flags & IDE_HFLAG_NO_AUTODMA) == 0 || |
435 | ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && | 437 | ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && |
436 | (dev->class & 0x80))) { | 438 | (dev->class & 0x80))) { |
437 | unsigned long dma_base = ide_get_or_set_dma_base(hwif); | 439 | unsigned long dma_base = ide_get_or_set_dma_base(d, hwif); |
438 | if (dma_base && !(pcicmd & PCI_COMMAND_MASTER)) { | 440 | if (dma_base && !(pcicmd & PCI_COMMAND_MASTER)) { |
439 | /* | 441 | /* |
440 | * Set up BM-DMA capability | 442 | * Set up BM-DMA capability |
@@ -559,14 +561,9 @@ void ide_pci_setup_ports(struct pci_dev *dev, ide_pci_device_t *d, int pciirq, a | |||
559 | if (d->init_iops) | 561 | if (d->init_iops) |
560 | d->init_iops(hwif); | 562 | d->init_iops(hwif); |
561 | 563 | ||
562 | if (d->host_flags & IDE_HFLAG_NO_DMA) | 564 | if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0) |
563 | goto bypass_legacy_dma; | ||
564 | |||
565 | if(d->init_setup_dma) | ||
566 | d->init_setup_dma(dev, d, hwif); | ||
567 | else | ||
568 | ide_hwif_setup_dma(dev, d, hwif); | 565 | ide_hwif_setup_dma(dev, d, hwif); |
569 | bypass_legacy_dma: | 566 | |
570 | hwif->host_flags = d->host_flags; | 567 | hwif->host_flags = d->host_flags; |
571 | hwif->pio_mask = d->pio_mask; | 568 | hwif->pio_mask = d->pio_mask; |
572 | 569 | ||