1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 #include <linux/interrupt.h>
46 struct device_attribute;
47
48 #define ARCMSR_MAX_FREECCB_NUM 1024
49 #define ARCMSR_MAX_OUTSTANDING_CMD 1024
50 #define ARCMSR_DEFAULT_OUTSTANDING_CMD 128
51 #define ARCMSR_MIN_OUTSTANDING_CMD 32
52 #define ARCMSR_DRIVER_VERSION "v1.40.00.10-20190116"
53 #define ARCMSR_SCSI_INITIATOR_ID 255
54 #define ARCMSR_MAX_XFER_SECTORS 512
55 #define ARCMSR_MAX_XFER_SECTORS_B 4096
56 #define ARCMSR_MAX_XFER_SECTORS_C 304
57 #define ARCMSR_MAX_TARGETID 17
58 #define ARCMSR_MAX_TARGETLUN 8
59 #define ARCMSR_MAX_CMD_PERLUN 128
60 #define ARCMSR_DEFAULT_CMD_PERLUN 32
61 #define ARCMSR_MIN_CMD_PERLUN 1
62 #define ARCMSR_MAX_QBUFFER 4096
63 #define ARCMSR_DEFAULT_SG_ENTRIES 38
64 #define ARCMSR_MAX_HBB_POSTQUEUE 264
65 #define ARCMSR_MAX_ARC1214_POSTQUEUE 256
66 #define ARCMSR_MAX_ARC1214_DONEQUEUE 257
67 #define ARCMSR_MAX_HBE_DONEQUEUE 512
68 #define ARCMSR_MAX_XFER_LEN 0x26000
69 #define ARCMSR_CDB_SG_PAGE_LENGTH 256
70 #define ARCMST_NUM_MSIX_VECTORS 4
71 #ifndef PCI_DEVICE_ID_ARECA_1880
72 #define PCI_DEVICE_ID_ARECA_1880 0x1880
73 #endif
74 #ifndef PCI_DEVICE_ID_ARECA_1214
75 #define PCI_DEVICE_ID_ARECA_1214 0x1214
76 #endif
77 #ifndef PCI_DEVICE_ID_ARECA_1203
78 #define PCI_DEVICE_ID_ARECA_1203 0x1203
79 #endif
80 #ifndef PCI_DEVICE_ID_ARECA_1884
81 #define PCI_DEVICE_ID_ARECA_1884 0x1884
82 #endif
83 #define ARCMSR_HOURS (1000 * 60 * 60 * 4)
84 #define ARCMSR_MINUTES (1000 * 60 * 60)
85
86
87
88
89
90 #define ARC_SUCCESS 0
91 #define ARC_FAILURE 1
92
93
94
95
96
97 #define dma_addr_hi32(addr) (uint32_t) ((addr>>16)>>16)
98 #define dma_addr_lo32(addr) (uint32_t) (addr & 0xffffffff)
99
100
101
102
103
104 struct CMD_MESSAGE
105 {
106 uint32_t HeaderLength;
107 uint8_t Signature[8];
108 uint32_t Timeout;
109 uint32_t ControlCode;
110 uint32_t ReturnCode;
111 uint32_t Length;
112 };
113
114
115
116
117
118 #define ARCMSR_API_DATA_BUFLEN 1032
119 struct CMD_MESSAGE_FIELD
120 {
121 struct CMD_MESSAGE cmdmessage;
122 uint8_t messagedatabuffer[ARCMSR_API_DATA_BUFLEN];
123 };
124
125 #define ARCMSR_MESSAGE_FAIL 0x0001
126
127 #define ARECA_SATA_RAID 0x90000000
128
129 #define FUNCTION_READ_RQBUFFER 0x0801
130 #define FUNCTION_WRITE_WQBUFFER 0x0802
131 #define FUNCTION_CLEAR_RQBUFFER 0x0803
132 #define FUNCTION_CLEAR_WQBUFFER 0x0804
133 #define FUNCTION_CLEAR_ALLQBUFFER 0x0805
134 #define FUNCTION_RETURN_CODE_3F 0x0806
135 #define FUNCTION_SAY_HELLO 0x0807
136 #define FUNCTION_SAY_GOODBYE 0x0808
137 #define FUNCTION_FLUSH_ADAPTER_CACHE 0x0809
138 #define FUNCTION_GET_FIRMWARE_STATUS 0x080A
139 #define FUNCTION_HARDWARE_RESET 0x080B
140
141 #define ARCMSR_MESSAGE_READ_RQBUFFER \
142 ARECA_SATA_RAID | FUNCTION_READ_RQBUFFER
143 #define ARCMSR_MESSAGE_WRITE_WQBUFFER \
144 ARECA_SATA_RAID | FUNCTION_WRITE_WQBUFFER
145 #define ARCMSR_MESSAGE_CLEAR_RQBUFFER \
146 ARECA_SATA_RAID | FUNCTION_CLEAR_RQBUFFER
147 #define ARCMSR_MESSAGE_CLEAR_WQBUFFER \
148 ARECA_SATA_RAID | FUNCTION_CLEAR_WQBUFFER
149 #define ARCMSR_MESSAGE_CLEAR_ALLQBUFFER \
150 ARECA_SATA_RAID | FUNCTION_CLEAR_ALLQBUFFER
151 #define ARCMSR_MESSAGE_RETURN_CODE_3F \
152 ARECA_SATA_RAID | FUNCTION_RETURN_CODE_3F
153 #define ARCMSR_MESSAGE_SAY_HELLO \
154 ARECA_SATA_RAID | FUNCTION_SAY_HELLO
155 #define ARCMSR_MESSAGE_SAY_GOODBYE \
156 ARECA_SATA_RAID | FUNCTION_SAY_GOODBYE
157 #define ARCMSR_MESSAGE_FLUSH_ADAPTER_CACHE \
158 ARECA_SATA_RAID | FUNCTION_FLUSH_ADAPTER_CACHE
159
160 #define ARCMSR_MESSAGE_RETURNCODE_OK 0x00000001
161 #define ARCMSR_MESSAGE_RETURNCODE_ERROR 0x00000006
162 #define ARCMSR_MESSAGE_RETURNCODE_3F 0x0000003F
163 #define ARCMSR_MESSAGE_RETURNCODE_BUS_HANG_ON 0x00000088
164
165
166
167
168
169 #define IS_DMA64 (sizeof(dma_addr_t) == 8)
170 #define IS_SG64_ADDR 0x01000000
171 struct SG32ENTRY
172 {
173 __le32 length;
174 __le32 address;
175 }__attribute__ ((packed));
176 struct SG64ENTRY
177 {
178 __le32 length;
179 __le32 address;
180 __le32 addresshigh;
181 }__attribute__ ((packed));
182
183
184
185
186
187 struct QBUFFER
188 {
189 uint32_t data_len;
190 uint8_t data[124];
191 };
192
193
194
195
196
197 struct FIRMWARE_INFO
198 {
199 uint32_t signature;
200 uint32_t request_len;
201 uint32_t numbers_queue;
202 uint32_t sdram_size;
203 uint32_t ide_channels;
204 char vendor[40];
205 char model[8];
206 char firmware_ver[16];
207 char device_map[16];
208 uint32_t cfgVersion;
209 uint8_t cfgSerial[16];
210 uint32_t cfgPicStatus;
211 };
212
213 #define ARCMSR_SIGNATURE_GET_CONFIG 0x87974060
214 #define ARCMSR_SIGNATURE_SET_CONFIG 0x87974063
215
216 #define ARCMSR_INBOUND_MESG0_NOP 0x00000000
217 #define ARCMSR_INBOUND_MESG0_GET_CONFIG 0x00000001
218 #define ARCMSR_INBOUND_MESG0_SET_CONFIG 0x00000002
219 #define ARCMSR_INBOUND_MESG0_ABORT_CMD 0x00000003
220 #define ARCMSR_INBOUND_MESG0_STOP_BGRB 0x00000004
221 #define ARCMSR_INBOUND_MESG0_FLUSH_CACHE 0x00000005
222 #define ARCMSR_INBOUND_MESG0_START_BGRB 0x00000006
223 #define ARCMSR_INBOUND_MESG0_CHK331PENDING 0x00000007
224 #define ARCMSR_INBOUND_MESG0_SYNC_TIMER 0x00000008
225
226 #define ARCMSR_INBOUND_DRIVER_DATA_WRITE_OK 0x00000001
227 #define ARCMSR_INBOUND_DRIVER_DATA_READ_OK 0x00000002
228 #define ARCMSR_OUTBOUND_IOP331_DATA_WRITE_OK 0x00000001
229 #define ARCMSR_OUTBOUND_IOP331_DATA_READ_OK 0x00000002
230
231 #define ARCMSR_CCBPOST_FLAG_SGL_BSIZE 0x80000000
232 #define ARCMSR_CCBPOST_FLAG_IAM_BIOS 0x40000000
233 #define ARCMSR_CCBREPLY_FLAG_IAM_BIOS 0x40000000
234 #define ARCMSR_CCBREPLY_FLAG_ERROR_MODE0 0x10000000
235 #define ARCMSR_CCBREPLY_FLAG_ERROR_MODE1 0x00000001
236
237 #define ARCMSR_OUTBOUND_MESG1_FIRMWARE_OK 0x80000000
238
239 #define ARCMSR_ARC1680_BUS_RESET 0x00000003
240
241 #define ARCMSR_ARC1880_RESET_ADAPTER 0x00000024
242 #define ARCMSR_ARC1880_DiagWrite_ENABLE 0x00000080
243
244
245
246
247
248
249
250
251 #define ARCMSR_DRV2IOP_DOORBELL 0x00020400
252 #define ARCMSR_DRV2IOP_DOORBELL_MASK 0x00020404
253
254 #define ARCMSR_IOP2DRV_DOORBELL 0x00020408
255 #define ARCMSR_IOP2DRV_DOORBELL_MASK 0x0002040C
256
257 #define ARCMSR_IOP2DRV_DOORBELL_1203 0x00021870
258 #define ARCMSR_IOP2DRV_DOORBELL_MASK_1203 0x00021874
259
260 #define ARCMSR_DRV2IOP_DOORBELL_1203 0x00021878
261 #define ARCMSR_DRV2IOP_DOORBELL_MASK_1203 0x0002187C
262
263
264 #define ARCMSR_IOP2DRV_DATA_WRITE_OK 0x00000001
265
266 #define ARCMSR_IOP2DRV_DATA_READ_OK 0x00000002
267 #define ARCMSR_IOP2DRV_CDB_DONE 0x00000004
268 #define ARCMSR_IOP2DRV_MESSAGE_CMD_DONE 0x00000008
269
270 #define ARCMSR_DOORBELL_HANDLE_INT 0x0000000F
271 #define ARCMSR_DOORBELL_INT_CLEAR_PATTERN 0xFF00FFF0
272 #define ARCMSR_MESSAGE_INT_CLEAR_PATTERN 0xFF00FFF7
273
274 #define ARCMSR_MESSAGE_GET_CONFIG 0x00010008
275
276 #define ARCMSR_MESSAGE_SET_CONFIG 0x00020008
277
278 #define ARCMSR_MESSAGE_ABORT_CMD 0x00030008
279
280 #define ARCMSR_MESSAGE_STOP_BGRB 0x00040008
281
282 #define ARCMSR_MESSAGE_FLUSH_CACHE 0x00050008
283
284 #define ARCMSR_MESSAGE_START_BGRB 0x00060008
285 #define ARCMSR_MESSAGE_SYNC_TIMER 0x00080008
286 #define ARCMSR_MESSAGE_START_DRIVER_MODE 0x000E0008
287 #define ARCMSR_MESSAGE_SET_POST_WINDOW 0x000F0008
288 #define ARCMSR_MESSAGE_ACTIVE_EOI_MODE 0x00100008
289
290 #define ARCMSR_MESSAGE_FIRMWARE_OK 0x80000000
291
292 #define ARCMSR_DRV2IOP_DATA_WRITE_OK 0x00000001
293
294 #define ARCMSR_DRV2IOP_DATA_READ_OK 0x00000002
295 #define ARCMSR_DRV2IOP_CDB_POSTED 0x00000004
296 #define ARCMSR_DRV2IOP_MESSAGE_CMD_POSTED 0x00000008
297 #define ARCMSR_DRV2IOP_END_OF_INTERRUPT 0x00000010
298
299
300
301 #define ARCMSR_MESSAGE_WBUFFER 0x0000fe00
302
303 #define ARCMSR_MESSAGE_RBUFFER 0x0000ff00
304
305 #define ARCMSR_MESSAGE_RWBUFFER 0x0000fa00
306
307 #define MEM_BASE0(x) (u32 __iomem *)((unsigned long)acb->mem_base0 + x)
308 #define MEM_BASE1(x) (u32 __iomem *)((unsigned long)acb->mem_base1 + x)
309
310
311
312
313
314 #define ARCMSR_HBC_ISR_THROTTLING_LEVEL 12
315 #define ARCMSR_HBC_ISR_MAX_DONE_QUEUE 20
316
317 #define ARCMSR_HBCMU_UTILITY_A_ISR_MASK 0x00000001
318 #define ARCMSR_HBCMU_OUTBOUND_DOORBELL_ISR_MASK 0x00000004
319 #define ARCMSR_HBCMU_OUTBOUND_POSTQUEUE_ISR_MASK 0x00000008
320 #define ARCMSR_HBCMU_ALL_INTMASKENABLE 0x0000000D
321
322 #define ARCMSR_HBCMU_UTILITY_A_ISR 0x00000001
323
324
325
326
327 #define ARCMSR_HBCMU_OUTBOUND_DOORBELL_ISR 0x00000004
328
329
330
331
332
333
334 #define ARCMSR_HBCMU_OUTBOUND_POSTQUEUE_ISR 0x00000008
335
336
337
338
339
340 #define ARCMSR_HBCMU_SAS_ALL_INT 0x00000010
341
342
343
344
345
346 #define ARCMSR_HBCMU_DRV2IOP_DATA_WRITE_OK 0x00000002
347 #define ARCMSR_HBCMU_DRV2IOP_DATA_READ_OK 0x00000004
348
349 #define ARCMSR_HBCMU_DRV2IOP_MESSAGE_CMD_DONE 0x00000008
350
351 #define ARCMSR_HBCMU_DRV2IOP_POSTQUEUE_THROTTLING 0x00000010
352 #define ARCMSR_HBCMU_IOP2DRV_DATA_WRITE_OK 0x00000002
353
354 #define ARCMSR_HBCMU_IOP2DRV_DATA_WRITE_DOORBELL_CLEAR 0x00000002
355 #define ARCMSR_HBCMU_IOP2DRV_DATA_READ_OK 0x00000004
356
357 #define ARCMSR_HBCMU_IOP2DRV_DATA_READ_DOORBELL_CLEAR 0x00000004
358
359 #define ARCMSR_HBCMU_IOP2DRV_MESSAGE_CMD_DONE 0x00000008
360
361 #define ARCMSR_HBCMU_IOP2DRV_MESSAGE_CMD_DONE_DOORBELL_CLEAR 0x00000008
362
363 #define ARCMSR_HBCMU_MESSAGE_FIRMWARE_OK 0x80000000
364
365
366
367
368
369 #define ARCMSR_ARC1214_CHIP_ID 0x00004
370 #define ARCMSR_ARC1214_CPU_MEMORY_CONFIGURATION 0x00008
371 #define ARCMSR_ARC1214_I2_HOST_INTERRUPT_MASK 0x00034
372 #define ARCMSR_ARC1214_SAMPLE_RESET 0x00100
373 #define ARCMSR_ARC1214_RESET_REQUEST 0x00108
374 #define ARCMSR_ARC1214_MAIN_INTERRUPT_STATUS 0x00200
375 #define ARCMSR_ARC1214_PCIE_F0_INTERRUPT_ENABLE 0x0020C
376 #define ARCMSR_ARC1214_INBOUND_MESSAGE0 0x00400
377 #define ARCMSR_ARC1214_INBOUND_MESSAGE1 0x00404
378 #define ARCMSR_ARC1214_OUTBOUND_MESSAGE0 0x00420
379 #define ARCMSR_ARC1214_OUTBOUND_MESSAGE1 0x00424
380 #define ARCMSR_ARC1214_INBOUND_DOORBELL 0x00460
381 #define ARCMSR_ARC1214_OUTBOUND_DOORBELL 0x00480
382 #define ARCMSR_ARC1214_OUTBOUND_DOORBELL_ENABLE 0x00484
383 #define ARCMSR_ARC1214_INBOUND_LIST_BASE_LOW 0x01000
384 #define ARCMSR_ARC1214_INBOUND_LIST_BASE_HIGH 0x01004
385 #define ARCMSR_ARC1214_INBOUND_LIST_WRITE_POINTER 0x01018
386 #define ARCMSR_ARC1214_OUTBOUND_LIST_BASE_LOW 0x01060
387 #define ARCMSR_ARC1214_OUTBOUND_LIST_BASE_HIGH 0x01064
388 #define ARCMSR_ARC1214_OUTBOUND_LIST_COPY_POINTER 0x0106C
389 #define ARCMSR_ARC1214_OUTBOUND_LIST_READ_POINTER 0x01070
390 #define ARCMSR_ARC1214_OUTBOUND_INTERRUPT_CAUSE 0x01088
391 #define ARCMSR_ARC1214_OUTBOUND_INTERRUPT_ENABLE 0x0108C
392 #define ARCMSR_ARC1214_MESSAGE_WBUFFER 0x02000
393 #define ARCMSR_ARC1214_MESSAGE_RBUFFER 0x02100
394 #define ARCMSR_ARC1214_MESSAGE_RWBUFFER 0x02200
395
396 #define ARCMSR_ARC1214_ALL_INT_ENABLE 0x00001010
397 #define ARCMSR_ARC1214_ALL_INT_DISABLE 0x00000000
398
399 #define ARCMSR_ARC1214_OUTBOUND_DOORBELL_ISR 0x00001000
400 #define ARCMSR_ARC1214_OUTBOUND_POSTQUEUE_ISR 0x00000010
401
402 #define ARCMSR_ARC1214_DRV2IOP_DATA_IN_READY 0x00000001
403 #define ARCMSR_ARC1214_DRV2IOP_DATA_OUT_READ 0x00000002
404
405 #define ARCMSR_ARC1214_IOP2DRV_DATA_WRITE_OK 0x00000001
406
407 #define ARCMSR_ARC1214_IOP2DRV_DATA_READ_OK 0x00000002
408
409 #define ARCMSR_ARC1214_IOP2DRV_MESSAGE_CMD_DONE 0x02000000
410
411
412 #define ARCMSR_ARC1214_MESSAGE_FIRMWARE_OK 0x80000000
413 #define ARCMSR_ARC1214_OUTBOUND_LIST_INTERRUPT_CLEAR 0x00000001
414
415
416
417
418
419 #define ARCMSR_SIGNATURE_1884 0x188417D3
420
421 #define ARCMSR_HBEMU_DRV2IOP_DATA_WRITE_OK 0x00000002
422 #define ARCMSR_HBEMU_DRV2IOP_DATA_READ_OK 0x00000004
423 #define ARCMSR_HBEMU_DRV2IOP_MESSAGE_CMD_DONE 0x00000008
424
425 #define ARCMSR_HBEMU_IOP2DRV_DATA_WRITE_OK 0x00000002
426 #define ARCMSR_HBEMU_IOP2DRV_DATA_READ_OK 0x00000004
427 #define ARCMSR_HBEMU_IOP2DRV_MESSAGE_CMD_DONE 0x00000008
428
429 #define ARCMSR_HBEMU_MESSAGE_FIRMWARE_OK 0x80000000
430
431 #define ARCMSR_HBEMU_OUTBOUND_DOORBELL_ISR 0x00000001
432 #define ARCMSR_HBEMU_OUTBOUND_POSTQUEUE_ISR 0x00000008
433 #define ARCMSR_HBEMU_ALL_INTMASKENABLE 0x00000009
434
435
436 #define ARCMSR_HBEMU_DOORBELL_SYNC 0x100
437 #define ARCMSR_ARC188X_RESET_ADAPTER 0x00000004
438 #define ARCMSR_ARC1884_DiagWrite_ENABLE 0x00000080
439
440
441
442
443
444 struct ARCMSR_CDB
445 {
446 uint8_t Bus;
447 uint8_t TargetID;
448 uint8_t LUN;
449 uint8_t Function;
450 uint8_t CdbLength;
451 uint8_t sgcount;
452 uint8_t Flags;
453 #define ARCMSR_CDB_FLAG_SGL_BSIZE 0x01
454 #define ARCMSR_CDB_FLAG_BIOS 0x02
455 #define ARCMSR_CDB_FLAG_WRITE 0x04
456 #define ARCMSR_CDB_FLAG_SIMPLEQ 0x00
457 #define ARCMSR_CDB_FLAG_HEADQ 0x08
458 #define ARCMSR_CDB_FLAG_ORDEREDQ 0x10
459
460 uint8_t msgPages;
461 uint32_t msgContext;
462 uint32_t DataLength;
463 uint8_t Cdb[16];
464 uint8_t DeviceStatus;
465 #define ARCMSR_DEV_CHECK_CONDITION 0x02
466 #define ARCMSR_DEV_SELECT_TIMEOUT 0xF0
467 #define ARCMSR_DEV_ABORTED 0xF1
468 #define ARCMSR_DEV_INIT_FAIL 0xF2
469
470 uint8_t SenseData[15];
471 union
472 {
473 struct SG32ENTRY sg32entry[1];
474 struct SG64ENTRY sg64entry[1];
475 } u;
476 };
477
478
479
480
481
482 struct MessageUnit_A
483 {
484 uint32_t resrved0[4];
485 uint32_t inbound_msgaddr0;
486 uint32_t inbound_msgaddr1;
487 uint32_t outbound_msgaddr0;
488 uint32_t outbound_msgaddr1;
489 uint32_t inbound_doorbell;
490 uint32_t inbound_intstatus;
491 uint32_t inbound_intmask;
492 uint32_t outbound_doorbell;
493 uint32_t outbound_intstatus;
494 uint32_t outbound_intmask;
495 uint32_t reserved1[2];
496 uint32_t inbound_queueport;
497 uint32_t outbound_queueport;
498 uint32_t reserved2[2];
499 uint32_t reserved3[492];
500 uint32_t reserved4[128];
501 uint32_t message_rwbuffer[256];
502 uint32_t message_wbuffer[32];
503 uint32_t reserved5[32];
504 uint32_t message_rbuffer[32];
505 uint32_t reserved6[32];
506 };
507
508 struct MessageUnit_B
509 {
510 uint32_t post_qbuffer[ARCMSR_MAX_HBB_POSTQUEUE];
511 uint32_t done_qbuffer[ARCMSR_MAX_HBB_POSTQUEUE];
512 uint32_t postq_index;
513 uint32_t doneq_index;
514 uint32_t __iomem *drv2iop_doorbell;
515 uint32_t __iomem *drv2iop_doorbell_mask;
516 uint32_t __iomem *iop2drv_doorbell;
517 uint32_t __iomem *iop2drv_doorbell_mask;
518 uint32_t __iomem *message_rwbuffer;
519 uint32_t __iomem *message_wbuffer;
520 uint32_t __iomem *message_rbuffer;
521 };
522
523
524
525
526
527 struct MessageUnit_C{
528 uint32_t message_unit_status;
529 uint32_t slave_error_attribute;
530 uint32_t slave_error_address;
531 uint32_t posted_outbound_doorbell;
532 uint32_t master_error_attribute;
533 uint32_t master_error_address_low;
534 uint32_t master_error_address_high;
535 uint32_t hcb_size;
536 uint32_t inbound_doorbell;
537 uint32_t diagnostic_rw_data;
538 uint32_t diagnostic_rw_address_low;
539 uint32_t diagnostic_rw_address_high;
540 uint32_t host_int_status;
541 uint32_t host_int_mask;
542 uint32_t dcr_data;
543 uint32_t dcr_address;
544 uint32_t inbound_queueport;
545 uint32_t outbound_queueport;
546 uint32_t hcb_pci_address_low;
547 uint32_t hcb_pci_address_high;
548 uint32_t iop_int_status;
549 uint32_t iop_int_mask;
550 uint32_t iop_inbound_queue_port;
551 uint32_t iop_outbound_queue_port;
552 uint32_t inbound_free_list_index;
553 uint32_t inbound_post_list_index;
554 uint32_t outbound_free_list_index;
555 uint32_t outbound_post_list_index;
556 uint32_t inbound_doorbell_clear;
557 uint32_t i2o_message_unit_control;
558 uint32_t last_used_message_source_address_low;
559 uint32_t last_used_message_source_address_high;
560 uint32_t pull_mode_data_byte_count[4];
561 uint32_t message_dest_address_index;
562 uint32_t done_queue_not_empty_int_counter_timer;
563 uint32_t utility_A_int_counter_timer;
564 uint32_t outbound_doorbell;
565 uint32_t outbound_doorbell_clear;
566 uint32_t message_source_address_index;
567 uint32_t message_done_queue_index;
568 uint32_t reserved0;
569 uint32_t inbound_msgaddr0;
570 uint32_t inbound_msgaddr1;
571 uint32_t outbound_msgaddr0;
572 uint32_t outbound_msgaddr1;
573 uint32_t inbound_queueport_low;
574 uint32_t inbound_queueport_high;
575 uint32_t outbound_queueport_low;
576 uint32_t outbound_queueport_high;
577 uint32_t iop_inbound_queue_port_low;
578 uint32_t iop_inbound_queue_port_high;
579 uint32_t iop_outbound_queue_port_low;
580 uint32_t iop_outbound_queue_port_high;
581 uint32_t message_dest_queue_port_low;
582 uint32_t message_dest_queue_port_high;
583 uint32_t last_used_message_dest_address_low;
584 uint32_t last_used_message_dest_address_high;
585 uint32_t message_done_queue_base_address_low;
586 uint32_t message_done_queue_base_address_high;
587 uint32_t host_diagnostic;
588 uint32_t write_sequence;
589 uint32_t reserved1[34];
590 uint32_t reserved2[1950];
591 uint32_t message_wbuffer[32];
592 uint32_t reserved3[32];
593 uint32_t message_rbuffer[32];
594 uint32_t reserved4[32];
595 uint32_t msgcode_rwbuffer[256];
596 };
597
598
599
600
601
602 struct InBound_SRB {
603 uint32_t addressLow;
604 uint32_t addressHigh;
605 uint32_t length;
606 uint32_t reserved0;
607 };
608
609 struct OutBound_SRB {
610 uint32_t addressLow;
611 uint32_t addressHigh;
612 };
613
614 struct MessageUnit_D {
615 struct InBound_SRB post_qbuffer[ARCMSR_MAX_ARC1214_POSTQUEUE];
616 volatile struct OutBound_SRB
617 done_qbuffer[ARCMSR_MAX_ARC1214_DONEQUEUE];
618 u16 postq_index;
619 volatile u16 doneq_index;
620 u32 __iomem *chip_id;
621 u32 __iomem *cpu_mem_config;
622 u32 __iomem *i2o_host_interrupt_mask;
623 u32 __iomem *sample_at_reset;
624 u32 __iomem *reset_request;
625 u32 __iomem *host_int_status;
626 u32 __iomem *pcief0_int_enable;
627 u32 __iomem *inbound_msgaddr0;
628 u32 __iomem *inbound_msgaddr1;
629 u32 __iomem *outbound_msgaddr0;
630 u32 __iomem *outbound_msgaddr1;
631 u32 __iomem *inbound_doorbell;
632 u32 __iomem *outbound_doorbell;
633 u32 __iomem *outbound_doorbell_enable;
634 u32 __iomem *inboundlist_base_low;
635 u32 __iomem *inboundlist_base_high;
636 u32 __iomem *inboundlist_write_pointer;
637 u32 __iomem *outboundlist_base_low;
638 u32 __iomem *outboundlist_base_high;
639 u32 __iomem *outboundlist_copy_pointer;
640 u32 __iomem *outboundlist_read_pointer;
641 u32 __iomem *outboundlist_interrupt_cause;
642 u32 __iomem *outboundlist_interrupt_enable;
643 u32 __iomem *message_wbuffer;
644 u32 __iomem *message_rbuffer;
645 u32 __iomem *msgcode_rwbuffer;
646 };
647
648
649
650
651
652 struct MessageUnit_E{
653 uint32_t iobound_doorbell;
654 uint32_t write_sequence_3xxx;
655 uint32_t host_diagnostic_3xxx;
656 uint32_t posted_outbound_doorbell;
657 uint32_t master_error_attribute;
658 uint32_t master_error_address_low;
659 uint32_t master_error_address_high;
660 uint32_t hcb_size;
661 uint32_t inbound_doorbell;
662 uint32_t diagnostic_rw_data;
663 uint32_t diagnostic_rw_address_low;
664 uint32_t diagnostic_rw_address_high;
665 uint32_t host_int_status;
666 uint32_t host_int_mask;
667 uint32_t dcr_data;
668 uint32_t dcr_address;
669 uint32_t inbound_queueport;
670 uint32_t outbound_queueport;
671 uint32_t hcb_pci_address_low;
672 uint32_t hcb_pci_address_high;
673 uint32_t iop_int_status;
674 uint32_t iop_int_mask;
675 uint32_t iop_inbound_queue_port;
676 uint32_t iop_outbound_queue_port;
677 uint32_t inbound_free_list_index;
678 uint32_t inbound_post_list_index;
679 uint32_t reply_post_producer_index;
680 uint32_t reply_post_consumer_index;
681 uint32_t inbound_doorbell_clear;
682 uint32_t i2o_message_unit_control;
683 uint32_t last_used_message_source_address_low;
684 uint32_t last_used_message_source_address_high;
685 uint32_t pull_mode_data_byte_count[4];
686 uint32_t message_dest_address_index;
687 uint32_t done_queue_not_empty_int_counter_timer;
688 uint32_t utility_A_int_counter_timer;
689 uint32_t outbound_doorbell;
690 uint32_t outbound_doorbell_clear;
691 uint32_t message_source_address_index;
692 uint32_t message_done_queue_index;
693 uint32_t reserved0;
694 uint32_t inbound_msgaddr0;
695 uint32_t inbound_msgaddr1;
696 uint32_t outbound_msgaddr0;
697 uint32_t outbound_msgaddr1;
698 uint32_t inbound_queueport_low;
699 uint32_t inbound_queueport_high;
700 uint32_t outbound_queueport_low;
701 uint32_t outbound_queueport_high;
702 uint32_t iop_inbound_queue_port_low;
703 uint32_t iop_inbound_queue_port_high;
704 uint32_t iop_outbound_queue_port_low;
705 uint32_t iop_outbound_queue_port_high;
706 uint32_t message_dest_queue_port_low;
707 uint32_t message_dest_queue_port_high;
708 uint32_t last_used_message_dest_address_low;
709 uint32_t last_used_message_dest_address_high;
710 uint32_t message_done_queue_base_address_low;
711 uint32_t message_done_queue_base_address_high;
712 uint32_t host_diagnostic;
713 uint32_t write_sequence;
714 uint32_t reserved1[34];
715 uint32_t reserved2[1950];
716 uint32_t message_wbuffer[32];
717 uint32_t reserved3[32];
718 uint32_t message_rbuffer[32];
719 uint32_t reserved4[32];
720 uint32_t msgcode_rwbuffer[256];
721 };
722
723 typedef struct deliver_completeQ {
724 uint16_t cmdFlag;
725 uint16_t cmdSMID;
726 uint16_t cmdLMID;
727 uint16_t cmdFlag2;
728 } DeliverQ, CompletionQ, *pDeliver_Q, *pCompletion_Q;
729
730
731
732
733
734 struct AdapterControlBlock
735 {
736 uint32_t adapter_type;
737 #define ACB_ADAPTER_TYPE_A 0x00000000
738 #define ACB_ADAPTER_TYPE_B 0x00000001
739 #define ACB_ADAPTER_TYPE_C 0x00000002
740 #define ACB_ADAPTER_TYPE_D 0x00000003
741 #define ACB_ADAPTER_TYPE_E 0x00000004
742 u32 ioqueue_size;
743 struct pci_dev * pdev;
744 struct Scsi_Host * host;
745 unsigned long vir2phy_offset;
746
747 uint32_t outbound_int_enable;
748 uint32_t cdb_phyaddr_hi32;
749 uint32_t reg_mu_acc_handle0;
750 uint64_t cdb_phyadd_hipart;
751 spinlock_t eh_lock;
752 spinlock_t ccblist_lock;
753 spinlock_t postq_lock;
754 spinlock_t doneq_lock;
755 spinlock_t rqbuffer_lock;
756 spinlock_t wqbuffer_lock;
757 union {
758 struct MessageUnit_A __iomem *pmuA;
759 struct MessageUnit_B *pmuB;
760 struct MessageUnit_C __iomem *pmuC;
761 struct MessageUnit_D *pmuD;
762 struct MessageUnit_E __iomem *pmuE;
763 };
764
765 void __iomem *mem_base0;
766 void __iomem *mem_base1;
767 uint32_t acb_flags;
768 u16 dev_id;
769 uint8_t adapter_index;
770 #define ACB_F_SCSISTOPADAPTER 0x0001
771 #define ACB_F_MSG_STOP_BGRB 0x0002
772
773 #define ACB_F_MSG_START_BGRB 0x0004
774
775 #define ACB_F_IOPDATA_OVERFLOW 0x0008
776
777 #define ACB_F_MESSAGE_WQBUFFER_CLEARED 0x0010
778
779 #define ACB_F_MESSAGE_RQBUFFER_CLEARED 0x0020
780
781 #define ACB_F_MESSAGE_WQBUFFER_READED 0x0040
782 #define ACB_F_BUS_RESET 0x0080
783
784 #define ACB_F_IOP_INITED 0x0100
785
786 #define ACB_F_ABORT 0x0200
787 #define ACB_F_FIRMWARE_TRAP 0x0400
788 #define ACB_F_ADAPTER_REMOVED 0x0800
789 #define ACB_F_MSG_GET_CONFIG 0x1000
790 struct CommandControlBlock * pccb_pool[ARCMSR_MAX_FREECCB_NUM];
791
792 struct list_head ccb_free_list;
793
794
795 atomic_t ccboutstandingcount;
796
797
798
799 void * dma_coherent;
800
801 dma_addr_t dma_coherent_handle;
802
803 dma_addr_t dma_coherent_handle2;
804 void *dma_coherent2;
805 unsigned int uncache_size;
806 uint8_t rqbuffer[ARCMSR_MAX_QBUFFER];
807
808 int32_t rqbuf_getIndex;
809
810 int32_t rqbuf_putIndex;
811
812 uint8_t wqbuffer[ARCMSR_MAX_QBUFFER];
813
814 int32_t wqbuf_getIndex;
815
816 int32_t wqbuf_putIndex;
817
818 uint8_t devstate[ARCMSR_MAX_TARGETID][ARCMSR_MAX_TARGETLUN];
819
820 #define ARECA_RAID_GONE 0x55
821 #define ARECA_RAID_GOOD 0xaa
822 uint32_t num_resets;
823 uint32_t num_aborts;
824 uint32_t signature;
825 uint32_t firm_request_len;
826 uint32_t firm_numbers_queue;
827 uint32_t firm_sdram_size;
828 uint32_t firm_hd_channels;
829 uint32_t firm_cfg_version;
830 char firm_model[12];
831 char firm_version[20];
832 char device_map[20];
833 struct work_struct arcmsr_do_message_isr_bh;
834 struct timer_list eternal_timer;
835 unsigned short fw_flag;
836 #define FW_NORMAL 0x0000
837 #define FW_BOG 0x0001
838 #define FW_DEADLOCK 0x0010
839 atomic_t rq_map_token;
840 atomic_t ante_token_value;
841 uint32_t maxOutstanding;
842 int vector_count;
843 uint32_t maxFreeCCB;
844 struct timer_list refresh_timer;
845 uint32_t doneq_index;
846 uint32_t ccbsize;
847 uint32_t in_doorbell;
848 uint32_t out_doorbell;
849 uint32_t completionQ_entry;
850 pCompletion_Q pCompletionQ;
851 };
852
853
854
855
856
857
858 struct CommandControlBlock{
859
860 struct list_head list;
861 struct scsi_cmnd *pcmd;
862 struct AdapterControlBlock *acb;
863 unsigned long cdb_phyaddr;
864 uint32_t arc_cdb_size;
865 uint16_t ccb_flags;
866 #define CCB_FLAG_READ 0x0000
867 #define CCB_FLAG_WRITE 0x0001
868 #define CCB_FLAG_ERROR 0x0002
869 #define CCB_FLAG_FLUSHCACHE 0x0004
870 #define CCB_FLAG_MASTER_ABORTED 0x0008
871 uint16_t startdone;
872 #define ARCMSR_CCB_DONE 0x0000
873 #define ARCMSR_CCB_START 0x55AA
874 #define ARCMSR_CCB_ABORTED 0xAA55
875 #define ARCMSR_CCB_ILLEGAL 0xFFFF
876 uint32_t smid;
877 #if BITS_PER_LONG == 64
878
879 uint32_t reserved[3];
880 #else
881
882 uint32_t reserved[8];
883 #endif
884
885 struct ARCMSR_CDB arcmsr_cdb;
886 };
887
888
889
890
891
892 struct SENSE_DATA
893 {
894 uint8_t ErrorCode:7;
895 #define SCSI_SENSE_CURRENT_ERRORS 0x70
896 #define SCSI_SENSE_DEFERRED_ERRORS 0x71
897 uint8_t Valid:1;
898 uint8_t SegmentNumber;
899 uint8_t SenseKey:4;
900 uint8_t Reserved:1;
901 uint8_t IncorrectLength:1;
902 uint8_t EndOfMedia:1;
903 uint8_t FileMark:1;
904 uint8_t Information[4];
905 uint8_t AdditionalSenseLength;
906 uint8_t CommandSpecificInformation[4];
907 uint8_t AdditionalSenseCode;
908 uint8_t AdditionalSenseCodeQualifier;
909 uint8_t FieldReplaceableUnitCode;
910 uint8_t SenseKeySpecific[3];
911 };
912
913
914
915
916
917 #define ARCMSR_MU_OUTBOUND_INTERRUPT_STATUS_REG 0x30
918 #define ARCMSR_MU_OUTBOUND_PCI_INT 0x10
919 #define ARCMSR_MU_OUTBOUND_POSTQUEUE_INT 0x08
920 #define ARCMSR_MU_OUTBOUND_DOORBELL_INT 0x04
921 #define ARCMSR_MU_OUTBOUND_MESSAGE1_INT 0x02
922 #define ARCMSR_MU_OUTBOUND_MESSAGE0_INT 0x01
923 #define ARCMSR_MU_OUTBOUND_HANDLE_INT \
924 (ARCMSR_MU_OUTBOUND_MESSAGE0_INT \
925 |ARCMSR_MU_OUTBOUND_MESSAGE1_INT \
926 |ARCMSR_MU_OUTBOUND_DOORBELL_INT \
927 |ARCMSR_MU_OUTBOUND_POSTQUEUE_INT \
928 |ARCMSR_MU_OUTBOUND_PCI_INT)
929
930
931
932
933
934 #define ARCMSR_MU_OUTBOUND_INTERRUPT_MASK_REG 0x34
935 #define ARCMSR_MU_OUTBOUND_PCI_INTMASKENABLE 0x10
936 #define ARCMSR_MU_OUTBOUND_POSTQUEUE_INTMASKENABLE 0x08
937 #define ARCMSR_MU_OUTBOUND_DOORBELL_INTMASKENABLE 0x04
938 #define ARCMSR_MU_OUTBOUND_MESSAGE1_INTMASKENABLE 0x02
939 #define ARCMSR_MU_OUTBOUND_MESSAGE0_INTMASKENABLE 0x01
940 #define ARCMSR_MU_OUTBOUND_ALL_INTMASKENABLE 0x1F
941
942 extern void arcmsr_write_ioctldata2iop(struct AdapterControlBlock *);
943 extern uint32_t arcmsr_Read_iop_rqbuffer_data(struct AdapterControlBlock *,
944 struct QBUFFER __iomem *);
945 extern void arcmsr_clear_iop2drv_rqueue_buffer(struct AdapterControlBlock *);
946 extern struct QBUFFER __iomem *arcmsr_get_iop_rqbuffer(struct AdapterControlBlock *);
947 extern struct device_attribute *arcmsr_host_attrs[];
948 extern int arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *);
949 void arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb);