Lines Matching refs:host

14  * This is the Linux low-level SCSI driver for Initio INI-9X00U/UW SCSI host
117 static struct scsi_ctrl_blk *initio_find_busy_scb(struct initio_host * host, u16 tarlun);
118 static struct scsi_ctrl_blk *initio_find_done_scb(struct initio_host * host);
120 static int tulip_main(struct initio_host * host);
122 static int initio_next_state(struct initio_host * host);
123 static int initio_state_1(struct initio_host * host);
124 static int initio_state_2(struct initio_host * host);
125 static int initio_state_3(struct initio_host * host);
126 static int initio_state_4(struct initio_host * host);
127 static int initio_state_5(struct initio_host * host);
128 static int initio_state_6(struct initio_host * host);
129 static int initio_state_7(struct initio_host * host);
130 static int initio_xfer_data_in(struct initio_host * host);
131 static int initio_xfer_data_out(struct initio_host * host);
132 static int initio_xpad_in(struct initio_host * host);
133 static int initio_xpad_out(struct initio_host * host);
134 static int initio_status_msg(struct initio_host * host);
136 static int initio_msgin(struct initio_host * host);
137 static int initio_msgin_sync(struct initio_host * host);
138 static int initio_msgin_accept(struct initio_host * host);
139 static int initio_msgout_reject(struct initio_host * host);
140 static int initio_msgin_extend(struct initio_host * host);
142 static int initio_msgout_ide(struct initio_host * host);
143 static int initio_msgout_abort_targ(struct initio_host * host);
144 static int initio_msgout_abort_tag(struct initio_host * host);
146 static int initio_bus_device_reset(struct initio_host * host);
147 static void initio_select_atn(struct initio_host * host, struct scsi_ctrl_blk * scb);
148 static void initio_select_atn3(struct initio_host * host, struct scsi_ctrl_blk * scb);
149 static void initio_select_atn_stop(struct initio_host * host, struct scsi_ctrl_blk * scb);
150 static int int_initio_busfree(struct initio_host * host);
151 static int int_initio_scsi_rst(struct initio_host * host);
152 static int int_initio_bad_seq(struct initio_host * host);
153 static int int_initio_resel(struct initio_host * host);
154 static int initio_sync_done(struct initio_host * host);
155 static int wdtr_done(struct initio_host * host);
156 static int wait_tulip(struct initio_host * host);
157 static int initio_wait_done_disc(struct initio_host * host);
158 static int initio_wait_disc(struct initio_host * host);
159 static void tulip_scsi(struct initio_host * host);
160 static int initio_post_scsi_rst(struct initio_host * host);
474 * Retrieve the host adapter configuration data from E2Prom. If the
502 * @host: InitIO we are stopping
507 static void initio_stop_bm(struct initio_host * host)
510 if (inb(host->addr + TUL_XStatus) & XPEND) { /* if DMA xfer is pending, abort DMA xfer */
511 outb(TAX_X_ABT | TAX_X_CLR_FIFO, host->addr + TUL_XCmd);
513 while ((inb(host->addr + TUL_Int) & XABT) == 0)
516 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0);
520 * initio_reset_scsi - Reset SCSI host controller
521 * @host: InitIO host to reset
527 static int initio_reset_scsi(struct initio_host * host, int seconds)
529 outb(TSC_RST_BUS, host->addr + TUL_SCtrl0);
531 while (!((host->jsint = inb(host->addr + TUL_SInt)) & TSS_SCSIRST_INT))
535 outb(0, host->addr + TUL_SSignal);
542 inb(host->addr + TUL_SInt);
547 * initio_init - set up an InitIO host adapter
548 * @host: InitIO host adapter
551 * Set up the host adapter and devices according to the configuration
558 static void initio_init(struct initio_host * host, u8 *bios_addr)
565 initio_read_eeprom(host->addr);
567 host->max_tar = 8;
569 host->max_tar = 16;
571 host->config = i91unvramp->NVM_SCSIInfo[0].NVM_ChConfig1;
573 host->scsi_id = i91unvramp->NVM_SCSIInfo[0].NVM_ChSCSIID;
574 host->idmask = ~(1 << host->scsi_id);
578 outb(inb(host->addr + TUL_PCMD) | 0x40, host->addr + TUL_PCMD);
582 outb(0x1F, host->addr + TUL_Mask);
584 initio_stop_bm(host);
586 outb(TSC_RST_CHIP, host->addr + TUL_SCtrl0);
589 outb(host->scsi_id << 4, host->addr + TUL_SScsiId);
593 if (host->config & HCC_EN_PAR)
594 host->sconf1 = (TSC_INITDEFAULT | TSC_EN_SCSI_PAR);
596 host->sconf1 = (TSC_INITDEFAULT);
597 outb(host->sconf1, host->addr + TUL_SConfig);
600 outb(TSC_HW_RESELECT, host->addr + TUL_SCtrl1);
602 outb(0, host->addr + TUL_SPeriod);
605 outb(153, host->addr + TUL_STimeOut);
608 outb((host->config & (HCC_ACT_TERM1 | HCC_ACT_TERM2)),
609 host->addr + TUL_XCtrl);
610 outb(((host->config & HCC_AUTO_TERM) >> 4) |
611 (inb(host->addr + TUL_GCTRL1) & 0xFE),
612 host->addr + TUL_GCTRL1);
617 i < host->max_tar;
619 host->targets[i].flags = *flags & ~(TCF_SYNC_DONE | TCF_WDTR_DONE);
620 if (host->targets[i].flags & TCF_EN_255)
621 host->targets[i].drv_flags = TCF_DRV_255_63;
623 host->targets[i].drv_flags = 0;
624 host->targets[i].js_period = 0;
625 host->targets[i].sconfig0 = host->sconf1;
626 host->targets[i].heads = *heads++;
627 if (host->targets[i].heads == 255)
628 host->targets[i].drv_flags = TCF_DRV_255_63;
630 host->targets[i].drv_flags = 0;
631 host->targets[i].sectors = *heads++;
632 host->targets[i].flags &= ~TCF_BUSY;
633 host->act_tags[i] = 0;
634 host->max_tags[i] = 0xFF;
637 host->addr, host->pci_dev->irq,
638 host->bios_addr, host->scsi_id);
640 if (host->config & HCC_SCSI_RESET) {
642 initio_reset_scsi(host, 10);
644 outb(0x17, host->addr + TUL_SCFG1);
645 outb(0xE9, host->addr + TUL_SIntEnable);
650 * @host: InitIO host we are allocating for
655 static struct scsi_ctrl_blk *initio_alloc_scb(struct initio_host *host)
660 spin_lock_irqsave(&host->avail_lock, flags);
661 if ((scb = host->first_avail) != NULL) {
665 if ((host->first_avail = scb->next) == NULL)
666 host->last_avail = NULL;
670 spin_unlock_irqrestore(&host->avail_lock, flags);
676 * @host: InitIO host that owns the SCB
679 * Return an allocated SCB to the host free list
682 static void initio_release_scb(struct initio_host * host, struct scsi_ctrl_blk * cmnd)
689 spin_lock_irqsave(&(host->avail_lock), flags);
693 if (host->last_avail != NULL) {
694 host->last_avail->next = cmnd;
695 host->last_avail = cmnd;
697 host->first_avail = cmnd;
698 host->last_avail = cmnd;
700 spin_unlock_irqrestore(&(host->avail_lock), flags);
704 static void initio_append_pend_scb(struct initio_host * host, struct scsi_ctrl_blk * scbp)
712 if (host->last_pending != NULL) {
713 host->last_pending->next = scbp;
714 host->last_pending = scbp;
716 host->first_pending = scbp;
717 host->last_pending = scbp;
722 static void initio_push_pend_scb(struct initio_host * host, struct scsi_ctrl_blk * scbp)
729 if ((scbp->next = host->first_pending) != NULL) {
730 host->first_pending = scbp;
732 host->first_pending = scbp;
733 host->last_pending = scbp;
737 static struct scsi_ctrl_blk *initio_find_first_pend_scb(struct initio_host * host)
742 first = host->first_pending;
747 if ((host->act_tags[first->target] == 0) &&
748 !(host->targets[first->target].flags & TCF_BUSY))
751 if ((host->act_tags[first->target] >=
752 host->max_tags[first->target]) |
753 (host->targets[first->target].flags & TCF_BUSY)) {
764 static void initio_unlink_pend_scb(struct initio_host * host, struct scsi_ctrl_blk * scb)
772 prev = tmp = host->first_pending;
775 if (tmp == host->first_pending) {
776 if ((host->first_pending = tmp->next) == NULL)
777 host->last_pending = NULL;
780 if (tmp == host->last_pending)
781 host->last_pending = prev;
791 static void initio_append_busy_scb(struct initio_host * host, struct scsi_ctrl_blk * scbp)
798 host->act_tags[scbp->target]++;
800 host->targets[scbp->target].flags |= TCF_BUSY;
803 if (host->last_busy != NULL) {
804 host->last_busy->next = scbp;
805 host->last_busy = scbp;
807 host->first_busy = scbp;
808 host->last_busy = scbp;
813 static struct scsi_ctrl_blk *initio_pop_busy_scb(struct initio_host * host)
818 if ((tmp = host->first_busy) != NULL) {
819 if ((host->first_busy = tmp->next) == NULL)
820 host->last_busy = NULL;
823 host->act_tags[tmp->target]--;
825 host->targets[tmp->target].flags &= ~TCF_BUSY;
834 static void initio_unlink_busy_scb(struct initio_host * host, struct scsi_ctrl_blk * scb)
842 prev = tmp = host->first_busy;
845 if (tmp == host->first_busy) {
846 if ((host->first_busy = tmp->next) == NULL)
847 host->last_busy = NULL;
850 if (tmp == host->last_busy)
851 host->last_busy = prev;
855 host->act_tags[tmp->target]--;
857 host->targets[tmp->target].flags &= ~TCF_BUSY;
866 struct scsi_ctrl_blk *initio_find_busy_scb(struct initio_host * host, u16 tarlun)
872 tmp = host->first_busy;
886 static void initio_append_done_scb(struct initio_host * host, struct scsi_ctrl_blk * scbp)
894 if (host->last_done != NULL) {
895 host->last_done->next = scbp;
896 host->last_done = scbp;
898 host->first_done = scbp;
899 host->last_done = scbp;
903 struct scsi_ctrl_blk *initio_find_done_scb(struct initio_host * host)
907 if ((tmp = host->first_done) != NULL) {
908 if ((host->first_done = tmp->next) == NULL)
909 host->last_done = NULL;
918 static int initio_abort_srb(struct initio_host * host, struct scsi_cmnd *srbp)
923 spin_lock_irqsave(&host->semaph_lock, flags);
925 if ((host->semaph == 0) && (host->active == NULL)) {
927 outb(0x1F, host->addr + TUL_Mask);
928 spin_unlock_irqrestore(&host->semaph_lock, flags);
930 tulip_main(host);
931 spin_lock_irqsave(&host->semaph_lock, flags);
932 host->semaph = 1;
933 outb(0x0F, host->addr + TUL_Mask);
934 spin_unlock_irqrestore(&host->semaph_lock, flags);
937 prev = tmp = host->first_pending; /* Check Pend queue */
941 if (tmp == host->active) {
942 spin_unlock_irqrestore(&host->semaph_lock, flags);
944 } else if (tmp == host->first_pending) {
945 if ((host->first_pending = tmp->next) == NULL)
946 host->last_pending = NULL;
949 if (tmp == host->last_pending)
950 host->last_pending = prev;
955 (*tmp->post) ((u8 *) host, (u8 *) tmp);
956 spin_unlock_irqrestore(&host->semaph_lock, flags);
963 prev = tmp = host->first_busy; /* Check Busy queue */
966 if (tmp == host->active) {
967 spin_unlock_irqrestore(&host->semaph_lock, flags);
970 spin_unlock_irqrestore(&host->semaph_lock, flags);
973 host->act_tags[tmp->target]--;
974 if (tmp == host->first_busy) {
975 if ((host->first_busy = tmp->next) == NULL)
976 host->last_busy = NULL;
979 if (tmp == host->last_busy)
980 host->last_busy = prev;
988 (*tmp->post) ((u8 *) host, (u8 *) tmp);
989 spin_unlock_irqrestore(&host->semaph_lock, flags);
996 spin_unlock_irqrestore(&host->semaph_lock, flags);
1001 static int initio_bad_seq(struct initio_host * host)
1005 printk("initio_bad_seg c=%d\n", host->index);
1007 if ((scb = host->active) != NULL) {
1008 initio_unlink_busy_scb(host, scb);
1011 initio_append_done_scb(host, scb);
1013 initio_stop_bm(host);
1014 initio_reset_scsi(host, 8); /* 7/29/98 */
1015 return initio_post_scsi_rst(host);
1020 static void initio_exec_scb(struct initio_host * host, struct scsi_ctrl_blk * scb)
1029 spin_lock_irqsave(&host->semaph_lock, flags);
1031 initio_append_pend_scb(host, scb); /* Append this SCB to Pending queue */
1034 if (host->semaph == 1) {
1036 outb(0x1F, host->addr + TUL_Mask);
1037 host->semaph = 0;
1038 spin_unlock_irqrestore(&host->semaph_lock, flags);
1040 tulip_main(host);
1042 spin_lock_irqsave(&host->semaph_lock, flags);
1043 host->semaph = 1;
1044 outb(0x0F, host->addr + TUL_Mask);
1046 spin_unlock_irqrestore(&host->semaph_lock, flags);
1051 static int initio_isr(struct initio_host * host)
1053 if (inb(host->addr + TUL_Int) & TSS_INT_PENDING) {
1054 if (host->semaph == 1) {
1055 outb(0x1F, host->addr + TUL_Mask);
1057 host->semaph = 0;
1059 tulip_main(host);
1061 host->semaph = 1;
1062 outb(0x0F, host->addr + TUL_Mask);
1069 static int tulip_main(struct initio_host * host)
1074 tulip_scsi(host); /* Call tulip_scsi */
1077 while ((scb = initio_find_done_scb(host)) != NULL) { /* find done entry */
1079 host->max_tags[scb->target] =
1080 host->act_tags[scb->target] - 1;
1082 initio_append_pend_scb(host, scb);
1111 initio_push_pend_scb(host, scb);
1126 (*scb->post) ((u8 *) host, (u8 *) scb);
1130 if (inb(host->addr + TUL_SStatus0) & TSS_INT_PENDING)
1132 if (host->active) /* return to OS and wait for xfer_done_ISR/Selected_ISR */
1135 if (initio_find_first_pend_scb(host) == NULL)
1141 static void tulip_scsi(struct initio_host * host)
1147 if ((host->jsstatus0 = inb(host->addr + TUL_SStatus0)) & TSS_INT_PENDING) {
1148 host->phase = host->jsstatus0 & TSS_PH_MASK;
1149 host->jsstatus1 = inb(host->addr + TUL_SStatus1);
1150 host->jsint = inb(host->addr + TUL_SInt);
1151 if (host->jsint & TSS_SCSIRST_INT) { /* SCSI bus reset detected */
1152 int_initio_scsi_rst(host);
1155 if (host->jsint & TSS_RESEL_INT) { /* if selected/reselected interrupt */
1156 if (int_initio_resel(host) == 0)
1157 initio_next_state(host);
1160 if (host->jsint & TSS_SEL_TIMEOUT) {
1161 int_initio_busfree(host);
1164 if (host->jsint & TSS_DISC_INT) { /* BUS disconnection */
1165 int_initio_busfree(host); /* unexpected bus free or sel timeout */
1168 if (host->jsint & (TSS_FUNC_COMP | TSS_BUS_SERV)) { /* func complete or Bus service */
1169 if (host->active)
1170 initio_next_state(host);
1174 if (host->active != NULL)
1177 if ((scb = initio_find_first_pend_scb(host)) == NULL)
1181 outb((host->scsi_id << 4) | (scb->target & 0x0F),
1182 host->addr + TUL_SScsiId);
1184 active_tc = &host->targets[scb->target];
1191 outb(active_tc->js_period, host->addr + TUL_SPeriod);
1193 initio_select_atn_stop(host, scb);
1196 initio_select_atn_stop(host, scb);
1199 initio_select_atn3(host, scb);
1201 initio_select_atn(host, scb);
1205 while (wait_tulip(host) != -1) {
1206 if (initio_next_state(host) == -1)
1211 initio_select_atn_stop(host, scb);
1214 while (wait_tulip(host) != -1) {
1215 if (initio_next_state(host) == -1)
1220 if (initio_abort_srb(host, scb->srb) != 0) {
1221 initio_unlink_pend_scb(host, scb);
1222 initio_release_scb(host, scb);
1225 initio_select_atn_stop(host, scb);
1229 initio_unlink_pend_scb(host, scb);
1231 initio_append_done_scb(host, scb);
1238 * @host: InitIO host we are processing
1246 static int initio_next_state(struct initio_host * host)
1250 next = host->active->next_state;
1254 next = initio_state_1(host);
1257 next = initio_state_2(host);
1260 next = initio_state_3(host);
1263 next = initio_state_4(host);
1266 next = initio_state_5(host);
1269 next = initio_state_6(host);
1272 next = initio_state_7(host);
1275 return initio_bus_device_reset(host);
1277 return initio_bad_seq(host);
1287 * @host: InitIO host we are controlling
1292 static int initio_state_1(struct initio_host * host)
1294 struct scsi_ctrl_blk *scb = host->active;
1295 struct target_control *active_tc = host->active_tc;
1301 initio_unlink_pend_scb(host, scb);
1302 initio_append_busy_scb(host, scb);
1304 outb(active_tc->sconfig0, host->addr + TUL_SConfig );
1306 if (host->phase == MSG_OUT) {
1307 outb(TSC_EN_BUS_IN | TSC_HW_RESELECT, host->addr + TUL_SCtrl1);
1308 outb(scb->ident, host->addr + TUL_SFifo);
1311 outb(scb->tagmsg, host->addr + TUL_SFifo);
1312 outb(scb->tagid, host->addr + TUL_SFifo);
1316 outb(EXTENDED_MESSAGE, host->addr + TUL_SFifo);
1317 outb(2, host->addr + TUL_SFifo); /* Extended msg length */
1318 outb(EXTENDED_SDTR, host->addr + TUL_SFifo); /* Sync request */
1319 outb(1, host->addr + TUL_SFifo); /* Start from 16 bits */
1322 outb(EXTENDED_MESSAGE, host->addr + TUL_SFifo);
1323 outb(3, host->addr + TUL_SFifo); /* extended msg length */
1324 outb(EXTENDED_SDTR, host->addr + TUL_SFifo); /* sync request */
1325 outb(initio_rate_tbl[active_tc->flags & TCF_SCSI_RATE], host->addr + TUL_SFifo);
1326 outb(MAX_OFFSET, host->addr + TUL_SFifo); /* REQ/ACK offset */
1328 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
1329 if (wait_tulip(host) == -1)
1332 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0);
1333 outb((inb(host->addr + TUL_SSignal) & (TSC_SET_ACK | 7)), host->addr + TUL_SSignal);
1341 * @host: InitIO host we are controlling
1347 static int initio_state_2(struct initio_host * host)
1349 struct scsi_ctrl_blk *scb = host->active;
1350 struct target_control *active_tc = host->active_tc;
1355 initio_unlink_pend_scb(host, scb);
1356 initio_append_busy_scb(host, scb);
1358 outb(active_tc->sconfig0, host->addr + TUL_SConfig);
1360 if (host->jsstatus1 & TSS_CMD_PH_CMP)
1363 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0);
1364 outb((inb(host->addr + TUL_SSignal) & (TSC_SET_ACK | 7)), host->addr + TUL_SSignal);
1371 * @host: InitIO host we are controlling
1376 static int initio_state_3(struct initio_host * host)
1378 struct scsi_ctrl_blk *scb = host->active;
1379 struct target_control *active_tc = host->active_tc;
1386 switch (host->phase) {
1389 outb(scb->cdb[i], host->addr + TUL_SFifo);
1390 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
1391 if (wait_tulip(host) == -1)
1393 if (host->phase == CMD_OUT)
1394 return initio_bad_seq(host);
1399 if (initio_msgin(host) == -1)
1404 if (initio_status_msg(host) == -1)
1410 outb(NOP, host->addr + TUL_SFifo); /* msg nop */
1411 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
1412 if (wait_tulip(host) == -1)
1417 outb(EXTENDED_MESSAGE, host->addr + TUL_SFifo);
1418 outb(3, host->addr + TUL_SFifo); /* ext. msg len */
1419 outb(EXTENDED_SDTR, host->addr + TUL_SFifo); /* sync request */
1420 outb(initio_rate_tbl[active_tc->flags & TCF_SCSI_RATE], host->addr + TUL_SFifo);
1421 outb(MAX_OFFSET, host->addr + TUL_SFifo); /* REQ/ACK offset */
1422 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
1423 if (wait_tulip(host) == -1)
1425 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0);
1426 outb(inb(host->addr + TUL_SSignal) & (TSC_SET_ACK | 7), host->addr + TUL_SSignal);
1431 return initio_bad_seq(host);
1438 * @host: InitIO host we are controlling
1443 static int initio_state_4(struct initio_host * host)
1445 struct scsi_ctrl_blk *scb = host->active;
1457 switch (host->phase) {
1462 if ((initio_status_msg(host)) == -1)
1468 if (initio_msgin(host) == -1)
1473 if (host->jsstatus0 & TSS_PAR_ERROR) {
1476 if (initio_msgout_ide(host) == -1)
1480 outb(NOP, host->addr + TUL_SFifo); /* msg nop */
1481 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
1482 if (wait_tulip(host) == -1)
1488 return initio_xfer_data_in(host);
1491 return initio_xfer_data_out(host);
1494 return initio_bad_seq(host);
1502 * @host: InitIO host we are controlling
1507 static int initio_state_5(struct initio_host * host)
1509 struct scsi_ctrl_blk *scb = host->active;
1516 cnt = inl(host->addr + TUL_SCnt0) & 0x0FFFFFF;
1518 if (inb(host->addr + TUL_XCmd) & 0x20) {
1521 if (host->jsstatus0 & TSS_PAR_ERROR)
1523 if (inb(host->addr + TUL_XStatus) & XPEND) { /* DMA xfer pending, Send STOP */
1525 outb(inb(host->addr + TUL_XCtrl) | 0x80, host->addr + TUL_XCtrl);
1527 while (inb(host->addr + TUL_XStatus) & XPEND)
1532 if ((inb(host->addr + TUL_SStatus1) & TSS_XFER_CMP) == 0) {
1533 if (host->active_tc->js_period & TSC_WIDE_SCSI)
1534 cnt += (inb(host->addr + TUL_SFifoCnt) & 0x1F) << 1;
1536 cnt += (inb(host->addr + TUL_SFifoCnt) & 0x1F);
1538 if (inb(host->addr + TUL_XStatus) & XPEND) { /* if DMA xfer is pending, abort DMA xfer */
1539 outb(TAX_X_ABT, host->addr + TUL_XCmd);
1541 while ((inb(host->addr + TUL_Int) & XABT) == 0)
1544 if ((cnt == 1) && (host->phase == DATA_OUT)) {
1545 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
1546 if (wait_tulip(host) == -1)
1550 if ((inb(host->addr + TUL_SStatus1) & TSS_XFER_CMP) == 0)
1551 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0);
1591 * @host: InitIO host we are controlling
1596 static int initio_state_6(struct initio_host * host)
1598 struct scsi_ctrl_blk *scb = host->active;
1604 switch (host->phase) {
1606 if ((initio_status_msg(host)) == -1)
1612 if ((initio_msgin(host)) == -1)
1617 outb(NOP, host->addr + TUL_SFifo); /* msg nop */
1618 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
1619 if (wait_tulip(host) == -1)
1624 return initio_xpad_in(host);
1627 return initio_xpad_out(host);
1630 return initio_bad_seq(host);
1637 * @host: InitIO host we are controlling
1641 static int initio_state_7(struct initio_host * host)
1649 cnt = inb(host->addr + TUL_SFifoCnt) & 0x1F;
1652 inb(host->addr + TUL_SFifo);
1654 switch (host->phase) {
1657 return initio_bad_seq(host);
1665 * @host: InitIO host in use
1671 static int initio_xfer_data_in(struct initio_host * host)
1673 struct scsi_ctrl_blk *scb = host->active;
1678 outl(scb->buflen, host->addr + TUL_SCnt0);
1679 outb(TSC_XF_DMA_IN, host->addr + TUL_SCmd); /* 7/25/95 */
1682 outl(((u32) scb->sglen) << 3, host->addr + TUL_XCntH);
1683 outl(scb->bufptr, host->addr + TUL_XAddH);
1684 outb(TAX_SG_IN, host->addr + TUL_XCmd);
1686 outl(scb->buflen, host->addr + TUL_XCntH);
1687 outl(scb->bufptr, host->addr + TUL_XAddH);
1688 outb(TAX_X_IN, host->addr + TUL_XCmd);
1696 * @host: InitIO host in use
1703 static int initio_xfer_data_out(struct initio_host * host)
1705 struct scsi_ctrl_blk *scb = host->active;
1710 outl(scb->buflen, host->addr + TUL_SCnt0);
1711 outb(TSC_XF_DMA_OUT, host->addr + TUL_SCmd);
1714 outl(((u32) scb->sglen) << 3, host->addr + TUL_XCntH);
1715 outl(scb->bufptr, host->addr + TUL_XAddH);
1716 outb(TAX_SG_OUT, host->addr + TUL_XCmd);
1718 outl(scb->buflen, host->addr + TUL_XCntH);
1719 outl(scb->bufptr, host->addr + TUL_XAddH);
1720 outb(TAX_X_OUT, host->addr + TUL_XCmd);
1727 int initio_xpad_in(struct initio_host * host)
1729 struct scsi_ctrl_blk *scb = host->active;
1730 struct target_control *active_tc = host->active_tc;
1736 outl(2, host->addr + TUL_SCnt0);
1738 outl(1, host->addr + TUL_SCnt0);
1740 outb(TSC_XF_FIFO_IN, host->addr + TUL_SCmd);
1741 if (wait_tulip(host) == -1)
1743 if (host->phase != DATA_IN) {
1744 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0);
1747 inb(host->addr + TUL_SFifo);
1751 int initio_xpad_out(struct initio_host * host)
1753 struct scsi_ctrl_blk *scb = host->active;
1754 struct target_control *active_tc = host->active_tc;
1760 outl(2, host->addr + TUL_SCnt0);
1762 outl(1, host->addr + TUL_SCnt0);
1764 outb(0, host->addr + TUL_SFifo);
1765 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
1766 if ((wait_tulip(host)) == -1)
1768 if (host->phase != DATA_OUT) { /* Disable wide CPU to allow read 16 bits */
1769 outb(TSC_HW_RESELECT, host->addr + TUL_SCtrl1);
1770 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0);
1776 int initio_status_msg(struct initio_host * host)
1778 struct scsi_ctrl_blk *scb = host->active;
1781 outb(TSC_CMD_COMP, host->addr + TUL_SCmd);
1782 if (wait_tulip(host) == -1)
1786 scb->tastat = inb(host->addr + TUL_SFifo);
1788 if (host->phase == MSG_OUT) {
1789 if (host->jsstatus0 & TSS_PAR_ERROR)
1790 outb(MSG_PARITY_ERROR, host->addr + TUL_SFifo);
1792 outb(NOP, host->addr + TUL_SFifo);
1793 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
1794 return wait_tulip(host);
1796 if (host->phase == MSG_IN) {
1797 msg = inb(host->addr + TUL_SFifo);
1798 if (host->jsstatus0 & TSS_PAR_ERROR) { /* Parity error */
1799 if ((initio_msgin_accept(host)) == -1)
1801 if (host->phase != MSG_OUT)
1802 return initio_bad_seq(host);
1803 outb(MSG_PARITY_ERROR, host->addr + TUL_SFifo);
1804 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
1805 return wait_tulip(host);
1810 return initio_bad_seq(host);
1811 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0);
1812 outb(TSC_MSG_ACCEPT, host->addr + TUL_SCmd);
1813 return initio_wait_done_disc(host);
1819 return initio_msgin_accept(host);
1822 return initio_bad_seq(host);
1827 int int_initio_busfree(struct initio_host * host)
1829 struct scsi_ctrl_blk *scb = host->active;
1833 initio_unlink_pend_scb(host, scb);
1835 initio_append_done_scb(host, scb);
1837 initio_unlink_busy_scb(host, scb);
1839 initio_append_done_scb(host, scb);
1841 host->active = NULL;
1842 host->active_tc = NULL;
1844 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0); /* Flush SCSI FIFO */
1845 outb(TSC_INITDEFAULT, host->addr + TUL_SConfig);
1846 outb(TSC_HW_RESELECT, host->addr + TUL_SCtrl1); /* Enable HW reselect */
1853 * @host: Host seeing the reset
1861 static int int_initio_scsi_rst(struct initio_host * host)
1867 if (inb(host->addr + TUL_XStatus) & 0x01) {
1868 outb(TAX_X_ABT | TAX_X_CLR_FIFO, host->addr + TUL_XCmd);
1870 while ((inb(host->addr + TUL_Int) & 0x04) == 0)
1872 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0);
1875 while ((scb = initio_pop_busy_scb(host)) != NULL) {
1877 initio_append_done_scb(host, scb);
1879 host->active = NULL;
1880 host->active_tc = NULL;
1883 for (i = 0; i < host->max_tar; i++)
1884 host->targets[i].flags &= ~(TCF_SYNC_DONE | TCF_WDTR_DONE);
1890 * @host: InitIO host adapter
1897 int int_initio_resel(struct initio_host * host)
1904 if ((scb = host->active) != NULL) {
1908 host->active = NULL;
1911 tar = inb(host->addr + TUL_SBusId);
1913 lun = inb(host->addr + TUL_SIdent) & 0x0F;
1915 active_tc = &host->targets[tar];
1916 host->active_tc = active_tc;
1917 outb(active_tc->sconfig0, host->addr + TUL_SConfig);
1918 outb(active_tc->js_period, host->addr + TUL_SPeriod);
1922 if ((initio_msgin_accept(host)) == -1)
1924 if (host->phase != MSG_IN)
1926 outl(1, host->addr + TUL_SCnt0);
1927 outb(TSC_XF_FIFO_IN, host->addr + TUL_SCmd);
1928 if (wait_tulip(host) == -1)
1930 msg = inb(host->addr + TUL_SFifo); /* Read Tag Message */
1936 if (initio_msgin_accept(host) == -1)
1939 if (host->phase != MSG_IN)
1942 outl(1, host->addr + TUL_SCnt0);
1943 outb(TSC_XF_FIFO_IN, host->addr + TUL_SCmd);
1944 if (wait_tulip(host) == -1)
1946 tag = inb(host->addr + TUL_SFifo); /* Read Tag ID */
1947 scb = host->scb + tag;
1949 return initio_msgout_abort_tag(host);
1952 return initio_msgout_abort_tag(host);
1954 host->active = scb;
1955 if ((initio_msgin_accept(host)) == -1)
1959 if ((scb = initio_find_busy_scb(host, tar | (lun << 8))) == NULL) {
1960 return initio_msgout_abort_targ(host);
1962 host->active = scb;
1964 if ((initio_msgin_accept(host)) == -1)
1973 * @host: InitIO host flagging event
1975 * We have ended up out of phase somehow. Reset the host controller
1979 static int int_initio_bad_seq(struct initio_host * host)
1984 initio_reset_scsi(host, 10);
1986 while ((scb = initio_pop_busy_scb(host)) != NULL) {
1988 initio_append_done_scb(host, scb);
1990 for (i = 0; i < host->max_tar; i++)
1991 host->targets[i].flags &= ~(TCF_SYNC_DONE | TCF_WDTR_DONE);
1998 * @host: InitIO host
2004 static int initio_msgout_abort_targ(struct initio_host * host)
2007 outb(((inb(host->addr + TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN), host->addr + TUL_SSignal);
2008 if (initio_msgin_accept(host) == -1)
2010 if (host->phase != MSG_OUT)
2011 return initio_bad_seq(host);
2013 outb(ABORT_TASK_SET, host->addr + TUL_SFifo);
2014 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
2016 return initio_wait_disc(host);
2021 * @host: InitIO host
2027 static int initio_msgout_abort_tag(struct initio_host * host)
2030 outb(((inb(host->addr + TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN), host->addr + TUL_SSignal);
2031 if (initio_msgin_accept(host) == -1)
2033 if (host->phase != MSG_OUT)
2034 return initio_bad_seq(host);
2036 outb(ABORT_TASK, host->addr + TUL_SFifo);
2037 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
2039 return initio_wait_disc(host);
2045 * @host: InitIO Host
2049 static int initio_msgin(struct initio_host * host)
2054 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0);
2056 outl(1, host->addr + TUL_SCnt0);
2057 outb(TSC_XF_FIFO_IN, host->addr + TUL_SCmd);
2058 if (wait_tulip(host) == -1)
2061 switch (inb(host->addr + TUL_SFifo)) {
2063 outb(TSC_MSG_ACCEPT, host->addr + TUL_SCmd);
2064 return initio_wait_disc(host);
2068 initio_msgin_accept(host);
2071 outb((inb(host->addr + TUL_SSignal) & (TSC_SET_ACK | 7)),
2072 host->addr + TUL_SSignal);
2073 active_tc = host->active_tc;
2075 outb(((inb(host->addr + TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN),
2076 host->addr + TUL_SSignal);
2077 initio_msgin_accept(host);
2080 initio_msgin_extend(host);
2083 initio_msgin_accept(host);
2086 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0);
2087 outb(TSC_MSG_ACCEPT, host->addr + TUL_SCmd);
2088 return initio_wait_done_disc(host);
2090 initio_msgout_reject(host);
2093 if (host->phase != MSG_IN)
2094 return host->phase;
2099 static int initio_msgout_reject(struct initio_host * host)
2101 outb(((inb(host->addr + TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN), host->addr + TUL_SSignal);
2103 if (initio_msgin_accept(host) == -1)
2106 if (host->phase == MSG_OUT) {
2107 outb(MESSAGE_REJECT, host->addr + TUL_SFifo); /* Msg reject */
2108 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
2109 return wait_tulip(host);
2111 return host->phase;
2114 static int initio_msgout_ide(struct initio_host * host)
2116 outb(INITIATOR_ERROR, host->addr + TUL_SFifo); /* Initiator Detected Error */
2117 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
2118 return wait_tulip(host);
2121 static int initio_msgin_extend(struct initio_host * host)
2125 if (initio_msgin_accept(host) != MSG_IN)
2126 return host->phase;
2129 outl(1, host->addr + TUL_SCnt0);
2130 outb(TSC_XF_FIFO_IN, host->addr + TUL_SCmd);
2131 if (wait_tulip(host) == -1)
2134 len = inb(host->addr + TUL_SFifo);
2135 host->msg[0] = len;
2138 if ((initio_msgin_accept(host)) != MSG_IN)
2139 return host->phase;
2140 outl(1, host->addr + TUL_SCnt0);
2141 outb(TSC_XF_FIFO_IN, host->addr + TUL_SCmd);
2142 if (wait_tulip(host) == -1)
2144 host->msg[idx++] = inb(host->addr + TUL_SFifo);
2146 if (host->msg[1] == 1) { /* if it's synchronous data transfer request */
2148 if (host->msg[0] != 3) /* if length is not right */
2149 return initio_msgout_reject(host);
2150 if (host->active_tc->flags & TCF_NO_SYNC_NEGO) { /* Set OFFSET=0 to do async, nego back */
2151 host->msg[3] = 0;
2153 if (initio_msgin_sync(host) == 0 &&
2154 (host->active_tc->flags & TCF_SYNC_DONE)) {
2155 initio_sync_done(host);
2156 return initio_msgin_accept(host);
2160 r = inb(host->addr + TUL_SSignal);
2162 host->addr + TUL_SSignal);
2163 if (initio_msgin_accept(host) != MSG_OUT)
2164 return host->phase;
2166 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0);
2168 initio_sync_done(host);
2170 outb(EXTENDED_MESSAGE, host->addr + TUL_SFifo);
2171 outb(3, host->addr + TUL_SFifo);
2172 outb(EXTENDED_SDTR, host->addr + TUL_SFifo);
2173 outb(host->msg[2], host->addr + TUL_SFifo);
2174 outb(host->msg[3], host->addr + TUL_SFifo);
2175 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
2176 return wait_tulip(host);
2178 if (host->msg[0] != 2 || host->msg[1] != 3)
2179 return initio_msgout_reject(host);
2181 if (host->active_tc->flags & TCF_NO_WDTR) {
2182 host->msg[2] = 0;
2184 if (host->msg[2] > 2) /* > 32 bits */
2185 return initio_msgout_reject(host);
2186 if (host->msg[2] == 2) { /* == 32 */
2187 host->msg[2] = 1;
2189 if ((host->active_tc->flags & TCF_NO_WDTR) == 0) {
2190 wdtr_done(host);
2191 if ((host->active_tc->flags & (TCF_SYNC_DONE | TCF_NO_SYNC_NEGO)) == 0)
2192 outb(((inb(host->addr + TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN), host->addr + TUL_SSignal);
2193 return initio_msgin_accept(host);
2197 outb(((inb(host->addr + TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN), host->addr + TUL_SSignal);
2199 if (initio_msgin_accept(host) != MSG_OUT)
2200 return host->phase;
2202 outb(EXTENDED_MESSAGE, host->addr + TUL_SFifo);
2203 outb(2, host->addr + TUL_SFifo);
2204 outb(EXTENDED_WDTR, host->addr + TUL_SFifo);
2205 outb(host->msg[2], host->addr + TUL_SFifo);
2206 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
2207 return wait_tulip(host);
2210 static int initio_msgin_sync(struct initio_host * host)
2214 default_period = initio_rate_tbl[host->active_tc->flags & TCF_SCSI_RATE];
2215 if (host->msg[3] > MAX_OFFSET) {
2216 host->msg[3] = MAX_OFFSET;
2217 if (host->msg[2] < default_period) {
2218 host->msg[2] = default_period;
2221 if (host->msg[2] >= 59) /* Change to async */
2222 host->msg[3] = 0;
2226 if (host->msg[3] == 0) {
2229 if (host->msg[2] < default_period) {
2230 host->msg[2] = default_period;
2233 if (host->msg[2] >= 59) {
2234 host->msg[3] = 0;
2240 static int wdtr_done(struct initio_host * host)
2242 host->active_tc->flags &= ~TCF_SYNC_DONE;
2243 host->active_tc->flags |= TCF_WDTR_DONE;
2245 host->active_tc->js_period = 0;
2246 if (host->msg[2]) /* if 16 bit */
2247 host->active_tc->js_period |= TSC_WIDE_SCSI;
2248 host->active_tc->sconfig0 &= ~TSC_ALT_PERIOD;
2249 outb(host->active_tc->sconfig0, host->addr + TUL_SConfig);
2250 outb(host->active_tc->js_period, host->addr + TUL_SPeriod);
2255 static int initio_sync_done(struct initio_host * host)
2259 host->active_tc->flags |= TCF_SYNC_DONE;
2261 if (host->msg[3]) {
2262 host->active_tc->js_period |= host->msg[3];
2264 if (initio_rate_tbl[i] >= host->msg[2]) /* pick the big one */
2267 host->active_tc->js_period |= (i << 4);
2268 host->active_tc->sconfig0 |= TSC_ALT_PERIOD;
2270 outb(host->active_tc->sconfig0, host->addr + TUL_SConfig);
2271 outb(host->active_tc->js_period, host->addr + TUL_SPeriod);
2277 static int initio_post_scsi_rst(struct initio_host * host)
2283 host->active = NULL;
2284 host->active_tc = NULL;
2285 host->flags = 0;
2287 while ((scb = initio_pop_busy_scb(host)) != NULL) {
2289 initio_append_done_scb(host, scb);
2292 active_tc = &host->targets[0];
2293 for (i = 0; i < host->max_tar; active_tc++, i++) {
2297 active_tc->sconfig0 = host->sconf1;
2298 host->act_tags[0] = 0; /* 07/22/98 */
2299 host->targets[i].flags &= ~TCF_BUSY; /* 07/22/98 */
2305 static void initio_select_atn_stop(struct initio_host * host, struct scsi_ctrl_blk * scb)
2309 host->active = scb;
2310 host->active_tc = &host->targets[scb->target];
2311 outb(TSC_SELATNSTOP, host->addr + TUL_SCmd);
2315 static void initio_select_atn(struct initio_host * host, struct scsi_ctrl_blk * scb)
2322 outb(scb->ident, host->addr + TUL_SFifo);
2324 outb(scb->cdb[i], host->addr + TUL_SFifo);
2325 host->active_tc = &host->targets[scb->target];
2326 host->active = scb;
2327 outb(TSC_SEL_ATN, host->addr + TUL_SCmd);
2330 static void initio_select_atn3(struct initio_host * host, struct scsi_ctrl_blk * scb)
2337 outb(scb->ident, host->addr + TUL_SFifo);
2338 outb(scb->tagmsg, host->addr + TUL_SFifo);
2339 outb(scb->tagid, host->addr + TUL_SFifo);
2341 outb(scb->cdb[i], host->addr + TUL_SFifo);
2342 host->active_tc = &host->targets[scb->target];
2343 host->active = scb;
2344 outb(TSC_SEL_ATN3, host->addr + TUL_SCmd);
2349 * @host: InitIO host to reset
2354 int initio_bus_device_reset(struct initio_host * host)
2356 struct scsi_ctrl_blk *scb = host->active;
2357 struct target_control *active_tc = host->active_tc;
2361 if (host->phase != MSG_OUT)
2362 return int_initio_bad_seq(host); /* Unexpected phase */
2364 initio_unlink_pend_scb(host, scb);
2365 initio_release_scb(host, scb);
2373 prev = tmp = host->first_busy; /* Check Busy queue */
2377 if (tmp == host->first_busy) {
2378 if ((host->first_busy = tmp->next) == NULL)
2379 host->last_busy = NULL;
2382 if (tmp == host->last_busy)
2383 host->last_busy = prev;
2386 initio_append_done_scb(host, tmp);
2394 outb(TARGET_RESET, host->addr + TUL_SFifo);
2395 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
2396 return initio_wait_disc(host);
2400 static int initio_msgin_accept(struct initio_host * host)
2402 outb(TSC_MSG_ACCEPT, host->addr + TUL_SCmd);
2403 return wait_tulip(host);
2406 static int wait_tulip(struct initio_host * host)
2409 while (!((host->jsstatus0 = inb(host->addr + TUL_SStatus0))
2413 host->jsint = inb(host->addr + TUL_SInt);
2414 host->phase = host->jsstatus0 & TSS_PH_MASK;
2415 host->jsstatus1 = inb(host->addr + TUL_SStatus1);
2417 if (host->jsint & TSS_RESEL_INT) /* if SCSI bus reset detected */
2418 return int_initio_resel(host);
2419 if (host->jsint & TSS_SEL_TIMEOUT) /* if selected/reselected timeout interrupt */
2420 return int_initio_busfree(host);
2421 if (host->jsint & TSS_SCSIRST_INT) /* if SCSI bus reset detected */
2422 return int_initio_scsi_rst(host);
2424 if (host->jsint & TSS_DISC_INT) { /* BUS disconnection */
2425 if (host->flags & HCF_EXPECT_DONE_DISC) {
2426 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0); /* Flush SCSI FIFO */
2427 initio_unlink_busy_scb(host, host->active);
2428 host->active->hastat = 0;
2429 initio_append_done_scb(host, host->active);
2430 host->active = NULL;
2431 host->active_tc = NULL;
2432 host->flags &= ~HCF_EXPECT_DONE_DISC;
2433 outb(TSC_INITDEFAULT, host->addr + TUL_SConfig);
2434 outb(TSC_HW_RESELECT, host->addr + TUL_SCtrl1); /* Enable HW reselect */
2437 if (host->flags & HCF_EXPECT_DISC) {
2438 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0); /* Flush SCSI FIFO */
2439 host->active = NULL;
2440 host->active_tc = NULL;
2441 host->flags &= ~HCF_EXPECT_DISC;
2442 outb(TSC_INITDEFAULT, host->addr + TUL_SConfig);
2443 outb(TSC_HW_RESELECT, host->addr + TUL_SCtrl1); /* Enable HW reselect */
2446 return int_initio_busfree(host);
2449 if (host->jsint & (TSS_FUNC_COMP | TSS_BUS_SERV))
2450 return host->phase;
2451 return host->phase;
2454 static int initio_wait_disc(struct initio_host * host)
2456 while (!((host->jsstatus0 = inb(host->addr + TUL_SStatus0)) & TSS_INT_PENDING))
2459 host->jsint = inb(host->addr + TUL_SInt);
2461 if (host->jsint & TSS_SCSIRST_INT) /* if SCSI bus reset detected */
2462 return int_initio_scsi_rst(host);
2463 if (host->jsint & TSS_DISC_INT) { /* BUS disconnection */
2464 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0); /* Flush SCSI FIFO */
2465 outb(TSC_INITDEFAULT, host->addr + TUL_SConfig);
2466 outb(TSC_HW_RESELECT, host->addr + TUL_SCtrl1); /* Enable HW reselect */
2467 host->active = NULL;
2470 return initio_bad_seq(host);
2473 static int initio_wait_done_disc(struct initio_host * host)
2475 while (!((host->jsstatus0 = inb(host->addr + TUL_SStatus0))
2479 host->jsint = inb(host->addr + TUL_SInt);
2481 if (host->jsint & TSS_SCSIRST_INT) /* if SCSI bus reset detected */
2482 return int_initio_scsi_rst(host);
2483 if (host->jsint & TSS_DISC_INT) { /* BUS disconnection */
2484 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0); /* Flush SCSI FIFO */
2485 outb(TSC_INITDEFAULT, host->addr + TUL_SConfig);
2486 outb(TSC_HW_RESELECT, host->addr + TUL_SCtrl1); /* Enable HW reselect */
2487 initio_unlink_busy_scb(host, host->active);
2489 initio_append_done_scb(host, host->active);
2490 host->active = NULL;
2493 return initio_bad_seq(host);
2523 * @host: InitIO host taking the command
2528 * suitable for feeding to the InitIO host controller. This also requires
2532 static void initio_build_scb(struct initio_host * host, struct scsi_ctrl_blk * cblk, struct scsi_cmnd * cmnd)
2552 dma_addr = dma_map_single(&host->pci_dev->dev, cmnd->sense_buffer,
2576 dma_addr = dma_map_single(&host->pci_dev->dev, &cblk->sglist[0],
2606 * Attempts to queue a new command with the host adapter. Will return
2607 * zero if successful or indicate a host busy condition if not (which
2612 struct initio_host *host = (struct initio_host *) cmd->device->host->hostdata;
2615 cmnd = initio_alloc_scb(host);
2619 initio_build_scb(host, cmnd, cmd);
2620 initio_exec_scb(host, cmnd);
2635 struct initio_host *host;
2637 host = (struct initio_host *) cmnd->device->host->hostdata;
2639 spin_lock_irq(cmnd->device->host->host_lock);
2640 initio_reset_scsi(host, 0);
2641 spin_unlock_irq(cmnd->device->host->host_lock);
2653 * Map the device geometry in a manner compatible with the host
2662 struct initio_host *host; /* Point to Host adapter control block */
2665 host = (struct initio_host *) sdev->host->hostdata;
2666 tc = &host->targets[sdev->id];
2735 struct initio_host *host;
2738 host = (struct initio_host *) host_mem;
2743 initio_release_scb(host, cblk); /* Release SCB for current channel */
2763 phase sequence was requested by the target. The host adapter
2764 will generate a SCSI Reset Condition, notifying the host with
2786 i91u_unmap_scb(host->pci_dev, cmnd);
2788 initio_release_scb(host, cblk); /* Release SCB for current channel */
2807 struct initio_host *host;
2830 printk(KERN_WARNING "initio: Could not allocate host structure.\n");
2834 host = (struct initio_host *)shost->hostdata;
2835 memset(host, 0, sizeof(struct initio_host));
2836 host->addr = pci_resource_start(pdev, 0);
2837 host->bios_addr = bios_seg;
2839 if (!request_region(host->addr, 256, "i91u")) {
2840 printk(KERN_WARNING "initio: I/O port range 0x%x is busy.\n", host->addr);
2863 host->pci_dev = pdev;
2865 host->semaph = 1;
2866 spin_lock_init(&host->semaph_lock);
2867 host->num_scbs = num_scb;
2868 host->scb = scb;
2869 host->next_pending = scb;
2870 host->next_avail = scb;
2878 host->scb_end = tmp;
2879 host->first_avail = scb;
2880 host->last_avail = prev;
2881 spin_lock_init(&host->avail_lock);
2883 initio_init(host, phys_to_virt(((u32)bios_seg << 4)));
2885 host->jsstatus0 = 0;
2887 shost->io_port = host->addr;
2890 shost->unique_id = host->addr;
2891 shost->max_id = host->max_tar;
2894 shost->this_id = host->scsi_id; /* Assign HCS index */
2895 shost->base = host->addr;
2914 kfree(host->scb);
2916 release_region(host->addr, 256);
2934 struct Scsi_Host *host = pci_get_drvdata(pdev);
2935 struct initio_host *s = (struct initio_host *)host->hostdata;
2936 scsi_remove_host(host);
2937 free_irq(pdev->irq, host);
2939 scsi_host_put(host);