Sridhar Parasuram | 782645e | 2015-02-06 16:47:00 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
|
Deepa Dinamani | ab9c2b9 | 2013-09-12 11:30:58 -0700 | [diff] [blame] | 2 | *
|
| 3 | * Redistribution and use in source and binary forms, with or without
|
| 4 | * modification, are permitted provided that the following conditions are
|
| 5 | * met:
|
| 6 | * * Redistributions of source code must retain the above copyright
|
| 7 | * notice, this list of conditions and the following disclaimer.
|
| 8 | * * Redistributions in binary form must reproduce the above
|
| 9 | * copyright notice, this list of conditions and the following
|
| 10 | * disclaimer in the documentation and/or other materials provided
|
| 11 | * with the distribution.
|
| 12 | * * Neither the name of The Linux Foundation nor the names of its
|
| 13 | * contributors may be used to endorse or promote products derived
|
| 14 | * from this software without specific prior written permission.
|
| 15 | *
|
| 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
| 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
| 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
| 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
| 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
| 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
| 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
| 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
| 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
| 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 27 | */
|
| 28 |
|
| 29 | #ifndef _UPIU_H
|
| 30 | #define _UPIU_H
|
| 31 |
|
| 32 | struct upiu_basic_hdr
|
| 33 | {
|
| 34 | uint8_t trans_type;
|
| 35 | uint8_t flags;
|
| 36 | uint8_t lun;
|
| 37 | uint8_t task_tag;
|
| 38 | uint8_t cmd_set_type;
|
| 39 | uint8_t query_task_mgmt_func;
|
| 40 | uint8_t response;
|
| 41 | uint8_t status;
|
| 42 | uint8_t total_ehs_len;
|
| 43 | uint8_t device_info;
|
| 44 | uint16_t data_seg_len;
|
| 45 | } __PACKED;
|
| 46 |
|
Sridhar Parasuram | 782645e | 2015-02-06 16:47:00 -0800 | [diff] [blame] | 47 |
|
| 48 | struct upiu_basic_resp_hdr
|
| 49 | {
|
| 50 | uint8_t trans_type;
|
| 51 | uint8_t flags;
|
| 52 | uint8_t lun;
|
| 53 | uint8_t task_tag;
|
| 54 | uint8_t cmd_set_type;
|
| 55 | uint8_t query_task_mgmt_func;
|
| 56 | uint8_t response;
|
| 57 | uint8_t status;
|
| 58 | uint8_t total_ehs_len;
|
| 59 | uint8_t device_info;
|
| 60 | uint16_t data_seg_len;
|
| 61 | uint32_t residual_transfer_count;
|
| 62 | uint32_t reserved[4];
|
| 63 | uint16_t sense_length;
|
| 64 | uint16_t sense_response_code;
|
| 65 | uint32_t sense_data[4];
|
| 66 | } __PACKED;
|
| 67 |
|
Deepa Dinamani | ab9c2b9 | 2013-09-12 11:30:58 -0700 | [diff] [blame] | 68 | struct upiu_trans_mgmt_query_hdr
|
| 69 | {
|
| 70 | struct upiu_basic_hdr basic_hdr;
|
| 71 | uint8_t opcode;
|
| 72 | uint8_t idn;
|
| 73 | uint8_t index;
|
| 74 | uint8_t selector;
|
| 75 | uint8_t resv_0[2];
|
| 76 | uint16_t resp_len;
|
| 77 | uint8_t resv_1[3];
|
| 78 | uint8_t flag_value;
|
| 79 | uint8_t resv_2[4];
|
| 80 | }__PACKED;
|
| 81 |
|
| 82 | struct upiu_cmd_hdr
|
| 83 | {
|
| 84 | struct upiu_basic_hdr basic_hdr;
|
| 85 | uint32_t data_expected_len; // Requested length
|
| 86 | uint8_t param[16]; // Payload, operation specefic field
|
| 87 | }__PACKED;
|
| 88 |
|
| 89 | struct upiu_cmd_resp_hdr
|
| 90 | {
|
| 91 | struct upiu_basic_hdr basic_hdr;
|
| 92 | uint32_t residual_trans_count;
|
| 93 | uint8_t resv_0[16];
|
| 94 | }__PACKED;
|
| 95 |
|
| 96 | struct upiu_gen_hdr
|
| 97 | {
|
| 98 | struct upiu_basic_hdr basic_hdr;
|
| 99 | uint8_t trans_specific_fields[20];
|
| 100 | }__PACKED;
|
| 101 |
|
| 102 | /* UPIU transaction codes. */
|
| 103 | enum upiu_trans_type
|
| 104 | {
|
| 105 | UPIU_TYPE_NOP_OUT = 0x00,
|
| 106 | UPIU_TYPE_COMMAND = 0x01,
|
| 107 | UPIU_TYPE_TASK_MGMT = 0x04,
|
| 108 | UPIU_TYPE_QUERY_REQ = 0x16,
|
| 109 | UPIU_TYPE_NOP_IN = 0x20,
|
| 110 | UPIU_TYPE_RESPONSE = 0x21,
|
| 111 | UPIU_TYPE_TASK_MAN_RESP = 0x24,
|
| 112 | UPIU_TYPE_QUERY_RESP = 0x36,
|
| 113 | UPIU_TYPE_REJECT = 0x3f,
|
| 114 | };
|
| 115 |
|
| 116 | /* UPIU respones */
|
| 117 | enum upiu_response
|
| 118 | {
|
| 119 | UPIU_RESPONSE_TARGET_SUCCESS = 0x00,
|
| 120 | UPIU_RESPONSE_TARGET_FAILURE = 0x01,
|
| 121 | };
|
| 122 |
|
| 123 | enum upiu_cmd_set_type
|
| 124 | {
|
| 125 | UPIU_SCSI_CMD_SET = 0,
|
| 126 | UPIU_UFS_SPECIFIC_CMD_SET = 1,
|
| 127 | };
|
| 128 |
|
| 129 | enum upiu_query_opcode_type
|
| 130 | {
|
| 131 | UPIU_QUERY_OP_NOP = 0x0,
|
| 132 | UPIU_QUERY_OP_READ_DESCRIPTOR = 0x1,
|
| 133 | UPIU_QUERY_OP_WRITE_DESCRIPTOR = 0x2,
|
| 134 | UPIU_QUERY_OP_READ_ATTRIBUTE = 0x3,
|
| 135 | UPIU_QUERY_OP_WRITE_ATTRIBUTE = 0x4,
|
| 136 | UPIU_QUERY_OP_READ_FLAG = 0x5,
|
| 137 | UPIU_QUERY_OP_SET_FLAG = 0x6,
|
| 138 | UPIU_QUERY_OP_CLEAR_FLAG = 0x7,
|
| 139 | UPIU_QUERY_OP_TOGGLE_FLAG = 0x8,
|
| 140 | };
|
| 141 |
|
| 142 | enum upiu_cmd_type
|
| 143 | {
|
| 144 | UTRD_SCSCI_CMD = 0,
|
| 145 | UTRD_NATIVE_UFS_CMD = 1,
|
| 146 | UTRD_DEV_MGMT_FUNC = 2,
|
| 147 | };
|
| 148 |
|
| 149 | enum upiu_dd_type
|
| 150 | {
|
| 151 | UTRD_NO_DATA_TRANSFER = 0,
|
| 152 | UTRD_SYSTEM_TO_TARGET = 1,
|
| 153 | UTRD_TARGET_TO_SYSTEM = 2,
|
| 154 | };
|
| 155 |
|
| 156 | struct upiu_req_build_type
|
| 157 | {
|
| 158 | enum upiu_trans_type trans_type;
|
| 159 | uint8_t flags;
|
| 160 | uint8_t lun;
|
| 161 | enum upiu_cmd_set_type cmd_set_type;
|
| 162 | uint8_t query_mgmt_func;
|
| 163 | uint8_t ehs_len;
|
| 164 | uint16_t data_seg_len;
|
| 165 | addr_t data_buffer_addr;
|
| 166 | uint32_t data_buffer_len;
|
| 167 | addr_t cdb;
|
| 168 | uint64_t expected_data_len;
|
| 169 | enum upiu_query_opcode_type opcode;
|
| 170 | uint8_t idn;
|
| 171 | uint8_t index;
|
| 172 | uint8_t selector;
|
Sridhar Parasuram | 782645e | 2015-02-06 16:47:00 -0800 | [diff] [blame] | 173 | struct upiu_basic_resp_hdr *resp_ptr;
|
Deepa Dinamani | ab9c2b9 | 2013-09-12 11:30:58 -0700 | [diff] [blame] | 174 | uint64_t resp_len;
|
| 175 | uint16_t resp_data_len;
|
| 176 | addr_t resp_data_ptr;
|
| 177 |
|
| 178 | /* UTRD properties. */
|
| 179 | enum upiu_cmd_type cmd_type;
|
| 180 | enum upiu_dd_type dd;
|
| 181 | uint64_t timeout_msecs;
|
| 182 | };
|
| 183 |
|
| 184 |
|
| 185 | #endif
|