diff options
| author | Matt Jacob <mjacob@FreeBSD.org> | 2006-11-02 03:21:32 +0000 |
|---|---|---|
| committer | Matt Jacob <mjacob@FreeBSD.org> | 2006-11-02 03:21:32 +0000 |
| commit | 10365e5a68725142a2a7effaec46ca1d8f5b273a (patch) | |
| tree | 51750d8ca50a883d32c721be30cbb55cbe2c28c8 /sys/dev/isp/isp_sbus.c | |
| parent | 657669576694b95bd1ea4df0d3b94b9245f5e1c4 (diff) | |
Notes
Diffstat (limited to 'sys/dev/isp/isp_sbus.c')
| -rw-r--r-- | sys/dev/isp/isp_sbus.c | 103 |
1 files changed, 47 insertions, 56 deletions
diff --git a/sys/dev/isp/isp_sbus.c b/sys/dev/isp/isp_sbus.c index c8b88fc61b0a..2e1273be8968 100644 --- a/sys/dev/isp/isp_sbus.c +++ b/sys/dev/isp/isp_sbus.c @@ -51,15 +51,17 @@ __FBSDID("$FreeBSD$"); #include <dev/isp/isp_freebsd.h> -static uint16_t isp_sbus_rd_reg(ispsoftc_t *, int); -static void isp_sbus_wr_reg(ispsoftc_t *, int, uint16_t); +static uint32_t +isp_sbus_rd_reg(ispsoftc_t *, int); +static void +isp_sbus_wr_reg(ispsoftc_t *, int, uint32_t); static int -isp_sbus_rd_isr(ispsoftc_t *, uint16_t *, uint16_t *, uint16_t *); +isp_sbus_rd_isr(ispsoftc_t *, uint32_t *, uint16_t *, uint16_t *); static int isp_sbus_mbxdma(ispsoftc_t *); static int -isp_sbus_dmasetup(ispsoftc_t *, XS_T *, ispreq_t *, uint16_t *, uint16_t); +isp_sbus_dmasetup(ispsoftc_t *, XS_T *, ispreq_t *, uint32_t *, uint32_t); static void -isp_sbus_dmateardown(ispsoftc_t *, XS_T *, uint16_t); +isp_sbus_dmateardown(ispsoftc_t *, XS_T *, uint32_t); static void isp_sbus_reset1(ispsoftc_t *); static void isp_sbus_dumpregs(ispsoftc_t *, const char *); @@ -149,6 +151,7 @@ isp_sbus_attach(device_t dev) struct isp_sbussoftc *sbs; ispsoftc_t *isp = NULL; int locksetup = 0; + int ints_setup = 0; /* * Figure out if we're supposed to skip this one. @@ -184,10 +187,8 @@ isp_sbus_attach(device_t dev) regs = NULL; iqd = 0; - rid = 0; - regs = - bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); + regs = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); if (regs == 0) { device_printf(dev, "unable to map registers\n"); goto bad; @@ -243,19 +244,17 @@ isp_sbus_attach(device_t dev) } /* - * Some early versions of the PTI SBus adapter - * would fail in trying to download (via poking) - * FW. We give up on them. + * We don't trust NVRAM on SBus cards */ - if (strcmp("PTI,ptisp", ofw_bus_get_name(dev)) == 0 || - strcmp("ptisp", ofw_bus_get_name(dev)) == 0) { - isp->isp_confopts |= ISP_CFG_NORELOAD; - } + isp->isp_confopts |= ISP_CFG_NONVRAM; /* - * We don't trust NVRAM on SBus cards + * Mark things if we're a PTI SBus adapter. */ - isp->isp_confopts |= ISP_CFG_NONVRAM; + if (strcmp("PTI,ptisp", ofw_bus_get_name(dev)) == 0 || + strcmp("ptisp", ofw_bus_get_name(dev)) == 0) { + SDPARAM(isp)->isp_ptisp = 1; + } #if __FreeBSD_version >= 700000 @@ -277,14 +276,6 @@ isp_sbus_attach(device_t dev) } #endif - iqd = 0; - sbs->sbus_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ, &iqd, - RF_ACTIVE | RF_SHAREABLE); - if (sbs->sbus_ires == NULL) { - device_printf(dev, "could not allocate interrupt\n"); - goto bad; - } - tval = 0; if (resource_int_value(device_get_name(dev), device_get_unit(dev), "fwload_disable", &tval) == 0 && tval != 0) { @@ -313,11 +304,20 @@ isp_sbus_attach(device_t dev) mtx_init(&isp->isp_osinfo.lock, "isp", NULL, MTX_DEF); locksetup++; + iqd = 0; + sbs->sbus_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ, &iqd, + RF_ACTIVE | RF_SHAREABLE); + if (sbs->sbus_ires == NULL) { + device_printf(dev, "could not allocate interrupt\n"); + goto bad; + } + if (bus_setup_intr(dev, sbs->sbus_ires, ISP_IFLAGS, isp_sbus_intr, isp, &sbs->ih)) { device_printf(dev, "could not setup interrupt\n"); goto bad; } + ints_setup++; /* * Set up logging levels. @@ -327,8 +327,9 @@ isp_sbus_attach(device_t dev) } else { isp->isp_dblev = ISP_LOGWARN|ISP_LOGERR; } - if (bootverbose) + if (bootverbose) { isp->isp_dblev |= ISP_LOGCONFIG|ISP_LOGINFO; + } /* * Make sure we're in reset state. @@ -336,6 +337,7 @@ isp_sbus_attach(device_t dev) ISP_LOCK(isp); isp_reset(isp); if (isp->isp_state != ISP_RESETSTATE) { + isp_uninit(isp); ISP_UNLOCK(isp); goto bad; } @@ -351,42 +353,33 @@ isp_sbus_attach(device_t dev) ISP_UNLOCK(isp); goto bad; } - /* - * XXXX: Here is where we might unload the f/w module - * XXXX: (or decrease the reference count to it). - */ ISP_UNLOCK(isp); return (0); bad: - if (sbs && sbs->ih) { + if (sbs && ints_setup) { (void) bus_teardown_intr(dev, sbs->sbus_ires, sbs->ih); } - if (locksetup && isp) { - mtx_destroy(&isp->isp_osinfo.lock); - } - if (sbs && sbs->sbus_ires) { bus_release_resource(dev, SYS_RES_IRQ, iqd, sbs->sbus_ires); } + if (locksetup && isp) { + mtx_destroy(&isp->isp_osinfo.lock); + } if (regs) { (void) bus_release_resource(dev, 0, 0, regs); } if (sbs) { - if (sbs->sbus_isp.isp_param) + if (sbs->sbus_isp.isp_param) { free(sbs->sbus_isp.isp_param, M_DEVBUF); + } free(sbs, M_DEVBUF); } - - /* - * XXXX: Here is where we might unload the f/w module - * XXXX: (or decrease the reference count to it). - */ return (ENXIO); } @@ -394,17 +387,15 @@ static void isp_sbus_intr(void *arg) { ispsoftc_t *isp = arg; - uint16_t isr, sema, mbox; + uint32_t isr; + uint16_t sema, mbox; ISP_LOCK(isp); isp->isp_intcnt++; if (ISP_READ_ISR(isp, &isr, &sema, &mbox) == 0) { isp->isp_intbogus++; } else { - int iok = isp->isp_osinfo.intsok; - isp->isp_osinfo.intsok = 0; isp_intr(isp, isr, sema, mbox); - isp->isp_osinfo.intsok = iok; } ISP_UNLOCK(isp); } @@ -417,8 +408,7 @@ isp_sbus_intr(void *arg) bus_space_read_2(sbc->sbus_st, sbc->sbus_sh, off) static int -isp_sbus_rd_isr(ispsoftc_t *isp, uint16_t *isrp, - uint16_t *semap, uint16_t *mbp) +isp_sbus_rd_isr(ispsoftc_t *isp, uint32_t *isrp, uint16_t *semap, uint16_t *mbp) { struct isp_sbussoftc *sbc = (struct isp_sbussoftc *) isp; uint16_t isr, sema; @@ -438,7 +428,7 @@ isp_sbus_rd_isr(ispsoftc_t *isp, uint16_t *isrp, return (1); } -static uint16_t +static uint32_t isp_sbus_rd_reg(ispsoftc_t *isp, int regoff) { uint16_t rval; @@ -452,7 +442,7 @@ isp_sbus_rd_reg(ispsoftc_t *isp, int regoff) } static void -isp_sbus_wr_reg(ispsoftc_t *isp, int regoff, uint16_t val) +isp_sbus_wr_reg(ispsoftc_t *isp, int regoff, uint32_t val) { struct isp_sbussoftc *sbs = (struct isp_sbussoftc *) isp; int offset = sbs->sbus_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT]; @@ -605,8 +595,8 @@ typedef struct { ispsoftc_t *isp; void *cmd_token; void *rq; - uint16_t *nxtip; - uint16_t optr; + uint32_t *nxtip; + uint32_t optr; int error; } mush_t; @@ -721,7 +711,7 @@ dma2(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) static int isp_sbus_dmasetup(ispsoftc_t *isp, struct ccb_scsiio *csio, ispreq_t *rq, - uint16_t *nxtip, uint16_t optr) + uint32_t *nxtip, uint32_t optr) { struct isp_sbussoftc *sbs = (struct isp_sbussoftc *)isp; ispreq_t *qep; @@ -809,6 +799,9 @@ isp_sbus_dmasetup(ispsoftc_t *isp, struct ccb_scsiio *csio, ispreq_t *rq, return (retval); } mbxsync: + if (isp->isp_dblev & ISP_LOGDEBUG1) { + isp_print_bytes(isp, "Request Queue Entry", QENTRY_LEN, rq); + } switch (rq->req_header.rqs_entry_type) { case RQSTYPE_REQUEST: isp_put_request(isp, rq, qep); @@ -822,7 +815,7 @@ mbxsync: } static void -isp_sbus_dmateardown(ispsoftc_t *isp, XS_T *xs, uint16_t handle) +isp_sbus_dmateardown(ispsoftc_t *isp, XS_T *xs, uint32_t handle) { struct isp_sbussoftc *sbs = (struct isp_sbussoftc *)isp; bus_dmamap_t *dp = &sbs->dmaps[isp_handle_index(handle)]; @@ -834,12 +827,10 @@ isp_sbus_dmateardown(ispsoftc_t *isp, XS_T *xs, uint16_t handle) bus_dmamap_unload(sbs->dmat, *dp); } - static void isp_sbus_reset1(ispsoftc_t *isp) { - /* enable interrupts */ - ENABLE_INTS(isp); + ISP_ENABLE_INTS(isp); } static void |
