aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/ata.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/ata.h')
-rw-r--r--include/linux/ata.h138
1 files changed, 126 insertions, 12 deletions
diff --git a/include/linux/ata.h b/include/linux/ata.h
index b5a20162af32..a4f373f8b798 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -64,6 +64,28 @@ enum {
64 ATA_ID_PROD_LEN = 40, 64 ATA_ID_PROD_LEN = 40,
65 65
66 ATA_PCI_CTL_OFS = 2, 66 ATA_PCI_CTL_OFS = 2,
67
68 ATA_PIO0 = (1 << 0),
69 ATA_PIO1 = ATA_PIO0 | (1 << 1),
70 ATA_PIO2 = ATA_PIO1 | (1 << 2),
71 ATA_PIO3 = ATA_PIO2 | (1 << 3),
72 ATA_PIO4 = ATA_PIO3 | (1 << 4),
73 ATA_PIO5 = ATA_PIO4 | (1 << 5),
74 ATA_PIO6 = ATA_PIO5 | (1 << 6),
75
76 ATA_SWDMA0 = (1 << 0),
77 ATA_SWDMA1 = ATA_SWDMA0 | (1 << 1),
78 ATA_SWDMA2 = ATA_SWDMA1 | (1 << 2),
79
80 ATA_SWDMA2_ONLY = (1 << 2),
81
82 ATA_MWDMA0 = (1 << 0),
83 ATA_MWDMA1 = ATA_MWDMA0 | (1 << 1),
84 ATA_MWDMA2 = ATA_MWDMA1 | (1 << 2),
85
86 ATA_MWDMA12_ONLY = (1 << 1) | (1 << 2),
87 ATA_MWDMA2_ONLY = (1 << 2),
88
67 ATA_UDMA0 = (1 << 0), 89 ATA_UDMA0 = (1 << 0),
68 ATA_UDMA1 = ATA_UDMA0 | (1 << 1), 90 ATA_UDMA1 = ATA_UDMA0 | (1 << 1),
69 ATA_UDMA2 = ATA_UDMA1 | (1 << 2), 91 ATA_UDMA2 = ATA_UDMA1 | (1 << 2),
@@ -208,6 +230,12 @@ enum {
208 230
209 SETFEATURES_SPINUP = 0x07, /* Spin-up drive */ 231 SETFEATURES_SPINUP = 0x07, /* Spin-up drive */
210 232
233 SETFEATURES_SATA_ENABLE = 0x10, /* Enable use of SATA feature */
234 SETFEATURES_SATA_DISABLE = 0x90, /* Disable use of SATA feature */
235
236 /* SETFEATURE Sector counts for SATA features */
237 SATA_AN = 0x05, /* Asynchronous Notification */
238
211 /* ATAPI stuff */ 239 /* ATAPI stuff */
212 ATAPI_PKT_DMA = (1 << 0), 240 ATAPI_PKT_DMA = (1 << 0),
213 ATAPI_DMADIR = (1 << 2), /* ATAPI data dir: 241 ATAPI_DMADIR = (1 << 2), /* ATAPI data dir:
@@ -259,6 +287,15 @@ enum {
259 SERR_PROTOCOL = (1 << 10), /* protocol violation */ 287 SERR_PROTOCOL = (1 << 10), /* protocol violation */
260 SERR_INTERNAL = (1 << 11), /* host internal error */ 288 SERR_INTERNAL = (1 << 11), /* host internal error */
261 SERR_PHYRDY_CHG = (1 << 16), /* PHY RDY changed */ 289 SERR_PHYRDY_CHG = (1 << 16), /* PHY RDY changed */
290 SERR_PHY_INT_ERR = (1 << 17), /* PHY internal error */
291 SERR_COMM_WAKE = (1 << 18), /* Comm wake */
292 SERR_10B_8B_ERR = (1 << 19), /* 10b to 8b decode error */
293 SERR_DISPARITY = (1 << 20), /* Disparity */
294 SERR_CRC = (1 << 21), /* CRC error */
295 SERR_HANDSHAKE = (1 << 22), /* Handshake error */
296 SERR_LINK_SEQ_ERR = (1 << 23), /* Link sequence error */
297 SERR_TRANS_ST_ERROR = (1 << 24), /* Transport state trans. error */
298 SERR_UNRECOG_FIS = (1 << 25), /* Unrecognized FIS */
262 SERR_DEV_XCHG = (1 << 26), /* device exchanged */ 299 SERR_DEV_XCHG = (1 << 26), /* device exchanged */
263 300
264 /* struct ata_taskfile flags */ 301 /* struct ata_taskfile flags */
@@ -319,24 +356,17 @@ struct ata_taskfile {
319}; 356};
320 357
321#define ata_id_is_ata(id) (((id)[0] & (1 << 15)) == 0) 358#define ata_id_is_ata(id) (((id)[0] & (1 << 15)) == 0)
322#define ata_id_rahead_enabled(id) ((id)[85] & (1 << 6))
323#define ata_id_wcache_enabled(id) ((id)[85] & (1 << 5))
324#define ata_id_hpa_enabled(id) ((id)[85] & (1 << 10))
325#define ata_id_has_fua(id) ((id)[84] & (1 << 6))
326#define ata_id_has_flush(id) ((id)[83] & (1 << 12))
327#define ata_id_has_flush_ext(id) ((id)[83] & (1 << 13))
328#define ata_id_has_lba48(id) ((id)[83] & (1 << 10))
329#define ata_id_has_hpa(id) ((id)[82] & (1 << 10))
330#define ata_id_has_wcache(id) ((id)[82] & (1 << 5))
331#define ata_id_has_pm(id) ((id)[82] & (1 << 3))
332#define ata_id_has_lba(id) ((id)[49] & (1 << 9)) 359#define ata_id_has_lba(id) ((id)[49] & (1 << 9))
333#define ata_id_has_dma(id) ((id)[49] & (1 << 8)) 360#define ata_id_has_dma(id) ((id)[49] & (1 << 8))
334#define ata_id_has_ncq(id) ((id)[76] & (1 << 8)) 361#define ata_id_has_ncq(id) ((id)[76] & (1 << 8))
335#define ata_id_queue_depth(id) (((id)[75] & 0x1f) + 1) 362#define ata_id_queue_depth(id) (((id)[75] & 0x1f) + 1)
336#define ata_id_removeable(id) ((id)[0] & (1 << 7)) 363#define ata_id_removeable(id) ((id)[0] & (1 << 7))
337#define ata_id_has_dword_io(id) ((id)[50] & (1 << 0)) 364#define ata_id_has_dword_io(id) ((id)[48] & (1 << 0))
365#define ata_id_has_atapi_AN(id) \
366 ( (((id)[76] != 0x0000) && ((id)[76] != 0xffff)) && \
367 ((id)[78] & (1 << 5)) )
338#define ata_id_iordy_disable(id) ((id)[49] & (1 << 10)) 368#define ata_id_iordy_disable(id) ((id)[49] & (1 << 10))
339#define ata_id_has_iordy(id) ((id)[49] & (1 << 9)) 369#define ata_id_has_iordy(id) ((id)[49] & (1 << 11))
340#define ata_id_u32(id,n) \ 370#define ata_id_u32(id,n) \
341 (((u32) (id)[(n) + 1] << 16) | ((u32) (id)[(n)])) 371 (((u32) (id)[(n) + 1] << 16) | ((u32) (id)[(n)]))
342#define ata_id_u64(id,n) \ 372#define ata_id_u64(id,n) \
@@ -347,6 +377,90 @@ struct ata_taskfile {
347 377
348#define ata_id_cdb_intr(id) (((id)[0] & 0x60) == 0x20) 378#define ata_id_cdb_intr(id) (((id)[0] & 0x60) == 0x20)
349 379
380static inline int ata_id_has_fua(const u16 *id)
381{
382 if ((id[84] & 0xC000) != 0x4000)
383 return 0;
384 return id[84] & (1 << 6);
385}
386
387static inline int ata_id_has_flush(const u16 *id)
388{
389 if ((id[83] & 0xC000) != 0x4000)
390 return 0;
391 return id[83] & (1 << 12);
392}
393
394static inline int ata_id_has_flush_ext(const u16 *id)
395{
396 if ((id[83] & 0xC000) != 0x4000)
397 return 0;
398 return id[83] & (1 << 13);
399}
400
401static inline int ata_id_has_lba48(const u16 *id)
402{
403 if ((id[83] & 0xC000) != 0x4000)
404 return 0;
405 return id[83] & (1 << 10);
406}
407
408static inline int ata_id_hpa_enabled(const u16 *id)
409{
410 /* Yes children, word 83 valid bits cover word 82 data */
411 if ((id[83] & 0xC000) != 0x4000)
412 return 0;
413 /* And 87 covers 85-87 */
414 if ((id[87] & 0xC000) != 0x4000)
415 return 0;
416 /* Check command sets enabled as well as supported */
417 if ((id[85] & ( 1 << 10)) == 0)
418 return 0;
419 return id[82] & (1 << 10);
420}
421
422static inline int ata_id_has_wcache(const u16 *id)
423{
424 /* Yes children, word 83 valid bits cover word 82 data */
425 if ((id[83] & 0xC000) != 0x4000)
426 return 0;
427 return id[82] & (1 << 5);
428}
429
430static inline int ata_id_has_pm(const u16 *id)
431{
432 if ((id[83] & 0xC000) != 0x4000)
433 return 0;
434 return id[82] & (1 << 3);
435}
436
437static inline int ata_id_rahead_enabled(const u16 *id)
438{
439 if ((id[87] & 0xC000) != 0x4000)
440 return 0;
441 return id[85] & (1 << 6);
442}
443
444static inline int ata_id_wcache_enabled(const u16 *id)
445{
446 if ((id[87] & 0xC000) != 0x4000)
447 return 0;
448 return id[85] & (1 << 5);
449}
450
451/**
452 * ata_id_major_version - get ATA level of drive
453 * @id: Identify data
454 *
455 * Caveats:
456 * ATA-1 considers identify optional
457 * ATA-2 introduces mandatory identify
458 * ATA-3 introduces word 80 and accurate reporting
459 *
460 * The practical impact of this is that ata_id_major_version cannot
461 * reliably report on drives below ATA3.
462 */
463
350static inline unsigned int ata_id_major_version(const u16 *id) 464static inline unsigned int ata_id_major_version(const u16 *id)
351{ 465{
352 unsigned int mver; 466 unsigned int mver;