diff options
Diffstat (limited to 'drivers/ide/legacy/qd65xx.c')
-rw-r--r-- | drivers/ide/legacy/qd65xx.c | 64 |
1 files changed, 21 insertions, 43 deletions
diff --git a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c index 0c81d2d0b94..912e73853fa 100644 --- a/drivers/ide/legacy/qd65xx.c +++ b/drivers/ide/legacy/qd65xx.c | |||
@@ -89,26 +89,6 @@ | |||
89 | 89 | ||
90 | static int timings[4]={-1,-1,-1,-1}; /* stores current timing for each timer */ | 90 | static int timings[4]={-1,-1,-1,-1}; /* stores current timing for each timer */ |
91 | 91 | ||
92 | static void qd_write_reg (u8 content, unsigned long reg) | ||
93 | { | ||
94 | unsigned long flags; | ||
95 | |||
96 | spin_lock_irqsave(&ide_lock, flags); | ||
97 | outb(content,reg); | ||
98 | spin_unlock_irqrestore(&ide_lock, flags); | ||
99 | } | ||
100 | |||
101 | static u8 __init qd_read_reg (unsigned long reg) | ||
102 | { | ||
103 | unsigned long flags; | ||
104 | u8 read; | ||
105 | |||
106 | spin_lock_irqsave(&ide_lock, flags); | ||
107 | read = inb(reg); | ||
108 | spin_unlock_irqrestore(&ide_lock, flags); | ||
109 | return read; | ||
110 | } | ||
111 | |||
112 | /* | 92 | /* |
113 | * qd_select: | 93 | * qd_select: |
114 | * | 94 | * |
@@ -121,7 +101,7 @@ static void qd_select (ide_drive_t *drive) | |||
121 | (QD_TIMREG(drive) & 0x02); | 101 | (QD_TIMREG(drive) & 0x02); |
122 | 102 | ||
123 | if (timings[index] != QD_TIMING(drive)) | 103 | if (timings[index] != QD_TIMING(drive)) |
124 | qd_write_reg(timings[index] = QD_TIMING(drive), QD_TIMREG(drive)); | 104 | outb(timings[index] = QD_TIMING(drive), QD_TIMREG(drive)); |
125 | } | 105 | } |
126 | 106 | ||
127 | /* | 107 | /* |
@@ -284,7 +264,7 @@ static void qd6580_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
284 | } | 264 | } |
285 | 265 | ||
286 | if (!HWIF(drive)->channel && drive->media != ide_disk) { | 266 | if (!HWIF(drive)->channel && drive->media != ide_disk) { |
287 | qd_write_reg(0x5f, QD_CONTROL_PORT); | 267 | outb(0x5f, QD_CONTROL_PORT); |
288 | printk(KERN_WARNING "%s: ATAPI: disabled read-ahead FIFO " | 268 | printk(KERN_WARNING "%s: ATAPI: disabled read-ahead FIFO " |
289 | "and post-write buffer on %s.\n", | 269 | "and post-write buffer on %s.\n", |
290 | drive->name, HWIF(drive)->name); | 270 | drive->name, HWIF(drive)->name); |
@@ -301,16 +281,15 @@ static void qd6580_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
301 | 281 | ||
302 | static int __init qd_testreg(int port) | 282 | static int __init qd_testreg(int port) |
303 | { | 283 | { |
304 | u8 savereg; | ||
305 | u8 readreg; | ||
306 | unsigned long flags; | 284 | unsigned long flags; |
285 | u8 savereg, readreg; | ||
307 | 286 | ||
308 | spin_lock_irqsave(&ide_lock, flags); | 287 | local_irq_save(flags); |
309 | savereg = inb_p(port); | 288 | savereg = inb_p(port); |
310 | outb_p(QD_TESTVAL, port); /* safe value */ | 289 | outb_p(QD_TESTVAL, port); /* safe value */ |
311 | readreg = inb_p(port); | 290 | readreg = inb_p(port); |
312 | outb(savereg, port); | 291 | outb(savereg, port); |
313 | spin_unlock_irqrestore(&ide_lock, flags); | 292 | local_irq_restore(flags); |
314 | 293 | ||
315 | if (savereg == QD_TESTVAL) { | 294 | if (savereg == QD_TESTVAL) { |
316 | printk(KERN_ERR "Outch ! the probe for qd65xx isn't reliable !\n"); | 295 | printk(KERN_ERR "Outch ! the probe for qd65xx isn't reliable !\n"); |
@@ -364,13 +343,13 @@ static void __exit qd_unsetup(ide_hwif_t *hwif) | |||
364 | 343 | ||
365 | if (set_pio_mode == (void *)qd6500_set_pio_mode) { | 344 | if (set_pio_mode == (void *)qd6500_set_pio_mode) { |
366 | // will do it for both | 345 | // will do it for both |
367 | qd_write_reg(QD6500_DEF_DATA, QD_TIMREG(&hwif->drives[0])); | 346 | outb(QD6500_DEF_DATA, QD_TIMREG(&hwif->drives[0])); |
368 | } else if (set_pio_mode == (void *)qd6580_set_pio_mode) { | 347 | } else if (set_pio_mode == (void *)qd6580_set_pio_mode) { |
369 | if (QD_CONTROL(hwif) & QD_CONTR_SEC_DISABLED) { | 348 | if (QD_CONTROL(hwif) & QD_CONTR_SEC_DISABLED) { |
370 | qd_write_reg(QD6580_DEF_DATA, QD_TIMREG(&hwif->drives[0])); | 349 | outb(QD6580_DEF_DATA, QD_TIMREG(&hwif->drives[0])); |
371 | qd_write_reg(QD6580_DEF_DATA2, QD_TIMREG(&hwif->drives[1])); | 350 | outb(QD6580_DEF_DATA2, QD_TIMREG(&hwif->drives[1])); |
372 | } else { | 351 | } else { |
373 | qd_write_reg(hwif->channel ? QD6580_DEF_DATA2 : QD6580_DEF_DATA, QD_TIMREG(&hwif->drives[0])); | 352 | outb(hwif->channel ? QD6580_DEF_DATA2 : QD6580_DEF_DATA, QD_TIMREG(&hwif->drives[0])); |
374 | } | 353 | } |
375 | } else { | 354 | } else { |
376 | printk(KERN_WARNING "Unknown qd65xx tuning fonction !\n"); | 355 | printk(KERN_WARNING "Unknown qd65xx tuning fonction !\n"); |
@@ -389,10 +368,11 @@ static void __exit qd_unsetup(ide_hwif_t *hwif) | |||
389 | static int __init qd_probe(int base) | 368 | static int __init qd_probe(int base) |
390 | { | 369 | { |
391 | ide_hwif_t *hwif; | 370 | ide_hwif_t *hwif; |
371 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
392 | u8 config; | 372 | u8 config; |
393 | u8 unit; | 373 | u8 unit; |
394 | 374 | ||
395 | config = qd_read_reg(QD_CONFIG_PORT); | 375 | config = inb(QD_CONFIG_PORT); |
396 | 376 | ||
397 | if (! ((config & QD_CONFIG_BASEPORT) >> 1 == (base == 0xb0)) ) | 377 | if (! ((config & QD_CONFIG_BASEPORT) >> 1 == (base == 0xb0)) ) |
398 | return 1; | 378 | return 1; |
@@ -419,9 +399,9 @@ static int __init qd_probe(int base) | |||
419 | 399 | ||
420 | hwif->set_pio_mode = &qd6500_set_pio_mode; | 400 | hwif->set_pio_mode = &qd6500_set_pio_mode; |
421 | 401 | ||
422 | probe_hwif_init(hwif); | 402 | idx[0] = unit; |
423 | 403 | ||
424 | ide_proc_register_port(hwif); | 404 | ide_device_add(idx); |
425 | 405 | ||
426 | return 1; | 406 | return 1; |
427 | } | 407 | } |
@@ -436,7 +416,7 @@ static int __init qd_probe(int base) | |||
436 | 416 | ||
437 | /* qd6580 found */ | 417 | /* qd6580 found */ |
438 | 418 | ||
439 | control = qd_read_reg(QD_CONTROL_PORT); | 419 | control = inb(QD_CONTROL_PORT); |
440 | 420 | ||
441 | printk(KERN_NOTICE "qd6580 at %#x\n", base); | 421 | printk(KERN_NOTICE "qd6580 at %#x\n", base); |
442 | printk(KERN_DEBUG "qd6580: config=%#x, control=%#x, ID3=%u\n", | 422 | printk(KERN_DEBUG "qd6580: config=%#x, control=%#x, ID3=%u\n", |
@@ -453,11 +433,11 @@ static int __init qd_probe(int base) | |||
453 | 433 | ||
454 | hwif->set_pio_mode = &qd6580_set_pio_mode; | 434 | hwif->set_pio_mode = &qd6580_set_pio_mode; |
455 | 435 | ||
456 | probe_hwif_init(hwif); | 436 | idx[0] = unit; |
457 | 437 | ||
458 | qd_write_reg(QD_DEF_CONTR,QD_CONTROL_PORT); | 438 | ide_device_add(idx); |
459 | 439 | ||
460 | ide_proc_register_port(hwif); | 440 | outb(QD_DEF_CONTR, QD_CONTROL_PORT); |
461 | 441 | ||
462 | return 1; | 442 | return 1; |
463 | } else { | 443 | } else { |
@@ -474,19 +454,17 @@ static int __init qd_probe(int base) | |||
474 | 454 | ||
475 | hwif->set_pio_mode = &qd6580_set_pio_mode; | 455 | hwif->set_pio_mode = &qd6580_set_pio_mode; |
476 | 456 | ||
477 | probe_hwif_init(hwif); | ||
478 | |||
479 | qd_setup(mate, base, config | (control << 8), | 457 | qd_setup(mate, base, config | (control << 8), |
480 | QD6580_DEF_DATA2, QD6580_DEF_DATA2); | 458 | QD6580_DEF_DATA2, QD6580_DEF_DATA2); |
481 | 459 | ||
482 | mate->set_pio_mode = &qd6580_set_pio_mode; | 460 | mate->set_pio_mode = &qd6580_set_pio_mode; |
483 | 461 | ||
484 | probe_hwif_init(mate); | 462 | idx[0] = 0; |
463 | idx[1] = 1; | ||
485 | 464 | ||
486 | qd_write_reg(QD_DEF_CONTR,QD_CONTROL_PORT); | 465 | ide_device_add(idx); |
487 | 466 | ||
488 | ide_proc_register_port(hwif); | 467 | outb(QD_DEF_CONTR, QD_CONTROL_PORT); |
489 | ide_proc_register_port(mate); | ||
490 | 468 | ||
491 | return 0; /* no other qd65xx possible */ | 469 | return 0; /* no other qd65xx possible */ |
492 | } | 470 | } |