1
2 #ifndef _WD719X_H_
3 #define _WD719X_H_
4
5 #define WD719X_SG 255
6
7 struct wd719x_sglist {
8 __le32 ptr;
9 __le32 length;
10 } __packed;
11
12 enum wd719x_card_type {
13 WD719X_TYPE_UNKNOWN = 0,
14 WD719X_TYPE_7193,
15 WD719X_TYPE_7197,
16 WD719X_TYPE_7296,
17 };
18
19 union wd719x_regs {
20 __le32 all;
21 struct {
22 u8 OPC;
23 u8 SCSI;
24 u8 SUE;
25 u8 INT;
26 } bytes;
27 };
28
29
30 struct wd719x_scb {
31 __le32 Int_SCB;
32 u8 SCB_opcode;
33 u8 CDB_tag;
34 u8 lun;
35 u8 devid;
36 u8 CDB[16];
37 __le32 data_p;
38 __le32 data_length;
39 __le32 CDB_link;
40 __le32 sense_buf;
41 u8 sense_buf_length;
42 u8 reserved;
43 u8 SCB_options;
44 u8 SCB_tag_msg;
45
46 __le32 req_ptr;
47 u8 host_opcode;
48 u8 scsi_stat;
49 u8 ret_error;
50 u8 int_stat;
51 __le32 transferred;
52 u8 last_trans[3];
53 u8 length;
54 u8 sync_offset;
55 u8 sync_rate;
56 u8 flags[2];
57
58 dma_addr_t phys;
59 struct scsi_cmnd *cmd;
60 struct list_head list;
61 struct wd719x_sglist sg_list[WD719X_SG] __aligned(8);
62 } __packed;
63
64 struct wd719x {
65 struct Scsi_Host *sh;
66 struct pci_dev *pdev;
67 void __iomem *base;
68 enum wd719x_card_type type;
69 void *fw_virt;
70 dma_addr_t fw_phys;
71 size_t fw_size;
72 struct wd719x_host_param *params;
73 dma_addr_t params_phys;
74 void *hash_virt;
75 dma_addr_t hash_phys;
76 struct list_head active_scbs;
77 };
78
79
80 #define WD719X_WAIT_FOR_CMD_READY 500
81 #define WD719X_WAIT_FOR_RISC 2000
82 #define WD719X_WAIT_FOR_SCSI_RESET 3000000
83
84
85 #define WD719X_CMD_READY 0x00
86 #define WD719X_CMD_INIT_RISC 0x01
87
88 #define WD719X_CMD_BUSRESET 0x03
89 #define WD719X_CMD_READ_FIRMVER 0x04
90 #define WD719X_CMD_ECHO_BYTES 0x05
91
92
93 #define WD719X_CMD_GET_PARAM 0x08
94 #define WD719X_CMD_SET_PARAM 0x09
95 #define WD719X_CMD_SLEEP 0x0a
96 #define WD719X_CMD_READ_INIT 0x0b
97 #define WD719X_CMD_RESTORE_INIT 0x0c
98
99
100
101 #define WD719X_CMD_ABORT_TAG 0x10
102 #define WD719X_CMD_ABORT 0x11
103 #define WD719X_CMD_RESET 0x12
104 #define WD719X_CMD_INIT_SCAM 0x13
105 #define WD719X_CMD_GET_SYNC 0x14
106 #define WD719X_CMD_SET_SYNC 0x15
107 #define WD719X_CMD_GET_WIDTH 0x16
108 #define WD719X_CMD_SET_WIDTH 0x17
109 #define WD719X_CMD_GET_TAGS 0x18
110 #define WD719X_CMD_SET_TAGS 0x19
111 #define WD719X_CMD_GET_PARAM2 0x1a
112 #define WD719X_CMD_SET_PARAM2 0x1b
113
114 #define WD719X_CMD_PROCESS_SCB 0x80
115
116
117
118 #define WD719X_INT_NONE 0x00
119 #define WD719X_INT_NOERRORS 0x01
120 #define WD719X_INT_LINKNOERRORS 0x02
121 #define WD719X_INT_LINKNOSTATUS 0x03
122 #define WD719X_INT_ERRORSLOGGED 0x04
123 #define WD719X_INT_SPIDERFAILED 0x05
124 #define WD719X_INT_BADINT 0x80
125 #define WD719X_INT_PIOREADY 0xf0
126
127
128 #define WD719X_SUE_NOERRORS 0x00
129 #define WD719X_SUE_REJECTED 0x01
130 #define WD719X_SUE_SCBQFULL 0x02
131
132 #define WD719X_SUE_TERM 0x04
133 #define WD719X_SUE_CHAN1PAR 0x05
134 #define WD719X_SUE_CHAN1ABORT 0x06
135 #define WD719X_SUE_CHAN23PAR 0x07
136 #define WD719X_SUE_CHAN23ABORT 0x08
137 #define WD719X_SUE_TIMEOUT 0x10
138 #define WD719X_SUE_RESET 0x11
139 #define WD719X_SUE_BUSERROR 0x12
140 #define WD719X_SUE_WRONGWAY 0x13
141 #define WD719X_SUE_BADPHASE 0x14
142 #define WD719X_SUE_TOOLONG 0x15
143 #define WD719X_SUE_BUSFREE 0x16
144 #define WD719X_SUE_ARSDONE 0x17
145 #define WD719X_SUE_IGNORED 0x18
146 #define WD719X_SUE_WRONGTAGS 0x19
147 #define WD719X_SUE_BADTAGS 0x1a
148 #define WD719X_SUE_NOSCAMID 0x1b
149
150
151 #define WD719X_HASH_TABLE_SIZE 4096
152
153
154
155 #define WD719X_AMR_COMMAND 0x00
156 #define WD719X_AMR_CMD_PARAM 0x01
157 #define WD719X_AMR_CMD_PARAM_2 0x02
158 #define WD719X_AMR_CMD_PARAM_3 0x03
159 #define WD719X_AMR_SCB_IN 0x04
160
161 #define WD719X_AMR_BIOS_SHARE_INT 0x0f
162
163 #define WD719X_AMR_SCB_OUT 0x18
164 #define WD719X_AMR_OP_CODE 0x1c
165 #define WD719X_AMR_SCSI_STATUS 0x1d
166 #define WD719X_AMR_SCB_ERROR 0x1e
167 #define WD719X_AMR_INT_STATUS 0x1f
168
169 #define WD719X_DISABLE_INT 0x80
170
171
172 #define WD719X_SCB_FLAGS_CHECK_DIRECTION 0x01
173 #define WD719X_SCB_FLAGS_PCI_TO_SCSI 0x02
174 #define WD719X_SCB_FLAGS_AUTO_REQUEST_SENSE 0x10
175 #define WD719X_SCB_FLAGS_DO_SCATTER_GATHER 0x20
176 #define WD719X_SCB_FLAGS_NO_DISCONNECT 0x40
177
178
179
180 #define WD719X_PCI_GPIO_CONTROL 0x3C
181 #define WD719X_PCI_GPIO_DATA 0x3D
182 #define WD719X_PCI_PORT_RESET 0x3E
183 #define WD719X_PCI_MODE_SELECT 0x3F
184
185 #define WD719X_PCI_EXTERNAL_ADDR 0x60
186 #define WD719X_PCI_INTERNAL_ADDR 0x64
187 #define WD719X_PCI_DMA_TRANSFER_SIZE 0x66
188 #define WD719X_PCI_CHANNEL2_3CMD 0x68
189 #define WD719X_PCI_CHANNEL2_3STATUS 0x69
190
191 #define WD719X_GPIO_ID_BITS 0x0a
192 #define WD719X_PRAM_BASE_ADDR 0x00
193
194
195 #define WD719X_PCI_RESET 0x01
196 #define WD719X_ENABLE_ADVANCE_MODE 0x01
197
198 #define WD719X_START_CHANNEL2_3DMA 0x17
199 #define WD719X_START_CHANNEL2_3DONE 0x01
200 #define WD719X_START_CHANNEL2_3ABORT 0x20
201
202
203 #define WD719X_EE_DI (1 << 1)
204 #define WD719X_EE_CS (1 << 2)
205 #define WD719X_EE_CLK (1 << 3)
206 #define WD719X_EE_DO (1 << 4)
207
208
209 struct wd719x_eeprom_header {
210 u8 sig1;
211 u8 sig2;
212 u8 version;
213 u8 checksum;
214 u8 cfg_offset;
215 u8 cfg_size;
216 u8 setup_offset;
217 u8 setup_size;
218 } __packed;
219
220 #define WD719X_EE_SIG1 0
221 #define WD719X_EE_SIG2 1
222 #define WD719X_EE_VERSION 2
223 #define WD719X_EE_CHECKSUM 3
224 #define WD719X_EE_CFG_OFFSET 4
225 #define WD719X_EE_CFG_SIZE 5
226 #define WD719X_EE_SETUP_OFFSET 6
227 #define WD719X_EE_SETUP_SIZE 7
228
229 #define WD719X_EE_SCSI_ID_MASK 0xf
230
231
232 struct wd719x_host_param {
233 u8 ch_1_th;
234 u8 scsi_conf;
235 u8 own_scsi_id;
236 u8 sel_timeout;
237 u8 sleep_timer;
238 __le16 cdb_size;
239 __le16 tag_en;
240 u8 scsi_pad;
241 __le32 wide;
242 __le32 sync;
243 u8 soft_mask;
244 u8 unsol_mask;
245 } __packed;
246
247 #endif