Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rtsx_scsi.h
Go to the documentation of this file.
1 /* Driver for Realtek PCI-Express card reader
2  * Header file
3  *
4  * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the
8  * Free Software Foundation; either version 2, or (at your option) any
9  * later version.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, see <http://www.gnu.org/licenses/>.
18  *
19  * Author:
20  * wwang ([email protected])
21  * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
22  */
23 
24 #ifndef __REALTEK_RTSX_SCSI_H
25 #define __REALTEK_RTSX_SCSI_H
26 
27 #include "rtsx.h"
28 #include "rtsx_chip.h"
29 
30 #define MS_SP_CMND 0xFA
31 #define MS_FORMAT 0xA0
32 #define GET_MS_INFORMATION 0xB0
33 
34 #define VENDOR_CMND 0xF0
35 
36 #define READ_STATUS 0x09
37 
38 #define READ_EEPROM 0x04
39 #define WRITE_EEPROM 0x05
40 #define READ_MEM 0x0D
41 #define WRITE_MEM 0x0E
42 #define GET_BUS_WIDTH 0x13
43 #define GET_SD_CSD 0x14
44 #define TOGGLE_GPIO 0x15
45 #define TRACE_MSG 0x18
46 
47 #define SCSI_APP_CMD 0x10
48 
49 #define PP_READ10 0x1A
50 #define PP_WRITE10 0x0A
51 #define READ_HOST_REG 0x1D
52 #define WRITE_HOST_REG 0x0D
53 #define SET_VAR 0x05
54 #define GET_VAR 0x15
55 #define DMA_READ 0x16
56 #define DMA_WRITE 0x06
57 #define GET_DEV_STATUS 0x10
58 #define SET_CHIP_MODE 0x27
59 #define SUIT_CMD 0xE0
60 #define WRITE_PHY 0x07
61 #define READ_PHY 0x17
62 #define WRITE_EEPROM2 0x03
63 #define READ_EEPROM2 0x13
64 #define ERASE_EEPROM2 0x23
65 #define WRITE_EFUSE 0x04
66 #define READ_EFUSE 0x14
67 #define WRITE_CFG 0x0E
68 #define READ_CFG 0x1E
69 
70 #define SPI_VENDOR_COMMAND 0x1C
71 
72 #define SCSI_SPI_GETSTATUS 0x00
73 #define SCSI_SPI_SETPARAMETER 0x01
74 #define SCSI_SPI_READFALSHID 0x02
75 #define SCSI_SPI_READFLASH 0x03
76 #define SCSI_SPI_WRITEFLASH 0x04
77 #define SCSI_SPI_WRITEFLASHSTATUS 0x05
78 #define SCSI_SPI_ERASEFLASH 0x06
79 
80 #define INIT_BATCHCMD 0x41
81 #define ADD_BATCHCMD 0x42
82 #define SEND_BATCHCMD 0x43
83 #define GET_BATCHRSP 0x44
84 
85 #define CHIP_NORMALMODE 0x00
86 #define CHIP_DEBUGMODE 0x01
87 
88 /* SD Pass Through Command Extension */
89 #define SD_PASS_THRU_MODE 0xD0
90 #define SD_EXECUTE_NO_DATA 0xD1
91 #define SD_EXECUTE_READ 0xD2
92 #define SD_EXECUTE_WRITE 0xD3
93 #define SD_GET_RSP 0xD4
94 #define SD_HW_RST 0xD6
95 
96 #ifdef SUPPORT_MAGIC_GATE
97 #define CMD_MSPRO_MG_RKEY 0xA4 /* Report Key Command */
98 #define CMD_MSPRO_MG_SKEY 0xA3 /* Send Key Command */
99 
100 /* CBWCB field: key class */
101 #define KC_MG_R_PRO 0xBE /* MG-R PRO*/
102 
103 /* CBWCB field: key format */
104 #define KF_SET_LEAF_ID 0x31 /* Set Leaf ID */
105 #define KF_GET_LOC_EKB 0x32 /* Get Local EKB */
106 #define KF_CHG_HOST 0x33 /* Challenge (host) */
107 #define KF_RSP_CHG 0x34 /* Response and Challenge (device) */
108 #define KF_RSP_HOST 0x35 /* Response (host) */
109 #define KF_GET_ICV 0x36 /* Get ICV */
110 #define KF_SET_ICV 0x37 /* SSet ICV */
111 #endif
112 
113 /* Sense type */
114 #define SENSE_TYPE_NO_SENSE 0
115 #define SENSE_TYPE_MEDIA_CHANGE 1
116 #define SENSE_TYPE_MEDIA_NOT_PRESENT 2
117 #define SENSE_TYPE_MEDIA_LBA_OVER_RANGE 3
118 #define SENSE_TYPE_MEDIA_LUN_NOT_SUPPORT 4
119 #define SENSE_TYPE_MEDIA_WRITE_PROTECT 5
120 #define SENSE_TYPE_MEDIA_INVALID_CMD_FIELD 6
121 #define SENSE_TYPE_MEDIA_UNRECOVER_READ_ERR 7
122 #define SENSE_TYPE_MEDIA_WRITE_ERR 8
123 #define SENSE_TYPE_FORMAT_IN_PROGRESS 9
124 #define SENSE_TYPE_FORMAT_CMD_FAILED 10
125 #ifdef SUPPORT_MAGIC_GATE
126 #define SENSE_TYPE_MG_KEY_FAIL_NOT_ESTAB 0x0b
127 #define SENSE_TYPE_MG_KEY_FAIL_NOT_AUTHEN 0x0c
128 #define SENSE_TYPE_MG_INCOMPATIBLE_MEDIUM 0x0d
129 #define SENSE_TYPE_MG_WRITE_ERR 0x0e
130 #endif
131 #ifdef SUPPORT_SD_LOCK
132 #define SENSE_TYPE_MEDIA_READ_FORBIDDEN 0x10 /* FOR Locked SD card*/
133 #endif
134 
135 void scsi_show_command(struct scsi_cmnd *srb);
136 void set_sense_type(struct rtsx_chip *chip, unsigned int lun, int sense_type);
137 void set_sense_data(struct rtsx_chip *chip, unsigned int lun, u8 err_code, u8 sense_key,
138  u32 info, u8 asc, u8 ascq, u8 sns_key_info0, u16 sns_key_info1);
139 int rtsx_scsi_handler(struct scsi_cmnd *srb, struct rtsx_chip *chip);
140 
141 #endif /* __REALTEK_RTSX_SCSI_H */
142