aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/pci
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2007-07-19 19:11:56 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2007-07-19 19:11:56 -0400
commit7dd00083b1160b560fa2a0a486799b57baa5d035 (patch)
tree22e8cf2c740d55ff9b4fdf57b9593a357d0092b7 /drivers/ide/pci
parent31c4df441cce6b9ec541e7f722f50bfbc617dd76 (diff)
ide: add ide_pio_cycle_time() helper (take 2)
* Add ide_pio_cycle_time() helper. * Use it in ali14xx/ht6560b/qd65xx/cmd64{0,x}/sl82c105 and pmac host drivers (previously cycle time given by the device was only used for "pio" == 255). * Remove no longer needed ide_pio_data_t.cycle_time field. v2: * Fix "ata_" prefix (Noticed by Jeff). Acked-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')
-rw-r--r--drivers/ide/pci/cmd640.c12
-rw-r--r--drivers/ide/pci/cmd64x.c10
-rw-r--r--drivers/ide/pci/sl82c105.c16
3 files changed, 19 insertions, 19 deletions
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c
index dff21597e643..9f67ffc43421 100644
--- a/drivers/ide/pci/cmd640.c
+++ b/drivers/ide/pci/cmd640.c
@@ -633,9 +633,8 @@ static void cmd640_set_mode (unsigned int index, u8 pio_mode, unsigned int cycle
633 */ 633 */
634static void cmd640_tune_drive (ide_drive_t *drive, u8 mode_wanted) 634static void cmd640_tune_drive (ide_drive_t *drive, u8 mode_wanted)
635{ 635{
636 unsigned int index = 0, cycle_time;
636 u8 b; 637 u8 b;
637 ide_pio_data_t d;
638 unsigned int index = 0;
639 638
640 while (drive != cmd_drives[index]) { 639 while (drive != cmd_drives[index]) {
641 if (++index > 3) { 640 if (++index > 3) {
@@ -662,13 +661,12 @@ static void cmd640_tune_drive (ide_drive_t *drive, u8 mode_wanted)
662 return; 661 return;
663 } 662 }
664 663
665 (void) ide_get_best_pio_mode (drive, mode_wanted, 5, &d); 664 mode_wanted = ide_get_best_pio_mode(drive, mode_wanted, 5, NULL);
666 cmd640_set_mode (index, d.pio_mode, d.cycle_time); 665 cycle_time = ide_pio_cycle_time(drive, mode_wanted);
666 cmd640_set_mode(index, mode_wanted, cycle_time);
667 667
668 printk("%s: selected cmd640 PIO mode%d (%dns)", 668 printk("%s: selected cmd640 PIO mode%d (%dns)",
669 drive->name, 669 drive->name, mode_wanted, cycle_time);
670 d.pio_mode,
671 d.cycle_time);
672 670
673 display_clocks(index); 671 display_clocks(index);
674} 672}
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c
index 8150a023dd7a..c383f6dc67dd 100644
--- a/drivers/ide/pci/cmd64x.c
+++ b/drivers/ide/pci/cmd64x.c
@@ -221,16 +221,18 @@ static u8 cmd64x_tune_pio (ide_drive_t *drive, u8 mode_wanted)
221{ 221{
222 ide_hwif_t *hwif = HWIF(drive); 222 ide_hwif_t *hwif = HWIF(drive);
223 struct pci_dev *dev = hwif->pci_dev; 223 struct pci_dev *dev = hwif->pci_dev;
224 ide_pio_data_t pio; 224 unsigned int cycle_time;
225 u8 pio_mode, setup_count, arttim = 0; 225 u8 pio_mode, setup_count, arttim = 0;
226 static const u8 setup_values[] = {0x40, 0x40, 0x40, 0x80, 0, 0xc0}; 226 static const u8 setup_values[] = {0x40, 0x40, 0x40, 0x80, 0, 0xc0};
227 static const u8 arttim_regs[4] = {ARTTIM0, ARTTIM1, ARTTIM23, ARTTIM23}; 227 static const u8 arttim_regs[4] = {ARTTIM0, ARTTIM1, ARTTIM23, ARTTIM23};
228 pio_mode = ide_get_best_pio_mode(drive, mode_wanted, 5, &pio); 228
229 pio_mode = ide_get_best_pio_mode(drive, mode_wanted, 5, NULL);
230 cycle_time = ide_pio_cycle_time(drive, pio_mode);
229 231
230 cmdprintk("%s: PIO mode wanted %d, selected %d (%d ns)\n", 232 cmdprintk("%s: PIO mode wanted %d, selected %d (%d ns)\n",
231 drive->name, mode_wanted, pio_mode, pio.cycle_time); 233 drive->name, mode_wanted, pio_mode, cycle_time);
232 234
233 program_cycle_times(drive, pio.cycle_time, 235 program_cycle_times(drive, cycle_time,
234 ide_pio_timings[pio_mode].active_time); 236 ide_pio_timings[pio_mode].active_time);
235 237
236 setup_count = quantize_timing(ide_pio_timings[pio_mode].setup_time, 238 setup_count = quantize_timing(ide_pio_timings[pio_mode].setup_time,
diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c
index f4637d29aaf5..cc5f69b7514f 100644
--- a/drivers/ide/pci/sl82c105.c
+++ b/drivers/ide/pci/sl82c105.c
@@ -52,13 +52,13 @@
52 * Convert a PIO mode and cycle time to the required on/off times 52 * Convert a PIO mode and cycle time to the required on/off times
53 * for the interface. This has protection against runaway timings. 53 * for the interface. This has protection against runaway timings.
54 */ 54 */
55static unsigned int get_pio_timings(ide_drive_t *drive, ide_pio_data_t *p) 55static unsigned int get_pio_timings(ide_drive_t *drive, u8 pio)
56{ 56{
57 unsigned int cmd_on, cmd_off; 57 unsigned int cmd_on, cmd_off;
58 u8 iordy = 0; 58 u8 iordy = 0;
59 59
60 cmd_on = (ide_pio_timings[p->pio_mode].active_time + 29) / 30; 60 cmd_on = (ide_pio_timings[pio].active_time + 29) / 30;
61 cmd_off = (p->cycle_time - 30 * cmd_on + 29) / 30; 61 cmd_off = (ide_pio_cycle_time(drive, pio) - 30 * cmd_on + 29) / 30;
62 62
63 if (cmd_on == 0) 63 if (cmd_on == 0)
64 cmd_on = 1; 64 cmd_on = 1;
@@ -66,7 +66,7 @@ static unsigned int get_pio_timings(ide_drive_t *drive, ide_pio_data_t *p)
66 if (cmd_off == 0) 66 if (cmd_off == 0)
67 cmd_off = 1; 67 cmd_off = 1;
68 68
69 if (p->pio_mode > 2 || ide_dev_has_iordy(drive->id)) 69 if (pio > 2 || ide_dev_has_iordy(drive->id))
70 iordy = 0x40; 70 iordy = 0x40;
71 71
72 return (cmd_on - 1) << 8 | (cmd_off - 1) | iordy; 72 return (cmd_on - 1) << 8 | (cmd_off - 1) | iordy;
@@ -79,14 +79,13 @@ static u8 sl82c105_tune_pio(ide_drive_t *drive, u8 pio)
79{ 79{
80 struct pci_dev *dev = HWIF(drive)->pci_dev; 80 struct pci_dev *dev = HWIF(drive)->pci_dev;
81 int reg = 0x44 + drive->dn * 4; 81 int reg = 0x44 + drive->dn * 4;
82 ide_pio_data_t p;
83 u16 drv_ctrl; 82 u16 drv_ctrl;
84 83
85 DBG(("sl82c105_tune_pio(drive:%s, pio:%u)\n", drive->name, pio)); 84 DBG(("sl82c105_tune_pio(drive:%s, pio:%u)\n", drive->name, pio));
86 85
87 pio = ide_get_best_pio_mode(drive, pio, 5, &p); 86 pio = ide_get_best_pio_mode(drive, pio, 5, NULL);
88 87
89 drv_ctrl = get_pio_timings(drive, &p); 88 drv_ctrl = get_pio_timings(drive, pio);
90 89
91 /* 90 /*
92 * Store the PIO timings so that we can restore them 91 * Store the PIO timings so that we can restore them
@@ -105,7 +104,8 @@ static u8 sl82c105_tune_pio(ide_drive_t *drive, u8 pio)
105 } 104 }
106 105
107 printk(KERN_DEBUG "%s: selected %s (%dns) (%04X)\n", drive->name, 106 printk(KERN_DEBUG "%s: selected %s (%dns) (%04X)\n", drive->name,
108 ide_xfer_verbose(pio + XFER_PIO_0), p.cycle_time, drv_ctrl); 107 ide_xfer_verbose(pio + XFER_PIO_0),
108 ide_pio_cycle_time(drive, pio), drv_ctrl);
109 109
110 return pio; 110 return pio;
111} 111}