aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/pci/cy82c693.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/pci/cy82c693.c')
-rw-r--r--drivers/ide/pci/cy82c693.c64
1 files changed, 11 insertions, 53 deletions
diff --git a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c
index 1cd4e9cb0521..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.42 Oct 23, 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,17 +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 if (mode > drive->id->tDMA) /* to be absolutly sure we have a valid mode */
187 mode = drive->id->tDMA;
188
189 index = (HWIF(drive)->channel==0) ? CY82_INDEX_CHANNEL0 : CY82_INDEX_CHANNEL1;
190 185
191#if CY82C693_DEBUG_LOGS 186#if CY82C693_DEBUG_LOGS
192 /* for debug let's show the previous values */ 187 /* for debug let's show the previous values */
@@ -199,7 +194,7 @@ static void cy82c693_dma_enable (ide_drive_t *drive, int mode, int single)
199 (data&0x3), ((data>>2)&1)); 194 (data&0x3), ((data>>2)&1));
200#endif /* CY82C693_DEBUG_LOGS */ 195#endif /* CY82C693_DEBUG_LOGS */
201 196
202 data = (u8)mode|(u8)(single<<2); 197 data = (mode & 3) | (single << 2);
203 198
204 outb(index, CY82_INDEX_PORT); 199 outb(index, CY82_INDEX_PORT);
205 outb(data, CY82_DATA_PORT); 200 outb(data, CY82_DATA_PORT);
@@ -207,7 +202,7 @@ static void cy82c693_dma_enable (ide_drive_t *drive, int mode, int single)
207#if CY82C693_DEBUG_INFO 202#if CY82C693_DEBUG_INFO
208 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",
209 drive->name, HWIF(drive)->channel, drive->select.b.unit, 204 drive->name, HWIF(drive)->channel, drive->select.b.unit,
210 mode, single); 205 mode & 3, single);
211#endif /* CY82C693_DEBUG_INFO */ 206#endif /* CY82C693_DEBUG_INFO */
212 207
213 /* 208 /*
@@ -230,39 +225,6 @@ static void cy82c693_dma_enable (ide_drive_t *drive, int mode, int single)
230#endif /* CY82C693_DEBUG_INFO */ 225#endif /* CY82C693_DEBUG_INFO */
231} 226}
232 227
233/*
234 * used to set DMA mode for CY82C693 (single and multi modes)
235 */
236static int cy82c693_ide_dma_on (ide_drive_t *drive)
237{
238 struct hd_driveid *id = drive->id;
239
240#if CY82C693_DEBUG_INFO
241 printk (KERN_INFO "dma_on: %s\n", drive->name);
242#endif /* CY82C693_DEBUG_INFO */
243
244 if (id != NULL) {
245 /* Enable DMA on any drive that has DMA
246 * (multi or single) enabled
247 */
248 if (id->field_valid & 2) { /* regular DMA */
249 int mmode, smode;
250
251 mmode = id->dma_mword & (id->dma_mword >> 8);
252 smode = id->dma_1word & (id->dma_1word >> 8);
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)