• Home
  • Raw
  • Download

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");
78 .name = "WorkBit NinjaSCSI-3/32Bi(16bit)",
87 .dma_boundary = PAGE_SIZE - 1,
90 static nsp_hw_data nsp_data_base; /* attach <-> detect glue */
165 printk("nsp_cs-debug: 0x%x %s (%d): %s\n", mask, func, line, buf); in nsp_cs_dmessage()
174 * You must be set SCpnt->result before call this function.
178 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_scsi_done()
180 data->CurrentSC = NULL; in nsp_scsi_done()
182 SCpnt->scsi_done(SCpnt); in nsp_scsi_done()
189 /*unsigned int host_id = SCpnt->device->host->this_id;*/ in nsp_queuecommand_lck()
190 /*unsigned int base = SCpnt->device->host->io_port;*/ in nsp_queuecommand_lck()
193 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_queuecommand_lck()
196 "SCpnt=0x%p target=%d lun=%llu sglist=0x%p bufflen=%d sg_count=%d", in nsp_queuecommand_lck()
197 SCpnt, target, SCpnt->device->lun, scsi_sglist(SCpnt), in nsp_queuecommand_lck()
199 //nsp_dbg(NSP_DEBUG_QUEUECOMMAND, "before CurrentSC=0x%p", data->CurrentSC); in nsp_queuecommand_lck()
201 SCpnt->scsi_done = done; in nsp_queuecommand_lck()
203 if (data->CurrentSC != NULL) { in nsp_queuecommand_lck()
205 SCpnt->result = DID_BAD_TARGET << 16; in nsp_queuecommand_lck()
211 /* XXX: pcmcia-cs generates SCSI command with "scsi_info" utility. in nsp_queuecommand_lck()
213 if (data->ScsiInfo->stop != 0) { in nsp_queuecommand_lck()
215 SCpnt->result = DID_BAD_TARGET << 16; in nsp_queuecommand_lck()
223 data->CurrentSC = SCpnt; in nsp_queuecommand_lck()
225 SCpnt->SCp.Status = CHECK_CONDITION; in nsp_queuecommand_lck()
226 SCpnt->SCp.Message = 0; in nsp_queuecommand_lck()
227 SCpnt->SCp.have_data_in = IO_UNKNOWN; in nsp_queuecommand_lck()
228 SCpnt->SCp.sent_command = 0; in nsp_queuecommand_lck()
229 SCpnt->SCp.phase = PH_UNDETERMINED; in nsp_queuecommand_lck()
239 SCpnt->SCp.buffer = scsi_sglist(SCpnt); in nsp_queuecommand_lck()
240 SCpnt->SCp.ptr = BUFFER_ADDR; in nsp_queuecommand_lck()
241 SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length; in nsp_queuecommand_lck()
242 SCpnt->SCp.buffers_residual = scsi_sg_count(SCpnt) - 1; in nsp_queuecommand_lck()
244 SCpnt->SCp.ptr = NULL; in nsp_queuecommand_lck()
245 SCpnt->SCp.this_residual = 0; in nsp_queuecommand_lck()
246 SCpnt->SCp.buffer = NULL; in nsp_queuecommand_lck()
247 SCpnt->SCp.buffers_residual = 0; in nsp_queuecommand_lck()
252 SCpnt->result = DID_BUS_BUSY << 16; in nsp_queuecommand_lck()
260 data->CmdId++; in nsp_queuecommand_lck()
272 unsigned int base = data->BaseAddress; in DEF_SCSI_QCMD() local
283 transfer_mode_reg |= data->TransferMode; in DEF_SCSI_QCMD()
285 nsp_index_write(base, TRANSFERMODE, transfer_mode_reg); in DEF_SCSI_QCMD()
297 for ( i = 0; i < ARRAY_SIZE(data->Sync); i++ ) { in nsphw_init_sync()
298 data->Sync[i] = tmp_sync; in nsphw_init_sync()
307 unsigned int base = data->BaseAddress; in nsphw_init() local
309 nsp_dbg(NSP_DEBUG_INIT, "in base=0x%x", base); in nsphw_init()
311 data->ScsiClockDiv = CLOCK_40M | FAST_20; in nsphw_init()
312 data->CurrentSC = NULL; in nsphw_init()
313 data->FifoCount = 0; in nsphw_init()
314 data->TransferMode = MODE_IO8; in nsphw_init()
319 nsp_write(base, IRQCONTROL, IRQCONTROL_ALLMASK); in nsphw_init()
322 nsp_write(base, IFSELECT, IF_IFSEL); in nsphw_init()
324 nsp_index_write(base, SCSIIRQMODE, 0); in nsphw_init()
326 nsp_index_write(base, TRANSFERMODE, MODE_IO8); in nsphw_init()
327 nsp_index_write(base, CLOCKDIV, data->ScsiClockDiv); in nsphw_init()
329 nsp_index_write(base, PARITYCTRL, 0); in nsphw_init()
330 nsp_index_write(base, POINTERCLR, POINTER_CLEAR | in nsphw_init()
336 nsp_write(base, IFSELECT, IF_REGSEL); in nsphw_init()
337 nsp_index_write(base, TERMPWRCTRL, 0); in nsphw_init()
338 if ((nsp_index_read(base, OTHERCONTROL) & TPWR_SENSE) == 0) { in nsphw_init()
340 nsp_index_write(base, TERMPWRCTRL, POWER_ON); in nsphw_init()
343 nsp_index_write(base, TIMERCOUNT, 0); in nsphw_init()
344 nsp_index_write(base, TIMERCOUNT, 0); /* requires 2 times!! */ in nsphw_init()
346 nsp_index_write(base, SYNCREG, 0); in nsphw_init()
347 nsp_index_write(base, ACKWIDTH, 0); in nsphw_init()
350 nsp_index_write(base, SCSIIRQMODE, SCSI_PHASE_CHANGE_EI | in nsphw_init()
353 nsp_write(base, IRQCONTROL, IRQCONTROL_ALLCLEAR); in nsphw_init()
365 unsigned int host_id = SCpnt->device->host->this_id; in nsphw_start_selection()
366 unsigned int base = SCpnt->device->host->io_port; in nsphw_start_selection() local
368 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsphw_start_selection()
374 phase = nsp_index_read(base, SCSIBUSMON); in nsphw_start_selection()
382 SCpnt->SCp.phase = PH_ARBSTART; in nsphw_start_selection()
383 nsp_index_write(base, SETARBIT, ARBIT_GO); in nsphw_start_selection()
385 time_out = 1000; in nsphw_start_selection()
388 arbit = nsp_index_read(base, ARBITSTATUS); in nsphw_start_selection()
392 (time_out-- != 0)); in nsphw_start_selection()
396 nsp_index_write(base, SETARBIT, ARBIT_FLAG_CLEAR); in nsphw_start_selection()
402 SCpnt->SCp.phase = PH_SELSTART; in nsphw_start_selection()
404 nsp_index_write(base, SCSIDATALATCH, BIT(host_id) | BIT(target)); in nsphw_start_selection()
405 nsp_index_write(base, SCSIBUSCTRL, SCSI_SEL | SCSI_BSY | SCSI_ATN); in nsphw_start_selection()
407 nsp_index_write(base, SCSIBUSCTRL, SCSI_SEL | SCSI_BSY | SCSI_DATAOUT_ENB | SCSI_ATN); in nsphw_start_selection()
408 nsp_index_write(base, SETARBIT, ARBIT_FLAG_CLEAR); in nsphw_start_selection()
410 nsp_index_write(base, SCSIBUSCTRL, SCSI_SEL | SCSI_DATAOUT_ENB | SCSI_ATN); in nsphw_start_selection()
413 nsp_start_timer(SCpnt, 1000/51); in nsphw_start_selection()
414 data->SelectionTimeOut = 1; in nsphw_start_selection()
447 // unsigned char lun = SCpnt->device->lun; in nsp_analyze_sdtr()
448 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_analyze_sdtr()
449 sync_data *sync = &(data->Sync[target]); in nsp_analyze_sdtr()
457 period = sync->SyncPeriod; in nsp_analyze_sdtr()
458 offset = sync->SyncOffset; in nsp_analyze_sdtr()
460 nsp_dbg(NSP_DEBUG_SYNC, "period=0x%x, offset=0x%x", period, offset); in nsp_analyze_sdtr()
462 if ((data->ScsiClockDiv & (BIT(0)|BIT(1))) == CLOCK_20M) { in nsp_analyze_sdtr()
468 for ( i = 0; sync_table->max_period != 0; i++, sync_table++) { in nsp_analyze_sdtr()
469 if ( period >= sync_table->min_period && in nsp_analyze_sdtr()
470 period <= sync_table->max_period ) { in nsp_analyze_sdtr()
475 if (period != 0 && sync_table->max_period == 0) { in nsp_analyze_sdtr()
481 sync->SyncPeriod = 0; in nsp_analyze_sdtr()
482 sync->SyncOffset = 0; in nsp_analyze_sdtr()
483 sync->SyncRegister = 0; in nsp_analyze_sdtr()
484 sync->AckWidth = 0; in nsp_analyze_sdtr()
489 sync->SyncRegister = (sync_table->chip_period << SYNCREG_PERIOD_SHIFT) | in nsp_analyze_sdtr()
491 sync->AckWidth = sync_table->ack_width; in nsp_analyze_sdtr()
493 nsp_dbg(NSP_DEBUG_SYNC, "sync_reg=0x%x, ack_width=0x%x", sync->SyncRegister, sync->AckWidth); in nsp_analyze_sdtr()
504 unsigned int base = SCpnt->device->host->io_port; in nsp_start_timer() local
505 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_start_timer()
507 //nsp_dbg(NSP_DEBUG_INTR, "in SCpnt=0x%p, time=%d", SCpnt, time); in nsp_start_timer()
508 data->TimerCount = time; in nsp_start_timer()
509 nsp_index_write(base, TIMERCOUNT, time); in nsp_start_timer()
518 unsigned int base = SCpnt->device->host->io_port; in nsp_negate_signal() local
527 reg = nsp_index_read(base, SCSIBUSMON); in nsp_negate_signal()
531 } while ((--time_out != 0) && (reg & mask) != 0); in nsp_negate_signal()
547 unsigned int base = SCpnt->device->host->io_port; in nsp_expect_signal() local
551 //nsp_dbg(NSP_DEBUG_INTR, "current_phase=0x%x, mask=0x%x", current_phase, mask); in nsp_expect_signal()
555 phase = nsp_index_read(base, SCSIBUSMON); in nsp_expect_signal()
557 //nsp_dbg(NSP_DEBUG_INTR, "ret -1"); in nsp_expect_signal()
558 return -1; in nsp_expect_signal()
560 i_src = nsp_read(base, IRQSTATUS); in nsp_expect_signal()
566 //nsp_dbg(NSP_DEBUG_INTR, "ret 1 phase=0x%x", phase); in nsp_expect_signal()
569 } while(time_out-- != 0); in nsp_expect_signal()
572 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 && SCpnt->SCp.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()
620 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_dataphase_bypass()
625 if (SCpnt->SCp.have_data_in != IO_IN) { in nsp_dataphase_bypass()
630 if (data->FifoCount == count) { in nsp_dataphase_bypass()
640 SCpnt->SCp.phase = PH_DATA; in nsp_dataphase_bypass()
652 unsigned int base = SCpnt->device->host->io_port; in nsp_reselected() local
653 unsigned int host_id = SCpnt->device->host->this_id; in nsp_reselected()
654 //nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_reselected()
661 id_reg = nsp_index_read(base, RESELECTID); in nsp_reselected()
679 bus_reg = nsp_index_read(base, SCSIBUSCTRL) & ~(SCSI_BSY | SCSI_ATN); in nsp_reselected()
680 nsp_index_write(base, SCSIBUSCTRL, bus_reg); in nsp_reselected()
681 nsp_index_write(base, SCSIBUSCTRL, bus_reg | AUTODIRECTION | ACKENB); in nsp_reselected()
691 unsigned int base = SCpnt->device->host->io_port; in nsp_fifo_count() local
695 nsp_index_write(base, POINTERCLR, POINTER_CLEAR | ACK_COUNTER); in nsp_fifo_count()
697 l = nsp_index_read(base, TRANSFERCOUNT); in nsp_fifo_count()
698 m = nsp_index_read(base, TRANSFERCOUNT); in nsp_fifo_count()
699 h = nsp_index_read(base, TRANSFERCOUNT); in nsp_fifo_count()
700 nsp_index_read(base, TRANSFERCOUNT); /* required this! */ in nsp_fifo_count()
704 //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, SCpnt->SCp.ptr, in nsp_pio_read()
729 SCpnt->SCp.this_residual, SCpnt->SCp.buffer, in nsp_pio_read()
730 SCpnt->SCp.buffers_residual); in nsp_pio_read()
732 time_out = 1000; in nsp_pio_read()
734 while ((time_out-- != 0) && in nsp_pio_read()
735 (SCpnt->SCp.this_residual > 0 || SCpnt->SCp.buffers_residual > 0 ) ) { in nsp_pio_read()
737 stat = nsp_index_read(base, SCSIBUSMON); in nsp_pio_read()
741 res = nsp_fifo_count(SCpnt) - ocount; in nsp_pio_read()
742 …//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()
745 //nsp_dbg(NSP_DEBUG_DATA_IO, " wait for data this=%d", SCpnt->SCp.this_residual); in nsp_pio_read()
748 nsp_dbg(NSP_DEBUG_DATA_IO, "phase changed stat=0x%x", stat); in nsp_pio_read()
753 fifo_stat = nsp_read(base, FIFOSTATUS); in nsp_pio_read()
759 res = min(res, SCpnt->SCp.this_residual); in nsp_pio_read()
761 switch (data->TransferMode) { in nsp_pio_read()
764 nsp_fifo32_read(base, SCpnt->SCp.ptr, res >> 2); in nsp_pio_read()
767 nsp_fifo8_read (base, SCpnt->SCp.ptr, res ); in nsp_pio_read()
772 nsp_mmio_fifo32_read(mmio_base, SCpnt->SCp.ptr, res >> 2); in nsp_pio_read()
780 nsp_inc_resid(SCpnt, -res); in nsp_pio_read()
781 SCpnt->SCp.ptr += res; in nsp_pio_read()
782 SCpnt->SCp.this_residual -= res; in nsp_pio_read()
784 …//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()
787 if (SCpnt->SCp.this_residual == 0 && in nsp_pio_read()
788 SCpnt->SCp.buffers_residual != 0 ) { in nsp_pio_read()
790 SCpnt->SCp.buffers_residual--; in nsp_pio_read()
791 SCpnt->SCp.buffer = sg_next(SCpnt->SCp.buffer); in nsp_pio_read()
792 SCpnt->SCp.ptr = BUFFER_ADDR; in nsp_pio_read()
793 SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length; in nsp_pio_read()
794 time_out = 1000; in nsp_pio_read()
796 …//nsp_dbg(NSP_DEBUG_DATA_IO, "page: 0x%p, off: 0x%x", SCpnt->SCp.buffer->page, SCpnt->SCp.buffer->… in nsp_pio_read()
800 data->FifoCount = ocount; in nsp_pio_read()
804 scsi_get_resid(SCpnt), SCpnt->SCp.this_residual, in nsp_pio_read()
805 SCpnt->SCp.buffers_residual); in nsp_pio_read()
807 nsp_dbg(NSP_DEBUG_DATA_IO, "read ocount=0x%x", ocount); in nsp_pio_read()
808 nsp_dbg(NSP_DEBUG_DATA_IO, "r cmd=%d resid=0x%x\n", data->CmdId, in nsp_pio_read()
817 unsigned int base = SCpnt->device->host->io_port; in nsp_pio_write() local
818 unsigned long mmio_base = SCpnt->device->host->base; in nsp_pio_write()
819 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_pio_write()
824 ocount = data->FifoCount; in nsp_pio_write()
826 …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()
827 data->FifoCount, SCpnt->SCp.ptr, SCpnt->SCp.this_residual, in nsp_pio_write()
828 SCpnt->SCp.buffer, SCpnt->SCp.buffers_residual, in nsp_pio_write()
831 time_out = 1000; in nsp_pio_write()
833 while ((time_out-- != 0) && in nsp_pio_write()
834 (SCpnt->SCp.this_residual > 0 || SCpnt->SCp.buffers_residual > 0)) { in nsp_pio_write()
835 stat = nsp_index_read(base, SCSIBUSMON); in nsp_pio_write()
839 res = ocount - nsp_fifo_count(SCpnt); in nsp_pio_write()
841 nsp_dbg(NSP_DEBUG_DATA_IO, "phase changed stat=0x%x, res=%d\n", stat, res); in nsp_pio_write()
844 SCpnt->SCp.ptr -= res; in nsp_pio_write()
845 SCpnt->SCp.this_residual += res; in nsp_pio_write()
846 ocount -= res; in nsp_pio_write()
851 res = ocount - nsp_fifo_count(SCpnt); in nsp_pio_write()
853 nsp_dbg(NSP_DEBUG_DATA_IO, "wait for all data out. ocount=0x%x res=%d", ocount, res); in nsp_pio_write()
857 res = min(SCpnt->SCp.this_residual, WFIFO_CRIT); in nsp_pio_write()
859 …//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()
860 switch (data->TransferMode) { in nsp_pio_write()
863 nsp_fifo32_write(base, SCpnt->SCp.ptr, res >> 2); in nsp_pio_write()
866 nsp_fifo8_write (base, SCpnt->SCp.ptr, res ); in nsp_pio_write()
871 nsp_mmio_fifo32_write(mmio_base, SCpnt->SCp.ptr, res >> 2); in nsp_pio_write()
879 nsp_inc_resid(SCpnt, -res); in nsp_pio_write()
880 SCpnt->SCp.ptr += res; in nsp_pio_write()
881 SCpnt->SCp.this_residual -= res; in nsp_pio_write()
885 if (SCpnt->SCp.this_residual == 0 && in nsp_pio_write()
886 SCpnt->SCp.buffers_residual != 0 ) { in nsp_pio_write()
888 SCpnt->SCp.buffers_residual--; in nsp_pio_write()
889 SCpnt->SCp.buffer = sg_next(SCpnt->SCp.buffer); in nsp_pio_write()
890 SCpnt->SCp.ptr = BUFFER_ADDR; in nsp_pio_write()
891 SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length; in nsp_pio_write()
892 time_out = 1000; in nsp_pio_write()
896 data->FifoCount = ocount; in nsp_pio_write()
899 nsp_msg(KERN_DEBUG, "pio write timeout resid=0x%x", in nsp_pio_write()
902 nsp_dbg(NSP_DEBUG_DATA_IO, "write ocount=0x%x", ocount); in nsp_pio_write()
903 nsp_dbg(NSP_DEBUG_DATA_IO, "w cmd=%d resid=0x%x\n", data->CmdId, in nsp_pio_write()
914 unsigned int base = SCpnt->device->host->io_port; in nsp_nexus() local
916 // unsigned char lun = SCpnt->device->lun; in nsp_nexus()
917 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_nexus()
918 sync_data *sync = &(data->Sync[target]); in nsp_nexus()
920 //nsp_dbg(NSP_DEBUG_DATA_IO, "in SCpnt=0x%p", SCpnt); in nsp_nexus()
923 nsp_index_write(base, SYNCREG, sync->SyncRegister); in nsp_nexus()
924 nsp_index_write(base, ACKWIDTH, sync->AckWidth); in nsp_nexus()
928 data->TransferMode = MODE_IO8; in nsp_nexus()
930 data->TransferMode = MODE_MEM32; in nsp_nexus()
932 data->TransferMode = MODE_IO32; in nsp_nexus()
934 data->TransferMode = MODE_IO8; in nsp_nexus()
941 data->FifoCount = 0; in nsp_nexus()
942 nsp_index_write(base, POINTERCLR, POINTER_CLEAR | in nsp_nexus()
956 unsigned int base; in nspintr() local
965 //nsp_dbg(NSP_DEBUG_INTR, "dev_id=0x%p", dev_id); in nspintr()
966 //nsp_dbg(NSP_DEBUG_INTR, "host=0x%p", ((scsi_info_t *)dev_id)->host); in nspintr()
969 ((scsi_info_t *)dev_id)->host != NULL ) { in nspintr()
972 data = (nsp_hw_data *)info->host->hostdata; in nspintr()
978 //nsp_dbg(NSP_DEBUG_INTR, "&nsp_data_base=0x%p, dev_id=0x%p", &nsp_data_base, dev_id); in nspintr()
980 base = data->BaseAddress; in nspintr()
981 //nsp_dbg(NSP_DEBUG_INTR, "base=0x%x", base); in nspintr()
986 nsp_write(base, IRQCONTROL, IRQCONTROL_IRQDISABLE); in nspintr()
987 irq_status = nsp_read(base, IRQSTATUS); in nspintr()
988 //nsp_dbg(NSP_DEBUG_INTR, "irq_status=0x%x", irq_status); in nspintr()
990 nsp_write(base, IRQCONTROL, 0); in nspintr()
999 phase = nsp_index_read(base, SCSIBUSMON); in nspintr()
1001 irq_phase = nsp_index_read(base, IRQPHASESENCE); in nspintr()
1006 //nsp_dbg(NSP_DEBUG_INTR, "irq_phase=0x%x", irq_phase); in nspintr()
1011 //nsp_dbg(NSP_DEBUG_INTR, "timercount=%d", data->TimerCount); in nspintr()
1012 if (data->TimerCount != 0) { in nspintr()
1014 nsp_index_write(base, TIMERCOUNT, 0); in nspintr()
1015 nsp_index_write(base, TIMERCOUNT, 0); in nspintr()
1016 data->TimerCount = 0; in nspintr()
1020 data->SelectionTimeOut == 0) { in nspintr()
1022 nsp_write(base, IRQCONTROL, IRQCONTROL_TIMER_CLEAR); in nspintr()
1026 nsp_write(base, IRQCONTROL, IRQCONTROL_TIMER_CLEAR | IRQCONTROL_FIFO_CLEAR); in nspintr()
1035 if(data->CurrentSC != NULL) { in nspintr()
1036 tmpSC = data->CurrentSC; in nspintr()
1037 tmpSC->result = (DID_RESET << 16) | in nspintr()
1038 ((tmpSC->SCp.Message & 0xff) << 8) | in nspintr()
1039 ((tmpSC->SCp.Status & 0xff) << 0); in nspintr()
1045 if (data->CurrentSC == NULL) { in nspintr()
1046 …nsp_msg(KERN_ERR, "CurrentSC==NULL irq_status=0x%x phase=0x%x irq_phase=0x%x this can't be happen.… in nspintr()
1052 tmpSC = data->CurrentSC; in nspintr()
1053 target = tmpSC->device->id; in nspintr()
1054 lun = tmpSC->device->lun; in nspintr()
1055 sync_neg = &(data->Sync[target].SyncNegotiation); in nspintr()
1063 nsp_write(base, IRQCONTROL, IRQCONTROL_RESELECT_CLEAR); in nspintr()
1076 switch(tmpSC->SCp.phase) { in nspintr()
1080 //nsp_dbg(NSP_DEBUG_INTR, "selection count=%d", data->SelectionTimeOut); in nspintr()
1081 if (data->SelectionTimeOut >= NSP_SELTIMEOUT) { in nspintr()
1083 data->SelectionTimeOut = 0; in nspintr()
1084 nsp_index_write(base, SCSIBUSCTRL, 0); in nspintr()
1086 tmpSC->result = DID_TIME_OUT << 16; in nspintr()
1091 data->SelectionTimeOut += 1; in nspintr()
1092 nsp_start_timer(tmpSC, 1000/51); in nspintr()
1098 data->SelectionTimeOut = 0; in nspintr()
1099 tmpSC->SCp.phase = PH_SELECTED; in nspintr()
1100 nsp_index_write(base, SCSIBUSCTRL, SCSI_ATN); in nspintr()
1102 nsp_index_write(base, SCSIBUSCTRL, SCSI_ATN | AUTODIRECTION | ACKENB); in nspintr()
1112 tmpSC->result = DID_ABORT << 16; in nspintr()
1130 if (((tmpSC->SCp.phase == PH_MSG_IN) || (tmpSC->SCp.phase == PH_MSG_OUT)) && in nspintr()
1132 …nsp_dbg(NSP_DEBUG_INTR, "normal disconnect irq_status=0x%x, phase=0x%x, irq_phase=0x%x", irq_statu… in nspintr()
1137 if (tmpSC->SCp.Message == MSG_COMMAND_COMPLETE) { in nspintr()
1138 tmpSC->result = (DID_OK << 16) | in nspintr()
1139 ((tmpSC->SCp.Message & 0xff) << 8) | in nspintr()
1140 ((tmpSC->SCp.Status & 0xff) << 0); in nspintr()
1141 nsp_dbg(NSP_DEBUG_INTR, "command complete result=0x%x", tmpSC->result); in nspintr()
1153 …nsp_msg(KERN_DEBUG, "unexpected bus free. irq_status=0x%x, phase=0x%x, irq_phase=0x%x", irq_status… in nspintr()
1156 tmpSC->result = DID_ERROR << 16; in nspintr()
1169 tmpSC->SCp.phase = PH_COMMAND; in nspintr()
1174 nsp_dbg(NSP_DEBUG_INTR, "cmd_len=%d", tmpSC->cmd_len); in nspintr()
1175 nsp_index_write(base, COMMANDCTRL, CLEAR_COMMAND_POINTER); in nspintr()
1176 for (i = 0; i < tmpSC->cmd_len; i++) { in nspintr()
1177 nsp_index_write(base, COMMANDDATA, tmpSC->cmnd[i]); in nspintr()
1179 nsp_index_write(base, COMMANDCTRL, CLEAR_COMMAND_POINTER | AUTO_COMMAND_GO); in nspintr()
1185 tmpSC->SCp.phase = PH_DATA; in nspintr()
1186 tmpSC->SCp.have_data_in = IO_OUT; in nspintr()
1195 tmpSC->SCp.phase = PH_DATA; in nspintr()
1196 tmpSC->SCp.have_data_in = IO_IN; in nspintr()
1206 tmpSC->SCp.phase = PH_STATUS; in nspintr()
1208 tmpSC->SCp.Status = nsp_index_read(base, SCSIDATAWITHACK); in nspintr()
1209 nsp_dbg(NSP_DEBUG_INTR, "message=0x%x status=0x%x", tmpSC->SCp.Message, tmpSC->SCp.Status); in nspintr()
1219 tmpSC->SCp.phase = PH_MSG_OUT; in nspintr()
1223 data->MsgLen = i = 0; in nspintr()
1224 data->MsgBuffer[i] = IDENTIFY(TRUE, lun); i++; in nspintr()
1227 data->Sync[target].SyncPeriod = 0; in nspintr()
1228 data->Sync[target].SyncOffset = 0; in nspintr()
1231 data->MsgBuffer[i] = MSG_EXTENDED; i++; in nspintr()
1232 data->MsgBuffer[i] = 3; i++; in nspintr()
1233 data->MsgBuffer[i] = MSG_EXT_SDTR; i++; in nspintr()
1234 data->MsgBuffer[i] = 0x0c; i++; in nspintr()
1235 data->MsgBuffer[i] = 15; i++; in nspintr()
1238 data->MsgLen = i; in nspintr()
1252 tmpSC->SCp.phase = PH_MSG_IN; in nspintr()
1259 if (data->MsgLen >= 5 && in nspintr()
1260 data->MsgBuffer[0] == MSG_EXTENDED && in nspintr()
1261 data->MsgBuffer[1] == 3 && in nspintr()
1262 data->MsgBuffer[2] == MSG_EXT_SDTR ) { in nspintr()
1263 data->Sync[target].SyncPeriod = data->MsgBuffer[3]; in nspintr()
1264 data->Sync[target].SyncOffset = data->MsgBuffer[4]; in nspintr()
1265 //nsp_dbg(NSP_DEBUG_INTR, "sync ok, %d %d", data->MsgBuffer[3], data->MsgBuffer[4]); in nspintr()
1268 data->Sync[target].SyncPeriod = 0; in nspintr()
1269 data->Sync[target].SyncOffset = 0; in nspintr()
1277 tmp = -1; in nspintr()
1278 for (i = 0; i < data->MsgLen; i++) { in nspintr()
1279 tmp = data->MsgBuffer[i]; in nspintr()
1280 if (data->MsgBuffer[i] == MSG_EXTENDED) { in nspintr()
1281 i += (1 + data->MsgBuffer[i+1]); in nspintr()
1284 tmpSC->SCp.Message = tmp; in nspintr()
1286 nsp_dbg(NSP_DEBUG_INTR, "message=0x%x len=%d", tmpSC->SCp.Message, data->MsgLen); in nspintr()
1302 nsp_start_timer(tmpSC, 1000/102); in nspintr()
1310 /*----------------------------------------------------------------*/
1312 /*----------------------------------------------------------------*/
1318 nsp_dbg(NSP_DEBUG_INIT, "this_id=%d", sht->this_id); in nsp_detect()
1325 memcpy(host->hostdata, data_b, sizeof(nsp_hw_data)); in nsp_detect()
1326 data = (nsp_hw_data *)host->hostdata; in nsp_detect()
1327 data->ScsiInfo->host = host; in nsp_detect()
1329 data->CmdId = 0; in nsp_detect()
1332 …nsp_dbg(NSP_DEBUG_INIT, "irq=%d,%d", data_b->IrqNumber, ((nsp_hw_data *)host->hostdata)->IrqNumber… in nsp_detect()
1334 host->unique_id = data->BaseAddress; in nsp_detect()
1335 host->io_port = data->BaseAddress; in nsp_detect()
1336 host->n_io_port = data->NumAddress; in nsp_detect()
1337 host->irq = data->IrqNumber; in nsp_detect()
1338 host->base = data->MmioAddress; in nsp_detect()
1340 spin_lock_init(&(data->Lock)); in nsp_detect()
1342 snprintf(data->nspinfo, in nsp_detect()
1343 sizeof(data->nspinfo), in nsp_detect()
1344 "NinjaSCSI-3/32Bi Driver $Revision: 1.23 $ IO:0x%04lx-0x%04lx MMIO(virt addr):0x%04lx IRQ:%02d", in nsp_detect()
1345 host->io_port, host->io_port + host->n_io_port - 1, in nsp_detect()
1346 host->base, in nsp_detect()
1347 host->irq); in nsp_detect()
1348 sht->name = data->nspinfo; in nsp_detect()
1356 /*----------------------------------------------------------------*/
1358 /*----------------------------------------------------------------*/
1361 nsp_hw_data *data = (nsp_hw_data *)shpnt->hostdata; in nsp_info()
1363 return data->nspinfo; in nsp_info()
1374 hostno = host->host_no; in nsp_show_info()
1375 data = (nsp_hw_data *)host->hostdata; in nsp_show_info()
1380 seq_printf(m, "IRQ: %d\n", host->irq); in nsp_show_info()
1381 …seq_printf(m, "IO: 0x%lx-0x%lx\n", host->io_port, host->io_port + host->n_io_po… in nsp_show_info()
1382 …seq_printf(m, "MMIO(virtual address): 0x%lx-0x%lx\n", host->base, host->base + data->MmioLength - in nsp_show_info()
1383 seq_printf(m, "sg_tablesize: %d\n", host->sg_tablesize); in nsp_show_info()
1403 spin_lock_irqsave(&(data->Lock), flags); in nsp_show_info()
1404 seq_printf(m, "CurrentSC: 0x%p\n\n", data->CurrentSC); in nsp_show_info()
1405 spin_unlock_irqrestore(&(data->Lock), flags); in nsp_show_info()
1408 for(id = 0; id < ARRAY_SIZE(data->Sync); id++) { in nsp_show_info()
1412 if (id == host->this_id) { in nsp_show_info()
1413 seq_puts(m, "----- NinjaSCSI-3 host adapter\n"); in nsp_show_info()
1417 switch(data->Sync[id].SyncNegotiation) { in nsp_show_info()
1432 if (data->Sync[id].SyncPeriod != 0) { in nsp_show_info()
1433 speed = 1000000 / (data->Sync[id].SyncPeriod * 4); in nsp_show_info()
1436 speed / 1000, in nsp_show_info()
1437 speed % 1000, in nsp_show_info()
1438 data->Sync[id].SyncOffset in nsp_show_info()
1446 /*---------------------------------------------------------------*/
1448 /*---------------------------------------------------------------*/
1453 nsp_dbg(NSP_DEBUG_BUSRESET, "SCpnt=0x%p", SCpnt);
1460 unsigned int base = data->BaseAddress; in nsp_bus_reset() local
1463 nsp_write(base, IRQCONTROL, IRQCONTROL_ALLMASK); in nsp_bus_reset()
1465 nsp_index_write(base, SCSIBUSCTRL, SCSI_RST); in nsp_bus_reset()
1467 nsp_index_write(base, SCSIBUSCTRL, 0); in nsp_bus_reset()
1469 nsp_index_read(base, IRQPHASESENCE); /* dummy read */ in nsp_bus_reset()
1474 nsp_write(base, IRQCONTROL, IRQCONTROL_ALLCLEAR); in nsp_bus_reset()
1481 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_eh_bus_reset()
1483 nsp_dbg(NSP_DEBUG_BUSRESET, "SCpnt=0x%p", SCpnt); in nsp_eh_bus_reset()
1490 nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; in nsp_eh_host_reset()
1514 if (info == NULL) { return -ENOMEM; } in nsp_cs_probe()
1515 info->p_dev = link; in nsp_cs_probe()
1516 link->priv = info; in nsp_cs_probe()
1517 data->ScsiInfo = info; in nsp_cs_probe()
1519 nsp_dbg(NSP_DEBUG_INIT, "info=0x%p", info); in nsp_cs_probe()
1523 nsp_dbg(NSP_DEBUG_INIT, "link=0x%p", link); in nsp_cs_probe()
1530 nsp_dbg(NSP_DEBUG_INIT, "in, link=0x%p", link); in nsp_cs_detach()
1532 ((scsi_info_t *)link->priv)->stop = 1; in nsp_cs_detach()
1535 kfree(link->priv); in nsp_cs_detach()
1536 link->priv = NULL; in nsp_cs_detach()
1544 if (p_dev->config_index == 0) in nsp_cs_config_check()
1545 return -ENODEV; in nsp_cs_config_check()
1551 if (resource_size(p_dev->resource[2])) { in nsp_cs_config_check()
1552 p_dev->resource[2]->flags |= (WIN_DATA_WIDTH_16 | in nsp_cs_config_check()
1555 if (p_dev->resource[2]->end < 0x1000) in nsp_cs_config_check()
1556 p_dev->resource[2]->end = 0x1000; in nsp_cs_config_check()
1557 if (pcmcia_request_window(p_dev, p_dev->resource[2], 0) != 0) in nsp_cs_config_check()
1559 if (pcmcia_map_mem_page(p_dev, p_dev->resource[2], in nsp_cs_config_check()
1560 p_dev->card_addr) != 0) in nsp_cs_config_check()
1563 data->MmioAddress = (unsigned long) in nsp_cs_config_check()
1564 ioremap(p_dev->resource[2]->start, in nsp_cs_config_check()
1565 resource_size(p_dev->resource[2])); in nsp_cs_config_check()
1566 data->MmioLength = resource_size(p_dev->resource[2]); in nsp_cs_config_check()
1574 return -ENODEV; in nsp_cs_config_check()
1580 scsi_info_t *info = link->priv; in nsp_cs_config()
1586 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_CHECK_VCC | in nsp_cs_config()
1602 if (link->resource[0]) { in nsp_cs_config()
1603 release_region(link->resource[0]->start, in nsp_cs_config()
1604 resource_size(link->resource[0])); in nsp_cs_config()
1606 if (link->resource[1]) { in nsp_cs_config()
1607 release_region(link->resource[1]->start, in nsp_cs_config()
1608 resource_size(link->resource[1])); in nsp_cs_config()
1613 data->BaseAddress = link->resource[0]->start; in nsp_cs_config()
1614 data->NumAddress = resource_size(link->resource[0]); in nsp_cs_config()
1615 data->IrqNumber = link->irq; in nsp_cs_config()
1617 nsp_dbg(NSP_DEBUG_INIT, "I/O[0x%x+0x%x] IRQ %d", in nsp_cs_config()
1618 data->BaseAddress, data->NumAddress, data->IrqNumber); in nsp_cs_config()
1638 info->host = host; in nsp_cs_config()
1646 return -ENODEV; in nsp_cs_config()
1652 scsi_info_t *info = link->priv; in nsp_cs_release()
1655 if (info->host == NULL) { in nsp_cs_release()
1658 data = (nsp_hw_data *)info->host->hostdata; in nsp_cs_release()
1661 nsp_dbg(NSP_DEBUG_INIT, "link=0x%p", link); in nsp_cs_release()
1664 if (info->host != NULL) { in nsp_cs_release()
1665 scsi_remove_host(info->host); in nsp_cs_release()
1668 if (resource_size(link->resource[2])) { in nsp_cs_release()
1670 iounmap((void *)(data->MmioAddress)); in nsp_cs_release()
1675 if (info->host != NULL) { in nsp_cs_release()
1676 scsi_host_put(info->host); in nsp_cs_release()
1682 scsi_info_t *info = link->priv; in nsp_cs_suspend()
1687 if (info->host != NULL) { in nsp_cs_suspend()
1690 data = (nsp_hw_data *)info->host->hostdata; in nsp_cs_suspend()
1695 info->stop = 1; in nsp_cs_suspend()
1702 scsi_info_t *info = link->priv; in nsp_cs_resume()
1707 info->stop = 0; in nsp_cs_resume()
1709 if (info->host != NULL) { in nsp_cs_resume()
1712 data = (nsp_hw_data *)info->host->hostdata; in nsp_cs_resume()
1726 PCMCIA_DEVICE_PROD_ID123("KME ", "SCSI-CARD-001", "1", 0x534c02bc, 0x52008408, 0x51de003a),
1727 PCMCIA_DEVICE_PROD_ID123("KME ", "SCSI-CARD-002", "1", 0x534c02bc, 0xcb09d5b2, 0x51de003a),
1728 PCMCIA_DEVICE_PROD_ID123("KME ", "SCSI-CARD-003", "1", 0x534c02bc, 0xbc0ee524, 0x51de003a),
1729 PCMCIA_DEVICE_PROD_ID123("KME ", "SCSI-CARD-004", "1", 0x534c02bc, 0x226a7087, 0x51de003a),
1730 PCMCIA_DEVICE_PROD_ID123("WBT", "NinjaSCSI-3", "R1.0", 0xc7ba805f, 0xfdc7c97d, 0x6973710e),
1731 PCMCIA_DEVICE_PROD_ID123("WORKBIT", "UltraNinja-16", "1", 0x28191418, 0xb70f4b09, 0x51de003a),