diff options
Diffstat (limited to 'drivers/ide/legacy/qd65xx.c')
| -rw-r--r-- | drivers/ide/legacy/qd65xx.c | 130 |
1 files changed, 35 insertions, 95 deletions
diff --git a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c index 6e820c7c5c6b..15a99aae0cf9 100644 --- a/drivers/ide/legacy/qd65xx.c +++ b/drivers/ide/legacy/qd65xx.c | |||
| @@ -37,6 +37,8 @@ | |||
| 37 | #include <asm/system.h> | 37 | #include <asm/system.h> |
| 38 | #include <asm/io.h> | 38 | #include <asm/io.h> |
| 39 | 39 | ||
| 40 | #define DRV_NAME "qd65xx" | ||
| 41 | |||
| 40 | #include "qd65xx.h" | 42 | #include "qd65xx.h" |
| 41 | 43 | ||
| 42 | /* | 44 | /* |
| @@ -304,7 +306,20 @@ static void __init qd6580_port_init_devs(ide_hwif_t *hwif) | |||
| 304 | hwif->drives[1].drive_data = t2; | 306 | hwif->drives[1].drive_data = t2; |
| 305 | } | 307 | } |
| 306 | 308 | ||
| 309 | static const struct ide_port_ops qd6500_port_ops = { | ||
| 310 | .port_init_devs = qd6500_port_init_devs, | ||
| 311 | .set_pio_mode = qd6500_set_pio_mode, | ||
| 312 | .selectproc = qd65xx_select, | ||
| 313 | }; | ||
| 314 | |||
| 315 | static const struct ide_port_ops qd6580_port_ops = { | ||
| 316 | .port_init_devs = qd6580_port_init_devs, | ||
| 317 | .set_pio_mode = qd6580_set_pio_mode, | ||
| 318 | .selectproc = qd65xx_select, | ||
| 319 | }; | ||
| 320 | |||
| 307 | static const struct ide_port_info qd65xx_port_info __initdata = { | 321 | static const struct ide_port_info qd65xx_port_info __initdata = { |
| 322 | .name = DRV_NAME, | ||
| 308 | .chipset = ide_qd65xx, | 323 | .chipset = ide_qd65xx, |
| 309 | .host_flags = IDE_HFLAG_IO_32BIT | | 324 | .host_flags = IDE_HFLAG_IO_32BIT | |
| 310 | IDE_HFLAG_NO_DMA | | 325 | IDE_HFLAG_NO_DMA | |
| @@ -321,10 +336,8 @@ static const struct ide_port_info qd65xx_port_info __initdata = { | |||
| 321 | 336 | ||
| 322 | static int __init qd_probe(int base) | 337 | static int __init qd_probe(int base) |
| 323 | { | 338 | { |
| 324 | ide_hwif_t *hwif; | 339 | int rc; |
| 325 | u8 config, unit; | 340 | u8 config, unit, control; |
| 326 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
| 327 | hw_regs_t hw[2]; | ||
| 328 | struct ide_port_info d = qd65xx_port_info; | 341 | struct ide_port_info d = qd65xx_port_info; |
| 329 | 342 | ||
| 330 | config = inb(QD_CONFIG_PORT); | 343 | config = inb(QD_CONFIG_PORT); |
| @@ -337,21 +350,11 @@ static int __init qd_probe(int base) | |||
| 337 | if (unit) | 350 | if (unit) |
| 338 | d.host_flags |= IDE_HFLAG_QD_2ND_PORT; | 351 | d.host_flags |= IDE_HFLAG_QD_2ND_PORT; |
| 339 | 352 | ||
| 340 | memset(&hw, 0, sizeof(hw)); | 353 | switch (config & 0xf0) { |
| 341 | 354 | case QD_CONFIG_QD6500: | |
| 342 | ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); | ||
| 343 | hw[0].irq = 14; | ||
| 344 | |||
| 345 | ide_std_init_ports(&hw[1], 0x170, 0x376); | ||
| 346 | hw[1].irq = 15; | ||
| 347 | |||
| 348 | if ((config & 0xf0) == QD_CONFIG_QD6500) { | ||
| 349 | |||
| 350 | if (qd_testreg(base)) | 355 | if (qd_testreg(base)) |
| 351 | return -ENODEV; /* bad register */ | 356 | return -ENODEV; /* bad register */ |
| 352 | 357 | ||
| 353 | /* qd6500 found */ | ||
| 354 | |||
| 355 | if (config & QD_CONFIG_DISABLED) { | 358 | if (config & QD_CONFIG_DISABLED) { |
| 356 | printk(KERN_WARNING "qd6500 is disabled !\n"); | 359 | printk(KERN_WARNING "qd6500 is disabled !\n"); |
| 357 | return -ENODEV; | 360 | return -ENODEV; |
| @@ -361,37 +364,14 @@ static int __init qd_probe(int base) | |||
| 361 | printk(KERN_DEBUG "qd6500: config=%#x, ID3=%u\n", | 364 | printk(KERN_DEBUG "qd6500: config=%#x, ID3=%u\n", |
| 362 | config, QD_ID3); | 365 | config, QD_ID3); |
| 363 | 366 | ||
| 367 | d.port_ops = &qd6500_port_ops; | ||
| 364 | d.host_flags |= IDE_HFLAG_SINGLE; | 368 | d.host_flags |= IDE_HFLAG_SINGLE; |
| 365 | 369 | break; | |
| 366 | hwif = ide_find_port_slot(&d); | 370 | case QD_CONFIG_QD6580_A: |
| 367 | if (hwif == NULL) | 371 | case QD_CONFIG_QD6580_B: |
| 368 | return -ENOENT; | ||
| 369 | |||
| 370 | ide_init_port_hw(hwif, &hw[unit]); | ||
| 371 | |||
| 372 | hwif->config_data = (base << 8) | config; | ||
| 373 | |||
| 374 | hwif->port_init_devs = qd6500_port_init_devs; | ||
| 375 | hwif->set_pio_mode = qd6500_set_pio_mode; | ||
| 376 | hwif->selectproc = qd65xx_select; | ||
| 377 | |||
| 378 | idx[unit] = hwif->index; | ||
| 379 | |||
| 380 | ide_device_add(idx, &d); | ||
| 381 | |||
| 382 | return 1; | ||
| 383 | } | ||
| 384 | |||
| 385 | if (((config & 0xf0) == QD_CONFIG_QD6580_A) || | ||
| 386 | ((config & 0xf0) == QD_CONFIG_QD6580_B)) { | ||
| 387 | |||
| 388 | u8 control; | ||
| 389 | |||
| 390 | if (qd_testreg(base) || qd_testreg(base + 0x02)) | 372 | if (qd_testreg(base) || qd_testreg(base + 0x02)) |
| 391 | return -ENODEV; /* bad registers */ | 373 | return -ENODEV; /* bad registers */ |
| 392 | 374 | ||
| 393 | /* qd6580 found */ | ||
| 394 | |||
| 395 | control = inb(QD_CONTROL_PORT); | 375 | control = inb(QD_CONTROL_PORT); |
| 396 | 376 | ||
| 397 | printk(KERN_NOTICE "qd6580 at %#x\n", base); | 377 | printk(KERN_NOTICE "qd6580 at %#x\n", base); |
| @@ -400,63 +380,23 @@ static int __init qd_probe(int base) | |||
| 400 | 380 | ||
| 401 | outb(QD_DEF_CONTR, QD_CONTROL_PORT); | 381 | outb(QD_DEF_CONTR, QD_CONTROL_PORT); |
| 402 | 382 | ||
| 403 | if (control & QD_CONTR_SEC_DISABLED) { | 383 | d.port_ops = &qd6580_port_ops; |
| 404 | /* secondary disabled */ | 384 | if (control & QD_CONTR_SEC_DISABLED) |
| 405 | |||
| 406 | printk(KERN_INFO "qd6580: single IDE board\n"); | ||
| 407 | |||
| 408 | d.host_flags |= IDE_HFLAG_SINGLE; | 385 | d.host_flags |= IDE_HFLAG_SINGLE; |
| 409 | 386 | ||
| 410 | hwif = ide_find_port_slot(&d); | 387 | printk(KERN_INFO "qd6580: %s IDE board\n", |
| 411 | if (hwif == NULL) | 388 | (control & QD_CONTR_SEC_DISABLED) ? "single" : "dual"); |
| 412 | return -ENOENT; | 389 | break; |
| 413 | 390 | default: | |
| 414 | ide_init_port_hw(hwif, &hw[unit]); | 391 | return -ENODEV; |
| 415 | 392 | } | |
| 416 | hwif->config_data = (base << 8) | config; | ||
| 417 | |||
| 418 | hwif->port_init_devs = qd6580_port_init_devs; | ||
| 419 | hwif->set_pio_mode = qd6580_set_pio_mode; | ||
| 420 | hwif->selectproc = qd65xx_select; | ||
| 421 | 393 | ||
| 422 | idx[unit] = hwif->index; | 394 | rc = ide_legacy_device_add(&d, (base << 8) | config); |
| 423 | 395 | ||
| 424 | ide_device_add(idx, &d); | 396 | if (d.host_flags & IDE_HFLAG_SINGLE) |
| 397 | return (rc == 0) ? 1 : rc; | ||
| 425 | 398 | ||
| 426 | return 1; | 399 | return rc; |
| 427 | } else { | ||
| 428 | ide_hwif_t *mate; | ||
| 429 | |||
| 430 | /* secondary enabled */ | ||
| 431 | printk(KERN_INFO "qd6580: dual IDE board\n"); | ||
| 432 | |||
| 433 | hwif = ide_find_port(); | ||
| 434 | if (hwif) { | ||
| 435 | ide_init_port_hw(hwif, &hw[0]); | ||
| 436 | hwif->config_data = (base << 8) | config; | ||
| 437 | hwif->port_init_devs = qd6580_port_init_devs; | ||
| 438 | hwif->set_pio_mode = qd6580_set_pio_mode; | ||
| 439 | hwif->selectproc = qd65xx_select; | ||
| 440 | idx[0] = hwif->index; | ||
| 441 | } | ||
| 442 | |||
| 443 | mate = ide_find_port(); | ||
| 444 | if (mate) { | ||
| 445 | ide_init_port_hw(mate, &hw[1]); | ||
| 446 | mate->config_data = (base << 8) | config; | ||
| 447 | mate->port_init_devs = qd6580_port_init_devs; | ||
| 448 | mate->set_pio_mode = qd6580_set_pio_mode; | ||
| 449 | mate->selectproc = qd65xx_select; | ||
| 450 | idx[1] = mate->index; | ||
| 451 | } | ||
| 452 | |||
| 453 | ide_device_add(idx, &qd65xx_port_info); | ||
| 454 | |||
| 455 | return 0; /* no other qd65xx possible */ | ||
| 456 | } | ||
| 457 | } | ||
| 458 | /* no qd65xx found */ | ||
| 459 | return -ENODEV; | ||
| 460 | } | 400 | } |
| 461 | 401 | ||
| 462 | int probe_qd65xx = 0; | 402 | int probe_qd65xx = 0; |
