Lines Matching refs:ahc
134 static void ahc_force_renegotiation(struct ahc_softc *ahc,
137 ahc_alloc_tstate(struct ahc_softc *ahc,
140 static void ahc_free_tstate(struct ahc_softc *ahc,
144 ahc_devlimited_syncrate(struct ahc_softc *ahc,
149 static void ahc_update_pending_scbs(struct ahc_softc *ahc);
150 static void ahc_fetch_devinfo(struct ahc_softc *ahc,
152 static void ahc_scb_devinfo(struct ahc_softc *ahc,
155 static void ahc_assert_atn(struct ahc_softc *ahc);
156 static void ahc_setup_initiator_msgout(struct ahc_softc *ahc,
159 static void ahc_build_transfer_msg(struct ahc_softc *ahc,
161 static void ahc_construct_sdtr(struct ahc_softc *ahc,
164 static void ahc_construct_wdtr(struct ahc_softc *ahc,
167 static void ahc_construct_ppr(struct ahc_softc *ahc,
171 static void ahc_clear_msg_state(struct ahc_softc *ahc);
172 static void ahc_handle_proto_violation(struct ahc_softc *ahc);
173 static void ahc_handle_message_phase(struct ahc_softc *ahc);
179 static int ahc_sent_msg(struct ahc_softc *ahc, ahc_msgtype type,
181 static int ahc_parse_msg(struct ahc_softc *ahc,
183 static int ahc_handle_msg_reject(struct ahc_softc *ahc,
185 static void ahc_handle_ign_wide_residue(struct ahc_softc *ahc,
187 static void ahc_reinitialize_dataptrs(struct ahc_softc *ahc);
188 static void ahc_handle_devreset(struct ahc_softc *ahc,
193 static void ahc_setup_target_msgin(struct ahc_softc *ahc,
199 static void ahc_build_free_scb_list(struct ahc_softc *ahc);
200 static int ahc_init_scbdata(struct ahc_softc *ahc);
201 static void ahc_fini_scbdata(struct ahc_softc *ahc);
202 static void ahc_qinfifo_requeue(struct ahc_softc *ahc,
205 static int ahc_qinfifo_count(struct ahc_softc *ahc);
206 static u_int ahc_rem_scb_from_disc_list(struct ahc_softc *ahc,
208 static void ahc_add_curscb_to_free_list(struct ahc_softc *ahc);
209 static u_int ahc_rem_wscb(struct ahc_softc *ahc,
211 static void ahc_reset_current_bus(struct ahc_softc *ahc);
213 static void ahc_dumpseq(struct ahc_softc *ahc);
215 static int ahc_loadseq(struct ahc_softc *ahc);
216 static int ahc_check_patch(struct ahc_softc *ahc,
219 static void ahc_download_instr(struct ahc_softc *ahc,
222 static void ahc_queue_lstate_event(struct ahc_softc *ahc,
227 static void ahc_update_scsiid(struct ahc_softc *ahc,
229 static int ahc_handle_target_cmd(struct ahc_softc *ahc,
233 static u_int ahc_index_busy_tcl(struct ahc_softc *ahc, u_int tcl);
234 static void ahc_unbusy_tcl(struct ahc_softc *ahc, u_int tcl);
235 static void ahc_busy_tcl(struct ahc_softc *ahc,
239 static void ahc_run_untagged_queues(struct ahc_softc *ahc);
240 static void ahc_run_untagged_queue(struct ahc_softc *ahc,
244 static void ahc_alloc_scbs(struct ahc_softc *ahc);
248 static void ahc_clear_intstat(struct ahc_softc *ahc);
249 static void ahc_run_qoutfifo(struct ahc_softc *ahc);
251 static void ahc_run_tqinfifo(struct ahc_softc *ahc, int paused);
253 static void ahc_handle_brkadrint(struct ahc_softc *ahc);
254 static void ahc_handle_seqint(struct ahc_softc *ahc, u_int intstat);
255 static void ahc_handle_scsiint(struct ahc_softc *ahc,
257 static void ahc_clear_critical_section(struct ahc_softc *ahc);
260 static void ahc_freeze_devq(struct ahc_softc *ahc, struct scb *scb);
261 static int ahc_abort_scbs(struct ahc_softc *ahc, int target,
264 static void ahc_calc_residual(struct ahc_softc *ahc,
268 static inline void ahc_freeze_untagged_queues(struct ahc_softc *ahc);
269 static inline void ahc_release_untagged_queues(struct ahc_softc *ahc);
276 ahc_freeze_untagged_queues(struct ahc_softc *ahc) in ahc_freeze_untagged_queues() argument
278 if ((ahc->flags & AHC_SCB_BTT) == 0) in ahc_freeze_untagged_queues()
279 ahc->untagged_queue_lock++; in ahc_freeze_untagged_queues()
289 ahc_release_untagged_queues(struct ahc_softc *ahc) in ahc_release_untagged_queues() argument
291 if ((ahc->flags & AHC_SCB_BTT) == 0) { in ahc_release_untagged_queues()
292 ahc->untagged_queue_lock--; in ahc_release_untagged_queues()
293 if (ahc->untagged_queue_lock == 0) in ahc_release_untagged_queues()
294 ahc_run_untagged_queues(ahc); in ahc_release_untagged_queues()
308 ahc_pause_bug_fix(struct ahc_softc *ahc) in ahc_pause_bug_fix() argument
310 if ((ahc->features & AHC_ULTRA2) != 0) in ahc_pause_bug_fix()
311 (void)ahc_inb(ahc, CCSCBCTL); in ahc_pause_bug_fix()
319 ahc_is_paused(struct ahc_softc *ahc) in ahc_is_paused() argument
321 return ((ahc_inb(ahc, HCNTRL) & PAUSE) != 0); in ahc_is_paused()
332 ahc_pause(struct ahc_softc *ahc) in ahc_pause() argument
334 ahc_outb(ahc, HCNTRL, ahc->pause); in ahc_pause()
340 while (ahc_is_paused(ahc) == 0) in ahc_pause()
343 ahc_pause_bug_fix(ahc); in ahc_pause()
357 ahc_unpause(struct ahc_softc *ahc) in ahc_unpause() argument
359 if ((ahc_inb(ahc, INTSTAT) & (SCSIINT | SEQINT | BRKADRINT)) == 0) in ahc_unpause()
360 ahc_outb(ahc, HCNTRL, ahc->unpause); in ahc_unpause()
388 ahc_hscb_busaddr(struct ahc_softc *ahc, u_int index) in ahc_hscb_busaddr() argument
390 return (ahc->scb_data->hscb_busaddr in ahc_hscb_busaddr()
395 ahc_sync_scb(struct ahc_softc *ahc, struct scb *scb, int op) in ahc_sync_scb() argument
397 ahc_dmamap_sync(ahc, ahc->scb_data->hscb_dmat, in ahc_sync_scb()
398 ahc->scb_data->hscb_dmamap, in ahc_sync_scb()
399 /*offset*/(scb->hscb - ahc->hscbs) * sizeof(*scb->hscb), in ahc_sync_scb()
404 ahc_sync_sglist(struct ahc_softc *ahc, struct scb *scb, int op) in ahc_sync_sglist() argument
409 ahc_dmamap_sync(ahc, ahc->scb_data->sg_dmat, scb->sg_map->sg_dmamap, in ahc_sync_sglist()
417 ahc_targetcmd_offset(struct ahc_softc *ahc, u_int index) in ahc_targetcmd_offset() argument
419 return (((uint8_t *)&ahc->targetcmds[index]) - ahc->qoutfifo); in ahc_targetcmd_offset()
429 ahc_update_residual(struct ahc_softc *ahc, struct scb *scb) in ahc_update_residual() argument
435 ahc_calc_residual(ahc, scb); in ahc_update_residual()
443 ahc_fetch_transinfo(struct ahc_softc *ahc, char channel, u_int our_id, in ahc_fetch_transinfo() argument
454 *tstate = ahc->enabled_targets[our_id]; in ahc_fetch_transinfo()
459 ahc_inw(struct ahc_softc *ahc, u_int port) in ahc_inw() argument
461 uint16_t r = ahc_inb(ahc, port+1) << 8; in ahc_inw()
462 return r | ahc_inb(ahc, port); in ahc_inw()
466 ahc_outw(struct ahc_softc *ahc, u_int port, u_int value) in ahc_outw() argument
468 ahc_outb(ahc, port, value & 0xFF); in ahc_outw()
469 ahc_outb(ahc, port+1, (value >> 8) & 0xFF); in ahc_outw()
473 ahc_inl(struct ahc_softc *ahc, u_int port) in ahc_inl() argument
475 return ((ahc_inb(ahc, port)) in ahc_inl()
476 | (ahc_inb(ahc, port+1) << 8) in ahc_inl()
477 | (ahc_inb(ahc, port+2) << 16) in ahc_inl()
478 | (ahc_inb(ahc, port+3) << 24)); in ahc_inl()
482 ahc_outl(struct ahc_softc *ahc, u_int port, uint32_t value) in ahc_outl() argument
484 ahc_outb(ahc, port, (value) & 0xFF); in ahc_outl()
485 ahc_outb(ahc, port+1, ((value) >> 8) & 0xFF); in ahc_outl()
486 ahc_outb(ahc, port+2, ((value) >> 16) & 0xFF); in ahc_outl()
487 ahc_outb(ahc, port+3, ((value) >> 24) & 0xFF); in ahc_outl()
491 ahc_inq(struct ahc_softc *ahc, u_int port) in ahc_inq() argument
493 return ((ahc_inb(ahc, port)) in ahc_inq()
494 | (ahc_inb(ahc, port+1) << 8) in ahc_inq()
495 | (ahc_inb(ahc, port+2) << 16) in ahc_inq()
496 | (((uint64_t)ahc_inb(ahc, port+3)) << 24) in ahc_inq()
497 | (((uint64_t)ahc_inb(ahc, port+4)) << 32) in ahc_inq()
498 | (((uint64_t)ahc_inb(ahc, port+5)) << 40) in ahc_inq()
499 | (((uint64_t)ahc_inb(ahc, port+6)) << 48) in ahc_inq()
500 | (((uint64_t)ahc_inb(ahc, port+7)) << 56)); in ahc_inq()
504 ahc_outq(struct ahc_softc *ahc, u_int port, uint64_t value) in ahc_outq() argument
506 ahc_outb(ahc, port, value & 0xFF); in ahc_outq()
507 ahc_outb(ahc, port+1, (value >> 8) & 0xFF); in ahc_outq()
508 ahc_outb(ahc, port+2, (value >> 16) & 0xFF); in ahc_outq()
509 ahc_outb(ahc, port+3, (value >> 24) & 0xFF); in ahc_outq()
510 ahc_outb(ahc, port+4, (value >> 32) & 0xFF); in ahc_outq()
511 ahc_outb(ahc, port+5, (value >> 40) & 0xFF); in ahc_outq()
512 ahc_outb(ahc, port+6, (value >> 48) & 0xFF); in ahc_outq()
513 ahc_outb(ahc, port+7, (value >> 56) & 0xFF); in ahc_outq()
520 ahc_get_scb(struct ahc_softc *ahc) in ahc_get_scb() argument
524 if ((scb = SLIST_FIRST(&ahc->scb_data->free_scbs)) == NULL) { in ahc_get_scb()
525 ahc_alloc_scbs(ahc); in ahc_get_scb()
526 scb = SLIST_FIRST(&ahc->scb_data->free_scbs); in ahc_get_scb()
530 SLIST_REMOVE_HEAD(&ahc->scb_data->free_scbs, links.sle); in ahc_get_scb()
538 ahc_free_scb(struct ahc_softc *ahc, struct scb *scb) in ahc_free_scb() argument
544 ahc->scb_data->scbindex[hscb->tag] = NULL; in ahc_free_scb()
548 SLIST_INSERT_HEAD(&ahc->scb_data->free_scbs, scb, links.sle); in ahc_free_scb()
551 ahc_platform_scb_free(ahc, scb); in ahc_free_scb()
555 ahc_lookup_scb(struct ahc_softc *ahc, u_int tag) in ahc_lookup_scb() argument
559 scb = ahc->scb_data->scbindex[tag]; in ahc_lookup_scb()
561 ahc_sync_scb(ahc, scb, in ahc_lookup_scb()
567 ahc_swap_with_next_hscb(struct ahc_softc *ahc, struct scb *scb) in ahc_swap_with_next_hscb() argument
584 q_hscb = ahc->next_queued_scb->hscb; in ahc_swap_with_next_hscb()
589 ahc_htole32(ahc_hscb_busaddr(ahc, q_hscb->tag) in ahc_swap_with_next_hscb()
596 ahc->next_queued_scb->hscb = scb->hscb; in ahc_swap_with_next_hscb()
600 ahc->scb_data->scbindex[scb->hscb->tag] = scb; in ahc_swap_with_next_hscb()
607 ahc_queue_scb(struct ahc_softc *ahc, struct scb *scb) in ahc_queue_scb() argument
609 ahc_swap_with_next_hscb(ahc, scb); in ahc_queue_scb()
626 ahc->qinfifo[ahc->qinfifonext++] = scb->hscb->tag; in ahc_queue_scb()
632 ahc_sync_scb(ahc, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); in ahc_queue_scb()
635 if ((ahc->features & AHC_QUEUE_REGS) != 0) { in ahc_queue_scb()
636 ahc_outb(ahc, HNSCB_QOFF, ahc->qinfifonext); in ahc_queue_scb()
638 if ((ahc->features & AHC_AUTOPAUSE) == 0) in ahc_queue_scb()
639 ahc_pause(ahc); in ahc_queue_scb()
640 ahc_outb(ahc, KERNEL_QINPOS, ahc->qinfifonext); in ahc_queue_scb()
641 if ((ahc->features & AHC_AUTOPAUSE) == 0) in ahc_queue_scb()
642 ahc_unpause(ahc); in ahc_queue_scb()
647 ahc_get_sense_buf(struct ahc_softc *ahc, struct scb *scb) in ahc_get_sense_buf() argument
651 offset = scb - ahc->scb_data->scbarray; in ahc_get_sense_buf()
652 return (&ahc->scb_data->sense[offset]); in ahc_get_sense_buf()
656 ahc_get_sense_bufaddr(struct ahc_softc *ahc, struct scb *scb) in ahc_get_sense_bufaddr() argument
660 offset = scb - ahc->scb_data->scbarray; in ahc_get_sense_bufaddr()
661 return (ahc->scb_data->sense_busaddr in ahc_get_sense_bufaddr()
667 ahc_sync_qoutfifo(struct ahc_softc *ahc, int op) in ahc_sync_qoutfifo() argument
669 ahc_dmamap_sync(ahc, ahc->shared_data_dmat, ahc->shared_data_dmamap, in ahc_sync_qoutfifo()
674 ahc_sync_tqinfifo(struct ahc_softc *ahc, int op) in ahc_sync_tqinfifo() argument
677 if ((ahc->flags & AHC_TARGETROLE) != 0) { in ahc_sync_tqinfifo()
678 ahc_dmamap_sync(ahc, ahc->shared_data_dmat, in ahc_sync_tqinfifo()
679 ahc->shared_data_dmamap, in ahc_sync_tqinfifo()
680 ahc_targetcmd_offset(ahc, 0), in ahc_sync_tqinfifo()
694 ahc_check_cmdcmpltqueues(struct ahc_softc *ahc) in ahc_check_cmdcmpltqueues() argument
699 ahc_dmamap_sync(ahc, ahc->shared_data_dmat, ahc->shared_data_dmamap, in ahc_check_cmdcmpltqueues()
700 /*offset*/ahc->qoutfifonext, /*len*/1, in ahc_check_cmdcmpltqueues()
702 if (ahc->qoutfifo[ahc->qoutfifonext] != SCB_LIST_NULL) in ahc_check_cmdcmpltqueues()
705 if ((ahc->flags & AHC_TARGETROLE) != 0 in ahc_check_cmdcmpltqueues()
706 && (ahc->flags & AHC_TQINFIFO_BLOCKED) == 0) { in ahc_check_cmdcmpltqueues()
707 ahc_dmamap_sync(ahc, ahc->shared_data_dmat, in ahc_check_cmdcmpltqueues()
708 ahc->shared_data_dmamap, in ahc_check_cmdcmpltqueues()
709 ahc_targetcmd_offset(ahc, ahc->tqinfifofnext), in ahc_check_cmdcmpltqueues()
712 if (ahc->targetcmds[ahc->tqinfifonext].cmd_valid != 0) in ahc_check_cmdcmpltqueues()
723 ahc_intr(struct ahc_softc *ahc) in ahc_intr() argument
727 if ((ahc->pause & INTEN) == 0) { in ahc_intr()
742 if ((ahc->flags & (AHC_ALL_INTERRUPTS|AHC_EDGE_INTERRUPT)) == 0 in ahc_intr()
743 && (ahc_check_cmdcmpltqueues(ahc) != 0)) in ahc_intr()
746 intstat = ahc_inb(ahc, INTSTAT); in ahc_intr()
751 if (ahc->unsolicited_ints > 500) { in ahc_intr()
752 ahc->unsolicited_ints = 0; in ahc_intr()
753 if ((ahc->chip & AHC_PCI) != 0 in ahc_intr()
754 && (ahc_inb(ahc, ERROR) & PCIERRSTAT) != 0) in ahc_intr()
755 ahc->bus_intr(ahc); in ahc_intr()
758 ahc->unsolicited_ints++; in ahc_intr()
761 ahc->unsolicited_ints = 0; in ahc_intr()
764 ahc_outb(ahc, CLRINT, CLRCMDINT); in ahc_intr()
774 ahc_flush_device_writes(ahc); in ahc_intr()
775 ahc_run_qoutfifo(ahc); in ahc_intr()
777 if ((ahc->flags & AHC_TARGETROLE) != 0) in ahc_intr()
778 ahc_run_tqinfifo(ahc, /*paused*/FALSE); in ahc_intr()
786 if (intstat == 0xFF && (ahc->features & AHC_REMOVABLE) != 0) { in ahc_intr()
789 ahc_handle_brkadrint(ahc); in ahc_intr()
792 ahc_pause_bug_fix(ahc); in ahc_intr()
795 ahc_handle_seqint(ahc, intstat); in ahc_intr()
798 ahc_handle_scsiint(ahc, intstat); in ahc_intr()
808 ahc_restart(struct ahc_softc *ahc) in ahc_restart() argument
812 ahc_pause(ahc); in ahc_restart()
815 ahc_clear_msg_state(ahc); in ahc_restart()
817 ahc_outb(ahc, SCSISIGO, 0); /* De-assert BSY */ in ahc_restart()
818 ahc_outb(ahc, MSG_OUT, NOP); /* No message to send */ in ahc_restart()
819 ahc_outb(ahc, SXFRCTL1, ahc_inb(ahc, SXFRCTL1) & ~BITBUCKET); in ahc_restart()
820 ahc_outb(ahc, LASTPHASE, P_BUSFREE); in ahc_restart()
821 ahc_outb(ahc, SAVED_SCSIID, 0xFF); in ahc_restart()
822 ahc_outb(ahc, SAVED_LUN, 0xFF); in ahc_restart()
831 ahc_outb(ahc, TQINPOS, ahc->tqinfifonext); in ahc_restart()
834 ahc_outb(ahc, SCSISEQ, in ahc_restart()
835 ahc_inb(ahc, SCSISEQ_TEMPLATE) & (ENSELI|ENRSELI|ENAUTOATNP)); in ahc_restart()
836 if ((ahc->features & AHC_CMD_CHAN) != 0) { in ahc_restart()
838 ahc_outb(ahc, CCSCBCNT, 0); in ahc_restart()
839 ahc_outb(ahc, CCSGCTL, 0); in ahc_restart()
840 ahc_outb(ahc, CCSCBCTL, 0); in ahc_restart()
847 if ((ahc_inb(ahc, SEQ_FLAGS2) & SCB_DMA) != 0) { in ahc_restart()
848 ahc_add_curscb_to_free_list(ahc); in ahc_restart()
849 ahc_outb(ahc, SEQ_FLAGS2, in ahc_restart()
850 ahc_inb(ahc, SEQ_FLAGS2) & ~SCB_DMA); in ahc_restart()
858 ahc_outb(ahc, CLRINT, CLRSEQINT); in ahc_restart()
860 ahc_outb(ahc, MWI_RESIDUAL, 0); in ahc_restart()
861 ahc_outb(ahc, SEQCTL, ahc->seqctl); in ahc_restart()
862 ahc_outb(ahc, SEQADDR0, 0); in ahc_restart()
863 ahc_outb(ahc, SEQADDR1, 0); in ahc_restart()
868 sblkctl = ahc_inb(ahc, SBLKCTL); in ahc_restart()
869 ahc_outb(ahc, SBLKCTL, (sblkctl & ~(DIAGLEDEN|DIAGLEDON))); in ahc_restart()
871 ahc_unpause(ahc); in ahc_restart()
876 ahc_run_qoutfifo(struct ahc_softc *ahc) in ahc_run_qoutfifo() argument
881 ahc_sync_qoutfifo(ahc, BUS_DMASYNC_POSTREAD); in ahc_run_qoutfifo()
882 while (ahc->qoutfifo[ahc->qoutfifonext] != SCB_LIST_NULL) { in ahc_run_qoutfifo()
884 scb_index = ahc->qoutfifo[ahc->qoutfifonext]; in ahc_run_qoutfifo()
885 if ((ahc->qoutfifonext & 0x03) == 0x03) { in ahc_run_qoutfifo()
895 modnext = ahc->qoutfifonext & ~0x3; in ahc_run_qoutfifo()
896 *((uint32_t *)(&ahc->qoutfifo[modnext])) = 0xFFFFFFFFUL; in ahc_run_qoutfifo()
897 ahc_dmamap_sync(ahc, ahc->shared_data_dmat, in ahc_run_qoutfifo()
898 ahc->shared_data_dmamap, in ahc_run_qoutfifo()
902 ahc->qoutfifonext++; in ahc_run_qoutfifo()
904 scb = ahc_lookup_scb(ahc, scb_index); in ahc_run_qoutfifo()
908 ahc_name(ahc), scb_index, in ahc_run_qoutfifo()
909 (ahc->qoutfifonext - 1) & 0xFF); in ahc_run_qoutfifo()
917 ahc_update_residual(ahc, scb); in ahc_run_qoutfifo()
918 ahc_done(ahc, scb); in ahc_run_qoutfifo()
923 ahc_run_untagged_queues(struct ahc_softc *ahc) in ahc_run_untagged_queues() argument
928 ahc_run_untagged_queue(ahc, &ahc->untagged_queues[i]); in ahc_run_untagged_queues()
932 ahc_run_untagged_queue(struct ahc_softc *ahc, struct scb_tailq *queue) in ahc_run_untagged_queue() argument
936 if (ahc->untagged_queue_lock != 0) in ahc_run_untagged_queue()
942 ahc_queue_scb(ahc, scb); in ahc_run_untagged_queue()
948 ahc_handle_brkadrint(struct ahc_softc *ahc) in ahc_handle_brkadrint() argument
957 error = ahc_inb(ahc, ERROR); in ahc_handle_brkadrint()
961 ahc_name(ahc), ahc_hard_errors[i].errmesg, in ahc_handle_brkadrint()
962 ahc_inb(ahc, SEQADDR0) | in ahc_handle_brkadrint()
963 (ahc_inb(ahc, SEQADDR1) << 8)); in ahc_handle_brkadrint()
965 ahc_dump_card_state(ahc); in ahc_handle_brkadrint()
968 ahc_abort_scbs(ahc, CAM_TARGET_WILDCARD, ALL_CHANNELS, in ahc_handle_brkadrint()
973 ahc_shutdown(ahc); in ahc_handle_brkadrint()
977 ahc_handle_seqint(struct ahc_softc *ahc, u_int intstat) in ahc_handle_seqint() argument
982 ahc_fetch_devinfo(ahc, &devinfo); in ahc_handle_seqint()
990 ahc_outb(ahc, CLRINT, CLRSEQINT); in ahc_handle_seqint()
1002 ahc_outb(ahc, RETURN_1, 0); in ahc_handle_seqint()
1013 scb_index = ahc_inb(ahc, SCB_TAG); in ahc_handle_seqint()
1014 scb = ahc_lookup_scb(ahc, scb_index); in ahc_handle_seqint()
1016 ahc_print_devinfo(ahc, &devinfo); in ahc_handle_seqint()
1020 ahc_dump_card_state(ahc); in ahc_handle_seqint()
1040 ahc_freeze_devq(ahc, scb); in ahc_handle_seqint()
1046 ahc_name(ahc)); in ahc_handle_seqint()
1058 ahc_print_path(ahc, scb); in ahc_handle_seqint()
1067 targ_info = ahc_fetch_transinfo(ahc, in ahc_handle_seqint()
1078 ahc_update_residual(ahc, scb); in ahc_handle_seqint()
1081 ahc_print_path(ahc, scb); in ahc_handle_seqint()
1085 sg->addr = ahc_get_sense_bufaddr(ahc, scb); in ahc_handle_seqint()
1086 sg->len = ahc_get_sense_bufsize(ahc, scb); in ahc_handle_seqint()
1122 ahc_update_neg_request(ahc, &devinfo, in ahc_handle_seqint()
1138 ahc_qinfifo_requeue_tail(ahc, scb); in ahc_handle_seqint()
1139 ahc_outb(ahc, RETURN_1, SEND_SENSE); in ahc_handle_seqint()
1155 ahc_outb(ahc, SCSISEQ, in ahc_handle_seqint()
1156 ahc_inb(ahc, SCSISEQ) & (ENSELI|ENRSELI|ENAUTOATNP)); in ahc_handle_seqint()
1160 ahc_name(ahc), devinfo.channel, devinfo.target); in ahc_handle_seqint()
1163 ahc_inb(ahc, SAVED_SCSIID), ahc_inb(ahc, SAVED_LUN), in ahc_handle_seqint()
1164 ahc_inb(ahc, ARG_1), ahc_inb(ahc, ACCUM)); in ahc_handle_seqint()
1167 ahc_inb(ahc, SEQ_FLAGS), ahc_inb(ahc, SCBPTR), in ahc_handle_seqint()
1168 ahc_index_busy_tcl(ahc, in ahc_handle_seqint()
1169 BUILD_TCL(ahc_inb(ahc, SAVED_SCSIID), in ahc_handle_seqint()
1170 ahc_inb(ahc, SAVED_LUN))), in ahc_handle_seqint()
1171 ahc_inb(ahc, SINDEX)); in ahc_handle_seqint()
1174 ahc_inb(ahc, SCSIID), ahc_inb(ahc, SCB_SCSIID), in ahc_handle_seqint()
1175 ahc_inb(ahc, SCB_LUN), ahc_inb(ahc, SCB_TAG), in ahc_handle_seqint()
1176 ahc_inb(ahc, SCB_CONTROL)); in ahc_handle_seqint()
1178 ahc_inb(ahc, SCSIBUSL), ahc_inb(ahc, SCSISIGI)); in ahc_handle_seqint()
1179 printk("SXFRCTL0 == 0x%x\n", ahc_inb(ahc, SXFRCTL0)); in ahc_handle_seqint()
1180 printk("SEQCTL == 0x%x\n", ahc_inb(ahc, SEQCTL)); in ahc_handle_seqint()
1181 ahc_dump_card_state(ahc); in ahc_handle_seqint()
1182 ahc->msgout_buf[0] = TARGET_RESET; in ahc_handle_seqint()
1183 ahc->msgout_len = 1; in ahc_handle_seqint()
1184 ahc->msgout_index = 0; in ahc_handle_seqint()
1185 ahc->msg_type = MSG_TYPE_INITIATOR_MSGOUT; in ahc_handle_seqint()
1186 ahc_outb(ahc, MSG_OUT, HOST_MSG); in ahc_handle_seqint()
1187 ahc_assert_atn(ahc); in ahc_handle_seqint()
1192 u_int rejbyte = ahc_inb(ahc, ACCUM); in ahc_handle_seqint()
1195 ahc_name(ahc), devinfo.channel, devinfo.target, rejbyte); in ahc_handle_seqint()
1200 ahc_handle_proto_violation(ahc); in ahc_handle_seqint()
1204 ahc_handle_ign_wide_residue(ahc, &devinfo); in ahc_handle_seqint()
1207 ahc_reinitialize_dataptrs(ahc); in ahc_handle_seqint()
1213 lastphase = ahc_inb(ahc, LASTPHASE); in ahc_handle_seqint()
1216 ahc_name(ahc), devinfo.channel, devinfo.target, in ahc_handle_seqint()
1217 lastphase, ahc_inb(ahc, SCSISIGI)); in ahc_handle_seqint()
1224 lastphase = ahc_inb(ahc, LASTPHASE); in ahc_handle_seqint()
1227 ahc_name(ahc), devinfo.channel, devinfo.target, in ahc_handle_seqint()
1228 lastphase, ahc_inb(ahc, SCSISIGI)); in ahc_handle_seqint()
1229 ahc_restart(ahc); in ahc_handle_seqint()
1245 if (ahc->msg_type == MSG_TYPE_NONE) { in ahc_handle_seqint()
1250 bus_phase = ahc_inb(ahc, SCSISIGI) & PHASE_MASK; in ahc_handle_seqint()
1260 ahc_clear_intstat(ahc); in ahc_handle_seqint()
1261 ahc_restart(ahc); in ahc_handle_seqint()
1265 scb_index = ahc_inb(ahc, SCB_TAG); in ahc_handle_seqint()
1266 scb = ahc_lookup_scb(ahc, scb_index); in ahc_handle_seqint()
1274 ahc_setup_initiator_msgout(ahc, in ahc_handle_seqint()
1278 ahc->msg_type = in ahc_handle_seqint()
1280 ahc->msgin_index = 0; in ahc_handle_seqint()
1286 ahc->msg_type = in ahc_handle_seqint()
1288 ahc->msgin_index = 0; in ahc_handle_seqint()
1290 ahc_setup_target_msgin(ahc, in ahc_handle_seqint()
1297 ahc_handle_message_phase(ahc); in ahc_handle_seqint()
1314 && (ahc_inb(ahc, SSTAT1) & SCSIPERR) != 0) { in ahc_handle_seqint()
1316 if ((ahc->features & AHC_DT) == 0) { in ahc_handle_seqint()
1325 curphase = ahc_inb(ahc, SCSISIGI) & PHASE_MASK; in ahc_handle_seqint()
1326 ahc_outb(ahc, LASTPHASE, curphase); in ahc_handle_seqint()
1327 ahc_outb(ahc, SCSISIGO, curphase); in ahc_handle_seqint()
1329 if ((ahc_inb(ahc, SCSISIGI) & (CDI|MSGI)) == 0) { in ahc_handle_seqint()
1338 ahc_outb(ahc, SXFRCTL1, in ahc_handle_seqint()
1339 ahc_inb(ahc, SXFRCTL1) | BITBUCKET); in ahc_handle_seqint()
1342 if ((ahc_inb(ahc, SCSISIGI) in ahc_handle_seqint()
1347 ahc_outb(ahc, SXFRCTL1, in ahc_handle_seqint()
1348 ahc_inb(ahc, SXFRCTL1) & ~BITBUCKET); in ahc_handle_seqint()
1353 ahc_print_devinfo(ahc, &devinfo); in ahc_handle_seqint()
1356 scb_index = ahc_inb(ahc, SCB_TAG); in ahc_handle_seqint()
1357 scb = ahc_lookup_scb(ahc, scb_index); in ahc_handle_seqint()
1361 ahc_reset_channel(ahc, devinfo.channel, in ahc_handle_seqint()
1365 ahc_inb(ahc, SCSIDATL); in ahc_handle_seqint()
1380 u_int scbindex = ahc_inb(ahc, SCB_TAG); in ahc_handle_seqint()
1381 u_int lastphase = ahc_inb(ahc, LASTPHASE); in ahc_handle_seqint()
1384 scb = ahc_lookup_scb(ahc, scbindex); in ahc_handle_seqint()
1389 ahc_print_path(ahc, scb); in ahc_handle_seqint()
1394 ahc_print_path(ahc, scb); in ahc_handle_seqint()
1396 ahc_inb(ahc, SEQ_FLAGS) & DPHASE ? "Have" : "Haven't", in ahc_handle_seqint()
1414 ahc_freeze_devq(ahc, scb); in ahc_handle_seqint()
1423 if ((ahc->features & AHC_ULTRA2) != 0) { in ahc_handle_seqint()
1428 ahc_outb(ahc, SXFRCTL0, in ahc_handle_seqint()
1429 ahc_inb(ahc, SXFRCTL0) | CLRSTCNT|CLRCHN); in ahc_handle_seqint()
1430 ahc_outb(ahc, SXFRCTL0, in ahc_handle_seqint()
1431 ahc_inb(ahc, SXFRCTL0) | CLRSTCNT|CLRCHN); in ahc_handle_seqint()
1433 if ((ahc->flags & AHC_39BIT_ADDRESSING) != 0) { in ahc_handle_seqint()
1437 dscommand1 = ahc_inb(ahc, DSCOMMAND1); in ahc_handle_seqint()
1438 ahc_outb(ahc, DSCOMMAND1, dscommand1 | HADDLDSEL0); in ahc_handle_seqint()
1439 ahc_outb(ahc, HADDR, 0); in ahc_handle_seqint()
1440 ahc_outb(ahc, DSCOMMAND1, dscommand1); in ahc_handle_seqint()
1449 ahc_name(ahc), devinfo.channel, devinfo.target, in ahc_handle_seqint()
1451 scbindex = ahc_inb(ahc, SCB_TAG); in ahc_handle_seqint()
1452 scb = ahc_lookup_scb(ahc, scbindex); in ahc_handle_seqint()
1459 ahc_search_qinfifo(ahc, SCB_GET_TARGET(ahc, scb), in ahc_handle_seqint()
1460 SCB_GET_CHANNEL(ahc, scb), in ahc_handle_seqint()
1468 printk("%s: No free or disconnected SCBs\n", ahc_name(ahc)); in ahc_handle_seqint()
1469 ahc_dump_card_state(ahc); in ahc_handle_seqint()
1477 scbptr = ahc_inb(ahc, SCBPTR); in ahc_handle_seqint()
1479 scbptr, ahc_inb(ahc, ARG_1), in ahc_handle_seqint()
1480 ahc->scb_data->hscbs[scbptr].tag); in ahc_handle_seqint()
1481 ahc_dump_card_state(ahc); in ahc_handle_seqint()
1487 printk("%s: BTT calculation out of range\n", ahc_name(ahc)); in ahc_handle_seqint()
1490 ahc_inb(ahc, SAVED_SCSIID), ahc_inb(ahc, SAVED_LUN), in ahc_handle_seqint()
1491 ahc_inb(ahc, ARG_1), ahc_inb(ahc, ACCUM)); in ahc_handle_seqint()
1494 ahc_inb(ahc, SEQ_FLAGS), ahc_inb(ahc, SCBPTR), in ahc_handle_seqint()
1495 ahc_index_busy_tcl(ahc, in ahc_handle_seqint()
1496 BUILD_TCL(ahc_inb(ahc, SAVED_SCSIID), in ahc_handle_seqint()
1497 ahc_inb(ahc, SAVED_LUN))), in ahc_handle_seqint()
1498 ahc_inb(ahc, SINDEX), in ahc_handle_seqint()
1499 ahc_inb(ahc, ACCUM)); in ahc_handle_seqint()
1502 ahc_inb(ahc, SCSIID), ahc_inb(ahc, SCB_SCSIID), in ahc_handle_seqint()
1503 ahc_inb(ahc, SCB_LUN), ahc_inb(ahc, SCB_TAG), in ahc_handle_seqint()
1504 ahc_inb(ahc, SCB_CONTROL)); in ahc_handle_seqint()
1506 ahc_inb(ahc, SCSIBUSL), ahc_inb(ahc, SCSISIGI)); in ahc_handle_seqint()
1507 ahc_dump_card_state(ahc); in ahc_handle_seqint()
1514 intstat, ahc_inb(ahc, SCSISIGI)); in ahc_handle_seqint()
1523 ahc_unpause(ahc); in ahc_handle_seqint()
1527 ahc_handle_scsiint(struct ahc_softc *ahc, u_int intstat) in ahc_handle_scsiint() argument
1536 if ((ahc->features & AHC_TWIN) != 0 in ahc_handle_scsiint()
1537 && ((ahc_inb(ahc, SBLKCTL) & SELBUSB) != 0)) in ahc_handle_scsiint()
1543 if ((ahc->features & AHC_ULTRA2) != 0) in ahc_handle_scsiint()
1544 status0 = ahc_inb(ahc, SSTAT0) & IOERR; in ahc_handle_scsiint()
1547 status = ahc_inb(ahc, SSTAT1) & (SELTO|SCSIRSTI|BUSFREE|SCSIPERR); in ahc_handle_scsiint()
1549 if ((ahc->features & AHC_TWIN) != 0) { in ahc_handle_scsiint()
1551 ahc_outb(ahc, SBLKCTL, ahc_inb(ahc, SBLKCTL) ^ SELBUSB); in ahc_handle_scsiint()
1552 status = ahc_inb(ahc, SSTAT1) in ahc_handle_scsiint()
1557 printk("%s: Spurious SCSI interrupt\n", ahc_name(ahc)); in ahc_handle_scsiint()
1558 ahc_outb(ahc, CLRINT, CLRSCSIINT); in ahc_handle_scsiint()
1559 ahc_unpause(ahc); in ahc_handle_scsiint()
1565 ahc_clear_critical_section(ahc); in ahc_handle_scsiint()
1567 scb_index = ahc_inb(ahc, SCB_TAG); in ahc_handle_scsiint()
1568 scb = ahc_lookup_scb(ahc, scb_index); in ahc_handle_scsiint()
1570 && (ahc_inb(ahc, SEQ_FLAGS) & NOT_IDENTIFIED) != 0) in ahc_handle_scsiint()
1573 if ((ahc->features & AHC_ULTRA2) != 0 in ahc_handle_scsiint()
1577 now_lvd = ahc_inb(ahc, SBLKCTL) & ENAB40; in ahc_handle_scsiint()
1579 ahc_name(ahc), now_lvd ? "LVD" : "SE"); in ahc_handle_scsiint()
1580 ahc_outb(ahc, CLRSINT0, CLRIOERR); in ahc_handle_scsiint()
1591 ahc_reset_channel(ahc, intr_channel, in ahc_handle_scsiint()
1595 ahc_name(ahc), intr_channel); in ahc_handle_scsiint()
1597 ahc_outb(ahc, SBLKCTL, ahc_inb(ahc, SBLKCTL) ^ SELBUSB); in ahc_handle_scsiint()
1598 ahc_reset_channel(ahc, intr_channel, /*Initiate Reset*/FALSE); in ahc_handle_scsiint()
1620 lastphase = ahc_inb(ahc, LASTPHASE); in ahc_handle_scsiint()
1621 curphase = ahc_inb(ahc, SCSISIGI) & PHASE_MASK; in ahc_handle_scsiint()
1622 sstat2 = ahc_inb(ahc, SSTAT2); in ahc_handle_scsiint()
1623 ahc_outb(ahc, CLRSINT1, CLRSCSIPERR); in ahc_handle_scsiint()
1635 if ((ahc_inb(ahc, SSTAT1) & SCSIPERR) != 0 in ahc_handle_scsiint()
1651 ahc_print_path(ahc, scb); in ahc_handle_scsiint()
1654 printk("%s:%c:%d: ", ahc_name(ahc), intr_channel, in ahc_handle_scsiint()
1655 SCSIID_TARGET(ahc, ahc_inb(ahc, SAVED_SCSIID))); in ahc_handle_scsiint()
1656 scsirate = ahc_inb(ahc, SCSIRATE); in ahc_handle_scsiint()
1661 ahc_inw(ahc, SEQADDR0), in ahc_handle_scsiint()
1663 if ((ahc->features & AHC_DT) != 0) { in ahc_handle_scsiint()
1679 if ((ahc->features & AHC_DT) != 0 in ahc_handle_scsiint()
1697 if (ahc->msg_type != MSG_TYPE_NONE) in ahc_handle_scsiint()
1698 ahc->send_msg_perror = TRUE; in ahc_handle_scsiint()
1700 ahc_outb(ahc, MSG_OUT, mesg_out); in ahc_handle_scsiint()
1707 ahc_fetch_devinfo(ahc, &devinfo); in ahc_handle_scsiint()
1708 ahc_force_renegotiation(ahc, &devinfo); in ahc_handle_scsiint()
1710 ahc_outb(ahc, CLRINT, CLRSCSIINT); in ahc_handle_scsiint()
1711 ahc_unpause(ahc); in ahc_handle_scsiint()
1716 ahc_outb(ahc, SCSISEQ, 0); in ahc_handle_scsiint()
1719 ahc_clear_msg_state(ahc); in ahc_handle_scsiint()
1722 ahc_outb(ahc, SIMODE1, ahc_inb(ahc, SIMODE1) & ~ENBUSFREE); in ahc_handle_scsiint()
1723 ahc_outb(ahc, CLRSINT1, CLRSELTIMEO|CLRBUSFREE|CLRSCSIPERR); in ahc_handle_scsiint()
1733 ahc_outb(ahc, CLRSINT0, CLRSELINGO); in ahc_handle_scsiint()
1735 scbptr = ahc_inb(ahc, WAITING_SCBH); in ahc_handle_scsiint()
1736 ahc_outb(ahc, SCBPTR, scbptr); in ahc_handle_scsiint()
1737 scb_index = ahc_inb(ahc, SCB_TAG); in ahc_handle_scsiint()
1739 scb = ahc_lookup_scb(ahc, scb_index); in ahc_handle_scsiint()
1743 ahc_name(ahc), scbptr, scb_index); in ahc_handle_scsiint()
1744 ahc_dump_card_state(ahc); in ahc_handle_scsiint()
1749 ahc_print_path(ahc, scb); in ahc_handle_scsiint()
1754 ahc_scb_devinfo(ahc, &devinfo, scb); in ahc_handle_scsiint()
1756 ahc_freeze_devq(ahc, scb); in ahc_handle_scsiint()
1764 ahc_handle_devreset(ahc, &devinfo, in ahc_handle_scsiint()
1769 ahc_outb(ahc, CLRINT, CLRSCSIINT); in ahc_handle_scsiint()
1770 ahc_restart(ahc); in ahc_handle_scsiint()
1772 && (ahc_inb(ahc, SIMODE1) & ENBUSFREE) != 0) { in ahc_handle_scsiint()
1788 ahc_outb(ahc, SCSISEQ, in ahc_handle_scsiint()
1789 ahc_inb(ahc, SCSISEQ) & (ENSELI|ENRSELI|ENAUTOATNP)); in ahc_handle_scsiint()
1797 ahc_outb(ahc, SIMODE1, ahc_inb(ahc, SIMODE1) & ~ENBUSFREE); in ahc_handle_scsiint()
1798 ahc_outb(ahc, CLRSINT1, CLRBUSFREE|CLRSCSIPERR); in ahc_handle_scsiint()
1806 lastphase = ahc_inb(ahc, LASTPHASE); in ahc_handle_scsiint()
1807 saved_scsiid = ahc_inb(ahc, SAVED_SCSIID); in ahc_handle_scsiint()
1808 saved_lun = ahc_inb(ahc, SAVED_LUN); in ahc_handle_scsiint()
1809 target = SCSIID_TARGET(ahc, saved_scsiid); in ahc_handle_scsiint()
1811 channel = SCSIID_CHANNEL(ahc, saved_scsiid); in ahc_handle_scsiint()
1820 if (ahc_sent_msg(ahc, AHCMSG_1B, ABORT_TASK, TRUE) in ahc_handle_scsiint()
1821 || ahc_sent_msg(ahc, AHCMSG_1B, ABORT_TASK_SET, TRUE)) { in ahc_handle_scsiint()
1822 if (ahc->msgout_buf[ahc->msgout_index - 1] in ahc_handle_scsiint()
1825 ahc_print_path(ahc, scb); in ahc_handle_scsiint()
1829 ahc_abort_scbs(ahc, target, channel, in ahc_handle_scsiint()
1834 } else if (ahc_sent_msg(ahc, AHCMSG_1B, in ahc_handle_scsiint()
1842 ahc_handle_devreset(ahc, &devinfo, in ahc_handle_scsiint()
1847 } else if (ahc_sent_msg(ahc, AHCMSG_EXT, in ahc_handle_scsiint()
1856 tinfo = ahc_fetch_transinfo(ahc, in ahc_handle_scsiint()
1864 ahc_qinfifo_requeue_tail(ahc, scb); in ahc_handle_scsiint()
1866 } else if (ahc_sent_msg(ahc, AHCMSG_EXT, in ahc_handle_scsiint()
1872 ahc_set_width(ahc, &devinfo, in ahc_handle_scsiint()
1876 ahc_qinfifo_requeue_tail(ahc, scb); in ahc_handle_scsiint()
1878 } else if (ahc_sent_msg(ahc, AHCMSG_EXT, in ahc_handle_scsiint()
1884 ahc_set_syncrate(ahc, &devinfo, in ahc_handle_scsiint()
1890 ahc_qinfifo_requeue_tail(ahc, scb); in ahc_handle_scsiint()
1904 ahc_print_path(ahc, scb); in ahc_handle_scsiint()
1905 ahc_abort_scbs(ahc, target, channel, in ahc_handle_scsiint()
1914 printk("%s: ", ahc_name(ahc)); in ahc_handle_scsiint()
1927 ahc_force_renegotiation(ahc, &devinfo); in ahc_handle_scsiint()
1932 ahc_inb(ahc, SEQADDR0) in ahc_handle_scsiint()
1933 | (ahc_inb(ahc, SEQADDR1) << 8)); in ahc_handle_scsiint()
1935 ahc_outb(ahc, CLRINT, CLRSCSIINT); in ahc_handle_scsiint()
1936 ahc_restart(ahc); in ahc_handle_scsiint()
1939 ahc_name(ahc), status); in ahc_handle_scsiint()
1940 ahc_outb(ahc, CLRINT, CLRSCSIINT); in ahc_handle_scsiint()
1949 ahc_force_renegotiation(struct ahc_softc *ahc, struct ahc_devinfo *devinfo) in ahc_force_renegotiation() argument
1954 targ_info = ahc_fetch_transinfo(ahc, in ahc_force_renegotiation()
1959 ahc_update_neg_request(ahc, devinfo, tstate, in ahc_force_renegotiation()
1965 ahc_clear_critical_section(struct ahc_softc *ahc) in ahc_clear_critical_section() argument
1972 if (ahc->num_critical_sections == 0) in ahc_clear_critical_section()
1984 seqaddr = ahc_inb(ahc, SEQADDR0) in ahc_clear_critical_section()
1985 | (ahc_inb(ahc, SEQADDR1) << 8); in ahc_clear_critical_section()
1994 cs = ahc->critical_sections; in ahc_clear_critical_section()
1995 for (i = 0; i < ahc->num_critical_sections; i++, cs++) { in ahc_clear_critical_section()
2000 if (i == ahc->num_critical_sections) in ahc_clear_critical_section()
2005 ahc_name(ahc)); in ahc_clear_critical_section()
2006 ahc_dump_card_state(ahc); in ahc_clear_critical_section()
2019 simode0 = ahc_inb(ahc, SIMODE0); in ahc_clear_critical_section()
2020 ahc_outb(ahc, SIMODE0, 0); in ahc_clear_critical_section()
2021 simode1 = ahc_inb(ahc, SIMODE1); in ahc_clear_critical_section()
2022 if ((ahc->features & AHC_DT) != 0) in ahc_clear_critical_section()
2031 ahc_outb(ahc, SIMODE1, simode1 & ENBUSFREE); in ahc_clear_critical_section()
2033 ahc_outb(ahc, SIMODE1, 0); in ahc_clear_critical_section()
2034 ahc_outb(ahc, CLRINT, CLRSCSIINT); in ahc_clear_critical_section()
2035 ahc_outb(ahc, SEQCTL, ahc->seqctl | STEP); in ahc_clear_critical_section()
2038 if ((ahc->features & AHC_DT) != 0) { in ahc_clear_critical_section()
2039 ahc_outb(ahc, CLRSINT1, CLRBUSFREE); in ahc_clear_critical_section()
2040 ahc_outb(ahc, CLRINT, CLRSCSIINT); in ahc_clear_critical_section()
2042 ahc_outb(ahc, HCNTRL, ahc->unpause); in ahc_clear_critical_section()
2043 while (!ahc_is_paused(ahc)) in ahc_clear_critical_section()
2047 ahc_outb(ahc, SIMODE0, simode0); in ahc_clear_critical_section()
2048 ahc_outb(ahc, SIMODE1, simode1); in ahc_clear_critical_section()
2049 ahc_outb(ahc, SEQCTL, ahc->seqctl); in ahc_clear_critical_section()
2057 ahc_clear_intstat(struct ahc_softc *ahc) in ahc_clear_intstat() argument
2060 ahc_outb(ahc, CLRSINT1, CLRSELTIMEO|CLRATNO|CLRSCSIRSTI in ahc_clear_intstat()
2063 ahc_flush_device_writes(ahc); in ahc_clear_intstat()
2064 ahc_outb(ahc, CLRSINT0, CLRSELDO|CLRSELDI|CLRSELINGO); in ahc_clear_intstat()
2065 ahc_flush_device_writes(ahc); in ahc_clear_intstat()
2066 ahc_outb(ahc, CLRINT, CLRSCSIINT); in ahc_clear_intstat()
2067 ahc_flush_device_writes(ahc); in ahc_clear_intstat()
2116 ahc_alloc_tstate(struct ahc_softc *ahc, u_int scsi_id, char channel) in ahc_alloc_tstate() argument
2122 master_tstate = ahc->enabled_targets[ahc->our_id]; in ahc_alloc_tstate()
2125 master_tstate = ahc->enabled_targets[ahc->our_id_b + 8]; in ahc_alloc_tstate()
2127 if (ahc->enabled_targets[scsi_id] != NULL in ahc_alloc_tstate()
2128 && ahc->enabled_targets[scsi_id] != master_tstate) in ahc_alloc_tstate()
2130 ahc_name(ahc)); in ahc_alloc_tstate()
2153 ahc->enabled_targets[scsi_id] = tstate; in ahc_alloc_tstate()
2163 ahc_free_tstate(struct ahc_softc *ahc, u_int scsi_id, char channel, int force) in ahc_free_tstate() argument
2171 if (((channel == 'B' && scsi_id == ahc->our_id_b) in ahc_free_tstate()
2172 || (channel == 'A' && scsi_id == ahc->our_id)) in ahc_free_tstate()
2178 tstate = ahc->enabled_targets[scsi_id]; in ahc_free_tstate()
2180 ahc->enabled_targets[scsi_id] = NULL; in ahc_free_tstate()
2191 ahc_devlimited_syncrate(struct ahc_softc *ahc, in ahc_devlimited_syncrate() argument
2198 if ((ahc->features & AHC_ULTRA2) != 0) { in ahc_devlimited_syncrate()
2199 if ((ahc_inb(ahc, SBLKCTL) & ENAB40) != 0 in ahc_devlimited_syncrate()
2200 && (ahc_inb(ahc, SSTAT2) & EXP_ACTIVE) == 0) { in ahc_devlimited_syncrate()
2207 } else if ((ahc->features & AHC_ULTRA) != 0) { in ahc_devlimited_syncrate()
2237 return (ahc_find_syncrate(ahc, period, ppr_options, maxsync)); in ahc_devlimited_syncrate()
2246 ahc_find_syncrate(struct ahc_softc *ahc, u_int *period, in ahc_find_syncrate() argument
2251 if ((ahc->features & AHC_DT) == 0) in ahc_find_syncrate()
2261 if ((ahc->features & (AHC_DT | AHC_ULTRA2)) == 0 in ahc_find_syncrate()
2264 if ((ahc->features & (AHC_DT | AHC_ULTRA2 | AHC_ULTRA)) == 0 in ahc_find_syncrate()
2276 if ((ahc->features & AHC_ULTRA2) != 0 in ahc_find_syncrate()
2307 || ((ahc->features & AHC_ULTRA2) != 0 in ahc_find_syncrate()
2322 ahc_find_period(struct ahc_softc *ahc, u_int scsirate, u_int maxsync) in ahc_find_period() argument
2326 if ((ahc->features & AHC_ULTRA2) != 0) in ahc_find_period()
2332 if ((ahc->features & AHC_DT) == 0 && maxsync < AHC_SYNCRATE_ULTRA2) in ahc_find_period()
2334 if ((ahc->features & (AHC_DT | AHC_ULTRA2)) == 0 in ahc_find_period()
2337 if ((ahc->features & (AHC_DT | AHC_ULTRA2 | AHC_ULTRA)) == 0 in ahc_find_period()
2345 if ((ahc->features & AHC_ULTRA2) != 0) { in ahc_find_period()
2363 ahc_validate_offset(struct ahc_softc *ahc, in ahc_validate_offset() argument
2373 } else if ((ahc->features & AHC_ULTRA2) != 0) { in ahc_validate_offset()
2395 ahc_validate_width(struct ahc_softc *ahc, struct ahc_initiator_tinfo *tinfo, in ahc_validate_width() argument
2400 if (ahc->features & AHC_WIDE) { in ahc_validate_width()
2425 ahc_update_neg_request(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, in ahc_update_neg_request() argument
2439 if ((ahc->features & AHC_WIDE) != 0) in ahc_update_neg_request()
2468 ahc_set_syncrate(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, in ahc_set_syncrate() argument
2488 tinfo = ahc_fetch_transinfo(ahc, devinfo->channel, devinfo->our_scsiid, in ahc_set_syncrate()
2515 if ((ahc->features & AHC_ULTRA2) != 0) { in ahc_set_syncrate()
2544 sxfrctl0 = ahc_inb(ahc, SXFRCTL0); in ahc_set_syncrate()
2548 ahc_outb(ahc, SXFRCTL0, sxfrctl0); in ahc_set_syncrate()
2552 ahc_outb(ahc, SCSIRATE, scsirate); in ahc_set_syncrate()
2553 if ((ahc->features & AHC_ULTRA2) != 0) in ahc_set_syncrate()
2554 ahc_outb(ahc, SCSIOFFSET, offset); in ahc_set_syncrate()
2562 ahc_send_async(ahc, devinfo->channel, devinfo->target, in ahc_set_syncrate()
2567 "offset = 0x%x\n", ahc_name(ahc), in ahc_set_syncrate()
2574 ahc_name(ahc), devinfo->target); in ahc_set_syncrate()
2579 update_needed += ahc_update_neg_request(ahc, devinfo, tstate, in ahc_set_syncrate()
2583 ahc_update_pending_scbs(ahc); in ahc_set_syncrate()
2595 ahc_set_width(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, in ahc_set_width() argument
2606 tinfo = ahc_fetch_transinfo(ahc, devinfo->channel, devinfo->our_scsiid, in ahc_set_width()
2628 ahc_outb(ahc, SCSIRATE, scsirate); in ahc_set_width()
2632 ahc_send_async(ahc, devinfo->channel, devinfo->target, in ahc_set_width()
2636 ahc_name(ahc), devinfo->target, in ahc_set_width()
2641 update_needed += ahc_update_neg_request(ahc, devinfo, tstate, in ahc_set_width()
2644 ahc_update_pending_scbs(ahc); in ahc_set_width()
2651 ahc_set_tags(struct ahc_softc *ahc, struct scsi_cmnd *cmd, in ahc_set_tags() argument
2656 ahc_platform_set_tags(ahc, sdev, devinfo, alg); in ahc_set_tags()
2657 ahc_send_async(ahc, devinfo->channel, devinfo->target, in ahc_set_tags()
2667 ahc_update_pending_scbs(struct ahc_softc *ahc) in ahc_update_pending_scbs() argument
2680 LIST_FOREACH(pending_scb, &ahc->pending_scbs, pending_links) { in ahc_update_pending_scbs()
2686 ahc_scb_devinfo(ahc, &devinfo, pending_scb); in ahc_update_pending_scbs()
2687 tinfo = ahc_fetch_transinfo(ahc, devinfo.channel, in ahc_update_pending_scbs()
2701 ahc_sync_scb(ahc, pending_scb, in ahc_update_pending_scbs()
2709 if (ahc_is_paused(ahc)) { in ahc_update_pending_scbs()
2713 ahc_pause(ahc); in ahc_update_pending_scbs()
2716 saved_scbptr = ahc_inb(ahc, SCBPTR); in ahc_update_pending_scbs()
2718 for (i = 0; i < ahc->scb_data->maxhscbs; i++) { in ahc_update_pending_scbs()
2723 ahc_outb(ahc, SCBPTR, i); in ahc_update_pending_scbs()
2724 scb_tag = ahc_inb(ahc, SCB_TAG); in ahc_update_pending_scbs()
2725 pending_scb = ahc_lookup_scb(ahc, scb_tag); in ahc_update_pending_scbs()
2730 control = ahc_inb(ahc, SCB_CONTROL); in ahc_update_pending_scbs()
2733 ahc_outb(ahc, SCB_CONTROL, control); in ahc_update_pending_scbs()
2734 ahc_outb(ahc, SCB_SCSIRATE, pending_hscb->scsirate); in ahc_update_pending_scbs()
2735 ahc_outb(ahc, SCB_SCSIOFFSET, pending_hscb->scsioffset); in ahc_update_pending_scbs()
2737 ahc_outb(ahc, SCBPTR, saved_scbptr); in ahc_update_pending_scbs()
2740 ahc_unpause(ahc); in ahc_update_pending_scbs()
2745 ahc_fetch_devinfo(struct ahc_softc *ahc, struct ahc_devinfo *devinfo) in ahc_fetch_devinfo() argument
2751 if (ahc_inb(ahc, SSTAT0) & TARGET) in ahc_fetch_devinfo()
2757 && (ahc->features & AHC_MULTI_TID) != 0 in ahc_fetch_devinfo()
2758 && (ahc_inb(ahc, SEQ_FLAGS) in ahc_fetch_devinfo()
2761 our_id = ahc_inb(ahc, TARGIDIN) & OID; in ahc_fetch_devinfo()
2762 } else if ((ahc->features & AHC_ULTRA2) != 0) in ahc_fetch_devinfo()
2763 our_id = ahc_inb(ahc, SCSIID_ULTRA2) & OID; in ahc_fetch_devinfo()
2765 our_id = ahc_inb(ahc, SCSIID) & OID; in ahc_fetch_devinfo()
2767 saved_scsiid = ahc_inb(ahc, SAVED_SCSIID); in ahc_fetch_devinfo()
2770 SCSIID_TARGET(ahc, saved_scsiid), in ahc_fetch_devinfo()
2771 ahc_inb(ahc, SAVED_LUN), in ahc_fetch_devinfo()
2772 SCSIID_CHANNEL(ahc, saved_scsiid), in ahc_fetch_devinfo()
2810 ahc_print_devinfo(struct ahc_softc *ahc, struct ahc_devinfo *devinfo) in ahc_print_devinfo() argument
2812 printk("%s:%c:%d:%d: ", ahc_name(ahc), devinfo->channel, in ahc_print_devinfo()
2817 ahc_scb_devinfo(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, in ahc_scb_devinfo() argument
2827 ahc_compile_devinfo(devinfo, our_id, SCB_GET_TARGET(ahc, scb), in ahc_scb_devinfo()
2828 SCB_GET_LUN(scb), SCB_GET_CHANNEL(ahc, scb), role); in ahc_scb_devinfo()
2834 ahc_assert_atn(struct ahc_softc *ahc) in ahc_assert_atn() argument
2839 if ((ahc->features & AHC_DT) == 0) in ahc_assert_atn()
2840 scsisigo |= ahc_inb(ahc, SCSISIGI); in ahc_assert_atn()
2841 ahc_outb(ahc, SCSISIGO, scsisigo); in ahc_assert_atn()
2851 ahc_setup_initiator_msgout(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, in ahc_setup_initiator_msgout() argument
2859 ahc->msgout_index = 0; in ahc_setup_initiator_msgout()
2860 ahc->msgout_len = 0; in ahc_setup_initiator_msgout()
2863 && ahc_inb(ahc, MSG_OUT) == MSG_IDENTIFYFLAG) { in ahc_setup_initiator_msgout()
2869 ahc->msgout_buf[ahc->msgout_index++] = identify_msg; in ahc_setup_initiator_msgout()
2870 ahc->msgout_len++; in ahc_setup_initiator_msgout()
2873 ahc->msgout_buf[ahc->msgout_index++] = in ahc_setup_initiator_msgout()
2875 ahc->msgout_buf[ahc->msgout_index++] = scb->hscb->tag; in ahc_setup_initiator_msgout()
2876 ahc->msgout_len += 2; in ahc_setup_initiator_msgout()
2881 ahc->msgout_buf[ahc->msgout_index++] = TARGET_RESET; in ahc_setup_initiator_msgout()
2882 ahc->msgout_len++; in ahc_setup_initiator_msgout()
2883 ahc_print_path(ahc, scb); in ahc_setup_initiator_msgout()
2892 ahc_outb(ahc, SCSISEQ, (ahc_inb(ahc, SCSISEQ) & ~ENSELO)); in ahc_setup_initiator_msgout()
2895 ahc->msgout_buf[ahc->msgout_index++] = ABORT_TASK; in ahc_setup_initiator_msgout()
2897 ahc->msgout_buf[ahc->msgout_index++] = ABORT_TASK_SET; in ahc_setup_initiator_msgout()
2898 ahc->msgout_len++; in ahc_setup_initiator_msgout()
2899 ahc_print_path(ahc, scb); in ahc_setup_initiator_msgout()
2909 ahc_outb(ahc, SCSISEQ, (ahc_inb(ahc, SCSISEQ) & ~ENSELO)); in ahc_setup_initiator_msgout()
2911 ahc_build_transfer_msg(ahc, devinfo); in ahc_setup_initiator_msgout()
2919 ahc_inb(ahc, MSG_OUT), scb->flags); in ahc_setup_initiator_msgout()
2926 ahc_outb(ahc, SCB_CONTROL, ahc_inb(ahc, SCB_CONTROL) & ~MK_MESSAGE); in ahc_setup_initiator_msgout()
2928 ahc->msgout_index = 0; in ahc_setup_initiator_msgout()
2929 ahc->msg_type = MSG_TYPE_INITIATOR_MSGOUT; in ahc_setup_initiator_msgout()
2937 ahc_build_transfer_msg(struct ahc_softc *ahc, struct ahc_devinfo *devinfo) in ahc_build_transfer_msg() argument
2954 tinfo = ahc_fetch_transinfo(ahc, devinfo->channel, devinfo->our_scsiid, in ahc_build_transfer_msg()
2968 rate = ahc_devlimited_syncrate(ahc, tinfo, &period, in ahc_build_transfer_msg()
2989 if ((ahc->features & AHC_WIDE) != 0) in ahc_build_transfer_msg()
2995 ahc_print_devinfo(ahc, devinfo); in ahc_build_transfer_msg()
3015 ahc_validate_offset(ahc, tinfo, rate, &offset, in ahc_build_transfer_msg()
3020 ahc_construct_ppr(ahc, devinfo, period, offset, in ahc_build_transfer_msg()
3023 ahc_construct_sdtr(ahc, devinfo, period, offset); in ahc_build_transfer_msg()
3026 ahc_construct_wdtr(ahc, devinfo, tinfo->goal.width); in ahc_build_transfer_msg()
3035 ahc_construct_sdtr(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, in ahc_construct_sdtr() argument
3040 ahc->msgout_index += spi_populate_sync_msg( in ahc_construct_sdtr()
3041 ahc->msgout_buf + ahc->msgout_index, period, offset); in ahc_construct_sdtr()
3042 ahc->msgout_len += 5; in ahc_construct_sdtr()
3045 ahc_name(ahc), devinfo->channel, devinfo->target, in ahc_construct_sdtr()
3055 ahc_construct_wdtr(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, in ahc_construct_wdtr() argument
3058 ahc->msgout_index += spi_populate_width_msg( in ahc_construct_wdtr()
3059 ahc->msgout_buf + ahc->msgout_index, bus_width); in ahc_construct_wdtr()
3060 ahc->msgout_len += 4; in ahc_construct_wdtr()
3063 ahc_name(ahc), devinfo->channel, devinfo->target, in ahc_construct_wdtr()
3073 ahc_construct_ppr(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, in ahc_construct_ppr() argument
3079 ahc->msgout_index += spi_populate_ppr_msg( in ahc_construct_ppr()
3080 ahc->msgout_buf + ahc->msgout_index, period, offset, in ahc_construct_ppr()
3082 ahc->msgout_len += 8; in ahc_construct_ppr()
3085 "offset %x, ppr_options %x\n", ahc_name(ahc), in ahc_construct_ppr()
3095 ahc_clear_msg_state(struct ahc_softc *ahc) in ahc_clear_msg_state() argument
3097 ahc->msgout_len = 0; in ahc_clear_msg_state()
3098 ahc->msgin_index = 0; in ahc_clear_msg_state()
3099 ahc->msg_type = MSG_TYPE_NONE; in ahc_clear_msg_state()
3100 if ((ahc_inb(ahc, SCSISIGI) & ATNI) != 0) { in ahc_clear_msg_state()
3105 ahc_outb(ahc, CLRSINT1, CLRATNO); in ahc_clear_msg_state()
3107 ahc_outb(ahc, MSG_OUT, NOP); in ahc_clear_msg_state()
3108 ahc_outb(ahc, SEQ_FLAGS2, in ahc_clear_msg_state()
3109 ahc_inb(ahc, SEQ_FLAGS2) & ~TARGET_MSG_PENDING); in ahc_clear_msg_state()
3113 ahc_handle_proto_violation(struct ahc_softc *ahc) in ahc_handle_proto_violation() argument
3123 ahc_fetch_devinfo(ahc, &devinfo); in ahc_handle_proto_violation()
3124 scbid = ahc_inb(ahc, SCB_TAG); in ahc_handle_proto_violation()
3125 scb = ahc_lookup_scb(ahc, scbid); in ahc_handle_proto_violation()
3126 seq_flags = ahc_inb(ahc, SEQ_FLAGS); in ahc_handle_proto_violation()
3127 curphase = ahc_inb(ahc, SCSISIGI) & PHASE_MASK; in ahc_handle_proto_violation()
3128 lastphase = ahc_inb(ahc, LASTPHASE); in ahc_handle_proto_violation()
3136 ahc_print_devinfo(ahc, &devinfo); in ahc_handle_proto_violation()
3145 ahc_print_devinfo(ahc, &devinfo); in ahc_handle_proto_violation()
3151 ahc_print_path(ahc, scb); in ahc_handle_proto_violation()
3153 } else if ((ahc_inb(ahc, SCB_CONTROL) & STATUS_RCVD) == 0) { in ahc_handle_proto_violation()
3161 ahc_print_path(ahc, scb); in ahc_handle_proto_violation()
3164 ahc_print_path(ahc, scb); in ahc_handle_proto_violation()
3166 ahc_dump_card_state(ahc); in ahc_handle_proto_violation()
3178 found = ahc_reset_channel(ahc, 'A', TRUE); in ahc_handle_proto_violation()
3180 "%d SCBs aborted\n", ahc_name(ahc), 'A', found); in ahc_handle_proto_violation()
3187 ahc_outb(ahc, SCSISEQ, in ahc_handle_proto_violation()
3188 ahc_inb(ahc, SCSISEQ) & ~ENSELO); in ahc_handle_proto_violation()
3189 ahc_assert_atn(ahc); in ahc_handle_proto_violation()
3190 ahc_outb(ahc, MSG_OUT, HOST_MSG); in ahc_handle_proto_violation()
3192 ahc_print_devinfo(ahc, &devinfo); in ahc_handle_proto_violation()
3193 ahc->msgout_buf[0] = ABORT_TASK; in ahc_handle_proto_violation()
3194 ahc->msgout_len = 1; in ahc_handle_proto_violation()
3195 ahc->msgout_index = 0; in ahc_handle_proto_violation()
3196 ahc->msg_type = MSG_TYPE_INITIATOR_MSGOUT; in ahc_handle_proto_violation()
3198 ahc_print_path(ahc, scb); in ahc_handle_proto_violation()
3210 ahc_handle_message_phase(struct ahc_softc *ahc) in ahc_handle_message_phase() argument
3216 ahc_fetch_devinfo(ahc, &devinfo); in ahc_handle_message_phase()
3218 bus_phase = ahc_inb(ahc, SCSISIGI) & PHASE_MASK; in ahc_handle_message_phase()
3221 switch (ahc->msg_type) { in ahc_handle_message_phase()
3228 if (ahc->msgout_len == 0) in ahc_handle_message_phase()
3233 ahc_print_devinfo(ahc, &devinfo); in ahc_handle_message_phase()
3253 ahc_outb(ahc, CLRSINT1, CLRATNO); in ahc_handle_message_phase()
3254 ahc->send_msg_perror = FALSE; in ahc_handle_message_phase()
3255 ahc->msg_type = MSG_TYPE_INITIATOR_MSGIN; in ahc_handle_message_phase()
3256 ahc->msgin_index = 0; in ahc_handle_message_phase()
3263 if (ahc->send_msg_perror) { in ahc_handle_message_phase()
3264 ahc_outb(ahc, CLRSINT1, CLRATNO); in ahc_handle_message_phase()
3265 ahc_outb(ahc, CLRSINT1, CLRREQINIT); in ahc_handle_message_phase()
3268 printk(" byte 0x%x\n", ahc->send_msg_perror); in ahc_handle_message_phase()
3270 ahc_outb(ahc, SCSIDATL, MSG_PARITY_ERROR); in ahc_handle_message_phase()
3274 msgdone = ahc->msgout_index == ahc->msgout_len; in ahc_handle_message_phase()
3281 ahc->msgout_index = 0; in ahc_handle_message_phase()
3282 ahc_assert_atn(ahc); in ahc_handle_message_phase()
3285 lastbyte = ahc->msgout_index == (ahc->msgout_len - 1); in ahc_handle_message_phase()
3288 ahc_outb(ahc, CLRSINT1, CLRATNO); in ahc_handle_message_phase()
3295 ahc_outb(ahc, CLRSINT1, CLRREQINIT); in ahc_handle_message_phase()
3299 ahc->msgout_buf[ahc->msgout_index]); in ahc_handle_message_phase()
3301 ahc_outb(ahc, SCSIDATL, ahc->msgout_buf[ahc->msgout_index++]); in ahc_handle_message_phase()
3311 ahc_print_devinfo(ahc, &devinfo); in ahc_handle_message_phase()
3324 ahc->msgin_index = 0; in ahc_handle_message_phase()
3326 && (ahc->send_msg_perror == TRUE in ahc_handle_message_phase()
3327 || (ahc->msgout_len != 0 in ahc_handle_message_phase()
3328 && ahc->msgout_index == 0))) { in ahc_handle_message_phase()
3329 ahc->msg_type = MSG_TYPE_INITIATOR_MSGOUT; in ahc_handle_message_phase()
3337 ahc->msgin_buf[ahc->msgin_index] = ahc_inb(ahc, SCSIBUSL); in ahc_handle_message_phase()
3341 ahc->msgin_buf[ahc->msgin_index]); in ahc_handle_message_phase()
3344 message_done = ahc_parse_msg(ahc, &devinfo); in ahc_handle_message_phase()
3351 ahc->msgin_index = 0; in ahc_handle_message_phase()
3358 if (ahc->msgout_len != 0) { in ahc_handle_message_phase()
3361 ahc_print_devinfo(ahc, &devinfo); in ahc_handle_message_phase()
3365 ahc_assert_atn(ahc); in ahc_handle_message_phase()
3368 ahc->msgin_index++; in ahc_handle_message_phase()
3374 ahc_outb(ahc, CLRSINT1, CLRREQINIT); in ahc_handle_message_phase()
3375 ahc_inb(ahc, SCSIDATL); in ahc_handle_message_phase()
3384 if (ahc->msgout_len == 0) in ahc_handle_message_phase()
3393 if ((ahc_inb(ahc, SCSISIGI) & ATNI) != 0 in ahc_handle_message_phase()
3394 && ahc->msgout_index > 0) in ahc_handle_message_phase()
3407 ahc->msg_type = MSG_TYPE_TARGET_MSGOUT; in ahc_handle_message_phase()
3408 ahc_outb(ahc, SCSISIGO, P_MESGOUT | BSYO); in ahc_handle_message_phase()
3409 ahc->msgin_index = 0; in ahc_handle_message_phase()
3411 ahc_inb(ahc, SCSIDATL); in ahc_handle_message_phase()
3412 ahc_outb(ahc, SXFRCTL0, in ahc_handle_message_phase()
3413 ahc_inb(ahc, SXFRCTL0) | SPIOEN); in ahc_handle_message_phase()
3417 msgdone = ahc->msgout_index == ahc->msgout_len; in ahc_handle_message_phase()
3419 ahc_outb(ahc, SXFRCTL0, in ahc_handle_message_phase()
3420 ahc_inb(ahc, SXFRCTL0) & ~SPIOEN); in ahc_handle_message_phase()
3428 ahc_outb(ahc, SXFRCTL0, ahc_inb(ahc, SXFRCTL0) | SPIOEN); in ahc_handle_message_phase()
3429 ahc_outb(ahc, SCSIDATL, ahc->msgout_buf[ahc->msgout_index++]); in ahc_handle_message_phase()
3441 lastbyte = (ahc_inb(ahc, SCSISIGI) & ATNI) == 0; in ahc_handle_message_phase()
3448 ahc_outb(ahc, SXFRCTL0, ahc_inb(ahc, SXFRCTL0) & ~SPIOEN); in ahc_handle_message_phase()
3449 ahc->msgin_buf[ahc->msgin_index] = ahc_inb(ahc, SCSIDATL); in ahc_handle_message_phase()
3450 msgdone = ahc_parse_msg(ahc, &devinfo); in ahc_handle_message_phase()
3461 ahc->msgin_index++; in ahc_handle_message_phase()
3468 ahc->msgin_index = 0; in ahc_handle_message_phase()
3474 if (ahc->msgout_len != 0) { in ahc_handle_message_phase()
3475 ahc_outb(ahc, SCSISIGO, P_MESGIN | BSYO); in ahc_handle_message_phase()
3476 ahc_outb(ahc, SXFRCTL0, in ahc_handle_message_phase()
3477 ahc_inb(ahc, SXFRCTL0) | SPIOEN); in ahc_handle_message_phase()
3478 ahc->msg_type = MSG_TYPE_TARGET_MSGIN; in ahc_handle_message_phase()
3479 ahc->msgin_index = 0; in ahc_handle_message_phase()
3488 ahc_outb(ahc, SXFRCTL0, in ahc_handle_message_phase()
3489 ahc_inb(ahc, SXFRCTL0) | SPIOEN); in ahc_handle_message_phase()
3499 ahc_clear_msg_state(ahc); in ahc_handle_message_phase()
3500 ahc_outb(ahc, RETURN_1, EXIT_MSG_LOOP); in ahc_handle_message_phase()
3502 ahc_outb(ahc, RETURN_1, CONT_MSG_LOOP); in ahc_handle_message_phase()
3512 ahc_sent_msg(struct ahc_softc *ahc, ahc_msgtype type, u_int msgval, int full) in ahc_sent_msg() argument
3520 while (index < ahc->msgout_len) { in ahc_sent_msg()
3521 if (ahc->msgout_buf[index] == EXTENDED_MESSAGE) { in ahc_sent_msg()
3524 end_index = index + 1 + ahc->msgout_buf[index + 1]; in ahc_sent_msg()
3525 if (ahc->msgout_buf[index+2] == msgval in ahc_sent_msg()
3529 if (ahc->msgout_index > end_index) in ahc_sent_msg()
3531 } else if (ahc->msgout_index > index) in ahc_sent_msg()
3535 } else if (ahc->msgout_buf[index] >= SIMPLE_QUEUE_TAG in ahc_sent_msg()
3536 && ahc->msgout_buf[index] <= IGNORE_WIDE_RESIDUE) { in ahc_sent_msg()
3543 && ahc->msgout_buf[index] == msgval in ahc_sent_msg()
3544 && ahc->msgout_index > index) in ahc_sent_msg()
3559 ahc_parse_msg(struct ahc_softc *ahc, struct ahc_devinfo *devinfo) in ahc_parse_msg() argument
3571 tinfo = ahc_fetch_transinfo(ahc, devinfo->channel, devinfo->our_scsiid, in ahc_parse_msg()
3586 switch (ahc->msgin_buf[0]) { in ahc_parse_msg()
3599 response = ahc_handle_msg_reject(ahc, devinfo); in ahc_parse_msg()
3607 if (ahc->msgin_index < 2) in ahc_parse_msg()
3609 switch (ahc->msgin_buf[2]) { in ahc_parse_msg()
3618 if (ahc->msgin_buf[1] != MSG_EXT_SDTR_LEN) { in ahc_parse_msg()
3630 if (ahc->msgin_index < (MSG_EXT_SDTR_LEN + 1)) in ahc_parse_msg()
3633 period = ahc->msgin_buf[3]; in ahc_parse_msg()
3635 saved_offset = offset = ahc->msgin_buf[4]; in ahc_parse_msg()
3636 syncrate = ahc_devlimited_syncrate(ahc, tinfo, &period, in ahc_parse_msg()
3639 ahc_validate_offset(ahc, tinfo, syncrate, &offset, in ahc_parse_msg()
3646 ahc_name(ahc), devinfo->channel, in ahc_parse_msg()
3648 ahc->msgin_buf[3], saved_offset, in ahc_parse_msg()
3651 ahc_set_syncrate(ahc, devinfo, in ahc_parse_msg()
3662 if (ahc_sent_msg(ahc, AHCMSG_EXT, EXTENDED_SDTR, TRUE)) { in ahc_parse_msg()
3676 ahc_name(ahc), devinfo->channel, in ahc_parse_msg()
3679 ahc->msgout_index = 0; in ahc_parse_msg()
3680 ahc->msgout_len = 0; in ahc_parse_msg()
3681 ahc_construct_sdtr(ahc, devinfo, in ahc_parse_msg()
3683 ahc->msgout_index = 0; in ahc_parse_msg()
3696 if (ahc->msgin_buf[1] != MSG_EXT_WDTR_LEN) { in ahc_parse_msg()
3708 if (ahc->msgin_index < (MSG_EXT_WDTR_LEN + 1)) in ahc_parse_msg()
3711 bus_width = ahc->msgin_buf[3]; in ahc_parse_msg()
3713 ahc_validate_width(ahc, tinfo, &bus_width, in ahc_parse_msg()
3718 ahc_name(ahc), devinfo->channel, in ahc_parse_msg()
3723 if (ahc_sent_msg(ahc, AHCMSG_EXT, EXTENDED_WDTR, TRUE)) { in ahc_parse_msg()
3734 ahc_name(ahc), devinfo->channel, in ahc_parse_msg()
3747 ahc_name(ahc), devinfo->channel, in ahc_parse_msg()
3750 ahc->msgout_index = 0; in ahc_parse_msg()
3751 ahc->msgout_len = 0; in ahc_parse_msg()
3752 ahc_construct_wdtr(ahc, devinfo, bus_width); in ahc_parse_msg()
3753 ahc->msgout_index = 0; in ahc_parse_msg()
3766 ahc_update_neg_request(ahc, devinfo, tstate, in ahc_parse_msg()
3768 ahc_set_width(ahc, devinfo, bus_width, in ahc_parse_msg()
3776 ahc->msgout_index = 0; in ahc_parse_msg()
3777 ahc->msgout_len = 0; in ahc_parse_msg()
3778 ahc_build_transfer_msg(ahc, devinfo); in ahc_parse_msg()
3779 ahc->msgout_index = 0; in ahc_parse_msg()
3796 if (ahc->msgin_buf[1] != MSG_EXT_PPR_LEN) { in ahc_parse_msg()
3808 if (ahc->msgin_index < (MSG_EXT_PPR_LEN + 1)) in ahc_parse_msg()
3811 period = ahc->msgin_buf[3]; in ahc_parse_msg()
3812 offset = ahc->msgin_buf[5]; in ahc_parse_msg()
3813 bus_width = ahc->msgin_buf[6]; in ahc_parse_msg()
3815 ppr_options = ahc->msgin_buf[7]; in ahc_parse_msg()
3836 ahc_validate_width(ahc, tinfo, &bus_width, in ahc_parse_msg()
3838 syncrate = ahc_devlimited_syncrate(ahc, tinfo, &period, in ahc_parse_msg()
3841 ahc_validate_offset(ahc, tinfo, syncrate, in ahc_parse_msg()
3845 if (ahc_sent_msg(ahc, AHCMSG_EXT, EXTENDED_PPR, TRUE)) { in ahc_parse_msg()
3865 ahc_name(ahc), devinfo->channel, in ahc_parse_msg()
3870 ahc_name(ahc), devinfo->channel, in ahc_parse_msg()
3872 ahc->msgout_index = 0; in ahc_parse_msg()
3873 ahc->msgout_len = 0; in ahc_parse_msg()
3874 ahc_construct_ppr(ahc, devinfo, period, offset, in ahc_parse_msg()
3876 ahc->msgout_index = 0; in ahc_parse_msg()
3884 ahc_name(ahc), devinfo->channel, in ahc_parse_msg()
3886 saved_width, ahc->msgin_buf[3], in ahc_parse_msg()
3890 ahc_set_width(ahc, devinfo, bus_width, in ahc_parse_msg()
3893 ahc_set_syncrate(ahc, devinfo, in ahc_parse_msg()
3910 ahc_handle_devreset(ahc, devinfo, in ahc_parse_msg()
3914 ahc_restart(ahc); in ahc_parse_msg()
3929 if (ahc->msgin_buf[0] == ABORT_TASK) in ahc_parse_msg()
3930 tag = ahc_inb(ahc, INITIATOR_TAG); in ahc_parse_msg()
3931 ahc_abort_scbs(ahc, devinfo->target, devinfo->channel, in ahc_parse_msg()
3935 tstate = ahc->enabled_targets[devinfo->our_scsiid]; in ahc_parse_msg()
3941 ahc_queue_lstate_event(ahc, lstate, in ahc_parse_msg()
3943 ahc->msgin_buf[0], in ahc_parse_msg()
3945 ahc_send_lstate_events(ahc, lstate); in ahc_parse_msg()
3948 ahc_restart(ahc); in ahc_parse_msg()
3963 ahc->msgout_index = 0; in ahc_parse_msg()
3964 ahc->msgout_len = 1; in ahc_parse_msg()
3965 ahc->msgout_buf[0] = MESSAGE_REJECT; in ahc_parse_msg()
3972 ahc->msgout_len = 0; in ahc_parse_msg()
3981 ahc_handle_msg_reject(struct ahc_softc *ahc, struct ahc_devinfo *devinfo) in ahc_handle_msg_reject() argument
3996 scb_index = ahc_inb(ahc, SCB_TAG); in ahc_handle_msg_reject()
3997 scb = ahc_lookup_scb(ahc, scb_index); in ahc_handle_msg_reject()
3998 tinfo = ahc_fetch_transinfo(ahc, devinfo->channel, in ahc_handle_msg_reject()
4002 last_msg = ahc_inb(ahc, LAST_MSG); in ahc_handle_msg_reject()
4004 if (ahc_sent_msg(ahc, AHCMSG_EXT, EXTENDED_PPR, /*full*/FALSE)) { in ahc_handle_msg_reject()
4012 ahc_name(ahc), devinfo->channel, in ahc_handle_msg_reject()
4018 ahc->msgout_index = 0; in ahc_handle_msg_reject()
4019 ahc->msgout_len = 0; in ahc_handle_msg_reject()
4020 ahc_build_transfer_msg(ahc, devinfo); in ahc_handle_msg_reject()
4021 ahc->msgout_index = 0; in ahc_handle_msg_reject()
4023 } else if (ahc_sent_msg(ahc, AHCMSG_EXT, EXTENDED_WDTR, /*full*/FALSE)) { in ahc_handle_msg_reject()
4027 "8bit transfers\n", ahc_name(ahc), in ahc_handle_msg_reject()
4029 ahc_set_width(ahc, devinfo, MSG_EXT_WDTR_BUS_8_BIT, in ahc_handle_msg_reject()
4042 ahc->msgout_index = 0; in ahc_handle_msg_reject()
4043 ahc->msgout_len = 0; in ahc_handle_msg_reject()
4044 ahc_build_transfer_msg(ahc, devinfo); in ahc_handle_msg_reject()
4045 ahc->msgout_index = 0; in ahc_handle_msg_reject()
4048 } else if (ahc_sent_msg(ahc, AHCMSG_EXT, EXTENDED_SDTR, /*full*/FALSE)) { in ahc_handle_msg_reject()
4050 ahc_set_syncrate(ahc, devinfo, /*syncrate*/NULL, /*period*/0, in ahc_handle_msg_reject()
4056 ahc_name(ahc), devinfo->channel, in ahc_handle_msg_reject()
4066 "Performing non-tagged I/O\n", ahc_name(ahc), in ahc_handle_msg_reject()
4068 ahc_set_tags(ahc, scb->io_ctx, devinfo, AHC_QUEUE_NONE); in ahc_handle_msg_reject()
4073 ahc_name(ahc), devinfo->channel, devinfo->target, in ahc_handle_msg_reject()
4076 ahc_set_tags(ahc, scb->io_ctx, devinfo, AHC_QUEUE_BASIC); in ahc_handle_msg_reject()
4084 ahc_outb(ahc, SCB_CONTROL, in ahc_handle_msg_reject()
4085 ahc_inb(ahc, SCB_CONTROL) & mask); in ahc_handle_msg_reject()
4089 ahc_outb(ahc, MSG_OUT, MSG_IDENTIFYFLAG); in ahc_handle_msg_reject()
4090 ahc_assert_atn(ahc); in ahc_handle_msg_reject()
4096 if ((ahc->flags & AHC_SCB_BTT) == 0) { in ahc_handle_msg_reject()
4100 &(ahc->untagged_queues[devinfo->target_offset]); in ahc_handle_msg_reject()
4104 ahc_busy_tcl(ahc, BUILD_TCL(scb->hscb->scsiid, devinfo->lun), in ahc_handle_msg_reject()
4112 ahc_search_qinfifo(ahc, SCB_GET_TARGET(ahc, scb), in ahc_handle_msg_reject()
4113 SCB_GET_CHANNEL(ahc, scb), in ahc_handle_msg_reject()
4122 ahc_name(ahc), devinfo->channel, devinfo->target, in ahc_handle_msg_reject()
4132 ahc_handle_ign_wide_residue(struct ahc_softc *ahc, struct ahc_devinfo *devinfo) in ahc_handle_ign_wide_residue() argument
4137 scb_index = ahc_inb(ahc, SCB_TAG); in ahc_handle_ign_wide_residue()
4138 scb = ahc_lookup_scb(ahc, scb_index); in ahc_handle_ign_wide_residue()
4143 if ((ahc_inb(ahc, SEQ_FLAGS) & DPHASE) == 0 in ahc_handle_ign_wide_residue()
4159 sgptr = ahc_inb(ahc, SCB_RESIDUAL_SGPTR); in ahc_handle_ign_wide_residue()
4161 && (ahc_inb(ahc, SCB_LUN) & SCB_XFERLEN_ODD) != 0) { in ahc_handle_ign_wide_residue()
4175 sgptr = ahc_inl(ahc, SCB_RESIDUAL_SGPTR); in ahc_handle_ign_wide_residue()
4176 data_cnt = ahc_inl(ahc, SCB_RESIDUAL_DATACNT); in ahc_handle_ign_wide_residue()
4187 data_addr = ahc_inl(ahc, SHADDR); in ahc_handle_ign_wide_residue()
4221 ahc_outl(ahc, SCB_RESIDUAL_SGPTR, sgptr); in ahc_handle_ign_wide_residue()
4222 ahc_outl(ahc, SCB_RESIDUAL_DATACNT, data_cnt); in ahc_handle_ign_wide_residue()
4229 ahc_outb(ahc, SCB_LUN, in ahc_handle_ign_wide_residue()
4230 ahc_inb(ahc, SCB_LUN) ^ SCB_XFERLEN_ODD); in ahc_handle_ign_wide_residue()
4241 ahc_reinitialize_dataptrs(struct ahc_softc *ahc) in ahc_reinitialize_dataptrs() argument
4250 scb_index = ahc_inb(ahc, SCB_TAG); in ahc_reinitialize_dataptrs()
4251 scb = ahc_lookup_scb(ahc, scb_index); in ahc_reinitialize_dataptrs()
4252 sgptr = (ahc_inb(ahc, SCB_RESIDUAL_SGPTR + 3) << 24) in ahc_reinitialize_dataptrs()
4253 | (ahc_inb(ahc, SCB_RESIDUAL_SGPTR + 2) << 16) in ahc_reinitialize_dataptrs()
4254 | (ahc_inb(ahc, SCB_RESIDUAL_SGPTR + 1) << 8) in ahc_reinitialize_dataptrs()
4255 | ahc_inb(ahc, SCB_RESIDUAL_SGPTR); in ahc_reinitialize_dataptrs()
4263 resid = (ahc_inb(ahc, SCB_RESIDUAL_DATACNT + 2) << 16) in ahc_reinitialize_dataptrs()
4264 | (ahc_inb(ahc, SCB_RESIDUAL_DATACNT + 1) << 8) in ahc_reinitialize_dataptrs()
4265 | ahc_inb(ahc, SCB_RESIDUAL_DATACNT); in ahc_reinitialize_dataptrs()
4270 if ((ahc->flags & AHC_39BIT_ADDRESSING) != 0) { in ahc_reinitialize_dataptrs()
4273 dscommand1 = ahc_inb(ahc, DSCOMMAND1); in ahc_reinitialize_dataptrs()
4274 ahc_outb(ahc, DSCOMMAND1, dscommand1 | HADDLDSEL0); in ahc_reinitialize_dataptrs()
4275 ahc_outb(ahc, HADDR, in ahc_reinitialize_dataptrs()
4277 ahc_outb(ahc, DSCOMMAND1, dscommand1); in ahc_reinitialize_dataptrs()
4279 ahc_outb(ahc, HADDR + 3, dataptr >> 24); in ahc_reinitialize_dataptrs()
4280 ahc_outb(ahc, HADDR + 2, dataptr >> 16); in ahc_reinitialize_dataptrs()
4281 ahc_outb(ahc, HADDR + 1, dataptr >> 8); in ahc_reinitialize_dataptrs()
4282 ahc_outb(ahc, HADDR, dataptr); in ahc_reinitialize_dataptrs()
4283 ahc_outb(ahc, HCNT + 2, resid >> 16); in ahc_reinitialize_dataptrs()
4284 ahc_outb(ahc, HCNT + 1, resid >> 8); in ahc_reinitialize_dataptrs()
4285 ahc_outb(ahc, HCNT, resid); in ahc_reinitialize_dataptrs()
4286 if ((ahc->features & AHC_ULTRA2) == 0) { in ahc_reinitialize_dataptrs()
4287 ahc_outb(ahc, STCNT + 2, resid >> 16); in ahc_reinitialize_dataptrs()
4288 ahc_outb(ahc, STCNT + 1, resid >> 8); in ahc_reinitialize_dataptrs()
4289 ahc_outb(ahc, STCNT, resid); in ahc_reinitialize_dataptrs()
4297 ahc_handle_devreset(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, in ahc_handle_devreset() argument
4306 found = ahc_abort_scbs(ahc, devinfo->target, devinfo->channel, in ahc_handle_devreset()
4315 tstate = ahc->enabled_targets[devinfo->our_scsiid]; in ahc_handle_devreset()
4324 ahc_queue_lstate_event(ahc, lstate, devinfo->our_scsiid, in ahc_handle_devreset()
4326 ahc_send_lstate_events(ahc, lstate); in ahc_handle_devreset()
4334 ahc_set_width(ahc, devinfo, MSG_EXT_WDTR_BUS_8_BIT, in ahc_handle_devreset()
4336 ahc_set_syncrate(ahc, devinfo, /*syncrate*/NULL, in ahc_handle_devreset()
4341 ahc_send_async(ahc, devinfo->channel, devinfo->target, in ahc_handle_devreset()
4346 printk("%s: %s on %c:%d. %d SCBs aborted\n", ahc_name(ahc), in ahc_handle_devreset()
4352 ahc_setup_target_msgin(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, in ahc_setup_target_msgin() argument
4361 ahc->msgout_index = 0; in ahc_setup_target_msgin()
4362 ahc->msgout_len = 0; in ahc_setup_target_msgin()
4365 ahc_build_transfer_msg(ahc, devinfo); in ahc_setup_target_msgin()
4369 ahc->msgout_index = 0; in ahc_setup_target_msgin()
4370 ahc->msg_type = MSG_TYPE_TARGET_MSGIN; in ahc_setup_target_msgin()
4381 struct ahc_softc *ahc; in ahc_alloc() local
4384 ahc = kzalloc(sizeof(*ahc), GFP_ATOMIC); in ahc_alloc()
4385 if (!ahc) { in ahc_alloc()
4391 ahc->seep_config = kmalloc(sizeof(*ahc->seep_config), GFP_ATOMIC); in ahc_alloc()
4392 if (ahc->seep_config == NULL) { in ahc_alloc()
4393 kfree(ahc); in ahc_alloc()
4397 LIST_INIT(&ahc->pending_scbs); in ahc_alloc()
4399 ahc->name = name; in ahc_alloc()
4400 ahc->unit = -1; in ahc_alloc()
4401 ahc->description = NULL; in ahc_alloc()
4402 ahc->channel = 'A'; in ahc_alloc()
4403 ahc->channel_b = 'B'; in ahc_alloc()
4404 ahc->chip = AHC_NONE; in ahc_alloc()
4405 ahc->features = AHC_FENONE; in ahc_alloc()
4406 ahc->bugs = AHC_BUGNONE; in ahc_alloc()
4407 ahc->flags = AHC_FNONE; in ahc_alloc()
4413 ahc->seqctl = FASTMODE; in ahc_alloc()
4416 TAILQ_INIT(&ahc->untagged_queues[i]); in ahc_alloc()
4417 if (ahc_platform_alloc(ahc, platform_arg) != 0) { in ahc_alloc()
4418 ahc_free(ahc); in ahc_alloc()
4419 ahc = NULL; in ahc_alloc()
4421 return (ahc); in ahc_alloc()
4425 ahc_softc_init(struct ahc_softc *ahc) in ahc_softc_init() argument
4429 if ((ahc->chip & AHC_PCI) == 0) in ahc_softc_init()
4430 ahc->unpause = ahc_inb(ahc, HCNTRL) & IRQMS; in ahc_softc_init()
4432 ahc->unpause = 0; in ahc_softc_init()
4433 ahc->pause = ahc->unpause | PAUSE; in ahc_softc_init()
4435 if (ahc->scb_data == NULL) { in ahc_softc_init()
4436 ahc->scb_data = kzalloc(sizeof(*ahc->scb_data), GFP_ATOMIC); in ahc_softc_init()
4437 if (ahc->scb_data == NULL) in ahc_softc_init()
4445 ahc_set_unit(struct ahc_softc *ahc, int unit) in ahc_set_unit() argument
4447 ahc->unit = unit; in ahc_set_unit()
4451 ahc_set_name(struct ahc_softc *ahc, char *name) in ahc_set_name() argument
4453 kfree(ahc->name); in ahc_set_name()
4454 ahc->name = name; in ahc_set_name()
4458 ahc_free(struct ahc_softc *ahc) in ahc_free() argument
4462 switch (ahc->init_level) { in ahc_free()
4465 ahc_shutdown(ahc); in ahc_free()
4468 ahc_dmamap_unload(ahc, ahc->shared_data_dmat, in ahc_free()
4469 ahc->shared_data_dmamap); in ahc_free()
4472 ahc_dmamem_free(ahc, ahc->shared_data_dmat, ahc->qoutfifo, in ahc_free()
4473 ahc->shared_data_dmamap); in ahc_free()
4474 ahc_dmamap_destroy(ahc, ahc->shared_data_dmat, in ahc_free()
4475 ahc->shared_data_dmamap); in ahc_free()
4478 ahc_dma_tag_destroy(ahc, ahc->shared_data_dmat); in ahc_free()
4486 ahc_platform_free(ahc); in ahc_free()
4487 ahc_fini_scbdata(ahc); in ahc_free()
4491 tstate = ahc->enabled_targets[i]; in ahc_free()
4510 if (ahc->black_hole != NULL) { in ahc_free()
4511 xpt_free_path(ahc->black_hole->path); in ahc_free()
4512 kfree(ahc->black_hole); in ahc_free()
4515 kfree(ahc->name); in ahc_free()
4516 kfree(ahc->seep_config); in ahc_free()
4517 kfree(ahc); in ahc_free()
4524 struct ahc_softc *ahc; in ahc_shutdown() local
4527 ahc = (struct ahc_softc *)arg; in ahc_shutdown()
4530 ahc_reset(ahc, /*reinit*/FALSE); in ahc_shutdown()
4531 ahc_outb(ahc, SCSISEQ, 0); in ahc_shutdown()
4532 ahc_outb(ahc, SXFRCTL0, 0); in ahc_shutdown()
4533 ahc_outb(ahc, DSPCISTATUS, 0); in ahc_shutdown()
4536 ahc_outb(ahc, i, 0); in ahc_shutdown()
4549 ahc_reset(struct ahc_softc *ahc, int reinit) in ahc_reset() argument
4561 ahc_pause(ahc); in ahc_reset()
4563 if ((ahc->chip & AHC_CHIPID_MASK) == AHC_AIC7770) { in ahc_reset()
4570 sblkctl = ahc_inb(ahc, SBLKCTL); in ahc_reset()
4571 ahc_outb(ahc, SBLKCTL, sblkctl | SELBUSB); in ahc_reset()
4572 sxfrctl1_b = ahc_inb(ahc, SXFRCTL1); in ahc_reset()
4573 ahc_outb(ahc, SBLKCTL, sblkctl & ~SELBUSB); in ahc_reset()
4575 sxfrctl1_a = ahc_inb(ahc, SXFRCTL1); in ahc_reset()
4577 ahc_outb(ahc, HCNTRL, CHIPRST | ahc->pause); in ahc_reset()
4588 } while (--wait && !(ahc_inb(ahc, HCNTRL) & CHIPRSTACK)); in ahc_reset()
4592 "Trying to initialize anyway.\n", ahc_name(ahc)); in ahc_reset()
4594 ahc_outb(ahc, HCNTRL, ahc->pause); in ahc_reset()
4597 sblkctl = ahc_inb(ahc, SBLKCTL) & (SELBUSB|SELWIDE); in ahc_reset()
4599 if ((ahc->chip & AHC_PCI) != 0) in ahc_reset()
4607 ahc->features |= AHC_WIDE; in ahc_reset()
4611 ahc->features |= AHC_TWIN; in ahc_reset()
4626 if ((ahc->features & AHC_TWIN) != 0) { in ahc_reset()
4629 sblkctl = ahc_inb(ahc, SBLKCTL); in ahc_reset()
4630 ahc_outb(ahc, SBLKCTL, sblkctl | SELBUSB); in ahc_reset()
4631 ahc_outb(ahc, SXFRCTL1, sxfrctl1_b); in ahc_reset()
4632 ahc_outb(ahc, SBLKCTL, sblkctl & ~SELBUSB); in ahc_reset()
4634 ahc_outb(ahc, SXFRCTL1, sxfrctl1_a); in ahc_reset()
4642 error = ahc->bus_chip_init(ahc); in ahc_reset()
4645 ahc_dumpseq(ahc); in ahc_reset()
4655 ahc_probe_scbs(struct ahc_softc *ahc) { in ahc_probe_scbs() argument
4660 ahc_outb(ahc, SCBPTR, i); in ahc_probe_scbs()
4661 ahc_outb(ahc, SCB_BASE, i); in ahc_probe_scbs()
4662 if (ahc_inb(ahc, SCB_BASE) != i) in ahc_probe_scbs()
4664 ahc_outb(ahc, SCBPTR, 0); in ahc_probe_scbs()
4665 if (ahc_inb(ahc, SCB_BASE) != 0) in ahc_probe_scbs()
4681 ahc_build_free_scb_list(struct ahc_softc *ahc) in ahc_build_free_scb_list() argument
4687 if ((ahc->flags & AHC_LSCBS_ENABLED) != 0) in ahc_build_free_scb_list()
4690 for (i = 0; i < ahc->scb_data->maxhscbs; i++) { in ahc_build_free_scb_list()
4693 ahc_outb(ahc, SCBPTR, i); in ahc_build_free_scb_list()
4701 ahc_outb(ahc, SCB_BASE+j, 0xFF); in ahc_build_free_scb_list()
4704 ahc_outb(ahc, SCB_CONTROL, 0); in ahc_build_free_scb_list()
4707 if ((ahc->flags & AHC_PAGESCBS) != 0) in ahc_build_free_scb_list()
4708 ahc_outb(ahc, SCB_NEXT, i+1); in ahc_build_free_scb_list()
4710 ahc_outb(ahc, SCB_NEXT, SCB_LIST_NULL); in ahc_build_free_scb_list()
4713 ahc_outb(ahc, SCB_TAG, SCB_LIST_NULL); in ahc_build_free_scb_list()
4714 ahc_outb(ahc, SCB_SCSIID, 0xFF); in ahc_build_free_scb_list()
4715 ahc_outb(ahc, SCB_LUN, 0xFF); in ahc_build_free_scb_list()
4718 if ((ahc->flags & AHC_PAGESCBS) != 0) { in ahc_build_free_scb_list()
4720 ahc_outb(ahc, FREE_SCBH, 0); in ahc_build_free_scb_list()
4723 ahc_outb(ahc, FREE_SCBH, SCB_LIST_NULL); in ahc_build_free_scb_list()
4727 ahc_outb(ahc, SCBPTR, i-1); in ahc_build_free_scb_list()
4728 ahc_outb(ahc, SCB_NEXT, SCB_LIST_NULL); in ahc_build_free_scb_list()
4732 ahc_init_scbdata(struct ahc_softc *ahc) in ahc_init_scbdata() argument
4736 scb_data = ahc->scb_data; in ahc_init_scbdata()
4748 scb_data->maxhscbs = ahc_probe_scbs(ahc); in ahc_init_scbdata()
4749 if (ahc->scb_data->maxhscbs == 0) { in ahc_init_scbdata()
4750 printk("%s: No SCB space found\n", ahc_name(ahc)); in ahc_init_scbdata()
4765 if (ahc_dma_tag_create(ahc, ahc->parent_dmat, /*alignment*/1, in ahc_init_scbdata()
4780 if (ahc_dmamem_alloc(ahc, scb_data->hscb_dmat, in ahc_init_scbdata()
4789 ahc_dmamap_load(ahc, scb_data->hscb_dmat, scb_data->hscb_dmamap, in ahc_init_scbdata()
4797 if (ahc_dma_tag_create(ahc, ahc->parent_dmat, /*alignment*/1, in ahc_init_scbdata()
4812 if (ahc_dmamem_alloc(ahc, scb_data->sense_dmat, in ahc_init_scbdata()
4821 ahc_dmamap_load(ahc, scb_data->sense_dmat, scb_data->sense_dmamap, in ahc_init_scbdata()
4829 if (ahc_dma_tag_create(ahc, ahc->parent_dmat, /*alignment*/8, in ahc_init_scbdata()
4845 ahc_alloc_scbs(ahc); in ahc_init_scbdata()
4850 ahc_name(ahc)); in ahc_init_scbdata()
4857 ahc->next_queued_scb = ahc_get_scb(ahc); in ahc_init_scbdata()
4870 ahc_fini_scbdata(struct ahc_softc *ahc) in ahc_fini_scbdata() argument
4874 scb_data = ahc->scb_data; in ahc_fini_scbdata()
4886 ahc_dmamap_unload(ahc, scb_data->sg_dmat, in ahc_fini_scbdata()
4888 ahc_dmamem_free(ahc, scb_data->sg_dmat, in ahc_fini_scbdata()
4893 ahc_dma_tag_destroy(ahc, scb_data->sg_dmat); in ahc_fini_scbdata()
4897 ahc_dmamap_unload(ahc, scb_data->sense_dmat, in ahc_fini_scbdata()
4901 ahc_dmamem_free(ahc, scb_data->sense_dmat, scb_data->sense, in ahc_fini_scbdata()
4903 ahc_dmamap_destroy(ahc, scb_data->sense_dmat, in ahc_fini_scbdata()
4907 ahc_dma_tag_destroy(ahc, scb_data->sense_dmat); in ahc_fini_scbdata()
4910 ahc_dmamap_unload(ahc, scb_data->hscb_dmat, in ahc_fini_scbdata()
4914 ahc_dmamem_free(ahc, scb_data->hscb_dmat, scb_data->hscbs, in ahc_fini_scbdata()
4916 ahc_dmamap_destroy(ahc, scb_data->hscb_dmat, in ahc_fini_scbdata()
4920 ahc_dma_tag_destroy(ahc, scb_data->hscb_dmat); in ahc_fini_scbdata()
4929 ahc_alloc_scbs(struct ahc_softc *ahc) in ahc_alloc_scbs() argument
4939 scb_data = ahc->scb_data; in ahc_alloc_scbs()
4952 if (ahc_dmamem_alloc(ahc, scb_data->sg_dmat, in ahc_alloc_scbs()
4961 ahc_dmamap_load(ahc, scb_data->sg_dmat, sg_map->sg_dmamap, in ahc_alloc_scbs()
4984 next_scb->ahc_softc = ahc; in ahc_alloc_scbs()
4987 next_scb->hscb->tag = ahc->scb_data->numscbs; in ahc_alloc_scbs()
4988 SLIST_INSERT_HEAD(&ahc->scb_data->free_scbs, in ahc_alloc_scbs()
4993 ahc->scb_data->numscbs++; in ahc_alloc_scbs()
4998 ahc_controller_info(struct ahc_softc *ahc, char *buf) in ahc_controller_info() argument
5002 len = sprintf(buf, "%s: ", ahc_chip_names[ahc->chip & AHC_CHIPID_MASK]); in ahc_controller_info()
5004 if ((ahc->features & AHC_TWIN) != 0) in ahc_controller_info()
5007 ahc->our_id, ahc->our_id_b, in ahc_controller_info()
5008 (ahc->flags & AHC_PRIMARY_CHANNEL) + 'A'); in ahc_controller_info()
5014 if ((ahc->features & AHC_ULTRA) != 0) { in ahc_controller_info()
5016 } else if ((ahc->features & AHC_DT) != 0) { in ahc_controller_info()
5018 } else if ((ahc->features & AHC_ULTRA2) != 0) { in ahc_controller_info()
5021 if ((ahc->features & AHC_WIDE) != 0) { in ahc_controller_info()
5027 speed, type, ahc->channel, ahc->our_id); in ahc_controller_info()
5031 if ((ahc->flags & AHC_PAGESCBS) != 0) in ahc_controller_info()
5033 ahc->scb_data->maxhscbs, AHC_MAX_QUEUE); in ahc_controller_info()
5035 sprintf(buf, "%d SCBs", ahc->scb_data->maxhscbs); in ahc_controller_info()
5039 ahc_chip_init(struct ahc_softc *ahc) in ahc_chip_init() argument
5048 ahc_outb(ahc, SEQ_FLAGS, 0); in ahc_chip_init()
5049 ahc_outb(ahc, SEQ_FLAGS2, 0); in ahc_chip_init()
5052 if (ahc->features & AHC_TWIN) { in ahc_chip_init()
5057 ahc_outb(ahc, SBLKCTL, ahc_inb(ahc, SBLKCTL) | SELBUSB); in ahc_chip_init()
5058 term = (ahc->flags & AHC_TERM_ENB_B) != 0 ? STPWEN : 0; in ahc_chip_init()
5059 ahc_outb(ahc, SCSIID, ahc->our_id_b); in ahc_chip_init()
5060 scsi_conf = ahc_inb(ahc, SCSICONF + 1); in ahc_chip_init()
5061 ahc_outb(ahc, SXFRCTL1, (scsi_conf & (ENSPCHK|STIMESEL)) in ahc_chip_init()
5062 |term|ahc->seltime_b|ENSTIMER|ACTNEGEN); in ahc_chip_init()
5063 if ((ahc->features & AHC_ULTRA2) != 0) in ahc_chip_init()
5064 ahc_outb(ahc, SIMODE0, ahc_inb(ahc, SIMODE0)|ENIOERR); in ahc_chip_init()
5065 ahc_outb(ahc, SIMODE1, ENSELTIMO|ENSCSIRST|ENSCSIPERR); in ahc_chip_init()
5066 ahc_outb(ahc, SXFRCTL0, DFON|SPIOEN); in ahc_chip_init()
5069 ahc_outb(ahc, SBLKCTL, ahc_inb(ahc, SBLKCTL) & ~SELBUSB); in ahc_chip_init()
5071 term = (ahc->flags & AHC_TERM_ENB_A) != 0 ? STPWEN : 0; in ahc_chip_init()
5072 if ((ahc->features & AHC_ULTRA2) != 0) in ahc_chip_init()
5073 ahc_outb(ahc, SCSIID_ULTRA2, ahc->our_id); in ahc_chip_init()
5075 ahc_outb(ahc, SCSIID, ahc->our_id); in ahc_chip_init()
5076 scsi_conf = ahc_inb(ahc, SCSICONF); in ahc_chip_init()
5077 ahc_outb(ahc, SXFRCTL1, (scsi_conf & (ENSPCHK|STIMESEL)) in ahc_chip_init()
5078 |term|ahc->seltime in ahc_chip_init()
5080 if ((ahc->features & AHC_ULTRA2) != 0) in ahc_chip_init()
5081 ahc_outb(ahc, SIMODE0, ahc_inb(ahc, SIMODE0)|ENIOERR); in ahc_chip_init()
5082 ahc_outb(ahc, SIMODE1, ENSELTIMO|ENSCSIRST|ENSCSIPERR); in ahc_chip_init()
5083 ahc_outb(ahc, SXFRCTL0, DFON|SPIOEN); in ahc_chip_init()
5087 ahc_unbusy_tcl(ahc, BUILD_TCL(i << 4, 0)); in ahc_chip_init()
5088 if ((ahc->flags & AHC_SCB_BTT) != 0) { in ahc_chip_init()
5096 ahc_unbusy_tcl(ahc, BUILD_TCL(i << 4, lun)); in ahc_chip_init()
5102 ahc->qoutfifo[i] = SCB_LIST_NULL; in ahc_chip_init()
5103 ahc_sync_qoutfifo(ahc, BUS_DMASYNC_PREREAD); in ahc_chip_init()
5106 ahc->qinfifo[i] = SCB_LIST_NULL; in ahc_chip_init()
5108 if ((ahc->features & AHC_MULTI_TID) != 0) { in ahc_chip_init()
5109 ahc_outb(ahc, TARGID, 0); in ahc_chip_init()
5110 ahc_outb(ahc, TARGID + 1, 0); in ahc_chip_init()
5116 physaddr = ahc->scb_data->hscb_busaddr; in ahc_chip_init()
5117 ahc_outb(ahc, HSCB_ADDR, physaddr & 0xFF); in ahc_chip_init()
5118 ahc_outb(ahc, HSCB_ADDR + 1, (physaddr >> 8) & 0xFF); in ahc_chip_init()
5119 ahc_outb(ahc, HSCB_ADDR + 2, (physaddr >> 16) & 0xFF); in ahc_chip_init()
5120 ahc_outb(ahc, HSCB_ADDR + 3, (physaddr >> 24) & 0xFF); in ahc_chip_init()
5122 physaddr = ahc->shared_data_busaddr; in ahc_chip_init()
5123 ahc_outb(ahc, SHARED_DATA_ADDR, physaddr & 0xFF); in ahc_chip_init()
5124 ahc_outb(ahc, SHARED_DATA_ADDR + 1, (physaddr >> 8) & 0xFF); in ahc_chip_init()
5125 ahc_outb(ahc, SHARED_DATA_ADDR + 2, (physaddr >> 16) & 0xFF); in ahc_chip_init()
5126 ahc_outb(ahc, SHARED_DATA_ADDR + 3, (physaddr >> 24) & 0xFF); in ahc_chip_init()
5133 ahc_outb(ahc, CMDSIZE_TABLE, 5); in ahc_chip_init()
5134 ahc_outb(ahc, CMDSIZE_TABLE + 1, 9); in ahc_chip_init()
5135 ahc_outb(ahc, CMDSIZE_TABLE + 2, 9); in ahc_chip_init()
5136 ahc_outb(ahc, CMDSIZE_TABLE + 3, 0); in ahc_chip_init()
5137 ahc_outb(ahc, CMDSIZE_TABLE + 4, 15); in ahc_chip_init()
5138 ahc_outb(ahc, CMDSIZE_TABLE + 5, 11); in ahc_chip_init()
5139 ahc_outb(ahc, CMDSIZE_TABLE + 6, 0); in ahc_chip_init()
5140 ahc_outb(ahc, CMDSIZE_TABLE + 7, 0); in ahc_chip_init()
5142 if ((ahc->features & AHC_HS_MAILBOX) != 0) in ahc_chip_init()
5143 ahc_outb(ahc, HS_MAILBOX, 0); in ahc_chip_init()
5146 if ((ahc->features & AHC_TARGETMODE) != 0) { in ahc_chip_init()
5147 ahc->tqinfifonext = 1; in ahc_chip_init()
5148 ahc_outb(ahc, KERNEL_TQINPOS, ahc->tqinfifonext - 1); in ahc_chip_init()
5149 ahc_outb(ahc, TQINPOS, ahc->tqinfifonext); in ahc_chip_init()
5151 ahc->qinfifonext = 0; in ahc_chip_init()
5152 ahc->qoutfifonext = 0; in ahc_chip_init()
5153 if ((ahc->features & AHC_QUEUE_REGS) != 0) { in ahc_chip_init()
5154 ahc_outb(ahc, QOFF_CTLSTA, SCB_QSIZE_256); in ahc_chip_init()
5155 ahc_outb(ahc, HNSCB_QOFF, ahc->qinfifonext); in ahc_chip_init()
5156 ahc_outb(ahc, SNSCB_QOFF, ahc->qinfifonext); in ahc_chip_init()
5157 ahc_outb(ahc, SDSCB_QOFF, 0); in ahc_chip_init()
5159 ahc_outb(ahc, KERNEL_QINPOS, ahc->qinfifonext); in ahc_chip_init()
5160 ahc_outb(ahc, QINPOS, ahc->qinfifonext); in ahc_chip_init()
5161 ahc_outb(ahc, QOUTPOS, ahc->qoutfifonext); in ahc_chip_init()
5165 ahc_outb(ahc, WAITING_SCBH, SCB_LIST_NULL); in ahc_chip_init()
5168 ahc_outb(ahc, DISCONNECTED_SCBH, SCB_LIST_NULL); in ahc_chip_init()
5171 ahc_outb(ahc, MSG_OUT, NOP); in ahc_chip_init()
5179 if ((ahc->flags & AHC_INITIATORROLE) != 0) in ahc_chip_init()
5181 ahc_outb(ahc, SCSISEQ_TEMPLATE, scsiseq_template); in ahc_chip_init()
5184 ahc_build_free_scb_list(ahc); in ahc_chip_init()
5189 ahc_outb(ahc, NEXT_QUEUED_SCB, ahc->next_queued_scb->hscb->tag); in ahc_chip_init()
5197 ahc_name(ahc)); in ahc_chip_init()
5199 error = ahc_loadseq(ahc); in ahc_chip_init()
5203 if ((ahc->features & AHC_ULTRA2) != 0) { in ahc_chip_init()
5214 (ahc_inb(ahc, SBLKCTL) & (ENAB40|ENAB20)) == 0 && wait; in ahc_chip_init()
5218 ahc_restart(ahc); in ahc_chip_init()
5226 ahc_init(struct ahc_softc *ahc) in ahc_init() argument
5238 ahc->flags |= AHC_SEQUENCER_DEBUG; in ahc_init()
5247 printk (" 0x%x", ahc_inb(ahc, i)); in ahc_init()
5249 if ((ahc->features & AHC_MORE_SRAM) != 0) { in ahc_init()
5254 printk (" 0x%x", ahc_inb(ahc, i)); in ahc_init()
5262 ahc_outb(ahc, CLRINT, CLRPARERR); in ahc_init()
5263 ahc_outb(ahc, CLRINT, CLRBRKADRINT); in ahc_init()
5270 if ((ahc->flags & AHC_USEDEFAULTS) != 0) in ahc_init()
5271 ahc->our_id = ahc->our_id_b = 7; in ahc_init()
5276 ahc->flags |= AHC_INITIATORROLE; in ahc_init()
5281 if ((AHC_TMODE_ENABLE & (0x1 << ahc->unit)) == 0) in ahc_init()
5282 ahc->features &= ~AHC_TARGETMODE; in ahc_init()
5284 ahc->init_level++; in ahc_init()
5296 if ((ahc->features & AHC_TARGETMODE) != 0) in ahc_init()
5299 if (ahc_dma_tag_create(ahc, ahc->parent_dmat, /*alignment*/1, in ahc_init()
5307 /*flags*/0, &ahc->shared_data_dmat) != 0) { in ahc_init()
5311 ahc->init_level++; in ahc_init()
5314 if (ahc_dmamem_alloc(ahc, ahc->shared_data_dmat, in ahc_init()
5315 (void **)&ahc->qoutfifo, in ahc_init()
5316 BUS_DMA_NOWAIT, &ahc->shared_data_dmamap) != 0) { in ahc_init()
5320 ahc->init_level++; in ahc_init()
5323 ahc_dmamap_load(ahc, ahc->shared_data_dmat, ahc->shared_data_dmamap, in ahc_init()
5324 ahc->qoutfifo, driver_data_size, ahc_dmamap_cb, in ahc_init()
5325 &ahc->shared_data_busaddr, /*flags*/0); in ahc_init()
5327 if ((ahc->features & AHC_TARGETMODE) != 0) { in ahc_init()
5328 ahc->targetcmds = (struct target_cmd *)ahc->qoutfifo; in ahc_init()
5329 ahc->qoutfifo = (uint8_t *)&ahc->targetcmds[AHC_TMODE_CMDS]; in ahc_init()
5330 ahc->dma_bug_buf = ahc->shared_data_busaddr in ahc_init()
5334 ahc->targetcmds[i].cmd_valid = 0; in ahc_init()
5335 ahc_sync_tqinfifo(ahc, BUS_DMASYNC_PREREAD); in ahc_init()
5336 ahc->qoutfifo = (uint8_t *)&ahc->targetcmds[256]; in ahc_init()
5338 ahc->qinfifo = &ahc->qoutfifo[256]; in ahc_init()
5340 ahc->init_level++; in ahc_init()
5343 if (ahc->scb_data->maxhscbs == 0) in ahc_init()
5344 if (ahc_init_scbdata(ahc) != 0) in ahc_init()
5352 if (ahc_alloc_tstate(ahc, ahc->our_id, 'A') == NULL) { in ahc_init()
5354 "Failing attach\n", ahc_name(ahc)); in ahc_init()
5358 if ((ahc->features & AHC_TWIN) != 0) { in ahc_init()
5359 if (ahc_alloc_tstate(ahc, ahc->our_id_b, 'B') == NULL) { in ahc_init()
5361 "Failing attach\n", ahc_name(ahc)); in ahc_init()
5366 if (ahc->scb_data->maxhscbs < AHC_SCB_MAX_ALLOC) { in ahc_init()
5367 ahc->flags |= AHC_PAGESCBS; in ahc_init()
5369 ahc->flags &= ~AHC_PAGESCBS; in ahc_init()
5376 ahc_name(ahc), in ahc_init()
5387 if (ahc->features & AHC_TWIN) { in ahc_init()
5388 scsi_conf = ahc_inb(ahc, SCSICONF + 1); in ahc_init()
5390 && (ahc->flags & AHC_INITIATORROLE) != 0) in ahc_init()
5391 ahc->flags |= AHC_RESET_BUS_B; in ahc_init()
5394 scsi_conf = ahc_inb(ahc, SCSICONF); in ahc_init()
5396 && (ahc->flags & AHC_INITIATORROLE) != 0) in ahc_init()
5397 ahc->flags |= AHC_RESET_BUS_A; in ahc_init()
5403 if ((ahc->flags & AHC_USEDEFAULTS) != 0) { in ahc_init()
5405 "device parameters\n", ahc_name(ahc)); in ahc_init()
5406 ahc->flags |= AHC_EXTENDED_TRANS_A|AHC_EXTENDED_TRANS_B| in ahc_init()
5409 if ((ahc->features & AHC_ULTRA) != 0) in ahc_init()
5412 discenable = ~((ahc_inb(ahc, DISC_DSB + 1) << 8) in ahc_init()
5413 | ahc_inb(ahc, DISC_DSB)); in ahc_init()
5414 if ((ahc->features & (AHC_ULTRA|AHC_ULTRA2)) != 0) in ahc_init()
5415 ultraenb = (ahc_inb(ahc, ULTRA_ENB + 1) << 8) in ahc_init()
5416 | ahc_inb(ahc, ULTRA_ENB); in ahc_init()
5419 if ((ahc->features & (AHC_WIDE|AHC_TWIN)) == 0) in ahc_init()
5430 our_id = ahc->our_id; in ahc_init()
5432 if (i > 7 && (ahc->features & AHC_TWIN) != 0) { in ahc_init()
5434 our_id = ahc->our_id_b; in ahc_init()
5437 tinfo = ahc_fetch_transinfo(ahc, channel, our_id, in ahc_init()
5441 if (ahc->flags & AHC_USEDEFAULTS) { in ahc_init()
5442 if ((ahc->features & AHC_WIDE) != 0) in ahc_init()
5456 scsirate = ahc_inb(ahc, TARG_SCSIRATE + i); in ahc_init()
5458 if ((ahc->features & AHC_ULTRA2) != 0) { in ahc_init()
5473 offset = ahc_inb(ahc, TARG_OFFSET + i); in ahc_init()
5478 if ((ahc->features & AHC_DT) != 0) in ahc_init()
5481 ahc_find_period(ahc, scsirate, maxsync); in ahc_init()
5487 && (ahc->features & AHC_DT) != 0) in ahc_init()
5498 ahc_find_period(ahc, scsirate, in ahc_init()
5508 && (ahc->features & AHC_WIDE) != 0) in ahc_init()
5511 if ((ahc->features & AHC_DT) != 0) in ahc_init()
5522 ahc->user_discenable = discenable; in ahc_init()
5523 ahc->user_tagenable = tagenable; in ahc_init()
5525 return (ahc->bus_chip_init(ahc)); in ahc_init()
5529 ahc_intr_enable(struct ahc_softc *ahc, int enable) in ahc_intr_enable() argument
5533 hcntrl = ahc_inb(ahc, HCNTRL); in ahc_intr_enable()
5535 ahc->pause &= ~INTEN; in ahc_intr_enable()
5536 ahc->unpause &= ~INTEN; in ahc_intr_enable()
5539 ahc->pause |= INTEN; in ahc_intr_enable()
5540 ahc->unpause |= INTEN; in ahc_intr_enable()
5542 ahc_outb(ahc, HCNTRL, hcntrl); in ahc_intr_enable()
5553 ahc_pause_and_flushwork(struct ahc_softc *ahc) in ahc_pause_and_flushwork() argument
5560 ahc->flags |= AHC_ALL_INTERRUPTS; in ahc_pause_and_flushwork()
5564 ahc_unpause(ahc); in ahc_pause_and_flushwork()
5571 ahc_intr(ahc); in ahc_pause_and_flushwork()
5572 ahc_pause(ahc); in ahc_pause_and_flushwork()
5574 ahc_outb(ahc, SCSISEQ, ahc_inb(ahc, SCSISEQ) & ~ENSELO); in ahc_pause_and_flushwork()
5575 intstat = ahc_inb(ahc, INTSTAT); in ahc_pause_and_flushwork()
5577 ahc_clear_critical_section(ahc); in ahc_pause_and_flushwork()
5578 intstat = ahc_inb(ahc, INTSTAT); in ahc_pause_and_flushwork()
5581 && (intstat != 0xFF || (ahc->features & AHC_REMOVABLE) == 0) in ahc_pause_and_flushwork()
5583 || (ahc_inb(ahc, SSTAT0) & (SELDO|SELINGO)) != 0)); in ahc_pause_and_flushwork()
5586 ahc_inb(ahc, INTSTAT)); in ahc_pause_and_flushwork()
5588 ahc_platform_flushwork(ahc); in ahc_pause_and_flushwork()
5589 ahc->flags &= ~AHC_ALL_INTERRUPTS; in ahc_pause_and_flushwork()
5593 ahc_suspend(struct ahc_softc *ahc) in ahc_suspend() argument
5596 ahc_pause_and_flushwork(ahc); in ahc_suspend()
5598 if (LIST_FIRST(&ahc->pending_scbs) != NULL) { in ahc_suspend()
5599 ahc_unpause(ahc); in ahc_suspend()
5609 if (ahc->pending_device != NULL) { in ahc_suspend()
5610 ahc_unpause(ahc); in ahc_suspend()
5614 ahc_shutdown(ahc); in ahc_suspend()
5619 ahc_resume(struct ahc_softc *ahc) in ahc_resume() argument
5622 ahc_reset(ahc, /*reinit*/TRUE); in ahc_resume()
5623 ahc_intr_enable(ahc, TRUE); in ahc_resume()
5624 ahc_restart(ahc); in ahc_resume()
5633 ahc_index_busy_tcl(struct ahc_softc *ahc, u_int tcl) in ahc_index_busy_tcl() argument
5638 if ((ahc->flags & AHC_SCB_BTT) != 0) { in ahc_index_busy_tcl()
5641 saved_scbptr = ahc_inb(ahc, SCBPTR); in ahc_index_busy_tcl()
5642 ahc_outb(ahc, SCBPTR, TCL_LUN(tcl)); in ahc_index_busy_tcl()
5643 scbid = ahc_inb(ahc, SCB_64_BTT + TCL_TARGET_OFFSET(tcl)); in ahc_index_busy_tcl()
5644 ahc_outb(ahc, SCBPTR, saved_scbptr); in ahc_index_busy_tcl()
5647 scbid = ahc_inb(ahc, BUSY_TARGETS + target_offset); in ahc_index_busy_tcl()
5654 ahc_unbusy_tcl(struct ahc_softc *ahc, u_int tcl) in ahc_unbusy_tcl() argument
5658 if ((ahc->flags & AHC_SCB_BTT) != 0) { in ahc_unbusy_tcl()
5661 saved_scbptr = ahc_inb(ahc, SCBPTR); in ahc_unbusy_tcl()
5662 ahc_outb(ahc, SCBPTR, TCL_LUN(tcl)); in ahc_unbusy_tcl()
5663 ahc_outb(ahc, SCB_64_BTT+TCL_TARGET_OFFSET(tcl), SCB_LIST_NULL); in ahc_unbusy_tcl()
5664 ahc_outb(ahc, SCBPTR, saved_scbptr); in ahc_unbusy_tcl()
5667 ahc_outb(ahc, BUSY_TARGETS + target_offset, SCB_LIST_NULL); in ahc_unbusy_tcl()
5672 ahc_busy_tcl(struct ahc_softc *ahc, u_int tcl, u_int scbid) in ahc_busy_tcl() argument
5676 if ((ahc->flags & AHC_SCB_BTT) != 0) { in ahc_busy_tcl()
5679 saved_scbptr = ahc_inb(ahc, SCBPTR); in ahc_busy_tcl()
5680 ahc_outb(ahc, SCBPTR, TCL_LUN(tcl)); in ahc_busy_tcl()
5681 ahc_outb(ahc, SCB_64_BTT + TCL_TARGET_OFFSET(tcl), scbid); in ahc_busy_tcl()
5682 ahc_outb(ahc, SCBPTR, saved_scbptr); in ahc_busy_tcl()
5685 ahc_outb(ahc, BUSY_TARGETS + target_offset, scbid); in ahc_busy_tcl()
5691 ahc_match_scb(struct ahc_softc *ahc, struct scb *scb, int target, in ahc_match_scb() argument
5694 int targ = SCB_GET_TARGET(ahc, scb); in ahc_match_scb()
5695 char chan = SCB_GET_CHANNEL(ahc, scb); in ahc_match_scb()
5727 ahc_freeze_devq(struct ahc_softc *ahc, struct scb *scb) in ahc_freeze_devq() argument
5733 target = SCB_GET_TARGET(ahc, scb); in ahc_freeze_devq()
5735 channel = SCB_GET_CHANNEL(ahc, scb); in ahc_freeze_devq()
5737 ahc_search_qinfifo(ahc, target, channel, lun, in ahc_freeze_devq()
5741 ahc_platform_freeze_devq(ahc, scb); in ahc_freeze_devq()
5745 ahc_qinfifo_requeue_tail(struct ahc_softc *ahc, struct scb *scb) in ahc_qinfifo_requeue_tail() argument
5750 if (ahc_qinfifo_count(ahc) != 0) { in ahc_qinfifo_requeue_tail()
5754 prev_pos = ahc->qinfifonext - 1; in ahc_qinfifo_requeue_tail()
5755 prev_tag = ahc->qinfifo[prev_pos]; in ahc_qinfifo_requeue_tail()
5756 prev_scb = ahc_lookup_scb(ahc, prev_tag); in ahc_qinfifo_requeue_tail()
5758 ahc_qinfifo_requeue(ahc, prev_scb, scb); in ahc_qinfifo_requeue_tail()
5759 if ((ahc->features & AHC_QUEUE_REGS) != 0) { in ahc_qinfifo_requeue_tail()
5760 ahc_outb(ahc, HNSCB_QOFF, ahc->qinfifonext); in ahc_qinfifo_requeue_tail()
5762 ahc_outb(ahc, KERNEL_QINPOS, ahc->qinfifonext); in ahc_qinfifo_requeue_tail()
5767 ahc_qinfifo_requeue(struct ahc_softc *ahc, struct scb *prev_scb, in ahc_qinfifo_requeue() argument
5771 ahc_outb(ahc, NEXT_QUEUED_SCB, scb->hscb->tag); in ahc_qinfifo_requeue()
5774 ahc_sync_scb(ahc, prev_scb, in ahc_qinfifo_requeue()
5777 ahc->qinfifo[ahc->qinfifonext++] = scb->hscb->tag; in ahc_qinfifo_requeue()
5778 scb->hscb->next = ahc->next_queued_scb->hscb->tag; in ahc_qinfifo_requeue()
5779 ahc_sync_scb(ahc, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); in ahc_qinfifo_requeue()
5783 ahc_qinfifo_count(struct ahc_softc *ahc) in ahc_qinfifo_count() argument
5788 if ((ahc->features & AHC_QUEUE_REGS) != 0) { in ahc_qinfifo_count()
5789 qinpos = ahc_inb(ahc, SNSCB_QOFF); in ahc_qinfifo_count()
5790 ahc_outb(ahc, SNSCB_QOFF, qinpos); in ahc_qinfifo_count()
5792 qinpos = ahc_inb(ahc, QINPOS); in ahc_qinfifo_count()
5793 diff = ahc->qinfifonext - qinpos; in ahc_qinfifo_count()
5798 ahc_search_qinfifo(struct ahc_softc *ahc, int target, char channel, in ahc_search_qinfifo() argument
5813 qintail = ahc->qinfifonext; in ahc_search_qinfifo()
5814 have_qregs = (ahc->features & AHC_QUEUE_REGS) != 0; in ahc_search_qinfifo()
5816 qinstart = ahc_inb(ahc, SNSCB_QOFF); in ahc_search_qinfifo()
5817 ahc_outb(ahc, SNSCB_QOFF, qinstart); in ahc_search_qinfifo()
5819 qinstart = ahc_inb(ahc, QINPOS); in ahc_search_qinfifo()
5829 ahc_freeze_untagged_queues(ahc); in ahc_search_qinfifo()
5836 ahc->qinfifonext = qinpos; in ahc_search_qinfifo()
5837 ahc_outb(ahc, NEXT_QUEUED_SCB, ahc->next_queued_scb->hscb->tag); in ahc_search_qinfifo()
5840 scb = ahc_lookup_scb(ahc, ahc->qinfifo[qinpos]); in ahc_search_qinfifo()
5843 qinpos, ahc->qinfifo[qinpos]); in ahc_search_qinfifo()
5847 if (ahc_match_scb(ahc, scb, target, channel, lun, tag, role)) { in ahc_search_qinfifo()
5866 ahc_done(ahc, scb); in ahc_search_qinfifo()
5872 ahc_qinfifo_requeue(ahc, prev_scb, scb); in ahc_search_qinfifo()
5877 ahc_qinfifo_requeue(ahc, prev_scb, scb); in ahc_search_qinfifo()
5883 if ((ahc->features & AHC_QUEUE_REGS) != 0) { in ahc_search_qinfifo()
5884 ahc_outb(ahc, HNSCB_QOFF, ahc->qinfifonext); in ahc_search_qinfifo()
5886 ahc_outb(ahc, KERNEL_QINPOS, ahc->qinfifonext); in ahc_search_qinfifo()
5891 && (qinstart != ahc->qinfifonext)) { in ahc_search_qinfifo()
5904 scb = ahc_lookup_scb(ahc, ahc->qinfifo[qinstart]); in ahc_search_qinfifo()
5908 found, qinstart, ahc->qinfifonext); in ahc_search_qinfifo()
5918 ahc->scb_data->scbindex[scb->hscb->tag] = NULL; in ahc_search_qinfifo()
5919 ahc_swap_with_next_hscb(ahc, scb); in ahc_search_qinfifo()
5921 ahc->qinfifo[qinstart] = scb->hscb->tag; in ahc_search_qinfifo()
5924 ahc_outb(ahc, NEXT_QUEUED_SCB, scb->hscb->tag); in ahc_search_qinfifo()
5927 qintail = ahc->qinfifonext - 1; in ahc_search_qinfifo()
5928 scb = ahc_lookup_scb(ahc, ahc->qinfifo[qintail]); in ahc_search_qinfifo()
5929 scb->hscb->next = ahc->next_queued_scb->hscb->tag; in ahc_search_qinfifo()
5935 curscbptr = ahc_inb(ahc, SCBPTR); in ahc_search_qinfifo()
5936 next = ahc_inb(ahc, WAITING_SCBH); /* Start at head of list. */ in ahc_search_qinfifo()
5942 ahc_outb(ahc, SCBPTR, next); in ahc_search_qinfifo()
5943 scb_index = ahc_inb(ahc, SCB_TAG); in ahc_search_qinfifo()
5944 if (scb_index >= ahc->scb_data->numscbs) { in ahc_search_qinfifo()
5947 scb_index, ahc->scb_data->numscbs); in ahc_search_qinfifo()
5948 ahc_dump_card_state(ahc); in ahc_search_qinfifo()
5951 scb = ahc_lookup_scb(ahc, scb_index); in ahc_search_qinfifo()
5957 if (ahc_match_scb(ahc, scb, target, channel, in ahc_search_qinfifo()
5978 ahc_done(ahc, scb); in ahc_search_qinfifo()
5982 next = ahc_rem_wscb(ahc, next, prev); in ahc_search_qinfifo()
5986 next = ahc_inb(ahc, SCB_NEXT); in ahc_search_qinfifo()
5991 next = ahc_inb(ahc, SCB_NEXT); in ahc_search_qinfifo()
5994 ahc_outb(ahc, SCBPTR, curscbptr); in ahc_search_qinfifo()
5996 found += ahc_search_untagged_queues(ahc, /*ahc_io_ctx_t*/NULL, target, in ahc_search_qinfifo()
6000 ahc_release_untagged_queues(ahc); in ahc_search_qinfifo()
6005 ahc_search_untagged_queues(struct ahc_softc *ahc, ahc_io_ctx_t ctx, in ahc_search_untagged_queues() argument
6019 ahc_freeze_untagged_queues(ahc); in ahc_search_untagged_queues()
6024 if ((ahc->flags & AHC_SCB_BTT) == 0) { in ahc_search_untagged_queues()
6042 untagged_q = &(ahc->untagged_queues[i]); in ahc_search_untagged_queues()
6061 if (ahc_match_scb(ahc, scb, target, channel, lun, in ahc_search_untagged_queues()
6084 ahc_done(ahc, scb); in ahc_search_untagged_queues()
6098 ahc_release_untagged_queues(ahc); in ahc_search_untagged_queues()
6103 ahc_search_disc_list(struct ahc_softc *ahc, int target, char channel, in ahc_search_disc_list() argument
6114 next = ahc_inb(ahc, DISCONNECTED_SCBH); in ahc_search_disc_list()
6119 active_scb = ahc_inb(ahc, SCBPTR); in ahc_search_disc_list()
6127 ahc_outb(ahc, SCBPTR, next); in ahc_search_disc_list()
6128 scb_index = ahc_inb(ahc, SCB_TAG); in ahc_search_disc_list()
6129 if (scb_index >= ahc->scb_data->numscbs) { in ahc_search_disc_list()
6132 scb_index, ahc->scb_data->numscbs); in ahc_search_disc_list()
6133 ahc_dump_card_state(ahc); in ahc_search_disc_list()
6142 scbp = ahc_lookup_scb(ahc, scb_index); in ahc_search_disc_list()
6143 if (ahc_match_scb(ahc, scbp, target, channel, lun, in ahc_search_disc_list()
6148 ahc_rem_scb_from_disc_list(ahc, prev, next); in ahc_search_disc_list()
6151 next = ahc_inb(ahc, SCB_NEXT); in ahc_search_disc_list()
6157 next = ahc_inb(ahc, SCB_NEXT); in ahc_search_disc_list()
6161 ahc_outb(ahc, SCBPTR, active_scb); in ahc_search_disc_list()
6170 ahc_rem_scb_from_disc_list(struct ahc_softc *ahc, u_int prev, u_int scbptr) in ahc_rem_scb_from_disc_list() argument
6174 ahc_outb(ahc, SCBPTR, scbptr); in ahc_rem_scb_from_disc_list()
6175 next = ahc_inb(ahc, SCB_NEXT); in ahc_rem_scb_from_disc_list()
6177 ahc_outb(ahc, SCB_CONTROL, 0); in ahc_rem_scb_from_disc_list()
6179 ahc_add_curscb_to_free_list(ahc); in ahc_rem_scb_from_disc_list()
6182 ahc_outb(ahc, SCBPTR, prev); in ahc_rem_scb_from_disc_list()
6183 ahc_outb(ahc, SCB_NEXT, next); in ahc_rem_scb_from_disc_list()
6185 ahc_outb(ahc, DISCONNECTED_SCBH, next); in ahc_rem_scb_from_disc_list()
6196 ahc_add_curscb_to_free_list(struct ahc_softc *ahc) in ahc_add_curscb_to_free_list() argument
6202 ahc_outb(ahc, SCB_TAG, SCB_LIST_NULL); in ahc_add_curscb_to_free_list()
6204 if ((ahc->flags & AHC_PAGESCBS) != 0) { in ahc_add_curscb_to_free_list()
6205 ahc_outb(ahc, SCB_NEXT, ahc_inb(ahc, FREE_SCBH)); in ahc_add_curscb_to_free_list()
6206 ahc_outb(ahc, FREE_SCBH, ahc_inb(ahc, SCBPTR)); in ahc_add_curscb_to_free_list()
6215 ahc_rem_wscb(struct ahc_softc *ahc, u_int scbpos, u_int prev) in ahc_rem_wscb() argument
6223 curscb = ahc_inb(ahc, SCBPTR); in ahc_rem_wscb()
6224 ahc_outb(ahc, SCBPTR, scbpos); in ahc_rem_wscb()
6225 next = ahc_inb(ahc, SCB_NEXT); in ahc_rem_wscb()
6228 ahc_outb(ahc, SCB_CONTROL, 0); in ahc_rem_wscb()
6230 ahc_add_curscb_to_free_list(ahc); in ahc_rem_wscb()
6235 ahc_outb(ahc, WAITING_SCBH, next); in ahc_rem_wscb()
6241 ahc_outb(ahc, SCSISEQ, (ahc_inb(ahc, SCSISEQ) & ~ENSELO)); in ahc_rem_wscb()
6247 ahc_outb(ahc, SCBPTR, prev); in ahc_rem_wscb()
6248 ahc_outb(ahc, SCB_NEXT, next); in ahc_rem_wscb()
6254 ahc_outb(ahc, SCBPTR, curscb); in ahc_rem_wscb()
6266 ahc_abort_scbs(struct ahc_softc *ahc, int target, char channel, in ahc_abort_scbs() argument
6283 ahc_freeze_untagged_queues(ahc); in ahc_abort_scbs()
6286 active_scb = ahc_inb(ahc, SCBPTR); in ahc_abort_scbs()
6288 found = ahc_search_qinfifo(ahc, target, channel, lun, SCB_LIST_NULL, in ahc_abort_scbs()
6313 if ((ahc->flags & AHC_SCB_BTT) != 0) in ahc_abort_scbs()
6327 scbid = ahc_index_busy_tcl(ahc, tcl); in ahc_abort_scbs()
6328 scbp = ahc_lookup_scb(ahc, scbid); in ahc_abort_scbs()
6330 || ahc_match_scb(ahc, scbp, target, channel, in ahc_abort_scbs()
6333 ahc_unbusy_tcl(ahc, BUILD_TCL(i << 4, j)); in ahc_abort_scbs()
6343 ahc_search_disc_list(ahc, target, channel, lun, tag, in ahc_abort_scbs()
6355 for (i = 0; i < ahc->scb_data->maxhscbs; i++) { in ahc_abort_scbs()
6358 ahc_outb(ahc, SCBPTR, i); in ahc_abort_scbs()
6359 scbid = ahc_inb(ahc, SCB_TAG); in ahc_abort_scbs()
6360 scbp = ahc_lookup_scb(ahc, scbid); in ahc_abort_scbs()
6363 && ahc_match_scb(ahc, scbp, target, channel, lun, tag, role))) in ahc_abort_scbs()
6364 ahc_add_curscb_to_free_list(ahc); in ahc_abort_scbs()
6373 scbp_next = LIST_FIRST(&ahc->pending_scbs); in ahc_abort_scbs()
6377 if (ahc_match_scb(ahc, scbp, target, channel, lun, tag, role)) { in ahc_abort_scbs()
6387 ahc_done(ahc, scbp); in ahc_abort_scbs()
6391 ahc_outb(ahc, SCBPTR, active_scb); in ahc_abort_scbs()
6392 ahc_platform_abort_scbs(ahc, target, channel, lun, tag, role, status); in ahc_abort_scbs()
6393 ahc_release_untagged_queues(ahc); in ahc_abort_scbs()
6398 ahc_reset_current_bus(struct ahc_softc *ahc) in ahc_reset_current_bus() argument
6402 ahc_outb(ahc, SIMODE1, ahc_inb(ahc, SIMODE1) & ~ENSCSIRST); in ahc_reset_current_bus()
6403 scsiseq = ahc_inb(ahc, SCSISEQ); in ahc_reset_current_bus()
6404 ahc_outb(ahc, SCSISEQ, scsiseq | SCSIRSTO); in ahc_reset_current_bus()
6405 ahc_flush_device_writes(ahc); in ahc_reset_current_bus()
6408 ahc_outb(ahc, SCSISEQ, scsiseq & ~SCSIRSTO); in ahc_reset_current_bus()
6410 ahc_clear_intstat(ahc); in ahc_reset_current_bus()
6413 ahc_outb(ahc, SIMODE1, ahc_inb(ahc, SIMODE1) | ENSCSIRST); in ahc_reset_current_bus()
6417 ahc_reset_channel(struct ahc_softc *ahc, char channel, int initiate_reset) in ahc_reset_channel() argument
6428 ahc->pending_device = NULL; in ahc_reset_channel()
6435 ahc_pause(ahc); in ahc_reset_channel()
6438 ahc_clear_critical_section(ahc); in ahc_reset_channel()
6445 ahc_run_qoutfifo(ahc); in ahc_reset_channel()
6457 if ((ahc->flags & AHC_TARGETROLE) != 0) { in ahc_reset_channel()
6458 ahc_run_tqinfifo(ahc, /*paused*/TRUE); in ahc_reset_channel()
6465 sblkctl = ahc_inb(ahc, SBLKCTL); in ahc_reset_channel()
6467 if ((ahc->features & AHC_TWIN) != 0 in ahc_reset_channel()
6470 scsiseq = ahc_inb(ahc, SCSISEQ_TEMPLATE); in ahc_reset_channel()
6476 ahc_outb(ahc, SBLKCTL, sblkctl ^ SELBUSB); in ahc_reset_channel()
6477 simode1 = ahc_inb(ahc, SIMODE1) & ~(ENBUSFREE|ENSCSIRST); in ahc_reset_channel()
6484 if ((ahc->flags & AHC_TARGETROLE) != 0) in ahc_reset_channel()
6487 ahc_outb(ahc, SIMODE1, simode1); in ahc_reset_channel()
6489 ahc_reset_current_bus(ahc); in ahc_reset_channel()
6490 ahc_clear_intstat(ahc); in ahc_reset_channel()
6491 ahc_outb(ahc, SCSISEQ, scsiseq & (ENSELI|ENRSELI|ENAUTOATNP)); in ahc_reset_channel()
6492 ahc_outb(ahc, SBLKCTL, sblkctl); in ahc_reset_channel()
6496 simode1 = ahc_inb(ahc, SIMODE1) & ~(ENBUSFREE|ENSCSIRST); in ahc_reset_channel()
6503 if ((ahc->flags & AHC_TARGETROLE) != 0) in ahc_reset_channel()
6506 ahc_outb(ahc, SIMODE1, simode1); in ahc_reset_channel()
6508 ahc_reset_current_bus(ahc); in ahc_reset_channel()
6509 ahc_clear_intstat(ahc); in ahc_reset_channel()
6510 ahc_outb(ahc, SCSISEQ, scsiseq & (ENSELI|ENRSELI|ENAUTOATNP)); in ahc_reset_channel()
6518 found = ahc_abort_scbs(ahc, CAM_TARGET_WILDCARD, channel, in ahc_reset_channel()
6522 max_scsiid = (ahc->features & AHC_WIDE) ? 15 : 7; in ahc_reset_channel()
6533 tstate = ahc->enabled_targets[target]; in ahc_reset_channel()
6543 ahc_queue_lstate_event(ahc, lstate, CAM_TARGET_WILDCARD, in ahc_reset_channel()
6545 ahc_send_lstate_events(ahc, lstate); in ahc_reset_channel()
6550 ahc_send_async(ahc, devinfo.channel, CAM_TARGET_WILDCARD, in ahc_reset_channel()
6558 if (ahc->enabled_targets[target] == NULL) in ahc_reset_channel()
6566 ahc_set_width(ahc, &devinfo, MSG_EXT_WDTR_BUS_8_BIT, in ahc_reset_channel()
6568 ahc_set_syncrate(ahc, &devinfo, /*syncrate*/NULL, in ahc_reset_channel()
6576 ahc_restart(ahc); in ahc_reset_channel()
6578 ahc_unpause(ahc); in ahc_reset_channel()
6588 ahc_calc_residual(struct ahc_softc *ahc, struct scb *scb) in ahc_calc_residual() argument
6663 ahc_print_path(ahc, scb); in ahc_calc_residual()
6676 ahc_queue_lstate_event(struct ahc_softc *ahc, struct ahc_tmode_lstate *lstate, in ahc_queue_lstate_event() argument
6727 ahc_send_lstate_events(struct ahc_softc *ahc, struct ahc_tmode_lstate *lstate) in ahc_send_lstate_events() argument
6763 ahc_dumpseq(struct ahc_softc* ahc) in ahc_dumpseq() argument
6767 ahc_outb(ahc, SEQCTL, PERRORDIS|FAILDIS|FASTMODE|LOADRAM); in ahc_dumpseq()
6768 ahc_outb(ahc, SEQADDR0, 0); in ahc_dumpseq()
6769 ahc_outb(ahc, SEQADDR1, 0); in ahc_dumpseq()
6770 for (i = 0; i < ahc->instruction_ram_size; i++) { in ahc_dumpseq()
6773 ahc_insb(ahc, SEQRAM, ins_bytes, 4); in ahc_dumpseq()
6783 ahc_loadseq(struct ahc_softc *ahc) in ahc_loadseq() argument
6808 if (ahc->targetcmds != NULL) in ahc_loadseq()
6811 download_consts[CACHESIZE_MASK] = ahc->pci_cachesize - 1; in ahc_loadseq()
6812 download_consts[INVERTED_CACHESIZE_MASK] = ~(ahc->pci_cachesize - 1); in ahc_loadseq()
6813 sg_prefetch_cnt = ahc->pci_cachesize; in ahc_loadseq()
6823 ahc_outb(ahc, SEQCTL, PERRORDIS|FAILDIS|FASTMODE|LOADRAM); in ahc_loadseq()
6824 ahc_outb(ahc, SEQADDR0, 0); in ahc_loadseq()
6825 ahc_outb(ahc, SEQADDR1, 0); in ahc_loadseq()
6828 if (ahc_check_patch(ahc, &cur_patch, i, &skip_addr) == 0) { in ahc_loadseq()
6836 if (downloaded == ahc->instruction_ram_size) { in ahc_loadseq()
6843 "size of %d!\n", ahc_name(ahc), in ahc_loadseq()
6844 ahc->instruction_ram_size); in ahc_loadseq()
6869 ahc_download_instr(ahc, i, download_consts); in ahc_loadseq()
6873 ahc->num_critical_sections = cs_count; in ahc_loadseq()
6877 ahc->critical_sections = kmemdup(cs_table, cs_count, GFP_ATOMIC); in ahc_loadseq()
6878 if (ahc->critical_sections == NULL) in ahc_loadseq()
6881 ahc_outb(ahc, SEQCTL, PERRORDIS|FAILDIS|FASTMODE); in ahc_loadseq()
6886 ahc_name(ahc), ahc->features, ahc->bugs, ahc->flags); in ahc_loadseq()
6892 ahc_check_patch(struct ahc_softc *ahc, const struct patch **start_patch, in ahc_check_patch() argument
6905 if (cur_patch->patch_func(ahc) == 0) { in ahc_check_patch()
6928 ahc_download_instr(struct ahc_softc *ahc, u_int instrptr, uint8_t *dconsts) in ahc_download_instr() argument
6969 ahc_check_patch(ahc, &cur_patch, i, &skip_addr); in ahc_download_instr()
6995 if ((ahc->features & AHC_CMD_CHAN) == 0 in ahc_download_instr()
7006 ahc_name(ahc)); in ahc_download_instr()
7012 if ((ahc->features & AHC_ULTRA2) != 0) { in ahc_download_instr()
7044 ahc_outsb(ahc, SEQRAM, instr.bytes, 4); in ahc_download_instr()
7100 ahc_dump_card_state(struct ahc_softc *ahc) in ahc_dump_card_state() argument
7116 if (ahc_is_paused(ahc)) { in ahc_dump_card_state()
7120 ahc_pause(ahc); in ahc_dump_card_state()
7123 saved_scbptr = ahc_inb(ahc, SCBPTR); in ahc_dump_card_state()
7124 last_phase = ahc_inb(ahc, LASTPHASE); in ahc_dump_card_state()
7127 ahc_name(ahc), ahc_lookup_phase_entry(last_phase)->phasemsg, in ahc_dump_card_state()
7128 ahc_inb(ahc, SEQADDR0) | (ahc_inb(ahc, SEQADDR1) << 8)); in ahc_dump_card_state()
7132 ahc_inb(ahc, ACCUM), ahc_inb(ahc, SINDEX), ahc_inb(ahc, DINDEX), in ahc_dump_card_state()
7133 ahc_inb(ahc, ARG_2)); in ahc_dump_card_state()
7134 printk("HCNT = 0x%x SCBPTR = 0x%x\n", ahc_inb(ahc, HCNT), in ahc_dump_card_state()
7135 ahc_inb(ahc, SCBPTR)); in ahc_dump_card_state()
7137 if ((ahc->features & AHC_DT) != 0) in ahc_dump_card_state()
7138 ahc_scsiphase_print(ahc_inb(ahc, SCSIPHASE), &cur_col, 50); in ahc_dump_card_state()
7139 ahc_scsisigi_print(ahc_inb(ahc, SCSISIGI), &cur_col, 50); in ahc_dump_card_state()
7140 ahc_error_print(ahc_inb(ahc, ERROR), &cur_col, 50); in ahc_dump_card_state()
7141 ahc_scsibusl_print(ahc_inb(ahc, SCSIBUSL), &cur_col, 50); in ahc_dump_card_state()
7142 ahc_lastphase_print(ahc_inb(ahc, LASTPHASE), &cur_col, 50); in ahc_dump_card_state()
7143 ahc_scsiseq_print(ahc_inb(ahc, SCSISEQ), &cur_col, 50); in ahc_dump_card_state()
7144 ahc_sblkctl_print(ahc_inb(ahc, SBLKCTL), &cur_col, 50); in ahc_dump_card_state()
7145 ahc_scsirate_print(ahc_inb(ahc, SCSIRATE), &cur_col, 50); in ahc_dump_card_state()
7146 ahc_seqctl_print(ahc_inb(ahc, SEQCTL), &cur_col, 50); in ahc_dump_card_state()
7147 ahc_seq_flags_print(ahc_inb(ahc, SEQ_FLAGS), &cur_col, 50); in ahc_dump_card_state()
7148 ahc_sstat0_print(ahc_inb(ahc, SSTAT0), &cur_col, 50); in ahc_dump_card_state()
7149 ahc_sstat1_print(ahc_inb(ahc, SSTAT1), &cur_col, 50); in ahc_dump_card_state()
7150 ahc_sstat2_print(ahc_inb(ahc, SSTAT2), &cur_col, 50); in ahc_dump_card_state()
7151 ahc_sstat3_print(ahc_inb(ahc, SSTAT3), &cur_col, 50); in ahc_dump_card_state()
7152 ahc_simode0_print(ahc_inb(ahc, SIMODE0), &cur_col, 50); in ahc_dump_card_state()
7153 ahc_simode1_print(ahc_inb(ahc, SIMODE1), &cur_col, 50); in ahc_dump_card_state()
7154 ahc_sxfrctl0_print(ahc_inb(ahc, SXFRCTL0), &cur_col, 50); in ahc_dump_card_state()
7155 ahc_dfcntrl_print(ahc_inb(ahc, DFCNTRL), &cur_col, 50); in ahc_dump_card_state()
7156 ahc_dfstatus_print(ahc_inb(ahc, DFSTATUS), &cur_col, 50); in ahc_dump_card_state()
7161 printk(" 0x%x", ahc_inb(ahc, STACK)|(ahc_inb(ahc, STACK) << 8)); in ahc_dump_card_state()
7162 printk("\nSCB count = %d\n", ahc->scb_data->numscbs); in ahc_dump_card_state()
7163 printk("Kernel NEXTQSCB = %d\n", ahc->next_queued_scb->hscb->tag); in ahc_dump_card_state()
7164 printk("Card NEXTQSCB = %d\n", ahc_inb(ahc, NEXT_QUEUED_SCB)); in ahc_dump_card_state()
7167 if ((ahc->features & AHC_QUEUE_REGS) != 0) { in ahc_dump_card_state()
7168 qinpos = ahc_inb(ahc, SNSCB_QOFF); in ahc_dump_card_state()
7169 ahc_outb(ahc, SNSCB_QOFF, qinpos); in ahc_dump_card_state()
7171 qinpos = ahc_inb(ahc, QINPOS); in ahc_dump_card_state()
7172 qintail = ahc->qinfifonext; in ahc_dump_card_state()
7174 printk("%d ", ahc->qinfifo[qinpos]); in ahc_dump_card_state()
7180 scb_index = ahc_inb(ahc, WAITING_SCBH); in ahc_dump_card_state()
7183 ahc_outb(ahc, SCBPTR, scb_index); in ahc_dump_card_state()
7184 printk("%d:%d ", scb_index, ahc_inb(ahc, SCB_TAG)); in ahc_dump_card_state()
7185 scb_index = ahc_inb(ahc, SCB_NEXT); in ahc_dump_card_state()
7190 scb_index = ahc_inb(ahc, DISCONNECTED_SCBH); in ahc_dump_card_state()
7193 ahc_outb(ahc, SCBPTR, scb_index); in ahc_dump_card_state()
7194 printk("%d:%d ", scb_index, ahc_inb(ahc, SCB_TAG)); in ahc_dump_card_state()
7195 scb_index = ahc_inb(ahc, SCB_NEXT); in ahc_dump_card_state()
7199 ahc_sync_qoutfifo(ahc, BUS_DMASYNC_POSTREAD); in ahc_dump_card_state()
7201 qoutpos = ahc->qoutfifonext; in ahc_dump_card_state()
7203 while (ahc->qoutfifo[qoutpos] != SCB_LIST_NULL && i++ < 256) { in ahc_dump_card_state()
7204 printk("%d ", ahc->qoutfifo[qoutpos]); in ahc_dump_card_state()
7210 scb_index = ahc_inb(ahc, FREE_SCBH); in ahc_dump_card_state()
7213 ahc_outb(ahc, SCBPTR, scb_index); in ahc_dump_card_state()
7215 scb_index = ahc_inb(ahc, SCB_NEXT); in ahc_dump_card_state()
7220 for (i = 0; i < ahc->scb_data->maxhscbs; i++) { in ahc_dump_card_state()
7221 ahc_outb(ahc, SCBPTR, i); in ahc_dump_card_state()
7224 ahc_scb_control_print(ahc_inb(ahc, SCB_CONTROL), &cur_col, 60); in ahc_dump_card_state()
7225 ahc_scb_scsiid_print(ahc_inb(ahc, SCB_SCSIID), &cur_col, 60); in ahc_dump_card_state()
7226 ahc_scb_lun_print(ahc_inb(ahc, SCB_LUN), &cur_col, 60); in ahc_dump_card_state()
7227 ahc_scb_tag_print(ahc_inb(ahc, SCB_TAG), &cur_col, 60); in ahc_dump_card_state()
7233 LIST_FOREACH(scb, &ahc->pending_scbs, pending_links) { in ahc_dump_card_state()
7240 if ((ahc->flags & AHC_PAGESCBS) == 0) { in ahc_dump_card_state()
7241 ahc_outb(ahc, SCBPTR, scb->hscb->tag); in ahc_dump_card_state()
7243 ahc_scb_control_print(ahc_inb(ahc, SCB_CONTROL), in ahc_dump_card_state()
7245 ahc_scb_tag_print(ahc_inb(ahc, SCB_TAG), &cur_col, 60); in ahc_dump_card_state()
7253 SLIST_FOREACH(scb, &ahc->scb_data->free_scbs, links.sle) { in ahc_dump_card_state()
7260 maxtarget = (ahc->features & (AHC_WIDE|AHC_TWIN)) ? 15 : 7; in ahc_dump_card_state()
7262 untagged_q = &ahc->untagged_queues[target]; in ahc_dump_card_state()
7276 ahc_outb(ahc, SCBPTR, saved_scbptr); in ahc_dump_card_state()
7278 ahc_unpause(ahc); in ahc_dump_card_state()
7284 ahc_find_tmode_devs(struct ahc_softc *ahc, struct cam_sim *sim, union ccb *ccb, in ahc_find_tmode_devs() argument
7290 if ((ahc->features & AHC_TARGETMODE) == 0) in ahc_find_tmode_devs()
7300 *lstate = ahc->black_hole; in ahc_find_tmode_devs()
7304 max_id = (ahc->features & AHC_WIDE) ? 16 : 8; in ahc_find_tmode_devs()
7311 *tstate = ahc->enabled_targets[ccb->ccb_h.target_id]; in ahc_find_tmode_devs()
7325 ahc_handle_en_lun(struct ahc_softc *ahc, struct cam_sim *sim, union ccb *ccb) in ahc_handle_en_lun() argument
7339 status = ahc_find_tmode_devs(ahc, sim, ccb, &tstate, &lstate, in ahc_handle_en_lun()
7348 our_id = ahc->our_id; in ahc_handle_en_lun()
7350 our_id = ahc->our_id_b; in ahc_handle_en_lun()
7372 if ((ahc->features & AHC_MULTIROLE) != 0) { in ahc_handle_en_lun()
7374 if ((ahc->features & AHC_MULTI_TID) != 0 in ahc_handle_en_lun()
7375 && (ahc->flags & AHC_INITIATORROLE) != 0) { in ahc_handle_en_lun()
7384 } else if ((ahc->flags & AHC_INITIATORROLE) != 0 in ahc_handle_en_lun()
7385 || ahc->enabled_luns > 0) { in ahc_handle_en_lun()
7395 } else if ((ahc->features & AHC_MULTI_TID) == 0 in ahc_handle_en_lun()
7396 && ahc->enabled_luns > 0) { in ahc_handle_en_lun()
7411 if ((ahc->flags & AHC_TARGETROLE) == 0 in ahc_handle_en_lun()
7417 ahc_lock(ahc, &s); in ahc_handle_en_lun()
7418 if (LIST_FIRST(&ahc->pending_scbs) != NULL) { in ahc_handle_en_lun()
7420 ahc_unlock(ahc, &s); in ahc_handle_en_lun()
7423 saved_flags = ahc->flags; in ahc_handle_en_lun()
7424 ahc->flags |= AHC_TARGETROLE; in ahc_handle_en_lun()
7425 if ((ahc->features & AHC_MULTIROLE) == 0) in ahc_handle_en_lun()
7426 ahc->flags &= ~AHC_INITIATORROLE; in ahc_handle_en_lun()
7427 ahc_pause(ahc); in ahc_handle_en_lun()
7428 error = ahc_loadseq(ahc); in ahc_handle_en_lun()
7438 ahc->flags = saved_flags; in ahc_handle_en_lun()
7439 (void)ahc_loadseq(ahc); in ahc_handle_en_lun()
7440 ahc_restart(ahc); in ahc_handle_en_lun()
7441 ahc_unlock(ahc, &s); in ahc_handle_en_lun()
7445 ahc_restart(ahc); in ahc_handle_en_lun()
7446 ahc_unlock(ahc, &s); in ahc_handle_en_lun()
7451 channel = SIM_CHANNEL(ahc, sim); in ahc_handle_en_lun()
7483 tstate = ahc_alloc_tstate(ahc, target, channel); in ahc_handle_en_lun()
7511 ahc_lock(ahc, &s); in ahc_handle_en_lun()
7512 ahc_pause(ahc); in ahc_handle_en_lun()
7515 ahc->enabled_luns++; in ahc_handle_en_lun()
7517 if ((ahc->features & AHC_MULTI_TID) != 0) { in ahc_handle_en_lun()
7520 targid_mask = ahc_inb(ahc, TARGID) in ahc_handle_en_lun()
7521 | (ahc_inb(ahc, TARGID + 1) << 8); in ahc_handle_en_lun()
7524 ahc_outb(ahc, TARGID, targid_mask); in ahc_handle_en_lun()
7525 ahc_outb(ahc, TARGID+1, (targid_mask >> 8)); in ahc_handle_en_lun()
7526 ahc_update_scsiid(ahc, targid_mask); in ahc_handle_en_lun()
7531 channel = SIM_CHANNEL(ahc, sim); in ahc_handle_en_lun()
7532 our_id = SIM_SCSI_ID(ahc, sim); in ahc_handle_en_lun()
7543 sblkctl = ahc_inb(ahc, SBLKCTL); in ahc_handle_en_lun()
7546 if ((ahc->features & AHC_TWIN) == 0) in ahc_handle_en_lun()
7550 ahc->our_id = target; in ahc_handle_en_lun()
7552 ahc->our_id_b = target; in ahc_handle_en_lun()
7555 ahc_outb(ahc, SBLKCTL, in ahc_handle_en_lun()
7558 ahc_outb(ahc, SCSIID, target); in ahc_handle_en_lun()
7561 ahc_outb(ahc, SBLKCTL, sblkctl); in ahc_handle_en_lun()
7565 ahc->black_hole = lstate; in ahc_handle_en_lun()
7567 if (ahc->black_hole != NULL && ahc->enabled_luns > 0) { in ahc_handle_en_lun()
7568 scsiseq = ahc_inb(ahc, SCSISEQ_TEMPLATE); in ahc_handle_en_lun()
7570 ahc_outb(ahc, SCSISEQ_TEMPLATE, scsiseq); in ahc_handle_en_lun()
7571 scsiseq = ahc_inb(ahc, SCSISEQ); in ahc_handle_en_lun()
7573 ahc_outb(ahc, SCSISEQ, scsiseq); in ahc_handle_en_lun()
7575 ahc_unpause(ahc); in ahc_handle_en_lun()
7576 ahc_unlock(ahc, &s); in ahc_handle_en_lun()
7589 ahc_lock(ahc, &s); in ahc_handle_en_lun()
7592 LIST_FOREACH(scb, &ahc->pending_scbs, pending_links) { in ahc_handle_en_lun()
7600 ahc_unlock(ahc, &s); in ahc_handle_en_lun()
7616 ahc_unlock(ahc, &s); in ahc_handle_en_lun()
7625 ahc_pause(ahc); in ahc_handle_en_lun()
7629 ahc->enabled_luns--; in ahc_handle_en_lun()
7637 ahc_free_tstate(ahc, target, channel, in ahc_handle_en_lun()
7639 if (ahc->features & AHC_MULTI_TID) { in ahc_handle_en_lun()
7642 targid_mask = ahc_inb(ahc, TARGID) in ahc_handle_en_lun()
7643 | (ahc_inb(ahc, TARGID + 1) in ahc_handle_en_lun()
7647 ahc_outb(ahc, TARGID, targid_mask); in ahc_handle_en_lun()
7648 ahc_outb(ahc, TARGID+1, in ahc_handle_en_lun()
7650 ahc_update_scsiid(ahc, targid_mask); in ahc_handle_en_lun()
7655 ahc->black_hole = NULL; in ahc_handle_en_lun()
7663 if (ahc->enabled_luns == 0) { in ahc_handle_en_lun()
7667 scsiseq = ahc_inb(ahc, SCSISEQ_TEMPLATE); in ahc_handle_en_lun()
7669 ahc_outb(ahc, SCSISEQ_TEMPLATE, scsiseq); in ahc_handle_en_lun()
7670 scsiseq = ahc_inb(ahc, SCSISEQ); in ahc_handle_en_lun()
7672 ahc_outb(ahc, SCSISEQ, scsiseq); in ahc_handle_en_lun()
7674 if ((ahc->features & AHC_MULTIROLE) == 0) { in ahc_handle_en_lun()
7676 ahc->flags &= ~AHC_TARGETROLE; in ahc_handle_en_lun()
7677 ahc->flags |= AHC_INITIATORROLE; in ahc_handle_en_lun()
7682 (void)ahc_loadseq(ahc); in ahc_handle_en_lun()
7683 ahc_restart(ahc); in ahc_handle_en_lun()
7690 ahc_unpause(ahc); in ahc_handle_en_lun()
7691 ahc_unlock(ahc, &s); in ahc_handle_en_lun()
7696 ahc_update_scsiid(struct ahc_softc *ahc, u_int targid_mask) in ahc_update_scsiid() argument
7701 if ((ahc->features & AHC_MULTI_TID) == 0) in ahc_update_scsiid()
7710 if ((ahc->features & AHC_ULTRA2) != 0) in ahc_update_scsiid()
7711 scsiid = ahc_inb(ahc, SCSIID_ULTRA2); in ahc_update_scsiid()
7713 scsiid = ahc_inb(ahc, SCSIID); in ahc_update_scsiid()
7721 our_id = ahc->our_id; in ahc_update_scsiid()
7727 if ((ahc->features & AHC_ULTRA2) != 0) in ahc_update_scsiid()
7728 ahc_outb(ahc, SCSIID_ULTRA2, scsiid); in ahc_update_scsiid()
7730 ahc_outb(ahc, SCSIID, scsiid); in ahc_update_scsiid()
7734 ahc_run_tqinfifo(struct ahc_softc *ahc, int paused) in ahc_run_tqinfifo() argument
7743 if ((ahc->features & AHC_AUTOPAUSE) != 0) in ahc_run_tqinfifo()
7746 ahc_sync_tqinfifo(ahc, BUS_DMASYNC_POSTREAD); in ahc_run_tqinfifo()
7747 while ((cmd = &ahc->targetcmds[ahc->tqinfifonext])->cmd_valid != 0) { in ahc_run_tqinfifo()
7753 if (ahc_handle_target_cmd(ahc, cmd) != 0) in ahc_run_tqinfifo()
7757 ahc_dmamap_sync(ahc, ahc->shared_data_dmat, in ahc_run_tqinfifo()
7758 ahc->shared_data_dmamap, in ahc_run_tqinfifo()
7759 ahc_targetcmd_offset(ahc, ahc->tqinfifonext), in ahc_run_tqinfifo()
7762 ahc->tqinfifonext++; in ahc_run_tqinfifo()
7768 if ((ahc->tqinfifonext & (HOST_TQINPOS - 1)) == 1) { in ahc_run_tqinfifo()
7769 if ((ahc->features & AHC_HS_MAILBOX) != 0) { in ahc_run_tqinfifo()
7772 hs_mailbox = ahc_inb(ahc, HS_MAILBOX); in ahc_run_tqinfifo()
7774 hs_mailbox |= ahc->tqinfifonext & HOST_TQINPOS; in ahc_run_tqinfifo()
7775 ahc_outb(ahc, HS_MAILBOX, hs_mailbox); in ahc_run_tqinfifo()
7778 ahc_pause(ahc); in ahc_run_tqinfifo()
7779 ahc_outb(ahc, KERNEL_TQINPOS, in ahc_run_tqinfifo()
7780 ahc->tqinfifonext & HOST_TQINPOS); in ahc_run_tqinfifo()
7782 ahc_unpause(ahc); in ahc_run_tqinfifo()
7789 ahc_handle_target_cmd(struct ahc_softc *ahc, struct target_cmd *cmd) in ahc_handle_target_cmd() argument
7799 initiator = SCSIID_TARGET(ahc, cmd->scsiid); in ahc_handle_target_cmd()
7804 tstate = ahc->enabled_targets[target]; in ahc_handle_target_cmd()
7813 lstate = ahc->black_hole; in ahc_handle_target_cmd()
7817 ahc->flags |= AHC_TQINFIFO_BLOCKED; in ahc_handle_target_cmd()
7822 printk("%s: ATIOs exhausted\n", ahc_name(ahc)); in ahc_handle_target_cmd()
7825 ahc->flags &= ~AHC_TQINFIFO_BLOCKED; in ahc_handle_target_cmd()
7829 lstate == ahc->black_hole ? "(Black Holed)" : ""); in ahc_handle_target_cmd()
7833 if (lstate == ahc->black_hole) { in ahc_handle_target_cmd()
7891 initiator, target, lun, ahc->pending_device); in ahc_handle_target_cmd()
7893 ahc->pending_device = lstate; in ahc_handle_target_cmd()