hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/scsi/ufs/ufshci.h
....@@ -1,36 +1,11 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * Universal Flash Storage Host controller driver
3
- *
4
- * This code is based on drivers/scsi/ufs/ufshci.h
54 * Copyright (C) 2011-2013 Samsung India Software Operations
65 *
76 * Authors:
87 * Santosh Yaraganavi <santosh.sy@samsung.com>
98 * 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.
349 */
3510
3611 #ifndef _UFSHCI_H
....@@ -64,6 +39,7 @@
6439 REG_UTP_TRANSFER_REQ_DOOR_BELL = 0x58,
6540 REG_UTP_TRANSFER_REQ_LIST_CLEAR = 0x5C,
6641 REG_UTP_TRANSFER_REQ_LIST_RUN_STOP = 0x60,
42
+ REG_UTP_TRANSFER_REQ_LIST_COMPL = 0x64,
6743 REG_UTP_TASK_REQ_LIST_BASE_L = 0x70,
6844 REG_UTP_TASK_REQ_LIST_BASE_H = 0x74,
6945 REG_UTP_TASK_REQ_DOOR_BELL = 0x78,
....@@ -99,13 +75,17 @@
9975 #define MINOR_VERSION_NUM_MASK UFS_MASK(0xFFFF, 0)
10076 #define MAJOR_VERSION_NUM_MASK UFS_MASK(0xFFFF, 16)
10177
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
+}
10989
11090 /*
11191 * HCDDID - Host Controller Identification Descriptor
....@@ -146,22 +126,21 @@
146126 #define SYSTEM_BUS_FATAL_ERROR 0x20000
147127 #define CRYPTO_ENGINE_FATAL_ERROR 0x40000
148128
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 |\
151133 UIC_POWER_MODE)
152134
153135 #define UFSHCD_UIC_MASK (UIC_COMMAND_COMPL | UFSHCD_UIC_PWR_MASK)
154136
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)
160138
161139 #define INT_FATAL_ERRORS (DEVICE_FATAL_ERROR |\
162140 CONTROLLER_FATAL_ERROR |\
163141 SYSTEM_BUS_FATAL_ERROR |\
164
- CRYPTO_ENGINE_FATAL_ERROR)
142
+ CRYPTO_ENGINE_FATAL_ERROR |\
143
+ UIC_LINK_LOST)
165144
166145 /* HCS - Host Controller Status 30h */
167146 #define DEVICE_PRESENT 0x1
....@@ -194,10 +173,11 @@
194173 #define UIC_PHY_ADAPTER_LAYER_ERROR 0x80000000
195174 #define UIC_PHY_ADAPTER_LAYER_ERROR_CODE_MASK 0x1F
196175 #define UIC_PHY_ADAPTER_LAYER_LANE_ERR_MASK 0xF
176
+#define UIC_PHY_ADAPTER_LAYER_GENERIC_ERROR 0x10
197177
198178 /* UECDL - Host UIC Error Code Data Link Layer 3Ch */
199179 #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
201181 #define UIC_DATA_LINK_LAYER_ERROR_TCX_REP_TIMER_EXP 0x2
202182 #define UIC_DATA_LINK_LAYER_ERROR_AFCX_REQ_TIMER_EXP 0x4
203183 #define UIC_DATA_LINK_LAYER_ERROR_FCX_PRO_TIMER_EXP 0x8
....@@ -504,22 +484,25 @@
504484 __le16 prd_table_offset;
505485 };
506486
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.
512489 */
513490 struct utp_task_req_desc {
514
-
515491 /* DW 0-3 */
516492 struct request_desc_header header;
517493
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];
520500
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];
523506 };
524507
525508 #endif /* End of Header */