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.
12 * Problems to be fixed because of BH interface or the lack therefore.
14 * Fill me in stupid !!!
17 * General refers to the Controller and Driver "pair".
19 * Under the context of Linux it generally refers to an interrupt handler.
20 * However, it correctly describes the 'HOST'
22 * The amount of data needed to be transfered as predefined in the
23 * setup of the device.
25 * The 'DATA BLOCK' associated to the 'DATA HANDLER', and can be as
26 * small as a single sector or as large as the entire command block
30 #include <linux/config.h>
31 #include <linux/module.h>
32 #include <linux/types.h>
33 #include <linux/string.h>
34 #include <linux/kernel.h>
35 #include <linux/timer.h>
37 #include <linux/interrupt.h>
38 #include <linux/major.h>
39 #include <linux/errno.h>
40 #include <linux/genhd.h>
41 #include <linux/blkpg.h>
42 #include <linux/slab.h>
43 #include <linux/pci.h>
44 #include <linux/delay.h>
45 #include <linux/hdreg.h>
46 #include <linux/ide.h>
47 #include <linux/bitops.h>
49 #include <asm/byteorder.h>
51 #include <asm/uaccess.h>
54 static void ata_bswap_data (void *buffer, int wcount)
59 *p = *p << 8 | *p >> 8; p++;
60 *p = *p << 8 | *p >> 8; p++;
64 static void taskfile_input_data(ide_drive_t *drive, void *buffer, u32 wcount)
66 HWIF(drive)->ata_input_data(drive, buffer, wcount);
68 ata_bswap_data(buffer, wcount);
71 static void taskfile_output_data(ide_drive_t *drive, void *buffer, u32 wcount)
74 ata_bswap_data(buffer, wcount);
75 HWIF(drive)->ata_output_data(drive, buffer, wcount);
76 ata_bswap_data(buffer, wcount);
78 HWIF(drive)->ata_output_data(drive, buffer, wcount);
82 int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf)
85 memset(&args, 0, sizeof(ide_task_t));
86 args.tfRegister[IDE_NSECTOR_OFFSET] = 0x01;
87 if (drive->media == ide_disk)
88 args.tfRegister[IDE_COMMAND_OFFSET] = WIN_IDENTIFY;
90 args.tfRegister[IDE_COMMAND_OFFSET] = WIN_PIDENTIFY;
91 args.command_type = IDE_DRIVE_TASK_IN;
92 args.data_phase = TASKFILE_IN;
93 args.handler = &task_in_intr;
94 return ide_raw_taskfile(drive, &args, buf);
97 ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task)
99 ide_hwif_t *hwif = HWIF(drive);
100 task_struct_t *taskfile = (task_struct_t *) task->tfRegister;
101 hob_struct_t *hobfile = (hob_struct_t *) task->hobRegister;
102 u8 HIHI = (drive->addressing == 1) ? 0xE0 : 0xEF;
104 /* ALL Command Block Executions SHALL clear nIEN, unless otherwise */
105 if (IDE_CONTROL_REG) {
107 hwif->OUTB(drive->ctl, IDE_CONTROL_REG);
109 SELECT_MASK(drive, 0);
111 if (drive->addressing == 1) {
112 hwif->OUTB(hobfile->feature, IDE_FEATURE_REG);
113 hwif->OUTB(hobfile->sector_count, IDE_NSECTOR_REG);
114 hwif->OUTB(hobfile->sector_number, IDE_SECTOR_REG);
115 hwif->OUTB(hobfile->low_cylinder, IDE_LCYL_REG);
116 hwif->OUTB(hobfile->high_cylinder, IDE_HCYL_REG);
119 hwif->OUTB(taskfile->feature, IDE_FEATURE_REG);
120 hwif->OUTB(taskfile->sector_count, IDE_NSECTOR_REG);
121 hwif->OUTB(taskfile->sector_number, IDE_SECTOR_REG);
122 hwif->OUTB(taskfile->low_cylinder, IDE_LCYL_REG);
123 hwif->OUTB(taskfile->high_cylinder, IDE_HCYL_REG);
125 hwif->OUTB((taskfile->device_head & HIHI) | drive->select.all, IDE_SELECT_REG);
127 if (task->handler != NULL) {
128 if (task->prehandler != NULL) {
129 hwif->OUTBSYNC(drive, taskfile->command, IDE_COMMAND_REG);
130 ndelay(400); /* FIXME */
131 return task->prehandler(drive, task->rq);
133 ide_execute_command(drive, taskfile->command, task->handler, WAIT_WORSTCASE, NULL);
137 if (!drive->using_dma)
140 switch (taskfile->command) {
141 case WIN_WRITEDMA_ONCE:
143 case WIN_WRITEDMA_EXT:
144 case WIN_READDMA_ONCE:
146 case WIN_READDMA_EXT:
147 case WIN_IDENTIFY_DMA:
148 if (!hwif->dma_setup(drive)) {
149 hwif->dma_exec_cmd(drive, taskfile->command);
150 hwif->dma_start(drive);
155 if (task->handler == NULL)
163 * set_multmode_intr() is invoked on completion of a WIN_SETMULT cmd.
165 ide_startstop_t set_multmode_intr (ide_drive_t *drive)
167 ide_hwif_t *hwif = HWIF(drive);
170 if (OK_STAT(stat = hwif->INB(IDE_STATUS_REG),READY_STAT,BAD_STAT)) {
171 drive->mult_count = drive->mult_req;
173 drive->mult_req = drive->mult_count = 0;
174 drive->special.b.recalibrate = 1;
175 (void) ide_dump_status(drive, "set_multmode", stat);
181 * set_geometry_intr() is invoked on completion of a WIN_SPECIFY cmd.
183 ide_startstop_t set_geometry_intr (ide_drive_t *drive)
185 ide_hwif_t *hwif = HWIF(drive);
189 while (((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) && retries--)
192 if (OK_STAT(stat, READY_STAT, BAD_STAT))
195 if (stat & (ERR_STAT|DRQ_STAT))
196 return ide_error(drive, "set_geometry_intr", stat);
198 if (HWGROUP(drive)->handler != NULL)
200 ide_set_handler(drive, &set_geometry_intr, WAIT_WORSTCASE, NULL);
205 * recal_intr() is invoked on completion of a WIN_RESTORE (recalibrate) cmd.
207 ide_startstop_t recal_intr (ide_drive_t *drive)
209 ide_hwif_t *hwif = HWIF(drive);
212 if (!OK_STAT(stat = hwif->INB(IDE_STATUS_REG), READY_STAT, BAD_STAT))
213 return ide_error(drive, "recal_intr", stat);
218 * Handler for commands without a data phase
220 ide_startstop_t task_no_data_intr (ide_drive_t *drive)
222 ide_task_t *args = HWGROUP(drive)->rq->special;
223 ide_hwif_t *hwif = HWIF(drive);
227 if (!OK_STAT(stat = hwif->INB(IDE_STATUS_REG),READY_STAT,BAD_STAT)) {
228 return ide_error(drive, "task_no_data_intr", stat);
229 /* calls ide_end_drive_cmd */
232 ide_end_drive_cmd(drive, stat, hwif->INB(IDE_ERROR_REG));
237 EXPORT_SYMBOL(task_no_data_intr);
239 static u8 wait_drive_not_busy(ide_drive_t *drive)
241 ide_hwif_t *hwif = HWIF(drive);
246 * Last sector was transfered, wait until drive is ready.
247 * This can take up to 10 usec, but we will wait max 1 ms
248 * (drive_cmd_intr() waits that long).
250 while (((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) && retries--)
254 printk(KERN_ERR "%s: drive still BUSY!\n", drive->name);
259 static void ide_pio_sector(ide_drive_t *drive, unsigned int write)
261 ide_hwif_t *hwif = drive->hwif;
262 struct scatterlist *sg = hwif->sg_table;
264 #ifdef CONFIG_HIGHMEM
270 page = sg[hwif->cursg].page;
271 offset = sg[hwif->cursg].offset + hwif->cursg_ofs * SECTOR_SIZE;
273 /* get the current page and offset */
274 page = nth_page(page, (offset >> PAGE_SHIFT));
277 #ifdef CONFIG_HIGHMEM
278 local_irq_save(flags);
280 buf = kmap_atomic(page, KM_BIO_SRC_IRQ) + offset;
285 if ((hwif->cursg_ofs * SECTOR_SIZE) == sg[hwif->cursg].length) {
290 /* do the actual data transfer */
292 taskfile_output_data(drive, buf, SECTOR_WORDS);
294 taskfile_input_data(drive, buf, SECTOR_WORDS);
296 kunmap_atomic(buf, KM_BIO_SRC_IRQ);
297 #ifdef CONFIG_HIGHMEM
298 local_irq_restore(flags);
302 static void ide_pio_multi(ide_drive_t *drive, unsigned int write)
306 nsect = min_t(unsigned int, drive->hwif->nleft, drive->mult_count);
308 ide_pio_sector(drive, write);
311 static void ide_pio_datablock(ide_drive_t *drive, struct request *rq,
314 if (rq->bio) /* fs request */
317 switch (drive->hwif->data_phase) {
318 case TASKFILE_MULTI_IN:
319 case TASKFILE_MULTI_OUT:
320 ide_pio_multi(drive, write);
323 ide_pio_sector(drive, write);
328 static ide_startstop_t task_error(ide_drive_t *drive, struct request *rq,
329 const char *s, u8 stat)
332 ide_hwif_t *hwif = drive->hwif;
333 int sectors = hwif->nsect - hwif->nleft;
335 switch (hwif->data_phase) {
343 case TASKFILE_MULTI_IN:
347 case TASKFILE_MULTI_OUT:
348 sectors -= drive->mult_count;
356 drv = *(ide_driver_t **)rq->rq_disk->private_data;
357 drv->end_request(drive, 1, sectors);
360 return ide_error(drive, s, stat);
363 static void task_end_request(ide_drive_t *drive, struct request *rq, u8 stat)
365 if (rq->flags & REQ_DRIVE_TASKFILE) {
366 ide_task_t *task = rq->special;
368 if (task->tf_out_flags.all) {
369 u8 err = drive->hwif->INB(IDE_ERROR_REG);
370 ide_end_drive_cmd(drive, stat, err);
375 ide_end_request(drive, 1, rq->hard_nr_sectors);
379 * Handler for command with PIO data-in phase (Read/Read Multiple).
381 ide_startstop_t task_in_intr (ide_drive_t *drive)
383 ide_hwif_t *hwif = drive->hwif;
384 struct request *rq = HWGROUP(drive)->rq;
385 u8 stat = hwif->INB(IDE_STATUS_REG);
387 /* new way for dealing with premature shared PCI interrupts */
388 if (!OK_STAT(stat, DATA_READY, BAD_R_STAT)) {
389 if (stat & (ERR_STAT | DRQ_STAT))
390 return task_error(drive, rq, __FUNCTION__, stat);
391 /* No data yet, so wait for another IRQ. */
392 ide_set_handler(drive, &task_in_intr, WAIT_WORSTCASE, NULL);
396 ide_pio_datablock(drive, rq, 0);
398 /* If it was the last datablock check status and finish transfer. */
400 stat = wait_drive_not_busy(drive);
401 if (!OK_STAT(stat, 0, BAD_R_STAT))
402 return task_error(drive, rq, __FUNCTION__, stat);
403 task_end_request(drive, rq, stat);
407 /* Still data left to transfer. */
408 ide_set_handler(drive, &task_in_intr, WAIT_WORSTCASE, NULL);
412 EXPORT_SYMBOL(task_in_intr);
415 * Handler for command with PIO data-out phase (Write/Write Multiple).
417 static ide_startstop_t task_out_intr (ide_drive_t *drive)
419 ide_hwif_t *hwif = drive->hwif;
420 struct request *rq = HWGROUP(drive)->rq;
421 u8 stat = hwif->INB(IDE_STATUS_REG);
423 if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat))
424 return task_error(drive, rq, __FUNCTION__, stat);
426 /* Deal with unexpected ATA data phase. */
427 if (((stat & DRQ_STAT) == 0) ^ !hwif->nleft)
428 return task_error(drive, rq, __FUNCTION__, stat);
431 task_end_request(drive, rq, stat);
435 /* Still data left to transfer. */
436 ide_pio_datablock(drive, rq, 1);
437 ide_set_handler(drive, &task_out_intr, WAIT_WORSTCASE, NULL);
442 ide_startstop_t pre_task_out_intr (ide_drive_t *drive, struct request *rq)
444 ide_startstop_t startstop;
446 if (ide_wait_stat(&startstop, drive, DATA_READY,
447 drive->bad_wstat, WAIT_DRQ)) {
448 printk(KERN_ERR "%s: no DRQ after issuing %sWRITE%s\n",
450 drive->hwif->data_phase ? "MULT" : "",
451 drive->addressing ? "_EXT" : "");
458 ide_set_handler(drive, &task_out_intr, WAIT_WORSTCASE, NULL);
459 ide_pio_datablock(drive, rq, 1);
463 EXPORT_SYMBOL(pre_task_out_intr);
465 static int ide_diag_taskfile(ide_drive_t *drive, ide_task_t *args, unsigned long data_size, u8 *buf)
469 memset(&rq, 0, sizeof(rq));
470 rq.flags = REQ_DRIVE_TASKFILE;
474 * (ks) We transfer currently only whole sectors.
475 * This is suffient for now. But, it would be great,
476 * if we would find a solution to transfer any size.
477 * To support special commands like READ LONG.
479 if (args->command_type != IDE_DRIVE_TASK_NO_DATA) {
481 rq.nr_sectors = (args->hobRegister[IDE_NSECTOR_OFFSET] << 8) | args->tfRegister[IDE_NSECTOR_OFFSET];
483 rq.nr_sectors = data_size / SECTOR_SIZE;
485 if (!rq.nr_sectors) {
486 printk(KERN_ERR "%s: in/out command without data\n",
491 rq.hard_nr_sectors = rq.nr_sectors;
492 rq.hard_cur_sectors = rq.current_nr_sectors = rq.nr_sectors;
494 if (args->command_type == IDE_DRIVE_TASK_RAW_WRITE)
500 return ide_do_drive_cmd(drive, &rq, ide_wait);
503 int ide_raw_taskfile (ide_drive_t *drive, ide_task_t *args, u8 *buf)
505 return ide_diag_taskfile(drive, args, 0, buf);
508 EXPORT_SYMBOL(ide_raw_taskfile);
510 int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
512 ide_task_request_t *req_task;
516 task_ioreg_t *argsptr = args.tfRegister;
517 task_ioreg_t *hobsptr = args.hobRegister;
519 int tasksize = sizeof(struct ide_task_request_s);
522 u8 io_32bit = drive->io_32bit;
523 char __user *buf = (char __user *)arg;
525 // printk("IDE Taskfile ...\n");
527 req_task = kzalloc(tasksize, GFP_KERNEL);
528 if (req_task == NULL) return -ENOMEM;
529 if (copy_from_user(req_task, buf, tasksize)) {
534 taskout = (int) req_task->out_size;
535 taskin = (int) req_task->in_size;
538 int outtotal = tasksize;
539 outbuf = kzalloc(taskout, GFP_KERNEL);
540 if (outbuf == NULL) {
544 if (copy_from_user(outbuf, buf + outtotal, taskout)) {
551 int intotal = tasksize + taskout;
552 inbuf = kzalloc(taskin, GFP_KERNEL);
557 if (copy_from_user(inbuf, buf + intotal, taskin)) {
563 memset(&args, 0, sizeof(ide_task_t));
564 memcpy(argsptr, req_task->io_ports, HDIO_DRIVE_TASK_HDR_SIZE);
565 memcpy(hobsptr, req_task->hob_ports, HDIO_DRIVE_HOB_HDR_SIZE);
567 args.tf_in_flags = req_task->in_flags;
568 args.tf_out_flags = req_task->out_flags;
569 args.data_phase = req_task->data_phase;
570 args.command_type = req_task->req_cmd;
573 switch(req_task->data_phase) {
574 case TASKFILE_OUT_DMAQ:
575 case TASKFILE_OUT_DMA:
576 err = ide_diag_taskfile(drive, &args, taskout, outbuf);
578 case TASKFILE_IN_DMAQ:
579 case TASKFILE_IN_DMA:
580 err = ide_diag_taskfile(drive, &args, taskin, inbuf);
582 case TASKFILE_MULTI_OUT:
583 if (!drive->mult_count) {
584 /* (hs): give up if multcount is not set */
585 printk(KERN_ERR "%s: %s Multimode Write " \
586 "multcount is not set\n",
587 drive->name, __FUNCTION__);
593 args.prehandler = &pre_task_out_intr;
594 args.handler = &task_out_intr;
595 err = ide_diag_taskfile(drive, &args, taskout, outbuf);
597 case TASKFILE_MULTI_IN:
598 if (!drive->mult_count) {
599 /* (hs): give up if multcount is not set */
600 printk(KERN_ERR "%s: %s Multimode Read failure " \
601 "multcount is not set\n",
602 drive->name, __FUNCTION__);
608 args.handler = &task_in_intr;
609 err = ide_diag_taskfile(drive, &args, taskin, inbuf);
611 case TASKFILE_NO_DATA:
612 args.handler = &task_no_data_intr;
613 err = ide_diag_taskfile(drive, &args, 0, NULL);
620 memcpy(req_task->io_ports, &(args.tfRegister), HDIO_DRIVE_TASK_HDR_SIZE);
621 memcpy(req_task->hob_ports, &(args.hobRegister), HDIO_DRIVE_HOB_HDR_SIZE);
622 req_task->in_flags = args.tf_in_flags;
623 req_task->out_flags = args.tf_out_flags;
625 if (copy_to_user(buf, req_task, tasksize)) {
630 int outtotal = tasksize;
631 if (copy_to_user(buf + outtotal, outbuf, taskout)) {
637 int intotal = tasksize + taskout;
638 if (copy_to_user(buf + intotal, inbuf, taskin)) {
648 // printk("IDE Taskfile ioctl ended. rc = %i\n", err);
650 drive->io_32bit = io_32bit;
655 int ide_wait_cmd (ide_drive_t *drive, u8 cmd, u8 nsect, u8 feature, u8 sectors, u8 *buf)
662 memset(buf, 0, 4 + SECTOR_WORDS * 4 * sectors);
663 ide_init_drive_cmd(&rq);
669 return ide_do_drive_cmd(drive, &rq, ide_wait);
673 * FIXME : this needs to map into at taskfile. <andre@linux-ide.org>
675 int ide_cmd_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
678 u8 args[4], *argbuf = args;
683 if (NULL == (void *) arg) {
685 ide_init_drive_cmd(&rq);
686 return ide_do_drive_cmd(drive, &rq, ide_wait);
689 if (copy_from_user(args, (void __user *)arg, 4))
692 memset(&tfargs, 0, sizeof(ide_task_t));
693 tfargs.tfRegister[IDE_FEATURE_OFFSET] = args[2];
694 tfargs.tfRegister[IDE_NSECTOR_OFFSET] = args[3];
695 tfargs.tfRegister[IDE_SECTOR_OFFSET] = args[1];
696 tfargs.tfRegister[IDE_LCYL_OFFSET] = 0x00;
697 tfargs.tfRegister[IDE_HCYL_OFFSET] = 0x00;
698 tfargs.tfRegister[IDE_SELECT_OFFSET] = 0x00;
699 tfargs.tfRegister[IDE_COMMAND_OFFSET] = args[0];
702 argsize = 4 + (SECTOR_WORDS * 4 * args[3]);
703 argbuf = kzalloc(argsize, GFP_KERNEL);
707 if (set_transfer(drive, &tfargs)) {
709 if (ide_ata66_check(drive, &tfargs))
713 err = ide_wait_cmd(drive, args[0], args[1], args[2], args[3], argbuf);
715 if (!err && xfer_rate) {
716 /* active-retuning-calls future */
717 ide_set_xfer_rate(drive, xfer_rate);
718 ide_driveid_update(drive);
721 if (copy_to_user((void __user *)arg, argbuf, argsize))
728 static int ide_wait_cmd_task(ide_drive_t *drive, u8 *buf)
732 ide_init_drive_cmd(&rq);
733 rq.flags = REQ_DRIVE_TASK;
735 return ide_do_drive_cmd(drive, &rq, ide_wait);
739 * FIXME : this needs to map into at taskfile. <andre@linux-ide.org>
741 int ide_task_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
743 void __user *p = (void __user *)arg;
745 u8 args[7], *argbuf = args;
748 if (copy_from_user(args, p, 7))
750 err = ide_wait_cmd_task(drive, argbuf);
751 if (copy_to_user(p, argbuf, argsize))
757 * NOTICE: This is additions from IBM to provide a discrete interface,
758 * for selective taskregister access operations. Nice JOB Klaus!!!
759 * Glad to be able to work and co-develop this with you and IBM.
761 ide_startstop_t flagged_taskfile (ide_drive_t *drive, ide_task_t *task)
763 ide_hwif_t *hwif = HWIF(drive);
764 task_struct_t *taskfile = (task_struct_t *) task->tfRegister;
765 hob_struct_t *hobfile = (hob_struct_t *) task->hobRegister;
767 if (task->data_phase == TASKFILE_MULTI_IN ||
768 task->data_phase == TASKFILE_MULTI_OUT) {
769 if (!drive->mult_count) {
770 printk(KERN_ERR "%s: multimode not set!\n", drive->name);
776 * (ks) Check taskfile in flags.
777 * If set, then execute as it is defined.
778 * If not set, then define default settings.
779 * The default values are:
780 * read all taskfile registers (except data)
781 * read the hob registers (sector, nsector, lcyl, hcyl)
783 if (task->tf_in_flags.all == 0) {
784 task->tf_in_flags.all = IDE_TASKFILE_STD_IN_FLAGS;
785 if (drive->addressing == 1)
786 task->tf_in_flags.all |= (IDE_HOB_STD_IN_FLAGS << 8);
789 /* ALL Command Block Executions SHALL clear nIEN, unless otherwise */
792 hwif->OUTB(drive->ctl, IDE_CONTROL_REG);
793 SELECT_MASK(drive, 0);
795 if (task->tf_out_flags.b.data) {
796 u16 data = taskfile->data + (hobfile->data << 8);
797 hwif->OUTW(data, IDE_DATA_REG);
800 /* (ks) send hob registers first */
801 if (task->tf_out_flags.b.nsector_hob)
802 hwif->OUTB(hobfile->sector_count, IDE_NSECTOR_REG);
803 if (task->tf_out_flags.b.sector_hob)
804 hwif->OUTB(hobfile->sector_number, IDE_SECTOR_REG);
805 if (task->tf_out_flags.b.lcyl_hob)
806 hwif->OUTB(hobfile->low_cylinder, IDE_LCYL_REG);
807 if (task->tf_out_flags.b.hcyl_hob)
808 hwif->OUTB(hobfile->high_cylinder, IDE_HCYL_REG);
810 /* (ks) Send now the standard registers */
811 if (task->tf_out_flags.b.error_feature)
812 hwif->OUTB(taskfile->feature, IDE_FEATURE_REG);
813 /* refers to number of sectors to transfer */
814 if (task->tf_out_flags.b.nsector)
815 hwif->OUTB(taskfile->sector_count, IDE_NSECTOR_REG);
816 /* refers to sector offset or start sector */
817 if (task->tf_out_flags.b.sector)
818 hwif->OUTB(taskfile->sector_number, IDE_SECTOR_REG);
819 if (task->tf_out_flags.b.lcyl)
820 hwif->OUTB(taskfile->low_cylinder, IDE_LCYL_REG);
821 if (task->tf_out_flags.b.hcyl)
822 hwif->OUTB(taskfile->high_cylinder, IDE_HCYL_REG);
825 * (ks) In the flagged taskfile approch, we will use all specified
826 * registers and the register value will not be changed, except the
827 * select bit (master/slave) in the drive_head register. We must make
828 * sure that the desired drive is selected.
830 hwif->OUTB(taskfile->device_head | drive->select.all, IDE_SELECT_REG);
831 switch(task->data_phase) {
833 case TASKFILE_OUT_DMAQ:
834 case TASKFILE_OUT_DMA:
835 case TASKFILE_IN_DMAQ:
836 case TASKFILE_IN_DMA:
837 hwif->dma_setup(drive);
838 hwif->dma_exec_cmd(drive, taskfile->command);
839 hwif->dma_start(drive);
843 if (task->handler == NULL)
846 /* Issue the command */
847 if (task->prehandler) {
848 hwif->OUTBSYNC(drive, taskfile->command, IDE_COMMAND_REG);
849 ndelay(400); /* FIXME */
850 return task->prehandler(drive, task->rq);
852 ide_execute_command(drive, taskfile->command, task->handler, WAIT_WORSTCASE, NULL);