22 #include <linux/module.h>
23 #include <linux/types.h>
24 #include <linux/kernel.h>
34 #define DRV_NAME "qd65xx"
84 static int timings[4]={-1,-1,-1,-1};
94 u8 index = (( (QD_TIMREG(drive)) & 0x80 ) >> 7) |
95 (QD_TIMREG(drive) & 0x02);
97 if (timings[index] != QD_TIMING(drive))
98 outb(timings[index] = QD_TIMING(drive), QD_TIMREG(drive));
111 static u8 qd6500_compute_timing (
ide_hwif_t *hwif,
int active_time,
int recovery_time)
117 act_cyc = 9 -
IDE_IN(active_time * clk / 1000 + 1, 2, 9);
118 rec_cyc = 15 -
IDE_IN(recovery_time * clk / 1000 + 1, 0, 15);
120 act_cyc = 8 -
IDE_IN(active_time * clk / 1000 + 1, 1, 8);
121 rec_cyc = 18 -
IDE_IN(recovery_time * clk / 1000 + 1, 3, 18);
124 return (rec_cyc << 4) | 0x08 | act_cyc;
133 static u8 qd6580_compute_timing (
int active_time,
int recovery_time)
138 act_cyc = 17 -
IDE_IN(active_time * clk / 1000 + 1, 2, 17);
139 rec_cyc = 15 -
IDE_IN(recovery_time * clk / 1000 + 1, 2, 15);
141 return (rec_cyc << 4) | act_cyc;
151 int *active_time,
int *recovery_time)
153 struct qd65xx_timing_s *
p;
163 for (p = qd65xx_timing ; p->offset != -1 ; p++) {
164 if (!
strncmp(p->model, model+p->offset, 4)) {
166 *active_time = p->active;
167 *recovery_time = p->recovery;
182 unsigned long data = (
unsigned long)ide_get_drivedata(drive);
186 ide_set_drivedata(drive, (
void *)data);
194 int active_time = 175;
195 int recovery_time = 415;
198 if (!qd_find_disk_type(drive, &active_time, &recovery_time) &&
207 qd_set_timing(drive, qd6500_compute_timing(drive->
hwif,
208 active_time, recovery_time));
215 unsigned int cycle_time;
216 int active_time = 175;
217 int recovery_time = 415;
220 if (drive->
id && !qd_find_disk_type(drive, &active_time, &recovery_time)) {
226 if (cycle_time >= 110) {
228 recovery_time = cycle_time - 102;
233 if (cycle_time >= 69) {
235 recovery_time = cycle_time - 61;
240 if (cycle_time >= 180) {
242 recovery_time = cycle_time - 120;
245 recovery_time = cycle_time - active_time;
254 "and post-write buffer on %s.\n",
258 qd_set_timing(drive, qd6580_compute_timing(active_time, recovery_time));
273 savereg =
inb_p(port);
275 readreg =
inb_p(port);
280 printk(
KERN_ERR "Outch ! the probe for qd65xx isn't reliable !\n");
281 printk(
KERN_ERR "Please contact maintainers to tell about your hardware\n");
311 ide_set_drivedata(drive, (
void *)((drive->
dn & 1) ? t2 : t1));
314 static const struct ide_tp_ops qd65xx_tp_ops = {
320 .dev_select = qd65xx_dev_select,
329 .init_dev = qd6500_init_dev,
330 .set_pio_mode = qd6500_set_pio_mode,
334 .init_dev = qd6580_init_dev,
335 .set_pio_mode = qd6580_set_pio_mode,
340 .tp_ops = &qd65xx_tp_ops,
354 static int __init qd_probe(
int base)
370 switch (config & 0xf0) {
372 if (qd_testreg(base))
389 if (qd_testreg(base) || qd_testreg(base + 0x02))
405 (control & QD_CONTR_SEC_DISABLED) ?
"single" :
"dual");
414 return (rc == 0) ? 1 :
rc;
419 static bool probe_qd65xx;
424 static int __init qd65xx_init(
void)
428 if (probe_qd65xx == 0)
431 rc1 = qd_probe(0x30);
433 rc2 = qd_probe(0xb0);
435 if (rc1 < 0 && rc2 < 0)