aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-06-11 14:31:43 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-06-11 14:31:43 -0400
commitbb3d2dd72302ea3eefcc6738cdd39ed5864b62f8 (patch)
tree94aea714ae4b2b39e05aeb32d0dffccc8a15a8a8 /drivers
parentd5a169c87967981d06616c3c99408bc40ec9f618 (diff)
parentc1183a3345f2e553fa0907a453cbb311c7e1698c (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6: ide: Add the MCP73/77 support to PATA driver Add the PATA controller device ID to pci_ids.h for MCP73/MCP77. hpt366: disallow Ultra133 for HPT374 ide: generic IDE PCI driver, add another device exception ide: HPA detect from resume it821x: RAID mode fixes serverworks: fix CSB6 tuning logic serverworks: remove crappy code
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ide/ide-disk.c12
-rw-r--r--drivers/ide/ide-probe.c12
-rw-r--r--drivers/ide/ide.c9
-rw-r--r--drivers/ide/pci/amd74xx.c12
-rw-r--r--drivers/ide/pci/generic.c37
-rw-r--r--drivers/ide/pci/hpt366.c8
-rw-r--r--drivers/ide/pci/it821x.c34
-rw-r--r--drivers/ide/pci/serverworks.c51
8 files changed, 112 insertions, 63 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 7fff773f2df7..dc2175c81f5e 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -1037,6 +1037,17 @@ static void ide_disk_release(struct kref *kref)
1037 1037
1038static int ide_disk_probe(ide_drive_t *drive); 1038static int ide_disk_probe(ide_drive_t *drive);
1039 1039
1040/*
1041 * On HPA drives the capacity needs to be
1042 * reinitilized on resume otherwise the disk
1043 * can not be used and a hard reset is required
1044 */
1045static void ide_disk_resume(ide_drive_t *drive)
1046{
1047 if (idedisk_supports_hpa(drive->id))
1048 init_idedisk_capacity(drive);
1049}
1050
1040static void ide_device_shutdown(ide_drive_t *drive) 1051static void ide_device_shutdown(ide_drive_t *drive)
1041{ 1052{
1042#ifdef CONFIG_ALPHA 1053#ifdef CONFIG_ALPHA
@@ -1071,6 +1082,7 @@ static ide_driver_t idedisk_driver = {
1071 }, 1082 },
1072 .probe = ide_disk_probe, 1083 .probe = ide_disk_probe,
1073 .remove = ide_disk_remove, 1084 .remove = ide_disk_remove,
1085 .resume = ide_disk_resume,
1074 .shutdown = ide_device_shutdown, 1086 .shutdown = ide_device_shutdown,
1075 .version = IDEDISK_VERSION, 1087 .version = IDEDISK_VERSION,
1076 .media = ide_disk, 1088 .media = ide_disk,
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 3cebed77f55d..41bfa4d21ab6 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -717,7 +717,7 @@ EXPORT_SYMBOL_GPL(ide_undecoded_slave);
717 * This routine only knows how to look for drive units 0 and 1 717 * This routine only knows how to look for drive units 0 and 1
718 * on an interface, so any setting of MAX_DRIVES > 2 won't work here. 718 * on an interface, so any setting of MAX_DRIVES > 2 won't work here.
719 */ 719 */
720static void probe_hwif(ide_hwif_t *hwif) 720static void probe_hwif(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif))
721{ 721{
722 unsigned int unit; 722 unsigned int unit;
723 unsigned long flags; 723 unsigned long flags;
@@ -820,6 +820,9 @@ static void probe_hwif(ide_hwif_t *hwif)
820 return; 820 return;
821 } 821 }
822 822
823 if (fixup)
824 fixup(hwif);
825
823 for (unit = 0; unit < MAX_DRIVES; ++unit) { 826 for (unit = 0; unit < MAX_DRIVES; ++unit) {
824 ide_drive_t *drive = &hwif->drives[unit]; 827 ide_drive_t *drive = &hwif->drives[unit];
825 828
@@ -874,10 +877,7 @@ static int hwif_init(ide_hwif_t *hwif);
874 877
875int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif)) 878int probe_hwif_init_with_fixup(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif))
876{ 879{
877 probe_hwif(hwif); 880 probe_hwif(hwif, fixup);
878
879 if (fixup)
880 fixup(hwif);
881 881
882 if (!hwif_init(hwif)) { 882 if (!hwif_init(hwif)) {
883 printk(KERN_INFO "%s: failed to initialize IDE interface\n", 883 printk(KERN_INFO "%s: failed to initialize IDE interface\n",
@@ -1404,7 +1404,7 @@ int ideprobe_init (void)
1404 1404
1405 for (index = 0; index < MAX_HWIFS; ++index) 1405 for (index = 0; index < MAX_HWIFS; ++index)
1406 if (probe[index]) 1406 if (probe[index])
1407 probe_hwif(&ide_hwifs[index]); 1407 probe_hwif(&ide_hwifs[index], NULL);
1408 for (index = 0; index < MAX_HWIFS; ++index) 1408 for (index = 0; index < MAX_HWIFS; ++index)
1409 if (probe[index]) 1409 if (probe[index])
1410 hwif_init(&ide_hwifs[index]); 1410 hwif_init(&ide_hwifs[index]);
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 6002713a20a1..0af0d1614f75 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -1010,9 +1010,11 @@ static int generic_ide_resume(struct device *dev)
1010{ 1010{
1011 ide_drive_t *drive = dev->driver_data; 1011 ide_drive_t *drive = dev->driver_data;
1012 ide_hwif_t *hwif = HWIF(drive); 1012 ide_hwif_t *hwif = HWIF(drive);
1013 ide_driver_t *drv = to_ide_driver(dev->driver);
1013 struct request rq; 1014 struct request rq;
1014 struct request_pm_state rqpm; 1015 struct request_pm_state rqpm;
1015 ide_task_t args; 1016 ide_task_t args;
1017 int err;
1016 1018
1017 /* Call ACPI _STM only once */ 1019 /* Call ACPI _STM only once */
1018 if (!(drive->dn % 2)) 1020 if (!(drive->dn % 2))
@@ -1029,7 +1031,12 @@ static int generic_ide_resume(struct device *dev)
1029 rqpm.pm_step = ide_pm_state_start_resume; 1031 rqpm.pm_step = ide_pm_state_start_resume;
1030 rqpm.pm_state = PM_EVENT_ON; 1032 rqpm.pm_state = PM_EVENT_ON;
1031 1033
1032 return ide_do_drive_cmd(drive, &rq, ide_head_wait); 1034 err = ide_do_drive_cmd(drive, &rq, ide_head_wait);
1035
1036 if (err == 0 && drv && drv->resume)
1037 drv->resume(drive);
1038
1039 return err;
1033} 1040}
1034 1041
1035int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device *bdev, 1042int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device *bdev,
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c
index becb1a5648b0..9db1be826e80 100644
--- a/drivers/ide/pci/amd74xx.c
+++ b/drivers/ide/pci/amd74xx.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Version 2.13 2 * Version 2.15
3 * 3 *
4 * AMD 755/756/766/8111 and nVidia nForce/2/2s/3/3s/CK804/MCP04 4 * AMD 755/756/766/8111 and nVidia nForce/2/2s/3/3s/CK804/MCP04
5 * IDE driver for Linux. 5 * IDE driver for Linux.
@@ -76,6 +76,8 @@ static struct amd_ide_chip {
76 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, 0x50, AMD_UDMA_133 }, 76 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, 0x50, AMD_UDMA_133 },
77 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, 0x50, AMD_UDMA_133 }, 77 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, 0x50, AMD_UDMA_133 },
78 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE, 0x50, AMD_UDMA_133 }, 78 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE, 0x50, AMD_UDMA_133 },
79 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE, 0x50, AMD_UDMA_133 },
80 { PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE, 0x50, AMD_UDMA_133 },
79 { PCI_DEVICE_ID_AMD_CS5536_IDE, 0x40, AMD_UDMA_100 }, 81 { PCI_DEVICE_ID_AMD_CS5536_IDE, 0x40, AMD_UDMA_100 },
80 { 0 } 82 { 0 }
81}; 83};
@@ -494,7 +496,9 @@ static ide_pci_device_t amd74xx_chipsets[] __devinitdata = {
494 /* 17 */ DECLARE_NV_DEV("NFORCE-MCP61"), 496 /* 17 */ DECLARE_NV_DEV("NFORCE-MCP61"),
495 /* 18 */ DECLARE_NV_DEV("NFORCE-MCP65"), 497 /* 18 */ DECLARE_NV_DEV("NFORCE-MCP65"),
496 /* 19 */ DECLARE_NV_DEV("NFORCE-MCP67"), 498 /* 19 */ DECLARE_NV_DEV("NFORCE-MCP67"),
497 /* 20 */ DECLARE_AMD_DEV("AMD5536"), 499 /* 20 */ DECLARE_NV_DEV("NFORCE-MCP73"),
500 /* 21 */ DECLARE_NV_DEV("NFORCE-MCP77"),
501 /* 22 */ DECLARE_AMD_DEV("AMD5536"),
498}; 502};
499 503
500static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id) 504static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id)
@@ -534,7 +538,9 @@ static struct pci_device_id amd74xx_pci_tbl[] = {
534 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 17 }, 538 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 17 },
535 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 18 }, 539 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 18 },
536 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 19 }, 540 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 19 },
537 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 20 }, 541 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 20 },
542 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 21 },
543 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 22 },
538 { 0, }, 544 { 0, },
539}; 545};
540MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl); 546MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl);
diff --git a/drivers/ide/pci/generic.c b/drivers/ide/pci/generic.c
index f2c5a141ca10..0d51a11e81da 100644
--- a/drivers/ide/pci/generic.c
+++ b/drivers/ide/pci/generic.c
@@ -198,32 +198,41 @@ static ide_pci_device_t generic_chipsets[] __devinitdata = {
198static int __devinit generic_init_one(struct pci_dev *dev, const struct pci_device_id *id) 198static int __devinit generic_init_one(struct pci_dev *dev, const struct pci_device_id *id)
199{ 199{
200 ide_pci_device_t *d = &generic_chipsets[id->driver_data]; 200 ide_pci_device_t *d = &generic_chipsets[id->driver_data];
201 u16 command;
202 int ret = -ENODEV; 201 int ret = -ENODEV;
203 202
204 /* Don't use the generic entry unless instructed to do so */ 203 /* Don't use the generic entry unless instructed to do so */
205 if (id->driver_data == 0 && ide_generic_all == 0) 204 if (id->driver_data == 0 && ide_generic_all == 0)
206 goto out; 205 goto out;
207 206
208 if (dev->vendor == PCI_VENDOR_ID_UMC && 207 switch (dev->vendor) {
209 dev->device == PCI_DEVICE_ID_UMC_UM8886A && 208 case PCI_VENDOR_ID_UMC:
210 (!(PCI_FUNC(dev->devfn) & 1))) 209 if (dev->device == PCI_DEVICE_ID_UMC_UM8886A &&
211 goto out; /* UM8886A/BF pair */ 210 !(PCI_FUNC(dev->devfn) & 1))
212 211 goto out; /* UM8886A/BF pair */
213 if (dev->vendor == PCI_VENDOR_ID_OPTI && 212 break;
214 dev->device == PCI_DEVICE_ID_OPTI_82C558 && 213 case PCI_VENDOR_ID_OPTI:
215 (!(PCI_FUNC(dev->devfn) & 1))) 214 if (dev->device == PCI_DEVICE_ID_OPTI_82C558 &&
216 goto out; 215 !(PCI_FUNC(dev->devfn) & 1))
217 216 goto out;
218 if (dev->vendor == PCI_VENDOR_ID_JMICRON) { 217 break;
219 if (dev->device != PCI_DEVICE_ID_JMICRON_JMB368 && PCI_FUNC(dev->devfn) != 1) 218 case PCI_VENDOR_ID_JMICRON:
219 if (dev->device != PCI_DEVICE_ID_JMICRON_JMB368 &&
220 PCI_FUNC(dev->devfn) != 1)
221 goto out;
222 break;
223 case PCI_VENDOR_ID_NS:
224 if (dev->device == PCI_DEVICE_ID_NS_87410 &&
225 (dev->class >> 8) != PCI_CLASS_STORAGE_IDE)
220 goto out; 226 goto out;
227 break;
221 } 228 }
222 229
223 if (dev->vendor != PCI_VENDOR_ID_JMICRON) { 230 if (dev->vendor != PCI_VENDOR_ID_JMICRON) {
231 u16 command;
224 pci_read_config_word(dev, PCI_COMMAND, &command); 232 pci_read_config_word(dev, PCI_COMMAND, &command);
225 if (!(command & PCI_COMMAND_IO)) { 233 if (!(command & PCI_COMMAND_IO)) {
226 printk(KERN_INFO "Skipping disabled %s IDE controller.\n", d->name); 234 printk(KERN_INFO "Skipping disabled %s IDE "
235 "controller.\n", d->name);
227 goto out; 236 goto out;
228 } 237 }
229 } 238 }
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index fcbc5605b38e..ce8a5449a574 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/ide/pci/hpt366.c Version 1.03 May 4, 2007 2 * linux/drivers/ide/pci/hpt366.c Version 1.04 Jun 4, 2007
3 * 3 *
4 * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> 4 * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org>
5 * Portions Copyright (C) 2001 Sun Microsystems, Inc. 5 * Portions Copyright (C) 2001 Sun Microsystems, Inc.
@@ -106,7 +106,8 @@
106 * switch to calculating PCI clock frequency based on the chip's base DPLL 106 * switch to calculating PCI clock frequency based on the chip's base DPLL
107 * frequency 107 * frequency
108 * - switch to using the DPLL clock and enable UltraATA/133 mode by default on 108 * - switch to using the DPLL clock and enable UltraATA/133 mode by default on
109 * anything newer than HPT370/A 109 * anything newer than HPT370/A (except HPT374 that is not capable of this
110 * mode according to the manual)
110 * - fold PCI clock detection and DPLL setup code into init_chipset_hpt366(), 111 * - fold PCI clock detection and DPLL setup code into init_chipset_hpt366(),
111 * also fixing the interchanged 25/40 MHz PCI clock cases for HPT36x chips; 112 * also fixing the interchanged 25/40 MHz PCI clock cases for HPT36x chips;
112 * unify HPT36x/37x timing setup code and the speedproc handlers by joining 113 * unify HPT36x/37x timing setup code and the speedproc handlers by joining
@@ -365,7 +366,6 @@ static u32 sixty_six_base_hpt37x[] = {
365}; 366};
366 367
367#define HPT366_DEBUG_DRIVE_INFO 0 368#define HPT366_DEBUG_DRIVE_INFO 0
368#define HPT374_ALLOW_ATA133_6 1
369#define HPT371_ALLOW_ATA133_6 1 369#define HPT371_ALLOW_ATA133_6 1
370#define HPT302_ALLOW_ATA133_6 1 370#define HPT302_ALLOW_ATA133_6 1
371#define HPT372_ALLOW_ATA133_6 1 371#define HPT372_ALLOW_ATA133_6 1
@@ -450,7 +450,7 @@ static struct hpt_info hpt370a __devinitdata = {
450 450
451static struct hpt_info hpt374 __devinitdata = { 451static struct hpt_info hpt374 __devinitdata = {
452 .chip_type = HPT374, 452 .chip_type = HPT374,
453 .max_mode = HPT374_ALLOW_ATA133_6 ? 4 : 3, 453 .max_mode = 3,
454 .dpll_clk = 48, 454 .dpll_clk = 48,
455 .settings = hpt37x_settings 455 .settings = hpt37x_settings
456}; 456};
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c
index 5faaff87d580..4bd4bf02e917 100644
--- a/drivers/ide/pci/it821x.c
+++ b/drivers/ide/pci/it821x.c
@@ -1,6 +1,6 @@
1 1
2/* 2/*
3 * linux/drivers/ide/pci/it821x.c Version 0.10 Mar 10 2007 3 * linux/drivers/ide/pci/it821x.c Version 0.15 Jun 2 2007
4 * 4 *
5 * Copyright (C) 2004 Red Hat <alan@redhat.com> 5 * Copyright (C) 2004 Red Hat <alan@redhat.com>
6 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz 6 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz
@@ -262,7 +262,7 @@ static int it821x_tunepio(ide_drive_t *drive, u8 set_pio)
262 } 262 }
263 263
264 if (itdev->smart) 264 if (itdev->smart)
265 goto set_drive_speed; 265 return 0;
266 266
267 /* We prefer 66Mhz clock for PIO 0-3, don't care for PIO4 */ 267 /* We prefer 66Mhz clock for PIO 0-3, don't care for PIO4 */
268 itdev->want[unit][1] = pio_want[set_pio]; 268 itdev->want[unit][1] = pio_want[set_pio];
@@ -271,7 +271,6 @@ static int it821x_tunepio(ide_drive_t *drive, u8 set_pio)
271 it821x_clock_strategy(drive); 271 it821x_clock_strategy(drive);
272 it821x_program(drive, itdev->pio[unit]); 272 it821x_program(drive, itdev->pio[unit]);
273 273
274set_drive_speed:
275 return ide_config_drive_speed(drive, XFER_PIO_0 + set_pio); 274 return ide_config_drive_speed(drive, XFER_PIO_0 + set_pio);
276} 275}
277 276
@@ -455,12 +454,12 @@ static int it821x_tune_chipset (ide_drive_t *drive, byte xferspeed)
455 default: 454 default:
456 return 1; 455 return 1;
457 } 456 }
457
458 return ide_config_drive_speed(drive, speed);
458 } 459 }
459 /* 460
460 * In smart mode the clocking is done by the host controller 461 /* don't touch anything in the smart mode */
461 * snooping the mode we picked. The rest of it is not our problem 462 return 0;
462 */
463 return ide_config_drive_speed(drive, speed);
464} 463}
465 464
466/** 465/**
@@ -559,17 +558,10 @@ static void __devinit it821x_fixups(ide_hwif_t *hwif)
559 if(idbits[129] != 1) 558 if(idbits[129] != 1)
560 printk("(%dK stripe)", idbits[146]); 559 printk("(%dK stripe)", idbits[146]);
561 printk(".\n"); 560 printk(".\n");
562 /* Now the core code will have wrongly decided no DMA
563 so we need to fix this */
564 hwif->dma_off_quietly(drive);
565#ifdef CONFIG_IDEDMA_ONLYDISK
566 if (drive->media == ide_disk)
567#endif
568 ide_set_dma(drive);
569 } else { 561 } else {
570 /* Non RAID volume. Fixups to stop the core code 562 /* Non RAID volume. Fixups to stop the core code
571 doing unsupported things */ 563 doing unsupported things */
572 id->field_valid &= 1; 564 id->field_valid &= 3;
573 id->queue_depth = 0; 565 id->queue_depth = 0;
574 id->command_set_1 = 0; 566 id->command_set_1 = 0;
575 id->command_set_2 &= 0xC400; 567 id->command_set_2 &= 0xC400;
@@ -584,6 +576,16 @@ static void __devinit it821x_fixups(ide_hwif_t *hwif)
584 printk(KERN_INFO "%s: Performing identify fixups.\n", 576 printk(KERN_INFO "%s: Performing identify fixups.\n",
585 drive->name); 577 drive->name);
586 } 578 }
579
580 /*
581 * Set MWDMA0 mode as enabled/support - just to tell
582 * IDE core that DMA is supported (it821x hardware
583 * takes care of DMA mode programming).
584 */
585 if (id->capability & 1) {
586 id->dma_mword |= 0x0101;
587 drive->current_speed = XFER_MW_DMA_0;
588 }
587 } 589 }
588 590
589} 591}
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c
index 47bcd91c9b5f..d9c4fd1ae996 100644
--- a/drivers/ide/pci/serverworks.c
+++ b/drivers/ide/pci/serverworks.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/ide/pci/serverworks.c Version 0.9 Mar 4 2007 2 * linux/drivers/ide/pci/serverworks.c Version 0.11 Jun 2 2007
3 * 3 *
4 * Copyright (C) 1998-2000 Michel Aubry 4 * Copyright (C) 1998-2000 Michel Aubry
5 * Copyright (C) 1998-2000 Andrzej Krzysztofowicz 5 * Copyright (C) 1998-2000 Andrzej Krzysztofowicz
@@ -170,42 +170,55 @@ static int svwks_tune_chipset (ide_drive_t *drive, u8 xferspeed)
170 if (!drive->init_speed) { 170 if (!drive->init_speed) {
171 u8 dma_stat = inb(hwif->dma_status); 171 u8 dma_stat = inb(hwif->dma_status);
172 172
173dma_pio:
174 if (((ultra_enable << (7-drive->dn) & 0x80) == 0x80) && 173 if (((ultra_enable << (7-drive->dn) & 0x80) == 0x80) &&
175 ((dma_stat & (1<<(5+unit))) == (1<<(5+unit)))) { 174 ((dma_stat & (1<<(5+unit))) == (1<<(5+unit)))) {
176 drive->current_speed = drive->init_speed = XFER_UDMA_0 + udma_modes[(ultra_timing >> (4*unit)) & ~(0xF0)]; 175 drive->current_speed = drive->init_speed = XFER_UDMA_0 + udma_modes[(ultra_timing >> (4*unit)) & ~(0xF0)];
177 return 0; 176 return 0;
178 } else if ((dma_timing) && 177 } else if ((dma_timing) &&
179 ((dma_stat&(1<<(5+unit)))==(1<<(5+unit)))) { 178 ((dma_stat&(1<<(5+unit)))==(1<<(5+unit)))) {
180 u8 dmaspeed = dma_timing; 179 u8 dmaspeed;
181 180
182 dma_timing &= ~0xFFU; 181 switch (dma_timing & 0x77) {
183 if ((dmaspeed & 0x20) == 0x20) 182 case 0x20:
184 dmaspeed = XFER_MW_DMA_2; 183 dmaspeed = XFER_MW_DMA_2;
185 else if ((dmaspeed & 0x21) == 0x21) 184 break;
185 case 0x21:
186 dmaspeed = XFER_MW_DMA_1; 186 dmaspeed = XFER_MW_DMA_1;
187 else if ((dmaspeed & 0x77) == 0x77) 187 break;
188 case 0x77:
188 dmaspeed = XFER_MW_DMA_0; 189 dmaspeed = XFER_MW_DMA_0;
189 else 190 break;
191 default:
190 goto dma_pio; 192 goto dma_pio;
193 }
194
191 drive->current_speed = drive->init_speed = dmaspeed; 195 drive->current_speed = drive->init_speed = dmaspeed;
192 return 0; 196 return 0;
193 } else if (pio_timing) { 197 }
194 u8 piospeed = pio_timing; 198dma_pio:
199 if (pio_timing) {
200 u8 piospeed;
195 201
196 pio_timing &= ~0xFFU; 202 switch (pio_timing & 0x7f) {
197 if ((piospeed & 0x20) == 0x20) 203 case 0x20:
198 piospeed = XFER_PIO_4; 204 piospeed = XFER_PIO_4;
199 else if ((piospeed & 0x22) == 0x22) 205 break;
206 case 0x22:
200 piospeed = XFER_PIO_3; 207 piospeed = XFER_PIO_3;
201 else if ((piospeed & 0x34) == 0x34) 208 break;
209 case 0x34:
202 piospeed = XFER_PIO_2; 210 piospeed = XFER_PIO_2;
203 else if ((piospeed & 0x47) == 0x47) 211 break;
212 case 0x47:
204 piospeed = XFER_PIO_1; 213 piospeed = XFER_PIO_1;
205 else if ((piospeed & 0x5d) == 0x5d) 214 break;
215 case 0x5d:
206 piospeed = XFER_PIO_0; 216 piospeed = XFER_PIO_0;
207 else 217 break;
218 default:
208 goto oem_setup_failed; 219 goto oem_setup_failed;
220 }
221
209 drive->current_speed = drive->init_speed = piospeed; 222 drive->current_speed = drive->init_speed = piospeed;
210 return 0; 223 return 0;
211 } 224 }
@@ -214,8 +227,8 @@ dma_pio:
214 227
215oem_setup_failed: 228oem_setup_failed:
216 229
217 pio_timing &= ~0xFFU; 230 pio_timing = 0;
218 dma_timing &= ~0xFFU; 231 dma_timing = 0;
219 ultra_timing &= ~(0x0F << (4*unit)); 232 ultra_timing &= ~(0x0F << (4*unit));
220 ultra_enable &= ~(0x01 << drive->dn); 233 ultra_enable &= ~(0x01 << drive->dn);
221 csb5_pio &= ~(0x0F << (4*drive->dn)); 234 csb5_pio &= ~(0x0F << (4*drive->dn));