diff options
Diffstat (limited to 'drivers/ide/ide-probe.c')
-rw-r--r-- | drivers/ide/ide-probe.c | 73 |
1 files changed, 34 insertions, 39 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index a4b65b321f51..862f02603f9b 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -264,6 +264,7 @@ err_misc: | |||
264 | static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) | 264 | static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) |
265 | { | 265 | { |
266 | ide_hwif_t *hwif = HWIF(drive); | 266 | ide_hwif_t *hwif = HWIF(drive); |
267 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
267 | int use_altstatus = 0, rc; | 268 | int use_altstatus = 0, rc; |
268 | unsigned long timeout; | 269 | unsigned long timeout; |
269 | u8 s = 0, a = 0; | 270 | u8 s = 0, a = 0; |
@@ -271,7 +272,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) | |||
271 | /* take a deep breath */ | 272 | /* take a deep breath */ |
272 | msleep(50); | 273 | msleep(50); |
273 | 274 | ||
274 | if (hwif->io_ports[IDE_CONTROL_OFFSET]) { | 275 | if (io_ports->ctl_addr) { |
275 | a = ide_read_altstatus(drive); | 276 | a = ide_read_altstatus(drive); |
276 | s = ide_read_status(drive); | 277 | s = ide_read_status(drive); |
277 | if ((a ^ s) & ~INDEX_STAT) | 278 | if ((a ^ s) & ~INDEX_STAT) |
@@ -289,10 +290,10 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) | |||
289 | */ | 290 | */ |
290 | if ((cmd == WIN_PIDENTIFY)) | 291 | if ((cmd == WIN_PIDENTIFY)) |
291 | /* disable dma & overlap */ | 292 | /* disable dma & overlap */ |
292 | hwif->OUTB(0, hwif->io_ports[IDE_FEATURE_OFFSET]); | 293 | hwif->OUTB(0, io_ports->feature_addr); |
293 | 294 | ||
294 | /* ask drive for ID */ | 295 | /* ask drive for ID */ |
295 | hwif->OUTB(cmd, hwif->io_ports[IDE_COMMAND_OFFSET]); | 296 | hwif->OUTB(cmd, io_ports->command_addr); |
296 | 297 | ||
297 | timeout = ((cmd == WIN_IDENTIFY) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2; | 298 | timeout = ((cmd == WIN_IDENTIFY) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2; |
298 | timeout += jiffies; | 299 | timeout += jiffies; |
@@ -353,7 +354,7 @@ static int try_to_identify (ide_drive_t *drive, u8 cmd) | |||
353 | * interrupts during the identify-phase that | 354 | * interrupts during the identify-phase that |
354 | * the irq handler isn't expecting. | 355 | * the irq handler isn't expecting. |
355 | */ | 356 | */ |
356 | if (hwif->io_ports[IDE_CONTROL_OFFSET]) { | 357 | if (hwif->io_ports.ctl_addr) { |
357 | if (!hwif->irq) { | 358 | if (!hwif->irq) { |
358 | autoprobe = 1; | 359 | autoprobe = 1; |
359 | cookie = probe_irq_on(); | 360 | cookie = probe_irq_on(); |
@@ -393,7 +394,7 @@ static int ide_busy_sleep(ide_hwif_t *hwif) | |||
393 | 394 | ||
394 | do { | 395 | do { |
395 | msleep(50); | 396 | msleep(50); |
396 | stat = hwif->INB(hwif->io_ports[IDE_STATUS_OFFSET]); | 397 | stat = hwif->INB(hwif->io_ports.status_addr); |
397 | if ((stat & BUSY_STAT) == 0) | 398 | if ((stat & BUSY_STAT) == 0) |
398 | return 0; | 399 | return 0; |
399 | } while (time_before(jiffies, timeout)); | 400 | } while (time_before(jiffies, timeout)); |
@@ -425,6 +426,7 @@ static int ide_busy_sleep(ide_hwif_t *hwif) | |||
425 | static int do_probe (ide_drive_t *drive, u8 cmd) | 426 | static int do_probe (ide_drive_t *drive, u8 cmd) |
426 | { | 427 | { |
427 | ide_hwif_t *hwif = HWIF(drive); | 428 | ide_hwif_t *hwif = HWIF(drive); |
429 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
428 | int rc; | 430 | int rc; |
429 | u8 stat; | 431 | u8 stat; |
430 | 432 | ||
@@ -445,7 +447,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
445 | msleep(50); | 447 | msleep(50); |
446 | SELECT_DRIVE(drive); | 448 | SELECT_DRIVE(drive); |
447 | msleep(50); | 449 | msleep(50); |
448 | if (hwif->INB(hwif->io_ports[IDE_SELECT_OFFSET]) != drive->select.all && | 450 | if (hwif->INB(io_ports->device_addr) != drive->select.all && |
449 | !drive->present) { | 451 | !drive->present) { |
450 | if (drive->select.b.unit != 0) { | 452 | if (drive->select.b.unit != 0) { |
451 | /* exit with drive0 selected */ | 453 | /* exit with drive0 selected */ |
@@ -472,17 +474,13 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
472 | if (stat == (BUSY_STAT | READY_STAT)) | 474 | if (stat == (BUSY_STAT | READY_STAT)) |
473 | return 4; | 475 | return 4; |
474 | 476 | ||
475 | if ((rc == 1 && cmd == WIN_PIDENTIFY) && | 477 | if (rc == 1 && cmd == WIN_PIDENTIFY) { |
476 | ((drive->autotune == IDE_TUNE_DEFAULT) || | ||
477 | (drive->autotune == IDE_TUNE_AUTO))) { | ||
478 | printk(KERN_ERR "%s: no response (status = 0x%02x), " | 478 | printk(KERN_ERR "%s: no response (status = 0x%02x), " |
479 | "resetting drive\n", drive->name, stat); | 479 | "resetting drive\n", drive->name, stat); |
480 | msleep(50); | 480 | msleep(50); |
481 | hwif->OUTB(drive->select.all, | 481 | hwif->OUTB(drive->select.all, io_ports->device_addr); |
482 | hwif->io_ports[IDE_SELECT_OFFSET]); | ||
483 | msleep(50); | 482 | msleep(50); |
484 | hwif->OUTB(WIN_SRST, | 483 | hwif->OUTB(WIN_SRST, io_ports->command_addr); |
485 | hwif->io_ports[IDE_COMMAND_OFFSET]); | ||
486 | (void)ide_busy_sleep(hwif); | 484 | (void)ide_busy_sleep(hwif); |
487 | rc = try_to_identify(drive, cmd); | 485 | rc = try_to_identify(drive, cmd); |
488 | } | 486 | } |
@@ -518,7 +516,7 @@ static void enable_nest (ide_drive_t *drive) | |||
518 | printk("%s: enabling %s -- ", hwif->name, drive->id->model); | 516 | printk("%s: enabling %s -- ", hwif->name, drive->id->model); |
519 | SELECT_DRIVE(drive); | 517 | SELECT_DRIVE(drive); |
520 | msleep(50); | 518 | msleep(50); |
521 | hwif->OUTB(EXABYTE_ENABLE_NEST, hwif->io_ports[IDE_COMMAND_OFFSET]); | 519 | hwif->OUTB(EXABYTE_ENABLE_NEST, hwif->io_ports.command_addr); |
522 | 520 | ||
523 | if (ide_busy_sleep(hwif)) { | 521 | if (ide_busy_sleep(hwif)) { |
524 | printk(KERN_CONT "failed (timeout)\n"); | 522 | printk(KERN_CONT "failed (timeout)\n"); |
@@ -800,14 +798,9 @@ static int ide_probe_port(ide_hwif_t *hwif) | |||
800 | if (drive->present) | 798 | if (drive->present) |
801 | rc = 0; | 799 | rc = 0; |
802 | } | 800 | } |
803 | if (hwif->io_ports[IDE_CONTROL_OFFSET] && hwif->reset) { | 801 | |
804 | printk(KERN_WARNING "%s: reset\n", hwif->name); | ||
805 | hwif->OUTB(12, hwif->io_ports[IDE_CONTROL_OFFSET]); | ||
806 | udelay(10); | ||
807 | hwif->OUTB(8, hwif->io_ports[IDE_CONTROL_OFFSET]); | ||
808 | (void)ide_busy_sleep(hwif); | ||
809 | } | ||
810 | local_irq_restore(flags); | 802 | local_irq_restore(flags); |
803 | |||
811 | /* | 804 | /* |
812 | * Use cached IRQ number. It might be (and is...) changed by probe | 805 | * Use cached IRQ number. It might be (and is...) changed by probe |
813 | * code above | 806 | * code above |
@@ -834,12 +827,7 @@ static void ide_port_tune_devices(ide_hwif_t *hwif) | |||
834 | ide_drive_t *drive = &hwif->drives[unit]; | 827 | ide_drive_t *drive = &hwif->drives[unit]; |
835 | 828 | ||
836 | if (drive->present) { | 829 | if (drive->present) { |
837 | if (drive->autotune == IDE_TUNE_AUTO) | 830 | ide_set_max_pio(drive); |
838 | ide_set_max_pio(drive); | ||
839 | |||
840 | if (drive->autotune != IDE_TUNE_DEFAULT && | ||
841 | drive->autotune != IDE_TUNE_AUTO) | ||
842 | continue; | ||
843 | 831 | ||
844 | drive->nice1 = 1; | 832 | drive->nice1 = 1; |
845 | 833 | ||
@@ -994,6 +982,7 @@ static void ide_port_setup_devices(ide_hwif_t *hwif) | |||
994 | */ | 982 | */ |
995 | static int init_irq (ide_hwif_t *hwif) | 983 | static int init_irq (ide_hwif_t *hwif) |
996 | { | 984 | { |
985 | struct ide_io_ports *io_ports = &hwif->io_ports; | ||
997 | unsigned int index; | 986 | unsigned int index; |
998 | ide_hwgroup_t *hwgroup; | 987 | ide_hwgroup_t *hwgroup; |
999 | ide_hwif_t *match = NULL; | 988 | ide_hwif_t *match = NULL; |
@@ -1077,9 +1066,9 @@ static int init_irq (ide_hwif_t *hwif) | |||
1077 | if (IDE_CHIPSET_IS_PCI(hwif->chipset)) | 1066 | if (IDE_CHIPSET_IS_PCI(hwif->chipset)) |
1078 | sa = IRQF_SHARED; | 1067 | sa = IRQF_SHARED; |
1079 | 1068 | ||
1080 | if (hwif->io_ports[IDE_CONTROL_OFFSET]) | 1069 | if (io_ports->ctl_addr) |
1081 | /* clear nIEN */ | 1070 | /* clear nIEN */ |
1082 | hwif->OUTB(0x08, hwif->io_ports[IDE_CONTROL_OFFSET]); | 1071 | hwif->OUTB(0x08, io_ports->ctl_addr); |
1083 | 1072 | ||
1084 | if (request_irq(hwif->irq,&ide_intr,sa,hwif->name,hwgroup)) | 1073 | if (request_irq(hwif->irq,&ide_intr,sa,hwif->name,hwgroup)) |
1085 | goto out_unlink; | 1074 | goto out_unlink; |
@@ -1095,12 +1084,11 @@ static int init_irq (ide_hwif_t *hwif) | |||
1095 | 1084 | ||
1096 | #if !defined(__mc68000__) | 1085 | #if !defined(__mc68000__) |
1097 | printk("%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name, | 1086 | printk("%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name, |
1098 | hwif->io_ports[IDE_DATA_OFFSET], | 1087 | io_ports->data_addr, io_ports->status_addr, |
1099 | hwif->io_ports[IDE_DATA_OFFSET]+7, | 1088 | io_ports->ctl_addr, hwif->irq); |
1100 | hwif->io_ports[IDE_CONTROL_OFFSET], hwif->irq); | ||
1101 | #else | 1089 | #else |
1102 | printk("%s at 0x%08lx on irq %d", hwif->name, | 1090 | printk("%s at 0x%08lx on irq %d", hwif->name, |
1103 | hwif->io_ports[IDE_DATA_OFFSET], hwif->irq); | 1091 | io_ports->data_addr, hwif->irq); |
1104 | #endif /* __mc68000__ */ | 1092 | #endif /* __mc68000__ */ |
1105 | if (match) | 1093 | if (match) |
1106 | printk(" (%sed with %s)", | 1094 | printk(" (%sed with %s)", |
@@ -1242,8 +1230,8 @@ static int hwif_init(ide_hwif_t *hwif) | |||
1242 | int old_irq; | 1230 | int old_irq; |
1243 | 1231 | ||
1244 | if (!hwif->irq) { | 1232 | if (!hwif->irq) { |
1245 | if (!(hwif->irq = ide_default_irq(hwif->io_ports[IDE_DATA_OFFSET]))) | 1233 | hwif->irq = ide_default_irq(hwif->io_ports.data_addr); |
1246 | { | 1234 | if (!hwif->irq) { |
1247 | printk("%s: DISABLED, NO IRQ\n", hwif->name); | 1235 | printk("%s: DISABLED, NO IRQ\n", hwif->name); |
1248 | return 0; | 1236 | return 0; |
1249 | } | 1237 | } |
@@ -1272,7 +1260,8 @@ static int hwif_init(ide_hwif_t *hwif) | |||
1272 | * It failed to initialise. Find the default IRQ for | 1260 | * It failed to initialise. Find the default IRQ for |
1273 | * this port and try that. | 1261 | * this port and try that. |
1274 | */ | 1262 | */ |
1275 | if (!(hwif->irq = ide_default_irq(hwif->io_ports[IDE_DATA_OFFSET]))) { | 1263 | hwif->irq = ide_default_irq(hwif->io_ports.data_addr); |
1264 | if (!hwif->irq) { | ||
1276 | printk("%s: Disabled unable to get IRQ %d.\n", | 1265 | printk("%s: Disabled unable to get IRQ %d.\n", |
1277 | hwif->name, old_irq); | 1266 | hwif->name, old_irq); |
1278 | goto out; | 1267 | goto out; |
@@ -1336,8 +1325,6 @@ static void ide_port_init_devices(ide_hwif_t *hwif) | |||
1336 | drive->unmask = 1; | 1325 | drive->unmask = 1; |
1337 | if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS) | 1326 | if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS) |
1338 | drive->no_unmask = 1; | 1327 | drive->no_unmask = 1; |
1339 | if ((hwif->host_flags & IDE_HFLAG_NO_AUTOTUNE) == 0) | ||
1340 | drive->autotune = 1; | ||
1341 | } | 1328 | } |
1342 | 1329 | ||
1343 | if (port_ops && port_ops->port_init_devs) | 1330 | if (port_ops && port_ops->port_init_devs) |
@@ -1518,13 +1505,20 @@ int ide_device_add_all(u8 *idx, const struct ide_port_info *d) | |||
1518 | int i, rc = 0; | 1505 | int i, rc = 0; |
1519 | 1506 | ||
1520 | for (i = 0; i < MAX_HWIFS; i++) { | 1507 | for (i = 0; i < MAX_HWIFS; i++) { |
1521 | if (d == NULL || idx[i] == 0xff) { | 1508 | if (idx[i] == 0xff) { |
1522 | mate = NULL; | 1509 | mate = NULL; |
1523 | continue; | 1510 | continue; |
1524 | } | 1511 | } |
1525 | 1512 | ||
1526 | hwif = &ide_hwifs[idx[i]]; | 1513 | hwif = &ide_hwifs[idx[i]]; |
1527 | 1514 | ||
1515 | ide_port_apply_params(hwif); | ||
1516 | |||
1517 | if (d == NULL) { | ||
1518 | mate = NULL; | ||
1519 | continue; | ||
1520 | } | ||
1521 | |||
1528 | if (d->chipset != ide_etrax100 && (i & 1) && mate) { | 1522 | if (d->chipset != ide_etrax100 && (i & 1) && mate) { |
1529 | hwif->mate = mate; | 1523 | hwif->mate = mate; |
1530 | mate->mate = hwif; | 1524 | mate->mate = hwif; |
@@ -1621,6 +1615,7 @@ EXPORT_SYMBOL_GPL(ide_device_add); | |||
1621 | 1615 | ||
1622 | void ide_port_scan(ide_hwif_t *hwif) | 1616 | void ide_port_scan(ide_hwif_t *hwif) |
1623 | { | 1617 | { |
1618 | ide_port_apply_params(hwif); | ||
1624 | ide_port_cable_detect(hwif); | 1619 | ide_port_cable_detect(hwif); |
1625 | ide_port_init_devices(hwif); | 1620 | ide_port_init_devices(hwif); |
1626 | 1621 | ||