Deepa Dinamani | ab9c2b9 | 2013-09-12 11:30:58 -0700 | [diff] [blame^] | 1 | /* Copyright (c) 2013, The Linux Foundation. All rights reserved.
|
| 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 |
|
| 47 | struct upiu_trans_mgmt_query_hdr
|
| 48 | {
|
| 49 | struct upiu_basic_hdr basic_hdr;
|
| 50 | uint8_t opcode;
|
| 51 | uint8_t idn;
|
| 52 | uint8_t index;
|
| 53 | uint8_t selector;
|
| 54 | uint8_t resv_0[2];
|
| 55 | uint16_t resp_len;
|
| 56 | uint8_t resv_1[3];
|
| 57 | uint8_t flag_value;
|
| 58 | uint8_t resv_2[4];
|
| 59 | }__PACKED;
|
| 60 |
|
| 61 | struct upiu_cmd_hdr
|
| 62 | {
|
| 63 | struct upiu_basic_hdr basic_hdr;
|
| 64 | uint32_t data_expected_len; // Requested length
|
| 65 | uint8_t param[16]; // Payload, operation specefic field
|
| 66 | }__PACKED;
|
| 67 |
|
| 68 | struct upiu_cmd_resp_hdr
|
| 69 | {
|
| 70 | struct upiu_basic_hdr basic_hdr;
|
| 71 | uint32_t residual_trans_count;
|
| 72 | uint8_t resv_0[16];
|
| 73 | }__PACKED;
|
| 74 |
|
| 75 | struct upiu_gen_hdr
|
| 76 | {
|
| 77 | struct upiu_basic_hdr basic_hdr;
|
| 78 | uint8_t trans_specific_fields[20];
|
| 79 | }__PACKED;
|
| 80 |
|
| 81 | /* UPIU transaction codes. */
|
| 82 | enum upiu_trans_type
|
| 83 | {
|
| 84 | UPIU_TYPE_NOP_OUT = 0x00,
|
| 85 | UPIU_TYPE_COMMAND = 0x01,
|
| 86 | UPIU_TYPE_TASK_MGMT = 0x04,
|
| 87 | UPIU_TYPE_QUERY_REQ = 0x16,
|
| 88 | UPIU_TYPE_NOP_IN = 0x20,
|
| 89 | UPIU_TYPE_RESPONSE = 0x21,
|
| 90 | UPIU_TYPE_TASK_MAN_RESP = 0x24,
|
| 91 | UPIU_TYPE_QUERY_RESP = 0x36,
|
| 92 | UPIU_TYPE_REJECT = 0x3f,
|
| 93 | };
|
| 94 |
|
| 95 | /* UPIU respones */
|
| 96 | enum upiu_response
|
| 97 | {
|
| 98 | UPIU_RESPONSE_TARGET_SUCCESS = 0x00,
|
| 99 | UPIU_RESPONSE_TARGET_FAILURE = 0x01,
|
| 100 | };
|
| 101 |
|
| 102 | enum upiu_cmd_set_type
|
| 103 | {
|
| 104 | UPIU_SCSI_CMD_SET = 0,
|
| 105 | UPIU_UFS_SPECIFIC_CMD_SET = 1,
|
| 106 | };
|
| 107 |
|
| 108 | enum upiu_query_opcode_type
|
| 109 | {
|
| 110 | UPIU_QUERY_OP_NOP = 0x0,
|
| 111 | UPIU_QUERY_OP_READ_DESCRIPTOR = 0x1,
|
| 112 | UPIU_QUERY_OP_WRITE_DESCRIPTOR = 0x2,
|
| 113 | UPIU_QUERY_OP_READ_ATTRIBUTE = 0x3,
|
| 114 | UPIU_QUERY_OP_WRITE_ATTRIBUTE = 0x4,
|
| 115 | UPIU_QUERY_OP_READ_FLAG = 0x5,
|
| 116 | UPIU_QUERY_OP_SET_FLAG = 0x6,
|
| 117 | UPIU_QUERY_OP_CLEAR_FLAG = 0x7,
|
| 118 | UPIU_QUERY_OP_TOGGLE_FLAG = 0x8,
|
| 119 | };
|
| 120 |
|
| 121 | enum upiu_cmd_type
|
| 122 | {
|
| 123 | UTRD_SCSCI_CMD = 0,
|
| 124 | UTRD_NATIVE_UFS_CMD = 1,
|
| 125 | UTRD_DEV_MGMT_FUNC = 2,
|
| 126 | };
|
| 127 |
|
| 128 | enum upiu_dd_type
|
| 129 | {
|
| 130 | UTRD_NO_DATA_TRANSFER = 0,
|
| 131 | UTRD_SYSTEM_TO_TARGET = 1,
|
| 132 | UTRD_TARGET_TO_SYSTEM = 2,
|
| 133 | };
|
| 134 |
|
| 135 | struct upiu_req_build_type
|
| 136 | {
|
| 137 | enum upiu_trans_type trans_type;
|
| 138 | uint8_t flags;
|
| 139 | uint8_t lun;
|
| 140 | enum upiu_cmd_set_type cmd_set_type;
|
| 141 | uint8_t query_mgmt_func;
|
| 142 | uint8_t ehs_len;
|
| 143 | uint16_t data_seg_len;
|
| 144 | addr_t data_buffer_addr;
|
| 145 | uint32_t data_buffer_len;
|
| 146 | addr_t cdb;
|
| 147 | uint64_t expected_data_len;
|
| 148 | enum upiu_query_opcode_type opcode;
|
| 149 | uint8_t idn;
|
| 150 | uint8_t index;
|
| 151 | uint8_t selector;
|
| 152 | struct upiu_basic_hdr *resp_ptr;
|
| 153 | uint64_t resp_len;
|
| 154 | uint16_t resp_data_len;
|
| 155 | addr_t resp_data_ptr;
|
| 156 |
|
| 157 | /* UTRD properties. */
|
| 158 | enum upiu_cmd_type cmd_type;
|
| 159 | enum upiu_dd_type dd;
|
| 160 | uint64_t timeout_msecs;
|
| 161 | };
|
| 162 |
|
| 163 |
|
| 164 | #endif
|