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);
473 * Retrieve the host adapter configuration data from E2Prom. If the
501 * @host: InitIO we are stopping
506 static void initio_stop_bm(struct initio_host * host)
509 if (inb(host->addr + TUL_XStatus) & XPEND) { /* if DMA xfer is pending, abort DMA xfer */
510 outb(TAX_X_ABT | TAX_X_CLR_FIFO, host->addr + TUL_XCmd);
512 while ((inb(host->addr + TUL_Int) & XABT) == 0)
515 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0);
519 * initio_reset_scsi - Reset SCSI host controller
520 * @host: InitIO host to reset
526 static int initio_reset_scsi(struct initio_host * host, int seconds)
528 outb(TSC_RST_BUS, host->addr + TUL_SCtrl0);
530 while (!((host->jsint = inb(host->addr + TUL_SInt)) & TSS_SCSIRST_INT))
534 outb(0, host->addr + TUL_SSignal);
541 inb(host->addr + TUL_SInt);
546 * initio_init - set up an InitIO host adapter
547 * @host: InitIO host adapter
550 * Set up the host adapter and devices according to the configuration
557 static void initio_init(struct initio_host * host, u8 *bios_addr)
564 initio_read_eeprom(host->addr);
566 host->max_tar = 8;
568 host->max_tar = 16;
570 host->config = i91unvramp->NVM_SCSIInfo[0].NVM_ChConfig1;
572 host->scsi_id = i91unvramp->NVM_SCSIInfo[0].NVM_ChSCSIID;
573 host->idmask = ~(1 << host->scsi_id);
577 outb(inb(host->addr + TUL_PCMD) | 0x40, host->addr + TUL_PCMD);
581 outb(0x1F, host->addr + TUL_Mask);
583 initio_stop_bm(host);
585 outb(TSC_RST_CHIP, host->addr + TUL_SCtrl0);
588 outb(host->scsi_id << 4, host->addr + TUL_SScsiId);
592 if (host->config & HCC_EN_PAR)
593 host->sconf1 = (TSC_INITDEFAULT | TSC_EN_SCSI_PAR);
595 host->sconf1 = (TSC_INITDEFAULT);
596 outb(host->sconf1, host->addr + TUL_SConfig);
599 outb(TSC_HW_RESELECT, host->addr + TUL_SCtrl1);
601 outb(0, host->addr + TUL_SPeriod);
604 outb(153, host->addr + TUL_STimeOut);
607 outb((host->config & (HCC_ACT_TERM1 | HCC_ACT_TERM2)),
608 host->addr + TUL_XCtrl);
609 outb(((host->config & HCC_AUTO_TERM) >> 4) |
610 (inb(host->addr + TUL_GCTRL1) & 0xFE),
611 host->addr + TUL_GCTRL1);
616 i < host->max_tar;
618 host->targets[i].flags = *flags & ~(TCF_SYNC_DONE | TCF_WDTR_DONE);
619 if (host->targets[i].flags & TCF_EN_255)
620 host->targets[i].drv_flags = TCF_DRV_255_63;
622 host->targets[i].drv_flags = 0;
623 host->targets[i].js_period = 0;
624 host->targets[i].sconfig0 = host->sconf1;
625 host->targets[i].heads = *heads++;
626 if (host->targets[i].heads == 255)
627 host->targets[i].drv_flags = TCF_DRV_255_63;
629 host->targets[i].drv_flags = 0;
630 host->targets[i].sectors = *heads++;
631 host->targets[i].flags &= ~TCF_BUSY;
632 host->act_tags[i] = 0;
633 host->max_tags[i] = 0xFF;
636 host->addr, host->pci_dev->irq,
637 host->bios_addr, host->scsi_id);
639 if (host->config & HCC_SCSI_RESET) {
641 initio_reset_scsi(host, 10);
643 outb(0x17, host->addr + TUL_SCFG1);
644 outb(0xE9, host->addr + TUL_SIntEnable);
649 * @host: InitIO host we are allocating for
654 static struct scsi_ctrl_blk *initio_alloc_scb(struct initio_host *host)
659 spin_lock_irqsave(&host->avail_lock, flags);
660 if ((scb = host->first_avail) != NULL) {
664 if ((host->first_avail = scb->next) == NULL)
665 host->last_avail = NULL;
669 spin_unlock_irqrestore(&host->avail_lock, flags);
675 * @host: InitIO host that owns the SCB
678 * Return an allocated SCB to the host free list
681 static void initio_release_scb(struct initio_host * host, struct scsi_ctrl_blk * cmnd)
688 spin_lock_irqsave(&(host->avail_lock), flags);
692 if (host->last_avail != NULL) {
693 host->last_avail->next = cmnd;
694 host->last_avail = cmnd;
696 host->first_avail = cmnd;
697 host->last_avail = cmnd;
699 spin_unlock_irqrestore(&(host->avail_lock), flags);
703 static void initio_append_pend_scb(struct initio_host * host, struct scsi_ctrl_blk * scbp)
711 if (host->last_pending != NULL) {
712 host->last_pending->next = scbp;
713 host->last_pending = scbp;
715 host->first_pending = scbp;
716 host->last_pending = scbp;
721 static void initio_push_pend_scb(struct initio_host * host, struct scsi_ctrl_blk * scbp)
728 if ((scbp->next = host->first_pending) != NULL) {
729 host->first_pending = scbp;
731 host->first_pending = scbp;
732 host->last_pending = scbp;
736 static struct scsi_ctrl_blk *initio_find_first_pend_scb(struct initio_host * host)
741 first = host->first_pending;
746 if ((host->act_tags[first->target] == 0) &&
747 !(host->targets[first->target].flags & TCF_BUSY))
750 if ((host->act_tags[first->target] >=
751 host->max_tags[first->target]) |
752 (host->targets[first->target].flags & TCF_BUSY)) {
763 static void initio_unlink_pend_scb(struct initio_host * host, struct scsi_ctrl_blk * scb)
771 prev = tmp = host->first_pending;
774 if (tmp == host->first_pending) {
775 if ((host->first_pending = tmp->next) == NULL)
776 host->last_pending = NULL;
779 if (tmp == host->last_pending)
780 host->last_pending = prev;
790 static void initio_append_busy_scb(struct initio_host * host, struct scsi_ctrl_blk * scbp)
797 host->act_tags[scbp->target]++;
799 host->targets[scbp->target].flags |= TCF_BUSY;
802 if (host->last_busy != NULL) {
803 host->last_busy->next = scbp;
804 host->last_busy = scbp;
806 host->first_busy = scbp;
807 host->last_busy = scbp;
812 static struct scsi_ctrl_blk *initio_pop_busy_scb(struct initio_host * host)
817 if ((tmp = host->first_busy) != NULL) {
818 if ((host->first_busy = tmp->next) == NULL)
819 host->last_busy = NULL;
822 host->act_tags[tmp->target]--;
824 host->targets[tmp->target].flags &= ~TCF_BUSY;
833 static void initio_unlink_busy_scb(struct initio_host * host, struct scsi_ctrl_blk * scb)
841 prev = tmp = host->first_busy;
844 if (tmp == host->first_busy) {
845 if ((host->first_busy = tmp->next) == NULL)
846 host->last_busy = NULL;
849 if (tmp == host->last_busy)
850 host->last_busy = prev;
854 host->act_tags[tmp->target]--;
856 host->targets[tmp->target].flags &= ~TCF_BUSY;
865 struct scsi_ctrl_blk *initio_find_busy_scb(struct initio_host * host, u16 tarlun)
871 tmp = host->first_busy;
885 static void initio_append_done_scb(struct initio_host * host, struct scsi_ctrl_blk * scbp)
893 if (host->last_done != NULL) {
894 host->last_done->next = scbp;
895 host->last_done = scbp;
897 host->first_done = scbp;
898 host->last_done = scbp;
902 struct scsi_ctrl_blk *initio_find_done_scb(struct initio_host * host)
906 if ((tmp = host->first_done) != NULL) {
907 if ((host->first_done = tmp->next) == NULL)
908 host->last_done = NULL;
917 static int initio_abort_srb(struct initio_host * host, struct scsi_cmnd *srbp)
922 spin_lock_irqsave(&host->semaph_lock, flags);
924 if ((host->semaph == 0) && (host->active == NULL)) {
926 outb(0x1F, host->addr + TUL_Mask);
927 spin_unlock_irqrestore(&host->semaph_lock, flags);
929 tulip_main(host);
930 spin_lock_irqsave(&host->semaph_lock, flags);
931 host->semaph = 1;
932 outb(0x0F, host->addr + TUL_Mask);
933 spin_unlock_irqrestore(&host->semaph_lock, flags);
936 prev = tmp = host->first_pending; /* Check Pend queue */
940 if (tmp == host->active) {
941 spin_unlock_irqrestore(&host->semaph_lock, flags);
943 } else if (tmp == host->first_pending) {
944 if ((host->first_pending = tmp->next) == NULL)
945 host->last_pending = NULL;
948 if (tmp == host->last_pending)
949 host->last_pending = prev;
954 (*tmp->post) ((u8 *) host, (u8 *) tmp);
955 spin_unlock_irqrestore(&host->semaph_lock, flags);
962 prev = tmp = host->first_busy; /* Check Busy queue */
965 if (tmp == host->active) {
966 spin_unlock_irqrestore(&host->semaph_lock, flags);
969 spin_unlock_irqrestore(&host->semaph_lock, flags);
972 host->act_tags[tmp->target]--;
973 if (tmp == host->first_busy) {
974 if ((host->first_busy = tmp->next) == NULL)
975 host->last_busy = NULL;
978 if (tmp == host->last_busy)
979 host->last_busy = prev;
987 (*tmp->post) ((u8 *) host, (u8 *) tmp);
988 spin_unlock_irqrestore(&host->semaph_lock, flags);
995 spin_unlock_irqrestore(&host->semaph_lock, flags);
1000 static int initio_bad_seq(struct initio_host * host)
1004 printk("initio_bad_seg c=%d\n", host->index);
1006 if ((scb = host->active) != NULL) {
1007 initio_unlink_busy_scb(host, scb);
1010 initio_append_done_scb(host, scb);
1012 initio_stop_bm(host);
1013 initio_reset_scsi(host, 8); /* 7/29/98 */
1014 return initio_post_scsi_rst(host);
1019 static void initio_exec_scb(struct initio_host * host, struct scsi_ctrl_blk * scb)
1028 spin_lock_irqsave(&host->semaph_lock, flags);
1030 initio_append_pend_scb(host, scb); /* Append this SCB to Pending queue */
1033 if (host->semaph == 1) {
1035 outb(0x1F, host->addr + TUL_Mask);
1036 host->semaph = 0;
1037 spin_unlock_irqrestore(&host->semaph_lock, flags);
1039 tulip_main(host);
1041 spin_lock_irqsave(&host->semaph_lock, flags);
1042 host->semaph = 1;
1043 outb(0x0F, host->addr + TUL_Mask);
1045 spin_unlock_irqrestore(&host->semaph_lock, flags);
1050 static int initio_isr(struct initio_host * host)
1052 if (inb(host->addr + TUL_Int) & TSS_INT_PENDING) {
1053 if (host->semaph == 1) {
1054 outb(0x1F, host->addr + TUL_Mask);
1056 host->semaph = 0;
1058 tulip_main(host);
1060 host->semaph = 1;
1061 outb(0x0F, host->addr + TUL_Mask);
1068 static int tulip_main(struct initio_host * host)
1073 tulip_scsi(host); /* Call tulip_scsi */
1076 while ((scb = initio_find_done_scb(host)) != NULL) { /* find done entry */
1078 host->max_tags[scb->target] =
1079 host->act_tags[scb->target] - 1;
1081 initio_append_pend_scb(host, scb);
1110 initio_push_pend_scb(host, scb);
1125 (*scb->post) ((u8 *) host, (u8 *) scb);
1129 if (inb(host->addr + TUL_SStatus0) & TSS_INT_PENDING)
1131 if (host->active) /* return to OS and wait for xfer_done_ISR/Selected_ISR */
1134 if (initio_find_first_pend_scb(host) == NULL)
1140 static void tulip_scsi(struct initio_host * host)
1146 if ((host->jsstatus0 = inb(host->addr + TUL_SStatus0)) & TSS_INT_PENDING) {
1147 host->phase = host->jsstatus0 & TSS_PH_MASK;
1148 host->jsstatus1 = inb(host->addr + TUL_SStatus1);
1149 host->jsint = inb(host->addr + TUL_SInt);
1150 if (host->jsint & TSS_SCSIRST_INT) { /* SCSI bus reset detected */
1151 int_initio_scsi_rst(host);
1154 if (host->jsint & TSS_RESEL_INT) { /* if selected/reselected interrupt */
1155 if (int_initio_resel(host) == 0)
1156 initio_next_state(host);
1159 if (host->jsint & TSS_SEL_TIMEOUT) {
1160 int_initio_busfree(host);
1163 if (host->jsint & TSS_DISC_INT) { /* BUS disconnection */
1164 int_initio_busfree(host); /* unexpected bus free or sel timeout */
1167 if (host->jsint & (TSS_FUNC_COMP | TSS_BUS_SERV)) { /* func complete or Bus service */
1168 if (host->active)
1169 initio_next_state(host);
1173 if (host->active != NULL)
1176 if ((scb = initio_find_first_pend_scb(host)) == NULL)
1180 outb((host->scsi_id << 4) | (scb->target & 0x0F),
1181 host->addr + TUL_SScsiId);
1183 active_tc = &host->targets[scb->target];
1190 outb(active_tc->js_period, host->addr + TUL_SPeriod);
1192 initio_select_atn_stop(host, scb);
1195 initio_select_atn_stop(host, scb);
1198 initio_select_atn3(host, scb);
1200 initio_select_atn(host, scb);
1204 while (wait_tulip(host) != -1) {
1205 if (initio_next_state(host) == -1)
1210 initio_select_atn_stop(host, scb);
1213 while (wait_tulip(host) != -1) {
1214 if (initio_next_state(host) == -1)
1219 if (initio_abort_srb(host, scb->srb) != 0) {
1220 initio_unlink_pend_scb(host, scb);
1221 initio_release_scb(host, scb);
1224 initio_select_atn_stop(host, scb);
1228 initio_unlink_pend_scb(host, scb);
1230 initio_append_done_scb(host, scb);
1237 * @host: InitIO host we are processing
1245 static int initio_next_state(struct initio_host * host)
1249 next = host->active->next_state;
1253 next = initio_state_1(host);
1256 next = initio_state_2(host);
1259 next = initio_state_3(host);
1262 next = initio_state_4(host);
1265 next = initio_state_5(host);
1268 next = initio_state_6(host);
1271 next = initio_state_7(host);
1274 return initio_bus_device_reset(host);
1276 return initio_bad_seq(host);
1286 * @host: InitIO host we are controlling
1291 static int initio_state_1(struct initio_host * host)
1293 struct scsi_ctrl_blk *scb = host->active;
1294 struct target_control *active_tc = host->active_tc;
1300 initio_unlink_pend_scb(host, scb);
1301 initio_append_busy_scb(host, scb);
1303 outb(active_tc->sconfig0, host->addr + TUL_SConfig );
1305 if (host->phase == MSG_OUT) {
1306 outb(TSC_EN_BUS_IN | TSC_HW_RESELECT, host->addr + TUL_SCtrl1);
1307 outb(scb->ident, host->addr + TUL_SFifo);
1310 outb(scb->tagmsg, host->addr + TUL_SFifo);
1311 outb(scb->tagid, host->addr + TUL_SFifo);
1315 outb(EXTENDED_MESSAGE, host->addr + TUL_SFifo);
1316 outb(2, host->addr + TUL_SFifo); /* Extended msg length */
1317 outb(EXTENDED_SDTR, host->addr + TUL_SFifo); /* Sync request */
1318 outb(1, host->addr + TUL_SFifo); /* Start from 16 bits */
1321 outb(EXTENDED_MESSAGE, host->addr + TUL_SFifo);
1322 outb(3, host->addr + TUL_SFifo); /* extended msg length */
1323 outb(EXTENDED_SDTR, host->addr + TUL_SFifo); /* sync request */
1324 outb(initio_rate_tbl[active_tc->flags & TCF_SCSI_RATE], host->addr + TUL_SFifo);
1325 outb(MAX_OFFSET, host->addr + TUL_SFifo); /* REQ/ACK offset */
1327 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
1328 if (wait_tulip(host) == -1)
1331 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0);
1332 outb((inb(host->addr + TUL_SSignal) & (TSC_SET_ACK | 7)), host->addr + TUL_SSignal);
1340 * @host: InitIO host we are controlling
1346 static int initio_state_2(struct initio_host * host)
1348 struct scsi_ctrl_blk *scb = host->active;
1349 struct target_control *active_tc = host->active_tc;
1354 initio_unlink_pend_scb(host, scb);
1355 initio_append_busy_scb(host, scb);
1357 outb(active_tc->sconfig0, host->addr + TUL_SConfig);
1359 if (host->jsstatus1 & TSS_CMD_PH_CMP)
1362 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0);
1363 outb((inb(host->addr + TUL_SSignal) & (TSC_SET_ACK | 7)), host->addr + TUL_SSignal);
1370 * @host: InitIO host we are controlling
1375 static int initio_state_3(struct initio_host * host)
1377 struct scsi_ctrl_blk *scb = host->active;
1378 struct target_control *active_tc = host->active_tc;
1385 switch (host->phase) {
1388 outb(scb->cdb[i], host->addr + TUL_SFifo);
1389 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
1390 if (wait_tulip(host) == -1)
1392 if (host->phase == CMD_OUT)
1393 return initio_bad_seq(host);
1398 if (initio_msgin(host) == -1)
1403 if (initio_status_msg(host) == -1)
1409 outb(NOP, host->addr + TUL_SFifo); /* msg nop */
1410 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
1411 if (wait_tulip(host) == -1)
1416 outb(EXTENDED_MESSAGE, host->addr + TUL_SFifo);
1417 outb(3, host->addr + TUL_SFifo); /* ext. msg len */
1418 outb(EXTENDED_SDTR, host->addr + TUL_SFifo); /* sync request */
1419 outb(initio_rate_tbl[active_tc->flags & TCF_SCSI_RATE], host->addr + TUL_SFifo);
1420 outb(MAX_OFFSET, host->addr + TUL_SFifo); /* REQ/ACK offset */
1421 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
1422 if (wait_tulip(host) == -1)
1424 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0);
1425 outb(inb(host->addr + TUL_SSignal) & (TSC_SET_ACK | 7), host->addr + TUL_SSignal);
1430 return initio_bad_seq(host);
1437 * @host: InitIO host we are controlling
1442 static int initio_state_4(struct initio_host * host)
1444 struct scsi_ctrl_blk *scb = host->active;
1456 switch (host->phase) {
1461 if ((initio_status_msg(host)) == -1)
1467 if (initio_msgin(host) == -1)
1472 if (host->jsstatus0 & TSS_PAR_ERROR) {
1475 if (initio_msgout_ide(host) == -1)
1479 outb(NOP, host->addr + TUL_SFifo); /* msg nop */
1480 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
1481 if (wait_tulip(host) == -1)
1487 return initio_xfer_data_in(host);
1490 return initio_xfer_data_out(host);
1493 return initio_bad_seq(host);
1501 * @host: InitIO host we are controlling
1506 static int initio_state_5(struct initio_host * host)
1508 struct scsi_ctrl_blk *scb = host->active;
1515 cnt = inl(host->addr + TUL_SCnt0) & 0x0FFFFFF;
1517 if (inb(host->addr + TUL_XCmd) & 0x20) {
1520 if (host->jsstatus0 & TSS_PAR_ERROR)
1522 if (inb(host->addr + TUL_XStatus) & XPEND) { /* DMA xfer pending, Send STOP */
1524 outb(inb(host->addr + TUL_XCtrl) | 0x80, host->addr + TUL_XCtrl);
1526 while (inb(host->addr + TUL_XStatus) & XPEND)
1531 if ((inb(host->addr + TUL_SStatus1) & TSS_XFER_CMP) == 0) {
1532 if (host->active_tc->js_period & TSC_WIDE_SCSI)
1533 cnt += (inb(host->addr + TUL_SFifoCnt) & 0x1F) << 1;
1535 cnt += (inb(host->addr + TUL_SFifoCnt) & 0x1F);
1537 if (inb(host->addr + TUL_XStatus) & XPEND) { /* if DMA xfer is pending, abort DMA xfer */
1538 outb(TAX_X_ABT, host->addr + TUL_XCmd);
1540 while ((inb(host->addr + TUL_Int) & XABT) == 0)
1543 if ((cnt == 1) && (host->phase == DATA_OUT)) {
1544 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
1545 if (wait_tulip(host) == -1)
1549 if ((inb(host->addr + TUL_SStatus1) & TSS_XFER_CMP) == 0)
1550 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0);
1590 * @host: InitIO host we are controlling
1595 static int initio_state_6(struct initio_host * host)
1597 struct scsi_ctrl_blk *scb = host->active;
1603 switch (host->phase) {
1605 if ((initio_status_msg(host)) == -1)
1611 if ((initio_msgin(host)) == -1)
1616 outb(NOP, host->addr + TUL_SFifo); /* msg nop */
1617 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
1618 if (wait_tulip(host) == -1)
1623 return initio_xpad_in(host);
1626 return initio_xpad_out(host);
1629 return initio_bad_seq(host);
1636 * @host: InitIO host we are controlling
1640 static int initio_state_7(struct initio_host * host)
1648 cnt = inb(host->addr + TUL_SFifoCnt) & 0x1F;
1651 inb(host->addr + TUL_SFifo);
1653 switch (host->phase) {
1656 return initio_bad_seq(host);
1664 * @host: InitIO host in use
1670 static int initio_xfer_data_in(struct initio_host * host)
1672 struct scsi_ctrl_blk *scb = host->active;
1677 outl(scb->buflen, host->addr + TUL_SCnt0);
1678 outb(TSC_XF_DMA_IN, host->addr + TUL_SCmd); /* 7/25/95 */
1681 outl(((u32) scb->sglen) << 3, host->addr + TUL_XCntH);
1682 outl(scb->bufptr, host->addr + TUL_XAddH);
1683 outb(TAX_SG_IN, host->addr + TUL_XCmd);
1685 outl(scb->buflen, host->addr + TUL_XCntH);
1686 outl(scb->bufptr, host->addr + TUL_XAddH);
1687 outb(TAX_X_IN, host->addr + TUL_XCmd);
1695 * @host: InitIO host in use
1702 static int initio_xfer_data_out(struct initio_host * host)
1704 struct scsi_ctrl_blk *scb = host->active;
1709 outl(scb->buflen, host->addr + TUL_SCnt0);
1710 outb(TSC_XF_DMA_OUT, host->addr + TUL_SCmd);
1713 outl(((u32) scb->sglen) << 3, host->addr + TUL_XCntH);
1714 outl(scb->bufptr, host->addr + TUL_XAddH);
1715 outb(TAX_SG_OUT, host->addr + TUL_XCmd);
1717 outl(scb->buflen, host->addr + TUL_XCntH);
1718 outl(scb->bufptr, host->addr + TUL_XAddH);
1719 outb(TAX_X_OUT, host->addr + TUL_XCmd);
1726 int initio_xpad_in(struct initio_host * host)
1728 struct scsi_ctrl_blk *scb = host->active;
1729 struct target_control *active_tc = host->active_tc;
1735 outl(2, host->addr + TUL_SCnt0);
1737 outl(1, host->addr + TUL_SCnt0);
1739 outb(TSC_XF_FIFO_IN, host->addr + TUL_SCmd);
1740 if (wait_tulip(host) == -1)
1742 if (host->phase != DATA_IN) {
1743 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0);
1746 inb(host->addr + TUL_SFifo);
1750 int initio_xpad_out(struct initio_host * host)
1752 struct scsi_ctrl_blk *scb = host->active;
1753 struct target_control *active_tc = host->active_tc;
1759 outl(2, host->addr + TUL_SCnt0);
1761 outl(1, host->addr + TUL_SCnt0);
1763 outb(0, host->addr + TUL_SFifo);
1764 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
1765 if ((wait_tulip(host)) == -1)
1767 if (host->phase != DATA_OUT) { /* Disable wide CPU to allow read 16 bits */
1768 outb(TSC_HW_RESELECT, host->addr + TUL_SCtrl1);
1769 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0);
1775 int initio_status_msg(struct initio_host * host)
1777 struct scsi_ctrl_blk *scb = host->active;
1780 outb(TSC_CMD_COMP, host->addr + TUL_SCmd);
1781 if (wait_tulip(host) == -1)
1785 scb->tastat = inb(host->addr + TUL_SFifo);
1787 if (host->phase == MSG_OUT) {
1788 if (host->jsstatus0 & TSS_PAR_ERROR)
1789 outb(MSG_PARITY_ERROR, host->addr + TUL_SFifo);
1791 outb(NOP, host->addr + TUL_SFifo);
1792 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
1793 return wait_tulip(host);
1795 if (host->phase == MSG_IN) {
1796 msg = inb(host->addr + TUL_SFifo);
1797 if (host->jsstatus0 & TSS_PAR_ERROR) { /* Parity error */
1798 if ((initio_msgin_accept(host)) == -1)
1800 if (host->phase != MSG_OUT)
1801 return initio_bad_seq(host);
1802 outb(MSG_PARITY_ERROR, host->addr + TUL_SFifo);
1803 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
1804 return wait_tulip(host);
1809 return initio_bad_seq(host);
1810 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0);
1811 outb(TSC_MSG_ACCEPT, host->addr + TUL_SCmd);
1812 return initio_wait_done_disc(host);
1818 return initio_msgin_accept(host);
1821 return initio_bad_seq(host);
1826 int int_initio_busfree(struct initio_host * host)
1828 struct scsi_ctrl_blk *scb = host->active;
1832 initio_unlink_pend_scb(host, scb);
1834 initio_append_done_scb(host, scb);
1836 initio_unlink_busy_scb(host, scb);
1838 initio_append_done_scb(host, scb);
1840 host->active = NULL;
1841 host->active_tc = NULL;
1843 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0); /* Flush SCSI FIFO */
1844 outb(TSC_INITDEFAULT, host->addr + TUL_SConfig);
1845 outb(TSC_HW_RESELECT, host->addr + TUL_SCtrl1); /* Enable HW reselect */
1852 * @host: Host seeing the reset
1860 static int int_initio_scsi_rst(struct initio_host * host)
1866 if (inb(host->addr + TUL_XStatus) & 0x01) {
1867 outb(TAX_X_ABT | TAX_X_CLR_FIFO, host->addr + TUL_XCmd);
1869 while ((inb(host->addr + TUL_Int) & 0x04) == 0)
1871 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0);
1874 while ((scb = initio_pop_busy_scb(host)) != NULL) {
1876 initio_append_done_scb(host, scb);
1878 host->active = NULL;
1879 host->active_tc = NULL;
1882 for (i = 0; i < host->max_tar; i++)
1883 host->targets[i].flags &= ~(TCF_SYNC_DONE | TCF_WDTR_DONE);
1889 * @host: InitIO host adapter
1896 int int_initio_resel(struct initio_host * host)
1903 if ((scb = host->active) != NULL) {
1907 host->active = NULL;
1910 tar = inb(host->addr + TUL_SBusId);
1912 lun = inb(host->addr + TUL_SIdent) & 0x0F;
1914 active_tc = &host->targets[tar];
1915 host->active_tc = active_tc;
1916 outb(active_tc->sconfig0, host->addr + TUL_SConfig);
1917 outb(active_tc->js_period, host->addr + TUL_SPeriod);
1921 if ((initio_msgin_accept(host)) == -1)
1923 if (host->phase != MSG_IN)
1925 outl(1, host->addr + TUL_SCnt0);
1926 outb(TSC_XF_FIFO_IN, host->addr + TUL_SCmd);
1927 if (wait_tulip(host) == -1)
1929 msg = inb(host->addr + TUL_SFifo); /* Read Tag Message */
1935 if (initio_msgin_accept(host) == -1)
1938 if (host->phase != MSG_IN)
1941 outl(1, host->addr + TUL_SCnt0);
1942 outb(TSC_XF_FIFO_IN, host->addr + TUL_SCmd);
1943 if (wait_tulip(host) == -1)
1945 tag = inb(host->addr + TUL_SFifo); /* Read Tag ID */
1946 scb = host->scb + tag;
1948 return initio_msgout_abort_tag(host);
1951 return initio_msgout_abort_tag(host);
1953 host->active = scb;
1954 if ((initio_msgin_accept(host)) == -1)
1958 if ((scb = initio_find_busy_scb(host, tar | (lun << 8))) == NULL) {
1959 return initio_msgout_abort_targ(host);
1961 host->active = scb;
1963 if ((initio_msgin_accept(host)) == -1)
1972 * @host: InitIO host flagging event
1974 * We have ended up out of phase somehow. Reset the host controller
1978 static int int_initio_bad_seq(struct initio_host * host)
1983 initio_reset_scsi(host, 10);
1985 while ((scb = initio_pop_busy_scb(host)) != NULL) {
1987 initio_append_done_scb(host, scb);
1989 for (i = 0; i < host->max_tar; i++)
1990 host->targets[i].flags &= ~(TCF_SYNC_DONE | TCF_WDTR_DONE);
1997 * @host: InitIO host
2003 static int initio_msgout_abort_targ(struct initio_host * host)
2006 outb(((inb(host->addr + TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN), host->addr + TUL_SSignal);
2007 if (initio_msgin_accept(host) == -1)
2009 if (host->phase != MSG_OUT)
2010 return initio_bad_seq(host);
2012 outb(ABORT_TASK_SET, host->addr + TUL_SFifo);
2013 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
2015 return initio_wait_disc(host);
2020 * @host: InitIO host
2026 static int initio_msgout_abort_tag(struct initio_host * host)
2029 outb(((inb(host->addr + TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN), host->addr + TUL_SSignal);
2030 if (initio_msgin_accept(host) == -1)
2032 if (host->phase != MSG_OUT)
2033 return initio_bad_seq(host);
2035 outb(ABORT_TASK, host->addr + TUL_SFifo);
2036 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
2038 return initio_wait_disc(host);
2044 * @host: InitIO Host
2048 static int initio_msgin(struct initio_host * host)
2053 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0);
2055 outl(1, host->addr + TUL_SCnt0);
2056 outb(TSC_XF_FIFO_IN, host->addr + TUL_SCmd);
2057 if (wait_tulip(host) == -1)
2060 switch (inb(host->addr + TUL_SFifo)) {
2062 outb(TSC_MSG_ACCEPT, host->addr + TUL_SCmd);
2063 return initio_wait_disc(host);
2067 initio_msgin_accept(host);
2070 outb((inb(host->addr + TUL_SSignal) & (TSC_SET_ACK | 7)),
2071 host->addr + TUL_SSignal);
2072 active_tc = host->active_tc;
2074 outb(((inb(host->addr + TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN),
2075 host->addr + TUL_SSignal);
2076 initio_msgin_accept(host);
2079 initio_msgin_extend(host);
2082 initio_msgin_accept(host);
2085 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0);
2086 outb(TSC_MSG_ACCEPT, host->addr + TUL_SCmd);
2087 return initio_wait_done_disc(host);
2089 initio_msgout_reject(host);
2092 if (host->phase != MSG_IN)
2093 return host->phase;
2098 static int initio_msgout_reject(struct initio_host * host)
2100 outb(((inb(host->addr + TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN), host->addr + TUL_SSignal);
2102 if (initio_msgin_accept(host) == -1)
2105 if (host->phase == MSG_OUT) {
2106 outb(MESSAGE_REJECT, host->addr + TUL_SFifo); /* Msg reject */
2107 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
2108 return wait_tulip(host);
2110 return host->phase;
2113 static int initio_msgout_ide(struct initio_host * host)
2115 outb(INITIATOR_ERROR, host->addr + TUL_SFifo); /* Initiator Detected Error */
2116 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
2117 return wait_tulip(host);
2120 static int initio_msgin_extend(struct initio_host * host)
2124 if (initio_msgin_accept(host) != MSG_IN)
2125 return host->phase;
2128 outl(1, host->addr + TUL_SCnt0);
2129 outb(TSC_XF_FIFO_IN, host->addr + TUL_SCmd);
2130 if (wait_tulip(host) == -1)
2133 len = inb(host->addr + TUL_SFifo);
2134 host->msg[0] = len;
2137 if ((initio_msgin_accept(host)) != MSG_IN)
2138 return host->phase;
2139 outl(1, host->addr + TUL_SCnt0);
2140 outb(TSC_XF_FIFO_IN, host->addr + TUL_SCmd);
2141 if (wait_tulip(host) == -1)
2143 host->msg[idx++] = inb(host->addr + TUL_SFifo);
2145 if (host->msg[1] == 1) { /* if it's synchronous data transfer request */
2147 if (host->msg[0] != 3) /* if length is not right */
2148 return initio_msgout_reject(host);
2149 if (host->active_tc->flags & TCF_NO_SYNC_NEGO) { /* Set OFFSET=0 to do async, nego back */
2150 host->msg[3] = 0;
2152 if (initio_msgin_sync(host) == 0 &&
2153 (host->active_tc->flags & TCF_SYNC_DONE)) {
2154 initio_sync_done(host);
2155 return initio_msgin_accept(host);
2159 r = inb(host->addr + TUL_SSignal);
2161 host->addr + TUL_SSignal);
2162 if (initio_msgin_accept(host) != MSG_OUT)
2163 return host->phase;
2165 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0);
2167 initio_sync_done(host);
2169 outb(EXTENDED_MESSAGE, host->addr + TUL_SFifo);
2170 outb(3, host->addr + TUL_SFifo);
2171 outb(EXTENDED_SDTR, host->addr + TUL_SFifo);
2172 outb(host->msg[2], host->addr + TUL_SFifo);
2173 outb(host->msg[3], host->addr + TUL_SFifo);
2174 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
2175 return wait_tulip(host);
2177 if (host->msg[0] != 2 || host->msg[1] != 3)
2178 return initio_msgout_reject(host);
2180 if (host->active_tc->flags & TCF_NO_WDTR) {
2181 host->msg[2] = 0;
2183 if (host->msg[2] > 2) /* > 32 bits */
2184 return initio_msgout_reject(host);
2185 if (host->msg[2] == 2) { /* == 32 */
2186 host->msg[2] = 1;
2188 if ((host->active_tc->flags & TCF_NO_WDTR) == 0) {
2189 wdtr_done(host);
2190 if ((host->active_tc->flags & (TCF_SYNC_DONE | TCF_NO_SYNC_NEGO)) == 0)
2191 outb(((inb(host->addr + TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN), host->addr + TUL_SSignal);
2192 return initio_msgin_accept(host);
2196 outb(((inb(host->addr + TUL_SSignal) & (TSC_SET_ACK | 7)) | TSC_SET_ATN), host->addr + TUL_SSignal);
2198 if (initio_msgin_accept(host) != MSG_OUT)
2199 return host->phase;
2201 outb(EXTENDED_MESSAGE, host->addr + TUL_SFifo);
2202 outb(2, host->addr + TUL_SFifo);
2203 outb(EXTENDED_WDTR, host->addr + TUL_SFifo);
2204 outb(host->msg[2], host->addr + TUL_SFifo);
2205 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
2206 return wait_tulip(host);
2209 static int initio_msgin_sync(struct initio_host * host)
2213 default_period = initio_rate_tbl[host->active_tc->flags & TCF_SCSI_RATE];
2214 if (host->msg[3] > MAX_OFFSET) {
2215 host->msg[3] = MAX_OFFSET;
2216 if (host->msg[2] < default_period) {
2217 host->msg[2] = default_period;
2220 if (host->msg[2] >= 59) /* Change to async */
2221 host->msg[3] = 0;
2225 if (host->msg[3] == 0) {
2228 if (host->msg[2] < default_period) {
2229 host->msg[2] = default_period;
2232 if (host->msg[2] >= 59) {
2233 host->msg[3] = 0;
2239 static int wdtr_done(struct initio_host * host)
2241 host->active_tc->flags &= ~TCF_SYNC_DONE;
2242 host->active_tc->flags |= TCF_WDTR_DONE;
2244 host->active_tc->js_period = 0;
2245 if (host->msg[2]) /* if 16 bit */
2246 host->active_tc->js_period |= TSC_WIDE_SCSI;
2247 host->active_tc->sconfig0 &= ~TSC_ALT_PERIOD;
2248 outb(host->active_tc->sconfig0, host->addr + TUL_SConfig);
2249 outb(host->active_tc->js_period, host->addr + TUL_SPeriod);
2254 static int initio_sync_done(struct initio_host * host)
2258 host->active_tc->flags |= TCF_SYNC_DONE;
2260 if (host->msg[3]) {
2261 host->active_tc->js_period |= host->msg[3];
2263 if (initio_rate_tbl[i] >= host->msg[2]) /* pick the big one */
2266 host->active_tc->js_period |= (i << 4);
2267 host->active_tc->sconfig0 |= TSC_ALT_PERIOD;
2269 outb(host->active_tc->sconfig0, host->addr + TUL_SConfig);
2270 outb(host->active_tc->js_period, host->addr + TUL_SPeriod);
2276 static int initio_post_scsi_rst(struct initio_host * host)
2282 host->active = NULL;
2283 host->active_tc = NULL;
2284 host->flags = 0;
2286 while ((scb = initio_pop_busy_scb(host)) != NULL) {
2288 initio_append_done_scb(host, scb);
2291 active_tc = &host->targets[0];
2292 for (i = 0; i < host->max_tar; active_tc++, i++) {
2296 active_tc->sconfig0 = host->sconf1;
2297 host->act_tags[0] = 0; /* 07/22/98 */
2298 host->targets[i].flags &= ~TCF_BUSY; /* 07/22/98 */
2304 static void initio_select_atn_stop(struct initio_host * host, struct scsi_ctrl_blk * scb)
2308 host->active = scb;
2309 host->active_tc = &host->targets[scb->target];
2310 outb(TSC_SELATNSTOP, host->addr + TUL_SCmd);
2314 static void initio_select_atn(struct initio_host * host, struct scsi_ctrl_blk * scb)
2321 outb(scb->ident, host->addr + TUL_SFifo);
2323 outb(scb->cdb[i], host->addr + TUL_SFifo);
2324 host->active_tc = &host->targets[scb->target];
2325 host->active = scb;
2326 outb(TSC_SEL_ATN, host->addr + TUL_SCmd);
2329 static void initio_select_atn3(struct initio_host * host, struct scsi_ctrl_blk * scb)
2336 outb(scb->ident, host->addr + TUL_SFifo);
2337 outb(scb->tagmsg, host->addr + TUL_SFifo);
2338 outb(scb->tagid, host->addr + TUL_SFifo);
2340 outb(scb->cdb[i], host->addr + TUL_SFifo);
2341 host->active_tc = &host->targets[scb->target];
2342 host->active = scb;
2343 outb(TSC_SEL_ATN3, host->addr + TUL_SCmd);
2348 * @host: InitIO host to reset
2353 int initio_bus_device_reset(struct initio_host * host)
2355 struct scsi_ctrl_blk *scb = host->active;
2356 struct target_control *active_tc = host->active_tc;
2360 if (host->phase != MSG_OUT)
2361 return int_initio_bad_seq(host); /* Unexpected phase */
2363 initio_unlink_pend_scb(host, scb);
2364 initio_release_scb(host, scb);
2372 prev = tmp = host->first_busy; /* Check Busy queue */
2376 if (tmp == host->first_busy) {
2377 if ((host->first_busy = tmp->next) == NULL)
2378 host->last_busy = NULL;
2381 if (tmp == host->last_busy)
2382 host->last_busy = prev;
2385 initio_append_done_scb(host, tmp);
2393 outb(TARGET_RESET, host->addr + TUL_SFifo);
2394 outb(TSC_XF_FIFO_OUT, host->addr + TUL_SCmd);
2395 return initio_wait_disc(host);
2399 static int initio_msgin_accept(struct initio_host * host)
2401 outb(TSC_MSG_ACCEPT, host->addr + TUL_SCmd);
2402 return wait_tulip(host);
2405 static int wait_tulip(struct initio_host * host)
2408 while (!((host->jsstatus0 = inb(host->addr + TUL_SStatus0))
2412 host->jsint = inb(host->addr + TUL_SInt);
2413 host->phase = host->jsstatus0 & TSS_PH_MASK;
2414 host->jsstatus1 = inb(host->addr + TUL_SStatus1);
2416 if (host->jsint & TSS_RESEL_INT) /* if SCSI bus reset detected */
2417 return int_initio_resel(host);
2418 if (host->jsint & TSS_SEL_TIMEOUT) /* if selected/reselected timeout interrupt */
2419 return int_initio_busfree(host);
2420 if (host->jsint & TSS_SCSIRST_INT) /* if SCSI bus reset detected */
2421 return int_initio_scsi_rst(host);
2423 if (host->jsint & TSS_DISC_INT) { /* BUS disconnection */
2424 if (host->flags & HCF_EXPECT_DONE_DISC) {
2425 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0); /* Flush SCSI FIFO */
2426 initio_unlink_busy_scb(host, host->active);
2427 host->active->hastat = 0;
2428 initio_append_done_scb(host, host->active);
2429 host->active = NULL;
2430 host->active_tc = NULL;
2431 host->flags &= ~HCF_EXPECT_DONE_DISC;
2432 outb(TSC_INITDEFAULT, host->addr + TUL_SConfig);
2433 outb(TSC_HW_RESELECT, host->addr + TUL_SCtrl1); /* Enable HW reselect */
2436 if (host->flags & HCF_EXPECT_DISC) {
2437 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0); /* Flush SCSI FIFO */
2438 host->active = NULL;
2439 host->active_tc = NULL;
2440 host->flags &= ~HCF_EXPECT_DISC;
2441 outb(TSC_INITDEFAULT, host->addr + TUL_SConfig);
2442 outb(TSC_HW_RESELECT, host->addr + TUL_SCtrl1); /* Enable HW reselect */
2445 return int_initio_busfree(host);
2448 if (host->jsint & (TSS_FUNC_COMP | TSS_BUS_SERV))
2449 return host->phase;
2450 return host->phase;
2453 static int initio_wait_disc(struct initio_host * host)
2455 while (!((host->jsstatus0 = inb(host->addr + TUL_SStatus0)) & TSS_INT_PENDING))
2458 host->jsint = inb(host->addr + TUL_SInt);
2460 if (host->jsint & TSS_SCSIRST_INT) /* if SCSI bus reset detected */
2461 return int_initio_scsi_rst(host);
2462 if (host->jsint & TSS_DISC_INT) { /* BUS disconnection */
2463 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0); /* Flush SCSI FIFO */
2464 outb(TSC_INITDEFAULT, host->addr + TUL_SConfig);
2465 outb(TSC_HW_RESELECT, host->addr + TUL_SCtrl1); /* Enable HW reselect */
2466 host->active = NULL;
2469 return initio_bad_seq(host);
2472 static int initio_wait_done_disc(struct initio_host * host)
2474 while (!((host->jsstatus0 = inb(host->addr + TUL_SStatus0))
2478 host->jsint = inb(host->addr + TUL_SInt);
2480 if (host->jsint & TSS_SCSIRST_INT) /* if SCSI bus reset detected */
2481 return int_initio_scsi_rst(host);
2482 if (host->jsint & TSS_DISC_INT) { /* BUS disconnection */
2483 outb(TSC_FLUSH_FIFO, host->addr + TUL_SCtrl0); /* Flush SCSI FIFO */
2484 outb(TSC_INITDEFAULT, host->addr + TUL_SConfig);
2485 outb(TSC_HW_RESELECT, host->addr + TUL_SCtrl1); /* Enable HW reselect */
2486 initio_unlink_busy_scb(host, host->active);
2488 initio_append_done_scb(host, host->active);
2489 host->active = NULL;
2492 return initio_bad_seq(host);
2522 * @host: InitIO host taking the command
2527 * suitable for feeding to the InitIO host controller. This also requires
2531 static void initio_build_scb(struct initio_host * host, struct scsi_ctrl_blk * cblk, struct scsi_cmnd * cmnd)
2551 dma_addr = dma_map_single(&host->pci_dev->dev, cmnd->sense_buffer,
2575 dma_addr = dma_map_single(&host->pci_dev->dev, &cblk->sglist[0],
2605 * Attempts to queue a new command with the host adapter. Will return
2606 * zero if successful or indicate a host busy condition if not (which
2611 struct initio_host *host = (struct initio_host *) cmd->device->host->hostdata;
2614 cmnd = initio_alloc_scb(host);
2618 initio_build_scb(host, cmnd, cmd);
2619 initio_exec_scb(host, cmnd);
2634 struct initio_host *host;
2636 host = (struct initio_host *) cmnd->device->host->hostdata;
2638 spin_lock_irq(cmnd->device->host->host_lock);
2639 initio_reset_scsi(host, 0);
2640 spin_unlock_irq(cmnd->device->host->host_lock);
2652 * Map the device geometry in a manner compatible with the host
2661 struct initio_host *host; /* Point to Host adapter control block */
2664 host = (struct initio_host *) sdev->host->hostdata;
2665 tc = &host->targets[sdev->id];
2734 struct initio_host *host;
2737 host = (struct initio_host *) host_mem;
2742 initio_release_scb(host, cblk); /* Release SCB for current channel */
2762 phase sequence was requested by the target. The host adapter
2763 will generate a SCSI Reset Condition, notifying the host with
2785 i91u_unmap_scb(host->pci_dev, cmnd);
2787 initio_release_scb(host, cblk); /* Release SCB for current channel */
2806 struct initio_host *host;
2829 printk(KERN_WARNING "initio: Could not allocate host structure.\n");
2833 host = (struct initio_host *)shost->hostdata;
2834 memset(host, 0, sizeof(struct initio_host));
2835 host->addr = pci_resource_start(pdev, 0);
2836 host->bios_addr = bios_seg;
2838 if (!request_region(host->addr, 256, "i91u")) {
2839 printk(KERN_WARNING "initio: I/O port range 0x%x is busy.\n", host->addr);
2862 host->pci_dev = pdev;
2864 host->semaph = 1;
2865 spin_lock_init(&host->semaph_lock);
2866 host->num_scbs = num_scb;
2867 host->scb = scb;
2868 host->next_pending = scb;
2869 host->next_avail = scb;
2877 host->scb_end = tmp;
2878 host->first_avail = scb;
2879 host->last_avail = prev;
2880 spin_lock_init(&host->avail_lock);
2882 initio_init(host, phys_to_virt(((u32)bios_seg << 4)));
2884 host->jsstatus0 = 0;
2886 shost->io_port = host->addr;
2889 shost->unique_id = host->addr;
2890 shost->max_id = host->max_tar;
2893 shost->this_id = host->scsi_id; /* Assign HCS index */
2894 shost->base = host->addr;
2913 kfree(host->scb);
2915 release_region(host->addr, 256);
2933 struct Scsi_Host *host = pci_get_drvdata(pdev);
2934 struct initio_host *s = (struct initio_host *)host->hostdata;
2935 scsi_remove_host(host);
2936 free_irq(pdev->irq, host);
2938 scsi_host_put(host);