aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-09-03 21:19:53 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-03 21:19:53 -0400
commit357397a14117f0c2eeafcac06a1f8412a02aa6af (patch)
tree8420d5aab6b80fc211979d894174462c9806b26e /include/linux
parent9ee52a1633a77961cb7b7fb5bd40be682f8412c7 (diff)
parent86a565e61bcb9574bae3b622799682fef2d855bb (diff)
Merge branch 'for-3.12' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata
Pull libata changes from Tejun Heo: "Two interesting changes. - libata acpi handling has been restructured so that the association between ata devices and ACPI handles are less convoluted. This change shouldn't change visible behavior. - Queued TRIM support, which enables sending TRIM to the device without draining in-flight RW commands, is added. Currently only enabled for ahci (and likely to stay that way for the foreseeable future). Other changes are driver-specific updates / fixes" * 'for-3.12' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata: libata: bugfix: Remove __le32 in ata_tf_to_fis() libata: acpi: Remove ata_dev_acpi_handle stub in libata.h libata: Add support for queued DSM TRIM libata: Add support for SEND/RECEIVE FPDMA QUEUED libata: Add H2D FIS "auxiliary" port flag libata: Populate host-to-device FIS "auxiliary" field ata: acpi: rework the ata acpi bind support sata, highbank: send extra clock cycles in SGPIO patterns sata, highbank: set tx_atten override bits devicetree: create a separate binding description for sata_highbank drivers/ata/sata_rcar.c: simplify use of devm_ioremap_resource sata highbank: enable 64-bit DMA mask when using LPAE ata: pata_samsung_cf: add missing __iomem annotation ata: pata_arasan: Staticize local symbols sata_mv: Remove unneeded CONFIG_HAVE_CLK ifdefs ata: use dev_get_platdata() sata_mv: Remove unneeded forward declaration libata: acpi: remove dead code for ata_acpi_(un)bind libata: move 'struct ata_taskfile' and friends from ata.h to libata.h
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/ata.h123
-rw-r--r--include/linux/libata.h120
2 files changed, 139 insertions, 104 deletions
diff --git a/include/linux/ata.h b/include/linux/ata.h
index ee0bd9524055..bf4c69ca76df 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -239,6 +239,8 @@ enum {
239 ATA_CMD_WRITE_QUEUED_FUA_EXT = 0x3E, 239 ATA_CMD_WRITE_QUEUED_FUA_EXT = 0x3E,
240 ATA_CMD_FPDMA_READ = 0x60, 240 ATA_CMD_FPDMA_READ = 0x60,
241 ATA_CMD_FPDMA_WRITE = 0x61, 241 ATA_CMD_FPDMA_WRITE = 0x61,
242 ATA_CMD_FPDMA_SEND = 0x64,
243 ATA_CMD_FPDMA_RECV = 0x65,
242 ATA_CMD_PIO_READ = 0x20, 244 ATA_CMD_PIO_READ = 0x20,
243 ATA_CMD_PIO_READ_EXT = 0x24, 245 ATA_CMD_PIO_READ_EXT = 0x24,
244 ATA_CMD_PIO_WRITE = 0x30, 246 ATA_CMD_PIO_WRITE = 0x30,
@@ -293,8 +295,13 @@ enum {
293 /* marked obsolete in the ATA/ATAPI-7 spec */ 295 /* marked obsolete in the ATA/ATAPI-7 spec */
294 ATA_CMD_RESTORE = 0x10, 296 ATA_CMD_RESTORE = 0x10,
295 297
298 /* Subcmds for ATA_CMD_FPDMA_SEND */
299 ATA_SUBCMD_FPDMA_SEND_DSM = 0x00,
300 ATA_SUBCMD_FPDMA_SEND_WR_LOG_DMA_EXT = 0x02,
301
296 /* READ_LOG_EXT pages */ 302 /* READ_LOG_EXT pages */
297 ATA_LOG_SATA_NCQ = 0x10, 303 ATA_LOG_SATA_NCQ = 0x10,
304 ATA_LOG_NCQ_SEND_RECV = 0x13,
298 ATA_LOG_SATA_ID_DEV_DATA = 0x30, 305 ATA_LOG_SATA_ID_DEV_DATA = 0x30,
299 ATA_LOG_SATA_SETTINGS = 0x08, 306 ATA_LOG_SATA_SETTINGS = 0x08,
300 ATA_LOG_DEVSLP_OFFSET = 0x30, 307 ATA_LOG_DEVSLP_OFFSET = 0x30,
@@ -305,6 +312,15 @@ enum {
305 ATA_LOG_DEVSLP_VALID = 0x07, 312 ATA_LOG_DEVSLP_VALID = 0x07,
306 ATA_LOG_DEVSLP_VALID_MASK = 0x80, 313 ATA_LOG_DEVSLP_VALID_MASK = 0x80,
307 314
315 /* NCQ send and receive log */
316 ATA_LOG_NCQ_SEND_RECV_SUBCMDS_OFFSET = 0x00,
317 ATA_LOG_NCQ_SEND_RECV_SUBCMDS_DSM = (1 << 0),
318 ATA_LOG_NCQ_SEND_RECV_DSM_OFFSET = 0x04,
319 ATA_LOG_NCQ_SEND_RECV_DSM_TRIM = (1 << 0),
320 ATA_LOG_NCQ_SEND_RECV_RD_LOG_OFFSET = 0x08,
321 ATA_LOG_NCQ_SEND_RECV_WR_LOG_OFFSET = 0x0C,
322 ATA_LOG_NCQ_SEND_RECV_SIZE = 0x10,
323
308 /* READ/WRITE LONG (obsolete) */ 324 /* READ/WRITE LONG (obsolete) */
309 ATA_CMD_READ_LONG = 0x22, 325 ATA_CMD_READ_LONG = 0x22,
310 ATA_CMD_READ_LONG_ONCE = 0x23, 326 ATA_CMD_READ_LONG_ONCE = 0x23,
@@ -446,22 +462,6 @@ enum {
446 SERR_TRANS_ST_ERROR = (1 << 24), /* Transport state trans. error */ 462 SERR_TRANS_ST_ERROR = (1 << 24), /* Transport state trans. error */
447 SERR_UNRECOG_FIS = (1 << 25), /* Unrecognized FIS */ 463 SERR_UNRECOG_FIS = (1 << 25), /* Unrecognized FIS */
448 SERR_DEV_XCHG = (1 << 26), /* device exchanged */ 464 SERR_DEV_XCHG = (1 << 26), /* device exchanged */
449
450 /* struct ata_taskfile flags */
451 ATA_TFLAG_LBA48 = (1 << 0), /* enable 48-bit LBA and "HOB" */
452 ATA_TFLAG_ISADDR = (1 << 1), /* enable r/w to nsect/lba regs */
453 ATA_TFLAG_DEVICE = (1 << 2), /* enable r/w to device reg */
454 ATA_TFLAG_WRITE = (1 << 3), /* data dir: host->dev==1 (write) */
455 ATA_TFLAG_LBA = (1 << 4), /* enable LBA */
456 ATA_TFLAG_FUA = (1 << 5), /* enable FUA */
457 ATA_TFLAG_POLLING = (1 << 6), /* set nIEN to 1 and use polling */
458
459 /* protocol flags */
460 ATA_PROT_FLAG_PIO = (1 << 0), /* is PIO */
461 ATA_PROT_FLAG_DMA = (1 << 1), /* is DMA */
462 ATA_PROT_FLAG_DATA = ATA_PROT_FLAG_PIO | ATA_PROT_FLAG_DMA,
463 ATA_PROT_FLAG_NCQ = (1 << 2), /* is NCQ */
464 ATA_PROT_FLAG_ATAPI = (1 << 3), /* is ATAPI */
465}; 465};
466 466
467enum ata_tf_protocols { 467enum ata_tf_protocols {
@@ -488,83 +488,6 @@ struct ata_bmdma_prd {
488 __le32 flags_len; 488 __le32 flags_len;
489}; 489};
490 490
491struct ata_taskfile {
492 unsigned long flags; /* ATA_TFLAG_xxx */
493 u8 protocol; /* ATA_PROT_xxx */
494
495 u8 ctl; /* control reg */
496
497 u8 hob_feature; /* additional data */
498 u8 hob_nsect; /* to support LBA48 */
499 u8 hob_lbal;
500 u8 hob_lbam;
501 u8 hob_lbah;
502
503 u8 feature;
504 u8 nsect;
505 u8 lbal;
506 u8 lbam;
507 u8 lbah;
508
509 u8 device;
510
511 u8 command; /* IO operation */
512};
513
514/*
515 * protocol tests
516 */
517static inline unsigned int ata_prot_flags(u8 prot)
518{
519 switch (prot) {
520 case ATA_PROT_NODATA:
521 return 0;
522 case ATA_PROT_PIO:
523 return ATA_PROT_FLAG_PIO;
524 case ATA_PROT_DMA:
525 return ATA_PROT_FLAG_DMA;
526 case ATA_PROT_NCQ:
527 return ATA_PROT_FLAG_DMA | ATA_PROT_FLAG_NCQ;
528 case ATAPI_PROT_NODATA:
529 return ATA_PROT_FLAG_ATAPI;
530 case ATAPI_PROT_PIO:
531 return ATA_PROT_FLAG_ATAPI | ATA_PROT_FLAG_PIO;
532 case ATAPI_PROT_DMA:
533 return ATA_PROT_FLAG_ATAPI | ATA_PROT_FLAG_DMA;
534 }
535 return 0;
536}
537
538static inline int ata_is_atapi(u8 prot)
539{
540 return ata_prot_flags(prot) & ATA_PROT_FLAG_ATAPI;
541}
542
543static inline int ata_is_nodata(u8 prot)
544{
545 return !(ata_prot_flags(prot) & ATA_PROT_FLAG_DATA);
546}
547
548static inline int ata_is_pio(u8 prot)
549{
550 return ata_prot_flags(prot) & ATA_PROT_FLAG_PIO;
551}
552
553static inline int ata_is_dma(u8 prot)
554{
555 return ata_prot_flags(prot) & ATA_PROT_FLAG_DMA;
556}
557
558static inline int ata_is_ncq(u8 prot)
559{
560 return ata_prot_flags(prot) & ATA_PROT_FLAG_NCQ;
561}
562
563static inline int ata_is_data(u8 prot)
564{
565 return ata_prot_flags(prot) & ATA_PROT_FLAG_DATA;
566}
567
568/* 491/*
569 * id tests 492 * id tests
570 */ 493 */
@@ -865,6 +788,11 @@ static inline int ata_id_rotation_rate(const u16 *id)
865 return val; 788 return val;
866} 789}
867 790
791static inline bool ata_id_has_ncq_send_and_recv(const u16 *id)
792{
793 return id[ATA_ID_SATA_CAPABILITY_2] & BIT(6);
794}
795
868static inline bool ata_id_has_trim(const u16 *id) 796static inline bool ata_id_has_trim(const u16 *id)
869{ 797{
870 if (ata_id_major_version(id) >= 7 && 798 if (ata_id_major_version(id) >= 7 &&
@@ -1060,15 +988,6 @@ static inline unsigned ata_set_lba_range_entries(void *_buffer,
1060 return used_bytes; 988 return used_bytes;
1061} 989}
1062 990
1063static inline int is_multi_taskfile(struct ata_taskfile *tf)
1064{
1065 return (tf->command == ATA_CMD_READ_MULTI) ||
1066 (tf->command == ATA_CMD_WRITE_MULTI) ||
1067 (tf->command == ATA_CMD_READ_MULTI_EXT) ||
1068 (tf->command == ATA_CMD_WRITE_MULTI_EXT) ||
1069 (tf->command == ATA_CMD_WRITE_MULTI_FUA_EXT);
1070}
1071
1072static inline bool ata_ok(u8 status) 991static inline bool ata_ok(u8 status)
1073{ 992{
1074 return ((status & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | ATA_ERR)) 993 return ((status & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ | ATA_ERR))
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 4ea55bb45deb..0e23c26485f4 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -138,6 +138,22 @@ enum {
138 ATA_SHT_THIS_ID = -1, 138 ATA_SHT_THIS_ID = -1,
139 ATA_SHT_USE_CLUSTERING = 1, 139 ATA_SHT_USE_CLUSTERING = 1,
140 140
141 /* struct ata_taskfile flags */
142 ATA_TFLAG_LBA48 = (1 << 0), /* enable 48-bit LBA and "HOB" */
143 ATA_TFLAG_ISADDR = (1 << 1), /* enable r/w to nsect/lba regs */
144 ATA_TFLAG_DEVICE = (1 << 2), /* enable r/w to device reg */
145 ATA_TFLAG_WRITE = (1 << 3), /* data dir: host->dev==1 (write) */
146 ATA_TFLAG_LBA = (1 << 4), /* enable LBA */
147 ATA_TFLAG_FUA = (1 << 5), /* enable FUA */
148 ATA_TFLAG_POLLING = (1 << 6), /* set nIEN to 1 and use polling */
149
150 /* protocol flags */
151 ATA_PROT_FLAG_PIO = (1 << 0), /* is PIO */
152 ATA_PROT_FLAG_DMA = (1 << 1), /* is DMA */
153 ATA_PROT_FLAG_DATA = ATA_PROT_FLAG_PIO | ATA_PROT_FLAG_DMA,
154 ATA_PROT_FLAG_NCQ = (1 << 2), /* is NCQ */
155 ATA_PROT_FLAG_ATAPI = (1 << 3), /* is ATAPI */
156
141 /* struct ata_device stuff */ 157 /* struct ata_device stuff */
142 ATA_DFLAG_LBA = (1 << 0), /* device supports LBA */ 158 ATA_DFLAG_LBA = (1 << 0), /* device supports LBA */
143 ATA_DFLAG_LBA48 = (1 << 1), /* device supports LBA48 */ 159 ATA_DFLAG_LBA48 = (1 << 1), /* device supports LBA48 */
@@ -156,6 +172,7 @@ enum {
156 ATA_DFLAG_DUBIOUS_XFER = (1 << 16), /* data transfer not verified */ 172 ATA_DFLAG_DUBIOUS_XFER = (1 << 16), /* data transfer not verified */
157 ATA_DFLAG_NO_UNLOAD = (1 << 17), /* device doesn't support unload */ 173 ATA_DFLAG_NO_UNLOAD = (1 << 17), /* device doesn't support unload */
158 ATA_DFLAG_UNLOCK_HPA = (1 << 18), /* unlock HPA */ 174 ATA_DFLAG_UNLOCK_HPA = (1 << 18), /* unlock HPA */
175 ATA_DFLAG_NCQ_SEND_RECV = (1 << 19), /* device supports NCQ SEND and RECV */
159 ATA_DFLAG_INIT_MASK = (1 << 24) - 1, 176 ATA_DFLAG_INIT_MASK = (1 << 24) - 1,
160 177
161 ATA_DFLAG_DETACH = (1 << 24), 178 ATA_DFLAG_DETACH = (1 << 24),
@@ -207,6 +224,7 @@ enum {
207 ATA_FLAG_ACPI_SATA = (1 << 17), /* need native SATA ACPI layout */ 224 ATA_FLAG_ACPI_SATA = (1 << 17), /* need native SATA ACPI layout */
208 ATA_FLAG_AN = (1 << 18), /* controller supports AN */ 225 ATA_FLAG_AN = (1 << 18), /* controller supports AN */
209 ATA_FLAG_PMP = (1 << 19), /* controller supports PMP */ 226 ATA_FLAG_PMP = (1 << 19), /* controller supports PMP */
227 ATA_FLAG_FPDMA_AUX = (1 << 20), /* controller supports H2DFIS aux field */
210 ATA_FLAG_EM = (1 << 21), /* driver supports enclosure 228 ATA_FLAG_EM = (1 << 21), /* driver supports enclosure
211 * management */ 229 * management */
212 ATA_FLAG_SW_ACTIVITY = (1 << 22), /* driver supports sw activity 230 ATA_FLAG_SW_ACTIVITY = (1 << 22), /* driver supports sw activity
@@ -518,6 +536,33 @@ enum sw_activity {
518 BLINK_OFF, 536 BLINK_OFF,
519}; 537};
520 538
539struct ata_taskfile {
540 unsigned long flags; /* ATA_TFLAG_xxx */
541 u8 protocol; /* ATA_PROT_xxx */
542
543 u8 ctl; /* control reg */
544
545 u8 hob_feature; /* additional data */
546 u8 hob_nsect; /* to support LBA48 */
547 u8 hob_lbal;
548 u8 hob_lbam;
549 u8 hob_lbah;
550
551 u8 feature;
552 u8 nsect;
553 u8 lbal;
554 u8 lbam;
555 u8 lbah;
556
557 u8 device;
558
559 u8 command; /* IO operation */
560
561 u32 auxiliary; /* auxiliary field */
562 /* from SATA 3.1 and */
563 /* ATA-8 ACS-3 */
564};
565
521#ifdef CONFIG_ATA_SFF 566#ifdef CONFIG_ATA_SFF
522struct ata_ioports { 567struct ata_ioports {
523 void __iomem *cmd_addr; 568 void __iomem *cmd_addr;
@@ -660,6 +705,9 @@ struct ata_device {
660 /* DEVSLP Timing Variables from Identify Device Data Log */ 705 /* DEVSLP Timing Variables from Identify Device Data Log */
661 u8 devslp_timing[ATA_LOG_DEVSLP_SIZE]; 706 u8 devslp_timing[ATA_LOG_DEVSLP_SIZE];
662 707
708 /* NCQ send and receive log subcommand support */
709 u8 ncq_send_recv_cmds[ATA_LOG_NCQ_SEND_RECV_SIZE];
710
663 /* error history */ 711 /* error history */
664 int spdn_cnt; 712 int spdn_cnt;
665 /* ering is CLEAR_END, read comment above CLEAR_END */ 713 /* ering is CLEAR_END, read comment above CLEAR_END */
@@ -959,6 +1007,69 @@ extern const unsigned long sata_deb_timing_long[];
959extern struct ata_port_operations ata_dummy_port_ops; 1007extern struct ata_port_operations ata_dummy_port_ops;
960extern const struct ata_port_info ata_dummy_port_info; 1008extern const struct ata_port_info ata_dummy_port_info;
961 1009
1010/*
1011 * protocol tests
1012 */
1013static inline unsigned int ata_prot_flags(u8 prot)
1014{
1015 switch (prot) {
1016 case ATA_PROT_NODATA:
1017 return 0;
1018 case ATA_PROT_PIO:
1019 return ATA_PROT_FLAG_PIO;
1020 case ATA_PROT_DMA:
1021 return ATA_PROT_FLAG_DMA;
1022 case ATA_PROT_NCQ:
1023 return ATA_PROT_FLAG_DMA | ATA_PROT_FLAG_NCQ;
1024 case ATAPI_PROT_NODATA:
1025 return ATA_PROT_FLAG_ATAPI;
1026 case ATAPI_PROT_PIO:
1027 return ATA_PROT_FLAG_ATAPI | ATA_PROT_FLAG_PIO;
1028 case ATAPI_PROT_DMA:
1029 return ATA_PROT_FLAG_ATAPI | ATA_PROT_FLAG_DMA;
1030 }
1031 return 0;
1032}
1033
1034static inline int ata_is_atapi(u8 prot)
1035{
1036 return ata_prot_flags(prot) & ATA_PROT_FLAG_ATAPI;
1037}
1038
1039static inline int ata_is_nodata(u8 prot)
1040{
1041 return !(ata_prot_flags(prot) & ATA_PROT_FLAG_DATA);
1042}
1043
1044static inline int ata_is_pio(u8 prot)
1045{
1046 return ata_prot_flags(prot) & ATA_PROT_FLAG_PIO;
1047}
1048
1049static inline int ata_is_dma(u8 prot)
1050{
1051 return ata_prot_flags(prot) & ATA_PROT_FLAG_DMA;
1052}
1053
1054static inline int ata_is_ncq(u8 prot)
1055{
1056 return ata_prot_flags(prot) & ATA_PROT_FLAG_NCQ;
1057}
1058
1059static inline int ata_is_data(u8 prot)
1060{
1061 return ata_prot_flags(prot) & ATA_PROT_FLAG_DATA;
1062}
1063
1064static inline int is_multi_taskfile(struct ata_taskfile *tf)
1065{
1066 return (tf->command == ATA_CMD_READ_MULTI) ||
1067 (tf->command == ATA_CMD_WRITE_MULTI) ||
1068 (tf->command == ATA_CMD_READ_MULTI_EXT) ||
1069 (tf->command == ATA_CMD_WRITE_MULTI_EXT) ||
1070 (tf->command == ATA_CMD_WRITE_MULTI_FUA_EXT);
1071}
1072
962static inline const unsigned long * 1073static inline const unsigned long *
963sata_ehc_deb_timing(struct ata_eh_context *ehc) 1074sata_ehc_deb_timing(struct ata_eh_context *ehc)
964{ 1075{
@@ -1142,8 +1253,6 @@ int ata_acpi_stm(struct ata_port *ap, const struct ata_acpi_gtm *stm);
1142int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *stm); 1253int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *stm);
1143unsigned long ata_acpi_gtm_xfermask(struct ata_device *dev, 1254unsigned long ata_acpi_gtm_xfermask(struct ata_device *dev,
1144 const struct ata_acpi_gtm *gtm); 1255 const struct ata_acpi_gtm *gtm);
1145acpi_handle ata_ap_acpi_handle(struct ata_port *ap);
1146acpi_handle ata_dev_acpi_handle(struct ata_device *dev);
1147int ata_acpi_cbl_80wire(struct ata_port *ap, const struct ata_acpi_gtm *gtm); 1256int ata_acpi_cbl_80wire(struct ata_port *ap, const struct ata_acpi_gtm *gtm);
1148#else 1257#else
1149static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap) 1258static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap)
@@ -1497,6 +1606,13 @@ static inline int ata_ncq_enabled(struct ata_device *dev)
1497 ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ; 1606 ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ;
1498} 1607}
1499 1608
1609static inline bool ata_fpdma_dsm_supported(struct ata_device *dev)
1610{
1611 return (dev->flags & ATA_DFLAG_NCQ_SEND_RECV) &&
1612 (dev->ncq_send_recv_cmds[ATA_LOG_NCQ_SEND_RECV_DSM_OFFSET] &
1613 ATA_LOG_NCQ_SEND_RECV_DSM_TRIM);
1614}
1615
1500static inline void ata_qc_set_polling(struct ata_queued_cmd *qc) 1616static inline void ata_qc_set_polling(struct ata_queued_cmd *qc)
1501{ 1617{
1502 qc->tf.ctl |= ATA_NIEN; 1618 qc->tf.ctl |= ATA_NIEN;