ufs.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /*
  2. * Universal Flash Storage Host controller driver
  3. *
  4. * This code is based on drivers/scsi/ufs/ufs.h
  5. * Copyright (C) 2011-2013 Samsung India Software Operations
  6. *
  7. * Authors:
  8. * Santosh Yaraganavi <santosh.sy@samsung.com>
  9. * Vinayak Holikatti <h.vinayak@samsung.com>
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License
  13. * as published by the Free Software Foundation; either version 2
  14. * of the License, or (at your option) any later version.
  15. * See the COPYING file in the top-level directory or visit
  16. * <http://www.gnu.org/licenses/gpl-2.0.html>
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * This program is provided "AS IS" and "WITH ALL FAULTS" and
  24. * without warranty of any kind. You are solely responsible for
  25. * determining the appropriateness of using and distributing
  26. * the program and assume all risks associated with your exercise
  27. * of rights with respect to the program, including but not limited
  28. * to infringement of third party rights, the risks and costs of
  29. * program errors, damage to or loss of data, programs or equipment,
  30. * and unavailability or interruption of operations. Under no
  31. * circumstances will the contributor of this Program be liable for
  32. * any damages of any kind arising from your use or distribution of
  33. * this program.
  34. */
  35. #ifndef _UFS_H
  36. #define _UFS_H
  37. #define MAX_CDB_SIZE 16
  38. #define UPIU_HEADER_DWORD(byte3, byte2, byte1, byte0)\
  39. ((byte3 << 24) | (byte2 << 16) |\
  40. (byte1 << 8) | (byte0))
  41. /*
  42. * UFS Protocol Information Unit related definitions
  43. */
  44. /* Task management functions */
  45. enum {
  46. UFS_ABORT_TASK = 0x01,
  47. UFS_ABORT_TASK_SET = 0x02,
  48. UFS_CLEAR_TASK_SET = 0x04,
  49. UFS_LOGICAL_RESET = 0x08,
  50. UFS_QUERY_TASK = 0x80,
  51. UFS_QUERY_TASK_SET = 0x81,
  52. };
  53. /* UTP UPIU Transaction Codes Initiator to Target */
  54. enum {
  55. UPIU_TRANSACTION_NOP_OUT = 0x00,
  56. UPIU_TRANSACTION_COMMAND = 0x01,
  57. UPIU_TRANSACTION_DATA_OUT = 0x02,
  58. UPIU_TRANSACTION_TASK_REQ = 0x04,
  59. UPIU_TRANSACTION_QUERY_REQ = 0x26,
  60. };
  61. /* UTP UPIU Transaction Codes Target to Initiator */
  62. enum {
  63. UPIU_TRANSACTION_NOP_IN = 0x20,
  64. UPIU_TRANSACTION_RESPONSE = 0x21,
  65. UPIU_TRANSACTION_DATA_IN = 0x22,
  66. UPIU_TRANSACTION_TASK_RSP = 0x24,
  67. UPIU_TRANSACTION_READY_XFER = 0x31,
  68. UPIU_TRANSACTION_QUERY_RSP = 0x36,
  69. };
  70. /* UPIU Read/Write flags */
  71. enum {
  72. UPIU_CMD_FLAGS_NONE = 0x00,
  73. UPIU_CMD_FLAGS_WRITE = 0x20,
  74. UPIU_CMD_FLAGS_READ = 0x40,
  75. };
  76. /* UPIU Task Attributes */
  77. enum {
  78. UPIU_TASK_ATTR_SIMPLE = 0x00,
  79. UPIU_TASK_ATTR_ORDERED = 0x01,
  80. UPIU_TASK_ATTR_HEADQ = 0x02,
  81. UPIU_TASK_ATTR_ACA = 0x03,
  82. };
  83. /* UTP QUERY Transaction Specific Fields OpCode */
  84. enum {
  85. UPIU_QUERY_OPCODE_NOP = 0x0,
  86. UPIU_QUERY_OPCODE_READ_DESC = 0x1,
  87. UPIU_QUERY_OPCODE_WRITE_DESC = 0x2,
  88. UPIU_QUERY_OPCODE_READ_ATTR = 0x3,
  89. UPIU_QUERY_OPCODE_WRITE_ATTR = 0x4,
  90. UPIU_QUERY_OPCODE_READ_FLAG = 0x5,
  91. UPIU_QUERY_OPCODE_SET_FLAG = 0x6,
  92. UPIU_QUERY_OPCODE_CLEAR_FLAG = 0x7,
  93. UPIU_QUERY_OPCODE_TOGGLE_FLAG = 0x8,
  94. };
  95. /* UTP Transfer Request Command Type (CT) */
  96. enum {
  97. UPIU_COMMAND_SET_TYPE_SCSI = 0x0,
  98. UPIU_COMMAND_SET_TYPE_UFS = 0x1,
  99. UPIU_COMMAND_SET_TYPE_QUERY = 0x2,
  100. };
  101. enum {
  102. MASK_SCSI_STATUS = 0xFF,
  103. MASK_TASK_RESPONSE = 0xFF00,
  104. MASK_RSP_UPIU_RESULT = 0xFFFF,
  105. };
  106. /* Task management service response */
  107. enum {
  108. UPIU_TASK_MANAGEMENT_FUNC_COMPL = 0x00,
  109. UPIU_TASK_MANAGEMENT_FUNC_NOT_SUPPORTED = 0x04,
  110. UPIU_TASK_MANAGEMENT_FUNC_SUCCEEDED = 0x08,
  111. UPIU_TASK_MANAGEMENT_FUNC_FAILED = 0x05,
  112. UPIU_INCORRECT_LOGICAL_UNIT_NO = 0x09,
  113. };
  114. /**
  115. * struct utp_upiu_header - UPIU header structure
  116. * @dword_0: UPIU header DW-0
  117. * @dword_1: UPIU header DW-1
  118. * @dword_2: UPIU header DW-2
  119. */
  120. struct utp_upiu_header {
  121. u32 dword_0;
  122. u32 dword_1;
  123. u32 dword_2;
  124. };
  125. /**
  126. * struct utp_upiu_cmd - Command UPIU structure
  127. * @header: UPIU header structure DW-0 to DW-2
  128. * @data_transfer_len: Data Transfer Length DW-3
  129. * @cdb: Command Descriptor Block CDB DW-4 to DW-7
  130. */
  131. struct utp_upiu_cmd {
  132. struct utp_upiu_header header;
  133. u32 exp_data_transfer_len;
  134. u8 cdb[MAX_CDB_SIZE];
  135. };
  136. /**
  137. * struct utp_upiu_rsp - Response UPIU structure
  138. * @header: UPIU header DW-0 to DW-2
  139. * @residual_transfer_count: Residual transfer count DW-3
  140. * @reserved: Reserved double words DW-4 to DW-7
  141. * @sense_data_len: Sense data length DW-8 U16
  142. * @sense_data: Sense data field DW-8 to DW-12
  143. */
  144. struct utp_upiu_rsp {
  145. struct utp_upiu_header header;
  146. u32 residual_transfer_count;
  147. u32 reserved[4];
  148. u16 sense_data_len;
  149. u8 sense_data[18];
  150. };
  151. /**
  152. * struct utp_upiu_task_req - Task request UPIU structure
  153. * @header - UPIU header structure DW0 to DW-2
  154. * @input_param1: Input parameter 1 DW-3
  155. * @input_param2: Input parameter 2 DW-4
  156. * @input_param3: Input parameter 3 DW-5
  157. * @reserved: Reserved double words DW-6 to DW-7
  158. */
  159. struct utp_upiu_task_req {
  160. struct utp_upiu_header header;
  161. u32 input_param1;
  162. u32 input_param2;
  163. u32 input_param3;
  164. u32 reserved[2];
  165. };
  166. /**
  167. * struct utp_upiu_task_rsp - Task Management Response UPIU structure
  168. * @header: UPIU header structure DW0-DW-2
  169. * @output_param1: Ouput parameter 1 DW3
  170. * @output_param2: Output parameter 2 DW4
  171. * @reserved: Reserved double words DW-5 to DW-7
  172. */
  173. struct utp_upiu_task_rsp {
  174. struct utp_upiu_header header;
  175. u32 output_param1;
  176. u32 output_param2;
  177. u32 reserved[3];
  178. };
  179. #endif /* End of Header */