diff options
Diffstat (limited to 'include/linux/ata.h')
-rw-r--r-- | include/linux/ata.h | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/include/linux/ata.h b/include/linux/ata.h index 9a061accd8b8..cb79b7a208e1 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h | |||
@@ -29,6 +29,8 @@ | |||
29 | #ifndef __LINUX_ATA_H__ | 29 | #ifndef __LINUX_ATA_H__ |
30 | #define __LINUX_ATA_H__ | 30 | #define __LINUX_ATA_H__ |
31 | 31 | ||
32 | #include <linux/kernel.h> | ||
33 | #include <linux/string.h> | ||
32 | #include <linux/types.h> | 34 | #include <linux/types.h> |
33 | #include <asm/byteorder.h> | 35 | #include <asm/byteorder.h> |
34 | 36 | ||
@@ -91,6 +93,7 @@ enum { | |||
91 | ATA_ID_CFA_POWER = 160, | 93 | ATA_ID_CFA_POWER = 160, |
92 | ATA_ID_CFA_KEY_MGMT = 162, | 94 | ATA_ID_CFA_KEY_MGMT = 162, |
93 | ATA_ID_CFA_MODES = 163, | 95 | ATA_ID_CFA_MODES = 163, |
96 | ATA_ID_DATA_SET_MGMT = 169, | ||
94 | ATA_ID_ROT_SPEED = 217, | 97 | ATA_ID_ROT_SPEED = 217, |
95 | ATA_ID_PIO4 = (1 << 1), | 98 | ATA_ID_PIO4 = (1 << 1), |
96 | 99 | ||
@@ -108,6 +111,8 @@ enum { | |||
108 | ATA_PIO5 = ATA_PIO4 | (1 << 5), | 111 | ATA_PIO5 = ATA_PIO4 | (1 << 5), |
109 | ATA_PIO6 = ATA_PIO5 | (1 << 6), | 112 | ATA_PIO6 = ATA_PIO5 | (1 << 6), |
110 | 113 | ||
114 | ATA_PIO4_ONLY = (1 << 4), | ||
115 | |||
111 | ATA_SWDMA0 = (1 << 0), | 116 | ATA_SWDMA0 = (1 << 0), |
112 | ATA_SWDMA1 = ATA_SWDMA0 | (1 << 1), | 117 | ATA_SWDMA1 = ATA_SWDMA0 | (1 << 1), |
113 | ATA_SWDMA2 = ATA_SWDMA1 | (1 << 2), | 118 | ATA_SWDMA2 = ATA_SWDMA1 | (1 << 2), |
@@ -117,6 +122,8 @@ enum { | |||
117 | ATA_MWDMA0 = (1 << 0), | 122 | ATA_MWDMA0 = (1 << 0), |
118 | ATA_MWDMA1 = ATA_MWDMA0 | (1 << 1), | 123 | ATA_MWDMA1 = ATA_MWDMA0 | (1 << 1), |
119 | ATA_MWDMA2 = ATA_MWDMA1 | (1 << 2), | 124 | ATA_MWDMA2 = ATA_MWDMA1 | (1 << 2), |
125 | ATA_MWDMA3 = ATA_MWDMA2 | (1 << 3), | ||
126 | ATA_MWDMA4 = ATA_MWDMA3 | (1 << 4), | ||
120 | 127 | ||
121 | ATA_MWDMA12_ONLY = (1 << 1) | (1 << 2), | 128 | ATA_MWDMA12_ONLY = (1 << 1) | (1 << 2), |
122 | ATA_MWDMA2_ONLY = (1 << 2), | 129 | ATA_MWDMA2_ONLY = (1 << 2), |
@@ -131,6 +138,8 @@ enum { | |||
131 | ATA_UDMA7 = ATA_UDMA6 | (1 << 7), | 138 | ATA_UDMA7 = ATA_UDMA6 | (1 << 7), |
132 | /* ATA_UDMA7 is just for completeness... doesn't exist (yet?). */ | 139 | /* ATA_UDMA7 is just for completeness... doesn't exist (yet?). */ |
133 | 140 | ||
141 | ATA_UDMA24_ONLY = (1 << 2) | (1 << 4), | ||
142 | |||
134 | ATA_UDMA_MASK_40C = ATA_UDMA2, /* udma0-2 */ | 143 | ATA_UDMA_MASK_40C = ATA_UDMA2, /* udma0-2 */ |
135 | 144 | ||
136 | /* DMA-related */ | 145 | /* DMA-related */ |
@@ -242,10 +251,9 @@ enum { | |||
242 | ATA_CMD_SMART = 0xB0, | 251 | ATA_CMD_SMART = 0xB0, |
243 | ATA_CMD_MEDIA_LOCK = 0xDE, | 252 | ATA_CMD_MEDIA_LOCK = 0xDE, |
244 | ATA_CMD_MEDIA_UNLOCK = 0xDF, | 253 | ATA_CMD_MEDIA_UNLOCK = 0xDF, |
254 | ATA_CMD_DSM = 0x06, | ||
245 | /* marked obsolete in the ATA/ATAPI-7 spec */ | 255 | /* marked obsolete in the ATA/ATAPI-7 spec */ |
246 | ATA_CMD_RESTORE = 0x10, | 256 | ATA_CMD_RESTORE = 0x10, |
247 | /* EXABYTE specific */ | ||
248 | ATA_EXABYTE_ENABLE_NEST = 0xF0, | ||
249 | 257 | ||
250 | /* READ_LOG_EXT pages */ | 258 | /* READ_LOG_EXT pages */ |
251 | ATA_LOG_SATA_NCQ = 0x10, | 259 | ATA_LOG_SATA_NCQ = 0x10, |
@@ -317,6 +325,9 @@ enum { | |||
317 | ATA_SMART_READ_VALUES = 0xD0, | 325 | ATA_SMART_READ_VALUES = 0xD0, |
318 | ATA_SMART_READ_THRESHOLDS = 0xD1, | 326 | ATA_SMART_READ_THRESHOLDS = 0xD1, |
319 | 327 | ||
328 | /* feature values for Data Set Management */ | ||
329 | ATA_DSM_TRIM = 0x01, | ||
330 | |||
320 | /* password used in LBA Mid / LBA High for executing SMART commands */ | 331 | /* password used in LBA Mid / LBA High for executing SMART commands */ |
321 | ATA_SMART_LBAM_PASS = 0x4F, | 332 | ATA_SMART_LBAM_PASS = 0x4F, |
322 | ATA_SMART_LBAH_PASS = 0xC2, | 333 | ATA_SMART_LBAH_PASS = 0xC2, |
@@ -719,6 +730,14 @@ static inline int ata_id_has_unload(const u16 *id) | |||
719 | return 0; | 730 | return 0; |
720 | } | 731 | } |
721 | 732 | ||
733 | static inline int ata_id_has_trim(const u16 *id) | ||
734 | { | ||
735 | if (ata_id_major_version(id) >= 7 && | ||
736 | (id[ATA_ID_DATA_SET_MGMT] & 1)) | ||
737 | return 1; | ||
738 | return 0; | ||
739 | } | ||
740 | |||
722 | static inline int ata_id_current_chs_valid(const u16 *id) | 741 | static inline int ata_id_current_chs_valid(const u16 *id) |
723 | { | 742 | { |
724 | /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command | 743 | /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command |
@@ -859,6 +878,32 @@ static inline void ata_id_to_hd_driveid(u16 *id) | |||
859 | #endif | 878 | #endif |
860 | } | 879 | } |
861 | 880 | ||
881 | /* | ||
882 | * Write up to 'max' LBA Range Entries to the buffer that will cover the | ||
883 | * extent from sector to sector + count. This is used for TRIM and for | ||
884 | * ADD LBA(S) TO NV CACHE PINNED SET. | ||
885 | */ | ||
886 | static inline unsigned ata_set_lba_range_entries(void *_buffer, unsigned max, | ||
887 | u64 sector, unsigned long count) | ||
888 | { | ||
889 | __le64 *buffer = _buffer; | ||
890 | unsigned i = 0; | ||
891 | |||
892 | while (i < max) { | ||
893 | u64 entry = sector | | ||
894 | ((u64)(count > 0xffff ? 0xffff : count) << 48); | ||
895 | buffer[i++] = __cpu_to_le64(entry); | ||
896 | if (count <= 0xffff) | ||
897 | break; | ||
898 | count -= 0xffff; | ||
899 | sector += 0xffff; | ||
900 | } | ||
901 | |||
902 | max = ALIGN(i * 8, 512); | ||
903 | memset(buffer + i, 0, max - i * 8); | ||
904 | return max; | ||
905 | } | ||
906 | |||
862 | static inline int is_multi_taskfile(struct ata_taskfile *tf) | 907 | static inline int is_multi_taskfile(struct ata_taskfile *tf) |
863 | { | 908 | { |
864 | return (tf->command == ATA_CMD_READ_MULTI) || | 909 | return (tf->command == ATA_CMD_READ_MULTI) || |