2 * PCI specific probe and attach routines for Qlogic ISP SCSI adapters.
5 * Copyright (c) 1997, 1998, 1999, 2000, 2001 by Matthew Jacob
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice immediately at the beginning of the file, without modification,
12 * this list of conditions, and the following disclaimer.
13 * 2. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
32 #include <sys/param.h>
33 #include <sys/systm.h>
35 #include <sys/kernel.h>
36 #include <sys/module.h>
37 #include <sys/resource.h>
39 #include <dev/ofw/ofw_bus.h>
41 #include <machine/bus.h>
42 #include <machine/resource.h>
44 #include <sparc64/sbus/sbusvar.h>
46 #include <dev/isp/isp_freebsd.h>
48 static u_int16_t isp_sbus_rd_reg(struct ispsoftc *, int);
49 static void isp_sbus_wr_reg(struct ispsoftc *, int, u_int16_t);
51 isp_sbus_rd_isr(struct ispsoftc *, u_int16_t *, u_int16_t *, u_int16_t *);
52 static int isp_sbus_mbxdma(struct ispsoftc *);
54 isp_sbus_dmasetup(struct ispsoftc *, XS_T *, ispreq_t *, u_int16_t *, u_int16_t);
56 isp_sbus_dmateardown(struct ispsoftc *, XS_T *, u_int16_t);
58 static void isp_sbus_reset1(struct ispsoftc *);
59 static void isp_sbus_dumpregs(struct ispsoftc *, const char *);
61 static struct ispmdvec mdvec = {
72 BIU_BURST_ENABLE|BIU_PCI_CONF1_FIFO_64
75 static int isp_sbus_probe (device_t);
76 static int isp_sbus_attach (device_t);
79 struct isp_sbussoftc {
80 struct ispsoftc sbus_isp;
82 struct resource * sbus_reg;
83 bus_space_tag_t sbus_st;
84 bus_space_handle_t sbus_sh;
86 int16_t sbus_poff[_NREG_BLKS];
90 struct ispmdvec sbus_mdvec;
91 struct resource * sbus_ires;
94 extern ispfwfunc *isp_get_firmware_p;
96 static device_method_t isp_sbus_methods[] = {
97 /* Device interface */
98 DEVMETHOD(device_probe, isp_sbus_probe),
99 DEVMETHOD(device_attach, isp_sbus_attach),
102 static void isp_sbus_intr(void *);
104 static driver_t isp_sbus_driver = {
105 "isp", isp_sbus_methods, sizeof (struct isp_sbussoftc)
107 static devclass_t isp_devclass;
108 DRIVER_MODULE(isp, sbus, isp_sbus_driver, isp_devclass, 0, 0);
111 isp_sbus_probe(device_t dev)
114 const char *name = ofw_bus_get_name(dev);
115 if (strcmp(name, "SUNW,isp") == 0 ||
116 strcmp(name, "QLGC,isp") == 0 ||
117 strcmp(name, "ptisp") == 0 ||
118 strcmp(name, "PTI,ptisp") == 0) {
124 if (isp_announced == 0 && bootverbose) {
125 printf("Qlogic ISP Driver, FreeBSD Version %d.%d, "
126 "Core Version %d.%d\n",
127 ISP_PLATFORM_VERSION_MAJOR, ISP_PLATFORM_VERSION_MINOR,
128 ISP_CORE_VERSION_MAJOR, ISP_CORE_VERSION_MINOR);
135 isp_sbus_attach(device_t dev)
137 struct resource *regs;
138 int tval, iqd, isp_debug, role, rid, ispburst, freq;
139 struct isp_sbussoftc *sbs;
140 struct ispsoftc *isp = NULL;
144 * Figure out if we're supposed to skip this one.
145 * If we are, we actually go to ISP_ROLE_NONE.
149 if (resource_int_value(device_get_name(dev), device_get_unit(dev),
150 "disable", &tval) == 0 && tval) {
151 device_printf(dev, "device is disabled\n");
152 /* but return 0 so the !$)$)*!$*) unit isn't reused */
157 if (resource_int_value(device_get_name(dev), device_get_unit(dev),
158 "role", &role) == 0 &&
159 ((role & ~(ISP_ROLE_INITIATOR|ISP_ROLE_TARGET)) == 0)) {
160 device_printf(dev, "setting role to 0x%x\n", role);
162 #ifdef ISP_TARGET_MODE
163 role = ISP_ROLE_INITIATOR|ISP_ROLE_TARGET;
165 role = ISP_DEFAULT_ROLES;
169 sbs = malloc(sizeof (*sbs), M_DEVBUF, M_NOWAIT | M_ZERO);
171 device_printf(dev, "cannot allocate softc\n");
180 bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
182 device_printf(dev, "unable to map registers\n");
186 sbs->sbus_reg = regs;
187 sbs->sbus_st = rman_get_bustag(regs);
188 sbs->sbus_sh = rman_get_bushandle(regs);
189 sbs->sbus_mdvec = mdvec;
191 sbs->sbus_poff[BIU_BLOCK >> _BLK_REG_SHFT] = BIU_REGS_OFF;
192 sbs->sbus_poff[MBOX_BLOCK >> _BLK_REG_SHFT] = SBUS_MBOX_REGS_OFF;
193 sbs->sbus_poff[SXP_BLOCK >> _BLK_REG_SHFT] = SBUS_SXP_REGS_OFF;
194 sbs->sbus_poff[RISC_BLOCK >> _BLK_REG_SHFT] = SBUS_RISC_REGS_OFF;
195 sbs->sbus_poff[DMA_BLOCK >> _BLK_REG_SHFT] = DMA_REGS_OFF;
196 isp = &sbs->sbus_isp;
197 isp->isp_mdvec = &sbs->sbus_mdvec;
198 isp->isp_bustype = ISP_BT_SBUS;
199 isp->isp_type = ISP_HA_SCSI_UNKNOWN;
200 isp->isp_param = &sbs->sbus_param;
201 isp->isp_revision = 0; /* XXX */
202 isp->isp_role = role;
205 freq = sbus_get_clockfreq(dev);
208 * Convert from HZ to MHz, rounding up.
210 freq = (freq + 500000)/1000000;
214 sbs->sbus_mdvec.dv_clock = freq << 8;
217 * Now figure out what the proper burst sizes, etc., to use.
218 * Unfortunately, there is no ddi_dma_burstsizes here which
219 * walks up the tree finding the limiting burst size node (if
220 * any). We just use what's here for isp.
222 ispburst = sbus_get_burstsz(dev);
224 ispburst = SBUS_BURST_32 - 1;
226 sbs->sbus_mdvec.dv_conf1 = 0;
227 if (ispburst & (1 << 5)) {
228 sbs->sbus_mdvec.dv_conf1 = BIU_SBUS_CONF1_FIFO_32;
229 } else if (ispburst & (1 << 4)) {
230 sbs->sbus_mdvec.dv_conf1 = BIU_SBUS_CONF1_FIFO_16;
231 } else if (ispburst & (1 << 3)) {
232 sbs->sbus_mdvec.dv_conf1 =
233 BIU_SBUS_CONF1_BURST8 | BIU_SBUS_CONF1_FIFO_8;
235 if (sbs->sbus_mdvec.dv_conf1) {
236 sbs->sbus_mdvec.dv_conf1 |= BIU_BURST_ENABLE;
240 * Some early versions of the PTI SBus adapter
241 * would fail in trying to download (via poking)
242 * FW. We give up on them.
244 if (strcmp("PTI,ptisp", ofw_bus_get_name(dev)) == 0 ||
245 strcmp("ptisp", ofw_bus_get_name(dev)) == 0) {
246 isp->isp_confopts |= ISP_CFG_NORELOAD;
250 * We don't trust NVRAM on SBus cards
252 isp->isp_confopts |= ISP_CFG_NONVRAM;
256 * Try and find firmware for this device.
259 if (isp_get_firmware_p) {
260 (*isp_get_firmware_p)(0, 0, 0x1000, &sbs->sbus_mdvec.dv_ispfw);
264 sbs->sbus_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ, &iqd,
265 RF_ACTIVE | RF_SHAREABLE);
266 if (sbs->sbus_ires == NULL) {
267 device_printf(dev, "could not allocate interrupt\n");
272 if (resource_int_value(device_get_name(dev), device_get_unit(dev),
273 "fwload_disable", &tval) == 0 && tval != 0) {
274 isp->isp_confopts |= ISP_CFG_NORELOAD;
277 isp->isp_osinfo.default_id = -1;
278 if (resource_int_value(device_get_name(dev), device_get_unit(dev),
279 "iid", &tval) == 0) {
280 isp->isp_osinfo.default_id = tval;
281 isp->isp_confopts |= ISP_CFG_OWNLOOPID;
283 if (isp->isp_osinfo.default_id == -1) {
285 * XXX: should be a way to get properties w/o having
286 * XXX: to call OF_xxx functions
288 isp->isp_osinfo.default_id = 7;
292 (void) resource_int_value(device_get_name(dev), device_get_unit(dev),
293 "debug", &isp_debug);
295 /* Make sure the lock is set up. */
296 mtx_init(&isp->isp_osinfo.lock, "isp", NULL, MTX_DEF);
299 if (bus_setup_intr(dev, sbs->sbus_ires, ISP_IFLAGS,
300 isp_sbus_intr, isp, &sbs->ih)) {
301 device_printf(dev, "could not setup interrupt\n");
306 * Set up logging levels.
309 isp->isp_dblev = isp_debug;
311 isp->isp_dblev = ISP_LOGWARN|ISP_LOGERR;
314 isp->isp_dblev |= ISP_LOGCONFIG|ISP_LOGINFO;
317 * Make sure we're in reset state.
321 if (isp->isp_state != ISP_RESETSTATE) {
326 if (isp->isp_role != ISP_ROLE_NONE && isp->isp_state != ISP_INITSTATE) {
332 if (isp->isp_role != ISP_ROLE_NONE && isp->isp_state != ISP_RUNSTATE) {
338 * XXXX: Here is where we might unload the f/w module
339 * XXXX: (or decrease the reference count to it).
346 if (sbs && sbs->ih) {
347 (void) bus_teardown_intr(dev, sbs->sbus_ires, sbs->ih);
350 if (locksetup && isp) {
351 mtx_destroy(&isp->isp_osinfo.lock);
354 if (sbs && sbs->sbus_ires) {
355 bus_release_resource(dev, SYS_RES_IRQ, iqd, sbs->sbus_ires);
360 (void) bus_release_resource(dev, 0, 0, regs);
364 if (sbs->sbus_isp.isp_param)
365 free(sbs->sbus_isp.isp_param, M_DEVBUF);
370 * XXXX: Here is where we might unload the f/w module
371 * XXXX: (or decrease the reference count to it).
377 isp_sbus_intr(void *arg)
379 struct ispsoftc *isp = arg;
380 u_int16_t isr, sema, mbox;
384 if (ISP_READ_ISR(isp, &isr, &sema, &mbox) == 0) {
387 int iok = isp->isp_osinfo.intsok;
388 isp->isp_osinfo.intsok = 0;
389 isp_intr(isp, isr, sema, mbox);
390 isp->isp_osinfo.intsok = iok;
395 #define IspVirt2Off(a, x) \
396 (((struct isp_sbussoftc *)a)->sbus_poff[((x) & _BLK_REG_MASK) >> \
397 _BLK_REG_SHFT] + ((x) & 0xff))
399 #define BXR2(sbc, off) \
400 bus_space_read_2(sbc->sbus_st, sbc->sbus_sh, off)
403 isp_sbus_rd_isr(struct ispsoftc *isp, u_int16_t *isrp,
404 u_int16_t *semap, u_int16_t *mbp)
406 struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) isp;
409 isr = BXR2(sbc, IspVirt2Off(isp, BIU_ISR));
410 sema = BXR2(sbc, IspVirt2Off(isp, BIU_SEMA));
411 isp_prt(isp, ISP_LOGDEBUG3, "ISR 0x%x SEMA 0x%x", isr, sema);
412 isr &= INT_PENDING_MASK(isp);
413 sema &= BIU_SEMA_LOCK;
414 if (isr == 0 && sema == 0) {
418 if ((*semap = sema) != 0) {
419 *mbp = BXR2(sbc, IspVirt2Off(isp, OUTMAILBOX0));
425 isp_sbus_rd_reg(struct ispsoftc *isp, int regoff)
428 struct isp_sbussoftc *sbs = (struct isp_sbussoftc *) isp;
429 int offset = sbs->sbus_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT];
430 offset += (regoff & 0xff);
431 rval = bus_space_read_2(sbs->sbus_st, sbs->sbus_sh, offset);
432 isp_prt(isp, ISP_LOGDEBUG3,
433 "isp_sbus_rd_reg(off %x) = %x", regoff, rval);
438 isp_sbus_wr_reg(struct ispsoftc *isp, int regoff, u_int16_t val)
440 struct isp_sbussoftc *sbs = (struct isp_sbussoftc *) isp;
441 int offset = sbs->sbus_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT];
442 offset += (regoff & 0xff);
443 isp_prt(isp, ISP_LOGDEBUG3,
444 "isp_sbus_wr_reg(off %x) = %x", regoff, val);
445 bus_space_write_2(sbs->sbus_st, sbs->sbus_sh, offset, val);
449 struct ispsoftc *isp;
453 static void imc(void *, bus_dma_segment_t *, int, int);
456 imc(void *arg, bus_dma_segment_t *segs, int nseg, int error)
458 struct imush *imushp = (struct imush *) arg;
460 imushp->error = error;
462 struct ispsoftc *isp =imushp->isp;
463 bus_addr_t addr = segs->ds_addr;
465 isp->isp_rquest_dma = addr;
466 addr += ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp));
467 isp->isp_result_dma = addr;
472 * Should be BUS_SPACE_MAXSIZE, but MAXPHYS is larger than BUS_SPACE_MAXSIZE
474 #define ISP_NSEGS ((MAXPHYS / PAGE_SIZE) + 1)
477 isp_sbus_mbxdma(struct ispsoftc *isp)
479 struct isp_sbussoftc *sbs = (struct isp_sbussoftc *)isp;
486 * Already been here? If so, leave...
488 if (isp->isp_rquest) {
494 if (bus_dma_tag_create(NULL, 1, BUS_SPACE_MAXADDR_24BIT+1,
495 BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR_32BIT,
496 NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, ISP_NSEGS,
497 BUS_SPACE_MAXADDR_24BIT, 0, busdma_lock_mutex, &Giant,
499 isp_prt(isp, ISP_LOGERR, "could not create master dma tag");
504 len = sizeof (XS_T **) * isp->isp_maxcmds;
505 isp->isp_xflist = (XS_T **) malloc(len, M_DEVBUF, M_WAITOK | M_ZERO);
506 if (isp->isp_xflist == NULL) {
507 isp_prt(isp, ISP_LOGERR, "cannot alloc xflist array");
511 len = sizeof (bus_dmamap_t) * isp->isp_maxcmds;
512 sbs->dmaps = (bus_dmamap_t *) malloc(len, M_DEVBUF, M_WAITOK);
513 if (sbs->dmaps == NULL) {
514 isp_prt(isp, ISP_LOGERR, "can't alloc dma map storage");
515 free(isp->isp_xflist, M_DEVBUF);
521 * Allocate and map the request, result queues, plus FC scratch area.
523 len = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp));
524 len += ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp));
526 ns = (len / PAGE_SIZE) + 1;
527 if (bus_dma_tag_create(sbs->dmat, QENTRY_LEN, BUS_SPACE_MAXADDR_24BIT+1,
528 BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR_32BIT, NULL, NULL,
529 len, ns, BUS_SPACE_MAXADDR_24BIT, 0, busdma_lock_mutex, &Giant,
531 isp_prt(isp, ISP_LOGERR,
532 "cannot create a dma tag for control spaces");
533 free(sbs->dmaps, M_DEVBUF);
534 free(isp->isp_xflist, M_DEVBUF);
539 if (bus_dmamem_alloc(isp->isp_cdmat, (void **)&base, BUS_DMA_NOWAIT,
540 &isp->isp_cdmap) != 0) {
541 isp_prt(isp, ISP_LOGERR,
542 "cannot allocate %d bytes of CCB memory", len);
543 bus_dma_tag_destroy(isp->isp_cdmat);
544 free(isp->isp_xflist, M_DEVBUF);
545 free(sbs->dmaps, M_DEVBUF);
550 for (i = 0; i < isp->isp_maxcmds; i++) {
551 error = bus_dmamap_create(sbs->dmat, 0, &sbs->dmaps[i]);
553 isp_prt(isp, ISP_LOGERR,
554 "error %d creating per-cmd DMA maps", error);
556 bus_dmamap_destroy(sbs->dmat, sbs->dmaps[i]);
564 bus_dmamap_load(isp->isp_cdmat, isp->isp_cdmap, base, len, imc, &im, 0);
566 isp_prt(isp, ISP_LOGERR,
567 "error %d loading dma map for control areas", im.error);
571 isp->isp_rquest = base;
572 base += ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp));
574 isp->isp_result = base;
578 bus_dmamem_free(isp->isp_cdmat, base, isp->isp_cdmap);
579 bus_dma_tag_destroy(isp->isp_cdmat);
580 free(isp->isp_xflist, M_DEVBUF);
581 free(sbs->dmaps, M_DEVBUF);
583 isp->isp_rquest = NULL;
588 struct ispsoftc *isp;
596 #define MUSHERR_NOQENTRIES -2
599 static void dma2(void *, bus_dma_segment_t *, int, int);
602 dma2(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
605 struct ispsoftc *isp;
606 struct ccb_scsiio *csio;
607 struct isp_sbussoftc *sbs;
609 bus_dma_segment_t *eseg;
621 isp_prt(mp->isp, ISP_LOGERR, "bad segment count (%d)", nseg);
625 csio = mp->cmd_token;
628 sbs = (struct isp_sbussoftc *)mp->isp;
629 dp = &sbs->dmaps[isp_handle_index(rq->req_handle)];
632 if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
633 bus_dmamap_sync(sbs->dmat, *dp, BUS_DMASYNC_PREREAD);
635 bus_dmamap_sync(sbs->dmat, *dp, BUS_DMASYNC_PREWRITE);
638 datalen = XS_XFRLEN(csio);
641 * We're passed an initial partially filled in entry that
642 * has most fields filled in except for data transfer
645 * Our job is to fill in the initial request queue entry and
646 * then to start allocating and filling in continuation entries
647 * until we've covered the entire transfer.
650 if (csio->cdb_len > 12) {
655 if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
656 rq->req_flags |= REQFLAG_DATA_IN;
658 rq->req_flags |= REQFLAG_DATA_OUT;
661 eseg = dm_segs + nseg;
663 while (datalen != 0 && rq->req_seg_count < seglim && dm_segs != eseg) {
664 rq->req_dataseg[rq->req_seg_count].ds_base = dm_segs->ds_addr;
665 rq->req_dataseg[rq->req_seg_count].ds_count = dm_segs->ds_len;
666 datalen -= dm_segs->ds_len;
671 while (datalen > 0 && dm_segs != eseg) {
673 ispcontreq_t local, *crq = &local, *cqe;
675 cqe = (ispcontreq_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, nxti);
677 nxti = ISP_NXT_QENTRY(onxti, RQUEST_QUEUE_LEN(isp));
678 if (nxti == mp->optr) {
679 isp_prt(isp, ISP_LOGDEBUG0, "Request Queue Overflow++");
680 mp->error = MUSHERR_NOQENTRIES;
683 rq->req_header.rqs_entry_count++;
684 MEMZERO((void *)crq, sizeof (*crq));
685 crq->req_header.rqs_entry_count = 1;
686 crq->req_header.rqs_entry_type = RQSTYPE_DATASEG;
689 while (datalen > 0 && seglim < ISP_CDSEG && dm_segs != eseg) {
690 crq->req_dataseg[seglim].ds_base =
692 crq->req_dataseg[seglim].ds_count =
697 datalen -= dm_segs->ds_len;
699 isp_put_cont_req(isp, crq, cqe);
700 MEMORYBARRIER(isp, SYNC_REQUEST, onxti, QENTRY_LEN);
706 isp_sbus_dmasetup(struct ispsoftc *isp, struct ccb_scsiio *csio, ispreq_t *rq,
707 u_int16_t *nxtip, u_int16_t optr)
709 struct isp_sbussoftc *sbs = (struct isp_sbussoftc *)isp;
711 bus_dmamap_t *dp = NULL;
713 void (*eptr)(void *, bus_dma_segment_t *, int, int);
715 qep = (ispreq_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, isp->isp_reqidx);
719 if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE ||
720 (csio->dxfer_len == 0)) {
721 rq->req_seg_count = 1;
726 * Do a virtual grapevine step to collect info for
727 * the callback dma allocation that we have to use...
731 mp->cmd_token = csio;
737 if ((csio->ccb_h.flags & CAM_SCATTER_VALID) == 0) {
738 if ((csio->ccb_h.flags & CAM_DATA_PHYS) == 0) {
740 dp = &sbs->dmaps[isp_handle_index(rq->req_handle)];
742 error = bus_dmamap_load(sbs->dmat, *dp,
743 csio->data_ptr, csio->dxfer_len, eptr, mp, 0);
744 if (error == EINPROGRESS) {
745 bus_dmamap_unload(sbs->dmat, *dp);
747 isp_prt(isp, ISP_LOGERR,
748 "deferred dma allocation not supported");
749 } else if (error && mp->error == 0) {
751 isp_prt(isp, ISP_LOGERR,
752 "error %d in dma mapping code", error);
758 /* Pointer to physical buffer */
759 struct bus_dma_segment seg;
760 seg.ds_addr = (bus_addr_t)csio->data_ptr;
761 seg.ds_len = csio->dxfer_len;
762 (*eptr)(mp, &seg, 1, 0);
765 struct bus_dma_segment *segs;
767 if ((csio->ccb_h.flags & CAM_DATA_PHYS) != 0) {
768 isp_prt(isp, ISP_LOGERR,
769 "Physical segment pointers unsupported");
771 } else if ((csio->ccb_h.flags & CAM_SG_LIST_PHYS) == 0) {
772 isp_prt(isp, ISP_LOGERR,
773 "Virtual segment addresses unsupported");
776 /* Just use the segments provided */
777 segs = (struct bus_dma_segment *) csio->data_ptr;
778 (*eptr)(mp, segs, csio->sglist_cnt, 0);
782 int retval = CMD_COMPLETE;
783 if (mp->error == MUSHERR_NOQENTRIES) {
785 } else if (mp->error == EFBIG) {
786 XS_SETERR(csio, CAM_REQ_TOO_BIG);
787 } else if (mp->error == EINVAL) {
788 XS_SETERR(csio, CAM_REQ_INVALID);
790 XS_SETERR(csio, CAM_UNREC_HBA_ERROR);
795 switch (rq->req_header.rqs_entry_type) {
796 case RQSTYPE_REQUEST:
797 isp_put_request(isp, rq, qep);
799 case RQSTYPE_CMDONLY:
800 isp_put_extended_request(isp, (ispextreq_t *)rq,
808 isp_sbus_dmateardown(struct ispsoftc *isp, XS_T *xs, u_int16_t handle)
810 struct isp_sbussoftc *sbs = (struct isp_sbussoftc *)isp;
811 bus_dmamap_t *dp = &sbs->dmaps[isp_handle_index(handle)];
812 if ((xs->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
813 bus_dmamap_sync(sbs->dmat, *dp, BUS_DMASYNC_POSTREAD);
815 bus_dmamap_sync(sbs->dmat, *dp, BUS_DMASYNC_POSTWRITE);
817 bus_dmamap_unload(sbs->dmat, *dp);
822 isp_sbus_reset1(struct ispsoftc *isp)
824 /* enable interrupts */
829 isp_sbus_dumpregs(struct ispsoftc *isp, const char *msg)
832 printf("%s: %s\n", device_get_nameunit(isp->isp_dev), msg);
834 printf("%s:\n", device_get_nameunit(isp->isp_dev));
835 printf(" biu_conf1=%x", ISP_READ(isp, BIU_CONF1));
836 printf(" biu_icr=%x biu_isr=%x biu_sema=%x ", ISP_READ(isp, BIU_ICR),
837 ISP_READ(isp, BIU_ISR), ISP_READ(isp, BIU_SEMA));
838 printf("risc_hccr=%x\n", ISP_READ(isp, HCCR));
841 ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE);
842 printf(" cdma_conf=%x cdma_sts=%x cdma_fifostat=%x\n",
843 ISP_READ(isp, CDMA_CONF), ISP_READ(isp, CDMA_STATUS),
844 ISP_READ(isp, CDMA_FIFO_STS));
845 printf(" ddma_conf=%x ddma_sts=%x ddma_fifostat=%x\n",
846 ISP_READ(isp, DDMA_CONF), ISP_READ(isp, DDMA_STATUS),
847 ISP_READ(isp, DDMA_FIFO_STS));
848 printf(" sxp_int=%x sxp_gross=%x sxp(scsi_ctrl)=%x\n",
849 ISP_READ(isp, SXP_INTERRUPT),
850 ISP_READ(isp, SXP_GROSS_ERR),
851 ISP_READ(isp, SXP_PINS_CTRL));
852 ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE);
853 printf(" mbox regs: %x %x %x %x %x\n",
854 ISP_READ(isp, OUTMAILBOX0), ISP_READ(isp, OUTMAILBOX1),
855 ISP_READ(isp, OUTMAILBOX2), ISP_READ(isp, OUTMAILBOX3),
856 ISP_READ(isp, OUTMAILBOX4));