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

3     NinjaSCSI-3 / NinjaSCSI-32Bi PCMCIA SCSI host adapter card driver
21 I-O DATA PCSC-F (Workbit NinjaSCSI-3)
22 "WBT", "NinjaSCSI-3", "R1.0"
23 I-O DATA CBSC-II (Workbit NinjaSCSI-32Bi in 16bit mode)
56 MODULE_DESCRIPTION("WorkBit NinjaSCSI-3 / NinjaSCSI-32Bi(16bit) PCMCIA SCSI host adapter module");
81 .name = "WorkBit NinjaSCSI-3/32Bi(16bit)",
90 .dma_boundary = PAGE_SIZE - 1,
94 static nsp_hw_data nsp_data_base; /* attach <-> detect glue */
116 #define NSP_DEBUG_INTR BIT(3)
169 printk("nsp_cs-debug: 0x%x %s (%d): %s\n", mask, func, line, buf); in nsp_cs_dmessage()
178 * You must be set SCpnt->result before call this function.
182 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_scsi_done()
184 data->CurrentSC = NULL; in nsp_scsi_done()
193 /*unsigned int host_id = SCpnt->device->host->this_id;*/ in nsp_queuecommand_lck()
194 /*unsigned int base = SCpnt->device->host->io_port;*/ in nsp_queuecommand_lck()
197 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_queuecommand_lck()
200 "SCpnt=0x%p target=%d lun=%llu sglist=0x%p bufflen=%d sg_count=%d", in nsp_queuecommand_lck()
201 SCpnt, target, SCpnt->device->lun, scsi_sglist(SCpnt), in nsp_queuecommand_lck()
203 //nsp_dbg(NSP_DEBUG_QUEUECOMMAND, "before CurrentSC=0x%p", data->CurrentSC); in nsp_queuecommand_lck()
205 if (data->CurrentSC != NULL) { in nsp_queuecommand_lck()
207 SCpnt->result = DID_BAD_TARGET << 16; in nsp_queuecommand_lck()
213 /* XXX: pcmcia-cs generates SCSI command with "scsi_info" utility. in nsp_queuecommand_lck()
215 if (data->ScsiInfo->stop != 0) { in nsp_queuecommand_lck()
217 SCpnt->result = DID_BAD_TARGET << 16; in nsp_queuecommand_lck()
225 data->CurrentSC = SCpnt; in nsp_queuecommand_lck()
227 scsi_pointer->Status = SAM_STAT_CHECK_CONDITION; in nsp_queuecommand_lck()
228 scsi_pointer->Message = 0; in nsp_queuecommand_lck()
229 scsi_pointer->have_data_in = IO_UNKNOWN; in nsp_queuecommand_lck()
230 scsi_pointer->sent_command = 0; in nsp_queuecommand_lck()
231 scsi_pointer->phase = PH_UNDETERMINED; in nsp_queuecommand_lck()
241 scsi_pointer->buffer = scsi_sglist(SCpnt); in nsp_queuecommand_lck()
242 scsi_pointer->ptr = BUFFER_ADDR(SCpnt); in nsp_queuecommand_lck()
243 scsi_pointer->this_residual = scsi_pointer->buffer->length; in nsp_queuecommand_lck()
244 scsi_pointer->buffers_residual = scsi_sg_count(SCpnt) - 1; in nsp_queuecommand_lck()
246 scsi_pointer->ptr = NULL; in nsp_queuecommand_lck()
247 scsi_pointer->this_residual = 0; in nsp_queuecommand_lck()
248 scsi_pointer->buffer = NULL; in nsp_queuecommand_lck()
249 scsi_pointer->buffers_residual = 0; in nsp_queuecommand_lck()
254 SCpnt->result = DID_BUS_BUSY << 16; in nsp_queuecommand_lck()
262 data->CmdId++; in nsp_queuecommand_lck()
274 unsigned int base = data->BaseAddress; in DEF_SCSI_QCMD() local
285 transfer_mode_reg |= data->TransferMode; in DEF_SCSI_QCMD()
287 nsp_index_write(base, TRANSFERMODE, transfer_mode_reg); in DEF_SCSI_QCMD()
299 for ( i = 0; i < ARRAY_SIZE(data->Sync); i++ ) { in nsphw_init_sync()
300 data->Sync[i] = tmp_sync; in nsphw_init_sync()
309 unsigned int base = data->BaseAddress; in nsphw_init() local
311 nsp_dbg(NSP_DEBUG_INIT, "in base=0x%x", base); in nsphw_init()
313 data->ScsiClockDiv = CLOCK_40M | FAST_20; in nsphw_init()
314 data->CurrentSC = NULL; in nsphw_init()
315 data->FifoCount = 0; in nsphw_init()
316 data->TransferMode = MODE_IO8; in nsphw_init()
321 nsp_write(base, IRQCONTROL, IRQCONTROL_ALLMASK); in nsphw_init()
324 nsp_write(base, IFSELECT, IF_IFSEL); in nsphw_init()
326 nsp_index_write(base, SCSIIRQMODE, 0); in nsphw_init()
328 nsp_index_write(base, TRANSFERMODE, MODE_IO8); in nsphw_init()
329 nsp_index_write(base, CLOCKDIV, data->ScsiClockDiv); in nsphw_init()
331 nsp_index_write(base, PARITYCTRL, 0); in nsphw_init()
332 nsp_index_write(base, POINTERCLR, POINTER_CLEAR | in nsphw_init()
338 nsp_write(base, IFSELECT, IF_REGSEL); in nsphw_init()
339 nsp_index_write(base, TERMPWRCTRL, 0); in nsphw_init()
340 if ((nsp_index_read(base, OTHERCONTROL) & TPWR_SENSE) == 0) { in nsphw_init()
342 nsp_index_write(base, TERMPWRCTRL, POWER_ON); in nsphw_init()
345 nsp_index_write(base, TIMERCOUNT, 0); in nsphw_init()
346 nsp_index_write(base, TIMERCOUNT, 0); /* requires 2 times!! */ in nsphw_init()
348 nsp_index_write(base, SYNCREG, 0); in nsphw_init()
349 nsp_index_write(base, ACKWIDTH, 0); in nsphw_init()
352 nsp_index_write(base, SCSIIRQMODE, SCSI_PHASE_CHANGE_EI | in nsphw_init()
355 nsp_write(base, IRQCONTROL, IRQCONTROL_ALLCLEAR); in nsphw_init()
366 unsigned int host_id = SCpnt->device->host->this_id; in nsphw_start_selection()
367 unsigned int base = SCpnt->device->host->io_port; in nsphw_start_selection() local
369 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsphw_start_selection()
375 phase = nsp_index_read(base, SCSIBUSMON); in nsphw_start_selection()
383 scsi_pointer->phase = PH_ARBSTART; in nsphw_start_selection()
384 nsp_index_write(base, SETARBIT, ARBIT_GO); in nsphw_start_selection()
389 arbit = nsp_index_read(base, ARBITSTATUS); in nsphw_start_selection()
393 (time_out-- != 0)); in nsphw_start_selection()
397 nsp_index_write(base, SETARBIT, ARBIT_FLAG_CLEAR); in nsphw_start_selection()
403 scsi_pointer->phase = PH_SELSTART; in nsphw_start_selection()
404 udelay(3); /* wait 2.4us */ in nsphw_start_selection()
405 nsp_index_write(base, SCSIDATALATCH, BIT(host_id) | BIT(target)); in nsphw_start_selection()
406 nsp_index_write(base, SCSIBUSCTRL, SCSI_SEL | SCSI_BSY | SCSI_ATN); in nsphw_start_selection()
408 nsp_index_write(base, SCSIBUSCTRL, SCSI_SEL | SCSI_BSY | SCSI_DATAOUT_ENB | SCSI_ATN); in nsphw_start_selection()
409 nsp_index_write(base, SETARBIT, ARBIT_FLAG_CLEAR); in nsphw_start_selection()
411 nsp_index_write(base, SCSIBUSCTRL, SCSI_SEL | SCSI_DATAOUT_ENB | SCSI_ATN); in nsphw_start_selection()
415 data->SelectionTimeOut = 1; in nsphw_start_selection()
431 {0x26, 0x32, 0x7, 3}, /* 5MB 200ns*/
448 // unsigned char lun = SCpnt->device->lun; in nsp_analyze_sdtr()
449 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_analyze_sdtr()
450 sync_data *sync = &(data->Sync[target]); in nsp_analyze_sdtr()
456 period = sync->SyncPeriod; in nsp_analyze_sdtr()
457 offset = sync->SyncOffset; in nsp_analyze_sdtr()
459 nsp_dbg(NSP_DEBUG_SYNC, "period=0x%x, offset=0x%x", period, offset); in nsp_analyze_sdtr()
461 if ((data->ScsiClockDiv & (BIT(0)|BIT(1))) == CLOCK_20M) { in nsp_analyze_sdtr()
467 for (; sync_table->max_period != 0; sync_table++) { in nsp_analyze_sdtr()
468 if ( period >= sync_table->min_period && in nsp_analyze_sdtr()
469 period <= sync_table->max_period ) { in nsp_analyze_sdtr()
474 if (period != 0 && sync_table->max_period == 0) { in nsp_analyze_sdtr()
480 sync->SyncPeriod = 0; in nsp_analyze_sdtr()
481 sync->SyncOffset = 0; in nsp_analyze_sdtr()
482 sync->SyncRegister = 0; in nsp_analyze_sdtr()
483 sync->AckWidth = 0; in nsp_analyze_sdtr()
488 sync->SyncRegister = (sync_table->chip_period << SYNCREG_PERIOD_SHIFT) | in nsp_analyze_sdtr()
490 sync->AckWidth = sync_table->ack_width; in nsp_analyze_sdtr()
492 nsp_dbg(NSP_DEBUG_SYNC, "sync_reg=0x%x, ack_width=0x%x", sync->SyncRegister, sync->AckWidth); in nsp_analyze_sdtr()
503 unsigned int base = SCpnt->device->host->io_port; in nsp_start_timer() local
504 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_start_timer()
506 //nsp_dbg(NSP_DEBUG_INTR, "in SCpnt=0x%p, time=%d", SCpnt, time); in nsp_start_timer()
507 data->TimerCount = time; in nsp_start_timer()
508 nsp_index_write(base, TIMERCOUNT, time); in nsp_start_timer()
517 unsigned int base = SCpnt->device->host->io_port; in nsp_negate_signal() local
526 reg = nsp_index_read(base, SCSIBUSMON); in nsp_negate_signal()
530 } while ((--time_out != 0) && (reg & mask) != 0); in nsp_negate_signal()
546 unsigned int base = SCpnt->device->host->io_port; in nsp_expect_signal() local
550 //nsp_dbg(NSP_DEBUG_INTR, "current_phase=0x%x, mask=0x%x", current_phase, mask); in nsp_expect_signal()
554 phase = nsp_index_read(base, SCSIBUSMON); in nsp_expect_signal()
556 //nsp_dbg(NSP_DEBUG_INTR, "ret -1"); in nsp_expect_signal()
557 return -1; in nsp_expect_signal()
559 i_src = nsp_read(base, IRQSTATUS); in nsp_expect_signal()
565 //nsp_dbg(NSP_DEBUG_INTR, "ret 1 phase=0x%x", phase); in nsp_expect_signal()
568 } while(time_out-- != 0); in nsp_expect_signal()
571 return -1; in nsp_expect_signal()
580 unsigned int base = SCpnt->device->host->io_port; in nsp_xfer() local
581 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_xfer()
582 char *buf = data->MsgBuffer; in nsp_xfer()
583 int len = min(MSGBUF_SIZE, data->MsgLen); in nsp_xfer()
588 for (ptr = 0; len > 0; len--, ptr++) { in nsp_xfer()
597 if (len == 1 && scsi_pointer->phase == PH_MSG_OUT) { in nsp_xfer()
598 nsp_index_write(base, SCSIBUSCTRL, AUTODIRECTION | ACKENB); in nsp_xfer()
604 buf[ptr] = nsp_index_read(base, SCSIDATAWITHACK); in nsp_xfer()
607 nsp_index_write(base, SCSIDATAWITHACK, buf[ptr]); in nsp_xfer()
621 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_dataphase_bypass()
626 if (scsi_pointer->have_data_in != IO_IN) { in nsp_dataphase_bypass()
631 if (data->FifoCount == count) { in nsp_dataphase_bypass()
641 scsi_pointer->phase = PH_DATA; in nsp_dataphase_bypass()
653 unsigned int base = SCpnt->device->host->io_port; in nsp_reselected() local
654 unsigned int host_id = SCpnt->device->host->this_id; in nsp_reselected()
655 //nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_reselected()
662 id_reg = nsp_index_read(base, RESELECTID); in nsp_reselected()
680 bus_reg = nsp_index_read(base, SCSIBUSCTRL) & ~(SCSI_BSY | SCSI_ATN); in nsp_reselected()
681 nsp_index_write(base, SCSIBUSCTRL, bus_reg); in nsp_reselected()
682 nsp_index_write(base, SCSIBUSCTRL, bus_reg | AUTODIRECTION | ACKENB); in nsp_reselected()
690 unsigned int base = SCpnt->device->host->io_port; in nsp_fifo_count() local
694 nsp_index_write(base, POINTERCLR, POINTER_CLEAR | ACK_COUNTER); in nsp_fifo_count()
696 l = nsp_index_read(base, TRANSFERCOUNT); in nsp_fifo_count()
697 m = nsp_index_read(base, TRANSFERCOUNT); in nsp_fifo_count()
698 h = nsp_index_read(base, TRANSFERCOUNT); in nsp_fifo_count()
699 nsp_index_read(base, TRANSFERCOUNT); /* required this! */ in nsp_fifo_count()
703 //nsp_dbg(NSP_DEBUG_DATA_IO, "count=0x%x", count); in nsp_fifo_count()
718 unsigned int base = SCpnt->device->host->io_port; in nsp_pio_read() local
719 unsigned long mmio_base = SCpnt->device->host->base; in nsp_pio_read()
720 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_pio_read()
725 ocount = data->FifoCount; in nsp_pio_read()
727 …nsp_dbg(NSP_DEBUG_DATA_IO, "in SCpnt=0x%p resid=%d ocount=%d ptr=0x%p this_residual=%d buffers=0x%… in nsp_pio_read()
728 SCpnt, scsi_get_resid(SCpnt), ocount, scsi_pointer->ptr, in nsp_pio_read()
729 scsi_pointer->this_residual, scsi_pointer->buffer, in nsp_pio_read()
730 scsi_pointer->buffers_residual); in nsp_pio_read()
734 while ((time_out-- != 0) && in nsp_pio_read()
735 (scsi_pointer->this_residual > 0 || in nsp_pio_read()
736 scsi_pointer->buffers_residual > 0)) { in nsp_pio_read()
738 stat = nsp_index_read(base, SCSIBUSMON); in nsp_pio_read()
742 res = nsp_fifo_count(SCpnt) - ocount; in nsp_pio_read()
743 …//nsp_dbg(NSP_DEBUG_DATA_IO, "ptr=0x%p this=0x%x ocount=0x%x res=0x%x", scsi_pointer->ptr, scsi_po… in nsp_pio_read()
746 //nsp_dbg(NSP_DEBUG_DATA_IO, " wait for data this=%d", scsi_pointer->this_residual); in nsp_pio_read()
749 nsp_dbg(NSP_DEBUG_DATA_IO, "phase changed stat=0x%x", stat); in nsp_pio_read()
754 fifo_stat = nsp_read(base, FIFOSTATUS); in nsp_pio_read()
760 res = min(res, scsi_pointer->this_residual); in nsp_pio_read()
762 switch (data->TransferMode) { in nsp_pio_read()
765 nsp_fifo32_read(base, scsi_pointer->ptr, res >> 2); in nsp_pio_read()
768 nsp_fifo8_read(base, scsi_pointer->ptr, res); in nsp_pio_read()
773 nsp_mmio_fifo32_read(mmio_base, scsi_pointer->ptr, in nsp_pio_read()
782 nsp_inc_resid(SCpnt, -res); in nsp_pio_read()
783 scsi_pointer->ptr += res; in nsp_pio_read()
784 scsi_pointer->this_residual -= res; in nsp_pio_read()
786 …//nsp_dbg(NSP_DEBUG_DATA_IO, "ptr=0x%p this_residual=0x%x ocount=0x%x", scsi_pointer->ptr, scsi_po… in nsp_pio_read()
789 if (scsi_pointer->this_residual == 0 && in nsp_pio_read()
790 scsi_pointer->buffers_residual != 0 ) { in nsp_pio_read()
792 scsi_pointer->buffers_residual--; in nsp_pio_read()
793 scsi_pointer->buffer = sg_next(scsi_pointer->buffer); in nsp_pio_read()
794 scsi_pointer->ptr = BUFFER_ADDR(SCpnt); in nsp_pio_read()
795 scsi_pointer->this_residual = in nsp_pio_read()
796 scsi_pointer->buffer->length; in nsp_pio_read()
799 …//nsp_dbg(NSP_DEBUG_DATA_IO, "page: 0x%p, off: 0x%x", scsi_pointer->buffer->page, scsi_pointer->bu… in nsp_pio_read()
803 data->FifoCount = ocount; in nsp_pio_read()
807 scsi_get_resid(SCpnt), scsi_pointer->this_residual, in nsp_pio_read()
808 scsi_pointer->buffers_residual); in nsp_pio_read()
810 nsp_dbg(NSP_DEBUG_DATA_IO, "read ocount=0x%x", ocount); in nsp_pio_read()
811 nsp_dbg(NSP_DEBUG_DATA_IO, "r cmd=%d resid=0x%x\n", data->CmdId, in nsp_pio_read()
821 unsigned int base = SCpnt->device->host->io_port; in nsp_pio_write() local
822 unsigned long mmio_base = SCpnt->device->host->base; in nsp_pio_write()
823 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_pio_write()
828 ocount = data->FifoCount; in nsp_pio_write()
830 …nsp_dbg(NSP_DEBUG_DATA_IO, "in fifocount=%d ptr=0x%p this_residual=%d buffers=0x%p nbuf=%d resid=0 in nsp_pio_write()
831 data->FifoCount, scsi_pointer->ptr, scsi_pointer->this_residual, in nsp_pio_write()
832 scsi_pointer->buffer, scsi_pointer->buffers_residual, in nsp_pio_write()
837 while ((time_out-- != 0) && in nsp_pio_write()
838 (scsi_pointer->this_residual > 0 || in nsp_pio_write()
839 scsi_pointer->buffers_residual > 0)) { in nsp_pio_write()
840 stat = nsp_index_read(base, SCSIBUSMON); in nsp_pio_write()
844 res = ocount - nsp_fifo_count(SCpnt); in nsp_pio_write()
846 nsp_dbg(NSP_DEBUG_DATA_IO, "phase changed stat=0x%x, res=%d\n", stat, res); in nsp_pio_write()
849 scsi_pointer->ptr -= res; in nsp_pio_write()
850 scsi_pointer->this_residual += res; in nsp_pio_write()
851 ocount -= res; in nsp_pio_write()
856 res = ocount - nsp_fifo_count(SCpnt); in nsp_pio_write()
858 nsp_dbg(NSP_DEBUG_DATA_IO, "wait for all data out. ocount=0x%x res=%d", ocount, res); in nsp_pio_write()
862 res = min(scsi_pointer->this_residual, WFIFO_CRIT); in nsp_pio_write()
864 …//nsp_dbg(NSP_DEBUG_DATA_IO, "ptr=0x%p this=0x%x res=0x%x", scsi_pointer->ptr, scsi_pointer->this_… in nsp_pio_write()
865 switch (data->TransferMode) { in nsp_pio_write()
868 nsp_fifo32_write(base, scsi_pointer->ptr, res >> 2); in nsp_pio_write()
871 nsp_fifo8_write(base, scsi_pointer->ptr, res); in nsp_pio_write()
876 nsp_mmio_fifo32_write(mmio_base, scsi_pointer->ptr, in nsp_pio_write()
885 nsp_inc_resid(SCpnt, -res); in nsp_pio_write()
886 scsi_pointer->ptr += res; in nsp_pio_write()
887 scsi_pointer->this_residual -= res; in nsp_pio_write()
891 if (scsi_pointer->this_residual == 0 && in nsp_pio_write()
892 scsi_pointer->buffers_residual != 0 ) { in nsp_pio_write()
894 scsi_pointer->buffers_residual--; in nsp_pio_write()
895 scsi_pointer->buffer = sg_next(scsi_pointer->buffer); in nsp_pio_write()
896 scsi_pointer->ptr = BUFFER_ADDR(SCpnt); in nsp_pio_write()
897 scsi_pointer->this_residual = in nsp_pio_write()
898 scsi_pointer->buffer->length; in nsp_pio_write()
903 data->FifoCount = ocount; in nsp_pio_write()
906 nsp_msg(KERN_DEBUG, "pio write timeout resid=0x%x", in nsp_pio_write()
909 nsp_dbg(NSP_DEBUG_DATA_IO, "write ocount=0x%x", ocount); in nsp_pio_write()
910 nsp_dbg(NSP_DEBUG_DATA_IO, "w cmd=%d resid=0x%x\n", data->CmdId, in nsp_pio_write()
921 unsigned int base = SCpnt->device->host->io_port; in nsp_nexus() local
923 // unsigned char lun = SCpnt->device->lun; in nsp_nexus()
924 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_nexus()
925 sync_data *sync = &(data->Sync[target]); in nsp_nexus()
927 //nsp_dbg(NSP_DEBUG_DATA_IO, "in SCpnt=0x%p", SCpnt); in nsp_nexus()
930 nsp_index_write(base, SYNCREG, sync->SyncRegister); in nsp_nexus()
931 nsp_index_write(base, ACKWIDTH, sync->AckWidth); in nsp_nexus()
935 data->TransferMode = MODE_IO8; in nsp_nexus()
937 data->TransferMode = MODE_MEM32; in nsp_nexus()
939 data->TransferMode = MODE_IO32; in nsp_nexus()
941 data->TransferMode = MODE_IO8; in nsp_nexus()
948 data->FifoCount = 0; in nsp_nexus()
949 nsp_index_write(base, POINTERCLR, POINTER_CLEAR | in nsp_nexus()
963 unsigned int base; in nspintr() local
973 //nsp_dbg(NSP_DEBUG_INTR, "dev_id=0x%p", dev_id); in nspintr()
974 //nsp_dbg(NSP_DEBUG_INTR, "host=0x%p", ((scsi_info_t *)dev_id)->host); in nspintr()
977 ((scsi_info_t *)dev_id)->host != NULL ) { in nspintr()
980 data = (nsp_hw_data *)info->host->hostdata; in nspintr()
986 //nsp_dbg(NSP_DEBUG_INTR, "&nsp_data_base=0x%p, dev_id=0x%p", &nsp_data_base, dev_id); in nspintr()
988 base = data->BaseAddress; in nspintr()
989 //nsp_dbg(NSP_DEBUG_INTR, "base=0x%x", base); in nspintr()
994 nsp_write(base, IRQCONTROL, IRQCONTROL_IRQDISABLE); in nspintr()
995 irq_status = nsp_read(base, IRQSTATUS); in nspintr()
996 //nsp_dbg(NSP_DEBUG_INTR, "irq_status=0x%x", irq_status); in nspintr()
998 nsp_write(base, IRQCONTROL, 0); in nspintr()
1007 phase = nsp_index_read(base, SCSIBUSMON); in nspintr()
1009 irq_phase = nsp_index_read(base, IRQPHASESENCE); in nspintr()
1014 //nsp_dbg(NSP_DEBUG_INTR, "irq_phase=0x%x", irq_phase); in nspintr()
1019 //nsp_dbg(NSP_DEBUG_INTR, "timercount=%d", data->TimerCount); in nspintr()
1020 if (data->TimerCount != 0) { in nspintr()
1022 nsp_index_write(base, TIMERCOUNT, 0); in nspintr()
1023 nsp_index_write(base, TIMERCOUNT, 0); in nspintr()
1024 data->TimerCount = 0; in nspintr()
1028 data->SelectionTimeOut == 0) { in nspintr()
1030 nsp_write(base, IRQCONTROL, IRQCONTROL_TIMER_CLEAR); in nspintr()
1034 nsp_write(base, IRQCONTROL, IRQCONTROL_TIMER_CLEAR | IRQCONTROL_FIFO_CLEAR); in nspintr()
1043 if(data->CurrentSC != NULL) { in nspintr()
1044 tmpSC = data->CurrentSC; in nspintr()
1046 tmpSC->result = (DID_RESET << 16) | in nspintr()
1047 ((scsi_pointer->Message & 0xff) << 8) | in nspintr()
1048 ((scsi_pointer->Status & 0xff) << 0); in nspintr()
1054 if (data->CurrentSC == NULL) { in nspintr()
1055 …nsp_msg(KERN_ERR, "CurrentSC==NULL irq_status=0x%x phase=0x%x irq_phase=0x%x this can't be happen.… in nspintr()
1061 tmpSC = data->CurrentSC; in nspintr()
1063 target = tmpSC->device->id; in nspintr()
1064 lun = tmpSC->device->lun; in nspintr()
1065 sync_neg = &(data->Sync[target].SyncNegotiation); in nspintr()
1073 nsp_write(base, IRQCONTROL, IRQCONTROL_RESELECT_CLEAR); in nspintr()
1085 switch (scsi_pointer->phase) { in nspintr()
1089 //nsp_dbg(NSP_DEBUG_INTR, "selection count=%d", data->SelectionTimeOut); in nspintr()
1090 if (data->SelectionTimeOut >= NSP_SELTIMEOUT) { in nspintr()
1092 data->SelectionTimeOut = 0; in nspintr()
1093 nsp_index_write(base, SCSIBUSCTRL, 0); in nspintr()
1095 tmpSC->result = DID_TIME_OUT << 16; in nspintr()
1100 data->SelectionTimeOut += 1; in nspintr()
1107 data->SelectionTimeOut = 0; in nspintr()
1108 scsi_pointer->phase = PH_SELECTED; in nspintr()
1109 nsp_index_write(base, SCSIBUSCTRL, SCSI_ATN); in nspintr()
1111 nsp_index_write(base, SCSIBUSCTRL, SCSI_ATN | AUTODIRECTION | ACKENB); in nspintr()
1119 tmpSC->result = DID_ABORT << 16; in nspintr()
1137 if ((scsi_pointer->phase == PH_MSG_IN || in nspintr()
1138 scsi_pointer->phase == PH_MSG_OUT) && in nspintr()
1140 …nsp_dbg(NSP_DEBUG_INTR, "normal disconnect irq_status=0x%x, phase=0x%x, irq_phase=0x%x", irq_statu… in nspintr()
1145 if (scsi_pointer->Message == COMMAND_COMPLETE) { in nspintr()
1146 tmpSC->result = (DID_OK << 16) | in nspintr()
1147 ((scsi_pointer->Message & 0xff) << 8) | in nspintr()
1148 ((scsi_pointer->Status & 0xff) << 0); in nspintr()
1149 nsp_dbg(NSP_DEBUG_INTR, "command complete result=0x%x", tmpSC->result); in nspintr()
1161 …nsp_msg(KERN_DEBUG, "unexpected bus free. irq_status=0x%x, phase=0x%x, irq_phase=0x%x", irq_status… in nspintr()
1164 tmpSC->result = DID_ERROR << 16; in nspintr()
1177 scsi_pointer->phase = PH_COMMAND; in nspintr()
1182 nsp_dbg(NSP_DEBUG_INTR, "cmd_len=%d", tmpSC->cmd_len); in nspintr()
1183 nsp_index_write(base, COMMANDCTRL, CLEAR_COMMAND_POINTER); in nspintr()
1184 for (i = 0; i < tmpSC->cmd_len; i++) { in nspintr()
1185 nsp_index_write(base, COMMANDDATA, tmpSC->cmnd[i]); in nspintr()
1187 nsp_index_write(base, COMMANDCTRL, CLEAR_COMMAND_POINTER | AUTO_COMMAND_GO); in nspintr()
1193 scsi_pointer->phase = PH_DATA; in nspintr()
1194 scsi_pointer->have_data_in = IO_OUT; in nspintr()
1203 scsi_pointer->phase = PH_DATA; in nspintr()
1204 scsi_pointer->have_data_in = IO_IN; in nspintr()
1214 scsi_pointer->phase = PH_STATUS; in nspintr()
1216 scsi_pointer->Status = nsp_index_read(base, SCSIDATAWITHACK); in nspintr()
1217 nsp_dbg(NSP_DEBUG_INTR, "message=0x%x status=0x%x", in nspintr()
1218 scsi_pointer->Message, scsi_pointer->Status); in nspintr()
1228 scsi_pointer->phase = PH_MSG_OUT; in nspintr()
1232 data->MsgLen = i = 0; in nspintr()
1233 data->MsgBuffer[i] = IDENTIFY(true, lun); i++; in nspintr()
1236 data->Sync[target].SyncPeriod = 0; in nspintr()
1237 data->Sync[target].SyncOffset = 0; in nspintr()
1240 data->MsgBuffer[i] = EXTENDED_MESSAGE; i++; in nspintr()
1241 data->MsgBuffer[i] = 3; i++; in nspintr()
1242 data->MsgBuffer[i] = EXTENDED_SDTR; i++; in nspintr()
1243 data->MsgBuffer[i] = 0x0c; i++; in nspintr()
1244 data->MsgBuffer[i] = 15; i++; in nspintr()
1247 data->MsgLen = i; in nspintr()
1261 scsi_pointer->phase = PH_MSG_IN; in nspintr()
1268 if (data->MsgLen >= 5 && in nspintr()
1269 data->MsgBuffer[0] == EXTENDED_MESSAGE && in nspintr()
1270 data->MsgBuffer[1] == 3 && in nspintr()
1271 data->MsgBuffer[2] == EXTENDED_SDTR ) { in nspintr()
1272 data->Sync[target].SyncPeriod = data->MsgBuffer[3]; in nspintr()
1273 data->Sync[target].SyncOffset = data->MsgBuffer[4]; in nspintr()
1274 //nsp_dbg(NSP_DEBUG_INTR, "sync ok, %d %d", data->MsgBuffer[3], data->MsgBuffer[4]); in nspintr()
1277 data->Sync[target].SyncPeriod = 0; in nspintr()
1278 data->Sync[target].SyncOffset = 0; in nspintr()
1286 tmp = -1; in nspintr()
1287 for (i = 0; i < data->MsgLen; i++) { in nspintr()
1288 tmp = data->MsgBuffer[i]; in nspintr()
1289 if (data->MsgBuffer[i] == EXTENDED_MESSAGE) { in nspintr()
1290 i += (1 + data->MsgBuffer[i+1]); in nspintr()
1293 scsi_pointer->Message = tmp; in nspintr()
1295 nsp_dbg(NSP_DEBUG_INTR, "message=0x%x len=%d", in nspintr()
1296 scsi_pointer->Message, data->MsgLen); in nspintr()
1320 /*----------------------------------------------------------------*/
1322 /*----------------------------------------------------------------*/
1328 nsp_dbg(NSP_DEBUG_INIT, "this_id=%d", sht->this_id); in nsp_detect()
1335 memcpy(host->hostdata, data_b, sizeof(nsp_hw_data)); in nsp_detect()
1336 data = (nsp_hw_data *)host->hostdata; in nsp_detect()
1337 data->ScsiInfo->host = host; in nsp_detect()
1339 data->CmdId = 0; in nsp_detect()
1342 …nsp_dbg(NSP_DEBUG_INIT, "irq=%d,%d", data_b->IrqNumber, ((nsp_hw_data *)host->hostdata)->IrqNumber… in nsp_detect()
1344 host->unique_id = data->BaseAddress; in nsp_detect()
1345 host->io_port = data->BaseAddress; in nsp_detect()
1346 host->n_io_port = data->NumAddress; in nsp_detect()
1347 host->irq = data->IrqNumber; in nsp_detect()
1348 host->base = data->MmioAddress; in nsp_detect()
1350 spin_lock_init(&(data->Lock)); in nsp_detect()
1352 snprintf(data->nspinfo, in nsp_detect()
1353 sizeof(data->nspinfo), in nsp_detect()
1354 "NinjaSCSI-3/32Bi Driver $Revision: 1.23 $ IO:0x%04lx-0x%04lx MMIO(virt addr):0x%04lx IRQ:%02d", in nsp_detect()
1355 host->io_port, host->io_port + host->n_io_port - 1, in nsp_detect()
1356 host->base, in nsp_detect()
1357 host->irq); in nsp_detect()
1358 sht->name = data->nspinfo; in nsp_detect()
1366 /*----------------------------------------------------------------*/
1368 /*----------------------------------------------------------------*/
1371 nsp_hw_data *data = (nsp_hw_data *)shpnt->hostdata; in nsp_info()
1373 return data->nspinfo; in nsp_info()
1384 hostno = host->host_no; in nsp_show_info()
1385 data = (nsp_hw_data *)host->hostdata; in nsp_show_info()
1390 seq_printf(m, "IRQ: %d\n", host->irq); in nsp_show_info()
1391 …seq_printf(m, "IO: 0x%lx-0x%lx\n", host->io_port, host->io_port + host->n_io_po… in nsp_show_info()
1392 …seq_printf(m, "MMIO(virtual address): 0x%lx-0x%lx\n", host->base, host->base + data->MmioLength - in nsp_show_info()
1393 seq_printf(m, "sg_tablesize: %d\n", host->sg_tablesize); in nsp_show_info()
1413 spin_lock_irqsave(&(data->Lock), flags); in nsp_show_info()
1414 seq_printf(m, "CurrentSC: 0x%p\n\n", data->CurrentSC); in nsp_show_info()
1415 spin_unlock_irqrestore(&(data->Lock), flags); in nsp_show_info()
1418 for(id = 0; id < ARRAY_SIZE(data->Sync); id++) { in nsp_show_info()
1422 if (id == host->this_id) { in nsp_show_info()
1423 seq_puts(m, "----- NinjaSCSI-3 host adapter\n"); in nsp_show_info()
1427 switch(data->Sync[id].SyncNegotiation) { in nsp_show_info()
1442 if (data->Sync[id].SyncPeriod != 0) { in nsp_show_info()
1443 speed = 1000000 / (data->Sync[id].SyncPeriod * 4); in nsp_show_info()
1448 data->Sync[id].SyncOffset in nsp_show_info()
1456 /*---------------------------------------------------------------*/
1458 /*---------------------------------------------------------------*/
1463 nsp_dbg(NSP_DEBUG_BUSRESET, "SCpnt=0x%p", SCpnt);
1470 unsigned int base = data->BaseAddress; in nsp_bus_reset() local
1473 nsp_write(base, IRQCONTROL, IRQCONTROL_ALLMASK); in nsp_bus_reset()
1475 nsp_index_write(base, SCSIBUSCTRL, SCSI_RST); in nsp_bus_reset()
1477 nsp_index_write(base, SCSIBUSCTRL, 0); in nsp_bus_reset()
1479 nsp_index_read(base, IRQPHASESENCE); /* dummy read */ in nsp_bus_reset()
1484 nsp_write(base, IRQCONTROL, IRQCONTROL_ALLCLEAR); in nsp_bus_reset()
1491 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_eh_bus_reset()
1493 nsp_dbg(NSP_DEBUG_BUSRESET, "SCpnt=0x%p", SCpnt); in nsp_eh_bus_reset()
1500 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_eh_host_reset()
1524 if (info == NULL) { return -ENOMEM; } in nsp_cs_probe()
1525 info->p_dev = link; in nsp_cs_probe()
1526 link->priv = info; in nsp_cs_probe()
1527 data->ScsiInfo = info; in nsp_cs_probe()
1529 nsp_dbg(NSP_DEBUG_INIT, "info=0x%p", info); in nsp_cs_probe()
1533 nsp_dbg(NSP_DEBUG_INIT, "link=0x%p", link); in nsp_cs_probe()
1540 nsp_dbg(NSP_DEBUG_INIT, "in, link=0x%p", link); in nsp_cs_detach()
1542 ((scsi_info_t *)link->priv)->stop = 1; in nsp_cs_detach()
1545 kfree(link->priv); in nsp_cs_detach()
1546 link->priv = NULL; in nsp_cs_detach()
1554 if (p_dev->config_index == 0) in nsp_cs_config_check()
1555 return -ENODEV; in nsp_cs_config_check()
1561 if (resource_size(p_dev->resource[2])) { in nsp_cs_config_check()
1562 p_dev->resource[2]->flags |= (WIN_DATA_WIDTH_16 | in nsp_cs_config_check()
1565 if (p_dev->resource[2]->end < 0x1000) in nsp_cs_config_check()
1566 p_dev->resource[2]->end = 0x1000; in nsp_cs_config_check()
1567 if (pcmcia_request_window(p_dev, p_dev->resource[2], 0) != 0) in nsp_cs_config_check()
1569 if (pcmcia_map_mem_page(p_dev, p_dev->resource[2], in nsp_cs_config_check()
1570 p_dev->card_addr) != 0) in nsp_cs_config_check()
1573 data->MmioAddress = (unsigned long) in nsp_cs_config_check()
1574 ioremap(p_dev->resource[2]->start, in nsp_cs_config_check()
1575 resource_size(p_dev->resource[2])); in nsp_cs_config_check()
1576 if (!data->MmioAddress) in nsp_cs_config_check()
1579 data->MmioLength = resource_size(p_dev->resource[2]); in nsp_cs_config_check()
1587 return -ENODEV; in nsp_cs_config_check()
1593 scsi_info_t *info = link->priv; in nsp_cs_config()
1599 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_CHECK_VCC | in nsp_cs_config()
1615 if (link->resource[0]) { in nsp_cs_config()
1616 release_region(link->resource[0]->start, in nsp_cs_config()
1617 resource_size(link->resource[0])); in nsp_cs_config()
1619 if (link->resource[1]) { in nsp_cs_config()
1620 release_region(link->resource[1]->start, in nsp_cs_config()
1621 resource_size(link->resource[1])); in nsp_cs_config()
1626 data->BaseAddress = link->resource[0]->start; in nsp_cs_config()
1627 data->NumAddress = resource_size(link->resource[0]); in nsp_cs_config()
1628 data->IrqNumber = link->irq; in nsp_cs_config()
1630 nsp_dbg(NSP_DEBUG_INIT, "I/O[0x%x+0x%x] IRQ %d", in nsp_cs_config()
1631 data->BaseAddress, data->NumAddress, data->IrqNumber); in nsp_cs_config()
1649 info->host = host; in nsp_cs_config()
1657 return -ENODEV; in nsp_cs_config()
1663 scsi_info_t *info = link->priv; in nsp_cs_release()
1666 if (info->host == NULL) { in nsp_cs_release()
1669 data = (nsp_hw_data *)info->host->hostdata; in nsp_cs_release()
1672 nsp_dbg(NSP_DEBUG_INIT, "link=0x%p", link); in nsp_cs_release()
1675 if (info->host != NULL) { in nsp_cs_release()
1676 scsi_remove_host(info->host); in nsp_cs_release()
1679 if (resource_size(link->resource[2])) { in nsp_cs_release()
1681 iounmap((void *)(data->MmioAddress)); in nsp_cs_release()
1686 if (info->host != NULL) { in nsp_cs_release()
1687 scsi_host_put(info->host); in nsp_cs_release()
1693 scsi_info_t *info = link->priv; in nsp_cs_suspend()
1698 if (info->host != NULL) { in nsp_cs_suspend()
1701 data = (nsp_hw_data *)info->host->hostdata; in nsp_cs_suspend()
1706 info->stop = 1; in nsp_cs_suspend()
1713 scsi_info_t *info = link->priv; in nsp_cs_resume()
1718 info->stop = 0; in nsp_cs_resume()
1720 if (info->host != NULL) { in nsp_cs_resume()
1723 data = (nsp_hw_data *)info->host->hostdata; in nsp_cs_resume()
1737 PCMCIA_DEVICE_PROD_ID123("KME ", "SCSI-CARD-001", "1", 0x534c02bc, 0x52008408, 0x51de003a),
1738 PCMCIA_DEVICE_PROD_ID123("KME ", "SCSI-CARD-002", "1", 0x534c02bc, 0xcb09d5b2, 0x51de003a),
1739 PCMCIA_DEVICE_PROD_ID123("KME ", "SCSI-CARD-003", "1", 0x534c02bc, 0xbc0ee524, 0x51de003a),
1740 PCMCIA_DEVICE_PROD_ID123("KME ", "SCSI-CARD-004", "1", 0x534c02bc, 0x226a7087, 0x51de003a),
1741 PCMCIA_DEVICE_PROD_ID123("WBT", "NinjaSCSI-3", "R1.0", 0xc7ba805f, 0xfdc7c97d, 0x6973710e),
1742 PCMCIA_DEVICE_PROD_ID123("WORKBIT", "UltraNinja-16", "1", 0x28191418, 0xb70f4b09, 0x51de003a),