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 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>
48 #include <asm/byteorder.h>
50 #include <asm/uaccess.h>
52 #include <asm/bitops.h>
54 #define DEBUG_TASKFILE 0 /* unset when fixed */
56 static void ata_bswap_data (void *buffer, int wcount)
61 *p = *p << 8 | *p >> 8; p++;
62 *p = *p << 8 | *p >> 8; p++;
66 void taskfile_input_data(ide_drive_t *drive, void *buffer, u32 wcount)
68 HWIF(drive)->ata_input_data(drive, buffer, wcount);
70 ata_bswap_data(buffer, wcount);
73 void taskfile_output_data(ide_drive_t *drive, void *buffer, u32 wcount)
76 ata_bswap_data(buffer, wcount);
77 HWIF(drive)->ata_output_data(drive, buffer, wcount);
78 ata_bswap_data(buffer, wcount);
80 HWIF(drive)->ata_output_data(drive, buffer, wcount);
84 int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf)
87 memset(&args, 0, sizeof(ide_task_t));
88 args.tfRegister[IDE_NSECTOR_OFFSET] = 0x01;
89 if (drive->media == ide_disk)
90 args.tfRegister[IDE_COMMAND_OFFSET] = WIN_IDENTIFY;
92 args.tfRegister[IDE_COMMAND_OFFSET] = WIN_PIDENTIFY;
93 args.command_type = IDE_DRIVE_TASK_IN;
94 args.data_phase = TASKFILE_IN;
95 args.handler = &task_in_intr;
96 return ide_raw_taskfile(drive, &args, buf);
99 ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task)
101 ide_hwif_t *hwif = HWIF(drive);
102 task_struct_t *taskfile = (task_struct_t *) task->tfRegister;
103 hob_struct_t *hobfile = (hob_struct_t *) task->hobRegister;
104 u8 HIHI = (drive->addressing == 1) ? 0xE0 : 0xEF;
106 /* ALL Command Block Executions SHALL clear nIEN, unless otherwise */
107 if (IDE_CONTROL_REG) {
109 hwif->OUTB(drive->ctl, IDE_CONTROL_REG);
111 SELECT_MASK(drive, 0);
113 if (drive->addressing == 1) {
114 hwif->OUTB(hobfile->feature, IDE_FEATURE_REG);
115 hwif->OUTB(hobfile->sector_count, IDE_NSECTOR_REG);
116 hwif->OUTB(hobfile->sector_number, IDE_SECTOR_REG);
117 hwif->OUTB(hobfile->low_cylinder, IDE_LCYL_REG);
118 hwif->OUTB(hobfile->high_cylinder, IDE_HCYL_REG);
121 hwif->OUTB(taskfile->feature, IDE_FEATURE_REG);
122 hwif->OUTB(taskfile->sector_count, IDE_NSECTOR_REG);
123 hwif->OUTB(taskfile->sector_number, IDE_SECTOR_REG);
124 hwif->OUTB(taskfile->low_cylinder, IDE_LCYL_REG);
125 hwif->OUTB(taskfile->high_cylinder, IDE_HCYL_REG);
127 hwif->OUTB((taskfile->device_head & HIHI) | drive->select.all, IDE_SELECT_REG);
129 if (task->handler != NULL) {
130 if (task->prehandler != NULL) {
131 hwif->OUTBSYNC(drive, taskfile->command, IDE_COMMAND_REG);
132 ndelay(400); /* FIXME */
133 return task->prehandler(drive, task->rq);
135 ide_execute_command(drive, taskfile->command, task->handler, WAIT_WORSTCASE, NULL);
139 if (!drive->using_dma)
142 switch (taskfile->command) {
143 case WIN_WRITEDMA_ONCE:
145 case WIN_WRITEDMA_EXT:
146 if (!hwif->ide_dma_write(drive))
149 case WIN_READDMA_ONCE:
151 case WIN_READDMA_EXT:
152 case WIN_IDENTIFY_DMA:
153 if (!hwif->ide_dma_read(drive))
157 if (task->handler == NULL)
164 EXPORT_SYMBOL(do_rw_taskfile);
167 * set_multmode_intr() is invoked on completion of a WIN_SETMULT cmd.
169 ide_startstop_t set_multmode_intr (ide_drive_t *drive)
171 ide_hwif_t *hwif = HWIF(drive);
174 if (OK_STAT(stat = hwif->INB(IDE_STATUS_REG),READY_STAT,BAD_STAT)) {
175 drive->mult_count = drive->mult_req;
177 drive->mult_req = drive->mult_count = 0;
178 drive->special.b.recalibrate = 1;
179 (void) ide_dump_status(drive, "set_multmode", stat);
184 EXPORT_SYMBOL(set_multmode_intr);
187 * set_geometry_intr() is invoked on completion of a WIN_SPECIFY cmd.
189 ide_startstop_t set_geometry_intr (ide_drive_t *drive)
191 ide_hwif_t *hwif = HWIF(drive);
195 while (((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) && retries--)
198 if (OK_STAT(stat, READY_STAT, BAD_STAT))
201 if (stat & (ERR_STAT|DRQ_STAT))
202 return DRIVER(drive)->error(drive, "set_geometry_intr", stat);
204 if (HWGROUP(drive)->handler != NULL)
206 ide_set_handler(drive, &set_geometry_intr, WAIT_WORSTCASE, NULL);
210 EXPORT_SYMBOL(set_geometry_intr);
213 * recal_intr() is invoked on completion of a WIN_RESTORE (recalibrate) cmd.
215 ide_startstop_t recal_intr (ide_drive_t *drive)
217 ide_hwif_t *hwif = HWIF(drive);
220 if (!OK_STAT(stat = hwif->INB(IDE_STATUS_REG), READY_STAT, BAD_STAT))
221 return DRIVER(drive)->error(drive, "recal_intr", stat);
225 EXPORT_SYMBOL(recal_intr);
228 * Handler for commands without a data phase
230 ide_startstop_t task_no_data_intr (ide_drive_t *drive)
232 ide_task_t *args = HWGROUP(drive)->rq->special;
233 ide_hwif_t *hwif = HWIF(drive);
237 if (!OK_STAT(stat = hwif->INB(IDE_STATUS_REG),READY_STAT,BAD_STAT)) {
238 return DRIVER(drive)->error(drive, "task_no_data_intr", stat);
239 /* calls ide_end_drive_cmd */
242 ide_end_drive_cmd(drive, stat, hwif->INB(IDE_ERROR_REG));
247 EXPORT_SYMBOL(task_no_data_intr);
249 static void task_buffer_sectors(ide_drive_t *drive, struct request *rq,
250 unsigned nsect, unsigned rw)
252 char *buf = rq->buffer + blk_rq_offset(rq);
255 rq->current_nr_sectors -= nsect;
256 rq->nr_sectors -= nsect;
257 __task_sectors(drive, buf, nsect, rw);
260 static inline void task_buffer_multi_sectors(ide_drive_t *drive,
261 struct request *rq, unsigned rw)
263 unsigned int msect = drive->mult_count, nsect;
265 nsect = rq->current_nr_sectors;
269 task_buffer_sectors(drive, rq, nsect, rw);
272 #ifdef CONFIG_IDE_TASKFILE_IO
273 static void task_sectors(ide_drive_t *drive, struct request *rq,
274 unsigned nsect, unsigned rw)
276 if (rq->cbio) { /* fs request */
278 task_bio_sectors(drive, rq, nsect, rw);
279 } else /* task request */
280 task_buffer_sectors(drive, rq, nsect, rw);
283 static inline void task_bio_multi_sectors(ide_drive_t *drive,
284 struct request *rq, unsigned rw)
286 unsigned int nsect, msect = drive->mult_count;
289 nsect = rq->current_nr_sectors;
293 task_bio_sectors(drive, rq, nsect, rw);
302 static void task_multi_sectors(ide_drive_t *drive,
303 struct request *rq, unsigned rw)
305 if (rq->cbio) { /* fs request */
307 task_bio_multi_sectors(drive, rq, rw);
308 } else /* task request */
309 task_buffer_multi_sectors(drive, rq, rw);
312 # define task_sectors(d, rq, nsect, rw) task_buffer_sectors(d, rq, nsect, rw)
313 # define task_multi_sectors(d, rq, rw) task_buffer_multi_sectors(d, rq, rw)
314 #endif /* CONFIG_IDE_TASKFILE_IO */
316 static u8 wait_drive_not_busy(ide_drive_t *drive)
318 ide_hwif_t *hwif = HWIF(drive);
323 * Last sector was transfered, wait until drive is ready.
324 * This can take up to 10 usec, but we will wait max 1 ms
325 * (drive_cmd_intr() waits that long).
327 while (((stat = hwif->INB(IDE_STATUS_REG)) & BUSY_STAT) && retries--)
331 printk(KERN_ERR "%s: drive still BUSY!\n", drive->name);
336 static inline void ide_pio_datablock(ide_drive_t *drive, struct request *rq,
339 switch (drive->hwif->data_phase) {
340 case TASKFILE_MULTI_IN:
341 case TASKFILE_MULTI_OUT:
342 task_multi_sectors(drive, rq, write);
345 task_sectors(drive, rq, 1, write);
350 #ifdef CONFIG_IDE_TASKFILE_IO
351 static ide_startstop_t task_error(ide_drive_t *drive, struct request *rq,
352 const char *s, u8 stat)
355 int sectors = rq->hard_nr_sectors - rq->nr_sectors;
357 switch (drive->hwif->data_phase) {
365 case TASKFILE_MULTI_IN:
369 case TASKFILE_MULTI_OUT:
370 sectors -= drive->mult_count;
376 drive->driver->end_request(drive, 1, sectors);
378 return drive->driver->error(drive, s, stat);
381 # define task_error(d, rq, s, stat) drive->driver->error(d, s, stat)
384 static void task_end_request(ide_drive_t *drive, struct request *rq, u8 stat)
386 if (rq->flags & REQ_DRIVE_TASKFILE) {
387 ide_task_t *task = rq->special;
389 if (task->tf_out_flags.all) {
390 u8 err = drive->hwif->INB(IDE_ERROR_REG);
391 ide_end_drive_cmd(drive, stat, err);
395 drive->driver->end_request(drive, 1, rq->hard_nr_sectors);
399 * Handler for command with PIO data-in phase (Read/Read Multiple).
401 ide_startstop_t task_in_intr (ide_drive_t *drive)
403 struct request *rq = HWGROUP(drive)->rq;
404 u8 stat = HWIF(drive)->INB(IDE_STATUS_REG);
406 if (!OK_STAT(stat, DATA_READY, BAD_R_STAT)) {
407 if (stat & (ERR_STAT | DRQ_STAT))
408 return task_error(drive, rq, __FUNCTION__, stat);
409 /* No data yet, so wait for another IRQ. */
410 ide_set_handler(drive, &task_in_intr, WAIT_WORSTCASE, NULL);
414 ide_pio_datablock(drive, rq, 0);
416 /* If it was the last datablock check status and finish transfer. */
417 if (!rq->nr_sectors) {
418 stat = wait_drive_not_busy(drive);
419 if (!OK_STAT(stat, 0, BAD_R_STAT))
420 return task_error(drive, rq, __FUNCTION__, stat);
421 task_end_request(drive, rq, stat);
425 /* Still data left to transfer. */
426 ide_set_handler(drive, &task_in_intr, WAIT_WORSTCASE, NULL);
430 EXPORT_SYMBOL(task_in_intr);
433 * Handler for command with PIO data-out phase (Write/Write Multiple).
435 ide_startstop_t task_out_intr (ide_drive_t *drive)
437 struct request *rq = HWGROUP(drive)->rq;
440 stat = HWIF(drive)->INB(IDE_STATUS_REG);
441 if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat))
442 return task_error(drive, rq, __FUNCTION__, stat);
444 /* Deal with unexpected ATA data phase. */
445 if (((stat & DRQ_STAT) == 0) ^ !rq->nr_sectors)
446 return task_error(drive, rq, __FUNCTION__, stat);
448 if (!rq->nr_sectors) {
449 task_end_request(drive, rq, stat);
453 /* Still data left to transfer. */
454 ide_pio_datablock(drive, rq, 1);
455 ide_set_handler(drive, &task_out_intr, WAIT_WORSTCASE, NULL);
460 EXPORT_SYMBOL(task_out_intr);
462 ide_startstop_t pre_task_out_intr (ide_drive_t *drive, struct request *rq)
464 ide_startstop_t startstop;
466 if (ide_wait_stat(&startstop, drive, DATA_READY,
467 drive->bad_wstat, WAIT_DRQ)) {
468 printk(KERN_ERR "%s: no DRQ after issuing %sWRITE%s\n",
470 drive->hwif->data_phase ? "MULT" : "",
471 drive->addressing ? "_EXT" : "");
478 ide_set_handler(drive, &task_out_intr, WAIT_WORSTCASE, NULL);
479 ide_pio_datablock(drive, rq, 1);
483 EXPORT_SYMBOL(pre_task_out_intr);
485 static int ide_diag_taskfile(ide_drive_t *drive, ide_task_t *args, unsigned long data_size, u8 *buf)
489 memset(&rq, 0, sizeof(rq));
490 rq.flags = REQ_DRIVE_TASKFILE;
494 * (ks) We transfer currently only whole sectors.
495 * This is suffient for now. But, it would be great,
496 * if we would find a solution to transfer any size.
497 * To support special commands like READ LONG.
499 if (args->command_type != IDE_DRIVE_TASK_NO_DATA) {
501 rq.nr_sectors = (args->hobRegister[IDE_NSECTOR_OFFSET] << 8) | args->tfRegister[IDE_NSECTOR_OFFSET];
503 rq.nr_sectors = data_size / SECTOR_SIZE;
505 if (!rq.nr_sectors) {
506 printk(KERN_ERR "%s: in/out command without data\n",
511 rq.hard_nr_sectors = rq.nr_sectors;
512 rq.hard_cur_sectors = rq.current_nr_sectors = rq.nr_sectors;
516 return ide_do_drive_cmd(drive, &rq, ide_wait);
519 int ide_raw_taskfile (ide_drive_t *drive, ide_task_t *args, u8 *buf)
521 ide_hwif_t *hwif = HWIF(drive);
522 if(hwif->raw_taskfile)
523 return hwif->raw_taskfile(drive, args, buf);
525 return ide_diag_taskfile(drive, args, 0, buf);
528 EXPORT_SYMBOL(ide_raw_taskfile);
530 int ide_taskfile_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
532 ide_task_request_t *req_task;
536 task_ioreg_t *argsptr = args.tfRegister;
537 task_ioreg_t *hobsptr = args.hobRegister;
539 int tasksize = sizeof(struct ide_task_request_s);
542 u8 io_32bit = drive->io_32bit;
543 char __user *buf = (char __user *)arg;
545 // printk("IDE Taskfile ...\n");
547 req_task = kmalloc(tasksize, GFP_KERNEL);
548 if (req_task == NULL) return -ENOMEM;
549 memset(req_task, 0, tasksize);
550 if (copy_from_user(req_task, buf, tasksize)) {
555 taskout = (int) req_task->out_size;
556 taskin = (int) req_task->in_size;
559 int outtotal = tasksize;
560 outbuf = kmalloc(taskout, GFP_KERNEL);
561 if (outbuf == NULL) {
565 memset(outbuf, 0, taskout);
566 if (copy_from_user(outbuf, buf + outtotal, taskout)) {
573 int intotal = tasksize + taskout;
574 inbuf = kmalloc(taskin, GFP_KERNEL);
579 memset(inbuf, 0, taskin);
580 if (copy_from_user(inbuf, buf + intotal, taskin)) {
586 memset(&args, 0, sizeof(ide_task_t));
587 memcpy(argsptr, req_task->io_ports, HDIO_DRIVE_TASK_HDR_SIZE);
588 memcpy(hobsptr, req_task->hob_ports, HDIO_DRIVE_HOB_HDR_SIZE);
590 args.tf_in_flags = req_task->in_flags;
591 args.tf_out_flags = req_task->out_flags;
592 args.data_phase = req_task->data_phase;
593 args.command_type = req_task->req_cmd;
596 switch(req_task->data_phase) {
597 case TASKFILE_OUT_DMAQ:
598 case TASKFILE_OUT_DMA:
599 err = ide_diag_taskfile(drive, &args, taskout, outbuf);
601 case TASKFILE_IN_DMAQ:
602 case TASKFILE_IN_DMA:
603 err = ide_diag_taskfile(drive, &args, taskin, inbuf);
605 case TASKFILE_MULTI_OUT:
606 if (!drive->mult_count) {
607 /* (hs): give up if multcount is not set */
608 printk(KERN_ERR "%s: %s Multimode Write " \
609 "multcount is not set\n",
610 drive->name, __FUNCTION__);
616 args.prehandler = &pre_task_out_intr;
617 args.handler = &task_out_intr;
618 err = ide_diag_taskfile(drive, &args, taskout, outbuf);
620 case TASKFILE_MULTI_IN:
621 if (!drive->mult_count) {
622 /* (hs): give up if multcount is not set */
623 printk(KERN_ERR "%s: %s Multimode Read failure " \
624 "multcount is not set\n",
625 drive->name, __FUNCTION__);
631 args.handler = &task_in_intr;
632 err = ide_diag_taskfile(drive, &args, taskin, inbuf);
634 case TASKFILE_NO_DATA:
635 args.handler = &task_no_data_intr;
636 err = ide_diag_taskfile(drive, &args, 0, NULL);
643 memcpy(req_task->io_ports, &(args.tfRegister), HDIO_DRIVE_TASK_HDR_SIZE);
644 memcpy(req_task->hob_ports, &(args.hobRegister), HDIO_DRIVE_HOB_HDR_SIZE);
645 req_task->in_flags = args.tf_in_flags;
646 req_task->out_flags = args.tf_out_flags;
648 if (copy_to_user(buf, req_task, tasksize)) {
653 int outtotal = tasksize;
654 if (copy_to_user(buf + outtotal, outbuf, taskout)) {
660 int intotal = tasksize + taskout;
661 if (copy_to_user(buf + intotal, inbuf, taskin)) {
673 // printk("IDE Taskfile ioctl ended. rc = %i\n", err);
675 drive->io_32bit = io_32bit;
680 int ide_wait_cmd (ide_drive_t *drive, u8 cmd, u8 nsect, u8 feature, u8 sectors, u8 *buf)
687 memset(buf, 0, 4 + SECTOR_WORDS * 4 * sectors);
688 ide_init_drive_cmd(&rq);
694 return ide_do_drive_cmd(drive, &rq, ide_wait);
698 * FIXME : this needs to map into at taskfile. <andre@linux-ide.org>
700 int ide_cmd_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
703 u8 args[4], *argbuf = args;
708 if (NULL == (void *) arg) {
710 ide_init_drive_cmd(&rq);
711 return ide_do_drive_cmd(drive, &rq, ide_wait);
714 if (copy_from_user(args, (void __user *)arg, 4))
717 memset(&tfargs, 0, sizeof(ide_task_t));
718 tfargs.tfRegister[IDE_FEATURE_OFFSET] = args[2];
719 tfargs.tfRegister[IDE_NSECTOR_OFFSET] = args[3];
720 tfargs.tfRegister[IDE_SECTOR_OFFSET] = args[1];
721 tfargs.tfRegister[IDE_LCYL_OFFSET] = 0x00;
722 tfargs.tfRegister[IDE_HCYL_OFFSET] = 0x00;
723 tfargs.tfRegister[IDE_SELECT_OFFSET] = 0x00;
724 tfargs.tfRegister[IDE_COMMAND_OFFSET] = args[0];
727 argsize = 4 + (SECTOR_WORDS * 4 * args[3]);
728 argbuf = kmalloc(argsize, GFP_KERNEL);
731 memcpy(argbuf, args, 4);
733 if (set_transfer(drive, &tfargs)) {
735 if (ide_ata66_check(drive, &tfargs))
739 err = ide_wait_cmd(drive, args[0], args[1], args[2], args[3], argbuf);
741 if (!err && xfer_rate) {
742 /* active-retuning-calls future */
743 ide_set_xfer_rate(drive, xfer_rate);
744 ide_driveid_update(drive);
747 if (copy_to_user((void __user *)arg, argbuf, argsize))
754 static int ide_wait_cmd_task(ide_drive_t *drive, u8 *buf)
758 ide_init_drive_cmd(&rq);
759 rq.flags = REQ_DRIVE_TASK;
761 return ide_do_drive_cmd(drive, &rq, ide_wait);
765 * FIXME : this needs to map into at taskfile. <andre@linux-ide.org>
767 int ide_task_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg)
769 void __user *p = (void __user *)arg;
771 u8 args[7], *argbuf = args;
774 if (copy_from_user(args, p, 7))
776 err = ide_wait_cmd_task(drive, argbuf);
777 if (copy_to_user(p, argbuf, argsize))
783 * NOTICE: This is additions from IBM to provide a discrete interface,
784 * for selective taskregister access operations. Nice JOB Klaus!!!
785 * Glad to be able to work and co-develop this with you and IBM.
787 ide_startstop_t flagged_taskfile (ide_drive_t *drive, ide_task_t *task)
789 ide_hwif_t *hwif = HWIF(drive);
790 task_struct_t *taskfile = (task_struct_t *) task->tfRegister;
791 hob_struct_t *hobfile = (hob_struct_t *) task->hobRegister;
796 if (task->data_phase == TASKFILE_MULTI_IN ||
797 task->data_phase == TASKFILE_MULTI_OUT) {
798 if (!drive->mult_count) {
799 printk(KERN_ERR "%s: multimode not set!\n", drive->name);
805 * (ks) Check taskfile in/out flags.
806 * If set, then execute as it is defined.
807 * If not set, then define default settings.
808 * The default values are:
809 * write and read all taskfile registers (except data)
810 * write and read the hob registers (sector,nsector,lcyl,hcyl)
812 if (task->tf_out_flags.all == 0) {
813 task->tf_out_flags.all = IDE_TASKFILE_STD_OUT_FLAGS;
814 if (drive->addressing == 1)
815 task->tf_out_flags.all |= (IDE_HOB_STD_OUT_FLAGS << 8);
818 if (task->tf_in_flags.all == 0) {
819 task->tf_in_flags.all = IDE_TASKFILE_STD_IN_FLAGS;
820 if (drive->addressing == 1)
821 task->tf_in_flags.all |= (IDE_HOB_STD_IN_FLAGS << 8);
824 /* ALL Command Block Executions SHALL clear nIEN, unless otherwise */
827 hwif->OUTB(drive->ctl, IDE_CONTROL_REG);
828 SELECT_MASK(drive, 0);
831 status = hwif->INB(IDE_STATUS_REG);
833 printk("flagged_taskfile -> Bad status. Status = %02x. wait 100 usec ...\n", status);
835 status = hwif->INB(IDE_STATUS_REG);
836 printk("flagged_taskfile -> Status = %02x\n", status);
840 if (task->tf_out_flags.b.data) {
841 u16 data = taskfile->data + (hobfile->data << 8);
842 hwif->OUTW(data, IDE_DATA_REG);
845 /* (ks) send hob registers first */
846 if (task->tf_out_flags.b.nsector_hob)
847 hwif->OUTB(hobfile->sector_count, IDE_NSECTOR_REG);
848 if (task->tf_out_flags.b.sector_hob)
849 hwif->OUTB(hobfile->sector_number, IDE_SECTOR_REG);
850 if (task->tf_out_flags.b.lcyl_hob)
851 hwif->OUTB(hobfile->low_cylinder, IDE_LCYL_REG);
852 if (task->tf_out_flags.b.hcyl_hob)
853 hwif->OUTB(hobfile->high_cylinder, IDE_HCYL_REG);
855 /* (ks) Send now the standard registers */
856 if (task->tf_out_flags.b.error_feature)
857 hwif->OUTB(taskfile->feature, IDE_FEATURE_REG);
858 /* refers to number of sectors to transfer */
859 if (task->tf_out_flags.b.nsector)
860 hwif->OUTB(taskfile->sector_count, IDE_NSECTOR_REG);
861 /* refers to sector offset or start sector */
862 if (task->tf_out_flags.b.sector)
863 hwif->OUTB(taskfile->sector_number, IDE_SECTOR_REG);
864 if (task->tf_out_flags.b.lcyl)
865 hwif->OUTB(taskfile->low_cylinder, IDE_LCYL_REG);
866 if (task->tf_out_flags.b.hcyl)
867 hwif->OUTB(taskfile->high_cylinder, IDE_HCYL_REG);
870 * (ks) In the flagged taskfile approch, we will used all specified
871 * registers and the register value will not be changed. Except the
872 * select bit (master/slave) in the drive_head register. We must make
873 * sure that the desired drive is selected.
875 hwif->OUTB(taskfile->device_head | drive->select.all, IDE_SELECT_REG);
876 switch(task->data_phase) {
878 case TASKFILE_OUT_DMAQ:
879 case TASKFILE_OUT_DMA:
880 hwif->ide_dma_write(drive);
883 case TASKFILE_IN_DMAQ:
884 case TASKFILE_IN_DMA:
885 hwif->ide_dma_read(drive);
889 if (task->handler == NULL)
892 /* Issue the command */
893 if (task->prehandler) {
894 hwif->OUTBSYNC(drive, taskfile->command, IDE_COMMAND_REG);
895 ndelay(400); /* FIXME */
896 return task->prehandler(drive, task->rq);
898 ide_execute_command(drive, taskfile->command, task->handler, WAIT_WORSTCASE, NULL);