Lines Matching +full:1000 +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)
57 MODULE_DESCRIPTION("WorkBit NinjaSCSI-3 / NinjaSCSI-32Bi(16bit) PCMCIA SCSI host adapter module");
77 .name = "WorkBit NinjaSCSI-3/32Bi(16bit)",
86 .dma_boundary = PAGE_SIZE - 1,
89 static nsp_hw_data nsp_data_base; /* attach <-> detect glue */
164 printk("nsp_cs-debug: 0x%x %s (%d): %s\n", mask, func, line, buf); in nsp_cs_dmessage()
173 * You must be set SCpnt->result before call this function.
177 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_scsi_done()
179 data->CurrentSC = NULL; in nsp_scsi_done()
181 SCpnt->scsi_done(SCpnt); in nsp_scsi_done()
188 /*unsigned int host_id = SCpnt->device->host->this_id;*/ in nsp_queuecommand_lck()
189 /*unsigned int base = SCpnt->device->host->io_port;*/ in nsp_queuecommand_lck()
192 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_queuecommand_lck()
195 "SCpnt=0x%p target=%d lun=%llu sglist=0x%p bufflen=%d sg_count=%d", in nsp_queuecommand_lck()
196 SCpnt, target, SCpnt->device->lun, scsi_sglist(SCpnt), in nsp_queuecommand_lck()
198 //nsp_dbg(NSP_DEBUG_QUEUECOMMAND, "before CurrentSC=0x%p", data->CurrentSC); in nsp_queuecommand_lck()
200 SCpnt->scsi_done = done; in nsp_queuecommand_lck()
202 if (data->CurrentSC != NULL) { in nsp_queuecommand_lck()
204 SCpnt->result = DID_BAD_TARGET << 16; in nsp_queuecommand_lck()
210 /* XXX: pcmcia-cs generates SCSI command with "scsi_info" utility. in nsp_queuecommand_lck()
212 if (data->ScsiInfo->stop != 0) { in nsp_queuecommand_lck()
214 SCpnt->result = DID_BAD_TARGET << 16; in nsp_queuecommand_lck()
222 data->CurrentSC = SCpnt; in nsp_queuecommand_lck()
224 SCpnt->SCp.Status = SAM_STAT_CHECK_CONDITION; in nsp_queuecommand_lck()
225 SCpnt->SCp.Message = 0; in nsp_queuecommand_lck()
226 SCpnt->SCp.have_data_in = IO_UNKNOWN; in nsp_queuecommand_lck()
227 SCpnt->SCp.sent_command = 0; in nsp_queuecommand_lck()
228 SCpnt->SCp.phase = PH_UNDETERMINED; in nsp_queuecommand_lck()
238 SCpnt->SCp.buffer = scsi_sglist(SCpnt); in nsp_queuecommand_lck()
239 SCpnt->SCp.ptr = BUFFER_ADDR; in nsp_queuecommand_lck()
240 SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length; in nsp_queuecommand_lck()
241 SCpnt->SCp.buffers_residual = scsi_sg_count(SCpnt) - 1; in nsp_queuecommand_lck()
243 SCpnt->SCp.ptr = NULL; in nsp_queuecommand_lck()
244 SCpnt->SCp.this_residual = 0; in nsp_queuecommand_lck()
245 SCpnt->SCp.buffer = NULL; in nsp_queuecommand_lck()
246 SCpnt->SCp.buffers_residual = 0; in nsp_queuecommand_lck()
251 SCpnt->result = DID_BUS_BUSY << 16; in nsp_queuecommand_lck()
259 data->CmdId++; in nsp_queuecommand_lck()
271 unsigned int base = data->BaseAddress; in DEF_SCSI_QCMD() local
282 transfer_mode_reg |= data->TransferMode; in DEF_SCSI_QCMD()
284 nsp_index_write(base, TRANSFERMODE, transfer_mode_reg); in DEF_SCSI_QCMD()
296 for ( i = 0; i < ARRAY_SIZE(data->Sync); i++ ) { in nsphw_init_sync()
297 data->Sync[i] = tmp_sync; in nsphw_init_sync()
306 unsigned int base = data->BaseAddress; in nsphw_init() local
308 nsp_dbg(NSP_DEBUG_INIT, "in base=0x%x", base); in nsphw_init()
310 data->ScsiClockDiv = CLOCK_40M | FAST_20; in nsphw_init()
311 data->CurrentSC = NULL; in nsphw_init()
312 data->FifoCount = 0; in nsphw_init()
313 data->TransferMode = MODE_IO8; in nsphw_init()
318 nsp_write(base, IRQCONTROL, IRQCONTROL_ALLMASK); in nsphw_init()
321 nsp_write(base, IFSELECT, IF_IFSEL); in nsphw_init()
323 nsp_index_write(base, SCSIIRQMODE, 0); in nsphw_init()
325 nsp_index_write(base, TRANSFERMODE, MODE_IO8); in nsphw_init()
326 nsp_index_write(base, CLOCKDIV, data->ScsiClockDiv); in nsphw_init()
328 nsp_index_write(base, PARITYCTRL, 0); in nsphw_init()
329 nsp_index_write(base, POINTERCLR, POINTER_CLEAR | in nsphw_init()
335 nsp_write(base, IFSELECT, IF_REGSEL); in nsphw_init()
336 nsp_index_write(base, TERMPWRCTRL, 0); in nsphw_init()
337 if ((nsp_index_read(base, OTHERCONTROL) & TPWR_SENSE) == 0) { in nsphw_init()
339 nsp_index_write(base, TERMPWRCTRL, POWER_ON); in nsphw_init()
342 nsp_index_write(base, TIMERCOUNT, 0); in nsphw_init()
343 nsp_index_write(base, TIMERCOUNT, 0); /* requires 2 times!! */ in nsphw_init()
345 nsp_index_write(base, SYNCREG, 0); in nsphw_init()
346 nsp_index_write(base, ACKWIDTH, 0); in nsphw_init()
349 nsp_index_write(base, SCSIIRQMODE, SCSI_PHASE_CHANGE_EI | in nsphw_init()
352 nsp_write(base, IRQCONTROL, IRQCONTROL_ALLCLEAR); in nsphw_init()
364 unsigned int host_id = SCpnt->device->host->this_id; in nsphw_start_selection()
365 unsigned int base = SCpnt->device->host->io_port; in nsphw_start_selection() local
367 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsphw_start_selection()
373 phase = nsp_index_read(base, SCSIBUSMON); in nsphw_start_selection()
381 SCpnt->SCp.phase = PH_ARBSTART; in nsphw_start_selection()
382 nsp_index_write(base, SETARBIT, ARBIT_GO); in nsphw_start_selection()
384 time_out = 1000; in nsphw_start_selection()
387 arbit = nsp_index_read(base, ARBITSTATUS); in nsphw_start_selection()
391 (time_out-- != 0)); in nsphw_start_selection()
395 nsp_index_write(base, SETARBIT, ARBIT_FLAG_CLEAR); in nsphw_start_selection()
401 SCpnt->SCp.phase = PH_SELSTART; in nsphw_start_selection()
403 nsp_index_write(base, SCSIDATALATCH, BIT(host_id) | BIT(target)); in nsphw_start_selection()
404 nsp_index_write(base, SCSIBUSCTRL, SCSI_SEL | SCSI_BSY | SCSI_ATN); in nsphw_start_selection()
406 nsp_index_write(base, SCSIBUSCTRL, SCSI_SEL | SCSI_BSY | SCSI_DATAOUT_ENB | SCSI_ATN); in nsphw_start_selection()
407 nsp_index_write(base, SETARBIT, ARBIT_FLAG_CLEAR); in nsphw_start_selection()
409 nsp_index_write(base, SCSIBUSCTRL, SCSI_SEL | SCSI_DATAOUT_ENB | SCSI_ATN); in nsphw_start_selection()
412 nsp_start_timer(SCpnt, 1000/51); in nsphw_start_selection()
413 data->SelectionTimeOut = 1; in nsphw_start_selection()
446 // unsigned char lun = SCpnt->device->lun; in nsp_analyze_sdtr()
447 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_analyze_sdtr()
448 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 ( i = 0; sync_table->max_period != 0; i++, 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()
579 unsigned int base = SCpnt->device->host->io_port; in nsp_xfer() local
580 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_xfer()
581 char *buf = data->MsgBuffer; in nsp_xfer()
582 int len = min(MSGBUF_SIZE, data->MsgLen); in nsp_xfer()
587 for (ptr = 0; len > 0; len--, ptr++) { in nsp_xfer()
596 if (len == 1 && SCpnt->SCp.phase == PH_MSG_OUT) { in nsp_xfer()
597 nsp_index_write(base, SCSIBUSCTRL, AUTODIRECTION | ACKENB); in nsp_xfer()
603 buf[ptr] = nsp_index_read(base, SCSIDATAWITHACK); in nsp_xfer()
606 nsp_index_write(base, SCSIDATAWITHACK, buf[ptr]); in nsp_xfer()
619 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_dataphase_bypass()
624 if (SCpnt->SCp.have_data_in != IO_IN) { in nsp_dataphase_bypass()
629 if (data->FifoCount == count) { in nsp_dataphase_bypass()
639 SCpnt->SCp.phase = PH_DATA; in nsp_dataphase_bypass()
651 unsigned int base = SCpnt->device->host->io_port; in nsp_reselected() local
652 unsigned int host_id = SCpnt->device->host->this_id; in nsp_reselected()
653 //nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_reselected()
660 id_reg = nsp_index_read(base, RESELECTID); in nsp_reselected()
678 bus_reg = nsp_index_read(base, SCSIBUSCTRL) & ~(SCSI_BSY | SCSI_ATN); in nsp_reselected()
679 nsp_index_write(base, SCSIBUSCTRL, bus_reg); in nsp_reselected()
680 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()
717 unsigned int base = SCpnt->device->host->io_port; in nsp_pio_read() local
718 unsigned long mmio_base = SCpnt->device->host->base; in nsp_pio_read()
719 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_pio_read()
724 ocount = data->FifoCount; in nsp_pio_read()
726 …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()
727 SCpnt, scsi_get_resid(SCpnt), ocount, SCpnt->SCp.ptr, in nsp_pio_read()
728 SCpnt->SCp.this_residual, SCpnt->SCp.buffer, in nsp_pio_read()
729 SCpnt->SCp.buffers_residual); in nsp_pio_read()
731 time_out = 1000; in nsp_pio_read()
733 while ((time_out-- != 0) && in nsp_pio_read()
734 (SCpnt->SCp.this_residual > 0 || SCpnt->SCp.buffers_residual > 0 ) ) { in nsp_pio_read()
736 stat = nsp_index_read(base, SCSIBUSMON); in nsp_pio_read()
740 res = nsp_fifo_count(SCpnt) - ocount; in nsp_pio_read()
741 …//nsp_dbg(NSP_DEBUG_DATA_IO, "ptr=0x%p this=0x%x ocount=0x%x res=0x%x", SCpnt->SCp.ptr, SCpnt->SCp… in nsp_pio_read()
744 //nsp_dbg(NSP_DEBUG_DATA_IO, " wait for data this=%d", SCpnt->SCp.this_residual); in nsp_pio_read()
747 nsp_dbg(NSP_DEBUG_DATA_IO, "phase changed stat=0x%x", stat); in nsp_pio_read()
752 fifo_stat = nsp_read(base, FIFOSTATUS); in nsp_pio_read()
758 res = min(res, SCpnt->SCp.this_residual); in nsp_pio_read()
760 switch (data->TransferMode) { in nsp_pio_read()
763 nsp_fifo32_read(base, SCpnt->SCp.ptr, res >> 2); in nsp_pio_read()
766 nsp_fifo8_read (base, SCpnt->SCp.ptr, res ); in nsp_pio_read()
771 nsp_mmio_fifo32_read(mmio_base, SCpnt->SCp.ptr, res >> 2); in nsp_pio_read()
779 nsp_inc_resid(SCpnt, -res); in nsp_pio_read()
780 SCpnt->SCp.ptr += res; in nsp_pio_read()
781 SCpnt->SCp.this_residual -= res; in nsp_pio_read()
783 …//nsp_dbg(NSP_DEBUG_DATA_IO, "ptr=0x%p this_residual=0x%x ocount=0x%x", SCpnt->SCp.ptr, SCpnt->SCp… in nsp_pio_read()
786 if (SCpnt->SCp.this_residual == 0 && in nsp_pio_read()
787 SCpnt->SCp.buffers_residual != 0 ) { in nsp_pio_read()
789 SCpnt->SCp.buffers_residual--; in nsp_pio_read()
790 SCpnt->SCp.buffer = sg_next(SCpnt->SCp.buffer); in nsp_pio_read()
791 SCpnt->SCp.ptr = BUFFER_ADDR; in nsp_pio_read()
792 SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length; in nsp_pio_read()
793 time_out = 1000; in nsp_pio_read()
795 …//nsp_dbg(NSP_DEBUG_DATA_IO, "page: 0x%p, off: 0x%x", SCpnt->SCp.buffer->page, SCpnt->SCp.buffer->… in nsp_pio_read()
799 data->FifoCount = ocount; in nsp_pio_read()
803 scsi_get_resid(SCpnt), SCpnt->SCp.this_residual, in nsp_pio_read()
804 SCpnt->SCp.buffers_residual); in nsp_pio_read()
806 nsp_dbg(NSP_DEBUG_DATA_IO, "read ocount=0x%x", ocount); in nsp_pio_read()
807 nsp_dbg(NSP_DEBUG_DATA_IO, "r cmd=%d resid=0x%x\n", data->CmdId, in nsp_pio_read()
816 unsigned int base = SCpnt->device->host->io_port; in nsp_pio_write() local
817 unsigned long mmio_base = SCpnt->device->host->base; in nsp_pio_write()
818 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_pio_write()
823 ocount = data->FifoCount; in nsp_pio_write()
825 …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()
826 data->FifoCount, SCpnt->SCp.ptr, SCpnt->SCp.this_residual, in nsp_pio_write()
827 SCpnt->SCp.buffer, SCpnt->SCp.buffers_residual, in nsp_pio_write()
830 time_out = 1000; in nsp_pio_write()
832 while ((time_out-- != 0) && in nsp_pio_write()
833 (SCpnt->SCp.this_residual > 0 || SCpnt->SCp.buffers_residual > 0)) { in nsp_pio_write()
834 stat = nsp_index_read(base, SCSIBUSMON); in nsp_pio_write()
838 res = ocount - nsp_fifo_count(SCpnt); in nsp_pio_write()
840 nsp_dbg(NSP_DEBUG_DATA_IO, "phase changed stat=0x%x, res=%d\n", stat, res); in nsp_pio_write()
843 SCpnt->SCp.ptr -= res; in nsp_pio_write()
844 SCpnt->SCp.this_residual += res; in nsp_pio_write()
845 ocount -= res; in nsp_pio_write()
850 res = ocount - nsp_fifo_count(SCpnt); in nsp_pio_write()
852 nsp_dbg(NSP_DEBUG_DATA_IO, "wait for all data out. ocount=0x%x res=%d", ocount, res); in nsp_pio_write()
856 res = min(SCpnt->SCp.this_residual, WFIFO_CRIT); in nsp_pio_write()
858 …//nsp_dbg(NSP_DEBUG_DATA_IO, "ptr=0x%p this=0x%x res=0x%x", SCpnt->SCp.ptr, SCpnt->SCp.this_residu… in nsp_pio_write()
859 switch (data->TransferMode) { in nsp_pio_write()
862 nsp_fifo32_write(base, SCpnt->SCp.ptr, res >> 2); in nsp_pio_write()
865 nsp_fifo8_write (base, SCpnt->SCp.ptr, res ); in nsp_pio_write()
870 nsp_mmio_fifo32_write(mmio_base, SCpnt->SCp.ptr, res >> 2); in nsp_pio_write()
878 nsp_inc_resid(SCpnt, -res); in nsp_pio_write()
879 SCpnt->SCp.ptr += res; in nsp_pio_write()
880 SCpnt->SCp.this_residual -= res; in nsp_pio_write()
884 if (SCpnt->SCp.this_residual == 0 && in nsp_pio_write()
885 SCpnt->SCp.buffers_residual != 0 ) { in nsp_pio_write()
887 SCpnt->SCp.buffers_residual--; in nsp_pio_write()
888 SCpnt->SCp.buffer = sg_next(SCpnt->SCp.buffer); in nsp_pio_write()
889 SCpnt->SCp.ptr = BUFFER_ADDR; in nsp_pio_write()
890 SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length; in nsp_pio_write()
891 time_out = 1000; in nsp_pio_write()
895 data->FifoCount = ocount; in nsp_pio_write()
898 nsp_msg(KERN_DEBUG, "pio write timeout resid=0x%x", in nsp_pio_write()
901 nsp_dbg(NSP_DEBUG_DATA_IO, "write ocount=0x%x", ocount); in nsp_pio_write()
902 nsp_dbg(NSP_DEBUG_DATA_IO, "w cmd=%d resid=0x%x\n", data->CmdId, in nsp_pio_write()
913 unsigned int base = SCpnt->device->host->io_port; in nsp_nexus() local
915 // unsigned char lun = SCpnt->device->lun; in nsp_nexus()
916 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_nexus()
917 sync_data *sync = &(data->Sync[target]); in nsp_nexus()
919 //nsp_dbg(NSP_DEBUG_DATA_IO, "in SCpnt=0x%p", SCpnt); in nsp_nexus()
922 nsp_index_write(base, SYNCREG, sync->SyncRegister); in nsp_nexus()
923 nsp_index_write(base, ACKWIDTH, sync->AckWidth); in nsp_nexus()
927 data->TransferMode = MODE_IO8; in nsp_nexus()
929 data->TransferMode = MODE_MEM32; in nsp_nexus()
931 data->TransferMode = MODE_IO32; in nsp_nexus()
933 data->TransferMode = MODE_IO8; in nsp_nexus()
940 data->FifoCount = 0; in nsp_nexus()
941 nsp_index_write(base, POINTERCLR, POINTER_CLEAR | in nsp_nexus()
955 unsigned int base; in nspintr() local
964 //nsp_dbg(NSP_DEBUG_INTR, "dev_id=0x%p", dev_id); in nspintr()
965 //nsp_dbg(NSP_DEBUG_INTR, "host=0x%p", ((scsi_info_t *)dev_id)->host); in nspintr()
968 ((scsi_info_t *)dev_id)->host != NULL ) { in nspintr()
971 data = (nsp_hw_data *)info->host->hostdata; in nspintr()
977 //nsp_dbg(NSP_DEBUG_INTR, "&nsp_data_base=0x%p, dev_id=0x%p", &nsp_data_base, dev_id); in nspintr()
979 base = data->BaseAddress; in nspintr()
980 //nsp_dbg(NSP_DEBUG_INTR, "base=0x%x", base); in nspintr()
985 nsp_write(base, IRQCONTROL, IRQCONTROL_IRQDISABLE); in nspintr()
986 irq_status = nsp_read(base, IRQSTATUS); in nspintr()
987 //nsp_dbg(NSP_DEBUG_INTR, "irq_status=0x%x", irq_status); in nspintr()
989 nsp_write(base, IRQCONTROL, 0); in nspintr()
998 phase = nsp_index_read(base, SCSIBUSMON); in nspintr()
1000 irq_phase = nsp_index_read(base, IRQPHASESENCE); in nspintr()
1005 //nsp_dbg(NSP_DEBUG_INTR, "irq_phase=0x%x", irq_phase); in nspintr()
1010 //nsp_dbg(NSP_DEBUG_INTR, "timercount=%d", data->TimerCount); in nspintr()
1011 if (data->TimerCount != 0) { in nspintr()
1013 nsp_index_write(base, TIMERCOUNT, 0); in nspintr()
1014 nsp_index_write(base, TIMERCOUNT, 0); in nspintr()
1015 data->TimerCount = 0; in nspintr()
1019 data->SelectionTimeOut == 0) { in nspintr()
1021 nsp_write(base, IRQCONTROL, IRQCONTROL_TIMER_CLEAR); in nspintr()
1025 nsp_write(base, IRQCONTROL, IRQCONTROL_TIMER_CLEAR | IRQCONTROL_FIFO_CLEAR); in nspintr()
1034 if(data->CurrentSC != NULL) { in nspintr()
1035 tmpSC = data->CurrentSC; in nspintr()
1036 tmpSC->result = (DID_RESET << 16) | in nspintr()
1037 ((tmpSC->SCp.Message & 0xff) << 8) | in nspintr()
1038 ((tmpSC->SCp.Status & 0xff) << 0); in nspintr()
1044 if (data->CurrentSC == NULL) { in nspintr()
1045 …nsp_msg(KERN_ERR, "CurrentSC==NULL irq_status=0x%x phase=0x%x irq_phase=0x%x this can't be happen.… in nspintr()
1051 tmpSC = data->CurrentSC; in nspintr()
1052 target = tmpSC->device->id; in nspintr()
1053 lun = tmpSC->device->lun; in nspintr()
1054 sync_neg = &(data->Sync[target].SyncNegotiation); in nspintr()
1062 nsp_write(base, IRQCONTROL, IRQCONTROL_RESELECT_CLEAR); in nspintr()
1075 switch(tmpSC->SCp.phase) { in nspintr()
1079 //nsp_dbg(NSP_DEBUG_INTR, "selection count=%d", data->SelectionTimeOut); in nspintr()
1080 if (data->SelectionTimeOut >= NSP_SELTIMEOUT) { in nspintr()
1082 data->SelectionTimeOut = 0; in nspintr()
1083 nsp_index_write(base, SCSIBUSCTRL, 0); in nspintr()
1085 tmpSC->result = DID_TIME_OUT << 16; in nspintr()
1090 data->SelectionTimeOut += 1; in nspintr()
1091 nsp_start_timer(tmpSC, 1000/51); in nspintr()
1097 data->SelectionTimeOut = 0; in nspintr()
1098 tmpSC->SCp.phase = PH_SELECTED; in nspintr()
1099 nsp_index_write(base, SCSIBUSCTRL, SCSI_ATN); in nspintr()
1101 nsp_index_write(base, SCSIBUSCTRL, SCSI_ATN | AUTODIRECTION | ACKENB); in nspintr()
1109 tmpSC->result = DID_ABORT << 16; in nspintr()
1127 if (((tmpSC->SCp.phase == PH_MSG_IN) || (tmpSC->SCp.phase == PH_MSG_OUT)) && in nspintr()
1129 …nsp_dbg(NSP_DEBUG_INTR, "normal disconnect irq_status=0x%x, phase=0x%x, irq_phase=0x%x", irq_statu… in nspintr()
1134 if (tmpSC->SCp.Message == COMMAND_COMPLETE) { in nspintr()
1135 tmpSC->result = (DID_OK << 16) | in nspintr()
1136 ((tmpSC->SCp.Message & 0xff) << 8) | in nspintr()
1137 ((tmpSC->SCp.Status & 0xff) << 0); in nspintr()
1138 nsp_dbg(NSP_DEBUG_INTR, "command complete result=0x%x", tmpSC->result); in nspintr()
1150 …nsp_msg(KERN_DEBUG, "unexpected bus free. irq_status=0x%x, phase=0x%x, irq_phase=0x%x", irq_status… in nspintr()
1153 tmpSC->result = DID_ERROR << 16; in nspintr()
1166 tmpSC->SCp.phase = PH_COMMAND; in nspintr()
1171 nsp_dbg(NSP_DEBUG_INTR, "cmd_len=%d", tmpSC->cmd_len); in nspintr()
1172 nsp_index_write(base, COMMANDCTRL, CLEAR_COMMAND_POINTER); in nspintr()
1173 for (i = 0; i < tmpSC->cmd_len; i++) { in nspintr()
1174 nsp_index_write(base, COMMANDDATA, tmpSC->cmnd[i]); in nspintr()
1176 nsp_index_write(base, COMMANDCTRL, CLEAR_COMMAND_POINTER | AUTO_COMMAND_GO); in nspintr()
1182 tmpSC->SCp.phase = PH_DATA; in nspintr()
1183 tmpSC->SCp.have_data_in = IO_OUT; in nspintr()
1192 tmpSC->SCp.phase = PH_DATA; in nspintr()
1193 tmpSC->SCp.have_data_in = IO_IN; in nspintr()
1203 tmpSC->SCp.phase = PH_STATUS; in nspintr()
1205 tmpSC->SCp.Status = nsp_index_read(base, SCSIDATAWITHACK); in nspintr()
1206 nsp_dbg(NSP_DEBUG_INTR, "message=0x%x status=0x%x", tmpSC->SCp.Message, tmpSC->SCp.Status); in nspintr()
1216 tmpSC->SCp.phase = PH_MSG_OUT; in nspintr()
1220 data->MsgLen = i = 0; in nspintr()
1221 data->MsgBuffer[i] = IDENTIFY(TRUE, lun); i++; in nspintr()
1224 data->Sync[target].SyncPeriod = 0; in nspintr()
1225 data->Sync[target].SyncOffset = 0; in nspintr()
1228 data->MsgBuffer[i] = EXTENDED_MESSAGE; i++; in nspintr()
1229 data->MsgBuffer[i] = 3; i++; in nspintr()
1230 data->MsgBuffer[i] = EXTENDED_SDTR; i++; in nspintr()
1231 data->MsgBuffer[i] = 0x0c; i++; in nspintr()
1232 data->MsgBuffer[i] = 15; i++; in nspintr()
1235 data->MsgLen = i; in nspintr()
1249 tmpSC->SCp.phase = PH_MSG_IN; in nspintr()
1256 if (data->MsgLen >= 5 && in nspintr()
1257 data->MsgBuffer[0] == EXTENDED_MESSAGE && in nspintr()
1258 data->MsgBuffer[1] == 3 && in nspintr()
1259 data->MsgBuffer[2] == EXTENDED_SDTR ) { in nspintr()
1260 data->Sync[target].SyncPeriod = data->MsgBuffer[3]; in nspintr()
1261 data->Sync[target].SyncOffset = data->MsgBuffer[4]; in nspintr()
1262 //nsp_dbg(NSP_DEBUG_INTR, "sync ok, %d %d", data->MsgBuffer[3], data->MsgBuffer[4]); in nspintr()
1265 data->Sync[target].SyncPeriod = 0; in nspintr()
1266 data->Sync[target].SyncOffset = 0; in nspintr()
1274 tmp = -1; in nspintr()
1275 for (i = 0; i < data->MsgLen; i++) { in nspintr()
1276 tmp = data->MsgBuffer[i]; in nspintr()
1277 if (data->MsgBuffer[i] == EXTENDED_MESSAGE) { in nspintr()
1278 i += (1 + data->MsgBuffer[i+1]); in nspintr()
1281 tmpSC->SCp.Message = tmp; in nspintr()
1283 nsp_dbg(NSP_DEBUG_INTR, "message=0x%x len=%d", tmpSC->SCp.Message, data->MsgLen); in nspintr()
1299 nsp_start_timer(tmpSC, 1000/102); in nspintr()
1307 /*----------------------------------------------------------------*/
1309 /*----------------------------------------------------------------*/
1315 nsp_dbg(NSP_DEBUG_INIT, "this_id=%d", sht->this_id); in nsp_detect()
1322 memcpy(host->hostdata, data_b, sizeof(nsp_hw_data)); in nsp_detect()
1323 data = (nsp_hw_data *)host->hostdata; in nsp_detect()
1324 data->ScsiInfo->host = host; in nsp_detect()
1326 data->CmdId = 0; in nsp_detect()
1329 …nsp_dbg(NSP_DEBUG_INIT, "irq=%d,%d", data_b->IrqNumber, ((nsp_hw_data *)host->hostdata)->IrqNumber… in nsp_detect()
1331 host->unique_id = data->BaseAddress; in nsp_detect()
1332 host->io_port = data->BaseAddress; in nsp_detect()
1333 host->n_io_port = data->NumAddress; in nsp_detect()
1334 host->irq = data->IrqNumber; in nsp_detect()
1335 host->base = data->MmioAddress; in nsp_detect()
1337 spin_lock_init(&(data->Lock)); in nsp_detect()
1339 snprintf(data->nspinfo, in nsp_detect()
1340 sizeof(data->nspinfo), in nsp_detect()
1341 "NinjaSCSI-3/32Bi Driver $Revision: 1.23 $ IO:0x%04lx-0x%04lx MMIO(virt addr):0x%04lx IRQ:%02d", in nsp_detect()
1342 host->io_port, host->io_port + host->n_io_port - 1, in nsp_detect()
1343 host->base, in nsp_detect()
1344 host->irq); in nsp_detect()
1345 sht->name = data->nspinfo; in nsp_detect()
1353 /*----------------------------------------------------------------*/
1355 /*----------------------------------------------------------------*/
1358 nsp_hw_data *data = (nsp_hw_data *)shpnt->hostdata; in nsp_info()
1360 return data->nspinfo; in nsp_info()
1371 hostno = host->host_no; in nsp_show_info()
1372 data = (nsp_hw_data *)host->hostdata; in nsp_show_info()
1377 seq_printf(m, "IRQ: %d\n", host->irq); in nsp_show_info()
1378 …seq_printf(m, "IO: 0x%lx-0x%lx\n", host->io_port, host->io_port + host->n_io_po… in nsp_show_info()
1379 …seq_printf(m, "MMIO(virtual address): 0x%lx-0x%lx\n", host->base, host->base + data->MmioLength - in nsp_show_info()
1380 seq_printf(m, "sg_tablesize: %d\n", host->sg_tablesize); in nsp_show_info()
1400 spin_lock_irqsave(&(data->Lock), flags); in nsp_show_info()
1401 seq_printf(m, "CurrentSC: 0x%p\n\n", data->CurrentSC); in nsp_show_info()
1402 spin_unlock_irqrestore(&(data->Lock), flags); in nsp_show_info()
1405 for(id = 0; id < ARRAY_SIZE(data->Sync); id++) { in nsp_show_info()
1409 if (id == host->this_id) { in nsp_show_info()
1410 seq_puts(m, "----- NinjaSCSI-3 host adapter\n"); in nsp_show_info()
1414 switch(data->Sync[id].SyncNegotiation) { in nsp_show_info()
1429 if (data->Sync[id].SyncPeriod != 0) { in nsp_show_info()
1430 speed = 1000000 / (data->Sync[id].SyncPeriod * 4); in nsp_show_info()
1433 speed / 1000, in nsp_show_info()
1434 speed % 1000, in nsp_show_info()
1435 data->Sync[id].SyncOffset in nsp_show_info()
1443 /*---------------------------------------------------------------*/
1445 /*---------------------------------------------------------------*/
1450 nsp_dbg(NSP_DEBUG_BUSRESET, "SCpnt=0x%p", SCpnt);
1457 unsigned int base = data->BaseAddress; in nsp_bus_reset() local
1460 nsp_write(base, IRQCONTROL, IRQCONTROL_ALLMASK); in nsp_bus_reset()
1462 nsp_index_write(base, SCSIBUSCTRL, SCSI_RST); in nsp_bus_reset()
1464 nsp_index_write(base, SCSIBUSCTRL, 0); in nsp_bus_reset()
1466 nsp_index_read(base, IRQPHASESENCE); /* dummy read */ in nsp_bus_reset()
1471 nsp_write(base, IRQCONTROL, IRQCONTROL_ALLCLEAR); in nsp_bus_reset()
1478 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_eh_bus_reset()
1480 nsp_dbg(NSP_DEBUG_BUSRESET, "SCpnt=0x%p", SCpnt); in nsp_eh_bus_reset()
1487 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_eh_host_reset()
1511 if (info == NULL) { return -ENOMEM; } in nsp_cs_probe()
1512 info->p_dev = link; in nsp_cs_probe()
1513 link->priv = info; in nsp_cs_probe()
1514 data->ScsiInfo = info; in nsp_cs_probe()
1516 nsp_dbg(NSP_DEBUG_INIT, "info=0x%p", info); in nsp_cs_probe()
1520 nsp_dbg(NSP_DEBUG_INIT, "link=0x%p", link); in nsp_cs_probe()
1527 nsp_dbg(NSP_DEBUG_INIT, "in, link=0x%p", link); in nsp_cs_detach()
1529 ((scsi_info_t *)link->priv)->stop = 1; in nsp_cs_detach()
1532 kfree(link->priv); in nsp_cs_detach()
1533 link->priv = NULL; in nsp_cs_detach()
1541 if (p_dev->config_index == 0) in nsp_cs_config_check()
1542 return -ENODEV; in nsp_cs_config_check()
1548 if (resource_size(p_dev->resource[2])) { in nsp_cs_config_check()
1549 p_dev->resource[2]->flags |= (WIN_DATA_WIDTH_16 | in nsp_cs_config_check()
1552 if (p_dev->resource[2]->end < 0x1000) in nsp_cs_config_check()
1553 p_dev->resource[2]->end = 0x1000; in nsp_cs_config_check()
1554 if (pcmcia_request_window(p_dev, p_dev->resource[2], 0) != 0) in nsp_cs_config_check()
1556 if (pcmcia_map_mem_page(p_dev, p_dev->resource[2], in nsp_cs_config_check()
1557 p_dev->card_addr) != 0) in nsp_cs_config_check()
1560 data->MmioAddress = (unsigned long) in nsp_cs_config_check()
1561 ioremap(p_dev->resource[2]->start, in nsp_cs_config_check()
1562 resource_size(p_dev->resource[2])); in nsp_cs_config_check()
1563 data->MmioLength = resource_size(p_dev->resource[2]); in nsp_cs_config_check()
1571 return -ENODEV; in nsp_cs_config_check()
1577 scsi_info_t *info = link->priv; in nsp_cs_config()
1583 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_CHECK_VCC | in nsp_cs_config()
1599 if (link->resource[0]) { in nsp_cs_config()
1600 release_region(link->resource[0]->start, in nsp_cs_config()
1601 resource_size(link->resource[0])); in nsp_cs_config()
1603 if (link->resource[1]) { in nsp_cs_config()
1604 release_region(link->resource[1]->start, in nsp_cs_config()
1605 resource_size(link->resource[1])); in nsp_cs_config()
1610 data->BaseAddress = link->resource[0]->start; in nsp_cs_config()
1611 data->NumAddress = resource_size(link->resource[0]); in nsp_cs_config()
1612 data->IrqNumber = link->irq; in nsp_cs_config()
1614 nsp_dbg(NSP_DEBUG_INIT, "I/O[0x%x+0x%x] IRQ %d", in nsp_cs_config()
1615 data->BaseAddress, data->NumAddress, data->IrqNumber); in nsp_cs_config()
1635 info->host = host; in nsp_cs_config()
1643 return -ENODEV; in nsp_cs_config()
1649 scsi_info_t *info = link->priv; in nsp_cs_release()
1652 if (info->host == NULL) { in nsp_cs_release()
1655 data = (nsp_hw_data *)info->host->hostdata; in nsp_cs_release()
1658 nsp_dbg(NSP_DEBUG_INIT, "link=0x%p", link); in nsp_cs_release()
1661 if (info->host != NULL) { in nsp_cs_release()
1662 scsi_remove_host(info->host); in nsp_cs_release()
1665 if (resource_size(link->resource[2])) { in nsp_cs_release()
1667 iounmap((void *)(data->MmioAddress)); in nsp_cs_release()
1672 if (info->host != NULL) { in nsp_cs_release()
1673 scsi_host_put(info->host); in nsp_cs_release()
1679 scsi_info_t *info = link->priv; in nsp_cs_suspend()
1684 if (info->host != NULL) { in nsp_cs_suspend()
1687 data = (nsp_hw_data *)info->host->hostdata; in nsp_cs_suspend()
1692 info->stop = 1; in nsp_cs_suspend()
1699 scsi_info_t *info = link->priv; in nsp_cs_resume()
1704 info->stop = 0; in nsp_cs_resume()
1706 if (info->host != NULL) { in nsp_cs_resume()
1709 data = (nsp_hw_data *)info->host->hostdata; in nsp_cs_resume()
1723 PCMCIA_DEVICE_PROD_ID123("KME ", "SCSI-CARD-001", "1", 0x534c02bc, 0x52008408, 0x51de003a),
1724 PCMCIA_DEVICE_PROD_ID123("KME ", "SCSI-CARD-002", "1", 0x534c02bc, 0xcb09d5b2, 0x51de003a),
1725 PCMCIA_DEVICE_PROD_ID123("KME ", "SCSI-CARD-003", "1", 0x534c02bc, 0xbc0ee524, 0x51de003a),
1726 PCMCIA_DEVICE_PROD_ID123("KME ", "SCSI-CARD-004", "1", 0x534c02bc, 0x226a7087, 0x51de003a),
1727 PCMCIA_DEVICE_PROD_ID123("WBT", "NinjaSCSI-3", "R1.0", 0xc7ba805f, 0xfdc7c97d, 0x6973710e),
1728 PCMCIA_DEVICE_PROD_ID123("WORKBIT", "UltraNinja-16", "1", 0x28191418, 0xb70f4b09, 0x51de003a),