Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rts51x_scsi.h
Go to the documentation of this file.
1 /* Driver for Realtek RTS51xx USB 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  * Maintainer:
23  * Edwin Rong ([email protected])
24  * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
25  */
26 
27 #ifndef __RTS51X_SCSI_H
28 #define __RTS51X_SCSI_H
29 
30 #include <linux/usb.h>
31 #include <linux/usb_usual.h>
32 #include <linux/blkdev.h>
33 #include <linux/completion.h>
34 #include <linux/mutex.h>
35 #include <scsi/scsi_host.h>
36 
37 #include "rts51x_chip.h"
38 
39 #define MS_SP_CMND 0xFA
40 #define MS_FORMAT 0xA0
41 #define GET_MS_INFORMATION 0xB0
42 
43 #define VENDOR_CMND 0xF0
44 
45 #define READ_STATUS 0x09
46 
47 #define READ_MEM 0x0D
48 #define WRITE_MEM 0x0E
49 #define GET_BUS_WIDTH 0x13
50 #define GET_SD_CSD 0x14
51 #define TOGGLE_GPIO 0x15
52 #define TRACE_MSG 0x18
53 
54 #define SCSI_APP_CMD 0x10
55 
56 #define PP_READ10 0x1A
57 #define PP_WRITE10 0x0A
58 #define READ_HOST_REG 0x1D
59 #define WRITE_HOST_REG 0x0D
60 #define SET_VAR 0x05
61 #define GET_VAR 0x15
62 #define DMA_READ 0x16
63 #define DMA_WRITE 0x06
64 #define GET_DEV_STATUS 0x10
65 #define SET_CHIP_MODE 0x27
66 #define SUIT_CMD 0xE0
67 #define WRITE_PHY 0x07
68 #define READ_PHY 0x17
69 
70 #define INIT_BATCHCMD 0x41
71 #define ADD_BATCHCMD 0x42
72 #define SEND_BATCHCMD 0x43
73 #define GET_BATCHRSP 0x44
74 
75 #ifdef SUPPORT_CPRM
76 /* SD Pass Through Command Extension */
77 #define SD_PASS_THRU_MODE 0xD0
78 #define SD_EXECUTE_NO_DATA 0xD1
79 #define SD_EXECUTE_READ 0xD2
80 #define SD_EXECUTE_WRITE 0xD3
81 #define SD_GET_RSP 0xD4
82 #define SD_HW_RST 0xD6
83 #endif
84 
85 #ifdef SUPPORT_MAGIC_GATE
86 #define CMD_MSPRO_MG_RKEY 0xA4 /* Report Key Command */
87 #define CMD_MSPRO_MG_SKEY 0xA3 /* Send Key Command */
88 
89 /* CBWCB field: key class */
90 #define KC_MG_R_PRO 0xBE /* MG-R PRO */
91 
92 /* CBWCB field: key format */
93 #define KF_SET_LEAF_ID 0x31 /* Set Leaf ID */
94 #define KF_GET_LOC_EKB 0x32 /* Get Local EKB */
95 #define KF_CHG_HOST 0x33 /* Challenge (host) */
96 #define KF_RSP_CHG 0x34 /* Response and Challenge (device) */
97 #define KF_RSP_HOST 0x35 /* Response (host) */
98 #define KF_GET_ICV 0x36 /* Get ICV */
99 #define KF_SET_ICV 0x37 /* SSet ICV */
100 #endif
101 
102 struct rts51x_chip;
103 
104 /*-----------------------------------
105  Start-Stop-Unit
106 -----------------------------------*/
107 #define STOP_MEDIUM 0x00 /* access disable */
108 #define MAKE_MEDIUM_READY 0x01 /* access enable */
109 #define UNLOAD_MEDIUM 0x02 /* unload */
110 #define LOAD_MEDIUM 0x03 /* load */
111 
112 /*-----------------------------------
113  STANDARD_INQUIRY
114 -----------------------------------*/
115 #define QULIFIRE 0x00
116 #define AENC_FNC 0x00
117 #define TRML_IOP 0x00
118 #define REL_ADR 0x00
119 #define WBUS_32 0x00
120 #define WBUS_16 0x00
121 #define SYNC 0x00
122 #define LINKED 0x00
123 #define CMD_QUE 0x00
124 #define SFT_RE 0x00
125 
126 #define VEN_ID_LEN 8 /* Vendor ID Length */
127 #define PRDCT_ID_LEN 16 /* Product ID Length */
128 #define PRDCT_REV_LEN 4 /* Product LOT Length */
129 
130 #define DRCT_ACCESS_DEV 0x00 /* Direct Access Device */
131 #define RMB_DISC 0x80 /* The Device is Removable */
132 #define ANSI_SCSI2 0x02 /* Based on ANSI-SCSI2 */
133 
134 #define SCSI 0x00 /* Interface ID */
135 
136 void scsi_show_command(struct scsi_cmnd *srb);
137 void set_sense_type(struct rts51x_chip *chip, unsigned int lun, int sense_type);
138 void set_sense_data(struct rts51x_chip *chip, unsigned int lun, u8 err_code,
139  u8 sense_key, u32 info, u8 asc, u8 ascq, u8 sns_key_info0,
140  u16 sns_key_info1);
141 
142 int rts51x_scsi_handler(struct scsi_cmnd *srb, struct rts51x_chip *chip);
143 
144 struct Scsi_Host;
145 struct scsi_device;
146 struct scsi_cmnd;
147 
148 int slave_alloc(struct scsi_device *sdev);
149 int slave_configure(struct scsi_device *sdev);
150 int proc_info(struct Scsi_Host *host, char *buffer,
151  char **start, off_t offset, int length, int inout);
152 int queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
153 int command_abort(struct scsi_cmnd *srb);
154 int device_reset(struct scsi_cmnd *srb);
155 int bus_reset(struct scsi_cmnd *srb);
156 
157 #endif /* __RTS51X_SCSI_H */