Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ufshci.h
Go to the documentation of this file.
1 /*
2  * Universal Flash Storage Host controller driver
3  *
4  * This code is based on drivers/scsi/ufs/ufshci.h
5  * Copyright (C) 2011-2012 Samsung India Software Operations
6  *
7  * Santosh Yaraganavi <[email protected]>
8  * Vinayak Holikatti <[email protected]>
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 
31  * DISCLAIMER OF LIABILITY
32  * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
33  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34  * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
35  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
36  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
37  * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
38  * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
39 
40  * You should have received a copy of the GNU General Public License
41  * along with this program; if not, write to the Free Software
42  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
43  * USA.
44  */
45 
46 #ifndef _UFSHCI_H
47 #define _UFSHCI_H
48 
49 enum {
53 };
54 
55 /* UFSHCI Registers */
56 enum {
85 };
86 
87 /* Controller capability masks */
88 enum {
94 };
95 
96 /* UFS Version 08h */
97 #define MINOR_VERSION_NUM_MASK UFS_MASK(0xFFFF, 0)
98 #define MAJOR_VERSION_NUM_MASK UFS_MASK(0xFFFF, 16)
99 
100 /* Controller UFSHCI version */
101 enum {
102  UFSHCI_VERSION_10 = 0x00010000,
103  UFSHCI_VERSION_11 = 0x00010100,
104 };
105 
106 /*
107  * HCDDID - Host Controller Identification Descriptor
108  * - Device ID and Device Class 10h
109  */
110 #define DEVICE_CLASS UFS_MASK(0xFFFF, 0)
111 #define DEVICE_ID UFS_MASK(0xFF, 24)
112 
113 /*
114  * HCPMID - Host Controller Identification Descriptor
115  * - Product/Manufacturer ID 14h
116  */
117 #define MANUFACTURE_ID_MASK UFS_MASK(0xFFFF, 0)
118 #define PRODUCT_ID_MASK UFS_MASK(0xFFFF, 16)
119 
120 #define UFS_BIT(x) (1L << (x))
121 
122 #define UTP_TRANSFER_REQ_COMPL UFS_BIT(0)
123 #define UIC_DME_END_PT_RESET UFS_BIT(1)
124 #define UIC_ERROR UFS_BIT(2)
125 #define UIC_TEST_MODE UFS_BIT(3)
126 #define UIC_POWER_MODE UFS_BIT(4)
127 #define UIC_HIBERNATE_EXIT UFS_BIT(5)
128 #define UIC_HIBERNATE_ENTER UFS_BIT(6)
129 #define UIC_LINK_LOST UFS_BIT(7)
130 #define UIC_LINK_STARTUP UFS_BIT(8)
131 #define UTP_TASK_REQ_COMPL UFS_BIT(9)
132 #define UIC_COMMAND_COMPL UFS_BIT(10)
133 #define DEVICE_FATAL_ERROR UFS_BIT(11)
134 #define CONTROLLER_FATAL_ERROR UFS_BIT(16)
135 #define SYSTEM_BUS_FATAL_ERROR UFS_BIT(17)
136 
137 #define UFSHCD_ERROR_MASK (UIC_ERROR |\
138  DEVICE_FATAL_ERROR |\
139  CONTROLLER_FATAL_ERROR |\
140  SYSTEM_BUS_FATAL_ERROR)
141 
142 #define INT_FATAL_ERRORS (DEVICE_FATAL_ERROR |\
143  CONTROLLER_FATAL_ERROR |\
144  SYSTEM_BUS_FATAL_ERROR)
145 
146 /* HCS - Host Controller Status 30h */
147 #define DEVICE_PRESENT UFS_BIT(0)
148 #define UTP_TRANSFER_REQ_LIST_READY UFS_BIT(1)
149 #define UTP_TASK_REQ_LIST_READY UFS_BIT(2)
150 #define UIC_COMMAND_READY UFS_BIT(3)
151 #define HOST_ERROR_INDICATOR UFS_BIT(4)
152 #define DEVICE_ERROR_INDICATOR UFS_BIT(5)
153 #define UIC_POWER_MODE_CHANGE_REQ_STATUS_MASK UFS_MASK(0x7, 8)
154 
155 /* HCE - Host Controller Enable 34h */
156 #define CONTROLLER_ENABLE UFS_BIT(0)
157 #define CONTROLLER_DISABLE 0x0
158 
159 /* UECPA - Host UIC Error Code PHY Adapter Layer 38h */
160 #define UIC_PHY_ADAPTER_LAYER_ERROR UFS_BIT(31)
161 #define UIC_PHY_ADAPTER_LAYER_ERROR_CODE_MASK 0x1F
162 
163 /* UECDL - Host UIC Error Code Data Link Layer 3Ch */
164 #define UIC_DATA_LINK_LAYER_ERROR UFS_BIT(31)
165 #define UIC_DATA_LINK_LAYER_ERROR_CODE_MASK 0x7FFF
166 #define UIC_DATA_LINK_LAYER_ERROR_PA_INIT 0x2000
167 
168 /* UECN - Host UIC Error Code Network Layer 40h */
169 #define UIC_NETWORK_LAYER_ERROR UFS_BIT(31)
170 #define UIC_NETWORK_LAYER_ERROR_CODE_MASK 0x7
171 
172 /* UECT - Host UIC Error Code Transport Layer 44h */
173 #define UIC_TRANSPORT_LAYER_ERROR UFS_BIT(31)
174 #define UIC_TRANSPORT_LAYER_ERROR_CODE_MASK 0x7F
175 
176 /* UECDME - Host UIC Error Code DME 48h */
177 #define UIC_DME_ERROR UFS_BIT(31)
178 #define UIC_DME_ERROR_CODE_MASK 0x1
179 
180 #define INT_AGGR_TIMEOUT_VAL_MASK 0xFF
181 #define INT_AGGR_COUNTER_THRESHOLD_MASK UFS_MASK(0x1F, 8)
182 #define INT_AGGR_COUNTER_AND_TIMER_RESET UFS_BIT(16)
183 #define INT_AGGR_STATUS_BIT UFS_BIT(20)
184 #define INT_AGGR_PARAM_WRITE UFS_BIT(24)
185 #define INT_AGGR_ENABLE UFS_BIT(31)
186 
187 /* UTRLRSR - UTP Transfer Request Run-Stop Register 60h */
188 #define UTP_TRANSFER_REQ_LIST_RUN_STOP_BIT UFS_BIT(0)
189 
190 /* UTMRLRSR - UTP Task Management Request Run-Stop Register 80h */
191 #define UTP_TASK_REQ_LIST_RUN_STOP_BIT UFS_BIT(0)
192 
193 /* UICCMD - UIC Command */
194 #define COMMAND_OPCODE_MASK 0xFF
195 #define GEN_SELECTOR_INDEX_MASK 0xFFFF
196 
197 #define MIB_ATTRIBUTE_MASK UFS_MASK(0xFFFF, 16)
198 #define RESET_LEVEL 0xFF
199 
200 #define ATTR_SET_TYPE_MASK UFS_MASK(0xFF, 16)
201 #define CONFIG_RESULT_CODE_MASK 0xFF
202 #define GENERIC_ERROR_CODE_MASK 0xFF
203 
204 /* UIC Commands */
205 enum {
219 };
220 
221 /* UIC Config result code / Generic error code */
222 enum {
235 };
236 
237 #define MASK_UIC_COMMAND_RESULT 0xFF
238 
239 #define INT_AGGR_COUNTER_THRESHOLD_VALUE (0x1F << 8)
240 #define INT_AGGR_TIMEOUT_VALUE (0x02)
241 
242 /* Interrupt disable masks */
243 enum {
244  /* Interrupt disable mask for UFSHCI v1.0 */
246 
247  /* Interrupt disable mask for UFSHCI v1.1 */
249 };
250 
251 /*
252  * Request Descriptor Definitions
253  */
254 
255 /* Transfer request command type */
256 enum {
260 };
261 
262 enum {
263  UTP_SCSI_COMMAND = 0x00000000,
266  UTP_REQ_DESC_INT_CMD = 0x01000000,
267 };
268 
269 /* UTP Transfer Request Data Direction (DD) */
270 enum {
271  UTP_NO_DATA_TRANSFER = 0x00000000,
272  UTP_HOST_TO_DEVICE = 0x02000000,
273  UTP_DEVICE_TO_HOST = 0x04000000,
274 };
275 
276 /* Overall command status values */
277 enum {
278  OCS_SUCCESS = 0x0,
284  OCS_ABORTED = 0x6,
287  MASK_OCS = 0x0F,
288 };
289 
302 };
303 
314 };
315 
328 };
329 
341 
342  /* DW 0-3 */
344 
345  /* DW 4-5*/
348 
349  /* DW 6 */
352 
353  /* DW 7 */
356 };
357 
365 
366  /* DW 0-3 */
368 
369  /* DW 4-11 */
371 
372  /* DW 12-19 */
374 };
375 
376 #endif /* End of Header */