Lines Matching refs:tf
538 void ata_tf_to_fis(const struct ata_taskfile *tf, u8 pmp, int is_cmd, u8 *fis) in ata_tf_to_fis() argument
545 fis[2] = tf->command; in ata_tf_to_fis()
546 fis[3] = tf->feature; in ata_tf_to_fis()
548 fis[4] = tf->lbal; in ata_tf_to_fis()
549 fis[5] = tf->lbam; in ata_tf_to_fis()
550 fis[6] = tf->lbah; in ata_tf_to_fis()
551 fis[7] = tf->device; in ata_tf_to_fis()
553 fis[8] = tf->hob_lbal; in ata_tf_to_fis()
554 fis[9] = tf->hob_lbam; in ata_tf_to_fis()
555 fis[10] = tf->hob_lbah; in ata_tf_to_fis()
556 fis[11] = tf->hob_feature; in ata_tf_to_fis()
558 fis[12] = tf->nsect; in ata_tf_to_fis()
559 fis[13] = tf->hob_nsect; in ata_tf_to_fis()
561 fis[15] = tf->ctl; in ata_tf_to_fis()
563 fis[16] = tf->auxiliary & 0xff; in ata_tf_to_fis()
564 fis[17] = (tf->auxiliary >> 8) & 0xff; in ata_tf_to_fis()
565 fis[18] = (tf->auxiliary >> 16) & 0xff; in ata_tf_to_fis()
566 fis[19] = (tf->auxiliary >> 24) & 0xff; in ata_tf_to_fis()
580 void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf) in ata_tf_from_fis() argument
582 tf->command = fis[2]; /* status */ in ata_tf_from_fis()
583 tf->feature = fis[3]; /* error */ in ata_tf_from_fis()
585 tf->lbal = fis[4]; in ata_tf_from_fis()
586 tf->lbam = fis[5]; in ata_tf_from_fis()
587 tf->lbah = fis[6]; in ata_tf_from_fis()
588 tf->device = fis[7]; in ata_tf_from_fis()
590 tf->hob_lbal = fis[8]; in ata_tf_from_fis()
591 tf->hob_lbam = fis[9]; in ata_tf_from_fis()
592 tf->hob_lbah = fis[10]; in ata_tf_from_fis()
594 tf->nsect = fis[12]; in ata_tf_from_fis()
595 tf->hob_nsect = fis[13]; in ata_tf_from_fis()
639 static int ata_rwcmd_protocol(struct ata_taskfile *tf, struct ata_device *dev) in ata_rwcmd_protocol() argument
645 fua = (tf->flags & ATA_TFLAG_FUA) ? 4 : 0; in ata_rwcmd_protocol()
646 lba48 = (tf->flags & ATA_TFLAG_LBA48) ? 2 : 0; in ata_rwcmd_protocol()
647 write = (tf->flags & ATA_TFLAG_WRITE) ? 1 : 0; in ata_rwcmd_protocol()
650 tf->protocol = ATA_PROT_PIO; in ata_rwcmd_protocol()
654 tf->protocol = ATA_PROT_PIO; in ata_rwcmd_protocol()
657 tf->protocol = ATA_PROT_DMA; in ata_rwcmd_protocol()
663 tf->command = cmd; in ata_rwcmd_protocol()
684 u64 ata_tf_read_block(const struct ata_taskfile *tf, struct ata_device *dev) in ata_tf_read_block() argument
688 if (tf->flags & ATA_TFLAG_LBA) { in ata_tf_read_block()
689 if (tf->flags & ATA_TFLAG_LBA48) { in ata_tf_read_block()
690 block |= (u64)tf->hob_lbah << 40; in ata_tf_read_block()
691 block |= (u64)tf->hob_lbam << 32; in ata_tf_read_block()
692 block |= (u64)tf->hob_lbal << 24; in ata_tf_read_block()
694 block |= (tf->device & 0xf) << 24; in ata_tf_read_block()
696 block |= tf->lbah << 16; in ata_tf_read_block()
697 block |= tf->lbam << 8; in ata_tf_read_block()
698 block |= tf->lbal; in ata_tf_read_block()
702 cyl = tf->lbam | (tf->lbah << 8); in ata_tf_read_block()
703 head = tf->device & 0xf; in ata_tf_read_block()
704 sect = tf->lbal; in ata_tf_read_block()
739 int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, in ata_build_rw_tf() argument
743 tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; in ata_build_rw_tf()
744 tf->flags |= tf_flags; in ata_build_rw_tf()
751 tf->protocol = ATA_PROT_NCQ; in ata_build_rw_tf()
752 tf->flags |= ATA_TFLAG_LBA | ATA_TFLAG_LBA48; in ata_build_rw_tf()
754 if (tf->flags & ATA_TFLAG_WRITE) in ata_build_rw_tf()
755 tf->command = ATA_CMD_FPDMA_WRITE; in ata_build_rw_tf()
757 tf->command = ATA_CMD_FPDMA_READ; in ata_build_rw_tf()
759 tf->nsect = tag << 3; in ata_build_rw_tf()
760 tf->hob_feature = (n_block >> 8) & 0xff; in ata_build_rw_tf()
761 tf->feature = n_block & 0xff; in ata_build_rw_tf()
763 tf->hob_lbah = (block >> 40) & 0xff; in ata_build_rw_tf()
764 tf->hob_lbam = (block >> 32) & 0xff; in ata_build_rw_tf()
765 tf->hob_lbal = (block >> 24) & 0xff; in ata_build_rw_tf()
766 tf->lbah = (block >> 16) & 0xff; in ata_build_rw_tf()
767 tf->lbam = (block >> 8) & 0xff; in ata_build_rw_tf()
768 tf->lbal = block & 0xff; in ata_build_rw_tf()
770 tf->device = ATA_LBA; in ata_build_rw_tf()
771 if (tf->flags & ATA_TFLAG_FUA) in ata_build_rw_tf()
772 tf->device |= 1 << 7; in ata_build_rw_tf()
776 tf->hob_nsect |= ATA_PRIO_HIGH << in ata_build_rw_tf()
780 tf->flags |= ATA_TFLAG_LBA; in ata_build_rw_tf()
784 tf->device |= (block >> 24) & 0xf; in ata_build_rw_tf()
790 tf->flags |= ATA_TFLAG_LBA48; in ata_build_rw_tf()
792 tf->hob_nsect = (n_block >> 8) & 0xff; in ata_build_rw_tf()
794 tf->hob_lbah = (block >> 40) & 0xff; in ata_build_rw_tf()
795 tf->hob_lbam = (block >> 32) & 0xff; in ata_build_rw_tf()
796 tf->hob_lbal = (block >> 24) & 0xff; in ata_build_rw_tf()
801 if (unlikely(ata_rwcmd_protocol(tf, dev) < 0)) in ata_build_rw_tf()
804 tf->nsect = n_block & 0xff; in ata_build_rw_tf()
806 tf->lbah = (block >> 16) & 0xff; in ata_build_rw_tf()
807 tf->lbam = (block >> 8) & 0xff; in ata_build_rw_tf()
808 tf->lbal = block & 0xff; in ata_build_rw_tf()
810 tf->device |= ATA_LBA; in ata_build_rw_tf()
819 if (unlikely(ata_rwcmd_protocol(tf, dev) < 0)) in ata_build_rw_tf()
838 tf->nsect = n_block & 0xff; /* Sector count 0 means 256 sectors */ in ata_build_rw_tf()
839 tf->lbal = sect; in ata_build_rw_tf()
840 tf->lbam = cyl; in ata_build_rw_tf()
841 tf->lbah = cyl >> 8; in ata_build_rw_tf()
842 tf->device |= head; in ata_build_rw_tf()
1046 unsigned int ata_dev_classify(const struct ata_taskfile *tf) in ata_dev_classify() argument
1069 if ((tf->lbam == 0) && (tf->lbah == 0)) { in ata_dev_classify()
1074 if ((tf->lbam == 0x14) && (tf->lbah == 0xeb)) { in ata_dev_classify()
1079 if ((tf->lbam == 0x69) && (tf->lbah == 0x96)) { in ata_dev_classify()
1084 if ((tf->lbam == 0x3c) && (tf->lbah == 0xc3)) { in ata_dev_classify()
1089 if ((tf->lbam == 0xcd) && (tf->lbah == 0xab)) { in ata_dev_classify()
1178 u64 ata_tf_to_lba48(const struct ata_taskfile *tf) in ata_tf_to_lba48() argument
1182 sectors |= ((u64)(tf->hob_lbah & 0xff)) << 40; in ata_tf_to_lba48()
1183 sectors |= ((u64)(tf->hob_lbam & 0xff)) << 32; in ata_tf_to_lba48()
1184 sectors |= ((u64)(tf->hob_lbal & 0xff)) << 24; in ata_tf_to_lba48()
1185 sectors |= (tf->lbah & 0xff) << 16; in ata_tf_to_lba48()
1186 sectors |= (tf->lbam & 0xff) << 8; in ata_tf_to_lba48()
1187 sectors |= (tf->lbal & 0xff); in ata_tf_to_lba48()
1192 u64 ata_tf_to_lba(const struct ata_taskfile *tf) in ata_tf_to_lba() argument
1196 sectors |= (tf->device & 0x0f) << 24; in ata_tf_to_lba()
1197 sectors |= (tf->lbah & 0xff) << 16; in ata_tf_to_lba()
1198 sectors |= (tf->lbam & 0xff) << 8; in ata_tf_to_lba()
1199 sectors |= (tf->lbal & 0xff); in ata_tf_to_lba()
1219 struct ata_taskfile tf; in ata_read_native_max_address() local
1222 ata_tf_init(dev, &tf); in ata_read_native_max_address()
1225 tf.flags |= ATA_TFLAG_DEVICE | ATA_TFLAG_ISADDR; in ata_read_native_max_address()
1228 tf.command = ATA_CMD_READ_NATIVE_MAX_EXT; in ata_read_native_max_address()
1229 tf.flags |= ATA_TFLAG_LBA48; in ata_read_native_max_address()
1231 tf.command = ATA_CMD_READ_NATIVE_MAX; in ata_read_native_max_address()
1233 tf.protocol = ATA_PROT_NODATA; in ata_read_native_max_address()
1234 tf.device |= ATA_LBA; in ata_read_native_max_address()
1236 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); in ata_read_native_max_address()
1241 if (err_mask == AC_ERR_DEV && (tf.feature & ATA_ABORTED)) in ata_read_native_max_address()
1247 *max_sectors = ata_tf_to_lba48(&tf) + 1; in ata_read_native_max_address()
1249 *max_sectors = ata_tf_to_lba(&tf) + 1; in ata_read_native_max_address()
1270 struct ata_taskfile tf; in ata_set_max_sectors() local
1275 ata_tf_init(dev, &tf); in ata_set_max_sectors()
1277 tf.flags |= ATA_TFLAG_DEVICE | ATA_TFLAG_ISADDR; in ata_set_max_sectors()
1280 tf.command = ATA_CMD_SET_MAX_EXT; in ata_set_max_sectors()
1281 tf.flags |= ATA_TFLAG_LBA48; in ata_set_max_sectors()
1283 tf.hob_lbal = (new_sectors >> 24) & 0xff; in ata_set_max_sectors()
1284 tf.hob_lbam = (new_sectors >> 32) & 0xff; in ata_set_max_sectors()
1285 tf.hob_lbah = (new_sectors >> 40) & 0xff; in ata_set_max_sectors()
1287 tf.command = ATA_CMD_SET_MAX; in ata_set_max_sectors()
1289 tf.device |= (new_sectors >> 24) & 0xf; in ata_set_max_sectors()
1292 tf.protocol = ATA_PROT_NODATA; in ata_set_max_sectors()
1293 tf.device |= ATA_LBA; in ata_set_max_sectors()
1295 tf.lbal = (new_sectors >> 0) & 0xff; in ata_set_max_sectors()
1296 tf.lbam = (new_sectors >> 8) & 0xff; in ata_set_max_sectors()
1297 tf.lbah = (new_sectors >> 16) & 0xff; in ata_set_max_sectors()
1299 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); in ata_set_max_sectors()
1305 (tf.feature & (ATA_ABORTED | ATA_IDNF))) in ata_set_max_sectors()
1548 struct ata_taskfile *tf, const u8 *cdb, in ata_exec_internal_sg() argument
1554 u8 command = tf->command; in ata_exec_internal_sg()
1594 qc->tf = *tf; in ata_exec_internal_sg()
1599 if (tf->protocol == ATAPI_PROT_DMA && (dev->flags & ATA_DFLAG_DMADIR) && in ata_exec_internal_sg()
1601 qc->tf.feature |= ATAPI_DMADIR; in ata_exec_internal_sg()
1680 } else if (qc->tf.command == ATA_CMD_REQ_SENSE_DATA) { in ata_exec_internal_sg()
1687 *tf = qc->result_tf; in ata_exec_internal_sg()
1724 struct ata_taskfile *tf, const u8 *cdb, in ata_exec_internal() argument
1738 return ata_exec_internal_sg(dev, tf, cdb, dma_dir, psg, n_elem, in ata_exec_internal()
1809 struct ata_taskfile *tf, u16 *id) in ata_do_dev_read_id() argument
1811 return ata_exec_internal(dev, tf, NULL, DMA_FROM_DEVICE, in ata_do_dev_read_id()
1841 struct ata_taskfile tf; in ata_dev_read_id() local
1852 ata_tf_init(dev, &tf); in ata_dev_read_id()
1860 tf.command = ATA_CMD_ID_ATA; in ata_dev_read_id()
1863 tf.command = ATA_CMD_ID_ATAPI; in ata_dev_read_id()
1871 tf.protocol = ATA_PROT_PIO; in ata_dev_read_id()
1876 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; in ata_dev_read_id()
1881 tf.flags |= ATA_TFLAG_POLLING; in ata_dev_read_id()
1884 err_mask = ap->ops->read_id(dev, &tf, id); in ata_dev_read_id()
1886 err_mask = ata_do_dev_read_id(dev, &tf, id); in ata_dev_read_id()
1902 if ((err_mask == AC_ERR_DEV) && (tf.feature & ATA_ABORTED)) { in ata_dev_read_id()
2046 struct ata_taskfile tf; in ata_read_log_page() local
2060 ata_tf_init(dev, &tf); in ata_read_log_page()
2063 tf.command = ATA_CMD_READ_LOG_DMA_EXT; in ata_read_log_page()
2064 tf.protocol = ATA_PROT_DMA; in ata_read_log_page()
2067 tf.command = ATA_CMD_READ_LOG_EXT; in ata_read_log_page()
2068 tf.protocol = ATA_PROT_PIO; in ata_read_log_page()
2071 tf.lbal = log; in ata_read_log_page()
2072 tf.lbam = page; in ata_read_log_page()
2073 tf.nsect = sectors; in ata_read_log_page()
2074 tf.hob_nsect = sectors >> 8; in ata_read_log_page()
2075 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_LBA48 | ATA_TFLAG_DEVICE; in ata_read_log_page()
2077 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE, in ata_read_log_page()
4808 struct ata_taskfile tf; in ata_dev_set_xfermode() local
4817 ata_tf_init(dev, &tf); in ata_dev_set_xfermode()
4818 tf.command = ATA_CMD_SET_FEATURES; in ata_dev_set_xfermode()
4819 tf.feature = SETFEATURES_XFER; in ata_dev_set_xfermode()
4820 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE | ATA_TFLAG_POLLING; in ata_dev_set_xfermode()
4821 tf.protocol = ATA_PROT_NODATA; in ata_dev_set_xfermode()
4824 tf.nsect = dev->xfer_mode; in ata_dev_set_xfermode()
4827 tf.nsect = 0x01; in ata_dev_set_xfermode()
4832 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 15000); in ata_dev_set_xfermode()
4855 struct ata_taskfile tf; in ata_dev_set_feature() local
4862 ata_tf_init(dev, &tf); in ata_dev_set_feature()
4863 tf.command = ATA_CMD_SET_FEATURES; in ata_dev_set_feature()
4864 tf.feature = enable; in ata_dev_set_feature()
4865 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; in ata_dev_set_feature()
4866 tf.protocol = ATA_PROT_NODATA; in ata_dev_set_feature()
4867 tf.nsect = feature; in ata_dev_set_feature()
4872 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, timeout); in ata_dev_set_feature()
4894 struct ata_taskfile tf; in ata_dev_init_params() local
4904 ata_tf_init(dev, &tf); in ata_dev_init_params()
4905 tf.command = ATA_CMD_INIT_DEV_PARAMS; in ata_dev_init_params()
4906 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; in ata_dev_init_params()
4907 tf.protocol = ATA_PROT_NODATA; in ata_dev_init_params()
4908 tf.nsect = sectors; in ata_dev_init_params()
4909 tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */ in ata_dev_init_params()
4911 err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0); in ata_dev_init_params()
4915 if (err_mask == AC_ERR_DEV && (tf.feature & ATA_ABORTED)) in ata_dev_init_params()
4972 if (ata_is_ncq(qc->tf.protocol)) { in ata_std_qc_defer()
5172 if (ata_is_ncq(qc->tf.protocol)) { in __ata_qc_complete()
5201 qc->result_tf.flags = qc->tf.flags; in fill_result_tf()
5209 if (!ata_is_data(qc->tf.protocol)) in ata_verify_xfer()
5212 if ((dev->mwdma_mask || dev->udma_mask) && ata_is_pio(qc->tf.protocol)) in ata_verify_xfer()
5238 ledtrig_disk_activity(!!(qc->tf.flags & ATA_TFLAG_WRITE)); in ata_qc_complete()
5292 switch (qc->tf.command) { in ata_qc_complete()
5294 if (qc->tf.feature != SETFEATURES_WC_ON && in ata_qc_complete()
5295 qc->tf.feature != SETFEATURES_WC_OFF && in ata_qc_complete()
5296 qc->tf.feature != SETFEATURES_RA_ON && in ata_qc_complete()
5297 qc->tf.feature != SETFEATURES_RA_OFF) in ata_qc_complete()
5426 u8 prot = qc->tf.protocol; in ata_qc_issue()