2 * linux/drivers/ide/ide-taskfile.c Version 0.38 March 05, 2003
4 * Copyright (C) 2000-2002 Michael Cornwell <cornwell@acm.org>
5 * Copyright (C) 2000-2002 Andre Hedrick <andre@linux-ide.org>
6 * Copyright (C) 2001-2002 Klaus Smolin
7 * IBM Storage Technology Division
8 * Copyright (C) 2003-2004 Bartlomiej Zolnierkiewicz
10 * The big the bad and the ugly.
13 #include <linux/module.h>
14 #include <linux/types.h>
15 #include <linux/string.h>
16 #include <linux/kernel.h>
17 #include <linux/timer.h>
19 #include <linux/sched.h>
20 #include <linux/interrupt.h>
21 #include <linux/major.h>
22 #include <linux/errno.h>
23 #include <linux/genhd.h>
24 #include <linux/blkpg.h>
25 #include <linux/slab.h>
26 #include <linux/pci.h>
27 #include <linux/delay.h>
28 #include <linux/hdreg.h>
29 #include <linux/ide.h>
30 #include <linux/bitops.h>
31 #include <linux/scatterlist.h>
33 #include <asm/byteorder.h>
35 #include <asm/uaccess.h>
38 static void ata_bswap_data (void *buffer, int wcount)
43 *p = *p << 8 | *p >> 8; p++;
44 *p = *p << 8 | *p >> 8; p++;
48 static void taskfile_input_data(ide_drive_t *drive, void *buffer, u32 wcount)
50 HWIF(drive)->ata_input_data(drive, buffer, wcount);
52 ata_bswap_data(buffer, wcount);
55 static void taskfile_output_data(ide_drive_t *drive, void *buffer, u32 wcount)
58 ata_bswap_data(buffer, wcount);
59 HWIF(drive)->ata_output_data(drive, buffer, wcount);
60 ata_bswap_data(buffer, wcount);
62 HWIF(drive)->ata_output_data(drive, buffer, wcount);
66 int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf)
69 memset(&args, 0, sizeof(ide_task_t));
70 args.tfRegister[IDE_NSECTOR_OFFSET] = 0x01;
71 if (drive->media == ide_disk)
72 args.tfRegister[IDE_COMMAND_OFFSET] = WIN_IDENTIFY;
74 args.tfRegister[IDE_COMMAND_OFFSET] = WIN_PIDENTIFY;
75 args.command_type = IDE_DRIVE_TASK_IN;
76 args.data_phase = TASKFILE_IN;
77 args.handler = &task_in_intr;
78 return ide_raw_taskfile(drive, &args, buf);
81 ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task)
83 ide_hwif_t *hwif = HWIF(drive);
84 task_struct_t *taskfile = (task_struct_t *) task->tfRegister;
85 hob_struct_t *hobfile = (hob_struct_t *) task->hobRegister;
86 u8 HIHI = (drive->addressing == 1) ? 0xE0 : 0xEF;
88 /* ALL Command Block Executions SHALL clear nIEN, unless otherwise */
89 if (IDE_CONTROL_REG) {
91 hwif->OUTB(drive->ctl, IDE_CONTROL_REG);
93 SELECT_MASK(drive, 0);
95 if (drive->addressing == 1) {
96 hwif->OUTB(hobfile->feature, IDE_FEATURE_REG);
97 hwif->OUTB(hobfile->sector_count, IDE_NSECTOR_REG);
98 hwif->OUTB(hobfile->sector_number, IDE_SECTOR_REG);
99 hwif->OUTB(hobfile->low_cylinder, IDE_LCYL_REG);
100 hwif->OUTB(hobfile->high_cylinder, IDE_HCYL_REG);
103 hwif->OUTB(taskfile->feature, IDE_FEATURE_REG);
104 hwif->OUTB(taskfile->sector_count, IDE_NSECTOR_REG);
105 hwif->OUTB(taskfile->sector_number, IDE_SECTOR_REG);
106 hwif->OUTB(taskfile->low_cylinder, IDE_LCYL_REG);
107 hwif->OUTB(taskfile->high_cylinder, IDE_HCYL_REG);
109 hwif->OUTB((taskfile->device_head & HIHI) | drive->select.all, IDE_SELECT_REG);
111 if (task->handler != NULL) {
112 if (task->prehandler != NULL) {
113 hwif->OUTBSYNC(drive, taskfile->command, IDE_COMMAND_REG);
114 ndelay(400); /* FIXME */
115 return task->prehandler(drive, task->rq);
117 ide_execute_command(drive, taskfile->command, task->handler, WAIT_WORSTCASE, NULL);
121 if (!drive->using_dma)
124 switch (taskfile->command) {
125 case WIN_WRITEDMA_ONCE:
127 case WIN_WRITEDMA_EXT:
128 case WIN_READDMA_ONCE:
130 case WIN_READDMA_EXT:
131 case WIN_IDENTIFY_DMA:
132 if (!hwif->dma_setup(drive)) {
133 hwif->dma_exec_cmd(drive, taskfile->command);
134 hwif->dma_start(drive);
139 if (task->handler == NULL)
147 * set_multmode_intr() is invoked on completion of a WIN_SETMULT cmd.
149 ide_startstop_t set_multmode_intr (ide_drive_t *drive)
151 ide_hwif_t *hwif = HWIF(drive);
154 if (OK_STAT(stat = hwif->INB(IDE_STATUS_REG),READY_STAT,BAD_STAT)) {
155 drive->mult_count = drive->mult_req;
157 drive->mult_req = drive->mult_count = 0;
158 drive->special.b.recalibrate = 1;
159 (void) ide_dump_status(drive, "set_multmode", stat);
165 * set_geometry_intr() is invoked on completion of a WIN_SPECIFY cmd.
167 ide_startstop_t set_geometry_intr (ide_drive_t *drive)
169 ide_hwif_t *hwif = HWIF(drive);
173 while (((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) && retries--)
176 if (OK_STAT(stat, READY_STAT, BAD_STAT))
179 if (stat & (ERR_STAT|DRQ_STAT))
180 return ide_error(drive, "set_geometry_intr", stat);
182 BUG_ON(HWGROUP(drive)->handler != NULL);
183 ide_set_handler(drive, &set_geometry_intr, WAIT_WORSTCASE, NULL);
188 * recal_intr() is invoked on completion of a WIN_RESTORE (recalibrate) cmd.
190 ide_startstop_t recal_intr (ide_drive_t *drive)
192 ide_hwif_t *hwif = HWIF(drive);
195 if (!OK_STAT(stat = hwif->INB(IDE_STATUS_REG), READY_STAT, BAD_STAT))
196 return ide_error(drive, "recal_intr", stat);
201 * Handler for commands without a data phase
203 ide_startstop_t task_no_data_intr (ide_drive_t *drive)
205 ide_task_t *args = HWGROUP(drive)->rq->special;
206 ide_hwif_t *hwif = HWIF(drive);
209 local_irq_enable_in_hardirq();
210 if (!OK_STAT(stat = hwif->INB(IDE_STATUS_REG),READY_STAT,BAD_STAT)) {
211 return ide_error(drive, "task_no_data_intr", stat);
212 /* calls ide_end_drive_cmd */
215 ide_end_drive_cmd(drive, stat, hwif->INB(IDE_ERROR_REG));
220 EXPORT_SYMBOL(task_no_data_intr);
222 static u8 wait_drive_not_busy(ide_drive_t *drive)
224 ide_hwif_t *hwif = HWIF(drive);
229 * Last sector was transfered, wait until drive is ready.
230 * This can take up to 10 usec, but we will wait max 1 ms
231 * (drive_cmd_intr() waits that long).
233 for (retries = 0; retries < 100; retries++) {
234 if ((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT)
240 if (stat & BUSY_STAT)
241 printk(KERN_ERR "%s: drive still BUSY!\n", drive->name);
246 static void ide_pio_sector(ide_drive_t *drive, unsigned int write)
248 ide_hwif_t *hwif = drive->hwif;
249 struct scatterlist *sg = hwif->sg_table;
250 struct scatterlist *cursg = hwif->cursg;
252 #ifdef CONFIG_HIGHMEM
264 page = sg_page(cursg);
265 offset = cursg->offset + hwif->cursg_ofs * SECTOR_SIZE;
267 /* get the current page and offset */
268 page = nth_page(page, (offset >> PAGE_SHIFT));
271 #ifdef CONFIG_HIGHMEM
272 local_irq_save(flags);
274 buf = kmap_atomic(page, KM_BIO_SRC_IRQ) + offset;
279 if ((hwif->cursg_ofs * SECTOR_SIZE) == cursg->length) {
280 hwif->cursg = sg_next(hwif->cursg);
284 /* do the actual data transfer */
286 taskfile_output_data(drive, buf, SECTOR_WORDS);
288 taskfile_input_data(drive, buf, SECTOR_WORDS);
290 kunmap_atomic(buf, KM_BIO_SRC_IRQ);
291 #ifdef CONFIG_HIGHMEM
292 local_irq_restore(flags);
296 static void ide_pio_multi(ide_drive_t *drive, unsigned int write)
300 nsect = min_t(unsigned int, drive->hwif->nleft, drive->mult_count);
302 ide_pio_sector(drive, write);
305 static void ide_pio_datablock(ide_drive_t *drive, struct request *rq,
308 if (rq->bio) /* fs request */
311 touch_softlockup_watchdog();
313 switch (drive->hwif->data_phase) {
314 case TASKFILE_MULTI_IN:
315 case TASKFILE_MULTI_OUT:
316 ide_pio_multi(drive, write);
319 ide_pio_sector(drive, write);
324 static ide_startstop_t task_error(ide_drive_t *drive, struct request *rq,
325 const char *s, u8 stat)
328 ide_hwif_t *hwif = drive->hwif;
329 int sectors = hwif->nsect - hwif->nleft;
331 switch (hwif->data_phase) {
339 case TASKFILE_MULTI_IN:
343 case TASKFILE_MULTI_OUT:
344 sectors -= drive->mult_count;
352 drv = *(ide_driver_t **)rq->rq_disk->private_data;
353 drv->end_request(drive, 1, sectors);
356 return ide_error(drive, s, stat);
359 static void task_end_request(ide_drive_t *drive, struct request *rq, u8 stat)
361 HWIF(drive)->cursg = NULL;
363 if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) {
364 ide_task_t *task = rq->special;
366 if (task->tf_out_flags.all) {
367 u8 err = drive->hwif->INB(IDE_ERROR_REG);
368 ide_end_drive_cmd(drive, stat, err);
376 drv = *(ide_driver_t **)rq->rq_disk->private_data;;
377 drv->end_request(drive, 1, rq->hard_nr_sectors);
379 ide_end_request(drive, 1, rq->hard_nr_sectors);
383 * Handler for command with PIO data-in phase (Read/Read Multiple).
385 ide_startstop_t task_in_intr (ide_drive_t *drive)
387 ide_hwif_t *hwif = drive->hwif;
388 struct request *rq = HWGROUP(drive)->rq;
389 u8 stat = hwif->INB(IDE_STATUS_REG);
391 /* new way for dealing with premature shared PCI interrupts */
392 if (!OK_STAT(stat, DATA_READY, BAD_R_STAT)) {
393 if (stat & (ERR_STAT | DRQ_STAT))
394 return task_error(drive, rq, __FUNCTION__, stat);
395 /* No data yet, so wait for another IRQ. */
396 ide_set_handler(drive, &task_in_intr, WAIT_WORSTCASE, NULL);
400 ide_pio_datablock(drive, rq, 0);
402 /* If it was the last datablock check status and finish transfer. */
404 stat = wait_drive_not_busy(drive);
405 if (!OK_STAT(stat, 0, BAD_R_STAT))
406 return task_error(drive, rq, __FUNCTION__, stat);
407 task_end_request(drive, rq, stat);
411 /* Still data left to transfer. */
412 ide_set_handler(drive, &task_in_intr, WAIT_WORSTCASE, NULL);
416 EXPORT_SYMBOL(task_in_intr);
419 * Handler for command with PIO data-out phase (Write/Write Multiple).
421 static ide_startstop_t task_out_intr (ide_drive_t *drive)
423 ide_hwif_t *hwif = drive->hwif;
424 struct request *rq = HWGROUP(drive)->rq;
425 u8 stat = hwif->INB(IDE_STATUS_REG);
427 if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat))
428 return task_error(drive, rq, __FUNCTION__, stat);
430 /* Deal with unexpected ATA data phase. */
431 if (((stat & DRQ_STAT) == 0) ^ !hwif->nleft)
432 return task_error(drive, rq, __FUNCTION__, stat);
435 task_end_request(drive, rq, stat);
439 /* Still data left to transfer. */
440 ide_pio_datablock(drive, rq, 1);
441 ide_set_handler(drive, &task_out_intr, WAIT_WORSTCASE, NULL);
446 ide_startstop_t pre_task_out_intr (ide_drive_t *drive, struct request *rq)
448 ide_startstop_t startstop;
450 if (ide_wait_stat(&startstop, drive, DATA_READY,
451 drive->bad_wstat, WAIT_DRQ)) {
452 printk(KERN_ERR "%s: no DRQ after issuing %sWRITE%s\n",
454 drive->hwif->data_phase ? "MULT" : "",
455 drive->addressing ? "_EXT" : "");
462 ide_set_handler(drive, &task_out_intr, WAIT_WORSTCASE, NULL);
463 ide_pio_datablock(drive, rq, 1);
467 EXPORT_SYMBOL(pre_task_out_intr);
469 static int ide_diag_taskfile(ide_drive_t *drive, ide_task_t *args, unsigned long data_size, u8 *buf)
473 memset(&rq, 0, sizeof(rq));
475 rq.cmd_type = REQ_TYPE_ATA_TASKFILE;
479 * (ks) We transfer currently only whole sectors.
480 * This is suffient for now. But, it would be great,
481 * if we would find a solution to transfer any size.
482 * To support special commands like READ LONG.
484 if (args->command_type != IDE_DRIVE_TASK_NO_DATA) {
486 rq.nr_sectors = (args->hobRegister[IDE_NSECTOR_OFFSET] << 8) | args->tfRegister[IDE_NSECTOR_OFFSET];
488 rq.nr_sectors = data_size / SECTOR_SIZE;
490 if (!rq.nr_sectors) {
491 printk(KERN_ERR "%s: in/out command without data\n",
496 rq.hard_nr_sectors = rq.nr_sectors;
497 rq.hard_cur_sectors = rq.current_nr_sectors = rq.nr_sectors;
499 if (args->command_type == IDE_DRIVE_TASK_RAW_WRITE)
500 rq.cmd_flags |= REQ_RW;
505 return ide_do_drive_cmd(drive, &rq, ide_wait);
508 int ide_raw_taskfile (ide_drive_t *drive, ide_task_t *args, u8 *buf)
510 return ide_diag_taskfile(drive, args, 0, buf);
513 EXPORT_SYMBOL(ide_raw_taskfile);
515 #ifdef CONFIG_IDE_TASK_IOCTL
516 int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
518 ide_task_request_t *req_task;
522 task_ioreg_t *argsptr = args.tfRegister;
523 task_ioreg_t *hobsptr = args.hobRegister;
525 int tasksize = sizeof(struct ide_task_request_s);
526 unsigned int taskin = 0;
527 unsigned int taskout = 0;
528 u8 io_32bit = drive->io_32bit;
529 char __user *buf = (char __user *)arg;
531 // printk("IDE Taskfile ...\n");
533 req_task = kzalloc(tasksize, GFP_KERNEL);
534 if (req_task == NULL) return -ENOMEM;
535 if (copy_from_user(req_task, buf, tasksize)) {
540 taskout = req_task->out_size;
541 taskin = req_task->in_size;
543 if (taskin > 65536 || taskout > 65536) {
549 int outtotal = tasksize;
550 outbuf = kzalloc(taskout, GFP_KERNEL);
551 if (outbuf == NULL) {
555 if (copy_from_user(outbuf, buf + outtotal, taskout)) {
562 int intotal = tasksize + taskout;
563 inbuf = kzalloc(taskin, GFP_KERNEL);
568 if (copy_from_user(inbuf, buf + intotal, taskin)) {
574 memset(&args, 0, sizeof(ide_task_t));
575 memcpy(argsptr, req_task->io_ports, HDIO_DRIVE_TASK_HDR_SIZE);
576 memcpy(hobsptr, req_task->hob_ports, HDIO_DRIVE_HOB_HDR_SIZE);
578 args.tf_in_flags = req_task->in_flags;
579 args.tf_out_flags = req_task->out_flags;
580 args.data_phase = req_task->data_phase;
581 args.command_type = req_task->req_cmd;
584 switch(req_task->data_phase) {
585 case TASKFILE_OUT_DMAQ:
586 case TASKFILE_OUT_DMA:
587 err = ide_diag_taskfile(drive, &args, taskout, outbuf);
589 case TASKFILE_IN_DMAQ:
590 case TASKFILE_IN_DMA:
591 err = ide_diag_taskfile(drive, &args, taskin, inbuf);
593 case TASKFILE_MULTI_OUT:
594 if (!drive->mult_count) {
595 /* (hs): give up if multcount is not set */
596 printk(KERN_ERR "%s: %s Multimode Write " \
597 "multcount is not set\n",
598 drive->name, __FUNCTION__);
604 args.prehandler = &pre_task_out_intr;
605 args.handler = &task_out_intr;
606 err = ide_diag_taskfile(drive, &args, taskout, outbuf);
608 case TASKFILE_MULTI_IN:
609 if (!drive->mult_count) {
610 /* (hs): give up if multcount is not set */
611 printk(KERN_ERR "%s: %s Multimode Read failure " \
612 "multcount is not set\n",
613 drive->name, __FUNCTION__);
619 args.handler = &task_in_intr;
620 err = ide_diag_taskfile(drive, &args, taskin, inbuf);
622 case TASKFILE_NO_DATA:
623 args.handler = &task_no_data_intr;
624 err = ide_diag_taskfile(drive, &args, 0, NULL);
631 memcpy(req_task->io_ports, &(args.tfRegister), HDIO_DRIVE_TASK_HDR_SIZE);
632 memcpy(req_task->hob_ports, &(args.hobRegister), HDIO_DRIVE_HOB_HDR_SIZE);
633 req_task->in_flags = args.tf_in_flags;
634 req_task->out_flags = args.tf_out_flags;
636 if (copy_to_user(buf, req_task, tasksize)) {
641 int outtotal = tasksize;
642 if (copy_to_user(buf + outtotal, outbuf, taskout)) {
648 int intotal = tasksize + taskout;
649 if (copy_to_user(buf + intotal, inbuf, taskin)) {
659 // printk("IDE Taskfile ioctl ended. rc = %i\n", err);
661 drive->io_32bit = io_32bit;
667 int ide_wait_cmd (ide_drive_t *drive, u8 cmd, u8 nsect, u8 feature, u8 sectors, u8 *buf)
674 memset(buf, 0, 4 + SECTOR_WORDS * 4 * sectors);
675 ide_init_drive_cmd(&rq);
681 return ide_do_drive_cmd(drive, &rq, ide_wait);
684 int ide_cmd_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
687 u8 args[4], *argbuf = args;
692 if (NULL == (void *) arg) {
694 ide_init_drive_cmd(&rq);
695 return ide_do_drive_cmd(drive, &rq, ide_wait);
698 if (copy_from_user(args, (void __user *)arg, 4))
701 memset(&tfargs, 0, sizeof(ide_task_t));
702 tfargs.tfRegister[IDE_FEATURE_OFFSET] = args[2];
703 tfargs.tfRegister[IDE_NSECTOR_OFFSET] = args[3];
704 tfargs.tfRegister[IDE_SECTOR_OFFSET] = args[1];
705 tfargs.tfRegister[IDE_LCYL_OFFSET] = 0x00;
706 tfargs.tfRegister[IDE_HCYL_OFFSET] = 0x00;
707 tfargs.tfRegister[IDE_SELECT_OFFSET] = 0x00;
708 tfargs.tfRegister[IDE_COMMAND_OFFSET] = args[0];
711 argsize = 4 + (SECTOR_WORDS * 4 * args[3]);
712 argbuf = kzalloc(argsize, GFP_KERNEL);
716 if (set_transfer(drive, &tfargs)) {
718 if (ide_ata66_check(drive, &tfargs))
722 err = ide_wait_cmd(drive, args[0], args[1], args[2], args[3], argbuf);
724 if (!err && xfer_rate) {
725 /* active-retuning-calls future */
726 ide_set_xfer_rate(drive, xfer_rate);
727 ide_driveid_update(drive);
730 if (copy_to_user((void __user *)arg, argbuf, argsize))
737 static int ide_wait_cmd_task(ide_drive_t *drive, u8 *buf)
741 ide_init_drive_cmd(&rq);
742 rq.cmd_type = REQ_TYPE_ATA_TASK;
744 return ide_do_drive_cmd(drive, &rq, ide_wait);
747 int ide_task_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
749 void __user *p = (void __user *)arg;
751 u8 args[7], *argbuf = args;
754 if (copy_from_user(args, p, 7))
756 err = ide_wait_cmd_task(drive, argbuf);
757 if (copy_to_user(p, argbuf, argsize))
763 * NOTICE: This is additions from IBM to provide a discrete interface,
764 * for selective taskregister access operations. Nice JOB Klaus!!!
765 * Glad to be able to work and co-develop this with you and IBM.
767 ide_startstop_t flagged_taskfile (ide_drive_t *drive, ide_task_t *task)
769 ide_hwif_t *hwif = HWIF(drive);
770 task_struct_t *taskfile = (task_struct_t *) task->tfRegister;
771 hob_struct_t *hobfile = (hob_struct_t *) task->hobRegister;
773 if (task->data_phase == TASKFILE_MULTI_IN ||
774 task->data_phase == TASKFILE_MULTI_OUT) {
775 if (!drive->mult_count) {
776 printk(KERN_ERR "%s: multimode not set!\n", drive->name);
782 * (ks) Check taskfile in flags.
783 * If set, then execute as it is defined.
784 * If not set, then define default settings.
785 * The default values are:
786 * read all taskfile registers (except data)
787 * read the hob registers (sector, nsector, lcyl, hcyl)
789 if (task->tf_in_flags.all == 0) {
790 task->tf_in_flags.all = IDE_TASKFILE_STD_IN_FLAGS;
791 if (drive->addressing == 1)
792 task->tf_in_flags.all |= (IDE_HOB_STD_IN_FLAGS << 8);
795 /* ALL Command Block Executions SHALL clear nIEN, unless otherwise */
798 hwif->OUTB(drive->ctl, IDE_CONTROL_REG);
799 SELECT_MASK(drive, 0);
801 if (task->tf_out_flags.b.data) {
802 u16 data = taskfile->data + (hobfile->data << 8);
803 hwif->OUTW(data, IDE_DATA_REG);
806 /* (ks) send hob registers first */
807 if (task->tf_out_flags.b.nsector_hob)
808 hwif->OUTB(hobfile->sector_count, IDE_NSECTOR_REG);
809 if (task->tf_out_flags.b.sector_hob)
810 hwif->OUTB(hobfile->sector_number, IDE_SECTOR_REG);
811 if (task->tf_out_flags.b.lcyl_hob)
812 hwif->OUTB(hobfile->low_cylinder, IDE_LCYL_REG);
813 if (task->tf_out_flags.b.hcyl_hob)
814 hwif->OUTB(hobfile->high_cylinder, IDE_HCYL_REG);
816 /* (ks) Send now the standard registers */
817 if (task->tf_out_flags.b.error_feature)
818 hwif->OUTB(taskfile->feature, IDE_FEATURE_REG);
819 /* refers to number of sectors to transfer */
820 if (task->tf_out_flags.b.nsector)
821 hwif->OUTB(taskfile->sector_count, IDE_NSECTOR_REG);
822 /* refers to sector offset or start sector */
823 if (task->tf_out_flags.b.sector)
824 hwif->OUTB(taskfile->sector_number, IDE_SECTOR_REG);
825 if (task->tf_out_flags.b.lcyl)
826 hwif->OUTB(taskfile->low_cylinder, IDE_LCYL_REG);
827 if (task->tf_out_flags.b.hcyl)
828 hwif->OUTB(taskfile->high_cylinder, IDE_HCYL_REG);
831 * (ks) In the flagged taskfile approch, we will use all specified
832 * registers and the register value will not be changed, except the
833 * select bit (master/slave) in the drive_head register. We must make
834 * sure that the desired drive is selected.
836 hwif->OUTB(taskfile->device_head | drive->select.all, IDE_SELECT_REG);
837 switch(task->data_phase) {
839 case TASKFILE_OUT_DMAQ:
840 case TASKFILE_OUT_DMA:
841 case TASKFILE_IN_DMAQ:
842 case TASKFILE_IN_DMA:
843 if (!drive->using_dma)
846 if (!hwif->dma_setup(drive)) {
847 hwif->dma_exec_cmd(drive, taskfile->command);
848 hwif->dma_start(drive);
854 if (task->handler == NULL)
857 /* Issue the command */
858 if (task->prehandler) {
859 hwif->OUTBSYNC(drive, taskfile->command, IDE_COMMAND_REG);
860 ndelay(400); /* FIXME */
861 return task->prehandler(drive, task->rq);
863 ide_execute_command(drive, taskfile->command, task->handler, WAIT_WORSTCASE, NULL);