.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | /* |
---|
2 | 3 | * Universal Flash Storage Host controller driver |
---|
3 | | - * |
---|
4 | | - * This code is based on drivers/scsi/ufs/ufshci.h |
---|
5 | 4 | * Copyright (C) 2011-2013 Samsung India Software Operations |
---|
6 | 5 | * |
---|
7 | 6 | * Authors: |
---|
8 | 7 | * Santosh Yaraganavi <santosh.sy@samsung.com> |
---|
9 | 8 | * 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 | 9 | */ |
---|
35 | 10 | |
---|
36 | 11 | #ifndef _UFSHCI_H |
---|
.. | .. |
---|
64 | 39 | REG_UTP_TRANSFER_REQ_DOOR_BELL = 0x58, |
---|
65 | 40 | REG_UTP_TRANSFER_REQ_LIST_CLEAR = 0x5C, |
---|
66 | 41 | REG_UTP_TRANSFER_REQ_LIST_RUN_STOP = 0x60, |
---|
| 42 | + REG_UTP_TRANSFER_REQ_LIST_COMPL = 0x64, |
---|
67 | 43 | REG_UTP_TASK_REQ_LIST_BASE_L = 0x70, |
---|
68 | 44 | REG_UTP_TASK_REQ_LIST_BASE_H = 0x74, |
---|
69 | 45 | REG_UTP_TASK_REQ_DOOR_BELL = 0x78, |
---|
.. | .. |
---|
99 | 75 | #define MINOR_VERSION_NUM_MASK UFS_MASK(0xFFFF, 0) |
---|
100 | 76 | #define MAJOR_VERSION_NUM_MASK UFS_MASK(0xFFFF, 16) |
---|
101 | 77 | |
---|
102 | | -/* Controller UFSHCI version */ |
---|
103 | | -enum { |
---|
104 | | - UFSHCI_VERSION_10 = 0x00010000, /* 1.0 */ |
---|
105 | | - UFSHCI_VERSION_11 = 0x00010100, /* 1.1 */ |
---|
106 | | - UFSHCI_VERSION_20 = 0x00000200, /* 2.0 */ |
---|
107 | | - UFSHCI_VERSION_21 = 0x00000210, /* 2.1 */ |
---|
108 | | -}; |
---|
| 78 | +/* |
---|
| 79 | + * Controller UFSHCI version |
---|
| 80 | + * - 2.x and newer use the following scheme: |
---|
| 81 | + * major << 8 + minor << 4 |
---|
| 82 | + * - 1.x has been converted to match this in |
---|
| 83 | + * ufshcd_get_ufs_version() |
---|
| 84 | + */ |
---|
| 85 | +static inline u32 ufshci_version(u32 major, u32 minor) |
---|
| 86 | +{ |
---|
| 87 | + return (major << 8) + (minor << 4); |
---|
| 88 | +} |
---|
109 | 89 | |
---|
110 | 90 | /* |
---|
111 | 91 | * HCDDID - Host Controller Identification Descriptor |
---|
.. | .. |
---|
146 | 126 | #define SYSTEM_BUS_FATAL_ERROR 0x20000 |
---|
147 | 127 | #define CRYPTO_ENGINE_FATAL_ERROR 0x40000 |
---|
148 | 128 | |
---|
149 | | -#define UFSHCD_UIC_PWR_MASK (UIC_HIBERNATE_ENTER |\ |
---|
150 | | - UIC_HIBERNATE_EXIT |\ |
---|
| 129 | +#define UFSHCD_UIC_HIBERN8_MASK (UIC_HIBERNATE_ENTER |\ |
---|
| 130 | + UIC_HIBERNATE_EXIT) |
---|
| 131 | + |
---|
| 132 | +#define UFSHCD_UIC_PWR_MASK (UFSHCD_UIC_HIBERN8_MASK |\ |
---|
151 | 133 | UIC_POWER_MODE) |
---|
152 | 134 | |
---|
153 | 135 | #define UFSHCD_UIC_MASK (UIC_COMMAND_COMPL | UFSHCD_UIC_PWR_MASK) |
---|
154 | 136 | |
---|
155 | | -#define UFSHCD_ERROR_MASK (UIC_ERROR |\ |
---|
156 | | - DEVICE_FATAL_ERROR |\ |
---|
157 | | - CONTROLLER_FATAL_ERROR |\ |
---|
158 | | - SYSTEM_BUS_FATAL_ERROR |\ |
---|
159 | | - CRYPTO_ENGINE_FATAL_ERROR) |
---|
| 137 | +#define UFSHCD_ERROR_MASK (UIC_ERROR | INT_FATAL_ERRORS) |
---|
160 | 138 | |
---|
161 | 139 | #define INT_FATAL_ERRORS (DEVICE_FATAL_ERROR |\ |
---|
162 | 140 | CONTROLLER_FATAL_ERROR |\ |
---|
163 | 141 | SYSTEM_BUS_FATAL_ERROR |\ |
---|
164 | | - CRYPTO_ENGINE_FATAL_ERROR) |
---|
| 142 | + CRYPTO_ENGINE_FATAL_ERROR |\ |
---|
| 143 | + UIC_LINK_LOST) |
---|
165 | 144 | |
---|
166 | 145 | /* HCS - Host Controller Status 30h */ |
---|
167 | 146 | #define DEVICE_PRESENT 0x1 |
---|
.. | .. |
---|
194 | 173 | #define UIC_PHY_ADAPTER_LAYER_ERROR 0x80000000 |
---|
195 | 174 | #define UIC_PHY_ADAPTER_LAYER_ERROR_CODE_MASK 0x1F |
---|
196 | 175 | #define UIC_PHY_ADAPTER_LAYER_LANE_ERR_MASK 0xF |
---|
| 176 | +#define UIC_PHY_ADAPTER_LAYER_GENERIC_ERROR 0x10 |
---|
197 | 177 | |
---|
198 | 178 | /* UECDL - Host UIC Error Code Data Link Layer 3Ch */ |
---|
199 | 179 | #define UIC_DATA_LINK_LAYER_ERROR 0x80000000 |
---|
200 | | -#define UIC_DATA_LINK_LAYER_ERROR_CODE_MASK 0x7FFF |
---|
| 180 | +#define UIC_DATA_LINK_LAYER_ERROR_CODE_MASK 0xFFFF |
---|
201 | 181 | #define UIC_DATA_LINK_LAYER_ERROR_TCX_REP_TIMER_EXP 0x2 |
---|
202 | 182 | #define UIC_DATA_LINK_LAYER_ERROR_AFCX_REQ_TIMER_EXP 0x4 |
---|
203 | 183 | #define UIC_DATA_LINK_LAYER_ERROR_FCX_PRO_TIMER_EXP 0x8 |
---|
.. | .. |
---|
504 | 484 | __le16 prd_table_offset; |
---|
505 | 485 | }; |
---|
506 | 486 | |
---|
507 | | -/** |
---|
508 | | - * struct utp_task_req_desc - UTMRD structure |
---|
509 | | - * @header: UTMRD header DW-0 to DW-3 |
---|
510 | | - * @task_req_upiu: Pointer to task request UPIU DW-4 to DW-11 |
---|
511 | | - * @task_rsp_upiu: Pointer to task response UPIU DW12 to DW-19 |
---|
| 487 | +/* |
---|
| 488 | + * UTMRD structure. |
---|
512 | 489 | */ |
---|
513 | 490 | struct utp_task_req_desc { |
---|
514 | | - |
---|
515 | 491 | /* DW 0-3 */ |
---|
516 | 492 | struct request_desc_header header; |
---|
517 | 493 | |
---|
518 | | - /* DW 4-11 */ |
---|
519 | | - __le32 task_req_upiu[TASK_REQ_UPIU_SIZE_DWORDS]; |
---|
| 494 | + /* DW 4-11 - Task request UPIU structure */ |
---|
| 495 | + struct utp_upiu_header req_header; |
---|
| 496 | + __be32 input_param1; |
---|
| 497 | + __be32 input_param2; |
---|
| 498 | + __be32 input_param3; |
---|
| 499 | + __be32 __reserved1[2]; |
---|
520 | 500 | |
---|
521 | | - /* DW 12-19 */ |
---|
522 | | - __le32 task_rsp_upiu[TASK_RSP_UPIU_SIZE_DWORDS]; |
---|
| 501 | + /* DW 12-19 - Task Management Response UPIU structure */ |
---|
| 502 | + struct utp_upiu_header rsp_header; |
---|
| 503 | + __be32 output_param1; |
---|
| 504 | + __be32 output_param2; |
---|
| 505 | + __be32 __reserved2[3]; |
---|
523 | 506 | }; |
---|
524 | 507 | |
---|
525 | 508 | #endif /* End of Header */ |
---|