aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-01-25 16:17:07 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-01-25 16:17:07 -0500
commit9e42237f26cf517a3f682505f03a3a8d89b3b35d (patch)
tree93b94dd8e1b1d9e257ed3ef84682bf4c0a22ad11 /drivers
parent2bd06b23e2a099abbf550202f62cd433e01f83e7 (diff)
ide: add ide_tf_load() helper
Based on the earlier work by Tejun Heo. * Add 'tf_flags' field (for taskfile flags) to ide_task_t. * Add IDE_TFLAG_LBA48 taskfile flag for LBA48 taskfiles. * Add IDE_TFLAG_NO_SELECT_MASK taskfile flag for __ide_do_rw_disk() which doesn't use SELECT_MASK() (looks like a bug but it requires some more investigation). * Split off ide_tf_load() helper from do_rw_taskfile(). * Convert __ide_do_rw_disk() to use ide_tf_load(). There should be no functionality changes caused by this patch. Cc: Tejun Heo <htejun@gmail.com> Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ide/ide-disk.c28
-rw-r--r--drivers/ide/ide-taskfile.c56
2 files changed, 40 insertions, 44 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 20d357e9329d..6387222dd200 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,
140 u8 lba48 = (drive->addressing == 1) ? 1 : 0; 140 u8 lba48 = (drive->addressing == 1) ? 1 : 0;
141 u8 command = WIN_NOP; 141 u8 command = WIN_NOP;
142 ata_nsector_t nsectors; 142 ata_nsector_t nsectors;
143 struct ide_taskfile ltf, *tf = &ltf; 143 ide_task_t task;
144 struct ide_taskfile *tf = &task.tf;
144 145
145 nsectors.all = (u16) rq->nr_sectors; 146 nsectors.all = (u16) rq->nr_sectors;
146 147
@@ -156,12 +157,8 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
156 ide_map_sg(drive, rq); 157 ide_map_sg(drive, rq);
157 } 158 }
158 159
159 if (IDE_CONTROL_REG) 160 memset(&task, 0, sizeof(task));
160 hwif->OUTB(drive->ctl, IDE_CONTROL_REG); 161 task.tf_flags = IDE_TFLAG_NO_SELECT_MASK; /* FIXME? */
161
162 /* FIXME: SELECT_MASK(drive, 0) ? */
163
164 memset(tf, 0, sizeof(*tf));
165 162
166 if (drive->select.b.lba) { 163 if (drive->select.b.lba) {
167 if (lba48) { 164 if (lba48) {
@@ -185,6 +182,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
185 tf->hob_lbah, tf->hob_lbam, tf->hob_lbal, 182 tf->hob_lbah, tf->hob_lbam, tf->hob_lbal,
186 tf->lbah, tf->lbam, tf->lbal); 183 tf->lbah, tf->lbam, tf->lbal);
187#endif 184#endif
185 task.tf_flags |= IDE_TFLAG_LBA48;
188 } else { 186 } else {
189 tf->nsect = nsectors.b.low; 187 tf->nsect = nsectors.b.low;
190 tf->lbal = block; 188 tf->lbal = block;
@@ -208,21 +206,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
208 tf->device = head; 206 tf->device = head;
209 } 207 }
210 208
211 if (drive->select.b.lba && lba48) { 209 ide_tf_load(drive, &task);
212 hwif->OUTB(tf->hob_feature, IDE_FEATURE_REG);
213 hwif->OUTB(tf->hob_nsect, IDE_NSECTOR_REG);
214 hwif->OUTB(tf->hob_lbal, IDE_SECTOR_REG);
215 hwif->OUTB(tf->hob_lbam, IDE_LCYL_REG);
216 hwif->OUTB(tf->hob_lbah, IDE_HCYL_REG);
217 }
218
219 hwif->OUTB(tf->feature, IDE_FEATURE_REG);
220 hwif->OUTB(tf->nsect, IDE_NSECTOR_REG);
221 hwif->OUTB(tf->lbal, IDE_SECTOR_REG);
222 hwif->OUTB(tf->lbam, IDE_LCYL_REG);
223 hwif->OUTB(tf->lbah, IDE_HCYL_REG);
224
225 hwif->OUTB(tf->device | drive->select.all, IDE_SELECT_REG);
226 210
227 if (dma) { 211 if (dma) {
228 if (!hwif->dma_setup(drive)) { 212 if (!hwif->dma_setup(drive)) {
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index 5a1a9f7846b6..a79150e6be07 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)
63 } 63 }
64} 64}
65 65
66void ide_tf_load(ide_drive_t *drive, ide_task_t *task)
67{
68 ide_hwif_t *hwif = drive->hwif;
69 struct ide_taskfile *tf = &task->tf;
70 u8 HIHI = (task->tf_flags & IDE_TFLAG_LBA48) ? 0xE0 : 0xEF;
71
72 if (IDE_CONTROL_REG)
73 hwif->OUTB(drive->ctl, IDE_CONTROL_REG); /* clear nIEN */
74
75 if ((task->tf_flags & IDE_TFLAG_NO_SELECT_MASK) == 0)
76 SELECT_MASK(drive, 0);
77
78 if (task->tf_flags & IDE_TFLAG_LBA48) {
79 hwif->OUTB(tf->hob_feature, IDE_FEATURE_REG);
80 hwif->OUTB(tf->hob_nsect, IDE_NSECTOR_REG);
81 hwif->OUTB(tf->hob_lbal, IDE_SECTOR_REG);
82 hwif->OUTB(tf->hob_lbam, IDE_LCYL_REG);
83 hwif->OUTB(tf->hob_lbah, IDE_HCYL_REG);
84 }
85
86 hwif->OUTB(tf->feature, IDE_FEATURE_REG);
87 hwif->OUTB(tf->nsect, IDE_NSECTOR_REG);
88 hwif->OUTB(tf->lbal, IDE_SECTOR_REG);
89 hwif->OUTB(tf->lbam, IDE_LCYL_REG);
90 hwif->OUTB(tf->lbah, IDE_HCYL_REG);
91
92 hwif->OUTB((tf->device & HIHI) | drive->select.all, IDE_SELECT_REG);
93}
94
95EXPORT_SYMBOL_GPL(ide_tf_load);
96
66int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf) 97int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf)
67{ 98{
68 ide_task_t args; 99 ide_task_t args;
@@ -83,30 +114,11 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task)
83{ 114{
84 ide_hwif_t *hwif = HWIF(drive); 115 ide_hwif_t *hwif = HWIF(drive);
85 struct ide_taskfile *tf = &task->tf; 116 struct ide_taskfile *tf = &task->tf;
86 u8 HIHI = (drive->addressing == 1) ? 0xE0 : 0xEF;
87 117
88 /* ALL Command Block Executions SHALL clear nIEN, unless otherwise */ 118 if (drive->addressing == 1)
89 if (IDE_CONTROL_REG) { 119 task->tf_flags |= IDE_TFLAG_LBA48;
90 /* clear nIEN */
91 hwif->OUTB(drive->ctl, IDE_CONTROL_REG);
92 }
93 SELECT_MASK(drive, 0);
94 120
95 if (drive->addressing == 1) { 121 ide_tf_load(drive, task);
96 hwif->OUTB(tf->hob_feature, IDE_FEATURE_REG);
97 hwif->OUTB(tf->hob_nsect, IDE_NSECTOR_REG);
98 hwif->OUTB(tf->hob_lbal, IDE_SECTOR_REG);
99 hwif->OUTB(tf->hob_lbam, IDE_LCYL_REG);
100 hwif->OUTB(tf->hob_lbah, IDE_HCYL_REG);
101 }
102
103 hwif->OUTB(tf->feature, IDE_FEATURE_REG);
104 hwif->OUTB(tf->nsect, IDE_NSECTOR_REG);
105 hwif->OUTB(tf->lbal, IDE_SECTOR_REG);
106 hwif->OUTB(tf->lbam, IDE_LCYL_REG);
107 hwif->OUTB(tf->lbah, IDE_HCYL_REG);
108
109 hwif->OUTB((tf->device & HIHI) | drive->select.all, IDE_SELECT_REG);
110 122
111 if (task->handler != NULL) { 123 if (task->handler != NULL) {
112 if (task->prehandler != NULL) { 124 if (task->prehandler != NULL) {