mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-16 19:46:55 +07:00
208 lines
6.0 KiB
C
208 lines
6.0 KiB
C
|
/*
|
||
|
* Universal Flash Storage Host controller driver
|
||
|
*
|
||
|
* This code is based on drivers/scsi/ufs/ufs.h
|
||
|
* Copyright (C) 2011-2012 Samsung India Software Operations
|
||
|
*
|
||
|
* Santosh Yaraganavi <santosh.sy@samsung.com>
|
||
|
* Vinayak Holikatti <h.vinayak@samsung.com>
|
||
|
*
|
||
|
* This program is free software; you can redistribute it and/or
|
||
|
* modify it under the terms of the GNU General Public License
|
||
|
* as published by the Free Software Foundation; either version 2
|
||
|
* of the License, or (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU General Public License for more details.
|
||
|
*
|
||
|
* NO WARRANTY
|
||
|
* THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||
|
* CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
|
||
|
* LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
|
||
|
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
|
||
|
* solely responsible for determining the appropriateness of using and
|
||
|
* distributing the Program and assumes all risks associated with its
|
||
|
* exercise of rights under this Agreement, including but not limited to
|
||
|
* the risks and costs of program errors, damage to or loss of data,
|
||
|
* programs or equipment, and unavailability or interruption of operations.
|
||
|
|
||
|
* DISCLAIMER OF LIABILITY
|
||
|
* NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
|
||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||
|
* DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
|
||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||
|
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||
|
* USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
|
||
|
* HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
|
||
|
|
||
|
* You should have received a copy of the GNU General Public License
|
||
|
* along with this program; if not, write to the Free Software
|
||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||
|
* USA.
|
||
|
*/
|
||
|
|
||
|
#ifndef _UFS_H
|
||
|
#define _UFS_H
|
||
|
|
||
|
#define MAX_CDB_SIZE 16
|
||
|
|
||
|
#define UPIU_HEADER_DWORD(byte3, byte2, byte1, byte0)\
|
||
|
((byte3 << 24) | (byte2 << 16) |\
|
||
|
(byte1 << 8) | (byte0))
|
||
|
|
||
|
/*
|
||
|
* UFS Protocol Information Unit related definitions
|
||
|
*/
|
||
|
|
||
|
/* Task management functions */
|
||
|
enum {
|
||
|
UFS_ABORT_TASK = 0x01,
|
||
|
UFS_ABORT_TASK_SET = 0x02,
|
||
|
UFS_CLEAR_TASK_SET = 0x04,
|
||
|
UFS_LOGICAL_RESET = 0x08,
|
||
|
UFS_QUERY_TASK = 0x80,
|
||
|
UFS_QUERY_TASK_SET = 0x81,
|
||
|
};
|
||
|
|
||
|
/* UTP UPIU Transaction Codes Initiator to Target */
|
||
|
enum {
|
||
|
UPIU_TRANSACTION_NOP_OUT = 0x00,
|
||
|
UPIU_TRANSACTION_COMMAND = 0x01,
|
||
|
UPIU_TRANSACTION_DATA_OUT = 0x02,
|
||
|
UPIU_TRANSACTION_TASK_REQ = 0x04,
|
||
|
UPIU_TRANSACTION_QUERY_REQ = 0x26,
|
||
|
};
|
||
|
|
||
|
/* UTP UPIU Transaction Codes Target to Initiator */
|
||
|
enum {
|
||
|
UPIU_TRANSACTION_NOP_IN = 0x20,
|
||
|
UPIU_TRANSACTION_RESPONSE = 0x21,
|
||
|
UPIU_TRANSACTION_DATA_IN = 0x22,
|
||
|
UPIU_TRANSACTION_TASK_RSP = 0x24,
|
||
|
UPIU_TRANSACTION_READY_XFER = 0x31,
|
||
|
UPIU_TRANSACTION_QUERY_RSP = 0x36,
|
||
|
};
|
||
|
|
||
|
/* UPIU Read/Write flags */
|
||
|
enum {
|
||
|
UPIU_CMD_FLAGS_NONE = 0x00,
|
||
|
UPIU_CMD_FLAGS_WRITE = 0x20,
|
||
|
UPIU_CMD_FLAGS_READ = 0x40,
|
||
|
};
|
||
|
|
||
|
/* UPIU Task Attributes */
|
||
|
enum {
|
||
|
UPIU_TASK_ATTR_SIMPLE = 0x00,
|
||
|
UPIU_TASK_ATTR_ORDERED = 0x01,
|
||
|
UPIU_TASK_ATTR_HEADQ = 0x02,
|
||
|
UPIU_TASK_ATTR_ACA = 0x03,
|
||
|
};
|
||
|
|
||
|
/* UTP QUERY Transaction Specific Fields OpCode */
|
||
|
enum {
|
||
|
UPIU_QUERY_OPCODE_NOP = 0x0,
|
||
|
UPIU_QUERY_OPCODE_READ_DESC = 0x1,
|
||
|
UPIU_QUERY_OPCODE_WRITE_DESC = 0x2,
|
||
|
UPIU_QUERY_OPCODE_READ_ATTR = 0x3,
|
||
|
UPIU_QUERY_OPCODE_WRITE_ATTR = 0x4,
|
||
|
UPIU_QUERY_OPCODE_READ_FLAG = 0x5,
|
||
|
UPIU_QUERY_OPCODE_SET_FLAG = 0x6,
|
||
|
UPIU_QUERY_OPCODE_CLEAR_FLAG = 0x7,
|
||
|
UPIU_QUERY_OPCODE_TOGGLE_FLAG = 0x8,
|
||
|
};
|
||
|
|
||
|
/* UTP Transfer Request Command Type (CT) */
|
||
|
enum {
|
||
|
UPIU_COMMAND_SET_TYPE_SCSI = 0x0,
|
||
|
UPIU_COMMAND_SET_TYPE_UFS = 0x1,
|
||
|
UPIU_COMMAND_SET_TYPE_QUERY = 0x2,
|
||
|
};
|
||
|
|
||
|
enum {
|
||
|
MASK_SCSI_STATUS = 0xFF,
|
||
|
MASK_TASK_RESPONSE = 0xFF00,
|
||
|
MASK_RSP_UPIU_RESULT = 0xFFFF,
|
||
|
};
|
||
|
|
||
|
/* Task management service response */
|
||
|
enum {
|
||
|
UPIU_TASK_MANAGEMENT_FUNC_COMPL = 0x00,
|
||
|
UPIU_TASK_MANAGEMENT_FUNC_NOT_SUPPORTED = 0x04,
|
||
|
UPIU_TASK_MANAGEMENT_FUNC_SUCCEEDED = 0x08,
|
||
|
UPIU_TASK_MANAGEMENT_FUNC_FAILED = 0x05,
|
||
|
UPIU_INCORRECT_LOGICAL_UNIT_NO = 0x09,
|
||
|
};
|
||
|
/**
|
||
|
* struct utp_upiu_header - UPIU header structure
|
||
|
* @dword_0: UPIU header DW-0
|
||
|
* @dword_1: UPIU header DW-1
|
||
|
* @dword_2: UPIU header DW-2
|
||
|
*/
|
||
|
struct utp_upiu_header {
|
||
|
u32 dword_0;
|
||
|
u32 dword_1;
|
||
|
u32 dword_2;
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* struct utp_upiu_cmd - Command UPIU structure
|
||
|
* @header: UPIU header structure DW-0 to DW-2
|
||
|
* @data_transfer_len: Data Transfer Length DW-3
|
||
|
* @cdb: Command Descriptor Block CDB DW-4 to DW-7
|
||
|
*/
|
||
|
struct utp_upiu_cmd {
|
||
|
struct utp_upiu_header header;
|
||
|
u32 exp_data_transfer_len;
|
||
|
u8 cdb[MAX_CDB_SIZE];
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* struct utp_upiu_rsp - Response UPIU structure
|
||
|
* @header: UPIU header DW-0 to DW-2
|
||
|
* @residual_transfer_count: Residual transfer count DW-3
|
||
|
* @reserved: Reserved double words DW-4 to DW-7
|
||
|
* @sense_data_len: Sense data length DW-8 U16
|
||
|
* @sense_data: Sense data field DW-8 to DW-12
|
||
|
*/
|
||
|
struct utp_upiu_rsp {
|
||
|
struct utp_upiu_header header;
|
||
|
u32 residual_transfer_count;
|
||
|
u32 reserved[4];
|
||
|
u16 sense_data_len;
|
||
|
u8 sense_data[18];
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* struct utp_upiu_task_req - Task request UPIU structure
|
||
|
* @header - UPIU header structure DW0 to DW-2
|
||
|
* @input_param1: Input parameter 1 DW-3
|
||
|
* @input_param2: Input parameter 2 DW-4
|
||
|
* @input_param3: Input parameter 3 DW-5
|
||
|
* @reserved: Reserved double words DW-6 to DW-7
|
||
|
*/
|
||
|
struct utp_upiu_task_req {
|
||
|
struct utp_upiu_header header;
|
||
|
u32 input_param1;
|
||
|
u32 input_param2;
|
||
|
u32 input_param3;
|
||
|
u32 reserved[2];
|
||
|
};
|
||
|
|
||
|
/**
|
||
|
* struct utp_upiu_task_rsp - Task Management Response UPIU structure
|
||
|
* @header: UPIU header structure DW0-DW-2
|
||
|
* @output_param1: Ouput parameter 1 DW3
|
||
|
* @output_param2: Output parameter 2 DW4
|
||
|
* @reserved: Reserved double words DW-5 to DW-7
|
||
|
*/
|
||
|
struct utp_upiu_task_rsp {
|
||
|
struct utp_upiu_header header;
|
||
|
u32 output_param1;
|
||
|
u32 output_param2;
|
||
|
u32 reserved[3];
|
||
|
};
|
||
|
|
||
|
#endif /* End of Header */
|