Lines Matching +full:tf +full:- +full:a

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2000-2002 Michael Cornwell <cornwell@acm.org>
4 * Copyright (C) 2000-2002 Andre Hedrick <andre@linux-ide.org>
5 * Copyright (C) 2001-2002 Klaus Smolin
7 * Copyright (C) 2003-2004, 2007 Bartlomiej Zolnierkiewicz
31 ide_hwif_t *hwif = drive->hwif; in ide_tf_readback()
32 const struct ide_tp_ops *tp_ops = hwif->tp_ops; in ide_tf_readback()
35 tp_ops->write_devctl(hwif, ATA_DEVCTL_OBS); in ide_tf_readback()
37 tp_ops->tf_read(drive, &cmd->tf, cmd->valid.in.tf); in ide_tf_readback()
39 if (cmd->tf_flags & IDE_TFLAG_LBA48) { in ide_tf_readback()
40 tp_ops->write_devctl(hwif, ATA_HOB | ATA_DEVCTL_OBS); in ide_tf_readback()
42 tp_ops->tf_read(drive, &cmd->hob, cmd->valid.in.hob); in ide_tf_readback()
49 printk("%s: tf: feat 0x%02x nsect 0x%02x lbal 0x%02x " in ide_tf_dump()
51 s, cmd->tf.feature, cmd->tf.nsect, in ide_tf_dump()
52 cmd->tf.lbal, cmd->tf.lbam, cmd->tf.lbah, in ide_tf_dump()
53 cmd->tf.device, cmd->tf.command); in ide_tf_dump()
55 s, cmd->hob.nsect, cmd->hob.lbal, cmd->hob.lbam, cmd->hob.lbah); in ide_tf_dump()
64 cmd.tf.nsect = 0x01; in taskfile_lib_get_identify()
65 if (drive->media == ide_disk) in taskfile_lib_get_identify()
66 cmd.tf.command = ATA_CMD_ID_ATA; in taskfile_lib_get_identify()
68 cmd.tf.command = ATA_CMD_ID_ATAPI; in taskfile_lib_get_identify()
69 cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE; in taskfile_lib_get_identify()
70 cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE; in taskfile_lib_get_identify()
82 ide_hwif_t *hwif = drive->hwif; in do_rw_taskfile()
83 struct ide_cmd *cmd = &hwif->cmd; in do_rw_taskfile()
84 struct ide_taskfile *tf = &cmd->tf; in do_rw_taskfile() local
86 const struct ide_tp_ops *tp_ops = hwif->tp_ops; in do_rw_taskfile()
87 const struct ide_dma_ops *dma_ops = hwif->dma_ops; in do_rw_taskfile()
89 if (orig_cmd->protocol == ATA_PROT_PIO && in do_rw_taskfile()
90 (orig_cmd->tf_flags & IDE_TFLAG_MULTI_PIO) && in do_rw_taskfile()
91 drive->mult_count == 0) { in do_rw_taskfile()
92 pr_err("%s: multimode not set!\n", drive->name); in do_rw_taskfile()
96 if (orig_cmd->ftf_flags & IDE_FTFLAG_FLAGGED) in do_rw_taskfile()
97 orig_cmd->ftf_flags |= IDE_FTFLAG_SET_IN_FLAGS; in do_rw_taskfile()
101 if ((cmd->tf_flags & IDE_TFLAG_DMA_PIO_FALLBACK) == 0) { in do_rw_taskfile()
102 ide_tf_dump(drive->name, cmd); in do_rw_taskfile()
103 tp_ops->write_devctl(hwif, ATA_DEVCTL_OBS); in do_rw_taskfile()
105 if (cmd->ftf_flags & IDE_FTFLAG_OUT_DATA) { in do_rw_taskfile()
106 u8 data[2] = { cmd->tf.data, cmd->hob.data }; in do_rw_taskfile()
108 tp_ops->output_data(drive, cmd, data, 2); in do_rw_taskfile()
111 if (cmd->valid.out.tf & IDE_VALID_DEVICE) { in do_rw_taskfile()
112 u8 HIHI = (cmd->tf_flags & IDE_TFLAG_LBA48) ? in do_rw_taskfile()
115 if (!(cmd->ftf_flags & IDE_FTFLAG_FLAGGED)) in do_rw_taskfile()
116 cmd->tf.device &= HIHI; in do_rw_taskfile()
117 cmd->tf.device |= drive->select; in do_rw_taskfile()
120 tp_ops->tf_load(drive, &cmd->hob, cmd->valid.out.hob); in do_rw_taskfile()
121 tp_ops->tf_load(drive, &cmd->tf, cmd->valid.out.tf); in do_rw_taskfile()
124 switch (cmd->protocol) { in do_rw_taskfile()
126 if (cmd->tf_flags & IDE_TFLAG_WRITE) { in do_rw_taskfile()
127 tp_ops->exec_command(hwif, tf->command); in do_rw_taskfile()
141 hwif->expiry = dma_ops->dma_timer_expiry; in do_rw_taskfile()
143 dma_ops->dma_start(drive); in do_rw_taskfile()
153 ide_hwif_t *hwif = drive->hwif; in task_no_data_intr()
154 struct ide_cmd *cmd = &hwif->cmd; in task_no_data_intr()
155 struct ide_taskfile *tf = &cmd->tf; in task_no_data_intr() local
156 int custom = (cmd->tf_flags & IDE_TFLAG_CUSTOM_HANDLER) ? 1 : 0; in task_no_data_intr()
157 int retries = (custom && tf->command == ATA_CMD_INIT_DEV_PARAMS) ? 5 : 1; in task_no_data_intr()
163 stat = hwif->tp_ops->read_status(hwif); in task_no_data_intr()
164 if ((stat & ATA_BUSY) == 0 || retries-- == 0) in task_no_data_intr()
170 if (custom && tf->command == ATA_CMD_SET_MULTI) { in task_no_data_intr()
171 drive->mult_req = drive->mult_count = 0; in task_no_data_intr()
172 drive->special_flags |= IDE_SFLAG_RECALIBRATE; in task_no_data_intr()
175 } else if (custom && tf->command == ATA_CMD_INIT_DEV_PARAMS) { in task_no_data_intr()
185 if (custom && tf->command == ATA_CMD_SET_MULTI) in task_no_data_intr()
186 drive->mult_count = drive->mult_req; in task_no_data_intr()
188 if (custom == 0 || tf->command == ATA_CMD_IDLEIMMEDIATE || in task_no_data_intr()
189 tf->command == ATA_CMD_CHK_POWER) { in task_no_data_intr()
190 struct request *rq = hwif->rq; in task_no_data_intr()
203 ide_hwif_t *hwif = drive->hwif; in wait_drive_not_busy()
212 stat = hwif->tp_ops->read_status(hwif); in wait_drive_not_busy()
221 pr_err("%s: drive still BUSY!\n", drive->name); in wait_drive_not_busy()
229 ide_hwif_t *hwif = drive->hwif; in ide_pio_bytes()
230 struct scatterlist *sg = hwif->sg_table; in ide_pio_bytes()
231 struct scatterlist *cursg = cmd->cursg; in ide_pio_bytes()
237 cursg = cmd->cursg = sg; in ide_pio_bytes()
240 unsigned nr_bytes = min(len, cursg->length - cmd->cursg_ofs); in ide_pio_bytes()
243 offset = cursg->offset + cmd->cursg_ofs; in ide_pio_bytes()
249 nr_bytes = min_t(unsigned, nr_bytes, (PAGE_SIZE - offset)); in ide_pio_bytes()
253 cmd->nleft -= nr_bytes; in ide_pio_bytes()
254 cmd->cursg_ofs += nr_bytes; in ide_pio_bytes()
256 if (cmd->cursg_ofs == cursg->length) { in ide_pio_bytes()
257 cursg = cmd->cursg = sg_next(cmd->cursg); in ide_pio_bytes()
258 cmd->cursg_ofs = 0; in ide_pio_bytes()
263 hwif->tp_ops->output_data(drive, cmd, buf, nr_bytes); in ide_pio_bytes()
265 hwif->tp_ops->input_data(drive, cmd, buf, nr_bytes); in ide_pio_bytes()
269 len -= nr_bytes; in ide_pio_bytes()
279 u8 saved_io_32bit = drive->io_32bit; in ide_pio_datablock()
281 if (cmd->tf_flags & IDE_TFLAG_FS) in ide_pio_datablock()
282 scsi_req(cmd->rq)->result = 0; in ide_pio_datablock()
284 if (cmd->tf_flags & IDE_TFLAG_IO_16BIT) in ide_pio_datablock()
285 drive->io_32bit = 0; in ide_pio_datablock()
289 if (cmd->tf_flags & IDE_TFLAG_MULTI_PIO) in ide_pio_datablock()
290 nr_bytes = min_t(unsigned, cmd->nleft, drive->mult_count << 9); in ide_pio_datablock()
296 drive->io_32bit = saved_io_32bit; in ide_pio_datablock()
301 if (cmd->tf_flags & IDE_TFLAG_FS) { in ide_error_cmd()
302 int nr_bytes = cmd->nbytes - cmd->nleft; in ide_error_cmd()
304 if (cmd->protocol == ATA_PROT_PIO && in ide_error_cmd()
305 ((cmd->tf_flags & IDE_TFLAG_WRITE) || cmd->nleft == 0)) { in ide_error_cmd()
306 if (cmd->tf_flags & IDE_TFLAG_MULTI_PIO) in ide_error_cmd()
307 nr_bytes -= drive->mult_count << 9; in ide_error_cmd()
309 nr_bytes -= SECTOR_SIZE; in ide_error_cmd()
319 struct request *rq = drive->hwif->rq; in ide_finish_cmd()
320 u8 err = ide_read_error(drive), nsect = cmd->tf.nsect; in ide_finish_cmd()
321 u8 set_xfer = !!(cmd->tf_flags & IDE_TFLAG_SET_XFER); in ide_finish_cmd()
324 scsi_req(rq)->result = err; in ide_finish_cmd()
339 ide_hwif_t *hwif = drive->hwif; in task_pio_intr()
340 struct ide_cmd *cmd = &drive->hwif->cmd; in task_pio_intr()
341 u8 stat = hwif->tp_ops->read_status(hwif); in task_pio_intr()
342 u8 write = !!(cmd->tf_flags & IDE_TFLAG_WRITE); in task_pio_intr()
355 /* Assume it was a spurious irq */ in task_pio_intr()
359 if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat)) in task_pio_intr()
363 if (((stat & ATA_DRQ) == 0) ^ (cmd->nleft == 0)) in task_pio_intr()
367 if (write && cmd->nleft == 0) in task_pio_intr()
374 if (write == 0 && cmd->nleft == 0) { in task_pio_intr()
386 if ((cmd->tf_flags & IDE_TFLAG_FS) == 0) in task_pio_intr()
389 ide_complete_rq(drive, BLK_STS_OK, blk_rq_sectors(cmd->rq) << 9); in task_pio_intr()
402 drive->bad_wstat, WAIT_DRQ)) { in pre_task_out_intr()
403 pr_err("%s: no DRQ after issuing %sWRITE%s\n", drive->name, in pre_task_out_intr()
404 (cmd->tf_flags & IDE_TFLAG_MULTI_PIO) ? "MULT" : "", in pre_task_out_intr()
405 (drive->dev_flags & IDE_DFLAG_LBA48) ? "_EXT" : ""); in pre_task_out_intr()
409 if (!force_irqthreads && (drive->dev_flags & IDE_DFLAG_UNMASK) == 0) in pre_task_out_intr()
425 rq = blk_get_request(drive->queue, in ide_raw_taskfile()
426 (cmd->tf_flags & IDE_TFLAG_WRITE) ? in ide_raw_taskfile()
428 ide_req(rq)->type = ATA_PRIV_TASKFILE; in ide_raw_taskfile()
433 * if we would find a solution to transfer any size. in ide_raw_taskfile()
437 error = blk_rq_map_kern(drive->queue, rq, buf, in ide_raw_taskfile()
443 ide_req(rq)->special = cmd; in ide_raw_taskfile()
444 cmd->rq = rq; in ide_raw_taskfile()
446 blk_execute_rq(drive->queue, NULL, rq, 0); in ide_raw_taskfile()
447 error = scsi_req(rq)->result ? -EIO : 0; in ide_raw_taskfile()
456 cmd->protocol = ATA_PROT_NODATA; in ide_no_data_taskfile()
481 taskout = req_task->out_size; in ide_taskfile_ioctl()
482 taskin = req_task->in_size; in ide_taskfile_ioctl()
485 err = -EINVAL; in ide_taskfile_ioctl()
493 err = -ENOMEM; in ide_taskfile_ioctl()
497 err = -EFAULT; in ide_taskfile_ioctl()
506 err = -ENOMEM; in ide_taskfile_ioctl()
510 err = -EFAULT; in ide_taskfile_ioctl()
517 memcpy(&cmd.hob, req_task->hob_ports, HDIO_DRIVE_HOB_HDR_SIZE - 2); in ide_taskfile_ioctl()
518 memcpy(&cmd.tf, req_task->io_ports, HDIO_DRIVE_TASK_HDR_SIZE); in ide_taskfile_ioctl()
520 cmd.valid.out.tf = IDE_VALID_DEVICE; in ide_taskfile_ioctl()
521 cmd.valid.in.tf = IDE_VALID_DEVICE | IDE_VALID_IN_TF; in ide_taskfile_ioctl()
524 if (drive->dev_flags & IDE_DFLAG_LBA48) { in ide_taskfile_ioctl()
529 if (req_task->out_flags.all) { in ide_taskfile_ioctl()
532 if (req_task->out_flags.b.data) in ide_taskfile_ioctl()
535 if (req_task->out_flags.b.nsector_hob) in ide_taskfile_ioctl()
537 if (req_task->out_flags.b.sector_hob) in ide_taskfile_ioctl()
539 if (req_task->out_flags.b.lcyl_hob) in ide_taskfile_ioctl()
541 if (req_task->out_flags.b.hcyl_hob) in ide_taskfile_ioctl()
544 if (req_task->out_flags.b.error_feature) in ide_taskfile_ioctl()
545 cmd.valid.out.tf |= IDE_VALID_FEATURE; in ide_taskfile_ioctl()
546 if (req_task->out_flags.b.nsector) in ide_taskfile_ioctl()
547 cmd.valid.out.tf |= IDE_VALID_NSECT; in ide_taskfile_ioctl()
548 if (req_task->out_flags.b.sector) in ide_taskfile_ioctl()
549 cmd.valid.out.tf |= IDE_VALID_LBAL; in ide_taskfile_ioctl()
550 if (req_task->out_flags.b.lcyl) in ide_taskfile_ioctl()
551 cmd.valid.out.tf |= IDE_VALID_LBAM; in ide_taskfile_ioctl()
552 if (req_task->out_flags.b.hcyl) in ide_taskfile_ioctl()
553 cmd.valid.out.tf |= IDE_VALID_LBAH; in ide_taskfile_ioctl()
555 cmd.valid.out.tf |= IDE_VALID_OUT_TF; in ide_taskfile_ioctl()
560 if (req_task->in_flags.b.data) in ide_taskfile_ioctl()
563 if (req_task->req_cmd == IDE_DRIVE_TASK_RAW_WRITE) { in ide_taskfile_ioctl()
565 if (req_task->data_phase == TASKFILE_IN_DMAQ || in ide_taskfile_ioctl()
566 req_task->data_phase == TASKFILE_IN_DMA) in ide_taskfile_ioctl()
572 switch (req_task->data_phase) { in ide_taskfile_ioctl()
574 if (!drive->mult_count) { in ide_taskfile_ioctl()
577 drive->name, __func__); in ide_taskfile_ioctl()
578 err = -EPERM; in ide_taskfile_ioctl()
593 if (!drive->mult_count) { in ide_taskfile_ioctl()
596 drive->name, __func__); in ide_taskfile_ioctl()
597 err = -EPERM; in ide_taskfile_ioctl()
614 err = -EFAULT; in ide_taskfile_ioctl()
618 if (req_task->req_cmd == IDE_DRIVE_TASK_NO_DATA) in ide_taskfile_ioctl()
621 nsect = (cmd.hob.nsect << 8) | cmd.tf.nsect; in ide_taskfile_ioctl()
625 drive->name); in ide_taskfile_ioctl()
626 err = -EFAULT; in ide_taskfile_ioctl()
633 memcpy(req_task->hob_ports, &cmd.hob, HDIO_DRIVE_HOB_HDR_SIZE - 2); in ide_taskfile_ioctl()
634 memcpy(req_task->io_ports, &cmd.tf, HDIO_DRIVE_TASK_HDR_SIZE); in ide_taskfile_ioctl()
637 req_task->in_flags.all == 0) { in ide_taskfile_ioctl()
638 req_task->in_flags.all = IDE_TASKFILE_STD_IN_FLAGS; in ide_taskfile_ioctl()
639 if (drive->dev_flags & IDE_DFLAG_LBA48) in ide_taskfile_ioctl()
640 req_task->in_flags.all |= (IDE_HOB_STD_IN_FLAGS << 8); in ide_taskfile_ioctl()
644 err = -EFAULT; in ide_taskfile_ioctl()
650 err = -EFAULT; in ide_taskfile_ioctl()
657 err = -EFAULT; in ide_taskfile_ioctl()