blob: 96ee19471debc0a87b05c5380bd71da3a00b1ae7 [file] [log] [blame]
Christopher Ferris86a48372019-01-10 14:14:59 -08001/****************************************************************************
2 ****************************************************************************
3 ***
4 *** This header was automatically generated from a Linux kernel header
5 *** of the same name, to make information necessary for userspace to
6 *** call into the kernel available to libc. It contains only constants,
7 *** structures, and macros generated from the original header, and thus,
8 *** contains no copyrightable information.
9 ***
10 *** To edit the content of this header, modify the corresponding
11 *** source file (e.g. under external/kernel-headers/original/) then
12 *** run bionic/libc/kernel/tools/update_all.py
13 ***
14 *** Any manual change here will be lost the next time this script will
15 *** be run. You've been warned!
16 ***
17 ****************************************************************************
18 ****************************************************************************/
19#ifndef SCSI_BSG_UFS_H
20#define SCSI_BSG_UFS_H
Christopher Ferris67d1e5e2023-10-31 13:36:37 -070021#include <asm/byteorder.h>
Christopher Ferris86a48372019-01-10 14:14:59 -080022#include <linux/types.h>
23#define UFS_CDB_SIZE 16
Christopher Ferris86a48372019-01-10 14:14:59 -080024#define UIC_CMD_SIZE (sizeof(__u32) * 4)
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +000025enum ufs_bsg_msg_code {
26 UPIU_TRANSACTION_UIC_CMD = 0x1F,
27 UPIU_TRANSACTION_ARPMB_CMD,
28};
29enum ufs_rpmb_op_type {
30 UFS_RPMB_WRITE_KEY = 0x01,
31 UFS_RPMB_READ_CNT = 0x02,
32 UFS_RPMB_WRITE = 0x03,
33 UFS_RPMB_READ = 0x04,
34 UFS_RPMB_READ_RESP = 0x05,
35 UFS_RPMB_SEC_CONF_WRITE = 0x06,
36 UFS_RPMB_SEC_CONF_READ = 0x07,
37 UFS_RPMB_PURGE_ENABLE = 0x08,
38 UFS_RPMB_PURGE_STATUS_READ = 0x09,
39};
Christopher Ferris86a48372019-01-10 14:14:59 -080040struct utp_upiu_header {
Christopher Ferris67d1e5e2023-10-31 13:36:37 -070041 union {
42 struct {
43 __be32 dword_0;
44 __be32 dword_1;
45 __be32 dword_2;
46 };
47 struct {
48 __u8 transaction_code;
49 __u8 flags;
50 __u8 lun;
51 __u8 task_tag;
52#ifdef __BIG_ENDIAN
53 __u8 iid : 4;
54 __u8 command_set_type : 4;
55#elif defined(__LITTLE_ENDIAN)
56 __u8 command_set_type : 4;
57 __u8 iid : 4;
58#else
59#error
60#endif
61 union {
62 __u8 tm_function;
63 __u8 query_function;
64 } __attribute__((packed));
65 __u8 response;
66 __u8 status;
67 __u8 ehs_length;
68 __u8 device_information;
69 __be16 data_segment_length;
70 };
71 };
Christopher Ferris86a48372019-01-10 14:14:59 -080072};
73struct utp_upiu_query {
74 __u8 opcode;
75 __u8 idn;
76 __u8 index;
77 __u8 selector;
78 __be16 reserved_osf;
79 __be16 length;
80 __be32 value;
81 __be32 reserved[2];
82};
Christopher Ferris8666d042023-09-06 14:55:31 -070083struct utp_upiu_query_v4_0 {
84 __u8 opcode;
85 __u8 idn;
86 __u8 index;
87 __u8 selector;
88 __u8 osf3;
89 __u8 osf4;
90 __be16 osf5;
91 __be32 osf6;
92 __be32 osf7;
93 __be32 reserved;
94};
Christopher Ferris86a48372019-01-10 14:14:59 -080095struct utp_upiu_cmd {
96 __be32 exp_data_transfer_len;
97 __u8 cdb[UFS_CDB_SIZE];
98};
99struct utp_upiu_req {
100 struct utp_upiu_header header;
101 union {
102 struct utp_upiu_cmd sc;
103 struct utp_upiu_query qr;
Christopher Ferris86a48372019-01-10 14:14:59 -0800104 struct utp_upiu_query uc;
105 };
106};
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +0000107struct ufs_arpmb_meta {
108 __be16 req_resp_type;
109 __u8 nonce[16];
110 __be32 write_counter;
111 __be16 addr_lun;
112 __be16 block_count;
113 __be16 result;
114} __attribute__((__packed__));
115struct ufs_ehs {
116 __u8 length;
117 __u8 ehs_type;
118 __be16 ehssub_type;
119 struct ufs_arpmb_meta meta;
120 __u8 mac_key[32];
121} __attribute__((__packed__));
Christopher Ferris86a48372019-01-10 14:14:59 -0800122struct ufs_bsg_request {
123 __u32 msgcode;
124 struct utp_upiu_req upiu_req;
125};
126struct ufs_bsg_reply {
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +0000127 int result;
Christopher Ferris86a48372019-01-10 14:14:59 -0800128 __u32 reply_payload_rcv_len;
129 struct utp_upiu_req upiu_rsp;
130};
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +0000131struct ufs_rpmb_request {
132 struct ufs_bsg_request bsg_request;
133 struct ufs_ehs ehs_req;
134};
135struct ufs_rpmb_reply {
136 struct ufs_bsg_reply bsg_reply;
137 struct ufs_ehs ehs_rsp;
138};
Christopher Ferris86a48372019-01-10 14:14:59 -0800139#endif