Lines Matching refs:host

200 static void acornscsi_done(AS_Host *host, Scsi_Cmnd **SCpntp, unsigned int result);
201 static int acornscsi_reconnect_finish(AS_Host *host);
202 static void acornscsi_dma_cleanup(AS_Host *host);
203 static void acornscsi_abortcmd(AS_Host *host, unsigned char tag);
250 void acornscsi_dumpdma(AS_Host *host, char *where) in acornscsi_dumpdma() argument
254 mode = dmac_read(host->dma.io_port, MODECON); in acornscsi_dumpdma()
255 addr = dmac_address(host->dma.io_port); in acornscsi_dumpdma()
256 len = dmac_read(host->dma.io_port, TXCNTHI) << 8 | in acornscsi_dumpdma()
257 dmac_read(host->dma.io_port, TXCNTLO); in acornscsi_dumpdma()
260 host->host->host_no, where, in acornscsi_dumpdma()
262 dmac_read(host->dma.io_port, MASKREG)); in acornscsi_dumpdma()
264 printk("DMA @%06x, ", host->dma.start_addr); in acornscsi_dumpdma()
265 printk("BH @%p +%04x, ", host->scsi.SCp.ptr, in acornscsi_dumpdma()
266 host->scsi.SCp.this_residual); in acornscsi_dumpdma()
267 printk("DT @+%04x ST @+%04x", host->dma.transferred, in acornscsi_dumpdma()
268 host->scsi.SCp.scsi_xferred); in acornscsi_dumpdma()
274 unsigned long acornscsi_sbic_xfcount(AS_Host *host) in acornscsi_sbic_xfcount() argument
278 length = sbic_arm_read(host->scsi.io_port, TRANSCNTH) << 16; in acornscsi_sbic_xfcount()
279 length |= sbic_arm_readnext(host->scsi.io_port) << 8; in acornscsi_sbic_xfcount()
280 length |= sbic_arm_readnext(host->scsi.io_port); in acornscsi_sbic_xfcount()
286 acornscsi_sbic_wait(AS_Host *host, int stat_mask, int stat, int timeout, char *msg) in acornscsi_sbic_wait() argument
291 asr = sbic_arm_read(host->scsi.io_port, ASR); in acornscsi_sbic_wait()
299 printk("scsi%d: timeout while %s\n", host->host->host_no, msg); in acornscsi_sbic_wait()
305 int acornscsi_sbic_issuecmd(AS_Host *host, int command) in acornscsi_sbic_issuecmd() argument
307 if (acornscsi_sbic_wait(host, ASR_CIP, 0, 1000, "issuing command")) in acornscsi_sbic_issuecmd()
310 sbic_arm_write(host->scsi.io_port, CMND, command); in acornscsi_sbic_issuecmd()
331 void acornscsi_resetcard(AS_Host *host) in acornscsi_resetcard() argument
336 host->card.page_reg = 0x80; in acornscsi_resetcard()
337 outb(host->card.page_reg, host->card.io_page); in acornscsi_resetcard()
342 host->card.page_reg = 0; in acornscsi_resetcard()
343 outb(host->card.page_reg, host->card.io_page); in acornscsi_resetcard()
350 if (inb(host->card.io_intr) & 8) in acornscsi_resetcard()
357 host->host->host_no); in acornscsi_resetcard()
359 sbic_arm_read(host->scsi.io_port, ASR); in acornscsi_resetcard()
360 sbic_arm_read(host->scsi.io_port, SSR); in acornscsi_resetcard()
363 sbic_arm_write(host->scsi.io_port, OWNID, OWNID_EAF | host->host->this_id); in acornscsi_resetcard()
364 sbic_arm_write(host->scsi.io_port, CMND, CMND_RESET); in acornscsi_resetcard()
371 if (inb(host->card.io_intr) & 8) in acornscsi_resetcard()
378 host->host->host_no); in acornscsi_resetcard()
380 sbic_arm_read(host->scsi.io_port, ASR); in acornscsi_resetcard()
381 if (sbic_arm_read(host->scsi.io_port, SSR) != 0x01) in acornscsi_resetcard()
383 host->host->host_no); in acornscsi_resetcard()
385 sbic_arm_write(host->scsi.io_port, CTRL, INIT_SBICDMA | CTRL_IDI); in acornscsi_resetcard()
386 sbic_arm_write(host->scsi.io_port, TIMEOUT, TIMEOUT_TIME); in acornscsi_resetcard()
387 sbic_arm_write(host->scsi.io_port, SYNCHTRANSFER, SYNCHTRANSFER_2DBA); in acornscsi_resetcard()
388 sbic_arm_write(host->scsi.io_port, SOURCEID, SOURCEID_ER | SOURCEID_DSP); in acornscsi_resetcard()
390 host->card.page_reg = 0x40; in acornscsi_resetcard()
391 outb(host->card.page_reg, host->card.io_page); in acornscsi_resetcard()
394 dmac_write(host->dma.io_port, INIT, 0); in acornscsi_resetcard()
396 dmac_write(host->dma.io_port, INIT, INIT_8BIT); in acornscsi_resetcard()
397 dmac_write(host->dma.io_port, CHANNEL, CHANNEL_0); in acornscsi_resetcard()
398 dmac_write(host->dma.io_port, DEVCON0, INIT_DEVCON0); in acornscsi_resetcard()
399 dmac_write(host->dma.io_port, DEVCON1, INIT_DEVCON1); in acornscsi_resetcard()
402 host->SCpnt = NULL; in acornscsi_resetcard()
403 host->scsi.phase = PHASE_IDLE; in acornscsi_resetcard()
404 host->scsi.disconnectable = 0; in acornscsi_resetcard()
407 host->busyluns[i] = 0; in acornscsi_resetcard()
408 host->device[i].sync_state = SYNC_NEGOCIATE; in acornscsi_resetcard()
409 host->device[i].disconnect_ok = 1; in acornscsi_resetcard()
515 acornscsi_dumplogline(AS_Host *host, int target, int line) in acornscsi_dumplogline() argument
520 ptr = host->status_ptr[target] - STATUS_BUFFER_TO_PRINT; in acornscsi_dumplogline()
527 prev = host->status[target][ptr].when; in acornscsi_dumplogline()
529 for (; ptr != host->status_ptr[target]; ptr = (ptr + 1) & (STATUS_BUFFER_SIZE - 1)) { in acornscsi_dumplogline()
532 if (!host->status[target][ptr].when) in acornscsi_dumplogline()
537 printk("%c%02X", host->status[target][ptr].irq ? '-' : ' ', in acornscsi_dumplogline()
538 host->status[target][ptr].ph); in acornscsi_dumplogline()
542 printk(" %02X", host->status[target][ptr].ssr); in acornscsi_dumplogline()
546 time_diff = host->status[target][ptr].when - prev; in acornscsi_dumplogline()
547 prev = host->status[target][ptr].when; in acornscsi_dumplogline()
562 void acornscsi_dumplog(AS_Host *host, int target) in acornscsi_dumplog() argument
565 acornscsi_dumplogline(host, target, 0); in acornscsi_dumplog()
566 acornscsi_dumplogline(host, target, 1); in acornscsi_dumplog()
567 acornscsi_dumplogline(host, target, 2); in acornscsi_dumplog()
577 char acornscsi_target(AS_Host *host) in acornscsi_target() argument
579 if (host->SCpnt) in acornscsi_target()
580 return '0' + host->SCpnt->target; in acornscsi_target()
714 intr_ret_t acornscsi_kick(AS_Host *host) in acornscsi_kick() argument
720 SCpnt = host->origSCpnt; in acornscsi_kick()
721 host->origSCpnt = NULL; in acornscsi_kick()
725 SCpnt = queue_remove_exclude(&host->queues.issue, host->busyluns); in acornscsi_kick()
732 if (host->scsi.disconnectable && host->SCpnt) { in acornscsi_kick()
733 queue_add_cmd_tail(&host->queues.disconnected, host->SCpnt); in acornscsi_kick()
734 host->scsi.disconnectable = 0; in acornscsi_kick()
736 DBG(host->SCpnt, printk("scsi%d.%c: moved command to disconnected queue\n", in acornscsi_kick()
737 host->host->host_no, acornscsi_target(host))); in acornscsi_kick()
739 host->SCpnt = NULL; in acornscsi_kick()
746 if (!(sbic_arm_read(host->scsi.io_port, ASR) & (ASR_INT|ASR_BSY|ASR_CIP))) { in acornscsi_kick()
747 sbic_arm_write(host->scsi.io_port, DESTID, SCpnt->target); in acornscsi_kick()
748 sbic_arm_write(host->scsi.io_port, CMND, CMND_SELWITHATN); in acornscsi_kick()
755 host->scsi.phase = PHASE_CONNECTING; in acornscsi_kick()
756 host->SCpnt = SCpnt; in acornscsi_kick()
757 host->scsi.SCp = SCpnt->SCp; in acornscsi_kick()
758 host->dma.xfer_setup = 0; in acornscsi_kick()
759 host->dma.xfer_required = 0; in acornscsi_kick()
760 host->dma.xfer_done = 0; in acornscsi_kick()
764 host->host->host_no, '0' + SCpnt->target, in acornscsi_kick()
780 set_bit(SCpnt->target * 8 + SCpnt->lun, host->busyluns); in acornscsi_kick()
782 host->stats.removes += 1; in acornscsi_kick()
786 host->stats.writes += 1; in acornscsi_kick()
789 host->stats.reads += 1; in acornscsi_kick()
792 host->stats.miscs += 1; in acornscsi_kick()
807 void acornscsi_done(AS_Host *host, Scsi_Cmnd **SCpntp, unsigned int result) in acornscsi_done() argument
812 sbic_arm_write(host->scsi.io_port, SOURCEID, SOURCEID_ER | SOURCEID_DSP); in acornscsi_done()
814 host->stats.fins += 1; in acornscsi_done()
819 acornscsi_dma_cleanup(host); in acornscsi_done()
821 SCpnt->result = result << 16 | host->scsi.SCp.Message << 8 | host->scsi.SCp.Status; in acornscsi_done()
835 if (host->scsi.SCp.ptr && in acornscsi_done()
839 if (host->scsi.SCp.scsi_xferred < SCpnt->underflow || in acornscsi_done()
840 host->scsi.SCp.scsi_xferred != host->dma.transferred) in acornscsi_done()
856 if (host->dma.xfer_done) in acornscsi_done()
870 host->host->host_no, SCpnt->result); in acornscsi_done()
872 acornscsi_dumpdma(host, "done"); in acornscsi_done()
873 acornscsi_dumplog(host, SCpnt->target); in acornscsi_done()
881 panic("scsi%d.H: null scsi_done function in acornscsi_done", host->host->host_no); in acornscsi_done()
883 clear_bit(SCpnt->target * 8 + SCpnt->lun, host->busyluns); in acornscsi_done()
887 printk("scsi%d: null command in acornscsi_done", host->host->host_no); in acornscsi_done()
889 host->scsi.phase = PHASE_IDLE; in acornscsi_done()
900 void acornscsi_data_updateptr(AS_Host *host, Scsi_Pointer *SCp, unsigned int length) in acornscsi_data_updateptr() argument
913 host->dma.xfer_done = 1; in acornscsi_data_updateptr()
929 void acornscsi_data_read(AS_Host *host, char *ptr, in acornscsi_data_read() argument
938 outb((page & 0x3f) | host->card.page_reg, host->card.io_page); in acornscsi_data_read()
948 __acornscsi_in(host->card.io_ram + (offset << 1), ptr, this_len); in acornscsi_data_read()
957 outb((page & 0x3f) | host->card.page_reg, host->card.io_page); in acornscsi_data_read()
960 outb(host->card.page_reg, host->card.io_page); in acornscsi_data_read()
974 void acornscsi_data_write(AS_Host *host, char *ptr, in acornscsi_data_write() argument
983 outb((page & 0x3f) | host->card.page_reg, host->card.io_page); in acornscsi_data_write()
993 __acornscsi_out(host->card.io_ram + (offset << 1), ptr, this_len); in acornscsi_data_write()
1002 outb((page & 0x3f) | host->card.page_reg, host->card.io_page); in acornscsi_data_write()
1005 outb(host->card.page_reg, host->card.io_page); in acornscsi_data_write()
1020 void acornscsi_dma_stop(AS_Host *host) in acornscsi_dma_stop() argument
1022 dmac_write(host->dma.io_port, MASKREG, MASK_ON); in acornscsi_dma_stop()
1023 dmac_clearintr(host->dma.io_intr_clear); in acornscsi_dma_stop()
1026 DBG(host->SCpnt, acornscsi_dumpdma(host, "stop")); in acornscsi_dma_stop()
1039 void acornscsi_dma_setup(AS_Host *host, dmadir_t direction) in acornscsi_dma_setup() argument
1043 host->dma.direction = direction; in acornscsi_dma_setup()
1045 dmac_write(host->dma.io_port, MASKREG, MASK_ON); in acornscsi_dma_setup()
1049 if (NO_WRITE & (1 << host->SCpnt->target)) { in acornscsi_dma_setup()
1051 host->host->host_no, acornscsi_target(host)); in acornscsi_dma_setup()
1062 length = min_t(unsigned int, host->scsi.SCp.this_residual, DMAC_BUFFER_SIZE / 2); in acornscsi_dma_setup()
1064 host->dma.start_addr = address = host->dma.free_addr; in acornscsi_dma_setup()
1065 host->dma.free_addr = (host->dma.free_addr + length) & in acornscsi_dma_setup()
1072 acornscsi_data_write(host, host->scsi.SCp.ptr, host->dma.start_addr, in acornscsi_dma_setup()
1076 dmac_write(host->dma.io_port, TXCNTLO, length); in acornscsi_dma_setup()
1077 dmac_write(host->dma.io_port, TXCNTHI, length >> 8); in acornscsi_dma_setup()
1078 dmac_write(host->dma.io_port, TXADRLO, address); in acornscsi_dma_setup()
1079 dmac_write(host->dma.io_port, TXADRMD, address >> 8); in acornscsi_dma_setup()
1080 dmac_write(host->dma.io_port, TXADRHI, 0); in acornscsi_dma_setup()
1081 dmac_write(host->dma.io_port, MODECON, mode); in acornscsi_dma_setup()
1082 dmac_write(host->dma.io_port, MASKREG, MASK_OFF); in acornscsi_dma_setup()
1085 DBG(host->SCpnt, acornscsi_dumpdma(host, "strt")); in acornscsi_dma_setup()
1087 host->dma.xfer_setup = 1; in acornscsi_dma_setup()
1100 void acornscsi_dma_cleanup(AS_Host *host) in acornscsi_dma_cleanup() argument
1102 dmac_write(host->dma.io_port, MASKREG, MASK_ON); in acornscsi_dma_cleanup()
1103 dmac_clearintr(host->dma.io_intr_clear); in acornscsi_dma_cleanup()
1108 if (host->dma.xfer_required) { in acornscsi_dma_cleanup()
1109 host->dma.xfer_required = 0; in acornscsi_dma_cleanup()
1110 if (host->dma.direction == DMA_IN) in acornscsi_dma_cleanup()
1111 acornscsi_data_read(host, host->dma.xfer_ptr, in acornscsi_dma_cleanup()
1112 host->dma.xfer_start, host->dma.xfer_length); in acornscsi_dma_cleanup()
1118 if (host->dma.xfer_setup) { in acornscsi_dma_cleanup()
1121 host->dma.xfer_setup = 0; in acornscsi_dma_cleanup()
1124 DBG(host->SCpnt, acornscsi_dumpdma(host, "cupi")); in acornscsi_dma_cleanup()
1130 transferred = dmac_address(host->dma.io_port) - host->dma.start_addr; in acornscsi_dma_cleanup()
1131 host->dma.transferred += transferred; in acornscsi_dma_cleanup()
1133 if (host->dma.direction == DMA_IN) in acornscsi_dma_cleanup()
1134 acornscsi_data_read(host, host->scsi.SCp.ptr, in acornscsi_dma_cleanup()
1135 host->dma.start_addr, transferred); in acornscsi_dma_cleanup()
1140 acornscsi_data_updateptr(host, &host->scsi.SCp, transferred); in acornscsi_dma_cleanup()
1142 DBG(host->SCpnt, acornscsi_dumpdma(host, "cupo")); in acornscsi_dma_cleanup()
1158 void acornscsi_dma_intr(AS_Host *host) in acornscsi_dma_intr() argument
1163 DBG(host->SCpnt, acornscsi_dumpdma(host, "inti")); in acornscsi_dma_intr()
1166 dmac_write(host->dma.io_port, MASKREG, MASK_ON); in acornscsi_dma_intr()
1167 dmac_clearintr(host->dma.io_intr_clear); in acornscsi_dma_intr()
1172 transferred = dmac_address(host->dma.io_port) - host->dma.start_addr; in acornscsi_dma_intr()
1173 host->dma.transferred += transferred; in acornscsi_dma_intr()
1178 if (host->dma.direction == DMA_IN) { in acornscsi_dma_intr()
1179 host->dma.xfer_start = host->dma.start_addr; in acornscsi_dma_intr()
1180 host->dma.xfer_length = transferred; in acornscsi_dma_intr()
1181 host->dma.xfer_ptr = host->scsi.SCp.ptr; in acornscsi_dma_intr()
1182 host->dma.xfer_required = 1; in acornscsi_dma_intr()
1185 acornscsi_data_updateptr(host, &host->scsi.SCp, transferred); in acornscsi_dma_intr()
1190 length = min_t(unsigned int, host->scsi.SCp.this_residual, DMAC_BUFFER_SIZE / 2); in acornscsi_dma_intr()
1192 host->dma.start_addr = address = host->dma.free_addr; in acornscsi_dma_intr()
1193 host->dma.free_addr = (host->dma.free_addr + length) & in acornscsi_dma_intr()
1199 if (host->dma.direction == DMA_OUT) in acornscsi_dma_intr()
1200 acornscsi_data_write(host, host->scsi.SCp.ptr, host->dma.start_addr, in acornscsi_dma_intr()
1204 dmac_write(host->dma.io_port, TXCNTLO, length); in acornscsi_dma_intr()
1205 dmac_write(host->dma.io_port, TXCNTHI, length >> 8); in acornscsi_dma_intr()
1206 dmac_write(host->dma.io_port, TXADRLO, address); in acornscsi_dma_intr()
1207 dmac_write(host->dma.io_port, TXADRMD, address >> 8); in acornscsi_dma_intr()
1208 dmac_write(host->dma.io_port, TXADRHI, 0); in acornscsi_dma_intr()
1209 dmac_write(host->dma.io_port, MASKREG, MASK_OFF); in acornscsi_dma_intr()
1212 DBG(host->SCpnt, acornscsi_dumpdma(host, "into")); in acornscsi_dma_intr()
1215 host->dma.xfer_setup = 0; in acornscsi_dma_intr()
1223 if (dmac_read(host->dma.io_port, STATUS) & STATUS_RQ0) { in acornscsi_dma_intr()
1224 acornscsi_abortcmd(host, host->SCpnt->tag); in acornscsi_dma_intr()
1226 dmac_write(host->dma.io_port, TXCNTLO, 0); in acornscsi_dma_intr()
1227 dmac_write(host->dma.io_port, TXCNTHI, 0); in acornscsi_dma_intr()
1228 dmac_write(host->dma.io_port, TXADRLO, 0); in acornscsi_dma_intr()
1229 dmac_write(host->dma.io_port, TXADRMD, 0); in acornscsi_dma_intr()
1230 dmac_write(host->dma.io_port, TXADRHI, 0); in acornscsi_dma_intr()
1231 dmac_write(host->dma.io_port, MASKREG, MASK_OFF); in acornscsi_dma_intr()
1243 void acornscsi_dma_xfer(AS_Host *host) in acornscsi_dma_xfer() argument
1245 host->dma.xfer_required = 0; in acornscsi_dma_xfer()
1247 if (host->dma.direction == DMA_IN) in acornscsi_dma_xfer()
1248 acornscsi_data_read(host, host->dma.xfer_ptr, in acornscsi_dma_xfer()
1249 host->dma.xfer_start, host->dma.xfer_length); in acornscsi_dma_xfer()
1259 void acornscsi_dma_adjust(AS_Host *host) in acornscsi_dma_adjust() argument
1261 if (host->dma.xfer_setup) { in acornscsi_dma_adjust()
1264 DBG(host->SCpnt, acornscsi_dumpdma(host, "adji")); in acornscsi_dma_adjust()
1277 transferred = host->scsi.SCp.scsi_xferred - host->dma.transferred; in acornscsi_dma_adjust()
1280 host->host->host_no, acornscsi_target(host), transferred); in acornscsi_dma_adjust()
1282 host->dma.xfer_setup = 0; in acornscsi_dma_adjust()
1284 transferred += host->dma.start_addr; in acornscsi_dma_adjust()
1285 dmac_write(host->dma.io_port, TXADRLO, transferred); in acornscsi_dma_adjust()
1286 dmac_write(host->dma.io_port, TXADRMD, transferred >> 8); in acornscsi_dma_adjust()
1287 dmac_write(host->dma.io_port, TXADRHI, transferred >> 16); in acornscsi_dma_adjust()
1289 DBG(host->SCpnt, acornscsi_dumpdma(host, "adjo")); in acornscsi_dma_adjust()
1300 acornscsi_write_pio(AS_Host *host, char *bytes, int *ptr, int len, unsigned int max_timeout) in acornscsi_write_pio() argument
1306 asr = sbic_arm_read(host->scsi.io_port, ASR); in acornscsi_write_pio()
1311 sbic_arm_write(host->scsi.io_port, DATA, bytes[my_ptr++]); in acornscsi_write_pio()
1330 acornscsi_sendcommand(AS_Host *host) in acornscsi_sendcommand() argument
1332 Scsi_Cmnd *SCpnt = host->SCpnt; in acornscsi_sendcommand()
1334 sbic_arm_write(host->scsi.io_port, TRANSCNTH, 0); in acornscsi_sendcommand()
1335 sbic_arm_writenext(host->scsi.io_port, 0); in acornscsi_sendcommand()
1336 sbic_arm_writenext(host->scsi.io_port, SCpnt->cmd_len - host->scsi.SCp.sent_command); in acornscsi_sendcommand()
1338 acornscsi_sbic_issuecmd(host, CMND_XFERINFO); in acornscsi_sendcommand()
1340 if (acornscsi_write_pio(host, SCpnt->cmnd, in acornscsi_sendcommand()
1341 (int *)&host->scsi.SCp.sent_command, SCpnt->cmd_len, 1000000)) in acornscsi_sendcommand()
1342 printk("scsi%d: timeout while sending command\n", host->host->host_no); in acornscsi_sendcommand()
1344 host->scsi.phase = PHASE_COMMAND; in acornscsi_sendcommand()
1348 void acornscsi_sendmessage(AS_Host *host) in acornscsi_sendmessage() argument
1350 unsigned int message_length = msgqueue_msglength(&host->scsi.msgs); in acornscsi_sendmessage()
1356 host->host->host_no, acornscsi_target(host)); in acornscsi_sendmessage()
1361 acornscsi_sbic_issuecmd(host, CMND_XFERINFO | CMND_SBT); in acornscsi_sendmessage()
1363 acornscsi_sbic_wait(host, ASR_DBR, ASR_DBR, 1000, "sending message 1"); in acornscsi_sendmessage()
1365 sbic_arm_write(host->scsi.io_port, DATA, NOP); in acornscsi_sendmessage()
1367 host->scsi.last_message = NOP; in acornscsi_sendmessage()
1374 acornscsi_sbic_issuecmd(host, CMND_XFERINFO | CMND_SBT); in acornscsi_sendmessage()
1375 msg = msgqueue_getmsg(&host->scsi.msgs, 0); in acornscsi_sendmessage()
1377 acornscsi_sbic_wait(host, ASR_DBR, ASR_DBR, 1000, "sending message 2"); in acornscsi_sendmessage()
1379 sbic_arm_write(host->scsi.io_port, DATA, msg->msg[0]); in acornscsi_sendmessage()
1381 host->scsi.last_message = msg->msg[0]; in acornscsi_sendmessage()
1396 sbic_arm_write(host->scsi.io_port, TRANSCNTH, 0); in acornscsi_sendmessage()
1397 sbic_arm_writenext(host->scsi.io_port, 0); in acornscsi_sendmessage()
1398 sbic_arm_writenext(host->scsi.io_port, message_length); in acornscsi_sendmessage()
1399 acornscsi_sbic_issuecmd(host, CMND_XFERINFO); in acornscsi_sendmessage()
1402 while ((msg = msgqueue_getmsg(&host->scsi.msgs, msgnr++)) != NULL) { in acornscsi_sendmessage()
1408 if (acornscsi_write_pio(host, msg->msg, &i, msg->length, 1000000)) in acornscsi_sendmessage()
1409 printk("scsi%d: timeout while sending message\n", host->host->host_no); in acornscsi_sendmessage()
1411 host->scsi.last_message = msg->msg[0]; in acornscsi_sendmessage()
1413 host->scsi.last_message |= msg->msg[2] << 8; in acornscsi_sendmessage()
1431 void acornscsi_readstatusbyte(AS_Host *host) in acornscsi_readstatusbyte() argument
1433 acornscsi_sbic_issuecmd(host, CMND_XFERINFO|CMND_SBT); in acornscsi_readstatusbyte()
1434 acornscsi_sbic_wait(host, ASR_DBR, ASR_DBR, 1000, "reading status byte"); in acornscsi_readstatusbyte()
1435 host->scsi.SCp.Status = sbic_arm_read(host->scsi.io_port, DATA); in acornscsi_readstatusbyte()
1444 unsigned char acornscsi_readmessagebyte(AS_Host *host) in acornscsi_readmessagebyte() argument
1448 acornscsi_sbic_issuecmd(host, CMND_XFERINFO | CMND_SBT); in acornscsi_readmessagebyte()
1450 acornscsi_sbic_wait(host, ASR_DBR, ASR_DBR, 1000, "for message byte"); in acornscsi_readmessagebyte()
1452 message = sbic_arm_read(host->scsi.io_port, DATA); in acornscsi_readmessagebyte()
1455 acornscsi_sbic_wait(host, ASR_INT, ASR_INT, 1000, "for interrupt after message byte"); in acornscsi_readmessagebyte()
1457 sbic_arm_read(host->scsi.io_port, SSR); in acornscsi_readmessagebyte()
1468 void acornscsi_message(AS_Host *host) in acornscsi_message() argument
1474 message[msgidx] = acornscsi_readmessagebyte(host); in acornscsi_message()
1490 acornscsi_sbic_issuecmd(host, CMND_NEGATEACK); in acornscsi_message()
1493 acornscsi_sbic_wait(host, ASR_INT, ASR_INT, 1000, "for interrupt after negate ack"); in acornscsi_message()
1494 sbic_arm_read(host->scsi.io_port, SSR); in acornscsi_message()
1500 host->host->host_no, acornscsi_target(host)); in acornscsi_message()
1505 if (host->scsi.phase == PHASE_RECONNECTED) { in acornscsi_message()
1513 host->scsi.reconnected.tag = message[1]; in acornscsi_message()
1514 if (acornscsi_reconnect_finish(host)) in acornscsi_message()
1515 host->scsi.phase = PHASE_MSGIN; in acornscsi_message()
1522 if (host->scsi.phase != PHASE_STATUSIN) { in acornscsi_message()
1524 host->host->host_no, acornscsi_target(host)); in acornscsi_message()
1525 acornscsi_dumplog(host, host->SCpnt->target); in acornscsi_message()
1527 host->scsi.phase = PHASE_DONE; in acornscsi_message()
1528 host->scsi.SCp.Message = message[0]; in acornscsi_message()
1538 acornscsi_dma_cleanup(host); in acornscsi_message()
1539 host->SCpnt->SCp = host->scsi.SCp; in acornscsi_message()
1540 host->SCpnt->SCp.sent_command = 0; in acornscsi_message()
1541 host->scsi.phase = PHASE_MSGIN; in acornscsi_message()
1554 acornscsi_dma_cleanup(host); in acornscsi_message()
1555 host->scsi.SCp = host->SCpnt->SCp; in acornscsi_message()
1556 host->scsi.phase = PHASE_MSGIN; in acornscsi_message()
1569 acornscsi_dma_cleanup(host); in acornscsi_message()
1570 host->scsi.phase = PHASE_DISCONNECT; in acornscsi_message()
1581 if (host->device[host->SCpnt->target].sync_state == SYNC_SENT_REQUEST) in acornscsi_message()
1582 host->device[host->SCpnt->target].sync_state = SYNC_NEGOCIATE; in acornscsi_message()
1588 if (msgqueue_msglength(&host->scsi.msgs)) in acornscsi_message()
1589 acornscsi_sbic_issuecmd(host, CMND_ASSERTATN); in acornscsi_message()
1591 switch (host->scsi.last_message) { in acornscsi_message()
1603 host->host->host_no, acornscsi_target(host)); in acornscsi_message()
1604 host->SCpnt->device->tagged_queue = 0; in acornscsi_message()
1605 set_bit(host->SCpnt->target * 8 + host->SCpnt->lun, &host->busyluns); in acornscsi_message()
1613 host->host->host_no, acornscsi_target(host)); in acornscsi_message()
1614 host->device[host->SCpnt->target].sync_xfer = SYNCHTRANSFER_2DBA; in acornscsi_message()
1615 host->device[host->SCpnt->target].sync_state = SYNC_ASYNCHRONOUS; in acornscsi_message()
1616 sbic_arm_write(host->scsi.io_port, SYNCHTRANSFER, host->device[host->SCpnt->target].sync_xfer); in acornscsi_message()
1631 host->host->host_no, acornscsi_target(host), in acornscsi_message()
1639 if (host->device[host->SCpnt->target].sync_state == SYNC_SENT_REQUEST) { in acornscsi_message()
1646 host->device[host->SCpnt->target].sync_state = SYNC_COMPLETED; in acornscsi_message()
1648 host->host->host_no, acornscsi_target(host), in acornscsi_message()
1650 host->device[host->SCpnt->target].sync_xfer = in acornscsi_message()
1658 acornscsi_sbic_issuecmd(host, CMND_ASSERTATN); in acornscsi_message()
1661 msgqueue_addmsg(&host->scsi.msgs, 5, EXTENDED_MESSAGE, 3, in acornscsi_message()
1663 host->device[host->SCpnt->target].sync_xfer = in acornscsi_message()
1666 sbic_arm_write(host->scsi.io_port, SYNCHTRANSFER, host->device[host->SCpnt->target].sync_xfer); in acornscsi_message()
1679 acornscsi_sbic_issuecmd(host, CMND_ASSERTATN); in acornscsi_message()
1680 msgqueue_flush(&host->scsi.msgs); in acornscsi_message()
1681 msgqueue_addmsg(&host->scsi.msgs, 1, MESSAGE_REJECT); in acornscsi_message()
1695 host->host->host_no, acornscsi_target(host), host->SCpnt->tag); in acornscsi_message()
1701 if (!host->SCpnt->next_link) { in acornscsi_message()
1703 instance->host_no, acornscsi_target(host), host->SCpnt->tag); in acornscsi_message()
1704 acornscsi_sbic_issuecmd(host, CMND_ASSERTATN); in acornscsi_message()
1705 msgqueue_addmsg(&host->scsi.msgs, 1, ABORT); in acornscsi_message()
1707 Scsi_Cmnd *SCpnt = host->SCpnt; in acornscsi_message()
1709 acornscsi_dma_cleanup(host); in acornscsi_message()
1711 host->SCpnt = host->SCpnt->next_link; in acornscsi_message()
1712 host->SCpnt->tag = SCpnt->tag; in acornscsi_message()
1713 SCpnt->result = DID_OK | host->scsi.SCp.Message << 8 | host->Scsi.SCp.Status; in acornscsi_message()
1724 host->host->host_no, acornscsi_target(host), in acornscsi_message()
1726 acornscsi_sbic_issuecmd(host, CMND_ASSERTATN); in acornscsi_message()
1727 msgqueue_flush(&host->scsi.msgs); in acornscsi_message()
1728 msgqueue_addmsg(&host->scsi.msgs, 1, MESSAGE_REJECT); in acornscsi_message()
1729 host->scsi.phase = PHASE_MSGIN; in acornscsi_message()
1732 acornscsi_sbic_issuecmd(host, CMND_NEGATEACK); in acornscsi_message()
1741 void acornscsi_buildmessages(AS_Host *host) in acornscsi_buildmessages() argument
1746 msgqueue_addmsg(&host->scsi.msgs, 1, BUS_DEVICE_RESET); in acornscsi_buildmessages()
1751 msgqueue_addmsg(&host->scsi.msgs, 1, in acornscsi_buildmessages()
1752 IDENTIFY(host->device[host->SCpnt->target].disconnect_ok, in acornscsi_buildmessages()
1753 host->SCpnt->lun)); in acornscsi_buildmessages()
1758 acornscsi_abortcmd(host->SCpnt->tag); in acornscsi_buildmessages()
1764 if (host->SCpnt->tag) { in acornscsi_buildmessages()
1767 if (host->SCpnt->cmnd[0] == REQUEST_SENSE || in acornscsi_buildmessages()
1768 host->SCpnt->cmnd[0] == TEST_UNIT_READY || in acornscsi_buildmessages()
1769 host->SCpnt->cmnd[0] == INQUIRY) in acornscsi_buildmessages()
1773 msgqueue_addmsg(&host->scsi.msgs, 2, tag_type, host->SCpnt->tag); in acornscsi_buildmessages()
1778 if (host->device[host->SCpnt->target].sync_state == SYNC_NEGOCIATE) { in acornscsi_buildmessages()
1779 host->device[host->SCpnt->target].sync_state = SYNC_SENT_REQUEST; in acornscsi_buildmessages()
1780 msgqueue_addmsg(&host->scsi.msgs, 5, in acornscsi_buildmessages()
1794 int acornscsi_starttransfer(AS_Host *host) in acornscsi_starttransfer() argument
1798 if (!host->scsi.SCp.ptr /*&& host->scsi.SCp.this_residual*/) { in acornscsi_starttransfer()
1800 host->host->host_no, acornscsi_target(host)); in acornscsi_starttransfer()
1804 residual = host->SCpnt->request_bufflen - host->scsi.SCp.scsi_xferred; in acornscsi_starttransfer()
1806 sbic_arm_write(host->scsi.io_port, SYNCHTRANSFER, host->device[host->SCpnt->target].sync_xfer); in acornscsi_starttransfer()
1807 sbic_arm_writenext(host->scsi.io_port, residual >> 16); in acornscsi_starttransfer()
1808 sbic_arm_writenext(host->scsi.io_port, residual >> 8); in acornscsi_starttransfer()
1809 sbic_arm_writenext(host->scsi.io_port, residual); in acornscsi_starttransfer()
1810 acornscsi_sbic_issuecmd(host, CMND_XFERINFO); in acornscsi_starttransfer()
1826 int acornscsi_reconnect(AS_Host *host) in acornscsi_reconnect() argument
1830 target = sbic_arm_read(host->scsi.io_port, SOURCEID); in acornscsi_reconnect()
1835 host->host->host_no); in acornscsi_reconnect()
1839 if (host->SCpnt && !host->scsi.disconnectable) { in acornscsi_reconnect()
1842 host->host->host_no, target, host->SCpnt->target); in acornscsi_reconnect()
1843 host->SCpnt = NULL; in acornscsi_reconnect()
1846 lun = sbic_arm_read(host->scsi.io_port, DATA) & 7; in acornscsi_reconnect()
1848 host->scsi.reconnected.target = target; in acornscsi_reconnect()
1849 host->scsi.reconnected.lun = lun; in acornscsi_reconnect()
1850 host->scsi.reconnected.tag = 0; in acornscsi_reconnect()
1852 if (host->scsi.disconnectable && host->SCpnt && in acornscsi_reconnect()
1853 host->SCpnt->target == target && host->SCpnt->lun == lun) in acornscsi_reconnect()
1856 if (!ok && queue_probetgtlun(&host->queues.disconnected, target, lun)) in acornscsi_reconnect()
1859 ADD_STATUS(target, 0x81, host->scsi.phase, 0); in acornscsi_reconnect()
1862 host->scsi.phase = PHASE_RECONNECTED; in acornscsi_reconnect()
1867 host->host->host_no, '0' + target); in acornscsi_reconnect()
1868 acornscsi_dumplog(host, target); in acornscsi_reconnect()
1869 acornscsi_abortcmd(host, 0); in acornscsi_reconnect()
1870 if (host->SCpnt) { in acornscsi_reconnect()
1871 queue_add_cmd_tail(&host->queues.disconnected, host->SCpnt); in acornscsi_reconnect()
1872 host->SCpnt = NULL; in acornscsi_reconnect()
1875 acornscsi_sbic_issuecmd(host, CMND_NEGATEACK); in acornscsi_reconnect()
1886 int acornscsi_reconnect_finish(AS_Host *host) in acornscsi_reconnect_finish() argument
1888 if (host->scsi.disconnectable && host->SCpnt) { in acornscsi_reconnect_finish()
1889 host->scsi.disconnectable = 0; in acornscsi_reconnect_finish()
1890 if (host->SCpnt->target == host->scsi.reconnected.target && in acornscsi_reconnect_finish()
1891 host->SCpnt->lun == host->scsi.reconnected.lun && in acornscsi_reconnect_finish()
1892 host->SCpnt->tag == host->scsi.reconnected.tag) { in acornscsi_reconnect_finish()
1894 DBG(host->SCpnt, printk("scsi%d.%c: reconnected", in acornscsi_reconnect_finish()
1895 host->host->host_no, acornscsi_target(host))); in acornscsi_reconnect_finish()
1898 queue_add_cmd_tail(&host->queues.disconnected, host->SCpnt); in acornscsi_reconnect_finish()
1900 DBG(host->SCpnt, printk("scsi%d.%c: had to move command " in acornscsi_reconnect_finish()
1902 host->host->host_no, acornscsi_target(host))); in acornscsi_reconnect_finish()
1904 host->SCpnt = NULL; in acornscsi_reconnect_finish()
1907 if (!host->SCpnt) { in acornscsi_reconnect_finish()
1908 host->SCpnt = queue_remove_tgtluntag(&host->queues.disconnected, in acornscsi_reconnect_finish()
1909 host->scsi.reconnected.target, in acornscsi_reconnect_finish()
1910 host->scsi.reconnected.lun, in acornscsi_reconnect_finish()
1911 host->scsi.reconnected.tag); in acornscsi_reconnect_finish()
1913 DBG(host->SCpnt, printk("scsi%d.%c: had to get command", in acornscsi_reconnect_finish()
1914 host->host->host_no, acornscsi_target(host))); in acornscsi_reconnect_finish()
1918 if (!host->SCpnt) in acornscsi_reconnect_finish()
1919 acornscsi_abortcmd(host, host->scsi.reconnected.tag); in acornscsi_reconnect_finish()
1924 host->scsi.SCp = host->SCpnt->SCp; in acornscsi_reconnect_finish()
1927 host->scsi.SCp.ptr, host->scsi.SCp.this_residual); in acornscsi_reconnect_finish()
1934 host->dma.transferred = host->scsi.SCp.scsi_xferred; in acornscsi_reconnect_finish()
1936 return host->SCpnt != NULL; in acornscsi_reconnect_finish()
1945 void acornscsi_disconnect_unexpected(AS_Host *host) in acornscsi_disconnect_unexpected() argument
1948 host->host->host_no, acornscsi_target(host)); in acornscsi_disconnect_unexpected()
1950 acornscsi_dumplog(host, 8); in acornscsi_disconnect_unexpected()
1953 acornscsi_done(host, &host->SCpnt, DID_ERROR); in acornscsi_disconnect_unexpected()
1963 void acornscsi_abortcmd(AS_Host *host, unsigned char tag) in acornscsi_abortcmd() argument
1965 host->scsi.phase = PHASE_ABORTED; in acornscsi_abortcmd()
1966 sbic_arm_write(host->scsi.io_port, CMND, CMND_ASSERTATN); in acornscsi_abortcmd()
1968 msgqueue_flush(&host->scsi.msgs); in acornscsi_abortcmd()
1971 msgqueue_addmsg(&host->scsi.msgs, 2, ABORT_TAG, tag); in acornscsi_abortcmd()
1974 msgqueue_addmsg(&host->scsi.msgs, 1, ABORT); in acornscsi_abortcmd()
1989 intr_ret_t acornscsi_sbicintr(AS_Host *host, int in_irq) in acornscsi_sbicintr() argument
1993 asr = sbic_arm_read(host->scsi.io_port, ASR); in acornscsi_sbicintr()
1997 ssr = sbic_arm_read(host->scsi.io_port, SSR); in acornscsi_sbicintr()
2000 print_sbic_status(asr, ssr, host->scsi.phase); in acornscsi_sbicintr()
2003 ADD_STATUS(8, ssr, host->scsi.phase, in_irq); in acornscsi_sbicintr()
2005 if (host->SCpnt && !host->scsi.disconnectable) in acornscsi_sbicintr()
2006 ADD_STATUS(host->SCpnt->target, ssr, host->scsi.phase, in_irq); in acornscsi_sbicintr()
2011 host->host->host_no); in acornscsi_sbicintr()
2013 sbic_arm_write(host->scsi.io_port, OWNID, OWNID_EAF | host->host->this_id); in acornscsi_sbicintr()
2014 sbic_arm_write(host->scsi.io_port, CMND, CMND_RESET); in acornscsi_sbicintr()
2018 sbic_arm_write(host->scsi.io_port, CTRL, INIT_SBICDMA | CTRL_IDI); in acornscsi_sbicintr()
2019 sbic_arm_write(host->scsi.io_port, TIMEOUT, TIMEOUT_TIME); in acornscsi_sbicintr()
2020 sbic_arm_write(host->scsi.io_port, SYNCHTRANSFER, SYNCHTRANSFER_2DBA); in acornscsi_sbicintr()
2021 sbic_arm_write(host->scsi.io_port, SOURCEID, SOURCEID_ER | SOURCEID_DSP); in acornscsi_sbicintr()
2022 msgqueue_flush(&host->scsi.msgs); in acornscsi_sbicintr()
2026 acornscsi_disconnect_unexpected(host); in acornscsi_sbicintr()
2030 switch (host->scsi.phase) { in acornscsi_sbicintr()
2035 host->scsi.phase = PHASE_CONNECTED; in acornscsi_sbicintr()
2036 msgqueue_flush(&host->scsi.msgs); in acornscsi_sbicintr()
2037 host->dma.transferred = host->scsi.SCp.scsi_xferred; in acornscsi_sbicintr()
2039 asr = sbic_arm_read(host->scsi.io_port, ASR); in acornscsi_sbicintr()
2042 ssr = sbic_arm_read(host->scsi.io_port, SSR); in acornscsi_sbicintr()
2043 ADD_STATUS(8, ssr, host->scsi.phase, 1); in acornscsi_sbicintr()
2044 ADD_STATUS(host->SCpnt->target, ssr, host->scsi.phase, 1); in acornscsi_sbicintr()
2049 acornscsi_done(host, &host->SCpnt, DID_NO_CONNECT); in acornscsi_sbicintr()
2054 host->origSCpnt = host->SCpnt; in acornscsi_sbicintr()
2055 host->SCpnt = NULL; in acornscsi_sbicintr()
2056 msgqueue_flush(&host->scsi.msgs); in acornscsi_sbicintr()
2057 acornscsi_reconnect(host); in acornscsi_sbicintr()
2062 host->host->host_no, acornscsi_target(host), ssr); in acornscsi_sbicintr()
2063 acornscsi_dumplog(host, host->SCpnt ? host->SCpnt->target : 8); in acornscsi_sbicintr()
2064 acornscsi_abortcmd(host, host->SCpnt->tag); in acornscsi_sbicintr()
2074 acornscsi_sendcommand(host); in acornscsi_sbicintr()
2079 acornscsi_readstatusbyte(host); in acornscsi_sbicintr()
2080 host->scsi.phase = PHASE_STATUSIN; in acornscsi_sbicintr()
2086 host->scsi.phase = PHASE_MSGOUT; in acornscsi_sbicintr()
2087 acornscsi_buildmessages(host); in acornscsi_sbicintr()
2088 acornscsi_sendmessage(host); in acornscsi_sbicintr()
2093 acornscsi_done(host, &host->SCpnt, DID_ERROR); in acornscsi_sbicintr()
2098 host->host->host_no, acornscsi_target(host), ssr); in acornscsi_sbicintr()
2099 acornscsi_dumplog(host, host->SCpnt ? host->SCpnt->target : 8); in acornscsi_sbicintr()
2100 acornscsi_abortcmd(host, host->SCpnt->tag); in acornscsi_sbicintr()
2113 acornscsi_sendcommand(host); in acornscsi_sbicintr()
2119 acornscsi_readstatusbyte(host); in acornscsi_sbicintr()
2120 host->scsi.phase = PHASE_STATUSIN; in acornscsi_sbicintr()
2125 acornscsi_sendmessage(host); in acornscsi_sbicintr()
2131 acornscsi_message(host); in acornscsi_sbicintr()
2136 host->host->host_no, acornscsi_target(host), ssr); in acornscsi_sbicintr()
2137 acornscsi_dumplog(host, host->SCpnt ? host->SCpnt->target : 8); in acornscsi_sbicintr()
2145 if (host->scsi.SCp.sent_command != host->SCpnt->cmd_len) in acornscsi_sbicintr()
2146 acornscsi_abortcmd(host, host->SCpnt->tag); in acornscsi_sbicintr()
2147 acornscsi_dma_setup(host, DMA_OUT); in acornscsi_sbicintr()
2148 if (!acornscsi_starttransfer(host)) in acornscsi_sbicintr()
2149 acornscsi_abortcmd(host, host->SCpnt->tag); in acornscsi_sbicintr()
2150 host->scsi.phase = PHASE_DATAOUT; in acornscsi_sbicintr()
2155 if (host->scsi.SCp.sent_command != host->SCpnt->cmd_len) in acornscsi_sbicintr()
2156 acornscsi_abortcmd(host, host->SCpnt->tag); in acornscsi_sbicintr()
2157 acornscsi_dma_setup(host, DMA_IN); in acornscsi_sbicintr()
2158 if (!acornscsi_starttransfer(host)) in acornscsi_sbicintr()
2159 acornscsi_abortcmd(host, host->SCpnt->tag); in acornscsi_sbicintr()
2160 host->scsi.phase = PHASE_DATAIN; in acornscsi_sbicintr()
2165 acornscsi_readstatusbyte(host); in acornscsi_sbicintr()
2166 host->scsi.phase = PHASE_STATUSIN; in acornscsi_sbicintr()
2171 acornscsi_sendmessage(host); in acornscsi_sbicintr()
2176 acornscsi_message(host); in acornscsi_sbicintr()
2181 host->host->host_no, acornscsi_target(host), ssr); in acornscsi_sbicintr()
2182 acornscsi_dumplog(host, host->SCpnt ? host->SCpnt->target : 8); in acornscsi_sbicintr()
2188 host->scsi.disconnectable = 1; in acornscsi_sbicintr()
2189 host->scsi.reconnected.tag = 0; in acornscsi_sbicintr()
2190 host->scsi.phase = PHASE_IDLE; in acornscsi_sbicintr()
2191 host->stats.disconnects += 1; in acornscsi_sbicintr()
2194 host->host->host_no, acornscsi_target(host), ssr); in acornscsi_sbicintr()
2195 acornscsi_dumplog(host, host->SCpnt ? host->SCpnt->target : 8); in acornscsi_sbicintr()
2201 acornscsi_reconnect(host); in acornscsi_sbicintr()
2204 host->host->host_no, acornscsi_target(host), ssr); in acornscsi_sbicintr()
2205 acornscsi_dumplog(host, host->SCpnt ? host->SCpnt->target : 8); in acornscsi_sbicintr()
2218 if (ssr != 0x8f && !acornscsi_reconnect_finish(host)) in acornscsi_sbicintr()
2220 ADD_STATUS(host->SCpnt->target, ssr, host->scsi.phase, in_irq); in acornscsi_sbicintr()
2225 acornscsi_dma_setup(host, DMA_OUT); in acornscsi_sbicintr()
2226 if (!acornscsi_starttransfer(host)) in acornscsi_sbicintr()
2227 acornscsi_abortcmd(host, host->SCpnt->tag); in acornscsi_sbicintr()
2228 host->scsi.phase = PHASE_DATAOUT; in acornscsi_sbicintr()
2234 acornscsi_dma_setup(host, DMA_IN); in acornscsi_sbicintr()
2235 if (!acornscsi_starttransfer(host)) in acornscsi_sbicintr()
2236 acornscsi_abortcmd(host, host->SCpnt->tag); in acornscsi_sbicintr()
2237 host->scsi.phase = PHASE_DATAIN; in acornscsi_sbicintr()
2242 acornscsi_sendcommand(host);/* -> PHASE_COMMAND, PHASE_COMMANDPAUSED */ in acornscsi_sbicintr()
2248 acornscsi_readstatusbyte(host); in acornscsi_sbicintr()
2249 host->scsi.phase = PHASE_STATUSIN; in acornscsi_sbicintr()
2255 acornscsi_sendmessage(host); in acornscsi_sbicintr()
2259 acornscsi_message(host); /* -> PHASE_MSGIN, PHASE_DISCONNECT */ in acornscsi_sbicintr()
2264 host->host->host_no, acornscsi_target(host), ssr); in acornscsi_sbicintr()
2265 acornscsi_dumplog(host, host->SCpnt ? host->SCpnt->target : 8); in acornscsi_sbicintr()
2277 acornscsi_abortcmd(host, host->SCpnt->tag); in acornscsi_sbicintr()
2284 host->scsi.SCp.scsi_xferred = host->SCpnt->request_bufflen - in acornscsi_sbicintr()
2285 acornscsi_sbic_xfcount(host); in acornscsi_sbicintr()
2286 acornscsi_dma_stop(host); in acornscsi_sbicintr()
2287 acornscsi_readstatusbyte(host); in acornscsi_sbicintr()
2288 host->scsi.phase = PHASE_STATUSIN; in acornscsi_sbicintr()
2295 host->scsi.SCp.scsi_xferred = host->SCpnt->request_bufflen - in acornscsi_sbicintr()
2296 acornscsi_sbic_xfcount(host); in acornscsi_sbicintr()
2297 acornscsi_dma_stop(host); in acornscsi_sbicintr()
2298 acornscsi_sendmessage(host); in acornscsi_sbicintr()
2305 host->scsi.SCp.scsi_xferred = host->SCpnt->request_bufflen - in acornscsi_sbicintr()
2306 acornscsi_sbic_xfcount(host); in acornscsi_sbicintr()
2307 acornscsi_dma_stop(host); in acornscsi_sbicintr()
2308 acornscsi_message(host); /* -> PHASE_MSGIN, PHASE_DISCONNECT */ in acornscsi_sbicintr()
2313 host->host->host_no, acornscsi_target(host), ssr); in acornscsi_sbicintr()
2314 acornscsi_dumplog(host, host->SCpnt ? host->SCpnt->target : 8); in acornscsi_sbicintr()
2326 acornscsi_abortcmd(host, host->SCpnt->tag); in acornscsi_sbicintr()
2333 host->scsi.SCp.scsi_xferred = host->SCpnt->request_bufflen - in acornscsi_sbicintr()
2334 acornscsi_sbic_xfcount(host); in acornscsi_sbicintr()
2335 acornscsi_dma_stop(host); in acornscsi_sbicintr()
2336 acornscsi_dma_adjust(host); in acornscsi_sbicintr()
2337 acornscsi_readstatusbyte(host); in acornscsi_sbicintr()
2338 host->scsi.phase = PHASE_STATUSIN; in acornscsi_sbicintr()
2345 host->scsi.SCp.scsi_xferred = host->SCpnt->request_bufflen - in acornscsi_sbicintr()
2346 acornscsi_sbic_xfcount(host); in acornscsi_sbicintr()
2347 acornscsi_dma_stop(host); in acornscsi_sbicintr()
2348 acornscsi_dma_adjust(host); in acornscsi_sbicintr()
2349 acornscsi_sendmessage(host); in acornscsi_sbicintr()
2356 host->scsi.SCp.scsi_xferred = host->SCpnt->request_bufflen - in acornscsi_sbicintr()
2357 acornscsi_sbic_xfcount(host); in acornscsi_sbicintr()
2358 acornscsi_dma_stop(host); in acornscsi_sbicintr()
2359 acornscsi_dma_adjust(host); in acornscsi_sbicintr()
2360 acornscsi_message(host); /* -> PHASE_MSGIN, PHASE_DISCONNECT */ in acornscsi_sbicintr()
2365 host->host->host_no, acornscsi_target(host), ssr); in acornscsi_sbicintr()
2366 acornscsi_dumplog(host, host->SCpnt ? host->SCpnt->target : 8); in acornscsi_sbicintr()
2375 acornscsi_message(host); in acornscsi_sbicintr()
2381 acornscsi_sendmessage(host); in acornscsi_sbicintr()
2386 host->host->host_no, acornscsi_target(host), ssr); in acornscsi_sbicintr()
2387 acornscsi_dumplog(host, host->SCpnt ? host->SCpnt->target : 8); in acornscsi_sbicintr()
2397 acornscsi_sendmessage(host); in acornscsi_sbicintr()
2404 acornscsi_message(host); in acornscsi_sbicintr()
2409 host->host->host_no, acornscsi_target(host)); in acornscsi_sbicintr()
2410 acornscsi_dumplog(host, host->SCpnt ? host->SCpnt->target : 8); in acornscsi_sbicintr()
2411 acornscsi_done(host, &host->SCpnt, DID_ERROR); in acornscsi_sbicintr()
2416 host->host->host_no, acornscsi_target(host), ssr); in acornscsi_sbicintr()
2417 acornscsi_dumplog(host, host->SCpnt ? host->SCpnt->target : 8); in acornscsi_sbicintr()
2424 acornscsi_done(host, &host->SCpnt, DID_OK); in acornscsi_sbicintr()
2429 acornscsi_sendmessage(host); in acornscsi_sbicintr()
2434 host->host->host_no, acornscsi_target(host), ssr); in acornscsi_sbicintr()
2435 acornscsi_dumplog(host, host->SCpnt ? host->SCpnt->target : 8); in acornscsi_sbicintr()
2442 if (host->SCpnt) in acornscsi_sbicintr()
2443 acornscsi_done(host, &host->SCpnt, DID_ABORT); in acornscsi_sbicintr()
2445 clear_bit(host->scsi.reconnected.target * 8 + host->scsi.reconnected.lun, in acornscsi_sbicintr()
2446 host->busyluns); in acornscsi_sbicintr()
2447 host->scsi.phase = PHASE_IDLE; in acornscsi_sbicintr()
2455 acornscsi_sendmessage(host); in acornscsi_sbicintr()
2460 host->host->host_no, acornscsi_target(host), ssr); in acornscsi_sbicintr()
2461 acornscsi_dumplog(host, host->SCpnt ? host->SCpnt->target : 8); in acornscsi_sbicintr()
2467 host->host->host_no, acornscsi_target(host), ssr); in acornscsi_sbicintr()
2468 acornscsi_dumplog(host, host->SCpnt ? host->SCpnt->target : 8); in acornscsi_sbicintr()
2483 AS_Host *host = (AS_Host *)dev_id; in acornscsi_intr() local
2488 if (host->scsi.interrupt) in acornscsi_intr()
2489 printk("scsi%d: interrupt re-entered\n", host->host->host_no); in acornscsi_intr()
2490 host->scsi.interrupt = 1; in acornscsi_intr()
2495 iostatus = inb(host->card.io_intr); in acornscsi_intr()
2498 acornscsi_dma_intr(host); in acornscsi_intr()
2499 iostatus = inb(host->card.io_intr); in acornscsi_intr()
2503 ret = acornscsi_sbicintr(host, in_irq); in acornscsi_intr()
2510 if (host->dma.xfer_required) in acornscsi_intr()
2511 acornscsi_dma_xfer(host); in acornscsi_intr()
2514 ret = acornscsi_kick(host); in acornscsi_intr()
2519 host->scsi.interrupt = 0; in acornscsi_intr()
2535 AS_Host *host = (AS_Host *)SCpnt->host->hostdata; in acornscsi_queuecmd() local
2540 SCpnt->host->host_no, SCpnt); in acornscsi_queuecmd()
2547 SCpnt->host->host_no, '0' + SCpnt->target); in acornscsi_queuecmd()
2576 host->stats.queues += 1; in acornscsi_queuecmd()
2581 if (!queue_add_cmd_ordered(&host->queues.issue, SCpnt)) { in acornscsi_queuecmd()
2587 if (host->scsi.phase == PHASE_IDLE) in acornscsi_queuecmd()
2588 acornscsi_kick(host); in acornscsi_queuecmd()
2627 acornscsi_do_abort(AS_Host *host, Scsi_Cmnd *SCpnt) in acornscsi_do_abort() argument
2631 if (queue_remove_cmd(&host->queues.issue, SCpnt)) { in acornscsi_do_abort()
2642 } else if (queue_remove_cmd(&host->queues.disconnected, SCpnt)) { in acornscsi_do_abort()
2654 } else if (host->SCpnt == SCpnt) { in acornscsi_do_abort()
2663 switch (host->scsi.phase) { in acornscsi_do_abort()
2673 if (host->scsi.disconnectable) { in acornscsi_do_abort()
2674 host->scsi.disconnectable = 0; in acornscsi_do_abort()
2675 host->SCpnt = NULL; in acornscsi_do_abort()
2686 sbic_arm_write(host->scsi.io_port, CMND, CMND_DISCONNECT); in acornscsi_do_abort()
2687 host->SCpnt = NULL; in acornscsi_do_abort()
2692 acornscsi_abortcmd(host, host->SCpnt->tag); in acornscsi_do_abort()
2696 } else if (host->origSCpnt == SCpnt) { in acornscsi_do_abort()
2703 host->origSCpnt = NULL; in acornscsi_do_abort()
2722 AS_Host *host = (AS_Host *) SCpnt->host->hostdata; in acornscsi_abort() local
2725 host->stats.aborts += 1; in acornscsi_abort()
2730 asr = sbic_arm_read(host->scsi.io_port, ASR); in acornscsi_abort()
2731 ssr = sbic_arm_read(host->scsi.io_port, SSR); in acornscsi_abort()
2734 print_sbic_status(asr, ssr, host->scsi.phase); in acornscsi_abort()
2735 acornscsi_dumplog(host, SCpnt->target); in acornscsi_abort()
2739 printk("scsi%d: ", host->host->host_no); in acornscsi_abort()
2741 switch (acornscsi_do_abort(host, SCpnt)) { in acornscsi_abort()
2751 clear_bit(SCpnt->target * 8 + SCpnt->lun, host->busyluns); in acornscsi_abort()
2785 acornscsi_dumplog(host, SCpnt->target); in acornscsi_abort()
2809 AS_Host *host = (AS_Host *)SCpnt->host->hostdata; in acornscsi_reset() local
2812 host->stats.resets += 1; in acornscsi_reset()
2818 asr = sbic_arm_read(host->scsi.io_port, ASR); in acornscsi_reset()
2819 ssr = sbic_arm_read(host->scsi.io_port, SSR); in acornscsi_reset()
2822 print_sbic_status(asr, ssr, host->scsi.phase); in acornscsi_reset()
2823 acornscsi_dumplog(host, SCpnt->target); in acornscsi_reset()
2827 acornscsi_dma_stop(host); in acornscsi_reset()
2829 SCptr = host->SCpnt; in acornscsi_reset()
2835 acornscsi_resetcard(host); in acornscsi_reset()
2840 acornscsi_reportstatus(&host->SCpnt, &SCptr, DID_RESET); in acornscsi_reset()
2842 while ((SCptr = queue_remove(&host->queues.disconnected)) != NULL) in acornscsi_reset()
2864 void acornscsi_host_init(AS_Host *host) in acornscsi_host_init() argument
2866 memset(&host->stats, 0, sizeof (host->stats)); in acornscsi_host_init()
2867 queue_initialise(&host->queues.issue); in acornscsi_host_init()
2868 queue_initialise(&host->queues.disconnected); in acornscsi_host_init()
2869 msgqueue_initialise(&host->scsi.msgs); in acornscsi_host_init()
2871 acornscsi_resetcard(host); in acornscsi_host_init()
2879 AS_Host *host; in acornscsi_detect() local
2901 host = (AS_Host *)instance->hostdata; in acornscsi_detect()
2906 host->host = instance; in acornscsi_detect()
2907 host->scsi.io_port = ioaddr(instance->io_port + 0x800); in acornscsi_detect()
2908 host->scsi.irq = instance->irq; in acornscsi_detect()
2909 host->card.io_intr = POD_SPACE(instance->io_port) + 0x800; in acornscsi_detect()
2910 host->card.io_page = POD_SPACE(instance->io_port) + 0xc00; in acornscsi_detect()
2911 host->card.io_ram = ioaddr(instance->io_port); in acornscsi_detect()
2912 host->dma.io_port = instance->io_port + 0xc00; in acornscsi_detect()
2913 host->dma.io_intr_clear = POD_SPACE(instance->io_port) + 0x800; in acornscsi_detect()
2915 ecs[count]->irqaddr = (char *)ioaddr(host->card.io_intr); in acornscsi_detect()
2920 if (!request_region(host->card.io_intr, 1, "acornscsi(intr)")) in acornscsi_detect()
2922 if (!request_region(host->card.io_page, 1, "acornscsi(page)")) in acornscsi_detect()
2925 if (!request_region(host->dma.io_port, 256, "acornscsi(dmac)")) in acornscsi_detect()
2931 if (request_irq(host->scsi.irq, acornscsi_intr, SA_INTERRUPT, "acornscsi", host)) { in acornscsi_detect()
2933 instance->host_no, host->scsi.irq); in acornscsi_detect()
2934 host->scsi.irq = NO_IRQ; in acornscsi_detect()
2937 acornscsi_host_init(host); in acornscsi_detect()
2945 release_region(host->dma.io_port, 256); in acornscsi_detect()
2948 release_region(host->card.io_page, 1); in acornscsi_detect()
2950 release_region(host->card.io_intr, 1); in acornscsi_detect()
2966 AS_Host *host = (AS_Host *)instance->hostdata; in acornscsi_release() local
2972 outb(0x80, host->card.io_page); in acornscsi_release()
2974 if (host->scsi.irq != NO_IRQ) in acornscsi_release()
2975 free_irq(host->scsi.irq, host); in acornscsi_release()
2978 release_region(host->card.io_intr, 1); in acornscsi_release()
2979 release_region(host->card.io_page, 1); in acornscsi_release()
2980 release_region(host->dma.io_port, 256); in acornscsi_release()
2987 msgqueue_free(&host->scsi.msgs); in acornscsi_release()
2988 queue_free(&host->queues.disconnected); in acornscsi_release()
2989 queue_free(&host->queues.issue); in acornscsi_release()
3001 char *acornscsi_info(struct Scsi_Host *host) in acornscsi_info() argument
3020 , host->hostt->name, host->io_port, host->irq, in acornscsi_info()
3031 AS_Host *host; in acornscsi_proc_info() local
3041 host = (AS_Host *)instance->hostdata; in acornscsi_proc_info()
3059 host->scsi.io_port, host->scsi.irq); in acornscsi_proc_info()
3062 host->dma.io_port, host->scsi.irq); in acornscsi_proc_info()
3071 host->stats.queues, host->stats.removes, in acornscsi_proc_info()
3072 host->stats.fins, host->stats.reads, in acornscsi_proc_info()
3073 host->stats.writes, host->stats.miscs, in acornscsi_proc_info()
3074 host->stats.disconnects, host->stats.aborts, in acornscsi_proc_info()
3075 host->stats.resets); in acornscsi_proc_info()
3081 statptr = host->status_ptr[devidx] - 10; in acornscsi_proc_info()
3086 prev = host->status[devidx][statptr].when; in acornscsi_proc_info()
3088 for (; statptr != host->status_ptr[devidx]; statptr = (statptr + 1) & (STATUS_BUFFER_SIZE - 1)) { in acornscsi_proc_info()
3089 if (host->status[devidx][statptr].when) { in acornscsi_proc_info()
3091 host->status[devidx][statptr].irq ? '-' : ' ', in acornscsi_proc_info()
3092 host->status[devidx][statptr].ph, in acornscsi_proc_info()
3093 host->status[devidx][statptr].ssr, in acornscsi_proc_info()
3094 (host->status[devidx][statptr].when - prev) < 100 ? in acornscsi_proc_info()
3095 (host->status[devidx][statptr].when - prev) : 99); in acornscsi_proc_info()
3096 prev = host->status[devidx][statptr].when; in acornscsi_proc_info()
3115 if (host->device[scd->id].sync_xfer & 15) in acornscsi_proc_info()
3117 host->device[scd->id].sync_xfer & 15, in acornscsi_proc_info()
3118 acornscsi_getperiod(host->device[scd->id].sync_xfer)); in acornscsi_proc_info()