aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-09 18:41:31 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-09 18:41:31 -0400
commit3cb7396b7b26585b1ab7c1a8ca554ec103da5d37 (patch)
tree94720199f016045fe2a204ac8fd26c0029f4544c /drivers/ide
parentd0b6e0e380d6a32d479120a8b5d98cdff936ec8c (diff)
parent317a46a200e6514a1acf50ed30291160185a5c73 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/bart/ide-2.6: ide: fix PIO setup on resume for ATAPI devices ide: legacy PCI bus order probing fixes ide: add ide_proc_register_port() ide: add "initializing" argument to ide_register_hw() ide: cable detection fixes (take 2) ide: move IDE settings handling to ide-proc.c ide: split off ioctl handling from IDE settings (v2) ide: make /proc/ide/ optional ide: add ide_tune_dma() helper ide: rework the code for selecting the best DMA transfer mode (v3) ide: fix UDMA/MWDMA/SWDMA masks (v3)
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/Kconfig14
-rw-r--r--drivers/ide/Makefile2
-rw-r--r--drivers/ide/arm/bast-ide.c2
-rw-r--r--drivers/ide/arm/icside.c9
-rw-r--r--drivers/ide/arm/ide_arm.c2
-rw-r--r--drivers/ide/arm/rapide.c2
-rw-r--r--drivers/ide/cris/ide-cris.c4
-rw-r--r--drivers/ide/h8300/ide-h8300.c2
-rw-r--r--drivers/ide/ide-cd.c20
-rw-r--r--drivers/ide/ide-disk.c101
-rw-r--r--drivers/ide/ide-dma.c94
-rw-r--r--drivers/ide/ide-floppy.c30
-rw-r--r--drivers/ide/ide-generic.c2
-rw-r--r--drivers/ide/ide-io.c17
-rw-r--r--drivers/ide/ide-iops.c55
-rw-r--r--drivers/ide/ide-lib.c132
-rw-r--r--drivers/ide/ide-pnp.c2
-rw-r--r--drivers/ide/ide-probe.c3
-rw-r--r--drivers/ide/ide-proc.c344
-rw-r--r--drivers/ide/ide-tape.c49
-rw-r--r--drivers/ide/ide.c470
-rw-r--r--drivers/ide/legacy/ali14xx.c3
-rw-r--r--drivers/ide/legacy/buddha.c2
-rw-r--r--drivers/ide/legacy/dtc2278.c3
-rw-r--r--drivers/ide/legacy/falconide.c2
-rw-r--r--drivers/ide/legacy/gayle.c2
-rw-r--r--drivers/ide/legacy/ht6560b.c3
-rw-r--r--drivers/ide/legacy/ide-cs.c2
-rw-r--r--drivers/ide/legacy/macide.c6
-rw-r--r--drivers/ide/legacy/q40ide.c2
-rw-r--r--drivers/ide/legacy/qd65xx.c7
-rw-r--r--drivers/ide/legacy/umc8672.c3
-rw-r--r--drivers/ide/mips/au1xxx-ide.c3
-rw-r--r--drivers/ide/mips/swarm.c3
-rw-r--r--drivers/ide/pci/aec62xx.c62
-rw-r--r--drivers/ide/pci/alim15x3.c97
-rw-r--r--drivers/ide/pci/amd74xx.c6
-rw-r--r--drivers/ide/pci/atiixp.c40
-rw-r--r--drivers/ide/pci/cmd64x.c90
-rw-r--r--drivers/ide/pci/cs5520.c20
-rw-r--r--drivers/ide/pci/cs5535.c33
-rw-r--r--drivers/ide/pci/delkin_cb.c2
-rw-r--r--drivers/ide/pci/hpt34x.c27
-rw-r--r--drivers/ide/pci/hpt366.c85
-rw-r--r--drivers/ide/pci/it8213.c39
-rw-r--r--drivers/ide/pci/it821x.c20
-rw-r--r--drivers/ide/pci/jmicron.c40
-rw-r--r--drivers/ide/pci/pdc202xx_new.c40
-rw-r--r--drivers/ide/pci/pdc202xx_old.c54
-rw-r--r--drivers/ide/pci/piix.c163
-rw-r--r--drivers/ide/pci/scc_pata.c21
-rw-r--r--drivers/ide/pci/serverworks.c31
-rw-r--r--drivers/ide/pci/sgiioc4.c2
-rw-r--r--drivers/ide/pci/siimage.c45
-rw-r--r--drivers/ide/pci/sis5513.c44
-rw-r--r--drivers/ide/pci/slc90e66.c24
-rw-r--r--drivers/ide/pci/tc86c001.c20
-rw-r--r--drivers/ide/pci/triflex.c15
-rw-r--r--drivers/ide/ppc/pmac.c2
-rw-r--r--drivers/ide/setup-pci.c27
60 files changed, 1039 insertions, 1407 deletions
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 5bdf64b77913..1d06b415ede9 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -291,6 +291,17 @@ config IDE_TASK_IOCTL
291 291
292 If you are unsure, say N here. 292 If you are unsure, say N here.
293 293
294config IDE_PROC_FS
295 bool "legacy /proc/ide/ support"
296 depends on IDE && PROC_FS
297 default y
298 help
299 This option enables support for the various files in
300 /proc/ide. In Linux 2.6 this has been superseded by
301 files in sysfs but many legacy applications rely on this.
302
303 If unsure say Y.
304
294comment "IDE chipset support/bugfixes" 305comment "IDE chipset support/bugfixes"
295 306
296config IDE_GENERIC 307config IDE_GENERIC
@@ -360,6 +371,9 @@ config IDEPCI_SHARE_IRQ
360 It is safe to say Y to this question, in most cases. 371 It is safe to say Y to this question, in most cases.
361 If unsure, say N. 372 If unsure, say N.
362 373
374config IDEPCI_PCIBUS_ORDER
375 def_bool PCI && BLK_DEV_IDE=y && BLK_DEV_IDEPCI
376
363config BLK_DEV_OFFBOARD 377config BLK_DEV_OFFBOARD
364 bool "Boot off-board chipsets first support" 378 bool "Boot off-board chipsets first support"
365 depends on PCI && BLK_DEV_IDEPCI 379 depends on PCI && BLK_DEV_IDEPCI
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile
index d9f029e8ff74..75dc6969e0a7 100644
--- a/drivers/ide/Makefile
+++ b/drivers/ide/Makefile
@@ -20,7 +20,7 @@ ide-core-$(CONFIG_BLK_DEV_CMD640) += pci/cmd640.o
20# Core IDE code - must come before legacy 20# Core IDE code - must come before legacy
21ide-core-$(CONFIG_BLK_DEV_IDEPCI) += setup-pci.o 21ide-core-$(CONFIG_BLK_DEV_IDEPCI) += setup-pci.o
22ide-core-$(CONFIG_BLK_DEV_IDEDMA) += ide-dma.o 22ide-core-$(CONFIG_BLK_DEV_IDEDMA) += ide-dma.o
23ide-core-$(CONFIG_PROC_FS) += ide-proc.o 23ide-core-$(CONFIG_IDE_PROC_FS) += ide-proc.o
24ide-core-$(CONFIG_BLK_DEV_IDEPNP) += ide-pnp.o 24ide-core-$(CONFIG_BLK_DEV_IDEPNP) += ide-pnp.o
25ide-core-$(CONFIG_BLK_DEV_IDEACPI) += ide-acpi.o 25ide-core-$(CONFIG_BLK_DEV_IDEACPI) += ide-acpi.o
26 26
diff --git a/drivers/ide/arm/bast-ide.c b/drivers/ide/arm/bast-ide.c
index 9d474e5fd8dc..f7449d04114a 100644
--- a/drivers/ide/arm/bast-ide.c
+++ b/drivers/ide/arm/bast-ide.c
@@ -45,7 +45,7 @@ bastide_register(unsigned int base, unsigned int aux, int irq,
45 hw.io_ports[IDE_CONTROL_OFFSET] = aux + (6 * 0x20); 45 hw.io_ports[IDE_CONTROL_OFFSET] = aux + (6 * 0x20);
46 hw.irq = irq; 46 hw.irq = irq;
47 47
48 ide_register_hw(&hw, hwif); 48 ide_register_hw(&hw, 0, hwif);
49 49
50 return 0; 50 return 0;
51} 51}
diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c
index e2953fc1fafb..1fe0457243db 100644
--- a/drivers/ide/arm/icside.c
+++ b/drivers/ide/arm/icside.c
@@ -342,7 +342,7 @@ static int icside_dma_check(ide_drive_t *drive)
342 * Enable DMA on any drive that has multiword DMA 342 * Enable DMA on any drive that has multiword DMA
343 */ 343 */
344 if (id->field_valid & 2) { 344 if (id->field_valid & 2) {
345 xfer_mode = ide_dma_speed(drive, 0); 345 xfer_mode = ide_max_dma_mode(drive);
346 goto out; 346 goto out;
347 } 347 }
348 348
@@ -591,7 +591,8 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
591 state->hwif[0] = hwif; 591 state->hwif[0] = hwif;
592 592
593 probe_hwif_init(hwif); 593 probe_hwif_init(hwif);
594 create_proc_ide_interfaces(); 594
595 ide_proc_register_port(hwif);
595 596
596 return 0; 597 return 0;
597} 598}
@@ -679,7 +680,9 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
679 680
680 probe_hwif_init(hwif); 681 probe_hwif_init(hwif);
681 probe_hwif_init(mate); 682 probe_hwif_init(mate);
682 create_proc_ide_interfaces(); 683
684 ide_proc_register_port(hwif);
685 ide_proc_register_port(mate);
683 686
684 return 0; 687 return 0;
685 688
diff --git a/drivers/ide/arm/ide_arm.c b/drivers/ide/arm/ide_arm.c
index 23488c4d1fcd..a3d6744e870a 100644
--- a/drivers/ide/arm/ide_arm.c
+++ b/drivers/ide/arm/ide_arm.c
@@ -38,6 +38,6 @@ void __init ide_arm_init(void)
38 memset(&hw, 0, sizeof(hw)); 38 memset(&hw, 0, sizeof(hw));
39 ide_std_init_ports(&hw, IDE_ARM_IO, IDE_ARM_IO + 0x206); 39 ide_std_init_ports(&hw, IDE_ARM_IO, IDE_ARM_IO + 0x206);
40 hw.irq = IDE_ARM_IRQ; 40 hw.irq = IDE_ARM_IRQ;
41 ide_register_hw(&hw, NULL); 41 ide_register_hw(&hw, 1, NULL);
42 } 42 }
43} 43}
diff --git a/drivers/ide/arm/rapide.c b/drivers/ide/arm/rapide.c
index 9c6c49fdd2b1..890ea3fac3c6 100644
--- a/drivers/ide/arm/rapide.c
+++ b/drivers/ide/arm/rapide.c
@@ -76,7 +76,7 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
76 hwif->gendev.parent = &ec->dev; 76 hwif->gendev.parent = &ec->dev;
77 hwif->noprobe = 0; 77 hwif->noprobe = 0;
78 probe_hwif_init(hwif); 78 probe_hwif_init(hwif);
79 create_proc_ide_interfaces(); 79 ide_proc_register_port(hwif);
80 ecard_set_drvdata(ec, hwif); 80 ecard_set_drvdata(ec, hwif);
81 goto out; 81 goto out;
82 } 82 }
diff --git a/drivers/ide/cris/ide-cris.c b/drivers/ide/cris/ide-cris.c
index 5e8efc89255a..c04cb25a01ff 100644
--- a/drivers/ide/cris/ide-cris.c
+++ b/drivers/ide/cris/ide-cris.c
@@ -796,7 +796,7 @@ init_e100_ide (void)
796 ide_offsets, 796 ide_offsets,
797 0, 0, cris_ide_ack_intr, 797 0, 0, cris_ide_ack_intr,
798 ide_default_irq(0)); 798 ide_default_irq(0));
799 ide_register_hw(&hw, &hwif); 799 ide_register_hw(&hw, 1, &hwif);
800 hwif->mmio = 1; 800 hwif->mmio = 1;
801 hwif->chipset = ide_etrax100; 801 hwif->chipset = ide_etrax100;
802 hwif->tuneproc = &tune_cris_ide; 802 hwif->tuneproc = &tune_cris_ide;
@@ -1004,7 +1004,7 @@ static int cris_ide_build_dmatable (ide_drive_t *drive)
1004 1004
1005static int cris_config_drive_for_dma (ide_drive_t *drive) 1005static int cris_config_drive_for_dma (ide_drive_t *drive)
1006{ 1006{
1007 u8 speed = ide_dma_speed(drive, 1); 1007 u8 speed = ide_max_dma_mode(drive);
1008 1008
1009 if (!speed) 1009 if (!speed)
1010 return 0; 1010 return 0;
diff --git a/drivers/ide/h8300/ide-h8300.c b/drivers/ide/h8300/ide-h8300.c
index 88750a300337..6d26ad7360d5 100644
--- a/drivers/ide/h8300/ide-h8300.c
+++ b/drivers/ide/h8300/ide-h8300.c
@@ -101,7 +101,7 @@ void __init h8300_ide_init(void)
101 hw_setup(&hw); 101 hw_setup(&hw);
102 102
103 /* register if */ 103 /* register if */
104 idx = ide_register_hw(&hw, &hwif); 104 idx = ide_register_hw(&hw, 1, &hwif);
105 if (idx == -1) { 105 if (idx == -1) {
106 printk(KERN_ERR "ide-h8300: IDE I/F register failed\n"); 106 printk(KERN_ERR "ide-h8300: IDE I/F register failed\n");
107 return; 107 return;
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 638becda81c6..252ab8295edf 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -3059,10 +3059,14 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive)
3059 return nslots; 3059 return nslots;
3060} 3060}
3061 3061
3062#ifdef CONFIG_IDE_PROC_FS
3062static void ide_cdrom_add_settings(ide_drive_t *drive) 3063static void ide_cdrom_add_settings(ide_drive_t *drive)
3063{ 3064{
3064 ide_add_setting(drive, "dsc_overlap", SETTING_RW, -1, -1, TYPE_BYTE, 0, 1, 1, 1, &drive->dsc_overlap, NULL); 3065 ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->dsc_overlap, NULL);
3065} 3066}
3067#else
3068static inline void ide_cdrom_add_settings(ide_drive_t *drive) { ; }
3069#endif
3066 3070
3067/* 3071/*
3068 * standard prep_rq_fn that builds 10 byte cmds 3072 * standard prep_rq_fn that builds 10 byte cmds
@@ -3274,7 +3278,7 @@ int ide_cdrom_setup (ide_drive_t *drive)
3274 return 0; 3278 return 0;
3275} 3279}
3276 3280
3277#ifdef CONFIG_PROC_FS 3281#ifdef CONFIG_IDE_PROC_FS
3278static 3282static
3279sector_t ide_cdrom_capacity (ide_drive_t *drive) 3283sector_t ide_cdrom_capacity (ide_drive_t *drive)
3280{ 3284{
@@ -3291,7 +3295,7 @@ static void ide_cd_remove(ide_drive_t *drive)
3291{ 3295{
3292 struct cdrom_info *info = drive->driver_data; 3296 struct cdrom_info *info = drive->driver_data;
3293 3297
3294 ide_unregister_subdriver(drive, info->driver); 3298 ide_proc_unregister_driver(drive, info->driver);
3295 3299
3296 del_gendisk(info->disk); 3300 del_gendisk(info->disk);
3297 3301
@@ -3321,7 +3325,7 @@ static void ide_cd_release(struct kref *kref)
3321 3325
3322static int ide_cd_probe(ide_drive_t *); 3326static int ide_cd_probe(ide_drive_t *);
3323 3327
3324#ifdef CONFIG_PROC_FS 3328#ifdef CONFIG_IDE_PROC_FS
3325static int proc_idecd_read_capacity 3329static int proc_idecd_read_capacity
3326 (char *page, char **start, off_t off, int count, int *eof, void *data) 3330 (char *page, char **start, off_t off, int count, int *eof, void *data)
3327{ 3331{
@@ -3336,8 +3340,6 @@ static ide_proc_entry_t idecd_proc[] = {
3336 { "capacity", S_IFREG|S_IRUGO, proc_idecd_read_capacity, NULL }, 3340 { "capacity", S_IFREG|S_IRUGO, proc_idecd_read_capacity, NULL },
3337 { NULL, 0, NULL, NULL } 3341 { NULL, 0, NULL, NULL }
3338}; 3342};
3339#else
3340# define idecd_proc NULL
3341#endif 3343#endif
3342 3344
3343static ide_driver_t ide_cdrom_driver = { 3345static ide_driver_t ide_cdrom_driver = {
@@ -3355,7 +3357,9 @@ static ide_driver_t ide_cdrom_driver = {
3355 .end_request = ide_end_request, 3357 .end_request = ide_end_request,
3356 .error = __ide_error, 3358 .error = __ide_error,
3357 .abort = __ide_abort, 3359 .abort = __ide_abort,
3360#ifdef CONFIG_IDE_PROC_FS
3358 .proc = idecd_proc, 3361 .proc = idecd_proc,
3362#endif
3359}; 3363};
3360 3364
3361static int idecd_open(struct inode * inode, struct file * file) 3365static int idecd_open(struct inode * inode, struct file * file)
@@ -3517,7 +3521,7 @@ static int ide_cd_probe(ide_drive_t *drive)
3517 3521
3518 ide_init_disk(g, drive); 3522 ide_init_disk(g, drive);
3519 3523
3520 ide_register_subdriver(drive, &ide_cdrom_driver); 3524 ide_proc_register_driver(drive, &ide_cdrom_driver);
3521 3525
3522 kref_init(&info->kref); 3526 kref_init(&info->kref);
3523 3527
@@ -3534,7 +3538,7 @@ static int ide_cd_probe(ide_drive_t *drive)
3534 g->flags = GENHD_FL_CD | GENHD_FL_REMOVABLE; 3538 g->flags = GENHD_FL_CD | GENHD_FL_REMOVABLE;
3535 if (ide_cdrom_setup(drive)) { 3539 if (ide_cdrom_setup(drive)) {
3536 struct cdrom_device_info *devinfo = &info->devinfo; 3540 struct cdrom_device_info *devinfo = &info->devinfo;
3537 ide_unregister_subdriver(drive, &ide_cdrom_driver); 3541 ide_proc_unregister_driver(drive, &ide_cdrom_driver);
3538 kfree(info->buffer); 3542 kfree(info->buffer);
3539 kfree(info->toc); 3543 kfree(info->toc);
3540 kfree(info->changer_info); 3544 kfree(info->changer_info);
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 37aa6ddd9702..7fff773f2df7 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -559,8 +559,7 @@ static sector_t idedisk_capacity (ide_drive_t *drive)
559 return drive->capacity64 - drive->sect0; 559 return drive->capacity64 - drive->sect0;
560} 560}
561 561
562#ifdef CONFIG_PROC_FS 562#ifdef CONFIG_IDE_PROC_FS
563
564static int smart_enable(ide_drive_t *drive) 563static int smart_enable(ide_drive_t *drive)
565{ 564{
566 ide_task_t args; 565 ide_task_t args;
@@ -678,12 +677,7 @@ static ide_proc_entry_t idedisk_proc[] = {
678 { "smart_thresholds", S_IFREG|S_IRUSR, proc_idedisk_read_smart_thresholds, NULL }, 677 { "smart_thresholds", S_IFREG|S_IRUSR, proc_idedisk_read_smart_thresholds, NULL },
679 { NULL, 0, NULL, NULL } 678 { NULL, 0, NULL, NULL }
680}; 679};
681 680#endif /* CONFIG_IDE_PROC_FS */
682#else
683
684#define idedisk_proc NULL
685
686#endif /* CONFIG_PROC_FS */
687 681
688static void idedisk_prepare_flush(request_queue_t *q, struct request *rq) 682static void idedisk_prepare_flush(request_queue_t *q, struct request *rq)
689{ 683{
@@ -737,6 +731,9 @@ static int set_multcount(ide_drive_t *drive, int arg)
737{ 731{
738 struct request rq; 732 struct request rq;
739 733
734 if (arg < 0 || arg > drive->id->max_multsect)
735 return -EINVAL;
736
740 if (drive->special.b.set_multmode) 737 if (drive->special.b.set_multmode)
741 return -EBUSY; 738 return -EBUSY;
742 ide_init_drive_cmd (&rq); 739 ide_init_drive_cmd (&rq);
@@ -749,6 +746,9 @@ static int set_multcount(ide_drive_t *drive, int arg)
749 746
750static int set_nowerr(ide_drive_t *drive, int arg) 747static int set_nowerr(ide_drive_t *drive, int arg)
751{ 748{
749 if (arg < 0 || arg > 1)
750 return -EINVAL;
751
752 if (ide_spin_wait_hwgroup(drive)) 752 if (ide_spin_wait_hwgroup(drive))
753 return -EBUSY; 753 return -EBUSY;
754 drive->nowerr = arg; 754 drive->nowerr = arg;
@@ -800,6 +800,9 @@ static int write_cache(ide_drive_t *drive, int arg)
800 ide_task_t args; 800 ide_task_t args;
801 int err = 1; 801 int err = 1;
802 802
803 if (arg < 0 || arg > 1)
804 return -EINVAL;
805
803 if (ide_id_has_flush_cache(drive->id)) { 806 if (ide_id_has_flush_cache(drive->id)) {
804 memset(&args, 0, sizeof(ide_task_t)); 807 memset(&args, 0, sizeof(ide_task_t));
805 args.tfRegister[IDE_FEATURE_OFFSET] = (arg) ? 808 args.tfRegister[IDE_FEATURE_OFFSET] = (arg) ?
@@ -835,6 +838,9 @@ static int set_acoustic (ide_drive_t *drive, int arg)
835{ 838{
836 ide_task_t args; 839 ide_task_t args;
837 840
841 if (arg < 0 || arg > 254)
842 return -EINVAL;
843
838 memset(&args, 0, sizeof(ide_task_t)); 844 memset(&args, 0, sizeof(ide_task_t));
839 args.tfRegister[IDE_FEATURE_OFFSET] = (arg) ? SETFEATURES_EN_AAM : 845 args.tfRegister[IDE_FEATURE_OFFSET] = (arg) ? SETFEATURES_EN_AAM :
840 SETFEATURES_DIS_AAM; 846 SETFEATURES_DIS_AAM;
@@ -855,6 +861,9 @@ static int set_acoustic (ide_drive_t *drive, int arg)
855 */ 861 */
856static int set_lba_addressing(ide_drive_t *drive, int arg) 862static int set_lba_addressing(ide_drive_t *drive, int arg)
857{ 863{
864 if (arg < 0 || arg > 2)
865 return -EINVAL;
866
858 drive->addressing = 0; 867 drive->addressing = 0;
859 868
860 if (HWIF(drive)->no_lba48) 869 if (HWIF(drive)->no_lba48)
@@ -866,23 +875,27 @@ static int set_lba_addressing(ide_drive_t *drive, int arg)
866 return 0; 875 return 0;
867} 876}
868 877
878#ifdef CONFIG_IDE_PROC_FS
869static void idedisk_add_settings(ide_drive_t *drive) 879static void idedisk_add_settings(ide_drive_t *drive)
870{ 880{
871 struct hd_driveid *id = drive->id; 881 struct hd_driveid *id = drive->id;
872 882
873 ide_add_setting(drive, "bios_cyl", SETTING_RW, -1, -1, TYPE_INT, 0, 65535, 1, 1, &drive->bios_cyl, NULL); 883 ide_add_setting(drive, "bios_cyl", SETTING_RW, TYPE_INT, 0, 65535, 1, 1, &drive->bios_cyl, NULL);
874 ide_add_setting(drive, "bios_head", SETTING_RW, -1, -1, TYPE_BYTE, 0, 255, 1, 1, &drive->bios_head, NULL); 884 ide_add_setting(drive, "bios_head", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, &drive->bios_head, NULL);
875 ide_add_setting(drive, "bios_sect", SETTING_RW, -1, -1, TYPE_BYTE, 0, 63, 1, 1, &drive->bios_sect, NULL); 885 ide_add_setting(drive, "bios_sect", SETTING_RW, TYPE_BYTE, 0, 63, 1, 1, &drive->bios_sect, NULL);
876 ide_add_setting(drive, "address", SETTING_RW, HDIO_GET_ADDRESS, HDIO_SET_ADDRESS, TYPE_INTA, 0, 2, 1, 1, &drive->addressing, set_lba_addressing); 886 ide_add_setting(drive, "address", SETTING_RW, TYPE_BYTE, 0, 2, 1, 1, &drive->addressing, set_lba_addressing);
877 ide_add_setting(drive, "bswap", SETTING_READ, -1, -1, TYPE_BYTE, 0, 1, 1, 1, &drive->bswap, NULL); 887 ide_add_setting(drive, "bswap", SETTING_READ, TYPE_BYTE, 0, 1, 1, 1, &drive->bswap, NULL);
878 ide_add_setting(drive, "multcount", id ? SETTING_RW : SETTING_READ, HDIO_GET_MULTCOUNT, HDIO_SET_MULTCOUNT, TYPE_BYTE, 0, id ? id->max_multsect : 0, 1, 1, &drive->mult_count, set_multcount); 888 ide_add_setting(drive, "multcount", SETTING_RW, TYPE_BYTE, 0, id->max_multsect, 1, 1, &drive->mult_count, set_multcount);
879 ide_add_setting(drive, "nowerr", SETTING_RW, HDIO_GET_NOWERR, HDIO_SET_NOWERR, TYPE_BYTE, 0, 1, 1, 1, &drive->nowerr, set_nowerr); 889 ide_add_setting(drive, "nowerr", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->nowerr, set_nowerr);
880 ide_add_setting(drive, "lun", SETTING_RW, -1, -1, TYPE_INT, 0, 7, 1, 1, &drive->lun, NULL); 890 ide_add_setting(drive, "lun", SETTING_RW, TYPE_INT, 0, 7, 1, 1, &drive->lun, NULL);
881 ide_add_setting(drive, "wcache", SETTING_RW, HDIO_GET_WCACHE, HDIO_SET_WCACHE, TYPE_BYTE, 0, 1, 1, 1, &drive->wcache, write_cache); 891 ide_add_setting(drive, "wcache", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->wcache, write_cache);
882 ide_add_setting(drive, "acoustic", SETTING_RW, HDIO_GET_ACOUSTIC, HDIO_SET_ACOUSTIC, TYPE_BYTE, 0, 254, 1, 1, &drive->acoustic, set_acoustic); 892 ide_add_setting(drive, "acoustic", SETTING_RW, TYPE_BYTE, 0, 254, 1, 1, &drive->acoustic, set_acoustic);
883 ide_add_setting(drive, "failures", SETTING_RW, -1, -1, TYPE_INT, 0, 65535, 1, 1, &drive->failures, NULL); 893 ide_add_setting(drive, "failures", SETTING_RW, TYPE_INT, 0, 65535, 1, 1, &drive->failures, NULL);
884 ide_add_setting(drive, "max_failures", SETTING_RW, -1, -1, TYPE_INT, 0, 65535, 1, 1, &drive->max_failures, NULL); 894 ide_add_setting(drive, "max_failures", SETTING_RW, TYPE_INT, 0, 65535, 1, 1, &drive->max_failures, NULL);
885} 895}
896#else
897static inline void idedisk_add_settings(ide_drive_t *drive) { ; }
898#endif
886 899
887static void idedisk_setup (ide_drive_t *drive) 900static void idedisk_setup (ide_drive_t *drive)
888{ 901{
@@ -1001,7 +1014,7 @@ static void ide_disk_remove(ide_drive_t *drive)
1001 struct ide_disk_obj *idkp = drive->driver_data; 1014 struct ide_disk_obj *idkp = drive->driver_data;
1002 struct gendisk *g = idkp->disk; 1015 struct gendisk *g = idkp->disk;
1003 1016
1004 ide_unregister_subdriver(drive, idkp->driver); 1017 ide_proc_unregister_driver(drive, idkp->driver);
1005 1018
1006 del_gendisk(g); 1019 del_gendisk(g);
1007 1020
@@ -1066,7 +1079,9 @@ static ide_driver_t idedisk_driver = {
1066 .end_request = ide_end_request, 1079 .end_request = ide_end_request,
1067 .error = __ide_error, 1080 .error = __ide_error,
1068 .abort = __ide_abort, 1081 .abort = __ide_abort,
1082#ifdef CONFIG_IDE_PROC_FS
1069 .proc = idedisk_proc, 1083 .proc = idedisk_proc,
1084#endif
1070}; 1085};
1071 1086
1072static int idedisk_open(struct inode *inode, struct file *filp) 1087static int idedisk_open(struct inode *inode, struct file *filp)
@@ -1140,9 +1155,49 @@ static int idedisk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
1140static int idedisk_ioctl(struct inode *inode, struct file *file, 1155static int idedisk_ioctl(struct inode *inode, struct file *file,
1141 unsigned int cmd, unsigned long arg) 1156 unsigned int cmd, unsigned long arg)
1142{ 1157{
1158 unsigned long flags;
1143 struct block_device *bdev = inode->i_bdev; 1159 struct block_device *bdev = inode->i_bdev;
1144 struct ide_disk_obj *idkp = ide_disk_g(bdev->bd_disk); 1160 struct ide_disk_obj *idkp = ide_disk_g(bdev->bd_disk);
1145 return generic_ide_ioctl(idkp->drive, file, bdev, cmd, arg); 1161 ide_drive_t *drive = idkp->drive;
1162 int err, (*setfunc)(ide_drive_t *, int);
1163 u8 *val;
1164
1165 switch (cmd) {
1166 case HDIO_GET_ADDRESS: val = &drive->addressing; goto read_val;
1167 case HDIO_GET_MULTCOUNT: val = &drive->mult_count; goto read_val;
1168 case HDIO_GET_NOWERR: val = &drive->nowerr; goto read_val;
1169 case HDIO_GET_WCACHE: val = &drive->wcache; goto read_val;
1170 case HDIO_GET_ACOUSTIC: val = &drive->acoustic; goto read_val;
1171 case HDIO_SET_ADDRESS: setfunc = set_lba_addressing; goto set_val;
1172 case HDIO_SET_MULTCOUNT: setfunc = set_multcount; goto set_val;
1173 case HDIO_SET_NOWERR: setfunc = set_nowerr; goto set_val;
1174 case HDIO_SET_WCACHE: setfunc = write_cache; goto set_val;
1175 case HDIO_SET_ACOUSTIC: setfunc = set_acoustic; goto set_val;
1176 }
1177
1178 return generic_ide_ioctl(drive, file, bdev, cmd, arg);
1179
1180read_val:
1181 down(&ide_setting_sem);
1182 spin_lock_irqsave(&ide_lock, flags);
1183 err = *val;
1184 spin_unlock_irqrestore(&ide_lock, flags);
1185 up(&ide_setting_sem);
1186 return err >= 0 ? put_user(err, (long __user *)arg) : err;
1187
1188set_val:
1189 if (bdev != bdev->bd_contains)
1190 err = -EINVAL;
1191 else {
1192 if (!capable(CAP_SYS_ADMIN))
1193 err = -EACCES;
1194 else {
1195 down(&ide_setting_sem);
1196 err = setfunc(drive, arg);
1197 up(&ide_setting_sem);
1198 }
1199 }
1200 return err;
1146} 1201}
1147 1202
1148static int idedisk_media_changed(struct gendisk *disk) 1203static int idedisk_media_changed(struct gendisk *disk)
@@ -1202,7 +1257,7 @@ static int ide_disk_probe(ide_drive_t *drive)
1202 1257
1203 ide_init_disk(g, drive); 1258 ide_init_disk(g, drive);
1204 1259
1205 ide_register_subdriver(drive, &idedisk_driver); 1260 ide_proc_register_driver(drive, &idedisk_driver);
1206 1261
1207 kref_init(&idkp->kref); 1262 kref_init(&idkp->kref);
1208 1263
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index fd213088b06b..5fe85191d49c 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -705,6 +705,100 @@ int ide_use_dma(ide_drive_t *drive)
705 705
706EXPORT_SYMBOL_GPL(ide_use_dma); 706EXPORT_SYMBOL_GPL(ide_use_dma);
707 707
708static const u8 xfer_mode_bases[] = {
709 XFER_UDMA_0,
710 XFER_MW_DMA_0,
711 XFER_SW_DMA_0,
712};
713
714static unsigned int ide_get_mode_mask(ide_drive_t *drive, u8 base)
715{
716 struct hd_driveid *id = drive->id;
717 ide_hwif_t *hwif = drive->hwif;
718 unsigned int mask = 0;
719
720 switch(base) {
721 case XFER_UDMA_0:
722 if ((id->field_valid & 4) == 0)
723 break;
724
725 mask = id->dma_ultra & hwif->ultra_mask;
726
727 if (hwif->udma_filter)
728 mask &= hwif->udma_filter(drive);
729
730 if ((mask & 0x78) && (eighty_ninty_three(drive) == 0))
731 mask &= 0x07;
732 break;
733 case XFER_MW_DMA_0:
734 mask = id->dma_mword & hwif->mwdma_mask;
735 break;
736 case XFER_SW_DMA_0:
737 mask = id->dma_1word & hwif->swdma_mask;
738 break;
739 default:
740 BUG();
741 break;
742 }
743
744 return mask;
745}
746
747/**
748 * ide_max_dma_mode - compute DMA speed
749 * @drive: IDE device
750 *
751 * Checks the drive capabilities and returns the speed to use
752 * for the DMA transfer. Returns 0 if the drive is incapable
753 * of DMA transfers.
754 */
755
756u8 ide_max_dma_mode(ide_drive_t *drive)
757{
758 ide_hwif_t *hwif = drive->hwif;
759 unsigned int mask;
760 int x, i;
761 u8 mode = 0;
762
763 if (drive->media != ide_disk && hwif->atapi_dma == 0)
764 return 0;
765
766 for (i = 0; i < ARRAY_SIZE(xfer_mode_bases); i++) {
767 mask = ide_get_mode_mask(drive, xfer_mode_bases[i]);
768 x = fls(mask) - 1;
769 if (x >= 0) {
770 mode = xfer_mode_bases[i] + x;
771 break;
772 }
773 }
774
775 printk(KERN_DEBUG "%s: selected mode 0x%x\n", drive->name, mode);
776
777 return mode;
778}
779
780EXPORT_SYMBOL_GPL(ide_max_dma_mode);
781
782int ide_tune_dma(ide_drive_t *drive)
783{
784 u8 speed;
785
786 /* TODO: use only ide_max_dma_mode() */
787 if (!ide_use_dma(drive))
788 return 0;
789
790 speed = ide_max_dma_mode(drive);
791
792 if (!speed)
793 return 0;
794
795 drive->hwif->speedproc(drive, speed);
796
797 return ide_dma_enable(drive);
798}
799
800EXPORT_SYMBOL_GPL(ide_tune_dma);
801
708void ide_dma_verbose(ide_drive_t *drive) 802void ide_dma_verbose(ide_drive_t *drive)
709{ 803{
710 struct hd_driveid *id = drive->id; 804 struct hd_driveid *id = drive->id;
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 57cd21c5b2c1..f429be88c4f9 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -1811,18 +1811,22 @@ static int idefloppy_identify_device (ide_drive_t *drive,struct hd_driveid *id)
1811 return 0; 1811 return 0;
1812} 1812}
1813 1813
1814#ifdef CONFIG_IDE_PROC_FS
1814static void idefloppy_add_settings(ide_drive_t *drive) 1815static void idefloppy_add_settings(ide_drive_t *drive)
1815{ 1816{
1816 idefloppy_floppy_t *floppy = drive->driver_data; 1817 idefloppy_floppy_t *floppy = drive->driver_data;
1817 1818
1818/* 1819/*
1819 * drive setting name read/write ioctl ioctl data type min max mul_factor div_factor data pointer set function 1820 * drive setting name read/write data type min max mul_factor div_factor data pointer set function
1820 */ 1821 */
1821 ide_add_setting(drive, "bios_cyl", SETTING_RW, -1, -1, TYPE_INT, 0, 1023, 1, 1, &drive->bios_cyl, NULL); 1822 ide_add_setting(drive, "bios_cyl", SETTING_RW, TYPE_INT, 0, 1023, 1, 1, &drive->bios_cyl, NULL);
1822 ide_add_setting(drive, "bios_head", SETTING_RW, -1, -1, TYPE_BYTE, 0, 255, 1, 1, &drive->bios_head, NULL); 1823 ide_add_setting(drive, "bios_head", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, &drive->bios_head, NULL);
1823 ide_add_setting(drive, "bios_sect", SETTING_RW, -1, -1, TYPE_BYTE, 0, 63, 1, 1, &drive->bios_sect, NULL); 1824 ide_add_setting(drive, "bios_sect", SETTING_RW, TYPE_BYTE, 0, 63, 1, 1, &drive->bios_sect, NULL);
1824 ide_add_setting(drive, "ticks", SETTING_RW, -1, -1, TYPE_BYTE, 0, 255, 1, 1, &floppy->ticks, NULL); 1825 ide_add_setting(drive, "ticks", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, &floppy->ticks, NULL);
1825} 1826}
1827#else
1828static inline void idefloppy_add_settings(ide_drive_t *drive) { ; }
1829#endif
1826 1830
1827/* 1831/*
1828 * Driver initialization. 1832 * Driver initialization.
@@ -1873,7 +1877,7 @@ static void ide_floppy_remove(ide_drive_t *drive)
1873 idefloppy_floppy_t *floppy = drive->driver_data; 1877 idefloppy_floppy_t *floppy = drive->driver_data;
1874 struct gendisk *g = floppy->disk; 1878 struct gendisk *g = floppy->disk;
1875 1879
1876 ide_unregister_subdriver(drive, floppy->driver); 1880 ide_proc_unregister_driver(drive, floppy->driver);
1877 1881
1878 del_gendisk(g); 1882 del_gendisk(g);
1879 1883
@@ -1892,8 +1896,7 @@ static void ide_floppy_release(struct kref *kref)
1892 kfree(floppy); 1896 kfree(floppy);
1893} 1897}
1894 1898
1895#ifdef CONFIG_PROC_FS 1899#ifdef CONFIG_IDE_PROC_FS
1896
1897static int proc_idefloppy_read_capacity 1900static int proc_idefloppy_read_capacity
1898 (char *page, char **start, off_t off, int count, int *eof, void *data) 1901 (char *page, char **start, off_t off, int count, int *eof, void *data)
1899{ 1902{
@@ -1909,12 +1912,7 @@ static ide_proc_entry_t idefloppy_proc[] = {
1909 { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL }, 1912 { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL },
1910 { NULL, 0, NULL, NULL } 1913 { NULL, 0, NULL, NULL }
1911}; 1914};
1912 1915#endif /* CONFIG_IDE_PROC_FS */
1913#else
1914
1915#define idefloppy_proc NULL
1916
1917#endif /* CONFIG_PROC_FS */
1918 1916
1919static int ide_floppy_probe(ide_drive_t *); 1917static int ide_floppy_probe(ide_drive_t *);
1920 1918
@@ -1933,7 +1931,9 @@ static ide_driver_t idefloppy_driver = {
1933 .end_request = idefloppy_do_end_request, 1931 .end_request = idefloppy_do_end_request,
1934 .error = __ide_error, 1932 .error = __ide_error,
1935 .abort = __ide_abort, 1933 .abort = __ide_abort,
1934#ifdef CONFIG_IDE_PROC_FS
1936 .proc = idefloppy_proc, 1935 .proc = idefloppy_proc,
1936#endif
1937}; 1937};
1938 1938
1939static int idefloppy_open(struct inode *inode, struct file *filp) 1939static int idefloppy_open(struct inode *inode, struct file *filp)
@@ -2159,7 +2159,7 @@ static int ide_floppy_probe(ide_drive_t *drive)
2159 2159
2160 ide_init_disk(g, drive); 2160 ide_init_disk(g, drive);
2161 2161
2162 ide_register_subdriver(drive, &idefloppy_driver); 2162 ide_proc_register_driver(drive, &idefloppy_driver);
2163 2163
2164 kref_init(&floppy->kref); 2164 kref_init(&floppy->kref);
2165 2165
diff --git a/drivers/ide/ide-generic.c b/drivers/ide/ide-generic.c
index 99fd56151131..0f72b98d727f 100644
--- a/drivers/ide/ide-generic.c
+++ b/drivers/ide/ide-generic.c
@@ -22,8 +22,6 @@ static int __init ide_generic_init(void)
22 if (ide_hwifs[0].io_ports[IDE_DATA_OFFSET]) 22 if (ide_hwifs[0].io_ports[IDE_DATA_OFFSET])
23 ide_release_lock(); /* for atari only */ 23 ide_release_lock(); /* for atari only */
24 24
25 create_proc_ide_interfaces();
26
27 return 0; 25 return 0;
28} 26}
29 27
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 8670112f1d39..8e568143d90d 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -172,15 +172,6 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *
172 172
173 memset(args, 0, sizeof(*args)); 173 memset(args, 0, sizeof(*args));
174 174
175 if (drive->media != ide_disk) {
176 /*
177 * skip idedisk_pm_restore_pio and idedisk_pm_idle for ATAPI
178 * devices
179 */
180 if (pm->pm_step == idedisk_pm_restore_pio)
181 pm->pm_step = ide_pm_restore_dma;
182 }
183
184 switch (pm->pm_step) { 175 switch (pm->pm_step) {
185 case ide_pm_flush_cache: /* Suspend step 1 (flush cache) */ 176 case ide_pm_flush_cache: /* Suspend step 1 (flush cache) */
186 if (drive->media != ide_disk) 177 if (drive->media != ide_disk)
@@ -207,7 +198,13 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *
207 case idedisk_pm_restore_pio: /* Resume step 1 (restore PIO) */ 198 case idedisk_pm_restore_pio: /* Resume step 1 (restore PIO) */
208 if (drive->hwif->tuneproc != NULL) 199 if (drive->hwif->tuneproc != NULL)
209 drive->hwif->tuneproc(drive, 255); 200 drive->hwif->tuneproc(drive, 255);
210 ide_complete_power_step(drive, rq, 0, 0); 201 /*
202 * skip idedisk_pm_idle for ATAPI devices
203 */
204 if (drive->media != ide_disk)
205 pm->pm_step = ide_pm_restore_dma;
206 else
207 ide_complete_power_step(drive, rq, 0, 0);
211 return ide_stopped; 208 return ide_stopped;
212 209
213 case idedisk_pm_idle: /* Resume step 2 (idle) */ 210 case idedisk_pm_idle: /* Resume step 2 (idle) */
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index 3caa176b3155..f0be5f665a0e 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -571,51 +571,54 @@ EXPORT_SYMBOL(ide_wait_stat);
571 */ 571 */
572u8 eighty_ninty_three (ide_drive_t *drive) 572u8 eighty_ninty_three (ide_drive_t *drive)
573{ 573{
574 if(HWIF(drive)->udma_four == 0) 574 ide_hwif_t *hwif = drive->hwif;
575 return 0; 575 struct hd_driveid *id = drive->id;
576
577 if (hwif->udma_four == 0)
578 goto no_80w;
576 579
577 /* Check for SATA but only if we are ATA5 or higher */ 580 /* Check for SATA but only if we are ATA5 or higher */
578 if (drive->id->hw_config == 0 && (drive->id->major_rev_num & 0x7FE0)) 581 if (id->hw_config == 0 && (id->major_rev_num & 0x7FE0))
579 return 1; 582 return 1;
580 if (!(drive->id->hw_config & 0x6000)) 583
581 return 0;
582#ifndef CONFIG_IDEDMA_IVB
583 if(!(drive->id->hw_config & 0x4000))
584 return 0;
585#endif /* CONFIG_IDEDMA_IVB */
586 /* 584 /*
587 * FIXME: 585 * FIXME:
588 * - change master/slave IDENTIFY order 586 * - change master/slave IDENTIFY order
589 * - force bit13 (80c cable present) check 587 * - force bit13 (80c cable present) check
590 * (unless the slave device is pre-ATA3) 588 * (unless the slave device is pre-ATA3)
591 */ 589 */
592 return 1; 590#ifndef CONFIG_IDEDMA_IVB
593} 591 if (id->hw_config & 0x4000)
592#else
593 if (id->hw_config & 0x6000)
594#endif
595 return 1;
596
597no_80w:
598 if (drive->udma33_warned == 1)
599 return 0;
594 600
595EXPORT_SYMBOL(eighty_ninty_three); 601 printk(KERN_WARNING "%s: %s side 80-wire cable detection failed, "
602 "limiting max speed to UDMA33\n",
603 drive->name, hwif->udma_four ? "drive" : "host");
604
605 drive->udma33_warned = 1;
606
607 return 0;
608}
596 609
597int ide_ata66_check (ide_drive_t *drive, ide_task_t *args) 610int ide_ata66_check (ide_drive_t *drive, ide_task_t *args)
598{ 611{
599 if ((args->tfRegister[IDE_COMMAND_OFFSET] == WIN_SETFEATURES) && 612 if ((args->tfRegister[IDE_COMMAND_OFFSET] == WIN_SETFEATURES) &&
600 (args->tfRegister[IDE_SECTOR_OFFSET] > XFER_UDMA_2) && 613 (args->tfRegister[IDE_SECTOR_OFFSET] > XFER_UDMA_2) &&
601 (args->tfRegister[IDE_FEATURE_OFFSET] == SETFEATURES_XFER)) { 614 (args->tfRegister[IDE_FEATURE_OFFSET] == SETFEATURES_XFER)) {
602#ifndef CONFIG_IDEDMA_IVB 615 if (eighty_ninty_three(drive) == 0) {
603 if ((drive->id->hw_config & 0x6000) == 0) { 616 printk(KERN_WARNING "%s: UDMA speeds >UDMA33 cannot "
604#else /* !CONFIG_IDEDMA_IVB */ 617 "be set\n", drive->name);
605 if (((drive->id->hw_config & 0x2000) == 0) ||
606 ((drive->id->hw_config & 0x4000) == 0)) {
607#endif /* CONFIG_IDEDMA_IVB */
608 printk("%s: Speed warnings UDMA 3/4/5 is not "
609 "functional.\n", drive->name);
610 return 1;
611 }
612 if (!HWIF(drive)->udma_four) {
613 printk("%s: Speed warnings UDMA 3/4/5 is not "
614 "functional.\n",
615 HWIF(drive)->name);
616 return 1; 618 return 1;
617 } 619 }
618 } 620 }
621
619 return 0; 622 return 0;
620} 623}
621 624
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
index 68719314df3f..3be3c69383f2 100644
--- a/drivers/ide/ide-lib.c
+++ b/drivers/ide/ide-lib.c
@@ -69,123 +69,41 @@ char *ide_xfer_verbose (u8 xfer_rate)
69EXPORT_SYMBOL(ide_xfer_verbose); 69EXPORT_SYMBOL(ide_xfer_verbose);
70 70
71/** 71/**
72 * ide_dma_speed - compute DMA speed 72 * ide_rate_filter - filter transfer mode
73 * @drive: drive 73 * @drive: IDE device
74 * @mode: modes available
75 *
76 * Checks the drive capabilities and returns the speed to use
77 * for the DMA transfer. Returns 0 if the drive is incapable
78 * of DMA transfers.
79 */
80
81u8 ide_dma_speed(ide_drive_t *drive, u8 mode)
82{
83 struct hd_driveid *id = drive->id;
84 ide_hwif_t *hwif = HWIF(drive);
85 u8 ultra_mask, mwdma_mask, swdma_mask;
86 u8 speed = 0;
87
88 if (drive->media != ide_disk && hwif->atapi_dma == 0)
89 return 0;
90
91 /* Capable of UltraDMA modes? */
92 ultra_mask = id->dma_ultra & hwif->ultra_mask;
93
94 if (!(id->field_valid & 4))
95 mode = 0; /* fallback to MW/SW DMA if no UltraDMA */
96
97 switch (mode) {
98 case 4:
99 if (ultra_mask & 0x40) {
100 speed = XFER_UDMA_6;
101 break;
102 }
103 case 3:
104 if (ultra_mask & 0x20) {
105 speed = XFER_UDMA_5;
106 break;
107 }
108 case 2:
109 if (ultra_mask & 0x10) {
110 speed = XFER_UDMA_4;
111 break;
112 }
113 if (ultra_mask & 0x08) {
114 speed = XFER_UDMA_3;
115 break;
116 }
117 case 1:
118 if (ultra_mask & 0x04) {
119 speed = XFER_UDMA_2;
120 break;
121 }
122 if (ultra_mask & 0x02) {
123 speed = XFER_UDMA_1;
124 break;
125 }
126 if (ultra_mask & 0x01) {
127 speed = XFER_UDMA_0;
128 break;
129 }
130 case 0:
131 mwdma_mask = id->dma_mword & hwif->mwdma_mask;
132
133 if (mwdma_mask & 0x04) {
134 speed = XFER_MW_DMA_2;
135 break;
136 }
137 if (mwdma_mask & 0x02) {
138 speed = XFER_MW_DMA_1;
139 break;
140 }
141 if (mwdma_mask & 0x01) {
142 speed = XFER_MW_DMA_0;
143 break;
144 }
145
146 swdma_mask = id->dma_1word & hwif->swdma_mask;
147
148 if (swdma_mask & 0x04) {
149 speed = XFER_SW_DMA_2;
150 break;
151 }
152 if (swdma_mask & 0x02) {
153 speed = XFER_SW_DMA_1;
154 break;
155 }
156 if (swdma_mask & 0x01) {
157 speed = XFER_SW_DMA_0;
158 break;
159 }
160 }
161
162 return speed;
163}
164EXPORT_SYMBOL(ide_dma_speed);
165
166
167/**
168 * ide_rate_filter - return best speed for mode
169 * @mode: modes available
170 * @speed: desired speed 74 * @speed: desired speed
171 * 75 *
172 * Given the available DMA/UDMA mode this function returns 76 * Given the available transfer modes this function returns
173 * the best available speed at or below the speed requested. 77 * the best available speed at or below the speed requested.
78 *
79 * FIXME: filter also PIO/SWDMA/MWDMA modes
174 */ 80 */
175 81
176u8 ide_rate_filter (u8 mode, u8 speed) 82u8 ide_rate_filter(ide_drive_t *drive, u8 speed)
177{ 83{
178#ifdef CONFIG_BLK_DEV_IDEDMA 84#ifdef CONFIG_BLK_DEV_IDEDMA
179 static u8 speed_max[] = { 85 ide_hwif_t *hwif = drive->hwif;
180 XFER_MW_DMA_2, XFER_UDMA_2, XFER_UDMA_4, 86 u8 mask = hwif->ultra_mask, mode = XFER_MW_DMA_2;
181 XFER_UDMA_5, XFER_UDMA_6 87
182 }; 88 if (hwif->udma_filter)
89 mask = hwif->udma_filter(drive);
90
91 /*
92 * TODO: speed > XFER_UDMA_2 extra check is needed to avoid false
93 * cable warning from eighty_ninty_three(), moving ide_rate_filter()
94 * calls from ->speedproc to core code will make this hack go away
95 */
96 if (speed > XFER_UDMA_2) {
97 if ((mask & 0x78) && (eighty_ninty_three(drive) == 0))
98 mask &= 0x07;
99 }
100
101 if (mask)
102 mode = fls(mask) - 1 + XFER_UDMA_0;
183 103
184// printk("%s: mode 0x%02x, speed 0x%02x\n", __FUNCTION__, mode, speed); 104// printk("%s: mode 0x%02x, speed 0x%02x\n", __FUNCTION__, mode, speed);
185 105
186 /* So that we remember to update this if new modes appear */ 106 return min(speed, mode);
187 BUG_ON(mode > 4);
188 return min(speed, speed_max[mode]);
189#else /* !CONFIG_BLK_DEV_IDEDMA */ 107#else /* !CONFIG_BLK_DEV_IDEDMA */
190 return min(speed, (u8)XFER_PIO_4); 108 return min(speed, (u8)XFER_PIO_4);
191#endif /* CONFIG_BLK_DEV_IDEDMA */ 109#endif /* CONFIG_BLK_DEV_IDEDMA */
diff --git a/drivers/ide/ide-pnp.c b/drivers/ide/ide-pnp.c
index 98410ca044cf..2b8009c50e91 100644
--- a/drivers/ide/ide-pnp.c
+++ b/drivers/ide/ide-pnp.c
@@ -42,7 +42,7 @@ static int idepnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id
42 hw.irq = pnp_irq(dev, 0); 42 hw.irq = pnp_irq(dev, 0);
43 hw.dma = NO_DMA; 43 hw.dma = NO_DMA;
44 44
45 index = ide_register_hw(&hw, &hwif); 45 index = ide_register_hw(&hw, 1, &hwif);
46 46
47 if (index != -1) { 47 if (index != -1) {
48 printk(KERN_INFO "ide%d: generic PnP IDE interface\n", index); 48 printk(KERN_INFO "ide%d: generic PnP IDE interface\n", index);
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 8f15c23aa70d..3cebed77f55d 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1427,6 +1427,9 @@ int ideprobe_init (void)
1427 } 1427 }
1428 } 1428 }
1429 } 1429 }
1430 for (index = 0; index < MAX_HWIFS; ++index)
1431 if (probe[index])
1432 ide_proc_register_port(&ide_hwifs[index]);
1430 return 0; 1433 return 0;
1431} 1434}
1432 1435
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c
index a9e0b30fb1f2..d50bd996ff22 100644
--- a/drivers/ide/ide-proc.c
+++ b/drivers/ide/ide-proc.c
@@ -3,6 +3,8 @@
3 * 3 *
4 * Copyright (C) 1997-1998 Mark Lord 4 * Copyright (C) 1997-1998 Mark Lord
5 * Copyright (C) 2003 Red Hat <alan@redhat.com> 5 * Copyright (C) 2003 Red Hat <alan@redhat.com>
6 *
7 * Some code was moved here from ide.c, see it for original copyrights.
6 */ 8 */
7 9
8/* 10/*
@@ -37,6 +39,8 @@
37 39
38#include <asm/io.h> 40#include <asm/io.h>
39 41
42static struct proc_dir_entry *proc_ide_root;
43
40static int proc_ide_read_imodel 44static int proc_ide_read_imodel
41 (char *page, char **start, off_t off, int count, int *eof, void *data) 45 (char *page, char **start, off_t off, int count, int *eof, void *data)
42{ 46{
@@ -121,6 +125,265 @@ static int proc_ide_read_identify
121 PROC_IDE_READ_RETURN(page,start,off,count,eof,len); 125 PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
122} 126}
123 127
128/**
129 * __ide_add_setting - add an ide setting option
130 * @drive: drive to use
131 * @name: setting name
132 * @rw: true if the function is read write
133 * @data_type: type of data
134 * @min: range minimum
135 * @max: range maximum
136 * @mul_factor: multiplication scale
137 * @div_factor: divison scale
138 * @data: private data field
139 * @set: setting
140 * @auto_remove: setting auto removal flag
141 *
142 * Removes the setting named from the device if it is present.
143 * The function takes the settings_lock to protect against
144 * parallel changes. This function must not be called from IRQ
145 * context. Returns 0 on success or -1 on failure.
146 *
147 * BUGS: This code is seriously over-engineered. There is also
148 * magic about how the driver specific features are setup. If
149 * a driver is attached we assume the driver settings are auto
150 * remove.
151 */
152
153static int __ide_add_setting(ide_drive_t *drive, const char *name, int rw, int data_type, int min, int max, int mul_factor, int div_factor, void *data, ide_procset_t *set, int auto_remove)
154{
155 ide_settings_t **p = (ide_settings_t **) &drive->settings, *setting = NULL;
156
157 down(&ide_setting_sem);
158 while ((*p) && strcmp((*p)->name, name) < 0)
159 p = &((*p)->next);
160 if ((setting = kzalloc(sizeof(*setting), GFP_KERNEL)) == NULL)
161 goto abort;
162 if ((setting->name = kmalloc(strlen(name) + 1, GFP_KERNEL)) == NULL)
163 goto abort;
164 strcpy(setting->name, name);
165 setting->rw = rw;
166 setting->data_type = data_type;
167 setting->min = min;
168 setting->max = max;
169 setting->mul_factor = mul_factor;
170 setting->div_factor = div_factor;
171 setting->data = data;
172 setting->set = set;
173
174 setting->next = *p;
175 if (auto_remove)
176 setting->auto_remove = 1;
177 *p = setting;
178 up(&ide_setting_sem);
179 return 0;
180abort:
181 up(&ide_setting_sem);
182 kfree(setting);
183 return -1;
184}
185
186int ide_add_setting(ide_drive_t *drive, const char *name, int rw, int data_type, int min, int max, int mul_factor, int div_factor, void *data, ide_procset_t *set)
187{
188 return __ide_add_setting(drive, name, rw, data_type, min, max, mul_factor, div_factor, data, set, 1);
189}
190
191EXPORT_SYMBOL(ide_add_setting);
192
193/**
194 * __ide_remove_setting - remove an ide setting option
195 * @drive: drive to use
196 * @name: setting name
197 *
198 * Removes the setting named from the device if it is present.
199 * The caller must hold the setting semaphore.
200 */
201
202static void __ide_remove_setting (ide_drive_t *drive, char *name)
203{
204 ide_settings_t **p, *setting;
205
206 p = (ide_settings_t **) &drive->settings;
207
208 while ((*p) && strcmp((*p)->name, name))
209 p = &((*p)->next);
210 if ((setting = (*p)) == NULL)
211 return;
212
213 (*p) = setting->next;
214
215 kfree(setting->name);
216 kfree(setting);
217}
218
219/**
220 * auto_remove_settings - remove driver specific settings
221 * @drive: drive
222 *
223 * Automatically remove all the driver specific settings for this
224 * drive. This function may not be called from IRQ context. The
225 * caller must hold ide_setting_sem.
226 */
227
228static void auto_remove_settings (ide_drive_t *drive)
229{
230 ide_settings_t *setting;
231repeat:
232 setting = drive->settings;
233 while (setting) {
234 if (setting->auto_remove) {
235 __ide_remove_setting(drive, setting->name);
236 goto repeat;
237 }
238 setting = setting->next;
239 }
240}
241
242/**
243 * ide_find_setting_by_name - find a drive specific setting
244 * @drive: drive to scan
245 * @name: setting name
246 *
247 * Scan's the device setting table for a matching entry and returns
248 * this or NULL if no entry is found. The caller must hold the
249 * setting semaphore
250 */
251
252static ide_settings_t *ide_find_setting_by_name(ide_drive_t *drive, char *name)
253{
254 ide_settings_t *setting = drive->settings;
255
256 while (setting) {
257 if (strcmp(setting->name, name) == 0)
258 break;
259 setting = setting->next;
260 }
261 return setting;
262}
263
264/**
265 * ide_read_setting - read an IDE setting
266 * @drive: drive to read from
267 * @setting: drive setting
268 *
269 * Read a drive setting and return the value. The caller
270 * must hold the ide_setting_sem when making this call.
271 *
272 * BUGS: the data return and error are the same return value
273 * so an error -EINVAL and true return of the same value cannot
274 * be told apart
275 */
276
277static int ide_read_setting(ide_drive_t *drive, ide_settings_t *setting)
278{
279 int val = -EINVAL;
280 unsigned long flags;
281
282 if ((setting->rw & SETTING_READ)) {
283 spin_lock_irqsave(&ide_lock, flags);
284 switch(setting->data_type) {
285 case TYPE_BYTE:
286 val = *((u8 *) setting->data);
287 break;
288 case TYPE_SHORT:
289 val = *((u16 *) setting->data);
290 break;
291 case TYPE_INT:
292 val = *((u32 *) setting->data);
293 break;
294 }
295 spin_unlock_irqrestore(&ide_lock, flags);
296 }
297 return val;
298}
299
300/**
301 * ide_write_setting - read an IDE setting
302 * @drive: drive to read from
303 * @setting: drive setting
304 * @val: value
305 *
306 * Write a drive setting if it is possible. The caller
307 * must hold the ide_setting_sem when making this call.
308 *
309 * BUGS: the data return and error are the same return value
310 * so an error -EINVAL and true return of the same value cannot
311 * be told apart
312 *
313 * FIXME: This should be changed to enqueue a special request
314 * to the driver to change settings, and then wait on a sema for completion.
315 * The current scheme of polling is kludgy, though safe enough.
316 */
317
318static int ide_write_setting(ide_drive_t *drive, ide_settings_t *setting, int val)
319{
320 if (!capable(CAP_SYS_ADMIN))
321 return -EACCES;
322 if (setting->set)
323 return setting->set(drive, val);
324 if (!(setting->rw & SETTING_WRITE))
325 return -EPERM;
326 if (val < setting->min || val > setting->max)
327 return -EINVAL;
328 if (ide_spin_wait_hwgroup(drive))
329 return -EBUSY;
330 switch (setting->data_type) {
331 case TYPE_BYTE:
332 *((u8 *) setting->data) = val;
333 break;
334 case TYPE_SHORT:
335 *((u16 *) setting->data) = val;
336 break;
337 case TYPE_INT:
338 *((u32 *) setting->data) = val;
339 break;
340 }
341 spin_unlock_irq(&ide_lock);
342 return 0;
343}
344
345static int set_xfer_rate (ide_drive_t *drive, int arg)
346{
347 int err;
348
349 if (arg < 0 || arg > 70)
350 return -EINVAL;
351
352 err = ide_wait_cmd(drive,
353 WIN_SETFEATURES, (u8) arg,
354 SETFEATURES_XFER, 0, NULL);
355
356 if (!err && arg) {
357 ide_set_xfer_rate(drive, (u8) arg);
358 ide_driveid_update(drive);
359 }
360 return err;
361}
362
363/**
364 * ide_add_generic_settings - generic ide settings
365 * @drive: drive being configured
366 *
367 * Add the generic parts of the system settings to the /proc files.
368 * The caller must not be holding the ide_setting_sem.
369 */
370
371void ide_add_generic_settings (ide_drive_t *drive)
372{
373/*
374 * drive setting name read/write access data type min max mul_factor div_factor data pointer set function
375 */
376 __ide_add_setting(drive, "io_32bit", drive->no_io_32bit ? SETTING_READ : SETTING_RW, TYPE_BYTE, 0, 1 + (SUPPORT_VLB_SYNC << 1), 1, 1, &drive->io_32bit, set_io_32bit, 0);
377 __ide_add_setting(drive, "keepsettings", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->keep_settings, NULL, 0);
378 __ide_add_setting(drive, "nice1", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->nice1, NULL, 0);
379 __ide_add_setting(drive, "pio_mode", SETTING_WRITE, TYPE_BYTE, 0, 255, 1, 1, NULL, set_pio_mode, 0);
380 __ide_add_setting(drive, "unmaskirq", drive->no_unmask ? SETTING_READ : SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->unmask, NULL, 0);
381 __ide_add_setting(drive, "using_dma", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->using_dma, set_using_dma, 0);
382 __ide_add_setting(drive, "init_speed", SETTING_RW, TYPE_BYTE, 0, 70, 1, 1, &drive->init_speed, NULL, 0);
383 __ide_add_setting(drive, "current_speed", SETTING_RW, TYPE_BYTE, 0, 70, 1, 1, &drive->current_speed, set_xfer_rate, 0);
384 __ide_add_setting(drive, "number", SETTING_RW, TYPE_BYTE, 0, 3, 1, 1, &drive->dn, NULL, 0);
385}
386
124static void proc_ide_settings_warn(void) 387static void proc_ide_settings_warn(void)
125{ 388{
126 static int warned = 0; 389 static int warned = 0;
@@ -399,7 +662,7 @@ static ide_proc_entry_t generic_drive_entries[] = {
399 { NULL, 0, NULL, NULL } 662 { NULL, 0, NULL, NULL }
400}; 663};
401 664
402void ide_add_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p, void *data) 665static void ide_add_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p, void *data)
403{ 666{
404 struct proc_dir_entry *ent; 667 struct proc_dir_entry *ent;
405 668
@@ -415,7 +678,7 @@ void ide_add_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p, void
415 } 678 }
416} 679}
417 680
418void ide_remove_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p) 681static void ide_remove_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p)
419{ 682{
420 if (!dir || !p) 683 if (!dir || !p)
421 return; 684 return;
@@ -425,6 +688,51 @@ void ide_remove_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p)
425 } 688 }
426} 689}
427 690
691void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver)
692{
693 ide_add_proc_entries(drive->proc, driver->proc, drive);
694}
695
696EXPORT_SYMBOL(ide_proc_register_driver);
697
698/**
699 * ide_proc_unregister_driver - remove driver specific data
700 * @drive: drive
701 * @driver: driver
702 *
703 * Clean up the driver specific /proc files and IDE settings
704 * for a given drive.
705 *
706 * Takes ide_setting_sem and ide_lock.
707 * Caller must hold none of the locks.
708 */
709
710void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver)
711{
712 unsigned long flags;
713
714 ide_remove_proc_entries(drive->proc, driver->proc);
715
716 down(&ide_setting_sem);
717 spin_lock_irqsave(&ide_lock, flags);
718 /*
719 * ide_setting_sem protects the settings list
720 * ide_lock protects the use of settings
721 *
722 * so we need to hold both, ide_settings_sem because we want to
723 * modify the settings list, and ide_lock because we cannot take
724 * a setting out that is being used.
725 *
726 * OTOH both ide_{read,write}_setting are only ever used under
727 * ide_setting_sem.
728 */
729 auto_remove_settings(drive);
730 spin_unlock_irqrestore(&ide_lock, flags);
731 up(&ide_setting_sem);
732}
733
734EXPORT_SYMBOL(ide_proc_unregister_driver);
735
428static void create_proc_ide_drives(ide_hwif_t *hwif) 736static void create_proc_ide_drives(ide_hwif_t *hwif)
429{ 737{
430 int d; 738 int d;
@@ -477,26 +785,24 @@ static ide_proc_entry_t hwif_entries[] = {
477 { NULL, 0, NULL, NULL } 785 { NULL, 0, NULL, NULL }
478}; 786};
479 787
480void create_proc_ide_interfaces(void) 788void ide_proc_register_port(ide_hwif_t *hwif)
481{ 789{
482 int h; 790 if (!hwif->present)
791 return;
483 792
484 for (h = 0; h < MAX_HWIFS; h++) { 793 if (!hwif->proc) {
485 ide_hwif_t *hwif = &ide_hwifs[h]; 794 hwif->proc = proc_mkdir(hwif->name, proc_ide_root);
486 795
487 if (!hwif->present) 796 if (!hwif->proc)
488 continue; 797 return;
489 if (!hwif->proc) { 798
490 hwif->proc = proc_mkdir(hwif->name, proc_ide_root); 799 ide_add_proc_entries(hwif->proc, hwif_entries, hwif);
491 if (!hwif->proc)
492 return;
493 ide_add_proc_entries(hwif->proc, hwif_entries, hwif);
494 }
495 create_proc_ide_drives(hwif);
496 } 800 }
801
802 create_proc_ide_drives(hwif);
497} 803}
498 804
499EXPORT_SYMBOL(create_proc_ide_interfaces); 805EXPORT_SYMBOL_GPL(ide_proc_register_port);
500 806
501#ifdef CONFIG_BLK_DEV_IDEPCI 807#ifdef CONFIG_BLK_DEV_IDEPCI
502void ide_pci_create_host_proc(const char *name, get_info_t *get_info) 808void ide_pci_create_host_proc(const char *name, get_info_t *get_info)
@@ -507,7 +813,7 @@ void ide_pci_create_host_proc(const char *name, get_info_t *get_info)
507EXPORT_SYMBOL_GPL(ide_pci_create_host_proc); 813EXPORT_SYMBOL_GPL(ide_pci_create_host_proc);
508#endif 814#endif
509 815
510void destroy_proc_ide_interface(ide_hwif_t *hwif) 816void ide_proc_unregister_port(ide_hwif_t *hwif)
511{ 817{
512 if (hwif->proc) { 818 if (hwif->proc) {
513 destroy_proc_ide_drives(hwif); 819 destroy_proc_ide_drives(hwif);
@@ -554,11 +860,11 @@ void proc_ide_create(void)
554{ 860{
555 struct proc_dir_entry *entry; 861 struct proc_dir_entry *entry;
556 862
863 proc_ide_root = proc_mkdir("ide", NULL);
864
557 if (!proc_ide_root) 865 if (!proc_ide_root)
558 return; 866 return;
559 867
560 create_proc_ide_interfaces();
561
562 entry = create_proc_entry("drivers", 0, proc_ide_root); 868 entry = create_proc_entry("drivers", 0, proc_ide_root);
563 if (entry) 869 if (entry)
564 entry->proc_fops = &ide_drivers_operations; 870 entry->proc_fops = &ide_drivers_operations;
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 4e59239fef75..e82bfa5e0ab8 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -4561,28 +4561,33 @@ static void idetape_get_blocksize_from_block_descriptor(ide_drive_t *drive)
4561 printk(KERN_INFO "ide-tape: Adjusted block size - %d\n", tape->tape_block_size); 4561 printk(KERN_INFO "ide-tape: Adjusted block size - %d\n", tape->tape_block_size);
4562#endif /* IDETAPE_DEBUG_INFO */ 4562#endif /* IDETAPE_DEBUG_INFO */
4563} 4563}
4564
4565#ifdef CONFIG_IDE_PROC_FS
4564static void idetape_add_settings (ide_drive_t *drive) 4566static void idetape_add_settings (ide_drive_t *drive)
4565{ 4567{
4566 idetape_tape_t *tape = drive->driver_data; 4568 idetape_tape_t *tape = drive->driver_data;
4567 4569
4568/* 4570/*
4569 * drive setting name read/write ioctl ioctl data type min max mul_factor div_factor data pointer set function 4571 * drive setting name read/write data type min max mul_factor div_factor data pointer set function
4570 */ 4572 */
4571 ide_add_setting(drive, "buffer", SETTING_READ, -1, -1, TYPE_SHORT, 0, 0xffff, 1, 2, &tape->capabilities.buffer_size, NULL); 4573 ide_add_setting(drive, "buffer", SETTING_READ, TYPE_SHORT, 0, 0xffff, 1, 2, &tape->capabilities.buffer_size, NULL);
4572 ide_add_setting(drive, "pipeline_min", SETTING_RW, -1, -1, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->min_pipeline, NULL); 4574 ide_add_setting(drive, "pipeline_min", SETTING_RW, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->min_pipeline, NULL);
4573 ide_add_setting(drive, "pipeline", SETTING_RW, -1, -1, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->max_stages, NULL); 4575 ide_add_setting(drive, "pipeline", SETTING_RW, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->max_stages, NULL);
4574 ide_add_setting(drive, "pipeline_max", SETTING_RW, -1, -1, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->max_pipeline, NULL); 4576 ide_add_setting(drive, "pipeline_max", SETTING_RW, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->max_pipeline, NULL);
4575 ide_add_setting(drive, "pipeline_used",SETTING_READ, -1, -1, TYPE_INT, 0, 0xffff, tape->stage_size / 1024, 1, &tape->nr_stages, NULL); 4577 ide_add_setting(drive, "pipeline_used", SETTING_READ, TYPE_INT, 0, 0xffff, tape->stage_size / 1024, 1, &tape->nr_stages, NULL);
4576 ide_add_setting(drive, "pipeline_pending",SETTING_READ,-1, -1, TYPE_INT, 0, 0xffff, tape->stage_size / 1024, 1, &tape->nr_pending_stages, NULL); 4578 ide_add_setting(drive, "pipeline_pending", SETTING_READ, TYPE_INT, 0, 0xffff, tape->stage_size / 1024, 1, &tape->nr_pending_stages, NULL);
4577 ide_add_setting(drive, "speed", SETTING_READ, -1, -1, TYPE_SHORT, 0, 0xffff, 1, 1, &tape->capabilities.speed, NULL); 4579 ide_add_setting(drive, "speed", SETTING_READ, TYPE_SHORT, 0, 0xffff, 1, 1, &tape->capabilities.speed, NULL);
4578 ide_add_setting(drive, "stage", SETTING_READ, -1, -1, TYPE_INT, 0, 0xffff, 1, 1024, &tape->stage_size, NULL); 4580 ide_add_setting(drive, "stage", SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1024, &tape->stage_size, NULL);
4579 ide_add_setting(drive, "tdsc", SETTING_RW, -1, -1, TYPE_INT, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX, 1000, HZ, &tape->best_dsc_rw_frequency, NULL); 4581 ide_add_setting(drive, "tdsc", SETTING_RW, TYPE_INT, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX, 1000, HZ, &tape->best_dsc_rw_frequency, NULL);
4580 ide_add_setting(drive, "dsc_overlap", SETTING_RW, -1, -1, TYPE_BYTE, 0, 1, 1, 1, &drive->dsc_overlap, NULL); 4582 ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->dsc_overlap, NULL);
4581 ide_add_setting(drive, "pipeline_head_speed_c",SETTING_READ, -1, -1, TYPE_INT, 0, 0xffff, 1, 1, &tape->controlled_pipeline_head_speed, NULL); 4583 ide_add_setting(drive, "pipeline_head_speed_c",SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1, &tape->controlled_pipeline_head_speed, NULL);
4582 ide_add_setting(drive, "pipeline_head_speed_u",SETTING_READ, -1, -1, TYPE_INT, 0, 0xffff, 1, 1, &tape->uncontrolled_pipeline_head_speed, NULL); 4584 ide_add_setting(drive, "pipeline_head_speed_u",SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1, &tape->uncontrolled_pipeline_head_speed,NULL);
4583 ide_add_setting(drive, "avg_speed", SETTING_READ, -1, -1, TYPE_INT, 0, 0xffff, 1, 1, &tape->avg_speed, NULL); 4585 ide_add_setting(drive, "avg_speed", SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1, &tape->avg_speed, NULL);
4584 ide_add_setting(drive, "debug_level",SETTING_RW, -1, -1, TYPE_INT, 0, 0xffff, 1, 1, &tape->debug_level, NULL); 4586 ide_add_setting(drive, "debug_level", SETTING_RW, TYPE_INT, 0, 0xffff, 1, 1, &tape->debug_level, NULL);
4585} 4587}
4588#else
4589static inline void idetape_add_settings(ide_drive_t *drive) { ; }
4590#endif
4586 4591
4587/* 4592/*
4588 * ide_setup is called to: 4593 * ide_setup is called to:
@@ -4703,7 +4708,7 @@ static void ide_tape_remove(ide_drive_t *drive)
4703{ 4708{
4704 idetape_tape_t *tape = drive->driver_data; 4709 idetape_tape_t *tape = drive->driver_data;
4705 4710
4706 ide_unregister_subdriver(drive, tape->driver); 4711 ide_proc_unregister_driver(drive, tape->driver);
4707 4712
4708 ide_unregister_region(tape->disk); 4713 ide_unregister_region(tape->disk);
4709 4714
@@ -4730,8 +4735,7 @@ static void ide_tape_release(struct kref *kref)
4730 kfree(tape); 4735 kfree(tape);
4731} 4736}
4732 4737
4733#ifdef CONFIG_PROC_FS 4738#ifdef CONFIG_IDE_PROC_FS
4734
4735static int proc_idetape_read_name 4739static int proc_idetape_read_name
4736 (char *page, char **start, off_t off, int count, int *eof, void *data) 4740 (char *page, char **start, off_t off, int count, int *eof, void *data)
4737{ 4741{
@@ -4749,11 +4753,6 @@ static ide_proc_entry_t idetape_proc[] = {
4749 { "name", S_IFREG|S_IRUGO, proc_idetape_read_name, NULL }, 4753 { "name", S_IFREG|S_IRUGO, proc_idetape_read_name, NULL },
4750 { NULL, 0, NULL, NULL } 4754 { NULL, 0, NULL, NULL }
4751}; 4755};
4752
4753#else
4754
4755#define idetape_proc NULL
4756
4757#endif 4756#endif
4758 4757
4759static int ide_tape_probe(ide_drive_t *); 4758static int ide_tape_probe(ide_drive_t *);
@@ -4773,7 +4772,9 @@ static ide_driver_t idetape_driver = {
4773 .end_request = idetape_end_request, 4772 .end_request = idetape_end_request,
4774 .error = __ide_error, 4773 .error = __ide_error,
4775 .abort = __ide_abort, 4774 .abort = __ide_abort,
4775#ifdef CONFIG_IDE_PROC_FS
4776 .proc = idetape_proc, 4776 .proc = idetape_proc,
4777#endif
4777}; 4778};
4778 4779
4779/* 4780/*
@@ -4864,7 +4865,7 @@ static int ide_tape_probe(ide_drive_t *drive)
4864 4865
4865 ide_init_disk(g, drive); 4866 ide_init_disk(g, drive);
4866 4867
4867 ide_register_subdriver(drive, &idetape_driver); 4868 ide_proc_register_driver(drive, &idetape_driver);
4868 4869
4869 kref_init(&tape->kref); 4870 kref_init(&tape->kref);
4870 4871
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index ae5bf2be6f52..f2b547ff7722 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -168,12 +168,11 @@ static const u8 ide_hwif_to_major[] = { IDE0_MAJOR, IDE1_MAJOR,
168 168
169static int idebus_parameter; /* holds the "idebus=" parameter */ 169static int idebus_parameter; /* holds the "idebus=" parameter */
170static int system_bus_speed; /* holds what we think is VESA/PCI bus speed */ 170static int system_bus_speed; /* holds what we think is VESA/PCI bus speed */
171static int initializing; /* set while initializing built-in drivers */
172 171
173DECLARE_MUTEX(ide_cfg_sem); 172DECLARE_MUTEX(ide_cfg_sem);
174 __cacheline_aligned_in_smp DEFINE_SPINLOCK(ide_lock); 173 __cacheline_aligned_in_smp DEFINE_SPINLOCK(ide_lock);
175 174
176#ifdef CONFIG_BLK_DEV_IDEPCI 175#ifdef CONFIG_IDEPCI_PCIBUS_ORDER
177static int ide_scan_direction; /* THIS was formerly 2.2.x pci=reverse */ 176static int ide_scan_direction; /* THIS was formerly 2.2.x pci=reverse */
178#endif 177#endif
179 178
@@ -216,9 +215,6 @@ static void init_hwif_data(ide_hwif_t *hwif, unsigned int index)
216 hwif->bus_state = BUSSTATE_ON; 215 hwif->bus_state = BUSSTATE_ON;
217 216
218 hwif->atapi_dma = 0; /* disable all atapi dma */ 217 hwif->atapi_dma = 0; /* disable all atapi dma */
219 hwif->ultra_mask = 0x80; /* disable all ultra */
220 hwif->mwdma_mask = 0x80; /* disable all mwdma */
221 hwif->swdma_mask = 0x80; /* disable all swdma */
222 218
223 init_completion(&hwif->gendev_rel_comp); 219 init_completion(&hwif->gendev_rel_comp);
224 220
@@ -305,9 +301,7 @@ static void __init init_ide_data (void)
305#endif 301#endif
306 } 302 }
307#ifdef CONFIG_IDE_ARM 303#ifdef CONFIG_IDE_ARM
308 initializing = 1;
309 ide_arm_init(); 304 ide_arm_init();
310 initializing = 0;
311#endif 305#endif
312} 306}
313 307
@@ -353,10 +347,6 @@ static int ide_system_bus_speed(void)
353 return system_bus_speed; 347 return system_bus_speed;
354} 348}
355 349
356#ifdef CONFIG_PROC_FS
357struct proc_dir_entry *proc_ide_root;
358#endif
359
360static struct resource* hwif_request_region(ide_hwif_t *hwif, 350static struct resource* hwif_request_region(ide_hwif_t *hwif,
361 unsigned long addr, int num) 351 unsigned long addr, int num)
362{ 352{
@@ -480,6 +470,7 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif)
480 470
481 hwif->tuneproc = tmp_hwif->tuneproc; 471 hwif->tuneproc = tmp_hwif->tuneproc;
482 hwif->speedproc = tmp_hwif->speedproc; 472 hwif->speedproc = tmp_hwif->speedproc;
473 hwif->udma_filter = tmp_hwif->udma_filter;
483 hwif->selectproc = tmp_hwif->selectproc; 474 hwif->selectproc = tmp_hwif->selectproc;
484 hwif->reset_poll = tmp_hwif->reset_poll; 475 hwif->reset_poll = tmp_hwif->reset_poll;
485 hwif->pre_reset = tmp_hwif->pre_reset; 476 hwif->pre_reset = tmp_hwif->pre_reset;
@@ -599,7 +590,7 @@ void ide_unregister(unsigned int index)
599 590
600 spin_unlock_irq(&ide_lock); 591 spin_unlock_irq(&ide_lock);
601 592
602 destroy_proc_ide_interface(hwif); 593 ide_proc_unregister_port(hwif);
603 594
604 hwgroup = hwif->hwgroup; 595 hwgroup = hwif->hwgroup;
605 /* 596 /*
@@ -751,6 +742,7 @@ void ide_setup_ports ( hw_regs_t *hw,
751/** 742/**
752 * ide_register_hw_with_fixup - register IDE interface 743 * ide_register_hw_with_fixup - register IDE interface
753 * @hw: hardware registers 744 * @hw: hardware registers
745 * @initializing: set while initializing built-in drivers
754 * @hwifp: pointer to returned hwif 746 * @hwifp: pointer to returned hwif
755 * @fixup: fixup function 747 * @fixup: fixup function
756 * 748 *
@@ -760,7 +752,9 @@ void ide_setup_ports ( hw_regs_t *hw,
760 * Returns -1 on error. 752 * Returns -1 on error.
761 */ 753 */
762 754
763int ide_register_hw_with_fixup(hw_regs_t *hw, ide_hwif_t **hwifp, void(*fixup)(ide_hwif_t *hwif)) 755int ide_register_hw_with_fixup(hw_regs_t *hw, int initializing,
756 ide_hwif_t **hwifp,
757 void(*fixup)(ide_hwif_t *hwif))
764{ 758{
765 int index, retry = 1; 759 int index, retry = 1;
766 ide_hwif_t *hwif; 760 ide_hwif_t *hwif;
@@ -801,7 +795,7 @@ found:
801 795
802 if (!initializing) { 796 if (!initializing) {
803 probe_hwif_init_with_fixup(hwif, fixup); 797 probe_hwif_init_with_fixup(hwif, fixup);
804 create_proc_ide_interfaces(); 798 ide_proc_register_port(hwif);
805 } 799 }
806 800
807 if (hwifp) 801 if (hwifp)
@@ -812,9 +806,9 @@ found:
812 806
813EXPORT_SYMBOL(ide_register_hw_with_fixup); 807EXPORT_SYMBOL(ide_register_hw_with_fixup);
814 808
815int ide_register_hw(hw_regs_t *hw, ide_hwif_t **hwifp) 809int ide_register_hw(hw_regs_t *hw, int initializing, ide_hwif_t **hwifp)
816{ 810{
817 return ide_register_hw_with_fixup(hw, hwifp, NULL); 811 return ide_register_hw_with_fixup(hw, initializing, hwifp, NULL);
818} 812}
819 813
820EXPORT_SYMBOL(ide_register_hw); 814EXPORT_SYMBOL(ide_register_hw);
@@ -825,205 +819,7 @@ EXPORT_SYMBOL(ide_register_hw);
825 819
826DECLARE_MUTEX(ide_setting_sem); 820DECLARE_MUTEX(ide_setting_sem);
827 821
828/** 822EXPORT_SYMBOL_GPL(ide_setting_sem);
829 * __ide_add_setting - add an ide setting option
830 * @drive: drive to use
831 * @name: setting name
832 * @rw: true if the function is read write
833 * @read_ioctl: function to call on read
834 * @write_ioctl: function to call on write
835 * @data_type: type of data
836 * @min: range minimum
837 * @max: range maximum
838 * @mul_factor: multiplication scale
839 * @div_factor: divison scale
840 * @data: private data field
841 * @set: setting
842 * @auto_remove: setting auto removal flag
843 *
844 * Removes the setting named from the device if it is present.
845 * The function takes the settings_lock to protect against
846 * parallel changes. This function must not be called from IRQ
847 * context. Returns 0 on success or -1 on failure.
848 *
849 * BUGS: This code is seriously over-engineered. There is also
850 * magic about how the driver specific features are setup. If
851 * a driver is attached we assume the driver settings are auto
852 * remove.
853 */
854
855static int __ide_add_setting(ide_drive_t *drive, const char *name, int rw, int read_ioctl, int write_ioctl, int data_type, int min, int max, int mul_factor, int div_factor, void *data, ide_procset_t *set, int auto_remove)
856{
857 ide_settings_t **p = (ide_settings_t **) &drive->settings, *setting = NULL;
858
859 down(&ide_setting_sem);
860 while ((*p) && strcmp((*p)->name, name) < 0)
861 p = &((*p)->next);
862 if ((setting = kzalloc(sizeof(*setting), GFP_KERNEL)) == NULL)
863 goto abort;
864 if ((setting->name = kmalloc(strlen(name) + 1, GFP_KERNEL)) == NULL)
865 goto abort;
866 strcpy(setting->name, name);
867 setting->rw = rw;
868 setting->read_ioctl = read_ioctl;
869 setting->write_ioctl = write_ioctl;
870 setting->data_type = data_type;
871 setting->min = min;
872 setting->max = max;
873 setting->mul_factor = mul_factor;
874 setting->div_factor = div_factor;
875 setting->data = data;
876 setting->set = set;
877
878 setting->next = *p;
879 if (auto_remove)
880 setting->auto_remove = 1;
881 *p = setting;
882 up(&ide_setting_sem);
883 return 0;
884abort:
885 up(&ide_setting_sem);
886 kfree(setting);
887 return -1;
888}
889
890int ide_add_setting(ide_drive_t *drive, const char *name, int rw, int read_ioctl, int write_ioctl, int data_type, int min, int max, int mul_factor, int div_factor, void *data, ide_procset_t *set)
891{
892 return __ide_add_setting(drive, name, rw, read_ioctl, write_ioctl, data_type, min, max, mul_factor, div_factor, data, set, 1);
893}
894
895EXPORT_SYMBOL(ide_add_setting);
896
897/**
898 * __ide_remove_setting - remove an ide setting option
899 * @drive: drive to use
900 * @name: setting name
901 *
902 * Removes the setting named from the device if it is present.
903 * The caller must hold the setting semaphore.
904 */
905
906static void __ide_remove_setting (ide_drive_t *drive, char *name)
907{
908 ide_settings_t **p, *setting;
909
910 p = (ide_settings_t **) &drive->settings;
911
912 while ((*p) && strcmp((*p)->name, name))
913 p = &((*p)->next);
914 if ((setting = (*p)) == NULL)
915 return;
916
917 (*p) = setting->next;
918
919 kfree(setting->name);
920 kfree(setting);
921}
922
923/**
924 * ide_find_setting_by_ioctl - find a drive specific ioctl
925 * @drive: drive to scan
926 * @cmd: ioctl command to handle
927 *
928 * Scan's the device setting table for a matching entry and returns
929 * this or NULL if no entry is found. The caller must hold the
930 * setting semaphore
931 */
932
933static ide_settings_t *ide_find_setting_by_ioctl (ide_drive_t *drive, int cmd)
934{
935 ide_settings_t *setting = drive->settings;
936
937 while (setting) {
938 if (setting->read_ioctl == cmd || setting->write_ioctl == cmd)
939 break;
940 setting = setting->next;
941 }
942
943 return setting;
944}
945
946/**
947 * ide_find_setting_by_name - find a drive specific setting
948 * @drive: drive to scan
949 * @name: setting name
950 *
951 * Scan's the device setting table for a matching entry and returns
952 * this or NULL if no entry is found. The caller must hold the
953 * setting semaphore
954 */
955
956ide_settings_t *ide_find_setting_by_name (ide_drive_t *drive, char *name)
957{
958 ide_settings_t *setting = drive->settings;
959
960 while (setting) {
961 if (strcmp(setting->name, name) == 0)
962 break;
963 setting = setting->next;
964 }
965 return setting;
966}
967
968/**
969 * auto_remove_settings - remove driver specific settings
970 * @drive: drive
971 *
972 * Automatically remove all the driver specific settings for this
973 * drive. This function may not be called from IRQ context. The
974 * caller must hold ide_setting_sem.
975 */
976
977static void auto_remove_settings (ide_drive_t *drive)
978{
979 ide_settings_t *setting;
980repeat:
981 setting = drive->settings;
982 while (setting) {
983 if (setting->auto_remove) {
984 __ide_remove_setting(drive, setting->name);
985 goto repeat;
986 }
987 setting = setting->next;
988 }
989}
990
991/**
992 * ide_read_setting - read an IDE setting
993 * @drive: drive to read from
994 * @setting: drive setting
995 *
996 * Read a drive setting and return the value. The caller
997 * must hold the ide_setting_sem when making this call.
998 *
999 * BUGS: the data return and error are the same return value
1000 * so an error -EINVAL and true return of the same value cannot
1001 * be told apart
1002 */
1003
1004int ide_read_setting (ide_drive_t *drive, ide_settings_t *setting)
1005{
1006 int val = -EINVAL;
1007 unsigned long flags;
1008
1009 if ((setting->rw & SETTING_READ)) {
1010 spin_lock_irqsave(&ide_lock, flags);
1011 switch(setting->data_type) {
1012 case TYPE_BYTE:
1013 val = *((u8 *) setting->data);
1014 break;
1015 case TYPE_SHORT:
1016 val = *((u16 *) setting->data);
1017 break;
1018 case TYPE_INT:
1019 case TYPE_INTA:
1020 val = *((u32 *) setting->data);
1021 break;
1022 }
1023 spin_unlock_irqrestore(&ide_lock, flags);
1024 }
1025 return val;
1026}
1027 823
1028/** 824/**
1029 * ide_spin_wait_hwgroup - wait for group 825 * ide_spin_wait_hwgroup - wait for group
@@ -1058,61 +854,14 @@ int ide_spin_wait_hwgroup (ide_drive_t *drive)
1058 854
1059EXPORT_SYMBOL(ide_spin_wait_hwgroup); 855EXPORT_SYMBOL(ide_spin_wait_hwgroup);
1060 856
1061/** 857int set_io_32bit(ide_drive_t *drive, int arg)
1062 * ide_write_setting - read an IDE setting
1063 * @drive: drive to read from
1064 * @setting: drive setting
1065 * @val: value
1066 *
1067 * Write a drive setting if it is possible. The caller
1068 * must hold the ide_setting_sem when making this call.
1069 *
1070 * BUGS: the data return and error are the same return value
1071 * so an error -EINVAL and true return of the same value cannot
1072 * be told apart
1073 *
1074 * FIXME: This should be changed to enqueue a special request
1075 * to the driver to change settings, and then wait on a sema for completion.
1076 * The current scheme of polling is kludgy, though safe enough.
1077 */
1078
1079int ide_write_setting (ide_drive_t *drive, ide_settings_t *setting, int val)
1080{ 858{
1081 int i; 859 if (drive->no_io_32bit)
1082 u32 *p;
1083
1084 if (!capable(CAP_SYS_ADMIN))
1085 return -EACCES;
1086 if (!(setting->rw & SETTING_WRITE))
1087 return -EPERM; 860 return -EPERM;
1088 if (val < setting->min || val > setting->max) 861
862 if (arg < 0 || arg > 1 + (SUPPORT_VLB_SYNC << 1))
1089 return -EINVAL; 863 return -EINVAL;
1090 if (setting->set)
1091 return setting->set(drive, val);
1092 if (ide_spin_wait_hwgroup(drive))
1093 return -EBUSY;
1094 switch (setting->data_type) {
1095 case TYPE_BYTE:
1096 *((u8 *) setting->data) = val;
1097 break;
1098 case TYPE_SHORT:
1099 *((u16 *) setting->data) = val;
1100 break;
1101 case TYPE_INT:
1102 *((u32 *) setting->data) = val;
1103 break;
1104 case TYPE_INTA:
1105 p = (u32 *) setting->data;
1106 for (i = 0; i < 1 << PARTN_BITS; i++, p++)
1107 *p = val;
1108 break;
1109 }
1110 spin_unlock_irq(&ide_lock);
1111 return 0;
1112}
1113 864
1114static int set_io_32bit(ide_drive_t *drive, int arg)
1115{
1116 drive->io_32bit = arg; 865 drive->io_32bit = arg;
1117#ifdef CONFIG_BLK_DEV_DTC2278 866#ifdef CONFIG_BLK_DEV_DTC2278
1118 if (HWIF(drive)->chipset == ide_dtc2278) 867 if (HWIF(drive)->chipset == ide_dtc2278)
@@ -1121,12 +870,28 @@ static int set_io_32bit(ide_drive_t *drive, int arg)
1121 return 0; 870 return 0;
1122} 871}
1123 872
1124static int set_using_dma (ide_drive_t *drive, int arg) 873static int set_ksettings(ide_drive_t *drive, int arg)
874{
875 if (arg < 0 || arg > 1)
876 return -EINVAL;
877
878 if (ide_spin_wait_hwgroup(drive))
879 return -EBUSY;
880 drive->keep_settings = arg;
881 spin_unlock_irq(&ide_lock);
882
883 return 0;
884}
885
886int set_using_dma(ide_drive_t *drive, int arg)
1125{ 887{
1126#ifdef CONFIG_BLK_DEV_IDEDMA 888#ifdef CONFIG_BLK_DEV_IDEDMA
1127 ide_hwif_t *hwif = drive->hwif; 889 ide_hwif_t *hwif = drive->hwif;
1128 int err = -EPERM; 890 int err = -EPERM;
1129 891
892 if (arg < 0 || arg > 1)
893 return -EINVAL;
894
1130 if (!drive->id || !(drive->id->capability & 1)) 895 if (!drive->id || !(drive->id->capability & 1))
1131 goto out; 896 goto out;
1132 897
@@ -1159,14 +924,20 @@ static int set_using_dma (ide_drive_t *drive, int arg)
1159out: 924out:
1160 return err; 925 return err;
1161#else 926#else
927 if (arg < 0 || arg > 1)
928 return -EINVAL;
929
1162 return -EPERM; 930 return -EPERM;
1163#endif 931#endif
1164} 932}
1165 933
1166static int set_pio_mode (ide_drive_t *drive, int arg) 934int set_pio_mode(ide_drive_t *drive, int arg)
1167{ 935{
1168 struct request rq; 936 struct request rq;
1169 937
938 if (arg < 0 || arg > 255)
939 return -EINVAL;
940
1170 if (!HWIF(drive)->tuneproc) 941 if (!HWIF(drive)->tuneproc)
1171 return -ENOSYS; 942 return -ENOSYS;
1172 if (drive->special.b.set_tune) 943 if (drive->special.b.set_tune)
@@ -1178,42 +949,20 @@ static int set_pio_mode (ide_drive_t *drive, int arg)
1178 return 0; 949 return 0;
1179} 950}
1180 951
1181static int set_xfer_rate (ide_drive_t *drive, int arg) 952static int set_unmaskirq(ide_drive_t *drive, int arg)
1182{ 953{
1183 int err = ide_wait_cmd(drive, 954 if (drive->no_unmask)
1184 WIN_SETFEATURES, (u8) arg, 955 return -EPERM;
1185 SETFEATURES_XFER, 0, NULL);
1186 956
1187 if (!err && arg) { 957 if (arg < 0 || arg > 1)
1188 ide_set_xfer_rate(drive, (u8) arg); 958 return -EINVAL;
1189 ide_driveid_update(drive);
1190 }
1191 return err;
1192}
1193 959
1194/** 960 if (ide_spin_wait_hwgroup(drive))
1195 * ide_add_generic_settings - generic ide settings 961 return -EBUSY;
1196 * @drive: drive being configured 962 drive->unmask = arg;
1197 * 963 spin_unlock_irq(&ide_lock);
1198 * Add the generic parts of the system settings to the /proc files and
1199 * ioctls for this IDE device. The caller must not be holding the
1200 * ide_setting_sem.
1201 */
1202 964
1203void ide_add_generic_settings (ide_drive_t *drive) 965 return 0;
1204{
1205/*
1206 * drive setting name read/write access read ioctl write ioctl data type min max mul_factor div_factor data pointer set function
1207 */
1208 __ide_add_setting(drive, "io_32bit", drive->no_io_32bit ? SETTING_READ : SETTING_RW, HDIO_GET_32BIT, HDIO_SET_32BIT, TYPE_BYTE, 0, 1 + (SUPPORT_VLB_SYNC << 1), 1, 1, &drive->io_32bit, set_io_32bit, 0);
1209 __ide_add_setting(drive, "keepsettings", SETTING_RW, HDIO_GET_KEEPSETTINGS, HDIO_SET_KEEPSETTINGS, TYPE_BYTE, 0, 1, 1, 1, &drive->keep_settings, NULL, 0);
1210 __ide_add_setting(drive, "nice1", SETTING_RW, -1, -1, TYPE_BYTE, 0, 1, 1, 1, &drive->nice1, NULL, 0);
1211 __ide_add_setting(drive, "pio_mode", SETTING_WRITE, -1, HDIO_SET_PIO_MODE, TYPE_BYTE, 0, 255, 1, 1, NULL, set_pio_mode, 0);
1212 __ide_add_setting(drive, "unmaskirq", drive->no_unmask ? SETTING_READ : SETTING_RW, HDIO_GET_UNMASKINTR, HDIO_SET_UNMASKINTR, TYPE_BYTE, 0, 1, 1, 1, &drive->unmask, NULL, 0);
1213 __ide_add_setting(drive, "using_dma", SETTING_RW, HDIO_GET_DMA, HDIO_SET_DMA, TYPE_BYTE, 0, 1, 1, 1, &drive->using_dma, set_using_dma, 0);
1214 __ide_add_setting(drive, "init_speed", SETTING_RW, -1, -1, TYPE_BYTE, 0, 70, 1, 1, &drive->init_speed, NULL, 0);
1215 __ide_add_setting(drive, "current_speed", SETTING_RW, -1, -1, TYPE_BYTE, 0, 70, 1, 1, &drive->current_speed, set_xfer_rate, 0);
1216 __ide_add_setting(drive, "number", SETTING_RW, -1, -1, TYPE_BYTE, 0, 3, 1, 1, &drive->dn, NULL, 0);
1217} 966}
1218 967
1219/** 968/**
@@ -1285,27 +1034,23 @@ static int generic_ide_resume(struct device *dev)
1285int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device *bdev, 1034int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device *bdev,
1286 unsigned int cmd, unsigned long arg) 1035 unsigned int cmd, unsigned long arg)
1287{ 1036{
1288 ide_settings_t *setting; 1037 unsigned long flags;
1289 ide_driver_t *drv; 1038 ide_driver_t *drv;
1290 int err = 0;
1291 void __user *p = (void __user *)arg; 1039 void __user *p = (void __user *)arg;
1040 int err = 0, (*setfunc)(ide_drive_t *, int);
1041 u8 *val;
1292 1042
1293 down(&ide_setting_sem); 1043 switch (cmd) {
1294 if ((setting = ide_find_setting_by_ioctl(drive, cmd)) != NULL) { 1044 case HDIO_GET_32BIT: val = &drive->io_32bit; goto read_val;
1295 if (cmd == setting->read_ioctl) { 1045 case HDIO_GET_KEEPSETTINGS: val = &drive->keep_settings; goto read_val;
1296 err = ide_read_setting(drive, setting); 1046 case HDIO_GET_UNMASKINTR: val = &drive->unmask; goto read_val;
1297 up(&ide_setting_sem); 1047 case HDIO_GET_DMA: val = &drive->using_dma; goto read_val;
1298 return err >= 0 ? put_user(err, (long __user *)arg) : err; 1048 case HDIO_SET_32BIT: setfunc = set_io_32bit; goto set_val;
1299 } else { 1049 case HDIO_SET_KEEPSETTINGS: setfunc = set_ksettings; goto set_val;
1300 if (bdev != bdev->bd_contains) 1050 case HDIO_SET_PIO_MODE: setfunc = set_pio_mode; goto set_val;
1301 err = -EINVAL; 1051 case HDIO_SET_UNMASKINTR: setfunc = set_unmaskirq; goto set_val;
1302 else 1052 case HDIO_SET_DMA: setfunc = set_using_dma; goto set_val;
1303 err = ide_write_setting(drive, setting, arg);
1304 up(&ide_setting_sem);
1305 return err;
1306 }
1307 } 1053 }
1308 up(&ide_setting_sem);
1309 1054
1310 switch (cmd) { 1055 switch (cmd) {
1311 case HDIO_OBSOLETE_IDENTITY: 1056 case HDIO_OBSOLETE_IDENTITY:
@@ -1359,7 +1104,7 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device
1359 ide_init_hwif_ports(&hw, (unsigned long) args[0], 1104 ide_init_hwif_ports(&hw, (unsigned long) args[0],
1360 (unsigned long) args[1], NULL); 1105 (unsigned long) args[1], NULL);
1361 hw.irq = args[2]; 1106 hw.irq = args[2];
1362 if (ide_register_hw(&hw, NULL) == -1) 1107 if (ide_register_hw(&hw, 0, NULL) == -1)
1363 return -EIO; 1108 return -EIO;
1364 return 0; 1109 return 0;
1365 } 1110 }
@@ -1434,6 +1179,28 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device
1434 default: 1179 default:
1435 return -EINVAL; 1180 return -EINVAL;
1436 } 1181 }
1182
1183read_val:
1184 down(&ide_setting_sem);
1185 spin_lock_irqsave(&ide_lock, flags);
1186 err = *val;
1187 spin_unlock_irqrestore(&ide_lock, flags);
1188 up(&ide_setting_sem);
1189 return err >= 0 ? put_user(err, (long __user *)arg) : err;
1190
1191set_val:
1192 if (bdev != bdev->bd_contains)
1193 err = -EINVAL;
1194 else {
1195 if (!capable(CAP_SYS_ADMIN))
1196 err = -EACCES;
1197 else {
1198 down(&ide_setting_sem);
1199 err = setfunc(drive, arg);
1200 up(&ide_setting_sem);
1201 }
1202 }
1203 return err;
1437} 1204}
1438 1205
1439EXPORT_SYMBOL(generic_ide_ioctl); 1206EXPORT_SYMBOL(generic_ide_ioctl);
@@ -1566,13 +1333,13 @@ static int __init ide_setup(char *s)
1566 return 1; 1333 return 1;
1567 } 1334 }
1568 1335
1569#ifdef CONFIG_BLK_DEV_IDEPCI 1336#ifdef CONFIG_IDEPCI_PCIBUS_ORDER
1570 if (!strcmp(s, "ide=reverse")) { 1337 if (!strcmp(s, "ide=reverse")) {
1571 ide_scan_direction = 1; 1338 ide_scan_direction = 1;
1572 printk(" : Enabled support for IDE inverse scan order.\n"); 1339 printk(" : Enabled support for IDE inverse scan order.\n");
1573 return 1; 1340 return 1;
1574 } 1341 }
1575#endif /* CONFIG_BLK_DEV_IDEPCI */ 1342#endif
1576 1343
1577#ifdef CONFIG_BLK_DEV_IDEACPI 1344#ifdef CONFIG_BLK_DEV_IDEACPI
1578 if (!strcmp(s, "ide=noacpi")) { 1345 if (!strcmp(s, "ide=noacpi")) {
@@ -1832,9 +1599,9 @@ extern void __init h8300_ide_init(void);
1832 */ 1599 */
1833static void __init probe_for_hwifs (void) 1600static void __init probe_for_hwifs (void)
1834{ 1601{
1835#ifdef CONFIG_BLK_DEV_IDEPCI 1602#ifdef CONFIG_IDEPCI_PCIBUS_ORDER
1836 ide_scan_pcibus(ide_scan_direction); 1603 ide_scan_pcibus(ide_scan_direction);
1837#endif /* CONFIG_BLK_DEV_IDEPCI */ 1604#endif
1838 1605
1839#ifdef CONFIG_ETRAX_IDE 1606#ifdef CONFIG_ETRAX_IDE
1840 { 1607 {
@@ -1892,54 +1659,6 @@ static void __init probe_for_hwifs (void)
1892#endif 1659#endif
1893} 1660}
1894 1661
1895void ide_register_subdriver(ide_drive_t *drive, ide_driver_t *driver)
1896{
1897#ifdef CONFIG_PROC_FS
1898 ide_add_proc_entries(drive->proc, driver->proc, drive);
1899#endif
1900}
1901
1902EXPORT_SYMBOL(ide_register_subdriver);
1903
1904/**
1905 * ide_unregister_subdriver - disconnect drive from driver
1906 * @drive: drive to unplug
1907 * @driver: driver
1908 *
1909 * Disconnect a drive from the driver it was attached to and then
1910 * clean up the various proc files and other objects attached to it.
1911 *
1912 * Takes ide_setting_sem and ide_lock.
1913 * Caller must hold none of the locks.
1914 */
1915
1916void ide_unregister_subdriver(ide_drive_t *drive, ide_driver_t *driver)
1917{
1918 unsigned long flags;
1919
1920#ifdef CONFIG_PROC_FS
1921 ide_remove_proc_entries(drive->proc, driver->proc);
1922#endif
1923 down(&ide_setting_sem);
1924 spin_lock_irqsave(&ide_lock, flags);
1925 /*
1926 * ide_setting_sem protects the settings list
1927 * ide_lock protects the use of settings
1928 *
1929 * so we need to hold both, ide_settings_sem because we want to
1930 * modify the settings list, and ide_lock because we cannot take
1931 * a setting out that is being used.
1932 *
1933 * OTOH both ide_{read,write}_setting are only ever used under
1934 * ide_setting_sem.
1935 */
1936 auto_remove_settings(drive);
1937 spin_unlock_irqrestore(&ide_lock, flags);
1938 up(&ide_setting_sem);
1939}
1940
1941EXPORT_SYMBOL(ide_unregister_subdriver);
1942
1943/* 1662/*
1944 * Probe module 1663 * Probe module
1945 */ 1664 */
@@ -2071,9 +1790,7 @@ static int __init ide_init(void)
2071 1790
2072 init_ide_data(); 1791 init_ide_data();
2073 1792
2074#ifdef CONFIG_PROC_FS 1793 proc_ide_create();
2075 proc_ide_root = proc_mkdir("ide", NULL);
2076#endif
2077 1794
2078#ifdef CONFIG_BLK_DEV_ALI14XX 1795#ifdef CONFIG_BLK_DEV_ALI14XX
2079 if (probe_ali14xx) 1796 if (probe_ali14xx)
@@ -2096,14 +1813,9 @@ static int __init ide_init(void)
2096 (void)qd65xx_init(); 1813 (void)qd65xx_init();
2097#endif 1814#endif
2098 1815
2099 initializing = 1;
2100 /* Probe for special PCI and other "known" interface chipsets. */ 1816 /* Probe for special PCI and other "known" interface chipsets. */
2101 probe_for_hwifs(); 1817 probe_for_hwifs();
2102 initializing = 0;
2103 1818
2104#ifdef CONFIG_PROC_FS
2105 proc_ide_create();
2106#endif
2107 return 0; 1819 return 0;
2108} 1820}
2109 1821
@@ -2143,9 +1855,7 @@ void __exit cleanup_module (void)
2143 pnpide_exit(); 1855 pnpide_exit();
2144#endif 1856#endif
2145 1857
2146#ifdef CONFIG_PROC_FS
2147 proc_ide_destroy(); 1858 proc_ide_destroy();
2148#endif
2149 1859
2150 bus_unregister(&ide_bus_type); 1860 bus_unregister(&ide_bus_type);
2151} 1861}
diff --git a/drivers/ide/legacy/ali14xx.c b/drivers/ide/legacy/ali14xx.c
index 91961aa03047..df17ed68c0bc 100644
--- a/drivers/ide/legacy/ali14xx.c
+++ b/drivers/ide/legacy/ali14xx.c
@@ -223,7 +223,8 @@ static int __init ali14xx_probe(void)
223 probe_hwif_init(hwif); 223 probe_hwif_init(hwif);
224 probe_hwif_init(mate); 224 probe_hwif_init(mate);
225 225
226 create_proc_ide_interfaces(); 226 ide_proc_register_port(hwif);
227 ide_proc_register_port(mate);
227 228
228 return 0; 229 return 0;
229} 230}
diff --git a/drivers/ide/legacy/buddha.c b/drivers/ide/legacy/buddha.c
index 1ed224a01f79..101aee1711c4 100644
--- a/drivers/ide/legacy/buddha.c
+++ b/drivers/ide/legacy/buddha.c
@@ -213,7 +213,7 @@ fail_base2:
213 IRQ_AMIGA_PORTS); 213 IRQ_AMIGA_PORTS);
214 } 214 }
215 215
216 index = ide_register_hw(&hw, &hwif); 216 index = ide_register_hw(&hw, 1, &hwif);
217 if (index != -1) { 217 if (index != -1) {
218 hwif->mmio = 1; 218 hwif->mmio = 1;
219 printk("ide%d: ", index); 219 printk("ide%d: ", index);
diff --git a/drivers/ide/legacy/dtc2278.c b/drivers/ide/legacy/dtc2278.c
index 0219ffa64db6..36a3f0ac6162 100644
--- a/drivers/ide/legacy/dtc2278.c
+++ b/drivers/ide/legacy/dtc2278.c
@@ -138,7 +138,8 @@ static int __init dtc2278_probe(void)
138 probe_hwif_init(hwif); 138 probe_hwif_init(hwif);
139 probe_hwif_init(mate); 139 probe_hwif_init(mate);
140 140
141 create_proc_ide_interfaces(); 141 ide_proc_register_port(hwif);
142 ide_proc_register_port(mate);
142 143
143 return 0; 144 return 0;
144} 145}
diff --git a/drivers/ide/legacy/falconide.c b/drivers/ide/legacy/falconide.c
index a9f2cd5bb81e..e1e9d9d6893f 100644
--- a/drivers/ide/legacy/falconide.c
+++ b/drivers/ide/legacy/falconide.c
@@ -70,7 +70,7 @@ void __init falconide_init(void)
70 0, 0, NULL, 70 0, 0, NULL,
71// falconide_iops, 71// falconide_iops,
72 IRQ_MFP_IDE); 72 IRQ_MFP_IDE);
73 index = ide_register_hw(&hw, NULL); 73 index = ide_register_hw(&hw, 1, NULL);
74 74
75 if (index != -1) 75 if (index != -1)
76 printk("ide%d: Falcon IDE interface\n", index); 76 printk("ide%d: Falcon IDE interface\n", index);
diff --git a/drivers/ide/legacy/gayle.c b/drivers/ide/legacy/gayle.c
index dcfadbbf55d8..0830a021bbb6 100644
--- a/drivers/ide/legacy/gayle.c
+++ b/drivers/ide/legacy/gayle.c
@@ -165,7 +165,7 @@ found:
165// &gayle_iops, 165// &gayle_iops,
166 IRQ_AMIGA_PORTS); 166 IRQ_AMIGA_PORTS);
167 167
168 index = ide_register_hw(&hw, &hwif); 168 index = ide_register_hw(&hw, 1, &hwif);
169 if (index != -1) { 169 if (index != -1) {
170 hwif->mmio = 1; 170 hwif->mmio = 1;
171 switch (i) { 171 switch (i) {
diff --git a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c
index a2832643c522..c8f353b1296f 100644
--- a/drivers/ide/legacy/ht6560b.c
+++ b/drivers/ide/legacy/ht6560b.c
@@ -357,7 +357,8 @@ int __init ht6560b_init(void)
357 probe_hwif_init(hwif); 357 probe_hwif_init(hwif);
358 probe_hwif_init(mate); 358 probe_hwif_init(mate);
359 359
360 create_proc_ide_interfaces(); 360 ide_proc_register_port(hwif);
361 ide_proc_register_port(mate);
361 362
362 return 0; 363 return 0;
363 364
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
index c6522a64d7ec..2f3977f195b7 100644
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/legacy/ide-cs.c
@@ -153,7 +153,7 @@ static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq
153 hw.irq = irq; 153 hw.irq = irq;
154 hw.chipset = ide_pci; 154 hw.chipset = ide_pci;
155 hw.dev = &handle->dev; 155 hw.dev = &handle->dev;
156 return ide_register_hw_with_fixup(&hw, NULL, ide_undecoded_slave); 156 return ide_register_hw_with_fixup(&hw, 0, NULL, ide_undecoded_slave);
157} 157}
158 158
159/*====================================================================== 159/*======================================================================
diff --git a/drivers/ide/legacy/macide.c b/drivers/ide/legacy/macide.c
index 4c0079ad52ac..c211fc78345d 100644
--- a/drivers/ide/legacy/macide.c
+++ b/drivers/ide/legacy/macide.c
@@ -102,21 +102,21 @@ void macide_init(void)
102 0, 0, macide_ack_intr, 102 0, 0, macide_ack_intr,
103// quadra_ide_iops, 103// quadra_ide_iops,
104 IRQ_NUBUS_F); 104 IRQ_NUBUS_F);
105 index = ide_register_hw(&hw, &hwif); 105 index = ide_register_hw(&hw, 1, &hwif);
106 break; 106 break;
107 case MAC_IDE_PB: 107 case MAC_IDE_PB:
108 ide_setup_ports(&hw, IDE_BASE, macide_offsets, 108 ide_setup_ports(&hw, IDE_BASE, macide_offsets,
109 0, 0, macide_ack_intr, 109 0, 0, macide_ack_intr,
110// macide_pb_iops, 110// macide_pb_iops,
111 IRQ_NUBUS_C); 111 IRQ_NUBUS_C);
112 index = ide_register_hw(&hw, &hwif); 112 index = ide_register_hw(&hw, 1, &hwif);
113 break; 113 break;
114 case MAC_IDE_BABOON: 114 case MAC_IDE_BABOON:
115 ide_setup_ports(&hw, BABOON_BASE, macide_offsets, 115 ide_setup_ports(&hw, BABOON_BASE, macide_offsets,
116 0, 0, NULL, 116 0, 0, NULL,
117// macide_baboon_iops, 117// macide_baboon_iops,
118 IRQ_BABOON_1); 118 IRQ_BABOON_1);
119 index = ide_register_hw(&hw, &hwif); 119 index = ide_register_hw(&hw, 1, &hwif);
120 if (index == -1) break; 120 if (index == -1) break;
121 if (macintosh_config->ident == MAC_MODEL_PB190) { 121 if (macintosh_config->ident == MAC_MODEL_PB190) {
122 122
diff --git a/drivers/ide/legacy/q40ide.c b/drivers/ide/legacy/q40ide.c
index 74f08124eabb..e628a983ce33 100644
--- a/drivers/ide/legacy/q40ide.c
+++ b/drivers/ide/legacy/q40ide.c
@@ -142,7 +142,7 @@ void q40ide_init(void)
142 0, NULL, 142 0, NULL,
143// m68kide_iops, 143// m68kide_iops,
144 q40ide_default_irq(pcide_bases[i])); 144 q40ide_default_irq(pcide_bases[i]));
145 index = ide_register_hw(&hw, &hwif); 145 index = ide_register_hw(&hw, 1, &hwif);
146 // **FIXME** 146 // **FIXME**
147 if (index != -1) 147 if (index != -1)
148 hwif->mmio = 1; 148 hwif->mmio = 1;
diff --git a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c
index 2fb8f50f1293..d1414a75b523 100644
--- a/drivers/ide/legacy/qd65xx.c
+++ b/drivers/ide/legacy/qd65xx.c
@@ -427,7 +427,7 @@ static int __init qd_probe(int base)
427 qd_setup(hwif, base, config, QD6500_DEF_DATA, QD6500_DEF_DATA, 427 qd_setup(hwif, base, config, QD6500_DEF_DATA, QD6500_DEF_DATA,
428 &qd6500_tune_drive); 428 &qd6500_tune_drive);
429 429
430 create_proc_ide_interfaces(); 430 ide_proc_register_port(hwif);
431 431
432 return 1; 432 return 1;
433 } 433 }
@@ -459,7 +459,7 @@ static int __init qd_probe(int base)
459 &qd6580_tune_drive); 459 &qd6580_tune_drive);
460 qd_write_reg(QD_DEF_CONTR,QD_CONTROL_PORT); 460 qd_write_reg(QD_DEF_CONTR,QD_CONTROL_PORT);
461 461
462 create_proc_ide_interfaces(); 462 ide_proc_register_port(hwif);
463 463
464 return 1; 464 return 1;
465 } else { 465 } else {
@@ -479,7 +479,8 @@ static int __init qd_probe(int base)
479 &qd6580_tune_drive); 479 &qd6580_tune_drive);
480 qd_write_reg(QD_DEF_CONTR,QD_CONTROL_PORT); 480 qd_write_reg(QD_DEF_CONTR,QD_CONTROL_PORT);
481 481
482 create_proc_ide_interfaces(); 482 ide_proc_register_port(hwif);
483 ide_proc_register_port(mate);
483 484
484 return 0; /* no other qd65xx possible */ 485 return 0; /* no other qd65xx possible */
485 } 486 }
diff --git a/drivers/ide/legacy/umc8672.c b/drivers/ide/legacy/umc8672.c
index ca7974455578..ddc403a0bd82 100644
--- a/drivers/ide/legacy/umc8672.c
+++ b/drivers/ide/legacy/umc8672.c
@@ -160,7 +160,8 @@ static int __init umc8672_probe(void)
160 probe_hwif_init(hwif); 160 probe_hwif_init(hwif);
161 probe_hwif_init(mate); 161 probe_hwif_init(mate);
162 162
163 create_proc_ide_interfaces(); 163 ide_proc_register_port(hwif);
164 ide_proc_register_port(mate);
164 165
165 return 0; 166 return 0;
166} 167}
diff --git a/drivers/ide/mips/au1xxx-ide.c b/drivers/ide/mips/au1xxx-ide.c
index d54d9fe92a7d..ca95e990862e 100644
--- a/drivers/ide/mips/au1xxx-ide.c
+++ b/drivers/ide/mips/au1xxx-ide.c
@@ -760,6 +760,9 @@ static int au_ide_probe(struct device *dev)
760#endif 760#endif
761 761
762 probe_hwif_init(hwif); 762 probe_hwif_init(hwif);
763
764 ide_proc_register_port(hwif);
765
763 dev_set_drvdata(dev, hwif); 766 dev_set_drvdata(dev, hwif);
764 767
765 printk(KERN_INFO "Au1xxx IDE(builtin) configured for %s\n", mode ); 768 printk(KERN_INFO "Au1xxx IDE(builtin) configured for %s\n", mode );
diff --git a/drivers/ide/mips/swarm.c b/drivers/ide/mips/swarm.c
index 81fa06851b27..6e935d7c63fd 100644
--- a/drivers/ide/mips/swarm.c
+++ b/drivers/ide/mips/swarm.c
@@ -129,6 +129,9 @@ static int __devinit swarm_ide_probe(struct device *dev)
129 hwif->irq = hwif->hw.irq; 129 hwif->irq = hwif->hw.irq;
130 130
131 probe_hwif_init(hwif); 131 probe_hwif_init(hwif);
132
133 ide_proc_register_port(hwif);
134
132 dev_set_drvdata(dev, hwif); 135 dev_set_drvdata(dev, hwif);
133 136
134 return 0; 137 return 0;
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c
index 73bdf64dbbfc..b173bc66ce1e 100644
--- a/drivers/ide/pci/aec62xx.c
+++ b/drivers/ide/pci/aec62xx.c
@@ -87,38 +87,12 @@ static u8 pci_bus_clock_list_ultra (u8 speed, struct chipset_bus_clock_list_entr
87 return chipset_table->ultra_settings; 87 return chipset_table->ultra_settings;
88} 88}
89 89
90static u8 aec62xx_ratemask (ide_drive_t *drive)
91{
92 ide_hwif_t *hwif = HWIF(drive);
93 u8 mode;
94
95 switch(hwif->pci_dev->device) {
96 case PCI_DEVICE_ID_ARTOP_ATP865:
97 case PCI_DEVICE_ID_ARTOP_ATP865R:
98 mode = (inb(hwif->channel ?
99 hwif->mate->dma_status :
100 hwif->dma_status) & 0x10) ? 4 : 3;
101 break;
102 case PCI_DEVICE_ID_ARTOP_ATP860:
103 case PCI_DEVICE_ID_ARTOP_ATP860R:
104 mode = 2;
105 break;
106 case PCI_DEVICE_ID_ARTOP_ATP850UF:
107 default:
108 return 1;
109 }
110
111 if (!eighty_ninty_three(drive))
112 mode = min(mode, (u8)1);
113 return mode;
114}
115
116static int aec6210_tune_chipset (ide_drive_t *drive, u8 xferspeed) 90static int aec6210_tune_chipset (ide_drive_t *drive, u8 xferspeed)
117{ 91{
118 ide_hwif_t *hwif = HWIF(drive); 92 ide_hwif_t *hwif = HWIF(drive);
119 struct pci_dev *dev = hwif->pci_dev; 93 struct pci_dev *dev = hwif->pci_dev;
120 u16 d_conf = 0; 94 u16 d_conf = 0;
121 u8 speed = ide_rate_filter(aec62xx_ratemask(drive), xferspeed); 95 u8 speed = ide_rate_filter(drive, xferspeed);
122 u8 ultra = 0, ultra_conf = 0; 96 u8 ultra = 0, ultra_conf = 0;
123 u8 tmp0 = 0, tmp1 = 0, tmp2 = 0; 97 u8 tmp0 = 0, tmp1 = 0, tmp2 = 0;
124 unsigned long flags; 98 unsigned long flags;
@@ -145,7 +119,7 @@ static int aec6260_tune_chipset (ide_drive_t *drive, u8 xferspeed)
145{ 119{
146 ide_hwif_t *hwif = HWIF(drive); 120 ide_hwif_t *hwif = HWIF(drive);
147 struct pci_dev *dev = hwif->pci_dev; 121 struct pci_dev *dev = hwif->pci_dev;
148 u8 speed = ide_rate_filter(aec62xx_ratemask(drive), xferspeed); 122 u8 speed = ide_rate_filter(drive, xferspeed);
149 u8 unit = (drive->select.b.unit & 0x01); 123 u8 unit = (drive->select.b.unit & 0x01);
150 u8 tmp1 = 0, tmp2 = 0; 124 u8 tmp1 = 0, tmp2 = 0;
151 u8 ultra = 0, drive_conf = 0, ultra_conf = 0; 125 u8 ultra = 0, drive_conf = 0, ultra_conf = 0;
@@ -181,17 +155,6 @@ static int aec62xx_tune_chipset (ide_drive_t *drive, u8 speed)
181 } 155 }
182} 156}
183 157
184static int config_chipset_for_dma (ide_drive_t *drive)
185{
186 u8 speed = ide_dma_speed(drive, aec62xx_ratemask(drive));
187
188 if (!(speed))
189 return 0;
190
191 (void) aec62xx_tune_chipset(drive, speed);
192 return ide_dma_enable(drive);
193}
194
195static void aec62xx_tune_drive (ide_drive_t *drive, u8 pio) 158static void aec62xx_tune_drive (ide_drive_t *drive, u8 pio)
196{ 159{
197 pio = ide_get_best_pio_mode(drive, pio, 4, NULL); 160 pio = ide_get_best_pio_mode(drive, pio, 4, NULL);
@@ -200,7 +163,7 @@ static void aec62xx_tune_drive (ide_drive_t *drive, u8 pio)
200 163
201static int aec62xx_config_drive_xfer_rate (ide_drive_t *drive) 164static int aec62xx_config_drive_xfer_rate (ide_drive_t *drive)
202{ 165{
203 if (ide_use_dma(drive) && config_chipset_for_dma(drive)) 166 if (ide_tune_dma(drive))
204 return 0; 167 return 0;
205 168
206 if (ide_use_fast_pio(drive)) 169 if (ide_use_fast_pio(drive))
@@ -261,11 +224,13 @@ static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const ch
261 224
262static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif) 225static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif)
263{ 226{
227 struct pci_dev *dev = hwif->pci_dev;
228
264 hwif->autodma = 0; 229 hwif->autodma = 0;
265 hwif->tuneproc = &aec62xx_tune_drive; 230 hwif->tuneproc = &aec62xx_tune_drive;
266 hwif->speedproc = &aec62xx_tune_chipset; 231 hwif->speedproc = &aec62xx_tune_chipset;
267 232
268 if (hwif->pci_dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF) 233 if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF)
269 hwif->serialized = hwif->channel; 234 hwif->serialized = hwif->channel;
270 235
271 if (hwif->mate) 236 if (hwif->mate)
@@ -277,7 +242,15 @@ static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif)
277 return; 242 return;
278 } 243 }
279 244
280 hwif->ultra_mask = 0x7f; 245 hwif->ultra_mask = hwif->cds->udma_mask;
246
247 /* atp865 and atp865r */
248 if (hwif->ultra_mask == 0x3f) {
249 /* check bit 0x10 of DMA status register */
250 if (inb(pci_resource_start(dev, 4) + 2) & 0x10)
251 hwif->ultra_mask = 0x7f; /* udma0-6 */
252 }
253
281 hwif->mwdma_mask = 0x07; 254 hwif->mwdma_mask = 0x07;
282 255
283 hwif->ide_dma_check = &aec62xx_config_drive_xfer_rate; 256 hwif->ide_dma_check = &aec62xx_config_drive_xfer_rate;
@@ -344,6 +317,7 @@ static ide_pci_device_t aec62xx_chipsets[] __devinitdata = {
344 .autodma = AUTODMA, 317 .autodma = AUTODMA,
345 .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, 318 .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},
346 .bootable = OFF_BOARD, 319 .bootable = OFF_BOARD,
320 .udma_mask = 0x07, /* udma0-2 */
347 },{ /* 1 */ 321 },{ /* 1 */
348 .name = "AEC6260", 322 .name = "AEC6260",
349 .init_setup = init_setup_aec62xx, 323 .init_setup = init_setup_aec62xx,
@@ -353,6 +327,7 @@ static ide_pci_device_t aec62xx_chipsets[] __devinitdata = {
353 .channels = 2, 327 .channels = 2,
354 .autodma = NOAUTODMA, 328 .autodma = NOAUTODMA,
355 .bootable = OFF_BOARD, 329 .bootable = OFF_BOARD,
330 .udma_mask = 0x1f, /* udma0-4 */
356 },{ /* 2 */ 331 },{ /* 2 */
357 .name = "AEC6260R", 332 .name = "AEC6260R",
358 .init_setup = init_setup_aec62xx, 333 .init_setup = init_setup_aec62xx,
@@ -363,6 +338,7 @@ static ide_pci_device_t aec62xx_chipsets[] __devinitdata = {
363 .autodma = AUTODMA, 338 .autodma = AUTODMA,
364 .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, 339 .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},
365 .bootable = NEVER_BOARD, 340 .bootable = NEVER_BOARD,
341 .udma_mask = 0x1f, /* udma0-4 */
366 },{ /* 3 */ 342 },{ /* 3 */
367 .name = "AEC6X80", 343 .name = "AEC6X80",
368 .init_setup = init_setup_aec6x80, 344 .init_setup = init_setup_aec6x80,
@@ -372,6 +348,7 @@ static ide_pci_device_t aec62xx_chipsets[] __devinitdata = {
372 .channels = 2, 348 .channels = 2,
373 .autodma = AUTODMA, 349 .autodma = AUTODMA,
374 .bootable = OFF_BOARD, 350 .bootable = OFF_BOARD,
351 .udma_mask = 0x3f, /* udma0-5 */
375 },{ /* 4 */ 352 },{ /* 4 */
376 .name = "AEC6X80R", 353 .name = "AEC6X80R",
377 .init_setup = init_setup_aec6x80, 354 .init_setup = init_setup_aec6x80,
@@ -382,6 +359,7 @@ static ide_pci_device_t aec62xx_chipsets[] __devinitdata = {
382 .autodma = AUTODMA, 359 .autodma = AUTODMA,
383 .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, 360 .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},
384 .bootable = OFF_BOARD, 361 .bootable = OFF_BOARD,
362 .udma_mask = 0x3f, /* udma0-5 */
385 } 363 }
386}; 364};
387 365
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c
index 946a12746cb5..428efdae0c7b 100644
--- a/drivers/ide/pci/alim15x3.c
+++ b/drivers/ide/pci/alim15x3.c
@@ -50,7 +50,7 @@ static u8 m5229_revision;
50static u8 chip_is_1543c_e; 50static u8 chip_is_1543c_e;
51static struct pci_dev *isa_dev; 51static struct pci_dev *isa_dev;
52 52
53#if defined(DISPLAY_ALI_TIMINGS) && defined(CONFIG_PROC_FS) 53#if defined(DISPLAY_ALI_TIMINGS) && defined(CONFIG_IDE_PROC_FS)
54#include <linux/stat.h> 54#include <linux/stat.h>
55#include <linux/proc_fs.h> 55#include <linux/proc_fs.h>
56 56
@@ -278,7 +278,7 @@ static int ali_get_info (char *buffer, char **addr, off_t offset, int count)
278 278
279 return p-buffer; /* => must be less than 4k! */ 279 return p-buffer; /* => must be less than 4k! */
280} 280}
281#endif /* defined(DISPLAY_ALI_TIMINGS) && defined(CONFIG_PROC_FS) */ 281#endif /* defined(DISPLAY_ALI_TIMINGS) && defined(CONFIG_IDE_PROC_FS) */
282 282
283/** 283/**
284 * ali15x3_tune_pio - set up chipset for PIO mode 284 * ali15x3_tune_pio - set up chipset for PIO mode
@@ -378,74 +378,31 @@ static void ali15x3_tune_drive (ide_drive_t *drive, u8 pio)
378} 378}
379 379
380/** 380/**
381 * ali15x3_can_ultra - check for ultra DMA support 381 * ali_udma_filter - compute UDMA mask
382 * @drive: drive to do the check 382 * @drive: IDE device
383 * 383 *
384 * Check the drive and controller revisions. Return 0 if UDMA is 384 * Return available UDMA modes.
385 * not available, or 1 if UDMA can be used. The actual rules for 385 *
386 * the ALi are 386 * The actual rules for the ALi are:
387 * No UDMA on revisions <= 0x20 387 * No UDMA on revisions <= 0x20
388 * Disk only for revisions < 0xC2 388 * Disk only for revisions < 0xC2
389 * Not WDC drives for revisions < 0xC2 389 * Not WDC drives for revisions < 0xC2
390 * 390 *
391 * FIXME: WDC ifdef needs to die 391 * FIXME: WDC ifdef needs to die
392 */ 392 */
393
394static u8 ali15x3_can_ultra (ide_drive_t *drive)
395{
396#ifndef CONFIG_WDC_ALI15X3
397 struct hd_driveid *id = drive->id;
398#endif /* CONFIG_WDC_ALI15X3 */
399 393
400 if (m5229_revision <= 0x20) { 394static u8 ali_udma_filter(ide_drive_t *drive)
401 return 0;
402 } else if ((m5229_revision < 0xC2) &&
403#ifndef CONFIG_WDC_ALI15X3
404 ((chip_is_1543c_e && strstr(id->model, "WDC ")) ||
405 (drive->media!=ide_disk))) {
406#else /* CONFIG_WDC_ALI15X3 */
407 (drive->media!=ide_disk)) {
408#endif /* CONFIG_WDC_ALI15X3 */
409 return 0;
410 } else {
411 return 1;
412 }
413}
414
415/**
416 * ali15x3_ratemask - generate DMA mode list
417 * @drive: drive to compute against
418 *
419 * Generate a list of the available DMA modes for the drive.
420 * FIXME: this function contains lots of bogus masking we can dump
421 *
422 * Return the highest available mode (UDMA33, UDMA66, UDMA100,..)
423 */
424
425static u8 ali15x3_ratemask (ide_drive_t *drive)
426{ 395{
427 u8 mode = 0, can_ultra = ali15x3_can_ultra(drive); 396 if (m5229_revision > 0x20 && m5229_revision < 0xC2) {
428 397 if (drive->media != ide_disk)
429 if (m5229_revision > 0xC4 && can_ultra) { 398 return 0;
430 mode = 4; 399#ifndef CONFIG_WDC_ALI15X3
431 } else if (m5229_revision == 0xC4 && can_ultra) { 400 if (chip_is_1543c_e && strstr(drive->id->model, "WDC "))
432 mode = 3; 401 return 0;
433 } else if (m5229_revision >= 0xC2 && can_ultra) { 402#endif
434 mode = 2;
435 } else if (can_ultra) {
436 return 1;
437 } else {
438 return 0;
439 } 403 }
440 404
441 /* 405 return drive->hwif->ultra_mask;
442 * If the drive sees no suitable cable then UDMA 33
443 * is the highest permitted mode
444 */
445
446 if (!eighty_ninty_three(drive))
447 mode = min(mode, (u8)1);
448 return mode;
449} 406}
450 407
451/** 408/**
@@ -461,7 +418,7 @@ static int ali15x3_tune_chipset (ide_drive_t *drive, u8 xferspeed)
461{ 418{
462 ide_hwif_t *hwif = HWIF(drive); 419 ide_hwif_t *hwif = HWIF(drive);
463 struct pci_dev *dev = hwif->pci_dev; 420 struct pci_dev *dev = hwif->pci_dev;
464 u8 speed = ide_rate_filter(ali15x3_ratemask(drive), xferspeed); 421 u8 speed = ide_rate_filter(drive, xferspeed);
465 u8 speed1 = speed; 422 u8 speed1 = speed;
466 u8 unit = (drive->select.b.unit & 0x01); 423 u8 unit = (drive->select.b.unit & 0x01);
467 u8 tmpbyte = 0x00; 424 u8 tmpbyte = 0x00;
@@ -511,7 +468,7 @@ static int ali15x3_tune_chipset (ide_drive_t *drive, u8 xferspeed)
511 468
512static int config_chipset_for_dma (ide_drive_t *drive) 469static int config_chipset_for_dma (ide_drive_t *drive)
513{ 470{
514 u8 speed = ide_dma_speed(drive, ali15x3_ratemask(drive)); 471 u8 speed = ide_max_dma_mode(drive);
515 472
516 if (!(speed)) 473 if (!(speed))
517 return 0; 474 return 0;
@@ -609,13 +566,13 @@ static unsigned int __devinit init_chipset_ali15x3 (struct pci_dev *dev, const c
609 566
610 isa_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); 567 isa_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL);
611 568
612#if defined(DISPLAY_ALI_TIMINGS) && defined(CONFIG_PROC_FS) 569#if defined(DISPLAY_ALI_TIMINGS) && defined(CONFIG_IDE_PROC_FS)
613 if (!ali_proc) { 570 if (!ali_proc) {
614 ali_proc = 1; 571 ali_proc = 1;
615 bmide_dev = dev; 572 bmide_dev = dev;
616 ide_pci_create_host_proc("ali", ali_get_info); 573 ide_pci_create_host_proc("ali", ali_get_info);
617 } 574 }
618#endif /* defined(DISPLAY_ALI_TIMINGS) && defined(CONFIG_PROC_FS) */ 575#endif /* defined(DISPLAY_ALI_TIMINGS) && defined(CONFIG_IDE_PROC_FS) */
619 576
620 local_irq_save(flags); 577 local_irq_save(flags);
621 578
@@ -771,6 +728,7 @@ static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif)
771 hwif->autodma = 0; 728 hwif->autodma = 0;
772 hwif->tuneproc = &ali15x3_tune_drive; 729 hwif->tuneproc = &ali15x3_tune_drive;
773 hwif->speedproc = &ali15x3_tune_chipset; 730 hwif->speedproc = &ali15x3_tune_chipset;
731 hwif->udma_filter = &ali_udma_filter;
774 732
775 /* don't use LBA48 DMA on ALi devices before rev 0xC5 */ 733 /* don't use LBA48 DMA on ALi devices before rev 0xC5 */
776 hwif->no_lba48_dma = (m5229_revision <= 0xC4) ? 1 : 0; 734 hwif->no_lba48_dma = (m5229_revision <= 0xC4) ? 1 : 0;
@@ -783,8 +741,17 @@ static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif)
783 741
784 hwif->atapi_dma = 1; 742 hwif->atapi_dma = 1;
785 743
786 if (m5229_revision > 0x20) 744 if (m5229_revision <= 0x20)
787 hwif->ultra_mask = 0x7f; 745 hwif->ultra_mask = 0x00; /* no udma */
746 else if (m5229_revision < 0xC2)
747 hwif->ultra_mask = 0x07; /* udma0-2 */
748 else if (m5229_revision == 0xC2 || m5229_revision == 0xC3)
749 hwif->ultra_mask = 0x1f; /* udma0-4 */
750 else if (m5229_revision == 0xC4)
751 hwif->ultra_mask = 0x3f; /* udma0-5 */
752 else
753 hwif->ultra_mask = 0x7f; /* udma0-6 */
754
788 hwif->mwdma_mask = 0x07; 755 hwif->mwdma_mask = 0x07;
789 hwif->swdma_mask = 0x07; 756 hwif->swdma_mask = 0x07;
790 757
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c
index 7989bdd842a2..becb1a5648b0 100644
--- a/drivers/ide/pci/amd74xx.c
+++ b/drivers/ide/pci/amd74xx.c
@@ -92,7 +92,7 @@ static unsigned char amd_cyc2udma[] = { 6, 6, 5, 4, 0, 1, 1, 2, 2, 3, 3, 3, 3, 3
92 * AMD /proc entry. 92 * AMD /proc entry.
93 */ 93 */
94 94
95#ifdef CONFIG_PROC_FS 95#ifdef CONFIG_IDE_PROC_FS
96 96
97#include <linux/stat.h> 97#include <linux/stat.h>
98#include <linux/proc_fs.h> 98#include <linux/proc_fs.h>
@@ -402,14 +402,14 @@ static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev, const ch
402 * Register /proc/ide/amd74xx entry 402 * Register /proc/ide/amd74xx entry
403 */ 403 */
404 404
405#if defined(DISPLAY_AMD_TIMINGS) && defined(CONFIG_PROC_FS) 405#if defined(DISPLAY_AMD_TIMINGS) && defined(CONFIG_IDE_PROC_FS)
406 if (!amd74xx_proc) { 406 if (!amd74xx_proc) {
407 amd_base = pci_resource_start(dev, 4); 407 amd_base = pci_resource_start(dev, 4);
408 bmide_dev = dev; 408 bmide_dev = dev;
409 ide_pci_create_host_proc("amd74xx", amd74xx_get_info); 409 ide_pci_create_host_proc("amd74xx", amd74xx_get_info);
410 amd74xx_proc = 1; 410 amd74xx_proc = 1;
411 } 411 }
412#endif /* DISPLAY_AMD_TIMINGS && CONFIG_PROC_FS */ 412#endif /* DISPLAY_AMD_TIMINGS && CONFIG_IDE_PROC_FS */
413 413
414 return dev->irq; 414 return dev->irq;
415} 415}
diff --git a/drivers/ide/pci/atiixp.c b/drivers/ide/pci/atiixp.c
index 2d48af32e3f4..0e52ad722a72 100644
--- a/drivers/ide/pci/atiixp.c
+++ b/drivers/ide/pci/atiixp.c
@@ -49,22 +49,6 @@ static int save_mdma_mode[4];
49static DEFINE_SPINLOCK(atiixp_lock); 49static DEFINE_SPINLOCK(atiixp_lock);
50 50
51/** 51/**
52 * atiixp_ratemask - compute rate mask for ATIIXP IDE
53 * @drive: IDE drive to compute for
54 *
55 * Returns the available modes for the ATIIXP IDE controller.
56 */
57
58static u8 atiixp_ratemask(ide_drive_t *drive)
59{
60 u8 mode = 3;
61
62 if (!eighty_ninty_three(drive))
63 mode = min(mode, (u8)1);
64 return mode;
65}
66
67/**
68 * atiixp_dma_2_pio - return the PIO mode matching DMA 52 * atiixp_dma_2_pio - return the PIO mode matching DMA
69 * @xfer_rate: transfer speed 53 * @xfer_rate: transfer speed
70 * 54 *
@@ -189,7 +173,7 @@ static int atiixp_speedproc(ide_drive_t *drive, u8 xferspeed)
189 u16 tmp16; 173 u16 tmp16;
190 u8 speed, pio; 174 u8 speed, pio;
191 175
192 speed = ide_rate_filter(atiixp_ratemask(drive), xferspeed); 176 speed = ide_rate_filter(drive, xferspeed);
193 177
194 spin_lock_irqsave(&atiixp_lock, flags); 178 spin_lock_irqsave(&atiixp_lock, flags);
195 179
@@ -223,26 +207,6 @@ static int atiixp_speedproc(ide_drive_t *drive, u8 xferspeed)
223} 207}
224 208
225/** 209/**
226 * atiixp_config_drive_for_dma - configure drive for DMA
227 * @drive: IDE drive to configure
228 *
229 * Set up a ATIIXP interface channel for the best available speed.
230 * We prefer UDMA if it is available and then MWDMA. If DMA is
231 * not available we switch to PIO and return 0.
232 */
233
234static int atiixp_config_drive_for_dma(ide_drive_t *drive)
235{
236 u8 speed = ide_dma_speed(drive, atiixp_ratemask(drive));
237
238 if (!speed)
239 return 0;
240
241 (void) atiixp_speedproc(drive, speed);
242 return ide_dma_enable(drive);
243}
244
245/**
246 * atiixp_dma_check - set up an IDE device 210 * atiixp_dma_check - set up an IDE device
247 * @drive: IDE drive to configure 211 * @drive: IDE drive to configure
248 * 212 *
@@ -256,7 +220,7 @@ static int atiixp_dma_check(ide_drive_t *drive)
256 220
257 drive->init_speed = 0; 221 drive->init_speed = 0;
258 222
259 if (ide_use_dma(drive) && atiixp_config_drive_for_dma(drive)) 223 if (ide_tune_dma(drive))
260 return 0; 224 return 0;
261 225
262 if (ide_use_fast_pio(drive)) { 226 if (ide_use_fast_pio(drive)) {
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c
index 77f51ab6d439..61ea96b5555c 100644
--- a/drivers/ide/pci/cmd64x.c
+++ b/drivers/ide/pci/cmd64x.c
@@ -74,7 +74,7 @@
74#define UDIDETCR1 0x7B 74#define UDIDETCR1 0x7B
75#define DTPR1 0x7C 75#define DTPR1 0x7C
76 76
77#if defined(DISPLAY_CMD64X_TIMINGS) && defined(CONFIG_PROC_FS) 77#if defined(DISPLAY_CMD64X_TIMINGS) && defined(CONFIG_IDE_PROC_FS)
78#include <linux/stat.h> 78#include <linux/stat.h>
79#include <linux/proc_fs.h> 79#include <linux/proc_fs.h>
80 80
@@ -165,7 +165,7 @@ static int cmd64x_get_info (char *buffer, char **addr, off_t offset, int count)
165 return p-buffer; /* => must be less than 4k! */ 165 return p-buffer; /* => must be less than 4k! */
166} 166}
167 167
168#endif /* defined(DISPLAY_CMD64X_TIMINGS) && defined(CONFIG_PROC_FS) */ 168#endif /* defined(DISPLAY_CMD64X_TIMINGS) && defined(CONFIG_IDE_PROC_FS) */
169 169
170static u8 quantize_timing(int timing, int quant) 170static u8 quantize_timing(int timing, int quant)
171{ 171{
@@ -292,55 +292,6 @@ static void cmd64x_tune_drive (ide_drive_t *drive, u8 pio)
292 (void) ide_config_drive_speed(drive, XFER_PIO_0 + pio); 292 (void) ide_config_drive_speed(drive, XFER_PIO_0 + pio);
293} 293}
294 294
295static u8 cmd64x_ratemask (ide_drive_t *drive)
296{
297 struct pci_dev *dev = HWIF(drive)->pci_dev;
298 u8 mode = 0;
299
300 switch(dev->device) {
301 case PCI_DEVICE_ID_CMD_649:
302 mode = 3;
303 break;
304 case PCI_DEVICE_ID_CMD_648:
305 mode = 2;
306 break;
307 case PCI_DEVICE_ID_CMD_643:
308 return 0;
309
310 case PCI_DEVICE_ID_CMD_646:
311 {
312 unsigned int class_rev = 0;
313 pci_read_config_dword(dev,
314 PCI_CLASS_REVISION, &class_rev);
315 class_rev &= 0xff;
316 /*
317 * UltraDMA only supported on PCI646U and PCI646U2, which
318 * correspond to revisions 0x03, 0x05 and 0x07 respectively.
319 * Actually, although the CMD tech support people won't
320 * tell me the details, the 0x03 revision cannot support
321 * UDMA correctly without hardware modifications, and even
322 * then it only works with Quantum disks due to some
323 * hold time assumptions in the 646U part which are fixed
324 * in the 646U2.
325 *
326 * So we only do UltraDMA on revision 0x05 and 0x07 chipsets.
327 */
328 switch(class_rev) {
329 case 0x07:
330 case 0x05:
331 return 1;
332 case 0x03:
333 case 0x01:
334 default:
335 return 0;
336 }
337 }
338 }
339 if (!eighty_ninty_three(drive))
340 mode = min(mode, (u8)1);
341 return mode;
342}
343
344static int cmd64x_tune_chipset (ide_drive_t *drive, u8 speed) 295static int cmd64x_tune_chipset (ide_drive_t *drive, u8 speed)
345{ 296{
346 ide_hwif_t *hwif = HWIF(drive); 297 ide_hwif_t *hwif = HWIF(drive);
@@ -348,7 +299,7 @@ static int cmd64x_tune_chipset (ide_drive_t *drive, u8 speed)
348 u8 unit = drive->dn & 0x01; 299 u8 unit = drive->dn & 0x01;
349 u8 regU = 0, pciU = hwif->channel ? UDIDETCR1 : UDIDETCR0; 300 u8 regU = 0, pciU = hwif->channel ? UDIDETCR1 : UDIDETCR0;
350 301
351 speed = ide_rate_filter(cmd64x_ratemask(drive), speed); 302 speed = ide_rate_filter(drive, speed);
352 303
353 if (speed >= XFER_SW_DMA_0) { 304 if (speed >= XFER_SW_DMA_0) {
354 (void) pci_read_config_byte(dev, pciU, &regU); 305 (void) pci_read_config_byte(dev, pciU, &regU);
@@ -403,7 +354,7 @@ static int cmd64x_tune_chipset (ide_drive_t *drive, u8 speed)
403 354
404static int config_chipset_for_dma (ide_drive_t *drive) 355static int config_chipset_for_dma (ide_drive_t *drive)
405{ 356{
406 u8 speed = ide_dma_speed(drive, cmd64x_ratemask(drive)); 357 u8 speed = ide_max_dma_mode(drive);
407 358
408 if (!speed) 359 if (!speed)
409 return 0; 360 return 0;
@@ -597,7 +548,7 @@ static unsigned int __devinit init_chipset_cmd64x(struct pci_dev *dev, const cha
597 (void) pci_write_config_byte(dev, UDIDETCR0, 0xf0); 548 (void) pci_write_config_byte(dev, UDIDETCR0, 0xf0);
598#endif /* CONFIG_PPC */ 549#endif /* CONFIG_PPC */
599 550
600#if defined(DISPLAY_CMD64X_TIMINGS) && defined(CONFIG_PROC_FS) 551#if defined(DISPLAY_CMD64X_TIMINGS) && defined(CONFIG_IDE_PROC_FS)
601 552
602 cmd_devs[n_cmd_devs++] = dev; 553 cmd_devs[n_cmd_devs++] = dev;
603 554
@@ -605,7 +556,7 @@ static unsigned int __devinit init_chipset_cmd64x(struct pci_dev *dev, const cha
605 cmd64x_proc = 1; 556 cmd64x_proc = 1;
606 ide_pci_create_host_proc("cmd64x", cmd64x_get_info); 557 ide_pci_create_host_proc("cmd64x", cmd64x_get_info);
607 } 558 }
608#endif /* DISPLAY_CMD64X_TIMINGS && CONFIG_PROC_FS */ 559#endif /* DISPLAY_CMD64X_TIMINGS && CONFIG_IDE_PROC_FS */
609 560
610 return 0; 561 return 0;
611} 562}
@@ -644,15 +595,24 @@ static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif)
644 595
645 hwif->atapi_dma = 1; 596 hwif->atapi_dma = 1;
646 597
647 hwif->ultra_mask = 0x3f; 598 hwif->ultra_mask = hwif->cds->udma_mask;
648 hwif->mwdma_mask = 0x07; 599
600 /*
601 * UltraDMA only supported on PCI646U and PCI646U2, which
602 * correspond to revisions 0x03, 0x05 and 0x07 respectively.
603 * Actually, although the CMD tech support people won't
604 * tell me the details, the 0x03 revision cannot support
605 * UDMA correctly without hardware modifications, and even
606 * then it only works with Quantum disks due to some
607 * hold time assumptions in the 646U part which are fixed
608 * in the 646U2.
609 *
610 * So we only do UltraDMA on revision 0x05 and 0x07 chipsets.
611 */
612 if (dev->device == PCI_DEVICE_ID_CMD_646 && class_rev < 5)
613 hwif->ultra_mask = 0x00;
649 614
650 if (dev->device == PCI_DEVICE_ID_CMD_643) 615 hwif->mwdma_mask = 0x07;
651 hwif->ultra_mask = 0x80;
652 if (dev->device == PCI_DEVICE_ID_CMD_646)
653 hwif->ultra_mask = (class_rev > 0x04) ? 0x07 : 0x80;
654 if (dev->device == PCI_DEVICE_ID_CMD_648)
655 hwif->ultra_mask = 0x1f;
656 616
657 hwif->ide_dma_check = &cmd64x_config_drive_for_dma; 617 hwif->ide_dma_check = &cmd64x_config_drive_for_dma;
658 if (!(hwif->udma_four)) 618 if (!(hwif->udma_four))
@@ -716,6 +676,7 @@ static ide_pci_device_t cmd64x_chipsets[] __devinitdata = {
716 .autodma = AUTODMA, 676 .autodma = AUTODMA,
717 .enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}}, 677 .enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}},
718 .bootable = ON_BOARD, 678 .bootable = ON_BOARD,
679 .udma_mask = 0x00, /* no udma */
719 },{ /* 1 */ 680 },{ /* 1 */
720 .name = "CMD646", 681 .name = "CMD646",
721 .init_setup = init_setup_cmd646, 682 .init_setup = init_setup_cmd646,
@@ -725,6 +686,7 @@ static ide_pci_device_t cmd64x_chipsets[] __devinitdata = {
725 .autodma = AUTODMA, 686 .autodma = AUTODMA,
726 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, 687 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}},
727 .bootable = ON_BOARD, 688 .bootable = ON_BOARD,
689 .udma_mask = 0x07, /* udma0-2 */
728 },{ /* 2 */ 690 },{ /* 2 */
729 .name = "CMD648", 691 .name = "CMD648",
730 .init_setup = init_setup_cmd64x, 692 .init_setup = init_setup_cmd64x,
@@ -734,6 +696,7 @@ static ide_pci_device_t cmd64x_chipsets[] __devinitdata = {
734 .autodma = AUTODMA, 696 .autodma = AUTODMA,
735 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, 697 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}},
736 .bootable = ON_BOARD, 698 .bootable = ON_BOARD,
699 .udma_mask = 0x1f, /* udma0-4 */
737 },{ /* 3 */ 700 },{ /* 3 */
738 .name = "CMD649", 701 .name = "CMD649",
739 .init_setup = init_setup_cmd64x, 702 .init_setup = init_setup_cmd64x,
@@ -743,6 +706,7 @@ static ide_pci_device_t cmd64x_chipsets[] __devinitdata = {
743 .autodma = AUTODMA, 706 .autodma = AUTODMA,
744 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, 707 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}},
745 .bootable = ON_BOARD, 708 .bootable = ON_BOARD,
709 .udma_mask = 0x3f, /* udma0-5 */
746 } 710 }
747}; 711};
748 712
diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c
index 400859a839f7..3b88a3a56116 100644
--- a/drivers/ide/pci/cs5520.c
+++ b/drivers/ide/pci/cs5520.c
@@ -213,6 +213,7 @@ static ide_pci_device_t cyrix_chipsets[] __devinitdata = {
213 213
214static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id) 214static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id)
215{ 215{
216 ide_hwif_t *hwif = NULL, *mate = NULL;
216 ata_index_t index; 217 ata_index_t index;
217 ide_pci_device_t *d = &cyrix_chipsets[id->driver_data]; 218 ide_pci_device_t *d = &cyrix_chipsets[id->driver_data];
218 219
@@ -239,10 +240,21 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
239 240
240 ide_pci_setup_ports(dev, d, 14, &index); 241 ide_pci_setup_ports(dev, d, 14, &index);
241 242
242 if((index.b.low & 0xf0) != 0xf0) 243 if ((index.b.low & 0xf0) != 0xf0)
243 probe_hwif_init(&ide_hwifs[index.b.low]); 244 hwif = &ide_hwifs[index.b.low];
244 if((index.b.high & 0xf0) != 0xf0) 245 if ((index.b.high & 0xf0) != 0xf0)
245 probe_hwif_init(&ide_hwifs[index.b.high]); 246 mate = &ide_hwifs[index.b.high];
247
248 if (hwif)
249 probe_hwif_init(hwif);
250 if (mate)
251 probe_hwif_init(mate);
252
253 if (hwif)
254 ide_proc_register_port(hwif);
255 if (mate)
256 ide_proc_register_port(mate);
257
246 return 0; 258 return 0;
247} 259}
248 260
diff --git a/drivers/ide/pci/cs5535.c b/drivers/ide/pci/cs5535.c
index 45f43efbf92c..41925c47ef05 100644
--- a/drivers/ide/pci/cs5535.c
+++ b/drivers/ide/pci/cs5535.c
@@ -127,20 +127,6 @@ static void cs5535_set_speed(ide_drive_t *drive, u8 speed)
127 } 127 }
128} 128}
129 129
130static u8 cs5535_ratemask(ide_drive_t *drive)
131{
132 /* eighty93 will return 1 if it's 80core and capable of
133 exceeding udma2, 0 otherwise. we need ratemask to set
134 the max speed and if we can > udma2 then we return 2
135 which selects speed_max as udma4 which is the 5535's max
136 speed, and 1 selects udma2 which is the max for 40c */
137 if (!eighty_ninty_three(drive))
138 return 1;
139
140 return 2;
141}
142
143
144/**** 130/****
145 * cs5535_set_drive - Configure the drive to the new speed 131 * cs5535_set_drive - Configure the drive to the new speed
146 * @drive: Drive to set up 132 * @drive: Drive to set up
@@ -151,7 +137,7 @@ static u8 cs5535_ratemask(ide_drive_t *drive)
151 */ 137 */
152static int cs5535_set_drive(ide_drive_t *drive, u8 speed) 138static int cs5535_set_drive(ide_drive_t *drive, u8 speed)
153{ 139{
154 speed = ide_rate_filter(cs5535_ratemask(drive), speed); 140 speed = ide_rate_filter(drive, speed);
155 ide_config_drive_speed(drive, speed); 141 ide_config_drive_speed(drive, speed);
156 cs5535_set_speed(drive, speed); 142 cs5535_set_speed(drive, speed);
157 143
@@ -178,28 +164,13 @@ static void cs5535_tuneproc(ide_drive_t *drive, u8 xferspeed)
178 cs5535_set_speed(drive, xferspeed); 164 cs5535_set_speed(drive, xferspeed);
179} 165}
180 166
181static int cs5535_config_drive_for_dma(ide_drive_t *drive)
182{
183 u8 speed;
184
185 speed = ide_dma_speed(drive, cs5535_ratemask(drive));
186
187 /* If no DMA speed was available then let dma_check hit pio */
188 if (!speed) {
189 return 0;
190 }
191
192 cs5535_set_drive(drive, speed);
193 return ide_dma_enable(drive);
194}
195
196static int cs5535_dma_check(ide_drive_t *drive) 167static int cs5535_dma_check(ide_drive_t *drive)
197{ 168{
198 u8 speed; 169 u8 speed;
199 170
200 drive->init_speed = 0; 171 drive->init_speed = 0;
201 172
202 if (ide_use_dma(drive) && cs5535_config_drive_for_dma(drive)) 173 if (ide_tune_dma(drive))
203 return 0; 174 return 0;
204 175
205 if (ide_use_fast_pio(drive)) { 176 if (ide_use_fast_pio(drive)) {
diff --git a/drivers/ide/pci/delkin_cb.c b/drivers/ide/pci/delkin_cb.c
index dd7ec37fdeab..46f4a888c037 100644
--- a/drivers/ide/pci/delkin_cb.c
+++ b/drivers/ide/pci/delkin_cb.c
@@ -80,7 +80,7 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
80 hw.irq = dev->irq; 80 hw.irq = dev->irq;
81 hw.chipset = ide_pci; /* this enables IRQ sharing */ 81 hw.chipset = ide_pci; /* this enables IRQ sharing */
82 82
83 rc = ide_register_hw_with_fixup(&hw, &hwif, ide_undecoded_slave); 83 rc = ide_register_hw_with_fixup(&hw, 0, &hwif, ide_undecoded_slave);
84 if (rc < 0) { 84 if (rc < 0) {
85 printk(KERN_ERR "delkin_cb: ide_register_hw failed (%d)\n", rc); 85 printk(KERN_ERR "delkin_cb: ide_register_hw failed (%d)\n", rc);
86 pci_disable_device(dev); 86 pci_disable_device(dev);
diff --git a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c
index 924eaa3a5708..2c24c3de8846 100644
--- a/drivers/ide/pci/hpt34x.c
+++ b/drivers/ide/pci/hpt34x.c
@@ -43,15 +43,10 @@
43 43
44#define HPT343_DEBUG_DRIVE_INFO 0 44#define HPT343_DEBUG_DRIVE_INFO 0
45 45
46static u8 hpt34x_ratemask (ide_drive_t *drive)
47{
48 return 1;
49}
50
51static int hpt34x_tune_chipset (ide_drive_t *drive, u8 xferspeed) 46static int hpt34x_tune_chipset (ide_drive_t *drive, u8 xferspeed)
52{ 47{
53 struct pci_dev *dev = HWIF(drive)->pci_dev; 48 struct pci_dev *dev = HWIF(drive)->pci_dev;
54 u8 speed = ide_rate_filter(hpt34x_ratemask(drive), xferspeed); 49 u8 speed = ide_rate_filter(drive, xferspeed);
55 u32 reg1= 0, tmp1 = 0, reg2 = 0, tmp2 = 0; 50 u32 reg1= 0, tmp1 = 0, reg2 = 0, tmp2 = 0;
56 u8 hi_speed, lo_speed; 51 u8 hi_speed, lo_speed;
57 52
@@ -89,29 +84,11 @@ static void hpt34x_tune_drive (ide_drive_t *drive, u8 pio)
89 (void) hpt34x_tune_chipset(drive, (XFER_PIO_0 + pio)); 84 (void) hpt34x_tune_chipset(drive, (XFER_PIO_0 + pio));
90} 85}
91 86
92/*
93 * This allows the configuration of ide_pci chipset registers
94 * for cards that learn about the drive's UDMA, DMA, PIO capabilities
95 * after the drive is reported by the OS. Initially for designed for
96 * HPT343 UDMA chipset by HighPoint|Triones Technologies, Inc.
97 */
98
99static int config_chipset_for_dma (ide_drive_t *drive)
100{
101 u8 speed = ide_dma_speed(drive, hpt34x_ratemask(drive));
102
103 if (!(speed))
104 return 0;
105
106 (void) hpt34x_tune_chipset(drive, speed);
107 return ide_dma_enable(drive);
108}
109
110static int hpt34x_config_drive_xfer_rate (ide_drive_t *drive) 87static int hpt34x_config_drive_xfer_rate (ide_drive_t *drive)
111{ 88{
112 drive->init_speed = 0; 89 drive->init_speed = 0;
113 90
114 if (ide_use_dma(drive) && config_chipset_for_dma(drive)) 91 if (ide_tune_dma(drive))
115#ifndef CONFIG_HPT34X_AUTODMA 92#ifndef CONFIG_HPT34X_AUTODMA
116 return -1; 93 return -1;
117#else 94#else
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index cf9d344d19f8..fcbc5605b38e 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -514,43 +514,31 @@ static int check_in_drive_list(ide_drive_t *drive, const char **list)
514 return 0; 514 return 0;
515} 515}
516 516
517static u8 hpt3xx_ratemask(ide_drive_t *drive)
518{
519 struct hpt_info *info = pci_get_drvdata(HWIF(drive)->pci_dev);
520 u8 mode = info->max_mode;
521
522 if (!eighty_ninty_three(drive) && mode)
523 mode = min(mode, (u8)1);
524 return mode;
525}
526
527/* 517/*
528 * Note for the future; the SATA hpt37x we must set 518 * Note for the future; the SATA hpt37x we must set
529 * either PIO or UDMA modes 0,4,5 519 * either PIO or UDMA modes 0,4,5
530 */ 520 */
531 521
532static u8 hpt3xx_ratefilter(ide_drive_t *drive, u8 speed) 522static u8 hpt3xx_udma_filter(ide_drive_t *drive)
533{ 523{
534 struct hpt_info *info = pci_get_drvdata(HWIF(drive)->pci_dev); 524 struct hpt_info *info = pci_get_drvdata(HWIF(drive)->pci_dev);
535 u8 chip_type = info->chip_type; 525 u8 chip_type = info->chip_type;
536 u8 mode = hpt3xx_ratemask(drive); 526 u8 mode = info->max_mode;
537 527 u8 mask;
538 if (drive->media != ide_disk)
539 return min(speed, (u8)XFER_PIO_4);
540 528
541 switch (mode) { 529 switch (mode) {
542 case 0x04: 530 case 0x04:
543 speed = min_t(u8, speed, XFER_UDMA_6); 531 mask = 0x7f;
544 break; 532 break;
545 case 0x03: 533 case 0x03:
546 speed = min_t(u8, speed, XFER_UDMA_5); 534 mask = 0x3f;
547 if (chip_type >= HPT374) 535 if (chip_type >= HPT374)
548 break; 536 break;
549 if (!check_in_drive_list(drive, bad_ata100_5)) 537 if (!check_in_drive_list(drive, bad_ata100_5))
550 goto check_bad_ata33; 538 goto check_bad_ata33;
551 /* fall thru */ 539 /* fall thru */
552 case 0x02: 540 case 0x02:
553 speed = min_t(u8, speed, XFER_UDMA_4); 541 mask = 0x1f;
554 542
555 /* 543 /*
556 * CHECK ME, Does this need to be changed to HPT374 ?? 544 * CHECK ME, Does this need to be changed to HPT374 ??
@@ -561,13 +549,13 @@ static u8 hpt3xx_ratefilter(ide_drive_t *drive, u8 speed)
561 !check_in_drive_list(drive, bad_ata66_4)) 549 !check_in_drive_list(drive, bad_ata66_4))
562 goto check_bad_ata33; 550 goto check_bad_ata33;
563 551
564 speed = min_t(u8, speed, XFER_UDMA_3); 552 mask = 0x0f;
565 if (HPT366_ALLOW_ATA66_3 && 553 if (HPT366_ALLOW_ATA66_3 &&
566 !check_in_drive_list(drive, bad_ata66_3)) 554 !check_in_drive_list(drive, bad_ata66_3))
567 goto check_bad_ata33; 555 goto check_bad_ata33;
568 /* fall thru */ 556 /* fall thru */
569 case 0x01: 557 case 0x01:
570 speed = min_t(u8, speed, XFER_UDMA_2); 558 mask = 0x07;
571 559
572 check_bad_ata33: 560 check_bad_ata33:
573 if (chip_type >= HPT370A) 561 if (chip_type >= HPT370A)
@@ -577,10 +565,10 @@ static u8 hpt3xx_ratefilter(ide_drive_t *drive, u8 speed)
577 /* fall thru */ 565 /* fall thru */
578 case 0x00: 566 case 0x00:
579 default: 567 default:
580 speed = min_t(u8, speed, XFER_MW_DMA_2); 568 mask = 0x00;
581 break; 569 break;
582 } 570 }
583 return speed; 571 return mask;
584} 572}
585 573
586static u32 get_speed_setting(u8 speed, struct hpt_info *info) 574static u32 get_speed_setting(u8 speed, struct hpt_info *info)
@@ -608,12 +596,19 @@ static int hpt36x_tune_chipset(ide_drive_t *drive, u8 xferspeed)
608 ide_hwif_t *hwif = HWIF(drive); 596 ide_hwif_t *hwif = HWIF(drive);
609 struct pci_dev *dev = hwif->pci_dev; 597 struct pci_dev *dev = hwif->pci_dev;
610 struct hpt_info *info = pci_get_drvdata(dev); 598 struct hpt_info *info = pci_get_drvdata(dev);
611 u8 speed = hpt3xx_ratefilter(drive, xferspeed); 599 u8 speed = ide_rate_filter(drive, xferspeed);
612 u8 itr_addr = drive->dn ? 0x44 : 0x40; 600 u8 itr_addr = drive->dn ? 0x44 : 0x40;
613 u32 itr_mask = speed < XFER_MW_DMA_0 ? 0x30070000 :
614 (speed < XFER_UDMA_0 ? 0xc0070000 : 0xc03800ff);
615 u32 new_itr = get_speed_setting(speed, info);
616 u32 old_itr = 0; 601 u32 old_itr = 0;
602 u32 itr_mask, new_itr;
603
604 /* TODO: move this to ide_rate_filter() [ check ->atapi_dma ] */
605 if (drive->media != ide_disk)
606 speed = min_t(u8, speed, XFER_PIO_4);
607
608 itr_mask = speed < XFER_MW_DMA_0 ? 0x30070000 :
609 (speed < XFER_UDMA_0 ? 0xc0070000 : 0xc03800ff);
610
611 new_itr = get_speed_setting(speed, info);
617 612
618 /* 613 /*
619 * Disable on-chip PIO FIFO/buffer (and PIO MST mode as well) 614 * Disable on-chip PIO FIFO/buffer (and PIO MST mode as well)
@@ -633,12 +628,19 @@ static int hpt37x_tune_chipset(ide_drive_t *drive, u8 xferspeed)
633 ide_hwif_t *hwif = HWIF(drive); 628 ide_hwif_t *hwif = HWIF(drive);
634 struct pci_dev *dev = hwif->pci_dev; 629 struct pci_dev *dev = hwif->pci_dev;
635 struct hpt_info *info = pci_get_drvdata(dev); 630 struct hpt_info *info = pci_get_drvdata(dev);
636 u8 speed = hpt3xx_ratefilter(drive, xferspeed); 631 u8 speed = ide_rate_filter(drive, xferspeed);
637 u8 itr_addr = 0x40 + (drive->dn * 4); 632 u8 itr_addr = 0x40 + (drive->dn * 4);
638 u32 itr_mask = speed < XFER_MW_DMA_0 ? 0x303c0000 :
639 (speed < XFER_UDMA_0 ? 0xc03c0000 : 0xc1c001ff);
640 u32 new_itr = get_speed_setting(speed, info);
641 u32 old_itr = 0; 633 u32 old_itr = 0;
634 u32 itr_mask, new_itr;
635
636 /* TODO: move this to ide_rate_filter() [ check ->atapi_dma ] */
637 if (drive->media != ide_disk)
638 speed = min_t(u8, speed, XFER_PIO_4);
639
640 itr_mask = speed < XFER_MW_DMA_0 ? 0x303c0000 :
641 (speed < XFER_UDMA_0 ? 0xc03c0000 : 0xc1c001ff);
642
643 new_itr = get_speed_setting(speed, info);
642 644
643 pci_read_config_dword(dev, itr_addr, &old_itr); 645 pci_read_config_dword(dev, itr_addr, &old_itr);
644 new_itr = (new_itr & ~itr_mask) | (old_itr & itr_mask); 646 new_itr = (new_itr & ~itr_mask) | (old_itr & itr_mask);
@@ -667,24 +669,6 @@ static void hpt3xx_tune_drive(ide_drive_t *drive, u8 pio)
667 (void) hpt3xx_tune_chipset (drive, XFER_PIO_0 + pio); 669 (void) hpt3xx_tune_chipset (drive, XFER_PIO_0 + pio);
668} 670}
669 671
670/*
671 * This allows the configuration of ide_pci chipset registers
672 * for cards that learn about the drive's UDMA, DMA, PIO capabilities
673 * after the drive is reported by the OS. Initially designed for
674 * HPT366 UDMA chipset by HighPoint|Triones Technologies, Inc.
675 *
676 */
677static int config_chipset_for_dma(ide_drive_t *drive)
678{
679 u8 speed = ide_dma_speed(drive, hpt3xx_ratemask(drive));
680
681 if (!speed)
682 return 0;
683
684 (void) hpt3xx_tune_chipset(drive, speed);
685 return ide_dma_enable(drive);
686}
687
688static int hpt3xx_quirkproc(ide_drive_t *drive) 672static int hpt3xx_quirkproc(ide_drive_t *drive)
689{ 673{
690 struct hd_driveid *id = drive->id; 674 struct hd_driveid *id = drive->id;
@@ -739,7 +723,7 @@ static int hpt366_config_drive_xfer_rate(ide_drive_t *drive)
739{ 723{
740 drive->init_speed = 0; 724 drive->init_speed = 0;
741 725
742 if (ide_use_dma(drive) && config_chipset_for_dma(drive)) 726 if (ide_tune_dma(drive))
743 return 0; 727 return 0;
744 728
745 if (ide_use_fast_pio(drive)) 729 if (ide_use_fast_pio(drive))
@@ -1271,6 +1255,7 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
1271 hwif->intrproc = &hpt3xx_intrproc; 1255 hwif->intrproc = &hpt3xx_intrproc;
1272 hwif->maskproc = &hpt3xx_maskproc; 1256 hwif->maskproc = &hpt3xx_maskproc;
1273 hwif->busproc = &hpt3xx_busproc; 1257 hwif->busproc = &hpt3xx_busproc;
1258 hwif->udma_filter = &hpt3xx_udma_filter;
1274 1259
1275 /* 1260 /*
1276 * HPT3xxN chips have some complications: 1261 * HPT3xxN chips have some complications:
diff --git a/drivers/ide/pci/it8213.c b/drivers/ide/pci/it8213.c
index 424f00bb160d..c04a02687b95 100644
--- a/drivers/ide/pci/it8213.c
+++ b/drivers/ide/pci/it8213.c
@@ -17,22 +17,6 @@
17 17
18#include <asm/io.h> 18#include <asm/io.h>
19 19
20/*
21 * it8213_ratemask - Compute available modes
22 * @drive: IDE drive
23 *
24 * Compute the available speeds for the devices on the interface. This
25 * is all modes to ATA133 clipped by drive cable setup.
26 */
27
28static u8 it8213_ratemask (ide_drive_t *drive)
29{
30 u8 mode = 4;
31 if (!eighty_ninty_three(drive))
32 mode = min_t(u8, mode, 1);
33 return mode;
34}
35
36/** 20/**
37 * it8213_dma_2_pio - return the PIO mode matching DMA 21 * it8213_dma_2_pio - return the PIO mode matching DMA
38 * @xfer_rate: transfer speed 22 * @xfer_rate: transfer speed
@@ -145,7 +129,7 @@ static int it8213_tune_chipset (ide_drive_t *drive, u8 xferspeed)
145 ide_hwif_t *hwif = HWIF(drive); 129 ide_hwif_t *hwif = HWIF(drive);
146 struct pci_dev *dev = hwif->pci_dev; 130 struct pci_dev *dev = hwif->pci_dev;
147 u8 maslave = 0x40; 131 u8 maslave = 0x40;
148 u8 speed = ide_rate_filter(it8213_ratemask(drive), xferspeed); 132 u8 speed = ide_rate_filter(drive, xferspeed);
149 int a_speed = 3 << (drive->dn * 4); 133 int a_speed = 3 << (drive->dn * 4);
150 int u_flag = 1 << drive->dn; 134 int u_flag = 1 << drive->dn;
151 int v_flag = 0x01 << drive->dn; 135 int v_flag = 0x01 << drive->dn;
@@ -213,25 +197,6 @@ static int it8213_tune_chipset (ide_drive_t *drive, u8 xferspeed)
213 return ide_config_drive_speed(drive, speed); 197 return ide_config_drive_speed(drive, speed);
214} 198}
215 199
216/*
217 * config_chipset_for_dma - configure for DMA
218 * @drive: drive to configure
219 *
220 * Called by the IDE layer when it wants the timings set up.
221 */
222
223static int config_chipset_for_dma (ide_drive_t *drive)
224{
225 u8 speed = ide_dma_speed(drive, it8213_ratemask(drive));
226
227 if (!speed)
228 return 0;
229
230 it8213_tune_chipset(drive, speed);
231
232 return ide_dma_enable(drive);
233}
234
235/** 200/**
236 * it8213_configure_drive_for_dma - set up for DMA transfers 201 * it8213_configure_drive_for_dma - set up for DMA transfers
237 * @drive: drive we are going to set up 202 * @drive: drive we are going to set up
@@ -246,7 +211,7 @@ static int it8213_config_drive_for_dma (ide_drive_t *drive)
246{ 211{
247 u8 pio; 212 u8 pio;
248 213
249 if (ide_use_dma(drive) && config_chipset_for_dma(drive)) 214 if (ide_tune_dma(drive))
250 return 0; 215 return 0;
251 216
252 pio = ide_get_best_pio_mode(drive, 255, 4, NULL); 217 pio = ide_get_best_pio_mode(drive, 255, 4, NULL);
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c
index 4e1254813ee0..442f658c6ae7 100644
--- a/drivers/ide/pci/it821x.c
+++ b/drivers/ide/pci/it821x.c
@@ -229,22 +229,6 @@ static void it821x_clock_strategy(ide_drive_t *drive)
229} 229}
230 230
231/** 231/**
232 * it821x_ratemask - Compute available modes
233 * @drive: IDE drive
234 *
235 * Compute the available speeds for the devices on the interface. This
236 * is all modes to ATA133 clipped by drive cable setup.
237 */
238
239static u8 it821x_ratemask (ide_drive_t *drive)
240{
241 u8 mode = 4;
242 if (!eighty_ninty_three(drive))
243 mode = min(mode, (u8)1);
244 return mode;
245}
246
247/**
248 * it821x_tunepio - tune a drive 232 * it821x_tunepio - tune a drive
249 * @drive: drive to tune 233 * @drive: drive to tune
250 * @pio: the desired PIO mode 234 * @pio: the desired PIO mode
@@ -438,7 +422,7 @@ static int it821x_tune_chipset (ide_drive_t *drive, byte xferspeed)
438 422
439 ide_hwif_t *hwif = drive->hwif; 423 ide_hwif_t *hwif = drive->hwif;
440 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 424 struct it821x_dev *itdev = ide_get_hwifdata(hwif);
441 u8 speed = ide_rate_filter(it821x_ratemask(drive), xferspeed); 425 u8 speed = ide_rate_filter(drive, xferspeed);
442 426
443 switch (speed) { 427 switch (speed) {
444 case XFER_PIO_4: 428 case XFER_PIO_4:
@@ -488,7 +472,7 @@ static int it821x_tune_chipset (ide_drive_t *drive, byte xferspeed)
488 472
489static int config_chipset_for_dma (ide_drive_t *drive) 473static int config_chipset_for_dma (ide_drive_t *drive)
490{ 474{
491 u8 speed = ide_dma_speed(drive, it821x_ratemask(drive)); 475 u8 speed = ide_max_dma_mode(drive);
492 476
493 if (speed == 0) 477 if (speed == 0)
494 return 0; 478 return 0;
diff --git a/drivers/ide/pci/jmicron.c b/drivers/ide/pci/jmicron.c
index be4fc96c29e0..76ed25147229 100644
--- a/drivers/ide/pci/jmicron.c
+++ b/drivers/ide/pci/jmicron.c
@@ -22,22 +22,6 @@ typedef enum {
22} port_type; 22} port_type;
23 23
24/** 24/**
25 * jmicron_ratemask - Compute available modes
26 * @drive: IDE drive
27 *
28 * Compute the available speeds for the devices on the interface. This
29 * is all modes to ATA133 clipped by drive cable setup.
30 */
31
32static u8 jmicron_ratemask(ide_drive_t *drive)
33{
34 u8 mode = 4;
35 if (!eighty_ninty_three(drive))
36 mode = min(mode, (u8)1);
37 return mode;
38}
39
40/**
41 * ata66_jmicron - Cable check 25 * ata66_jmicron - Cable check
42 * @hwif: IDE port 26 * @hwif: IDE port
43 * 27 *
@@ -129,32 +113,12 @@ static void config_jmicron_chipset_for_pio (ide_drive_t *drive, byte set_speed)
129 113
130static int jmicron_tune_chipset (ide_drive_t *drive, byte xferspeed) 114static int jmicron_tune_chipset (ide_drive_t *drive, byte xferspeed)
131{ 115{
132 116 u8 speed = ide_rate_filter(drive, xferspeed);
133 u8 speed = ide_rate_filter(jmicron_ratemask(drive), xferspeed);
134 117
135 return ide_config_drive_speed(drive, speed); 118 return ide_config_drive_speed(drive, speed);
136} 119}
137 120
138/** 121/**
139 * config_chipset_for_dma - configure for DMA
140 * @drive: drive to configure
141 *
142 * As the JMicron snoops for timings all we actually need to do is
143 * make sure we don't set an invalid mode.
144 */
145
146static int config_chipset_for_dma (ide_drive_t *drive)
147{
148 u8 speed = ide_dma_speed(drive, jmicron_ratemask(drive));
149
150 if (!speed)
151 return 0;
152
153 jmicron_tune_chipset(drive, speed);
154 return ide_dma_enable(drive);
155}
156
157/**
158 * jmicron_configure_drive_for_dma - set up for DMA transfers 122 * jmicron_configure_drive_for_dma - set up for DMA transfers
159 * @drive: drive we are going to set up 123 * @drive: drive we are going to set up
160 * 124 *
@@ -164,7 +128,7 @@ static int config_chipset_for_dma (ide_drive_t *drive)
164 128
165static int jmicron_config_drive_for_dma (ide_drive_t *drive) 129static int jmicron_config_drive_for_dma (ide_drive_t *drive)
166{ 130{
167 if (ide_use_dma(drive) && config_chipset_for_dma(drive)) 131 if (ide_tune_dma(drive))
168 return 0; 132 return 0;
169 133
170 config_jmicron_chipset_for_pio(drive, 1); 134 config_jmicron_chipset_for_pio(drive, 1);
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c
index 2cdd629c653d..65b1e124edf7 100644
--- a/drivers/ide/pci/pdc202xx_new.c
+++ b/drivers/ide/pci/pdc202xx_new.c
@@ -37,8 +37,6 @@
37#include <asm/pci-bridge.h> 37#include <asm/pci-bridge.h>
38#endif 38#endif
39 39
40#define PDC202_DEBUG_CABLE 0
41
42#undef DEBUG 40#undef DEBUG
43 41
44#ifdef DEBUG 42#ifdef DEBUG
@@ -82,16 +80,6 @@ static u8 max_dma_rate(struct pci_dev *pdev)
82 return mode; 80 return mode;
83} 81}
84 82
85static u8 pdcnew_ratemask(ide_drive_t *drive)
86{
87 u8 mode = max_dma_rate(HWIF(drive)->pci_dev);
88
89 if (!eighty_ninty_three(drive))
90 mode = min_t(u8, mode, 1);
91
92 return mode;
93}
94
95/** 83/**
96 * get_indexed_reg - Get indexed register 84 * get_indexed_reg - Get indexed register
97 * @hwif: for the port address 85 * @hwif: for the port address
@@ -164,7 +152,7 @@ static int pdcnew_tune_chipset(ide_drive_t *drive, u8 speed)
164 u8 adj = (drive->dn & 1) ? 0x08 : 0x00; 152 u8 adj = (drive->dn & 1) ? 0x08 : 0x00;
165 int err; 153 int err;
166 154
167 speed = ide_rate_filter(pdcnew_ratemask(drive), speed); 155 speed = ide_rate_filter(drive, speed);
168 156
169 /* 157 /*
170 * Issue SETFEATURES_XFER to the drive first. PDC202xx hardware will 158 * Issue SETFEATURES_XFER to the drive first. PDC202xx hardware will
@@ -244,17 +232,8 @@ static int config_chipset_for_dma(ide_drive_t *drive)
244{ 232{
245 struct hd_driveid *id = drive->id; 233 struct hd_driveid *id = drive->id;
246 ide_hwif_t *hwif = HWIF(drive); 234 ide_hwif_t *hwif = HWIF(drive);
247 u8 ultra_66 = (id->dma_ultra & 0x0078) ? 1 : 0;
248 u8 cable = pdcnew_cable_detect(hwif);
249 u8 speed; 235 u8 speed;
250 236
251 if (ultra_66 && cable) {
252 printk(KERN_WARNING "Warning: %s channel "
253 "requires an 80-pin cable for operation.\n",
254 hwif->channel ? "Secondary" : "Primary");
255 printk(KERN_WARNING "%s reduced to Ultra33 mode.\n", drive->name);
256 }
257
258 if (id->capability & 4) { 237 if (id->capability & 4) {
259 /* 238 /*
260 * Set IORDY_EN & PREFETCH_EN (this seems to have 239 * Set IORDY_EN & PREFETCH_EN (this seems to have
@@ -267,7 +246,7 @@ static int config_chipset_for_dma(ide_drive_t *drive)
267 set_indexed_reg(hwif, 0x13 + adj, tmp | 0x03); 246 set_indexed_reg(hwif, 0x13 + adj, tmp | 0x03);
268 } 247 }
269 248
270 speed = ide_dma_speed(drive, pdcnew_ratemask(drive)); 249 speed = ide_max_dma_mode(drive);
271 250
272 if (!speed) 251 if (!speed)
273 return 0; 252 return 0;
@@ -543,7 +522,8 @@ static void __devinit init_hwif_pdc202new(ide_hwif_t *hwif)
543 hwif->drives[0].autotune = hwif->drives[1].autotune = 1; 522 hwif->drives[0].autotune = hwif->drives[1].autotune = 1;
544 523
545 hwif->atapi_dma = 1; 524 hwif->atapi_dma = 1;
546 hwif->ultra_mask = 0x7f; 525
526 hwif->ultra_mask = hwif->cds->udma_mask;
547 hwif->mwdma_mask = 0x07; 527 hwif->mwdma_mask = 0x07;
548 528
549 hwif->err_stops_fifo = 1; 529 hwif->err_stops_fifo = 1;
@@ -556,11 +536,6 @@ static void __devinit init_hwif_pdc202new(ide_hwif_t *hwif)
556 if (!noautodma) 536 if (!noautodma)
557 hwif->autodma = 1; 537 hwif->autodma = 1;
558 hwif->drives[0].autodma = hwif->drives[1].autodma = hwif->autodma; 538 hwif->drives[0].autodma = hwif->drives[1].autodma = hwif->autodma;
559
560#if PDC202_DEBUG_CABLE
561 printk(KERN_DEBUG "%s: %s-pin cable\n",
562 hwif->name, hwif->udma_four ? "80" : "40");
563#endif /* PDC202_DEBUG_CABLE */
564} 539}
565 540
566static int __devinit init_setup_pdcnew(struct pci_dev *dev, ide_pci_device_t *d) 541static int __devinit init_setup_pdcnew(struct pci_dev *dev, ide_pci_device_t *d)
@@ -619,6 +594,7 @@ static ide_pci_device_t pdcnew_chipsets[] __devinitdata = {
619 .channels = 2, 594 .channels = 2,
620 .autodma = AUTODMA, 595 .autodma = AUTODMA,
621 .bootable = OFF_BOARD, 596 .bootable = OFF_BOARD,
597 .udma_mask = 0x3f, /* udma0-5 */
622 },{ /* 1 */ 598 },{ /* 1 */
623 .name = "PDC20269", 599 .name = "PDC20269",
624 .init_setup = init_setup_pdcnew, 600 .init_setup = init_setup_pdcnew,
@@ -627,6 +603,7 @@ static ide_pci_device_t pdcnew_chipsets[] __devinitdata = {
627 .channels = 2, 603 .channels = 2,
628 .autodma = AUTODMA, 604 .autodma = AUTODMA,
629 .bootable = OFF_BOARD, 605 .bootable = OFF_BOARD,
606 .udma_mask = 0x7f, /* udma0-6*/
630 },{ /* 2 */ 607 },{ /* 2 */
631 .name = "PDC20270", 608 .name = "PDC20270",
632 .init_setup = init_setup_pdc20270, 609 .init_setup = init_setup_pdc20270,
@@ -635,6 +612,7 @@ static ide_pci_device_t pdcnew_chipsets[] __devinitdata = {
635 .channels = 2, 612 .channels = 2,
636 .autodma = AUTODMA, 613 .autodma = AUTODMA,
637 .bootable = OFF_BOARD, 614 .bootable = OFF_BOARD,
615 .udma_mask = 0x3f, /* udma0-5 */
638 },{ /* 3 */ 616 },{ /* 3 */
639 .name = "PDC20271", 617 .name = "PDC20271",
640 .init_setup = init_setup_pdcnew, 618 .init_setup = init_setup_pdcnew,
@@ -643,6 +621,7 @@ static ide_pci_device_t pdcnew_chipsets[] __devinitdata = {
643 .channels = 2, 621 .channels = 2,
644 .autodma = AUTODMA, 622 .autodma = AUTODMA,
645 .bootable = OFF_BOARD, 623 .bootable = OFF_BOARD,
624 .udma_mask = 0x7f, /* udma0-6*/
646 },{ /* 4 */ 625 },{ /* 4 */
647 .name = "PDC20275", 626 .name = "PDC20275",
648 .init_setup = init_setup_pdcnew, 627 .init_setup = init_setup_pdcnew,
@@ -651,6 +630,7 @@ static ide_pci_device_t pdcnew_chipsets[] __devinitdata = {
651 .channels = 2, 630 .channels = 2,
652 .autodma = AUTODMA, 631 .autodma = AUTODMA,
653 .bootable = OFF_BOARD, 632 .bootable = OFF_BOARD,
633 .udma_mask = 0x7f, /* udma0-6*/
654 },{ /* 5 */ 634 },{ /* 5 */
655 .name = "PDC20276", 635 .name = "PDC20276",
656 .init_setup = init_setup_pdc20276, 636 .init_setup = init_setup_pdc20276,
@@ -659,6 +639,7 @@ static ide_pci_device_t pdcnew_chipsets[] __devinitdata = {
659 .channels = 2, 639 .channels = 2,
660 .autodma = AUTODMA, 640 .autodma = AUTODMA,
661 .bootable = OFF_BOARD, 641 .bootable = OFF_BOARD,
642 .udma_mask = 0x7f, /* udma0-6*/
662 },{ /* 6 */ 643 },{ /* 6 */
663 .name = "PDC20277", 644 .name = "PDC20277",
664 .init_setup = init_setup_pdcnew, 645 .init_setup = init_setup_pdcnew,
@@ -667,6 +648,7 @@ static ide_pci_device_t pdcnew_chipsets[] __devinitdata = {
667 .channels = 2, 648 .channels = 2,
668 .autodma = AUTODMA, 649 .autodma = AUTODMA,
669 .bootable = OFF_BOARD, 650 .bootable = OFF_BOARD,
651 .udma_mask = 0x7f, /* udma0-6*/
670 } 652 }
671}; 653};
672 654
diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c
index a7a639fe1eaf..7146fe3f6ba7 100644
--- a/drivers/ide/pci/pdc202xx_old.c
+++ b/drivers/ide/pci/pdc202xx_old.c
@@ -46,7 +46,6 @@
46#include <asm/io.h> 46#include <asm/io.h>
47#include <asm/irq.h> 47#include <asm/irq.h>
48 48
49#define PDC202_DEBUG_CABLE 0
50#define PDC202XX_DEBUG_DRIVE_INFO 0 49#define PDC202XX_DEBUG_DRIVE_INFO 0
51 50
52static const char *pdc_quirk_drives[] = { 51static const char *pdc_quirk_drives[] = {
@@ -101,35 +100,12 @@ static const char *pdc_quirk_drives[] = {
101#define MC1 0x02 /* DMA"C" timing */ 100#define MC1 0x02 /* DMA"C" timing */
102#define MC0 0x01 /* DMA"C" timing */ 101#define MC0 0x01 /* DMA"C" timing */
103 102
104static u8 pdc202xx_ratemask (ide_drive_t *drive)
105{
106 u8 mode;
107
108 switch(HWIF(drive)->pci_dev->device) {
109 case PCI_DEVICE_ID_PROMISE_20267:
110 case PCI_DEVICE_ID_PROMISE_20265:
111 mode = 3;
112 break;
113 case PCI_DEVICE_ID_PROMISE_20263:
114 case PCI_DEVICE_ID_PROMISE_20262:
115 mode = 2;
116 break;
117 case PCI_DEVICE_ID_PROMISE_20246:
118 return 1;
119 default:
120 return 0;
121 }
122 if (!eighty_ninty_three(drive))
123 mode = min(mode, (u8)1);
124 return mode;
125}
126
127static int pdc202xx_tune_chipset (ide_drive_t *drive, u8 xferspeed) 103static int pdc202xx_tune_chipset (ide_drive_t *drive, u8 xferspeed)
128{ 104{
129 ide_hwif_t *hwif = HWIF(drive); 105 ide_hwif_t *hwif = HWIF(drive);
130 struct pci_dev *dev = hwif->pci_dev; 106 struct pci_dev *dev = hwif->pci_dev;
131 u8 drive_pci = 0x60 + (drive->dn << 2); 107 u8 drive_pci = 0x60 + (drive->dn << 2);
132 u8 speed = ide_rate_filter(pdc202xx_ratemask(drive), xferspeed); 108 u8 speed = ide_rate_filter(drive, xferspeed);
133 109
134 u32 drive_conf; 110 u32 drive_conf;
135 u8 AP, BP, CP, DP; 111 u8 AP, BP, CP, DP;
@@ -261,20 +237,7 @@ static int config_chipset_for_dma (ide_drive_t *drive)
261 u32 drive_conf = 0; 237 u32 drive_conf = 0;
262 u8 drive_pci = 0x60 + (drive->dn << 2); 238 u8 drive_pci = 0x60 + (drive->dn << 2);
263 u8 test1 = 0, test2 = 0, speed = -1; 239 u8 test1 = 0, test2 = 0, speed = -1;
264 u8 AP = 0, cable = 0; 240 u8 AP = 0;
265
266 u8 ultra_66 = ((id->dma_ultra & 0x0010) ||
267 (id->dma_ultra & 0x0008)) ? 1 : 0;
268
269 if (dev->device != PCI_DEVICE_ID_PROMISE_20246)
270 cable = pdc202xx_old_cable_detect(hwif);
271 else
272 ultra_66 = 0;
273
274 if (ultra_66 && cable) {
275 printk(KERN_WARNING "Warning: %s channel requires an 80-pin cable for operation.\n", hwif->channel ? "Secondary":"Primary");
276 printk(KERN_WARNING "%s reduced to Ultra33 mode.\n", drive->name);
277 }
278 241
279 if (dev->device != PCI_DEVICE_ID_PROMISE_20246) 242 if (dev->device != PCI_DEVICE_ID_PROMISE_20246)
280 pdc_old_disable_66MHz_clock(drive->hwif); 243 pdc_old_disable_66MHz_clock(drive->hwif);
@@ -308,7 +271,7 @@ chipset_is_set:
308 if (drive->media == ide_disk) /* PREFETCH_EN */ 271 if (drive->media == ide_disk) /* PREFETCH_EN */
309 pci_write_config_byte(dev, (drive_pci), AP|PREFETCH_EN); 272 pci_write_config_byte(dev, (drive_pci), AP|PREFETCH_EN);
310 273
311 speed = ide_dma_speed(drive, pdc202xx_ratemask(drive)); 274 speed = ide_max_dma_mode(drive);
312 275
313 if (!(speed)) { 276 if (!(speed)) {
314 /* restore original pci-config space */ 277 /* restore original pci-config space */
@@ -478,7 +441,7 @@ static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif)
478 441
479 hwif->drives[0].autotune = hwif->drives[1].autotune = 1; 442 hwif->drives[0].autotune = hwif->drives[1].autotune = 1;
480 443
481 hwif->ultra_mask = 0x3f; 444 hwif->ultra_mask = hwif->cds->udma_mask;
482 hwif->mwdma_mask = 0x07; 445 hwif->mwdma_mask = 0x07;
483 hwif->swdma_mask = 0x07; 446 hwif->swdma_mask = 0x07;
484 hwif->atapi_dma = 1; 447 hwif->atapi_dma = 1;
@@ -500,10 +463,6 @@ static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif)
500 if (!noautodma) 463 if (!noautodma)
501 hwif->autodma = 1; 464 hwif->autodma = 1;
502 hwif->drives[0].autodma = hwif->drives[1].autodma = hwif->autodma; 465 hwif->drives[0].autodma = hwif->drives[1].autodma = hwif->autodma;
503#if PDC202_DEBUG_CABLE
504 printk(KERN_DEBUG "%s: %s-pin cable\n",
505 hwif->name, hwif->udma_four ? "80" : "40");
506#endif /* PDC202_DEBUG_CABLE */
507} 466}
508 467
509static void __devinit init_dma_pdc202xx(ide_hwif_t *hwif, unsigned long dmabase) 468static void __devinit init_dma_pdc202xx(ide_hwif_t *hwif, unsigned long dmabase)
@@ -587,6 +546,7 @@ static ide_pci_device_t pdc202xx_chipsets[] __devinitdata = {
587 .autodma = AUTODMA, 546 .autodma = AUTODMA,
588 .bootable = OFF_BOARD, 547 .bootable = OFF_BOARD,
589 .extra = 16, 548 .extra = 16,
549 .udma_mask = 0x07, /* udma0-2 */
590 },{ /* 1 */ 550 },{ /* 1 */
591 .name = "PDC20262", 551 .name = "PDC20262",
592 .init_setup = init_setup_pdc202ata4, 552 .init_setup = init_setup_pdc202ata4,
@@ -597,6 +557,7 @@ static ide_pci_device_t pdc202xx_chipsets[] __devinitdata = {
597 .autodma = AUTODMA, 557 .autodma = AUTODMA,
598 .bootable = OFF_BOARD, 558 .bootable = OFF_BOARD,
599 .extra = 48, 559 .extra = 48,
560 .udma_mask = 0x1f, /* udma0-4 */
600 },{ /* 2 */ 561 },{ /* 2 */
601 .name = "PDC20263", 562 .name = "PDC20263",
602 .init_setup = init_setup_pdc202ata4, 563 .init_setup = init_setup_pdc202ata4,
@@ -607,6 +568,7 @@ static ide_pci_device_t pdc202xx_chipsets[] __devinitdata = {
607 .autodma = AUTODMA, 568 .autodma = AUTODMA,
608 .bootable = OFF_BOARD, 569 .bootable = OFF_BOARD,
609 .extra = 48, 570 .extra = 48,
571 .udma_mask = 0x1f, /* udma0-4 */
610 },{ /* 3 */ 572 },{ /* 3 */
611 .name = "PDC20265", 573 .name = "PDC20265",
612 .init_setup = init_setup_pdc20265, 574 .init_setup = init_setup_pdc20265,
@@ -617,6 +579,7 @@ static ide_pci_device_t pdc202xx_chipsets[] __devinitdata = {
617 .autodma = AUTODMA, 579 .autodma = AUTODMA,
618 .bootable = OFF_BOARD, 580 .bootable = OFF_BOARD,
619 .extra = 48, 581 .extra = 48,
582 .udma_mask = 0x3f, /* udma0-5 */
620 },{ /* 4 */ 583 },{ /* 4 */
621 .name = "PDC20267", 584 .name = "PDC20267",
622 .init_setup = init_setup_pdc202xx, 585 .init_setup = init_setup_pdc202xx,
@@ -627,6 +590,7 @@ static ide_pci_device_t pdc202xx_chipsets[] __devinitdata = {
627 .autodma = AUTODMA, 590 .autodma = AUTODMA,
628 .bootable = OFF_BOARD, 591 .bootable = OFF_BOARD,
629 .extra = 48, 592 .extra = 48,
593 .udma_mask = 0x3f, /* udma0-5 */
630 } 594 }
631}; 595};
632 596
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c
index 061d300ab8be..8b219dd63024 100644
--- a/drivers/ide/pci/piix.c
+++ b/drivers/ide/pci/piix.c
@@ -106,68 +106,6 @@
106static int no_piix_dma; 106static int no_piix_dma;
107 107
108/** 108/**
109 * piix_ratemask - compute rate mask for PIIX IDE
110 * @drive: IDE drive to compute for
111 *
112 * Returns the available modes for the PIIX IDE controller.
113 */
114
115static u8 piix_ratemask (ide_drive_t *drive)
116{
117 struct pci_dev *dev = HWIF(drive)->pci_dev;
118 u8 mode;
119
120 switch(dev->device) {
121 case PCI_DEVICE_ID_INTEL_82801EB_1:
122 mode = 3;
123 break;
124 /* UDMA 100 capable */
125 case PCI_DEVICE_ID_INTEL_82801BA_8:
126 case PCI_DEVICE_ID_INTEL_82801BA_9:
127 case PCI_DEVICE_ID_INTEL_82801CA_10:
128 case PCI_DEVICE_ID_INTEL_82801CA_11:
129 case PCI_DEVICE_ID_INTEL_82801E_11:
130 case PCI_DEVICE_ID_INTEL_82801DB_1:
131 case PCI_DEVICE_ID_INTEL_82801DB_10:
132 case PCI_DEVICE_ID_INTEL_82801DB_11:
133 case PCI_DEVICE_ID_INTEL_82801EB_11:
134 case PCI_DEVICE_ID_INTEL_ESB_2:
135 case PCI_DEVICE_ID_INTEL_ICH6_19:
136 case PCI_DEVICE_ID_INTEL_ICH7_21:
137 case PCI_DEVICE_ID_INTEL_ESB2_18:
138 case PCI_DEVICE_ID_INTEL_ICH8_6:
139 mode = 3;
140 break;
141 /* UDMA 66 capable */
142 case PCI_DEVICE_ID_INTEL_82801AA_1:
143 case PCI_DEVICE_ID_INTEL_82372FB_1:
144 mode = 2;
145 break;
146 /* UDMA 33 capable */
147 case PCI_DEVICE_ID_INTEL_82371AB:
148 case PCI_DEVICE_ID_INTEL_82443MX_1:
149 case PCI_DEVICE_ID_INTEL_82451NX:
150 case PCI_DEVICE_ID_INTEL_82801AB_1:
151 return 1;
152 /* Non UDMA capable (MWDMA2) */
153 case PCI_DEVICE_ID_INTEL_82371SB_1:
154 case PCI_DEVICE_ID_INTEL_82371FB_1:
155 case PCI_DEVICE_ID_INTEL_82371FB_0:
156 case PCI_DEVICE_ID_INTEL_82371MX:
157 default:
158 return 0;
159 }
160
161 /*
162 * If we are UDMA66 capable fall back to UDMA33
163 * if the drive cannot see an 80pin cable.
164 */
165 if (!eighty_ninty_three(drive))
166 mode = min_t(u8, mode, 1);
167 return mode;
168}
169
170/**
171 * piix_dma_2_pio - return the PIO mode matching DMA 109 * piix_dma_2_pio - return the PIO mode matching DMA
172 * @xfer_rate: transfer speed 110 * @xfer_rate: transfer speed
173 * 111 *
@@ -301,7 +239,7 @@ static int piix_tune_chipset (ide_drive_t *drive, u8 xferspeed)
301 ide_hwif_t *hwif = HWIF(drive); 239 ide_hwif_t *hwif = HWIF(drive);
302 struct pci_dev *dev = hwif->pci_dev; 240 struct pci_dev *dev = hwif->pci_dev;
303 u8 maslave = hwif->channel ? 0x42 : 0x40; 241 u8 maslave = hwif->channel ? 0x42 : 0x40;
304 u8 speed = ide_rate_filter(piix_ratemask(drive), xferspeed); 242 u8 speed = ide_rate_filter(drive, xferspeed);
305 int a_speed = 3 << (drive->dn * 4); 243 int a_speed = 3 << (drive->dn * 4);
306 int u_flag = 1 << drive->dn; 244 int u_flag = 1 << drive->dn;
307 int v_flag = 0x01 << drive->dn; 245 int v_flag = 0x01 << drive->dn;
@@ -366,30 +304,6 @@ static int piix_tune_chipset (ide_drive_t *drive, u8 xferspeed)
366} 304}
367 305
368/** 306/**
369 * piix_config_drive_for_dma - configure drive for DMA
370 * @drive: IDE drive to configure
371 *
372 * Set up a PIIX interface channel for the best available speed.
373 * We prefer UDMA if it is available and then MWDMA. If DMA is
374 * not available we switch to PIO and return 0.
375 */
376
377static int piix_config_drive_for_dma (ide_drive_t *drive)
378{
379 u8 speed = ide_dma_speed(drive, piix_ratemask(drive));
380
381 /*
382 * If no DMA speed was available or the chipset has DMA bugs
383 * then disable DMA and use PIO
384 */
385 if (!speed)
386 return 0;
387
388 (void) piix_tune_chipset(drive, speed);
389 return ide_dma_enable(drive);
390}
391
392/**
393 * piix_config_drive_xfer_rate - set up an IDE device 307 * piix_config_drive_xfer_rate - set up an IDE device
394 * @drive: IDE drive to configure 308 * @drive: IDE drive to configure
395 * 309 *
@@ -401,7 +315,7 @@ static int piix_config_drive_xfer_rate (ide_drive_t *drive)
401{ 315{
402 drive->init_speed = 0; 316 drive->init_speed = 0;
403 317
404 if (ide_use_dma(drive) && piix_config_drive_for_dma(drive)) 318 if (ide_tune_dma(drive))
405 return 0; 319 return 0;
406 320
407 if (ide_use_fast_pio(drive)) 321 if (ide_use_fast_pio(drive))
@@ -524,26 +438,14 @@ static void __devinit init_hwif_piix(ide_hwif_t *hwif)
524 hwif->ide_dma_clear_irq = &piix_dma_clear_irq; 438 hwif->ide_dma_clear_irq = &piix_dma_clear_irq;
525 439
526 hwif->atapi_dma = 1; 440 hwif->atapi_dma = 1;
527 hwif->ultra_mask = 0x3f; 441
442 hwif->ultra_mask = hwif->cds->udma_mask;
528 hwif->mwdma_mask = 0x06; 443 hwif->mwdma_mask = 0x06;
529 hwif->swdma_mask = 0x04; 444 hwif->swdma_mask = 0x04;
530 445
531 switch(hwif->pci_dev->device) { 446 if (hwif->ultra_mask & 0x78) {
532 case PCI_DEVICE_ID_INTEL_82371FB_0: 447 if (!hwif->udma_four)
533 case PCI_DEVICE_ID_INTEL_82371FB_1: 448 hwif->udma_four = piix_cable_detect(hwif);
534 case PCI_DEVICE_ID_INTEL_82371SB_1:
535 hwif->ultra_mask = 0x80;
536 break;
537 case PCI_DEVICE_ID_INTEL_82371AB:
538 case PCI_DEVICE_ID_INTEL_82443MX_1:
539 case PCI_DEVICE_ID_INTEL_82451NX:
540 case PCI_DEVICE_ID_INTEL_82801AB_1:
541 hwif->ultra_mask = 0x07;
542 break;
543 default:
544 if (!hwif->udma_four)
545 hwif->udma_four = piix_cable_detect(hwif);
546 break;
547 } 449 }
548 450
549 if (no_piix_dma) 451 if (no_piix_dma)
@@ -557,7 +459,7 @@ static void __devinit init_hwif_piix(ide_hwif_t *hwif)
557 hwif->drives[0].autodma = hwif->autodma; 459 hwif->drives[0].autodma = hwif->autodma;
558} 460}
559 461
560#define DECLARE_PIIX_DEV(name_str) \ 462#define DECLARE_PIIX_DEV(name_str, udma) \
561 { \ 463 { \
562 .name = name_str, \ 464 .name = name_str, \
563 .init_chipset = init_chipset_piix, \ 465 .init_chipset = init_chipset_piix, \
@@ -566,11 +468,12 @@ static void __devinit init_hwif_piix(ide_hwif_t *hwif)
566 .autodma = AUTODMA, \ 468 .autodma = AUTODMA, \
567 .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ 469 .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \
568 .bootable = ON_BOARD, \ 470 .bootable = ON_BOARD, \
471 .udma_mask = udma, \
569 } 472 }
570 473
571static ide_pci_device_t piix_pci_info[] __devinitdata = { 474static ide_pci_device_t piix_pci_info[] __devinitdata = {
572 /* 0 */ DECLARE_PIIX_DEV("PIIXa"), 475 /* 0 */ DECLARE_PIIX_DEV("PIIXa", 0x00), /* no udma */
573 /* 1 */ DECLARE_PIIX_DEV("PIIXb"), 476 /* 1 */ DECLARE_PIIX_DEV("PIIXb", 0x00), /* no udma */
574 477
575 /* 2 */ 478 /* 2 */
576 { /* 479 { /*
@@ -587,28 +490,28 @@ static ide_pci_device_t piix_pci_info[] __devinitdata = {
587 .flags = IDEPCI_FLAG_ISA_PORTS 490 .flags = IDEPCI_FLAG_ISA_PORTS
588 }, 491 },
589 492
590 /* 3 */ DECLARE_PIIX_DEV("PIIX3"), 493 /* 3 */ DECLARE_PIIX_DEV("PIIX3", 0x00), /* no udma */
591 /* 4 */ DECLARE_PIIX_DEV("PIIX4"), 494 /* 4 */ DECLARE_PIIX_DEV("PIIX4", 0x07), /* udma0-2 */
592 /* 5 */ DECLARE_PIIX_DEV("ICH0"), 495 /* 5 */ DECLARE_PIIX_DEV("ICH0", 0x07), /* udma0-2 */
593 /* 6 */ DECLARE_PIIX_DEV("PIIX4"), 496 /* 6 */ DECLARE_PIIX_DEV("PIIX4", 0x07), /* udma0-2 */
594 /* 7 */ DECLARE_PIIX_DEV("ICH"), 497 /* 7 */ DECLARE_PIIX_DEV("ICH", 0x1f), /* udma0-4 */
595 /* 8 */ DECLARE_PIIX_DEV("PIIX4"), 498 /* 8 */ DECLARE_PIIX_DEV("PIIX4", 0x1f), /* udma0-4 */
596 /* 9 */ DECLARE_PIIX_DEV("PIIX4"), 499 /* 9 */ DECLARE_PIIX_DEV("PIIX4", 0x07), /* udma0-2 */
597 /* 10 */ DECLARE_PIIX_DEV("ICH2"), 500 /* 10 */ DECLARE_PIIX_DEV("ICH2", 0x3f), /* udma0-5 */
598 /* 11 */ DECLARE_PIIX_DEV("ICH2M"), 501 /* 11 */ DECLARE_PIIX_DEV("ICH2M", 0x3f), /* udma0-5 */
599 /* 12 */ DECLARE_PIIX_DEV("ICH3M"), 502 /* 12 */ DECLARE_PIIX_DEV("ICH3M", 0x3f), /* udma0-5 */
600 /* 13 */ DECLARE_PIIX_DEV("ICH3"), 503 /* 13 */ DECLARE_PIIX_DEV("ICH3", 0x3f), /* udma0-5 */
601 /* 14 */ DECLARE_PIIX_DEV("ICH4"), 504 /* 14 */ DECLARE_PIIX_DEV("ICH4", 0x3f), /* udma0-5 */
602 /* 15 */ DECLARE_PIIX_DEV("ICH5"), 505 /* 15 */ DECLARE_PIIX_DEV("ICH5", 0x3f), /* udma0-5 */
603 /* 16 */ DECLARE_PIIX_DEV("C-ICH"), 506 /* 16 */ DECLARE_PIIX_DEV("C-ICH", 0x3f), /* udma0-5 */
604 /* 17 */ DECLARE_PIIX_DEV("ICH4"), 507 /* 17 */ DECLARE_PIIX_DEV("ICH4", 0x3f), /* udma0-5 */
605 /* 18 */ DECLARE_PIIX_DEV("ICH5-SATA"), 508 /* 18 */ DECLARE_PIIX_DEV("ICH5-SATA", 0x3f), /* udma0-5 */
606 /* 19 */ DECLARE_PIIX_DEV("ICH5"), 509 /* 19 */ DECLARE_PIIX_DEV("ICH5", 0x3f), /* udma0-5 */
607 /* 20 */ DECLARE_PIIX_DEV("ICH6"), 510 /* 20 */ DECLARE_PIIX_DEV("ICH6", 0x3f), /* udma0-5 */
608 /* 21 */ DECLARE_PIIX_DEV("ICH7"), 511 /* 21 */ DECLARE_PIIX_DEV("ICH7", 0x3f), /* udma0-5 */
609 /* 22 */ DECLARE_PIIX_DEV("ICH4"), 512 /* 22 */ DECLARE_PIIX_DEV("ICH4", 0x3f), /* udma0-5 */
610 /* 23 */ DECLARE_PIIX_DEV("ESB2"), 513 /* 23 */ DECLARE_PIIX_DEV("ESB2", 0x3f), /* udma0-5 */
611 /* 24 */ DECLARE_PIIX_DEV("ICH8M"), 514 /* 24 */ DECLARE_PIIX_DEV("ICH8M", 0x3f), /* udma0-5 */
612}; 515};
613 516
614/** 517/**
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c
index f84bf791f72e..cbf936325355 100644
--- a/drivers/ide/pci/scc_pata.c
+++ b/drivers/ide/pci/scc_pata.c
@@ -190,23 +190,6 @@ scc_ide_outsl(unsigned long port, void *addr, u32 count)
190} 190}
191 191
192/** 192/**
193 * scc_ratemask - Compute available modes
194 * @drive: IDE drive
195 *
196 * Compute the available speeds for the devices on the interface.
197 * Enforce UDMA33 as a limit if there is no 80pin cable present.
198 */
199
200static u8 scc_ratemask(ide_drive_t *drive)
201{
202 u8 mode = 4;
203
204 if (!eighty_ninty_three(drive))
205 mode = min(mode, (u8)1);
206 return mode;
207}
208
209/**
210 * scc_tuneproc - tune a drive PIO mode 193 * scc_tuneproc - tune a drive PIO mode
211 * @drive: drive to tune 194 * @drive: drive to tune
212 * @mode_wanted: the target operating mode 195 * @mode_wanted: the target operating mode
@@ -273,7 +256,7 @@ static void scc_tuneproc(ide_drive_t *drive, byte mode_wanted)
273static int scc_tune_chipset(ide_drive_t *drive, byte xferspeed) 256static int scc_tune_chipset(ide_drive_t *drive, byte xferspeed)
274{ 257{
275 ide_hwif_t *hwif = HWIF(drive); 258 ide_hwif_t *hwif = HWIF(drive);
276 u8 speed = ide_rate_filter(scc_ratemask(drive), xferspeed); 259 u8 speed = ide_rate_filter(drive, xferspeed);
277 struct scc_ports *ports = ide_get_hwifdata(hwif); 260 struct scc_ports *ports = ide_get_hwifdata(hwif);
278 unsigned long ctl_base = ports->ctl; 261 unsigned long ctl_base = ports->ctl;
279 unsigned long cckctrl_port = ctl_base + 0xff0; 262 unsigned long cckctrl_port = ctl_base + 0xff0;
@@ -347,7 +330,7 @@ static int scc_tune_chipset(ide_drive_t *drive, byte xferspeed)
347 330
348static int scc_config_chipset_for_dma(ide_drive_t *drive) 331static int scc_config_chipset_for_dma(ide_drive_t *drive)
349{ 332{
350 u8 speed = ide_dma_speed(drive, scc_ratemask(drive)); 333 u8 speed = ide_max_dma_mode(drive);
351 334
352 if (!speed) 335 if (!speed)
353 return 0; 336 return 0;
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c
index dbcd37a0c652..2fa6d92d16cc 100644
--- a/drivers/ide/pci/serverworks.c
+++ b/drivers/ide/pci/serverworks.c
@@ -65,16 +65,16 @@ static int check_in_drive_lists (ide_drive_t *drive, const char **list)
65 return 0; 65 return 0;
66} 66}
67 67
68static u8 svwks_ratemask (ide_drive_t *drive) 68static u8 svwks_udma_filter(ide_drive_t *drive)
69{ 69{
70 struct pci_dev *dev = HWIF(drive)->pci_dev; 70 struct pci_dev *dev = HWIF(drive)->pci_dev;
71 u8 mode = 0; 71 u8 mask = 0;
72 72
73 if (!svwks_revision) 73 if (!svwks_revision)
74 pci_read_config_byte(dev, PCI_REVISION_ID, &svwks_revision); 74 pci_read_config_byte(dev, PCI_REVISION_ID, &svwks_revision);
75 75
76 if (dev->device == PCI_DEVICE_ID_SERVERWORKS_HT1000IDE) 76 if (dev->device == PCI_DEVICE_ID_SERVERWORKS_HT1000IDE)
77 return 2; 77 return 0x1f;
78 if (dev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) { 78 if (dev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) {
79 u32 reg = 0; 79 u32 reg = 0;
80 if (isa_dev) 80 if (isa_dev)
@@ -86,25 +86,31 @@ static u8 svwks_ratemask (ide_drive_t *drive)
86 if(drive->media == ide_disk) 86 if(drive->media == ide_disk)
87 return 0; 87 return 0;
88 /* Check the OSB4 DMA33 enable bit */ 88 /* Check the OSB4 DMA33 enable bit */
89 return ((reg & 0x00004000) == 0x00004000) ? 1 : 0; 89 return ((reg & 0x00004000) == 0x00004000) ? 0x07 : 0;
90 } else if (svwks_revision < SVWKS_CSB5_REVISION_NEW) { 90 } else if (svwks_revision < SVWKS_CSB5_REVISION_NEW) {
91 return 1; 91 return 0x07;
92 } else if (svwks_revision >= SVWKS_CSB5_REVISION_NEW) { 92 } else if (svwks_revision >= SVWKS_CSB5_REVISION_NEW) {
93 u8 btr = 0; 93 u8 btr = 0, mode;
94 pci_read_config_byte(dev, 0x5A, &btr); 94 pci_read_config_byte(dev, 0x5A, &btr);
95 mode = btr & 0x3; 95 mode = btr & 0x3;
96 if (!eighty_ninty_three(drive)) 96
97 mode = min(mode, (u8)1);
98 /* If someone decides to do UDMA133 on CSB5 the same 97 /* If someone decides to do UDMA133 on CSB5 the same
99 issue will bite so be inclusive */ 98 issue will bite so be inclusive */
100 if (mode > 2 && check_in_drive_lists(drive, svwks_bad_ata100)) 99 if (mode > 2 && check_in_drive_lists(drive, svwks_bad_ata100))
101 mode = 2; 100 mode = 2;
101
102 switch(mode) {
103 case 2: mask = 0x1f; break;
104 case 1: mask = 0x07; break;
105 default: mask = 0x00; break;
106 }
102 } 107 }
103 if (((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) || 108 if (((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) ||
104 (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2)) && 109 (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2)) &&
105 (!(PCI_FUNC(dev->devfn) & 1))) 110 (!(PCI_FUNC(dev->devfn) & 1)))
106 mode = 2; 111 mask = 0x1f;
107 return mode; 112
113 return mask;
108} 114}
109 115
110static u8 svwks_csb_check (struct pci_dev *dev) 116static u8 svwks_csb_check (struct pci_dev *dev)
@@ -141,7 +147,7 @@ static int svwks_tune_chipset (ide_drive_t *drive, u8 xferspeed)
141 if (xferspeed == 255) /* PIO auto-tuning */ 147 if (xferspeed == 255) /* PIO auto-tuning */
142 speed = XFER_PIO_0 + pio; 148 speed = XFER_PIO_0 + pio;
143 else 149 else
144 speed = ide_rate_filter(svwks_ratemask(drive), xferspeed); 150 speed = ide_rate_filter(drive, xferspeed);
145 151
146 /* If we are about to put a disk into UDMA mode we screwed up. 152 /* If we are about to put a disk into UDMA mode we screwed up.
147 Our code assumes we never _ever_ do this on an OSB4 */ 153 Our code assumes we never _ever_ do this on an OSB4 */
@@ -304,7 +310,7 @@ static void svwks_tune_drive (ide_drive_t *drive, u8 pio)
304 310
305static int config_chipset_for_dma (ide_drive_t *drive) 311static int config_chipset_for_dma (ide_drive_t *drive)
306{ 312{
307 u8 speed = ide_dma_speed(drive, svwks_ratemask(drive)); 313 u8 speed = ide_max_dma_mode(drive);
308 314
309 if (!(speed)) 315 if (!(speed))
310 speed = XFER_PIO_0 + ide_get_best_pio_mode(drive, 255, 5, NULL); 316 speed = XFER_PIO_0 + ide_get_best_pio_mode(drive, 255, 5, NULL);
@@ -500,6 +506,7 @@ static void __devinit init_hwif_svwks (ide_hwif_t *hwif)
500 506
501 hwif->tuneproc = &svwks_tune_drive; 507 hwif->tuneproc = &svwks_tune_drive;
502 hwif->speedproc = &svwks_tune_chipset; 508 hwif->speedproc = &svwks_tune_chipset;
509 hwif->udma_filter = &svwks_udma_filter;
503 510
504 hwif->atapi_dma = 1; 511 hwif->atapi_dma = 1;
505 512
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index fd09b295a69d..d3185e29a38e 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -692,7 +692,7 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t * d)
692 return -EIO; 692 return -EIO;
693 693
694 /* Create /proc/ide entries */ 694 /* Create /proc/ide entries */
695 create_proc_ide_interfaces(); 695 ide_proc_register_port(hwif);
696 696
697 return 0; 697 return 0;
698} 698}
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
index 79cec50a242f..d09e74c2996e 100644
--- a/drivers/ide/pci/siimage.c
+++ b/drivers/ide/pci/siimage.c
@@ -122,45 +122,41 @@ static inline unsigned long siimage_seldev(ide_drive_t *drive, int r)
122} 122}
123 123
124/** 124/**
125 * siimage_ratemask - Compute available modes 125 * sil_udma_filter - compute UDMA mask
126 * @drive: IDE drive 126 * @drive: IDE device
127 *
128 * Compute the available UDMA speeds for the device on the interface.
127 * 129 *
128 * Compute the available speeds for the devices on the interface.
129 * For the CMD680 this depends on the clocking mode (scsc), for the 130 * For the CMD680 this depends on the clocking mode (scsc), for the
130 * SI3312 SATA controller life is a bit simpler. Enforce UDMA33 131 * SI3112 SATA controller life is a bit simpler.
131 * as a limit if there is no 80pin cable present.
132 */ 132 */
133 133
134static byte siimage_ratemask (ide_drive_t *drive) 134static u8 sil_udma_filter(ide_drive_t *drive)
135{ 135{
136 ide_hwif_t *hwif = HWIF(drive); 136 ide_hwif_t *hwif = drive->hwif;
137 u8 mode = 0, scsc = 0;
138 unsigned long base = (unsigned long) hwif->hwif_data; 137 unsigned long base = (unsigned long) hwif->hwif_data;
138 u8 mask = 0, scsc = 0;
139 139
140 if (hwif->mmio) 140 if (hwif->mmio)
141 scsc = hwif->INB(base + 0x4A); 141 scsc = hwif->INB(base + 0x4A);
142 else 142 else
143 pci_read_config_byte(hwif->pci_dev, 0x8A, &scsc); 143 pci_read_config_byte(hwif->pci_dev, 0x8A, &scsc);
144 144
145 if(is_sata(hwif)) 145 if (is_sata(hwif)) {
146 { 146 mask = strstr(drive->id->model, "Maxtor") ? 0x3f : 0x7f;
147 if(strstr(drive->id->model, "Maxtor")) 147 goto out;
148 return 3;
149 return 4;
150 } 148 }
151 149
152 if ((scsc & 0x30) == 0x10) /* 133 */ 150 if ((scsc & 0x30) == 0x10) /* 133 */
153 mode = 4; 151 mask = 0x7f;
154 else if ((scsc & 0x30) == 0x20) /* 2xPCI */ 152 else if ((scsc & 0x30) == 0x20) /* 2xPCI */
155 mode = 4; 153 mask = 0x7f;
156 else if ((scsc & 0x30) == 0x00) /* 100 */ 154 else if ((scsc & 0x30) == 0x00) /* 100 */
157 mode = 3; 155 mask = 0x3f;
158 else /* Disabled ? */ 156 else /* Disabled ? */
159 BUG(); 157 BUG();
160 158out:
161 if (!eighty_ninty_three(drive)) 159 return mask;
162 mode = min(mode, (u8)1);
163 return mode;
164} 160}
165 161
166/** 162/**
@@ -306,7 +302,7 @@ static int siimage_tune_chipset (ide_drive_t *drive, byte xferspeed)
306 ide_hwif_t *hwif = HWIF(drive); 302 ide_hwif_t *hwif = HWIF(drive);
307 u16 ultra = 0, multi = 0; 303 u16 ultra = 0, multi = 0;
308 u8 mode = 0, unit = drive->select.b.unit; 304 u8 mode = 0, unit = drive->select.b.unit;
309 u8 speed = ide_rate_filter(siimage_ratemask(drive), xferspeed); 305 u8 speed = ide_rate_filter(drive, xferspeed);
310 unsigned long base = (unsigned long)hwif->hwif_data; 306 unsigned long base = (unsigned long)hwif->hwif_data;
311 u8 scsc = 0, addr_mask = ((hwif->channel) ? 307 u8 scsc = 0, addr_mask = ((hwif->channel) ?
312 ((hwif->mmio) ? 0xF4 : 0x84) : 308 ((hwif->mmio) ? 0xF4 : 0x84) :
@@ -389,7 +385,7 @@ static int siimage_tune_chipset (ide_drive_t *drive, byte xferspeed)
389 385
390static int config_chipset_for_dma (ide_drive_t *drive) 386static int config_chipset_for_dma (ide_drive_t *drive)
391{ 387{
392 u8 speed = ide_dma_speed(drive, siimage_ratemask(drive)); 388 u8 speed = ide_max_dma_mode(drive);
393 389
394 if (!speed) 390 if (!speed)
395 return 0; 391 return 0;
@@ -989,6 +985,7 @@ static void __devinit init_hwif_siimage(ide_hwif_t *hwif)
989 hwif->tuneproc = &siimage_tuneproc; 985 hwif->tuneproc = &siimage_tuneproc;
990 hwif->reset_poll = &siimage_reset_poll; 986 hwif->reset_poll = &siimage_reset_poll;
991 hwif->pre_reset = &siimage_pre_reset; 987 hwif->pre_reset = &siimage_pre_reset;
988 hwif->udma_filter = &sil_udma_filter;
992 989
993 if(is_sata(hwif)) { 990 if(is_sata(hwif)) {
994 static int first = 1; 991 static int first = 1;
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c
index 2ba0669f36a1..2bde1b92784a 100644
--- a/drivers/ide/pci/sis5513.c
+++ b/drivers/ide/pci/sis5513.c
@@ -191,7 +191,7 @@ static char* chipset_capability[] = {
191 "ATA 133 (1st gen)", "ATA 133 (2nd gen)" 191 "ATA 133 (1st gen)", "ATA 133 (2nd gen)"
192}; 192};
193 193
194#if defined(DISPLAY_SIS_TIMINGS) && defined(CONFIG_PROC_FS) 194#if defined(DISPLAY_SIS_TIMINGS) && defined(CONFIG_IDE_PROC_FS)
195#include <linux/stat.h> 195#include <linux/stat.h>
196#include <linux/proc_fs.h> 196#include <linux/proc_fs.h>
197 197
@@ -426,17 +426,7 @@ static int sis_get_info (char *buffer, char **addr, off_t offset, int count)
426 426
427 return len > count ? count : len; 427 return len > count ? count : len;
428} 428}
429#endif /* defined(DISPLAY_SIS_TIMINGS) && defined(CONFIG_PROC_FS) */ 429#endif /* defined(DISPLAY_SIS_TIMINGS) && defined(CONFIG_IDE_PROC_FS) */
430
431static u8 sis5513_ratemask (ide_drive_t *drive)
432{
433 u8 rates[] = { 0, 0, 1, 2, 3, 3, 4, 4 };
434 u8 mode = rates[chipset_family];
435
436 if (!eighty_ninty_three(drive))
437 mode = min(mode, (u8)1);
438 return mode;
439}
440 430
441/* 431/*
442 * Configuration functions 432 * Configuration functions
@@ -563,7 +553,7 @@ static int sis5513_tune_chipset (ide_drive_t *drive, u8 xferspeed)
563 u8 drive_pci, reg, speed; 553 u8 drive_pci, reg, speed;
564 u32 regdw; 554 u32 regdw;
565 555
566 speed = ide_rate_filter(sis5513_ratemask(drive), xferspeed); 556 speed = ide_rate_filter(drive, xferspeed);
567 557
568 /* See config_art_rwp_pio for drive pci config registers */ 558 /* See config_art_rwp_pio for drive pci config registers */
569 drive_pci = 0x40; 559 drive_pci = 0x40;
@@ -648,32 +638,13 @@ static void sis5513_tune_drive (ide_drive_t *drive, u8 pio)
648 (void) config_chipset_for_pio(drive, pio); 638 (void) config_chipset_for_pio(drive, pio);
649} 639}
650 640
651/*
652 * ((id->hw_config & 0x4000|0x2000) && (HWIF(drive)->udma_four))
653 */
654static int config_chipset_for_dma (ide_drive_t *drive)
655{
656 u8 speed = ide_dma_speed(drive, sis5513_ratemask(drive));
657
658#ifdef DEBUG
659 printk("SIS5513: config_chipset_for_dma, drive %d, ultra %x\n",
660 drive->dn, drive->id->dma_ultra);
661#endif
662
663 if (!(speed))
664 return 0;
665
666 sis5513_tune_chipset(drive, speed);
667 return ide_dma_enable(drive);
668}
669
670static int sis5513_config_xfer_rate(ide_drive_t *drive) 641static int sis5513_config_xfer_rate(ide_drive_t *drive)
671{ 642{
672 config_art_rwp_pio(drive, 5); 643 config_art_rwp_pio(drive, 5);
673 644
674 drive->init_speed = 0; 645 drive->init_speed = 0;
675 646
676 if (ide_use_dma(drive) && config_chipset_for_dma(drive)) 647 if (ide_tune_dma(drive))
677 return 0; 648 return 0;
678 649
679 if (ide_use_fast_pio(drive)) 650 if (ide_use_fast_pio(drive))
@@ -826,7 +797,7 @@ static unsigned int __devinit init_chipset_sis5513 (struct pci_dev *dev, const c
826 break; 797 break;
827 } 798 }
828 799
829#if defined(DISPLAY_SIS_TIMINGS) && defined(CONFIG_PROC_FS) 800#if defined(DISPLAY_SIS_TIMINGS) && defined(CONFIG_IDE_PROC_FS)
830 if (!sis_proc) { 801 if (!sis_proc) {
831 sis_proc = 1; 802 sis_proc = 1;
832 bmide_dev = dev; 803 bmide_dev = dev;
@@ -858,6 +829,8 @@ static unsigned int __devinit ata66_sis5513 (ide_hwif_t *hwif)
858 829
859static void __devinit init_hwif_sis5513 (ide_hwif_t *hwif) 830static void __devinit init_hwif_sis5513 (ide_hwif_t *hwif)
860{ 831{
832 u8 udma_rates[] = { 0x00, 0x00, 0x07, 0x1f, 0x3f, 0x3f, 0x7f, 0x7f };
833
861 hwif->autodma = 0; 834 hwif->autodma = 0;
862 835
863 if (!hwif->irq) 836 if (!hwif->irq)
@@ -873,7 +846,8 @@ static void __devinit init_hwif_sis5513 (ide_hwif_t *hwif)
873 } 846 }
874 847
875 hwif->atapi_dma = 1; 848 hwif->atapi_dma = 1;
876 hwif->ultra_mask = 0x7f; 849
850 hwif->ultra_mask = udma_rates[chipset_family];
877 hwif->mwdma_mask = 0x07; 851 hwif->mwdma_mask = 0x07;
878 hwif->swdma_mask = 0x07; 852 hwif->swdma_mask = 0x07;
879 853
diff --git a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c
index 852ccb36da1d..c40f291f91e0 100644
--- a/drivers/ide/pci/slc90e66.c
+++ b/drivers/ide/pci/slc90e66.c
@@ -21,15 +21,6 @@
21 21
22#include <asm/io.h> 22#include <asm/io.h>
23 23
24static u8 slc90e66_ratemask (ide_drive_t *drive)
25{
26 u8 mode = 2;
27
28 if (!eighty_ninty_three(drive))
29 mode = min_t(u8, mode, 1);
30 return mode;
31}
32
33static u8 slc90e66_dma_2_pio (u8 xfer_rate) { 24static u8 slc90e66_dma_2_pio (u8 xfer_rate) {
34 switch(xfer_rate) { 25 switch(xfer_rate) {
35 case XFER_UDMA_4: 26 case XFER_UDMA_4:
@@ -122,7 +113,7 @@ static int slc90e66_tune_chipset (ide_drive_t *drive, u8 xferspeed)
122 ide_hwif_t *hwif = HWIF(drive); 113 ide_hwif_t *hwif = HWIF(drive);
123 struct pci_dev *dev = hwif->pci_dev; 114 struct pci_dev *dev = hwif->pci_dev;
124 u8 maslave = hwif->channel ? 0x42 : 0x40; 115 u8 maslave = hwif->channel ? 0x42 : 0x40;
125 u8 speed = ide_rate_filter(slc90e66_ratemask(drive), xferspeed); 116 u8 speed = ide_rate_filter(drive, xferspeed);
126 int sitre = 0, a_speed = 7 << (drive->dn * 4); 117 int sitre = 0, a_speed = 7 << (drive->dn * 4);
127 int u_speed = 0, u_flag = 1 << drive->dn; 118 int u_speed = 0, u_flag = 1 << drive->dn;
128 u16 reg4042, reg44, reg48, reg4a; 119 u16 reg4042, reg44, reg48, reg4a;
@@ -169,22 +160,11 @@ static int slc90e66_tune_chipset (ide_drive_t *drive, u8 xferspeed)
169 return ide_config_drive_speed(drive, speed); 160 return ide_config_drive_speed(drive, speed);
170} 161}
171 162
172static int slc90e66_config_drive_for_dma (ide_drive_t *drive)
173{
174 u8 speed = ide_dma_speed(drive, slc90e66_ratemask(drive));
175
176 if (!speed)
177 return 0;
178
179 (void) slc90e66_tune_chipset(drive, speed);
180 return ide_dma_enable(drive);
181}
182
183static int slc90e66_config_drive_xfer_rate (ide_drive_t *drive) 163static int slc90e66_config_drive_xfer_rate (ide_drive_t *drive)
184{ 164{
185 drive->init_speed = 0; 165 drive->init_speed = 0;
186 166
187 if (ide_use_dma(drive) && slc90e66_config_drive_for_dma(drive)) 167 if (ide_tune_dma(drive))
188 return 0; 168 return 0;
189 169
190 if (ide_use_fast_pio(drive)) 170 if (ide_use_fast_pio(drive))
diff --git a/drivers/ide/pci/tc86c001.c b/drivers/ide/pci/tc86c001.c
index 0b6d81d6ce48..cee619bb2eaf 100644
--- a/drivers/ide/pci/tc86c001.c
+++ b/drivers/ide/pci/tc86c001.c
@@ -13,18 +13,13 @@
13#include <linux/pci.h> 13#include <linux/pci.h>
14#include <linux/ide.h> 14#include <linux/ide.h>
15 15
16static inline u8 tc86c001_ratemask(ide_drive_t *drive)
17{
18 return eighty_ninty_three(drive) ? 2 : 1;
19}
20
21static int tc86c001_tune_chipset(ide_drive_t *drive, u8 speed) 16static int tc86c001_tune_chipset(ide_drive_t *drive, u8 speed)
22{ 17{
23 ide_hwif_t *hwif = HWIF(drive); 18 ide_hwif_t *hwif = HWIF(drive);
24 unsigned long scr_port = hwif->config_data + (drive->dn ? 0x02 : 0x00); 19 unsigned long scr_port = hwif->config_data + (drive->dn ? 0x02 : 0x00);
25 u16 mode, scr = hwif->INW(scr_port); 20 u16 mode, scr = hwif->INW(scr_port);
26 21
27 speed = ide_rate_filter(tc86c001_ratemask(drive), speed); 22 speed = ide_rate_filter(drive, speed);
28 23
29 switch (speed) { 24 switch (speed) {
30 case XFER_UDMA_4: mode = 0x00c0; break; 25 case XFER_UDMA_4: mode = 0x00c0; break;
@@ -172,20 +167,9 @@ static int tc86c001_busproc(ide_drive_t *drive, int state)
172 return 0; 167 return 0;
173} 168}
174 169
175static int config_chipset_for_dma(ide_drive_t *drive)
176{
177 u8 speed = ide_dma_speed(drive, tc86c001_ratemask(drive));
178
179 if (!speed)
180 return 0;
181
182 (void) tc86c001_tune_chipset(drive, speed);
183 return ide_dma_enable(drive);
184}
185
186static int tc86c001_config_drive_xfer_rate(ide_drive_t *drive) 170static int tc86c001_config_drive_xfer_rate(ide_drive_t *drive)
187{ 171{
188 if (ide_use_dma(drive) && config_chipset_for_dma(drive)) 172 if (ide_tune_dma(drive))
189 return 0; 173 return 0;
190 174
191 if (ide_use_fast_pio(drive)) 175 if (ide_use_fast_pio(drive))
diff --git a/drivers/ide/pci/triflex.c b/drivers/ide/pci/triflex.c
index 5e06179c3469..35e8c612638f 100644
--- a/drivers/ide/pci/triflex.c
+++ b/drivers/ide/pci/triflex.c
@@ -48,7 +48,7 @@ static int triflex_tune_chipset(ide_drive_t *drive, u8 xferspeed)
48 u16 timing = 0; 48 u16 timing = 0;
49 u32 triflex_timings = 0; 49 u32 triflex_timings = 0;
50 u8 unit = (drive->select.b.unit & 0x01); 50 u8 unit = (drive->select.b.unit & 0x01);
51 u8 speed = ide_rate_filter(0, xferspeed); 51 u8 speed = ide_rate_filter(drive, xferspeed);
52 52
53 pci_read_config_dword(dev, channel_offset, &triflex_timings); 53 pci_read_config_dword(dev, channel_offset, &triflex_timings);
54 54
@@ -100,20 +100,9 @@ static void triflex_tune_drive(ide_drive_t *drive, u8 pio)
100 (void) triflex_tune_chipset(drive, (XFER_PIO_0 + use_pio)); 100 (void) triflex_tune_chipset(drive, (XFER_PIO_0 + use_pio));
101} 101}
102 102
103static int triflex_config_drive_for_dma(ide_drive_t *drive)
104{
105 int speed = ide_dma_speed(drive, 0); /* No ultra speeds */
106
107 if (!speed)
108 return 0;
109
110 (void) triflex_tune_chipset(drive, speed);
111 return ide_dma_enable(drive);
112}
113
114static int triflex_config_drive_xfer_rate(ide_drive_t *drive) 103static int triflex_config_drive_xfer_rate(ide_drive_t *drive)
115{ 104{
116 if (ide_use_dma(drive) && triflex_config_drive_for_dma(drive)) 105 if (ide_tune_dma(drive))
117 return 0; 106 return 0;
118 107
119 triflex_tune_drive(drive, 255); 108 triflex_tune_drive(drive, 255);
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index a49ebe44babd..45fc36f0f219 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -1276,6 +1276,8 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
1276 /* We probe the hwif now */ 1276 /* We probe the hwif now */
1277 probe_hwif_init(hwif); 1277 probe_hwif_init(hwif);
1278 1278
1279 ide_proc_register_port(hwif);
1280
1279 return 0; 1281 return 0;
1280} 1282}
1281 1283
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
index 118fb3205ca8..67035ba4bf5e 100644
--- a/drivers/ide/setup-pci.c
+++ b/drivers/ide/setup-pci.c
@@ -702,6 +702,7 @@ out:
702 702
703int ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d) 703int ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d)
704{ 704{
705 ide_hwif_t *hwif = NULL, *mate = NULL;
705 ata_index_t index_list; 706 ata_index_t index_list;
706 int ret; 707 int ret;
707 708
@@ -710,11 +711,19 @@ int ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d)
710 goto out; 711 goto out;
711 712
712 if ((index_list.b.low & 0xf0) != 0xf0) 713 if ((index_list.b.low & 0xf0) != 0xf0)
713 probe_hwif_init_with_fixup(&ide_hwifs[index_list.b.low], d->fixup); 714 hwif = &ide_hwifs[index_list.b.low];
714 if ((index_list.b.high & 0xf0) != 0xf0) 715 if ((index_list.b.high & 0xf0) != 0xf0)
715 probe_hwif_init_with_fixup(&ide_hwifs[index_list.b.high], d->fixup); 716 mate = &ide_hwifs[index_list.b.high];
716 717
717 create_proc_ide_interfaces(); 718 if (hwif)
719 probe_hwif_init_with_fixup(hwif, d->fixup);
720 if (mate)
721 probe_hwif_init_with_fixup(mate, d->fixup);
722
723 if (hwif)
724 ide_proc_register_port(hwif);
725 if (mate)
726 ide_proc_register_port(mate);
718out: 727out:
719 return ret; 728 return ret;
720} 729}
@@ -748,13 +757,22 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2,
748 } 757 }
749 } 758 }
750 759
751 create_proc_ide_interfaces(); 760 for (i = 0; i < 2; i++) {
761 u8 idx[2] = { index_list[i].b.low, index_list[i].b.high };
762 int j;
763
764 for (j = 0; j < 2; j++) {
765 if ((idx[j] & 0xf0) != 0xf0)
766 ide_proc_register_port(ide_hwifs + idx[j]);
767 }
768 }
752out: 769out:
753 return ret; 770 return ret;
754} 771}
755 772
756EXPORT_SYMBOL_GPL(ide_setup_pci_devices); 773EXPORT_SYMBOL_GPL(ide_setup_pci_devices);
757 774
775#ifdef CONFIG_IDEPCI_PCIBUS_ORDER
758/* 776/*
759 * Module interfaces 777 * Module interfaces
760 */ 778 */
@@ -861,3 +879,4 @@ void __init ide_scan_pcibus (int scan_direction)
861 __pci_register_driver(d, d->driver.owner, d->driver.mod_name); 879 __pci_register_driver(d, d->driver.owner, d->driver.mod_name);
862 } 880 }
863} 881}
882#endif