Lines Matching +full:3 +full:base +full:- +full:x

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * NinjaSCSI-32Bi Cardbus, NinjaSCSI-32UDE PCI/CardBus SCSI driver
28 #include <linux/dma-mapping.h>
60 MODULE_DESCRIPTION("Workbit NinjaSCSI-32Bi/UDE CardBus/PCI SCSI host bus adapter module");
130 static nsp32_hw_data nsp32_data_base; /* probe <-> detect glue */
146 {0x7, 3, 0x32, 0x32, SMPL_20M}, /* 5.0 : 200ns, 100ns */
147 {0x8, 3, 0x33, 0x38, SMPL_10M}, /* 4.4 : 225ns, 100ns */
148 {0x9, 3, 0x39, 0x3e, SMPL_10M}, /* 4.0 : 250ns, 100ns */
158 {0x7, 3, 0x58, 0x64, SMPL_10M}, /* 2.5 : 400ns, 200ns */
159 {0x8, 3, 0x65, 0x70, SMPL_10M}, /* 2.2 : 450ns, 200ns */
160 {0x9, 3, 0x71, 0x7d, SMPL_10M}, /* 2.0 : 500ns, 200ns */
170 {0x7, 3, 0x35, 0x3c, SMPL_10M}, /* 4.2 : 240ns, 120ns */
171 {0x8, 3, 0x3d, 0x43, SMPL_10M}, /* 3.7 : 270ns, 120ns */
172 {0x9, 3, 0x44, 0x4b, SMPL_10M}, /* 3.3 : 300ns, 120ns */
264 .name = "Workbit NinjaSCSI-32Bi/UDE",
272 .dma_boundary = PAGE_SIZE - 1,
299 #define NSP32_DEBUG_INTR BIT(3)
346 printk("nsp32-debug: 0x%x %s (%d): %s\n", mask, func, line, buf); in nsp32_dmessage()
364 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; in nsp32_build_identify()
365 int pos = data->msgout_len; in nsp32_build_identify()
373 data->msgoutbuf[pos] = IDENTIFY(mode, SCpnt->device->lun); pos++; in nsp32_build_identify()
375 data->msgout_len = pos; in nsp32_build_identify()
385 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; in nsp32_build_sdtr()
386 int pos = data->msgout_len; in nsp32_build_sdtr()
388 data->msgoutbuf[pos] = EXTENDED_MESSAGE; pos++; in nsp32_build_sdtr()
389 data->msgoutbuf[pos] = EXTENDED_SDTR_LEN; pos++; in nsp32_build_sdtr()
390 data->msgoutbuf[pos] = EXTENDED_SDTR; pos++; in nsp32_build_sdtr()
391 data->msgoutbuf[pos] = period; pos++; in nsp32_build_sdtr()
392 data->msgoutbuf[pos] = offset; pos++; in nsp32_build_sdtr()
394 data->msgout_len = pos; in nsp32_build_sdtr()
402 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; in nsp32_build_nop()
403 int pos = data->msgout_len; in nsp32_build_nop()
411 data->msgoutbuf[pos] = NOP; pos++; in nsp32_build_nop()
412 data->msgout_len = pos; in nsp32_build_nop()
420 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; in nsp32_build_reject()
421 int pos = data->msgout_len; in nsp32_build_reject()
423 data->msgoutbuf[pos] = MESSAGE_REJECT; pos++; in nsp32_build_reject()
424 data->msgout_len = pos; in nsp32_build_reject()
433 unsigned int base = SCpnt->host->io_port;
441 nsp32_write2(base, TIMER_SET, time & TIMER_CNT_MASK);
451 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; in nsp32_selection_autopara()
452 unsigned int base = SCpnt->device->host->io_port; in nsp32_selection_autopara() local
453 unsigned int host_id = SCpnt->device->host->this_id; in nsp32_selection_autopara()
455 nsp32_autoparam *param = data->autoparam; in nsp32_selection_autopara()
466 phase = nsp32_read1(base, SCSI_BUS_MONITOR); in nsp32_selection_autopara()
470 SCpnt->result = DID_BUS_BUSY << 16; in nsp32_selection_autopara()
477 * Note: If the range of msgout_len is 1 - 3, fill scsi_msgout. in nsp32_selection_autopara()
478 * over 3 messages needs another routine. in nsp32_selection_autopara()
480 if (data->msgout_len == 0) { in nsp32_selection_autopara()
482 SCpnt->result = DID_ERROR << 16; in nsp32_selection_autopara()
484 } else if (data->msgout_len > 0 && data->msgout_len <= 3) { in nsp32_selection_autopara()
486 for (i = 0; i < data->msgout_len; i++) { in nsp32_selection_autopara()
489 * MCNT 3: MSG#0 -> MSG#1 -> MSG#2 in nsp32_selection_autopara()
490 * MCNT 2: MSG#1 -> MSG#2 in nsp32_selection_autopara()
494 msgout |= ((unsigned int)(data->msgoutbuf[i]) << 24); in nsp32_selection_autopara()
497 msgout |= (unsigned int)data->msgout_len; /* len */ in nsp32_selection_autopara()
499 /* data->msgout_len > 3 */ in nsp32_selection_autopara()
503 // nsp_dbg(NSP32_DEBUG_AUTOSCSI, "sel time out=0x%x\n", in nsp32_selection_autopara()
504 // nsp32_read2(base, SEL_TIME_OUT)); in nsp32_selection_autopara()
505 // nsp32_write2(base, SEL_TIME_OUT, SEL_TIMEOUT_TIME); in nsp32_selection_autopara()
513 for (i = 0; i < SCpnt->cmd_len; i++) { in nsp32_selection_autopara()
514 param->cdb[4 * i] = SCpnt->cmnd[i]; in nsp32_selection_autopara()
518 param->msgout = cpu_to_le32(msgout); in nsp32_selection_autopara()
521 param->syncreg = data->cur_target->syncreg; in nsp32_selection_autopara()
522 param->ackwidth = data->cur_target->ackwidth; in nsp32_selection_autopara()
523 param->target_id = BIT(host_id) | BIT(target); in nsp32_selection_autopara()
524 param->sample_reg = data->cur_target->sample_reg; in nsp32_selection_autopara()
526 // nsp32_dbg(NSP32_DEBUG_AUTOSCSI, "sample rate=0x%x\n", data->cur_target->sample_reg); in nsp32_selection_autopara()
529 param->command_control = cpu_to_le16(CLEAR_CDB_FIFO_POINTER | in nsp32_selection_autopara()
538 switch (data->trans_method) { in nsp32_selection_autopara()
553 * OR-ed BLIEND_MODE, FIFO intr is decreased, instead of PCI bus waits. in nsp32_selection_autopara()
557 param->transfer_control = cpu_to_le16(s); in nsp32_selection_autopara()
560 param->sgt_pointer = cpu_to_le32(data->cur_lunt->sglun_paddr); in nsp32_selection_autopara()
565 nsp32_write4(base, SGT_ADR, data->auto_paddr); in nsp32_selection_autopara()
566 nsp32_write2(base, COMMAND_CONTROL, in nsp32_selection_autopara()
572 ret = nsp32_arbitration(SCpnt, base); in nsp32_selection_autopara()
583 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; in nsp32_selection_autoscsi()
584 unsigned int base = SCpnt->device->host->io_port; in nsp32_selection_autoscsi() local
585 unsigned int host_id = SCpnt->device->host->this_id; in nsp32_selection_autoscsi()
598 nsp32_write2(base, IRQ_CONTROL, IRQ_CONTROL_ALL_IRQ_MASK); in nsp32_selection_autoscsi()
603 phase = nsp32_read1(base, SCSI_BUS_MONITOR); in nsp32_selection_autoscsi()
606 SCpnt->result = DID_BUS_BUSY << 16; in nsp32_selection_autoscsi()
614 nsp32_read2(base, SCSI_EXECUTE_PHASE); in nsp32_selection_autoscsi()
619 nsp32_write2(base, COMMAND_CONTROL, CLEAR_CDB_FIFO_POINTER); in nsp32_selection_autoscsi()
622 * set CDB0 - CDB15 in nsp32_selection_autoscsi()
624 for (i = 0; i < SCpnt->cmd_len; i++) { in nsp32_selection_autoscsi()
625 nsp32_write1(base, COMMAND_DATA, SCpnt->cmnd[i]); in nsp32_selection_autoscsi()
627 nsp32_dbg(NSP32_DEBUG_CDB_CONTENTS, "CDB[0]=[0x%x]", SCpnt->cmnd[0]); in nsp32_selection_autoscsi()
630 * set SCSIOUT LATCH(initiator)/TARGET(target) (OR-ed) ID in nsp32_selection_autoscsi()
632 nsp32_write1(base, SCSI_OUT_LATCH_TARGET_ID, in nsp32_selection_autoscsi()
638 * Note: If the range of msgout_len is 1 - 3, fill scsi_msgout. in nsp32_selection_autoscsi()
639 * over 3 messages needs another routine. in nsp32_selection_autoscsi()
641 if (data->msgout_len == 0) { in nsp32_selection_autoscsi()
643 SCpnt->result = DID_ERROR << 16; in nsp32_selection_autoscsi()
646 } else if (data->msgout_len > 0 && data->msgout_len <= 3) { in nsp32_selection_autoscsi()
648 for (i = 0; i < data->msgout_len; i++) { in nsp32_selection_autoscsi()
651 * MCNT 3: MSG#0 -> MSG#1 -> MSG#2 in nsp32_selection_autoscsi()
652 * MCNT 2: MSG#1 -> MSG#2 in nsp32_selection_autoscsi()
656 msgout |= ((unsigned int)(data->msgoutbuf[i]) << 24); in nsp32_selection_autoscsi()
659 msgout |= (unsigned int)data->msgout_len; /* len */ in nsp32_selection_autoscsi()
660 nsp32_write4(base, SCSI_MSG_OUT, msgout); in nsp32_selection_autoscsi()
662 /* data->msgout_len > 3 */ in nsp32_selection_autoscsi()
663 nsp32_write4(base, SCSI_MSG_OUT, 0); in nsp32_selection_autoscsi()
669 nsp32_write2(base, SEL_TIME_OUT, SEL_TIMEOUT_TIME); in nsp32_selection_autoscsi()
674 * TODO: sample_rate (BASE+0F) is 0 when internal clock = 40MHz. in nsp32_selection_autoscsi()
677 nsp32_write1(base, SREQ_SMPL_RATE, data->cur_target->sample_reg); in nsp32_selection_autoscsi()
682 nsp32_write1(base, SET_ARBIT, ARBIT_CLEAR); in nsp32_selection_autoscsi()
688 nsp32_write1(base, SYNC_REG, data->cur_target->syncreg); in nsp32_selection_autoscsi()
693 nsp32_write1(base, ACK_WIDTH, data->cur_target->ackwidth); in nsp32_selection_autoscsi()
696 "syncreg=0x%x, ackwidth=0x%x, sgtpaddr=0x%x, id=0x%x", in nsp32_selection_autoscsi()
697 nsp32_read1(base, SYNC_REG), nsp32_read1(base, ACK_WIDTH), in nsp32_selection_autoscsi()
698 nsp32_read4(base, SGT_ADR), in nsp32_selection_autoscsi()
699 nsp32_read1(base, SCSI_OUT_LATCH_TARGET_ID)); in nsp32_selection_autoscsi()
700 nsp32_dbg(NSP32_DEBUG_AUTOSCSI, "msgout_len=%d, msgout=0x%x", in nsp32_selection_autoscsi()
701 data->msgout_len, msgout); in nsp32_selection_autoscsi()
706 nsp32_write4(base, SGT_ADR, data->cur_lunt->sglun_paddr); in nsp32_selection_autoscsi()
713 if (data->trans_method & NSP32_TRANSFER_BUSMASTER) { in nsp32_selection_autoscsi()
717 } else if (data->trans_method & NSP32_TRANSFER_MMIO) { in nsp32_selection_autoscsi()
719 } else if (data->trans_method & NSP32_TRANSFER_PIO) { in nsp32_selection_autoscsi()
722 nsp32_write2(base, TRANSFER_CONTROL, command); in nsp32_selection_autoscsi()
732 nsp32_write2(base, COMMAND_CONTROL, command); in nsp32_selection_autoscsi()
737 status = nsp32_arbitration(SCpnt, base); in nsp32_selection_autoscsi()
743 nsp32_write2(base, IRQ_CONTROL, 0); in nsp32_selection_autoscsi()
757 static int nsp32_arbitration(struct scsi_cmnd *SCpnt, unsigned int base) in nsp32_arbitration() argument
764 arbit = nsp32_read1(base, ARBIT_STATUS); in nsp32_arbitration()
770 "arbit: 0x%x, delay time: %d", arbit, time); in nsp32_arbitration()
774 SCpnt->result = DID_OK << 16; in nsp32_arbitration()
775 nsp32_index_write1(base, EXT_PORT, LED_ON); /* PCI LED on */ in nsp32_arbitration()
778 SCpnt->result = DID_BUS_BUSY << 16; in nsp32_arbitration()
786 SCpnt->result = DID_NO_CONNECT << 16; in nsp32_arbitration()
793 nsp32_write1(base, SET_ARBIT, ARBIT_CLEAR); in nsp32_arbitration()
804 * SCSI-2 says IDENTIFY implies RESTORE_POINTER operation.
808 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; in nsp32_reselection()
809 unsigned int host_id = SCpnt->device->host->this_id; in nsp32_reselection()
810 unsigned int base = SCpnt->device->host->io_port; in nsp32_reselection() local
818 tmpid = nsp32_read1(base, RESELECT_ID); in nsp32_reselection()
834 if (newid >= ARRAY_SIZE(data->lunt) || in nsp32_reselection()
835 newlun >= ARRAY_SIZE(data->lunt[0])) { in nsp32_reselection()
838 } else if(data->lunt[newid][newlun].SCpnt == NULL) { in nsp32_reselection()
843 data->cur_id = newid; in nsp32_reselection()
844 data->cur_lun = newlun; in nsp32_reselection()
845 data->cur_target = &(data->target[newid]); in nsp32_reselection()
846 data->cur_lunt = &(data->lunt[newid][newlun]); in nsp32_reselection()
849 nsp32_write4(base, CLR_COUNTER, CLRCOUNTER_ALLMASK); in nsp32_reselection()
856 * nsp32_setup_sg_table - build scatter gather list for transfer data
859 * Note: NinjaSCSI-32Bi/UDE bus master can not transfer over 64KB at a time.
863 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; in nsp32_setup_sg_table()
865 nsp32_sgtable *sgt = data->cur_lunt->sglun->sgt; in nsp32_setup_sg_table()
890 "size=0x%x", le32_to_cpu(sgt[i].len)); in nsp32_setup_sg_table()
894 "num 0x%x : addr 0x%lx len 0x%lx", in nsp32_setup_sg_table()
901 l = le32_to_cpu(sgt[num-1].len); in nsp32_setup_sg_table()
902 sgt[num-1].len = cpu_to_le32(l | SGTEND); in nsp32_setup_sg_table()
911 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; in nsp32_queuecommand_lck()
917 "enter. target: 0x%x LUN: 0x%llx cmnd: 0x%x cmndlen: 0x%x " in nsp32_queuecommand_lck()
918 "use_sg: 0x%x reqbuf: 0x%lx reqlen: 0x%x", in nsp32_queuecommand_lck()
919 SCpnt->device->id, SCpnt->device->lun, SCpnt->cmnd[0], in nsp32_queuecommand_lck()
920 SCpnt->cmd_len, scsi_sg_count(SCpnt), scsi_sglist(SCpnt), in nsp32_queuecommand_lck()
923 if (data->CurrentSC != NULL) { in nsp32_queuecommand_lck()
925 data->CurrentSC = NULL; in nsp32_queuecommand_lck()
926 SCpnt->result = DID_NO_CONNECT << 16; in nsp32_queuecommand_lck()
932 if (scmd_id(SCpnt) == SCpnt->device->host->this_id) { in nsp32_queuecommand_lck()
934 SCpnt->result = DID_BAD_TARGET << 16; in nsp32_queuecommand_lck()
940 if (SCpnt->device->lun >= MAX_LUN) { in nsp32_queuecommand_lck()
942 SCpnt->result = DID_BAD_TARGET << 16; in nsp32_queuecommand_lck()
949 data->CurrentSC = SCpnt; in nsp32_queuecommand_lck()
950 nsp32_priv(SCpnt)->status = SAM_STAT_CHECK_CONDITION; in nsp32_queuecommand_lck()
954 data->msgout_len = 0; in nsp32_queuecommand_lck()
955 data->msgin_len = 0; in nsp32_queuecommand_lck()
956 cur_lunt = &(data->lunt[SCpnt->device->id][SCpnt->device->lun]); in nsp32_queuecommand_lck()
957 cur_lunt->SCpnt = SCpnt; in nsp32_queuecommand_lck()
958 cur_lunt->save_datp = 0; in nsp32_queuecommand_lck()
959 cur_lunt->msgin03 = FALSE; in nsp32_queuecommand_lck()
960 data->cur_lunt = cur_lunt; in nsp32_queuecommand_lck()
961 data->cur_id = SCpnt->device->id; in nsp32_queuecommand_lck()
962 data->cur_lun = SCpnt->device->lun; in nsp32_queuecommand_lck()
967 SCpnt->result = DID_ERROR << 16; in nsp32_queuecommand_lck()
980 target = &data->target[scmd_id(SCpnt)]; in nsp32_queuecommand_lck()
981 data->cur_target = target; in nsp32_queuecommand_lck()
983 if (!(target->sync_flag & (SDTR_DONE | SDTR_INITIATOR | SDTR_TARGET))) { in nsp32_queuecommand_lck()
989 target->sync_flag |= SDTR_INITIATOR; in nsp32_queuecommand_lck()
992 target->sync_flag |= SDTR_DONE; in nsp32_queuecommand_lck()
996 "SDTR: entry: %d start_period: 0x%x offset: 0x%x\n", in nsp32_queuecommand_lck()
997 target->limit_entry, period, offset); in nsp32_queuecommand_lck()
998 } else if (target->sync_flag & SDTR_INITIATOR) { in nsp32_queuecommand_lck()
1005 target->sync_flag &= ~SDTR_INITIATOR; in nsp32_queuecommand_lck()
1006 target->sync_flag |= SDTR_DONE; in nsp32_queuecommand_lck()
1010 } else if (target->sync_flag & SDTR_TARGET) { in nsp32_queuecommand_lck()
1017 target->sync_flag &= ~SDTR_TARGET; in nsp32_queuecommand_lck()
1018 target->sync_flag |= SDTR_DONE; in nsp32_queuecommand_lck()
1025 "target: %d sync_flag: 0x%x syncreg: 0x%x ackwidth: 0x%x", in nsp32_queuecommand_lck()
1026 SCpnt->device->id, target->sync_flag, target->syncreg, in nsp32_queuecommand_lck()
1027 target->ackwidth); in nsp32_queuecommand_lck()
1049 unsigned int base = data->BaseAddress; in DEF_SCSI_QCMD() local
1054 lc_reg = nsp32_index_read4(base, CFG_LATE_CACHE); in DEF_SCSI_QCMD()
1057 nsp32_index_write2(base, CFG_LATE_CACHE, lc_reg & 0xffff); in DEF_SCSI_QCMD()
1060 nsp32_write2(base, IRQ_CONTROL, IRQ_CONTROL_ALL_IRQ_MASK); in DEF_SCSI_QCMD()
1061 nsp32_write2(base, TRANSFER_CONTROL, 0); in DEF_SCSI_QCMD()
1062 nsp32_write4(base, BM_CNT, 0); in DEF_SCSI_QCMD()
1063 nsp32_write2(base, SCSI_EXECUTE_PHASE, 0); in DEF_SCSI_QCMD()
1066 irq_stat = nsp32_read2(base, IRQ_STATUS); in DEF_SCSI_QCMD()
1067 nsp32_dbg(NSP32_DEBUG_INIT, "irq_stat 0x%x", irq_stat); in DEF_SCSI_QCMD()
1074 if ((data->trans_method & NSP32_TRANSFER_PIO) || in DEF_SCSI_QCMD()
1075 (data->trans_method & NSP32_TRANSFER_MMIO)) { in DEF_SCSI_QCMD()
1076 nsp32_index_write1(base, FIFO_FULL_SHLD_COUNT, 0x40); in DEF_SCSI_QCMD()
1077 nsp32_index_write1(base, FIFO_EMPTY_SHLD_COUNT, 0x40); in DEF_SCSI_QCMD()
1078 } else if (data->trans_method & NSP32_TRANSFER_BUSMASTER) { in DEF_SCSI_QCMD()
1079 nsp32_index_write1(base, FIFO_FULL_SHLD_COUNT, 0x10); in DEF_SCSI_QCMD()
1080 nsp32_index_write1(base, FIFO_EMPTY_SHLD_COUNT, 0x60); in DEF_SCSI_QCMD()
1085 nsp32_dbg(NSP32_DEBUG_INIT, "full 0x%x emp 0x%x", in DEF_SCSI_QCMD()
1086 nsp32_index_read1(base, FIFO_FULL_SHLD_COUNT), in DEF_SCSI_QCMD()
1087 nsp32_index_read1(base, FIFO_EMPTY_SHLD_COUNT)); in DEF_SCSI_QCMD()
1089 nsp32_index_write1(base, CLOCK_DIV, data->clock); in DEF_SCSI_QCMD()
1090 nsp32_index_write1(base, BM_CYCLE, in DEF_SCSI_QCMD()
1092 nsp32_write1(base, PARITY_CONTROL, 0); /* parity check is disable */ in DEF_SCSI_QCMD()
1109 nsp32_index_write2(base, MISC_WR, in DEF_SCSI_QCMD()
1117 nsp32_index_write1(base, TERM_PWR_CONTROL, 0); in DEF_SCSI_QCMD()
1118 power = nsp32_index_read1(base, TERM_PWR_CONTROL); in DEF_SCSI_QCMD()
1121 nsp32_index_write1(base, TERM_PWR_CONTROL, BPWR); in DEF_SCSI_QCMD()
1124 nsp32_write2(base, TIMER_SET, TIMER_STOP); in DEF_SCSI_QCMD()
1125 nsp32_write2(base, TIMER_SET, TIMER_STOP); /* Required 2 times */ in DEF_SCSI_QCMD()
1127 nsp32_write1(base, SYNC_REG, 0); in DEF_SCSI_QCMD()
1128 nsp32_write1(base, ACK_WIDTH, 0); in DEF_SCSI_QCMD()
1129 nsp32_write2(base, SEL_TIME_OUT, SEL_TIMEOUT_TIME); in DEF_SCSI_QCMD()
1135 nsp32_index_write2(base, IRQ_SELECT, in DEF_SCSI_QCMD()
1145 nsp32_write2(base, IRQ_CONTROL, 0); in DEF_SCSI_QCMD()
1148 nsp32_index_write1(base, EXT_PORT_DDR, LED_OFF); in DEF_SCSI_QCMD()
1149 nsp32_index_write1(base, EXT_PORT, LED_OFF); in DEF_SCSI_QCMD()
1159 unsigned int base = data->BaseAddress; in do_nsp32_isr() local
1160 struct scsi_cmnd *SCpnt = data->CurrentSC; in do_nsp32_isr()
1166 struct Scsi_Host *host = data->Host; in do_nsp32_isr()
1168 spin_lock_irqsave(host->host_lock, flags); in do_nsp32_isr()
1173 irq_stat = nsp32_read2(base, IRQ_STATUS); in do_nsp32_isr()
1175 "enter IRQ: %d, IRQstatus: 0x%x", irq, irq_stat); in do_nsp32_isr()
1179 "shared interrupt: irq other 0x%x", irq_stat); in do_nsp32_isr()
1183 nsp32_write2(base, IRQ_CONTROL, IRQ_CONTROL_ALL_IRQ_MASK); in do_nsp32_isr()
1185 busmon = nsp32_read1(base, SCSI_BUS_MONITOR); in do_nsp32_isr()
1188 trans_stat = nsp32_read2(base, TRANSFER_STATUS); in do_nsp32_isr()
1191 if (data->CurrentSC != NULL) { in do_nsp32_isr()
1193 SCpnt->result = DID_BAD_TARGET << 16; in do_nsp32_isr()
1202 nsp32_write2(base, TIMER_SET, TIMER_STOP); in do_nsp32_isr()
1211 SCpnt->result = DID_RESET << 16; in do_nsp32_isr()
1219 nsp32_msg(KERN_WARNING, "irq_stat=0x%x trans_stat=0x%x", in do_nsp32_isr()
1232 auto_stat = nsp32_read2(base, SCSI_EXECUTE_PHASE); in do_nsp32_isr()
1233 nsp32_write2(base, SCSI_EXECUTE_PHASE, 0); in do_nsp32_isr()
1240 SCpnt->result = DID_TIME_OUT << 16; in do_nsp32_isr()
1254 (data->msgout_len <= 3)) { in do_nsp32_isr()
1256 * !MSG_IN_OCCUER && msgout_len <=3 in do_nsp32_isr()
1257 * ---> AutoSCSI with MSGOUTreg is processed. in do_nsp32_isr()
1259 data->msgout_len = 0; in do_nsp32_isr()
1267 ((nsp32_read2(base, FIFO_REST_CNT) & FIFO_REST_MASK) != 0)) { in do_nsp32_isr()
1278 nsp32_dbg(NSP32_DEBUG_INTR, "BMCNT=0x%lx", in do_nsp32_isr()
1279 nsp32_read4(base, BM_CNT)); in do_nsp32_isr()
1280 nsp32_dbg(NSP32_DEBUG_INTR, "addr=0x%lx", in do_nsp32_isr()
1281 nsp32_read4(base, SGT_ADR)); in do_nsp32_isr()
1282 nsp32_dbg(NSP32_DEBUG_INTR, "SACK=0x%lx", in do_nsp32_isr()
1283 nsp32_read4(base, SACK_CNT)); in do_nsp32_isr()
1284 nsp32_dbg(NSP32_DEBUG_INTR, "SSACK=0x%lx", in do_nsp32_isr()
1285 nsp32_read4(base, SAVED_SACK_CNT)); in do_nsp32_isr()
1316 * Read CSB and substitute CSB for SCpnt->result in do_nsp32_isr()
1322 SCpnt->result = (int)nsp32_read1(base, SCSI_CSB_IN); in do_nsp32_isr()
1375 nsp32_priv(SCpnt)->status = nsp32_read1(base, SCSI_CSB_IN); in do_nsp32_isr()
1380 nsp32_dbg(NSP32_DEBUG_INTR, "irq_stat=0x%x trans_stat=0x%x", in do_nsp32_isr()
1400 nsp32_msg(KERN_WARNING, "irq_stat=0x%x trans_stat=0x%x\n", in do_nsp32_isr()
1426 "irq_stat=0x%x trans_stat=0x%x", irq_stat, trans_stat); in do_nsp32_isr()
1432 nsp32_write2(base, IRQ_CONTROL, 0); in do_nsp32_isr()
1435 spin_unlock_irqrestore(host->host_lock, flags); in do_nsp32_isr()
1448 unsigned int base; in nsp32_show_info() local
1453 hostno = host->host_no; in nsp32_show_info()
1454 data = (nsp32_hw_data *)host->hostdata; in nsp32_show_info()
1455 base = host->io_port; in nsp32_show_info()
1457 seq_puts(m, "NinjaSCSI-32 status\n\n"); in nsp32_show_info()
1461 seq_printf(m, "IRQ: %d\n", host->irq); in nsp32_show_info()
1462 seq_printf(m, "IO: 0x%lx-0x%lx\n", in nsp32_show_info()
1463 host->io_port, host->io_port + host->n_io_port - 1); in nsp32_show_info()
1464 seq_printf(m, "MMIO(virtual address): 0x%lx-0x%lx\n", in nsp32_show_info()
1465 host->base, host->base + data->MmioLength - 1); in nsp32_show_info()
1467 host->sg_tablesize); in nsp32_show_info()
1468 seq_printf(m, "Chip revision: 0x%x\n", in nsp32_show_info()
1469 (nsp32_read2(base, INDEX_REG) >> 8) & 0xff); in nsp32_show_info()
1471 mode_reg = nsp32_index_read1(base, CHIP_MODE); in nsp32_show_info()
1472 model = data->pci_devid->driver_data; in nsp32_show_info()
1481 spin_lock_irqsave(&(data->Lock), flags); in nsp32_show_info()
1482 seq_printf(m, "CurrentSC: 0x%p\n\n", data->CurrentSC); in nsp32_show_info()
1483 spin_unlock_irqrestore(&(data->Lock), flags); in nsp32_show_info()
1487 for (id = 0; id < ARRAY_SIZE(data->target); id++) { in nsp32_show_info()
1491 if (id == host->this_id) { in nsp32_show_info()
1492 seq_puts(m, "----- NinjaSCSI-32 host adapter\n"); in nsp32_show_info()
1496 if (data->target[id].sync_flag == SDTR_DONE) { in nsp32_show_info()
1497 if (data->target[id].period == 0 && in nsp32_show_info()
1498 data->target[id].offset == ASYNC_OFFSET ) { in nsp32_show_info()
1507 if (data->target[id].period != 0) { in nsp32_show_info()
1509 speed = 1000000 / (data->target[id].period * 4); in nsp32_show_info()
1514 data->target[id].offset in nsp32_show_info()
1525 * Reset parameters and call scsi_done for data->cur_lunt.
1526 * Be careful setting SCpnt->result = DID_* before calling this function.
1530 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; in nsp32_scsi_done()
1531 unsigned int base = SCpnt->device->host->io_port; in nsp32_scsi_done() local
1538 nsp32_write2(base, TRANSFER_CONTROL, 0); in nsp32_scsi_done()
1539 nsp32_write4(base, BM_CNT, 0); in nsp32_scsi_done()
1549 data->cur_lunt->SCpnt = NULL; in nsp32_scsi_done()
1550 data->cur_lunt = NULL; in nsp32_scsi_done()
1551 data->cur_target = NULL; in nsp32_scsi_done()
1552 data->CurrentSC = NULL; in nsp32_scsi_done()
1568 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; in nsp32_busfree_occur()
1569 unsigned int base = SCpnt->device->host->io_port; in nsp32_busfree_occur() local
1571 nsp32_dbg(NSP32_DEBUG_BUSFREE, "enter execph=0x%x", execph); in nsp32_busfree_occur()
1574 nsp32_write4(base, BM_CNT, 0); in nsp32_busfree_occur()
1575 nsp32_write2(base, TRANSFER_CONTROL, 0); in nsp32_busfree_occur()
1583 * NO-VALID: in nsp32_busfree_occur()
1584 * SCSI-3 says if Save Data Pointer is not received, then we restart in nsp32_busfree_occur()
1602 sacklen = nsp32_read4(base, SACK_CNT ); in nsp32_busfree_occur()
1603 s_sacklen = nsp32_read4(base, SAVED_SACK_CNT); in nsp32_busfree_occur()
1622 data->cur_lunt->msgin03 = FALSE; in nsp32_busfree_occur()
1624 data->cur_lunt->msgin03 = TRUE; in nsp32_busfree_occur()
1632 //data->cur_lunt->save_datp = data->cur_datp; in nsp32_busfree_occur()
1646 if (data->cur_target->sync_flag & SDTR_INITIATOR) { in nsp32_busfree_occur()
1651 nsp32_set_async(data, data->cur_target); in nsp32_busfree_occur()
1652 data->cur_target->sync_flag &= ~SDTR_INITIATOR; in nsp32_busfree_occur()
1653 data->cur_target->sync_flag |= SDTR_DONE; in nsp32_busfree_occur()
1654 } else if (data->cur_target->sync_flag & SDTR_TARGET) { in nsp32_busfree_occur()
1670 nsp32_set_async(data, data->cur_target); in nsp32_busfree_occur()
1672 data->cur_target->sync_flag &= ~SDTR_TARGET; in nsp32_busfree_occur()
1673 data->cur_target->sync_flag |= SDTR_DONE; in nsp32_busfree_occur()
1686 nsp32_priv(SCpnt)->status = nsp32_read1(base, SCSI_CSB_IN); in nsp32_busfree_occur()
1688 "normal end stat=0x%x resid=0x%x\n", in nsp32_busfree_occur()
1689 nsp32_priv(SCpnt)->status, scsi_get_resid(SCpnt)); in nsp32_busfree_occur()
1690 SCpnt->result = (DID_OK << 16) | in nsp32_busfree_occur()
1691 (nsp32_priv(SCpnt)->status << 0); in nsp32_busfree_occur()
1697 nsp32_priv(SCpnt)->status = nsp32_read1(base, SCSI_CSB_IN); in nsp32_busfree_occur()
1705 SCpnt->result = DID_ERROR << 16; in nsp32_busfree_occur()
1714 * nsp32_adjust_busfree - adjusting SG table
1721 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; in nsp32_adjust_busfree()
1722 int old_entry = data->cur_entry; in nsp32_adjust_busfree()
1724 int sg_num = data->cur_lunt->sg_num; in nsp32_adjust_busfree()
1725 nsp32_sgtable *sgt = data->cur_lunt->sglun->sgt; in nsp32_adjust_busfree()
1729 nsp32_dbg(NSP32_DEBUG_SGLIST, "old resid=0x%x", scsi_get_resid(SCpnt)); in nsp32_adjust_busfree()
1732 s_sacklen -= le32_to_cpu(sgt[old_entry].addr) & 3; in nsp32_adjust_busfree()
1760 restlen = sentlen - s_sacklen; in nsp32_adjust_busfree()
1765 addr += (len - restlen); in nsp32_adjust_busfree()
1770 data->cur_entry = new_entry; in nsp32_adjust_busfree()
1779 scsi_set_resid(SCpnt, scsi_get_resid(SCpnt) - sentlen); in nsp32_adjust_busfree()
1780 nsp32_dbg(NSP32_DEBUG_SGLIST, "new resid=0x%x", scsi_get_resid(SCpnt)); in nsp32_adjust_busfree()
1790 * NinjaSCSI-32Bi/UDE automatically processes up to 3 messages in
1791 * message out phase. It, however, has more than 3 messages,
1796 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; in nsp32_msgout_occur()
1797 unsigned int base = SCpnt->device->host->io_port; in nsp32_msgout_occur() local
1801 "enter: msgout_len: 0x%x", data->msgout_len); in nsp32_msgout_occur()
1805 * message, then No_Operation is sent (SCSI-2). in nsp32_msgout_occur()
1807 if (data->msgout_len == 0) { in nsp32_msgout_occur()
1814 for (i = 0; i < data->msgout_len; i++) { in nsp32_msgout_occur()
1816 "%d : 0x%x", i, data->msgoutbuf[i]); in nsp32_msgout_occur()
1823 if (i == (data->msgout_len - 1)) { in nsp32_msgout_occur()
1831 nsp32_write2(base, COMMAND_CONTROL, in nsp32_msgout_occur()
1842 nsp32_write1(base, SCSI_DATA_WITH_ACK, data->msgoutbuf[i]); in nsp32_msgout_occur()
1845 nsp32_dbg(NSP32_DEBUG_MSGOUTOCCUR, "bus: 0x%x\n", in nsp32_msgout_occur()
1846 nsp32_read1(base, SCSI_BUS_MONITOR)); in nsp32_msgout_occur()
1849 data->msgout_len = 0; in nsp32_msgout_occur()
1862 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; in nsp32_restart_autoscsi()
1863 unsigned int base = data->BaseAddress; in nsp32_restart_autoscsi() local
1868 if (data->cur_target == NULL || data->cur_lunt == NULL) { in nsp32_restart_autoscsi()
1876 nsp32_write1(base, SYNC_REG, data->cur_target->syncreg); in nsp32_restart_autoscsi()
1881 nsp32_write1(base, ACK_WIDTH, data->cur_target->ackwidth); in nsp32_restart_autoscsi()
1886 nsp32_write1(base, SREQ_SMPL_RATE, data->cur_target->sample_reg); in nsp32_restart_autoscsi()
1891 nsp32_write4(base, SGT_ADR, data->cur_lunt->sglun_paddr); in nsp32_restart_autoscsi()
1898 if (data->trans_method & NSP32_TRANSFER_BUSMASTER) { in nsp32_restart_autoscsi()
1902 } else if (data->trans_method & NSP32_TRANSFER_MMIO) { in nsp32_restart_autoscsi()
1904 } else if (data->trans_method & NSP32_TRANSFER_PIO) { in nsp32_restart_autoscsi()
1907 nsp32_write2(base, TRANSFER_CONTROL, transfer); in nsp32_restart_autoscsi()
1917 nsp32_write2(base, COMMAND_CONTROL, command); in nsp32_restart_autoscsi()
1930 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; in nsp32_msgin_occur()
1931 unsigned int base = SCpnt->device->host->io_port; in nsp32_msgin_occur() local
1943 * of Message-In have to be processed before sending back SCSI ACK. in nsp32_msgin_occur()
1945 msg = nsp32_read1(base, SCSI_DATA_IN); in nsp32_msgin_occur()
1946 data->msginbuf[(unsigned char)data->msgin_len] = msg; in nsp32_msgin_occur()
1947 msgtype = data->msginbuf[0]; in nsp32_msgin_occur()
1949 "enter: msglen: 0x%x msgin: 0x%x msgtype: 0x%x", in nsp32_msgin_occur()
1950 data->msgin_len, msg, msgtype); in nsp32_msgin_occur()
1970 newlun = msgtype & 0x1f; /* TODO: SPI-3 compliant? */ in nsp32_msgin_occur()
1982 * TODO: Messages are all SCSI-2 terminology. SCSI-3 compliance is TODO. in nsp32_msgin_occur()
1986 * 1-byte message in nsp32_msgin_occur()
1995 "unexpected message of AutoSCSI MsgIn: 0x%x", msg); in nsp32_msgin_occur()
2006 s_sacklen = nsp32_read4(base, SAVED_SACK_CNT); in nsp32_msgin_occur()
2013 data->cur_lunt->msgin03 = FALSE; in nsp32_msgin_occur()
2018 nsp32_write4(base, CLR_COUNTER, CLRCOUNTER_ALLMASK); in nsp32_msgin_occur()
2023 new_sgtp = data->cur_lunt->sglun_paddr + in nsp32_msgin_occur()
2024 (data->cur_lunt->cur_entry * sizeof(nsp32_sgtable)); in nsp32_msgin_occur()
2025 nsp32_write4(base, SGT_ADR, new_sgtp); in nsp32_msgin_occur()
2042 if (data->cur_target->sync_flag & in nsp32_msgin_occur()
2049 nsp32_set_async(data, data->cur_target); in nsp32_msgin_occur()
2050 data->cur_target->sync_flag &= ~SDTR_INITIATOR; in nsp32_msgin_occur()
2051 data->cur_target->sync_flag |= SDTR_DONE; in nsp32_msgin_occur()
2060 "unsupported message: 0x%x", msgtype); in nsp32_msgin_occur()
2070 * 2-byte message in nsp32_msgin_occur()
2078 if (data->msgin_len >= 1) { in nsp32_msgin_occur()
2082 /* current position is 1-byte of 2 byte */ in nsp32_msgin_occur()
2091 if (data->msgin_len < 1) { in nsp32_msgin_occur()
2093 * Current position does not reach 2-byte in nsp32_msgin_occur()
2094 * (2-byte is extended message length). in nsp32_msgin_occur()
2100 if ((data->msginbuf[1] + 1) > data->msgin_len) { in nsp32_msgin_occur()
2115 switch (data->msginbuf[2]) { in nsp32_msgin_occur()
2125 if (data->msgin_len != EXTENDED_SDTR_LEN + 1) { in nsp32_msgin_occur()
2138 /* SCSI-I only, not supported. */ in nsp32_msgin_occur()
2159 data->msgin_len = 0; in nsp32_msgin_occur()
2168 if (data->msgout_len > 0) { in nsp32_msgin_occur()
2169 nsp32_write4(base, SCSI_MSG_OUT, 0); in nsp32_msgin_occur()
2182 if (data->cur_lunt->msgin03 == TRUE) { in nsp32_msgin_occur()
2185 data->cur_lunt->msgin03 = FALSE; in nsp32_msgin_occur()
2187 data->msgin_len++; in nsp32_msgin_occur()
2196 * wait SCSI REQ negate for REQ-ACK handshake in nsp32_msgin_occur()
2212 "current msg: 0x%x (len: 0x%x), processing msg: 0x%x", in nsp32_msgin_occur()
2213 msg, data->msgin_len, msgtype); in nsp32_msgin_occur()
2215 data->msgin_len = 0; in nsp32_msgin_occur()
2225 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; in nsp32_analyze_sdtr()
2226 nsp32_target *target = data->cur_target; in nsp32_analyze_sdtr()
2227 unsigned char get_period = data->msginbuf[3]; in nsp32_analyze_sdtr()
2228 unsigned char get_offset = data->msginbuf[4]; in nsp32_analyze_sdtr()
2240 if (target->sync_flag & SDTR_INITIATOR) { in nsp32_analyze_sdtr()
2247 target->sync_flag &= ~SDTR_INITIATOR; in nsp32_analyze_sdtr()
2248 target->sync_flag |= SDTR_DONE; in nsp32_analyze_sdtr()
2279 if (get_period < data->synct[0].period_num) { in nsp32_analyze_sdtr()
2292 * acceptable NinjaSCSI-32Bi/UDE. in nsp32_analyze_sdtr()
2305 target->sync_flag |= SDTR_INITIATOR; in nsp32_analyze_sdtr()
2314 if (get_period < data->synct[0].period_num) { in nsp32_analyze_sdtr()
2315 get_period = data->synct[0].period_num; in nsp32_analyze_sdtr()
2329 target->period = get_period; in nsp32_analyze_sdtr()
2343 target->period = 0; in nsp32_analyze_sdtr()
2359 if (target->limit_entry >= data->syncnum) { in nsp32_search_period_entry()
2361 target->limit_entry = 0; in nsp32_search_period_entry()
2364 for (i = target->limit_entry; i < data->syncnum; i++) { in nsp32_search_period_entry()
2365 if (period >= data->synct[i].start_period && in nsp32_search_period_entry()
2366 period <= data->synct[i].end_period) { in nsp32_search_period_entry()
2375 if (i == data->syncnum) { in nsp32_search_period_entry()
2376 i = -1; in nsp32_search_period_entry()
2384 * target <-> initiator use ASYNC transfer
2388 unsigned char period = data->synct[target->limit_entry].period_num; in nsp32_set_async()
2390 target->offset = ASYNC_OFFSET; in nsp32_set_async()
2391 target->period = 0; in nsp32_set_async()
2392 target->syncreg = TO_SYNCREG(period, ASYNC_OFFSET); in nsp32_set_async()
2393 target->ackwidth = 0; in nsp32_set_async()
2394 target->sample_reg = 0; in nsp32_set_async()
2401 * target <-> initiator use maximum SYNC transfer
2410 period_num = data->synct[target->limit_entry].period_num; in nsp32_set_max_sync()
2411 *period = data->synct[target->limit_entry].start_period; in nsp32_set_max_sync()
2412 ackwidth = data->synct[target->limit_entry].ackwidth; in nsp32_set_max_sync()
2415 target->syncreg = TO_SYNCREG(period_num, *offset); in nsp32_set_max_sync()
2416 target->ackwidth = ackwidth; in nsp32_set_max_sync()
2417 target->offset = *offset; in nsp32_set_max_sync()
2418 target->sample_reg = 0; /* disable SREQ sampling */ in nsp32_set_max_sync()
2423 * target <-> initiator use entry number speed
2432 period = data->synct[entry].period_num; in nsp32_set_sync_entry()
2433 ackwidth = data->synct[entry].ackwidth; in nsp32_set_sync_entry()
2434 sample_rate = data->synct[entry].sample_rate; in nsp32_set_sync_entry()
2436 target->syncreg = TO_SYNCREG(period, offset); in nsp32_set_sync_entry()
2437 target->ackwidth = ackwidth; in nsp32_set_sync_entry()
2438 target->offset = offset; in nsp32_set_sync_entry()
2439 target->sample_reg = sample_rate | SAMPLING_ENABLE; in nsp32_set_sync_entry()
2451 * REQ-ACK handshake.
2455 unsigned int base = data->BaseAddress; in nsp32_wait_req() local
2466 bus = nsp32_read1(base, SCSI_BUS_MONITOR); in nsp32_wait_req()
2476 nsp32_msg(KERN_WARNING, "wait REQ timeout, req_bit: 0x%x", req_bit); in nsp32_wait_req()
2484 unsigned int base = data->BaseAddress; in nsp32_wait_sack() local
2495 bus = nsp32_read1(base, SCSI_BUS_MONITOR); in nsp32_wait_sack()
2505 nsp32_msg(KERN_WARNING, "wait SACK timeout, ack_bit: 0x%x", ack_bit); in nsp32_wait_sack()
2515 unsigned int base = data->BaseAddress; in nsp32_sack_assert() local
2518 busctrl = nsp32_read1(base, SCSI_BUS_CONTROL); in nsp32_sack_assert()
2520 nsp32_write1(base, SCSI_BUS_CONTROL, busctrl); in nsp32_sack_assert()
2528 unsigned int base = data->BaseAddress; in nsp32_sack_negate() local
2531 busctrl = nsp32_read1(base, SCSI_BUS_CONTROL); in nsp32_sack_negate()
2533 nsp32_write1(base, SCSI_BUS_CONTROL, busctrl); in nsp32_sack_negate()
2541 * 0x800-0x8ff: memory mapped I/O port
2542 * 0x900-0xbff: (map same 0x800-0x8ff I/O port image repeatedly)
2543 * 0xc00-0xfff: CardBus status registers
2567 data = (nsp32_hw_data *)host->hostdata; in nsp32_detect()
2571 host->irq = data->IrqNumber; in nsp32_detect()
2572 host->io_port = data->BaseAddress; in nsp32_detect()
2573 host->unique_id = data->BaseAddress; in nsp32_detect()
2574 host->n_io_port = data->NumAddress; in nsp32_detect()
2575 host->base = (unsigned long)data->MmioAddress; in nsp32_detect()
2577 data->Host = host; in nsp32_detect()
2578 spin_lock_init(&(data->Lock)); in nsp32_detect()
2580 data->cur_lunt = NULL; in nsp32_detect()
2581 data->cur_target = NULL; in nsp32_detect()
2586 data->trans_method = NSP32_TRANSFER_BUSMASTER; in nsp32_detect()
2593 data->clock = CLOCK_4; in nsp32_detect()
2598 switch (data->clock) { in nsp32_detect()
2600 /* If data->clock is CLOCK_4, then select 40M sync table. */ in nsp32_detect()
2601 data->synct = nsp32_sync_table_40M; in nsp32_detect()
2602 data->syncnum = ARRAY_SIZE(nsp32_sync_table_40M); in nsp32_detect()
2605 /* If data->clock is CLOCK_2, then select 20M sync table. */ in nsp32_detect()
2606 data->synct = nsp32_sync_table_20M; in nsp32_detect()
2607 data->syncnum = ARRAY_SIZE(nsp32_sync_table_20M); in nsp32_detect()
2610 /* If data->clock is PCICLK, then select pci sync table. */ in nsp32_detect()
2611 data->synct = nsp32_sync_table_pci; in nsp32_detect()
2612 data->syncnum = ARRAY_SIZE(nsp32_sync_table_pci); in nsp32_detect()
2618 data->clock = CLOCK_4; in nsp32_detect()
2619 data->synct = nsp32_sync_table_40M; in nsp32_detect()
2620 data->syncnum = ARRAY_SIZE(nsp32_sync_table_40M); in nsp32_detect()
2630 if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)) != 0) { in nsp32_detect()
2638 data->autoparam = dma_alloc_coherent(&pdev->dev, in nsp32_detect()
2639 sizeof(nsp32_autoparam), &(data->auto_paddr), in nsp32_detect()
2641 if (data->autoparam == NULL) { in nsp32_detect()
2647 * allocate scatter-gather DMA resource. in nsp32_detect()
2649 data->sg_list = dma_alloc_coherent(&pdev->dev, NSP32_SG_TABLE_SIZE, in nsp32_detect()
2650 &data->sg_paddr, GFP_KERNEL); in nsp32_detect()
2651 if (data->sg_list == NULL) { in nsp32_detect()
2656 for (i = 0; i < ARRAY_SIZE(data->lunt); i++) { in nsp32_detect()
2657 for (j = 0; j < ARRAY_SIZE(data->lunt[0]); j++) { in nsp32_detect()
2658 int offset = i * ARRAY_SIZE(data->lunt[0]) + j; in nsp32_detect()
2665 .sglun = &(data->sg_list[offset]), in nsp32_detect()
2666 .sglun_paddr = data->sg_paddr + (offset * sizeof(nsp32_sglun)), in nsp32_detect()
2669 data->lunt[i][j] = tmp; in nsp32_detect()
2676 for (i = 0; i < ARRAY_SIZE(data->target); i++) { in nsp32_detect()
2677 nsp32_target *target = &(data->target[i]); in nsp32_detect()
2679 target->limit_entry = 0; in nsp32_detect()
2680 target->sync_flag = 0; in nsp32_detect()
2689 data->resettime = 3; /* default 3 */ in nsp32_detect()
2697 snprintf(data->info_str, sizeof(data->info_str), in nsp32_detect()
2698 "NinjaSCSI-32Bi/UDE: irq %d, io 0x%lx+0x%x", in nsp32_detect()
2699 host->irq, host->io_port, host->n_io_port); in nsp32_detect()
2705 * NinjaSCSI-32Bi/UDE HBA EEPROM seems to exchange SDTR when in nsp32_detect()
2707 * un-asynchronous mode. It brings the merit that this HBA is in nsp32_detect()
2710 * it prevents device transfer speed from effecting EEPROM start-up in nsp32_detect()
2711 * SDTR. NinjaSCSI-32Bi/UDE has the feature if EEPROM is set as in nsp32_detect()
2712 * Auto Mode, then FAST-10M is selected when SCSI devices are in nsp32_detect()
2721 ret = request_irq(host->irq, do_nsp32_isr, IRQF_SHARED, "nsp32", data); in nsp32_detect()
2724 "SCSI PCI controller. Interrupt: %d", host->irq); in nsp32_detect()
2731 res = request_region(host->io_port, host->n_io_port, "nsp32"); in nsp32_detect()
2734 "I/O region 0x%x+0x%x is already used", in nsp32_detect()
2735 data->BaseAddress, data->NumAddress); in nsp32_detect()
2739 ret = scsi_add_host(host, &pdev->dev); in nsp32_detect()
2749 release_region(host->io_port, host->n_io_port); in nsp32_detect()
2752 free_irq(host->irq, data); in nsp32_detect()
2755 dma_free_coherent(&pdev->dev, NSP32_SG_TABLE_SIZE, in nsp32_detect()
2756 data->sg_list, data->sg_paddr); in nsp32_detect()
2759 dma_free_coherent(&pdev->dev, sizeof(nsp32_autoparam), in nsp32_detect()
2760 data->autoparam, data->auto_paddr); in nsp32_detect()
2771 nsp32_hw_data *data = (nsp32_hw_data *)host->hostdata; in nsp32_release()
2773 if (data->autoparam) { in nsp32_release()
2774 dma_free_coherent(&data->Pci->dev, sizeof(nsp32_autoparam), in nsp32_release()
2775 data->autoparam, data->auto_paddr); in nsp32_release()
2778 if (data->sg_list) { in nsp32_release()
2779 dma_free_coherent(&data->Pci->dev, NSP32_SG_TABLE_SIZE, in nsp32_release()
2780 data->sg_list, data->sg_paddr); in nsp32_release()
2783 if (host->irq) { in nsp32_release()
2784 free_irq(host->irq, data); in nsp32_release()
2787 if (host->io_port && host->n_io_port) { in nsp32_release()
2788 release_region(host->io_port, host->n_io_port); in nsp32_release()
2791 if (data->MmioAddress) { in nsp32_release()
2792 iounmap(data->MmioAddress); in nsp32_release()
2800 nsp32_hw_data *data = (nsp32_hw_data *)shpnt->hostdata; in nsp32_info()
2802 return data->info_str; in nsp32_info()
2811 nsp32_hw_data *data = (nsp32_hw_data *)SCpnt->device->host->hostdata; in nsp32_eh_abort()
2812 unsigned int base = SCpnt->device->host->io_port; in nsp32_eh_abort() local
2816 if (data->cur_lunt->SCpnt == NULL) { in nsp32_eh_abort()
2821 if (data->cur_target->sync_flag & (SDTR_INITIATOR | SDTR_TARGET)) { in nsp32_eh_abort()
2823 data->cur_target->sync_flag = 0; in nsp32_eh_abort()
2824 nsp32_set_async(data, data->cur_target); in nsp32_eh_abort()
2827 nsp32_write2(base, TRANSFER_CONTROL, 0); in nsp32_eh_abort()
2828 nsp32_write2(base, BM_CNT, 0); in nsp32_eh_abort()
2830 SCpnt->result = DID_ABORT << 16; in nsp32_eh_abort()
2839 unsigned int base = data->BaseAddress; in nsp32_do_bus_reset() local
2850 nsp32_write2(base, TRANSFER_CONTROL, 0); in nsp32_do_bus_reset()
2851 nsp32_write4(base, BM_CNT, 0); in nsp32_do_bus_reset()
2852 nsp32_write4(base, CLR_COUNTER, CLRCOUNTER_ALLMASK); in nsp32_do_bus_reset()
2858 for (i = 0; i < ARRAY_SIZE(data->target); i++) { in nsp32_do_bus_reset()
2859 nsp32_target *target = &data->target[i]; in nsp32_do_bus_reset()
2861 target->sync_flag = 0; in nsp32_do_bus_reset()
2868 nsp32_write1(base, SCSI_BUS_CONTROL, BUSCTL_RST); in nsp32_do_bus_reset()
2870 nsp32_write1(base, SCSI_BUS_CONTROL, 0); in nsp32_do_bus_reset()
2872 intrdat = nsp32_read2(base, IRQ_STATUS); /* dummy read */ in nsp32_do_bus_reset()
2873 nsp32_dbg(NSP32_DEBUG_BUSRESET, "irq:1: 0x%x", intrdat); in nsp32_do_bus_reset()
2876 data->CurrentSC = NULL; in nsp32_do_bus_reset()
2881 struct Scsi_Host *host = SCpnt->device->host; in nsp32_eh_host_reset()
2882 unsigned int base = SCpnt->device->host->io_port; in nsp32_eh_host_reset() local
2883 nsp32_hw_data *data = (nsp32_hw_data *)host->hostdata; in nsp32_eh_host_reset()
2886 nsp32_dbg(NSP32_DEBUG_BUSRESET, "SCpnt=0x%x", SCpnt); in nsp32_eh_host_reset()
2888 spin_lock_irq(SCpnt->device->host->host_lock); in nsp32_eh_host_reset()
2891 nsp32_write2(base, IRQ_CONTROL, IRQ_CONTROL_ALL_IRQ_MASK); in nsp32_eh_host_reset()
2893 nsp32_write2(base, IRQ_CONTROL, 0); in nsp32_eh_host_reset()
2895 spin_unlock_irq(SCpnt->device->host->host_lock); in nsp32_eh_host_reset()
2909 int vendor = data->pci_devid->vendor; in nsp32_getprom_param()
2910 int device = data->pci_devid->device; in nsp32_getprom_param()
2919 nsp32_msg(KERN_INFO, "No EEPROM detected: 0x%x", ret); in nsp32_getprom_param()
2924 nsp32_msg(KERN_INFO, "Invalid number: 0x%x", ret); in nsp32_getprom_param()
2949 "rom address 0x%x : 0x%x", i, val); in nsp32_getprom_param()
2957 * AT24C01A (Logitec: LHA-600S), AT24C02 (Melco Buffalo: IFC-USLP) data map:
2960 * 0x00 - 0x06 : Device Synchronous Transfer Period (SCSI ID 0 - 6)
2961 * Value 0x0: ASYNC, 0x0c: Ultra-20M, 0x19: Fast-10M
2964 * 0x08 - 0x0f : Not Used? (0x0)
2972 * Bit 7 6 5 4 3 2 1 0
2973 * | <----------------->
2975 * |-> Value 0: ALL scan, Value 1: Manual
2976 * 0x15 - 0x1b : Not Used? (0)
2978 * 0x1d - 0x7c : Not Used (0xff)
2995 data->resettime = nsp32_prom_read(data, 0x12); in nsp32_getprom_at24()
3002 * same or lower than 3, then transfer speed is set as ULTRA-20M. in nsp32_getprom_at24()
3004 * than 4, then transfer speed is set as FAST-10M. in nsp32_getprom_at24()
3008 * forced as ULTRA-20M. in nsp32_getprom_at24()
3032 target = &data->target[i]; in nsp32_getprom_at24()
3034 target->limit_entry = 0; /* set as ULTRA20M */ in nsp32_getprom_at24()
3042 target->limit_entry = entry; in nsp32_getprom_at24()
3051 * C16 110 (I-O Data: SC-NBD) data map:
3054 * 0x00 - 0x06 : Device Synchronous Transfer Period (SCSI ID 0 - 6)
3057 * 0x08 - 0x0f : Not Used? (0x0)
3060 * 0x11 : Bus Reset Delay Time (0x00-0x20)
3063 * 0x13 - 0x19 : Disconnection
3065 * 0x1a - 0x7c : Not Used? (0)
3081 data->resettime = nsp32_prom_read(data, 0x11); in nsp32_getprom_c16()
3087 target = &data->target[i]; in nsp32_getprom_c16()
3099 case 3: /* ASYNC */ in nsp32_getprom_c16()
3111 target->limit_entry = entry; in nsp32_getprom_c16()
3144 for (i = 7; i >= 0; i--) { in nsp32_prom_read()
3171 for (i = 7; i >= 0; i--) { in nsp32_prom_read()
3186 int base = data->BaseAddress; in nsp32_prom_set() local
3189 tmp = nsp32_index_read1(base, SERIAL_ROM_CTL); in nsp32_prom_set()
3197 nsp32_index_write1(base, SERIAL_ROM_CTL, tmp); in nsp32_prom_set()
3204 int base = data->BaseAddress; in nsp32_prom_get() local
3213 tmp = nsp32_index_read1(base, SERIAL_ROM_CTL) & bit; in nsp32_prom_get()
3233 * SDA 1->0 is start condition */ in nsp32_prom_start()
3282 nsp32_msg(KERN_INFO, "pci-suspend: pdev=0x%p, state.event=%x, slot=%s, host=0x%p", in nsp32_suspend()
3296 nsp32_hw_data *data = (nsp32_hw_data *)host->hostdata; in nsp32_resume()
3299 nsp32_msg(KERN_INFO, "pci-resume: pdev=0x%p, slot=%s, host=0x%p", in nsp32_resume()
3306 reg = nsp32_read2(data->BaseAddress, INDEX_REG); in nsp32_resume()
3308 nsp32_msg(KERN_INFO, "io=0x%x reg=0x%x", data->BaseAddress, reg); in nsp32_resume()
3341 data->Pci = pdev; in nsp32_probe()
3342 data->pci_devid = id; in nsp32_probe()
3343 data->IrqNumber = pdev->irq; in nsp32_probe()
3344 data->BaseAddress = pci_resource_start(pdev, 0); in nsp32_probe()
3345 data->NumAddress = pci_resource_len (pdev, 0); in nsp32_probe()
3346 data->MmioAddress = pci_ioremap_bar(pdev, 1); in nsp32_probe()
3347 data->MmioLength = pci_resource_len (pdev, 1); in nsp32_probe()
3353 nsp32_msg(KERN_INFO, "irq: %i mmio: %p+0x%lx slot: %s model: %s", in nsp32_probe()
3354 pdev->irq, in nsp32_probe()
3355 data->MmioAddress, data->MmioLength, in nsp32_probe()
3357 nsp32_model[id->driver_data]); in nsp32_probe()