aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 19:56:35 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 19:56:35 -0400
commit2b0460b534f383eca744eb8fff66ec9f57e702b9 (patch)
tree1bf4b9d0ebccd3083da4de7e4273b8d29f5d5c5d
parentd91f5bb69adde86173071cf7fffbdf705ae8c6e7 (diff)
parentb02fcae007ac64012806bc57054e7fee6e2ffe5e (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: (33 commits) amd74xx: remove /proc/ide/amd74xx amd74xx/via82cxxx: don't initialize drive->dn sis5513: remove /proc/ide/sis ide: remove CONFIG_IDEDMA_ONLYDISK ide: add "hdx=nodma" kernel parameter ide: remove hwif->autodma and drive->autodma ide: remove "idex=dma" kernel parameter ide: remove CONFIG_BLK_DEV_IDEDMA_FORCED ide: use PCI_VDEVICE() macro sis5513: clear prefetch and postwrite for ATAPI devices it8213/piix/slc90e66: "de-couple" PIO and UDMA modes ide: unexport noautodma ide: unexport ide_tune_dma ide: remove ->ide_dma_check (take 2) ide-pmac: add PIO autotune fallback to ->ide_dma_check ide-cris: add PIO autotune fallback to ->ide_dma_check sl82c105: add PIO autotune fallback to ->ide_dma_check cs5530/sc1200: add PIO autotune fallback to ->ide_dma_check ide: remove ide_use_fast_pio() ide: remove drive->init_speed zeroing ...
-rw-r--r--Documentation/ide.txt6
-rw-r--r--drivers/ide/Kconfig18
-rw-r--r--drivers/ide/arm/icside.c17
-rw-r--r--drivers/ide/cris/ide-cris.c15
-rw-r--r--drivers/ide/ide-dma.c77
-rw-r--r--drivers/ide/ide-io.c4
-rw-r--r--drivers/ide/ide-iops.c4
-rw-r--r--drivers/ide/ide-lib.c15
-rw-r--r--drivers/ide/ide-probe.c16
-rw-r--r--drivers/ide/ide.c19
-rw-r--r--drivers/ide/legacy/ide-cs.c12
-rw-r--r--drivers/ide/mips/au1xxx-ide.c38
-rw-r--r--drivers/ide/pci/aec62xx.c36
-rw-r--r--drivers/ide/pci/alim15x3.c34
-rw-r--r--drivers/ide/pci/amd74xx.c197
-rw-r--r--drivers/ide/pci/atiixp.c93
-rw-r--r--drivers/ide/pci/cmd64x.c27
-rw-r--r--drivers/ide/pci/cs5520.c25
-rw-r--r--drivers/ide/pci/cs5530.c45
-rw-r--r--drivers/ide/pci/cs5535.c28
-rw-r--r--drivers/ide/pci/cy82c693.c12
-rw-r--r--drivers/ide/pci/generic.c57
-rw-r--r--drivers/ide/pci/hpt34x.c28
-rw-r--r--drivers/ide/pci/hpt366.c41
-rw-r--r--drivers/ide/pci/it8213.c84
-rw-r--r--drivers/ide/pci/it821x.c50
-rw-r--r--drivers/ide/pci/jmicron.c32
-rw-r--r--drivers/ide/pci/ns87415.c11
-rw-r--r--drivers/ide/pci/opti621.c14
-rw-r--r--drivers/ide/pci/pdc202xx_new.c37
-rw-r--r--drivers/ide/pci/pdc202xx_old.c32
-rw-r--r--drivers/ide/pci/piix.c125
-rw-r--r--drivers/ide/pci/rz1000.c6
-rw-r--r--drivers/ide/pci/sc1200.c30
-rw-r--r--drivers/ide/pci/scc_pata.c33
-rw-r--r--drivers/ide/pci/serverworks.c33
-rw-r--r--drivers/ide/pci/sgiioc4.c22
-rw-r--r--drivers/ide/pci/siimage.c42
-rw-r--r--drivers/ide/pci/sis5513.c462
-rw-r--r--drivers/ide/pci/sl82c105.c22
-rw-r--r--drivers/ide/pci/slc90e66.c67
-rw-r--r--drivers/ide/pci/tc86c001.c21
-rw-r--r--drivers/ide/pci/triflex.c21
-rw-r--r--drivers/ide/pci/trm290.c10
-rw-r--r--drivers/ide/pci/via82cxxx.c37
-rw-r--r--drivers/ide/ppc/pmac.c34
-rw-r--r--drivers/ide/setup-pci.c48
-rw-r--r--include/linux/ide.h11
48 files changed, 449 insertions, 1699 deletions
diff --git a/Documentation/ide.txt b/Documentation/ide.txt
index 3bb9f9c98611..1d50f23a5cab 100644
--- a/Documentation/ide.txt
+++ b/Documentation/ide.txt
@@ -242,6 +242,8 @@ Summary of ide driver parameters for kernel command line
242 and quite likely to cause trouble with 242 and quite likely to cause trouble with
243 older/odd IDE drives. 243 older/odd IDE drives.
244 244
245 "hdx=nodma" : disallow DMA
246
245 "hdx=swapdata" : when the drive is a disk, byte swap all data 247 "hdx=swapdata" : when the drive is a disk, byte swap all data
246 248
247 "hdx=bswap" : same as above.......... 249 "hdx=bswap" : same as above..........
@@ -278,8 +280,6 @@ Summary of ide driver parameters for kernel command line
278 "idex=four" : four drives on idex and ide(x^1) share same ports 280 "idex=four" : four drives on idex and ide(x^1) share same ports
279 281
280 "idex=reset" : reset interface after probe 282 "idex=reset" : reset interface after probe
281
282 "idex=dma" : automatically configure/use DMA if possible.
283 283
284 "idex=ata66" : informs the interface that it has an 80c cable 284 "idex=ata66" : informs the interface that it has an 80c cable
285 for chipsets that are ATA-66 capable, but the 285 for chipsets that are ATA-66 capable, but the
@@ -288,8 +288,6 @@ Summary of ide driver parameters for kernel command line
288 288
289 "ide=reverse" : formerly called to pci sub-system, but now local. 289 "ide=reverse" : formerly called to pci sub-system, but now local.
290 290
291 "ide=nodma" : disable DMA globally for the IDE subsystem.
292
293The following are valid ONLY on ide0, which usually corresponds 291The following are valid ONLY on ide0, which usually corresponds
294to the first ATA interface found on the particular host, and the defaults for 292to the first ATA interface found on the particular host, and the defaults for
295the base,ctl ports must not be altered. 293the base,ctl ports must not be altered.
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 8982c0932438..6d9fd92763f4 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -435,24 +435,6 @@ config BLK_DEV_IDEDMA_PCI
435 bool 435 bool
436 select BLK_DEV_IDEPCI 436 select BLK_DEV_IDEPCI
437 437
438config BLK_DEV_IDEDMA_FORCED
439 bool "Force enable legacy 2.0.X HOSTS to use DMA"
440 depends on BLK_DEV_IDEDMA_PCI
441 help
442 This is an old piece of lost code from Linux 2.0 Kernels.
443
444 Generally say N here.
445
446# TODO: remove it
447config IDEDMA_ONLYDISK
448 bool "Enable DMA only for disks "
449 depends on BLK_DEV_IDEDMA_PCI
450 help
451 This is used if you know your ATAPI Devices are going to fail DMA
452 Transfers.
453
454 Generally say N here.
455
456config BLK_DEV_AEC62XX 438config BLK_DEV_AEC62XX
457 tristate "AEC62XX chipset support" 439 tristate "AEC62XX chipset support"
458 select BLK_DEV_IDEDMA_PCI 440 select BLK_DEV_IDEDMA_PCI
diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c
index bd1f5b670378..e4875cef78bb 100644
--- a/drivers/ide/arm/icside.c
+++ b/drivers/ide/arm/icside.c
@@ -309,14 +309,6 @@ static int icside_dma_on(ide_drive_t *drive)
309 return 0; 309 return 0;
310} 310}
311 311
312static int icside_dma_check(ide_drive_t *drive)
313{
314 if (ide_tune_dma(drive))
315 return 0;
316
317 return -1;
318}
319
320static int icside_dma_end(ide_drive_t *drive) 312static int icside_dma_end(ide_drive_t *drive)
321{ 313{
322 ide_hwif_t *hwif = HWIF(drive); 314 ide_hwif_t *hwif = HWIF(drive);
@@ -423,8 +415,6 @@ static void icside_dma_lost_irq(ide_drive_t *drive)
423 415
424static void icside_dma_init(ide_hwif_t *hwif) 416static void icside_dma_init(ide_hwif_t *hwif)
425{ 417{
426 printk(" %s: SG-DMA", hwif->name);
427
428 hwif->atapi_dma = 1; 418 hwif->atapi_dma = 1;
429 hwif->mwdma_mask = 7; /* MW0..2 */ 419 hwif->mwdma_mask = 7; /* MW0..2 */
430 hwif->swdma_mask = 7; /* SW0..2 */ 420 hwif->swdma_mask = 7; /* SW0..2 */
@@ -432,9 +422,7 @@ static void icside_dma_init(ide_hwif_t *hwif)
432 hwif->dmatable_cpu = NULL; 422 hwif->dmatable_cpu = NULL;
433 hwif->dmatable_dma = 0; 423 hwif->dmatable_dma = 0;
434 hwif->set_dma_mode = icside_set_dma_mode; 424 hwif->set_dma_mode = icside_set_dma_mode;
435 hwif->autodma = 1;
436 425
437 hwif->ide_dma_check = icside_dma_check;
438 hwif->dma_host_off = icside_dma_host_off; 426 hwif->dma_host_off = icside_dma_host_off;
439 hwif->dma_off_quietly = icside_dma_off_quietly; 427 hwif->dma_off_quietly = icside_dma_off_quietly;
440 hwif->dma_host_on = icside_dma_host_on; 428 hwif->dma_host_on = icside_dma_host_on;
@@ -446,11 +434,6 @@ static void icside_dma_init(ide_hwif_t *hwif)
446 hwif->ide_dma_test_irq = icside_dma_test_irq; 434 hwif->ide_dma_test_irq = icside_dma_test_irq;
447 hwif->dma_timeout = icside_dma_timeout; 435 hwif->dma_timeout = icside_dma_timeout;
448 hwif->dma_lost_irq = icside_dma_lost_irq; 436 hwif->dma_lost_irq = icside_dma_lost_irq;
449
450 hwif->drives[0].autodma = hwif->autodma;
451 hwif->drives[1].autodma = hwif->autodma;
452
453 printk(" capable%s\n", hwif->autodma ? ", auto-enable" : "");
454} 437}
455#else 438#else
456#define icside_dma_init(hwif) (0) 439#define icside_dma_init(hwif) (0)
diff --git a/drivers/ide/cris/ide-cris.c b/drivers/ide/cris/ide-cris.c
index c306c9f534ab..06c75f18eb88 100644
--- a/drivers/ide/cris/ide-cris.c
+++ b/drivers/ide/cris/ide-cris.c
@@ -664,7 +664,6 @@ cris_ide_inb(unsigned long reg)
664 return (unsigned char)cris_ide_inw(reg); 664 return (unsigned char)cris_ide_inw(reg);
665} 665}
666 666
667static int cris_dma_check (ide_drive_t *drive);
668static int cris_dma_end (ide_drive_t *drive); 667static int cris_dma_end (ide_drive_t *drive);
669static int cris_dma_setup (ide_drive_t *drive); 668static int cris_dma_setup (ide_drive_t *drive);
670static void cris_dma_exec_cmd (ide_drive_t *drive, u8 command); 669static void cris_dma_exec_cmd (ide_drive_t *drive, u8 command);
@@ -792,7 +791,6 @@ init_e100_ide (void)
792 hwif->ata_output_data = &cris_ide_output_data; 791 hwif->ata_output_data = &cris_ide_output_data;
793 hwif->atapi_input_bytes = &cris_atapi_input_bytes; 792 hwif->atapi_input_bytes = &cris_atapi_input_bytes;
794 hwif->atapi_output_bytes = &cris_atapi_output_bytes; 793 hwif->atapi_output_bytes = &cris_atapi_output_bytes;
795 hwif->ide_dma_check = &cris_dma_check;
796 hwif->ide_dma_end = &cris_dma_end; 794 hwif->ide_dma_end = &cris_dma_end;
797 hwif->dma_setup = &cris_dma_setup; 795 hwif->dma_setup = &cris_dma_setup;
798 hwif->dma_exec_cmd = &cris_dma_exec_cmd; 796 hwif->dma_exec_cmd = &cris_dma_exec_cmd;
@@ -808,11 +806,10 @@ init_e100_ide (void)
808 hwif->dma_off_quietly = &cris_dma_off; 806 hwif->dma_off_quietly = &cris_dma_off;
809 hwif->cbl = ATA_CBL_PATA40; 807 hwif->cbl = ATA_CBL_PATA40;
810 hwif->pio_mask = ATA_PIO4, 808 hwif->pio_mask = ATA_PIO4,
809 hwif->drives[0].autotune = 1;
810 hwif->drives[1].autotune = 1;
811 hwif->ultra_mask = cris_ultra_mask; 811 hwif->ultra_mask = cris_ultra_mask;
812 hwif->mwdma_mask = 0x07; /* Multiword DMA 0-2 */ 812 hwif->mwdma_mask = 0x07; /* Multiword DMA 0-2 */
813 hwif->autodma = 1;
814 hwif->drives[0].autodma = 1;
815 hwif->drives[1].autodma = 1;
816 } 813 }
817 814
818 /* Reset pulse */ 815 /* Reset pulse */
@@ -1018,14 +1015,6 @@ static ide_startstop_t cris_dma_intr (ide_drive_t *drive)
1018 * the caller should revert to PIO for the current request. 1015 * the caller should revert to PIO for the current request.
1019 */ 1016 */
1020 1017
1021static int cris_dma_check(ide_drive_t *drive)
1022{
1023 if (ide_tune_dma(drive))
1024 return 0;
1025
1026 return -1;
1027}
1028
1029static int cris_dma_end(ide_drive_t *drive) 1018static int cris_dma_end(ide_drive_t *drive)
1030{ 1019{
1031 drive->waiting_for_dma = 0; 1020 drive->waiting_for_dma = 0;
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index a4cbbbaccde9..bc57ce6bf0b3 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -338,35 +338,30 @@ static int config_drive_for_dma (ide_drive_t *drive)
338 ide_hwif_t *hwif = drive->hwif; 338 ide_hwif_t *hwif = drive->hwif;
339 struct hd_driveid *id = drive->id; 339 struct hd_driveid *id = drive->id;
340 340
341 /* consult the list of known "bad" drives */
342 if (__ide_dma_bad_drive(drive))
343 return -1;
344
345 if (drive->media != ide_disk && hwif->atapi_dma == 0) 341 if (drive->media != ide_disk && hwif->atapi_dma == 0)
346 return -1; 342 return 0;
347 343
348 if ((id->capability & 1) && drive->autodma) { 344 /*
349 /* 345 * Enable DMA on any drive that has
350 * Enable DMA on any drive that has 346 * UltraDMA (mode 0/1/2/3/4/5/6) enabled
351 * UltraDMA (mode 0/1/2/3/4/5/6) enabled 347 */
352 */ 348 if ((id->field_valid & 4) && ((id->dma_ultra >> 8) & 0x7f))
353 if ((id->field_valid & 4) && ((id->dma_ultra >> 8) & 0x7f)) 349 return 1;
354 return 0; 350
355 /* 351 /*
356 * Enable DMA on any drive that has mode2 DMA 352 * Enable DMA on any drive that has mode2 DMA
357 * (multi or single) enabled 353 * (multi or single) enabled
358 */ 354 */
359 if (id->field_valid & 2) /* regular DMA */ 355 if (id->field_valid & 2) /* regular DMA */
360 if ((id->dma_mword & 0x404) == 0x404 || 356 if ((id->dma_mword & 0x404) == 0x404 ||
361 (id->dma_1word & 0x404) == 0x404) 357 (id->dma_1word & 0x404) == 0x404)
362 return 0; 358 return 1;
363 359
364 /* Consult the list of known "good" drives */ 360 /* Consult the list of known "good" drives */
365 if (ide_dma_good_drive(drive)) 361 if (ide_dma_good_drive(drive))
366 return 0; 362 return 1;
367 }
368 363
369 return -1; 364 return 0;
370} 365}
371 366
372/** 367/**
@@ -627,6 +622,8 @@ static int __ide_dma_test_irq(ide_drive_t *drive)
627 drive->name, __FUNCTION__); 622 drive->name, __FUNCTION__);
628 return 0; 623 return 0;
629} 624}
625#else
626static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; }
630#endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ 627#endif /* CONFIG_BLK_DEV_IDEDMA_PCI */
631 628
632int __ide_dma_bad_drive (ide_drive_t *drive) 629int __ide_dma_bad_drive (ide_drive_t *drive)
@@ -758,17 +755,20 @@ u8 ide_find_dma_mode(ide_drive_t *drive, u8 req_mode)
758 755
759EXPORT_SYMBOL_GPL(ide_find_dma_mode); 756EXPORT_SYMBOL_GPL(ide_find_dma_mode);
760 757
761int ide_tune_dma(ide_drive_t *drive) 758static int ide_tune_dma(ide_drive_t *drive)
762{ 759{
763 u8 speed; 760 u8 speed;
764 761
765 if ((drive->id->capability & 1) == 0 || drive->autodma == 0) 762 if (noautodma || drive->nodma || (drive->id->capability & 1) == 0)
766 return 0; 763 return 0;
767 764
768 /* consult the list of known "bad" drives */ 765 /* consult the list of known "bad" drives */
769 if (__ide_dma_bad_drive(drive)) 766 if (__ide_dma_bad_drive(drive))
770 return 0; 767 return 0;
771 768
769 if (drive->hwif->host_flags & IDE_HFLAG_TRUST_BIOS_FOR_DMA)
770 return config_drive_for_dma(drive);
771
772 speed = ide_max_dma_mode(drive); 772 speed = ide_max_dma_mode(drive);
773 773
774 if (!speed) 774 if (!speed)
@@ -783,7 +783,22 @@ int ide_tune_dma(ide_drive_t *drive)
783 return 1; 783 return 1;
784} 784}
785 785
786EXPORT_SYMBOL_GPL(ide_tune_dma); 786static int ide_dma_check(ide_drive_t *drive)
787{
788 ide_hwif_t *hwif = drive->hwif;
789 int vdma = (hwif->host_flags & IDE_HFLAG_VDMA)? 1 : 0;
790
791 if (!vdma && ide_tune_dma(drive))
792 return 0;
793
794 /* TODO: always do PIO fallback */
795 if (hwif->host_flags & IDE_HFLAG_TRUST_BIOS_FOR_DMA)
796 return -1;
797
798 ide_set_max_pio(drive);
799
800 return vdma ? 0 : -1;
801}
787 802
788void ide_dma_verbose(ide_drive_t *drive) 803void ide_dma_verbose(ide_drive_t *drive)
789{ 804{
@@ -842,7 +857,7 @@ int ide_set_dma(ide_drive_t *drive)
842 ide_hwif_t *hwif = drive->hwif; 857 ide_hwif_t *hwif = drive->hwif;
843 int rc; 858 int rc;
844 859
845 rc = hwif->ide_dma_check(drive); 860 rc = ide_dma_check(drive);
846 861
847 switch(rc) { 862 switch(rc) {
848 case -1: /* DMA needs to be disabled */ 863 case -1: /* DMA needs to be disabled */
@@ -1019,8 +1034,6 @@ void ide_setup_dma (ide_hwif_t *hwif, unsigned long dma_base, unsigned int num_p
1019 hwif->ide_dma_on = &__ide_dma_on; 1034 hwif->ide_dma_on = &__ide_dma_on;
1020 if (!hwif->dma_host_on) 1035 if (!hwif->dma_host_on)
1021 hwif->dma_host_on = &ide_dma_host_on; 1036 hwif->dma_host_on = &ide_dma_host_on;
1022 if (!hwif->ide_dma_check)
1023 hwif->ide_dma_check = &config_drive_for_dma;
1024 if (!hwif->dma_setup) 1037 if (!hwif->dma_setup)
1025 hwif->dma_setup = &ide_dma_setup; 1038 hwif->dma_setup = &ide_dma_setup;
1026 if (!hwif->dma_exec_cmd) 1039 if (!hwif->dma_exec_cmd)
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 04273d3c147c..ec835e37e729 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -219,11 +219,11 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *
219 219
220 case ide_pm_restore_dma: /* Resume step 3 (restore DMA) */ 220 case ide_pm_restore_dma: /* Resume step 3 (restore DMA) */
221 /* 221 /*
222 * Right now, all we do is call hwif->ide_dma_check(drive), 222 * Right now, all we do is call ide_set_dma(drive),
223 * we could be smarter and check for current xfer_speed 223 * we could be smarter and check for current xfer_speed
224 * in struct drive etc... 224 * in struct drive etc...
225 */ 225 */
226 if (drive->hwif->ide_dma_check == NULL) 226 if (drive->hwif->ide_dma_on == NULL)
227 break; 227 break;
228 drive->hwif->dma_off_quietly(drive); 228 drive->hwif->dma_off_quietly(drive);
229 /* 229 /*
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index aa738833bed5..d4d790f91f91 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -776,7 +776,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
776// msleep(50); 776// msleep(50);
777 777
778#ifdef CONFIG_BLK_DEV_IDEDMA 778#ifdef CONFIG_BLK_DEV_IDEDMA
779 if (hwif->ide_dma_check) /* check if host supports DMA */ 779 if (hwif->ide_dma_on) /* check if host supports DMA */
780 hwif->dma_host_off(drive); 780 hwif->dma_host_off(drive);
781#endif 781#endif
782 782
@@ -830,7 +830,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
830#ifdef CONFIG_BLK_DEV_IDEDMA 830#ifdef CONFIG_BLK_DEV_IDEDMA
831 if (speed >= XFER_SW_DMA_0) 831 if (speed >= XFER_SW_DMA_0)
832 hwif->dma_host_on(drive); 832 hwif->dma_host_on(drive);
833 else if (hwif->ide_dma_check) /* check if host supports DMA */ 833 else if (hwif->ide_dma_on) /* check if host supports DMA */
834 hwif->dma_off_quietly(drive); 834 hwif->dma_off_quietly(drive);
835#endif 835#endif
836 836
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
index 0e2562f0f74e..af86433baede 100644
--- a/drivers/ide/ide-lib.c
+++ b/drivers/ide/ide-lib.c
@@ -96,21 +96,6 @@ static u8 ide_rate_filter(ide_drive_t *drive, u8 speed)
96 return min(speed, mode); 96 return min(speed, mode);
97} 97}
98 98
99int ide_use_fast_pio(ide_drive_t *drive)
100{
101 struct hd_driveid *id = drive->id;
102
103 if ((id->capability & 1) && drive->autodma)
104 return 1;
105
106 if ((id->capability & 8) || (id->field_valid & 2))
107 return 1;
108
109 return 0;
110}
111
112EXPORT_SYMBOL_GPL(ide_use_fast_pio);
113
114/* 99/*
115 * Standard (generic) timings for PIO modes, from ATA2 specification. 100 * Standard (generic) timings for PIO modes, from ATA2 specification.
116 * These timings are for access to the IDE data port register *only*. 101 * These timings are for access to the IDE data port register *only*.
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 34b1fb65bc79..3c945d64d845 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -835,16 +835,7 @@ static void probe_hwif(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif))
835 835
836 drive->nice1 = 1; 836 drive->nice1 = 1;
837 837
838 /* 838 if (hwif->ide_dma_on) {
839 * MAJOR HACK BARF :-/
840 *
841 * FIXME: chipsets own this cruft!
842 */
843 /*
844 * Move here to prevent module loading clashing.
845 */
846 // drive->autodma = hwif->autodma;
847 if (hwif->ide_dma_check) {
848 /* 839 /*
849 * Force DMAing for the beginning of the check. 840 * Force DMAing for the beginning of the check.
850 * Some chipsets appear to do interesting 841 * Some chipsets appear to do interesting
@@ -852,10 +843,7 @@ static void probe_hwif(ide_hwif_t *hwif, void (*fixup)(ide_hwif_t *hwif))
852 * PARANOIA!!! 843 * PARANOIA!!!
853 */ 844 */
854 hwif->dma_off_quietly(drive); 845 hwif->dma_off_quietly(drive);
855#ifdef CONFIG_IDEDMA_ONLYDISK 846 ide_set_dma(drive);
856 if (drive->media == ide_disk)
857#endif
858 ide_set_dma(drive);
859 } 847 }
860 } 848 }
861 } 849 }
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 5c0e4078b5cb..5b090662683e 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -100,8 +100,6 @@ static int ide_scan_direction; /* THIS was formerly 2.2.x pci=reverse */
100 100
101int noautodma = 0; 101int noautodma = 0;
102 102
103EXPORT_SYMBOL(noautodma);
104
105#ifdef CONFIG_BLK_DEV_IDEACPI 103#ifdef CONFIG_BLK_DEV_IDEACPI
106int ide_noacpi = 0; 104int ide_noacpi = 0;
107int ide_noacpitfs = 1; 105int ide_noacpitfs = 1;
@@ -418,7 +416,6 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif)
418 hwif->dma_exec_cmd = tmp_hwif->dma_exec_cmd; 416 hwif->dma_exec_cmd = tmp_hwif->dma_exec_cmd;
419 hwif->dma_start = tmp_hwif->dma_start; 417 hwif->dma_start = tmp_hwif->dma_start;
420 hwif->ide_dma_end = tmp_hwif->ide_dma_end; 418 hwif->ide_dma_end = tmp_hwif->ide_dma_end;
421 hwif->ide_dma_check = tmp_hwif->ide_dma_check;
422 hwif->ide_dma_on = tmp_hwif->ide_dma_on; 419 hwif->ide_dma_on = tmp_hwif->ide_dma_on;
423 hwif->dma_off_quietly = tmp_hwif->dma_off_quietly; 420 hwif->dma_off_quietly = tmp_hwif->dma_off_quietly;
424 hwif->ide_dma_test_irq = tmp_hwif->ide_dma_test_irq; 421 hwif->ide_dma_test_irq = tmp_hwif->ide_dma_test_irq;
@@ -461,7 +458,6 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif)
461 hwif->select_data = tmp_hwif->select_data; 458 hwif->select_data = tmp_hwif->select_data;
462 hwif->extra_base = tmp_hwif->extra_base; 459 hwif->extra_base = tmp_hwif->extra_base;
463 hwif->extra_ports = tmp_hwif->extra_ports; 460 hwif->extra_ports = tmp_hwif->extra_ports;
464 hwif->autodma = tmp_hwif->autodma;
465 461
466 hwif->hwif_data = tmp_hwif->hwif_data; 462 hwif->hwif_data = tmp_hwif->hwif_data;
467} 463}
@@ -823,7 +819,7 @@ int set_using_dma(ide_drive_t *drive, int arg)
823 if (!drive->id || !(drive->id->capability & 1)) 819 if (!drive->id || !(drive->id->capability & 1))
824 goto out; 820 goto out;
825 821
826 if (hwif->ide_dma_check == NULL) 822 if (hwif->ide_dma_on == NULL)
827 goto out; 823 goto out;
828 824
829 err = -EBUSY; 825 err = -EBUSY;
@@ -1276,7 +1272,7 @@ static int __init ide_setup(char *s)
1276 if (!strcmp(s, "ide=nodma")) { 1272 if (!strcmp(s, "ide=nodma")) {
1277 printk(" : Prevented DMA\n"); 1273 printk(" : Prevented DMA\n");
1278 noautodma = 1; 1274 noautodma = 1;
1279 return 1; 1275 goto obsolete_option;
1280 } 1276 }
1281 1277
1282#ifdef CONFIG_IDEPCI_PCIBUS_ORDER 1278#ifdef CONFIG_IDEPCI_PCIBUS_ORDER
@@ -1310,7 +1306,7 @@ static int __init ide_setup(char *s)
1310 */ 1306 */
1311 if (s[0] == 'h' && s[1] == 'd' && s[2] >= 'a' && s[2] <= max_drive) { 1307 if (s[0] == 'h' && s[1] == 'd' && s[2] >= 'a' && s[2] <= max_drive) {
1312 const char *hd_words[] = { 1308 const char *hd_words[] = {
1313 "none", "noprobe", "nowerr", "cdrom", "minus5", 1309 "none", "noprobe", "nowerr", "cdrom", "nodma",
1314 "autotune", "noautotune", "minus8", "swapdata", "bswap", 1310 "autotune", "noautotune", "minus8", "swapdata", "bswap",
1315 "noflush", "remap", "remap63", "scsi", NULL }; 1311 "noflush", "remap", "remap63", "scsi", NULL };
1316 unit = s[2] - 'a'; 1312 unit = s[2] - 'a';
@@ -1338,6 +1334,9 @@ static int __init ide_setup(char *s)
1338 drive->ready_stat = 0; 1334 drive->ready_stat = 0;
1339 hwif->noprobe = 0; 1335 hwif->noprobe = 0;
1340 goto done; 1336 goto done;
1337 case -5: /* nodma */
1338 drive->nodma = 1;
1339 goto done;
1341 case -6: /* "autotune" */ 1340 case -6: /* "autotune" */
1342 drive->autotune = IDE_TUNE_AUTO; 1341 drive->autotune = IDE_TUNE_AUTO;
1343 goto obsolete_option; 1342 goto obsolete_option;
@@ -1399,7 +1398,7 @@ static int __init ide_setup(char *s)
1399 */ 1398 */
1400 static const char *ide_words[] = { 1399 static const char *ide_words[] = {
1401 "noprobe", "serialize", "minus3", "minus4", 1400 "noprobe", "serialize", "minus3", "minus4",
1402 "reset", "dma", "ata66", "minus8", "minus9", 1401 "reset", "minus6", "ata66", "minus8", "minus9",
1403 "minus10", "four", "qd65xx", "ht6560b", "cmd640_vlb", 1402 "minus10", "four", "qd65xx", "ht6560b", "cmd640_vlb",
1404 "dtc2278", "umc8672", "ali14xx", NULL }; 1403 "dtc2278", "umc8672", "ali14xx", NULL };
1405 hw = s[3] - '0'; 1404 hw = s[3] - '0';
@@ -1478,6 +1477,7 @@ static int __init ide_setup(char *s)
1478 case -10: /* minus10 */ 1477 case -10: /* minus10 */
1479 case -9: /* minus9 */ 1478 case -9: /* minus9 */
1480 case -8: /* minus8 */ 1479 case -8: /* minus8 */
1480 case -6:
1481 case -4: 1481 case -4:
1482 case -3: 1482 case -3:
1483 goto bad_option; 1483 goto bad_option;
@@ -1492,9 +1492,6 @@ static int __init ide_setup(char *s)
1492#else 1492#else
1493 goto bad_hwif; 1493 goto bad_hwif;
1494#endif 1494#endif
1495 case -6: /* dma */
1496 hwif->autodma = 1;
1497 goto obsolete_option;
1498 case -5: /* "reset" */ 1495 case -5: /* "reset" */
1499 hwif->reset = 1; 1496 hwif->reset = 1;
1500 goto obsolete_option; 1497 goto obsolete_option;
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
index 4cdb519f9832..e8e360c2619d 100644
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/legacy/ide-cs.c
@@ -28,7 +28,7 @@
28 and other provisions required by the GPL. If you do not delete 28 and other provisions required by the GPL. If you do not delete
29 the provisions above, a recipient may use your version of this 29 the provisions above, a recipient may use your version of this
30 file under either the MPL or the GPL. 30 file under either the MPL or the GPL.
31 31
32======================================================================*/ 32======================================================================*/
33 33
34#include <linux/module.h> 34#include <linux/module.h>
@@ -327,13 +327,13 @@ failed:
327 After a card is removed, ide_release() will unregister the net 327 After a card is removed, ide_release() will unregister the net
328 device, and release the PCMCIA configuration. If the device is 328 device, and release the PCMCIA configuration. If the device is
329 still open, this will be postponed until it is closed. 329 still open, this will be postponed until it is closed.
330 330
331======================================================================*/ 331======================================================================*/
332 332
333void ide_release(struct pcmcia_device *link) 333void ide_release(struct pcmcia_device *link)
334{ 334{
335 ide_info_t *info = link->priv; 335 ide_info_t *info = link->priv;
336 336
337 DEBUG(0, "ide_release(0x%p)\n", link); 337 DEBUG(0, "ide_release(0x%p)\n", link);
338 338
339 if (info->ndev) { 339 if (info->ndev) {
@@ -353,11 +353,12 @@ void ide_release(struct pcmcia_device *link)
353 stuff to run after an event is received. A CARD_REMOVAL event 353 stuff to run after an event is received. A CARD_REMOVAL event
354 also sets some flags to discourage the ide drivers from 354 also sets some flags to discourage the ide drivers from
355 talking to the ports. 355 talking to the ports.
356 356
357======================================================================*/ 357======================================================================*/
358 358
359static struct pcmcia_device_id ide_ids[] = { 359static struct pcmcia_device_id ide_ids[] = {
360 PCMCIA_DEVICE_FUNC_ID(4), 360 PCMCIA_DEVICE_FUNC_ID(4),
361 PCMCIA_DEVICE_MANF_CARD(0x0000, 0x0000), /* Corsair */
361 PCMCIA_DEVICE_MANF_CARD(0x0007, 0x0000), /* Hitachi */ 362 PCMCIA_DEVICE_MANF_CARD(0x0007, 0x0000), /* Hitachi */
362 PCMCIA_DEVICE_MANF_CARD(0x000a, 0x0000), /* I-O Data CFA */ 363 PCMCIA_DEVICE_MANF_CARD(0x000a, 0x0000), /* I-O Data CFA */
363 PCMCIA_DEVICE_MANF_CARD(0x001c, 0x0001), /* Mitsubishi CFA */ 364 PCMCIA_DEVICE_MANF_CARD(0x001c, 0x0001), /* Mitsubishi CFA */
@@ -366,7 +367,7 @@ static struct pcmcia_device_id ide_ids[] = {
366 PCMCIA_DEVICE_MANF_CARD(0x0098, 0x0000), /* Toshiba */ 367 PCMCIA_DEVICE_MANF_CARD(0x0098, 0x0000), /* Toshiba */
367 PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x002d), 368 PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x002d),
368 PCMCIA_DEVICE_MANF_CARD(0x00ce, 0x0000), /* Samsung */ 369 PCMCIA_DEVICE_MANF_CARD(0x00ce, 0x0000), /* Samsung */
369 PCMCIA_DEVICE_MANF_CARD(0x0319, 0x0000), /* Hitachi */ 370 PCMCIA_DEVICE_MANF_CARD(0x0319, 0x0000), /* Hitachi */
370 PCMCIA_DEVICE_MANF_CARD(0x2080, 0x0001), 371 PCMCIA_DEVICE_MANF_CARD(0x2080, 0x0001),
371 PCMCIA_DEVICE_MANF_CARD(0x4e01, 0x0100), /* Viking CFA */ 372 PCMCIA_DEVICE_MANF_CARD(0x4e01, 0x0100), /* Viking CFA */
372 PCMCIA_DEVICE_MANF_CARD(0x4e01, 0x0200), /* Lexar, Viking CFA */ 373 PCMCIA_DEVICE_MANF_CARD(0x4e01, 0x0200), /* Lexar, Viking CFA */
@@ -384,6 +385,7 @@ static struct pcmcia_device_id ide_ids[] = {
384 PCMCIA_DEVICE_PROD_ID12("FREECOM", "PCCARD-IDE", 0x5714cbf7, 0x48e0ab8e), 385 PCMCIA_DEVICE_PROD_ID12("FREECOM", "PCCARD-IDE", 0x5714cbf7, 0x48e0ab8e),
385 PCMCIA_DEVICE_PROD_ID12("HITACHI", "FLASH", 0xf4f43949, 0x9eb86aae), 386 PCMCIA_DEVICE_PROD_ID12("HITACHI", "FLASH", 0xf4f43949, 0x9eb86aae),
386 PCMCIA_DEVICE_PROD_ID12("HITACHI", "microdrive", 0xf4f43949, 0xa6d76178), 387 PCMCIA_DEVICE_PROD_ID12("HITACHI", "microdrive", 0xf4f43949, 0xa6d76178),
388 PCMCIA_DEVICE_PROD_ID12("Hyperstone", "Model1", 0x3d5b9ef5, 0xca6ab420),
387 PCMCIA_DEVICE_PROD_ID12("IBM", "microdrive", 0xb569a6e5, 0xa6d76178), 389 PCMCIA_DEVICE_PROD_ID12("IBM", "microdrive", 0xb569a6e5, 0xa6d76178),
388 PCMCIA_DEVICE_PROD_ID12("IBM", "IBM17JSSFP20", 0xb569a6e5, 0xf2508753), 390 PCMCIA_DEVICE_PROD_ID12("IBM", "IBM17JSSFP20", 0xb569a6e5, 0xf2508753),
389 PCMCIA_DEVICE_PROD_ID12("KINGSTON", "CF8GB", 0x2e6d1829, 0xacbe682e), 391 PCMCIA_DEVICE_PROD_ID12("KINGSTON", "CF8GB", 0x2e6d1829, 0xacbe682e),
diff --git a/drivers/ide/mips/au1xxx-ide.c b/drivers/ide/mips/au1xxx-ide.c
index 892d08f61dc0..47c035a550e3 100644
--- a/drivers/ide/mips/au1xxx-ide.c
+++ b/drivers/ide/mips/au1xxx-ide.c
@@ -351,11 +351,18 @@ static int auide_dma_setup(ide_drive_t *drive)
351 return 0; 351 return 0;
352} 352}
353 353
354static int auide_dma_check(ide_drive_t *drive) 354static u8 auide_mdma_filter(ide_drive_t *drive)
355{ 355{
356 u8 speed = ide_max_dma_mode(drive); 356 /*
357 * FIXME: ->white_list and ->black_list are based on completely bogus
358 * ->ide_dma_check implementation which didn't set neither the host
359 * controller timings nor the device for the desired transfer mode.
360 *
361 * They should be either removed or 0x00 MWDMA mask should be
362 * returned for devices on the ->black_list.
363 */
357 364
358 if( dbdma_init_done == 0 ){ 365 if (dbdma_init_done == 0) {
359 auide_hwif.white_list = ide_in_drive_list(drive->id, 366 auide_hwif.white_list = ide_in_drive_list(drive->id,
360 dma_white_list); 367 dma_white_list);
361 auide_hwif.black_list = ide_in_drive_list(drive->id, 368 auide_hwif.black_list = ide_in_drive_list(drive->id,
@@ -366,22 +373,11 @@ static int auide_dma_check(ide_drive_t *drive)
366 } 373 }
367 374
368 /* Is the drive in our DMA black list? */ 375 /* Is the drive in our DMA black list? */
369 376 if (auide_hwif.black_list)
370 if ( auide_hwif.black_list ) {
371 drive->using_dma = 0;
372
373 /* Borrowed the warning message from ide-dma.c */
374
375 printk(KERN_WARNING "%s: Disabling DMA for %s (blacklisted)\n", 377 printk(KERN_WARNING "%s: Disabling DMA for %s (blacklisted)\n",
376 drive->name, drive->id->model); 378 drive->name, drive->id->model);
377 }
378 else
379 drive->using_dma = 1;
380
381 if (drive->autodma && (speed & XFER_MODE) != XFER_PIO)
382 return 0;
383 379
384 return -1; 380 return drive->hwif->mwdma_mask;
385} 381}
386 382
387static int auide_dma_test_irq(ide_drive_t *drive) 383static int auide_dma_test_irq(ide_drive_t *drive)
@@ -692,7 +688,8 @@ static int au_ide_probe(struct device *dev)
692 hwif->dma_off_quietly = &auide_dma_off_quietly; 688 hwif->dma_off_quietly = &auide_dma_off_quietly;
693 hwif->dma_timeout = &auide_dma_timeout; 689 hwif->dma_timeout = &auide_dma_timeout;
694 690
695 hwif->ide_dma_check = &auide_dma_check; 691 hwif->mdma_filter = &auide_mdma_filter;
692
696 hwif->dma_exec_cmd = &auide_dma_exec_cmd; 693 hwif->dma_exec_cmd = &auide_dma_exec_cmd;
697 hwif->dma_start = &auide_dma_start; 694 hwif->dma_start = &auide_dma_start;
698 hwif->ide_dma_end = &auide_dma_end; 695 hwif->ide_dma_end = &auide_dma_end;
@@ -703,19 +700,14 @@ static int au_ide_probe(struct device *dev)
703 hwif->dma_lost_irq = &auide_dma_lost_irq; 700 hwif->dma_lost_irq = &auide_dma_lost_irq;
704 hwif->ide_dma_on = &auide_dma_on; 701 hwif->ide_dma_on = &auide_dma_on;
705 702
706 hwif->autodma = 1;
707 hwif->drives[0].autodma = hwif->autodma;
708 hwif->drives[1].autodma = hwif->autodma;
709 hwif->atapi_dma = 1; 703 hwif->atapi_dma = 1;
710 704
711#else /* !CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA */ 705#else /* !CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA */
712 hwif->autodma = 0;
713 hwif->channel = 0; 706 hwif->channel = 0;
714 hwif->hold = 1; 707 hwif->hold = 1;
715 hwif->select_data = 0; /* no chipset-specific code */ 708 hwif->select_data = 0; /* no chipset-specific code */
716 hwif->config_data = 0; /* no chipset-specific code */ 709 hwif->config_data = 0; /* no chipset-specific code */
717 710
718 hwif->drives[0].autodma = 0;
719 hwif->drives[0].autotune = 1; /* 1=autotune, 2=noautotune, 0=default */ 711 hwif->drives[0].autotune = 1; /* 1=autotune, 2=noautotune, 0=default */
720#endif 712#endif
721 hwif->drives[0].no_io_32bit = 1; 713 hwif->drives[0].no_io_32bit = 1;
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c
index d6cb2d5143c8..3a4c2c26a77e 100644
--- a/drivers/ide/pci/aec62xx.c
+++ b/drivers/ide/pci/aec62xx.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/ide/pci/aec62xx.c Version 0.24 May 24, 2007 2 * linux/drivers/ide/pci/aec62xx.c Version 0.25 Aug 1, 2007
3 * 3 *
4 * Copyright (C) 1999-2002 Andre Hedrick <andre@linux-ide.org> 4 * Copyright (C) 1999-2002 Andre Hedrick <andre@linux-ide.org>
5 * Copyright (C) 2007 MontaVista Software, Inc. <source@mvista.com> 5 * Copyright (C) 2007 MontaVista Software, Inc. <source@mvista.com>
@@ -141,17 +141,6 @@ static void aec_set_pio_mode(ide_drive_t *drive, const u8 pio)
141 drive->hwif->set_dma_mode(drive, pio + XFER_PIO_0); 141 drive->hwif->set_dma_mode(drive, pio + XFER_PIO_0);
142} 142}
143 143
144static int aec62xx_config_drive_xfer_rate (ide_drive_t *drive)
145{
146 if (ide_tune_dma(drive))
147 return 0;
148
149 if (ide_use_fast_pio(drive))
150 ide_set_max_pio(drive);
151
152 return -1;
153}
154
155static void aec62xx_dma_lost_irq (ide_drive_t *drive) 144static void aec62xx_dma_lost_irq (ide_drive_t *drive)
156{ 145{
157 switch (HWIF(drive)->pci_dev->device) { 146 switch (HWIF(drive)->pci_dev->device) {
@@ -207,15 +196,14 @@ static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif)
207 } else 196 } else
208 hwif->set_dma_mode = &aec6260_set_mode; 197 hwif->set_dma_mode = &aec6260_set_mode;
209 198
210 if (!hwif->dma_base) { 199 hwif->drives[0].autotune = hwif->drives[1].autotune = 1;
211 hwif->drives[0].autotune = hwif->drives[1].autotune = 1; 200
201 if (hwif->dma_base == 0)
212 return; 202 return;
213 }
214 203
215 hwif->ultra_mask = hwif->cds->udma_mask; 204 hwif->ultra_mask = hwif->cds->udma_mask;
216 hwif->mwdma_mask = 0x07; 205 hwif->mwdma_mask = 0x07;
217 206
218 hwif->ide_dma_check = &aec62xx_config_drive_xfer_rate;
219 hwif->dma_lost_irq = &aec62xx_dma_lost_irq; 207 hwif->dma_lost_irq = &aec62xx_dma_lost_irq;
220 208
221 if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF) { 209 if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF) {
@@ -230,10 +218,6 @@ static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif)
230 218
231 hwif->cbl = (ata66 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; 219 hwif->cbl = (ata66 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
232 } 220 }
233
234 if (!noautodma)
235 hwif->autodma = 1;
236 hwif->drives[0].autodma = hwif->drives[1].autodma = hwif->autodma;
237} 221}
238 222
239static int __devinit init_setup_aec62xx(struct pci_dev *dev, ide_pci_device_t *d) 223static int __devinit init_setup_aec62xx(struct pci_dev *dev, ide_pci_device_t *d)
@@ -325,12 +309,12 @@ static int __devinit aec62xx_init_one(struct pci_dev *dev, const struct pci_devi
325 return d.init_setup(dev, &d); 309 return d.init_setup(dev, &d);
326} 310}
327 311
328static struct pci_device_id aec62xx_pci_tbl[] = { 312static const struct pci_device_id aec62xx_pci_tbl[] = {
329 { PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP850UF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 313 { PCI_VDEVICE(ARTOP, PCI_DEVICE_ID_ARTOP_ATP850UF), 0 },
330 { PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP860, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 }, 314 { PCI_VDEVICE(ARTOP, PCI_DEVICE_ID_ARTOP_ATP860), 1 },
331 { PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP860R, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2 }, 315 { PCI_VDEVICE(ARTOP, PCI_DEVICE_ID_ARTOP_ATP860R), 2 },
332 { PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP865, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3 }, 316 { PCI_VDEVICE(ARTOP, PCI_DEVICE_ID_ARTOP_ATP865), 3 },
333 { PCI_VENDOR_ID_ARTOP, PCI_DEVICE_ID_ARTOP_ATP865R, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4 }, 317 { PCI_VDEVICE(ARTOP, PCI_DEVICE_ID_ARTOP_ATP865R), 4 },
334 { 0, }, 318 { 0, },
335}; 319};
336MODULE_DEVICE_TABLE(pci, aec62xx_pci_tbl); 320MODULE_DEVICE_TABLE(pci, aec62xx_pci_tbl);
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c
index 0b83443bf250..31d4e50647d5 100644
--- a/drivers/ide/pci/alim15x3.c
+++ b/drivers/ide/pci/alim15x3.c
@@ -437,26 +437,6 @@ static void ali_set_dma_mode(ide_drive_t *drive, const u8 speed)
437} 437}
438 438
439/** 439/**
440 * ali15x3_config_drive_for_dma - configure for DMA
441 * @drive: drive to configure
442 *
443 * Configure a drive for DMA operation. If DMA is not possible we
444 * drop the drive into PIO mode instead.
445 */
446
447static int ali15x3_config_drive_for_dma(ide_drive_t *drive)
448{
449 drive->init_speed = 0;
450
451 if (ide_tune_dma(drive))
452 return 0;
453
454 ide_set_max_pio(drive);
455
456 return -1;
457}
458
459/**
460 * ali15x3_dma_setup - begin a DMA phase 440 * ali15x3_dma_setup - begin a DMA phase
461 * @drive: target device 441 * @drive: target device
462 * 442 *
@@ -680,7 +660,6 @@ static u8 __devinit ata66_ali15x3(ide_hwif_t *hwif)
680 660
681static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif) 661static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif)
682{ 662{
683 hwif->autodma = 0;
684 hwif->set_pio_mode = &ali_set_pio_mode; 663 hwif->set_pio_mode = &ali_set_pio_mode;
685 hwif->set_dma_mode = &ali_set_dma_mode; 664 hwif->set_dma_mode = &ali_set_dma_mode;
686 hwif->udma_filter = &ali_udma_filter; 665 hwif->udma_filter = &ali_udma_filter;
@@ -715,17 +694,10 @@ static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif)
715 hwif->mwdma_mask = 0x07; 694 hwif->mwdma_mask = 0x07;
716 hwif->swdma_mask = 0x07; 695 hwif->swdma_mask = 0x07;
717 696
718 hwif->ide_dma_check = &ali15x3_config_drive_for_dma;
719 hwif->dma_setup = &ali15x3_dma_setup; 697 hwif->dma_setup = &ali15x3_dma_setup;
720 698
721 if (hwif->cbl != ATA_CBL_PATA40_SHORT) 699 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
722 hwif->cbl = ata66_ali15x3(hwif); 700 hwif->cbl = ata66_ali15x3(hwif);
723
724 if (!noautodma)
725 hwif->autodma = 1;
726
727 hwif->drives[0].autodma = hwif->autodma;
728 hwif->drives[1].autodma = hwif->autodma;
729} 701}
730 702
731/** 703/**
@@ -836,9 +808,9 @@ static int __devinit alim15x3_init_one(struct pci_dev *dev, const struct pci_dev
836} 808}
837 809
838 810
839static struct pci_device_id alim15x3_pci_tbl[] = { 811static const struct pci_device_id alim15x3_pci_tbl[] = {
840 { PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M5229, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 812 { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5229), 0 },
841 { PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M5228, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 813 { PCI_VDEVICE(AL, PCI_DEVICE_ID_AL_M5228), 0 },
842 { 0, }, 814 { 0, },
843}; 815};
844MODULE_DEVICE_TABLE(pci, alim15x3_pci_tbl); 816MODULE_DEVICE_TABLE(pci, alim15x3_pci_tbl);
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c
index 6ff4089a2379..3bf3d931eea1 100644
--- a/drivers/ide/pci/amd74xx.c
+++ b/drivers/ide/pci/amd74xx.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Version 2.23 2 * Version 2.24
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.
@@ -28,9 +28,6 @@
28 28
29#include "ide-timing.h" 29#include "ide-timing.h"
30 30
31#define DISPLAY_AMD_TIMINGS
32
33#define AMD_IDE_ENABLE (0x00 + amd_config->base)
34#define AMD_IDE_CONFIG (0x01 + amd_config->base) 31#define AMD_IDE_CONFIG (0x01 + amd_config->base)
35#define AMD_CABLE_DETECT (0x02 + amd_config->base) 32#define AMD_CABLE_DETECT (0x02 + amd_config->base)
36#define AMD_DRIVE_TIMING (0x08 + amd_config->base) 33#define AMD_DRIVE_TIMING (0x08 + amd_config->base)
@@ -88,118 +85,6 @@ static char *amd_dma[] = { "16", "25", "33", "44", "66", "100", "133" };
88static unsigned char amd_cyc2udma[] = { 6, 6, 5, 4, 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 7 }; 85static unsigned char amd_cyc2udma[] = { 6, 6, 5, 4, 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 7 };
89 86
90/* 87/*
91 * AMD /proc entry.
92 */
93
94#ifdef CONFIG_IDE_PROC_FS
95
96#include <linux/stat.h>
97#include <linux/proc_fs.h>
98
99static u8 amd74xx_proc;
100
101static unsigned char amd_udma2cyc[] = { 4, 6, 8, 10, 3, 2, 1, 15 };
102static unsigned long amd_base;
103static struct pci_dev *bmide_dev;
104extern int (*amd74xx_display_info)(char *, char **, off_t, int); /* ide-proc.c */
105
106#define amd_print(format, arg...) p += sprintf(p, format "\n" , ## arg)
107#define amd_print_drive(name, format, arg...)\
108 p += sprintf(p, name); for (i = 0; i < 4; i++) p += sprintf(p, format, ## arg); p += sprintf(p, "\n");
109
110static int amd74xx_get_info(char *buffer, char **addr, off_t offset, int count)
111{
112 int speed[4], cycle[4], setup[4], active[4], recover[4], den[4],
113 uen[4], udma[4], active8b[4], recover8b[4];
114 struct pci_dev *dev = bmide_dev;
115 unsigned int v, u, i;
116 unsigned short c, w;
117 unsigned char t;
118 int len;
119 char *p = buffer;
120
121 amd_print("----------AMD BusMastering IDE Configuration----------------");
122
123 amd_print("Driver Version: 2.13");
124 amd_print("South Bridge: %s", pci_name(bmide_dev));
125
126 amd_print("Revision: IDE %#x", dev->revision);
127 amd_print("Highest DMA rate: UDMA%s", amd_dma[fls(amd_config->udma_mask) - 1]);
128
129 amd_print("BM-DMA base: %#lx", amd_base);
130 amd_print("PCI clock: %d.%dMHz", amd_clock / 1000, amd_clock / 100 % 10);
131
132 amd_print("-----------------------Primary IDE-------Secondary IDE------");
133
134 pci_read_config_byte(dev, AMD_IDE_CONFIG, &t);
135 amd_print("Prefetch Buffer: %10s%20s", (t & 0x80) ? "yes" : "no", (t & 0x20) ? "yes" : "no");
136 amd_print("Post Write Buffer: %10s%20s", (t & 0x40) ? "yes" : "no", (t & 0x10) ? "yes" : "no");
137
138 pci_read_config_byte(dev, AMD_IDE_ENABLE, &t);
139 amd_print("Enabled: %10s%20s", (t & 0x02) ? "yes" : "no", (t & 0x01) ? "yes" : "no");
140
141 c = inb(amd_base + 0x02) | (inb(amd_base + 0x0a) << 8);
142 amd_print("Simplex only: %10s%20s", (c & 0x80) ? "yes" : "no", (c & 0x8000) ? "yes" : "no");
143
144 amd_print("Cable Type: %10s%20s", (amd_80w & 1) ? "80w" : "40w", (amd_80w & 2) ? "80w" : "40w");
145
146 if (!amd_clock)
147 return p - buffer;
148
149 amd_print("-------------------drive0----drive1----drive2----drive3-----");
150
151 pci_read_config_byte(dev, AMD_ADDRESS_SETUP, &t);
152 pci_read_config_dword(dev, AMD_DRIVE_TIMING, &v);
153 pci_read_config_word(dev, AMD_8BIT_TIMING, &w);
154 pci_read_config_dword(dev, AMD_UDMA_TIMING, &u);
155
156 for (i = 0; i < 4; i++) {
157 setup[i] = ((t >> ((3 - i) << 1)) & 0x3) + 1;
158 recover8b[i] = ((w >> ((1 - (i >> 1)) << 3)) & 0xf) + 1;
159 active8b[i] = ((w >> (((1 - (i >> 1)) << 3) + 4)) & 0xf) + 1;
160 active[i] = ((v >> (((3 - i) << 3) + 4)) & 0xf) + 1;
161 recover[i] = ((v >> ((3 - i) << 3)) & 0xf) + 1;
162
163 udma[i] = amd_udma2cyc[((u >> ((3 - i) << 3)) & 0x7)];
164 uen[i] = ((u >> ((3 - i) << 3)) & 0x40) ? 1 : 0;
165 den[i] = (c & ((i & 1) ? 0x40 : 0x20) << ((i & 2) << 2));
166
167 if (den[i] && uen[i] && udma[i] == 1) {
168 speed[i] = amd_clock * 3;
169 cycle[i] = 666666 / amd_clock;
170 continue;
171 }
172
173 if (den[i] && uen[i] && udma[i] == 15) {
174 speed[i] = amd_clock * 4;
175 cycle[i] = 500000 / amd_clock;
176 continue;
177 }
178
179 speed[i] = 4 * amd_clock / ((den[i] && uen[i]) ? udma[i] : (active[i] + recover[i]) * 2);
180 cycle[i] = 1000000 * ((den[i] && uen[i]) ? udma[i] : (active[i] + recover[i]) * 2) / amd_clock / 2;
181 }
182
183 amd_print_drive("Transfer Mode: ", "%10s", den[i] ? (uen[i] ? "UDMA" : "DMA") : "PIO");
184
185 amd_print_drive("Address Setup: ", "%8dns", 1000000 * setup[i] / amd_clock);
186 amd_print_drive("Cmd Active: ", "%8dns", 1000000 * active8b[i] / amd_clock);
187 amd_print_drive("Cmd Recovery: ", "%8dns", 1000000 * recover8b[i] / amd_clock);
188 amd_print_drive("Data Active: ", "%8dns", 1000000 * active[i] / amd_clock);
189 amd_print_drive("Data Recovery: ", "%8dns", 1000000 * recover[i] / amd_clock);
190 amd_print_drive("Cycle Time: ", "%8dns", cycle[i]);
191 amd_print_drive("Transfer Rate: ", "%4d.%dMB/s", speed[i] / 1000, speed[i] / 100 % 10);
192
193 /* hoping p - buffer is less than 4K... */
194 len = (p - buffer) - offset;
195 *addr = buffer + offset;
196
197 return len > count ? count : len;
198}
199
200#endif
201
202/*
203 * amd_set_speed() writes timing values to the chipset registers 88 * amd_set_speed() writes timing values to the chipset registers
204 */ 89 */
205 90
@@ -264,16 +149,6 @@ static void amd_set_pio_mode(ide_drive_t *drive, const u8 pio)
264 amd_set_drive(drive, XFER_PIO_0 + pio); 149 amd_set_drive(drive, XFER_PIO_0 + pio);
265} 150}
266 151
267static int amd74xx_ide_dma_check(ide_drive_t *drive)
268{
269 if (ide_tune_dma(drive))
270 return 0;
271
272 ide_set_max_pio(drive);
273
274 return -1;
275}
276
277/* 152/*
278 * The initialization callback. Here we determine the IDE chip type 153 * The initialization callback. Here we determine the IDE chip type
279 * and initialize its drive independent registers. 154 * and initialize its drive independent registers.
@@ -363,19 +238,6 @@ static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev, const ch
363 amd_chipset->name, pci_name(dev), dev->revision, 238 amd_chipset->name, pci_name(dev), dev->revision,
364 amd_dma[fls(amd_config->udma_mask) - 1]); 239 amd_dma[fls(amd_config->udma_mask) - 1]);
365 240
366/*
367 * Register /proc/ide/amd74xx entry
368 */
369
370#if defined(DISPLAY_AMD_TIMINGS) && defined(CONFIG_IDE_PROC_FS)
371 if (!amd74xx_proc) {
372 amd_base = pci_resource_start(dev, 4);
373 bmide_dev = dev;
374 ide_pci_create_host_proc("amd74xx", amd74xx_get_info);
375 amd74xx_proc = 1;
376 }
377#endif /* DISPLAY_AMD_TIMINGS && CONFIG_IDE_PROC_FS */
378
379 return dev->irq; 241 return dev->irq;
380} 242}
381 243
@@ -386,8 +248,6 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif)
386 if (hwif->irq == 0) /* 0 is bogus but will do for now */ 248 if (hwif->irq == 0) /* 0 is bogus but will do for now */
387 hwif->irq = pci_get_legacy_ide_irq(hwif->pci_dev, hwif->channel); 249 hwif->irq = pci_get_legacy_ide_irq(hwif->pci_dev, hwif->channel);
388 250
389 hwif->autodma = 0;
390
391 hwif->set_pio_mode = &amd_set_pio_mode; 251 hwif->set_pio_mode = &amd_set_pio_mode;
392 hwif->set_dma_mode = &amd_set_drive; 252 hwif->set_dma_mode = &amd_set_drive;
393 253
@@ -395,7 +255,6 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif)
395 hwif->drives[i].io_32bit = 1; 255 hwif->drives[i].io_32bit = 1;
396 hwif->drives[i].unmask = 1; 256 hwif->drives[i].unmask = 1;
397 hwif->drives[i].autotune = 1; 257 hwif->drives[i].autotune = 1;
398 hwif->drives[i].dn = hwif->channel * 2 + i;
399 } 258 }
400 259
401 if (!hwif->dma_base) 260 if (!hwif->dma_base)
@@ -414,12 +273,6 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif)
414 else 273 else
415 hwif->cbl = ATA_CBL_PATA40; 274 hwif->cbl = ATA_CBL_PATA40;
416 } 275 }
417
418 hwif->ide_dma_check = &amd74xx_ide_dma_check;
419 if (!noautodma)
420 hwif->autodma = 1;
421 hwif->drives[0].autodma = hwif->autodma;
422 hwif->drives[1].autodma = hwif->autodma;
423} 276}
424 277
425#define DECLARE_AMD_DEV(name_str) \ 278#define DECLARE_AMD_DEV(name_str) \
@@ -489,34 +342,34 @@ static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_
489 return ide_setup_pci_device(dev, amd_chipset); 342 return ide_setup_pci_device(dev, amd_chipset);
490} 343}
491 344
492static struct pci_device_id amd74xx_pci_tbl[] = { 345static const struct pci_device_id amd74xx_pci_tbl[] = {
493 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_COBRA_7401, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 346 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_COBRA_7401), 0 },
494 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7409, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 }, 347 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_VIPER_7409), 1 },
495 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7411, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2 }, 348 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_VIPER_7411), 2 },
496 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_OPUS_7441, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3 }, 349 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_OPUS_7441), 3 },
497 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4 }, 350 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_8111_IDE), 4 },
498 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5 }, 351 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_IDE), 5 },
499 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 6 }, 352 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE), 6 },
500 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 7 }, 353 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE), 7 },
501#ifdef CONFIG_BLK_DEV_IDE_SATA 354#ifdef CONFIG_BLK_DEV_IDE_SATA
502 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 8 }, 355 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA), 8 },
503#endif 356#endif
504 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 9 }, 357 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE), 9 },
505 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 10 }, 358 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE), 10 },
506#ifdef CONFIG_BLK_DEV_IDE_SATA 359#ifdef CONFIG_BLK_DEV_IDE_SATA
507 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 11 }, 360 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA), 11 },
508 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 12 }, 361 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2), 12 },
509#endif 362#endif
510 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 13 }, 363 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE), 13 },
511 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 14 }, 364 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE), 14 },
512 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 15 }, 365 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE), 15 },
513 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 16 }, 366 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE), 16 },
514 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 17 }, 367 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE), 17 },
515 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 18 }, 368 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE), 18 },
516 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 19 }, 369 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE), 19 },
517 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 20 }, 370 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE), 20 },
518 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 21 }, 371 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE), 21 },
519 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 22 }, 372 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5536_IDE), 22 },
520 { 0, }, 373 { 0, },
521}; 374};
522MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl); 375MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl);
diff --git a/drivers/ide/pci/atiixp.c b/drivers/ide/pci/atiixp.c
index 0eb97f021d39..446900da1329 100644
--- a/drivers/ide/pci/atiixp.c
+++ b/drivers/ide/pci/atiixp.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/ide/pci/atiixp.c Version 0.02 Jun 16 2007 2 * linux/drivers/ide/pci/atiixp.c Version 0.03 Aug 3 2007
3 * 3 *
4 * Copyright (C) 2003 ATI Inc. <hyu@ati.com> 4 * Copyright (C) 2003 ATI Inc. <hyu@ati.com>
5 * Copyright (C) 2004,2007 Bartlomiej Zolnierkiewicz 5 * Copyright (C) 2004,2007 Bartlomiej Zolnierkiewicz
@@ -47,43 +47,6 @@ static int save_mdma_mode[4];
47 47
48static DEFINE_SPINLOCK(atiixp_lock); 48static DEFINE_SPINLOCK(atiixp_lock);
49 49
50/**
51 * atiixp_dma_2_pio - return the PIO mode matching DMA
52 * @xfer_rate: transfer speed
53 *
54 * Returns the nearest equivalent PIO timing for the PIO or DMA
55 * mode requested by the controller.
56 */
57
58static u8 atiixp_dma_2_pio(u8 xfer_rate) {
59 switch(xfer_rate) {
60 case XFER_UDMA_6:
61 case XFER_UDMA_5:
62 case XFER_UDMA_4:
63 case XFER_UDMA_3:
64 case XFER_UDMA_2:
65 case XFER_UDMA_1:
66 case XFER_UDMA_0:
67 case XFER_MW_DMA_2:
68 case XFER_PIO_4:
69 return 4;
70 case XFER_MW_DMA_1:
71 case XFER_PIO_3:
72 return 3;
73 case XFER_SW_DMA_2:
74 case XFER_PIO_2:
75 return 2;
76 case XFER_MW_DMA_0:
77 case XFER_SW_DMA_1:
78 case XFER_SW_DMA_0:
79 case XFER_PIO_1:
80 case XFER_PIO_0:
81 case XFER_PIO_SLOW:
82 default:
83 return 0;
84 }
85}
86
87static void atiixp_dma_host_on(ide_drive_t *drive) 50static void atiixp_dma_host_on(ide_drive_t *drive)
88{ 51{
89 struct pci_dev *dev = drive->hwif->pci_dev; 52 struct pci_dev *dev = drive->hwif->pci_dev;
@@ -169,7 +132,9 @@ static void atiixp_set_dma_mode(ide_drive_t *drive, const u8 speed)
169 int timing_shift = (drive->dn & 2) ? 16 : 0 + (drive->dn & 1) ? 0 : 8; 132 int timing_shift = (drive->dn & 2) ? 16 : 0 + (drive->dn & 1) ? 0 : 8;
170 u32 tmp32; 133 u32 tmp32;
171 u16 tmp16; 134 u16 tmp16;
172 u8 pio; 135
136 if (speed < XFER_MW_DMA_0)
137 return;
173 138
174 spin_lock_irqsave(&atiixp_lock, flags); 139 spin_lock_irqsave(&atiixp_lock, flags);
175 140
@@ -191,34 +156,6 @@ static void atiixp_set_dma_mode(ide_drive_t *drive, const u8 speed)
191 } 156 }
192 157
193 spin_unlock_irqrestore(&atiixp_lock, flags); 158 spin_unlock_irqrestore(&atiixp_lock, flags);
194
195 if (speed >= XFER_SW_DMA_0)
196 pio = atiixp_dma_2_pio(speed);
197 else
198 pio = speed - XFER_PIO_0;
199
200 atiixp_set_pio_mode(drive, pio);
201}
202
203/**
204 * atiixp_dma_check - set up an IDE device
205 * @drive: IDE drive to configure
206 *
207 * Set up the ATIIXP interface for the best available speed on this
208 * interface, preferring DMA to PIO.
209 */
210
211static int atiixp_dma_check(ide_drive_t *drive)
212{
213 drive->init_speed = 0;
214
215 if (ide_tune_dma(drive))
216 return 0;
217
218 if (ide_use_fast_pio(drive))
219 ide_set_max_pio(drive);
220
221 return -1;
222} 159}
223 160
224/** 161/**
@@ -238,7 +175,6 @@ static void __devinit init_hwif_atiixp(ide_hwif_t *hwif)
238 if (!hwif->irq) 175 if (!hwif->irq)
239 hwif->irq = ch ? 15 : 14; 176 hwif->irq = ch ? 15 : 14;
240 177
241 hwif->autodma = 0;
242 hwif->set_pio_mode = &atiixp_set_pio_mode; 178 hwif->set_pio_mode = &atiixp_set_pio_mode;
243 hwif->set_dma_mode = &atiixp_set_dma_mode; 179 hwif->set_dma_mode = &atiixp_set_dma_mode;
244 hwif->drives[0].autotune = 1; 180 hwif->drives[0].autotune = 1;
@@ -249,8 +185,7 @@ static void __devinit init_hwif_atiixp(ide_hwif_t *hwif)
249 185
250 hwif->atapi_dma = 1; 186 hwif->atapi_dma = 1;
251 hwif->ultra_mask = 0x3f; 187 hwif->ultra_mask = 0x3f;
252 hwif->mwdma_mask = 0x06; 188 hwif->mwdma_mask = 0x07;
253 hwif->swdma_mask = 0x04;
254 189
255 pci_read_config_byte(pdev, ATIIXP_IDE_UDMA_MODE + ch, &udma_mode); 190 pci_read_config_byte(pdev, ATIIXP_IDE_UDMA_MODE + ch, &udma_mode);
256 191
@@ -261,12 +196,6 @@ static void __devinit init_hwif_atiixp(ide_hwif_t *hwif)
261 196
262 hwif->dma_host_on = &atiixp_dma_host_on; 197 hwif->dma_host_on = &atiixp_dma_host_on;
263 hwif->dma_host_off = &atiixp_dma_host_off; 198 hwif->dma_host_off = &atiixp_dma_host_off;
264 hwif->ide_dma_check = &atiixp_dma_check;
265 if (!noautodma)
266 hwif->autodma = 1;
267
268 hwif->drives[1].autodma = hwif->autodma;
269 hwif->drives[0].autodma = hwif->autodma;
270} 199}
271 200
272 201
@@ -303,12 +232,12 @@ static int __devinit atiixp_init_one(struct pci_dev *dev, const struct pci_devic
303 return ide_setup_pci_device(dev, &atiixp_pci_info[id->driver_data]); 232 return ide_setup_pci_device(dev, &atiixp_pci_info[id->driver_data]);
304} 233}
305 234
306static struct pci_device_id atiixp_pci_tbl[] = { 235static const struct pci_device_id atiixp_pci_tbl[] = {
307 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP200_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 236 { PCI_VDEVICE(ATI, PCI_DEVICE_ID_ATI_IXP200_IDE), 0 },
308 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP300_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 237 { PCI_VDEVICE(ATI, PCI_DEVICE_ID_ATI_IXP300_IDE), 0 },
309 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP400_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 238 { PCI_VDEVICE(ATI, PCI_DEVICE_ID_ATI_IXP400_IDE), 0 },
310 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, 239 { PCI_VDEVICE(ATI, PCI_DEVICE_ID_ATI_IXP600_IDE), 1 },
311 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 240 { PCI_VDEVICE(ATI, PCI_DEVICE_ID_ATI_IXP700_IDE), 0 },
312 { 0, }, 241 { 0, },
313}; 242};
314MODULE_DEVICE_TABLE(pci, atiixp_pci_tbl); 243MODULE_DEVICE_TABLE(pci, atiixp_pci_tbl);
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c
index d50f15e34b80..f3d3bde8daba 100644
--- a/drivers/ide/pci/cmd64x.c
+++ b/drivers/ide/pci/cmd64x.c
@@ -330,17 +330,6 @@ static void cmd64x_set_dma_mode(ide_drive_t *drive, const u8 speed)
330 (void) pci_write_config_byte(dev, pciU, regU); 330 (void) pci_write_config_byte(dev, pciU, regU);
331} 331}
332 332
333static int cmd64x_config_drive_for_dma (ide_drive_t *drive)
334{
335 if (ide_tune_dma(drive))
336 return 0;
337
338 if (ide_use_fast_pio(drive))
339 ide_set_max_pio(drive);
340
341 return -1;
342}
343
344static int cmd648_ide_dma_end (ide_drive_t *drive) 333static int cmd648_ide_dma_end (ide_drive_t *drive)
345{ 334{
346 ide_hwif_t *hwif = HWIF(drive); 335 ide_hwif_t *hwif = HWIF(drive);
@@ -547,8 +536,6 @@ static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif)
547 if (dev->device == PCI_DEVICE_ID_CMD_646 && rev < 5) 536 if (dev->device == PCI_DEVICE_ID_CMD_646 && rev < 5)
548 hwif->ultra_mask = 0x00; 537 hwif->ultra_mask = 0x00;
549 538
550 hwif->ide_dma_check = &cmd64x_config_drive_for_dma;
551
552 if (hwif->cbl != ATA_CBL_PATA40_SHORT) 539 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
553 hwif->cbl = ata66_cmd64x(hwif); 540 hwif->cbl = ata66_cmd64x(hwif);
554 541
@@ -572,10 +559,6 @@ static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif)
572 hwif->ide_dma_test_irq = &cmd64x_ide_dma_test_irq; 559 hwif->ide_dma_test_irq = &cmd64x_ide_dma_test_irq;
573 break; 560 break;
574 } 561 }
575
576 if (!noautodma)
577 hwif->autodma = 1;
578 hwif->drives[0].autodma = hwif->drives[1].autodma = hwif->autodma;
579} 562}
580 563
581static int __devinit init_setup_cmd64x(struct pci_dev *dev, ide_pci_device_t *d) 564static int __devinit init_setup_cmd64x(struct pci_dev *dev, ide_pci_device_t *d)
@@ -654,11 +637,11 @@ static int __devinit cmd64x_init_one(struct pci_dev *dev, const struct pci_devic
654 return d.init_setup(dev, &d); 637 return d.init_setup(dev, &d);
655} 638}
656 639
657static struct pci_device_id cmd64x_pci_tbl[] = { 640static const struct pci_device_id cmd64x_pci_tbl[] = {
658 { PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_CMD_643, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 641 { PCI_VDEVICE(CMD, PCI_DEVICE_ID_CMD_643), 0 },
659 { PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_CMD_646, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, 642 { PCI_VDEVICE(CMD, PCI_DEVICE_ID_CMD_646), 1 },
660 { PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_CMD_648, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2}, 643 { PCI_VDEVICE(CMD, PCI_DEVICE_ID_CMD_648), 2 },
661 { PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_CMD_649, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3}, 644 { PCI_VDEVICE(CMD, PCI_DEVICE_ID_CMD_649), 3 },
662 { 0, }, 645 { 0, },
663}; 646};
664MODULE_DEVICE_TABLE(pci, cmd64x_pci_tbl); 647MODULE_DEVICE_TABLE(pci, cmd64x_pci_tbl);
diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c
index fbce90048aec..a8bf4940ca9c 100644
--- a/drivers/ide/pci/cs5520.c
+++ b/drivers/ide/pci/cs5520.c
@@ -105,15 +105,6 @@ static void cs5520_set_dma_mode(ide_drive_t *drive, const u8 speed)
105 cs5520_set_pio_mode(drive, 0); 105 cs5520_set_pio_mode(drive, 0);
106} 106}
107 107
108static int cs5520_config_drive_xfer_rate(ide_drive_t *drive)
109{
110 /* Tune the drive for PIO modes up to PIO 4 */
111 ide_set_max_pio(drive);
112
113 /* Then tell the core to use DMA operations */
114 return 0;
115}
116
117/* 108/*
118 * We provide a callback for our nonstandard DMA location 109 * We provide a callback for our nonstandard DMA location
119 */ 110 */
@@ -148,7 +139,6 @@ static void __devinit init_hwif_cs5520(ide_hwif_t *hwif)
148 return; 139 return;
149 } 140 }
150 141
151 hwif->ide_dma_check = &cs5520_config_drive_xfer_rate;
152 hwif->ide_dma_on = &cs5520_dma_on; 142 hwif->ide_dma_on = &cs5520_dma_on;
153 143
154 /* ATAPI is harder so leave it for now */ 144 /* ATAPI is harder so leave it for now */
@@ -156,12 +146,6 @@ static void __devinit init_hwif_cs5520(ide_hwif_t *hwif)
156 hwif->ultra_mask = 0; 146 hwif->ultra_mask = 0;
157 hwif->swdma_mask = 0; 147 hwif->swdma_mask = 0;
158 hwif->mwdma_mask = 0; 148 hwif->mwdma_mask = 0;
159
160 if (!noautodma)
161 hwif->autodma = 1;
162
163 hwif->drives[0].autodma = hwif->autodma;
164 hwif->drives[1].autodma = hwif->autodma;
165} 149}
166 150
167#define DECLARE_CS_DEV(name_str) \ 151#define DECLARE_CS_DEV(name_str) \
@@ -171,7 +155,8 @@ static void __devinit init_hwif_cs5520(ide_hwif_t *hwif)
171 .init_hwif = init_hwif_cs5520, \ 155 .init_hwif = init_hwif_cs5520, \
172 .autodma = AUTODMA, \ 156 .autodma = AUTODMA, \
173 .bootable = ON_BOARD, \ 157 .bootable = ON_BOARD, \
174 .host_flags = IDE_HFLAG_ISA_PORTS, \ 158 .host_flags = IDE_HFLAG_ISA_PORTS | \
159 IDE_HFLAG_VDMA, \
175 .pio_mask = ATA_PIO4, \ 160 .pio_mask = ATA_PIO4, \
176 } 161 }
177 162
@@ -233,9 +218,9 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
233 return 0; 218 return 0;
234} 219}
235 220
236static struct pci_device_id cs5520_pci_tbl[] = { 221static const struct pci_device_id cs5520_pci_tbl[] = {
237 { PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5510, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 222 { PCI_VDEVICE(CYRIX, PCI_DEVICE_ID_CYRIX_5510), 0 },
238 { PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5520, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, 223 { PCI_VDEVICE(CYRIX, PCI_DEVICE_ID_CYRIX_5520), 1 },
239 { 0, }, 224 { 0, },
240}; 225};
241MODULE_DEVICE_TABLE(pci, cs5520_pci_tbl); 226MODULE_DEVICE_TABLE(pci, cs5520_pci_tbl);
diff --git a/drivers/ide/pci/cs5530.c b/drivers/ide/pci/cs5530.c
index e4121577cef0..0d23b8aabe9c 100644
--- a/drivers/ide/pci/cs5530.c
+++ b/drivers/ide/pci/cs5530.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/ide/pci/cs5530.c Version 0.74 Jul 28 2007 2 * linux/drivers/ide/pci/cs5530.c Version 0.76 Aug 3 2007
3 * 3 *
4 * Copyright (C) 2000 Andre Hedrick <andre@linux-ide.org> 4 * Copyright (C) 2000 Andre Hedrick <andre@linux-ide.org>
5 * Copyright (C) 2000 Mark Lord <mlord@pobox.com> 5 * Copyright (C) 2000 Mark Lord <mlord@pobox.com>
@@ -104,22 +104,6 @@ out:
104 return mask; 104 return mask;
105} 105}
106 106
107/**
108 * cs5530_config_dma - set DMA/UDMA mode
109 * @drive: drive to tune
110 *
111 * cs5530_config_dma() handles setting of DMA/UDMA mode
112 * for both the chipset and drive.
113 */
114
115static int cs5530_config_dma(ide_drive_t *drive)
116{
117 if (ide_tune_dma(drive))
118 return 0;
119
120 return 1;
121}
122
123static void cs5530_set_dma_mode(ide_drive_t *drive, const u8 mode) 107static void cs5530_set_dma_mode(ide_drive_t *drive, const u8 mode)
124{ 108{
125 unsigned long basereg; 109 unsigned long basereg;
@@ -260,7 +244,6 @@ static void __devinit init_hwif_cs5530 (ide_hwif_t *hwif)
260{ 244{
261 unsigned long basereg; 245 unsigned long basereg;
262 u32 d0_timings; 246 u32 d0_timings;
263 hwif->autodma = 0;
264 247
265 if (hwif->mate) 248 if (hwif->mate)
266 hwif->serialized = hwif->mate->serialized = 1; 249 hwif->serialized = hwif->mate->serialized = 1;
@@ -270,20 +253,13 @@ static void __devinit init_hwif_cs5530 (ide_hwif_t *hwif)
270 253
271 basereg = CS5530_BASEREG(hwif); 254 basereg = CS5530_BASEREG(hwif);
272 d0_timings = inl(basereg + 0); 255 d0_timings = inl(basereg + 0);
273 if (CS5530_BAD_PIO(d0_timings)) { 256 if (CS5530_BAD_PIO(d0_timings))
274 /* PIO timings not initialized? */
275 outl(cs5530_pio_timings[(d0_timings >> 31) & 1][0], basereg + 0); 257 outl(cs5530_pio_timings[(d0_timings >> 31) & 1][0], basereg + 0);
276 if (!hwif->drives[0].autotune) 258 if (CS5530_BAD_PIO(inl(basereg + 8)))
277 hwif->drives[0].autotune = 1;
278 /* needs autotuning later */
279 }
280 if (CS5530_BAD_PIO(inl(basereg + 8))) {
281 /* PIO timings not initialized? */
282 outl(cs5530_pio_timings[(d0_timings >> 31) & 1][0], basereg + 8); 259 outl(cs5530_pio_timings[(d0_timings >> 31) & 1][0], basereg + 8);
283 if (!hwif->drives[1].autotune) 260
284 hwif->drives[1].autotune = 1; 261 hwif->drives[0].autotune = 1;
285 /* needs autotuning later */ 262 hwif->drives[1].autotune = 1;
286 }
287 263
288 if (hwif->dma_base == 0) 264 if (hwif->dma_base == 0)
289 return; 265 return;
@@ -293,11 +269,6 @@ static void __devinit init_hwif_cs5530 (ide_hwif_t *hwif)
293 hwif->mwdma_mask = 0x07; 269 hwif->mwdma_mask = 0x07;
294 270
295 hwif->udma_filter = cs5530_udma_filter; 271 hwif->udma_filter = cs5530_udma_filter;
296 hwif->ide_dma_check = &cs5530_config_dma;
297 if (!noautodma)
298 hwif->autodma = 1;
299 hwif->drives[0].autodma = hwif->autodma;
300 hwif->drives[1].autodma = hwif->autodma;
301} 272}
302 273
303static ide_pci_device_t cs5530_chipset __devinitdata = { 274static ide_pci_device_t cs5530_chipset __devinitdata = {
@@ -315,8 +286,8 @@ static int __devinit cs5530_init_one(struct pci_dev *dev, const struct pci_devic
315 return ide_setup_pci_device(dev, &cs5530_chipset); 286 return ide_setup_pci_device(dev, &cs5530_chipset);
316} 287}
317 288
318static struct pci_device_id cs5530_pci_tbl[] = { 289static const struct pci_device_id cs5530_pci_tbl[] = {
319 { PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5530_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 290 { PCI_VDEVICE(CYRIX, PCI_DEVICE_ID_CYRIX_5530_IDE), 0 },
320 { 0, }, 291 { 0, },
321}; 292};
322MODULE_DEVICE_TABLE(pci, cs5530_pci_tbl); 293MODULE_DEVICE_TABLE(pci, cs5530_pci_tbl);
diff --git a/drivers/ide/pci/cs5535.c b/drivers/ide/pci/cs5535.c
index 257865778f92..e4891a16afef 100644
--- a/drivers/ide/pci/cs5535.c
+++ b/drivers/ide/pci/cs5535.c
@@ -157,19 +157,6 @@ static void cs5535_set_pio_mode(ide_drive_t *drive, const u8 pio)
157 cs5535_set_speed(drive, XFER_PIO_0 + pio); 157 cs5535_set_speed(drive, XFER_PIO_0 + pio);
158} 158}
159 159
160static int cs5535_dma_check(ide_drive_t *drive)
161{
162 drive->init_speed = 0;
163
164 if (ide_tune_dma(drive))
165 return 0;
166
167 if (ide_use_fast_pio(drive))
168 ide_set_max_pio(drive);
169
170 return -1;
171}
172
173static u8 __devinit cs5535_cable_detect(struct pci_dev *dev) 160static u8 __devinit cs5535_cable_detect(struct pci_dev *dev)
174{ 161{
175 u8 bit; 162 u8 bit;
@@ -190,8 +177,6 @@ static u8 __devinit cs5535_cable_detect(struct pci_dev *dev)
190 */ 177 */
191static void __devinit init_hwif_cs5535(ide_hwif_t *hwif) 178static void __devinit init_hwif_cs5535(ide_hwif_t *hwif)
192{ 179{
193 hwif->autodma = 0;
194
195 hwif->set_pio_mode = &cs5535_set_pio_mode; 180 hwif->set_pio_mode = &cs5535_set_pio_mode;
196 hwif->set_dma_mode = &cs5535_set_dma_mode; 181 hwif->set_dma_mode = &cs5535_set_dma_mode;
197 182
@@ -200,18 +185,11 @@ static void __devinit init_hwif_cs5535(ide_hwif_t *hwif)
200 if (hwif->dma_base == 0) 185 if (hwif->dma_base == 0)
201 return; 186 return;
202 187
203 hwif->ide_dma_check = &cs5535_dma_check;
204
205 hwif->atapi_dma = 1; 188 hwif->atapi_dma = 1;
206 hwif->ultra_mask = 0x1F; 189 hwif->ultra_mask = 0x1F;
207 hwif->mwdma_mask = 0x07; 190 hwif->mwdma_mask = 0x07;
208 191
209 hwif->cbl = cs5535_cable_detect(hwif->pci_dev); 192 hwif->cbl = cs5535_cable_detect(hwif->pci_dev);
210
211 if (!noautodma)
212 hwif->autodma = 1;
213
214 hwif->drives[1].autodma = hwif->drives[0].autodma = hwif->autodma;
215} 193}
216 194
217static ide_pci_device_t cs5535_chipset __devinitdata = { 195static ide_pci_device_t cs5535_chipset __devinitdata = {
@@ -229,10 +207,8 @@ static int __devinit cs5535_init_one(struct pci_dev *dev,
229 return ide_setup_pci_device(dev, &cs5535_chipset); 207 return ide_setup_pci_device(dev, &cs5535_chipset);
230} 208}
231 209
232static struct pci_device_id cs5535_pci_tbl[] = 210static const struct pci_device_id cs5535_pci_tbl[] = {
233{ 211 { PCI_VDEVICE(NS, PCI_DEVICE_ID_NS_CS5535_IDE), 0 },
234 { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_IDE, PCI_ANY_ID,
235 PCI_ANY_ID, 0, 0, 0},
236 { 0, }, 212 { 0, },
237}; 213};
238 214
diff --git a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c
index dc278025d318..c498ecfd7fcb 100644
--- a/drivers/ide/pci/cy82c693.c
+++ b/drivers/ide/pci/cy82c693.c
@@ -428,8 +428,6 @@ static unsigned int __devinit init_chipset_cy82c693(struct pci_dev *dev, const c
428 */ 428 */
429static void __devinit init_hwif_cy82c693(ide_hwif_t *hwif) 429static void __devinit init_hwif_cy82c693(ide_hwif_t *hwif)
430{ 430{
431 hwif->autodma = 0;
432
433 hwif->chipset = ide_cy82c693; 431 hwif->chipset = ide_cy82c693;
434 hwif->set_pio_mode = &cy82c693_set_pio_mode; 432 hwif->set_pio_mode = &cy82c693_set_pio_mode;
435 433
@@ -444,10 +442,6 @@ static void __devinit init_hwif_cy82c693(ide_hwif_t *hwif)
444 hwif->swdma_mask = 0x04; 442 hwif->swdma_mask = 0x04;
445 443
446 hwif->ide_dma_on = &cy82c693_ide_dma_on; 444 hwif->ide_dma_on = &cy82c693_ide_dma_on;
447 if (!noautodma)
448 hwif->autodma = 1;
449 hwif->drives[0].autodma = hwif->autodma;
450 hwif->drives[1].autodma = hwif->autodma;
451} 445}
452 446
453static __devinitdata ide_hwif_t *primary; 447static __devinitdata ide_hwif_t *primary;
@@ -469,7 +463,7 @@ static ide_pci_device_t cy82c693_chipset __devinitdata = {
469 .init_hwif = init_hwif_cy82c693, 463 .init_hwif = init_hwif_cy82c693,
470 .autodma = AUTODMA, 464 .autodma = AUTODMA,
471 .bootable = ON_BOARD, 465 .bootable = ON_BOARD,
472 .host_flags = IDE_HFLAG_SINGLE, 466 .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_TRUST_BIOS_FOR_DMA,
473 .pio_mask = ATA_PIO4, 467 .pio_mask = ATA_PIO4,
474}; 468};
475 469
@@ -489,8 +483,8 @@ static int __devinit cy82c693_init_one(struct pci_dev *dev, const struct pci_dev
489 return ret; 483 return ret;
490} 484}
491 485
492static struct pci_device_id cy82c693_pci_tbl[] = { 486static const struct pci_device_id cy82c693_pci_tbl[] = {
493 { PCI_VENDOR_ID_CONTAQ, PCI_DEVICE_ID_CONTAQ_82C693, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 487 { PCI_VDEVICE(CONTAQ, PCI_DEVICE_ID_CONTAQ_82C693), 0 },
494 { 0, }, 488 { 0, },
495}; 489};
496MODULE_DEVICE_TABLE(pci, cy82c693_pci_tbl); 490MODULE_DEVICE_TABLE(pci, cy82c693_pci_tbl);
diff --git a/drivers/ide/pci/generic.c b/drivers/ide/pci/generic.c
index 48caa468b762..cce6311b02df 100644
--- a/drivers/ide/pci/generic.c
+++ b/drivers/ide/pci/generic.c
@@ -73,11 +73,6 @@ static void __devinit init_hwif_generic (ide_hwif_t *hwif)
73 hwif->ultra_mask = 0x7f; 73 hwif->ultra_mask = 0x7f;
74 hwif->mwdma_mask = 0x07; 74 hwif->mwdma_mask = 0x07;
75 hwif->swdma_mask = 0x07; 75 hwif->swdma_mask = 0x07;
76
77 if (!noautodma)
78 hwif->autodma = 1;
79 hwif->drives[0].autodma = hwif->autodma;
80 hwif->drives[1].autodma = hwif->autodma;
81} 76}
82 77
83#if 0 78#if 0
@@ -97,77 +92,92 @@ static ide_pci_device_t generic_chipsets[] __devinitdata = {
97 .init_hwif = init_hwif_generic, 92 .init_hwif = init_hwif_generic,
98 .autodma = AUTODMA, 93 .autodma = AUTODMA,
99 .bootable = ON_BOARD, 94 .bootable = ON_BOARD,
95 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
100 },{ /* 1 */ 96 },{ /* 1 */
101 .name = "NS87410", 97 .name = "NS87410",
102 .init_hwif = init_hwif_generic, 98 .init_hwif = init_hwif_generic,
103 .autodma = AUTODMA, 99 .autodma = AUTODMA,
104 .enablebits = {{0x43,0x08,0x08}, {0x47,0x08,0x08}}, 100 .enablebits = {{0x43,0x08,0x08}, {0x47,0x08,0x08}},
105 .bootable = ON_BOARD, 101 .bootable = ON_BOARD,
102 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
106 },{ /* 2 */ 103 },{ /* 2 */
107 .name = "SAMURAI", 104 .name = "SAMURAI",
108 .init_hwif = init_hwif_generic, 105 .init_hwif = init_hwif_generic,
109 .autodma = AUTODMA, 106 .autodma = AUTODMA,
110 .bootable = ON_BOARD, 107 .bootable = ON_BOARD,
108 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
111 },{ /* 3 */ 109 },{ /* 3 */
112 .name = "HT6565", 110 .name = "HT6565",
113 .init_hwif = init_hwif_generic, 111 .init_hwif = init_hwif_generic,
114 .autodma = AUTODMA, 112 .autodma = AUTODMA,
115 .bootable = ON_BOARD, 113 .bootable = ON_BOARD,
114 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
116 },{ /* 4 */ 115 },{ /* 4 */
117 .name = "UM8673F", 116 .name = "UM8673F",
118 .init_hwif = init_hwif_generic, 117 .init_hwif = init_hwif_generic,
119 .autodma = NODMA, 118 .autodma = NODMA,
120 .bootable = ON_BOARD, 119 .bootable = ON_BOARD,
120 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
121 },{ /* 5 */ 121 },{ /* 5 */
122 .name = "UM8886A", 122 .name = "UM8886A",
123 .init_hwif = init_hwif_generic, 123 .init_hwif = init_hwif_generic,
124 .autodma = NODMA, 124 .autodma = NODMA,
125 .bootable = ON_BOARD, 125 .bootable = ON_BOARD,
126 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
126 },{ /* 6 */ 127 },{ /* 6 */
127 .name = "UM8886BF", 128 .name = "UM8886BF",
128 .init_hwif = init_hwif_generic, 129 .init_hwif = init_hwif_generic,
129 .autodma = NODMA, 130 .autodma = NODMA,
130 .bootable = ON_BOARD, 131 .bootable = ON_BOARD,
132 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
131 },{ /* 7 */ 133 },{ /* 7 */
132 .name = "HINT_IDE", 134 .name = "HINT_IDE",
133 .init_hwif = init_hwif_generic, 135 .init_hwif = init_hwif_generic,
134 .autodma = AUTODMA, 136 .autodma = AUTODMA,
135 .bootable = ON_BOARD, 137 .bootable = ON_BOARD,
138 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
136 },{ /* 8 */ 139 },{ /* 8 */
137 .name = "VIA_IDE", 140 .name = "VIA_IDE",
138 .init_hwif = init_hwif_generic, 141 .init_hwif = init_hwif_generic,
139 .autodma = NOAUTODMA, 142 .autodma = NOAUTODMA,
140 .bootable = ON_BOARD, 143 .bootable = ON_BOARD,
144 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
141 },{ /* 9 */ 145 },{ /* 9 */
142 .name = "OPTI621V", 146 .name = "OPTI621V",
143 .init_hwif = init_hwif_generic, 147 .init_hwif = init_hwif_generic,
144 .autodma = NOAUTODMA, 148 .autodma = NOAUTODMA,
145 .bootable = ON_BOARD, 149 .bootable = ON_BOARD,
150 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
146 },{ /* 10 */ 151 },{ /* 10 */
147 .name = "VIA8237SATA", 152 .name = "VIA8237SATA",
148 .init_hwif = init_hwif_generic, 153 .init_hwif = init_hwif_generic,
149 .autodma = AUTODMA, 154 .autodma = AUTODMA,
150 .bootable = OFF_BOARD, 155 .bootable = OFF_BOARD,
156 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
151 },{ /* 11 */ 157 },{ /* 11 */
152 .name = "Piccolo0102", 158 .name = "Piccolo0102",
153 .init_hwif = init_hwif_generic, 159 .init_hwif = init_hwif_generic,
154 .autodma = NOAUTODMA, 160 .autodma = NOAUTODMA,
155 .bootable = ON_BOARD, 161 .bootable = ON_BOARD,
162 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
156 },{ /* 12 */ 163 },{ /* 12 */
157 .name = "Piccolo0103", 164 .name = "Piccolo0103",
158 .init_hwif = init_hwif_generic, 165 .init_hwif = init_hwif_generic,
159 .autodma = NOAUTODMA, 166 .autodma = NOAUTODMA,
160 .bootable = ON_BOARD, 167 .bootable = ON_BOARD,
168 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
161 },{ /* 13 */ 169 },{ /* 13 */
162 .name = "Piccolo0105", 170 .name = "Piccolo0105",
163 .init_hwif = init_hwif_generic, 171 .init_hwif = init_hwif_generic,
164 .autodma = NOAUTODMA, 172 .autodma = NOAUTODMA,
165 .bootable = ON_BOARD, 173 .bootable = ON_BOARD,
174 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
166 },{ /* 14 */ 175 },{ /* 14 */
167 .name = "Revolution", 176 .name = "Revolution",
168 .init_hwif = init_hwif_generic, 177 .init_hwif = init_hwif_generic,
169 .autodma = AUTODMA, 178 .autodma = AUTODMA,
170 .bootable = OFF_BOARD, 179 .bootable = OFF_BOARD,
180 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
171 } 181 }
172}; 182};
173 183
@@ -226,25 +236,28 @@ out:
226 return ret; 236 return ret;
227} 237}
228 238
229static struct pci_device_id generic_pci_tbl[] = { 239static const struct pci_device_id generic_pci_tbl[] = {
230 { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87410, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, 240 { PCI_VDEVICE(NS, PCI_DEVICE_ID_NS_87410), 1 },
231 { PCI_VENDOR_ID_PCTECH, PCI_DEVICE_ID_PCTECH_SAMURAI_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2}, 241 { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_SAMURAI_IDE), 2 },
232 { PCI_VENDOR_ID_HOLTEK, PCI_DEVICE_ID_HOLTEK_6565, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3}, 242 { PCI_VDEVICE(HOLTEK, PCI_DEVICE_ID_HOLTEK_6565), 3 },
233 { PCI_VENDOR_ID_UMC, PCI_DEVICE_ID_UMC_UM8673F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4}, 243 { PCI_VDEVICE(UMC, PCI_DEVICE_ID_UMC_UM8673F), 4 },
234 { PCI_VENDOR_ID_UMC, PCI_DEVICE_ID_UMC_UM8886A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5}, 244 { PCI_VDEVICE(UMC, PCI_DEVICE_ID_UMC_UM8886A), 5 },
235 { PCI_VENDOR_ID_UMC, PCI_DEVICE_ID_UMC_UM8886BF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 6}, 245 { PCI_VDEVICE(UMC, PCI_DEVICE_ID_UMC_UM8886BF), 6 },
236 { PCI_VENDOR_ID_HINT, PCI_DEVICE_ID_HINT_VXPROII_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 7}, 246 { PCI_VDEVICE(HINT, PCI_DEVICE_ID_HINT_VXPROII_IDE), 7 },
237 { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C561, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 8}, 247 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C561), 8 },
238 { PCI_VENDOR_ID_OPTI, PCI_DEVICE_ID_OPTI_82C558, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 9}, 248 { PCI_VDEVICE(OPTI, PCI_DEVICE_ID_OPTI_82C558), 9 },
239#ifdef CONFIG_BLK_DEV_IDE_SATA 249#ifdef CONFIG_BLK_DEV_IDE_SATA
240 { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237_SATA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 10}, 250 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_8237_SATA), 10 },
241#endif 251#endif
242 { PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 11}, 252 { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO), 11 },
243 { PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 12}, 253 { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO_1), 12 },
244 { PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 13}, 254 { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO_2), 13 },
245 { PCI_VENDOR_ID_NETCELL,PCI_DEVICE_ID_REVOLUTION, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 14}, 255 { PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), 14 },
246 /* Must come last. If you add entries adjust this table appropriately and the init_one code */ 256 /*
247 { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE << 8, 0xFFFFFF00UL, 0}, 257 * Must come last. If you add entries adjust
258 * this table and generic_chipsets[] appropriately.
259 */
260 { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE << 8, 0xFFFFFF00UL, 0 },
248 { 0, }, 261 { 0, },
249}; 262};
250MODULE_DEVICE_TABLE(pci, generic_pci_tbl); 263MODULE_DEVICE_TABLE(pci, generic_pci_tbl);
diff --git a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c
index 218852aaf22a..44ac0e2f7a09 100644
--- a/drivers/ide/pci/hpt34x.c
+++ b/drivers/ide/pci/hpt34x.c
@@ -80,19 +80,6 @@ static void hpt34x_set_pio_mode(ide_drive_t *drive, const u8 pio)
80 hpt34x_set_mode(drive, XFER_PIO_0 + pio); 80 hpt34x_set_mode(drive, XFER_PIO_0 + pio);
81} 81}
82 82
83static int hpt34x_config_drive_xfer_rate (ide_drive_t *drive)
84{
85 drive->init_speed = 0;
86
87 if (ide_tune_dma(drive))
88 return -1;
89
90 if (ide_use_fast_pio(drive))
91 ide_set_max_pio(drive);
92
93 return -1;
94}
95
96/* 83/*
97 * If the BIOS does not set the IO base addaress to XX00, 343 will fail. 84 * If the BIOS does not set the IO base addaress to XX00, 343 will fail.
98 */ 85 */
@@ -140,8 +127,6 @@ static void __devinit init_hwif_hpt34x(ide_hwif_t *hwif)
140{ 127{
141 u16 pcicmd = 0; 128 u16 pcicmd = 0;
142 129
143 hwif->autodma = 0;
144
145 hwif->set_pio_mode = &hpt34x_set_pio_mode; 130 hwif->set_pio_mode = &hpt34x_set_pio_mode;
146 hwif->set_dma_mode = &hpt34x_set_mode; 131 hwif->set_dma_mode = &hpt34x_set_mode;
147 132
@@ -154,16 +139,13 @@ static void __devinit init_hwif_hpt34x(ide_hwif_t *hwif)
154 return; 139 return;
155 140
156#ifdef CONFIG_HPT34X_AUTODMA 141#ifdef CONFIG_HPT34X_AUTODMA
142 if ((pcicmd & PCI_COMMAND_MEMORY) == 0)
143 return;
144
157 hwif->ultra_mask = 0x07; 145 hwif->ultra_mask = 0x07;
158 hwif->mwdma_mask = 0x07; 146 hwif->mwdma_mask = 0x07;
159 hwif->swdma_mask = 0x07; 147 hwif->swdma_mask = 0x07;
160#endif 148#endif
161
162 hwif->ide_dma_check = &hpt34x_config_drive_xfer_rate;
163 if (!noautodma)
164 hwif->autodma = (pcicmd & PCI_COMMAND_MEMORY) ? 1 : 0;
165 hwif->drives[0].autodma = hwif->autodma;
166 hwif->drives[1].autodma = hwif->autodma;
167} 149}
168 150
169static ide_pci_device_t hpt34x_chipset __devinitdata = { 151static ide_pci_device_t hpt34x_chipset __devinitdata = {
@@ -190,8 +172,8 @@ static int __devinit hpt34x_init_one(struct pci_dev *dev, const struct pci_devic
190 return ide_setup_pci_device(dev, d); 172 return ide_setup_pci_device(dev, d);
191} 173}
192 174
193static struct pci_device_id hpt34x_pci_tbl[] = { 175static const struct pci_device_id hpt34x_pci_tbl[] = {
194 { PCI_VENDOR_ID_TTI, PCI_DEVICE_ID_TTI_HPT343, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 176 { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT343), 0 },
195 { 0, }, 177 { 0, },
196}; 178};
197MODULE_DEVICE_TABLE(pci, hpt34x_pci_tbl); 179MODULE_DEVICE_TABLE(pci, hpt34x_pci_tbl);
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index 8812a9bb032f..fcb21ddab2cc 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.13 Sep 29, 2007 2 * linux/drivers/ide/pci/hpt366.c Version 1.14 Oct 1, 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.
@@ -713,19 +713,6 @@ static void hpt3xx_maskproc(ide_drive_t *drive, int mask)
713 IDE_CONTROL_REG); 713 IDE_CONTROL_REG);
714} 714}
715 715
716static int hpt366_config_drive_xfer_rate(ide_drive_t *drive)
717{
718 drive->init_speed = 0;
719
720 if (ide_tune_dma(drive))
721 return 0;
722
723 if (ide_use_fast_pio(drive))
724 ide_set_max_pio(drive);
725
726 return -1;
727}
728
729/* 716/*
730 * This is specific to the HPT366 UDMA chipset 717 * This is specific to the HPT366 UDMA chipset
731 * by HighPoint|Triones Technologies, Inc. 718 * by HighPoint|Triones Technologies, Inc.
@@ -1304,10 +1291,10 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
1304 if (new_mcr != old_mcr) 1291 if (new_mcr != old_mcr)
1305 pci_write_config_byte(dev, hwif->select_data + 1, new_mcr); 1292 pci_write_config_byte(dev, hwif->select_data + 1, new_mcr);
1306 1293
1307 if (!hwif->dma_base) { 1294 hwif->drives[0].autotune = hwif->drives[1].autotune = 1;
1308 hwif->drives[0].autotune = hwif->drives[1].autotune = 1; 1295
1296 if (hwif->dma_base == 0)
1309 return; 1297 return;
1310 }
1311 1298
1312 hwif->ultra_mask = hwif->cds->udma_mask; 1299 hwif->ultra_mask = hwif->cds->udma_mask;
1313 hwif->mwdma_mask = 0x07; 1300 hwif->mwdma_mask = 0x07;
@@ -1349,8 +1336,6 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
1349 if (hwif->cbl != ATA_CBL_PATA40_SHORT) 1336 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
1350 hwif->cbl = (scr1 & ata66) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; 1337 hwif->cbl = (scr1 & ata66) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
1351 1338
1352 hwif->ide_dma_check = &hpt366_config_drive_xfer_rate;
1353
1354 if (chip_type >= HPT374) { 1339 if (chip_type >= HPT374) {
1355 hwif->ide_dma_test_irq = &hpt374_ide_dma_test_irq; 1340 hwif->ide_dma_test_irq = &hpt374_ide_dma_test_irq;
1356 hwif->ide_dma_end = &hpt374_ide_dma_end; 1341 hwif->ide_dma_end = &hpt374_ide_dma_end;
@@ -1360,10 +1345,6 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
1360 hwif->dma_timeout = &hpt370_dma_timeout; 1345 hwif->dma_timeout = &hpt370_dma_timeout;
1361 } else 1346 } else
1362 hwif->dma_lost_irq = &hpt366_dma_lost_irq; 1347 hwif->dma_lost_irq = &hpt366_dma_lost_irq;
1363
1364 if (!noautodma)
1365 hwif->autodma = 1;
1366 hwif->drives[0].autodma = hwif->drives[1].autodma = hwif->autodma;
1367} 1348}
1368 1349
1369static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase) 1350static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase)
@@ -1657,13 +1638,13 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic
1657 return d.init_setup(dev, &d); 1638 return d.init_setup(dev, &d);
1658} 1639}
1659 1640
1660static struct pci_device_id hpt366_pci_tbl[] = { 1641static const struct pci_device_id hpt366_pci_tbl[] = {
1661 { PCI_VENDOR_ID_TTI, PCI_DEVICE_ID_TTI_HPT366, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 1642 { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT366), 0 },
1662 { PCI_VENDOR_ID_TTI, PCI_DEVICE_ID_TTI_HPT372, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, 1643 { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT372), 1 },
1663 { PCI_VENDOR_ID_TTI, PCI_DEVICE_ID_TTI_HPT302, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2}, 1644 { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT302), 2 },
1664 { PCI_VENDOR_ID_TTI, PCI_DEVICE_ID_TTI_HPT371, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3}, 1645 { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT371), 3 },
1665 { PCI_VENDOR_ID_TTI, PCI_DEVICE_ID_TTI_HPT374, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4}, 1646 { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT374), 4 },
1666 { PCI_VENDOR_ID_TTI, PCI_DEVICE_ID_TTI_HPT372N, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5}, 1647 { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT372N), 5 },
1667 { 0, }, 1648 { 0, },
1668}; 1649};
1669MODULE_DEVICE_TABLE(pci, hpt366_pci_tbl); 1650MODULE_DEVICE_TABLE(pci, hpt366_pci_tbl);
diff --git a/drivers/ide/pci/it8213.c b/drivers/ide/pci/it8213.c
index ecf4ce078dce..24a71d03744a 100644
--- a/drivers/ide/pci/it8213.c
+++ b/drivers/ide/pci/it8213.c
@@ -18,37 +18,6 @@
18#include <asm/io.h> 18#include <asm/io.h>
19 19
20/** 20/**
21 * it8213_dma_2_pio - return the PIO mode matching DMA
22 * @xfer_rate: transfer speed
23 *
24 * Returns the nearest equivalent PIO timing for the DMA
25 * mode requested by the controller.
26 */
27
28static u8 it8213_dma_2_pio (u8 xfer_rate) {
29 switch(xfer_rate) {
30 case XFER_UDMA_6:
31 case XFER_UDMA_5:
32 case XFER_UDMA_4:
33 case XFER_UDMA_3:
34 case XFER_UDMA_2:
35 case XFER_UDMA_1:
36 case XFER_UDMA_0:
37 case XFER_MW_DMA_2:
38 return 4;
39 case XFER_MW_DMA_1:
40 return 3;
41 case XFER_SW_DMA_2:
42 return 2;
43 case XFER_MW_DMA_0:
44 case XFER_SW_DMA_1:
45 case XFER_SW_DMA_0:
46 default:
47 return 0;
48 }
49}
50
51/**
52 * it8213_set_pio_mode - set host controller for PIO mode 21 * it8213_set_pio_mode - set host controller for PIO mode
53 * @drive: drive 22 * @drive: drive
54 * @pio: PIO mode number 23 * @pio: PIO mode number
@@ -166,6 +135,9 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed)
166 } else 135 } else
167 pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); 136 pci_write_config_byte(dev, 0x54, reg54 & ~v_flag);
168 } else { 137 } else {
138 const u8 mwdma_to_pio[] = { 0, 3, 4 };
139 u8 pio;
140
169 if (reg48 & u_flag) 141 if (reg48 & u_flag)
170 pci_write_config_byte(dev, 0x48, reg48 & ~u_flag); 142 pci_write_config_byte(dev, 0x48, reg48 & ~u_flag);
171 if (reg4a & a_speed) 143 if (reg4a & a_speed)
@@ -174,38 +146,21 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed)
174 pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); 146 pci_write_config_byte(dev, 0x54, reg54 & ~v_flag);
175 if (reg55 & w_flag) 147 if (reg55 & w_flag)
176 pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag); 148 pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag);
177 }
178
179 it8213_set_pio_mode(drive, it8213_dma_2_pio(speed));
180}
181
182/**
183 * it8213_configure_drive_for_dma - set up for DMA transfers
184 * @drive: drive we are going to set up
185 *
186 * Set up the drive for DMA, tune the controller and drive as
187 * required. If the drive isn't suitable for DMA or we hit
188 * other problems then we will drop down to PIO and set up
189 * PIO appropriately
190 */
191 149
192static int it8213_config_drive_for_dma (ide_drive_t *drive) 150 if (speed >= XFER_MW_DMA_0)
193{ 151 pio = mwdma_to_pio[speed - XFER_MW_DMA_0];
194 if (ide_tune_dma(drive)) 152 else
195 return 0; 153 pio = 2; /* only SWDMA2 is allowed */
196 154
197 ide_set_max_pio(drive); 155 it8213_set_pio_mode(drive, pio);
198 156 }
199 return -1;
200} 157}
201 158
202/** 159/**
203 * init_hwif_it8213 - set up hwif structs 160 * init_hwif_it8213 - set up hwif structs
204 * @hwif: interface to set up 161 * @hwif: interface to set up
205 * 162 *
206 * We do the basic set up of the interface structure. The IT8212 163 * We do the basic set up of the interface structure.
207 * requires several custom handlers so we override the default
208 * ide DMA handlers appropriately
209 */ 164 */
210 165
211static void __devinit init_hwif_it8213(ide_hwif_t *hwif) 166static void __devinit init_hwif_it8213(ide_hwif_t *hwif)
@@ -215,8 +170,6 @@ static void __devinit init_hwif_it8213(ide_hwif_t *hwif)
215 hwif->set_dma_mode = &it8213_set_dma_mode; 170 hwif->set_dma_mode = &it8213_set_dma_mode;
216 hwif->set_pio_mode = &it8213_set_pio_mode; 171 hwif->set_pio_mode = &it8213_set_pio_mode;
217 172
218 hwif->autodma = 0;
219
220 hwif->drives[0].autotune = 1; 173 hwif->drives[0].autotune = 1;
221 hwif->drives[1].autotune = 1; 174 hwif->drives[1].autotune = 1;
222 175
@@ -230,20 +183,8 @@ static void __devinit init_hwif_it8213(ide_hwif_t *hwif)
230 183
231 pci_read_config_byte(hwif->pci_dev, 0x42, &reg42h); 184 pci_read_config_byte(hwif->pci_dev, 0x42, &reg42h);
232 185
233 hwif->ide_dma_check = &it8213_config_drive_for_dma;
234
235 if (hwif->cbl != ATA_CBL_PATA40_SHORT) 186 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
236 hwif->cbl = (reg42h & 0x02) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; 187 hwif->cbl = (reg42h & 0x02) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
237
238 /*
239 * The BIOS often doesn't set up DMA on this controller
240 * so we always do it.
241 */
242 if (!noautodma)
243 hwif->autodma = 1;
244
245 hwif->drives[0].autodma = hwif->autodma;
246 hwif->drives[1].autodma = hwif->autodma;
247} 188}
248 189
249 190
@@ -279,9 +220,8 @@ static int __devinit it8213_init_one(struct pci_dev *dev, const struct pci_devic
279 return 0; 220 return 0;
280} 221}
281 222
282 223static const struct pci_device_id it8213_pci_tbl[] = {
283static struct pci_device_id it8213_pci_tbl[] = { 224 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8213), 0 },
284 { PCI_VENDOR_ID_ITE, 0x8213, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
285 { 0, }, 225 { 0, },
286}; 226};
287 227
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c
index 1b69d82478c6..f3391a8698ac 100644
--- a/drivers/ide/pci/it821x.c
+++ b/drivers/ide/pci/it821x.c
@@ -416,26 +416,6 @@ static void it821x_set_dma_mode(ide_drive_t *drive, const u8 speed)
416} 416}
417 417
418/** 418/**
419 * it821x_configure_drive_for_dma - set up for DMA transfers
420 * @drive: drive we are going to set up
421 *
422 * Set up the drive for DMA, tune the controller and drive as
423 * required. If the drive isn't suitable for DMA or we hit
424 * other problems then we will drop down to PIO and set up
425 * PIO appropriately
426 */
427
428static int it821x_config_drive_for_dma (ide_drive_t *drive)
429{
430 if (ide_tune_dma(drive))
431 return 0;
432
433 ide_set_max_pio(drive);
434
435 return -1;
436}
437
438/**
439 * ata66_it821x - check for 80 pin cable 419 * ata66_it821x - check for 80 pin cable
440 * @hwif: interface to check 420 * @hwif: interface to check
441 * 421 *
@@ -557,10 +537,11 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
557 struct it821x_dev *idev = kzalloc(sizeof(struct it821x_dev), GFP_KERNEL); 537 struct it821x_dev *idev = kzalloc(sizeof(struct it821x_dev), GFP_KERNEL);
558 u8 conf; 538 u8 conf;
559 539
560 if(idev == NULL) { 540 if (idev == NULL) {
561 printk(KERN_ERR "it821x: out of memory, falling back to legacy behaviour.\n"); 541 printk(KERN_ERR "it821x: out of memory, falling back to legacy behaviour.\n");
562 goto fallback; 542 return;
563 } 543 }
544
564 ide_set_hwifdata(hwif, idev); 545 ide_set_hwifdata(hwif, idev);
565 546
566 hwif->atapi_dma = 1; 547 hwif->atapi_dma = 1;
@@ -609,29 +590,14 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
609 hwif->drives[0].autotune = 1; 590 hwif->drives[0].autotune = 1;
610 hwif->drives[1].autotune = 1; 591 hwif->drives[1].autotune = 1;
611 592
612 if (!hwif->dma_base) 593 if (hwif->dma_base == 0)
613 goto fallback; 594 return;
614 595
615 hwif->ultra_mask = 0x7f; 596 hwif->ultra_mask = 0x7f;
616 hwif->mwdma_mask = 0x07; 597 hwif->mwdma_mask = 0x07;
617 598
618 hwif->ide_dma_check = &it821x_config_drive_for_dma;
619
620 if (hwif->cbl != ATA_CBL_PATA40_SHORT) 599 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
621 hwif->cbl = ata66_it821x(hwif); 600 hwif->cbl = ata66_it821x(hwif);
622
623 /*
624 * The BIOS often doesn't set up DMA on this controller
625 * so we always do it.
626 */
627
628 hwif->autodma = 1;
629 hwif->drives[0].autodma = hwif->autodma;
630 hwif->drives[1].autodma = hwif->autodma;
631 return;
632fallback:
633 hwif->autodma = 0;
634 return;
635} 601}
636 602
637static void __devinit it8212_disable_raid(struct pci_dev *dev) 603static void __devinit it8212_disable_raid(struct pci_dev *dev)
@@ -697,9 +663,9 @@ static int __devinit it821x_init_one(struct pci_dev *dev, const struct pci_devic
697 return 0; 663 return 0;
698} 664}
699 665
700static struct pci_device_id it821x_pci_tbl[] = { 666static const struct pci_device_id it821x_pci_tbl[] = {
701 { PCI_VENDOR_ID_ITE, PCI_DEVICE_ID_ITE_8211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 667 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8211), 0 },
702 { PCI_VENDOR_ID_ITE, PCI_DEVICE_ID_ITE_8212, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 668 { PCI_VDEVICE(ITE, PCI_DEVICE_ID_ITE_8212), 0 },
703 { 0, }, 669 { 0, },
704}; 670};
705 671
diff --git a/drivers/ide/pci/jmicron.c b/drivers/ide/pci/jmicron.c
index 582b4cae2b53..bb893ffcc987 100644
--- a/drivers/ide/pci/jmicron.c
+++ b/drivers/ide/pci/jmicron.c
@@ -100,24 +100,6 @@ static void jmicron_set_dma_mode(ide_drive_t *drive, const u8 mode)
100} 100}
101 101
102/** 102/**
103 * jmicron_configure_drive_for_dma - set up for DMA transfers
104 * @drive: drive we are going to set up
105 *
106 * As the JMicron snoops for timings all we actually need to do is
107 * make sure we don't set an invalid mode.
108 */
109
110static int jmicron_config_drive_for_dma (ide_drive_t *drive)
111{
112 if (ide_tune_dma(drive))
113 return 0;
114
115 ide_set_max_pio(drive);
116
117 return -1;
118}
119
120/**
121 * init_hwif_jmicron - set up hwif structs 103 * init_hwif_jmicron - set up hwif structs
122 * @hwif: interface to set up 104 * @hwif: interface to set up
123 * 105 *
@@ -132,25 +114,15 @@ static void __devinit init_hwif_jmicron(ide_hwif_t *hwif)
132 hwif->drives[0].autotune = 1; 114 hwif->drives[0].autotune = 1;
133 hwif->drives[1].autotune = 1; 115 hwif->drives[1].autotune = 1;
134 116
135 if (!hwif->dma_base) 117 if (hwif->dma_base == 0)
136 goto fallback; 118 return;
137 119
138 hwif->atapi_dma = 1; 120 hwif->atapi_dma = 1;
139 hwif->ultra_mask = 0x7f; 121 hwif->ultra_mask = 0x7f;
140 hwif->mwdma_mask = 0x07; 122 hwif->mwdma_mask = 0x07;
141 123
142 hwif->ide_dma_check = &jmicron_config_drive_for_dma;
143
144 if (hwif->cbl != ATA_CBL_PATA40_SHORT) 124 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
145 hwif->cbl = ata66_jmicron(hwif); 125 hwif->cbl = ata66_jmicron(hwif);
146
147 hwif->autodma = 1;
148 hwif->drives[0].autodma = hwif->autodma;
149 hwif->drives[1].autodma = hwif->autodma;
150 return;
151fallback:
152 hwif->autodma = 0;
153 return;
154} 126}
155 127
156static ide_pci_device_t jmicron_chipset __devinitdata = { 128static ide_pci_device_t jmicron_chipset __devinitdata = {
diff --git a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c
index 465c935fdf25..a8cd50ab62fb 100644
--- a/drivers/ide/pci/ns87415.c
+++ b/drivers/ide/pci/ns87415.c
@@ -197,7 +197,6 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif)
197 u8 stat; 197 u8 stat;
198#endif 198#endif
199 199
200 hwif->autodma = 0;
201 hwif->selectproc = &ns87415_selectproc; 200 hwif->selectproc = &ns87415_selectproc;
202 201
203 /* 202 /*
@@ -259,11 +258,6 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif)
259 outb(0x60, hwif->dma_status); 258 outb(0x60, hwif->dma_status);
260 hwif->dma_setup = &ns87415_ide_dma_setup; 259 hwif->dma_setup = &ns87415_ide_dma_setup;
261 hwif->ide_dma_end = &ns87415_ide_dma_end; 260 hwif->ide_dma_end = &ns87415_ide_dma_end;
262
263 if (!noautodma)
264 hwif->autodma = 1;
265 hwif->drives[0].autodma = hwif->autodma;
266 hwif->drives[1].autodma = hwif->autodma;
267} 261}
268 262
269static ide_pci_device_t ns87415_chipset __devinitdata = { 263static ide_pci_device_t ns87415_chipset __devinitdata = {
@@ -274,6 +268,7 @@ static ide_pci_device_t ns87415_chipset __devinitdata = {
274 .init_hwif = init_hwif_ns87415, 268 .init_hwif = init_hwif_ns87415,
275 .autodma = AUTODMA, 269 .autodma = AUTODMA,
276 .bootable = ON_BOARD, 270 .bootable = ON_BOARD,
271 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
277}; 272};
278 273
279static int __devinit ns87415_init_one(struct pci_dev *dev, const struct pci_device_id *id) 274static int __devinit ns87415_init_one(struct pci_dev *dev, const struct pci_device_id *id)
@@ -281,8 +276,8 @@ static int __devinit ns87415_init_one(struct pci_dev *dev, const struct pci_devi
281 return ide_setup_pci_device(dev, &ns87415_chipset); 276 return ide_setup_pci_device(dev, &ns87415_chipset);
282} 277}
283 278
284static struct pci_device_id ns87415_pci_tbl[] = { 279static const struct pci_device_id ns87415_pci_tbl[] = {
285 { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87415, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 280 { PCI_VDEVICE(NS, PCI_DEVICE_ID_NS_87415), 0 },
286 { 0, }, 281 { 0, },
287}; 282};
288MODULE_DEVICE_TABLE(pci, ns87415_pci_tbl); 283MODULE_DEVICE_TABLE(pci, ns87415_pci_tbl);
diff --git a/drivers/ide/pci/opti621.c b/drivers/ide/pci/opti621.c
index 9fa06393469a..250662ea18ad 100644
--- a/drivers/ide/pci/opti621.c
+++ b/drivers/ide/pci/opti621.c
@@ -328,7 +328,6 @@ static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio)
328 */ 328 */
329static void __devinit init_hwif_opti621 (ide_hwif_t *hwif) 329static void __devinit init_hwif_opti621 (ide_hwif_t *hwif)
330{ 330{
331 hwif->autodma = 0;
332 hwif->drives[0].drive_data = PIO_DONT_KNOW; 331 hwif->drives[0].drive_data = PIO_DONT_KNOW;
333 hwif->drives[1].drive_data = PIO_DONT_KNOW; 332 hwif->drives[1].drive_data = PIO_DONT_KNOW;
334 333
@@ -340,11 +339,6 @@ static void __devinit init_hwif_opti621 (ide_hwif_t *hwif)
340 hwif->atapi_dma = 1; 339 hwif->atapi_dma = 1;
341 hwif->mwdma_mask = 0x07; 340 hwif->mwdma_mask = 0x07;
342 hwif->swdma_mask = 0x07; 341 hwif->swdma_mask = 0x07;
343
344 if (!noautodma)
345 hwif->autodma = 1;
346 hwif->drives[0].autodma = hwif->autodma;
347 hwif->drives[1].autodma = hwif->autodma;
348} 342}
349 343
350static ide_pci_device_t opti621_chipsets[] __devinitdata = { 344static ide_pci_device_t opti621_chipsets[] __devinitdata = {
@@ -355,6 +349,7 @@ static ide_pci_device_t opti621_chipsets[] __devinitdata = {
355 .enablebits = {{0x45,0x80,0x00}, {0x40,0x08,0x00}}, 349 .enablebits = {{0x45,0x80,0x00}, {0x40,0x08,0x00}},
356 .bootable = ON_BOARD, 350 .bootable = ON_BOARD,
357 .pio_mask = ATA_PIO3, 351 .pio_mask = ATA_PIO3,
352 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
358 },{ /* 1 */ 353 },{ /* 1 */
359 .name = "OPTI621X", 354 .name = "OPTI621X",
360 .init_hwif = init_hwif_opti621, 355 .init_hwif = init_hwif_opti621,
@@ -362,6 +357,7 @@ static ide_pci_device_t opti621_chipsets[] __devinitdata = {
362 .enablebits = {{0x45,0x80,0x00}, {0x40,0x08,0x00}}, 357 .enablebits = {{0x45,0x80,0x00}, {0x40,0x08,0x00}},
363 .bootable = ON_BOARD, 358 .bootable = ON_BOARD,
364 .pio_mask = ATA_PIO3, 359 .pio_mask = ATA_PIO3,
360 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
365 } 361 }
366}; 362};
367 363
@@ -370,9 +366,9 @@ static int __devinit opti621_init_one(struct pci_dev *dev, const struct pci_devi
370 return ide_setup_pci_device(dev, &opti621_chipsets[id->driver_data]); 366 return ide_setup_pci_device(dev, &opti621_chipsets[id->driver_data]);
371} 367}
372 368
373static struct pci_device_id opti621_pci_tbl[] = { 369static const struct pci_device_id opti621_pci_tbl[] = {
374 { PCI_VENDOR_ID_OPTI, PCI_DEVICE_ID_OPTI_82C621, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 370 { PCI_VDEVICE(OPTI, PCI_DEVICE_ID_OPTI_82C621), 0 },
375 { PCI_VENDOR_ID_OPTI, PCI_DEVICE_ID_OPTI_82C825, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, 371 { PCI_VDEVICE(OPTI, PCI_DEVICE_ID_OPTI_82C825), 1 },
376 { 0, }, 372 { 0, },
377}; 373};
378MODULE_DEVICE_TABLE(pci, opti621_pci_tbl); 374MODULE_DEVICE_TABLE(pci, opti621_pci_tbl);
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c
index ad0bdcb0c02b..8704b6f33312 100644
--- a/drivers/ide/pci/pdc202xx_new.c
+++ b/drivers/ide/pci/pdc202xx_new.c
@@ -223,19 +223,6 @@ static u8 pdcnew_cable_detect(ide_hwif_t *hwif)
223 return ATA_CBL_PATA80; 223 return ATA_CBL_PATA80;
224} 224}
225 225
226static int pdcnew_config_drive_xfer_rate(ide_drive_t *drive)
227{
228 drive->init_speed = 0;
229
230 if (ide_tune_dma(drive))
231 return 0;
232
233 if (ide_use_fast_pio(drive))
234 ide_set_max_pio(drive);
235
236 return -1;
237}
238
239static int pdcnew_quirkproc(ide_drive_t *drive) 226static int pdcnew_quirkproc(ide_drive_t *drive)
240{ 227{
241 const char **list, *model = drive->id->model; 228 const char **list, *model = drive->id->model;
@@ -482,8 +469,6 @@ static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev, const cha
482 469
483static void __devinit init_hwif_pdc202new(ide_hwif_t *hwif) 470static void __devinit init_hwif_pdc202new(ide_hwif_t *hwif)
484{ 471{
485 hwif->autodma = 0;
486
487 hwif->set_pio_mode = &pdcnew_set_pio_mode; 472 hwif->set_pio_mode = &pdcnew_set_pio_mode;
488 hwif->set_dma_mode = &pdcnew_set_mode; 473 hwif->set_dma_mode = &pdcnew_set_mode;
489 474
@@ -502,14 +487,8 @@ static void __devinit init_hwif_pdc202new(ide_hwif_t *hwif)
502 hwif->ultra_mask = hwif->cds->udma_mask; 487 hwif->ultra_mask = hwif->cds->udma_mask;
503 hwif->mwdma_mask = 0x07; 488 hwif->mwdma_mask = 0x07;
504 489
505 hwif->ide_dma_check = &pdcnew_config_drive_xfer_rate;
506
507 if (hwif->cbl != ATA_CBL_PATA40_SHORT) 490 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
508 hwif->cbl = pdcnew_cable_detect(hwif); 491 hwif->cbl = pdcnew_cable_detect(hwif);
509
510 if (!noautodma)
511 hwif->autodma = 1;
512 hwif->drives[0].autodma = hwif->drives[1].autodma = hwif->autodma;
513} 492}
514 493
515static int __devinit init_setup_pdcnew(struct pci_dev *dev, ide_pci_device_t *d) 494static int __devinit init_setup_pdcnew(struct pci_dev *dev, ide_pci_device_t *d)
@@ -658,14 +637,14 @@ static int __devinit pdc202new_init_one(struct pci_dev *dev, const struct pci_de
658 return d->init_setup(dev, d); 637 return d->init_setup(dev, d);
659} 638}
660 639
661static struct pci_device_id pdc202new_pci_tbl[] = { 640static const struct pci_device_id pdc202new_pci_tbl[] = {
662 { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20268, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 641 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20268), 0 },
663 { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20269, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, 642 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20269), 1 },
664 { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20270, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2}, 643 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20270), 2 },
665 { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20271, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3}, 644 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20271), 3 },
666 { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20275, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4}, 645 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20275), 4 },
667 { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20276, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5}, 646 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20276), 5 },
668 { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20277, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 6}, 647 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20277), 6 },
669 { 0, }, 648 { 0, },
670}; 649};
671MODULE_DEVICE_TABLE(pci, pdc202new_pci_tbl); 650MODULE_DEVICE_TABLE(pci, pdc202new_pci_tbl);
diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c
index 8c3e8cf36ec9..e1d2337a9f1d 100644
--- a/drivers/ide/pci/pdc202xx_old.c
+++ b/drivers/ide/pci/pdc202xx_old.c
@@ -179,19 +179,6 @@ static void pdc_old_disable_66MHz_clock(ide_hwif_t *hwif)
179 outb(clock & ~(hwif->channel ? 0x08 : 0x02), clock_reg); 179 outb(clock & ~(hwif->channel ? 0x08 : 0x02), clock_reg);
180} 180}
181 181
182static int pdc202xx_config_drive_xfer_rate (ide_drive_t *drive)
183{
184 drive->init_speed = 0;
185
186 if (ide_tune_dma(drive))
187 return 0;
188
189 if (ide_use_fast_pio(drive))
190 ide_set_max_pio(drive);
191
192 return -1;
193}
194
195static int pdc202xx_quirkproc (ide_drive_t *drive) 182static int pdc202xx_quirkproc (ide_drive_t *drive)
196{ 183{
197 const char **list, *model = drive->id->model; 184 const char **list, *model = drive->id->model;
@@ -325,8 +312,6 @@ static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif)
325 (dev->device == PCI_DEVICE_ID_PROMISE_20265)) 312 (dev->device == PCI_DEVICE_ID_PROMISE_20265))
326 hwif->rqsize = 256; 313 hwif->rqsize = 256;
327 314
328 hwif->autodma = 0;
329
330 hwif->set_pio_mode = &pdc202xx_set_pio_mode; 315 hwif->set_pio_mode = &pdc202xx_set_pio_mode;
331 hwif->set_dma_mode = &pdc202xx_set_mode; 316 hwif->set_dma_mode = &pdc202xx_set_mode;
332 317
@@ -347,7 +332,6 @@ static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif)
347 hwif->swdma_mask = 0x07; 332 hwif->swdma_mask = 0x07;
348 hwif->atapi_dma = 1; 333 hwif->atapi_dma = 1;
349 334
350 hwif->ide_dma_check = &pdc202xx_config_drive_xfer_rate;
351 hwif->dma_lost_irq = &pdc202xx_dma_lost_irq; 335 hwif->dma_lost_irq = &pdc202xx_dma_lost_irq;
352 hwif->dma_timeout = &pdc202xx_dma_timeout; 336 hwif->dma_timeout = &pdc202xx_dma_timeout;
353 337
@@ -359,10 +343,6 @@ static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif)
359 hwif->ide_dma_end = &pdc202xx_old_ide_dma_end; 343 hwif->ide_dma_end = &pdc202xx_old_ide_dma_end;
360 } 344 }
361 hwif->ide_dma_test_irq = &pdc202xx_old_ide_dma_test_irq; 345 hwif->ide_dma_test_irq = &pdc202xx_old_ide_dma_test_irq;
362
363 if (!noautodma)
364 hwif->autodma = 1;
365 hwif->drives[0].autodma = hwif->drives[1].autodma = hwif->autodma;
366} 346}
367 347
368static void __devinit init_dma_pdc202xx(ide_hwif_t *hwif, unsigned long dmabase) 348static void __devinit init_dma_pdc202xx(ide_hwif_t *hwif, unsigned long dmabase)
@@ -510,12 +490,12 @@ static int __devinit pdc202xx_init_one(struct pci_dev *dev, const struct pci_dev
510 return d->init_setup(dev, d); 490 return d->init_setup(dev, d);
511} 491}
512 492
513static struct pci_device_id pdc202xx_pci_tbl[] = { 493static const struct pci_device_id pdc202xx_pci_tbl[] = {
514 { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20246, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 494 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20246), 0 },
515 { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20262, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, 495 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20262), 1 },
516 { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20263, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2}, 496 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20263), 2 },
517 { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20265, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3}, 497 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20265), 3 },
518 { PCI_VENDOR_ID_PROMISE, PCI_DEVICE_ID_PROMISE_20267, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4}, 498 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20267), 4 },
519 { 0, }, 499 { 0, },
520}; 500};
521MODULE_DEVICE_TABLE(pci, pdc202xx_pci_tbl); 501MODULE_DEVICE_TABLE(pci, pdc202xx_pci_tbl);
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c
index 38c91ba6497b..a8dd0c0add35 100644
--- a/drivers/ide/pci/piix.c
+++ b/drivers/ide/pci/piix.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/ide/pci/piix.c Version 0.52 Jul 14, 2007 2 * linux/drivers/ide/pci/piix.c Version 0.53 Aug 9, 2007
3 * 3 *
4 * Copyright (C) 1998-1999 Andrzej Krzysztofowicz, Author and Maintainer 4 * Copyright (C) 1998-1999 Andrzej Krzysztofowicz, Author and Maintainer
5 * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org> 5 * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org>
@@ -106,37 +106,6 @@
106static int no_piix_dma; 106static int no_piix_dma;
107 107
108/** 108/**
109 * piix_dma_2_pio - return the PIO mode matching DMA
110 * @xfer_rate: transfer speed
111 *
112 * Returns the nearest equivalent PIO timing for the DMA
113 * mode requested by the controller.
114 */
115
116static u8 piix_dma_2_pio (u8 xfer_rate) {
117 switch(xfer_rate) {
118 case XFER_UDMA_6:
119 case XFER_UDMA_5:
120 case XFER_UDMA_4:
121 case XFER_UDMA_3:
122 case XFER_UDMA_2:
123 case XFER_UDMA_1:
124 case XFER_UDMA_0:
125 case XFER_MW_DMA_2:
126 return 4;
127 case XFER_MW_DMA_1:
128 return 3;
129 case XFER_SW_DMA_2:
130 return 2;
131 case XFER_MW_DMA_0:
132 case XFER_SW_DMA_1:
133 case XFER_SW_DMA_0:
134 default:
135 return 0;
136 }
137}
138
139/**
140 * piix_set_pio_mode - set host controller for PIO mode 109 * piix_set_pio_mode - set host controller for PIO mode
141 * @drive: drive 110 * @drive: drive
142 * @pio: PIO mode number 111 * @pio: PIO mode number
@@ -263,6 +232,9 @@ static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed)
263 } else 232 } else
264 pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); 233 pci_write_config_byte(dev, 0x54, reg54 & ~v_flag);
265 } else { 234 } else {
235 const u8 mwdma_to_pio[] = { 0, 3, 4 };
236 u8 pio;
237
266 if (reg48 & u_flag) 238 if (reg48 & u_flag)
267 pci_write_config_byte(dev, 0x48, reg48 & ~u_flag); 239 pci_write_config_byte(dev, 0x48, reg48 & ~u_flag);
268 if (reg4a & a_speed) 240 if (reg4a & a_speed)
@@ -271,30 +243,14 @@ static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed)
271 pci_write_config_byte(dev, 0x54, reg54 & ~v_flag); 243 pci_write_config_byte(dev, 0x54, reg54 & ~v_flag);
272 if (reg55 & w_flag) 244 if (reg55 & w_flag)
273 pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag); 245 pci_write_config_byte(dev, 0x55, (u8) reg55 & ~w_flag);
274 }
275 246
276 piix_set_pio_mode(drive, piix_dma_2_pio(speed)); 247 if (speed >= XFER_MW_DMA_0)
277} 248 pio = mwdma_to_pio[speed - XFER_MW_DMA_0];
278 249 else
279/** 250 pio = 2; /* only SWDMA2 is allowed */
280 * piix_config_drive_xfer_rate - set up an IDE device
281 * @drive: IDE drive to configure
282 *
283 * Set up the PIIX interface for the best available speed on this
284 * interface, preferring DMA to PIO.
285 */
286
287static int piix_config_drive_xfer_rate (ide_drive_t *drive)
288{
289 drive->init_speed = 0;
290 251
291 if (ide_tune_dma(drive)) 252 piix_set_pio_mode(drive, pio);
292 return 0; 253 }
293
294 if (ide_use_fast_pio(drive))
295 ide_set_max_pio(drive);
296
297 return -1;
298} 254}
299 255
300/** 256/**
@@ -428,8 +384,6 @@ static void __devinit init_hwif_piix(ide_hwif_t *hwif)
428 return; 384 return;
429 } 385 }
430 386
431 hwif->autodma = 0;
432
433 hwif->set_pio_mode = &piix_set_pio_mode; 387 hwif->set_pio_mode = &piix_set_pio_mode;
434 hwif->set_dma_mode = &piix_set_dma_mode; 388 hwif->set_dma_mode = &piix_set_dma_mode;
435 389
@@ -456,13 +410,6 @@ static void __devinit init_hwif_piix(ide_hwif_t *hwif)
456 410
457 if (no_piix_dma) 411 if (no_piix_dma)
458 hwif->ultra_mask = hwif->mwdma_mask = hwif->swdma_mask = 0; 412 hwif->ultra_mask = hwif->mwdma_mask = hwif->swdma_mask = 0;
459
460 hwif->ide_dma_check = &piix_config_drive_xfer_rate;
461 if (!noautodma)
462 hwif->autodma = 1;
463
464 hwif->drives[1].autodma = hwif->autodma;
465 hwif->drives[0].autodma = hwif->autodma;
466} 413}
467 414
468#define DECLARE_PIIX_DEV(name_str, udma) \ 415#define DECLARE_PIIX_DEV(name_str, udma) \
@@ -565,34 +512,34 @@ static void __devinit piix_check_450nx(void)
565 printk(KERN_WARNING "piix: A BIOS update may resolve this.\n"); 512 printk(KERN_WARNING "piix: A BIOS update may resolve this.\n");
566} 513}
567 514
568static struct pci_device_id piix_pci_tbl[] = { 515static const struct pci_device_id piix_pci_tbl[] = {
569 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371FB_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 516 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371FB_0), 0 },
570 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371FB_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, 517 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371FB_1), 1 },
571 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371MX, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2}, 518 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371MX), 2 },
572 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371SB_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3}, 519 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371SB_1), 3 },
573 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4}, 520 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371AB), 4 },
574 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AB_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5}, 521 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801AB_1), 5 },
575 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443MX_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 6}, 522 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82443MX_1), 6 },
576 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 7}, 523 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801AA_1), 7 },
577 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82372FB_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 8}, 524 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82372FB_1), 8 },
578 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82451NX, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 9}, 525 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82451NX), 9 },
579 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 10}, 526 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801BA_9), 10 },
580 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 11}, 527 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801BA_8), 11 },
581 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_10,PCI_ANY_ID, PCI_ANY_ID, 0, 0, 12}, 528 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801CA_10), 12 },
582 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_11,PCI_ANY_ID, PCI_ANY_ID, 0, 0, 13}, 529 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801CA_11), 13 },
583 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_11,PCI_ANY_ID, PCI_ANY_ID, 0, 0, 14}, 530 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801DB_11), 14 },
584 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_11,PCI_ANY_ID, PCI_ANY_ID, 0, 0, 15}, 531 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801EB_11), 15 },
585 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801E_11, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 16}, 532 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801E_11), 16 },
586 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_10,PCI_ANY_ID, PCI_ANY_ID, 0, 0, 17}, 533 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801DB_10), 17 },
587#ifdef CONFIG_BLK_DEV_IDE_SATA 534#ifdef CONFIG_BLK_DEV_IDE_SATA
588 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 18}, 535 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801EB_1), 18 },
589#endif 536#endif
590 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 19}, 537 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ESB_2), 19 },
591 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_19, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 20}, 538 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ICH6_19), 20 },
592 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_21, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 21}, 539 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ICH7_21), 21 },
593 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 22}, 540 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801DB_1), 22 },
594 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_18, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 23}, 541 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ESB2_18), 23 },
595 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 24}, 542 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ICH8_6), 24 },
596 { 0, }, 543 { 0, },
597}; 544};
598MODULE_DEVICE_TABLE(pci, piix_pci_tbl); 545MODULE_DEVICE_TABLE(pci, piix_pci_tbl);
diff --git a/drivers/ide/pci/rz1000.c b/drivers/ide/pci/rz1000.c
index 10e1ae7a4a02..3f506e8d44e3 100644
--- a/drivers/ide/pci/rz1000.c
+++ b/drivers/ide/pci/rz1000.c
@@ -61,9 +61,9 @@ static int __devinit rz1000_init_one(struct pci_dev *dev, const struct pci_devic
61 return ide_setup_pci_device(dev, &rz1000_chipset); 61 return ide_setup_pci_device(dev, &rz1000_chipset);
62} 62}
63 63
64static struct pci_device_id rz1000_pci_tbl[] = { 64static const struct pci_device_id rz1000_pci_tbl[] = {
65 { PCI_VENDOR_ID_PCTECH, PCI_DEVICE_ID_PCTECH_RZ1000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 65 { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_RZ1000), 0 },
66 { PCI_VENDOR_ID_PCTECH, PCI_DEVICE_ID_PCTECH_RZ1001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 66 { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_RZ1001), 0 },
67 { 0, }, 67 { 0, },
68}; 68};
69MODULE_DEVICE_TABLE(pci, rz1000_pci_tbl); 69MODULE_DEVICE_TABLE(pci, rz1000_pci_tbl);
diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c
index ee0e3f554d9a..54c5c98a2e26 100644
--- a/drivers/ide/pci/sc1200.c
+++ b/drivers/ide/pci/sc1200.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/ide/pci/sc1200.c Version 0.95 Jun 16 2007 2 * linux/drivers/ide/pci/sc1200.c Version 0.97 Aug 3 2007
3 * 3 *
4 * Copyright (C) 2000-2002 Mark Lord <mlord@pobox.com> 4 * Copyright (C) 2000-2002 Mark Lord <mlord@pobox.com>
5 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz 5 * Copyright (C) 2007 Bartlomiej Zolnierkiewicz
@@ -199,19 +199,6 @@ static void sc1200_set_dma_mode(ide_drive_t *drive, const u8 mode)
199 } 199 }
200} 200}
201 201
202/*
203 * sc1200_config_dma() handles selection/setting of DMA/UDMA modes
204 * for both the chipset and drive.
205 */
206static int sc1200_config_dma (ide_drive_t *drive)
207{
208 if (ide_tune_dma(drive))
209 return 0;
210
211 return 1;
212}
213
214
215/* Replacement for the standard ide_dma_end action in 202/* Replacement for the standard ide_dma_end action in
216 * dma_proc. 203 * dma_proc.
217 * 204 *
@@ -377,27 +364,22 @@ static void __devinit init_hwif_sc1200 (ide_hwif_t *hwif)
377{ 364{
378 if (hwif->mate) 365 if (hwif->mate)
379 hwif->serialized = hwif->mate->serialized = 1; 366 hwif->serialized = hwif->mate->serialized = 1;
380 hwif->autodma = 0;
381 367
382 hwif->set_pio_mode = &sc1200_set_pio_mode; 368 hwif->set_pio_mode = &sc1200_set_pio_mode;
383 hwif->set_dma_mode = &sc1200_set_dma_mode; 369 hwif->set_dma_mode = &sc1200_set_dma_mode;
384 370
371 hwif->drives[0].autotune = 1;
372 hwif->drives[1].autotune = 1;
373
385 if (hwif->dma_base == 0) 374 if (hwif->dma_base == 0)
386 return; 375 return;
387 376
388 hwif->udma_filter = sc1200_udma_filter; 377 hwif->udma_filter = sc1200_udma_filter;
389 hwif->ide_dma_check = &sc1200_config_dma;
390 hwif->ide_dma_end = &sc1200_ide_dma_end; 378 hwif->ide_dma_end = &sc1200_ide_dma_end;
391 379
392 if (!noautodma)
393 hwif->autodma = 1;
394
395 hwif->atapi_dma = 1; 380 hwif->atapi_dma = 1;
396 hwif->ultra_mask = 0x07; 381 hwif->ultra_mask = 0x07;
397 hwif->mwdma_mask = 0x07; 382 hwif->mwdma_mask = 0x07;
398
399 hwif->drives[0].autodma = hwif->autodma;
400 hwif->drives[1].autodma = hwif->autodma;
401} 383}
402 384
403static ide_pci_device_t sc1200_chipset __devinitdata = { 385static ide_pci_device_t sc1200_chipset __devinitdata = {
@@ -414,8 +396,8 @@ static int __devinit sc1200_init_one(struct pci_dev *dev, const struct pci_devic
414 return ide_setup_pci_device(dev, &sc1200_chipset); 396 return ide_setup_pci_device(dev, &sc1200_chipset);
415} 397}
416 398
417static struct pci_device_id sc1200_pci_tbl[] = { 399static const struct pci_device_id sc1200_pci_tbl[] = {
418 { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SCx200_IDE), 0}, 400 { PCI_VDEVICE(NS, PCI_DEVICE_ID_NS_SCx200_IDE), 0},
419 { 0, }, 401 { 0, },
420}; 402};
421MODULE_DEVICE_TABLE(pci, sc1200_pci_tbl); 403MODULE_DEVICE_TABLE(pci, sc1200_pci_tbl);
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c
index 67f06dd11b34..bd4c1d3070e4 100644
--- a/drivers/ide/pci/scc_pata.c
+++ b/drivers/ide/pci/scc_pata.c
@@ -284,28 +284,6 @@ static void scc_set_dma_mode(ide_drive_t *drive, const u8 speed)
284} 284}
285 285
286/** 286/**
287 * scc_configure_drive_for_dma - set up for DMA transfers
288 * @drive: drive we are going to set up
289 *
290 * Set up the drive for DMA, tune the controller and drive as
291 * required.
292 * If the drive isn't suitable for DMA or we hit other problems
293 * then we will drop down to PIO and set up PIO appropriately.
294 * (return -1)
295 */
296
297static int scc_config_drive_for_dma(ide_drive_t *drive)
298{
299 if (ide_tune_dma(drive))
300 return 0;
301
302 if (ide_use_fast_pio(drive))
303 ide_set_max_pio(drive);
304
305 return -1;
306}
307
308/**
309 * scc_ide_dma_setup - begin a DMA phase 287 * scc_ide_dma_setup - begin a DMA phase
310 * @drive: target device 288 * @drive: target device
311 * 289 *
@@ -702,7 +680,6 @@ static void __devinit init_hwif_scc(ide_hwif_t *hwif)
702 hwif->ide_dma_end = scc_ide_dma_end; 680 hwif->ide_dma_end = scc_ide_dma_end;
703 hwif->set_pio_mode = scc_set_pio_mode; 681 hwif->set_pio_mode = scc_set_pio_mode;
704 hwif->set_dma_mode = scc_set_dma_mode; 682 hwif->set_dma_mode = scc_set_dma_mode;
705 hwif->ide_dma_check = scc_config_drive_for_dma;
706 hwif->ide_dma_test_irq = scc_dma_test_irq; 683 hwif->ide_dma_test_irq = scc_dma_test_irq;
707 hwif->udma_filter = scc_udma_filter; 684 hwif->udma_filter = scc_udma_filter;
708 685
@@ -720,12 +697,6 @@ static void __devinit init_hwif_scc(ide_hwif_t *hwif)
720 697
721 /* we support 80c cable only. */ 698 /* we support 80c cable only. */
722 hwif->cbl = ATA_CBL_PATA80; 699 hwif->cbl = ATA_CBL_PATA80;
723
724 hwif->autodma = 0;
725 if (!noautodma)
726 hwif->autodma = 1;
727 hwif->drives[0].autodma = hwif->autodma;
728 hwif->drives[1].autodma = hwif->autodma;
729} 700}
730 701
731#define DECLARE_SCC_DEV(name_str) \ 702#define DECLARE_SCC_DEV(name_str) \
@@ -793,8 +764,8 @@ static void __devexit scc_remove(struct pci_dev *dev)
793 memset(ports, 0, sizeof(*ports)); 764 memset(ports, 0, sizeof(*ports));
794} 765}
795 766
796static struct pci_device_id scc_pci_tbl[] = { 767static const struct pci_device_id scc_pci_tbl[] = {
797 { PCI_VENDOR_ID_TOSHIBA_2, PCI_DEVICE_ID_TOSHIBA_SCC_ATA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 768 { PCI_VDEVICE(TOSHIBA_2, PCI_DEVICE_ID_TOSHIBA_SCC_ATA), 0 },
798 { 0, }, 769 { 0, },
799}; 770};
800MODULE_DEVICE_TABLE(pci, scc_pci_tbl); 771MODULE_DEVICE_TABLE(pci, scc_pci_tbl);
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c
index 49ec0ac64a4b..d3ffc52e22af 100644
--- a/drivers/ide/pci/serverworks.c
+++ b/drivers/ide/pci/serverworks.c
@@ -97,6 +97,7 @@ static u8 svwks_udma_filter(ide_drive_t *drive)
97 mode = 2; 97 mode = 2;
98 98
99 switch(mode) { 99 switch(mode) {
100 case 3: mask = 0x3f; break;
100 case 2: mask = 0x1f; break; 101 case 2: mask = 0x1f; break;
101 case 1: mask = 0x07; break; 102 case 1: mask = 0x07; break;
102 default: mask = 0x00; break; 103 default: mask = 0x00; break;
@@ -195,19 +196,6 @@ static void svwks_set_dma_mode(ide_drive_t *drive, const u8 speed)
195 pci_write_config_byte(dev, 0x54, ultra_enable); 196 pci_write_config_byte(dev, 0x54, ultra_enable);
196} 197}
197 198
198static int svwks_config_drive_xfer_rate (ide_drive_t *drive)
199{
200 drive->init_speed = 0;
201
202 if (ide_tune_dma(drive))
203 return 0;
204
205 if (ide_use_fast_pio(drive))
206 ide_set_max_pio(drive);
207
208 return -1;
209}
210
211static unsigned int __devinit init_chipset_svwks (struct pci_dev *dev, const char *name) 199static unsigned int __devinit init_chipset_svwks (struct pci_dev *dev, const char *name)
212{ 200{
213 unsigned int reg; 201 unsigned int reg;
@@ -386,23 +374,16 @@ static void __devinit init_hwif_svwks (ide_hwif_t *hwif)
386 374
387 hwif->mwdma_mask = 0x07; 375 hwif->mwdma_mask = 0x07;
388 376
389 hwif->autodma = 0;
390
391 hwif->drives[0].autotune = 1; 377 hwif->drives[0].autotune = 1;
392 hwif->drives[1].autotune = 1; 378 hwif->drives[1].autotune = 1;
393 379
394 if (!hwif->dma_base) 380 if (!hwif->dma_base)
395 return; 381 return;
396 382
397 hwif->ide_dma_check = &svwks_config_drive_xfer_rate;
398 if (hwif->pci_dev->device != PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) { 383 if (hwif->pci_dev->device != PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) {
399 if (hwif->cbl != ATA_CBL_PATA40_SHORT) 384 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
400 hwif->cbl = ata66_svwks(hwif); 385 hwif->cbl = ata66_svwks(hwif);
401 } 386 }
402 if (!noautodma)
403 hwif->autodma = 1;
404
405 hwif->drives[0].autodma = hwif->drives[1].autodma = 1;
406} 387}
407 388
408static int __devinit init_setup_svwks (struct pci_dev *dev, ide_pci_device_t *d) 389static int __devinit init_setup_svwks (struct pci_dev *dev, ide_pci_device_t *d)
@@ -490,12 +471,12 @@ static int __devinit svwks_init_one(struct pci_dev *dev, const struct pci_device
490 return d->init_setup(dev, d); 471 return d->init_setup(dev, d);
491} 472}
492 473
493static struct pci_device_id svwks_pci_tbl[] = { 474static const struct pci_device_id svwks_pci_tbl[] = {
494 { PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_OSB4IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 475 { PCI_VDEVICE(SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_OSB4IDE), 0 },
495 { PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, 476 { PCI_VDEVICE(SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5IDE), 1 },
496 { PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2}, 477 { PCI_VDEVICE(SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6IDE), 2 },
497 { PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3}, 478 { PCI_VDEVICE(SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2), 3 },
498 { PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4}, 479 { PCI_VDEVICE(SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000IDE), 4 },
499 { 0, }, 480 { 0, },
500}; 481};
501MODULE_DEVICE_TABLE(pci, svwks_pci_tbl); 482MODULE_DEVICE_TABLE(pci, svwks_pci_tbl);
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index c74fef6bbc91..9a9474f534e5 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -296,20 +296,6 @@ static void sgiioc4_set_dma_mode(ide_drive_t *drive, const u8 speed)
296{ 296{
297} 297}
298 298
299static int sgiioc4_ide_dma_check(ide_drive_t *drive)
300{
301 if (ide_tune_dma(drive))
302 return 0;
303
304 /*
305 * ->set_pio_mode is not implemented currently
306 * so this is just for the completness
307 */
308 ide_set_max_pio(drive);
309
310 return -1;
311}
312
313/* returns 1 if dma irq issued, 0 otherwise */ 299/* returns 1 if dma irq issued, 0 otherwise */
314static int 300static int
315sgiioc4_ide_dma_test_irq(ide_drive_t * drive) 301sgiioc4_ide_dma_test_irq(ide_drive_t * drive)
@@ -612,7 +598,6 @@ ide_init_sgiioc4(ide_hwif_t * hwif)
612 hwif->dma_setup = &sgiioc4_ide_dma_setup; 598 hwif->dma_setup = &sgiioc4_ide_dma_setup;
613 hwif->dma_start = &sgiioc4_ide_dma_start; 599 hwif->dma_start = &sgiioc4_ide_dma_start;
614 hwif->ide_dma_end = &sgiioc4_ide_dma_end; 600 hwif->ide_dma_end = &sgiioc4_ide_dma_end;
615 hwif->ide_dma_check = &sgiioc4_ide_dma_check;
616 hwif->ide_dma_on = &sgiioc4_ide_dma_on; 601 hwif->ide_dma_on = &sgiioc4_ide_dma_on;
617 hwif->dma_off_quietly = &sgiioc4_dma_off_quietly; 602 hwif->dma_off_quietly = &sgiioc4_dma_off_quietly;
618 hwif->ide_dma_test_irq = &sgiioc4_ide_dma_test_irq; 603 hwif->ide_dma_test_irq = &sgiioc4_ide_dma_test_irq;
@@ -689,12 +674,7 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev)
689 /* Initializing chipset IRQ Registers */ 674 /* Initializing chipset IRQ Registers */
690 writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4)); 675 writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4));
691 676
692 hwif->autodma = 0; 677 if (dma_base == 0 || ide_dma_sgiioc4(hwif, dma_base))
693
694 if (dma_base && ide_dma_sgiioc4(hwif, dma_base) == 0) {
695 hwif->autodma = 1;
696 hwif->drives[1].autodma = hwif->drives[0].autodma = 1;
697 } else
698 printk(KERN_INFO "%s: %s Bus-Master DMA disabled\n", 678 printk(KERN_INFO "%s: %s Bus-Master DMA disabled\n",
699 hwif->name, DRV_NAME); 679 hwif->name, DRV_NAME);
700 680
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
index ce7784996d12..85d0afd00e66 100644
--- a/drivers/ide/pci/siimage.c
+++ b/drivers/ide/pci/siimage.c
@@ -311,27 +311,6 @@ static void sil_set_dma_mode(ide_drive_t *drive, const u8 speed)
311 } 311 }
312} 312}
313 313
314/**
315 * siimage_configure_drive_for_dma - set up for DMA transfers
316 * @drive: drive we are going to set up
317 *
318 * Set up the drive for DMA, tune the controller and drive as
319 * required. If the drive isn't suitable for DMA or we hit
320 * other problems then we will drop down to PIO and set up
321 * PIO appropriately
322 */
323
324static int siimage_config_drive_for_dma (ide_drive_t *drive)
325{
326 if (ide_tune_dma(drive))
327 return 0;
328
329 if (ide_use_fast_pio(drive))
330 ide_set_max_pio(drive);
331
332 return -1;
333}
334
335/* returns 1 if dma irq issued, 0 otherwise */ 314/* returns 1 if dma irq issued, 0 otherwise */
336static int siimage_io_ide_dma_test_irq (ide_drive_t *drive) 315static int siimage_io_ide_dma_test_irq (ide_drive_t *drive)
337{ 316{
@@ -894,8 +873,6 @@ static u8 __devinit ata66_siimage(ide_hwif_t *hwif)
894 873
895static void __devinit init_hwif_siimage(ide_hwif_t *hwif) 874static void __devinit init_hwif_siimage(ide_hwif_t *hwif)
896{ 875{
897 hwif->autodma = 0;
898
899 hwif->resetproc = &siimage_reset; 876 hwif->resetproc = &siimage_reset;
900 hwif->set_pio_mode = &sil_set_pio_mode; 877 hwif->set_pio_mode = &sil_set_pio_mode;
901 hwif->set_dma_mode = &sil_set_dma_mode; 878 hwif->set_dma_mode = &sil_set_dma_mode;
@@ -925,8 +902,6 @@ static void __devinit init_hwif_siimage(ide_hwif_t *hwif)
925 if (!is_sata(hwif)) 902 if (!is_sata(hwif))
926 hwif->atapi_dma = 1; 903 hwif->atapi_dma = 1;
927 904
928 hwif->ide_dma_check = &siimage_config_drive_for_dma;
929
930 if (hwif->cbl != ATA_CBL_PATA40_SHORT) 905 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
931 hwif->cbl = ata66_siimage(hwif); 906 hwif->cbl = ata66_siimage(hwif);
932 907
@@ -935,15 +910,6 @@ static void __devinit init_hwif_siimage(ide_hwif_t *hwif)
935 } else { 910 } else {
936 hwif->ide_dma_test_irq = & siimage_io_ide_dma_test_irq; 911 hwif->ide_dma_test_irq = & siimage_io_ide_dma_test_irq;
937 } 912 }
938
939 /*
940 * The BIOS often doesn't set up DMA on this controller
941 * so we always do it.
942 */
943
944 hwif->autodma = 1;
945 hwif->drives[0].autodma = hwif->autodma;
946 hwif->drives[1].autodma = hwif->autodma;
947} 913}
948 914
949#define DECLARE_SII_DEV(name_str) \ 915#define DECLARE_SII_DEV(name_str) \
@@ -978,11 +944,11 @@ static int __devinit siimage_init_one(struct pci_dev *dev, const struct pci_devi
978 return ide_setup_pci_device(dev, &siimage_chipsets[id->driver_data]); 944 return ide_setup_pci_device(dev, &siimage_chipsets[id->driver_data]);
979} 945}
980 946
981static struct pci_device_id siimage_pci_tbl[] = { 947static const struct pci_device_id siimage_pci_tbl[] = {
982 { PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_SII_680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 948 { PCI_VDEVICE(CMD, PCI_DEVICE_ID_SII_680), 0 },
983#ifdef CONFIG_BLK_DEV_IDE_SATA 949#ifdef CONFIG_BLK_DEV_IDE_SATA
984 { PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_SII_3112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, 950 { PCI_VDEVICE(CMD, PCI_DEVICE_ID_SII_3112), 1 },
985 { PCI_VENDOR_ID_CMD, PCI_DEVICE_ID_SII_1210SA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2}, 951 { PCI_VDEVICE(CMD, PCI_DEVICE_ID_SII_1210SA), 2 },
986#endif 952#endif
987 { 0, }, 953 { 0, },
988}; 954};
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c
index b375ee53d66d..5a54e2e20b3c 100644
--- a/drivers/ide/pci/sis5513.c
+++ b/drivers/ide/pci/sis5513.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/ide/pci/sis5513.c Version 0.27 Jul 14, 2007 2 * linux/drivers/ide/pci/sis5513.c Version 0.31 Aug 9, 2007
3 * 3 *
4 * Copyright (C) 1999-2000 Andre Hedrick <andre@linux-ide.org> 4 * Copyright (C) 1999-2000 Andre Hedrick <andre@linux-ide.org>
5 * Copyright (C) 2002 Lionel Bouton <Lionel.Bouton@inet6.fr>, Maintainer 5 * Copyright (C) 2002 Lionel Bouton <Lionel.Bouton@inet6.fr>, Maintainer
@@ -65,8 +65,6 @@
65 65
66#include "ide-timing.h" 66#include "ide-timing.h"
67 67
68#define DISPLAY_SIS_TIMINGS
69
70/* registers layout and init values are chipset family dependant */ 68/* registers layout and init values are chipset family dependant */
71 69
72#define ATA_16 0x01 70#define ATA_16 0x01
@@ -193,362 +191,124 @@ static char* chipset_capability[] = {
193 "ATA 133 (1st gen)", "ATA 133 (2nd gen)" 191 "ATA 133 (1st gen)", "ATA 133 (2nd gen)"
194}; 192};
195 193
196#if defined(DISPLAY_SIS_TIMINGS) && defined(CONFIG_IDE_PROC_FS) 194/*
197#include <linux/stat.h> 195 * Configuration functions
198#include <linux/proc_fs.h> 196 */
199
200static u8 sis_proc = 0;
201
202static struct pci_dev *bmide_dev;
203
204static char* cable_type[] = {
205 "80 pins",
206 "40 pins"
207};
208 197
209static char* recovery_time[] ={ 198static u8 sis_ata133_get_base(ide_drive_t *drive)
210 "12 PCICLK", "1 PCICLK", 199{
211 "2 PCICLK", "3 PCICLK", 200 struct pci_dev *dev = drive->hwif->pci_dev;
212 "4 PCICLK", "5 PCICLCK", 201 u32 reg54 = 0;
213 "6 PCICLK", "7 PCICLCK",
214 "8 PCICLK", "9 PCICLCK",
215 "10 PCICLK", "11 PCICLK",
216 "13 PCICLK", "14 PCICLK",
217 "15 PCICLK", "15 PCICLK"
218};
219 202
220static char* active_time[] = { 203 pci_read_config_dword(dev, 0x54, &reg54);
221 "8 PCICLK", "1 PCICLCK",
222 "2 PCICLK", "3 PCICLK",
223 "4 PCICLK", "5 PCICLK",
224 "6 PCICLK", "12 PCICLK"
225};
226 204
227static char* cycle_time[] = { 205 return ((reg54 & 0x40000000) ? 0x70 : 0x40) + drive->dn * 4;
228 "Reserved", "2 CLK", 206}
229 "3 CLK", "4 CLK",
230 "5 CLK", "6 CLK",
231 "7 CLK", "8 CLK",
232 "9 CLK", "10 CLK",
233 "11 CLK", "12 CLK",
234 "13 CLK", "14 CLK",
235 "15 CLK", "16 CLK"
236};
237 207
238/* Generic add master or slave info function */ 208static void sis_ata16_program_timings(ide_drive_t *drive, const u8 mode)
239static char* get_drives_info (char *buffer, u8 pos)
240{ 209{
241 u8 reg00, reg01, reg10, reg11; /* timing registers */ 210 struct pci_dev *dev = drive->hwif->pci_dev;
242 u32 regdw0, regdw1; 211 u16 t1 = 0;
243 char* p = buffer; 212 u8 drive_pci = 0x40 + drive->dn * 2;
244
245/* Postwrite/Prefetch */
246 if (chipset_family < ATA_133) {
247 pci_read_config_byte(bmide_dev, 0x4b, &reg00);
248 p += sprintf(p, "Drive %d: Postwrite %s \t \t Postwrite %s\n",
249 pos, (reg00 & (0x10 << pos)) ? "Enabled" : "Disabled",
250 (reg00 & (0x40 << pos)) ? "Enabled" : "Disabled");
251 p += sprintf(p, " Prefetch %s \t \t Prefetch %s\n",
252 (reg00 & (0x01 << pos)) ? "Enabled" : "Disabled",
253 (reg00 & (0x04 << pos)) ? "Enabled" : "Disabled");
254 pci_read_config_byte(bmide_dev, 0x40+2*pos, &reg00);
255 pci_read_config_byte(bmide_dev, 0x41+2*pos, &reg01);
256 pci_read_config_byte(bmide_dev, 0x44+2*pos, &reg10);
257 pci_read_config_byte(bmide_dev, 0x45+2*pos, &reg11);
258 } else {
259 u32 reg54h;
260 u8 drive_pci = 0x40;
261 pci_read_config_dword(bmide_dev, 0x54, &reg54h);
262 if (reg54h & 0x40000000) {
263 // Configuration space remapped to 0x70
264 drive_pci = 0x70;
265 }
266 pci_read_config_dword(bmide_dev, (unsigned long)drive_pci+4*pos, &regdw0);
267 pci_read_config_dword(bmide_dev, (unsigned long)drive_pci+4*pos+8, &regdw1);
268 213
269 p += sprintf(p, "Drive %d:\n", pos); 214 const u16 pio_timings[] = { 0x000, 0x607, 0x404, 0x303, 0x301 };
270 } 215 const u16 mwdma_timings[] = { 0x008, 0x302, 0x301 };
271 216
217 pci_read_config_word(dev, drive_pci, &t1);
272 218
273/* UDMA */ 219 /* clear active/recovery timings */
274 if (chipset_family >= ATA_133) { 220 t1 &= ~0x070f;
275 p += sprintf(p, " UDMA %s \t \t \t UDMA %s\n", 221 if (mode >= XFER_MW_DMA_0) {
276 (regdw0 & 0x04) ? "Enabled" : "Disabled", 222 if (chipset_family > ATA_16)
277 (regdw1 & 0x04) ? "Enabled" : "Disabled"); 223 t1 &= ~0x8000; /* disable UDMA */
278 p += sprintf(p, " UDMA Cycle Time %s \t UDMA Cycle Time %s\n", 224 t1 |= mwdma_timings[mode - XFER_MW_DMA_0];
279 cycle_time[(regdw0 & 0xF0) >> 4], 225 } else
280 cycle_time[(regdw1 & 0xF0) >> 4]); 226 t1 |= pio_timings[mode - XFER_PIO_0];
281 } else if (chipset_family >= ATA_33) {
282 p += sprintf(p, " UDMA %s \t \t \t UDMA %s\n",
283 (reg01 & 0x80) ? "Enabled" : "Disabled",
284 (reg11 & 0x80) ? "Enabled" : "Disabled");
285
286 p += sprintf(p, " UDMA Cycle Time ");
287 switch(chipset_family) {
288 case ATA_33: p += sprintf(p, cycle_time[(reg01 & 0x60) >> 5]); break;
289 case ATA_66:
290 case ATA_100a: p += sprintf(p, cycle_time[(reg01 & 0x70) >> 4]); break;
291 case ATA_100:
292 case ATA_133a: p += sprintf(p, cycle_time[reg01 & 0x0F]); break;
293 default: p += sprintf(p, "?"); break;
294 }
295 p += sprintf(p, " \t UDMA Cycle Time ");
296 switch(chipset_family) {
297 case ATA_33: p += sprintf(p, cycle_time[(reg11 & 0x60) >> 5]); break;
298 case ATA_66:
299 case ATA_100a: p += sprintf(p, cycle_time[(reg11 & 0x70) >> 4]); break;
300 case ATA_100:
301 case ATA_133a: p += sprintf(p, cycle_time[reg11 & 0x0F]); break;
302 default: p += sprintf(p, "?"); break;
303 }
304 p += sprintf(p, "\n");
305 }
306 227
228 pci_write_config_word(dev, drive_pci, t1);
229}
307 230
308 if (chipset_family < ATA_133) { /* else case TODO */ 231static void sis_ata100_program_timings(ide_drive_t *drive, const u8 mode)
232{
233 struct pci_dev *dev = drive->hwif->pci_dev;
234 u8 t1, drive_pci = 0x40 + drive->dn * 2;
309 235
310/* Data Active */ 236 /* timing bits: 7:4 active 3:0 recovery */
311 p += sprintf(p, " Data Active Time "); 237 const u8 pio_timings[] = { 0x00, 0x67, 0x44, 0x33, 0x31 };
312 switch(chipset_family) { 238 const u8 mwdma_timings[] = { 0x08, 0x32, 0x31 };
313 case ATA_16: /* confirmed */
314 case ATA_33:
315 case ATA_66:
316 case ATA_100a: p += sprintf(p, active_time[reg01 & 0x07]); break;
317 case ATA_100:
318 case ATA_133a: p += sprintf(p, active_time[(reg00 & 0x70) >> 4]); break;
319 default: p += sprintf(p, "?"); break;
320 }
321 p += sprintf(p, " \t Data Active Time ");
322 switch(chipset_family) {
323 case ATA_16:
324 case ATA_33:
325 case ATA_66:
326 case ATA_100a: p += sprintf(p, active_time[reg11 & 0x07]); break;
327 case ATA_100:
328 case ATA_133a: p += sprintf(p, active_time[(reg10 & 0x70) >> 4]); break;
329 default: p += sprintf(p, "?"); break;
330 }
331 p += sprintf(p, "\n");
332 239
333/* Data Recovery */ 240 if (mode >= XFER_MW_DMA_0) {
334 /* warning: may need (reg&0x07) for pre ATA66 chips */ 241 u8 t2 = 0;
335 p += sprintf(p, " Data Recovery Time %s \t Data Recovery Time %s\n",
336 recovery_time[reg00 & 0x0f], recovery_time[reg10 & 0x0f]);
337 }
338 242
339 return p; 243 pci_read_config_byte(dev, drive_pci, &t2);
340} 244 t2 &= ~0x80; /* disable UDMA */
245 pci_write_config_byte(dev, drive_pci, t2);
341 246
342static char* get_masters_info(char* buffer) 247 t1 = mwdma_timings[mode - XFER_MW_DMA_0];
343{ 248 } else
344 return get_drives_info(buffer, 0); 249 t1 = pio_timings[mode - XFER_PIO_0];
345}
346 250
347static char* get_slaves_info(char* buffer) 251 pci_write_config_byte(dev, drive_pci + 1, t1);
348{
349 return get_drives_info(buffer, 1);
350} 252}
351 253
352/* Main get_info, called on /proc/ide/sis reads */ 254static void sis_ata133_program_timings(ide_drive_t *drive, const u8 mode)
353static int sis_get_info (char *buffer, char **addr, off_t offset, int count)
354{ 255{
355 char *p = buffer; 256 struct pci_dev *dev = drive->hwif->pci_dev;
356 int len; 257 u32 t1 = 0;
357 u8 reg; 258 u8 drive_pci = sis_ata133_get_base(drive), clk, idx;
358 u16 reg2, reg3;
359
360 p += sprintf(p, "\nSiS 5513 ");
361 switch(chipset_family) {
362 case ATA_16: p += sprintf(p, "DMA 16"); break;
363 case ATA_33: p += sprintf(p, "Ultra 33"); break;
364 case ATA_66: p += sprintf(p, "Ultra 66"); break;
365 case ATA_100a:
366 case ATA_100: p += sprintf(p, "Ultra 100"); break;
367 case ATA_133a:
368 case ATA_133: p += sprintf(p, "Ultra 133"); break;
369 default: p+= sprintf(p, "Unknown???"); break;
370 }
371 p += sprintf(p, " chipset\n");
372 p += sprintf(p, "--------------- Primary Channel "
373 "---------------- Secondary Channel "
374 "-------------\n");
375
376/* Status */
377 pci_read_config_byte(bmide_dev, 0x4a, &reg);
378 if (chipset_family == ATA_133) {
379 pci_read_config_word(bmide_dev, 0x50, &reg2);
380 pci_read_config_word(bmide_dev, 0x52, &reg3);
381 }
382 p += sprintf(p, "Channel Status: ");
383 if (chipset_family < ATA_66) {
384 p += sprintf(p, "%s \t \t \t \t %s\n",
385 (reg & 0x04) ? "On" : "Off",
386 (reg & 0x02) ? "On" : "Off");
387 } else if (chipset_family < ATA_133) {
388 p += sprintf(p, "%s \t \t \t \t %s \n",
389 (reg & 0x02) ? "On" : "Off",
390 (reg & 0x04) ? "On" : "Off");
391 } else { /* ATA_133 */
392 p += sprintf(p, "%s \t \t \t \t %s \n",
393 (reg2 & 0x02) ? "On" : "Off",
394 (reg3 & 0x02) ? "On" : "Off");
395 }
396
397/* Operation Mode */
398 pci_read_config_byte(bmide_dev, 0x09, &reg);
399 p += sprintf(p, "Operation Mode: %s \t \t \t %s \n",
400 (reg & 0x01) ? "Native" : "Compatible",
401 (reg & 0x04) ? "Native" : "Compatible");
402 259
403/* 80-pin cable ? */ 260 pci_read_config_dword(dev, drive_pci, &t1);
404 if (chipset_family >= ATA_133) {
405 p += sprintf(p, "Cable Type: %s \t \t \t %s\n",
406 (reg2 & 0x01) ? cable_type[1] : cable_type[0],
407 (reg3 & 0x01) ? cable_type[1] : cable_type[0]);
408 } else if (chipset_family > ATA_33) {
409 pci_read_config_byte(bmide_dev, 0x48, &reg);
410 p += sprintf(p, "Cable Type: %s \t \t \t %s\n",
411 (reg & 0x10) ? cable_type[1] : cable_type[0],
412 (reg & 0x20) ? cable_type[1] : cable_type[0]);
413 }
414 261
415/* Prefetch Count */ 262 t1 &= 0xc0c00fff;
416 if (chipset_family < ATA_133) { 263 clk = (t1 & 0x08) ? ATA_133 : ATA_100;
417 pci_read_config_word(bmide_dev, 0x4c, &reg2); 264 if (mode >= XFER_MW_DMA_0) {
418 pci_read_config_word(bmide_dev, 0x4e, &reg3); 265 t1 &= ~0x04; /* disable UDMA */
419 p += sprintf(p, "Prefetch Count: %d \t \t \t \t %d\n", 266 idx = mode - XFER_MW_DMA_0 + 5;
420 reg2, reg3);
421 } 267 }
268 idx = mode - XFER_PIO_0;
269 t1 |= ini_time_value[clk][idx] << 12;
270 t1 |= act_time_value[clk][idx] << 16;
271 t1 |= rco_time_value[clk][idx] << 24;
422 272
423 p = get_masters_info(p); 273 pci_write_config_dword(dev, drive_pci, t1);
424 p = get_slaves_info(p); 274}
425
426 len = (p - buffer) - offset;
427 *addr = buffer + offset;
428 275
429 return len > count ? count : len; 276static void sis_program_timings(ide_drive_t *drive, const u8 mode)
277{
278 if (chipset_family < ATA_100) /* ATA_16/33/66/100a */
279 sis_ata16_program_timings(drive, mode);
280 else if (chipset_family < ATA_133) /* ATA_100/133a */
281 sis_ata100_program_timings(drive, mode);
282 else /* ATA_133 */
283 sis_ata133_program_timings(drive, mode);
430} 284}
431#endif /* defined(DISPLAY_SIS_TIMINGS) && defined(CONFIG_IDE_PROC_FS) */
432 285
433/*
434 * Configuration functions
435 */
436/* Enables per-drive prefetch and postwrite */
437static void config_drive_art_rwp (ide_drive_t *drive) 286static void config_drive_art_rwp (ide_drive_t *drive)
438{ 287{
439 ide_hwif_t *hwif = HWIF(drive); 288 ide_hwif_t *hwif = HWIF(drive);
440 struct pci_dev *dev = hwif->pci_dev; 289 struct pci_dev *dev = hwif->pci_dev;
441
442 u8 reg4bh = 0; 290 u8 reg4bh = 0;
443 u8 rw_prefetch = (0x11 << drive->dn); 291 u8 rw_prefetch = 0;
444 292
445 if (drive->media != ide_disk)
446 return;
447 pci_read_config_byte(dev, 0x4b, &reg4bh); 293 pci_read_config_byte(dev, 0x4b, &reg4bh);
448 294
449 if ((reg4bh & rw_prefetch) != rw_prefetch) 295 if (drive->media == ide_disk)
296 rw_prefetch = 0x11 << drive->dn;
297
298 if ((reg4bh & (0x11 << drive->dn)) != rw_prefetch)
450 pci_write_config_byte(dev, 0x4b, reg4bh|rw_prefetch); 299 pci_write_config_byte(dev, 0x4b, reg4bh|rw_prefetch);
451} 300}
452 301
453/* Set per-drive active and recovery time */
454static void sis_set_pio_mode(ide_drive_t *drive, const u8 pio) 302static void sis_set_pio_mode(ide_drive_t *drive, const u8 pio)
455{ 303{
456 ide_hwif_t *hwif = HWIF(drive);
457 struct pci_dev *dev = hwif->pci_dev;
458
459 u8 drive_pci, test1, test2;
460
461 config_drive_art_rwp(drive); 304 config_drive_art_rwp(drive);
462 305 sis_program_timings(drive, XFER_PIO_0 + pio);
463 /* In pre ATA_133 case, drives sit at 0x40 + 4*drive->dn */
464 drive_pci = 0x40;
465 /* In SiS962 case drives sit at (0x40 or 0x70) + 8*drive->dn) */
466 if (chipset_family >= ATA_133) {
467 u32 reg54h;
468 pci_read_config_dword(dev, 0x54, &reg54h);
469 if (reg54h & 0x40000000) drive_pci = 0x70;
470 drive_pci += ((drive->dn)*0x4);
471 } else {
472 drive_pci += ((drive->dn)*0x2);
473 }
474
475 /* register layout changed with newer ATA100 chips */
476 if (chipset_family < ATA_100) {
477 pci_read_config_byte(dev, drive_pci, &test1);
478 pci_read_config_byte(dev, drive_pci+1, &test2);
479
480 /* Clear active and recovery timings */
481 test1 &= ~0x0F;
482 test2 &= ~0x07;
483
484 switch(pio) {
485 case 4: test1 |= 0x01; test2 |= 0x03; break;
486 case 3: test1 |= 0x03; test2 |= 0x03; break;
487 case 2: test1 |= 0x04; test2 |= 0x04; break;
488 case 1: test1 |= 0x07; test2 |= 0x06; break;
489 case 0: /* PIO0: register setting == X000 */
490 default: break;
491 }
492 pci_write_config_byte(dev, drive_pci, test1);
493 pci_write_config_byte(dev, drive_pci+1, test2);
494 } else if (chipset_family < ATA_133) {
495 switch(pio) { /* active recovery
496 v v */
497 case 4: test1 = 0x30|0x01; break;
498 case 3: test1 = 0x30|0x03; break;
499 case 2: test1 = 0x40|0x04; break;
500 case 1: test1 = 0x60|0x07; break;
501 case 0: test1 = 0x00; break;
502 default: break;
503 }
504 pci_write_config_byte(dev, drive_pci, test1);
505 } else { /* ATA_133 */
506 u32 test3;
507 pci_read_config_dword(dev, drive_pci, &test3);
508 test3 &= 0xc0c00fff;
509 if (test3 & 0x08) {
510 test3 |= ini_time_value[ATA_133][pio] << 12;
511 test3 |= act_time_value[ATA_133][pio] << 16;
512 test3 |= rco_time_value[ATA_133][pio] << 24;
513 } else {
514 test3 |= ini_time_value[ATA_100][pio] << 12;
515 test3 |= act_time_value[ATA_100][pio] << 16;
516 test3 |= rco_time_value[ATA_100][pio] << 24;
517 }
518 pci_write_config_dword(dev, drive_pci, test3);
519 }
520} 306}
521 307
522static void sis_set_dma_mode(ide_drive_t *drive, const u8 speed) 308static void sis_set_dma_mode(ide_drive_t *drive, const u8 speed)
523{ 309{
524 ide_hwif_t *hwif = HWIF(drive); 310 ide_hwif_t *hwif = HWIF(drive);
525 struct pci_dev *dev = hwif->pci_dev; 311 struct pci_dev *dev = hwif->pci_dev;
526 u32 regdw;
527 u8 drive_pci, reg;
528
529 /* See sis_set_pio_mode() for drive PCI config registers */
530 drive_pci = 0x40;
531 if (chipset_family >= ATA_133) {
532 u32 reg54h;
533 pci_read_config_dword(dev, 0x54, &reg54h);
534 if (reg54h & 0x40000000) drive_pci = 0x70;
535 drive_pci += ((drive->dn)*0x4);
536 pci_read_config_dword(dev, (unsigned long)drive_pci, &regdw);
537 /* Disable UDMA bit for non UDMA modes on UDMA chips */
538 if (speed < XFER_UDMA_0) {
539 regdw &= 0xfffffffb;
540 pci_write_config_dword(dev, (unsigned long)drive_pci, regdw);
541 }
542
543 } else {
544 drive_pci += ((drive->dn)*0x2);
545 pci_read_config_byte(dev, drive_pci+1, &reg);
546 /* Disable UDMA bit for non UDMA modes on UDMA chips */
547 if ((speed < XFER_UDMA_0) && (chipset_family > ATA_16)) {
548 reg &= 0x7F;
549 pci_write_config_byte(dev, drive_pci+1, reg);
550 }
551 }
552 312
553 /* Config chip for mode */ 313 /* Config chip for mode */
554 switch(speed) { 314 switch(speed) {
@@ -560,6 +320,10 @@ static void sis_set_dma_mode(ide_drive_t *drive, const u8 speed)
560 case XFER_UDMA_1: 320 case XFER_UDMA_1:
561 case XFER_UDMA_0: 321 case XFER_UDMA_0:
562 if (chipset_family >= ATA_133) { 322 if (chipset_family >= ATA_133) {
323 u32 regdw = 0;
324 u8 drive_pci = sis_ata133_get_base(drive);
325
326 pci_read_config_dword(dev, drive_pci, &regdw);
563 regdw |= 0x04; 327 regdw |= 0x04;
564 regdw &= 0xfffff00f; 328 regdw &= 0xfffff00f;
565 /* check if ATA133 enable */ 329 /* check if ATA133 enable */
@@ -572,6 +336,9 @@ static void sis_set_dma_mode(ide_drive_t *drive, const u8 speed)
572 } 336 }
573 pci_write_config_dword(dev, (unsigned long)drive_pci, regdw); 337 pci_write_config_dword(dev, (unsigned long)drive_pci, regdw);
574 } else { 338 } else {
339 u8 drive_pci = 0x40 + drive->dn * 2, reg = 0;
340
341 pci_read_config_byte(dev, drive_pci+1, &reg);
575 /* Force the UDMA bit on if we want to use UDMA */ 342 /* Force the UDMA bit on if we want to use UDMA */
576 reg |= 0x80; 343 reg |= 0x80;
577 /* clean reg cycle time bits */ 344 /* clean reg cycle time bits */
@@ -586,9 +353,7 @@ static void sis_set_dma_mode(ide_drive_t *drive, const u8 speed)
586 case XFER_MW_DMA_2: 353 case XFER_MW_DMA_2:
587 case XFER_MW_DMA_1: 354 case XFER_MW_DMA_1:
588 case XFER_MW_DMA_0: 355 case XFER_MW_DMA_0:
589 case XFER_SW_DMA_2: 356 sis_program_timings(drive, speed);
590 case XFER_SW_DMA_1:
591 case XFER_SW_DMA_0:
592 break; 357 break;
593 default: 358 default:
594 BUG(); 359 BUG();
@@ -596,32 +361,12 @@ static void sis_set_dma_mode(ide_drive_t *drive, const u8 speed)
596 } 361 }
597} 362}
598 363
599static int sis5513_config_xfer_rate(ide_drive_t *drive)
600{
601 /*
602 * TODO: always set PIO mode and remove this
603 */
604 ide_set_max_pio(drive);
605
606 drive->init_speed = 0;
607
608 if (ide_tune_dma(drive))
609 return 0;
610
611 if (ide_use_fast_pio(drive))
612 ide_set_max_pio(drive);
613
614 return -1;
615}
616
617static u8 sis5513_ata133_udma_filter(ide_drive_t *drive) 364static u8 sis5513_ata133_udma_filter(ide_drive_t *drive)
618{ 365{
619 struct pci_dev *dev = drive->hwif->pci_dev; 366 struct pci_dev *dev = drive->hwif->pci_dev;
620 int drive_pci; 367 u32 regdw = 0;
621 u32 reg54 = 0, regdw = 0; 368 u8 drive_pci = sis_ata133_get_base(drive);
622 369
623 pci_read_config_dword(dev, 0x54, &reg54);
624 drive_pci = ((reg54 & 0x40000000) ? 0x70 : 0x40) + drive->dn * 4;
625 pci_read_config_dword(dev, drive_pci, &regdw); 370 pci_read_config_dword(dev, drive_pci, &regdw);
626 371
627 /* if ATA133 disable, we should not set speed above UDMA5 */ 372 /* if ATA133 disable, we should not set speed above UDMA5 */
@@ -767,14 +512,6 @@ static unsigned int __devinit init_chipset_sis5513 (struct pci_dev *dev, const c
767 } 512 }
768 break; 513 break;
769 } 514 }
770
771#if defined(DISPLAY_SIS_TIMINGS) && defined(CONFIG_IDE_PROC_FS)
772 if (!sis_proc) {
773 sis_proc = 1;
774 bmide_dev = dev;
775 ide_pci_create_host_proc("sis", sis_get_info);
776 }
777#endif
778 } 515 }
779 516
780 return 0; 517 return 0;
@@ -827,8 +564,6 @@ static void __devinit init_hwif_sis5513 (ide_hwif_t *hwif)
827{ 564{
828 u8 udma_rates[] = { 0x00, 0x00, 0x07, 0x1f, 0x3f, 0x3f, 0x7f, 0x7f }; 565 u8 udma_rates[] = { 0x00, 0x00, 0x07, 0x1f, 0x3f, 0x3f, 0x7f, 0x7f };
829 566
830 hwif->autodma = 0;
831
832 if (!hwif->irq) 567 if (!hwif->irq)
833 hwif->irq = hwif->channel ? 15 : 14; 568 hwif->irq = hwif->channel ? 15 : 14;
834 569
@@ -838,32 +573,19 @@ static void __devinit init_hwif_sis5513 (ide_hwif_t *hwif)
838 if (chipset_family >= ATA_133) 573 if (chipset_family >= ATA_133)
839 hwif->udma_filter = sis5513_ata133_udma_filter; 574 hwif->udma_filter = sis5513_ata133_udma_filter;
840 575
841 if (!(hwif->dma_base)) { 576 hwif->drives[0].autotune = 1;
842 hwif->drives[0].autotune = 1; 577 hwif->drives[1].autotune = 1;
843 hwif->drives[1].autotune = 1; 578
579 if (hwif->dma_base == 0)
844 return; 580 return;
845 }
846 581
847 hwif->atapi_dma = 1; 582 hwif->atapi_dma = 1;
848 583
849 hwif->ultra_mask = udma_rates[chipset_family]; 584 hwif->ultra_mask = udma_rates[chipset_family];
850 hwif->mwdma_mask = 0x07; 585 hwif->mwdma_mask = 0x07;
851 hwif->swdma_mask = 0x07;
852
853 if (!chipset_family)
854 return;
855 586
856 if (hwif->cbl != ATA_CBL_PATA40_SHORT) 587 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
857 hwif->cbl = ata66_sis5513(hwif); 588 hwif->cbl = ata66_sis5513(hwif);
858
859 if (chipset_family > ATA_16) {
860 hwif->ide_dma_check = &sis5513_config_xfer_rate;
861 if (!noautodma)
862 hwif->autodma = 1;
863 }
864 hwif->drives[0].autodma = hwif->autodma;
865 hwif->drives[1].autodma = hwif->autodma;
866 return;
867} 589}
868 590
869static ide_pci_device_t sis5513_chipset __devinitdata = { 591static ide_pci_device_t sis5513_chipset __devinitdata = {
@@ -881,10 +603,10 @@ static int __devinit sis5513_init_one(struct pci_dev *dev, const struct pci_devi
881 return ide_setup_pci_device(dev, &sis5513_chipset); 603 return ide_setup_pci_device(dev, &sis5513_chipset);
882} 604}
883 605
884static struct pci_device_id sis5513_pci_tbl[] = { 606static const struct pci_device_id sis5513_pci_tbl[] = {
885 { PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_5513, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 607 { PCI_VDEVICE(SI, PCI_DEVICE_ID_SI_5513), 0 },
886 { PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_5518, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 608 { PCI_VDEVICE(SI, PCI_DEVICE_ID_SI_5518), 0 },
887 { PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_1180, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 609 { PCI_VDEVICE(SI, PCI_DEVICE_ID_SI_1180), 0 },
888 { 0, }, 610 { 0, },
889}; 611};
890MODULE_DEVICE_TABLE(pci, sis5513_pci_tbl); 612MODULE_DEVICE_TABLE(pci, sis5513_pci_tbl);
diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c
index 2ef26e3f7be4..771efb8884c8 100644
--- a/drivers/ide/pci/sl82c105.c
+++ b/drivers/ide/pci/sl82c105.c
@@ -145,19 +145,6 @@ static void sl82c105_set_dma_mode(ide_drive_t *drive, const u8 speed)
145} 145}
146 146
147/* 147/*
148 * Check to see if the drive and chipset are capable of DMA mode.
149 */
150static int sl82c105_ide_dma_check(ide_drive_t *drive)
151{
152 DBG(("sl82c105_ide_dma_check(drive:%s)\n", drive->name));
153
154 if (ide_tune_dma(drive))
155 return 0;
156
157 return -1;
158}
159
160/*
161 * The SL82C105 holds off all IDE interrupts while in DMA mode until 148 * The SL82C105 holds off all IDE interrupts while in DMA mode until
162 * all DMA activity is completed. Sometimes this causes problems (eg, 149 * all DMA activity is completed. Sometimes this causes problems (eg,
163 * when the drive wants to report an error condition). 150 * when the drive wants to report an error condition).
@@ -404,17 +391,12 @@ static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif)
404 hwif->atapi_dma = 1; 391 hwif->atapi_dma = 1;
405 hwif->mwdma_mask = 0x07; 392 hwif->mwdma_mask = 0x07;
406 393
407 hwif->ide_dma_check = &sl82c105_ide_dma_check;
408 hwif->ide_dma_on = &sl82c105_ide_dma_on; 394 hwif->ide_dma_on = &sl82c105_ide_dma_on;
409 hwif->dma_off_quietly = &sl82c105_dma_off_quietly; 395 hwif->dma_off_quietly = &sl82c105_dma_off_quietly;
410 hwif->dma_lost_irq = &sl82c105_dma_lost_irq; 396 hwif->dma_lost_irq = &sl82c105_dma_lost_irq;
411 hwif->dma_start = &sl82c105_dma_start; 397 hwif->dma_start = &sl82c105_dma_start;
412 hwif->dma_timeout = &sl82c105_dma_timeout; 398 hwif->dma_timeout = &sl82c105_dma_timeout;
413 399
414 if (!noautodma)
415 hwif->autodma = 1;
416 hwif->drives[0].autodma = hwif->drives[1].autodma = hwif->autodma;
417
418 if (hwif->mate) 400 if (hwif->mate)
419 hwif->serialized = hwif->mate->serialized = 1; 401 hwif->serialized = hwif->mate->serialized = 1;
420} 402}
@@ -434,8 +416,8 @@ static int __devinit sl82c105_init_one(struct pci_dev *dev, const struct pci_dev
434 return ide_setup_pci_device(dev, &sl82c105_chipset); 416 return ide_setup_pci_device(dev, &sl82c105_chipset);
435} 417}
436 418
437static struct pci_device_id sl82c105_pci_tbl[] = { 419static const struct pci_device_id sl82c105_pci_tbl[] = {
438 { PCI_DEVICE(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105), 0}, 420 { PCI_VDEVICE(WINBOND, PCI_DEVICE_ID_WINBOND_82C105), 0 },
439 { 0, }, 421 { 0, },
440}; 422};
441MODULE_DEVICE_TABLE(pci, sl82c105_pci_tbl); 423MODULE_DEVICE_TABLE(pci, sl82c105_pci_tbl);
diff --git a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c
index ebac87f7200a..fa8df6d43832 100644
--- a/drivers/ide/pci/slc90e66.c
+++ b/drivers/ide/pci/slc90e66.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/ide/pci/slc90e66.c Version 0.16 Jul 14, 2007 2 * linux/drivers/ide/pci/slc90e66.c Version 0.18 Aug 9, 2007
3 * 3 *
4 * Copyright (C) 2000-2002 Andre Hedrick <andre@linux-ide.org> 4 * Copyright (C) 2000-2002 Andre Hedrick <andre@linux-ide.org>
5 * Copyright (C) 2006-2007 MontaVista Software, Inc. <source@mvista.com> 5 * Copyright (C) 2006-2007 MontaVista Software, Inc. <source@mvista.com>
@@ -21,27 +21,6 @@
21 21
22#include <asm/io.h> 22#include <asm/io.h>
23 23
24static u8 slc90e66_dma_2_pio (u8 xfer_rate) {
25 switch(xfer_rate) {
26 case XFER_UDMA_4:
27 case XFER_UDMA_3:
28 case XFER_UDMA_2:
29 case XFER_UDMA_1:
30 case XFER_UDMA_0:
31 case XFER_MW_DMA_2:
32 return 4;
33 case XFER_MW_DMA_1:
34 return 3;
35 case XFER_SW_DMA_2:
36 return 2;
37 case XFER_MW_DMA_0:
38 case XFER_SW_DMA_1:
39 case XFER_SW_DMA_0:
40 default:
41 return 0;
42 }
43}
44
45static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) 24static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio)
46{ 25{
47 ide_hwif_t *hwif = HWIF(drive); 26 ide_hwif_t *hwif = HWIF(drive);
@@ -132,26 +111,21 @@ static void slc90e66_set_dma_mode(ide_drive_t *drive, const u8 speed)
132 pci_write_config_word(dev, 0x4a, reg4a|u_speed); 111 pci_write_config_word(dev, 0x4a, reg4a|u_speed);
133 } 112 }
134 } else { 113 } else {
114 const u8 mwdma_to_pio[] = { 0, 3, 4 };
115 u8 pio;
116
135 if (reg48 & u_flag) 117 if (reg48 & u_flag)
136 pci_write_config_word(dev, 0x48, reg48 & ~u_flag); 118 pci_write_config_word(dev, 0x48, reg48 & ~u_flag);
137 if (reg4a & a_speed) 119 if (reg4a & a_speed)
138 pci_write_config_word(dev, 0x4a, reg4a & ~a_speed); 120 pci_write_config_word(dev, 0x4a, reg4a & ~a_speed);
139 }
140
141 slc90e66_set_pio_mode(drive, slc90e66_dma_2_pio(speed));
142}
143 121
144static int slc90e66_config_drive_xfer_rate (ide_drive_t *drive) 122 if (speed >= XFER_MW_DMA_0)
145{ 123 pio = mwdma_to_pio[speed - XFER_MW_DMA_0];
146 drive->init_speed = 0; 124 else
147 125 pio = 2; /* only SWDMA2 is allowed */
148 if (ide_tune_dma(drive))
149 return 0;
150
151 if (ide_use_fast_pio(drive))
152 ide_set_max_pio(drive);
153 126
154 return -1; 127 slc90e66_set_pio_mode(drive, pio);
128 }
155} 129}
156 130
157static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif) 131static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif)
@@ -159,8 +133,6 @@ static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif)
159 u8 reg47 = 0; 133 u8 reg47 = 0;
160 u8 mask = hwif->channel ? 0x01 : 0x02; /* bit0:Primary */ 134 u8 mask = hwif->channel ? 0x01 : 0x02; /* bit0:Primary */
161 135
162 hwif->autodma = 0;
163
164 if (!hwif->irq) 136 if (!hwif->irq)
165 hwif->irq = hwif->channel ? 15 : 14; 137 hwif->irq = hwif->channel ? 15 : 14;
166 138
@@ -169,11 +141,11 @@ static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif)
169 141
170 pci_read_config_byte(hwif->pci_dev, 0x47, &reg47); 142 pci_read_config_byte(hwif->pci_dev, 0x47, &reg47);
171 143
172 if (!hwif->dma_base) { 144 hwif->drives[0].autotune = 1;
173 hwif->drives[0].autotune = 1; 145 hwif->drives[1].autotune = 1;
174 hwif->drives[1].autotune = 1; 146
147 if (hwif->dma_base == 0)
175 return; 148 return;
176 }
177 149
178 hwif->atapi_dma = 1; 150 hwif->atapi_dma = 1;
179 hwif->ultra_mask = 0x1f; 151 hwif->ultra_mask = 0x1f;
@@ -183,13 +155,6 @@ static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif)
183 if (hwif->cbl != ATA_CBL_PATA40_SHORT) 155 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
184 /* bit[0(1)]: 0:80, 1:40 */ 156 /* bit[0(1)]: 0:80, 1:40 */
185 hwif->cbl = (reg47 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; 157 hwif->cbl = (reg47 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
186
187 hwif->ide_dma_check = &slc90e66_config_drive_xfer_rate;
188
189 if (!noautodma)
190 hwif->autodma = 1;
191 hwif->drives[0].autodma = hwif->autodma;
192 hwif->drives[1].autodma = hwif->autodma;
193} 158}
194 159
195static ide_pci_device_t slc90e66_chipset __devinitdata = { 160static ide_pci_device_t slc90e66_chipset __devinitdata = {
@@ -206,8 +171,8 @@ static int __devinit slc90e66_init_one(struct pci_dev *dev, const struct pci_dev
206 return ide_setup_pci_device(dev, &slc90e66_chipset); 171 return ide_setup_pci_device(dev, &slc90e66_chipset);
207} 172}
208 173
209static struct pci_device_id slc90e66_pci_tbl[] = { 174static const struct pci_device_id slc90e66_pci_tbl[] = {
210 { PCI_DEVICE(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_1), 0}, 175 { PCI_VDEVICE(EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_1), 0 },
211 { 0, }, 176 { 0, },
212}; 177};
213MODULE_DEVICE_TABLE(pci, slc90e66_pci_tbl); 178MODULE_DEVICE_TABLE(pci, slc90e66_pci_tbl);
diff --git a/drivers/ide/pci/tc86c001.c b/drivers/ide/pci/tc86c001.c
index 840415d68d38..de62db576adc 100644
--- a/drivers/ide/pci/tc86c001.c
+++ b/drivers/ide/pci/tc86c001.c
@@ -162,17 +162,6 @@ static int tc86c001_busproc(ide_drive_t *drive, int state)
162 return 0; 162 return 0;
163} 163}
164 164
165static int tc86c001_config_drive_xfer_rate(ide_drive_t *drive)
166{
167 if (ide_tune_dma(drive))
168 return 0;
169
170 if (ide_use_fast_pio(drive))
171 ide_set_max_pio(drive);
172
173 return -1;
174}
175
176static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif) 165static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif)
177{ 166{
178 unsigned long sc_base = pci_resource_start(hwif->pci_dev, 5); 167 unsigned long sc_base = pci_resource_start(hwif->pci_dev, 5);
@@ -213,7 +202,6 @@ static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif)
213 hwif->ultra_mask = 0x1f; 202 hwif->ultra_mask = 0x1f;
214 hwif->mwdma_mask = 0x07; 203 hwif->mwdma_mask = 0x07;
215 204
216 hwif->ide_dma_check = &tc86c001_config_drive_xfer_rate;
217 hwif->dma_start = &tc86c001_dma_start; 205 hwif->dma_start = &tc86c001_dma_start;
218 206
219 if (hwif->cbl != ATA_CBL_PATA40_SHORT) { 207 if (hwif->cbl != ATA_CBL_PATA40_SHORT) {
@@ -224,10 +212,6 @@ static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif)
224 scr1 = hwif->INW(sc_base + 0x00); 212 scr1 = hwif->INW(sc_base + 0x00);
225 hwif->cbl = (scr1 & 0x2000) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; 213 hwif->cbl = (scr1 & 0x2000) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
226 } 214 }
227
228 if (!noautodma)
229 hwif->autodma = 1;
230 hwif->drives[0].autodma = hwif->drives[1].autodma = hwif->autodma;
231} 215}
232 216
233static unsigned int __devinit init_chipset_tc86c001(struct pci_dev *dev, 217static unsigned int __devinit init_chipset_tc86c001(struct pci_dev *dev,
@@ -256,9 +240,8 @@ static int __devinit tc86c001_init_one(struct pci_dev *dev,
256 return ide_setup_pci_device(dev, &tc86c001_chipset); 240 return ide_setup_pci_device(dev, &tc86c001_chipset);
257} 241}
258 242
259static struct pci_device_id tc86c001_pci_tbl[] = { 243static const struct pci_device_id tc86c001_pci_tbl[] = {
260 { PCI_VENDOR_ID_TOSHIBA_2, PCI_DEVICE_ID_TOSHIBA_TC86C001_IDE, 244 { PCI_VDEVICE(TOSHIBA_2, PCI_DEVICE_ID_TOSHIBA_TC86C001_IDE), 0 },
261 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
262 { 0, } 245 { 0, }
263}; 246};
264MODULE_DEVICE_TABLE(pci, tc86c001_pci_tbl); 247MODULE_DEVICE_TABLE(pci, tc86c001_pci_tbl);
diff --git a/drivers/ide/pci/triflex.c b/drivers/ide/pci/triflex.c
index 54e411d4e56c..4075c907f05c 100644
--- a/drivers/ide/pci/triflex.c
+++ b/drivers/ide/pci/triflex.c
@@ -96,16 +96,6 @@ static void triflex_set_pio_mode(ide_drive_t *drive, const u8 pio)
96 triflex_set_mode(drive, XFER_PIO_0 + pio); 96 triflex_set_mode(drive, XFER_PIO_0 + pio);
97} 97}
98 98
99static int triflex_config_drive_xfer_rate(ide_drive_t *drive)
100{
101 if (ide_tune_dma(drive))
102 return 0;
103
104 ide_set_max_pio(drive);
105
106 return -1;
107}
108
109static void __devinit init_hwif_triflex(ide_hwif_t *hwif) 99static void __devinit init_hwif_triflex(ide_hwif_t *hwif)
110{ 100{
111 hwif->set_pio_mode = &triflex_set_pio_mode; 101 hwif->set_pio_mode = &triflex_set_pio_mode;
@@ -117,12 +107,6 @@ static void __devinit init_hwif_triflex(ide_hwif_t *hwif)
117 hwif->atapi_dma = 1; 107 hwif->atapi_dma = 1;
118 hwif->mwdma_mask = 0x07; 108 hwif->mwdma_mask = 0x07;
119 hwif->swdma_mask = 0x07; 109 hwif->swdma_mask = 0x07;
120 hwif->ide_dma_check = &triflex_config_drive_xfer_rate;
121
122 if (!noautodma)
123 hwif->autodma = 1;
124 hwif->drives[0].autodma = hwif->autodma;
125 hwif->drives[1].autodma = hwif->autodma;
126} 110}
127 111
128static ide_pci_device_t triflex_device __devinitdata = { 112static ide_pci_device_t triflex_device __devinitdata = {
@@ -140,9 +124,8 @@ static int __devinit triflex_init_one(struct pci_dev *dev,
140 return ide_setup_pci_device(dev, &triflex_device); 124 return ide_setup_pci_device(dev, &triflex_device);
141} 125}
142 126
143static struct pci_device_id triflex_pci_tbl[] = { 127static const struct pci_device_id triflex_pci_tbl[] = {
144 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_TRIFLEX_IDE, 128 { PCI_VDEVICE(COMPAQ, PCI_DEVICE_ID_COMPAQ_TRIFLEX_IDE), 0 },
145 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
146 { 0, }, 129 { 0, },
147}; 130};
148MODULE_DEVICE_TABLE(pci, triflex_pci_tbl); 131MODULE_DEVICE_TABLE(pci, triflex_pci_tbl);
diff --git a/drivers/ide/pci/trm290.c b/drivers/ide/pci/trm290.c
index dc4f4e298e00..e3d943ada7b0 100644
--- a/drivers/ide/pci/trm290.c
+++ b/drivers/ide/pci/trm290.c
@@ -292,9 +292,6 @@ static void __devinit init_hwif_trm290(ide_hwif_t *hwif)
292 hwif->ide_dma_test_irq = &trm290_ide_dma_test_irq; 292 hwif->ide_dma_test_irq = &trm290_ide_dma_test_irq;
293 293
294 hwif->selectproc = &trm290_selectproc; 294 hwif->selectproc = &trm290_selectproc;
295 hwif->autodma = 0; /* play it safe for now */
296 hwif->drives[0].autodma = hwif->autodma;
297 hwif->drives[1].autodma = hwif->autodma;
298#if 1 295#if 1
299 { 296 {
300 /* 297 /*
@@ -329,6 +326,9 @@ static ide_pci_device_t trm290_chipset __devinitdata = {
329 .init_hwif = init_hwif_trm290, 326 .init_hwif = init_hwif_trm290,
330 .autodma = NOAUTODMA, 327 .autodma = NOAUTODMA,
331 .bootable = ON_BOARD, 328 .bootable = ON_BOARD,
329#if 0 /* play it safe for now */
330 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
331#endif
332}; 332};
333 333
334static int __devinit trm290_init_one(struct pci_dev *dev, const struct pci_device_id *id) 334static int __devinit trm290_init_one(struct pci_dev *dev, const struct pci_device_id *id)
@@ -336,8 +336,8 @@ static int __devinit trm290_init_one(struct pci_dev *dev, const struct pci_devic
336 return ide_setup_pci_device(dev, &trm290_chipset); 336 return ide_setup_pci_device(dev, &trm290_chipset);
337} 337}
338 338
339static struct pci_device_id trm290_pci_tbl[] = { 339static const struct pci_device_id trm290_pci_tbl[] = {
340 { PCI_VENDOR_ID_TEKRAM, PCI_DEVICE_ID_TEKRAM_DC290, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 340 { PCI_VDEVICE(TEKRAM, PCI_DEVICE_ID_TEKRAM_DC290), 0 },
341 { 0, }, 341 { 0, },
342}; 342};
343MODULE_DEVICE_TABLE(pci, trm290_pci_tbl); 343MODULE_DEVICE_TABLE(pci, trm290_pci_tbl);
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c
index 479e49661032..b25fb65b240e 100644
--- a/drivers/ide/pci/via82cxxx.c
+++ b/drivers/ide/pci/via82cxxx.c
@@ -197,24 +197,6 @@ static void via_set_pio_mode(ide_drive_t *drive, const u8 pio)
197 via_set_drive(drive, XFER_PIO_0 + pio); 197 via_set_drive(drive, XFER_PIO_0 + pio);
198} 198}
199 199
200/**
201 * via82cxxx_ide_dma_check - set up for DMA if possible
202 * @drive: IDE drive to set up
203 *
204 * Set up the drive for the highest supported speed considering the
205 * driver, controller and cable
206 */
207
208static int via82cxxx_ide_dma_check (ide_drive_t *drive)
209{
210 if (ide_tune_dma(drive))
211 return 0;
212
213 ide_set_max_pio(drive);
214
215 return -1;
216}
217
218static struct via_isa_bridge *via_config_find(struct pci_dev **isa) 200static struct via_isa_bridge *via_config_find(struct pci_dev **isa)
219{ 201{
220 struct via_isa_bridge *via_config; 202 struct via_isa_bridge *via_config;
@@ -443,8 +425,6 @@ static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif)
443 struct via82cxxx_dev *vdev = pci_get_drvdata(hwif->pci_dev); 425 struct via82cxxx_dev *vdev = pci_get_drvdata(hwif->pci_dev);
444 int i; 426 int i;
445 427
446 hwif->autodma = 0;
447
448 hwif->set_pio_mode = &via_set_pio_mode; 428 hwif->set_pio_mode = &via_set_pio_mode;
449 hwif->set_dma_mode = &via_set_drive; 429 hwif->set_dma_mode = &via_set_drive;
450 430
@@ -458,7 +438,6 @@ static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif)
458 hwif->drives[i].io_32bit = 1; 438 hwif->drives[i].io_32bit = 1;
459 hwif->drives[i].unmask = (vdev->via_config->flags & VIA_NO_UNMASK) ? 0 : 1; 439 hwif->drives[i].unmask = (vdev->via_config->flags & VIA_NO_UNMASK) ? 0 : 1;
460 hwif->drives[i].autotune = 1; 440 hwif->drives[i].autotune = 1;
461 hwif->drives[i].dn = hwif->channel * 2 + i;
462 } 441 }
463 442
464 if (!hwif->dma_base) 443 if (!hwif->dma_base)
@@ -472,12 +451,6 @@ static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif)
472 451
473 if (hwif->cbl != ATA_CBL_PATA40_SHORT) 452 if (hwif->cbl != ATA_CBL_PATA40_SHORT)
474 hwif->cbl = via82cxxx_cable_detect(hwif); 453 hwif->cbl = via82cxxx_cable_detect(hwif);
475
476 hwif->ide_dma_check = &via82cxxx_ide_dma_check;
477 if (!noautodma)
478 hwif->autodma = 1;
479 hwif->drives[0].autodma = hwif->autodma;
480 hwif->drives[1].autodma = hwif->autodma;
481} 454}
482 455
483static ide_pci_device_t via82cxxx_chipsets[] __devinitdata = { 456static ide_pci_device_t via82cxxx_chipsets[] __devinitdata = {
@@ -522,11 +495,11 @@ static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_i
522 return ide_setup_pci_device(dev, &via82cxxx_chipsets[id->driver_data]); 495 return ide_setup_pci_device(dev, &via82cxxx_chipsets[id->driver_data]);
523} 496}
524 497
525static struct pci_device_id via_pci_tbl[] = { 498static const struct pci_device_id via_pci_tbl[] = {
526 { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C576_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 499 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C576_1), 0 },
527 { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 500 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C586_1), 0 },
528 { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_6410, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, 501 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_6410), 1 },
529 { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_SATA_EIDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, 502 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_SATA_EIDE), 1 },
530 { 0, }, 503 { 0, },
531}; 504};
532MODULE_DEVICE_TABLE(pci, via_pci_tbl); 505MODULE_DEVICE_TABLE(pci, via_pci_tbl);
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index 9e86406bf44b..1d25a3433008 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -1421,17 +1421,12 @@ static struct macio_driver pmac_ide_macio_driver =
1421 .resume = pmac_ide_macio_resume, 1421 .resume = pmac_ide_macio_resume,
1422}; 1422};
1423 1423
1424static struct pci_device_id pmac_ide_pci_match[] = { 1424static const struct pci_device_id pmac_ide_pci_match[] = {
1425 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_UNI_N_ATA, 1425 { PCI_VDEVICE(APPLE, PCI_DEVICE_ID_APPLE_UNI_N_ATA), 0 },
1426 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 1426 { PCI_VDEVICE(APPLE, PCI_DEVICE_ID_APPLE_IPID_ATA100), 0 },
1427 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_IPID_ATA100, 1427 { PCI_VDEVICE(APPLE, PCI_DEVICE_ID_APPLE_K2_ATA100), 0 },
1428 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 1428 { PCI_VDEVICE(APPLE, PCI_DEVICE_ID_APPLE_SH_ATA), 0 },
1429 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_K2_ATA100, 1429 { PCI_VDEVICE(APPLE, PCI_DEVICE_ID_APPLE_IPID2_ATA), 0 },
1430 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1431 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_SH_ATA,
1432 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1433 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_IPID2_ATA,
1434 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1435 {}, 1430 {},
1436}; 1431};
1437 1432
@@ -1579,19 +1574,6 @@ pmac_ide_destroy_dmatable (ide_drive_t *drive)
1579} 1574}
1580 1575
1581/* 1576/*
1582 * Check what is the best DMA timing setting for the drive and
1583 * call appropriate functions to apply it.
1584 */
1585static int
1586pmac_ide_dma_check(ide_drive_t *drive)
1587{
1588 if (ide_tune_dma(drive))
1589 return 0;
1590
1591 return -1;
1592}
1593
1594/*
1595 * Prepare a DMA transfer. We build the DMA table, adjust the timings for 1577 * Prepare a DMA transfer. We build the DMA table, adjust the timings for
1596 * a read on KeyLargo ATA/66 and mark us as waiting for DMA completion 1578 * a read on KeyLargo ATA/66 and mark us as waiting for DMA completion
1597 */ 1579 */
@@ -1788,7 +1770,6 @@ pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
1788 1770
1789 hwif->dma_off_quietly = &ide_dma_off_quietly; 1771 hwif->dma_off_quietly = &ide_dma_off_quietly;
1790 hwif->ide_dma_on = &__ide_dma_on; 1772 hwif->ide_dma_on = &__ide_dma_on;
1791 hwif->ide_dma_check = &pmac_ide_dma_check;
1792 hwif->dma_setup = &pmac_ide_dma_setup; 1773 hwif->dma_setup = &pmac_ide_dma_setup;
1793 hwif->dma_exec_cmd = &pmac_ide_dma_exec_cmd; 1774 hwif->dma_exec_cmd = &pmac_ide_dma_exec_cmd;
1794 hwif->dma_start = &pmac_ide_dma_start; 1775 hwif->dma_start = &pmac_ide_dma_start;
@@ -1823,9 +1804,6 @@ pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
1823 hwif->swdma_mask = 0x00; 1804 hwif->swdma_mask = 0x00;
1824 break; 1805 break;
1825 } 1806 }
1826
1827 hwif->autodma = 1;
1828 hwif->drives[1].autodma = hwif->drives[0].autodma = hwif->autodma;
1829} 1807}
1830 1808
1831#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ 1809#endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
index 1129f8c30840..3d101f73f910 100644
--- a/drivers/ide/setup-pci.c
+++ b/drivers/ide/setup-pci.c
@@ -145,27 +145,13 @@ static int ide_setup_pci_baseregs (struct pci_dev *dev, const char *name)
145} 145}
146 146
147#ifdef CONFIG_BLK_DEV_IDEDMA_PCI 147#ifdef CONFIG_BLK_DEV_IDEDMA_PCI
148
149#ifdef CONFIG_BLK_DEV_IDEDMA_FORCED
150/*
151 * Long lost data from 2.0.34 that is now in 2.0.39
152 *
153 * This was used in ./drivers/block/triton.c to do DMA Base address setup
154 * when PnP failed. Oh the things we forget. I believe this was part
155 * of SFF-8038i that has been withdrawn from public access... :-((
156 */
157#define DEFAULT_BMIBA 0xe800 /* in case BIOS did not init it */
158#define DEFAULT_BMCRBA 0xcc00 /* VIA's default value */
159#define DEFAULT_BMALIBA 0xd400 /* ALI's default value */
160#endif /* CONFIG_BLK_DEV_IDEDMA_FORCED */
161
162/** 148/**
163 * ide_get_or_set_dma_base - setup BMIBA 149 * ide_get_or_set_dma_base - setup BMIBA
164 * @hwif: Interface 150 * @hwif: Interface
165 * 151 *
166 * Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space: 152 * Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space.
167 * If need be we set up the DMA base. Where a device has a partner that 153 * Where a device has a partner that is already in DMA mode we check
168 * is already in DMA mode we check and enforce IDE simplex rules. 154 * and enforce IDE simplex rules.
169 */ 155 */
170 156
171static unsigned long ide_get_or_set_dma_base (ide_hwif_t *hwif) 157static unsigned long ide_get_or_set_dma_base (ide_hwif_t *hwif)
@@ -173,12 +159,6 @@ static unsigned long ide_get_or_set_dma_base (ide_hwif_t *hwif)
173 unsigned long dma_base = 0; 159 unsigned long dma_base = 0;
174 struct pci_dev *dev = hwif->pci_dev; 160 struct pci_dev *dev = hwif->pci_dev;
175 161
176#ifdef CONFIG_BLK_DEV_IDEDMA_FORCED
177 int second_chance = 0;
178
179second_chance_to_dma:
180#endif /* CONFIG_BLK_DEV_IDEDMA_FORCED */
181
182 if (hwif->mmio) 162 if (hwif->mmio)
183 return hwif->dma_base; 163 return hwif->dma_base;
184 164
@@ -192,26 +172,6 @@ second_chance_to_dma:
192 } 172 }
193 } 173 }
194 174
195#ifdef CONFIG_BLK_DEV_IDEDMA_FORCED
196 /* FIXME - should use pci_assign_resource surely */
197 if ((!dma_base) && (!second_chance)) {
198 unsigned long set_bmiba = 0;
199 second_chance++;
200 switch(dev->vendor) {
201 case PCI_VENDOR_ID_AL:
202 set_bmiba = DEFAULT_BMALIBA; break;
203 case PCI_VENDOR_ID_VIA:
204 set_bmiba = DEFAULT_BMCRBA; break;
205 case PCI_VENDOR_ID_INTEL:
206 set_bmiba = DEFAULT_BMIBA; break;
207 default:
208 return dma_base;
209 }
210 pci_write_config_dword(dev, 0x20, set_bmiba|1);
211 goto second_chance_to_dma;
212 }
213#endif /* CONFIG_BLK_DEV_IDEDMA_FORCED */
214
215 if (dma_base) { 175 if (dma_base) {
216 u8 simplex_stat = 0; 176 u8 simplex_stat = 0;
217 dma_base += hwif->channel ? 8 : 0; 177 dma_base += hwif->channel ? 8 : 0;
@@ -478,8 +438,6 @@ static void ide_hwif_setup_dma(struct pci_dev *dev, ide_pci_device_t *d, ide_hwi
478 * Set up BM-DMA capability 438 * Set up BM-DMA capability
479 * (PnP BIOS should have done this) 439 * (PnP BIOS should have done this)
480 */ 440 */
481 /* default DMA off if we had to configure it here */
482 hwif->autodma = 0;
483 pci_set_master(dev); 441 pci_set_master(dev);
484 if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd) || !(pcicmd & PCI_COMMAND_MASTER)) { 442 if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd) || !(pcicmd & PCI_COMMAND_MASTER)) {
485 printk(KERN_ERR "%s: %s error updating PCICMD\n", 443 printk(KERN_ERR "%s: %s error updating PCICMD\n",
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 30a1931466a6..e39ee2fa2607 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -576,7 +576,6 @@ typedef struct ide_drive_s {
576 select_t select; /* basic drive/head select reg value */ 576 select_t select; /* basic drive/head select reg value */
577 577
578 u8 keep_settings; /* restore settings after drive reset */ 578 u8 keep_settings; /* restore settings after drive reset */
579 u8 autodma; /* device can safely use dma on host */
580 u8 using_dma; /* disk is using dma for read/write */ 579 u8 using_dma; /* disk is using dma for read/write */
581 u8 retry_pio; /* retrying dma capable host in pio */ 580 u8 retry_pio; /* retrying dma capable host in pio */
582 u8 state; /* retry state */ 581 u8 state; /* retry state */
@@ -600,6 +599,7 @@ typedef struct ide_drive_s {
600 unsigned nice0 : 1; /* give obvious excess bandwidth */ 599 unsigned nice0 : 1; /* give obvious excess bandwidth */
601 unsigned nice2 : 1; /* give a share in our own bandwidth */ 600 unsigned nice2 : 1; /* give a share in our own bandwidth */
602 unsigned doorlocking : 1; /* for removable only: door lock/unlock works */ 601 unsigned doorlocking : 1; /* for removable only: door lock/unlock works */
602 unsigned nodma : 1; /* disallow DMA */
603 unsigned autotune : 2; /* 0=default, 1=autotune, 2=noautotune */ 603 unsigned autotune : 2; /* 0=default, 1=autotune, 2=noautotune */
604 unsigned remap_0_to_1 : 1; /* 0=noremap, 1=remap 0->1 (for EZDrive) */ 604 unsigned remap_0_to_1 : 1; /* 0=noremap, 1=remap 0->1 (for EZDrive) */
605 unsigned blocked : 1; /* 1=powermanagment told us not to do anything, so sleep nicely */ 605 unsigned blocked : 1; /* 1=powermanagment told us not to do anything, so sleep nicely */
@@ -736,7 +736,6 @@ typedef struct hwif_s {
736 void (*dma_exec_cmd)(ide_drive_t *, u8); 736 void (*dma_exec_cmd)(ide_drive_t *, u8);
737 void (*dma_start)(ide_drive_t *); 737 void (*dma_start)(ide_drive_t *);
738 int (*ide_dma_end)(ide_drive_t *drive); 738 int (*ide_dma_end)(ide_drive_t *drive);
739 int (*ide_dma_check)(ide_drive_t *drive);
740 int (*ide_dma_on)(ide_drive_t *drive); 739 int (*ide_dma_on)(ide_drive_t *drive);
741 void (*dma_off_quietly)(ide_drive_t *drive); 740 void (*dma_off_quietly)(ide_drive_t *drive);
742 int (*ide_dma_test_irq)(ide_drive_t *drive); 741 int (*ide_dma_test_irq)(ide_drive_t *drive);
@@ -798,7 +797,6 @@ typedef struct hwif_s {
798 unsigned serialized : 1; /* serialized all channel operation */ 797 unsigned serialized : 1; /* serialized all channel operation */
799 unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */ 798 unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */
800 unsigned reset : 1; /* reset after probe */ 799 unsigned reset : 1; /* reset after probe */
801 unsigned autodma : 1; /* auto-attempt using DMA at boot */
802 unsigned no_lba48 : 1; /* 1 = cannot do LBA48 */ 800 unsigned no_lba48 : 1; /* 1 = cannot do LBA48 */
803 unsigned no_lba48_dma : 1; /* 1 = cannot do LBA48 DMA */ 801 unsigned no_lba48_dma : 1; /* 1 = cannot do LBA48 DMA */
804 unsigned auto_poll : 1; /* supports nop auto-poll */ 802 unsigned auto_poll : 1; /* supports nop auto-poll */
@@ -1256,6 +1254,10 @@ enum {
1256 IDE_HFLAG_POST_SET_MODE = (1 << 8), 1254 IDE_HFLAG_POST_SET_MODE = (1 << 8),
1257 /* don't program host/device for the transfer mode ("smart" hosts) */ 1255 /* don't program host/device for the transfer mode ("smart" hosts) */
1258 IDE_HFLAG_NO_SET_MODE = (1 << 9), 1256 IDE_HFLAG_NO_SET_MODE = (1 << 9),
1257 /* trust BIOS for programming chipset/device for DMA */
1258 IDE_HFLAG_TRUST_BIOS_FOR_DMA = (1 << 10),
1259 /* host uses VDMA */
1260 IDE_HFLAG_VDMA = (1 << 11),
1259}; 1261};
1260 1262
1261typedef struct ide_pci_device_s { 1263typedef struct ide_pci_device_s {
@@ -1303,7 +1305,6 @@ static inline u8 ide_max_dma_mode(ide_drive_t *drive)
1303 return ide_find_dma_mode(drive, XFER_UDMA_6); 1305 return ide_find_dma_mode(drive, XFER_UDMA_6);
1304} 1306}
1305 1307
1306int ide_tune_dma(ide_drive_t *);
1307void ide_dma_off(ide_drive_t *); 1308void ide_dma_off(ide_drive_t *);
1308void ide_dma_verbose(ide_drive_t *); 1309void ide_dma_verbose(ide_drive_t *);
1309int ide_set_dma(ide_drive_t *); 1310int ide_set_dma(ide_drive_t *);
@@ -1330,7 +1331,6 @@ extern void ide_dma_timeout(ide_drive_t *);
1330#else 1331#else
1331static inline u8 ide_find_dma_mode(ide_drive_t *drive, u8 speed) { return 0; } 1332static inline u8 ide_find_dma_mode(ide_drive_t *drive, u8 speed) { return 0; }
1332static inline u8 ide_max_dma_mode(ide_drive_t *drive) { return 0; } 1333static inline u8 ide_max_dma_mode(ide_drive_t *drive) { return 0; }
1333static inline int ide_tune_dma(ide_drive_t *drive) { return 0; }
1334static inline void ide_dma_off(ide_drive_t *drive) { ; } 1334static inline void ide_dma_off(ide_drive_t *drive) { ; }
1335static inline void ide_dma_verbose(ide_drive_t *drive) { ; } 1335static inline void ide_dma_verbose(ide_drive_t *drive) { ; }
1336static inline int ide_set_dma(ide_drive_t *drive) { return 1; } 1336static inline int ide_set_dma(ide_drive_t *drive) { return 1; }
@@ -1380,7 +1380,6 @@ static inline void ide_set_hwifdata (ide_hwif_t * hwif, void *data)
1380extern char *ide_xfer_verbose(u8 xfer_rate); 1380extern char *ide_xfer_verbose(u8 xfer_rate);
1381extern void ide_toggle_bounce(ide_drive_t *drive, int on); 1381extern void ide_toggle_bounce(ide_drive_t *drive, int on);
1382extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate); 1382extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate);
1383int ide_use_fast_pio(ide_drive_t *);
1384 1383
1385static inline int ide_dev_has_iordy(struct hd_driveid *id) 1384static inline int ide_dev_has_iordy(struct hd_driveid *id)
1386{ 1385{