diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-01 17:09:30 -0500 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-01 17:09:30 -0500 |
commit | 8ac2b42a45896641ed292deaf038a1d2703d85a6 (patch) | |
tree | fb6c193f4a5f454c36b23c4e972fbe57bb1da6b1 /drivers/ide/setup-pci.c | |
parent | 993da8f9ea7e00d21af49d0e14a131183288bcf8 (diff) |
ide: add IDE_HFLAG_CLEAR_SIMPLEX host flag
* Rename 'simplex_stat' variable to 'dma_stat' in ide_get_or_set_dma_base().
* Factor out code for forcing host out of "simplex" mode from
ide_get_or_set_dma_base() to ide_pci_clear_simplex() helper.
* Add IDE_HFLAG_CLEAR_SIMPLEX host flag and set it in alim15x3 (for M5229),
amd74xx (for AMD 7409), cmd64x (for CMD643), generic (for Netcell) and
serverworks (for CSB5) host drivers.
* Make ide_get_or_set_dma_base() test for IDE_HFLAG_CLEAR_SIMPLEX host flag
instead of checking dev->device (BTW the code was buggy because it didn't
check for dev->vendor, luckily none of these PCI Device IDs was used by
some other vendor for PCI IDE controller).
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/setup-pci.c')
-rw-r--r-- | drivers/ide/setup-pci.c | 79 |
1 files changed, 34 insertions, 45 deletions
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index c473f45abd33..0a4b3a6857e1 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c | |||
@@ -140,6 +140,16 @@ static int ide_setup_pci_baseregs (struct pci_dev *dev, const char *name) | |||
140 | } | 140 | } |
141 | 141 | ||
142 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | 142 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI |
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 | |||
143 | /** | 153 | /** |
144 | * ide_get_or_set_dma_base - setup BMIBA | 154 | * ide_get_or_set_dma_base - setup BMIBA |
145 | * @d: IDE port info | 155 | * @d: IDE port info |
@@ -154,6 +164,7 @@ static unsigned long ide_get_or_set_dma_base(const struct ide_port_info *d, ide_ | |||
154 | { | 164 | { |
155 | unsigned long dma_base = 0; | 165 | unsigned long dma_base = 0; |
156 | struct pci_dev *dev = hwif->pci_dev; | 166 | struct pci_dev *dev = hwif->pci_dev; |
167 | u8 dma_stat = 0; | ||
157 | 168 | ||
158 | if (hwif->mmio) | 169 | if (hwif->mmio) |
159 | return hwif->dma_base; | 170 | return hwif->dma_base; |
@@ -174,52 +185,30 @@ static unsigned long ide_get_or_set_dma_base(const struct ide_port_info *d, ide_ | |||
174 | if (hwif->channel) | 185 | if (hwif->channel) |
175 | dma_base += 8; | 186 | dma_base += 8; |
176 | 187 | ||
177 | if ((d->host_flags & IDE_HFLAG_CS5520) == 0) { | 188 | if (d->host_flags & IDE_HFLAG_CS5520) |
178 | u8 simplex_stat = 0; | 189 | goto out; |
179 | 190 | ||
180 | switch(dev->device) { | 191 | if (d->host_flags & IDE_HFLAG_CLEAR_SIMPLEX) { |
181 | case PCI_DEVICE_ID_AL_M5219: | 192 | ide_pci_clear_simplex(dma_base, d->name); |
182 | case PCI_DEVICE_ID_AL_M5229: | 193 | goto out; |
183 | case PCI_DEVICE_ID_AMD_VIPER_7409: | 194 | } |
184 | case PCI_DEVICE_ID_CMD_643: | 195 | |
185 | case PCI_DEVICE_ID_SERVERWORKS_CSB5IDE: | 196 | /* |
186 | case PCI_DEVICE_ID_REVOLUTION: | 197 | * If the device claims "simplex" DMA, this means that only one of |
187 | simplex_stat = inb(dma_base + 2); | 198 | * the two interfaces can be trusted with DMA at any point in time |
188 | outb(simplex_stat & 0x60, dma_base + 2); | 199 | * (so we should enable DMA only on one of the two interfaces). |
189 | simplex_stat = inb(dma_base + 2); | 200 | * |
190 | if (simplex_stat & 0x80) { | 201 | * FIXME: At this point we haven't probed the drives so we can't make |
191 | printk(KERN_INFO "%s: simplex device: " | 202 | * the appropriate decision. Really we should defer this problem until |
192 | "DMA forced\n", | 203 | * we tune the drive then try to grab DMA ownership if we want to be |
193 | d->name); | 204 | * the DMA end. This has to be become dynamic to handle hot-plug. |
194 | } | 205 | */ |
195 | break; | 206 | dma_stat = hwif->INB(dma_base + 2); |
196 | default: | 207 | if ((dma_stat & 0x80) && hwif->mate && hwif->mate->dma_base) { |
197 | /* | 208 | printk(KERN_INFO "%s: simplex device: DMA disabled\n", d->name); |
198 | * If the device claims "simplex" DMA, | 209 | dma_base = 0; |
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: " | ||
216 | "DMA disabled\n", | ||
217 | d->name); | ||
218 | dma_base = 0; | ||
219 | } | ||
220 | } | ||
221 | } | ||
222 | } | 210 | } |
211 | out: | ||
223 | return dma_base; | 212 | return dma_base; |
224 | } | 213 | } |
225 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ | 214 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ |