diff options
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/ide-disk.c | 28 | ||||
-rw-r--r-- | drivers/ide/ide-taskfile.c | 56 |
2 files changed, 40 insertions, 44 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 20d357e9329..6387222dd20 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -140,7 +140,8 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, u8 lba48 = (drive->addressing == 1) ? 1 : 0; u8 command = WIN_NOP; ata_nsector_t nsectors; - struct ide_taskfile ltf, *tf = <f; + ide_task_t task; + struct ide_taskfile *tf = &task.tf; nsectors.all = (u16) rq->nr_sectors; @@ -156,12 +157,8 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, ide_map_sg(drive, rq); } - if (IDE_CONTROL_REG) - hwif->OUTB(drive->ctl, IDE_CONTROL_REG); - - /* FIXME: SELECT_MASK(drive, 0) ? */ - - memset(tf, 0, sizeof(*tf)); + memset(&task, 0, sizeof(task)); + task.tf_flags = IDE_TFLAG_NO_SELECT_MASK; /* FIXME? */ if (drive->select.b.lba) { if (lba48) { @@ -185,6 +182,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, tf->hob_lbah, tf->hob_lbam, tf->hob_lbal, tf->lbah, tf->lbam, tf->lbal); #endif + task.tf_flags |= IDE_TFLAG_LBA48; } else { tf->nsect = nsectors.b.low; tf->lbal = block; @@ -208,21 +206,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, tf->device = head; } - if (drive->select.b.lba && lba48) { - hwif->OUTB(tf->hob_feature, IDE_FEATURE_REG); - hwif->OUTB(tf->hob_nsect, IDE_NSECTOR_REG); - hwif->OUTB(tf->hob_lbal, IDE_SECTOR_REG); - hwif->OUTB(tf->hob_lbam, IDE_LCYL_REG); - hwif->OUTB(tf->hob_lbah, IDE_HCYL_REG); - } - - hwif->OUTB(tf->feature, IDE_FEATURE_REG); - hwif->OUTB(tf->nsect, IDE_NSECTOR_REG); - hwif->OUTB(tf->lbal, IDE_SECTOR_REG); - hwif->OUTB(tf->lbam, IDE_LCYL_REG); - hwif->OUTB(tf->lbah, IDE_HCYL_REG); - - hwif->OUTB(tf->device | drive->select.all, IDE_SELECT_REG); + ide_tf_load(drive, &task); if (dma) { if (!hwif->dma_setup(drive)) { diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 5a1a9f7846b..a79150e6be0 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c @@ -63,6 +63,37 @@ static void taskfile_output_data(ide_drive_t *drive, void *buffer, u32 wcount) } } +void ide_tf_load(ide_drive_t *drive, ide_task_t *task) +{ + ide_hwif_t *hwif = drive->hwif; + struct ide_taskfile *tf = &task->tf; + u8 HIHI = (task->tf_flags & IDE_TFLAG_LBA48) ? 0xE0 : 0xEF; + + if (IDE_CONTROL_REG) + hwif->OUTB(drive->ctl, IDE_CONTROL_REG); /* clear nIEN */ + + if ((task->tf_flags & IDE_TFLAG_NO_SELECT_MASK) == 0) + SELECT_MASK(drive, 0); + + if (task->tf_flags & IDE_TFLAG_LBA48) { + hwif->OUTB(tf->hob_feature, IDE_FEATURE_REG); + hwif->OUTB(tf->hob_nsect, IDE_NSECTOR_REG); + hwif->OUTB(tf->hob_lbal, IDE_SECTOR_REG); + hwif->OUTB(tf->hob_lbam, IDE_LCYL_REG); + hwif->OUTB(tf->hob_lbah, IDE_HCYL_REG); + } + + hwif->OUTB(tf->feature, IDE_FEATURE_REG); + hwif->OUTB(tf->nsect, IDE_NSECTOR_REG); + hwif->OUTB(tf->lbal, IDE_SECTOR_REG); + hwif->OUTB(tf->lbam, IDE_LCYL_REG); + hwif->OUTB(tf->lbah, IDE_HCYL_REG); + + hwif->OUTB((tf->device & HIHI) | drive->select.all, IDE_SELECT_REG); +} + +EXPORT_SYMBOL_GPL(ide_tf_load); + int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf) { ide_task_t args; @@ -83,30 +114,11 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) { ide_hwif_t *hwif = HWIF(drive); struct ide_taskfile *tf = &task->tf; - u8 HIHI = (drive->addressing == 1) ? 0xE0 : 0xEF; - /* ALL Command Block Executions SHALL clear nIEN, unless otherwise */ - if (IDE_CONTROL_REG) { - /* clear nIEN */ - hwif->OUTB(drive->ctl, IDE_CONTROL_REG); - } - SELECT_MASK(drive, 0); + if (drive->addressing == 1) + task->tf_flags |= IDE_TFLAG_LBA48; - if (drive->addressing == 1) { - hwif->OUTB(tf->hob_feature, IDE_FEATURE_REG); - hwif->OUTB(tf->hob_nsect, IDE_NSECTOR_REG); - hwif->OUTB(tf->hob_lbal, IDE_SECTOR_REG); - hwif->OUTB(tf->hob_lbam, IDE_LCYL_REG); - hwif->OUTB(tf->hob_lbah, IDE_HCYL_REG); - } - - hwif->OUTB(tf->feature, IDE_FEATURE_REG); - hwif->OUTB(tf->nsect, IDE_NSECTOR_REG); - hwif->OUTB(tf->lbal, IDE_SECTOR_REG); - hwif->OUTB(tf->lbam, IDE_LCYL_REG); - hwif->OUTB(tf->lbah, IDE_HCYL_REG); - - hwif->OUTB((tf->device & HIHI) | drive->select.all, IDE_SELECT_REG); + ide_tf_load(drive, task); if (task->handler != NULL) { if (task->prehandler != NULL) { |