1999-12-04 05:54:54 +03:00
|
|
|
/* $NetBSD: isp_pci.c,v 1.47 1999/12/04 02:54:54 mjacob Exp $ */
|
1997-03-12 23:44:50 +03:00
|
|
|
/*
|
|
|
|
* PCI specific probe and attach routines for Qlogic ISP SCSI adapters.
|
1999-07-06 00:28:11 +04:00
|
|
|
* Matthew Jacob (mjacob@nas.nasa.gov)
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* Copyright (C) 1997, 1998, 1999 National Aeronautics & Space Administration
|
1997-03-12 23:44:50 +03:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
1999-07-06 00:28:11 +04:00
|
|
|
* notice, this list of conditions and the following disclaimer.
|
1997-03-12 23:44:50 +03:00
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
1999-07-06 00:28:11 +04:00
|
|
|
* derived from this software without specific prior written permission
|
1998-07-15 23:53:57 +04:00
|
|
|
*
|
1999-07-06 00:28:11 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1997-03-12 23:44:50 +03:00
|
|
|
*/
|
|
|
|
|
1998-07-15 23:53:57 +04:00
|
|
|
#include <dev/ic/isp_netbsd.h>
|
1999-12-04 05:54:54 +03:00
|
|
|
#include <dev/microcode/isp/asm_pci.h>
|
1998-07-15 23:53:57 +04:00
|
|
|
|
1997-03-12 23:44:50 +03:00
|
|
|
#include <dev/pci/pcireg.h>
|
|
|
|
#include <dev/pci/pcivar.h>
|
|
|
|
#include <dev/pci/pcidevs.h>
|
1997-03-13 04:56:06 +03:00
|
|
|
|
1997-03-12 23:44:50 +03:00
|
|
|
static u_int16_t isp_pci_rd_reg __P((struct ispsoftc *, int));
|
|
|
|
static void isp_pci_wr_reg __P((struct ispsoftc *, int, u_int16_t));
|
1999-03-17 09:16:42 +03:00
|
|
|
#ifndef ISP_DISABLE_1080_SUPPORT
|
|
|
|
static u_int16_t isp_pci_rd_reg_1080 __P((struct ispsoftc *, int));
|
|
|
|
static void isp_pci_wr_reg_1080 __P((struct ispsoftc *, int, u_int16_t));
|
|
|
|
#endif
|
1997-06-08 10:34:52 +04:00
|
|
|
static int isp_pci_mbxdma __P((struct ispsoftc *));
|
1997-08-27 15:22:52 +04:00
|
|
|
static int isp_pci_dmasetup __P((struct ispsoftc *, struct scsipi_xfer *,
|
1999-12-04 05:54:54 +03:00
|
|
|
ispreq_t *, u_int16_t *, u_int16_t));
|
1997-08-27 15:22:52 +04:00
|
|
|
static void isp_pci_dmateardown __P((struct ispsoftc *, struct scsipi_xfer *,
|
1997-06-08 10:34:52 +04:00
|
|
|
u_int32_t));
|
1997-03-12 23:44:50 +03:00
|
|
|
static void isp_pci_reset1 __P((struct ispsoftc *));
|
1997-08-16 04:28:10 +04:00
|
|
|
static void isp_pci_dumpregs __P((struct ispsoftc *));
|
1998-07-31 06:08:16 +04:00
|
|
|
static int isp_pci_intr __P((void *));
|
1997-03-12 23:44:50 +03:00
|
|
|
|
1999-12-04 05:54:54 +03:00
|
|
|
#ifndef ISP_CODE_ORG
|
|
|
|
#define ISP_CODE_ORG 0x1000
|
|
|
|
#endif
|
|
|
|
#ifndef ISP_1040_RISC_CODE
|
|
|
|
#define ISP_1040_RISC_CODE NULL
|
|
|
|
#endif
|
|
|
|
#ifndef ISP_1080_RISC_CODE
|
|
|
|
#define ISP_1080_RISC_CODE NULL
|
|
|
|
#endif
|
|
|
|
#ifndef ISP_2100_RISC_CODE
|
|
|
|
#define ISP_2100_RISC_CODE NULL
|
|
|
|
#endif
|
|
|
|
#ifndef ISP_2200_RISC_CODE
|
|
|
|
#define ISP_2200_RISC_CODE NULL
|
|
|
|
#endif
|
|
|
|
|
1999-03-17 09:16:42 +03:00
|
|
|
#ifndef ISP_DISABLE_1020_SUPPORT
|
1997-03-12 23:44:50 +03:00
|
|
|
static struct ispmdvec mdvec = {
|
|
|
|
isp_pci_rd_reg,
|
|
|
|
isp_pci_wr_reg,
|
|
|
|
isp_pci_mbxdma,
|
|
|
|
isp_pci_dmasetup,
|
1997-06-08 10:34:52 +04:00
|
|
|
isp_pci_dmateardown,
|
1997-03-12 23:44:50 +03:00
|
|
|
NULL,
|
|
|
|
isp_pci_reset1,
|
1997-08-16 04:28:10 +04:00
|
|
|
isp_pci_dumpregs,
|
1999-12-04 05:54:54 +03:00
|
|
|
ISP_1040_RISC_CODE,
|
1999-10-28 20:11:19 +04:00
|
|
|
0,
|
1999-12-04 05:54:54 +03:00
|
|
|
ISP_CODE_ORG,
|
1999-10-14 06:14:35 +04:00
|
|
|
0,
|
1999-01-10 06:41:47 +03:00
|
|
|
BIU_BURST_ENABLE|BIU_PCI_CONF1_FIFO_64,
|
1998-09-08 11:16:46 +04:00
|
|
|
0
|
1997-08-16 04:28:10 +04:00
|
|
|
};
|
1999-03-17 09:16:42 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef ISP_DISABLE_1080_SUPPORT
|
|
|
|
static struct ispmdvec mdvec_1080 = {
|
|
|
|
isp_pci_rd_reg_1080,
|
|
|
|
isp_pci_wr_reg_1080,
|
|
|
|
isp_pci_mbxdma,
|
|
|
|
isp_pci_dmasetup,
|
|
|
|
isp_pci_dmateardown,
|
|
|
|
NULL,
|
|
|
|
isp_pci_reset1,
|
|
|
|
isp_pci_dumpregs,
|
1999-12-04 05:54:54 +03:00
|
|
|
ISP_1080_RISC_CODE,
|
1999-10-28 20:11:19 +04:00
|
|
|
0,
|
1999-12-04 05:54:54 +03:00
|
|
|
ISP_CODE_ORG,
|
1999-10-14 06:14:35 +04:00
|
|
|
0,
|
1999-03-17 09:16:42 +03:00
|
|
|
BIU_BURST_ENABLE|BIU_PCI_CONF1_FIFO_64,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
#endif
|
1997-08-16 04:28:10 +04:00
|
|
|
|
1999-03-17 09:16:42 +03:00
|
|
|
#ifndef ISP_DISABLE_2100_SUPPORT
|
1997-08-16 04:28:10 +04:00
|
|
|
static struct ispmdvec mdvec_2100 = {
|
|
|
|
isp_pci_rd_reg,
|
|
|
|
isp_pci_wr_reg,
|
|
|
|
isp_pci_mbxdma,
|
|
|
|
isp_pci_dmasetup,
|
|
|
|
isp_pci_dmateardown,
|
|
|
|
NULL,
|
|
|
|
isp_pci_reset1,
|
|
|
|
isp_pci_dumpregs,
|
1999-12-04 05:54:54 +03:00
|
|
|
ISP_2100_RISC_CODE,
|
1999-10-28 20:11:19 +04:00
|
|
|
0,
|
1999-12-04 05:54:54 +03:00
|
|
|
ISP_CODE_ORG,
|
1999-10-14 06:14:35 +04:00
|
|
|
0,
|
|
|
|
0,
|
1999-01-10 06:41:47 +03:00
|
|
|
0
|
1997-03-12 23:44:50 +03:00
|
|
|
};
|
1999-03-17 09:16:42 +03:00
|
|
|
#endif
|
1997-03-12 23:44:50 +03:00
|
|
|
|
1999-07-06 00:28:11 +04:00
|
|
|
#ifndef ISP_DISABLE_2200_SUPPORT
|
|
|
|
static struct ispmdvec mdvec_2200 = {
|
|
|
|
isp_pci_rd_reg,
|
|
|
|
isp_pci_wr_reg,
|
|
|
|
isp_pci_mbxdma,
|
|
|
|
isp_pci_dmasetup,
|
|
|
|
isp_pci_dmateardown,
|
|
|
|
NULL,
|
|
|
|
isp_pci_reset1,
|
|
|
|
isp_pci_dumpregs,
|
1999-12-04 05:54:54 +03:00
|
|
|
ISP_2200_RISC_CODE,
|
1999-10-28 20:11:19 +04:00
|
|
|
0,
|
1999-12-04 05:54:54 +03:00
|
|
|
ISP_CODE_ORG,
|
1999-10-14 06:14:35 +04:00
|
|
|
0,
|
|
|
|
0,
|
1999-07-06 00:28:11 +04:00
|
|
|
0
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
1999-03-17 09:16:42 +03:00
|
|
|
#ifndef PCI_VENDOR_QLOGIC
|
|
|
|
#define PCI_VENDOR_QLOGIC 0x1077
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef PCI_PRODUCT_QLOGIC_ISP1020
|
|
|
|
#define PCI_PRODUCT_QLOGIC_ISP1020 0x1020
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef PCI_PRODUCT_QLOGIC_ISP1080
|
|
|
|
#define PCI_PRODUCT_QLOGIC_ISP1080 0x1080
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef PCI_PRODUCT_QLOGIC_ISP1240
|
|
|
|
#define PCI_PRODUCT_QLOGIC_ISP1240 0x1240
|
|
|
|
#endif
|
1997-03-12 23:44:50 +03:00
|
|
|
|
1997-08-16 04:28:10 +04:00
|
|
|
#ifndef PCI_PRODUCT_QLOGIC_ISP2100
|
|
|
|
#define PCI_PRODUCT_QLOGIC_ISP2100 0x2100
|
|
|
|
#endif
|
1999-03-17 09:16:42 +03:00
|
|
|
|
1999-07-06 00:28:11 +04:00
|
|
|
#ifndef PCI_PRODUCT_QLOGIC_ISP2200
|
|
|
|
#define PCI_PRODUCT_QLOGIC_ISP2200 0x2200
|
|
|
|
#endif
|
|
|
|
|
1999-03-17 09:16:42 +03:00
|
|
|
#define PCI_QLOGIC_ISP ((PCI_PRODUCT_QLOGIC_ISP1020 << 16) | PCI_VENDOR_QLOGIC)
|
|
|
|
|
|
|
|
#define PCI_QLOGIC_ISP1080 \
|
|
|
|
((PCI_PRODUCT_QLOGIC_ISP1080 << 16) | PCI_VENDOR_QLOGIC)
|
|
|
|
|
|
|
|
#define PCI_QLOGIC_ISP1240 \
|
|
|
|
((PCI_PRODUCT_QLOGIC_ISP1240 << 16) | PCI_VENDOR_QLOGIC)
|
|
|
|
|
1997-08-16 04:28:10 +04:00
|
|
|
#define PCI_QLOGIC_ISP2100 \
|
|
|
|
((PCI_PRODUCT_QLOGIC_ISP2100 << 16) | PCI_VENDOR_QLOGIC)
|
|
|
|
|
1999-07-06 00:28:11 +04:00
|
|
|
#define PCI_QLOGIC_ISP2200 \
|
|
|
|
((PCI_PRODUCT_QLOGIC_ISP2200 << 16) | PCI_VENDOR_QLOGIC)
|
|
|
|
|
1999-10-17 05:22:08 +04:00
|
|
|
#define IO_MAP_REG 0x10
|
|
|
|
#define MEM_MAP_REG 0x14
|
1999-04-04 05:14:58 +04:00
|
|
|
#define PCIR_ROMADDR 0x30
|
|
|
|
|
|
|
|
#define PCI_DFLT_LTNCY 0x40
|
|
|
|
#define PCI_DFLT_LNSZ 0x10
|
1997-03-16 03:37:00 +03:00
|
|
|
|
1997-03-12 23:44:50 +03:00
|
|
|
|
|
|
|
static int isp_pci_probe __P((struct device *, struct cfdata *, void *));
|
|
|
|
static void isp_pci_attach __P((struct device *, struct device *, void *));
|
|
|
|
|
|
|
|
struct isp_pcisoftc {
|
|
|
|
struct ispsoftc pci_isp;
|
1997-08-16 04:28:10 +04:00
|
|
|
pci_chipset_tag_t pci_pc;
|
|
|
|
pcitag_t pci_tag;
|
1997-03-16 03:37:00 +03:00
|
|
|
bus_space_tag_t pci_st;
|
|
|
|
bus_space_handle_t pci_sh;
|
1997-06-08 10:34:52 +04:00
|
|
|
bus_dma_tag_t pci_dmat;
|
1997-08-16 04:28:10 +04:00
|
|
|
bus_dmamap_t pci_scratch_dmap; /* for fcp only */
|
1997-06-08 10:34:52 +04:00
|
|
|
bus_dmamap_t pci_rquest_dmap;
|
|
|
|
bus_dmamap_t pci_result_dmap;
|
1999-10-17 06:40:26 +04:00
|
|
|
bus_dmamap_t *pci_xfer_dmap;
|
1997-03-12 23:44:50 +03:00
|
|
|
void * pci_ih;
|
1999-03-17 09:16:42 +03:00
|
|
|
int16_t pci_poff[_NREG_BLKS];
|
1997-03-12 23:44:50 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct cfattach isp_pci_ca = {
|
|
|
|
sizeof (struct isp_pcisoftc), isp_pci_probe, isp_pci_attach
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
isp_pci_probe(parent, match, aux)
|
1999-10-17 05:22:08 +04:00
|
|
|
struct device *parent;
|
|
|
|
struct cfdata *match;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct pci_attach_args *pa = aux;
|
|
|
|
switch (pa->pa_id) {
|
1999-03-17 09:16:42 +03:00
|
|
|
#ifndef ISP_DISABLE_1020_SUPPORT
|
|
|
|
case PCI_QLOGIC_ISP:
|
1997-03-12 23:44:50 +03:00
|
|
|
return (1);
|
1999-03-17 09:16:42 +03:00
|
|
|
#endif
|
|
|
|
#ifndef ISP_DISABLE_1080_SUPPORT
|
|
|
|
case PCI_QLOGIC_ISP1080:
|
1999-05-12 22:59:23 +04:00
|
|
|
case PCI_QLOGIC_ISP1240:
|
1999-03-17 09:16:42 +03:00
|
|
|
return (1);
|
|
|
|
#endif
|
|
|
|
#ifndef ISP_DISABLE_2100_SUPPORT
|
|
|
|
case PCI_QLOGIC_ISP2100:
|
|
|
|
return (1);
|
1999-07-06 00:28:11 +04:00
|
|
|
#endif
|
|
|
|
#ifndef ISP_DISABLE_2200_SUPPORT
|
|
|
|
case PCI_QLOGIC_ISP2200:
|
|
|
|
return (1);
|
1999-03-17 09:16:42 +03:00
|
|
|
#endif
|
|
|
|
default:
|
1997-03-12 23:44:50 +03:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-17 05:22:08 +04:00
|
|
|
static void
|
1997-03-12 23:44:50 +03:00
|
|
|
isp_pci_attach(parent, self, aux)
|
1999-10-17 05:22:08 +04:00
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
1997-03-12 23:44:50 +03:00
|
|
|
{
|
1998-09-08 11:16:46 +04:00
|
|
|
#ifdef DEBUG
|
1998-07-31 06:14:40 +04:00
|
|
|
static char oneshot = 1;
|
|
|
|
#endif
|
1999-05-12 22:59:23 +04:00
|
|
|
static char *nomem = "%s: no mem for sdparam table\n";
|
1999-12-04 05:54:54 +03:00
|
|
|
u_int32_t data, rev, linesz = PCI_DFLT_LNSZ;
|
1997-03-12 23:44:50 +03:00
|
|
|
struct pci_attach_args *pa = aux;
|
|
|
|
struct isp_pcisoftc *pcs = (struct isp_pcisoftc *) self;
|
1998-07-15 23:53:57 +04:00
|
|
|
struct ispsoftc *isp = &pcs->pci_isp;
|
1997-04-13 23:48:16 +04:00
|
|
|
bus_space_tag_t st, iot, memt;
|
|
|
|
bus_space_handle_t sh, ioh, memh;
|
1997-03-12 23:44:50 +03:00
|
|
|
pci_intr_handle_t ih;
|
|
|
|
const char *intrstr;
|
1997-08-16 04:28:10 +04:00
|
|
|
int ioh_valid, memh_valid, i;
|
1998-07-19 01:02:06 +04:00
|
|
|
ISP_LOCKVAL_DECL;
|
1997-04-13 23:48:16 +04:00
|
|
|
|
1997-04-14 00:14:20 +04:00
|
|
|
ioh_valid = (pci_mapreg_map(pa, IO_MAP_REG,
|
1997-04-13 23:48:16 +04:00
|
|
|
PCI_MAPREG_TYPE_IO, 0,
|
|
|
|
&iot, &ioh, NULL, NULL) == 0);
|
1997-04-14 00:14:20 +04:00
|
|
|
memh_valid = (pci_mapreg_map(pa, MEM_MAP_REG,
|
1997-04-13 23:48:16 +04:00
|
|
|
PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT, 0,
|
|
|
|
&memt, &memh, NULL, NULL) == 0);
|
|
|
|
|
|
|
|
if (memh_valid) {
|
|
|
|
st = memt;
|
|
|
|
sh = memh;
|
|
|
|
} else if (ioh_valid) {
|
|
|
|
st = iot;
|
|
|
|
sh = ioh;
|
1997-03-16 03:37:00 +03:00
|
|
|
} else {
|
1997-04-13 23:48:16 +04:00
|
|
|
printf(": unable to map device registers\n");
|
1997-03-29 01:25:01 +03:00
|
|
|
return;
|
1997-03-12 23:44:50 +03:00
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
|
1997-03-16 03:37:00 +03:00
|
|
|
pcs->pci_st = st;
|
|
|
|
pcs->pci_sh = sh;
|
1997-06-08 10:34:52 +04:00
|
|
|
pcs->pci_dmat = pa->pa_dmat;
|
1997-08-16 04:28:10 +04:00
|
|
|
pcs->pci_pc = pa->pa_pc;
|
|
|
|
pcs->pci_tag = pa->pa_tag;
|
1999-03-17 09:16:42 +03:00
|
|
|
pcs->pci_poff[BIU_BLOCK >> _BLK_REG_SHFT] = BIU_REGS_OFF;
|
|
|
|
pcs->pci_poff[MBOX_BLOCK >> _BLK_REG_SHFT] = PCI_MBOX_REGS_OFF;
|
|
|
|
pcs->pci_poff[SXP_BLOCK >> _BLK_REG_SHFT] = PCI_SXP_REGS_OFF;
|
|
|
|
pcs->pci_poff[RISC_BLOCK >> _BLK_REG_SHFT] = PCI_RISC_REGS_OFF;
|
|
|
|
pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] = DMA_REGS_OFF;
|
1999-12-04 05:54:54 +03:00
|
|
|
rev = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_CLASS_REG) & 0xff;
|
1999-03-17 09:16:42 +03:00
|
|
|
|
|
|
|
#ifndef ISP_DISABLE_1020_SUPPORT
|
1997-08-16 04:28:10 +04:00
|
|
|
if (pa->pa_id == PCI_QLOGIC_ISP) {
|
1998-07-15 23:53:57 +04:00
|
|
|
isp->isp_mdvec = &mdvec;
|
|
|
|
isp->isp_type = ISP_HA_SCSI_UNKNOWN;
|
|
|
|
isp->isp_param = malloc(sizeof (sdparam), M_DEVBUF, M_NOWAIT);
|
|
|
|
if (isp->isp_param == NULL) {
|
1999-05-12 22:59:23 +04:00
|
|
|
printf(nomem, isp->isp_name);
|
1998-07-15 23:53:57 +04:00
|
|
|
return;
|
1997-08-16 04:28:10 +04:00
|
|
|
}
|
1998-07-15 23:53:57 +04:00
|
|
|
bzero(isp->isp_param, sizeof (sdparam));
|
1999-03-17 09:16:42 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifndef ISP_DISABLE_1080_SUPPORT
|
|
|
|
if (pa->pa_id == PCI_QLOGIC_ISP1080) {
|
|
|
|
isp->isp_mdvec = &mdvec_1080;
|
|
|
|
isp->isp_type = ISP_HA_SCSI_1080;
|
|
|
|
isp->isp_param = malloc(sizeof (sdparam), M_DEVBUF, M_NOWAIT);
|
|
|
|
if (isp->isp_param == NULL) {
|
1999-05-12 22:59:23 +04:00
|
|
|
printf(nomem, isp->isp_name);
|
1999-03-17 09:16:42 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
bzero(isp->isp_param, sizeof (sdparam));
|
|
|
|
pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] =
|
|
|
|
ISP1080_DMA_REGS_OFF;
|
|
|
|
}
|
1999-05-12 22:59:23 +04:00
|
|
|
if (pa->pa_id == PCI_QLOGIC_ISP1240) {
|
|
|
|
isp->isp_mdvec = &mdvec_1080;
|
|
|
|
isp->isp_type = ISP_HA_SCSI_12X0;
|
|
|
|
isp->isp_param =
|
|
|
|
malloc(2 * sizeof (sdparam), M_DEVBUF, M_NOWAIT);
|
|
|
|
if (isp->isp_param == NULL) {
|
|
|
|
printf(nomem, isp->isp_name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
bzero(isp->isp_param, 2 * sizeof (sdparam));
|
|
|
|
pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] =
|
|
|
|
ISP1080_DMA_REGS_OFF;
|
|
|
|
}
|
1999-03-17 09:16:42 +03:00
|
|
|
#endif
|
|
|
|
#ifndef ISP_DISABLE_2100_SUPPORT
|
|
|
|
if (pa->pa_id == PCI_QLOGIC_ISP2100) {
|
1998-07-15 23:53:57 +04:00
|
|
|
isp->isp_mdvec = &mdvec_2100;
|
|
|
|
isp->isp_type = ISP_HA_FC_2100;
|
|
|
|
isp->isp_param = malloc(sizeof (fcparam), M_DEVBUF, M_NOWAIT);
|
|
|
|
if (isp->isp_param == NULL) {
|
1999-05-12 22:59:23 +04:00
|
|
|
printf(nomem, isp->isp_name);
|
1998-07-15 23:53:57 +04:00
|
|
|
return;
|
1997-08-16 04:28:10 +04:00
|
|
|
}
|
1998-07-15 23:53:57 +04:00
|
|
|
bzero(isp->isp_param, sizeof (fcparam));
|
1999-03-17 09:16:42 +03:00
|
|
|
pcs->pci_poff[MBOX_BLOCK >> _BLK_REG_SHFT] =
|
|
|
|
PCI_MBOX_REGS2100_OFF;
|
1999-12-04 05:54:54 +03:00
|
|
|
if (rev < 3) {
|
1999-04-04 05:14:58 +04:00
|
|
|
/*
|
|
|
|
* XXX: Need to get the actual revision
|
|
|
|
* XXX: number of the 2100 FB. At any rate,
|
|
|
|
* XXX: lower cache line size for early revision
|
|
|
|
* XXX; boards.
|
|
|
|
*/
|
|
|
|
linesz = 1;
|
|
|
|
}
|
1997-08-16 04:28:10 +04:00
|
|
|
}
|
1999-03-17 09:16:42 +03:00
|
|
|
#endif
|
1999-07-06 00:28:11 +04:00
|
|
|
#ifndef ISP_DISABLE_2200_SUPPORT
|
|
|
|
if (pa->pa_id == PCI_QLOGIC_ISP2200) {
|
|
|
|
isp->isp_mdvec = &mdvec_2200;
|
|
|
|
isp->isp_type = ISP_HA_FC_2200;
|
|
|
|
isp->isp_param = malloc(sizeof (fcparam), M_DEVBUF, M_NOWAIT);
|
|
|
|
if (isp->isp_param == NULL) {
|
|
|
|
printf(nomem, isp->isp_name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
bzero(isp->isp_param, sizeof (fcparam));
|
|
|
|
pcs->pci_poff[MBOX_BLOCK >> _BLK_REG_SHFT] =
|
|
|
|
PCI_MBOX_REGS2100_OFF;
|
|
|
|
data = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_CLASS_REG);
|
|
|
|
}
|
|
|
|
#endif
|
1999-12-04 05:54:54 +03:00
|
|
|
isp->isp_revision = rev;
|
1999-03-17 09:16:42 +03:00
|
|
|
|
1999-02-09 03:35:35 +03:00
|
|
|
/*
|
|
|
|
* Make sure that command register set sanely.
|
|
|
|
*/
|
|
|
|
data = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
|
|
|
|
data |= PCI_COMMAND_MASTER_ENABLE | PCI_COMMAND_INVALIDATE_ENABLE;
|
1999-03-17 09:16:42 +03:00
|
|
|
|
1999-02-09 03:35:35 +03:00
|
|
|
/*
|
|
|
|
* Not so sure about these- but I think it's important that they get
|
|
|
|
* enabled......
|
|
|
|
*/
|
|
|
|
data |= PCI_COMMAND_PARITY_ENABLE | PCI_COMMAND_SERR_ENABLE;
|
|
|
|
pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, data);
|
1999-03-17 09:16:42 +03:00
|
|
|
|
1999-02-09 03:35:35 +03:00
|
|
|
/*
|
1999-04-04 05:14:58 +04:00
|
|
|
* Make sure that the latency timer, cache line size,
|
|
|
|
* and ROM is disabled.
|
1999-02-09 03:35:35 +03:00
|
|
|
*/
|
|
|
|
data = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_BHLC_REG);
|
|
|
|
data &= ~(PCI_LATTIMER_MASK << PCI_LATTIMER_SHIFT);
|
|
|
|
data &= ~(PCI_CACHELINE_MASK << PCI_CACHELINE_SHIFT);
|
1999-04-04 05:14:58 +04:00
|
|
|
data |= (PCI_DFLT_LTNCY << PCI_LATTIMER_SHIFT);
|
|
|
|
data |= (linesz << PCI_CACHELINE_SHIFT);
|
1999-02-09 03:35:35 +03:00
|
|
|
pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_BHLC_REG, data);
|
|
|
|
|
1999-04-04 05:14:58 +04:00
|
|
|
data = pci_conf_read(pa->pa_pc, pa->pa_tag, PCIR_ROMADDR);
|
|
|
|
data &= ~1;
|
|
|
|
pci_conf_write(pa->pa_pc, pa->pa_tag, PCIR_ROMADDR, data);
|
|
|
|
|
1998-07-31 06:14:40 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (oneshot) {
|
|
|
|
oneshot = 0;
|
1998-08-12 04:03:23 +04:00
|
|
|
printf("Qlogic ISP Driver, NetBSD (pci) Platform Version "
|
1998-07-31 06:14:40 +04:00
|
|
|
"%d.%d Core Version %d.%d\n",
|
|
|
|
ISP_PLATFORM_VERSION_MAJOR, ISP_PLATFORM_VERSION_MINOR,
|
|
|
|
ISP_CORE_VERSION_MAJOR, ISP_CORE_VERSION_MINOR);
|
|
|
|
}
|
|
|
|
#endif
|
1997-03-12 23:44:50 +03:00
|
|
|
if (pci_intr_map(pa->pa_pc, pa->pa_intrtag, pa->pa_intrpin,
|
1999-03-17 09:16:42 +03:00
|
|
|
pa->pa_intrline, &ih)) {
|
1998-07-15 23:53:57 +04:00
|
|
|
printf("%s: couldn't map interrupt\n", isp->isp_name);
|
|
|
|
free(isp->isp_param, M_DEVBUF);
|
1997-03-12 23:44:50 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
intrstr = pci_intr_string(pa->pa_pc, ih);
|
|
|
|
if (intrstr == NULL)
|
|
|
|
intrstr = "<I dunno>";
|
1999-10-17 05:22:08 +04:00
|
|
|
pcs->pci_ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO,
|
|
|
|
isp_pci_intr, isp);
|
1997-03-12 23:44:50 +03:00
|
|
|
if (pcs->pci_ih == NULL) {
|
|
|
|
printf("%s: couldn't establish interrupt at %s\n",
|
1998-07-15 23:53:57 +04:00
|
|
|
isp->isp_name, intrstr);
|
1999-03-17 09:16:42 +03:00
|
|
|
free(isp->isp_param, M_DEVBUF);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
printf("%s: interrupting at %s\n", isp->isp_name, intrstr);
|
|
|
|
|
1999-10-14 06:14:35 +04:00
|
|
|
if (IS_FC(isp)) {
|
1999-12-04 05:54:54 +03:00
|
|
|
long foo;
|
1999-10-14 06:14:35 +04:00
|
|
|
/*
|
|
|
|
* This isn't very random, but it's the best we can do for
|
|
|
|
* the real edge case of cards that don't have WWNs.
|
|
|
|
*/
|
|
|
|
foo = (long) isp;
|
|
|
|
foo >>= 4;
|
|
|
|
foo &= 0x7;
|
|
|
|
while (version[foo])
|
|
|
|
isp->isp_osinfo.seed += (int) version[foo++];
|
|
|
|
isp->isp_osinfo.seed <<= 8;
|
|
|
|
isp->isp_osinfo.seed += (isp->isp_osinfo._dev.dv_unit + 1);
|
|
|
|
}
|
1999-07-06 00:28:11 +04:00
|
|
|
|
1999-03-17 09:16:42 +03:00
|
|
|
ISP_LOCK(isp);
|
|
|
|
isp_reset(isp);
|
|
|
|
if (isp->isp_state != ISP_RESETSTATE) {
|
|
|
|
ISP_UNLOCK(isp);
|
|
|
|
free(isp->isp_param, M_DEVBUF);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
isp_init(isp);
|
|
|
|
if (isp->isp_state != ISP_INITSTATE) {
|
1998-07-15 23:53:57 +04:00
|
|
|
isp_uninit(isp);
|
1998-07-19 01:02:06 +04:00
|
|
|
ISP_UNLOCK(isp);
|
1998-07-15 23:53:57 +04:00
|
|
|
free(isp->isp_param, M_DEVBUF);
|
1997-03-12 23:44:50 +03:00
|
|
|
return;
|
|
|
|
}
|
1999-03-17 09:16:42 +03:00
|
|
|
|
1997-06-08 10:34:52 +04:00
|
|
|
/*
|
|
|
|
* Create the DMA maps for the data transfers.
|
|
|
|
*/
|
1999-10-17 06:40:26 +04:00
|
|
|
for (i = 0; i < isp->isp_maxcmds; i++) {
|
1997-06-08 10:34:52 +04:00
|
|
|
if (bus_dmamap_create(pcs->pci_dmat, MAXPHYS,
|
|
|
|
(MAXPHYS / NBPG) + 1, MAXPHYS, 0, BUS_DMA_NOWAIT,
|
|
|
|
&pcs->pci_xfer_dmap[i])) {
|
|
|
|
printf("%s: can't create dma maps\n",
|
1998-07-15 23:53:57 +04:00
|
|
|
isp->isp_name);
|
|
|
|
isp_uninit(isp);
|
1998-07-19 01:02:06 +04:00
|
|
|
ISP_UNLOCK(isp);
|
1997-06-08 10:34:52 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
1997-03-12 23:44:50 +03:00
|
|
|
/*
|
|
|
|
* Do Generic attach now.
|
|
|
|
*/
|
1998-07-15 23:53:57 +04:00
|
|
|
isp_attach(isp);
|
|
|
|
if (isp->isp_state != ISP_RUNSTATE) {
|
|
|
|
isp_uninit(isp);
|
|
|
|
free(isp->isp_param, M_DEVBUF);
|
1997-03-12 23:44:50 +03:00
|
|
|
}
|
1998-07-19 01:02:06 +04:00
|
|
|
ISP_UNLOCK(isp);
|
1997-03-12 23:44:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static u_int16_t
|
|
|
|
isp_pci_rd_reg(isp, regoff)
|
|
|
|
struct ispsoftc *isp;
|
|
|
|
int regoff;
|
|
|
|
{
|
1997-08-16 04:28:10 +04:00
|
|
|
u_int16_t rv;
|
1997-03-12 23:44:50 +03:00
|
|
|
struct isp_pcisoftc *pcs = (struct isp_pcisoftc *) isp;
|
1999-03-17 09:16:42 +03:00
|
|
|
int offset, oldconf = 0;
|
|
|
|
|
|
|
|
if ((regoff & _BLK_REG_MASK) == SXP_BLOCK) {
|
1997-03-12 23:44:50 +03:00
|
|
|
/*
|
1997-08-16 04:28:10 +04:00
|
|
|
* We will assume that someone has paused the RISC processor.
|
1997-03-12 23:44:50 +03:00
|
|
|
*/
|
1999-03-17 09:16:42 +03:00
|
|
|
oldconf = isp_pci_rd_reg(isp, BIU_CONF1);
|
|
|
|
isp_pci_wr_reg(isp, BIU_CONF1, oldconf | BIU_PCI_CONF1_SXP);
|
1997-03-12 23:44:50 +03:00
|
|
|
}
|
1999-03-17 09:16:42 +03:00
|
|
|
offset = pcs->pci_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT];
|
|
|
|
offset += (regoff & 0xff);
|
1997-08-16 04:28:10 +04:00
|
|
|
rv = bus_space_read_2(pcs->pci_st, pcs->pci_sh, offset);
|
1999-03-17 09:16:42 +03:00
|
|
|
if ((regoff & _BLK_REG_MASK) == SXP_BLOCK) {
|
|
|
|
isp_pci_wr_reg(isp, BIU_CONF1, oldconf);
|
1997-08-16 04:28:10 +04:00
|
|
|
}
|
|
|
|
return (rv);
|
1997-03-12 23:44:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
isp_pci_wr_reg(isp, regoff, val)
|
|
|
|
struct ispsoftc *isp;
|
|
|
|
int regoff;
|
|
|
|
u_int16_t val;
|
|
|
|
{
|
|
|
|
struct isp_pcisoftc *pcs = (struct isp_pcisoftc *) isp;
|
1999-03-17 09:16:42 +03:00
|
|
|
int offset, oldconf = 0;
|
|
|
|
|
|
|
|
if ((regoff & _BLK_REG_MASK) == SXP_BLOCK) {
|
1997-03-12 23:44:50 +03:00
|
|
|
/*
|
1997-08-16 04:28:10 +04:00
|
|
|
* We will assume that someone has paused the RISC processor.
|
1997-03-12 23:44:50 +03:00
|
|
|
*/
|
1999-03-17 09:16:42 +03:00
|
|
|
oldconf = isp_pci_rd_reg(isp, BIU_CONF1);
|
|
|
|
isp_pci_wr_reg(isp, BIU_CONF1, oldconf | BIU_PCI_CONF1_SXP);
|
1997-03-12 23:44:50 +03:00
|
|
|
}
|
1999-03-17 09:16:42 +03:00
|
|
|
offset = pcs->pci_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT];
|
|
|
|
offset += (regoff & 0xff);
|
1997-03-16 03:37:00 +03:00
|
|
|
bus_space_write_2(pcs->pci_st, pcs->pci_sh, offset, val);
|
1999-03-17 09:16:42 +03:00
|
|
|
if ((regoff & _BLK_REG_MASK) == SXP_BLOCK) {
|
|
|
|
isp_pci_wr_reg(isp, BIU_CONF1, oldconf);
|
1997-08-16 04:28:10 +04:00
|
|
|
}
|
1997-03-12 23:44:50 +03:00
|
|
|
}
|
|
|
|
|
1999-03-17 09:16:42 +03:00
|
|
|
#ifndef ISP_DISABLE_1080_SUPPORT
|
|
|
|
static u_int16_t
|
|
|
|
isp_pci_rd_reg_1080(isp, regoff)
|
|
|
|
struct ispsoftc *isp;
|
|
|
|
int regoff;
|
|
|
|
{
|
|
|
|
u_int16_t rv;
|
|
|
|
struct isp_pcisoftc *pcs = (struct isp_pcisoftc *) isp;
|
|
|
|
int offset, oc = 0;
|
|
|
|
|
|
|
|
if ((regoff & _BLK_REG_MASK) == SXP_BLOCK) {
|
|
|
|
/*
|
|
|
|
* We will assume that someone has paused the RISC processor.
|
|
|
|
*/
|
|
|
|
oc = isp_pci_rd_reg(isp, BIU_CONF1);
|
|
|
|
isp_pci_wr_reg(isp, BIU_CONF1, oc | BIU_PCI1080_CONF1_SXP);
|
|
|
|
} else if ((regoff & _BLK_REG_MASK) == DMA_BLOCK) {
|
|
|
|
oc = isp_pci_rd_reg(isp, BIU_CONF1);
|
|
|
|
isp_pci_wr_reg(isp, BIU_CONF1, oc | BIU_PCI1080_CONF1_DMA);
|
|
|
|
}
|
|
|
|
offset = pcs->pci_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT];
|
|
|
|
offset += (regoff & 0xff);
|
|
|
|
rv = bus_space_read_2(pcs->pci_st, pcs->pci_sh, offset);
|
|
|
|
if ((regoff & _BLK_REG_MASK) == SXP_BLOCK ||
|
|
|
|
((regoff & _BLK_REG_MASK) == DMA_BLOCK)) {
|
|
|
|
isp_pci_wr_reg(isp, BIU_CONF1, oc);
|
|
|
|
}
|
|
|
|
return (rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
isp_pci_wr_reg_1080(isp, regoff, val)
|
|
|
|
struct ispsoftc *isp;
|
|
|
|
int regoff;
|
|
|
|
u_int16_t val;
|
|
|
|
{
|
|
|
|
struct isp_pcisoftc *pcs = (struct isp_pcisoftc *) isp;
|
|
|
|
int offset, oc = 0;
|
|
|
|
|
|
|
|
if ((regoff & _BLK_REG_MASK) == SXP_BLOCK) {
|
|
|
|
/*
|
|
|
|
* We will assume that someone has paused the RISC processor.
|
|
|
|
*/
|
|
|
|
oc = isp_pci_rd_reg(isp, BIU_CONF1);
|
|
|
|
isp_pci_wr_reg(isp, BIU_CONF1, oc | BIU_PCI1080_CONF1_SXP);
|
|
|
|
} else if ((regoff & _BLK_REG_MASK) == DMA_BLOCK) {
|
|
|
|
oc = isp_pci_rd_reg(isp, BIU_CONF1);
|
|
|
|
isp_pci_wr_reg(isp, BIU_CONF1, oc | BIU_PCI1080_CONF1_DMA);
|
|
|
|
}
|
|
|
|
offset = pcs->pci_poff[(regoff & _BLK_REG_MASK) >> _BLK_REG_SHFT];
|
|
|
|
offset += (regoff & 0xff);
|
|
|
|
bus_space_write_2(pcs->pci_st, pcs->pci_sh, offset, val);
|
|
|
|
if ((regoff & _BLK_REG_MASK) == SXP_BLOCK ||
|
|
|
|
((regoff & _BLK_REG_MASK) == DMA_BLOCK)) {
|
|
|
|
isp_pci_wr_reg(isp, BIU_CONF1, oc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1997-06-08 10:34:52 +04:00
|
|
|
static int
|
|
|
|
isp_pci_mbxdma(isp)
|
1997-03-12 23:44:50 +03:00
|
|
|
struct ispsoftc *isp;
|
|
|
|
{
|
1997-06-08 10:34:52 +04:00
|
|
|
struct isp_pcisoftc *pci = (struct isp_pcisoftc *)isp;
|
|
|
|
bus_dma_segment_t seg;
|
|
|
|
bus_size_t len;
|
1997-08-16 04:28:10 +04:00
|
|
|
fcparam *fcp;
|
1997-06-08 10:34:52 +04:00
|
|
|
int rseg;
|
1997-03-12 23:44:50 +03:00
|
|
|
|
1999-10-14 06:14:35 +04:00
|
|
|
if (isp->isp_rquest_dma) /* been here before? */
|
|
|
|
return (0);
|
|
|
|
|
1999-10-17 06:40:26 +04:00
|
|
|
len = isp->isp_maxcmds * sizeof (ISP_SCSI_XFER_T);
|
|
|
|
isp->isp_xflist = (ISP_SCSI_XFER_T **) malloc(len, M_DEVBUF, M_WAITOK);
|
1999-10-14 06:14:35 +04:00
|
|
|
if (isp->isp_xflist == NULL) {
|
|
|
|
printf("%s: cannot malloc xflist array\n", isp->isp_name);
|
|
|
|
return (1);
|
|
|
|
}
|
1999-10-17 06:40:26 +04:00
|
|
|
bzero(isp->isp_xflist, len);
|
|
|
|
len = isp->isp_maxcmds * sizeof (bus_dmamap_t);
|
|
|
|
pci->pci_xfer_dmap = (bus_dmamap_t *) malloc(len, M_DEVBUF, M_WAITOK);
|
|
|
|
if (pci->pci_xfer_dmap == NULL) {
|
|
|
|
printf("%s: cannot malloc xflist array\n", isp->isp_name);
|
|
|
|
return (1);
|
|
|
|
}
|
1999-10-14 06:14:35 +04:00
|
|
|
|
1997-06-08 10:34:52 +04:00
|
|
|
/*
|
|
|
|
* Allocate and map the request queue.
|
|
|
|
*/
|
1998-07-15 23:53:57 +04:00
|
|
|
len = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN);
|
1997-06-08 10:34:52 +04:00
|
|
|
if (bus_dmamem_alloc(pci->pci_dmat, len, NBPG, 0, &seg, 1, &rseg,
|
1999-10-17 05:22:08 +04:00
|
|
|
BUS_DMA_NOWAIT) || bus_dmamem_map(pci->pci_dmat, &seg, rseg, len,
|
|
|
|
(caddr_t *)&isp->isp_rquest, BUS_DMA_NOWAIT|BUS_DMA_COHERENT))
|
1997-06-08 10:34:52 +04:00
|
|
|
return (1);
|
|
|
|
if (bus_dmamap_create(pci->pci_dmat, len, 1, len, 0, BUS_DMA_NOWAIT,
|
1999-10-17 05:22:08 +04:00
|
|
|
&pci->pci_rquest_dmap) || bus_dmamap_load(pci->pci_dmat,
|
|
|
|
pci->pci_rquest_dmap, (caddr_t)isp->isp_rquest, len, NULL,
|
|
|
|
BUS_DMA_NOWAIT))
|
1997-06-08 10:34:52 +04:00
|
|
|
return (1);
|
1997-03-12 23:44:50 +03:00
|
|
|
|
1997-06-08 10:34:52 +04:00
|
|
|
isp->isp_rquest_dma = pci->pci_rquest_dmap->dm_segs[0].ds_addr;
|
1997-03-12 23:44:50 +03:00
|
|
|
|
1997-06-08 10:34:52 +04:00
|
|
|
/*
|
|
|
|
* Allocate and map the result queue.
|
|
|
|
*/
|
1998-07-15 23:53:57 +04:00
|
|
|
len = ISP_QUEUE_SIZE(RESULT_QUEUE_LEN);
|
1997-06-08 10:34:52 +04:00
|
|
|
if (bus_dmamem_alloc(pci->pci_dmat, len, NBPG, 0, &seg, 1, &rseg,
|
1999-10-17 05:22:08 +04:00
|
|
|
BUS_DMA_NOWAIT) || bus_dmamem_map(pci->pci_dmat, &seg, rseg, len,
|
|
|
|
(caddr_t *)&isp->isp_result, BUS_DMA_NOWAIT|BUS_DMA_COHERENT))
|
1997-06-08 10:34:52 +04:00
|
|
|
return (1);
|
|
|
|
if (bus_dmamap_create(pci->pci_dmat, len, 1, len, 0, BUS_DMA_NOWAIT,
|
1999-10-17 05:22:08 +04:00
|
|
|
&pci->pci_result_dmap) || bus_dmamap_load(pci->pci_dmat,
|
|
|
|
pci->pci_result_dmap, (caddr_t)isp->isp_result, len, NULL,
|
|
|
|
BUS_DMA_NOWAIT))
|
1997-06-08 10:34:52 +04:00
|
|
|
return (1);
|
|
|
|
isp->isp_result_dma = pci->pci_result_dmap->dm_segs[0].ds_addr;
|
|
|
|
|
1999-07-06 00:28:11 +04:00
|
|
|
if (IS_SCSI(isp)) {
|
1997-08-16 04:28:10 +04:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
fcp = isp->isp_param;
|
|
|
|
len = ISP2100_SCRLEN;
|
|
|
|
if (bus_dmamem_alloc(pci->pci_dmat, len, NBPG, 0, &seg, 1, &rseg,
|
1999-10-17 05:22:08 +04:00
|
|
|
BUS_DMA_NOWAIT) || bus_dmamem_map(pci->pci_dmat, &seg, rseg, len,
|
|
|
|
(caddr_t *)&fcp->isp_scratch, BUS_DMA_NOWAIT|BUS_DMA_COHERENT))
|
1997-08-16 04:28:10 +04:00
|
|
|
return (1);
|
|
|
|
if (bus_dmamap_create(pci->pci_dmat, len, 1, len, 0, BUS_DMA_NOWAIT,
|
1999-10-17 05:22:08 +04:00
|
|
|
&pci->pci_scratch_dmap) || bus_dmamap_load(pci->pci_dmat,
|
|
|
|
pci->pci_scratch_dmap, (caddr_t)fcp->isp_scratch, len, NULL,
|
|
|
|
BUS_DMA_NOWAIT))
|
1997-08-16 04:28:10 +04:00
|
|
|
return (1);
|
|
|
|
fcp->isp_scdma = pci->pci_scratch_dmap->dm_segs[0].ds_addr;
|
1997-06-08 10:34:52 +04:00
|
|
|
return (0);
|
|
|
|
}
|
1997-03-12 23:44:50 +03:00
|
|
|
|
|
|
|
static int
|
|
|
|
isp_pci_dmasetup(isp, xs, rq, iptrp, optr)
|
|
|
|
struct ispsoftc *isp;
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipi_xfer *xs;
|
1997-03-12 23:44:50 +03:00
|
|
|
ispreq_t *rq;
|
1999-12-04 05:54:54 +03:00
|
|
|
u_int16_t *iptrp;
|
|
|
|
u_int16_t optr;
|
1997-03-12 23:44:50 +03:00
|
|
|
{
|
1997-06-08 10:34:52 +04:00
|
|
|
struct isp_pcisoftc *pci = (struct isp_pcisoftc *)isp;
|
1997-08-16 04:28:10 +04:00
|
|
|
bus_dmamap_t dmap = pci->pci_xfer_dmap[rq->req_handle - 1];
|
1997-03-12 23:44:50 +03:00
|
|
|
ispcontreq_t *crq;
|
1997-09-10 06:16:13 +04:00
|
|
|
int segcnt, seg, error, ovseg, seglim, drq;
|
1997-03-12 23:44:50 +03:00
|
|
|
|
|
|
|
if (xs->datalen == 0) {
|
|
|
|
rq->req_seg_count = 1;
|
1998-07-31 06:08:16 +04:00
|
|
|
goto mbxsync;
|
1997-03-12 23:44:50 +03:00
|
|
|
}
|
1999-10-14 06:14:35 +04:00
|
|
|
assert(rq->req_handle != 0 && rq->req_handle <= isp->isp_maxcmds);
|
1999-10-01 03:04:39 +04:00
|
|
|
if (xs->xs_control & XS_CTL_DATA_IN) {
|
1997-09-10 06:16:13 +04:00
|
|
|
drq = REQFLAG_DATA_IN;
|
1997-03-12 23:44:50 +03:00
|
|
|
} else {
|
1997-09-10 06:16:13 +04:00
|
|
|
drq = REQFLAG_DATA_OUT;
|
1997-03-12 23:44:50 +03:00
|
|
|
}
|
|
|
|
|
1999-07-06 00:28:11 +04:00
|
|
|
if (IS_FC(isp)) {
|
1997-08-16 04:28:10 +04:00
|
|
|
seglim = ISP_RQDSEG_T2;
|
|
|
|
((ispreqt2_t *)rq)->req_totalcnt = xs->datalen;
|
1997-09-10 06:16:13 +04:00
|
|
|
((ispreqt2_t *)rq)->req_flags |= drq;
|
1997-08-16 04:28:10 +04:00
|
|
|
} else {
|
|
|
|
seglim = ISP_RQDSEG;
|
1997-09-10 06:16:13 +04:00
|
|
|
rq->req_flags |= drq;
|
1997-08-16 04:28:10 +04:00
|
|
|
}
|
1997-06-08 10:34:52 +04:00
|
|
|
error = bus_dmamap_load(pci->pci_dmat, dmap, xs->data, xs->datalen,
|
1999-10-01 03:04:39 +04:00
|
|
|
NULL, xs->xs_control & XS_CTL_NOSLEEP ?
|
|
|
|
BUS_DMA_NOWAIT : BUS_DMA_WAITOK);
|
1998-07-15 23:53:57 +04:00
|
|
|
if (error) {
|
|
|
|
XS_SETERR(xs, HBA_BOTCH);
|
1998-09-18 03:10:20 +04:00
|
|
|
return (CMD_COMPLETE);
|
1998-07-15 23:53:57 +04:00
|
|
|
}
|
1997-06-08 10:34:52 +04:00
|
|
|
|
|
|
|
segcnt = dmap->dm_nsegs;
|
|
|
|
|
|
|
|
for (seg = 0, rq->req_seg_count = 0;
|
1999-10-17 05:22:08 +04:00
|
|
|
seg < segcnt && rq->req_seg_count < seglim;
|
|
|
|
seg++, rq->req_seg_count++) {
|
1999-07-06 00:28:11 +04:00
|
|
|
if (IS_FC(isp)) {
|
1997-08-16 04:28:10 +04:00
|
|
|
ispreqt2_t *rq2 = (ispreqt2_t *)rq;
|
|
|
|
rq2->req_dataseg[rq2->req_seg_count].ds_count =
|
|
|
|
dmap->dm_segs[seg].ds_len;
|
|
|
|
rq2->req_dataseg[rq2->req_seg_count].ds_base =
|
|
|
|
dmap->dm_segs[seg].ds_addr;
|
|
|
|
} else {
|
|
|
|
rq->req_dataseg[rq->req_seg_count].ds_count =
|
|
|
|
dmap->dm_segs[seg].ds_len;
|
|
|
|
rq->req_dataseg[rq->req_seg_count].ds_base =
|
|
|
|
dmap->dm_segs[seg].ds_addr;
|
|
|
|
}
|
1997-03-12 23:44:50 +03:00
|
|
|
}
|
|
|
|
|
1997-06-08 10:34:52 +04:00
|
|
|
if (seg == segcnt)
|
1998-07-31 06:08:16 +04:00
|
|
|
goto dmasync;
|
1997-06-08 10:34:52 +04:00
|
|
|
|
1997-03-12 23:44:50 +03:00
|
|
|
do {
|
1997-08-16 04:28:10 +04:00
|
|
|
crq = (ispcontreq_t *)
|
|
|
|
ISP_QUEUE_ENTRY(isp->isp_rquest, *iptrp);
|
1998-07-15 23:53:57 +04:00
|
|
|
*iptrp = (*iptrp + 1) & (RQUEST_QUEUE_LEN - 1);
|
1997-03-12 23:44:50 +03:00
|
|
|
if (*iptrp == optr) {
|
1999-10-17 05:22:08 +04:00
|
|
|
printf("%s: Request Queue Overflow++\n", isp->isp_name);
|
1997-06-08 10:34:52 +04:00
|
|
|
bus_dmamap_unload(pci->pci_dmat, dmap);
|
1998-07-15 23:53:57 +04:00
|
|
|
XS_SETERR(xs, HBA_BOTCH);
|
1998-09-18 03:10:20 +04:00
|
|
|
return (CMD_COMPLETE);
|
1997-03-12 23:44:50 +03:00
|
|
|
}
|
|
|
|
rq->req_header.rqs_entry_count++;
|
|
|
|
bzero((void *)crq, sizeof (*crq));
|
|
|
|
crq->req_header.rqs_entry_count = 1;
|
|
|
|
crq->req_header.rqs_entry_type = RQSTYPE_DATASEG;
|
1997-06-08 10:34:52 +04:00
|
|
|
|
|
|
|
for (ovseg = 0; seg < segcnt && ovseg < ISP_CDSEG;
|
|
|
|
rq->req_seg_count++, seg++, ovseg++) {
|
|
|
|
crq->req_dataseg[ovseg].ds_count =
|
|
|
|
dmap->dm_segs[seg].ds_len;
|
|
|
|
crq->req_dataseg[ovseg].ds_base =
|
|
|
|
dmap->dm_segs[seg].ds_addr;
|
1997-03-12 23:44:50 +03:00
|
|
|
}
|
1997-06-08 10:34:52 +04:00
|
|
|
} while (seg < segcnt);
|
|
|
|
|
1998-07-31 06:08:16 +04:00
|
|
|
dmasync:
|
1998-02-04 08:12:46 +03:00
|
|
|
bus_dmamap_sync(pci->pci_dmat, dmap, 0, dmap->dm_mapsize,
|
1999-10-01 03:04:39 +04:00
|
|
|
(xs->xs_control & XS_CTL_DATA_IN) ? BUS_DMASYNC_PREREAD :
|
1998-09-18 03:10:20 +04:00
|
|
|
BUS_DMASYNC_PREWRITE);
|
1998-07-31 06:08:16 +04:00
|
|
|
|
|
|
|
mbxsync:
|
1999-10-14 06:14:35 +04:00
|
|
|
ISP_SWIZZLE_REQUEST(isp, rq);
|
1998-07-31 06:08:16 +04:00
|
|
|
bus_dmamap_sync(pci->pci_dmat, pci->pci_rquest_dmap, 0,
|
|
|
|
pci->pci_rquest_dmap->dm_mapsize, BUS_DMASYNC_PREWRITE);
|
1998-09-18 03:10:20 +04:00
|
|
|
return (CMD_QUEUED);
|
1997-03-12 23:44:50 +03:00
|
|
|
}
|
|
|
|
|
1998-07-31 06:08:16 +04:00
|
|
|
static int
|
|
|
|
isp_pci_intr(arg)
|
|
|
|
void *arg;
|
|
|
|
{
|
|
|
|
struct isp_pcisoftc *pci = (struct isp_pcisoftc *)arg;
|
|
|
|
bus_dmamap_sync(pci->pci_dmat, pci->pci_result_dmap, 0,
|
|
|
|
pci->pci_result_dmap->dm_mapsize, BUS_DMASYNC_POSTREAD);
|
|
|
|
return (isp_intr(arg));
|
|
|
|
}
|
|
|
|
|
1997-06-08 10:34:52 +04:00
|
|
|
static void
|
|
|
|
isp_pci_dmateardown(isp, xs, handle)
|
|
|
|
struct ispsoftc *isp;
|
1997-08-27 15:22:52 +04:00
|
|
|
struct scsipi_xfer *xs;
|
1997-06-08 10:34:52 +04:00
|
|
|
u_int32_t handle;
|
|
|
|
{
|
|
|
|
struct isp_pcisoftc *pci = (struct isp_pcisoftc *)isp;
|
1999-10-14 06:14:35 +04:00
|
|
|
bus_dmamap_t dmap;
|
|
|
|
assert(handle != 0 && handle <= isp->isp_maxcmds);
|
|
|
|
dmap = pci->pci_xfer_dmap[handle-1];
|
1998-02-04 08:12:46 +03:00
|
|
|
bus_dmamap_sync(pci->pci_dmat, dmap, 0, dmap->dm_mapsize,
|
1999-10-01 03:04:39 +04:00
|
|
|
xs->xs_control & XS_CTL_DATA_IN ?
|
1997-06-08 10:34:52 +04:00
|
|
|
BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
|
|
|
|
bus_dmamap_unload(pci->pci_dmat, dmap);
|
|
|
|
}
|
|
|
|
|
1997-03-12 23:44:50 +03:00
|
|
|
static void
|
|
|
|
isp_pci_reset1(isp)
|
|
|
|
struct ispsoftc *isp;
|
|
|
|
{
|
|
|
|
/* Make sure the BIOS is disabled */
|
|
|
|
isp_pci_wr_reg(isp, HCCR, PCI_HCCR_CMD_BIOS);
|
|
|
|
}
|
1997-08-16 04:28:10 +04:00
|
|
|
|
|
|
|
static void
|
|
|
|
isp_pci_dumpregs(isp)
|
|
|
|
struct ispsoftc *isp;
|
|
|
|
{
|
|
|
|
struct isp_pcisoftc *pci = (struct isp_pcisoftc *)isp;
|
|
|
|
printf("%s: PCI Status Command/Status=%x\n", pci->pci_isp.isp_name,
|
|
|
|
pci_conf_read(pci->pci_pc, pci->pci_tag, PCI_COMMAND_STATUS_REG));
|
|
|
|
}
|