Elliott Hughes | 180edef | 2023-11-02 00:08:05 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is auto-generated. Modifications will be lost. |
| 3 | * |
| 4 | * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/ |
| 5 | * for more information. |
| 6 | */ |
Christopher Ferris | 86a4837 | 2019-01-10 14:14:59 -0800 | [diff] [blame] | 7 | #ifndef SCSI_BSG_UFS_H |
| 8 | #define SCSI_BSG_UFS_H |
Christopher Ferris | 67d1e5e | 2023-10-31 13:36:37 -0700 | [diff] [blame] | 9 | #include <asm/byteorder.h> |
Christopher Ferris | 86a4837 | 2019-01-10 14:14:59 -0800 | [diff] [blame] | 10 | #include <linux/types.h> |
| 11 | #define UFS_CDB_SIZE 16 |
Christopher Ferris | 86a4837 | 2019-01-10 14:14:59 -0800 | [diff] [blame] | 12 | #define UIC_CMD_SIZE (sizeof(__u32) * 4) |
Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame] | 13 | enum ufs_bsg_msg_code { |
| 14 | UPIU_TRANSACTION_UIC_CMD = 0x1F, |
| 15 | UPIU_TRANSACTION_ARPMB_CMD, |
| 16 | }; |
| 17 | enum ufs_rpmb_op_type { |
| 18 | UFS_RPMB_WRITE_KEY = 0x01, |
| 19 | UFS_RPMB_READ_CNT = 0x02, |
| 20 | UFS_RPMB_WRITE = 0x03, |
| 21 | UFS_RPMB_READ = 0x04, |
| 22 | UFS_RPMB_READ_RESP = 0x05, |
| 23 | UFS_RPMB_SEC_CONF_WRITE = 0x06, |
| 24 | UFS_RPMB_SEC_CONF_READ = 0x07, |
| 25 | UFS_RPMB_PURGE_ENABLE = 0x08, |
| 26 | UFS_RPMB_PURGE_STATUS_READ = 0x09, |
| 27 | }; |
Christopher Ferris | 86a4837 | 2019-01-10 14:14:59 -0800 | [diff] [blame] | 28 | struct utp_upiu_header { |
Christopher Ferris | 67d1e5e | 2023-10-31 13:36:37 -0700 | [diff] [blame] | 29 | union { |
| 30 | struct { |
| 31 | __be32 dword_0; |
| 32 | __be32 dword_1; |
| 33 | __be32 dword_2; |
| 34 | }; |
| 35 | struct { |
| 36 | __u8 transaction_code; |
| 37 | __u8 flags; |
| 38 | __u8 lun; |
| 39 | __u8 task_tag; |
| 40 | #ifdef __BIG_ENDIAN |
| 41 | __u8 iid : 4; |
| 42 | __u8 command_set_type : 4; |
| 43 | #elif defined(__LITTLE_ENDIAN) |
| 44 | __u8 command_set_type : 4; |
| 45 | __u8 iid : 4; |
| 46 | #else |
| 47 | #error |
| 48 | #endif |
| 49 | union { |
| 50 | __u8 tm_function; |
| 51 | __u8 query_function; |
| 52 | } __attribute__((packed)); |
| 53 | __u8 response; |
| 54 | __u8 status; |
| 55 | __u8 ehs_length; |
| 56 | __u8 device_information; |
| 57 | __be16 data_segment_length; |
| 58 | }; |
| 59 | }; |
Christopher Ferris | 86a4837 | 2019-01-10 14:14:59 -0800 | [diff] [blame] | 60 | }; |
| 61 | struct utp_upiu_query { |
| 62 | __u8 opcode; |
| 63 | __u8 idn; |
| 64 | __u8 index; |
| 65 | __u8 selector; |
| 66 | __be16 reserved_osf; |
| 67 | __be16 length; |
| 68 | __be32 value; |
| 69 | __be32 reserved[2]; |
| 70 | }; |
Christopher Ferris | 8666d04 | 2023-09-06 14:55:31 -0700 | [diff] [blame] | 71 | struct utp_upiu_query_v4_0 { |
| 72 | __u8 opcode; |
| 73 | __u8 idn; |
| 74 | __u8 index; |
| 75 | __u8 selector; |
| 76 | __u8 osf3; |
| 77 | __u8 osf4; |
| 78 | __be16 osf5; |
| 79 | __be32 osf6; |
| 80 | __be32 osf7; |
| 81 | __be32 reserved; |
| 82 | }; |
Christopher Ferris | 86a4837 | 2019-01-10 14:14:59 -0800 | [diff] [blame] | 83 | struct utp_upiu_cmd { |
| 84 | __be32 exp_data_transfer_len; |
| 85 | __u8 cdb[UFS_CDB_SIZE]; |
| 86 | }; |
| 87 | struct utp_upiu_req { |
| 88 | struct utp_upiu_header header; |
| 89 | union { |
| 90 | struct utp_upiu_cmd sc; |
| 91 | struct utp_upiu_query qr; |
Christopher Ferris | 86a4837 | 2019-01-10 14:14:59 -0800 | [diff] [blame] | 92 | struct utp_upiu_query uc; |
| 93 | }; |
| 94 | }; |
Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame] | 95 | struct ufs_arpmb_meta { |
| 96 | __be16 req_resp_type; |
| 97 | __u8 nonce[16]; |
| 98 | __be32 write_counter; |
| 99 | __be16 addr_lun; |
| 100 | __be16 block_count; |
| 101 | __be16 result; |
| 102 | } __attribute__((__packed__)); |
| 103 | struct ufs_ehs { |
| 104 | __u8 length; |
| 105 | __u8 ehs_type; |
| 106 | __be16 ehssub_type; |
| 107 | struct ufs_arpmb_meta meta; |
| 108 | __u8 mac_key[32]; |
| 109 | } __attribute__((__packed__)); |
Christopher Ferris | 86a4837 | 2019-01-10 14:14:59 -0800 | [diff] [blame] | 110 | struct ufs_bsg_request { |
| 111 | __u32 msgcode; |
| 112 | struct utp_upiu_req upiu_req; |
| 113 | }; |
| 114 | struct ufs_bsg_reply { |
Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame] | 115 | int result; |
Christopher Ferris | 86a4837 | 2019-01-10 14:14:59 -0800 | [diff] [blame] | 116 | __u32 reply_payload_rcv_len; |
| 117 | struct utp_upiu_req upiu_rsp; |
| 118 | }; |
Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame] | 119 | struct ufs_rpmb_request { |
| 120 | struct ufs_bsg_request bsg_request; |
| 121 | struct ufs_ehs ehs_req; |
| 122 | }; |
| 123 | struct ufs_rpmb_reply { |
| 124 | struct ufs_bsg_reply bsg_reply; |
| 125 | struct ufs_ehs ehs_rsp; |
| 126 | }; |
Christopher Ferris | 86a4837 | 2019-01-10 14:14:59 -0800 | [diff] [blame] | 127 | #endif |