1 #define DRV_NAME "advansys"
2 #define ASC_VERSION "3.4"
24 #include <linux/module.h>
25 #include <linux/string.h>
26 #include <linux/kernel.h>
27 #include <linux/types.h>
31 #include <linux/slab.h>
38 #include <linux/pci.h>
49 #include <scsi/scsi.h>
71 #warning this driver is still not properly converted to the DMA API
74 #define ADVANSYS_STATS
88 #define ASC_PADDR __u32
89 #define ASC_VADDR __u32
90 #define ASC_DCNT __u32
91 #define ASC_SDCNT __s32
103 #define UW_ERR (uint)(0xFFFF)
104 #define isodd_word(val) ((((uint)val) & (uint)0x0001) != 0)
106 #define PCI_VENDOR_ID_ASP 0x10cd
107 #define PCI_DEVICE_ID_ASP_1200A 0x1100
108 #define PCI_DEVICE_ID_ASP_ABP940 0x1200
109 #define PCI_DEVICE_ID_ASP_ABP940U 0x1300
110 #define PCI_DEVICE_ID_ASP_ABP940UW 0x2300
111 #define PCI_DEVICE_ID_38C0800_REV1 0x2500
112 #define PCI_DEVICE_ID_38C1600_REV1 0x2700
120 #define CC_VERY_LONG_SG_LIST 0
121 #define ASC_SRB2SCSIQ(srb_ptr) (srb_ptr)
123 #define PortAddr unsigned int
124 #define inp(port) inb(port)
125 #define outp(port, byte) outb((byte), (port))
127 #define inpw(port) inw(port)
128 #define outpw(port, word) outw((word), (port))
130 #define ASC_MAX_SG_QUEUE 7
131 #define ASC_MAX_SG_LIST 255
133 #define ASC_CS_TYPE unsigned short
135 #define ASC_IS_ISA (0x0001)
136 #define ASC_IS_ISAPNP (0x0081)
137 #define ASC_IS_EISA (0x0002)
138 #define ASC_IS_PCI (0x0004)
139 #define ASC_IS_PCI_ULTRA (0x0104)
140 #define ASC_IS_PCMCIA (0x0008)
141 #define ASC_IS_MCA (0x0020)
142 #define ASC_IS_VL (0x0040)
143 #define ASC_IS_WIDESCSI_16 (0x0100)
144 #define ASC_IS_WIDESCSI_32 (0x0200)
145 #define ASC_IS_BIG_ENDIAN (0x8000)
147 #define ASC_CHIP_MIN_VER_VL (0x01)
148 #define ASC_CHIP_MAX_VER_VL (0x07)
149 #define ASC_CHIP_MIN_VER_PCI (0x09)
150 #define ASC_CHIP_MAX_VER_PCI (0x0F)
151 #define ASC_CHIP_VER_PCI_BIT (0x08)
152 #define ASC_CHIP_MIN_VER_ISA (0x11)
153 #define ASC_CHIP_MIN_VER_ISA_PNP (0x21)
154 #define ASC_CHIP_MAX_VER_ISA (0x27)
155 #define ASC_CHIP_VER_ISA_BIT (0x30)
156 #define ASC_CHIP_VER_ISAPNP_BIT (0x20)
157 #define ASC_CHIP_VER_ASYN_BUG (0x21)
158 #define ASC_CHIP_VER_PCI 0x08
159 #define ASC_CHIP_VER_PCI_ULTRA_3150 (ASC_CHIP_VER_PCI | 0x02)
160 #define ASC_CHIP_VER_PCI_ULTRA_3050 (ASC_CHIP_VER_PCI | 0x03)
161 #define ASC_CHIP_MIN_VER_EISA (0x41)
162 #define ASC_CHIP_MAX_VER_EISA (0x47)
163 #define ASC_CHIP_VER_EISA_BIT (0x40)
164 #define ASC_CHIP_LATEST_VER_EISA ((ASC_CHIP_MIN_VER_EISA - 1) + 3)
165 #define ASC_MAX_VL_DMA_COUNT (0x07FFFFFFL)
166 #define ASC_MAX_PCI_DMA_COUNT (0xFFFFFFFFL)
167 #define ASC_MAX_ISA_DMA_COUNT (0x00FFFFFFL)
169 #define ASC_SCSI_ID_BITS 3
170 #define ASC_SCSI_TIX_TYPE uchar
171 #define ASC_ALL_DEVICE_BIT_SET 0xFF
172 #define ASC_SCSI_BIT_ID_TYPE uchar
173 #define ASC_MAX_TID 7
174 #define ASC_MAX_LUN 7
175 #define ASC_SCSI_WIDTH_BIT_SET 0xFF
176 #define ASC_MAX_SENSE_LEN 32
177 #define ASC_MIN_SENSE_LEN 14
178 #define ASC_SCSI_RESET_HOLD_TIME_US 60
184 #define ASC_MAX_CDB_LEN 12
185 #define ADV_MAX_CDB_LEN 16
187 #define MS_SDTR_LEN 0x03
188 #define MS_WDTR_LEN 0x02
190 #define ASC_SG_LIST_PER_Q 7
192 #define QS_READY 0x01
193 #define QS_DISC1 0x02
194 #define QS_DISC2 0x04
196 #define QS_ABORTED 0x40
198 #define QC_NO_CALLBACK 0x01
199 #define QC_SG_SWAP_QUEUE 0x02
200 #define QC_SG_HEAD 0x04
201 #define QC_DATA_IN 0x08
202 #define QC_DATA_OUT 0x10
203 #define QC_URGENT 0x20
204 #define QC_MSG_OUT 0x40
205 #define QC_REQ_SENSE 0x80
206 #define QCSG_SG_XFER_LIST 0x02
207 #define QCSG_SG_XFER_MORE 0x04
208 #define QCSG_SG_XFER_END 0x08
209 #define QD_IN_PROGRESS 0x00
210 #define QD_NO_ERROR 0x01
211 #define QD_ABORTED_BY_HOST 0x02
212 #define QD_WITH_ERROR 0x04
213 #define QD_INVALID_REQUEST 0x80
214 #define QD_INVALID_HOST_NUM 0x81
215 #define QD_INVALID_DEVICE 0x82
216 #define QD_ERR_INTERNAL 0xFF
217 #define QHSTA_NO_ERROR 0x00
218 #define QHSTA_M_SEL_TIMEOUT 0x11
219 #define QHSTA_M_DATA_OVER_RUN 0x12
220 #define QHSTA_M_DATA_UNDER_RUN 0x12
221 #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
222 #define QHSTA_M_BAD_BUS_PHASE_SEQ 0x14
223 #define QHSTA_D_QDONE_SG_LIST_CORRUPTED 0x21
224 #define QHSTA_D_ASC_DVC_ERROR_CODE_SET 0x22
225 #define QHSTA_D_HOST_ABORT_FAILED 0x23
226 #define QHSTA_D_EXE_SCSI_Q_FAILED 0x24
227 #define QHSTA_D_EXE_SCSI_Q_BUSY_TIMEOUT 0x25
228 #define QHSTA_D_ASPI_NO_BUF_POOL 0x26
229 #define QHSTA_M_WTM_TIMEOUT 0x41
230 #define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
231 #define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
232 #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
233 #define QHSTA_M_TARGET_STATUS_BUSY 0x45
234 #define QHSTA_M_BAD_TAG_CODE 0x46
235 #define QHSTA_M_BAD_QUEUE_FULL_OR_BUSY 0x47
236 #define QHSTA_M_HUNG_REQ_SCSI_BUS_RESET 0x48
237 #define QHSTA_D_LRAM_CMP_ERROR 0x81
238 #define QHSTA_M_MICRO_CODE_ERROR_HALT 0xA1
239 #define ASC_FLAG_SCSIQ_REQ 0x01
240 #define ASC_FLAG_BIOS_SCSIQ_REQ 0x02
241 #define ASC_FLAG_BIOS_ASYNC_IO 0x04
242 #define ASC_FLAG_SRB_LINEAR_ADDR 0x08
243 #define ASC_FLAG_WIN16 0x10
244 #define ASC_FLAG_WIN32 0x20
245 #define ASC_FLAG_ISA_OVER_16MB 0x40
246 #define ASC_FLAG_DOS_VM_CALLBACK 0x80
247 #define ASC_TAG_FLAG_EXTRA_BYTES 0x10
248 #define ASC_TAG_FLAG_DISABLE_DISCONNECT 0x04
249 #define ASC_TAG_FLAG_DISABLE_ASYN_USE_SYN_FIX 0x08
250 #define ASC_TAG_FLAG_DISABLE_CHK_COND_INT_HOST 0x40
251 #define ASC_SCSIQ_CPY_BEG 4
252 #define ASC_SCSIQ_SGHD_CPY_BEG 2
253 #define ASC_SCSIQ_B_FWD 0
254 #define ASC_SCSIQ_B_BWD 1
255 #define ASC_SCSIQ_B_STATUS 2
256 #define ASC_SCSIQ_B_QNO 3
257 #define ASC_SCSIQ_B_CNTL 4
258 #define ASC_SCSIQ_B_SG_QUEUE_CNT 5
259 #define ASC_SCSIQ_D_DATA_ADDR 8
260 #define ASC_SCSIQ_D_DATA_CNT 12
261 #define ASC_SCSIQ_B_SENSE_LEN 20
262 #define ASC_SCSIQ_DONE_INFO_BEG 22
263 #define ASC_SCSIQ_D_SRBPTR 22
264 #define ASC_SCSIQ_B_TARGET_IX 26
265 #define ASC_SCSIQ_B_CDB_LEN 28
266 #define ASC_SCSIQ_B_TAG_CODE 29
267 #define ASC_SCSIQ_W_VM_ID 30
268 #define ASC_SCSIQ_DONE_STATUS 32
269 #define ASC_SCSIQ_HOST_STATUS 33
270 #define ASC_SCSIQ_SCSI_STATUS 34
271 #define ASC_SCSIQ_CDB_BEG 36
272 #define ASC_SCSIQ_DW_REMAIN_XFER_ADDR 56
273 #define ASC_SCSIQ_DW_REMAIN_XFER_CNT 60
274 #define ASC_SCSIQ_B_FIRST_SG_WK_QP 48
275 #define ASC_SCSIQ_B_SG_WK_QP 49
276 #define ASC_SCSIQ_B_SG_WK_IX 50
277 #define ASC_SCSIQ_W_ALT_DC1 52
278 #define ASC_SCSIQ_B_LIST_CNT 6
279 #define ASC_SCSIQ_B_CUR_LIST_CNT 7
280 #define ASC_SGQ_B_SG_CNTL 4
281 #define ASC_SGQ_B_SG_HEAD_QP 5
282 #define ASC_SGQ_B_SG_LIST_CNT 6
283 #define ASC_SGQ_B_SG_CUR_LIST_CNT 7
284 #define ASC_SGQ_LIST_BEG 8
285 #define ASC_DEF_SCSI1_QNG 4
286 #define ASC_MAX_SCSI1_QNG 4
287 #define ASC_DEF_SCSI2_QNG 16
288 #define ASC_MAX_SCSI2_QNG 32
289 #define ASC_TAG_CODE_MASK 0x23
290 #define ASC_STOP_REQ_RISC_STOP 0x01
291 #define ASC_STOP_ACK_RISC_STOP 0x03
292 #define ASC_STOP_CLEAN_UP_BUSY_Q 0x10
293 #define ASC_STOP_CLEAN_UP_DISC_Q 0x20
294 #define ASC_STOP_HOST_REQ_RISC_HALT 0x40
295 #define ASC_TIDLUN_TO_IX(tid, lun) (ASC_SCSI_TIX_TYPE)((tid) + ((lun)<<ASC_SCSI_ID_BITS))
296 #define ASC_TID_TO_TARGET_ID(tid) (ASC_SCSI_BIT_ID_TYPE)(0x01 << (tid))
297 #define ASC_TIX_TO_TARGET_ID(tix) (0x01 << ((tix) & ASC_MAX_TID))
298 #define ASC_TIX_TO_TID(tix) ((tix) & ASC_MAX_TID)
299 #define ASC_TID_TO_TIX(tid) ((tid) & ASC_MAX_TID)
300 #define ASC_TIX_TO_LUN(tix) (((tix) >> ASC_SCSI_ID_BITS) & ASC_MAX_LUN)
301 #define ASC_QNO_TO_QADDR(q_no) ((ASC_QADR_BEG)+((int)(q_no) << 6))
426 #define ASCQ_ERR_Q_STATUS 0x0D
427 #define ASCQ_ERR_CUR_QNG 0x17
428 #define ASCQ_ERR_SG_Q_LINKS 0x18
429 #define ASCQ_ERR_ISR_RE_ENTRY 0x1A
430 #define ASCQ_ERR_CRITICAL_RE_ENTRY 0x1B
431 #define ASCQ_ERR_ISR_ON_CRITICAL 0x1C
436 #define ASC_WARN_NO_ERROR 0x0000
437 #define ASC_WARN_IO_PORT_ROTATE 0x0001
438 #define ASC_WARN_EEPROM_CHKSUM 0x0002
439 #define ASC_WARN_IRQ_MODIFIED 0x0004
440 #define ASC_WARN_AUTO_CONFIG 0x0008
441 #define ASC_WARN_CMD_QNG_CONFLICT 0x0010
442 #define ASC_WARN_EEPROM_RECOVER 0x0020
443 #define ASC_WARN_CFG_MSW_RECOVER 0x0040
448 #define ASC_IERR_NO_CARRIER 0x0001
449 #define ASC_IERR_MCODE_CHKSUM 0x0002
450 #define ASC_IERR_SET_PC_ADDR 0x0004
451 #define ASC_IERR_START_STOP_CHIP 0x0008
452 #define ASC_IERR_ILLEGAL_CONNECTION 0x0010
453 #define ASC_IERR_SINGLE_END_DEVICE 0x0020
454 #define ASC_IERR_REVERSED_CABLE 0x0040
455 #define ASC_IERR_SET_SCSI_ID 0x0080
456 #define ASC_IERR_HVD_DEVICE 0x0100
457 #define ASC_IERR_BAD_SIGNATURE 0x0200
458 #define ASC_IERR_NO_BUS_TYPE 0x0400
459 #define ASC_IERR_BIST_PRE_TEST 0x0800
460 #define ASC_IERR_BIST_RAM_TEST 0x1000
461 #define ASC_IERR_BAD_CHIPTYPE 0x2000
463 #define ASC_DEF_MAX_TOTAL_QNG (0xF0)
464 #define ASC_MIN_TAG_Q_PER_DVC (0x04)
465 #define ASC_MIN_FREE_Q (0x02)
466 #define ASC_MIN_TOTAL_QNG ((ASC_MAX_SG_QUEUE)+(ASC_MIN_FREE_Q))
467 #define ASC_MAX_TOTAL_QNG 240
468 #define ASC_MAX_PCI_ULTRA_INRAM_TOTAL_QNG 16
469 #define ASC_MAX_PCI_ULTRA_INRAM_TAG_QNG 8
470 #define ASC_MAX_PCI_INRAM_TOTAL_QNG 20
471 #define ASC_MAX_INRAM_TAG_QNG 16
472 #define ASC_IOADR_GAP 0x10
473 #define ASC_SYN_MAX_OFFSET 0x0F
474 #define ASC_DEF_SDTR_OFFSET 0x0F
475 #define ASC_SDTR_ULTRA_PCI_10MB_INDEX 0x02
476 #define ASYN_SDTR_DATA_FIX_PCI_REV_AB 0x41
482 static const unsigned char asc_syn_xfer_period[8] = {
483 25, 30, 35, 40, 50, 60, 70, 85
486 static const unsigned char asc_syn_ultra_xfer_period[16] = {
487 12, 19, 25, 32, 38, 44, 50, 57, 63, 69, 75, 82, 88, 94, 100, 107
512 #define xfer_period u_ext_msg.sdtr.sdtr_xfer_period
513 #define req_ack_offset u_ext_msg.sdtr.sdtr_req_ack_offset
514 #define wdtr_width u_ext_msg.wdtr.wdtr_width
515 #define mdp_b3 u_ext_msg.mdp_b3
516 #define mdp_b2 u_ext_msg.mdp_b2
517 #define mdp_b1 u_ext_msg.mdp_b1
518 #define mdp_b0 u_ext_msg.mdp_b0
536 #define ASC_DEF_DVC_CNTL 0xFFFF
537 #define ASC_DEF_CHIP_SCSI_ID 7
538 #define ASC_DEF_ISA_DMA_SPEED 4
539 #define ASC_INIT_STATE_BEG_GET_CFG 0x0001
540 #define ASC_INIT_STATE_END_GET_CFG 0x0002
541 #define ASC_INIT_STATE_BEG_SET_CFG 0x0004
542 #define ASC_INIT_STATE_END_SET_CFG 0x0008
543 #define ASC_INIT_STATE_BEG_LOAD_MC 0x0010
544 #define ASC_INIT_STATE_END_LOAD_MC 0x0020
545 #define ASC_INIT_STATE_BEG_INQUIRY 0x0040
546 #define ASC_INIT_STATE_END_INQUIRY 0x0080
547 #define ASC_INIT_RESET_SCSI_DONE 0x0100
548 #define ASC_INIT_STATE_WITHOUT_EEP 0x8000
549 #define ASC_BUG_FIX_IF_NOT_DWB 0x0001
550 #define ASC_BUG_FIX_ASYN_USE_SYN 0x0002
551 #define ASC_MIN_TAGGED_CMD 7
552 #define ASC_MAX_SCSI_RESET_WAIT 30
553 #define ASC_OVERRUN_BSIZE 64
613 #define ASC_MCNTL_NO_SEL_TIMEOUT (ushort)0x0001
614 #define ASC_MCNTL_NULL_TARGET (ushort)0x0002
615 #define ASC_CNTL_INITIATOR (ushort)0x0001
616 #define ASC_CNTL_BIOS_GT_1GB (ushort)0x0002
617 #define ASC_CNTL_BIOS_GT_2_DISK (ushort)0x0004
618 #define ASC_CNTL_BIOS_REMOVABLE (ushort)0x0008
619 #define ASC_CNTL_NO_SCAM (ushort)0x0010
620 #define ASC_CNTL_INT_MULTI_Q (ushort)0x0080
621 #define ASC_CNTL_NO_LUN_SUPPORT (ushort)0x0040
622 #define ASC_CNTL_NO_VERIFY_COPY (ushort)0x0100
623 #define ASC_CNTL_RESET_SCSI (ushort)0x0200
624 #define ASC_CNTL_INIT_INQUIRY (ushort)0x0400
625 #define ASC_CNTL_INIT_VERBOSE (ushort)0x0800
626 #define ASC_CNTL_SCSI_PARITY (ushort)0x1000
627 #define ASC_CNTL_BURST_MODE (ushort)0x2000
628 #define ASC_CNTL_SDTR_ENABLE_ULTRA (ushort)0x4000
629 #define ASC_EEP_DVC_CFG_BEG_VL 2
630 #define ASC_EEP_MAX_DVC_ADDR_VL 15
631 #define ASC_EEP_DVC_CFG_BEG 32
632 #define ASC_EEP_MAX_DVC_ADDR 45
633 #define ASC_EEP_MAX_RETRY 20
642 #define ASC_EEP_GET_CHIP_ID(cfg) ((cfg)->id_speed & 0x0f)
643 #define ASC_EEP_GET_DMA_SPD(cfg) (((cfg)->id_speed & 0xf0) >> 4)
644 #define ASC_EEP_SET_CHIP_ID(cfg, sid) \
645 ((cfg)->id_speed = ((cfg)->id_speed & 0xf0) | ((sid) & ASC_MAX_TID))
646 #define ASC_EEP_SET_DMA_SPD(cfg, spd) \
647 ((cfg)->id_speed = ((cfg)->id_speed & 0x0f) | ((spd) & 0x0f) << 4)
669 #define ASC_EEP_CMD_READ 0x80
670 #define ASC_EEP_CMD_WRITE 0x40
671 #define ASC_EEP_CMD_WRITE_ABLE 0x30
672 #define ASC_EEP_CMD_WRITE_DISABLE 0x00
673 #define ASCV_MSGOUT_BEG 0x0000
674 #define ASCV_MSGOUT_SDTR_PERIOD (ASCV_MSGOUT_BEG+3)
675 #define ASCV_MSGOUT_SDTR_OFFSET (ASCV_MSGOUT_BEG+4)
676 #define ASCV_BREAK_SAVED_CODE (ushort)0x0006
677 #define ASCV_MSGIN_BEG (ASCV_MSGOUT_BEG+8)
678 #define ASCV_MSGIN_SDTR_PERIOD (ASCV_MSGIN_BEG+3)
679 #define ASCV_MSGIN_SDTR_OFFSET (ASCV_MSGIN_BEG+4)
680 #define ASCV_SDTR_DATA_BEG (ASCV_MSGIN_BEG+8)
681 #define ASCV_SDTR_DONE_BEG (ASCV_SDTR_DATA_BEG+8)
682 #define ASCV_MAX_DVC_QNG_BEG (ushort)0x0020
683 #define ASCV_BREAK_ADDR (ushort)0x0028
684 #define ASCV_BREAK_NOTIFY_COUNT (ushort)0x002A
685 #define ASCV_BREAK_CONTROL (ushort)0x002C
686 #define ASCV_BREAK_HIT_COUNT (ushort)0x002E
688 #define ASCV_ASCDVC_ERR_CODE_W (ushort)0x0030
689 #define ASCV_MCODE_CHKSUM_W (ushort)0x0032
690 #define ASCV_MCODE_SIZE_W (ushort)0x0034
691 #define ASCV_STOP_CODE_B (ushort)0x0036
692 #define ASCV_DVC_ERR_CODE_B (ushort)0x0037
693 #define ASCV_OVERRUN_PADDR_D (ushort)0x0038
694 #define ASCV_OVERRUN_BSIZE_D (ushort)0x003C
695 #define ASCV_HALTCODE_W (ushort)0x0040
696 #define ASCV_CHKSUM_W (ushort)0x0042
697 #define ASCV_MC_DATE_W (ushort)0x0044
698 #define ASCV_MC_VER_W (ushort)0x0046
699 #define ASCV_NEXTRDY_B (ushort)0x0048
700 #define ASCV_DONENEXT_B (ushort)0x0049
701 #define ASCV_USE_TAGGED_QNG_B (ushort)0x004A
702 #define ASCV_SCSIBUSY_B (ushort)0x004B
703 #define ASCV_Q_DONE_IN_PROGRESS_B (ushort)0x004C
704 #define ASCV_CURCDB_B (ushort)0x004D
705 #define ASCV_RCLUN_B (ushort)0x004E
706 #define ASCV_BUSY_QHEAD_B (ushort)0x004F
707 #define ASCV_DISC1_QHEAD_B (ushort)0x0050
708 #define ASCV_DISC_ENABLE_B (ushort)0x0052
709 #define ASCV_CAN_TAGGED_QNG_B (ushort)0x0053
710 #define ASCV_HOSTSCSI_ID_B (ushort)0x0055
711 #define ASCV_MCODE_CNTL_B (ushort)0x0056
712 #define ASCV_NULL_TARGET_B (ushort)0x0057
713 #define ASCV_FREE_Q_HEAD_W (ushort)0x0058
714 #define ASCV_DONE_Q_TAIL_W (ushort)0x005A
715 #define ASCV_FREE_Q_HEAD_B (ushort)(ASCV_FREE_Q_HEAD_W+1)
716 #define ASCV_DONE_Q_TAIL_B (ushort)(ASCV_DONE_Q_TAIL_W+1)
717 #define ASCV_HOST_FLAG_B (ushort)0x005D
718 #define ASCV_TOTAL_READY_Q_B (ushort)0x0064
719 #define ASCV_VER_SERIAL_B (ushort)0x0065
720 #define ASCV_HALTCODE_SAVED_W (ushort)0x0066
721 #define ASCV_WTM_FLAG_B (ushort)0x0068
722 #define ASCV_RISC_FLAG_B (ushort)0x006A
723 #define ASCV_REQ_SG_LIST_QP (ushort)0x006B
724 #define ASC_HOST_FLAG_IN_ISR 0x01
725 #define ASC_HOST_FLAG_ACK_INT 0x02
726 #define ASC_RISC_FLAG_GEN_INT 0x01
727 #define ASC_RISC_FLAG_REQ_SG_LIST 0x02
728 #define IOP_CTRL (0x0F)
729 #define IOP_STATUS (0x0E)
730 #define IOP_INT_ACK IOP_STATUS
731 #define IOP_REG_IFC (0x0D)
732 #define IOP_SYN_OFFSET (0x0B)
733 #define IOP_EXTRA_CONTROL (0x0D)
734 #define IOP_REG_PC (0x0C)
735 #define IOP_RAM_ADDR (0x0A)
736 #define IOP_RAM_DATA (0x08)
737 #define IOP_EEP_DATA (0x06)
738 #define IOP_EEP_CMD (0x07)
739 #define IOP_VERSION (0x03)
740 #define IOP_CONFIG_HIGH (0x04)
741 #define IOP_CONFIG_LOW (0x02)
742 #define IOP_SIG_BYTE (0x01)
743 #define IOP_SIG_WORD (0x00)
744 #define IOP_REG_DC1 (0x0E)
745 #define IOP_REG_DC0 (0x0C)
746 #define IOP_REG_SB (0x0B)
747 #define IOP_REG_DA1 (0x0A)
748 #define IOP_REG_DA0 (0x08)
749 #define IOP_REG_SC (0x09)
750 #define IOP_DMA_SPEED (0x07)
751 #define IOP_REG_FLAG (0x07)
752 #define IOP_FIFO_H (0x06)
753 #define IOP_FIFO_L (0x04)
754 #define IOP_REG_ID (0x05)
755 #define IOP_REG_QP (0x03)
756 #define IOP_REG_IH (0x02)
757 #define IOP_REG_IX (0x01)
758 #define IOP_REG_AX (0x00)
759 #define IFC_REG_LOCK (0x00)
760 #define IFC_REG_UNLOCK (0x09)
761 #define IFC_WR_EN_FILTER (0x10)
762 #define IFC_RD_NO_EEPROM (0x10)
763 #define IFC_SLEW_RATE (0x20)
764 #define IFC_ACT_NEG (0x40)
765 #define IFC_INP_FILTER (0x80)
766 #define IFC_INIT_DEFAULT (IFC_ACT_NEG | IFC_REG_UNLOCK)
767 #define SC_SEL (uchar)(0x80)
768 #define SC_BSY (uchar)(0x40)
769 #define SC_ACK (uchar)(0x20)
770 #define SC_REQ (uchar)(0x10)
771 #define SC_ATN (uchar)(0x08)
772 #define SC_IO (uchar)(0x04)
773 #define SC_CD (uchar)(0x02)
774 #define SC_MSG (uchar)(0x01)
775 #define SEC_SCSI_CTL (uchar)(0x80)
776 #define SEC_ACTIVE_NEGATE (uchar)(0x40)
777 #define SEC_SLEW_RATE (uchar)(0x20)
778 #define SEC_ENABLE_FILTER (uchar)(0x10)
779 #define ASC_HALT_EXTMSG_IN (ushort)0x8000
780 #define ASC_HALT_CHK_CONDITION (ushort)0x8100
781 #define ASC_HALT_SS_QUEUE_FULL (ushort)0x8200
782 #define ASC_HALT_DISABLE_ASYN_USE_SYN_FIX (ushort)0x8300
783 #define ASC_HALT_ENABLE_ASYN_USE_SYN_FIX (ushort)0x8400
784 #define ASC_HALT_SDTR_REJECTED (ushort)0x4000
785 #define ASC_HALT_HOST_COPY_SG_LIST_TO_RISC ( ushort )0x2000
786 #define ASC_MAX_QNO 0xF8
787 #define ASC_DATA_SEC_BEG (ushort)0x0080
788 #define ASC_DATA_SEC_END (ushort)0x0080
789 #define ASC_CODE_SEC_BEG (ushort)0x0080
790 #define ASC_CODE_SEC_END (ushort)0x0080
791 #define ASC_QADR_BEG (0x4000)
792 #define ASC_QADR_USED (ushort)(ASC_MAX_QNO * 64)
793 #define ASC_QADR_END (ushort)0x7FFF
794 #define ASC_QLAST_ADR (ushort)0x7FC0
795 #define ASC_QBLK_SIZE 0x40
796 #define ASC_BIOS_DATA_QBEG 0xF8
797 #define ASC_MIN_ACTIVE_QNO 0x01
798 #define ASC_QLINK_END 0xFF
799 #define ASC_EEPROM_WORDS 0x10
800 #define ASC_MAX_MGS_LEN 0x10
801 #define ASC_BIOS_ADDR_DEF 0xDC00
802 #define ASC_BIOS_SIZE 0x3800
803 #define ASC_BIOS_RAM_OFF 0x3800
804 #define ASC_BIOS_RAM_SIZE 0x800
805 #define ASC_BIOS_MIN_ADDR 0xC000
806 #define ASC_BIOS_MAX_ADDR 0xEC00
807 #define ASC_BIOS_BANK_SIZE 0x0400
808 #define ASC_MCODE_START_ADDR 0x0080
809 #define ASC_CFG0_HOST_INT_ON 0x0020
810 #define ASC_CFG0_BIOS_ON 0x0040
811 #define ASC_CFG0_VERA_BURST_ON 0x0080
812 #define ASC_CFG0_SCSI_PARITY_ON 0x0800
813 #define ASC_CFG1_SCSI_TARGET_ON 0x0080
814 #define ASC_CFG1_LRAM_8BITS_ON 0x0800
815 #define ASC_CFG_MSW_CLR_MASK 0x3080
816 #define CSW_TEST1 (ASC_CS_TYPE)0x8000
817 #define CSW_AUTO_CONFIG (ASC_CS_TYPE)0x4000
818 #define CSW_RESERVED1 (ASC_CS_TYPE)0x2000
819 #define CSW_IRQ_WRITTEN (ASC_CS_TYPE)0x1000
820 #define CSW_33MHZ_SELECTED (ASC_CS_TYPE)0x0800
821 #define CSW_TEST2 (ASC_CS_TYPE)0x0400
822 #define CSW_TEST3 (ASC_CS_TYPE)0x0200
823 #define CSW_RESERVED2 (ASC_CS_TYPE)0x0100
824 #define CSW_DMA_DONE (ASC_CS_TYPE)0x0080
825 #define CSW_FIFO_RDY (ASC_CS_TYPE)0x0040
826 #define CSW_EEP_READ_DONE (ASC_CS_TYPE)0x0020
827 #define CSW_HALTED (ASC_CS_TYPE)0x0010
828 #define CSW_SCSI_RESET_ACTIVE (ASC_CS_TYPE)0x0008
829 #define CSW_PARITY_ERR (ASC_CS_TYPE)0x0004
830 #define CSW_SCSI_RESET_LATCH (ASC_CS_TYPE)0x0002
831 #define CSW_INT_PENDING (ASC_CS_TYPE)0x0001
832 #define CIW_CLR_SCSI_RESET_INT (ASC_CS_TYPE)0x1000
833 #define CIW_INT_ACK (ASC_CS_TYPE)0x0100
834 #define CIW_TEST1 (ASC_CS_TYPE)0x0200
835 #define CIW_TEST2 (ASC_CS_TYPE)0x0400
836 #define CIW_SEL_33MHZ (ASC_CS_TYPE)0x0800
837 #define CIW_IRQ_ACT (ASC_CS_TYPE)0x1000
838 #define CC_CHIP_RESET (uchar)0x80
839 #define CC_SCSI_RESET (uchar)0x40
840 #define CC_HALT (uchar)0x20
841 #define CC_SINGLE_STEP (uchar)0x10
842 #define CC_DMA_ABLE (uchar)0x08
843 #define CC_TEST (uchar)0x04
844 #define CC_BANK_ONE (uchar)0x02
845 #define CC_DIAG (uchar)0x01
846 #define ASC_1000_ID0W 0x04C1
847 #define ASC_1000_ID0W_FIX 0x00C1
848 #define ASC_1000_ID1B 0x25
849 #define ASC_EISA_REV_IOP_MASK (0x0C83)
850 #define ASC_EISA_CFG_IOP_MASK (0x0C86)
851 #define ASC_GET_EISA_SLOT(iop) (PortAddr)((iop) & 0xF000)
852 #define INS_HALTINT (ushort)0x6281
853 #define INS_HALT (ushort)0x6280
854 #define INS_SINT (ushort)0x6200
855 #define INS_RFLAG_WTM (ushort)0x7380
856 #define ASC_MC_SAVE_CODE_WSIZE 0x500
857 #define ASC_MC_SAVE_DATA_WSIZE 0x40
864 #define AscGetQDoneInProgress(port) AscReadLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B)
865 #define AscPutQDoneInProgress(port, val) AscWriteLramByte((port), ASCV_Q_DONE_IN_PROGRESS_B, val)
866 #define AscGetVarFreeQHead(port) AscReadLramWord((port), ASCV_FREE_Q_HEAD_W)
867 #define AscGetVarDoneQTail(port) AscReadLramWord((port), ASCV_DONE_Q_TAIL_W)
868 #define AscPutVarFreeQHead(port, val) AscWriteLramWord((port), ASCV_FREE_Q_HEAD_W, val)
869 #define AscPutVarDoneQTail(port, val) AscWriteLramWord((port), ASCV_DONE_Q_TAIL_W, val)
870 #define AscGetRiscVarFreeQHead(port) AscReadLramByte((port), ASCV_NEXTRDY_B)
871 #define AscGetRiscVarDoneQTail(port) AscReadLramByte((port), ASCV_DONENEXT_B)
872 #define AscPutRiscVarFreeQHead(port, val) AscWriteLramByte((port), ASCV_NEXTRDY_B, val)
873 #define AscPutRiscVarDoneQTail(port, val) AscWriteLramByte((port), ASCV_DONENEXT_B, val)
874 #define AscPutMCodeSDTRDoneAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id), (data))
875 #define AscGetMCodeSDTRDoneAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DONE_BEG+(ushort)id))
876 #define AscPutMCodeInitSDTRAtID(port, id, data) AscWriteLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id), data)
877 #define AscGetMCodeInitSDTRAtID(port, id) AscReadLramByte((port), (ushort)((ushort)ASCV_SDTR_DATA_BEG+(ushort)id))
878 #define AscGetChipSignatureByte(port) (uchar)inp((port)+IOP_SIG_BYTE)
879 #define AscGetChipSignatureWord(port) (ushort)inpw((port)+IOP_SIG_WORD)
880 #define AscGetChipVerNo(port) (uchar)inp((port)+IOP_VERSION)
881 #define AscGetChipCfgLsw(port) (ushort)inpw((port)+IOP_CONFIG_LOW)
882 #define AscGetChipCfgMsw(port) (ushort)inpw((port)+IOP_CONFIG_HIGH)
883 #define AscSetChipCfgLsw(port, data) outpw((port)+IOP_CONFIG_LOW, data)
884 #define AscSetChipCfgMsw(port, data) outpw((port)+IOP_CONFIG_HIGH, data)
885 #define AscGetChipEEPCmd(port) (uchar)inp((port)+IOP_EEP_CMD)
886 #define AscSetChipEEPCmd(port, data) outp((port)+IOP_EEP_CMD, data)
887 #define AscGetChipEEPData(port) (ushort)inpw((port)+IOP_EEP_DATA)
888 #define AscSetChipEEPData(port, data) outpw((port)+IOP_EEP_DATA, data)
889 #define AscGetChipLramAddr(port) (ushort)inpw((PortAddr)((port)+IOP_RAM_ADDR))
890 #define AscSetChipLramAddr(port, addr) outpw((PortAddr)((port)+IOP_RAM_ADDR), addr)
891 #define AscGetChipLramData(port) (ushort)inpw((port)+IOP_RAM_DATA)
892 #define AscSetChipLramData(port, data) outpw((port)+IOP_RAM_DATA, data)
893 #define AscGetChipIFC(port) (uchar)inp((port)+IOP_REG_IFC)
894 #define AscSetChipIFC(port, data) outp((port)+IOP_REG_IFC, data)
895 #define AscGetChipStatus(port) (ASC_CS_TYPE)inpw((port)+IOP_STATUS)
896 #define AscSetChipStatus(port, cs_val) outpw((port)+IOP_STATUS, cs_val)
897 #define AscGetChipControl(port) (uchar)inp((port)+IOP_CTRL)
898 #define AscSetChipControl(port, cc_val) outp((port)+IOP_CTRL, cc_val)
899 #define AscGetChipSyn(port) (uchar)inp((port)+IOP_SYN_OFFSET)
900 #define AscSetChipSyn(port, data) outp((port)+IOP_SYN_OFFSET, data)
901 #define AscSetPCAddr(port, data) outpw((port)+IOP_REG_PC, data)
902 #define AscGetPCAddr(port) (ushort)inpw((port)+IOP_REG_PC)
903 #define AscIsIntPending(port) (AscGetChipStatus(port) & (CSW_INT_PENDING | CSW_SCSI_RESET_LATCH))
904 #define AscGetChipScsiID(port) ((AscGetChipCfgLsw(port) >> 8) & ASC_MAX_TID)
905 #define AscGetExtraControl(port) (uchar)inp((port)+IOP_EXTRA_CONTROL)
906 #define AscSetExtraControl(port, data) outp((port)+IOP_EXTRA_CONTROL, data)
907 #define AscReadChipAX(port) (ushort)inpw((port)+IOP_REG_AX)
908 #define AscWriteChipAX(port, data) outpw((port)+IOP_REG_AX, data)
909 #define AscReadChipIX(port) (uchar)inp((port)+IOP_REG_IX)
910 #define AscWriteChipIX(port, data) outp((port)+IOP_REG_IX, data)
911 #define AscReadChipIH(port) (ushort)inpw((port)+IOP_REG_IH)
912 #define AscWriteChipIH(port, data) outpw((port)+IOP_REG_IH, data)
913 #define AscReadChipQP(port) (uchar)inp((port)+IOP_REG_QP)
914 #define AscWriteChipQP(port, data) outp((port)+IOP_REG_QP, data)
915 #define AscReadChipFIFO_L(port) (ushort)inpw((port)+IOP_REG_FIFO_L)
916 #define AscWriteChipFIFO_L(port, data) outpw((port)+IOP_REG_FIFO_L, data)
917 #define AscReadChipFIFO_H(port) (ushort)inpw((port)+IOP_REG_FIFO_H)
918 #define AscWriteChipFIFO_H(port, data) outpw((port)+IOP_REG_FIFO_H, data)
919 #define AscReadChipDmaSpeed(port) (uchar)inp((port)+IOP_DMA_SPEED)
920 #define AscWriteChipDmaSpeed(port, data) outp((port)+IOP_DMA_SPEED, data)
921 #define AscReadChipDA0(port) (ushort)inpw((port)+IOP_REG_DA0)
922 #define AscWriteChipDA0(port) outpw((port)+IOP_REG_DA0, data)
923 #define AscReadChipDA1(port) (ushort)inpw((port)+IOP_REG_DA1)
924 #define AscWriteChipDA1(port) outpw((port)+IOP_REG_DA1, data)
925 #define AscReadChipDC0(port) (ushort)inpw((port)+IOP_REG_DC0)
926 #define AscWriteChipDC0(port) outpw((port)+IOP_REG_DC0, data)
927 #define AscReadChipDC1(port) (ushort)inpw((port)+IOP_REG_DC1)
928 #define AscWriteChipDC1(port) outpw((port)+IOP_REG_DC1, data)
929 #define AscReadChipDvcID(port) (uchar)inp((port)+IOP_REG_ID)
930 #define AscWriteChipDvcID(port, data) outp((port)+IOP_REG_ID, data)
941 #define ADV_PADDR __u32
942 #define ADV_VADDR __u32
943 #define ADV_DCNT __u32
944 #define ADV_SDCNT __s32
954 #define ADV_VADDR_TO_U32 virt_to_bus
955 #define ADV_U32_TO_VADDR bus_to_virt
957 #define AdvPortAddr void __iomem *
962 #define ADV_MEM_READB(addr) readb(addr)
963 #define ADV_MEM_READW(addr) readw(addr)
964 #define ADV_MEM_WRITEB(addr, byte) writeb(byte, addr)
965 #define ADV_MEM_WRITEW(addr, word) writew(word, addr)
966 #define ADV_MEM_WRITEDW(addr, dword) writel(dword, addr)
968 #define ADV_CARRIER_COUNT (ASC_DEF_MAX_HOST_QNG + 15)
979 #define ADV_TOT_SG_BLOCK ASC_DEF_MAX_HOST_QNG
984 #define ADV_MAX_SG_LIST 255
985 #define NO_OF_SG_PER_BLOCK 15
987 #define ADV_EEP_DVC_CFG_BEGIN (0x00)
988 #define ADV_EEP_DVC_CFG_END (0x15)
989 #define ADV_EEP_DVC_CTL_BEGIN (0x16)
990 #define ADV_EEP_MAX_WORD_ADDR (0x1E)
992 #define ADV_EEP_DELAY_MS 100
994 #define ADV_EEPROM_BIG_ENDIAN 0x8000
995 #define ADV_EEPROM_BIOS_ENABLE 0x4000
1001 #define ADV_EEPROM_TERM_POL 0x2000
1002 #define ADV_EEPROM_CIS_LD 0x2000
1014 #define ADV_EEPROM_INTAB 0x0800
1290 #define ASC_EEP_CMD_DONE 0x0200
1293 #define BIOS_CTRL_BIOS 0x0001
1294 #define BIOS_CTRL_EXTENDED_XLAT 0x0002
1295 #define BIOS_CTRL_GT_2_DISK 0x0004
1296 #define BIOS_CTRL_BIOS_REMOVABLE 0x0008
1297 #define BIOS_CTRL_BOOTABLE_CD 0x0010
1298 #define BIOS_CTRL_MULTIPLE_LUN 0x0040
1299 #define BIOS_CTRL_DISPLAY_MSG 0x0080
1300 #define BIOS_CTRL_NO_SCAM 0x0100
1301 #define BIOS_CTRL_RESET_SCSI_BUS 0x0200
1302 #define BIOS_CTRL_INIT_VERBOSE 0x0800
1303 #define BIOS_CTRL_SCSI_PARITY 0x1000
1304 #define BIOS_CTRL_AIPP_DIS 0x2000
1306 #define ADV_3550_MEMSIZE 0x2000
1308 #define ADV_38C0800_MEMSIZE 0x4000
1317 #define ADV_38C1600_MEMSIZE 0x4000
1322 #define IOPB_INTR_STATUS_REG 0x00
1323 #define IOPB_CHIP_ID_1 0x01
1324 #define IOPB_INTR_ENABLES 0x02
1325 #define IOPB_CHIP_TYPE_REV 0x03
1326 #define IOPB_RES_ADDR_4 0x04
1327 #define IOPB_RES_ADDR_5 0x05
1328 #define IOPB_RAM_DATA 0x06
1329 #define IOPB_RES_ADDR_7 0x07
1330 #define IOPB_FLAG_REG 0x08
1331 #define IOPB_RES_ADDR_9 0x09
1332 #define IOPB_RISC_CSR 0x0A
1333 #define IOPB_RES_ADDR_B 0x0B
1334 #define IOPB_RES_ADDR_C 0x0C
1335 #define IOPB_RES_ADDR_D 0x0D
1336 #define IOPB_SOFT_OVER_WR 0x0E
1337 #define IOPB_RES_ADDR_F 0x0F
1338 #define IOPB_MEM_CFG 0x10
1339 #define IOPB_RES_ADDR_11 0x11
1340 #define IOPB_GPIO_DATA 0x12
1341 #define IOPB_RES_ADDR_13 0x13
1342 #define IOPB_FLASH_PAGE 0x14
1343 #define IOPB_RES_ADDR_15 0x15
1344 #define IOPB_GPIO_CNTL 0x16
1345 #define IOPB_RES_ADDR_17 0x17
1346 #define IOPB_FLASH_DATA 0x18
1347 #define IOPB_RES_ADDR_19 0x19
1348 #define IOPB_RES_ADDR_1A 0x1A
1349 #define IOPB_RES_ADDR_1B 0x1B
1350 #define IOPB_RES_ADDR_1C 0x1C
1351 #define IOPB_RES_ADDR_1D 0x1D
1352 #define IOPB_RES_ADDR_1E 0x1E
1353 #define IOPB_RES_ADDR_1F 0x1F
1354 #define IOPB_DMA_CFG0 0x20
1355 #define IOPB_DMA_CFG1 0x21
1356 #define IOPB_TICKLE 0x22
1357 #define IOPB_DMA_REG_WR 0x23
1358 #define IOPB_SDMA_STATUS 0x24
1359 #define IOPB_SCSI_BYTE_CNT 0x25
1360 #define IOPB_HOST_BYTE_CNT 0x26
1361 #define IOPB_BYTE_LEFT_TO_XFER 0x27
1362 #define IOPB_BYTE_TO_XFER_0 0x28
1363 #define IOPB_BYTE_TO_XFER_1 0x29
1364 #define IOPB_BYTE_TO_XFER_2 0x2A
1365 #define IOPB_BYTE_TO_XFER_3 0x2B
1366 #define IOPB_ACC_GRP 0x2C
1367 #define IOPB_RES_ADDR_2D 0x2D
1368 #define IOPB_DEV_ID 0x2E
1369 #define IOPB_RES_ADDR_2F 0x2F
1370 #define IOPB_SCSI_DATA 0x30
1371 #define IOPB_RES_ADDR_31 0x31
1372 #define IOPB_RES_ADDR_32 0x32
1373 #define IOPB_SCSI_DATA_HSHK 0x33
1374 #define IOPB_SCSI_CTRL 0x34
1375 #define IOPB_RES_ADDR_35 0x35
1376 #define IOPB_RES_ADDR_36 0x36
1377 #define IOPB_RES_ADDR_37 0x37
1378 #define IOPB_RAM_BIST 0x38
1379 #define IOPB_PLL_TEST 0x39
1380 #define IOPB_PCI_INT_CFG 0x3A
1381 #define IOPB_RES_ADDR_3B 0x3B
1382 #define IOPB_RFIFO_CNT 0x3C
1383 #define IOPB_RES_ADDR_3D 0x3D
1384 #define IOPB_RES_ADDR_3E 0x3E
1385 #define IOPB_RES_ADDR_3F 0x3F
1390 #define IOPW_CHIP_ID_0 0x00
1391 #define IOPW_CTRL_REG 0x02
1392 #define IOPW_RAM_ADDR 0x04
1393 #define IOPW_RAM_DATA 0x06
1394 #define IOPW_RES_ADDR_08 0x08
1395 #define IOPW_RISC_CSR 0x0A
1396 #define IOPW_SCSI_CFG0 0x0C
1397 #define IOPW_SCSI_CFG1 0x0E
1398 #define IOPW_RES_ADDR_10 0x10
1399 #define IOPW_SEL_MASK 0x12
1400 #define IOPW_RES_ADDR_14 0x14
1401 #define IOPW_FLASH_ADDR 0x16
1402 #define IOPW_RES_ADDR_18 0x18
1403 #define IOPW_EE_CMD 0x1A
1404 #define IOPW_EE_DATA 0x1C
1405 #define IOPW_SFIFO_CNT 0x1E
1406 #define IOPW_RES_ADDR_20 0x20
1407 #define IOPW_Q_BASE 0x22
1408 #define IOPW_QP 0x24
1409 #define IOPW_IX 0x26
1410 #define IOPW_SP 0x28
1411 #define IOPW_PC 0x2A
1412 #define IOPW_RES_ADDR_2C 0x2C
1413 #define IOPW_RES_ADDR_2E 0x2E
1414 #define IOPW_SCSI_DATA 0x30
1415 #define IOPW_SCSI_DATA_HSHK 0x32
1416 #define IOPW_SCSI_CTRL 0x34
1417 #define IOPW_HSHK_CFG 0x36
1418 #define IOPW_SXFR_STATUS 0x36
1419 #define IOPW_SXFR_CNTL 0x38
1420 #define IOPW_SXFR_CNTH 0x3A
1421 #define IOPW_RES_ADDR_3C 0x3C
1422 #define IOPW_RFIFO_DATA 0x3E
1427 #define IOPDW_RES_ADDR_0 0x00
1428 #define IOPDW_RAM_DATA 0x04
1429 #define IOPDW_RES_ADDR_8 0x08
1430 #define IOPDW_RES_ADDR_C 0x0C
1431 #define IOPDW_RES_ADDR_10 0x10
1432 #define IOPDW_COMMA 0x14
1433 #define IOPDW_COMMB 0x18
1434 #define IOPDW_RES_ADDR_1C 0x1C
1435 #define IOPDW_SDMA_ADDR0 0x20
1436 #define IOPDW_SDMA_ADDR1 0x24
1437 #define IOPDW_SDMA_COUNT 0x28
1438 #define IOPDW_SDMA_ERROR 0x2C
1439 #define IOPDW_RDMA_ADDR0 0x30
1440 #define IOPDW_RDMA_ADDR1 0x34
1441 #define IOPDW_RDMA_COUNT 0x38
1442 #define IOPDW_RDMA_ERROR 0x3C
1444 #define ADV_CHIP_ID_BYTE 0x25
1445 #define ADV_CHIP_ID_WORD 0x04C1
1447 #define ADV_INTR_ENABLE_HOST_INTR 0x01
1448 #define ADV_INTR_ENABLE_SEL_INTR 0x02
1449 #define ADV_INTR_ENABLE_DPR_INTR 0x04
1450 #define ADV_INTR_ENABLE_RTA_INTR 0x08
1451 #define ADV_INTR_ENABLE_RMA_INTR 0x10
1452 #define ADV_INTR_ENABLE_RST_INTR 0x20
1453 #define ADV_INTR_ENABLE_DPE_INTR 0x40
1454 #define ADV_INTR_ENABLE_GLOBAL_INTR 0x80
1456 #define ADV_INTR_STATUS_INTRA 0x01
1457 #define ADV_INTR_STATUS_INTRB 0x02
1458 #define ADV_INTR_STATUS_INTRC 0x04
1460 #define ADV_RISC_CSR_STOP (0x0000)
1461 #define ADV_RISC_TEST_COND (0x2000)
1462 #define ADV_RISC_CSR_RUN (0x4000)
1463 #define ADV_RISC_CSR_SINGLE_STEP (0x8000)
1465 #define ADV_CTRL_REG_HOST_INTR 0x0100
1466 #define ADV_CTRL_REG_SEL_INTR 0x0200
1467 #define ADV_CTRL_REG_DPR_INTR 0x0400
1468 #define ADV_CTRL_REG_RTA_INTR 0x0800
1469 #define ADV_CTRL_REG_RMA_INTR 0x1000
1470 #define ADV_CTRL_REG_RES_BIT14 0x2000
1471 #define ADV_CTRL_REG_DPE_INTR 0x4000
1472 #define ADV_CTRL_REG_POWER_DONE 0x8000
1473 #define ADV_CTRL_REG_ANY_INTR 0xFF00
1475 #define ADV_CTRL_REG_CMD_RESET 0x00C6
1476 #define ADV_CTRL_REG_CMD_WR_IO_REG 0x00C5
1477 #define ADV_CTRL_REG_CMD_RD_IO_REG 0x00C4
1478 #define ADV_CTRL_REG_CMD_WR_PCI_CFG_SPACE 0x00C3
1479 #define ADV_CTRL_REG_CMD_RD_PCI_CFG_SPACE 0x00C2
1481 #define ADV_TICKLE_NOP 0x00
1482 #define ADV_TICKLE_A 0x01
1483 #define ADV_TICKLE_B 0x02
1484 #define ADV_TICKLE_C 0x03
1486 #define AdvIsIntPending(port) \
1487 (AdvReadWordRegister(port, IOPW_CTRL_REG) & ADV_CTRL_REG_HOST_INTR)
1492 #define TIMER_MODEAB 0xC000
1493 #define PARITY_EN 0x2000
1494 #define EVEN_PARITY 0x1000
1495 #define WD_LONG 0x0800
1496 #define QUEUE_128 0x0400
1497 #define PRIM_MODE 0x0100
1498 #define SCAM_EN 0x0080
1499 #define SEL_TMO_LONG 0x0040
1500 #define CFRM_ID 0x0020
1501 #define OUR_ID_EN 0x0010
1502 #define OUR_ID 0x000F
1507 #define BIG_ENDIAN 0x8000
1508 #define TERM_POL 0x2000
1509 #define SLEW_RATE 0x1000
1510 #define FILTER_SEL 0x0C00
1511 #define FLTR_DISABLE 0x0000
1512 #define FLTR_11_TO_20NS 0x0800
1513 #define FLTR_21_TO_39NS 0x0C00
1514 #define ACTIVE_DBL 0x0200
1515 #define DIFF_MODE 0x0100
1516 #define DIFF_SENSE 0x0080
1517 #define TERM_CTL_SEL 0x0040
1518 #define TERM_CTL 0x0030
1519 #define TERM_CTL_H 0x0020
1520 #define TERM_CTL_L 0x0010
1521 #define CABLE_DETECT 0x000F
1534 #define DIS_TERM_DRV 0x4000
1535 #define HVD_LVD_SE 0x1C00
1539 #define TERM_LVD 0x00C0
1540 #define TERM_LVD_HI 0x0080
1541 #define TERM_LVD_LO 0x0040
1542 #define TERM_SE 0x0030
1543 #define TERM_SE_HI 0x0020
1544 #define TERM_SE_LO 0x0010
1545 #define C_DET_LVD 0x000C
1546 #define C_DET3 0x0008
1547 #define C_DET2 0x0004
1548 #define C_DET_SE 0x0003
1549 #define C_DET1 0x0002
1550 #define C_DET0 0x0001
1552 #define CABLE_ILLEGAL_A 0x7
1555 #define CABLE_ILLEGAL_B 0xB
1561 #define BIOS_EN 0x40
1562 #define FAST_EE_CLK 0x20
1564 #define RAM_SZ_2KB 0x00
1565 #define RAM_SZ_4KB 0x04
1566 #define RAM_SZ_8KB 0x08
1567 #define RAM_SZ_16KB 0x0C
1568 #define RAM_SZ_32KB 0x10
1569 #define RAM_SZ_64KB 0x14
1576 #define BC_THRESH_ENB 0x80
1577 #define FIFO_THRESH 0x70
1578 #define FIFO_THRESH_16B 0x00
1579 #define FIFO_THRESH_32B 0x20
1580 #define FIFO_THRESH_48B 0x30
1581 #define FIFO_THRESH_64B 0x40
1582 #define FIFO_THRESH_80B 0x50
1583 #define FIFO_THRESH_96B 0x60
1584 #define FIFO_THRESH_112B 0x70
1585 #define START_CTL 0x0C
1586 #define START_CTL_TH 0x00
1587 #define START_CTL_ID 0x04
1588 #define START_CTL_THID 0x08
1589 #define START_CTL_EMFU 0x0C
1590 #define READ_CMD 0x03
1591 #define READ_CMD_MR 0x00
1592 #define READ_CMD_MRL 0x02
1593 #define READ_CMD_MRM 0x03
1598 #define RAM_TEST_MODE 0x80
1599 #define PRE_TEST_MODE 0x40
1600 #define NORMAL_MODE 0x00
1601 #define RAM_TEST_DONE 0x10
1602 #define RAM_TEST_STATUS 0x0F
1603 #define RAM_TEST_HOST_ERROR 0x08
1604 #define RAM_TEST_INTRAM_ERROR 0x04
1605 #define RAM_TEST_RISC_ERROR 0x02
1606 #define RAM_TEST_SCSI_ERROR 0x01
1607 #define RAM_TEST_SUCCESS 0x00
1608 #define PRE_TEST_VALUE 0x05
1609 #define NORMAL_VALUE 0x00
1617 #define INTAB_LD 0x80
1625 #define TOTEMPOLE 0x02
1643 #define ADV_SUCCESS 1
1645 #define ADV_ERROR (-1)
1650 #define ASC_WARN_BUSRESET_ERROR 0x0001
1651 #define ASC_WARN_EEPROM_CHKSUM 0x0002
1652 #define ASC_WARN_EEPROM_TERMINATION 0x0004
1653 #define ASC_WARN_ERROR 0xFFFF
1655 #define ADV_MAX_TID 15
1656 #define ADV_MAX_LUN 7
1661 #define ASC_MC_CODE_BEGIN_ADDR 0x0028
1662 #define ASC_MC_CODE_END_ADDR 0x002A
1663 #define ASC_MC_CODE_CHK_SUM 0x002C
1664 #define ASC_MC_VERSION_DATE 0x0038
1665 #define ASC_MC_VERSION_NUM 0x003A
1666 #define ASC_MC_BIOSMEM 0x0040
1667 #define ASC_MC_BIOSLEN 0x0050
1668 #define ASC_MC_BIOS_SIGNATURE 0x0058
1669 #define ASC_MC_BIOS_VERSION 0x005A
1670 #define ASC_MC_SDTR_SPEED1 0x0090
1671 #define ASC_MC_SDTR_SPEED2 0x0092
1672 #define ASC_MC_SDTR_SPEED3 0x0094
1673 #define ASC_MC_SDTR_SPEED4 0x0096
1674 #define ASC_MC_CHIP_TYPE 0x009A
1675 #define ASC_MC_INTRB_CODE 0x009B
1676 #define ASC_MC_WDTR_ABLE 0x009C
1677 #define ASC_MC_SDTR_ABLE 0x009E
1678 #define ASC_MC_TAGQNG_ABLE 0x00A0
1679 #define ASC_MC_DISC_ENABLE 0x00A2
1680 #define ASC_MC_IDLE_CMD_STATUS 0x00A4
1681 #define ASC_MC_IDLE_CMD 0x00A6
1682 #define ASC_MC_IDLE_CMD_PARAMETER 0x00A8
1683 #define ASC_MC_DEFAULT_SCSI_CFG0 0x00AC
1684 #define ASC_MC_DEFAULT_SCSI_CFG1 0x00AE
1685 #define ASC_MC_DEFAULT_MEM_CFG 0x00B0
1686 #define ASC_MC_DEFAULT_SEL_MASK 0x00B2
1687 #define ASC_MC_SDTR_DONE 0x00B6
1688 #define ASC_MC_NUMBER_OF_QUEUED_CMD 0x00C0
1689 #define ASC_MC_NUMBER_OF_MAX_CMD 0x00D0
1690 #define ASC_MC_DEVICE_HSHK_CFG_TABLE 0x0100
1691 #define ASC_MC_CONTROL_FLAG 0x0122
1692 #define ASC_MC_WDTR_DONE 0x0124
1693 #define ASC_MC_CAM_MODE_MASK 0x015E
1694 #define ASC_MC_ICQ 0x0160
1695 #define ASC_MC_IRQ 0x0164
1696 #define ASC_MC_PPR_ABLE 0x017A
1701 #define BIOS_CODESEG 0x54
1702 #define BIOS_CODELEN 0x56
1703 #define BIOS_SIGNATURE 0x58
1704 #define BIOS_VERSION 0x5A
1712 #define CONTROL_FLAG_IGNORE_PERR 0x0001
1713 #define CONTROL_FLAG_ENABLE_AIPP 0x0002
1718 #define HSHK_CFG_WIDE_XFR 0x8000
1719 #define HSHK_CFG_RATE 0x0F00
1720 #define HSHK_CFG_OFFSET 0x001F
1722 #define ASC_DEF_MAX_HOST_QNG 0xFD
1723 #define ASC_DEF_MIN_HOST_QNG 0x10
1724 #define ASC_DEF_MAX_DVC_QNG 0x3F
1725 #define ASC_DEF_MIN_DVC_QNG 0x04
1727 #define ASC_QC_DATA_CHECK 0x01
1728 #define ASC_QC_DATA_OUT 0x02
1729 #define ASC_QC_START_MOTOR 0x04
1730 #define ASC_QC_NO_OVERRUN 0x08
1731 #define ASC_QC_FREEZE_TIDQ 0x10
1733 #define ASC_QSC_NO_DISC 0x01
1734 #define ASC_QSC_NO_TAGMSG 0x02
1735 #define ASC_QSC_NO_SYNC 0x04
1736 #define ASC_QSC_NO_WIDE 0x08
1737 #define ASC_QSC_REDO_DTR 0x10
1742 #define ASC_QSC_HEAD_TAG 0x40
1743 #define ASC_QSC_ORDERED_TAG 0x80
1765 #define ASC_NEXT_VPA_MASK 0xFFFFFFF0
1767 #define ASC_RQ_DONE 0x00000001
1768 #define ASC_RQ_GOOD 0x00000002
1769 #define ASC_CQ_STOPPER 0x00000000
1771 #define ASC_GET_CARRP(carrp) ((carrp) & ASC_NEXT_VPA_MASK)
1773 #define ADV_CARRIER_NUM_PAGE_CROSSING \
1774 (((ADV_CARRIER_COUNT * sizeof(ADV_CARR_T)) + (PAGE_SIZE - 1))/PAGE_SIZE)
1776 #define ADV_CARRIER_BUFSIZE \
1777 ((ADV_CARRIER_COUNT + ADV_CARRIER_NUM_PAGE_CROSSING) * sizeof(ADV_CARR_T))
1785 #define ADV_POLL_REQUEST 0x01
1786 #define ADV_SCSIQ_DONE 0x02
1787 #define ADV_DONT_RETRY 0x08
1789 #define ADV_CHIP_ASC3550 0x01
1790 #define ADV_CHIP_ASC38C0800 0x02
1791 #define ADV_CHIP_ASC38C1600 0x03
1956 #define IDLE_CMD_COMPLETED 0
1957 #define IDLE_CMD_STOP_CHIP 0x0001
1958 #define IDLE_CMD_STOP_CHIP_SEND_INT 0x0002
1959 #define IDLE_CMD_SEND_INT 0x0004
1960 #define IDLE_CMD_ABORT 0x0008
1961 #define IDLE_CMD_DEVICE_RESET 0x0010
1962 #define IDLE_CMD_SCSI_RESET_START 0x0020
1963 #define IDLE_CMD_SCSI_RESET_END 0x0040
1964 #define IDLE_CMD_SCSIREQ 0x0080
1966 #define IDLE_CMD_STATUS_SUCCESS 0x0001
1967 #define IDLE_CMD_STATUS_FAILURE 0x0002
1972 #define ADV_NOWAIT 0x01
1977 #define SCSI_WAIT_100_MSEC 100UL
1978 #define SCSI_US_PER_MSEC 1000
1979 #define SCSI_MAX_RETRY 10
1981 #define ADV_ASYNC_RDMA_FAILURE 0x01
1982 #define ADV_ASYNC_SCSI_BUS_RESET_DET 0x02
1983 #define ADV_ASYNC_CARRIER_READY_FAILURE 0x03
1984 #define ADV_RDMA_IN_CARR_AND_Q_INVALID 0x04
1986 #define ADV_HOST_SCSI_BUS_RESET 0x80
1989 #define AdvReadByteRegister(iop_base, reg_off) \
1990 (ADV_MEM_READB((iop_base) + (reg_off)))
1993 #define AdvWriteByteRegister(iop_base, reg_off, byte) \
1994 (ADV_MEM_WRITEB((iop_base) + (reg_off), (byte)))
1997 #define AdvReadWordRegister(iop_base, reg_off) \
1998 (ADV_MEM_READW((iop_base) + (reg_off)))
2001 #define AdvWriteWordRegister(iop_base, reg_off, word) \
2002 (ADV_MEM_WRITEW((iop_base) + (reg_off), (word)))
2005 #define AdvWriteDWordRegister(iop_base, reg_off, dword) \
2006 (ADV_MEM_WRITEDW((iop_base) + (reg_off), (dword)))
2009 #define AdvReadByteLram(iop_base, addr, byte) \
2011 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
2012 (byte) = ADV_MEM_READB((iop_base) + IOPB_RAM_DATA); \
2016 #define AdvWriteByteLram(iop_base, addr, byte) \
2017 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
2018 ADV_MEM_WRITEB((iop_base) + IOPB_RAM_DATA, (byte)))
2021 #define AdvReadWordLram(iop_base, addr, word) \
2023 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)); \
2024 (word) = (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA)); \
2028 #define AdvWriteWordLram(iop_base, addr, word) \
2029 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
2030 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
2034 #define AdvWriteDWordLramNoSwap(iop_base, addr, dword) \
2035 ((ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr)), \
2036 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
2037 cpu_to_le16((ushort) ((dword) & 0xFFFF)))), \
2038 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_ADDR, (addr) + 2), \
2039 ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, \
2040 cpu_to_le16((ushort) ((dword >> 16) & 0xFFFF)))))
2043 #define AdvReadWordAutoIncLram(iop_base) \
2044 (ADV_MEM_READW((iop_base) + IOPW_RAM_DATA))
2047 #define AdvWriteWordAutoIncLram(iop_base, word) \
2048 (ADV_MEM_WRITEW((iop_base) + IOPW_RAM_DATA, (word)))
2056 #define AdvFindSignature(iop_base) \
2057 (((AdvReadByteRegister((iop_base), IOPB_CHIP_ID_1) == \
2058 ADV_CHIP_ID_BYTE) && \
2059 (AdvReadWordRegister((iop_base), IOPW_CHIP_ID_0) == \
2060 ADV_CHIP_ID_WORD)) ? ADV_TRUE : ADV_FALSE)
2067 #define AdvGetChipVersion(iop_base, bus_type) \
2068 AdvReadByteRegister((iop_base), IOPB_CHIP_TYPE_REV)
2082 #define AdvAbortQueue(asc_dvc, scsiq) \
2083 AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_ABORT, \
2097 #define AdvResetDevice(asc_dvc, target_id) \
2098 AdvSendIdleCmd((asc_dvc), (ushort) IDLE_CMD_DEVICE_RESET, \
2099 (ADV_DCNT) (target_id))
2104 #define ADV_SCSI_BIT_ID_TYPE ushort
2109 #define ADV_SCAN_LUN 0x01
2110 #define ADV_CAPINFO_NOLUN 0x02
2115 #define ADV_TID_TO_TIDMASK(tid) (0x01 << ((tid) & ADV_MAX_TID))
2121 #define QD_NO_STATUS 0x00
2122 #define QD_NO_ERROR 0x01
2123 #define QD_ABORTED_BY_HOST 0x02
2124 #define QD_WITH_ERROR 0x04
2126 #define QHSTA_NO_ERROR 0x00
2127 #define QHSTA_M_SEL_TIMEOUT 0x11
2128 #define QHSTA_M_DATA_OVER_RUN 0x12
2129 #define QHSTA_M_UNEXPECTED_BUS_FREE 0x13
2130 #define QHSTA_M_QUEUE_ABORTED 0x15
2131 #define QHSTA_M_SXFR_SDMA_ERR 0x16
2132 #define QHSTA_M_SXFR_SXFR_PERR 0x17
2133 #define QHSTA_M_RDMA_PERR 0x18
2134 #define QHSTA_M_SXFR_OFF_UFLW 0x19
2135 #define QHSTA_M_SXFR_OFF_OFLW 0x20
2136 #define QHSTA_M_SXFR_WD_TMO 0x21
2137 #define QHSTA_M_SXFR_DESELECTED 0x22
2139 #define QHSTA_M_SXFR_XFR_OFLW 0x12
2140 #define QHSTA_M_SXFR_XFR_PH_ERR 0x24
2141 #define QHSTA_M_SXFR_UNKNOWN_ERROR 0x25
2142 #define QHSTA_M_SCSI_BUS_RESET 0x30
2143 #define QHSTA_M_SCSI_BUS_RESET_UNSOL 0x31
2144 #define QHSTA_M_BUS_DEVICE_RESET 0x32
2145 #define QHSTA_M_DIRECTION_ERR 0x35
2146 #define QHSTA_M_DIRECTION_ERR_HUNG 0x36
2147 #define QHSTA_M_WTM_TIMEOUT 0x41
2148 #define QHSTA_M_BAD_CMPL_STATUS_IN 0x42
2149 #define QHSTA_M_NO_AUTO_REQ_SENSE 0x43
2150 #define QHSTA_M_AUTO_REQ_SENSE_FAIL 0x44
2151 #define QHSTA_M_INVALID_DEVICE 0x45
2152 #define QHSTA_M_FROZEN_TIDQ 0x46
2153 #define QHSTA_M_SGBACKUP_ERROR 0x47
2156 #define ADV_8BALIGN(addr) (((ulong) (addr) + 0x7) & ~0x7)
2157 #define ADV_16BALIGN(addr) (((ulong) (addr) + 0xF) & ~0xF)
2158 #define ADV_32BALIGN(addr) (((ulong) (addr) + 0x1F) & ~0x1F)
2168 #define ADV_SG_LIST_MAX_BYTE_SIZE \
2169 (sizeof(ADV_SG_BLOCK) * \
2170 ((ADV_MAX_SG_LIST + (NO_OF_SG_PER_BLOCK - 1))/NO_OF_SG_PER_BLOCK))
2173 #define ASC_IS_WIDE_BOARD 0x04
2175 #define ASC_NARROW_BOARD(boardp) (((boardp)->flags & ASC_IS_WIDE_BOARD) == 0)
2177 #define NO_ISA_DMA 0xff
2179 #define ASC_INFO_SIZE 128
2181 #ifdef CONFIG_PROC_FS
2183 #define ASC_PRTBUF_SIZE 2048
2184 #define ASC_PRTLINE_SIZE 160
2186 #define ASC_PRT_NEXT() \
2190 if (leftlen == 0) { \
2200 #define ASC_NOERROR 1
2202 #define ASC_ERROR (-1)
2205 #define STATUS_BYTE(byte) (byte)
2206 #define MSG_BYTE(byte) ((byte) << 8)
2207 #define HOST_BYTE(byte) ((byte) << 16)
2208 #define DRIVER_BYTE(byte) ((byte) << 24)
2210 #define ASC_STATS(shost, counter) ASC_STATS_ADD(shost, counter, 1)
2211 #ifndef ADVANSYS_STATS
2212 #define ASC_STATS_ADD(shost, counter, count)
2214 #define ASC_STATS_ADD(shost, counter, count) \
2215 (((struct asc_board *) shost_priv(shost))->asc_stats.counter += (count))
2219 #define ASC_TENTHS(num, den) \
2220 (((10 * ((num)/(den))) > (((num) * 10)/(den))) ? \
2221 0 : ((((num) * 10)/(den)) - (10 * ((num)/(den)))))
2226 #define ASC_PRINT(s) \
2228 printk("advansys: "); \
2232 #define ASC_PRINT1(s, a1) \
2234 printk("advansys: "); \
2235 printk((s), (a1)); \
2238 #define ASC_PRINT2(s, a1, a2) \
2240 printk("advansys: "); \
2241 printk((s), (a1), (a2)); \
2244 #define ASC_PRINT3(s, a1, a2, a3) \
2246 printk("advansys: "); \
2247 printk((s), (a1), (a2), (a3)); \
2250 #define ASC_PRINT4(s, a1, a2, a3, a4) \
2252 printk("advansys: "); \
2253 printk((s), (a1), (a2), (a3), (a4)); \
2256 #ifndef ADVANSYS_DEBUG
2258 #define ASC_DBG(lvl, s...)
2259 #define ASC_DBG_PRT_SCSI_HOST(lvl, s)
2260 #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp)
2261 #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
2262 #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone)
2263 #define ADV_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp)
2264 #define ASC_DBG_PRT_HEX(lvl, name, start, length)
2265 #define ASC_DBG_PRT_CDB(lvl, cdb, len)
2266 #define ASC_DBG_PRT_SENSE(lvl, sense, len)
2267 #define ASC_DBG_PRT_INQUIRY(lvl, inq, len)
2278 #define ASC_DBG(lvl, format, arg...) { \
2279 if (asc_dbglvl >= (lvl)) \
2280 printk(KERN_DEBUG "%s: %s: " format, DRV_NAME, \
2281 __func__ , ## arg); \
2284 #define ASC_DBG_PRT_SCSI_HOST(lvl, s) \
2286 if (asc_dbglvl >= (lvl)) { \
2287 asc_prt_scsi_host(s); \
2291 #define ASC_DBG_PRT_ASC_SCSI_Q(lvl, scsiqp) \
2293 if (asc_dbglvl >= (lvl)) { \
2294 asc_prt_asc_scsi_q(scsiqp); \
2298 #define ASC_DBG_PRT_ASC_QDONE_INFO(lvl, qdone) \
2300 if (asc_dbglvl >= (lvl)) { \
2301 asc_prt_asc_qdone_info(qdone); \
2305 #define ASC_DBG_PRT_ADV_SCSI_REQ_Q(lvl, scsiqp) \
2307 if (asc_dbglvl >= (lvl)) { \
2308 asc_prt_adv_scsi_req_q(scsiqp); \
2312 #define ASC_DBG_PRT_HEX(lvl, name, start, length) \
2314 if (asc_dbglvl >= (lvl)) { \
2315 asc_prt_hex((name), (start), (length)); \
2319 #define ASC_DBG_PRT_CDB(lvl, cdb, len) \
2320 ASC_DBG_PRT_HEX((lvl), "CDB", (uchar *) (cdb), (len));
2322 #define ASC_DBG_PRT_SENSE(lvl, sense, len) \
2323 ASC_DBG_PRT_HEX((lvl), "SENSE", (uchar *) (sense), (len));
2325 #define ASC_DBG_PRT_INQUIRY(lvl, inq, len) \
2326 ASC_DBG_PRT_HEX((lvl), "INQUIRY", (uchar *) (inq), (len));
2329 #ifdef ADVANSYS_STATS
2388 #ifdef ADVANSYS_STATS
2408 #define asc_dvc_to_board(asc_dvc) container_of(asc_dvc, struct asc_board, \
2409 dvc_var.asc_dvc_var)
2410 #define adv_dvc_to_board(adv_dvc) container_of(adv_dvc, struct asc_board, \
2411 dvc_var.adv_dvc_var)
2412 #define adv_dvc_to_pdev(adv_dvc) to_pci_dev(adv_dvc_to_board(adv_dvc)->dev)
2414 #ifdef ADVANSYS_DEBUG
2415 static int asc_dbglvl = 3;
2424 printk(
" iop_base 0x%x, err_code 0x%x, dvc_cntl 0x%x, bug_fix_cntl "
2425 "%d,\n", h->iop_base, h->err_code, h->dvc_cntl, h->bug_fix_cntl);
2427 printk(
" bus_type %d, init_sdtr 0x%x,\n", h->bus_type,
2428 (
unsigned)h->init_sdtr);
2430 printk(
" sdtr_done 0x%x, use_tagged_qng 0x%x, unit_not_ready 0x%x, "
2431 "chip_no 0x%x,\n", (
unsigned)h->sdtr_done,
2432 (
unsigned)h->use_tagged_qng, (
unsigned)h->unit_not_ready,
2433 (
unsigned)h->chip_no);
2435 printk(
" queue_full_or_busy 0x%x, start_motor 0x%x, scsi_reset_wait "
2436 "%u,\n", (
unsigned)h->queue_full_or_busy,
2437 (
unsigned)h->start_motor, (
unsigned)h->scsi_reset_wait);
2439 printk(
" is_in_int %u, max_total_qng %u, cur_total_qng %u, "
2440 "in_critical_cnt %u,\n", (
unsigned)h->is_in_int,
2441 (
unsigned)h->max_total_qng, (
unsigned)h->cur_total_qng,
2442 (
unsigned)h->in_critical_cnt);
2444 printk(
" last_q_shortage %u, init_state 0x%x, no_scam 0x%x, "
2445 "pci_fix_asyn_xfer 0x%x,\n", (
unsigned)h->last_q_shortage,
2446 (
unsigned)h->init_state, (
unsigned)h->no_scam,
2447 (
unsigned)h->pci_fix_asyn_xfer);
2459 printk(
" can_tagged_qng 0x%x, cmd_qng_enabled 0x%x,\n",
2461 printk(
" disc_enable 0x%x, sdtr_enable 0x%x,\n",
2464 printk(
" chip_scsi_id %d, isa_dma_speed %d, isa_dma_channel %d, "
2468 printk(
" mcode_date 0x%x, mcode_version %d\n",
2481 printk(
" iop_base 0x%lx, err_code 0x%x, ultra_able 0x%x\n",
2484 printk(
" sdtr_able 0x%x, wdtr_able 0x%x\n",
2487 printk(
" start_motor 0x%x, scsi_reset_wait 0x%x\n",
2490 printk(
" max_host_qng %u, max_dvc_qng %u, carr_freelist 0x%lxn\n",
2494 printk(
" icq_sp 0x%lx, irq_sp 0x%lx\n",
2497 printk(
" no_scam 0x%x, tagqng_able 0x%x\n",
2500 printk(
" chip_scsi_id 0x%x, cfg 0x%lx\n",
2513 printk(
" disc_enable 0x%x, termination 0x%x\n",
2516 printk(
" chip_version 0x%x, mcode_date 0x%x\n",
2519 printk(
" mcode_version 0x%x, control_flag 0x%x\n",
2526 static void asc_prt_scsi_host(
struct Scsi_Host *
s)
2528 struct asc_board *boardp = shost_priv(s);
2530 printk(
"Scsi_Host at addr 0x%p, device %s\n", s, dev_name(boardp->
dev));
2531 printk(
" host_busy %u, host_no %d, last_reset %d,\n",
2534 printk(
" base 0x%lx, io_port 0x%lx, irq %d,\n",
2537 printk(
" dma_channel %d, this_id %d, can_queue %d,\n",
2540 printk(
" cmd_per_lun %d, sg_tablesize %d, unchecked_isa_dma %d\n",
2558 static void asc_prt_hex(
char *
f,
uchar *s,
int l)
2565 printk(
"%s: (%d bytes)\n", f, l);
2567 for (i = 0; i <
l; i += 32) {
2570 if ((k = (l - i) / 4) >= 8) {
2577 for (j = 0; j <
k; j++) {
2578 printk(
" %2.2X%2.2X%2.2X%2.2X",
2579 (
unsigned)s[i + (j * 4)],
2580 (
unsigned)s[i + (j * 4) + 1],
2581 (
unsigned)s[i + (j * 4) + 2],
2582 (
unsigned)s[i + (j * 4) + 3]);
2590 printk(
" %2.2X", (
unsigned)s[i + (j * 4)]);
2594 (
unsigned)s[i + (j * 4)],
2595 (
unsigned)s[i + (j * 4) + 1]);
2598 printk(
" %2.2X%2.2X%2.2X",
2599 (
unsigned)s[i + (j * 4) + 1],
2600 (
unsigned)s[i + (j * 4) + 2],
2601 (
unsigned)s[i + (j * 4) + 3]);
2620 (
" target_ix 0x%x, target_lun %u, srb_ptr 0x%lx, tag_code 0x%x,\n",
2625 (
" data_addr 0x%lx, data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
2630 printk(
" cdbptr 0x%lx, cdb_len %u, sg_head 0x%lx, sg_queue_cnt %u\n",
2636 printk(
"ASC_SG_HEAD at addr 0x%lx\n", (
ulong)sgp);
2640 printk(
" [%u]: addr 0x%lx, bytes %lu\n",
2653 printk(
"ASC_QDONE_INFO at addr 0x%lx\n", (
ulong)q);
2654 printk(
" srb_ptr 0x%lx, target_ix %u, cdb_len %u, tag_code %u,\n",
2658 (
" done_stat 0x%x, host_stat 0x%x, scsi_stat 0x%x, scsi_msg 0x%x\n",
2667 static void asc_prt_adv_sgblock(
int sgblockno,
ADV_SG_BLOCK *
b)
2671 printk(
" ASC_SG_BLOCK at addr 0x%lx (sgblockno %d)\n",
2672 (
ulong)b, sgblockno);
2673 printk(
" sg_cnt %u, sg_ptr 0x%lx\n",
2678 for (i = 0; i < b->
sg_cnt; i++) {
2679 printk(
" [%u]: sg_addr 0x%lx, sg_count 0x%lx\n",
2695 printk(
"ADV_SCSI_REQ_Q at addr 0x%lx\n", (
ulong)q);
2697 printk(
" target_id %u, target_lun %u, srb_ptr 0x%lx, a_flag 0x%x\n",
2700 printk(
" cntl 0x%x, data_addr 0x%lx, vdata_addr 0x%lx\n",
2703 printk(
" data_cnt %lu, sense_addr 0x%lx, sense_len %u,\n",
2708 (
" cdb_len %u, done_status 0x%x, host_status 0x%x, scsi_status 0x%x\n",
2711 printk(
" sg_working_ix 0x%x, target_cmd %u\n",
2714 printk(
" scsiq_rptr 0x%lx, sg_real_addr 0x%lx, sg_list_ptr 0x%lx\n",
2731 asc_prt_adv_sgblock(sg_blk_cnt, sg_ptr);
2732 if (sg_ptr->
sg_ptr == 0) {
2773 ASC_DBG(3,
"Putting ptr %p into array offset %d\n", ptr, i);
2784 printk(
"advansys: bad SRB %u, max %u\n", srb,
2790 ASC_DBG(3,
"Returning ptr %p from array offset %d\n", ptr, srb);
2806 struct asc_board *boardp = shost_priv(shost);
2810 char *widename =
NULL;
2818 busname =
"ISA PnP";
2823 "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X, DMA 0x%X",
2836 busname =
"PCI Ultra";
2843 "type %d\n", asc_dvc_varp->
bus_type);
2846 "AdvanSys SCSI %s: %s: IO 0x%lX-0x%lX, IRQ 0x%X",
2861 widename =
"Ultra-Wide";
2863 widename =
"Ultra2-Wide";
2865 widename =
"Ultra3-Wide";
2868 "AdvanSys SCSI %s: PCI %s: PCIMEM 0x%lX-0x%lX, IRQ 0x%X",
2877 #ifdef CONFIG_PROC_FS
2889 static int asc_prt_line(
char *
buf,
int buflen,
char *
fmt, ...)
2893 char s[ASC_PRTLINE_SIZE];
2897 BUG_ON(ret >= ASC_PRTLINE_SIZE);
2902 ret =
min(buflen, ret);
2920 static int asc_prt_board_devices(
struct Scsi_Host *shost,
char *
cp,
int cplen)
2922 struct asc_board *boardp = shost_priv(shost);
2932 len = asc_prt_line(cp, leftlen,
2933 "\nDevice Information for AdvanSys SCSI Host %d:\n",
2943 len = asc_prt_line(cp, leftlen,
"Target IDs Detected:");
2947 len = asc_prt_line(cp, leftlen,
" %X,", i);
2951 len = asc_prt_line(cp, leftlen,
" (%X=Host Adapter)\n", chip_scsi_id);
2960 static int asc_prt_adv_bios(
struct Scsi_Host *shost,
char *cp,
int cplen)
2962 struct asc_board *boardp = shost_priv(shost);
2971 len = asc_prt_line(cp, leftlen,
"\nROM BIOS Version: ");
2979 len = asc_prt_line(cp, leftlen,
"Disabled or Pre-3.1\n");
2981 len = asc_prt_line(cp, leftlen,
2982 "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n");
2984 len = asc_prt_line(cp, leftlen,
2985 "can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n");
2992 len = asc_prt_line(cp, leftlen,
"%d.%d%c\n",
2994 letter >= 26 ?
'?' : letter +
'A');
3002 if (major < 3 || (major <= 3 && minor < 1) ||
3003 (major <= 3 && minor <= 1 && letter < (
'I' -
'A'))) {
3004 len = asc_prt_line(cp, leftlen,
3005 "Newer version of ROM BIOS is available at the ConnectCom FTP site:\n");
3007 len = asc_prt_line(cp, leftlen,
3008 "ftp://ftp.connectcom.net/pub\n");
3039 static int asc_get_eeprom_string(
ushort *serialnum,
uchar *cp)
3043 if ((serialnum[1] & 0xFE00) != ((
ushort)0xAA << 8)) {
3052 if ((*cp =
'A' + ((w & 0xE000) >> 13)) ==
'H') {
3059 *cp++ =
'A' + ((w & 0x1C00) >> 10);
3063 *cp++ =
'0' + (num / 100);
3065 *cp++ =
'0' + (num / 10);
3068 *cp++ =
'A' + (num % 10);
3081 if (serialnum[2] & 0x8000) {
3082 *cp++ =
'8' + ((w & 0x1C0) >> 6);
3084 *cp++ =
'0' + ((w & 0x1C0) >> 6);
3089 *cp++ =
'0' + num / 10;
3096 w = serialnum[2] & 0x7FFF;
3099 *cp++ =
'A' + (w / 1000);
3103 *cp++ =
'0' + num / 100;
3105 *cp++ =
'0' + num / 10;
3125 static int asc_prt_asc_board_eeprom(
struct Scsi_Host *shost,
char *cp,
int cplen)
3127 struct asc_board *boardp = shost_priv(shost);
3135 int isa_dma_speed[] = { 10, 8, 7, 6, 5, 4, 3, 2 };
3137 uchar serialstr[13];
3145 len = asc_prt_line(cp, leftlen,
3146 "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
3153 asc_prt_line(cp, leftlen,
" Serial Number: %s\n",
3158 len = asc_prt_line(cp, leftlen,
3159 " Default Settings Used for EEPROM-less Adapter.\n");
3162 len = asc_prt_line(cp, leftlen,
3163 " Serial Number Signature Not Present.\n");
3168 len = asc_prt_line(cp, leftlen,
3169 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
3174 len = asc_prt_line(cp, leftlen,
3175 " cntl 0x%x, no_scam 0x%x\n", ep->
cntl, ep->
no_scam);
3178 len = asc_prt_line(cp, leftlen,
" Target ID: ");
3181 len = asc_prt_line(cp, leftlen,
" %d", i);
3184 len = asc_prt_line(cp, leftlen,
"\n");
3187 len = asc_prt_line(cp, leftlen,
" Disconnects: ");
3190 len = asc_prt_line(cp, leftlen,
" %c",
3196 len = asc_prt_line(cp, leftlen,
"\n");
3199 len = asc_prt_line(cp, leftlen,
" Command Queuing: ");
3202 len = asc_prt_line(cp, leftlen,
" %c",
3208 len = asc_prt_line(cp, leftlen,
"\n");
3211 len = asc_prt_line(cp, leftlen,
" Start Motor: ");
3214 len = asc_prt_line(cp, leftlen,
" %c",
3220 len = asc_prt_line(cp, leftlen,
"\n");
3223 len = asc_prt_line(cp, leftlen,
" Synchronous Transfer:");
3226 len = asc_prt_line(cp, leftlen,
" %c",
3232 len = asc_prt_line(cp, leftlen,
"\n");
3237 len = asc_prt_line(cp, leftlen,
3238 " Host ISA DMA speed: %d MB/S\n",
3258 static int asc_prt_adv_board_eeprom(
struct Scsi_Host *shost,
char *cp,
int cplen)
3260 struct asc_board *boardp = shost_priv(shost);
3267 uchar serialstr[13];
3287 len = asc_prt_line(cp, leftlen,
3288 "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
3300 if (asc_get_eeprom_string(wordp, serialstr) ==
ASC_TRUE) {
3302 asc_prt_line(cp, leftlen,
" Serial Number: %s\n",
3306 len = asc_prt_line(cp, leftlen,
3307 " Serial Number Signature Not Present.\n");
3312 len = asc_prt_line(cp, leftlen,
3313 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
3318 len = asc_prt_line(cp, leftlen,
3319 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
3325 len = asc_prt_line(cp, leftlen,
3326 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
3341 termstr =
"Low Off/High Off";
3344 termstr =
"Low Off/High On";
3347 termstr =
"Low On/High On";
3351 termstr =
"Automatic";
3356 len = asc_prt_line(cp, leftlen,
3357 " termination: %u (%s), bios_ctrl: 0x%x\n",
3362 len = asc_prt_line(cp, leftlen,
3363 " termination: %u (%s), bios_ctrl: 0x%x\n",
3368 len = asc_prt_line(cp, leftlen,
3369 " termination: %u (%s), bios_ctrl: 0x%x\n",
3375 len = asc_prt_line(cp, leftlen,
" Target ID: ");
3378 len = asc_prt_line(cp, leftlen,
" %X", i);
3381 len = asc_prt_line(cp, leftlen,
"\n");
3391 len = asc_prt_line(cp, leftlen,
" Disconnects: ");
3394 len = asc_prt_line(cp, leftlen,
" %c",
3398 len = asc_prt_line(cp, leftlen,
"\n");
3408 len = asc_prt_line(cp, leftlen,
" Command Queuing: ");
3411 len = asc_prt_line(cp, leftlen,
" %c",
3415 len = asc_prt_line(cp, leftlen,
"\n");
3425 len = asc_prt_line(cp, leftlen,
" Start Motor: ");
3428 len = asc_prt_line(cp, leftlen,
" %c",
3432 len = asc_prt_line(cp, leftlen,
"\n");
3436 len = asc_prt_line(cp, leftlen,
" Synchronous Transfer:");
3439 len = asc_prt_line(cp, leftlen,
" %c",
3445 len = asc_prt_line(cp, leftlen,
"\n");
3450 len = asc_prt_line(cp, leftlen,
" Ultra Transfer: ");
3453 len = asc_prt_line(cp, leftlen,
" %c",
3459 len = asc_prt_line(cp, leftlen,
"\n");
3470 len = asc_prt_line(cp, leftlen,
" Wide Transfer: ");
3473 len = asc_prt_line(cp, leftlen,
" %c",
3477 len = asc_prt_line(cp, leftlen,
"\n");
3482 len = asc_prt_line(cp, leftlen,
3483 " Synchronous Transfer Speed (Mhz):\n ");
3490 }
else if (i == 4) {
3492 }
else if (i == 8) {
3494 }
else if (i == 12) {
3520 len = asc_prt_line(cp, leftlen,
"%X:%s ", i, speed_str);
3523 len = asc_prt_line(cp, leftlen,
"\n ");
3528 len = asc_prt_line(cp, leftlen,
"\n");
3544 static int asc_prt_driver_conf(
struct Scsi_Host *shost,
char *cp,
int cplen)
3546 struct asc_board *boardp = shost_priv(shost);
3555 len = asc_prt_line(cp, leftlen,
3556 "\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n",
3560 len = asc_prt_line(cp, leftlen,
3561 " host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n",
3566 len = asc_prt_line(cp, leftlen,
3567 " unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n",
3572 len = asc_prt_line(cp, leftlen,
3573 " unchecked_isa_dma %d, use_clustering %d\n",
3577 len = asc_prt_line(cp, leftlen,
3578 " flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n",
3583 len = asc_prt_line(cp, leftlen,
" io_port 0x%x\n", shost->
io_port);
3606 static int asc_prt_asc_board_info(
struct Scsi_Host *shost,
char *cp,
int cplen)
3608 struct asc_board *boardp = shost_priv(shost);
3616 int renegotiate = 0;
3625 len = asc_prt_line(cp, leftlen,
3626 "\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
3630 len = asc_prt_line(cp, leftlen,
" chip_version %u, mcode_date 0x%x, "
3631 "mcode_version 0x%x, err_code %u\n",
3637 len = asc_prt_line(cp, leftlen,
3641 len = asc_prt_line(cp, leftlen,
" Command Queuing:");
3644 if ((chip_scsi_id == i) ||
3648 len = asc_prt_line(cp, leftlen,
" %X:%c",
3655 len = asc_prt_line(cp, leftlen,
"\n");
3659 len = asc_prt_line(cp, leftlen,
" Command Queue Pending:");
3662 if ((chip_scsi_id == i) ||
3666 len = asc_prt_line(cp, leftlen,
" %X:%u", i, v->
cur_dvc_qng[i]);
3669 len = asc_prt_line(cp, leftlen,
"\n");
3673 len = asc_prt_line(cp, leftlen,
" Command Queue Limit:");
3676 if ((chip_scsi_id == i) ||
3680 len = asc_prt_line(cp, leftlen,
" %X:%u", i, v->
max_dvc_qng[i]);
3683 len = asc_prt_line(cp, leftlen,
"\n");
3687 len = asc_prt_line(cp, leftlen,
" Command Queue Full:");
3690 if ((chip_scsi_id == i) ||
3695 len = asc_prt_line(cp, leftlen,
" %X:Y-%d",
3698 len = asc_prt_line(cp, leftlen,
" %X:N", i);
3702 len = asc_prt_line(cp, leftlen,
"\n");
3705 len = asc_prt_line(cp, leftlen,
" Synchronous Transfer:");
3708 if ((chip_scsi_id == i) ||
3712 len = asc_prt_line(cp, leftlen,
" %X:%c",
3719 len = asc_prt_line(cp, leftlen,
"\n");
3723 uchar syn_period_ix;
3725 if ((chip_scsi_id == i) ||
3731 len = asc_prt_line(cp, leftlen,
" %X:", i);
3735 len = asc_prt_line(cp, leftlen,
" Asynchronous");
3742 len = asc_prt_line(cp, leftlen,
3743 " Transfer Period Factor: %d (%d.%d Mhz),",
3753 len = asc_prt_line(cp, leftlen,
" REQ/ACK Offset: %d",
3760 len = asc_prt_line(cp, leftlen,
"*\n");
3763 len = asc_prt_line(cp, leftlen,
"\n");
3769 len = asc_prt_line(cp, leftlen,
3770 " * = Re-negotiation pending before next command.\n");
3788 static int asc_prt_adv_board_info(
struct Scsi_Host *shost,
char *cp,
int cplen)
3790 struct asc_board *boardp = shost_priv(shost);
3802 ushort sdtr_able, wdtr_able;
3805 int renegotiate = 0;
3815 len = asc_prt_line(cp, leftlen,
3816 "\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
3820 len = asc_prt_line(cp, leftlen,
3821 " iop_base 0x%lx, cable_detect: %X, err_code %u\n",
3828 len = asc_prt_line(cp, leftlen,
" chip_version %u, mcode_date 0x%x, "
3834 len = asc_prt_line(cp, leftlen,
" Queuing Enabled:");
3837 if ((chip_scsi_id == i) ||
3842 len = asc_prt_line(cp, leftlen,
" %X:%c",
3848 len = asc_prt_line(cp, leftlen,
"\n");
3851 len = asc_prt_line(cp, leftlen,
" Queue Limit:");
3854 if ((chip_scsi_id == i) ||
3862 len = asc_prt_line(cp, leftlen,
" %X:%d", i, lrambyte);
3865 len = asc_prt_line(cp, leftlen,
"\n");
3868 len = asc_prt_line(cp, leftlen,
" Command Pending:");
3871 if ((chip_scsi_id == i) ||
3879 len = asc_prt_line(cp, leftlen,
" %X:%d", i, lrambyte);
3882 len = asc_prt_line(cp, leftlen,
"\n");
3886 len = asc_prt_line(cp, leftlen,
" Wide Enabled:");
3889 if ((chip_scsi_id == i) ||
3894 len = asc_prt_line(cp, leftlen,
" %X:%c",
3900 len = asc_prt_line(cp, leftlen,
"\n");
3904 len = asc_prt_line(cp, leftlen,
" Transfer Bit Width:");
3907 if ((chip_scsi_id == i) ||
3916 len = asc_prt_line(cp, leftlen,
" %X:%d",
3917 i, (lramword & 0x8000) ? 16 : 8);
3922 len = asc_prt_line(cp, leftlen,
"*");
3927 len = asc_prt_line(cp, leftlen,
"\n");
3931 len = asc_prt_line(cp, leftlen,
" Synchronous Enabled:");
3934 if ((chip_scsi_id == i) ||
3939 len = asc_prt_line(cp, leftlen,
" %X:%c",
3945 len = asc_prt_line(cp, leftlen,
"\n");
3954 lramword &= ~0x8000;
3956 if ((chip_scsi_id == i) ||
3962 len = asc_prt_line(cp, leftlen,
" %X:", i);
3965 if ((lramword & 0x1F) == 0) {
3966 len = asc_prt_line(cp, leftlen,
" Asynchronous");
3970 asc_prt_line(cp, leftlen,
3971 " Transfer Period Factor: ");
3974 if ((lramword & 0x1F00) == 0x1100) {
3976 asc_prt_line(cp, leftlen,
"9 (80.0 Mhz),");
3978 }
else if ((lramword & 0x1F00) == 0x1000) {
3980 asc_prt_line(cp, leftlen,
"10 (40.0 Mhz),");
3984 period = (((lramword >> 8) * 25) + 50) / 4;
3988 asc_prt_line(cp, leftlen,
3992 len = asc_prt_line(cp, leftlen,
3994 period, 250 / period,
4001 len = asc_prt_line(cp, leftlen,
" REQ/ACK Offset: %d",
4007 len = asc_prt_line(cp, leftlen,
"*\n");
4010 len = asc_prt_line(cp, leftlen,
"\n");
4016 len = asc_prt_line(cp, leftlen,
4017 " * = Re-negotiation pending before next command.\n");
4032 char *cp,
int cplen)
4036 ASC_DBG(2,
"offset %d, advoffset %d, cplen %d\n",
4037 (
unsigned)offset, (
unsigned)advoffset, cplen);
4038 if (offset <= advoffset) {
4040 cnt =
min(cplen, leftlen);
4041 ASC_DBG(2,
"curbuf 0x%lx, cp 0x%lx, cnt %d\n",
4044 }
else if (offset < advoffset + cplen) {
4046 cnt = (advoffset + cplen) - offset;
4047 cp = (cp + cplen) - cnt;
4048 cnt =
min(cnt, leftlen);
4049 ASC_DBG(2,
"curbuf 0x%lx, cp 0x%lx, cnt %d\n",
4056 #ifdef ADVANSYS_STATS
4066 static int asc_prt_board_stats(
struct Scsi_Host *shost,
char *cp,
int cplen)
4068 struct asc_board *boardp = shost_priv(shost);
4071 int leftlen = cplen;
4072 int len, totlen = 0;
4074 len = asc_prt_line(cp, leftlen,
4075 "\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n",
4079 len = asc_prt_line(cp, leftlen,
4080 " queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n",
4085 len = asc_prt_line(cp, leftlen,
4086 " callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n",
4091 len = asc_prt_line(cp, leftlen,
4092 " exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n",
4101 len = asc_prt_line(cp, leftlen,
" xfer_cnt %lu, xfer_elem %lu, ",
4105 len = asc_prt_line(cp, leftlen,
"xfer_bytes %lu.%01lu kb\n",
4110 len = asc_prt_line(cp, leftlen,
" avg_num_elem %lu.%01lu, ",
4115 len = asc_prt_line(cp, leftlen,
"avg_elem_size %lu.%01lu kb, ",
4120 len = asc_prt_line(cp, leftlen,
"avg_xfer_size %lu.%01lu kb\n",
4154 struct asc_board *boardp = shost_priv(shost);
4187 cp = (
char *)advansys_info(shost);
4191 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4195 ASC_DBG(1,
"totcnt %d\n", totcnt);
4206 cplen = asc_prt_adv_bios(shost, cp, ASC_PRTBUF_SIZE);
4207 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4208 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
4213 ASC_DBG(1,
"totcnt %d\n", totcnt);
4224 cplen = asc_prt_board_devices(shost, cp, ASC_PRTBUF_SIZE);
4225 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4226 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4230 ASC_DBG(1,
"totcnt %d\n", totcnt);
4241 cplen = asc_prt_asc_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
4243 cplen = asc_prt_adv_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
4245 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4246 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4250 ASC_DBG(1,
"totcnt %d\n", totcnt);
4260 cplen = asc_prt_driver_conf(shost, cp, ASC_PRTBUF_SIZE);
4261 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4262 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4266 ASC_DBG(1,
"totcnt %d\n", totcnt);
4272 #ifdef ADVANSYS_STATS
4277 cplen = asc_prt_board_stats(shost, cp, ASC_PRTBUF_SIZE);
4278 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4279 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4283 ASC_DBG(1,
"totcnt %d\n", totcnt);
4296 cplen = asc_prt_asc_board_info(shost, cp, ASC_PRTBUF_SIZE);
4298 cplen = asc_prt_adv_board_info(shost, cp, ASC_PRTBUF_SIZE);
4300 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4301 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4305 ASC_DBG(1,
"totcnt %d\n", totcnt);
4311 ASC_DBG(1,
"totcnt %d\n", totcnt);
4334 }
else if (bank == 2) {
4344 AscSetBank(iop_base, 1);
4346 AscSetBank(iop_base, 0);
4349 static int AscStartChip(
PortAddr iop_base)
4358 static int AscStopChip(
PortAddr iop_base)
4374 static int AscIsChipHalted(
PortAddr iop_base)
4384 static int AscResetChipAndScsiBus(
ASC_DVC_VAR *asc_dvc)
4394 AscStopChip(iop_base);
4404 return (AscIsChipHalted(iop_base));
4407 static int AscFindSignature(
PortAddr iop_base)
4411 ASC_DBG(1,
"AscGetChipSignatureByte(0x%x) 0x%x\n",
4414 ASC_DBG(1,
"AscGetChipSignatureWord(0x%x) 0x%x\n",
4425 static void AscEnableInterrupt(
PortAddr iop_base)
4433 static void AscDisableInterrupt(
PortAddr iop_base)
4443 unsigned char byte_data;
4444 unsigned short word_data;
4449 byte_data = (word_data >> 8) & 0xFF;
4453 byte_data = word_data & 0xFF;
4467 #if CC_VERY_LONG_SG_LIST
4470 ushort val_low, val_high;
4477 return (dword_data);
4487 for (i = 0; i < words; i++) {
4504 word_data = AscReadLramWord(iop_base, addr);
4505 word_data &= 0x00FF;
4506 word_data |= (((
ushort)byte_val << 8) & 0xFF00);
4508 word_data = AscReadLramWord(iop_base, addr);
4509 word_data &= 0xFF00;
4510 word_data |= ((
ushort)byte_val & 0x00FF);
4512 AscWriteLramWord(iop_base, addr, word_data);
4523 const uchar *s_buffer,
int words)
4528 for (i = 0; i < 2 * words; i += 2) {
4538 ((
ushort)s_buffer[i + 1] << 8) | s_buffer[i]);
4549 AscMemDWordCopyPtrToLram(
PortAddr iop_base,
4555 for (i = 0; i < 4 * dwords; i += 4) {
4568 AscMemWordCopyPtrFromLram(
PortAddr iop_base,
4575 for (i = 0; i < 2 * words; i += 2) {
4577 d_buffer[
i] = word & 0xff;
4578 d_buffer[i + 1] = (word >> 8) & 0xff;
4588 for (i = 0; i < words; i++, s_addr += 2) {
4589 sum += AscReadLramWord(iop_base, s_addr);
4634 AscWriteLramByte(iop_base,
4636 AscWriteLramByte(iop_base,
4638 AscWriteLramByte(iop_base,
4653 mcode_word_size = (
ushort)(mcode_size >> 1);
4654 AscMemWordSetLram(iop_base, s_addr, 0, mcode_word_size);
4655 AscMemWordCopyPtrToLram(iop_base, s_addr, mcode_buf, mcode_word_size);
4657 chksum = AscMemSumLramWord(iop_base, s_addr, mcode_word_size);
4659 mcode_chksum = (
ushort)AscMemSumLramWord(iop_base,
4665 ASC_DBG(1,
"mcode_chksum 0x%lx\n", (
ulong)mcode_chksum);
4695 for (i = 0; i < 32; i++, lram_addr += 2) {
4696 AscWriteLramWord(iop_base, lram_addr, 0);
4716 AscInitQLinkVar(asc_dvc);
4732 (
uchar *)&phy_addr, 1);
4735 (
uchar *)&phy_size, 1);
4746 goto err_mcode_start;
4748 if (AscStartChip(iop_base) != 1) {
4751 goto err_mcode_start;
4767 const char fwname[] =
"advansys/mcode.bin";
4777 AscResetChipAndScsiBus(asc_dvc);
4783 if (!AscFindSignature(asc_dvc->
iop_base)) {
4787 AscDisableInterrupt(iop_base);
4788 warn_code |= AscInitLram(asc_dvc);
4806 chksum = (fw->
data[3] << 24) | (fw->
data[2] << 16) |
4809 if (AscLoadMicroCode(iop_base, 0, &fw->
data[4],
4816 warn_code |= AscInitMicroCodeVar(asc_dvc);
4820 AscEnableInterrupt(iop_base);
4846 static int AdvLoadMicrocode(
AdvPortAddr iop_base,
const unsigned char *buf,
4849 int i,
j,
end, len = 0;
4854 for (i = 253 * 2; i <
size; i++) {
4855 if (buf[i] == 0xff) {
4856 unsigned short word = (buf[i + 3] << 8) | buf[i + 2];
4857 for (j = 0; j < buf[i + 1]; j++) {
4862 }
else if (buf[i] == 0xfe) {
4863 unsigned short word = (buf[i + 2] << 8) | buf[i + 1];
4868 unsigned int off = buf[
i] * 2;
4869 unsigned short word = (buf[off + 1] << 8) | buf[off];
4877 while (len < memsize) {
4886 for (len = 0; len <
end; len += 2) {
4896 static void AdvBuildCarrierFreelist(
struct adv_dvc_var *asc_dvc)
4927 }
while (buf_size > 0);
5054 static int AdvInitAsc3550Driver(
ADV_DVC_VAR *asc_dvc)
5057 const char fwname[] =
"advansys/3550.bin";
5070 ushort wdtr_able = 0, sdtr_able, tagqng_able;
5105 ushort bios_version, major, minor;
5109 major = (bios_version >> 12) & 0xF;
5110 minor = (bios_version >> 8) & 0xF;
5111 if (major < 3 || (major == 3 && minor == 1)) {
5139 chksum = (fw->
data[3] << 24) | (fw->
data[2] << 16) |
5141 asc_dvc->
err_code = AdvLoadMicrocode(iop_base, &fw->
data[4],
5164 for (word = begin_addr; word < end_addr; word += 2) {
5246 word |= (0x3 << (4 * (tid % 4)));
5249 word |= (0x2 << (4 * (tid % 4)));
5254 }
else if (tid == 7) {
5257 }
else if (tid == 11) {
5260 }
else if (tid == 15) {
5410 AdvBuildCarrierFreelist(asc_dvc);
5494 if (AdvResetSB(asc_dvc) !=
ADV_TRUE) {
5513 static int AdvInitAsc38C0800Driver(
ADV_DVC_VAR *asc_dvc)
5516 const char fwname[] =
"advansys/38C0800.bin";
5530 ushort wdtr_able, sdtr_able, tagqng_able;
5601 for (i = 0; i < 2; i++) {
5655 chksum = (fw->
data[3] << 24) | (fw->
data[2] << 16) |
5657 asc_dvc->
err_code = AdvLoadMicrocode(iop_base, &fw->
data[4],
5680 for (word = begin_addr; word < end_addr; word += 2) {
5810 if (scsi_cfg1 &
HVD) {
5907 AdvBuildCarrierFreelist(asc_dvc);
5994 if (AdvResetSB(asc_dvc) !=
ADV_TRUE) {
6013 static int AdvInitAsc38C1600Driver(
ADV_DVC_VAR *asc_dvc)
6016 const char fwname[] =
"advansys/38C1600.bin";
6030 ushort wdtr_able, sdtr_able, ppr_able, tagqng_able;
6103 for (i = 0; i < 2; i++) {
6107 if ((byte & RAM_TEST_DONE) == 0
6133 if ((byte & RAM_TEST_DONE) == 0 || (byte & RAM_TEST_STATUS) != 0) {
6157 chksum = (fw->
data[3] << 24) | (fw->
data[2] << 16) |
6159 asc_dvc->
err_code = AdvLoadMicrocode(iop_base, &fw->
data[4],
6182 for (word = begin_addr; word < end_addr; word += 2) {
6317 if (scsi_cfg1 & HVD) {
6418 AdvBuildCarrierFreelist(asc_dvc);
6504 if (AdvResetSB(asc_dvc) !=
ADV_TRUE) {
6520 static int AdvResetChipAndSB(
ADV_DVC_VAR *asc_dvc)
6523 ushort wdtr_able, sdtr_able, tagqng_able;
6569 status = AdvInitAsc38C1600Driver(asc_dvc);
6571 status = AdvInitAsc38C0800Driver(asc_dvc);
6573 status = AdvInitAsc3550Driver(asc_dvc);
6615 ASC_DBG(0,
"ADV_ASYNC_SCSI_BUS_RESET_DET\n");
6624 ASC_DBG(0,
"ADV_ASYNC_RDMA_FAILURE\n");
6625 AdvResetChipAndSB(adv_dvc_varp);
6632 ASC_DBG(0,
"ADV_HOST_SCSI_BUS_RESET\n");
6636 ASC_DBG(0,
"unknown code 0x%x\n", code);
6655 ASC_DBG(1,
"adv_dvc_varp 0x%lx, scsiqp 0x%lx\n",
6667 ASC_PRINT(
"adv_isr_callback: reqp is NULL\n");
6680 ASC_DBG(1,
"scp 0x%p\n", scp);
6683 (
"adv_isr_callback: scp is NULL; adv_req_t dropped.\n");
6688 shost = scp->
device->host;
6690 ASC_DBG(1,
"shost 0x%p\n", shost);
6692 boardp = shost_priv(shost);
6710 if (scsi_bufflen(scp) != 0 && resid_cnt != 0 &&
6711 resid_cnt <= scsi_bufflen(scp)) {
6712 ASC_DBG(1,
"underrun condition %lu bytes\n",
6714 scsi_set_resid(scp, resid_cnt);
6719 ASC_DBG(2,
"QD_WITH_ERROR\n");
6723 ASC_DBG(2,
"SAM_STAT_CHECK_CONDITION\n");
6754 ASC_DBG(1,
"QD_ABORTED_BY_HOST\n");
6863 adv_async_callback(asc_dvc, intrb_code);
6869 while (((irq_next_vpa =
6899 free_carrp = asc_dvc->
irq_sp;
6920 adv_isr_callback(asc_dvc, scsiq);
6942 static void AscAckInterrupt(
PortAddr iop_base)
6951 if (loop++ > 0x7FFF) {
6956 AscReadLramByte(iop_base,
6973 const uchar *period_table;
6981 if ((syn_time <= period_table[max_index])) {
6982 for (i = min_index; i < (max_index - 1); i++) {
6983 if (syn_time <= period_table[i]) {
6987 return (
uchar)max_index;
6989 return (
uchar)(max_index + 1);
6997 uchar sdtr_period_index;
7006 sdtr_buf.req_ack_offset = sdtr_offset;
7007 sdtr_period_index = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
7008 if (sdtr_period_index <= asc_dvc->max_sdtr_index) {
7012 return ((sdtr_period_index << 4) | sdtr_offset);
7014 sdtr_buf.req_ack_offset = 0;
7026 uchar sdtr_period_ix;
7028 sdtr_period_ix = AscGetSynPeriodIndex(asc_dvc, sdtr_period);
7031 byte = (sdtr_period_ix << 4) | (syn_offset & ASC_SYN_MAX_OFFSET);
7041 AscSetBank(iop_base, 1);
7044 if (org_id == (0x01 << i))
7050 AscSetBank(iop_base, 0);
7058 AscSetBank(iop_base, 1);
7060 AscSetBank(iop_base, 0);
7066 AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
7085 uchar q_cntl, tid_no;
7099 target_ix = AscReadLramByte(iop_base,
7102 q_cntl = AscReadLramByte(iop_base,
7113 AscSetChipSDTR(iop_base, 0, tid_no);
7120 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
7126 AscMemWordCopyPtrFromLram(iop_base,
7135 if ((ext_msg.req_ack_offset > ASC_SYN_MAX_OFFSET)) {
7137 sdtr_accept =
FALSE;
7140 if ((ext_msg.xfer_period <
7142 || (ext_msg.xfer_period >
7145 sdtr_accept =
FALSE;
7146 ext_msg.xfer_period =
7152 AscCalSDTRData(asc_dvc, ext_msg.xfer_period,
7153 ext_msg.req_ack_offset);
7154 if ((sdtr_data == 0xFF)) {
7159 AscSetChipSDTR(iop_base, asyn_sdtr,
7164 if (ext_msg.req_ack_offset == 0) {
7169 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
7172 q_cntl &= ~QC_MSG_OUT;
7178 AscCalSDTRData(asc_dvc,
7179 ext_msg.xfer_period,
7182 AscSetChipSDTR(iop_base, sdtr_data,
7187 AscMsgOutSDTR(asc_dvc,
7188 ext_msg.xfer_period,
7189 ext_msg.req_ack_offset);
7193 AscCalSDTRData(asc_dvc,
7194 ext_msg.xfer_period,
7197 AscSetChipSDTR(iop_base, sdtr_data,
7205 AscWriteLramByte(iop_base,
7216 AscMemWordCopyPtrToLram(iop_base,
7221 AscWriteLramByte(iop_base,
7230 AscMemWordCopyPtrToLram(iop_base,
7235 AscWriteLramByte(iop_base,
7246 if ((asc_dvc->
init_sdtr & target_id) != 0) {
7252 AscMsgOutSDTR(asc_dvc,
7254 sdtr_period_tbl[(sdtr_data >> 4) &
7259 ASC_SYN_MAX_OFFSET));
7262 AscWriteLramByte(iop_base,
7266 tag_code = AscReadLramByte(iop_base,
7278 AscWriteLramByte(iop_base,
7283 q_status = AscReadLramByte(iop_base,
7287 AscWriteLramByte(iop_base,
7293 scsi_busy &= ~target_id;
7300 AscMemWordCopyPtrFromLram(iop_base,
7311 AscSetChipSDTR(iop_base, asyn_sdtr, tid_no);
7315 AscWriteLramByte(iop_base,
7322 scsi_status = AscReadLramByte(iop_base,
7327 AscReadLramByte(iop_base,
7330 if ((cur_dvc_qng > 0) && (asc_dvc->
cur_dvc_qng[tid_no] > 0)) {
7332 scsi_busy = AscReadLramByte(iop_base,
7335 AscWriteLramByte(iop_base,
7345 AscWriteLramByte(iop_base,
7366 #if CC_VERY_LONG_SG_LIST
7371 uchar first_sg_wk_q_no;
7402 sg_wk_q_no = AscReadLramByte(iop_base,
7406 first_sg_wk_q_no = AscReadLramByte(iop_base,
7414 AscWriteLramByte(iop_base,
7448 next_qp = first_sg_wk_q_no;
7452 for (i = 0; i < sg_head->
queue_cnt; i++) {
7453 scsi_sg_q.
seq_no = i + 1;
7480 sg_list_dwords = sg_entry_cnt << 1;
7486 scsi_sg_q.
q_no = next_qp;
7487 AscMemWordCopyPtrToLram(iop_base,
7489 (
uchar *)&scsi_sg_q,
7492 AscMemDWordCopyPtrToLram(iop_base,
7509 next_qp = AscReadLramByte(iop_base,
7543 for (i = 0; i < 2 * words; i += 2) {
7548 inbuf[
i] = word & 0xff;
7549 inbuf[i + 1] = (word >> 8) & 0xff;
7555 _AscCopyLramScsiDoneQ(
PortAddr iop_base,
7562 DvcGetQinfo(iop_base,
7567 _val = AscReadLramWord(iop_base,
7571 _val = AscReadLramWord(iop_base,
7574 sg_queue_cnt = (
uchar)(_val >> 8);
7575 _val = AscReadLramWord(iop_base,
7597 return sg_queue_cnt;
7611 ASC_DBG(1,
"asc_dvc_varp 0x%p, qdonep 0x%p\n", asc_dvc_varp, qdonep);
7614 scp = advansys_srb_to_ptr(asc_dvc_varp, qdonep->
d2.
srb_ptr);
7620 shost = scp->
device->host;
7622 ASC_DBG(1,
"shost 0x%p\n", shost);
7624 boardp = shost_priv(shost);
7643 if (scsi_bufflen(scp) != 0 && qdonep->
remain_bytes != 0 &&
7645 ASC_DBG(1,
"underrun condition %u bytes\n",
7652 ASC_DBG(2,
"QD_WITH_ERROR\n");
7656 ASC_DBG(2,
"SAM_STAT_CHECK_CONDITION\n");
7687 ASC_DBG(1,
"QD_ABORTED_BY_HOST\n");
7731 uchar cur_target_qng;
7741 next_qp = AscReadLramByte(iop_base,
7746 sg_queue_cnt = _AscCopyLramScsiDoneQ(iop_base, q_addr, scsiq,
7748 AscWriteLramByte(iop_base,
7758 sg_list_qp = next_qp;
7759 for (q_cnt = 0; q_cnt < sg_queue_cnt; q_cnt++) {
7760 sg_list_qp = AscReadLramByte(iop_base,
7766 AscSetLibErrorCode(asc_dvc,
7771 goto FATAL_ERR_QDONE;
7773 AscWriteLramByte(iop_base,
7775 ASC_SCSIQ_B_STATUS),
7778 n_q_used = sg_queue_cnt + 1;
7782 cur_target_qng = AscReadLramByte(iop_base,
7788 if (cur_target_qng < asc_dvc->max_dvc_qng[tid_no]) {
7789 scsi_busy = AscReadLramByte(iop_base, (
ushort)
7791 scsi_busy &= ~target_id;
7792 AscWriteLramByte(iop_base,
7806 goto FATAL_ERR_QDONE;
7812 false_overrun =
FALSE;
7827 }
else if (false_overrun) {
7835 AscStopChip(iop_base);
7848 asc_isr_callback(asc_dvc, scsiq);
7850 if ((AscReadLramByte(iop_base,
7866 asc_isr_callback(asc_dvc, scsiq);
7880 uchar saved_ctrl_reg;
7886 int_pending =
FALSE;
7912 saved_ctrl_reg &= (
uchar)(~CC_HALT);
7914 CSW_SCSI_RESET_ACTIVE) && (i-- > 0)) {
7925 host_flag = AscReadLramByte(iop_base,
7930 if ((chipstat & CSW_INT_PENDING) || (int_pending)) {
7931 AscAckInterrupt(iop_base);
7934 if (AscIsrChipHalted(asc_dvc) ==
ERR) {
7935 goto ISR_REPORT_QDONE_FATAL_ERROR;
7937 saved_ctrl_reg &= (
uchar)(~CC_HALT);
7940 ISR_REPORT_QDONE_FATAL_ERROR:
7943 AscIsrQDone(asc_dvc)) & 0x01) != 0) {
7948 AscIsrQDone(asc_dvc)) == 1) {
7951 }
while (status == 0x11);
7953 if ((status & 0x80) != 0)
7973 static int advansys_reset(
struct scsi_cmnd *scp)
7976 struct asc_board *boardp = shost_priv(shost);
7977 unsigned long flags;
7991 ASC_DBG(1,
"before AscInitAsc1000Driver()\n");
7992 status = AscInitAsc1000Driver(asc_dvc);
7997 "0x%x, status: 0x%x\n", asc_dvc->
err_code,
8000 }
else if (status) {
8008 ASC_DBG(1,
"after AscInitAsc1000Driver()\n");
8020 ASC_DBG(1,
"before AdvResetChipAndSB()\n");
8021 switch (AdvResetChipAndSB(adv_dvc)) {
8038 spin_unlock_irqrestore(shost->
host_lock, flags);
8083 ip[2] = (
unsigned long)capacity / (ip[0] * ip[1]);
8096 struct asc_board *boardp = shost_priv(shost);
8099 ASC_DBG(2,
"boardp 0x%p\n", boardp);
8105 ASC_DBG(1,
"before AscISR()\n");
8109 ASC_DBG(1,
"before AdvISR()\n");
8121 static int AscHostReqRiscHalt(
PortAddr iop_base)
8125 uchar saved_stop_code;
8127 if (AscIsChipHalted(iop_base))
8133 if (AscIsChipHalted(iop_base)) {
8138 }
while (count++ < 20);
8148 if (AscHostReqRiscHalt(iop_base)) {
8149 sta = AscSetChipSynRegAtID(iop_base, tid_no, sdtr_data);
8150 AscStartChip(iop_base);
8174 AscSetRunChipSynRegAtID(asc_dvc->
iop_base, sdev->
id,
8184 if (sdev->
lun == 0) {
8192 if (orig_init_sdtr != asc_dvc->
init_sdtr)
8193 AscAsyncFix(asc_dvc, sdev);
8198 if (sdev->
lun == 0) {
8206 if (sdev->
lun == 0) {
8213 if ((sdev->
lun == 0) &&
8224 AscWriteLramByte(asc_dvc->
iop_base,
8238 advansys_wide_enable_wdtr(
AdvPortAddr iop_base,
unsigned short tidmask)
8240 unsigned short cfg_word;
8242 if ((cfg_word & tidmask) != 0)
8245 cfg_word |= tidmask;
8255 cfg_word &= ~tidmask;
8258 cfg_word &= ~tidmask;
8270 advansys_wide_enable_sdtr(
AdvPortAddr iop_base,
unsigned short tidmask)
8272 unsigned short cfg_word;
8274 if ((cfg_word & tidmask) != 0)
8277 cfg_word |= tidmask;
8285 cfg_word &= ~tidmask;
8297 static void advansys_wide_enable_ppr(
ADV_DVC_VAR *adv_dvc,
8309 unsigned short tidmask = 1 << sdev->
id;
8311 if (sdev->
lun == 0) {
8319 advansys_wide_enable_wdtr(iop_base, tidmask);
8321 advansys_wide_enable_sdtr(iop_base, tidmask);
8323 advansys_wide_enable_ppr(adv_dvc, iop_base, tidmask);
8333 unsigned short cfg_word;
8335 cfg_word |= tidmask;
8356 static int advansys_slave_configure(
struct scsi_device *sdev)
8361 advansys_narrow_slave_configure(sdev,
8364 advansys_wide_slave_configure(sdev,
8386 memset(asc_scsi_q, 0,
sizeof(*asc_scsi_q));
8391 asc_scsi_q->
q2.
srb_ptr = advansys_ptr_to_srb(asc_dvc, scp);
8406 asc_scsi_q->
q1.
sense_addr = advansys_get_sense_buffer_dma(scp);
8434 if (use_sg > scp->
device->host->sg_tablesize) {
8436 "sg_tablesize %d\n", use_sg,
8437 scp->
device->host->sg_tablesize);
8443 asc_sg_head = kzalloc(
sizeof(asc_scsi_q->
sg_head) +
8452 asc_scsi_q->
sg_head = asc_sg_head;
8506 slp = scsi_sglist(scp);
8507 sg_elem_cnt = use_sg;
8508 prev_sg_block =
NULL;
8518 ASC_DBG(1,
"no free adv_sgblk_t\n");
8581 if (--sg_elem_cnt == 0) {
8582 sg_block->
sg_cnt = i + 1;
8589 prev_sg_block = sg_block;
8618 ASC_DBG(1,
"no free adv_req_t\n");
8654 for (i = 0; i < scp->
cmd_len && i < 12; i++) {
8658 for (; i < scp->
cmd_len; i++) {
8683 "ADV_MAX_SG_LIST %d\n", use_sg,
8684 scp->
device->host->sg_tablesize);
8700 ret = adv_get_sglist(boardp, reqp, scp, use_sg);
8720 *adv_scsiqpp = scsiqp;
8725 static int AscSgListToQueue(
int sg_list)
8732 return n_sg_list_qs + 1;
8780 q_status = (
uchar)AscReadLramByte(iop_base,
8794 for (i = 0; i < n_free_q; i++) {
8795 free_q_head = AscAllocFreeQueue(iop_base, free_q_head);
8819 for (i = 0; i < 2 * words; i += 2) {
8820 if (i == 4 || i == 20) {
8824 ((
ushort)outbuf[i + 1] << 8) | outbuf[i]);
8833 uchar syn_period_ix;
8845 AscMsgOutSDTR(asc_dvc,
8855 AscMemWordCopyPtrToLram(iop_base,
8856 q_addr + ASC_SCSIQ_CDB_BEG,
8859 DvcPutScsiQ(iop_base,
8863 AscWriteLramWord(iop_base,
8866 q_no << 8) | (
ushort)QS_READY));
8892 #if CC_VERY_LONG_SG_LIST
8923 #if CC_VERY_LONG_SG_LIST
8926 if (sg_entry_cnt != 0) {
8933 for (i = 0; i < sg_head->
queue_cnt; i++) {
8934 scsi_sg_q.
seq_no = i + 1;
8950 #if CC_VERY_LONG_SG_LIST
8962 #if CC_VERY_LONG_SG_LIST
8965 sg_list_dwords = sg_entry_cnt << 1;
8978 next_qp = AscReadLramByte(iop_base,
8981 scsi_sg_q.
q_no = next_qp;
8983 AscMemWordCopyPtrToLram(iop_base,
8985 (
uchar *)&scsi_sg_q,
8987 AscMemDWordCopyPtrToLram(iop_base,
8998 sta = AscPutReadyQueue(asc_dvc, scsiq, q_no);
9019 if (n_q_required > 1) {
9020 next_qp = AscAllocMultipleFreeQueue(iop_base, free_q_head,
9021 (
uchar)n_q_required);
9025 scsiq->
q1.
q_no = free_q_head;
9026 sta = AscPutReadySgListQueue(asc_dvc, scsiq,
9029 }
else if (n_q_required == 1) {
9030 next_qp = AscAllocFreeQueue(iop_base, free_q_head);
9032 scsiq->
q1.
q_no = free_q_head;
9033 sta = AscPutReadyQueue(asc_dvc, scsiq, free_q_head);
9044 #define ASC_SYN_OFFSET_ONE_DISABLE_LIST 16
9069 int disable_syn_offset_one_fix;
9073 ushort sg_entry_cnt_minus_one = 0;
9099 AscMsgOutSDTR(asc_dvc,
9101 sdtr_period_tbl[(sdtr_data >> 4) &
9106 ASC_SYN_MAX_OFFSET));
9116 if ((sg_entry_cnt = sg_head->
entry_cnt) == 0) {
9120 #if !CC_VERY_LONG_SG_LIST
9126 if (sg_entry_cnt == 1) {
9133 sg_entry_cnt_minus_one = sg_entry_cnt - 1;
9135 scsi_cmd = scsiq->
cdbptr[0];
9136 disable_syn_offset_one_fix =
FALSE;
9141 for (i = 0; i < sg_entry_cnt; i++) {
9149 if (data_cnt != 0
UL) {
9150 if (data_cnt < 512
UL) {
9151 disable_syn_offset_one_fix =
TRUE;
9156 _syn_offset_one_disable_cmd[
i];
9157 if (disable_cmd == 0xFF) {
9160 if (scsi_cmd == disable_cmd) {
9161 disable_syn_offset_one_fix =
9169 if (disable_syn_offset_one_fix) {
9179 if ((scsi_cmd ==
READ_6) ||
9184 [sg_entry_cnt_minus_one].
9188 [sg_entry_cnt_minus_one].
9192 if ((extra_bytes != 0)
9205 [sg_entry_cnt_minus_one].
9211 [sg_entry_cnt_minus_one].
9219 #if CC_VERY_LONG_SG_LIST
9229 n_q_required = AscSgListToQueue(sg_entry_cnt);
9230 if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, n_q_required) >=
9231 (
uint) n_q_required)
9234 AscSendScsiQueue(asc_dvc, scsiq,
9235 n_q_required)) == 1) {
9243 if ((scsi_cmd ==
READ_6) ||
9250 if ((extra_bytes != 0)
9259 if (((
ushort)data_cnt & 0x01FF)
9276 if ((AscGetNumOfFreeQueue(asc_dvc, target_ix, 1) >= 1) ||
9278 if ((sta = AscSendScsiQueue(asc_dvc, scsiq,
9279 n_q_required)) == 1) {
9383 asc_dvc->
icq_sp = new_carrp;
9415 static int asc_execute_scsi_cmnd(
struct scsi_cmnd *scp)
9420 ASC_DBG(1,
"scp 0x%p\n", scp);
9424 struct asc_scsi_q asc_scsi_q;
9427 ret = asc_build_req(boardp, scp, &asc_scsi_q);
9433 ret = AscExeScsiQueue(asc_dvc, &asc_scsi_q);
9440 switch (adv_build_req(boardp, scp, &adv_scsiqp)) {
9442 ASC_DBG(3,
"adv_build_req ASC_NOERROR\n");
9445 ASC_DBG(1,
"adv_build_req ASC_BUSY\n");
9455 ASC_DBG(1,
"adv_build_req ASC_ERROR\n");
9460 ret = AdvExeScsiQueue(adv_dvc, adv_scsiqp);
9472 ASC_DBG(1,
"ExeScsiQueue() ASC_NOERROR\n");
9479 "err_code 0x%x\n", err_code);
9485 "err_code 0x%x\n", err_code);
9505 int asc_res, result = 0;
9510 asc_res = asc_execute_scsi_cmnd(scp);
9533 return inpw(eisa_cfg_iop);
9543 unsigned short cfg_lsw;
9544 unsigned short bios_addr;
9555 cfg_lsw = AscGetEisaChipCfg(iop_base);
9577 return (new_host_id);
9590 AscSetBank(iop_base, 1);
9592 AscSetBank(iop_base, 0);
9597 AscGetChipVersion(
PortAddr iop_base,
unsigned short bus_type)
9599 if (bus_type & ASC_IS_EISA) {
9604 revision =
inp(eisa_iop);
9613 if (dma_channel < 4) {
9615 outp(0x000A, dma_channel);
9616 }
else if (dma_channel < 8) {
9617 outp(0x00D6, (
ushort)(0xC0 | (dma_channel - 4)));
9623 static int AscStopQueueExe(
PortAddr iop_base)
9636 }
while (count++ < 20);
9645 else if (bus_type & (ASC_IS_EISA |
ASC_IS_VL))
9656 if (channel == 0x03)
9658 else if (channel == 0x00)
9660 return (channel + 4);
9668 if ((dma_channel >= 5) && (dma_channel <= 7)) {
9669 if (dma_channel == 7)
9672 value = dma_channel - 4;
9676 return (AscGetIsaDmaChannel(iop_base));
9685 AscSetBank(iop_base, 1);
9687 speed_value &= 0x07;
9688 AscSetBank(iop_base, 0);
9694 speed_value &= 0x07;
9695 AscSetBank(iop_base, 1);
9697 AscSetBank(iop_base, 0);
9698 return AscGetIsaDmaSpeed(iop_base);
9713 (ASC_IS_ISA | ASC_IS_PCI | ASC_IS_EISA |
ASC_IS_VL)) == 0) {
9745 chip_version = AscGetChipVersion(iop_base, asc_dvc->
bus_type);
9749 if ((asc_dvc->
bus_type & ASC_IS_PCI) &&
9763 if (asc_dvc->
bus_type == ASC_IS_PCI) {
9770 if ((asc_dvc->
bus_type & ASC_IS_ISA) != 0) {
9776 (
uchar)AscGetIsaDmaChannel(iop_base);
9794 unsigned char read_back;
9798 if (read_back == cmd_reg)
9804 static void __devinit AscWaitEEPRead(
void)
9817 AscWriteEEPCmdReg(iop_base, cmd_reg);
9835 wbuf = (
ushort *)cfg_buf;
9838 for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
9839 *wbuf = AscReadEEPWord(iop_base, (
uchar)s_addr);
9849 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
9850 wval = AscReadEEPWord(iop_base, (
uchar)s_addr);
9851 if (s_addr <= uchar_end_in_config) {
9867 *wbuf = AscReadEEPWord(iop_base, (
uchar)s_addr);
9881 saved_word = AscReadLramWord(iop_base, q_addr);
9888 AscWriteLramWord(iop_base, q_addr, saved_word);
9893 static void __devinit AscWaitEEPWrite(
void)
9908 if (read_back == data_reg) {
9911 if (retry++ > ASC_EEP_MAX_RETRY) {
9922 read_wval = AscReadEEPWord(iop_base, addr);
9923 if (read_wval != word_val) {
9926 AscWriteEEPDataReg(iop_base, word_val);
9928 AscWriteEEPCmdReg(iop_base,
9933 return (AscReadEEPWord(iop_base, addr));
9950 wbuf = (
ushort *)cfg_buf;
9954 for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
9956 if (*wbuf != AscWriteEEPWord(iop_base, (
uchar)s_addr, *wbuf)) {
9960 if (bus_type & ASC_IS_VL) {
9967 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
9968 if (s_addr <= uchar_end_in_config) {
9975 AscWriteEEPWord(iop_base, (
uchar)s_addr, word)) {
9981 AscWriteEEPWord(iop_base, (
uchar)s_addr, *wbuf)) {
9989 if (sum != AscWriteEEPWord(iop_base, (
uchar)s_addr, sum)) {
9994 wbuf = (
ushort *)cfg_buf;
9998 for (s_addr = 0; s_addr < 2; s_addr++, wbuf++) {
9999 if (*wbuf != AscReadEEPWord(iop_base, (
uchar)s_addr)) {
10003 if (bus_type & ASC_IS_VL) {
10010 for (s_addr = cfg_beg; s_addr <= (cfg_end - 1); s_addr++, wbuf++) {
10011 if (s_addr <= uchar_end_in_config) {
10018 (iop_base, (
uchar)s_addr));
10021 word = AscReadEEPWord(iop_base, (
uchar)s_addr);
10023 if (*wbuf != word) {
10028 if (AscReadEEPWord(iop_base, (
uchar)s_addr) != sum) {
10042 if ((n_error = AscSetEEPConfigOnce(iop_base, cfg_buf,
10046 if (++retry > ASC_EEP_MAX_RETRY) {
10060 ushort cfg_msw, cfg_lsw;
10067 AscStopQueueExe(iop_base);
10068 if ((AscStopChip(iop_base) ==
FALSE) ||
10069 (AscGetChipScsiCtrl(iop_base) != 0)) {
10071 AscResetChipAndScsiBus(asc_dvc);
10074 if (AscIsChipHalted(iop_base) ==
FALSE) {
10076 return (warn_code);
10081 return (warn_code);
10087 cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
10091 chksum = AscGetEEPConfig(iop_base, eep_config, asc_dvc->
bus_type);
10092 ASC_DBG(1,
"chksum 0x%x\n", chksum);
10099 if (eep_config->
cfg_lsw != cfg_lsw) {
10104 if (eep_config->
cfg_msw != cfg_msw) {
10111 eep_config->
cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
10113 ASC_DBG(1,
"eep_config->chksum 0x%x\n", eep_config->
chksum);
10114 if (chksum != eep_config->
chksum) {
10115 if (AscGetChipVersion(iop_base, asc_dvc->
bus_type) ==
10117 ASC_DBG(1,
"chksum error ignored; EEPROM-less board\n");
10124 eep_config->
cntl = 0xBFFF;
10136 (
"AscInitFromEEP: EEPROM checksum error; Will try to re-write EEPROM.\n");
10154 if (!AscTestExternalLram(asc_dvc)) {
10162 eep_config->
cfg_msw |= 0x0800;
10205 if ((i = AscSetEEPConfig(iop_base, eep_config,
10208 (
"AscInitFromEEP: Failed to re-write EEPROM with %d errors.\n",
10212 (
"AscInitFromEEP: Successfully re-wrote EEPROM.\n");
10215 return (warn_code);
10220 struct asc_board *board = shost_priv(shost);
10222 unsigned short warn_code = 0;
10228 if (AscFindSignature(asc_dvc->
iop_base)) {
10229 warn_code |= AscInitAscDvcVar(asc_dvc);
10230 warn_code |= AscInitFromEEP(asc_dvc);
10238 switch (warn_code) {
10274 struct asc_board *board = shost_priv(shost);
10277 unsigned short cfg_msw;
10278 unsigned short warn_code = 0;
10283 if (!AscFindSignature(asc_dvc->
iop_base)) {
10289 if ((cfg_msw & ASC_CFG_MSW_CLR_MASK) != 0) {
10290 cfg_msw &= ~ASC_CFG_MSW_CLR_MASK;
10303 if (asc_dvc->
bus_type & ASC_IS_PCI) {
10318 if (AscGetChipVersion(iop_base, asc_dvc->
bus_type)
10328 if (asc_dvc->
bus_type & ASC_IS_ISA) {
10336 switch (warn_code) {
10413 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
10451 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
10489 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
10554 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
10619 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
10684 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
10749 AdvWaitEEPCmd(iop_base);
10763 wbuf = (
ushort *)cfg_buf;
10764 charfields = (
ushort *)&ADVEEP_3550_Config_Field_IsChar;
10768 AdvWaitEEPCmd(iop_base);
10777 if (*charfields++) {
10786 AdvWaitEEPCmd(iop_base);
10787 mdelay(ADV_EEP_DELAY_MS);
10795 AdvWaitEEPCmd(iop_base);
10806 if (*charfields++) {
10814 AdvWaitEEPCmd(iop_base);
10817 AdvWaitEEPCmd(iop_base);
10830 wbuf = (
ushort *)cfg_buf;
10831 charfields = (
ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
10835 AdvWaitEEPCmd(iop_base);
10844 if (*charfields++) {
10853 AdvWaitEEPCmd(iop_base);
10854 mdelay(ADV_EEP_DELAY_MS);
10862 AdvWaitEEPCmd(iop_base);
10873 if (*charfields++) {
10881 AdvWaitEEPCmd(iop_base);
10884 AdvWaitEEPCmd(iop_base);
10897 wbuf = (
ushort *)cfg_buf;
10898 charfields = (
ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
10902 AdvWaitEEPCmd(iop_base);
10911 if (*charfields++) {
10920 AdvWaitEEPCmd(iop_base);
10921 mdelay(ADV_EEP_DELAY_MS);
10929 AdvWaitEEPCmd(iop_base);
10940 if (*charfields++) {
10948 AdvWaitEEPCmd(iop_base);
10951 AdvWaitEEPCmd(iop_base);
10967 charfields = (
ushort *)&ADVEEP_3550_Config_Field_IsChar;
10968 wbuf = (
ushort *)cfg_buf;
10973 wval = AdvReadEEPWord(iop_base, eep_addr);
10975 if (*charfields++) {
10982 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
10989 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
10990 if (*charfields++) {
11010 charfields = (
ushort *)&ADVEEP_38C0800_Config_Field_IsChar;
11011 wbuf = (
ushort *)cfg_buf;
11016 wval = AdvReadEEPWord(iop_base, eep_addr);
11018 if (*charfields++) {
11025 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
11032 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
11033 if (*charfields++) {
11053 charfields = (
ushort *)&ADVEEP_38C1600_Config_Field_IsChar;
11054 wbuf = (
ushort *)cfg_buf;
11059 wval = AdvReadEEPWord(iop_base, eep_addr);
11061 if (*charfields++) {
11068 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
11075 *wbuf = AdvReadEEPWord(iop_base, eep_addr);
11076 if (*charfields++) {
11110 if (AdvGet3550EEPConfig(iop_base, &eep_config) != eep_config.
check_sum) {
11116 memcpy(&eep_config, &Default_3550_EEPROM_Config,
11124 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
11127 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
11130 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
11132 AdvSet3550EEPConfig(iop_base, &eep_config);
11250 uchar tid, termination;
11262 if (AdvGet38C0800EEPConfig(iop_base, &eep_config) !=
11269 memcpy(&eep_config, &Default_38C0800_EEPROM_Config,
11277 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
11280 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
11283 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
11285 AdvSet38C0800EEPConfig(iop_base, &eep_config);
11319 }
else if (tid == 4) {
11321 }
else if (tid == 8) {
11323 }
else if (tid == 12) {
11449 uchar tid, termination;
11461 if (AdvGet38C1600EEPConfig(iop_base, &eep_config) !=
11469 memcpy(&eep_config, &Default_38C1600_EEPROM_Config,
11495 if ((ints & 0x01) == 0)
11504 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
11506 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
11508 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
11510 AdvSet38C1600EEPConfig(iop_base, &eep_config);
11543 }
else if (tid == 4) {
11545 }
else if (tid == 8) {
11547 }
else if (tid == 12) {
11550 if (sdtr_speed & ASC_MAX_TID) {
11667 struct asc_board *board = shost_priv(shost);
11669 unsigned short warn_code = 0;
11690 ASC_DBG(1,
"iopb_chip_id_1: 0x%x 0x%x\n",
11694 ASC_DBG(1,
"iopw_chip_id_0: 0x%x 0x%x\n",
11725 status = AdvInitFrom38C1600EEP(asc_dvc);
11727 status = AdvInitFrom38C0800EEP(asc_dvc);
11729 status = AdvInitFrom3550EEP(asc_dvc);
11734 if (warn_code != 0)
11747 #ifdef CONFIG_PROC_FS
11748 .proc_info = advansys_proc_info,
11751 .info = advansys_info,
11752 .queuecommand = advansys_queuecommand,
11753 .eh_bus_reset_handler = advansys_reset,
11754 .bios_param = advansys_biosparam,
11755 .slave_configure = advansys_slave_configure,
11761 .unchecked_isa_dma = 1,
11774 struct asc_board *board = shost_priv(shost);
11790 goto kmalloc_failed;
11797 for (req_cnt = adv_dvc->
max_host_qng; req_cnt > 0; req_cnt--) {
11800 ASC_DBG(1,
"reqp 0x%p, req_cnt %d, bytes %lu\n", reqp, req_cnt,
11808 goto kmalloc_failed;
11832 goto kmalloc_failed;
11840 for (; req_cnt > 0; req_cnt--) {
11841 reqp[req_cnt - 1].
next_reqp = &reqp[req_cnt];
11846 ASC_DBG(2,
"AdvInitAsc3550Driver()\n");
11847 warn_code = AdvInitAsc3550Driver(adv_dvc);
11849 ASC_DBG(2,
"AdvInitAsc38C0800Driver()\n");
11850 warn_code = AdvInitAsc38C0800Driver(adv_dvc);
11852 ASC_DBG(2,
"AdvInitAsc38C1600Driver()\n");
11853 warn_code = AdvInitAsc38C1600Driver(adv_dvc);
11857 if (warn_code || err_code) {
11859 "0x%x\n", warn_code, err_code);
11871 static void advansys_wide_free_mem(
struct asc_board *board)
11886 unsigned int iop,
int bus_type)
11889 struct asc_board *boardp = shost_priv(shost);
11892 int share_irq, warn_code,
ret;
11897 ASC_DBG(1,
"narrow board\n");
11899 asc_dvc_varp->
bus_type = bus_type;
11900 asc_dvc_varp->
drv_ptr = boardp;
11906 adv_dvc_varp->
drv_ptr = boardp;
11909 ASC_DBG(1,
"wide board ASC-3550\n");
11912 ASC_DBG(1,
"wide board ASC-38C0800\n");
11915 ASC_DBG(1,
"wide board ASC-38C1600\n");
11939 ASC_DBG(1,
"iopb_chip_id_1 0x%x, iopw_chip_id_0 0x%x\n",
11944 #ifdef CONFIG_PROC_FS
11998 ASC_DBG(2,
"AscInitGetConfig()\n");
11999 ret = AscInitGetConfig(shost) ? -
ENODEV : 0;
12008 ASC_DBG(2,
"AdvInitGetConfig()\n");
12010 ret = AdvInitGetConfig(pdev, shost) ? -
ENODEV : 0;
12015 goto err_free_proc;
12057 ASC_DBG(2,
"AscInitSetConfig()\n");
12058 ret = AscInitSetConfig(pdev, shost) ? -
ENODEV : 0;
12060 goto err_free_proc;
12163 shost->
max_id = ASC_MAX_TID + 1;
12242 shost->
base = AscGetChipBiosAddress(asc_dvc_varp->
iop_base,
12258 ASC_DBG(1,
"bios_signature 0x%x, bios_version 0x%x\n",
12261 ASC_DBG(1,
"bios_codeseg 0x%x, bios_codelen 0x%x\n",
12288 if (asc_dvc_varp->
bus_type & ASC_IS_ISA) {
12295 goto err_free_proc;
12303 ASC_DBG(2,
"request_irq(%d, %p)\n", boardp->
irq, shost);
12309 if (ret == -
EBUSY) {
12311 "already in use\n", boardp->
irq);
12312 }
else if (ret == -
EINVAL) {
12314 "not valid\n", boardp->
irq);
12317 "failed with %d\n", boardp->
irq, ret);
12326 ASC_DBG(2,
"AscInitAsc1000Driver()\n");
12333 warn_code = AscInitAsc1000Driver(asc_dvc_varp);
12335 if (warn_code || asc_dvc_varp->
err_code) {
12337 "warn 0x%x, error 0x%x\n",
12346 if (advansys_wide_init_chip(shost)) {
12354 ret = scsi_add_host(shost, boardp->
dev);
12368 advansys_wide_free_mem(boardp);
12390 static int advansys_release(
struct Scsi_Host *shost)
12392 struct asc_board *board = shost_priv(shost);
12409 advansys_wide_free_mem(board);
12417 #define ASC_IOADR_TABLE_MAX_IX 11
12420 0x100, 0x0110, 0x120, 0x0130, 0x140, 0x0150, 0x0190,
12421 0x0210, 0x0230, 0x0250, 0x0330
12434 unsigned int chip_irq = ((cfg_lsw >> 2) & 0x03) + 10;
12435 if (chip_irq == 13)
12448 ASC_DBG(1,
"I/O port 0x%x busy\n", iop_base);
12451 ASC_DBG(1,
"probing I/O port 0x%x\n", iop_base);
12452 if (!AscFindSignature(iop_base))
12462 board = shost_priv(shost);
12463 board->
irq = advansys_isa_irq_no(iop_base);
12466 err = advansys_board_found(shost, iop_base, ASC_IS_ISA);
12480 static int __devexit advansys_isa_remove(
struct device *dev,
unsigned int id)
12482 int ioport = _asc_def_iop_base[
id];
12488 static struct isa_driver advansys_isa_driver = {
12489 .probe = advansys_isa_probe,
12511 unsigned int chip_irq = ((cfg_lsw >> 2) & 0x07) + 9;
12512 if ((chip_irq < 10) || (chip_irq == 13) || (chip_irq > 15))
12517 static int __devinit advansys_vlb_probe(
struct device *dev,
unsigned int id)
12525 ASC_DBG(1,
"I/O port 0x%x busy\n", iop_base);
12528 ASC_DBG(1,
"probing I/O port 0x%x\n", iop_base);
12529 if (!AscFindSignature(iop_base))
12544 board = shost_priv(shost);
12545 board->
irq = advansys_vlb_irq_no(iop_base);
12548 err = advansys_board_found(shost, iop_base, ASC_IS_VL);
12562 static struct isa_driver advansys_vlb_driver = {
12563 .probe = advansys_vlb_probe,
12567 .name =
"advansys_vlb",
12571 static struct eisa_device_id advansys_eisa_table[] __devinitdata = {
12600 unsigned short cfg_lsw =
inw(edev->
base_addr + 0xc86);
12601 unsigned int chip_irq = ((cfg_lsw >> 8) & 0x07) + 10;
12602 if ((chip_irq == 13) || (chip_irq > 15))
12621 for (i = 0; i < 2; i++, ioport += 0x20) {
12629 if (!AscFindSignature(ioport)) {
12644 irq = advansys_eisa_irq_no(edev);
12651 board = shost_priv(shost);
12655 err = advansys_board_found(shost, ioport, ASC_IS_EISA);
12685 for (i = 0; i < 2; i++) {
12691 advansys_release(shost);
12699 static struct eisa_driver advansys_eisa_driver = {
12700 .id_table = advansys_eisa_table,
12703 .probe = advansys_eisa_probe,
12709 static struct pci_device_id advansys_pci_tbl[] __devinitdata = {
12735 if (latency < 0x20)
12752 goto disable_device;
12754 advansys_set_latency(pdev);
12767 board = shost_priv(shost);
12769 board->
dev = &pdev->
dev;
12777 err = advansys_board_found(shost, ioport, ASC_IS_PCI);
12781 pci_set_drvdata(pdev, shost);
12796 advansys_release(pci_get_drvdata(pdev));
12801 static struct pci_driver advansys_pci_driver = {
12803 .id_table = advansys_pci_tbl,
12804 .probe = advansys_pci_probe,
12808 static int __init advansys_init(
void)
12820 goto unregister_isa;
12824 goto unregister_vlb;
12826 error = pci_register_driver(&advansys_pci_driver);
12828 goto unregister_eisa;
12842 static void __exit advansys_exit(
void)