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