aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/pci/opti621.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2007-10-11 17:54:00 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2007-10-11 17:54:00 -0400
commit26bcb879c03254545a19c6700fe5bcef6f21e7b1 (patch)
treedc35f1a7d7860fe0de268ff92189ff0884b689d3 /drivers/ide/pci/opti621.c
parent842c19ad6fc0dbd9ac9d2f8527466201802934cf (diff)
ide: add ide_set{_max}_pio() (take 4)
* Add IDE_HFLAG_ABUSE_{PREFETCH,FAST_DEVSEL,DMA_MODES} flags and set them in ht6560, cmd640, cmd64x and sc1200 host drivers. * Add set_pio_mode_abuse() for checking if host driver has a non-standard ->tuneproc() implementation and use it in do_special(). * Add ide_set_pio() for setting PIO mode (it uses hwif->pio_mask to find the maximum PIO mode supported by the host), also add ide_set_max_pio() wrapper for ide_set_pio() to use for auto-tuning. Convert users of ->tuneproc to use ide_set{_max}_pio() where possible. This leaves only do_special(), set_using_pio(), ide_hwif_restore() and ide_set_pio() as a direct users of ->tuneproc. * Remove no longer needed ide_get_best_pio_mode() calls and printk-s reporting PIO mode selected from ->tuneproc implementations. * Rename ->tuneproc hook to ->set_pio_mode and make 'pio' argument const. * Remove stale comment from ide_config_drive_speed(). v2: * Fix "ata_" prefix (Noticed by Jeff). v3: * Minor cleanups/fixups per Sergei's suggestions. v4: * Fix compile problem in drivers/ide/pci/cmd640.c (Noticed by Andrew Morton). * Improve some ->set_pio_mode comments. Reviewed-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Cc: Jeff Garzik <jeff@garzik.org> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/pci/opti621.c')
-rw-r--r--drivers/ide/pci/opti621.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/ide/pci/opti621.c b/drivers/ide/pci/opti621.c
index 3a2bb2723515..9fa06393469a 100644
--- a/drivers/ide/pci/opti621.c
+++ b/drivers/ide/pci/opti621.c
@@ -47,7 +47,7 @@
47 * The main problem with OPTi is that some timings for master 47 * The main problem with OPTi is that some timings for master
48 * and slave must be the same. For example, if you have master 48 * and slave must be the same. For example, if you have master
49 * PIO 3 and slave PIO 0, driver have to set some timings of 49 * PIO 3 and slave PIO 0, driver have to set some timings of
50 * master for PIO 0. Second problem is that opti621_tune_drive 50 * master for PIO 0. Second problem is that opti621_set_pio_mode
51 * got only one drive to set, but have to set both drives. 51 * got only one drive to set, but have to set both drives.
52 * This is solved in compute_pios. If you don't set 52 * This is solved in compute_pios. If you don't set
53 * the second drive, compute_pios use ide_get_best_pio_mode 53 * the second drive, compute_pios use ide_get_best_pio_mode
@@ -103,7 +103,7 @@
103 103
104#include <asm/io.h> 104#include <asm/io.h>
105 105
106#define OPTI621_MAX_PIO 3 106//#define OPTI621_MAX_PIO 3
107/* In fact, I do not have any PIO 4 drive 107/* In fact, I do not have any PIO 4 drive
108 * (address: 25 ns, data: 70 ns, recovery: 35 ns), 108 * (address: 25 ns, data: 70 ns, recovery: 35 ns),
109 * but OPTi 82C621 is programmable and it can do (minimal values): 109 * but OPTi 82C621 is programmable and it can do (minimal values):
@@ -136,8 +136,8 @@ static int reg_base;
136#define PIO_NOT_EXIST 254 136#define PIO_NOT_EXIST 254
137#define PIO_DONT_KNOW 255 137#define PIO_DONT_KNOW 255
138 138
139/* there are stored pio numbers from other calls of opti621_tune_drive */ 139/* there are stored pio numbers from other calls of opti621_set_pio_mode */
140static void compute_pios(ide_drive_t *drive, u8 pio) 140static void compute_pios(ide_drive_t *drive, const u8 pio)
141/* Store values into drive->drive_data 141/* Store values into drive->drive_data
142 * second_contr - 0 for primary controller, 1 for secondary 142 * second_contr - 0 for primary controller, 1 for secondary
143 * slave_drive - 0 -> pio is for master, 1 -> pio is for slave 143 * slave_drive - 0 -> pio is for master, 1 -> pio is for slave
@@ -147,12 +147,13 @@ static void compute_pios(ide_drive_t *drive, u8 pio)
147 int d; 147 int d;
148 ide_hwif_t *hwif = HWIF(drive); 148 ide_hwif_t *hwif = HWIF(drive);
149 149
150 drive->drive_data = ide_get_best_pio_mode(drive, pio, OPTI621_MAX_PIO); 150 drive->drive_data = pio;
151
151 for (d = 0; d < 2; ++d) { 152 for (d = 0; d < 2; ++d) {
152 drive = &hwif->drives[d]; 153 drive = &hwif->drives[d];
153 if (drive->present) { 154 if (drive->present) {
154 if (drive->drive_data == PIO_DONT_KNOW) 155 if (drive->drive_data == PIO_DONT_KNOW)
155 drive->drive_data = ide_get_best_pio_mode(drive, 255, OPTI621_MAX_PIO); 156 drive->drive_data = ide_get_best_pio_mode(drive, 255, 3);
156#ifdef OPTI621_DEBUG 157#ifdef OPTI621_DEBUG
157 printk("%s: Selected PIO mode %d\n", 158 printk("%s: Selected PIO mode %d\n",
158 drive->name, drive->drive_data); 159 drive->name, drive->drive_data);
@@ -240,8 +241,7 @@ static void compute_clocks(int pio, pio_clocks_t *clks)
240 241
241} 242}
242 243
243/* Main tune procedure, called from tuneproc. */ 244static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio)
244static void opti621_tune_drive (ide_drive_t *drive, u8 pio)
245{ 245{
246 /* primary and secondary drives share some registers, 246 /* primary and secondary drives share some registers,
247 * so we have to program both drives 247 * so we have to program both drives
@@ -331,7 +331,8 @@ static void __devinit init_hwif_opti621 (ide_hwif_t *hwif)
331 hwif->autodma = 0; 331 hwif->autodma = 0;
332 hwif->drives[0].drive_data = PIO_DONT_KNOW; 332 hwif->drives[0].drive_data = PIO_DONT_KNOW;
333 hwif->drives[1].drive_data = PIO_DONT_KNOW; 333 hwif->drives[1].drive_data = PIO_DONT_KNOW;
334 hwif->tuneproc = &opti621_tune_drive; 334
335 hwif->set_pio_mode = &opti621_set_pio_mode;
335 336
336 if (!(hwif->dma_base)) 337 if (!(hwif->dma_base))
337 return; 338 return;