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>

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