blob: 5a4b1b29ee5402aa655249b99cb507a5e5b1403e [file] [log] [blame]
Elliott Hughes180edef2023-11-02 00:08:05 +00001/*
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 Ferris86a48372019-01-10 14:14:59 -08007#ifndef SCSI_BSG_UFS_H
8#define SCSI_BSG_UFS_H
Christopher Ferris67d1e5e2023-10-31 13:36:37 -07009#include <asm/byteorder.h>
Christopher Ferris86a48372019-01-10 14:14:59 -080010#include <linux/types.h>
11#define UFS_CDB_SIZE 16
Christopher Ferris86a48372019-01-10 14:14:59 -080012#define UIC_CMD_SIZE (sizeof(__u32) * 4)
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +000013enum ufs_bsg_msg_code {
14 UPIU_TRANSACTION_UIC_CMD = 0x1F,
15 UPIU_TRANSACTION_ARPMB_CMD,
16};
17enum 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 Ferris86a48372019-01-10 14:14:59 -080028struct utp_upiu_header {
Christopher Ferris67d1e5e2023-10-31 13:36:37 -070029 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 Ferris86a48372019-01-10 14:14:59 -080060};
61struct 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 Ferris8666d042023-09-06 14:55:31 -070071struct 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 Ferris86a48372019-01-10 14:14:59 -080083struct utp_upiu_cmd {
84 __be32 exp_data_transfer_len;
85 __u8 cdb[UFS_CDB_SIZE];
86};
87struct utp_upiu_req {
88 struct utp_upiu_header header;
89 union {
90 struct utp_upiu_cmd sc;
91 struct utp_upiu_query qr;
Christopher Ferris86a48372019-01-10 14:14:59 -080092 struct utp_upiu_query uc;
93 };
94};
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +000095struct 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__));
103struct 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 Ferris86a48372019-01-10 14:14:59 -0800110struct ufs_bsg_request {
111 __u32 msgcode;
112 struct utp_upiu_req upiu_req;
113};
114struct ufs_bsg_reply {
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +0000115 int result;
Christopher Ferris86a48372019-01-10 14:14:59 -0800116 __u32 reply_payload_rcv_len;
117 struct utp_upiu_req upiu_rsp;
118};
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +0000119struct ufs_rpmb_request {
120 struct ufs_bsg_request bsg_request;
121 struct ufs_ehs ehs_req;
122};
123struct ufs_rpmb_reply {
124 struct ufs_bsg_reply bsg_reply;
125 struct ufs_ehs ehs_rsp;
126};
Christopher Ferris86a48372019-01-10 14:14:59 -0800127#endif