diff options
Diffstat (limited to 'include/linux/ata.h')
-rw-r--r-- | include/linux/ata.h | 116 |
1 files changed, 104 insertions, 12 deletions
diff --git a/include/linux/ata.h b/include/linux/ata.h index c043c1ccf1c5..a4f373f8b798 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h | |||
@@ -230,6 +230,12 @@ enum { | |||
230 | 230 | ||
231 | SETFEATURES_SPINUP = 0x07, /* Spin-up drive */ | 231 | SETFEATURES_SPINUP = 0x07, /* Spin-up drive */ |
232 | 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 | |||
233 | /* ATAPI stuff */ | 239 | /* ATAPI stuff */ |
234 | ATAPI_PKT_DMA = (1 << 0), | 240 | ATAPI_PKT_DMA = (1 << 0), |
235 | ATAPI_DMADIR = (1 << 2), /* ATAPI data dir: | 241 | ATAPI_DMADIR = (1 << 2), /* ATAPI data dir: |
@@ -281,6 +287,15 @@ enum { | |||
281 | SERR_PROTOCOL = (1 << 10), /* protocol violation */ | 287 | SERR_PROTOCOL = (1 << 10), /* protocol violation */ |
282 | SERR_INTERNAL = (1 << 11), /* host internal error */ | 288 | SERR_INTERNAL = (1 << 11), /* host internal error */ |
283 | 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 */ | ||
284 | SERR_DEV_XCHG = (1 << 26), /* device exchanged */ | 299 | SERR_DEV_XCHG = (1 << 26), /* device exchanged */ |
285 | 300 | ||
286 | /* struct ata_taskfile flags */ | 301 | /* struct ata_taskfile flags */ |
@@ -341,24 +356,17 @@ struct ata_taskfile { | |||
341 | }; | 356 | }; |
342 | 357 | ||
343 | #define ata_id_is_ata(id) (((id)[0] & (1 << 15)) == 0) | 358 | #define ata_id_is_ata(id) (((id)[0] & (1 << 15)) == 0) |
344 | #define ata_id_rahead_enabled(id) ((id)[85] & (1 << 6)) | ||
345 | #define ata_id_wcache_enabled(id) ((id)[85] & (1 << 5)) | ||
346 | #define ata_id_hpa_enabled(id) ((id)[85] & (1 << 10)) | ||
347 | #define ata_id_has_fua(id) ((id)[84] & (1 << 6)) | ||
348 | #define ata_id_has_flush(id) ((id)[83] & (1 << 12)) | ||
349 | #define ata_id_has_flush_ext(id) ((id)[83] & (1 << 13)) | ||
350 | #define ata_id_has_lba48(id) ((id)[83] & (1 << 10)) | ||
351 | #define ata_id_has_hpa(id) ((id)[82] & (1 << 10)) | ||
352 | #define ata_id_has_wcache(id) ((id)[82] & (1 << 5)) | ||
353 | #define ata_id_has_pm(id) ((id)[82] & (1 << 3)) | ||
354 | #define ata_id_has_lba(id) ((id)[49] & (1 << 9)) | 359 | #define ata_id_has_lba(id) ((id)[49] & (1 << 9)) |
355 | #define ata_id_has_dma(id) ((id)[49] & (1 << 8)) | 360 | #define ata_id_has_dma(id) ((id)[49] & (1 << 8)) |
356 | #define ata_id_has_ncq(id) ((id)[76] & (1 << 8)) | 361 | #define ata_id_has_ncq(id) ((id)[76] & (1 << 8)) |
357 | #define ata_id_queue_depth(id) (((id)[75] & 0x1f) + 1) | 362 | #define ata_id_queue_depth(id) (((id)[75] & 0x1f) + 1) |
358 | #define ata_id_removeable(id) ((id)[0] & (1 << 7)) | 363 | #define ata_id_removeable(id) ((id)[0] & (1 << 7)) |
359 | #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)) ) | ||
360 | #define ata_id_iordy_disable(id) ((id)[49] & (1 << 10)) | 368 | #define ata_id_iordy_disable(id) ((id)[49] & (1 << 10)) |
361 | #define ata_id_has_iordy(id) ((id)[49] & (1 << 9)) | 369 | #define ata_id_has_iordy(id) ((id)[49] & (1 << 11)) |
362 | #define ata_id_u32(id,n) \ | 370 | #define ata_id_u32(id,n) \ |
363 | (((u32) (id)[(n) + 1] << 16) | ((u32) (id)[(n)])) | 371 | (((u32) (id)[(n) + 1] << 16) | ((u32) (id)[(n)])) |
364 | #define ata_id_u64(id,n) \ | 372 | #define ata_id_u64(id,n) \ |
@@ -369,6 +377,90 @@ struct ata_taskfile { | |||
369 | 377 | ||
370 | #define ata_id_cdb_intr(id) (((id)[0] & 0x60) == 0x20) | 378 | #define ata_id_cdb_intr(id) (((id)[0] & 0x60) == 0x20) |
371 | 379 | ||
380 | static 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 | |||
387 | static 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 | |||
394 | static 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 | |||
401 | static 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 | |||
408 | static 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 | |||
422 | static 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 | |||
430 | static 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 | |||
437 | static 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 | |||
444 | static 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 | |||
372 | static inline unsigned int ata_id_major_version(const u16 *id) | 464 | static inline unsigned int ata_id_major_version(const u16 *id) |
373 | { | 465 | { |
374 | unsigned int mver; | 466 | unsigned int mver; |