Home | History | Annotate | Download | only in ic

Lines Matching defs:ahc

54 static __inline void ahc_pause_bug_fix(struct ahc_softc *ahc);
55 static __inline int ahc_is_paused(struct ahc_softc *ahc);
56 static __inline void ahc_pause(struct ahc_softc *ahc);
57 static __inline void ahc_unpause(struct ahc_softc *ahc);
68 ahc_pause_bug_fix(struct ahc_softc *ahc)
70 if ((ahc->features & AHC_ULTRA2) != 0)
71 (void)ahc_inb(ahc, CCSCBCTL);
79 ahc_is_paused(struct ahc_softc *ahc)
81 return ((ahc_inb(ahc, HCNTRL) & PAUSE) != 0);
92 ahc_pause(struct ahc_softc *ahc)
94 ahc_outb(ahc, HCNTRL, ahc->pause);
100 while (ahc_is_paused(ahc) == 0)
103 ahc_pause_bug_fix(ahc);
117 ahc_unpause(struct ahc_softc *ahc)
119 if ((ahc_inb(ahc, INTSTAT) & (SCSIINT | SEQINT | BRKADRINT)) == 0)
120 ahc_outb(ahc, HCNTRL, ahc->unpause);
124 static __inline void ahc_freeze_untagged_queues(struct ahc_softc *ahc);
125 static __inline void ahc_release_untagged_queues(struct ahc_softc *ahc);
132 ahc_freeze_untagged_queues(struct ahc_softc *ahc)
134 if ((ahc->flags & AHC_SCB_BTT) == 0)
135 ahc->untagged_queue_lock++;
145 ahc_release_untagged_queues(struct ahc_softc *ahc)
147 if ((ahc->flags & AHC_SCB_BTT) == 0) {
148 ahc->untagged_queue_lock--;
149 if (ahc->untagged_queue_lock == 0)
150 ahc_run_untagged_queues(ahc);
162 ahc_hscb_busaddr(struct ahc_softc *ahc, u_int index);
163 static __inline void ahc_sync_scb(struct ahc_softc *ahc,
165 static __inline void ahc_sync_sglist(struct ahc_softc *ahc,
168 ahc_targetcmd_offset(struct ahc_softc *ahc,
195 ahc_hscb_busaddr(struct ahc_softc *ahc, u_int index)
197 return (ahc->scb_data->hscb_busaddr
202 ahc_sync_scb(struct ahc_softc *ahc, struct scb *scb, int op)
204 ahc_dmamap_sync(ahc, ahc->parent_dmat,
205 ahc->scb_data->hscb_dmamap,
206 /*offset*/(scb->hscb - ahc->scb_data->hscbs) * sizeof(*scb->hscb),
211 ahc_sync_sglist(struct ahc_softc *ahc, struct scb *scb, int op)
216 ahc_dmamap_sync(ahc, ahc->parent_dmat, scb->sg_map->sg_dmamap,
223 ahc_targetcmd_offset(struct ahc_softc *ahc, u_int index)
225 return (((uint8_t *)&ahc->targetcmds[index]) - ahc->qoutfifo);
229 static __inline const char *ahc_name(struct ahc_softc *ahc);
232 ahc_name(struct ahc_softc *ahc)
234 return (ahc->name);
239 static __inline void ahc_update_residual(struct ahc_softc *ahc,
242 ahc_fetch_transinfo(struct ahc_softc *ahc,
247 ahc_inw(struct ahc_softc *ahc, u_int port);
248 static __inline void ahc_outw(struct ahc_softc *ahc, u_int port,
251 ahc_inl(struct ahc_softc *ahc, u_int port);
252 static __inline void ahc_outl(struct ahc_softc *ahc, u_int port,
255 ahc_inq(struct ahc_softc *ahc, u_int port);
256 static __inline void ahc_outq(struct ahc_softc *ahc, u_int port,
259 ahc_get_scb(struct ahc_softc *ahc);
260 static __inline void ahc_free_scb(struct ahc_softc *ahc, struct scb *scb);
261 static __inline void ahc_swap_with_next_hscb(struct ahc_softc *ahc,
263 static __inline void ahc_queue_scb(struct ahc_softc *ahc, struct scb *scb);
265 ahc_get_sense_buf(struct ahc_softc *ahc,
268 ahc_get_sense_bufaddr(struct ahc_softc *ahc,
276 ahc_update_residual(struct ahc_softc *ahc, struct scb *scb)
282 ahc_calc_residual(ahc, scb);
290 ahc_fetch_transinfo(struct ahc_softc *ahc, char channel, u_int our_id,
303 *tstate = ahc->enabled_targets[our_id];
308 ahc_inw(struct ahc_softc *ahc, u_int port)
310 return ((ahc_inb(ahc, port+1) << 8) | ahc_inb(ahc, port));
314 ahc_outw(struct ahc_softc *ahc, u_int port, u_int value)
316 ahc_outb(ahc, port, value & 0xFF);
317 ahc_outb(ahc, port+1, (value >> 8) & 0xFF);
321 ahc_inl(struct ahc_softc *ahc, u_int port)
323 return ((ahc_inb(ahc, port))
324 | (ahc_inb(ahc, port+1) << 8)
325 | (ahc_inb(ahc, port+2) << 16)
326 | (ahc_inb(ahc, port+3) << 24));
330 ahc_outl(struct ahc_softc *ahc, u_int port, uint32_t value)
332 ahc_outb(ahc, port, (value) & 0xFF);
333 ahc_outb(ahc, port+1, ((value) >> 8) & 0xFF);
334 ahc_outb(ahc, port+2, ((value) >> 16) & 0xFF);
335 ahc_outb(ahc, port+3, ((value) >> 24) & 0xFF);
339 ahc_inq(struct ahc_softc *ahc, u_int port)
341 return ((ahc_inb(ahc, port))
342 | (ahc_inb(ahc, port+1) << 8)
343 | (ahc_inb(ahc, port+2) << 16)
344 | (ahc_inb(ahc, port+3) << 24)
345 | (((uint64_t)ahc_inb(ahc, port+4)) << 32)
346 | (((uint64_t)ahc_inb(ahc, port+5)) << 40)
347 | (((uint64_t)ahc_inb(ahc, port+6)) << 48)
348 | (((uint64_t)ahc_inb(ahc, port+7)) << 56));
352 ahc_outq(struct ahc_softc *ahc, u_int port, uint64_t value)
354 ahc_outb(ahc, port, value & 0xFF);
355 ahc_outb(ahc, port+1, (value >> 8) & 0xFF);
356 ahc_outb(ahc, port+2, (value >> 16) & 0xFF);
357 ahc_outb(ahc, port+3, (value >> 24) & 0xFF);
358 ahc_outb(ahc, port+4, (value >> 32) & 0xFF);
359 ahc_outb(ahc, port+5, (value >> 40) & 0xFF);
360 ahc_outb(ahc, port+6, (value >> 48) & 0xFF);
361 ahc_outb(ahc, port+7, (value >> 56) & 0xFF);
368 ahc_get_scb(struct ahc_softc *ahc)
372 if ((scb = SLIST_FIRST(&ahc->scb_data->free_scbs)) == NULL)
374 SLIST_REMOVE_HEAD(&ahc->scb_data->free_scbs, links.sle);
382 ahc_free_scb(struct ahc_softc *ahc, struct scb *scb)
388 ahc->scb_data->scbindex[hscb->tag] = NULL;
392 SLIST_INSERT_HEAD(&ahc->scb_data->free_scbs, scb, links.sle);
395 ahc_platform_scb_free(ahc, scb);
399 ahc_lookup_scb(struct ahc_softc *ahc, u_int tag)
403 scb = ahc->scb_data->scbindex[tag];
405 ahc_sync_scb(ahc, scb,
411 ahc_swap_with_next_hscb(struct ahc_softc *ahc, struct scb *scb)
420 * SCB to download is saved off in ahc->next_queued_scb.
428 q_hscb = ahc->next_queued_scb->hscb;
433 ahc_htole32(ahc_hscb_busaddr(ahc, q_hscb->tag)
440 ahc->next_queued_scb->hscb = scb->hscb;
444 ahc->scb_data->scbindex[scb->hscb->tag] = scb;
451 ahc_queue_scb(struct ahc_softc *ahc, struct scb *scb)
453 ahc_swap_with_next_hscb(ahc, scb);
462 ahc->qinfifo[ahc->qinfifonext++] = scb->hscb->tag;
468 ahc_sync_scb(ahc, scb, BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE);
471 if ((ahc->features & AHC_QUEUE_REGS) != 0) {
472 ahc_outb(ahc, HNSCB_QOFF, ahc->qinfifonext);
474 if ((ahc->features & AHC_AUTOPAUSE) == 0)
475 ahc_pause(ahc);
476 ahc_outb(ahc, KERNEL_QINPOS, ahc->qinfifonext);
477 if ((ahc->features & AHC_AUTOPAUSE) == 0)
478 ahc_unpause(ahc);
483 ahc_get_sense_buf(struct ahc_softc *ahc, struct scb *scb)
487 offset = scb - ahc->scb_data->scbarray;
488 return (&ahc->scb_data->sense[offset]);
492 ahc_get_sense_bufaddr(struct ahc_softc *ahc, struct scb *scb)
496 offset = scb - ahc->scb_data->scbarray;
497 return (ahc->scb_data->sense_busaddr
502 static __inline void ahc_sync_qoutfifo(struct ahc_softc *ahc, int op);
503 static __inline void ahc_sync_tqinfifo(struct ahc_softc *ahc, int op);
504 static __inline u_int ahc_check_cmdcmpltqueues(struct ahc_softc *ahc);
525 ahc_sync_qoutfifo(struct ahc_softc *ahc, int op)
527 ahc_dmamap_sync(ahc, ahc->parent_dmat, ahc->shared_data_dmamap,
532 ahc_sync_tqinfifo(struct ahc_softc *ahc, int op)
535 if ((ahc->flags & AHC_TARGETROLE) != 0) {
536 ahc_dmamap_sync(ahc, ahc->parent_dmat /*shared_data_dmat*/,
537 ahc->shared_data_dmamap,
538 ahc_targetcmd_offset(ahc, 0),
552 ahc_check_cmdcmpltqueues(struct ahc_softc *ahc)
557 ahc_dmamap_sync(ahc, ahc->parent_dmat /*shared_data_dmat*/, ahc->shared_data_dmamap,
558 /*offset*/ahc->qoutfifonext, /*len*/1,
560 if (ahc->qoutfifo[ahc->qoutfifonext] != SCB_LIST_NULL)
563 if ((ahc->flags & AHC_TARGETROLE) != 0
564 && (ahc->flags & AHC_TQINFIFO_BLOCKED) == 0) {
565 ahc_dmamap_sync(ahc, ahc->parent_dmat /*shared_data_dmat*/,
566 ahc->shared_data_dmamap,
567 ahc_targetcmd_offset(ahc, ahc->tqinfifonext),
570 if (ahc->targetcmds[ahc->tqinfifonext].cmd_valid != 0)
583 struct ahc_softc *ahc = (struct ahc_softc*)arg;
586 if ((ahc->pause & INTEN) == 0) {
601 if ((ahc->flags & (AHC_ALL_INTERRUPTS|AHC_EDGE_INTERRUPT)) == 0
602 && (ahc_check_cmdcmpltqueues(ahc) != 0))
605 intstat = ahc_inb(ahc, INTSTAT);
609 ahc_outb(ahc, CLRINT, CLRCMDINT);
618 ahc_flush_device_writes(ahc);
619 scsipi_channel_freeze(ahc->channel == 'A' ? &ahc->sc_channel : &ahc->sc_channel_b, 1);
620 ahc_run_qoutfifo(ahc);
621 scsipi_channel_thaw(ahc->channel == 'A' ? &ahc->sc_channel : &ahc->sc_channel_b, 1);
623 if ((ahc->flags & AHC_TARGETROLE) != 0)
624 ahc_run_tqinfifo(ahc, /*paused*/FALSE);
628 if (intstat == 0xFF && (ahc->features & AHC_REMOVABLE) != 0)
634 if (ahc->unsolicited_ints > 500) {
635 ahc->unsolicited_ints = 0;
636 if ((ahc->chip & AHC_PCI) != 0
637 && (ahc_inb(ahc, ERROR) & PCIERRSTAT) != 0)
638 ahc->bus_intr(ahc);
641 ahc->unsolicited_ints++;
644 ahc->unsolicited_ints = 0;
647 ahc_handle_brkadrint(ahc);
653 ahc_pause_bug_fix(ahc);
656 ahc_handle_seqint(ahc, intstat);
659 ahc_handle_scsiint(ahc, intstat);