diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-08-18 15:40:05 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-08-18 15:40:05 -0400 |
commit | 37014c64079748c47fd109ef2d91ecd785a8c764 (patch) | |
tree | 0a1079a386f0884ceb0c8ad9674d3f387f55fd24 /include | |
parent | 1b427a33b06ae76c64c1ad9af899a45b682ba6c6 (diff) |
ata: add missing ATA_ID_* defines (take 2)
Add missing ATA_ID_* defines and update {ata,atapi}_*()
inlines accordingly. The currently unused defines are
needed for the forthcoming drivers/ide/ changes.
v2:
Add ATA_ID_SPG.
Acked-by: Jeff Garzik <jgarzik@pobox.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/ata.h | 122 |
1 files changed, 76 insertions, 46 deletions
diff --git a/include/linux/ata.h b/include/linux/ata.h index 1c622e2b0504..03fff6239b3c 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h | |||
@@ -46,18 +46,48 @@ enum { | |||
46 | ATA_MAX_SECTORS_TAPE = 65535, | 46 | ATA_MAX_SECTORS_TAPE = 65535, |
47 | 47 | ||
48 | ATA_ID_WORDS = 256, | 48 | ATA_ID_WORDS = 256, |
49 | ATA_ID_CONFIG = 0, | ||
50 | ATA_ID_CYLS = 1, | ||
51 | ATA_ID_HEADS = 3, | ||
52 | ATA_ID_SECTORS = 6, | ||
49 | ATA_ID_SERNO = 10, | 53 | ATA_ID_SERNO = 10, |
54 | ATA_ID_BUF_SIZE = 21, | ||
50 | ATA_ID_FW_REV = 23, | 55 | ATA_ID_FW_REV = 23, |
51 | ATA_ID_PROD = 27, | 56 | ATA_ID_PROD = 27, |
57 | ATA_ID_MAX_MULTSECT = 47, | ||
58 | ATA_ID_DWORD_IO = 48, | ||
59 | ATA_ID_CAPABILITY = 49, | ||
52 | ATA_ID_OLD_PIO_MODES = 51, | 60 | ATA_ID_OLD_PIO_MODES = 51, |
61 | ATA_ID_OLD_DMA_MODES = 52, | ||
53 | ATA_ID_FIELD_VALID = 53, | 62 | ATA_ID_FIELD_VALID = 53, |
63 | ATA_ID_CUR_CYLS = 54, | ||
64 | ATA_ID_CUR_HEADS = 55, | ||
65 | ATA_ID_CUR_SECTORS = 56, | ||
66 | ATA_ID_MULTSECT = 59, | ||
67 | ATA_ID_LBA_CAPACITY = 60, | ||
68 | ATA_ID_SWDMA_MODES = 62, | ||
54 | ATA_ID_MWDMA_MODES = 63, | 69 | ATA_ID_MWDMA_MODES = 63, |
55 | ATA_ID_PIO_MODES = 64, | 70 | ATA_ID_PIO_MODES = 64, |
56 | ATA_ID_EIDE_DMA_MIN = 65, | 71 | ATA_ID_EIDE_DMA_MIN = 65, |
72 | ATA_ID_EIDE_DMA_TIME = 66, | ||
57 | ATA_ID_EIDE_PIO = 67, | 73 | ATA_ID_EIDE_PIO = 67, |
58 | ATA_ID_EIDE_PIO_IORDY = 68, | 74 | ATA_ID_EIDE_PIO_IORDY = 68, |
59 | ATA_ID_UDMA_MODES = 88, | 75 | ATA_ID_QUEUE_DEPTH = 75, |
60 | ATA_ID_MAJOR_VER = 80, | 76 | ATA_ID_MAJOR_VER = 80, |
77 | ATA_ID_COMMAND_SET_1 = 82, | ||
78 | ATA_ID_COMMAND_SET_2 = 83, | ||
79 | ATA_ID_CFSSE = 84, | ||
80 | ATA_ID_CFS_ENABLE_1 = 85, | ||
81 | ATA_ID_CFS_ENABLE_2 = 86, | ||
82 | ATA_ID_CSF_DEFAULT = 87, | ||
83 | ATA_ID_UDMA_MODES = 88, | ||
84 | ATA_ID_HW_CONFIG = 93, | ||
85 | ATA_ID_SPG = 98, | ||
86 | ATA_ID_LBA_CAPACITY_2 = 100, | ||
87 | ATA_ID_LAST_LUN = 126, | ||
88 | ATA_ID_DLF = 128, | ||
89 | ATA_ID_CSFO = 129, | ||
90 | ATA_ID_CFA_POWER = 160, | ||
61 | ATA_ID_PIO4 = (1 << 1), | 91 | ATA_ID_PIO4 = (1 << 1), |
62 | 92 | ||
63 | ATA_ID_SERNO_LEN = 20, | 93 | ATA_ID_SERNO_LEN = 20, |
@@ -438,17 +468,17 @@ static inline int ata_is_data(u8 prot) | |||
438 | /* | 468 | /* |
439 | * id tests | 469 | * id tests |
440 | */ | 470 | */ |
441 | #define ata_id_is_ata(id) (((id)[0] & (1 << 15)) == 0) | 471 | #define ata_id_is_ata(id) (((id)[ATA_ID_CONFIG] & (1 << 15)) == 0) |
442 | #define ata_id_has_lba(id) ((id)[49] & (1 << 9)) | 472 | #define ata_id_has_lba(id) ((id)[ATA_ID_CAPABILITY] & (1 << 9)) |
443 | #define ata_id_has_dma(id) ((id)[49] & (1 << 8)) | 473 | #define ata_id_has_dma(id) ((id)[ATA_ID_CAPABILITY] & (1 << 8)) |
444 | #define ata_id_has_ncq(id) ((id)[76] & (1 << 8)) | 474 | #define ata_id_has_ncq(id) ((id)[76] & (1 << 8)) |
445 | #define ata_id_queue_depth(id) (((id)[75] & 0x1f) + 1) | 475 | #define ata_id_queue_depth(id) (((id)[ATA_ID_QUEUE_DEPTH] & 0x1f) + 1) |
446 | #define ata_id_removeable(id) ((id)[0] & (1 << 7)) | 476 | #define ata_id_removeable(id) ((id)[ATA_ID_CONFIG] & (1 << 7)) |
447 | #define ata_id_has_atapi_AN(id) \ | 477 | #define ata_id_has_atapi_AN(id) \ |
448 | ( (((id)[76] != 0x0000) && ((id)[76] != 0xffff)) && \ | 478 | ( (((id)[76] != 0x0000) && ((id)[76] != 0xffff)) && \ |
449 | ((id)[78] & (1 << 5)) ) | 479 | ((id)[78] & (1 << 5)) ) |
450 | #define ata_id_iordy_disable(id) ((id)[49] & (1 << 10)) | 480 | #define ata_id_iordy_disable(id) ((id)[ATA_ID_CAPABILITY] & (1 << 10)) |
451 | #define ata_id_has_iordy(id) ((id)[49] & (1 << 11)) | 481 | #define ata_id_has_iordy(id) ((id)[ATA_ID_CAPABILITY] & (1 << 11)) |
452 | #define ata_id_u32(id,n) \ | 482 | #define ata_id_u32(id,n) \ |
453 | (((u32) (id)[(n) + 1] << 16) | ((u32) (id)[(n)])) | 483 | (((u32) (id)[(n) + 1] << 16) | ((u32) (id)[(n)])) |
454 | #define ata_id_u64(id,n) \ | 484 | #define ata_id_u64(id,n) \ |
@@ -457,7 +487,7 @@ static inline int ata_is_data(u8 prot) | |||
457 | ((u64) (id)[(n) + 1] << 16) | \ | 487 | ((u64) (id)[(n) + 1] << 16) | \ |
458 | ((u64) (id)[(n) + 0]) ) | 488 | ((u64) (id)[(n) + 0]) ) |
459 | 489 | ||
460 | #define ata_id_cdb_intr(id) (((id)[0] & 0x60) == 0x20) | 490 | #define ata_id_cdb_intr(id) (((id)[ATA_ID_CONFIG] & 0x60) == 0x20) |
461 | 491 | ||
462 | static inline bool ata_id_has_hipm(const u16 *id) | 492 | static inline bool ata_id_has_hipm(const u16 *id) |
463 | { | 493 | { |
@@ -482,75 +512,75 @@ static inline bool ata_id_has_dipm(const u16 *id) | |||
482 | 512 | ||
483 | static inline int ata_id_has_fua(const u16 *id) | 513 | static inline int ata_id_has_fua(const u16 *id) |
484 | { | 514 | { |
485 | if ((id[84] & 0xC000) != 0x4000) | 515 | if ((id[ATA_ID_CFSSE] & 0xC000) != 0x4000) |
486 | return 0; | 516 | return 0; |
487 | return id[84] & (1 << 6); | 517 | return id[ATA_ID_CFSSE] & (1 << 6); |
488 | } | 518 | } |
489 | 519 | ||
490 | static inline int ata_id_has_flush(const u16 *id) | 520 | static inline int ata_id_has_flush(const u16 *id) |
491 | { | 521 | { |
492 | if ((id[83] & 0xC000) != 0x4000) | 522 | if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) |
493 | return 0; | 523 | return 0; |
494 | return id[83] & (1 << 12); | 524 | return id[ATA_ID_COMMAND_SET_2] & (1 << 12); |
495 | } | 525 | } |
496 | 526 | ||
497 | static inline int ata_id_has_flush_ext(const u16 *id) | 527 | static inline int ata_id_has_flush_ext(const u16 *id) |
498 | { | 528 | { |
499 | if ((id[83] & 0xC000) != 0x4000) | 529 | if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) |
500 | return 0; | 530 | return 0; |
501 | return id[83] & (1 << 13); | 531 | return id[ATA_ID_COMMAND_SET_2] & (1 << 13); |
502 | } | 532 | } |
503 | 533 | ||
504 | static inline int ata_id_has_lba48(const u16 *id) | 534 | static inline int ata_id_has_lba48(const u16 *id) |
505 | { | 535 | { |
506 | if ((id[83] & 0xC000) != 0x4000) | 536 | if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) |
507 | return 0; | 537 | return 0; |
508 | if (!ata_id_u64(id, 100)) | 538 | if (!ata_id_u64(id, ATA_ID_LBA_CAPACITY_2)) |
509 | return 0; | 539 | return 0; |
510 | return id[83] & (1 << 10); | 540 | return id[ATA_ID_COMMAND_SET_2] & (1 << 10); |
511 | } | 541 | } |
512 | 542 | ||
513 | static inline int ata_id_hpa_enabled(const u16 *id) | 543 | static inline int ata_id_hpa_enabled(const u16 *id) |
514 | { | 544 | { |
515 | /* Yes children, word 83 valid bits cover word 82 data */ | 545 | /* Yes children, word 83 valid bits cover word 82 data */ |
516 | if ((id[83] & 0xC000) != 0x4000) | 546 | if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) |
517 | return 0; | 547 | return 0; |
518 | /* And 87 covers 85-87 */ | 548 | /* And 87 covers 85-87 */ |
519 | if ((id[87] & 0xC000) != 0x4000) | 549 | if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) |
520 | return 0; | 550 | return 0; |
521 | /* Check command sets enabled as well as supported */ | 551 | /* Check command sets enabled as well as supported */ |
522 | if ((id[85] & ( 1 << 10)) == 0) | 552 | if ((id[ATA_ID_CFS_ENABLE_1] & (1 << 10)) == 0) |
523 | return 0; | 553 | return 0; |
524 | return id[82] & (1 << 10); | 554 | return id[ATA_ID_COMMAND_SET_1] & (1 << 10); |
525 | } | 555 | } |
526 | 556 | ||
527 | static inline int ata_id_has_wcache(const u16 *id) | 557 | static inline int ata_id_has_wcache(const u16 *id) |
528 | { | 558 | { |
529 | /* Yes children, word 83 valid bits cover word 82 data */ | 559 | /* Yes children, word 83 valid bits cover word 82 data */ |
530 | if ((id[83] & 0xC000) != 0x4000) | 560 | if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) |
531 | return 0; | 561 | return 0; |
532 | return id[82] & (1 << 5); | 562 | return id[ATA_ID_COMMAND_SET_1] & (1 << 5); |
533 | } | 563 | } |
534 | 564 | ||
535 | static inline int ata_id_has_pm(const u16 *id) | 565 | static inline int ata_id_has_pm(const u16 *id) |
536 | { | 566 | { |
537 | if ((id[83] & 0xC000) != 0x4000) | 567 | if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) |
538 | return 0; | 568 | return 0; |
539 | return id[82] & (1 << 3); | 569 | return id[ATA_ID_COMMAND_SET_1] & (1 << 3); |
540 | } | 570 | } |
541 | 571 | ||
542 | static inline int ata_id_rahead_enabled(const u16 *id) | 572 | static inline int ata_id_rahead_enabled(const u16 *id) |
543 | { | 573 | { |
544 | if ((id[87] & 0xC000) != 0x4000) | 574 | if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) |
545 | return 0; | 575 | return 0; |
546 | return id[85] & (1 << 6); | 576 | return id[ATA_ID_CFS_ENABLE_1] & (1 << 6); |
547 | } | 577 | } |
548 | 578 | ||
549 | static inline int ata_id_wcache_enabled(const u16 *id) | 579 | static inline int ata_id_wcache_enabled(const u16 *id) |
550 | { | 580 | { |
551 | if ((id[87] & 0xC000) != 0x4000) | 581 | if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) |
552 | return 0; | 582 | return 0; |
553 | return id[85] & (1 << 5); | 583 | return id[ATA_ID_CFS_ENABLE_1] & (1 << 5); |
554 | } | 584 | } |
555 | 585 | ||
556 | /** | 586 | /** |
@@ -581,7 +611,7 @@ static inline unsigned int ata_id_major_version(const u16 *id) | |||
581 | 611 | ||
582 | static inline int ata_id_is_sata(const u16 *id) | 612 | static inline int ata_id_is_sata(const u16 *id) |
583 | { | 613 | { |
584 | return ata_id_major_version(id) >= 5 && id[93] == 0; | 614 | return ata_id_major_version(id) >= 5 && id[ATA_ID_HW_CONFIG] == 0; |
585 | } | 615 | } |
586 | 616 | ||
587 | static inline int ata_id_has_tpm(const u16 *id) | 617 | static inline int ata_id_has_tpm(const u16 *id) |
@@ -599,7 +629,7 @@ static inline int ata_id_has_dword_io(const u16 *id) | |||
599 | /* ATA 8 reuses this flag for "trusted" computing */ | 629 | /* ATA 8 reuses this flag for "trusted" computing */ |
600 | if (ata_id_major_version(id) > 7) | 630 | if (ata_id_major_version(id) > 7) |
601 | return 0; | 631 | return 0; |
602 | if (id[48] & (1 << 0)) | 632 | if (id[ATA_ID_DWORD_IO] & (1 << 0)) |
603 | return 1; | 633 | return 1; |
604 | return 0; | 634 | return 0; |
605 | } | 635 | } |
@@ -608,22 +638,22 @@ static inline int ata_id_current_chs_valid(const u16 *id) | |||
608 | { | 638 | { |
609 | /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command | 639 | /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command |
610 | has not been issued to the device then the values of | 640 | has not been issued to the device then the values of |
611 | id[54] to id[56] are vendor specific. */ | 641 | id[ATA_ID_CUR_CYLS] to id[ATA_ID_CUR_SECTORS] are vendor specific. */ |
612 | return (id[53] & 0x01) && /* Current translation valid */ | 642 | return (id[ATA_ID_FIELD_VALID] & 1) && /* Current translation valid */ |
613 | id[54] && /* cylinders in current translation */ | 643 | id[ATA_ID_CUR_CYLS] && /* cylinders in current translation */ |
614 | id[55] && /* heads in current translation */ | 644 | id[ATA_ID_CUR_HEADS] && /* heads in current translation */ |
615 | id[55] <= 16 && | 645 | id[ATA_ID_CUR_HEADS] <= 16 && |
616 | id[56]; /* sectors in current translation */ | 646 | id[ATA_ID_CUR_SECTORS]; /* sectors in current translation */ |
617 | } | 647 | } |
618 | 648 | ||
619 | static inline int ata_id_is_cfa(const u16 *id) | 649 | static inline int ata_id_is_cfa(const u16 *id) |
620 | { | 650 | { |
621 | u16 v = id[0]; | 651 | if (id[ATA_ID_CONFIG] == 0x848A) /* Standard CF */ |
622 | if (v == 0x848A) /* Standard CF */ | ||
623 | return 1; | 652 | return 1; |
624 | /* Could be CF hiding as standard ATA */ | 653 | /* Could be CF hiding as standard ATA */ |
625 | if (ata_id_major_version(id) >= 3 && id[82] != 0xFFFF && | 654 | if (ata_id_major_version(id) >= 3 && |
626 | (id[82] & ( 1 << 2))) | 655 | id[ATA_ID_COMMAND_SET_1] != 0xFFFF && |
656 | (id[ATA_ID_COMMAND_SET_1] & (1 << 2))) | ||
627 | return 1; | 657 | return 1; |
628 | return 0; | 658 | return 0; |
629 | } | 659 | } |
@@ -632,21 +662,21 @@ static inline int ata_drive_40wire(const u16 *dev_id) | |||
632 | { | 662 | { |
633 | if (ata_id_is_sata(dev_id)) | 663 | if (ata_id_is_sata(dev_id)) |
634 | return 0; /* SATA */ | 664 | return 0; /* SATA */ |
635 | if ((dev_id[93] & 0xE000) == 0x6000) | 665 | if ((dev_id[ATA_ID_HW_CONFIG] & 0xE000) == 0x6000) |
636 | return 0; /* 80 wire */ | 666 | return 0; /* 80 wire */ |
637 | return 1; | 667 | return 1; |
638 | } | 668 | } |
639 | 669 | ||
640 | static inline int ata_drive_40wire_relaxed(const u16 *dev_id) | 670 | static inline int ata_drive_40wire_relaxed(const u16 *dev_id) |
641 | { | 671 | { |
642 | if ((dev_id[93] & 0x2000) == 0x2000) | 672 | if ((dev_id[ATA_ID_HW_CONFIG] & 0x2000) == 0x2000) |
643 | return 0; /* 80 wire */ | 673 | return 0; /* 80 wire */ |
644 | return 1; | 674 | return 1; |
645 | } | 675 | } |
646 | 676 | ||
647 | static inline int atapi_cdb_len(const u16 *dev_id) | 677 | static inline int atapi_cdb_len(const u16 *dev_id) |
648 | { | 678 | { |
649 | u16 tmp = dev_id[0] & 0x3; | 679 | u16 tmp = dev_id[ATA_ID_CONFIG] & 0x3; |
650 | switch (tmp) { | 680 | switch (tmp) { |
651 | case 0: return 12; | 681 | case 0: return 12; |
652 | case 1: return 16; | 682 | case 1: return 16; |
@@ -656,7 +686,7 @@ static inline int atapi_cdb_len(const u16 *dev_id) | |||
656 | 686 | ||
657 | static inline int atapi_command_packet_set(const u16 *dev_id) | 687 | static inline int atapi_command_packet_set(const u16 *dev_id) |
658 | { | 688 | { |
659 | return (dev_id[0] >> 8) & 0x1f; | 689 | return (dev_id[ATA_ID_CONFIG] >> 8) & 0x1f; |
660 | } | 690 | } |
661 | 691 | ||
662 | static inline int atapi_id_dmadir(const u16 *dev_id) | 692 | static inline int atapi_id_dmadir(const u16 *dev_id) |