Lines Matching defs:ahc

49 static __inline void ahc_pause_bug_fix(struct ahc_softc *ahc);
50 static __inline int ahc_is_paused(struct ahc_softc *ahc);
51 static __inline void ahc_pause(struct ahc_softc *ahc);
52 static __inline void ahc_unpause(struct ahc_softc *ahc);
63 ahc_pause_bug_fix(struct ahc_softc *ahc)
65 if ((ahc->features & AHC_ULTRA2) != 0)
66 (void)ahc_inb(ahc, CCSCBCTL);
74 ahc_is_paused(struct ahc_softc *ahc)
76 return ((ahc_inb(ahc, HCNTRL) & PAUSE) != 0);
87 ahc_pause(struct ahc_softc *ahc)
89 ahc_outb(ahc, HCNTRL, ahc->pause);
95 while (ahc_is_paused(ahc) == 0)
98 ahc_pause_bug_fix(ahc);
112 ahc_unpause(struct ahc_softc *ahc)
114 if ((ahc_inb(ahc, INTSTAT) & (SCSIINT | SEQINT | BRKADRINT)) == 0)
115 ahc_outb(ahc, HCNTRL, ahc->unpause);
119 static __inline void ahc_freeze_untagged_queues(struct ahc_softc *ahc);
120 static __inline void ahc_release_untagged_queues(struct ahc_softc *ahc);
127 ahc_freeze_untagged_queues(struct ahc_softc *ahc)
129 if ((ahc->flags & AHC_SCB_BTT) == 0)
130 ahc->untagged_queue_lock++;
140 ahc_release_untagged_queues(struct ahc_softc *ahc)
142 if ((ahc->flags & AHC_SCB_BTT) == 0) {
143 ahc->untagged_queue_lock--;
144 if (ahc->untagged_queue_lock == 0)
145 ahc_run_untagged_queues(ahc);
157 ahc_hscb_busaddr(struct ahc_softc *ahc, u_int index);
158 static __inline void ahc_sync_scb(struct ahc_softc *ahc,
160 static __inline void ahc_sync_sglist(struct ahc_softc *ahc,
163 ahc_targetcmd_offset(struct ahc_softc *ahc,
190 ahc_hscb_busaddr(struct ahc_softc *ahc, u_int index)
192 return (ahc->scb_data->hscb_busaddr
197 ahc_sync_scb(struct ahc_softc *ahc, struct scb *scb, int op)
199 aic_dmamap_sync(ahc, ahc->scb_data->hscb_dmat,
200 ahc->scb_data->hscb_dmamap,
201 /*offset*/(scb->hscb - ahc->hscbs) * sizeof(*scb->hscb),
206 ahc_sync_sglist(struct ahc_softc *ahc, struct scb *scb, int op)
211 aic_dmamap_sync(ahc, ahc->scb_data->sg_dmat, scb->sg_map->sg_dmamap,
218 ahc_targetcmd_offset(struct ahc_softc *ahc, u_int index)
220 return (((uint8_t *)&ahc->targetcmds[index]) - (uint8_t *)ahc->targetcmds);
224 static __inline char *ahc_name(struct ahc_softc *ahc);
227 ahc_name(struct ahc_softc *ahc)
229 return (ahc->name);
234 static __inline void ahc_update_residual(struct ahc_softc *ahc,
237 ahc_fetch_transinfo(struct ahc_softc *ahc,
242 ahc_inw(struct ahc_softc *ahc, u_int port);
243 static __inline void ahc_outw(struct ahc_softc *ahc, u_int port,
246 ahc_inl(struct ahc_softc *ahc, u_int port);
247 static __inline void ahc_outl(struct ahc_softc *ahc, u_int port,
250 ahc_inq(struct ahc_softc *ahc, u_int port);
251 static __inline void ahc_outq(struct ahc_softc *ahc, u_int port,
254 ahc_get_scb(struct ahc_softc *ahc);
255 static __inline void ahc_free_scb(struct ahc_softc *ahc, struct scb *scb);
256 static __inline void ahc_swap_with_next_hscb(struct ahc_softc *ahc,
258 static __inline void ahc_queue_scb(struct ahc_softc *ahc, struct scb *scb);
260 ahc_get_sense_buf(struct ahc_softc *ahc,
263 ahc_get_sense_bufaddr(struct ahc_softc *ahc,
271 ahc_update_residual(struct ahc_softc *ahc, struct scb *scb)
277 ahc_calc_residual(ahc, scb);
285 ahc_fetch_transinfo(struct ahc_softc *ahc, char channel, u_int our_id,
296 *tstate = ahc->enabled_targets[our_id];
301 ahc_inw(struct ahc_softc *ahc, u_int port)
303 return ((ahc_inb(ahc, port+1) << 8) | ahc_inb(ahc, port));
307 ahc_outw(struct ahc_softc *ahc, u_int port, u_int value)
309 ahc_outb(ahc, port, value & 0xFF);
310 ahc_outb(ahc, port+1, (value >> 8) & 0xFF);
314 ahc_inl(struct ahc_softc *ahc, u_int port)
316 return ((ahc_inb(ahc, port))
317 | (ahc_inb(ahc, port+1) << 8)
318 | (ahc_inb(ahc, port+2) << 16)
319 | (ahc_inb(ahc, port+3) << 24));
323 ahc_outl(struct ahc_softc *ahc, u_int port, uint32_t value)
325 ahc_outb(ahc, port, (value) & 0xFF);
326 ahc_outb(ahc, port+1, ((value) >> 8) & 0xFF);
327 ahc_outb(ahc, port+2, ((value) >> 16) & 0xFF);
328 ahc_outb(ahc, port+3, ((value) >> 24) & 0xFF);
332 ahc_inq(struct ahc_softc *ahc, u_int port)
334 return ((ahc_inb(ahc, port))
335 | (ahc_inb(ahc, port+1) << 8)
336 | (ahc_inb(ahc, port+2) << 16)
337 | (ahc_inb(ahc, port+3) << 24)
338 | (((uint64_t)ahc_inb(ahc, port+4)) << 32)
339 | (((uint64_t)ahc_inb(ahc, port+5)) << 40)
340 | (((uint64_t)ahc_inb(ahc, port+6)) << 48)
341 | (((uint64_t)ahc_inb(ahc, port+7)) << 56));
345 ahc_outq(struct ahc_softc *ahc, u_int port, uint64_t value)
347 ahc_outb(ahc, port, value & 0xFF);
348 ahc_outb(ahc, port+1, (value >> 8) & 0xFF);
349 ahc_outb(ahc, port+2, (value >> 16) & 0xFF);
350 ahc_outb(ahc, port+3, (value >> 24) & 0xFF);
351 ahc_outb(ahc, port+4, (value >> 32) & 0xFF);
352 ahc_outb(ahc, port+5, (value >> 40) & 0xFF);
353 ahc_outb(ahc, port+6, (value >> 48) & 0xFF);
354 ahc_outb(ahc, port+7, (value >> 56) & 0xFF);
361 ahc_get_scb(struct ahc_softc *ahc)
365 if ((scb = SLIST_FIRST(&ahc->scb_data->free_scbs)) == NULL) {
366 if (ahc_alloc_scbs(ahc) == 0)
368 scb = SLIST_FIRST(&ahc->scb_data->free_scbs);
372 SLIST_REMOVE_HEAD(&ahc->scb_data->free_scbs, links.sle);
380 ahc_free_scb(struct ahc_softc *ahc, struct scb *scb)
386 ahc->scb_data->scbindex[hscb->tag] = NULL;
390 SLIST_INSERT_HEAD(&ahc->scb_data->free_scbs, scb, links.sle);
393 aic_platform_scb_free(ahc, scb);
397 ahc_lookup_scb(struct ahc_softc *ahc, u_int tag)
401 scb = ahc->scb_data->scbindex[tag];
403 ahc_sync_scb(ahc, scb,
409 ahc_swap_with_next_hscb(struct ahc_softc *ahc, struct scb *scb)
418 * SCB to download is saved off in ahc->next_queued_scb.
426 q_hscb = ahc->next_queued_scb->hscb;
431 aic_htole32(ahc_hscb_busaddr(ahc, q_hscb->tag)
438 ahc->next_queued_scb->hscb = scb->hscb;
442 ahc->scb_data->scbindex[scb->hscb->tag] = scb;
449 ahc_queue_scb(struct ahc_softc *ahc, struct scb *scb)
451 ahc_swap_with_next_hscb(ahc, scb);
468 ahc->qinfifo[ahc->qinfifonext++] = scb->hscb->tag;
474 ahc_sync_scb(ahc, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
477 if ((ahc->features & AHC_QUEUE_REGS) != 0) {
478 ahc_outb(ahc, HNSCB_QOFF, ahc->qinfifonext);
480 if ((ahc->features & AHC_AUTOPAUSE) == 0)
481 ahc_pause(ahc);
482 ahc_outb(ahc, KERNEL_QINPOS, ahc->qinfifonext);
483 if ((ahc->features & AHC_AUTOPAUSE) == 0)
484 ahc_unpause(ahc);
489 ahc_get_sense_buf(struct ahc_softc *ahc, struct scb *scb)
493 offset = scb - ahc->scb_data->scbarray;
494 return (&ahc->scb_data->sense[offset]);
498 ahc_get_sense_bufaddr(struct ahc_softc *ahc, struct scb *scb)
502 offset = scb - ahc->scb_data->scbarray;
503 return (ahc->scb_data->sense_busaddr
508 static __inline void ahc_sync_qoutfifo(struct ahc_softc *ahc, int op);
509 static __inline void ahc_sync_tqinfifo(struct ahc_softc *ahc, int op);
510 static __inline u_int ahc_check_cmdcmpltqueues(struct ahc_softc *ahc);
511 static __inline int ahc_intr(struct ahc_softc *ahc);
514 ahc_sync_qoutfifo(struct ahc_softc *ahc, int op)
516 aic_dmamap_sync(ahc, ahc->shared_data_dmat, ahc->shared_data_dmamap,
521 ahc_sync_tqinfifo(struct ahc_softc *ahc, int op)
524 if ((ahc->flags & AHC_TARGETROLE) != 0) {
525 aic_dmamap_sync(ahc, ahc->shared_data_dmat,
526 ahc->shared_data_dmamap,
527 ahc_targetcmd_offset(ahc, 0),
541 ahc_check_cmdcmpltqueues(struct ahc_softc *ahc)
546 aic_dmamap_sync(ahc, ahc->shared_data_dmat, ahc->shared_data_dmamap,
547 /*offset*/ahc->qoutfifonext, /*len*/1,
549 if (ahc->qoutfifo[ahc->qoutfifonext] != SCB_LIST_NULL)
552 if ((ahc->flags & AHC_TARGETROLE) != 0
553 && (ahc->flags & AHC_TQINFIFO_BLOCKED) == 0) {
554 aic_dmamap_sync(ahc, ahc->shared_data_dmat,
555 ahc->shared_data_dmamap,
556 ahc_targetcmd_offset(ahc, ahc->tqinfifofnext),
559 if (ahc->targetcmds[ahc->tqinfifonext].cmd_valid != 0)
570 ahc_intr(struct ahc_softc *ahc)
574 if ((ahc->pause & INTEN) == 0) {
589 if ((ahc->flags & (AHC_ALL_INTERRUPTS|AHC_EDGE_INTERRUPT)) == 0
590 && (ahc_check_cmdcmpltqueues(ahc) != 0))
593 intstat = ahc_inb(ahc, INTSTAT);
598 if (ahc->unsolicited_ints > 500) {
599 ahc->unsolicited_ints = 0;
600 if ((ahc->chip & AHC_PCI) != 0
601 && (ahc_inb(ahc, ERROR) & PCIERRSTAT) != 0)
602 ahc->bus_intr(ahc);
605 ahc->unsolicited_ints++;
608 ahc->unsolicited_ints = 0;
611 ahc_outb(ahc, CLRINT, CLRCMDINT);
621 ahc_flush_device_writes(ahc);
622 ahc_run_qoutfifo(ahc);
624 if ((ahc->flags & AHC_TARGETROLE) != 0)
625 ahc_run_tqinfifo(ahc, /*paused*/FALSE);
633 if (intstat == 0xFF && (ahc->features & AHC_REMOVABLE) != 0) {
636 ahc_handle_brkadrint(ahc);
638 ahc_pause_bug_fix(ahc);
641 ahc_handle_seqint(ahc, intstat);
644 ahc_handle_scsiint(ahc, intstat);