ufs.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /*
  2. * Universal Flash Storage Host controller driver
  3. *
  4. * This code is based on drivers/scsi/ufs/ufs.h
  5. * Copyright (C) 2011-2012 Samsung India Software Operations
  6. *
  7. * Santosh Yaraganavi <santosh.sy@samsung.com>
  8. * Vinayak Holikatti <h.vinayak@samsung.com>
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License
  12. * as published by the Free Software Foundation; either version 2
  13. * of the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * NO WARRANTY
  21. * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
  22. * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
  23. * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
  24. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
  25. * solely responsible for determining the appropriateness of using and
  26. * distributing the Program and assumes all risks associated with its
  27. * exercise of rights under this Agreement, including but not limited to
  28. * the risks and costs of program errors, damage to or loss of data,
  29. * programs or equipment, and unavailability or interruption of operations.
  30. * DISCLAIMER OF LIABILITY
  31. * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
  32. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  33. * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
  34. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  35. * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  36. * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
  37. * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
  38. * You should have received a copy of the GNU General Public License
  39. * along with this program; if not, write to the Free Software
  40. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
  41. * USA.
  42. */
  43. #ifndef _UFS_H
  44. #define _UFS_H
  45. #define MAX_CDB_SIZE 16
  46. #define UPIU_HEADER_DWORD(byte3, byte2, byte1, byte0)\
  47. ((byte3 << 24) | (byte2 << 16) |\
  48. (byte1 << 8) | (byte0))
  49. /*
  50. * UFS Protocol Information Unit related definitions
  51. */
  52. /* Task management functions */
  53. enum {
  54. UFS_ABORT_TASK = 0x01,
  55. UFS_ABORT_TASK_SET = 0x02,
  56. UFS_CLEAR_TASK_SET = 0x04,
  57. UFS_LOGICAL_RESET = 0x08,
  58. UFS_QUERY_TASK = 0x80,
  59. UFS_QUERY_TASK_SET = 0x81,
  60. };
  61. /* UTP UPIU Transaction Codes Initiator to Target */
  62. enum {
  63. UPIU_TRANSACTION_NOP_OUT = 0x00,
  64. UPIU_TRANSACTION_COMMAND = 0x01,
  65. UPIU_TRANSACTION_DATA_OUT = 0x02,
  66. UPIU_TRANSACTION_TASK_REQ = 0x04,
  67. UPIU_TRANSACTION_QUERY_REQ = 0x26,
  68. };
  69. /* UTP UPIU Transaction Codes Target to Initiator */
  70. enum {
  71. UPIU_TRANSACTION_NOP_IN = 0x20,
  72. UPIU_TRANSACTION_RESPONSE = 0x21,
  73. UPIU_TRANSACTION_DATA_IN = 0x22,
  74. UPIU_TRANSACTION_TASK_RSP = 0x24,
  75. UPIU_TRANSACTION_READY_XFER = 0x31,
  76. UPIU_TRANSACTION_QUERY_RSP = 0x36,
  77. };
  78. /* UPIU Read/Write flags */
  79. enum {
  80. UPIU_CMD_FLAGS_NONE = 0x00,
  81. UPIU_CMD_FLAGS_WRITE = 0x20,
  82. UPIU_CMD_FLAGS_READ = 0x40,
  83. };
  84. /* UPIU Task Attributes */
  85. enum {
  86. UPIU_TASK_ATTR_SIMPLE = 0x00,
  87. UPIU_TASK_ATTR_ORDERED = 0x01,
  88. UPIU_TASK_ATTR_HEADQ = 0x02,
  89. UPIU_TASK_ATTR_ACA = 0x03,
  90. };
  91. /* UTP QUERY Transaction Specific Fields OpCode */
  92. enum {
  93. UPIU_QUERY_OPCODE_NOP = 0x0,
  94. UPIU_QUERY_OPCODE_READ_DESC = 0x1,
  95. UPIU_QUERY_OPCODE_WRITE_DESC = 0x2,
  96. UPIU_QUERY_OPCODE_READ_ATTR = 0x3,
  97. UPIU_QUERY_OPCODE_WRITE_ATTR = 0x4,
  98. UPIU_QUERY_OPCODE_READ_FLAG = 0x5,
  99. UPIU_QUERY_OPCODE_SET_FLAG = 0x6,
  100. UPIU_QUERY_OPCODE_CLEAR_FLAG = 0x7,
  101. UPIU_QUERY_OPCODE_TOGGLE_FLAG = 0x8,
  102. };
  103. /* UTP Transfer Request Command Type (CT) */
  104. enum {
  105. UPIU_COMMAND_SET_TYPE_SCSI = 0x0,
  106. UPIU_COMMAND_SET_TYPE_UFS = 0x1,
  107. UPIU_COMMAND_SET_TYPE_QUERY = 0x2,
  108. };
  109. enum {
  110. MASK_SCSI_STATUS = 0xFF,
  111. MASK_TASK_RESPONSE = 0xFF00,
  112. MASK_RSP_UPIU_RESULT = 0xFFFF,
  113. };
  114. /* Task management service response */
  115. enum {
  116. UPIU_TASK_MANAGEMENT_FUNC_COMPL = 0x00,
  117. UPIU_TASK_MANAGEMENT_FUNC_NOT_SUPPORTED = 0x04,
  118. UPIU_TASK_MANAGEMENT_FUNC_SUCCEEDED = 0x08,
  119. UPIU_TASK_MANAGEMENT_FUNC_FAILED = 0x05,
  120. UPIU_INCORRECT_LOGICAL_UNIT_NO = 0x09,
  121. };
  122. /**
  123. * struct utp_upiu_header - UPIU header structure
  124. * @dword_0: UPIU header DW-0
  125. * @dword_1: UPIU header DW-1
  126. * @dword_2: UPIU header DW-2
  127. */
  128. struct utp_upiu_header {
  129. u32 dword_0;
  130. u32 dword_1;
  131. u32 dword_2;
  132. };
  133. /**
  134. * struct utp_upiu_cmd - Command UPIU structure
  135. * @header: UPIU header structure DW-0 to DW-2
  136. * @data_transfer_len: Data Transfer Length DW-3
  137. * @cdb: Command Descriptor Block CDB DW-4 to DW-7
  138. */
  139. struct utp_upiu_cmd {
  140. struct utp_upiu_header header;
  141. u32 exp_data_transfer_len;
  142. u8 cdb[MAX_CDB_SIZE];
  143. };
  144. /**
  145. * struct utp_upiu_rsp - Response UPIU structure
  146. * @header: UPIU header DW-0 to DW-2
  147. * @residual_transfer_count: Residual transfer count DW-3
  148. * @reserved: Reserved double words DW-4 to DW-7
  149. * @sense_data_len: Sense data length DW-8 U16
  150. * @sense_data: Sense data field DW-8 to DW-12
  151. */
  152. struct utp_upiu_rsp {
  153. struct utp_upiu_header header;
  154. u32 residual_transfer_count;
  155. u32 reserved[4];
  156. u16 sense_data_len;
  157. u8 sense_data[18];
  158. };
  159. /**
  160. * struct utp_upiu_task_req - Task request UPIU structure
  161. * @header - UPIU header structure DW0 to DW-2
  162. * @input_param1: Input parameter 1 DW-3
  163. * @input_param2: Input parameter 2 DW-4
  164. * @input_param3: Input parameter 3 DW-5
  165. * @reserved: Reserved double words DW-6 to DW-7
  166. */
  167. struct utp_upiu_task_req {
  168. struct utp_upiu_header header;
  169. u32 input_param1;
  170. u32 input_param2;
  171. u32 input_param3;
  172. u32 reserved[2];
  173. };
  174. /**
  175. * struct utp_upiu_task_rsp - Task Management Response UPIU structure
  176. * @header: UPIU header structure DW0-DW-2
  177. * @output_param1: Ouput parameter 1 DW3
  178. * @output_param2: Output parameter 2 DW4
  179. * @reserved: Reserved double words DW-5 to DW-7
  180. */
  181. struct utp_upiu_task_rsp {
  182. struct utp_upiu_header header;
  183. u32 output_param1;
  184. u32 output_param2;
  185. u32 reserved[3];
  186. };
  187. #endif /* End of Header */