1 /* Driver for Realtek RTS51xx USB card reader
4 * Copyright(c) 2009 Realtek Semiconductor Corp. All rights reserved.
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
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.
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/>.
20 * wwang (wei_wang@realsil.com.cn)
21 * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
23 * Edwin Rong (edwin_rong@realsil.com.cn)
24 * No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
27 #ifndef __RTS51X_SCSI_H
28 #define __RTS51X_SCSI_H
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>
37 #include "rts51x_chip.h"
39 #define MS_SP_CMND 0xFA
40 #define MS_FORMAT 0xA0
41 #define GET_MS_INFORMATION 0xB0
43 #define VENDOR_CMND 0xF0
45 #define READ_STATUS 0x09
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
54 #define SCSI_APP_CMD 0x10
56 #define PP_READ10 0x1A
57 #define PP_WRITE10 0x0A
58 #define READ_HOST_REG 0x1D
59 #define WRITE_HOST_REG 0x0D
63 #define DMA_WRITE 0x06
64 #define GET_DEV_STATUS 0x10
65 #define SET_CHIP_MODE 0x27
67 #define WRITE_PHY 0x07
70 #define INIT_BATCHCMD 0x41
71 #define ADD_BATCHCMD 0x42
72 #define SEND_BATCHCMD 0x43
73 #define GET_BATCHRSP 0x44
76 /* SD Pass Through Command Extention */
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
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 */
89 /* CBWCB field: key class */
90 #define KC_MG_R_PRO 0xBE /* MG-R PRO */
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 */
104 /*-----------------------------------
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 */
112 /*-----------------------------------
114 -----------------------------------*/
115 #define QULIFIRE 0x00
116 #define AENC_FNC 0x00
117 #define TRML_IOP 0x00
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 */
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 */
134 #define SCSI 0x00 /* Interface ID */
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
,
142 int rts51x_scsi_handler(struct scsi_cmnd
*srb
, struct rts51x_chip
*chip
);
148 const char *host_info(struct Scsi_Host
*host
);
149 int slave_alloc(struct scsi_device
*sdev
);
150 int slave_configure(struct scsi_device
*sdev
);
151 int proc_info(struct Scsi_Host
*host
, char *buffer
,
152 char **start
, off_t offset
, int length
, int inout
);
153 #if 0 /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) */
154 int queuecommand(struct scsi_cmnd
*srb
, void (*done
) (struct scsi_cmnd
*));
156 int queuecommand(struct Scsi_Host
*, struct scsi_cmnd
*);
158 int command_abort(struct scsi_cmnd
*srb
);
159 int device_reset(struct scsi_cmnd
*srb
);
160 int bus_reset(struct scsi_cmnd
*srb
);
162 #endif /* __RTS51X_SCSI_H */