aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-01-26 14:13:00 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-01-26 14:13:00 -0500
commit8704de8f296fcf6a4b2ff6bfd9a63974ad909b3e (patch)
tree386dccd98e7fc77b0c6b45b999bf474c04851165 /drivers/ide
parenta530201afed5074dac69b29c519a1df59da97945 (diff)
cy82c693: add ->set_dma_mode method
* Fix SWDMA/MWDMA masks in cy82c693_chipset. * Add IDE_HFLAG_CY82C693 host flag and use it in ide_tune_dma() to check whether the DMA should be enabled even if ide_max_dma_mode() fails. * Convert cy82c693_dma_enable() to become cy82c693_set_dma_mode() and remove no longer needed cy82c693_ide_dma_on(). Then set IDE_HFLAG_CY82C693 instead of IDE_HFLAG_TRUST_BIOS_FOR_DMA in cy82c693_chipset. * Bump driver version. As a result of this patch cy82c693 driver will configure and use DMA on all SWDMA0-2 and MWDMA0-2 capable ATA devices instead of relying on BIOS. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/ide-dma.c15
-rw-r--r--drivers/ide/pci/cy82c693.c64
2 files changed, 22 insertions, 57 deletions
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index 18c78ad2b31e..9d6dabbbf809 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -755,6 +755,7 @@ EXPORT_SYMBOL_GPL(ide_find_dma_mode);
755 755
756static int ide_tune_dma(ide_drive_t *drive) 756static int ide_tune_dma(ide_drive_t *drive)
757{ 757{
758 ide_hwif_t *hwif = drive->hwif;
758 u8 speed; 759 u8 speed;
759 760
760 if (noautodma || drive->nodma || (drive->id->capability & 1) == 0) 761 if (noautodma || drive->nodma || (drive->id->capability & 1) == 0)
@@ -767,15 +768,21 @@ static int ide_tune_dma(ide_drive_t *drive)
767 if (ide_id_dma_bug(drive)) 768 if (ide_id_dma_bug(drive))
768 return 0; 769 return 0;
769 770
770 if (drive->hwif->host_flags & IDE_HFLAG_TRUST_BIOS_FOR_DMA) 771 if (hwif->host_flags & IDE_HFLAG_TRUST_BIOS_FOR_DMA)
771 return config_drive_for_dma(drive); 772 return config_drive_for_dma(drive);
772 773
773 speed = ide_max_dma_mode(drive); 774 speed = ide_max_dma_mode(drive);
774 775
775 if (!speed) 776 if (!speed) {
776 return 0; 777 /* is this really correct/needed? */
778 if ((hwif->host_flags & IDE_HFLAG_CY82C693) &&
779 ide_dma_good_drive(drive))
780 return 1;
781 else
782 return 0;
783 }
777 784
778 if (drive->hwif->host_flags & IDE_HFLAG_NO_SET_MODE) 785 if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)
779 return 0; 786 return 0;
780 787
781 if (ide_set_dma_mode(drive, speed)) 788 if (ide_set_dma_mode(drive, speed))
diff --git a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c
index e7466f2bee7b..3ec4c659a37d 100644
--- a/drivers/ide/pci/cy82c693.c
+++ b/drivers/ide/pci/cy82c693.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/ide/pci/cy82c693.c Version 0.43 Nov 7, 2007 2 * linux/drivers/ide/pci/cy82c693.c Version 0.44 Nov 8, 2007
3 * 3 *
4 * Copyright (C) 1998-2000 Andreas S. Krebs (akrebs@altavista.net), Maintainer 4 * Copyright (C) 1998-2000 Andreas S. Krebs (akrebs@altavista.net), Maintainer
5 * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org>, Integrator 5 * Copyright (C) 1998-2002 Andre Hedrick <andre@linux-ide.org>, Integrator
@@ -176,14 +176,12 @@ static void compute_clocks (u8 pio, pio_clocks_t *p_pclk)
176 * set DMA mode a specific channel for CY82C693 176 * set DMA mode a specific channel for CY82C693
177 */ 177 */
178 178
179static void cy82c693_dma_enable (ide_drive_t *drive, int mode, int single) 179static void cy82c693_set_dma_mode(ide_drive_t *drive, const u8 mode)
180{ 180{
181 u8 index = 0, data = 0; 181 ide_hwif_t *hwif = drive->hwif;
182 u8 single = (mode & 0x10) >> 4, index = 0, data = 0;
182 183
183 if (mode>2) /* make sure we set a valid mode */ 184 index = hwif->channel ? CY82_INDEX_CHANNEL1 : CY82_INDEX_CHANNEL0;
184 mode = 2;
185
186 index = (HWIF(drive)->channel==0) ? CY82_INDEX_CHANNEL0 : CY82_INDEX_CHANNEL1;
187 185
188#if CY82C693_DEBUG_LOGS 186#if CY82C693_DEBUG_LOGS
189 /* for debug let's show the previous values */ 187 /* for debug let's show the previous values */
@@ -196,7 +194,7 @@ static void cy82c693_dma_enable (ide_drive_t *drive, int mode, int single)
196 (data&0x3), ((data>>2)&1)); 194 (data&0x3), ((data>>2)&1));
197#endif /* CY82C693_DEBUG_LOGS */ 195#endif /* CY82C693_DEBUG_LOGS */
198 196
199 data = (u8)mode|(u8)(single<<2); 197 data = (mode & 3) | (single << 2);
200 198
201 outb(index, CY82_INDEX_PORT); 199 outb(index, CY82_INDEX_PORT);
202 outb(data, CY82_DATA_PORT); 200 outb(data, CY82_DATA_PORT);
@@ -204,7 +202,7 @@ static void cy82c693_dma_enable (ide_drive_t *drive, int mode, int single)
204#if CY82C693_DEBUG_INFO 202#if CY82C693_DEBUG_INFO
205 printk(KERN_INFO "%s (ch=%d, dev=%d): set DMA mode to %d (single=%d)\n", 203 printk(KERN_INFO "%s (ch=%d, dev=%d): set DMA mode to %d (single=%d)\n",
206 drive->name, HWIF(drive)->channel, drive->select.b.unit, 204 drive->name, HWIF(drive)->channel, drive->select.b.unit,
207 mode, single); 205 mode & 3, single);
208#endif /* CY82C693_DEBUG_INFO */ 206#endif /* CY82C693_DEBUG_INFO */
209 207
210 /* 208 /*
@@ -227,42 +225,6 @@ static void cy82c693_dma_enable (ide_drive_t *drive, int mode, int single)
227#endif /* CY82C693_DEBUG_INFO */ 225#endif /* CY82C693_DEBUG_INFO */
228} 226}
229 227
230/*
231 * used to set DMA mode for CY82C693 (single and multi modes)
232 */
233static int cy82c693_ide_dma_on (ide_drive_t *drive)
234{
235 struct hd_driveid *id = drive->id;
236
237#if CY82C693_DEBUG_INFO
238 printk (KERN_INFO "dma_on: %s\n", drive->name);
239#endif /* CY82C693_DEBUG_INFO */
240
241 if (id != NULL) {
242 /* Enable DMA on any drive that has DMA
243 * (multi or single) enabled
244 */
245 if (id->field_valid & 2) { /* regular DMA */
246 int mmode, smode;
247
248 mmode = id->dma_mword & (id->dma_mword >> 8);
249 smode = id->dma_1word & (id->dma_1word >> 8);
250
251 mmode &= ATA_MWDMA2;
252 smode &= ATA_SWDMA2;
253
254 if (mmode != 0) {
255 /* enable multi */
256 cy82c693_dma_enable(drive, (mmode >> 1), 0);
257 } else if (smode != 0) {
258 /* enable single */
259 cy82c693_dma_enable(drive, (smode >> 1), 1);
260 }
261 }
262 }
263 return __ide_dma_on(drive);
264}
265
266static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio) 228static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio)
267{ 229{
268 ide_hwif_t *hwif = HWIF(drive); 230 ide_hwif_t *hwif = HWIF(drive);
@@ -429,11 +391,7 @@ static unsigned int __devinit init_chipset_cy82c693(struct pci_dev *dev, const c
429static void __devinit init_hwif_cy82c693(ide_hwif_t *hwif) 391static void __devinit init_hwif_cy82c693(ide_hwif_t *hwif)
430{ 392{
431 hwif->set_pio_mode = &cy82c693_set_pio_mode; 393 hwif->set_pio_mode = &cy82c693_set_pio_mode;
432 394 hwif->set_dma_mode = &cy82c693_set_dma_mode;
433 if (hwif->dma_base == 0)
434 return;
435
436 hwif->ide_dma_on = &cy82c693_ide_dma_on;
437} 395}
438 396
439static void __devinit init_iops_cy82c693(ide_hwif_t *hwif) 397static void __devinit init_iops_cy82c693(ide_hwif_t *hwif)
@@ -454,11 +412,11 @@ static const struct ide_port_info cy82c693_chipset __devinitdata = {
454 .init_iops = init_iops_cy82c693, 412 .init_iops = init_iops_cy82c693,
455 .init_hwif = init_hwif_cy82c693, 413 .init_hwif = init_hwif_cy82c693,
456 .chipset = ide_cy82c693, 414 .chipset = ide_cy82c693,
457 .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_TRUST_BIOS_FOR_DMA | 415 .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_CY82C693 |
458 IDE_HFLAG_BOOTABLE, 416 IDE_HFLAG_BOOTABLE,
459 .pio_mask = ATA_PIO4, 417 .pio_mask = ATA_PIO4,
460 .swdma_mask = ATA_SWDMA2_ONLY, 418 .swdma_mask = ATA_SWDMA2,
461 .mwdma_mask = ATA_MWDMA2_ONLY, 419 .mwdma_mask = ATA_MWDMA2,
462}; 420};
463 421
464static int __devinit cy82c693_init_one(struct pci_dev *dev, const struct pci_device_id *id) 422static int __devinit cy82c693_init_one(struct pci_dev *dev, const struct pci_device_id *id)