Home | History | Annotate | Line # | Download | only in ic
ispreg.h revision 1.30.32.1
      1  1.30.32.1     mjf /* $NetBSD: ispreg.h,v 1.30.32.1 2007/07/11 20:05:58 mjf Exp $ */
      2        1.1     cgd /*
      3       1.16  mjacob  * Copyright (C) 1997, 1998, 1999 National Aeronautics & Space Administration
      4        1.1     cgd  * All rights reserved.
      5       1.14  mjacob  *
      6  1.30.32.1     mjf  * Additional Copyright (C) 2000-2007 by Matthew Jacob
      7  1.30.32.1     mjf  * All rights reserved.
      8  1.30.32.1     mjf  *
      9        1.1     cgd  * Redistribution and use in source and binary forms, with or without
     10        1.1     cgd  * modification, are permitted provided that the following conditions
     11        1.1     cgd  * are met:
     12        1.1     cgd  * 1. Redistributions of source code must retain the above copyright
     13       1.16  mjacob  *    notice, this list of conditions and the following disclaimer.
     14        1.1     cgd  * 2. Redistributions in binary form must reproduce the above copyright
     15        1.1     cgd  *    notice, this list of conditions and the following disclaimer in the
     16        1.1     cgd  *    documentation and/or other materials provided with the distribution.
     17        1.1     cgd  * 3. The name of the author may not be used to endorse or promote products
     18       1.16  mjacob  *    derived from this software without specific prior written permission
     19       1.16  mjacob  *
     20       1.16  mjacob  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21       1.16  mjacob  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22       1.16  mjacob  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23       1.16  mjacob  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24       1.16  mjacob  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25       1.16  mjacob  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26       1.16  mjacob  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27       1.16  mjacob  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28       1.16  mjacob  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29       1.16  mjacob  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30       1.16  mjacob  */
     31       1.16  mjacob /*
     32       1.16  mjacob  * Machine Independent (well, as best as possible) register
     33       1.16  mjacob  * definitions for Qlogic ISP SCSI adapters.
     34        1.1     cgd  */
     35        1.1     cgd #ifndef	_ISPREG_H
     36        1.1     cgd #define	_ISPREG_H
     37        1.1     cgd 
     38        1.1     cgd /*
     39        1.1     cgd  * Hardware definitions for the Qlogic ISP  registers.
     40        1.1     cgd  */
     41        1.1     cgd 
     42        1.1     cgd /*
     43        1.1     cgd  * This defines types of access to various registers.
     44        1.1     cgd  *
     45        1.1     cgd  *  	R:		Read Only
     46        1.1     cgd  *	W:		Write Only
     47        1.1     cgd  *	RW:		Read/Write
     48        1.1     cgd  *
     49        1.1     cgd  *	R*, W*, RW*:	Read Only, Write Only, Read/Write, but only
     50        1.1     cgd  *			if RISC processor in ISP is paused.
     51        1.1     cgd  */
     52        1.1     cgd 
     53        1.1     cgd /*
     54        1.1     cgd  * Offsets for various register blocks.
     55        1.1     cgd  *
     56        1.1     cgd  * Sad but true, different architectures have different offsets.
     57       1.15  mjacob  *
     58       1.15  mjacob  * Don't be alarmed if none of this makes sense. The original register
     59       1.15  mjacob  * layout set some defines in a certain pattern. Everything else has been
     60       1.15  mjacob  * grafted on since. For example, the ISP1080 manual will state that DMA
     61       1.15  mjacob  * registers start at 0x80 from the base of the register address space.
     62       1.15  mjacob  * That's true, but for our purposes, we define DMA_REGS_OFF for the 1080
     63       1.15  mjacob  * to start at offset 0x60 because the DMA registers are all defined to
     64       1.15  mjacob  * be DMA_BLOCK+0x20 and so on. Clear?
     65        1.1     cgd  */
     66        1.1     cgd 
     67       1.13  mjacob #define	BIU_REGS_OFF			0x00
     68        1.1     cgd 
     69       1.13  mjacob #define	PCI_MBOX_REGS_OFF		0x70
     70       1.13  mjacob #define	PCI_MBOX_REGS2100_OFF		0x10
     71       1.26  mjacob #define	PCI_MBOX_REGS2300_OFF		0x40
     72  1.30.32.1     mjf #define	PCI_MBOX_REGS2400_OFF		0x80
     73        1.1     cgd #define	SBUS_MBOX_REGS_OFF		0x80
     74        1.1     cgd 
     75       1.13  mjacob #define	PCI_SXP_REGS_OFF		0x80
     76        1.1     cgd #define	SBUS_SXP_REGS_OFF		0x200
     77        1.1     cgd 
     78       1.13  mjacob #define	PCI_RISC_REGS_OFF		0x80
     79        1.1     cgd #define	SBUS_RISC_REGS_OFF		0x400
     80        1.1     cgd 
     81       1.13  mjacob /* Bless me! Chip designers have putzed it again! */
     82       1.13  mjacob #define	ISP1080_DMA_REGS_OFF		0x60
     83       1.13  mjacob #define	DMA_REGS_OFF			0x00	/* same as BIU block */
     84       1.22  mjacob 
     85       1.22  mjacob #define	SBUS_REGSIZE			0x450
     86       1.22  mjacob #define	PCI_REGSIZE			0x100
     87       1.13  mjacob 
     88        1.1     cgd /*
     89        1.1     cgd  * NB:	The *_BLOCK definitions have no specific hardware meaning.
     90        1.1     cgd  *	They serve simply to note to the MD layer which block of
     91        1.1     cgd  *	registers offsets are being accessed.
     92        1.1     cgd  */
     93       1.13  mjacob #define	_NREG_BLKS	5
     94       1.13  mjacob #define	_BLK_REG_SHFT	13
     95       1.13  mjacob #define	_BLK_REG_MASK	(7 << _BLK_REG_SHFT)
     96       1.13  mjacob #define	BIU_BLOCK	(0 << _BLK_REG_SHFT)
     97       1.13  mjacob #define	MBOX_BLOCK	(1 << _BLK_REG_SHFT)
     98       1.13  mjacob #define	SXP_BLOCK	(2 << _BLK_REG_SHFT)
     99       1.13  mjacob #define	RISC_BLOCK	(3 << _BLK_REG_SHFT)
    100       1.13  mjacob #define	DMA_BLOCK	(4 << _BLK_REG_SHFT)
    101        1.1     cgd 
    102        1.1     cgd /*
    103        1.1     cgd  * Bus Interface Block Register Offsets
    104        1.1     cgd  */
    105       1.13  mjacob 
    106       1.18  mjacob #define	BIU_ID_LO	(BIU_BLOCK+0x0)		/* R  : Bus ID, Low */
    107       1.18  mjacob #define		BIU2100_FLASH_ADDR	(BIU_BLOCK+0x0)
    108       1.18  mjacob #define	BIU_ID_HI	(BIU_BLOCK+0x2)		/* R  : Bus ID, High */
    109       1.18  mjacob #define		BIU2100_FLASH_DATA	(BIU_BLOCK+0x2)
    110       1.18  mjacob #define	BIU_CONF0	(BIU_BLOCK+0x4)		/* R  : Bus Configuration #0 */
    111       1.18  mjacob #define	BIU_CONF1	(BIU_BLOCK+0x6)		/* R  : Bus Configuration #1 */
    112       1.18  mjacob #define		BIU2100_CSR		(BIU_BLOCK+0x6)
    113       1.18  mjacob #define	BIU_ICR		(BIU_BLOCK+0x8)		/* RW : Bus Interface Ctrl */
    114       1.18  mjacob #define	BIU_ISR		(BIU_BLOCK+0xA)		/* R  : Bus Interface Status */
    115       1.18  mjacob #define	BIU_SEMA	(BIU_BLOCK+0xC)		/* RW : Bus Semaphore */
    116       1.18  mjacob #define	BIU_NVRAM	(BIU_BLOCK+0xE)		/* RW : Bus NVRAM */
    117       1.26  mjacob /*
    118       1.26  mjacob  * These are specific to the 2300.
    119       1.26  mjacob  */
    120       1.26  mjacob #define	BIU_REQINP	(BIU_BLOCK+0x10)	/* Request Queue In */
    121       1.26  mjacob #define	BIU_REQOUTP	(BIU_BLOCK+0x12)	/* Request Queue Out */
    122       1.26  mjacob #define	BIU_RSPINP	(BIU_BLOCK+0x14)	/* Response Queue In */
    123       1.26  mjacob #define	BIU_RSPOUTP	(BIU_BLOCK+0x16)	/* Response Queue Out */
    124       1.26  mjacob 
    125       1.26  mjacob #define	BIU_R2HSTSLO	(BIU_BLOCK+0x18)
    126       1.26  mjacob #define	BIU_R2HSTSHI	(BIU_BLOCK+0x1A)
    127       1.26  mjacob 
    128       1.26  mjacob #define	BIU_R2HST_INTR		(1 << 15)	/* RISC to Host Interrupt */
    129       1.26  mjacob #define	BIU_R2HST_PAUSED	(1 <<  8)	/* RISC paused */
    130       1.26  mjacob #define	BIU_R2HST_ISTAT_MASK	0x3f		/* intr information && status */
    131       1.26  mjacob #define		ISPR2HST_ROM_MBX_OK	0x1	/* ROM mailbox cmd done ok */
    132       1.26  mjacob #define		ISPR2HST_ROM_MBX_FAIL	0x2	/* ROM mailbox cmd done fail */
    133       1.26  mjacob #define		ISPR2HST_MBX_OK		0x10	/* mailbox cmd done ok */
    134       1.26  mjacob #define		ISPR2HST_MBX_FAIL	0x11	/* mailbox cmd done fail */
    135       1.26  mjacob #define		ISPR2HST_ASYNC_EVENT	0x12	/* Async Event */
    136       1.26  mjacob #define		ISPR2HST_RSPQ_UPDATE	0x13	/* Response Queue Update */
    137       1.26  mjacob #define		ISPR2HST_RQST_UPDATE	0x14	/* Resquest Queue Update */
    138       1.26  mjacob #define		ISPR2HST_RIO_16		0x15	/* RIO 1-16 */
    139       1.26  mjacob #define		ISPR2HST_FPOST		0x16	/* Low 16 bits fast post */
    140       1.26  mjacob #define		ISPR2HST_FPOST_CTIO	0x17	/* Low 16 bits fast post ctio */
    141       1.26  mjacob 
    142  1.30.32.1     mjf /* fifo command stuff- mostly for SPI */
    143       1.18  mjacob #define	DFIFO_COMMAND	(BIU_BLOCK+0x60)	/* RW : Command FIFO Port */
    144       1.13  mjacob #define		RDMA2100_CONTROL	DFIFO_COMMAND
    145       1.18  mjacob #define	DFIFO_DATA	(BIU_BLOCK+0x62)	/* RW : Data FIFO Port */
    146       1.13  mjacob 
    147       1.13  mjacob /*
    148       1.13  mjacob  * Putzed DMA register layouts.
    149       1.13  mjacob  */
    150       1.18  mjacob #define	CDMA_CONF	(DMA_BLOCK+0x20)	/* RW*: DMA Configuration */
    151        1.3  mjacob #define		CDMA2100_CONTROL	CDMA_CONF
    152       1.18  mjacob #define	CDMA_CONTROL	(DMA_BLOCK+0x22)	/* RW*: DMA Control */
    153       1.18  mjacob #define	CDMA_STATUS 	(DMA_BLOCK+0x24)	/* R  : DMA Status */
    154       1.18  mjacob #define	CDMA_FIFO_STS	(DMA_BLOCK+0x26)	/* R  : DMA FIFO Status */
    155       1.18  mjacob #define	CDMA_COUNT	(DMA_BLOCK+0x28)	/* RW*: DMA Transfer Count */
    156       1.18  mjacob #define	CDMA_ADDR0	(DMA_BLOCK+0x2C)	/* RW*: DMA Address, Word 0 */
    157       1.18  mjacob #define	CDMA_ADDR1	(DMA_BLOCK+0x2E)	/* RW*: DMA Address, Word 1 */
    158       1.18  mjacob #define	CDMA_ADDR2	(DMA_BLOCK+0x30)	/* RW*: DMA Address, Word 2 */
    159       1.18  mjacob #define	CDMA_ADDR3	(DMA_BLOCK+0x32)	/* RW*: DMA Address, Word 3 */
    160        1.1     cgd 
    161       1.18  mjacob #define	DDMA_CONF	(DMA_BLOCK+0x40)	/* RW*: DMA Configuration */
    162        1.3  mjacob #define		TDMA2100_CONTROL	DDMA_CONF
    163       1.18  mjacob #define	DDMA_CONTROL	(DMA_BLOCK+0x42)	/* RW*: DMA Control */
    164       1.18  mjacob #define	DDMA_STATUS	(DMA_BLOCK+0x44)	/* R  : DMA Status */
    165       1.18  mjacob #define	DDMA_FIFO_STS	(DMA_BLOCK+0x46)	/* R  : DMA FIFO Status */
    166       1.18  mjacob #define	DDMA_COUNT_LO	(DMA_BLOCK+0x48)	/* RW*: DMA Xfer Count, Low */
    167       1.18  mjacob #define	DDMA_COUNT_HI	(DMA_BLOCK+0x4A)	/* RW*: DMA Xfer Count, High */
    168       1.18  mjacob #define	DDMA_ADDR0	(DMA_BLOCK+0x4C)	/* RW*: DMA Address, Word 0 */
    169       1.18  mjacob #define	DDMA_ADDR1	(DMA_BLOCK+0x4E)	/* RW*: DMA Address, Word 1 */
    170        1.1     cgd /* these are for the 1040A cards */
    171       1.18  mjacob #define	DDMA_ADDR2	(DMA_BLOCK+0x50)	/* RW*: DMA Address, Word 2 */
    172       1.18  mjacob #define	DDMA_ADDR3	(DMA_BLOCK+0x52)	/* RW*: DMA Address, Word 3 */
    173        1.1     cgd 
    174        1.1     cgd 
    175        1.1     cgd /*
    176        1.1     cgd  * Bus Interface Block Register Definitions
    177        1.1     cgd  */
    178        1.1     cgd /* BUS CONFIGURATION REGISTER #0 */
    179        1.1     cgd #define	BIU_CONF0_HW_MASK		0x000F	/* Hardware revision mask */
    180        1.1     cgd /* BUS CONFIGURATION REGISTER #1 */
    181        1.1     cgd 
    182        1.1     cgd #define	BIU_SBUS_CONF1_PARITY		0x0100 	/* Enable parity checking */
    183        1.1     cgd #define	BIU_SBUS_CONF1_FCODE_MASK	0x00F0	/* Fcode cycle mask */
    184        1.1     cgd 
    185        1.1     cgd #define	BIU_PCI_CONF1_FIFO_128		0x0040	/* 128 bytes FIFO threshold */
    186        1.1     cgd #define	BIU_PCI_CONF1_FIFO_64		0x0030	/* 64 bytes FIFO threshold */
    187        1.1     cgd #define	BIU_PCI_CONF1_FIFO_32		0x0020	/* 32 bytes FIFO threshold */
    188        1.1     cgd #define	BIU_PCI_CONF1_FIFO_16		0x0010	/* 16 bytes FIFO threshold */
    189        1.1     cgd #define	BIU_BURST_ENABLE		0x0004	/* Global enable Bus bursts */
    190        1.1     cgd #define	BIU_SBUS_CONF1_FIFO_64		0x0003	/* 64 bytes FIFO threshold */
    191        1.1     cgd #define	BIU_SBUS_CONF1_FIFO_32		0x0002	/* 32 bytes FIFO threshold */
    192        1.1     cgd #define	BIU_SBUS_CONF1_FIFO_16		0x0001	/* 16 bytes FIFO threshold */
    193        1.1     cgd #define	BIU_SBUS_CONF1_FIFO_8		0x0000	/* 8 bytes FIFO threshold */
    194        1.1     cgd #define	BIU_SBUS_CONF1_BURST8		0x0008 	/* Enable 8-byte  bursts */
    195        1.1     cgd #define	BIU_PCI_CONF1_SXP		0x0008	/* SXP register select */
    196        1.1     cgd 
    197       1.18  mjacob #define	BIU_PCI1080_CONF1_SXP0		0x0100	/* SXP bank #1 select */
    198       1.18  mjacob #define	BIU_PCI1080_CONF1_SXP1		0x0200	/* SXP bank #2 select */
    199       1.13  mjacob #define	BIU_PCI1080_CONF1_DMA		0x0300	/* DMA bank select */
    200       1.13  mjacob 
    201       1.14  mjacob /* ISP2100 Bus Control/Status Register */
    202        1.3  mjacob 
    203        1.3  mjacob #define	BIU2100_ICSR_REGBSEL		0x30	/* RW: register bank select */
    204        1.3  mjacob #define		BIU2100_RISC_REGS	(0 << 4)	/* RISC Regs */
    205        1.3  mjacob #define		BIU2100_FB_REGS		(1 << 4)	/* FrameBuffer Regs */
    206        1.3  mjacob #define		BIU2100_FPM0_REGS	(2 << 4)	/* FPM 0 Regs */
    207        1.3  mjacob #define		BIU2100_FPM1_REGS	(3 << 4)	/* FPM 1 Regs */
    208  1.30.32.1     mjf #define	BIU2100_NVRAM_OFFSET		(1 << 14)
    209  1.30.32.1     mjf #define	BIU2100_FLASH_UPPER_64K		0x04	/* RW: Upper 64K Bank Select */
    210        1.3  mjacob #define	BIU2100_FLASH_ENABLE		0x02	/* RW: Enable Flash RAM */
    211        1.3  mjacob #define	BIU2100_SOFT_RESET		0x01
    212        1.3  mjacob /* SOFT RESET FOR ISP2100 is same bit, but in this register, not ICR */
    213        1.3  mjacob 
    214        1.3  mjacob 
    215        1.1     cgd /* BUS CONTROL REGISTER */
    216        1.1     cgd #define	BIU_ICR_ENABLE_DMA_INT		0x0020	/* Enable DMA interrupts */
    217        1.1     cgd #define	BIU_ICR_ENABLE_CDMA_INT		0x0010	/* Enable CDMA interrupts */
    218        1.1     cgd #define	BIU_ICR_ENABLE_SXP_INT		0x0008	/* Enable SXP interrupts */
    219        1.1     cgd #define	BIU_ICR_ENABLE_RISC_INT		0x0004	/* Enable Risc interrupts */
    220        1.1     cgd #define	BIU_ICR_ENABLE_ALL_INTS		0x0002	/* Global enable all inter */
    221        1.1     cgd #define	BIU_ICR_SOFT_RESET		0x0001	/* Soft Reset of ISP */
    222        1.1     cgd 
    223  1.30.32.1     mjf #define	BIU_IMASK	(BIU_ICR_ENABLE_RISC_INT|BIU_ICR_ENABLE_ALL_INTS)
    224  1.30.32.1     mjf 
    225        1.3  mjacob #define	BIU2100_ICR_ENABLE_ALL_INTS	0x8000
    226        1.3  mjacob #define	BIU2100_ICR_ENA_FPM_INT		0x0020
    227        1.3  mjacob #define	BIU2100_ICR_ENA_FB_INT		0x0010
    228        1.3  mjacob #define	BIU2100_ICR_ENA_RISC_INT	0x0008
    229        1.3  mjacob #define	BIU2100_ICR_ENA_CDMA_INT	0x0004
    230        1.3  mjacob #define	BIU2100_ICR_ENABLE_RXDMA_INT	0x0002
    231        1.3  mjacob #define	BIU2100_ICR_ENABLE_TXDMA_INT	0x0001
    232        1.3  mjacob #define	BIU2100_ICR_DISABLE_ALL_INTS	0x0000
    233        1.3  mjacob 
    234  1.30.32.1     mjf #define	BIU2100_IMASK	(BIU2100_ICR_ENA_RISC_INT|BIU2100_ICR_ENABLE_ALL_INTS)
    235        1.1     cgd 
    236        1.1     cgd /* BUS STATUS REGISTER */
    237        1.1     cgd #define	BIU_ISR_DMA_INT			0x0020	/* DMA interrupt pending */
    238        1.1     cgd #define	BIU_ISR_CDMA_INT		0x0010	/* CDMA interrupt pending */
    239        1.1     cgd #define	BIU_ISR_SXP_INT			0x0008	/* SXP interrupt pending */
    240        1.1     cgd #define	BIU_ISR_RISC_INT		0x0004	/* Risc interrupt pending */
    241        1.1     cgd #define	BIU_ISR_IPEND			0x0002	/* Global interrupt pending */
    242        1.1     cgd 
    243        1.3  mjacob #define	BIU2100_ISR_INT_PENDING		0x8000	/* Global interrupt pending */
    244        1.3  mjacob #define	BIU2100_ISR_FPM_INT		0x0020	/* FPM interrupt pending */
    245        1.3  mjacob #define	BIU2100_ISR_FB_INT		0x0010	/* FB interrupt pending */
    246        1.3  mjacob #define	BIU2100_ISR_RISC_INT		0x0008	/* Risc interrupt pending */
    247        1.3  mjacob #define	BIU2100_ISR_CDMA_INT		0x0004	/* CDMA interrupt pending */
    248        1.3  mjacob #define	BIU2100_ISR_RXDMA_INT_PENDING	0x0002	/* Global interrupt pending */
    249        1.3  mjacob #define	BIU2100_ISR_TXDMA_INT_PENDING	0x0001	/* Global interrupt pending */
    250        1.3  mjacob 
    251  1.30.32.1     mjf #define	INT_PENDING(isp, isr)						\
    252  1.30.32.1     mjf  IS_FC(isp)?								\
    253  1.30.32.1     mjf   (IS_24XX(isp)? (isr & BIU2400_ISR_RISC_INT) : (isr & BIU2100_ISR_RISC_INT)) :\
    254  1.30.32.1     mjf   (isr & BIU_ISR_RISC_INT)
    255        1.1     cgd 
    256       1.21  mjacob #define	INT_PENDING_MASK(isp)	\
    257  1.30.32.1     mjf  (IS_FC(isp)? (IS_24XX(isp)? BIU2400_ISR_RISC_INT : BIU2100_ISR_RISC_INT) : \
    258  1.30.32.1     mjf  (BIU_ISR_RISC_INT))
    259       1.21  mjacob 
    260        1.1     cgd /* BUS SEMAPHORE REGISTER */
    261        1.1     cgd #define	BIU_SEMA_STATUS		0x0002	/* Semaphore Status Bit */
    262        1.1     cgd #define	BIU_SEMA_LOCK  		0x0001	/* Semaphore Lock Bit */
    263        1.1     cgd 
    264        1.7  mjacob /* NVRAM SEMAPHORE REGISTER */
    265        1.7  mjacob #define	BIU_NVRAM_CLOCK		0x0001
    266        1.7  mjacob #define	BIU_NVRAM_SELECT	0x0002
    267        1.7  mjacob #define	BIU_NVRAM_DATAOUT	0x0004
    268        1.7  mjacob #define	BIU_NVRAM_DATAIN	0x0008
    269  1.30.32.1     mjf #define	BIU_NVRAM_BUSY		0x0080	/* 2322/24xx only */
    270        1.7  mjacob #define		ISP_NVRAM_READ		6
    271        1.1     cgd 
    272        1.1     cgd /* COMNMAND && DATA DMA CONFIGURATION REGISTER */
    273        1.1     cgd #define	DMA_ENABLE_SXP_DMA		0x0008	/* Enable SXP to DMA Data */
    274        1.1     cgd #define	DMA_ENABLE_INTS			0x0004	/* Enable interrupts to RISC */
    275        1.1     cgd #define	DMA_ENABLE_BURST		0x0002	/* Enable Bus burst trans */
    276        1.1     cgd #define	DMA_DMA_DIRECTION		0x0001	/*
    277        1.1     cgd 						 * Set DMA direction:
    278        1.1     cgd 						 *	0 - DMA FIFO to host
    279        1.1     cgd 						 *	1 - Host to DMA FIFO
    280        1.1     cgd 						 */
    281        1.1     cgd 
    282        1.1     cgd /* COMMAND && DATA DMA CONTROL REGISTER */
    283        1.1     cgd #define	DMA_CNTRL_SUSPEND_CHAN		0x0010	/* Suspend DMA transfer */
    284        1.1     cgd #define	DMA_CNTRL_CLEAR_CHAN		0x0008	/*
    285        1.1     cgd 						 * Clear FIFO and DMA Channel,
    286        1.1     cgd 						 * reset DMA registers
    287        1.1     cgd 						 */
    288        1.1     cgd #define	DMA_CNTRL_CLEAR_FIFO		0x0004	/* Clear DMA FIFO */
    289        1.1     cgd #define	DMA_CNTRL_RESET_INT		0x0002	/* Clear DMA interrupt */
    290        1.1     cgd #define	DMA_CNTRL_STROBE		0x0001	/* Start DMA transfer */
    291        1.1     cgd 
    292        1.3  mjacob /*
    293        1.3  mjacob  * Variants of same for 2100
    294        1.3  mjacob  */
    295        1.3  mjacob #define	DMA_CNTRL2100_CLEAR_CHAN	0x0004
    296        1.3  mjacob #define	DMA_CNTRL2100_RESET_INT		0x0002
    297        1.3  mjacob 
    298        1.3  mjacob 
    299        1.1     cgd 
    300        1.1     cgd /* DMA STATUS REGISTER */
    301        1.1     cgd #define	DMA_SBUS_STATUS_PIPE_MASK	0x00C0	/* DMA Pipeline status mask */
    302        1.1     cgd #define	DMA_SBUS_STATUS_CHAN_MASK	0x0030	/* Channel status mask */
    303        1.1     cgd #define	DMA_SBUS_STATUS_BUS_PARITY	0x0008	/* Parity Error on bus */
    304        1.1     cgd #define	DMA_SBUS_STATUS_BUS_ERR		0x0004	/* Error Detected on bus */
    305        1.1     cgd #define	DMA_SBUS_STATUS_TERM_COUNT	0x0002	/* DMA Transfer Completed */
    306        1.1     cgd #define	DMA_SBUS_STATUS_INTERRUPT	0x0001	/* Enable DMA channel inter */
    307        1.1     cgd 
    308        1.1     cgd #define	DMA_PCI_STATUS_INTERRUPT	0x8000	/* Enable DMA channel inter */
    309        1.1     cgd #define	DMA_PCI_STATUS_RETRY_STAT	0x4000	/* Retry status */
    310        1.1     cgd #define	DMA_PCI_STATUS_CHAN_MASK	0x3000	/* Channel status mask */
    311        1.1     cgd #define	DMA_PCI_STATUS_FIFO_OVR		0x0100	/* DMA FIFO overrun cond */
    312        1.1     cgd #define	DMA_PCI_STATUS_FIFO_UDR		0x0080	/* DMA FIFO underrun cond */
    313        1.1     cgd #define	DMA_PCI_STATUS_BUS_ERR		0x0040	/* Error Detected on bus */
    314        1.1     cgd #define	DMA_PCI_STATUS_BUS_PARITY	0x0020	/* Parity Error on bus */
    315        1.1     cgd #define	DMA_PCI_STATUS_CLR_PEND		0x0010	/* DMA clear pending */
    316        1.1     cgd #define	DMA_PCI_STATUS_TERM_COUNT	0x0008	/* DMA Transfer Completed */
    317        1.1     cgd #define	DMA_PCI_STATUS_DMA_SUSP		0x0004	/* DMA suspended */
    318        1.1     cgd #define	DMA_PCI_STATUS_PIPE_MASK	0x0003	/* DMA Pipeline status mask */
    319        1.1     cgd 
    320        1.1     cgd /* DMA Status Register, pipeline status bits */
    321        1.1     cgd #define	DMA_SBUS_PIPE_FULL		0x00C0	/* Both pipeline stages full */
    322        1.1     cgd #define	DMA_SBUS_PIPE_OVERRUN		0x0080	/* Pipeline overrun */
    323        1.1     cgd #define	DMA_SBUS_PIPE_STAGE1		0x0040	/*
    324        1.1     cgd 						 * Pipeline stage 1 Loaded,
    325        1.1     cgd 						 * stage 2 empty
    326        1.1     cgd 						 */
    327        1.1     cgd #define	DMA_PCI_PIPE_FULL		0x0003	/* Both pipeline stages full */
    328        1.1     cgd #define	DMA_PCI_PIPE_OVERRUN		0x0002	/* Pipeline overrun */
    329        1.1     cgd #define	DMA_PCI_PIPE_STAGE1		0x0001	/*
    330        1.1     cgd 						 * Pipeline stage 1 Loaded,
    331        1.1     cgd 						 * stage 2 empty
    332        1.1     cgd 						 */
    333        1.1     cgd #define	DMA_PIPE_EMPTY			0x0000	/* All pipeline stages empty */
    334        1.1     cgd 
    335        1.1     cgd /* DMA Status Register, channel status bits */
    336        1.1     cgd #define	DMA_SBUS_CHAN_SUSPEND	0x0030	/* Channel error or suspended */
    337        1.1     cgd #define	DMA_SBUS_CHAN_TRANSFER	0x0020	/* Chan transfer in progress */
    338        1.1     cgd #define	DMA_SBUS_CHAN_ACTIVE	0x0010	/* Chan trans to host active */
    339        1.1     cgd #define	DMA_PCI_CHAN_TRANSFER	0x3000	/* Chan transfer in progress */
    340        1.1     cgd #define	DMA_PCI_CHAN_SUSPEND	0x2000	/* Channel error or suspended */
    341        1.1     cgd #define	DMA_PCI_CHAN_ACTIVE	0x1000	/* Chan trans to host active */
    342        1.1     cgd #define	ISP_DMA_CHAN_IDLE	0x0000	/* Chan idle (normal comp) */
    343        1.1     cgd 
    344        1.1     cgd 
    345        1.1     cgd /* DMA FIFO STATUS REGISTER */
    346        1.1     cgd #define	DMA_FIFO_STATUS_OVERRUN		0x0200	/* FIFO Overrun Condition */
    347        1.1     cgd #define	DMA_FIFO_STATUS_UNDERRUN	0x0100	/* FIFO Underrun Condition */
    348        1.1     cgd #define	DMA_FIFO_SBUS_COUNT_MASK	0x007F	/* FIFO Byte count mask */
    349        1.1     cgd #define	DMA_FIFO_PCI_COUNT_MASK		0x00FF	/* FIFO Byte count mask */
    350        1.1     cgd 
    351        1.1     cgd /*
    352  1.30.32.1     mjf  * 2400 Interface Offsets and Register Definitions
    353  1.30.32.1     mjf  *
    354  1.30.32.1     mjf  * The 2400 looks quite different in terms of registers from other QLogic cards.
    355  1.30.32.1     mjf  * It is getting to be a genuine pain and challenge to keep the same model
    356  1.30.32.1     mjf  * for all.
    357  1.30.32.1     mjf  */
    358  1.30.32.1     mjf #define	BIU2400_FLASH_ADDR	(BIU_BLOCK+0x00)
    359  1.30.32.1     mjf #define	BIU2400_FLASH_DATA	(BIU_BLOCK+0x04)
    360  1.30.32.1     mjf #define	BIU2400_CSR		(BIU_BLOCK+0x08)
    361  1.30.32.1     mjf #define	BIU2400_ICR		(BIU_BLOCK+0x0C)
    362  1.30.32.1     mjf #define	BIU2400_ISR		(BIU_BLOCK+0x10)
    363  1.30.32.1     mjf 
    364  1.30.32.1     mjf #define	BIU2400_REQINP		(BIU_BLOCK+0x1C) /* Request Queue In */
    365  1.30.32.1     mjf #define	BIU2400_REQOUTP		(BIU_BLOCK+0x20) /* Request Queue Out */
    366  1.30.32.1     mjf #define	BIU2400_RSPINP		(BIU_BLOCK+0x24) /* Response Queue In */
    367  1.30.32.1     mjf #define	BIU2400_RSPOUTP		(BIU_BLOCK+0x28) /* Response Queue Out */
    368  1.30.32.1     mjf #define	BIU2400_PRI_RQINP 	(BIU_BLOCK+0x2C) /* Priority Request Q In */
    369  1.30.32.1     mjf #define	BIU2400_PRI_RSPINP 	(BIU_BLOCK+0x30) /* Priority Request Q Out */
    370  1.30.32.1     mjf 
    371  1.30.32.1     mjf #define	BIU2400_ATIO_RSPINP	(BIU_BLOCK+0x3C)	/* ATIO Queue In */
    372  1.30.32.1     mjf #define	BIU2400_ATIO_REQINP	(BIU_BLOCK+0x40)	/* ATIO Queue Out */
    373  1.30.32.1     mjf 
    374  1.30.32.1     mjf #define	BIU2400_R2HSTSLO	(BIU_BLOCK+0x44)
    375  1.30.32.1     mjf #define	BIU2400_R2HSTSHI	(BIU_BLOCK+0x46)
    376  1.30.32.1     mjf 
    377  1.30.32.1     mjf #define	BIU2400_HCCR		(BIU_BLOCK+0x48)
    378  1.30.32.1     mjf #define	BIU2400_GPIOD		(BIU_BLOCK+0x4C)
    379  1.30.32.1     mjf #define	BIU2400_GPIOE		(BIU_BLOCK+0x50)
    380  1.30.32.1     mjf #define	BIU2400_HSEMA		(BIU_BLOCK+0x58)
    381  1.30.32.1     mjf 
    382  1.30.32.1     mjf /* BIU2400_FLASH_ADDR definitions */
    383  1.30.32.1     mjf #define	BIU2400_FLASH_DFLAG	(1 << 30)
    384  1.30.32.1     mjf 
    385  1.30.32.1     mjf /* BIU2400_CSR definitions */
    386  1.30.32.1     mjf #define	BIU2400_NVERR		(1 << 18)
    387  1.30.32.1     mjf #define	BIU2400_DMA_ACTIVE	(1 << 17)		/* RO */
    388  1.30.32.1     mjf #define	BIU2400_DMA_STOP	(1 << 16)
    389  1.30.32.1     mjf #define	BIU2400_FUNCTION	(1 << 15)		/* RO */
    390  1.30.32.1     mjf #define	BIU2400_PCIX_MODE(x)	(((x) >> 8) & 0xf)	/* RO */
    391  1.30.32.1     mjf #define	BIU2400_CSR_64BIT	(1 << 2)		/* RO */
    392  1.30.32.1     mjf #define	BIU2400_FLASH_ENABLE	(1 << 1)
    393  1.30.32.1     mjf #define	BIU2400_SOFT_RESET	(1 << 0)
    394  1.30.32.1     mjf 
    395  1.30.32.1     mjf /* BIU2400_ICR definitions */
    396  1.30.32.1     mjf #define	BIU2400_ICR_ENA_RISC_INT	0x8
    397  1.30.32.1     mjf #define	BIU2400_IMASK			(BIU2400_ICR_ENA_RISC_INT)
    398  1.30.32.1     mjf 
    399  1.30.32.1     mjf /* BIU2400_ISR definitions */
    400  1.30.32.1     mjf #define	BIU2400_ISR_RISC_INT		0x8
    401  1.30.32.1     mjf 
    402  1.30.32.1     mjf #define	BIU2400_R2HST_INTR		BIU_R2HST_INTR
    403  1.30.32.1     mjf #define	BIU2400_R2HST_PAUSED		BIU_R2HST_PAUSED
    404  1.30.32.1     mjf #define	BIU2400_R2HST_ISTAT_MASK	0x1f
    405  1.30.32.1     mjf /* interrupt status meanings */
    406  1.30.32.1     mjf #define	ISP2400R2HST_ROM_MBX_OK		0x1	/* ROM mailbox cmd done ok */
    407  1.30.32.1     mjf #define	ISP2400R2HST_ROM_MBX_FAIL	0x2	/* ROM mailbox cmd done fail */
    408  1.30.32.1     mjf #define	ISP2400R2HST_MBX_OK		0x10	/* mailbox cmd done ok */
    409  1.30.32.1     mjf #define	ISP2400R2HST_MBX_FAIL		0x11	/* mailbox cmd done fail */
    410  1.30.32.1     mjf #define	ISP2400R2HST_ASYNC_EVENT	0x12	/* Async Event */
    411  1.30.32.1     mjf #define	ISP2400R2HST_RSPQ_UPDATE	0x13	/* Response Queue Update */
    412  1.30.32.1     mjf #define	ISP2400R2HST_ATIO_RSPQ_UPDATE	0x1C	/* ATIO Response Queue Update */
    413  1.30.32.1     mjf #define	ISP2400R2HST_ATIO_RQST_UPDATE	0x1D	/* ATIO Request Queue Update */
    414  1.30.32.1     mjf 
    415  1.30.32.1     mjf /* BIU2400_HCCR definitions */
    416  1.30.32.1     mjf 
    417  1.30.32.1     mjf #define	HCCR_2400_CMD_NOP		0x00000000
    418  1.30.32.1     mjf #define	HCCR_2400_CMD_RESET		0x10000000
    419  1.30.32.1     mjf #define	HCCR_2400_CMD_CLEAR_RESET	0x20000000
    420  1.30.32.1     mjf #define	HCCR_2400_CMD_PAUSE		0x30000000
    421  1.30.32.1     mjf #define	HCCR_2400_CMD_RELEASE		0x40000000
    422  1.30.32.1     mjf #define	HCCR_2400_CMD_SET_HOST_INT	0x50000000
    423  1.30.32.1     mjf #define	HCCR_2400_CMD_CLEAR_HOST_INT	0x60000000
    424  1.30.32.1     mjf #define	HCCR_2400_CMD_CLEAR_RISC_INT	0xA0000000
    425  1.30.32.1     mjf 
    426  1.30.32.1     mjf #define	HCCR_2400_RISC_ERR(x)		(((x) >> 12) & 0x7)	/* RO */
    427  1.30.32.1     mjf #define	HCCR_2400_RISC2HOST_INT		(1 << 6)		/* RO */
    428  1.30.32.1     mjf #define	HCCR_2400_RISC_RESET		(1 << 5)		/* RO */
    429  1.30.32.1     mjf 
    430  1.30.32.1     mjf 
    431  1.30.32.1     mjf /*
    432        1.1     cgd  * Mailbox Block Register Offsets
    433        1.1     cgd  */
    434        1.1     cgd 
    435       1.18  mjacob #define	INMAILBOX0	(MBOX_BLOCK+0x0)
    436       1.18  mjacob #define	INMAILBOX1	(MBOX_BLOCK+0x2)
    437       1.18  mjacob #define	INMAILBOX2	(MBOX_BLOCK+0x4)
    438       1.18  mjacob #define	INMAILBOX3	(MBOX_BLOCK+0x6)
    439       1.18  mjacob #define	INMAILBOX4	(MBOX_BLOCK+0x8)
    440       1.18  mjacob #define	INMAILBOX5	(MBOX_BLOCK+0xA)
    441       1.18  mjacob #define	INMAILBOX6	(MBOX_BLOCK+0xC)
    442       1.18  mjacob #define	INMAILBOX7	(MBOX_BLOCK+0xE)
    443       1.18  mjacob 
    444       1.18  mjacob #define	OUTMAILBOX0	(MBOX_BLOCK+0x0)
    445       1.18  mjacob #define	OUTMAILBOX1	(MBOX_BLOCK+0x2)
    446       1.18  mjacob #define	OUTMAILBOX2	(MBOX_BLOCK+0x4)
    447       1.18  mjacob #define	OUTMAILBOX3	(MBOX_BLOCK+0x6)
    448       1.18  mjacob #define	OUTMAILBOX4	(MBOX_BLOCK+0x8)
    449       1.18  mjacob #define	OUTMAILBOX5	(MBOX_BLOCK+0xA)
    450       1.18  mjacob #define	OUTMAILBOX6	(MBOX_BLOCK+0xC)
    451       1.18  mjacob #define	OUTMAILBOX7	(MBOX_BLOCK+0xE)
    452        1.1     cgd 
    453  1.30.32.1     mjf /*
    454  1.30.32.1     mjf  * Strictly speaking, it's
    455  1.30.32.1     mjf  *  SCSI && 2100 : 8 MBOX registers
    456  1.30.32.1     mjf  *  2200: 24 MBOX registers
    457  1.30.32.1     mjf  *  2300/2400: 32 MBOX registers
    458  1.30.32.1     mjf  */
    459       1.21  mjacob #define	MBOX_OFF(n)	(MBOX_BLOCK + ((n) << 1))
    460        1.3  mjacob #define	NMBOX(isp)	\
    461        1.3  mjacob 	(((((isp)->isp_type & ISP_HA_SCSI) >= ISP_HA_SCSI_1040A) || \
    462  1.30.32.1     mjf 	 ((isp)->isp_type & ISP_HA_FC))? 12 : 6)
    463       1.21  mjacob #define	NMBOX_BMASK(isp)	\
    464       1.21  mjacob 	(((((isp)->isp_type & ISP_HA_SCSI) >= ISP_HA_SCSI_1040A) || \
    465  1.30.32.1     mjf 	 ((isp)->isp_type & ISP_HA_FC))? 0xfff : 0x3f)
    466       1.21  mjacob 
    467  1.30.32.1     mjf #define	MAX_MAILBOX(isp)	((IS_FC(isp))? 12 : 8)
    468  1.30.32.1     mjf #define	MAILBOX_STORAGE		12
    469  1.30.32.1     mjf /* if timeout == 0, then default timeout is picked */
    470  1.30.32.1     mjf #define	MBCMD_DEFAULT_TIMEOUT	100000	/* 100 ms */
    471  1.30.32.1     mjf typedef struct {
    472  1.30.32.1     mjf 	uint16_t param[MAILBOX_STORAGE];
    473  1.30.32.1     mjf 	uint16_t ibits;
    474  1.30.32.1     mjf 	uint16_t obits;
    475  1.30.32.1     mjf 	uint32_t	: 28,
    476  1.30.32.1     mjf 		logval	: 4;
    477  1.30.32.1     mjf 	uint32_t timeout;
    478  1.30.32.1     mjf } mbreg_t;
    479        1.3  mjacob 
    480        1.1     cgd /*
    481       1.25  mjacob  * Fibre Protocol Module and Frame Buffer Register Offsets/Definitions (2X00).
    482       1.25  mjacob  * NB: The RISC processor must be paused and the appropriate register
    483       1.25  mjacob  * bank selected via BIU2100_CSR bits.
    484       1.25  mjacob  */
    485       1.25  mjacob 
    486       1.25  mjacob #define	FPM_DIAG_CONFIG	(BIU_BLOCK + 0x96)
    487       1.25  mjacob #define		FPM_SOFT_RESET		0x0100
    488       1.25  mjacob 
    489       1.25  mjacob #define	FBM_CMD		(BIU_BLOCK + 0xB8)
    490       1.25  mjacob #define		FBMCMD_FIFO_RESET_ALL	0xA000
    491       1.25  mjacob 
    492       1.25  mjacob 
    493       1.25  mjacob /*
    494        1.1     cgd  * SXP Block Register Offsets
    495        1.1     cgd  */
    496       1.18  mjacob #define	SXP_PART_ID	(SXP_BLOCK+0x0)		/* R  : Part ID Code */
    497       1.18  mjacob #define	SXP_CONFIG1	(SXP_BLOCK+0x2)		/* RW*: Configuration Reg #1 */
    498       1.18  mjacob #define	SXP_CONFIG2	(SXP_BLOCK+0x4)		/* RW*: Configuration Reg #2 */
    499       1.18  mjacob #define	SXP_CONFIG3	(SXP_BLOCK+0x6)		/* RW*: Configuration Reg #2 */
    500       1.18  mjacob #define	SXP_INSTRUCTION	(SXP_BLOCK+0xC)		/* RW*: Instruction Pointer */
    501       1.18  mjacob #define	SXP_RETURN_ADDR	(SXP_BLOCK+0x10)	/* RW*: Return Address */
    502       1.18  mjacob #define	SXP_COMMAND	(SXP_BLOCK+0x14)	/* RW*: Command */
    503       1.18  mjacob #define	SXP_INTERRUPT	(SXP_BLOCK+0x18)	/* R  : Interrupt */
    504       1.18  mjacob #define	SXP_SEQUENCE	(SXP_BLOCK+0x1C)	/* RW*: Sequence */
    505       1.18  mjacob #define	SXP_GROSS_ERR	(SXP_BLOCK+0x1E)	/* R  : Gross Error */
    506       1.18  mjacob #define	SXP_EXCEPTION	(SXP_BLOCK+0x20)	/* RW*: Exception Enable */
    507       1.18  mjacob #define	SXP_OVERRIDE	(SXP_BLOCK+0x24)	/* RW*: Override */
    508       1.18  mjacob #define	SXP_LIT_BASE	(SXP_BLOCK+0x28)	/* RW*: Literal Base */
    509       1.18  mjacob #define	SXP_USER_FLAGS	(SXP_BLOCK+0x2C)	/* RW*: User Flags */
    510       1.18  mjacob #define	SXP_USER_EXCEPT	(SXP_BLOCK+0x30)	/* RW*: User Exception */
    511       1.18  mjacob #define	SXP_BREAKPOINT	(SXP_BLOCK+0x34)	/* RW*: Breakpoint */
    512       1.18  mjacob #define	SXP_SCSI_ID	(SXP_BLOCK+0x40)	/* RW*: SCSI ID */
    513       1.18  mjacob #define	SXP_DEV_CONFIG1	(SXP_BLOCK+0x42)	/* RW*: Device Config Reg #1 */
    514       1.18  mjacob #define	SXP_DEV_CONFIG2	(SXP_BLOCK+0x44)	/* RW*: Device Config Reg #2 */
    515       1.18  mjacob #define	SXP_PHASE_PTR	(SXP_BLOCK+0x48)	/* RW*: SCSI Phase Pointer */
    516       1.18  mjacob #define	SXP_BUF_PTR	(SXP_BLOCK+0x4C)	/* RW*: SCSI Buffer Pointer */
    517       1.18  mjacob #define	SXP_BUF_CTR	(SXP_BLOCK+0x50)	/* RW*: SCSI Buffer Counter */
    518       1.18  mjacob #define	SXP_BUFFER	(SXP_BLOCK+0x52)	/* RW*: SCSI Buffer */
    519       1.18  mjacob #define	SXP_BUF_BYTE	(SXP_BLOCK+0x54)	/* RW*: SCSI Buffer Byte */
    520       1.18  mjacob #define	SXP_BUF_WD	(SXP_BLOCK+0x56)	/* RW*: SCSI Buffer Word */
    521       1.18  mjacob #define	SXP_BUF_WD_TRAN	(SXP_BLOCK+0x58)	/* RW*: SCSI Buffer Wd xlate */
    522       1.18  mjacob #define	SXP_FIFO	(SXP_BLOCK+0x5A)	/* RW*: SCSI FIFO */
    523       1.18  mjacob #define	SXP_FIFO_STATUS	(SXP_BLOCK+0x5C)	/* RW*: SCSI FIFO Status */
    524       1.18  mjacob #define	SXP_FIFO_TOP	(SXP_BLOCK+0x5E)	/* RW*: SCSI FIFO Top Resid */
    525       1.18  mjacob #define	SXP_FIFO_BOTTOM	(SXP_BLOCK+0x60)	/* RW*: SCSI FIFO Bot Resid */
    526  1.30.32.1     mjf #define	SXP_TRAN_REG	(SXP_BLOCK+0x64)	/* RW*: SCSI Transferr Reg */
    527       1.18  mjacob #define	SXP_TRAN_CNT_LO	(SXP_BLOCK+0x68)	/* RW*: SCSI Trans Count */
    528       1.18  mjacob #define	SXP_TRAN_CNT_HI	(SXP_BLOCK+0x6A)	/* RW*: SCSI Trans Count */
    529       1.18  mjacob #define	SXP_TRAN_CTR_LO	(SXP_BLOCK+0x6C)	/* RW*: SCSI Trans Counter */
    530       1.18  mjacob #define	SXP_TRAN_CTR_HI	(SXP_BLOCK+0x6E)	/* RW*: SCSI Trans Counter */
    531       1.18  mjacob #define	SXP_ARB_DATA	(SXP_BLOCK+0x70)	/* R  : SCSI Arb Data */
    532       1.18  mjacob #define	SXP_PINS_CTRL	(SXP_BLOCK+0x72)	/* RW*: SCSI Control Pins */
    533       1.18  mjacob #define	SXP_PINS_DATA	(SXP_BLOCK+0x74)	/* RW*: SCSI Data Pins */
    534       1.18  mjacob #define	SXP_PINS_DIFF	(SXP_BLOCK+0x76)	/* RW*: SCSI Diff Pins */
    535       1.18  mjacob 
    536       1.18  mjacob /* for 1080/1280/1240 only */
    537       1.18  mjacob #define	SXP_BANK1_SELECT	0x100
    538        1.1     cgd 
    539        1.1     cgd 
    540        1.1     cgd /* SXP CONF1 REGISTER */
    541        1.1     cgd #define	SXP_CONF1_ASYNCH_SETUP		0xF000	/* Asynchronous setup time */
    542        1.1     cgd #define	SXP_CONF1_SELECTION_UNIT	0x0000	/* Selection time unit */
    543        1.1     cgd #define	SXP_CONF1_SELECTION_TIMEOUT	0x0600	/* Selection timeout */
    544        1.1     cgd #define	SXP_CONF1_CLOCK_FACTOR		0x00E0	/* Clock factor */
    545        1.1     cgd #define	SXP_CONF1_SCSI_ID		0x000F	/* SCSI id */
    546        1.1     cgd 
    547        1.1     cgd /* SXP CONF2 REGISTER */
    548        1.1     cgd #define	SXP_CONF2_DISABLE_FILTER	0x0040	/* Disable SCSI rec filters */
    549        1.1     cgd #define	SXP_CONF2_REQ_ACK_PULLUPS	0x0020	/* Enable req/ack pullups */
    550        1.1     cgd #define	SXP_CONF2_DATA_PULLUPS		0x0010	/* Enable data pullups */
    551        1.1     cgd #define	SXP_CONF2_CONFIG_AUTOLOAD	0x0008	/* Enable dev conf auto-load */
    552        1.1     cgd #define	SXP_CONF2_RESELECT		0x0002	/* Enable reselection */
    553        1.1     cgd #define	SXP_CONF2_SELECT		0x0001	/* Enable selection */
    554        1.1     cgd 
    555        1.1     cgd /* SXP INTERRUPT REGISTER */
    556        1.1     cgd #define	SXP_INT_PARITY_ERR		0x8000	/* Parity error detected */
    557        1.1     cgd #define	SXP_INT_GROSS_ERR		0x4000	/* Gross error detected */
    558        1.1     cgd #define	SXP_INT_FUNCTION_ABORT		0x2000	/* Last cmd aborted */
    559        1.1     cgd #define	SXP_INT_CONDITION_FAILED	0x1000	/* Last cond failed test */
    560        1.1     cgd #define	SXP_INT_FIFO_EMPTY		0x0800	/* SCSI FIFO is empty */
    561        1.1     cgd #define	SXP_INT_BUF_COUNTER_ZERO	0x0400	/* SCSI buf count == zero */
    562        1.1     cgd #define	SXP_INT_XFER_ZERO		0x0200	/* SCSI trans count == zero */
    563        1.1     cgd #define	SXP_INT_INT_PENDING		0x0080	/* SXP interrupt pending */
    564        1.1     cgd #define	SXP_INT_CMD_RUNNING		0x0040	/* SXP is running a command */
    565        1.1     cgd #define	SXP_INT_INT_RETURN_CODE		0x000F	/* Interrupt return code */
    566        1.1     cgd 
    567        1.1     cgd 
    568        1.1     cgd /* SXP GROSS ERROR REGISTER */
    569        1.1     cgd #define	SXP_GROSS_OFFSET_RESID		0x0040	/* Req/Ack offset not zero */
    570        1.1     cgd #define	SXP_GROSS_OFFSET_UNDERFLOW	0x0020	/* Req/Ack offset underflow */
    571        1.1     cgd #define	SXP_GROSS_OFFSET_OVERFLOW	0x0010	/* Req/Ack offset overflow */
    572        1.1     cgd #define	SXP_GROSS_FIFO_UNDERFLOW	0x0008	/* SCSI FIFO underflow */
    573        1.1     cgd #define	SXP_GROSS_FIFO_OVERFLOW		0x0004	/* SCSI FIFO overflow */
    574        1.1     cgd #define	SXP_GROSS_WRITE_ERR		0x0002	/* SXP and RISC wrote to reg */
    575        1.1     cgd #define	SXP_GROSS_ILLEGAL_INST		0x0001	/* Bad inst loaded into SXP */
    576        1.1     cgd 
    577        1.1     cgd /* SXP EXCEPTION REGISTER */
    578        1.1     cgd #define	SXP_EXCEPT_USER_0		0x8000	/* Enable user exception #0 */
    579        1.1     cgd #define	SXP_EXCEPT_USER_1		0x4000	/* Enable user exception #1 */
    580        1.1     cgd #define	PCI_SXP_EXCEPT_SCAM		0x0400	/* SCAM Selection enable */
    581        1.1     cgd #define	SXP_EXCEPT_BUS_FREE		0x0200	/* Enable Bus Free det */
    582        1.1     cgd #define	SXP_EXCEPT_TARGET_ATN		0x0100	/* Enable TGT mode atten det */
    583        1.1     cgd #define	SXP_EXCEPT_RESELECTED		0x0080	/* Enable ReSEL exc handling */
    584        1.1     cgd #define	SXP_EXCEPT_SELECTED		0x0040	/* Enable SEL exc handling */
    585        1.1     cgd #define	SXP_EXCEPT_ARBITRATION		0x0020	/* Enable ARB exc handling */
    586        1.1     cgd #define	SXP_EXCEPT_GROSS_ERR		0x0010	/* Enable gross error except */
    587        1.1     cgd #define	SXP_EXCEPT_BUS_RESET		0x0008	/* Enable Bus Reset except */
    588        1.1     cgd 
    589        1.1     cgd 	/* SXP OVERRIDE REGISTER */
    590        1.1     cgd #define	SXP_ORIDE_EXT_TRIGGER		0x8000	/* Enable external trigger */
    591        1.1     cgd #define	SXP_ORIDE_STEP			0x4000	/* Enable single step mode */
    592        1.1     cgd #define	SXP_ORIDE_BREAKPOINT		0x2000	/* Enable breakpoint reg */
    593        1.1     cgd #define	SXP_ORIDE_PIN_WRITE		0x1000	/* Enable write to SCSI pins */
    594        1.1     cgd #define	SXP_ORIDE_FORCE_OUTPUTS		0x0800	/* Force SCSI outputs on */
    595        1.1     cgd #define	SXP_ORIDE_LOOPBACK		0x0400	/* Enable SCSI loopback mode */
    596        1.1     cgd #define	SXP_ORIDE_PARITY_TEST		0x0200	/* Enable parity test mode */
    597        1.1     cgd #define	SXP_ORIDE_TRISTATE_ENA_PINS	0x0100	/* Tristate SCSI enable pins */
    598        1.1     cgd #define	SXP_ORIDE_TRISTATE_PINS		0x0080	/* Tristate SCSI pins */
    599        1.1     cgd #define	SXP_ORIDE_FIFO_RESET		0x0008	/* Reset SCSI FIFO */
    600        1.1     cgd #define	SXP_ORIDE_CMD_TERMINATE		0x0004	/* Terminate cur SXP com */
    601        1.1     cgd #define	SXP_ORIDE_RESET_REG		0x0002	/* Reset SXP registers */
    602        1.1     cgd #define	SXP_ORIDE_RESET_MODULE		0x0001	/* Reset SXP module */
    603        1.1     cgd 
    604        1.1     cgd /* SXP COMMANDS */
    605        1.1     cgd #define	SXP_RESET_BUS_CMD		0x300b
    606        1.1     cgd 
    607        1.1     cgd /* SXP SCSI ID REGISTER */
    608        1.1     cgd #define	SXP_SELECTING_ID		0x0F00	/* (Re)Selecting id */
    609        1.1     cgd #define	SXP_SELECT_ID			0x000F	/* Select id */
    610        1.1     cgd 
    611        1.1     cgd /* SXP DEV CONFIG1 REGISTER */
    612        1.1     cgd #define	SXP_DCONF1_SYNC_HOLD		0x7000	/* Synchronous data hold */
    613        1.1     cgd #define	SXP_DCONF1_SYNC_SETUP		0x0F00	/* Synchronous data setup */
    614        1.1     cgd #define	SXP_DCONF1_SYNC_OFFSET		0x000F	/* Synchronous data offset */
    615        1.1     cgd 
    616        1.1     cgd 
    617        1.1     cgd /* SXP DEV CONFIG2 REGISTER */
    618        1.1     cgd #define	SXP_DCONF2_FLAGS_MASK		0xF000	/* Device flags */
    619        1.1     cgd #define	SXP_DCONF2_WIDE			0x0400	/* Enable wide SCSI */
    620        1.1     cgd #define	SXP_DCONF2_PARITY		0x0200	/* Enable parity checking */
    621        1.1     cgd #define	SXP_DCONF2_BLOCK_MODE		0x0100	/* Enable blk mode xfr count */
    622        1.1     cgd #define	SXP_DCONF2_ASSERTION_MASK	0x0007	/* Assersion period mask */
    623        1.1     cgd 
    624        1.1     cgd 
    625        1.1     cgd /* SXP PHASE POINTER REGISTER */
    626        1.1     cgd #define	SXP_PHASE_STATUS_PTR		0x1000	/* Status buffer offset */
    627        1.1     cgd #define	SXP_PHASE_MSG_IN_PTR		0x0700	/* Msg in buffer offset */
    628        1.1     cgd #define	SXP_PHASE_COM_PTR		0x00F0	/* Command buffer offset */
    629        1.1     cgd #define	SXP_PHASE_MSG_OUT_PTR		0x0007	/* Msg out buffer offset */
    630        1.1     cgd 
    631        1.1     cgd 
    632        1.1     cgd /* SXP FIFO STATUS REGISTER */
    633        1.1     cgd #define	SXP_FIFO_TOP_RESID		0x8000	/* Top residue reg full */
    634        1.1     cgd #define	SXP_FIFO_ACK_RESID		0x4000	/* Wide transfers odd resid */
    635        1.1     cgd #define	SXP_FIFO_COUNT_MASK		0x001C	/* Words in SXP FIFO */
    636        1.1     cgd #define	SXP_FIFO_BOTTOM_RESID		0x0001	/* Bottom residue reg full */
    637        1.1     cgd 
    638        1.1     cgd 
    639        1.1     cgd /* SXP CONTROL PINS REGISTER */
    640        1.1     cgd #define	SXP_PINS_CON_PHASE		0x8000	/* Scsi phase valid */
    641        1.1     cgd #define	SXP_PINS_CON_PARITY_HI		0x0400	/* Parity pin */
    642        1.1     cgd #define	SXP_PINS_CON_PARITY_LO		0x0200	/* Parity pin */
    643        1.1     cgd #define	SXP_PINS_CON_REQ		0x0100	/* SCSI bus REQUEST */
    644        1.1     cgd #define	SXP_PINS_CON_ACK		0x0080	/* SCSI bus ACKNOWLEDGE */
    645        1.1     cgd #define	SXP_PINS_CON_RST		0x0040	/* SCSI bus RESET */
    646        1.1     cgd #define	SXP_PINS_CON_BSY		0x0020	/* SCSI bus BUSY */
    647        1.1     cgd #define	SXP_PINS_CON_SEL		0x0010	/* SCSI bus SELECT */
    648        1.1     cgd #define	SXP_PINS_CON_ATN		0x0008	/* SCSI bus ATTENTION */
    649        1.1     cgd #define	SXP_PINS_CON_MSG		0x0004	/* SCSI bus MESSAGE */
    650        1.1     cgd #define	SXP_PINS_CON_CD 		0x0002	/* SCSI bus COMMAND */
    651        1.1     cgd #define	SXP_PINS_CON_IO 		0x0001	/* SCSI bus INPUT */
    652        1.1     cgd 
    653        1.1     cgd /*
    654        1.1     cgd  * Set the hold time for the SCSI Bus Reset to be 250 ms
    655        1.1     cgd  */
    656        1.1     cgd #define	SXP_SCSI_BUS_RESET_HOLD_TIME	250
    657        1.1     cgd 
    658        1.1     cgd /* SXP DIFF PINS REGISTER */
    659        1.1     cgd #define	SXP_PINS_DIFF_SENSE		0x0200	/* DIFFSENS sig on SCSI bus */
    660        1.1     cgd #define	SXP_PINS_DIFF_MODE		0x0100	/* DIFFM signal */
    661        1.1     cgd #define	SXP_PINS_DIFF_ENABLE_OUTPUT	0x0080	/* Enable SXP SCSI data drv */
    662        1.1     cgd #define	SXP_PINS_DIFF_PINS_MASK		0x007C	/* Differential control pins */
    663        1.1     cgd #define	SXP_PINS_DIFF_TARGET		0x0002	/* Enable SXP target mode */
    664        1.1     cgd #define	SXP_PINS_DIFF_INITIATOR		0x0001	/* Enable SXP initiator mode */
    665        1.1     cgd 
    666       1.18  mjacob /* Ultra2 only */
    667       1.14  mjacob #define	SXP_PINS_LVD_MODE		0x1000
    668       1.14  mjacob #define	SXP_PINS_HVD_MODE		0x0800
    669       1.14  mjacob #define	SXP_PINS_SE_MODE		0x0400
    670       1.14  mjacob 
    671       1.14  mjacob /* The above have to be put together with the DIFFM pin to make sense */
    672       1.14  mjacob #define	ISP1080_LVD_MODE		(SXP_PINS_LVD_MODE)
    673       1.14  mjacob #define	ISP1080_HVD_MODE		(SXP_PINS_HVD_MODE|SXP_PINS_DIFF_MODE)
    674       1.14  mjacob #define	ISP1080_SE_MODE			(SXP_PINS_SE_MODE)
    675       1.14  mjacob #define	ISP1080_MODE_MASK	\
    676       1.14  mjacob     (SXP_PINS_LVD_MODE|SXP_PINS_HVD_MODE|SXP_PINS_SE_MODE|SXP_PINS_DIFF_MODE)
    677       1.14  mjacob 
    678        1.1     cgd /*
    679        1.1     cgd  * RISC and Host Command and Control Block Register Offsets
    680        1.1     cgd  */
    681        1.1     cgd 
    682        1.1     cgd #define	RISC_ACC	RISC_BLOCK+0x0	/* RW*: Accumulator */
    683        1.1     cgd #define	RISC_R1		RISC_BLOCK+0x2	/* RW*: GP Reg R1  */
    684        1.1     cgd #define	RISC_R2		RISC_BLOCK+0x4	/* RW*: GP Reg R2  */
    685        1.1     cgd #define	RISC_R3		RISC_BLOCK+0x6	/* RW*: GP Reg R3  */
    686        1.1     cgd #define	RISC_R4		RISC_BLOCK+0x8	/* RW*: GP Reg R4  */
    687        1.1     cgd #define	RISC_R5		RISC_BLOCK+0xA	/* RW*: GP Reg R5  */
    688        1.1     cgd #define	RISC_R6		RISC_BLOCK+0xC	/* RW*: GP Reg R6  */
    689        1.1     cgd #define	RISC_R7		RISC_BLOCK+0xE	/* RW*: GP Reg R7  */
    690        1.1     cgd #define	RISC_R8		RISC_BLOCK+0x10	/* RW*: GP Reg R8  */
    691        1.1     cgd #define	RISC_R9		RISC_BLOCK+0x12	/* RW*: GP Reg R9  */
    692        1.1     cgd #define	RISC_R10	RISC_BLOCK+0x14	/* RW*: GP Reg R10 */
    693        1.1     cgd #define	RISC_R11	RISC_BLOCK+0x16	/* RW*: GP Reg R11 */
    694        1.1     cgd #define	RISC_R12	RISC_BLOCK+0x18	/* RW*: GP Reg R12 */
    695        1.1     cgd #define	RISC_R13	RISC_BLOCK+0x1a	/* RW*: GP Reg R13 */
    696        1.1     cgd #define	RISC_R14	RISC_BLOCK+0x1c	/* RW*: GP Reg R14 */
    697        1.1     cgd #define	RISC_R15	RISC_BLOCK+0x1e	/* RW*: GP Reg R15 */
    698        1.1     cgd #define	RISC_PSR	RISC_BLOCK+0x20	/* RW*: Processor Status */
    699        1.1     cgd #define	RISC_IVR	RISC_BLOCK+0x22	/* RW*: Interrupt Vector */
    700        1.1     cgd #define	RISC_PCR	RISC_BLOCK+0x24	/* RW*: Processor Ctrl */
    701        1.1     cgd #define	RISC_RAR0	RISC_BLOCK+0x26	/* RW*: Ram Address #0 */
    702        1.1     cgd #define	RISC_RAR1	RISC_BLOCK+0x28	/* RW*: Ram Address #1 */
    703        1.1     cgd #define	RISC_LCR	RISC_BLOCK+0x2a	/* RW*: Loop Counter */
    704        1.1     cgd #define	RISC_PC		RISC_BLOCK+0x2c	/* R  : Program Counter */
    705        1.1     cgd #define	RISC_MTR	RISC_BLOCK+0x2e	/* RW*: Memory Timing */
    706        1.3  mjacob #define		RISC_MTR2100	RISC_BLOCK+0x30
    707        1.3  mjacob 
    708        1.1     cgd #define	RISC_EMB	RISC_BLOCK+0x30	/* RW*: Ext Mem Boundary */
    709       1.11  mjacob #define		DUAL_BANK	8
    710        1.1     cgd #define	RISC_SP		RISC_BLOCK+0x32	/* RW*: Stack Pointer */
    711        1.1     cgd #define	RISC_HRL	RISC_BLOCK+0x3e	/* R *: Hardware Rev Level */
    712        1.1     cgd #define	HCCR		RISC_BLOCK+0x40	/* RW : Host Command & Ctrl */
    713        1.1     cgd #define	BP0		RISC_BLOCK+0x42	/* RW : Processor Brkpt #0 */
    714        1.1     cgd #define	BP1		RISC_BLOCK+0x44	/* RW : Processor Brkpt #1 */
    715        1.1     cgd #define	TCR		RISC_BLOCK+0x46	/*  W : Test Control */
    716        1.1     cgd #define	TMR		RISC_BLOCK+0x48	/*  W : Test Mode */
    717        1.1     cgd 
    718        1.1     cgd 
    719        1.1     cgd /* PROCESSOR STATUS REGISTER */
    720        1.1     cgd #define	RISC_PSR_FORCE_TRUE		0x8000
    721        1.1     cgd #define	RISC_PSR_LOOP_COUNT_DONE	0x4000
    722        1.1     cgd #define	RISC_PSR_RISC_INT		0x2000
    723        1.1     cgd #define	RISC_PSR_TIMER_ROLLOVER		0x1000
    724        1.1     cgd #define	RISC_PSR_ALU_OVERFLOW		0x0800
    725        1.1     cgd #define	RISC_PSR_ALU_MSB		0x0400
    726        1.1     cgd #define	RISC_PSR_ALU_CARRY		0x0200
    727        1.1     cgd #define	RISC_PSR_ALU_ZERO		0x0100
    728        1.7  mjacob 
    729        1.7  mjacob #define	RISC_PSR_PCI_ULTRA		0x0080
    730        1.7  mjacob #define	RISC_PSR_SBUS_ULTRA		0x0020
    731        1.7  mjacob 
    732        1.1     cgd #define	RISC_PSR_DMA_INT		0x0010
    733        1.1     cgd #define	RISC_PSR_SXP_INT		0x0008
    734        1.1     cgd #define	RISC_PSR_HOST_INT		0x0004
    735        1.1     cgd #define	RISC_PSR_INT_PENDING		0x0002
    736        1.1     cgd #define	RISC_PSR_FORCE_FALSE  		0x0001
    737        1.1     cgd 
    738        1.1     cgd 
    739        1.1     cgd /* Host Command and Control */
    740        1.1     cgd #define	HCCR_CMD_NOP			0x0000	/* NOP */
    741        1.1     cgd #define	HCCR_CMD_RESET			0x1000	/* Reset RISC */
    742        1.1     cgd #define	HCCR_CMD_PAUSE			0x2000	/* Pause RISC */
    743        1.1     cgd #define	HCCR_CMD_RELEASE		0x3000	/* Release Paused RISC */
    744        1.1     cgd #define	HCCR_CMD_STEP			0x4000	/* Single Step RISC */
    745       1.25  mjacob #define	HCCR_2X00_DISABLE_PARITY_PAUSE	0x4001	/*
    746       1.25  mjacob 						 * Disable RISC pause on FPM
    747       1.25  mjacob 						 * parity error.
    748       1.25  mjacob 						 */
    749        1.1     cgd #define	HCCR_CMD_SET_HOST_INT		0x5000	/* Set Host Interrupt */
    750        1.1     cgd #define	HCCR_CMD_CLEAR_HOST_INT		0x6000	/* Clear Host Interrupt */
    751        1.1     cgd #define	HCCR_CMD_CLEAR_RISC_INT		0x7000	/* Clear RISC interrupt */
    752        1.1     cgd #define	HCCR_CMD_BREAKPOINT		0x8000	/* Change breakpoint enables */
    753        1.1     cgd #define	PCI_HCCR_CMD_BIOS		0x9000	/* Write BIOS (disable) */
    754        1.1     cgd #define	PCI_HCCR_CMD_PARITY		0xA000	/* Write parity enable */
    755        1.1     cgd #define	PCI_HCCR_CMD_PARITY_ERR		0xE000	/* Generate parity error */
    756        1.1     cgd #define	HCCR_CMD_TEST_MODE		0xF000	/* Set Test Mode */
    757        1.3  mjacob 
    758  1.30.32.1     mjf 
    759        1.3  mjacob #define	ISP2100_HCCR_PARITY_ENABLE_2	0x0400
    760        1.3  mjacob #define	ISP2100_HCCR_PARITY_ENABLE_1	0x0200
    761        1.3  mjacob #define	ISP2100_HCCR_PARITY_ENABLE_0	0x0100
    762        1.3  mjacob #define	ISP2100_HCCR_PARITY		0x0001
    763        1.1     cgd 
    764        1.1     cgd #define	PCI_HCCR_PARITY			0x0400	/* Parity error flag */
    765        1.1     cgd #define	PCI_HCCR_PARITY_ENABLE_1	0x0200	/* Parity enable bank 1 */
    766        1.1     cgd #define	PCI_HCCR_PARITY_ENABLE_0	0x0100	/* Parity enable bank 0 */
    767        1.1     cgd 
    768        1.1     cgd #define	HCCR_HOST_INT			0x0080	/* R  : Host interrupt set */
    769        1.1     cgd #define	HCCR_RESET			0x0040	/* R  : reset in progress */
    770        1.1     cgd #define	HCCR_PAUSE			0x0020	/* R  : RISC paused */
    771        1.1     cgd 
    772        1.1     cgd #define	PCI_HCCR_BIOS			0x0001	/*  W : BIOS enable */
    773        1.7  mjacob 
    774        1.7  mjacob /*
    775  1.30.32.1     mjf  * Defines for Interrupts
    776  1.30.32.1     mjf  */
    777  1.30.32.1     mjf #define	ISP_INTS_ENABLED(isp)						\
    778  1.30.32.1     mjf  ((IS_SCSI(isp))?  							\
    779  1.30.32.1     mjf   (ISP_READ(isp, BIU_ICR) & BIU_IMASK) :				\
    780  1.30.32.1     mjf    (IS_24XX(isp)? (ISP_READ(isp, BIU2400_ICR) & BIU2400_IMASK) :	\
    781  1.30.32.1     mjf    (ISP_READ(isp, BIU_ICR) & BIU2100_IMASK)))
    782  1.30.32.1     mjf 
    783  1.30.32.1     mjf #define	ISP_ENABLE_INTS(isp)						\
    784  1.30.32.1     mjf  (IS_SCSI(isp) ?  							\
    785  1.30.32.1     mjf    ISP_WRITE(isp, BIU_ICR, BIU_IMASK) :					\
    786  1.30.32.1     mjf    (IS_24XX(isp) ?							\
    787  1.30.32.1     mjf     (ISP_WRITE(isp, BIU2400_ICR, BIU2400_IMASK)) :			\
    788  1.30.32.1     mjf     (ISP_WRITE(isp, BIU_ICR, BIU2100_IMASK))))
    789  1.30.32.1     mjf 
    790  1.30.32.1     mjf #define	ISP_DISABLE_INTS(isp)						\
    791  1.30.32.1     mjf  IS_24XX(isp)? ISP_WRITE(isp, BIU2400_ICR, 0) : ISP_WRITE(isp, BIU_ICR, 0)
    792  1.30.32.1     mjf 
    793  1.30.32.1     mjf /*
    794       1.15  mjacob  * NVRAM Definitions (PCI cards only)
    795       1.15  mjacob  */
    796       1.15  mjacob 
    797       1.15  mjacob #define	ISPBSMX(c, byte, shift, mask)	\
    798       1.15  mjacob 	(((c)[(byte)] >> (shift)) & (mask))
    799       1.15  mjacob /*
    800       1.15  mjacob  * Qlogic 1020/1040 NVRAM is an array of 128 bytes.
    801        1.7  mjacob  *
    802        1.7  mjacob  * Some portion of the front of this is for general host adapter properties
    803        1.7  mjacob  * This is followed by an array of per-target parameters, and is tailed off
    804        1.7  mjacob  * with a checksum xor byte at offset 127. For non-byte entities data is
    805        1.7  mjacob  * stored in Little Endian order.
    806        1.7  mjacob  */
    807        1.7  mjacob 
    808        1.7  mjacob #define	ISP_NVRAM_SIZE	128
    809       1.14  mjacob 
    810        1.7  mjacob #define	ISP_NVRAM_VERSION(c)			(c)[4]
    811        1.7  mjacob #define	ISP_NVRAM_FIFO_THRESHOLD(c)		ISPBSMX(c, 5, 0, 0x03)
    812        1.7  mjacob #define	ISP_NVRAM_BIOS_DISABLE(c)		ISPBSMX(c, 5, 2, 0x01)
    813        1.7  mjacob #define	ISP_NVRAM_HBA_ENABLE(c)			ISPBSMX(c, 5, 3, 0x01)
    814        1.7  mjacob #define	ISP_NVRAM_INITIATOR_ID(c)		ISPBSMX(c, 5, 4, 0x0f)
    815        1.7  mjacob #define	ISP_NVRAM_BUS_RESET_DELAY(c)		(c)[6]
    816        1.7  mjacob #define	ISP_NVRAM_BUS_RETRY_COUNT(c)		(c)[7]
    817        1.7  mjacob #define	ISP_NVRAM_BUS_RETRY_DELAY(c)		(c)[8]
    818        1.7  mjacob #define	ISP_NVRAM_ASYNC_DATA_SETUP_TIME(c)	ISPBSMX(c, 9, 0, 0x0f)
    819        1.7  mjacob #define	ISP_NVRAM_REQ_ACK_ACTIVE_NEGATION(c)	ISPBSMX(c, 9, 4, 0x01)
    820        1.7  mjacob #define	ISP_NVRAM_DATA_LINE_ACTIVE_NEGATION(c)	ISPBSMX(c, 9, 5, 0x01)
    821        1.7  mjacob #define	ISP_NVRAM_DATA_DMA_BURST_ENABLE(c)	ISPBSMX(c, 9, 6, 0x01)
    822        1.7  mjacob #define	ISP_NVRAM_CMD_DMA_BURST_ENABLE(c)	ISPBSMX(c, 9, 7, 0x01)
    823        1.7  mjacob #define	ISP_NVRAM_TAG_AGE_LIMIT(c)		(c)[10]
    824        1.7  mjacob #define	ISP_NVRAM_LOWTRM_ENABLE(c)		ISPBSMX(c, 11, 0, 0x01)
    825        1.7  mjacob #define	ISP_NVRAM_HITRM_ENABLE(c)		ISPBSMX(c, 11, 1, 0x01)
    826        1.7  mjacob #define	ISP_NVRAM_PCMC_BURST_ENABLE(c)		ISPBSMX(c, 11, 2, 0x01)
    827        1.7  mjacob #define	ISP_NVRAM_ENABLE_60_MHZ(c)		ISPBSMX(c, 11, 3, 0x01)
    828        1.7  mjacob #define	ISP_NVRAM_SCSI_RESET_DISABLE(c)		ISPBSMX(c, 11, 4, 0x01)
    829        1.7  mjacob #define	ISP_NVRAM_ENABLE_AUTO_TERM(c)		ISPBSMX(c, 11, 5, 0x01)
    830        1.7  mjacob #define	ISP_NVRAM_FIFO_THRESHOLD_128(c)		ISPBSMX(c, 11, 6, 0x01)
    831        1.7  mjacob #define	ISP_NVRAM_AUTO_TERM_SUPPORT(c)		ISPBSMX(c, 11, 7, 0x01)
    832        1.7  mjacob #define	ISP_NVRAM_SELECTION_TIMEOUT(c)		(((c)[12]) | ((c)[13] << 8))
    833        1.7  mjacob #define	ISP_NVRAM_MAX_QUEUE_DEPTH(c)		(((c)[14]) | ((c)[15] << 8))
    834        1.7  mjacob #define	ISP_NVRAM_SCSI_BUS_SIZE(c)		ISPBSMX(c, 16, 0, 0x01)
    835        1.7  mjacob #define	ISP_NVRAM_SCSI_BUS_TYPE(c)		ISPBSMX(c, 16, 1, 0x01)
    836        1.7  mjacob #define	ISP_NVRAM_ADAPTER_CLK_SPEED(c)		ISPBSMX(c, 16, 2, 0x01)
    837        1.7  mjacob #define	ISP_NVRAM_SOFT_TERM_SUPPORT(c)		ISPBSMX(c, 16, 3, 0x01)
    838        1.7  mjacob #define	ISP_NVRAM_FLASH_ONBOARD(c)		ISPBSMX(c, 16, 4, 0x01)
    839        1.7  mjacob #define	ISP_NVRAM_FAST_MTTR_ENABLE(c)		ISPBSMX(c, 22, 0, 0x01)
    840        1.7  mjacob 
    841        1.7  mjacob #define	ISP_NVRAM_TARGOFF			28
    842  1.30.32.1     mjf #define	ISP_NVRAM_TARGSIZE			6
    843        1.7  mjacob #define	_IxT(tgt, tidx)			\
    844  1.30.32.1     mjf 	(ISP_NVRAM_TARGOFF + (ISP_NVRAM_TARGSIZE * (tgt)) + (tidx))
    845        1.7  mjacob #define	ISP_NVRAM_TGT_RENEG(c, t)		ISPBSMX(c, _IxT(t, 0), 0, 0x01)
    846        1.7  mjacob #define	ISP_NVRAM_TGT_QFRZ(c, t)		ISPBSMX(c, _IxT(t, 0), 1, 0x01)
    847        1.7  mjacob #define	ISP_NVRAM_TGT_ARQ(c, t)			ISPBSMX(c, _IxT(t, 0), 2, 0x01)
    848        1.7  mjacob #define	ISP_NVRAM_TGT_TQING(c, t)		ISPBSMX(c, _IxT(t, 0), 3, 0x01)
    849        1.7  mjacob #define	ISP_NVRAM_TGT_SYNC(c, t)		ISPBSMX(c, _IxT(t, 0), 4, 0x01)
    850        1.7  mjacob #define	ISP_NVRAM_TGT_WIDE(c, t)		ISPBSMX(c, _IxT(t, 0), 5, 0x01)
    851        1.7  mjacob #define	ISP_NVRAM_TGT_PARITY(c, t)		ISPBSMX(c, _IxT(t, 0), 6, 0x01)
    852        1.7  mjacob #define	ISP_NVRAM_TGT_DISC(c, t)		ISPBSMX(c, _IxT(t, 0), 7, 0x01)
    853        1.7  mjacob #define	ISP_NVRAM_TGT_EXEC_THROTTLE(c, t)	ISPBSMX(c, _IxT(t, 1), 0, 0xff)
    854        1.7  mjacob #define	ISP_NVRAM_TGT_SYNC_PERIOD(c, t)		ISPBSMX(c, _IxT(t, 2), 0, 0xff)
    855        1.7  mjacob #define	ISP_NVRAM_TGT_SYNC_OFFSET(c, t)		ISPBSMX(c, _IxT(t, 3), 0, 0x0f)
    856        1.7  mjacob #define	ISP_NVRAM_TGT_DEVICE_ENABLE(c, t)	ISPBSMX(c, _IxT(t, 3), 4, 0x01)
    857        1.7  mjacob #define	ISP_NVRAM_TGT_LUN_DISABLE(c, t)		ISPBSMX(c, _IxT(t, 3), 5, 0x01)
    858       1.15  mjacob 
    859       1.15  mjacob /*
    860       1.15  mjacob  * Qlogic 1080/1240 NVRAM is an array of 256 bytes.
    861       1.15  mjacob  *
    862       1.15  mjacob  * Some portion of the front of this is for general host adapter properties
    863       1.15  mjacob  * This is followed by an array of per-target parameters, and is tailed off
    864       1.15  mjacob  * with a checksum xor byte at offset 256. For non-byte entities data is
    865       1.15  mjacob  * stored in Little Endian order.
    866       1.15  mjacob  */
    867       1.15  mjacob 
    868       1.15  mjacob #define	ISP1080_NVRAM_SIZE	256
    869       1.15  mjacob 
    870       1.15  mjacob #define	ISP1080_NVRAM_VERSION(c)		ISP_NVRAM_VERSION(c)
    871       1.15  mjacob 
    872       1.15  mjacob /* Offset 5 */
    873       1.15  mjacob /*
    874  1.30.32.1     mjf 	uint8_t bios_configuration_mode     :2;
    875  1.30.32.1     mjf 	uint8_t bios_disable                :1;
    876  1.30.32.1     mjf 	uint8_t selectable_scsi_boot_enable :1;
    877  1.30.32.1     mjf 	uint8_t cd_rom_boot_enable          :1;
    878  1.30.32.1     mjf 	uint8_t disable_loading_risc_code   :1;
    879  1.30.32.1     mjf 	uint8_t enable_64bit_addressing     :1;
    880  1.30.32.1     mjf 	uint8_t unused_7                    :1;
    881       1.15  mjacob  */
    882       1.15  mjacob 
    883       1.15  mjacob /* Offsets 6, 7 */
    884       1.15  mjacob /*
    885  1.30.32.1     mjf         uint8_t boot_lun_number    :5;
    886  1.30.32.1     mjf         uint8_t scsi_bus_number    :1;
    887  1.30.32.1     mjf         uint8_t unused_6           :1;
    888  1.30.32.1     mjf         uint8_t unused_7           :1;
    889  1.30.32.1     mjf         uint8_t boot_target_number :4;
    890  1.30.32.1     mjf         uint8_t unused_12          :1;
    891  1.30.32.1     mjf         uint8_t unused_13          :1;
    892  1.30.32.1     mjf         uint8_t unused_14          :1;
    893  1.30.32.1     mjf         uint8_t unused_15          :1;
    894       1.15  mjacob  */
    895       1.15  mjacob 
    896       1.15  mjacob #define	ISP1080_NVRAM_HBA_ENABLE(c)			ISPBSMX(c, 16, 3, 0x01)
    897       1.15  mjacob 
    898       1.15  mjacob #define	ISP1080_NVRAM_BURST_ENABLE(c)			ISPBSMX(c, 16, 1, 0x01)
    899       1.15  mjacob #define	ISP1080_NVRAM_FIFO_THRESHOLD(c)			ISPBSMX(c, 16, 4, 0x0f)
    900       1.15  mjacob 
    901       1.15  mjacob #define	ISP1080_NVRAM_AUTO_TERM_SUPPORT(c)		ISPBSMX(c, 17, 7, 0x01)
    902       1.15  mjacob #define	ISP1080_NVRAM_BUS0_TERM_MODE(c)			ISPBSMX(c, 17, 0, 0x03)
    903       1.15  mjacob #define	ISP1080_NVRAM_BUS1_TERM_MODE(c)			ISPBSMX(c, 17, 2, 0x03)
    904       1.15  mjacob 
    905       1.15  mjacob #define	ISP1080_ISP_PARAMETER(c)			\
    906       1.15  mjacob 	(((c)[18]) | ((c)[19] << 8))
    907       1.15  mjacob 
    908       1.19  mjacob #define	ISP1080_FAST_POST(c)				ISPBSMX(c, 20, 0, 0x01)
    909       1.19  mjacob #define	ISP1080_REPORT_LVD_TRANSITION(c)		ISPBSMX(c, 20, 1, 0x01)
    910       1.15  mjacob 
    911       1.15  mjacob #define	ISP1080_BUS1_OFF				112
    912       1.15  mjacob 
    913       1.15  mjacob #define	ISP1080_NVRAM_INITIATOR_ID(c, b)		\
    914       1.15  mjacob 	ISPBSMX(c, ((b == 0)? 0 : ISP1080_BUS1_OFF) + 24, 0, 0x0f)
    915       1.15  mjacob #define	ISP1080_NVRAM_BUS_RESET_DELAY(c, b)		\
    916       1.15  mjacob 	(c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 25]
    917       1.15  mjacob #define	ISP1080_NVRAM_BUS_RETRY_COUNT(c, b)		\
    918       1.15  mjacob 	(c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 26]
    919       1.15  mjacob #define	ISP1080_NVRAM_BUS_RETRY_DELAY(c, b)		\
    920       1.15  mjacob 	(c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 27]
    921       1.15  mjacob 
    922       1.15  mjacob #define	ISP1080_NVRAM_ASYNC_DATA_SETUP_TIME(c, b)	\
    923       1.15  mjacob 	ISPBSMX(c, ((b == 0)? 0 : ISP1080_BUS1_OFF) + 28, 0, 0x0f)
    924       1.15  mjacob #define	ISP1080_NVRAM_REQ_ACK_ACTIVE_NEGATION(c, b)	\
    925       1.15  mjacob 	ISPBSMX(c, ((b == 0)? 0 : ISP1080_BUS1_OFF) + 28, 4, 0x01)
    926       1.15  mjacob #define	ISP1080_NVRAM_DATA_LINE_ACTIVE_NEGATION(c, b)	\
    927       1.15  mjacob 	ISPBSMX(c, ((b == 0)? 0 : ISP1080_BUS1_OFF) + 28, 5, 0x01)
    928       1.15  mjacob #define	ISP1080_NVRAM_SELECTION_TIMEOUT(c, b)		\
    929       1.15  mjacob 	(((c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 30]) | \
    930       1.15  mjacob 	((c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 31] << 8))
    931       1.15  mjacob #define	ISP1080_NVRAM_MAX_QUEUE_DEPTH(c, b)		\
    932       1.15  mjacob 	(((c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 32]) | \
    933       1.15  mjacob 	((c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 33] << 8))
    934       1.15  mjacob 
    935       1.15  mjacob #define	ISP1080_NVRAM_TARGOFF(b)		\
    936       1.15  mjacob 	((b == 0)? 40: (40 + ISP1080_BUS1_OFF))
    937       1.15  mjacob #define	ISP1080_NVRAM_TARGSIZE			6
    938       1.15  mjacob #define	_IxT8(tgt, tidx, b)			\
    939       1.15  mjacob 	(ISP1080_NVRAM_TARGOFF((b)) + (ISP1080_NVRAM_TARGSIZE * (tgt)) + (tidx))
    940       1.15  mjacob 
    941       1.15  mjacob #define	ISP1080_NVRAM_TGT_RENEG(c, t, b)		\
    942       1.15  mjacob 	ISPBSMX(c, _IxT8(t, 0, (b)), 0, 0x01)
    943       1.15  mjacob #define	ISP1080_NVRAM_TGT_QFRZ(c, t, b)			\
    944       1.15  mjacob 	ISPBSMX(c, _IxT8(t, 0, (b)), 1, 0x01)
    945       1.15  mjacob #define	ISP1080_NVRAM_TGT_ARQ(c, t, b)			\
    946       1.15  mjacob 	ISPBSMX(c, _IxT8(t, 0, (b)), 2, 0x01)
    947       1.15  mjacob #define	ISP1080_NVRAM_TGT_TQING(c, t, b)		\
    948       1.15  mjacob 	ISPBSMX(c, _IxT8(t, 0, (b)), 3, 0x01)
    949       1.15  mjacob #define	ISP1080_NVRAM_TGT_SYNC(c, t, b)			\
    950       1.15  mjacob 	ISPBSMX(c, _IxT8(t, 0, (b)), 4, 0x01)
    951       1.15  mjacob #define	ISP1080_NVRAM_TGT_WIDE(c, t, b)			\
    952       1.15  mjacob 	ISPBSMX(c, _IxT8(t, 0, (b)), 5, 0x01)
    953       1.15  mjacob #define	ISP1080_NVRAM_TGT_PARITY(c, t, b)		\
    954       1.15  mjacob 	ISPBSMX(c, _IxT8(t, 0, (b)), 6, 0x01)
    955       1.15  mjacob #define	ISP1080_NVRAM_TGT_DISC(c, t, b)			\
    956       1.15  mjacob 	ISPBSMX(c, _IxT8(t, 0, (b)), 7, 0x01)
    957       1.15  mjacob #define	ISP1080_NVRAM_TGT_EXEC_THROTTLE(c, t, b)	\
    958       1.15  mjacob 	ISPBSMX(c, _IxT8(t, 1, (b)), 0, 0xff)
    959       1.15  mjacob #define	ISP1080_NVRAM_TGT_SYNC_PERIOD(c, t, b)		\
    960       1.15  mjacob 	ISPBSMX(c, _IxT8(t, 2, (b)), 0, 0xff)
    961       1.15  mjacob #define	ISP1080_NVRAM_TGT_SYNC_OFFSET(c, t, b)		\
    962       1.15  mjacob 	ISPBSMX(c, _IxT8(t, 3, (b)), 0, 0x0f)
    963       1.15  mjacob #define	ISP1080_NVRAM_TGT_DEVICE_ENABLE(c, t, b)	\
    964       1.15  mjacob 	ISPBSMX(c, _IxT8(t, 3, (b)), 4, 0x01)
    965       1.15  mjacob #define	ISP1080_NVRAM_TGT_LUN_DISABLE(c, t, b)		\
    966       1.15  mjacob 	ISPBSMX(c, _IxT8(t, 3, (b)), 5, 0x01)
    967       1.19  mjacob 
    968       1.19  mjacob #define	ISP12160_NVRAM_HBA_ENABLE	ISP1080_NVRAM_HBA_ENABLE
    969       1.19  mjacob #define	ISP12160_NVRAM_BURST_ENABLE	ISP1080_NVRAM_BURST_ENABLE
    970       1.19  mjacob #define	ISP12160_NVRAM_FIFO_THRESHOLD	ISP1080_NVRAM_FIFO_THRESHOLD
    971       1.19  mjacob #define	ISP12160_NVRAM_AUTO_TERM_SUPPORT	ISP1080_NVRAM_AUTO_TERM_SUPPORT
    972       1.19  mjacob #define	ISP12160_NVRAM_BUS0_TERM_MODE	ISP1080_NVRAM_BUS0_TERM_MODE
    973       1.19  mjacob #define	ISP12160_NVRAM_BUS1_TERM_MODE	ISP1080_NVRAM_BUS1_TERM_MODE
    974       1.19  mjacob #define	ISP12160_ISP_PARAMETER		ISP12160_ISP_PARAMETER
    975       1.19  mjacob #define	ISP12160_FAST_POST		ISP1080_FAST_POST
    976       1.19  mjacob #define	ISP12160_REPORT_LVD_TRANSITION	ISP1080_REPORT_LVD_TRANSTION
    977       1.19  mjacob 
    978       1.19  mjacob #define	ISP12160_NVRAM_INITIATOR_ID			\
    979       1.19  mjacob 	ISP1080_NVRAM_INITIATOR_ID
    980       1.19  mjacob #define	ISP12160_NVRAM_BUS_RESET_DELAY			\
    981       1.19  mjacob 	ISP1080_NVRAM_BUS_RESET_DELAY
    982       1.19  mjacob #define	ISP12160_NVRAM_BUS_RETRY_COUNT			\
    983       1.19  mjacob 	ISP1080_NVRAM_BUS_RETRY_COUNT
    984       1.19  mjacob #define	ISP12160_NVRAM_BUS_RETRY_DELAY			\
    985       1.19  mjacob 	ISP1080_NVRAM_BUS_RETRY_DELAY
    986       1.19  mjacob #define	ISP12160_NVRAM_ASYNC_DATA_SETUP_TIME		\
    987       1.19  mjacob 	ISP1080_NVRAM_ASYNC_DATA_SETUP_TIME
    988       1.19  mjacob #define	ISP12160_NVRAM_REQ_ACK_ACTIVE_NEGATION		\
    989       1.19  mjacob 	ISP1080_NVRAM_REQ_ACK_ACTIVE_NEGATION
    990       1.19  mjacob #define	ISP12160_NVRAM_DATA_LINE_ACTIVE_NEGATION	\
    991       1.19  mjacob 	ISP1080_NVRAM_DATA_LINE_ACTIVE_NEGATION
    992       1.19  mjacob #define	ISP12160_NVRAM_SELECTION_TIMEOUT		\
    993       1.19  mjacob 	ISP1080_NVRAM_SELECTION_TIMEOUT
    994       1.19  mjacob #define	ISP12160_NVRAM_MAX_QUEUE_DEPTH			\
    995       1.19  mjacob 	ISP1080_NVRAM_MAX_QUEUE_DEPTH
    996       1.19  mjacob 
    997       1.19  mjacob 
    998       1.19  mjacob #define	ISP12160_BUS0_OFF	24
    999       1.19  mjacob #define	ISP12160_BUS1_OFF	136
   1000       1.19  mjacob 
   1001       1.19  mjacob #define	ISP12160_NVRAM_TARGOFF(b)		\
   1002       1.19  mjacob 	(((b == 0)? ISP12160_BUS0_OFF : ISP12160_BUS1_OFF) + 16)
   1003       1.19  mjacob 
   1004       1.19  mjacob #define	ISP12160_NVRAM_TARGSIZE			6
   1005       1.19  mjacob #define	_IxT16(tgt, tidx, b)			\
   1006       1.19  mjacob 	(ISP12160_NVRAM_TARGOFF((b))+(ISP12160_NVRAM_TARGSIZE * (tgt))+(tidx))
   1007       1.19  mjacob 
   1008       1.19  mjacob #define	ISP12160_NVRAM_TGT_RENEG(c, t, b)		\
   1009       1.19  mjacob 	ISPBSMX(c, _IxT16(t, 0, (b)), 0, 0x01)
   1010       1.19  mjacob #define	ISP12160_NVRAM_TGT_QFRZ(c, t, b)		\
   1011       1.19  mjacob 	ISPBSMX(c, _IxT16(t, 0, (b)), 1, 0x01)
   1012       1.19  mjacob #define	ISP12160_NVRAM_TGT_ARQ(c, t, b)			\
   1013       1.19  mjacob 	ISPBSMX(c, _IxT16(t, 0, (b)), 2, 0x01)
   1014       1.19  mjacob #define	ISP12160_NVRAM_TGT_TQING(c, t, b)		\
   1015       1.19  mjacob 	ISPBSMX(c, _IxT16(t, 0, (b)), 3, 0x01)
   1016       1.19  mjacob #define	ISP12160_NVRAM_TGT_SYNC(c, t, b)		\
   1017       1.19  mjacob 	ISPBSMX(c, _IxT16(t, 0, (b)), 4, 0x01)
   1018       1.19  mjacob #define	ISP12160_NVRAM_TGT_WIDE(c, t, b)		\
   1019       1.19  mjacob 	ISPBSMX(c, _IxT16(t, 0, (b)), 5, 0x01)
   1020       1.19  mjacob #define	ISP12160_NVRAM_TGT_PARITY(c, t, b)		\
   1021       1.19  mjacob 	ISPBSMX(c, _IxT16(t, 0, (b)), 6, 0x01)
   1022       1.19  mjacob #define	ISP12160_NVRAM_TGT_DISC(c, t, b)		\
   1023       1.19  mjacob 	ISPBSMX(c, _IxT16(t, 0, (b)), 7, 0x01)
   1024       1.19  mjacob 
   1025       1.19  mjacob #define	ISP12160_NVRAM_TGT_EXEC_THROTTLE(c, t, b)	\
   1026       1.19  mjacob 	ISPBSMX(c, _IxT16(t, 1, (b)), 0, 0xff)
   1027       1.19  mjacob #define	ISP12160_NVRAM_TGT_SYNC_PERIOD(c, t, b)		\
   1028       1.19  mjacob 	ISPBSMX(c, _IxT16(t, 2, (b)), 0, 0xff)
   1029       1.19  mjacob 
   1030       1.19  mjacob #define	ISP12160_NVRAM_TGT_SYNC_OFFSET(c, t, b)		\
   1031       1.19  mjacob 	ISPBSMX(c, _IxT16(t, 3, (b)), 0, 0x1f)
   1032       1.19  mjacob #define	ISP12160_NVRAM_TGT_DEVICE_ENABLE(c, t, b)	\
   1033       1.19  mjacob 	ISPBSMX(c, _IxT16(t, 3, (b)), 5, 0x01)
   1034       1.19  mjacob 
   1035       1.19  mjacob #define	ISP12160_NVRAM_PPR_OPTIONS(c, t, b)		\
   1036       1.19  mjacob 	ISPBSMX(c, _IxT16(t, 4, (b)), 0, 0x0f)
   1037       1.19  mjacob #define	ISP12160_NVRAM_PPR_WIDTH(c, t, b)		\
   1038       1.19  mjacob 	ISPBSMX(c, _IxT16(t, 4, (b)), 4, 0x03)
   1039       1.19  mjacob #define	ISP12160_NVRAM_PPR_ENABLE(c, t, b)		\
   1040       1.19  mjacob 	ISPBSMX(c, _IxT16(t, 4, (b)), 7, 0x01)
   1041        1.7  mjacob 
   1042        1.7  mjacob /*
   1043  1.30.32.1     mjf  * Qlogic 2100 thru 2300 NVRAM is an array of 256 bytes.
   1044        1.7  mjacob  *
   1045        1.7  mjacob  * Some portion of the front of this is for general RISC engine parameters,
   1046        1.7  mjacob  * mostly reflecting the state of the last INITIALIZE FIRMWARE mailbox command.
   1047        1.7  mjacob  *
   1048        1.7  mjacob  * This is followed by some general host adapter parameters, and ends with
   1049        1.7  mjacob  * a checksum xor byte at offset 255. For non-byte entities data is stored
   1050        1.7  mjacob  * in Little Endian order.
   1051        1.7  mjacob  */
   1052        1.7  mjacob #define	ISP2100_NVRAM_SIZE	256
   1053        1.7  mjacob /* ISP_NVRAM_VERSION is in same overall place */
   1054        1.7  mjacob #define	ISP2100_NVRAM_RISCVER(c)		(c)[6]
   1055  1.30.32.1     mjf #define	ISP2100_NVRAM_OPTIONS(c)		((c)[8] | ((c)[9] << 8))
   1056        1.7  mjacob #define	ISP2100_NVRAM_MAXFRAMELENGTH(c)		(((c)[10]) | ((c)[11] << 8))
   1057        1.7  mjacob #define	ISP2100_NVRAM_MAXIOCBALLOCATION(c)	(((c)[12]) | ((c)[13] << 8))
   1058        1.7  mjacob #define	ISP2100_NVRAM_EXECUTION_THROTTLE(c)	(((c)[14]) | ((c)[15] << 8))
   1059        1.7  mjacob #define	ISP2100_NVRAM_RETRY_COUNT(c)		(c)[16]
   1060        1.7  mjacob #define	ISP2100_NVRAM_RETRY_DELAY(c)		(c)[17]
   1061        1.7  mjacob 
   1062       1.20      he #define	ISP2100_NVRAM_PORT_NAME(c)	(\
   1063  1.30.32.1     mjf 		(((uint64_t)(c)[18]) << 56) | \
   1064  1.30.32.1     mjf 		(((uint64_t)(c)[19]) << 48) | \
   1065  1.30.32.1     mjf 		(((uint64_t)(c)[20]) << 40) | \
   1066  1.30.32.1     mjf 		(((uint64_t)(c)[21]) << 32) | \
   1067  1.30.32.1     mjf 		(((uint64_t)(c)[22]) << 24) | \
   1068  1.30.32.1     mjf 		(((uint64_t)(c)[23]) << 16) | \
   1069  1.30.32.1     mjf 		(((uint64_t)(c)[24]) <<  8) | \
   1070  1.30.32.1     mjf 		(((uint64_t)(c)[25]) <<  0))
   1071  1.30.32.1     mjf 
   1072  1.30.32.1     mjf #define	ISP2100_NVRAM_HARDLOOPID(c)		((c)[26] | ((c)[27] << 8))
   1073  1.30.32.1     mjf #define	ISP2100_NVRAM_TOV(c)			((c)[29])
   1074  1.30.32.1     mjf 
   1075  1.30.32.1     mjf #define	ISP2100_NVRAM_NODE_NAME(c)	(\
   1076  1.30.32.1     mjf 		(((uint64_t)(c)[30]) << 56) | \
   1077  1.30.32.1     mjf 		(((uint64_t)(c)[31]) << 48) | \
   1078  1.30.32.1     mjf 		(((uint64_t)(c)[32]) << 40) | \
   1079  1.30.32.1     mjf 		(((uint64_t)(c)[33]) << 32) | \
   1080  1.30.32.1     mjf 		(((uint64_t)(c)[34]) << 24) | \
   1081  1.30.32.1     mjf 		(((uint64_t)(c)[35]) << 16) | \
   1082  1.30.32.1     mjf 		(((uint64_t)(c)[36]) <<  8) | \
   1083  1.30.32.1     mjf 		(((uint64_t)(c)[37]) <<  0))
   1084  1.30.32.1     mjf 
   1085  1.30.32.1     mjf #define	ISP2100_XFW_OPTIONS(c)			((c)[38] | ((c)[39] << 8))
   1086  1.30.32.1     mjf 
   1087  1.30.32.1     mjf #define	ISP2100_RACC_TIMER(c)			(c)[40]
   1088  1.30.32.1     mjf #define	ISP2100_IDELAY_TIMER(c)			(c)[41]
   1089  1.30.32.1     mjf 
   1090  1.30.32.1     mjf #define	ISP2100_ZFW_OPTIONS(c)			((c)[42] | ((c)[43] << 8))
   1091  1.30.32.1     mjf 
   1092  1.30.32.1     mjf #define	ISP2100_SERIAL_LINK(c)			((c)[68] | ((c)[69] << 8))
   1093        1.7  mjacob 
   1094  1.30.32.1     mjf #define	ISP2100_NVRAM_HBA_OPTIONS(c)		((c)[70] | ((c)[71] << 8))
   1095        1.7  mjacob #define	ISP2100_NVRAM_HBA_DISABLE(c)		ISPBSMX(c, 70, 0, 0x01)
   1096        1.7  mjacob #define	ISP2100_NVRAM_BIOS_DISABLE(c)		ISPBSMX(c, 70, 1, 0x01)
   1097        1.7  mjacob #define	ISP2100_NVRAM_LUN_DISABLE(c)		ISPBSMX(c, 70, 2, 0x01)
   1098        1.7  mjacob #define	ISP2100_NVRAM_ENABLE_SELECT_BOOT(c)	ISPBSMX(c, 70, 3, 0x01)
   1099        1.7  mjacob #define	ISP2100_NVRAM_DISABLE_CODELOAD(c)	ISPBSMX(c, 70, 4, 0x01)
   1100        1.7  mjacob #define	ISP2100_NVRAM_SET_CACHELINESZ(c)	ISPBSMX(c, 70, 5, 0x01)
   1101        1.7  mjacob 
   1102       1.14  mjacob #define	ISP2100_NVRAM_BOOT_NODE_NAME(c)	(\
   1103  1.30.32.1     mjf 		(((uint64_t)(c)[72]) << 56) | \
   1104  1.30.32.1     mjf 		(((uint64_t)(c)[73]) << 48) | \
   1105  1.30.32.1     mjf 		(((uint64_t)(c)[74]) << 40) | \
   1106  1.30.32.1     mjf 		(((uint64_t)(c)[75]) << 32) | \
   1107  1.30.32.1     mjf 		(((uint64_t)(c)[76]) << 24) | \
   1108  1.30.32.1     mjf 		(((uint64_t)(c)[77]) << 16) | \
   1109  1.30.32.1     mjf 		(((uint64_t)(c)[78]) <<  8) | \
   1110  1.30.32.1     mjf 		(((uint64_t)(c)[79]) <<  0))
   1111       1.12  mjacob 
   1112        1.7  mjacob #define	ISP2100_NVRAM_BOOT_LUN(c)		(c)[80]
   1113  1.30.32.1     mjf #define	ISP2100_RESET_DELAY(c)			(c)[81]
   1114        1.7  mjacob 
   1115  1.30.32.1     mjf #define	ISP2100_HBA_FEATURES(c)			((c)[232] | ((c)[233] << 8))
   1116  1.30.32.1     mjf 
   1117  1.30.32.1     mjf /*
   1118  1.30.32.1     mjf  * Qlogic 2400 NVRAM is an array of 512 bytes with a 32 bit checksum.
   1119  1.30.32.1     mjf  */
   1120  1.30.32.1     mjf #define	ISP2400_NVRAM_PORT0_ADDR	0x80
   1121  1.30.32.1     mjf #define	ISP2400_NVRAM_PORT1_ADDR	0x180
   1122  1.30.32.1     mjf #define	ISP2400_NVRAM_SIZE		512
   1123  1.30.32.1     mjf 
   1124  1.30.32.1     mjf #define	ISP2400_NVRAM_VERSION(c)		((c)[4] | ((c)[5] << 8))
   1125  1.30.32.1     mjf #define	ISP2400_NVRAM_MAXFRAMELENGTH(c)		(((c)[12]) | ((c)[13] << 8))
   1126  1.30.32.1     mjf #define	ISP2400_NVRAM_EXECUTION_THROTTLE(c)	(((c)[14]) | ((c)[15] << 8))
   1127  1.30.32.1     mjf #define	ISP2400_NVRAM_EXCHANGE_COUNT(c)		(((c)[16]) | ((c)[17] << 8))
   1128  1.30.32.1     mjf #define	ISP2400_NVRAM_HARDLOOPID(c)		((c)[18] | ((c)[19] << 8))
   1129  1.30.32.1     mjf 
   1130  1.30.32.1     mjf #define	ISP2400_NVRAM_PORT_NAME(c)	(\
   1131  1.30.32.1     mjf 		(((uint64_t)(c)[20]) << 56) | \
   1132  1.30.32.1     mjf 		(((uint64_t)(c)[21]) << 48) | \
   1133  1.30.32.1     mjf 		(((uint64_t)(c)[22]) << 40) | \
   1134  1.30.32.1     mjf 		(((uint64_t)(c)[23]) << 32) | \
   1135  1.30.32.1     mjf 		(((uint64_t)(c)[24]) << 24) | \
   1136  1.30.32.1     mjf 		(((uint64_t)(c)[25]) << 16) | \
   1137  1.30.32.1     mjf 		(((uint64_t)(c)[26]) <<  8) | \
   1138  1.30.32.1     mjf 		(((uint64_t)(c)[27]) <<  0))
   1139  1.30.32.1     mjf 
   1140  1.30.32.1     mjf #define	ISP2400_NVRAM_NODE_NAME(c)	(\
   1141  1.30.32.1     mjf 		(((uint64_t)(c)[28]) << 56) | \
   1142  1.30.32.1     mjf 		(((uint64_t)(c)[29]) << 48) | \
   1143  1.30.32.1     mjf 		(((uint64_t)(c)[30]) << 40) | \
   1144  1.30.32.1     mjf 		(((uint64_t)(c)[31]) << 32) | \
   1145  1.30.32.1     mjf 		(((uint64_t)(c)[32]) << 24) | \
   1146  1.30.32.1     mjf 		(((uint64_t)(c)[33]) << 16) | \
   1147  1.30.32.1     mjf 		(((uint64_t)(c)[34]) <<  8) | \
   1148  1.30.32.1     mjf 		(((uint64_t)(c)[35]) <<  0))
   1149  1.30.32.1     mjf 
   1150  1.30.32.1     mjf #define	ISP2400_NVRAM_LOGIN_RETRY_CNT(c)	((c)[36] | ((c)[37] << 8))
   1151  1.30.32.1     mjf #define	ISP2400_NVRAM_LINK_DOWN_ON_NOS(c)	((c)[38] | ((c)[39] << 8))
   1152  1.30.32.1     mjf #define	ISP2400_NVRAM_INTERRUPT_DELAY(c)	((c)[40] | ((c)[41] << 8))
   1153  1.30.32.1     mjf #define	ISP2400_NVRAM_LOGIN_TIMEOUT(c)		((c)[42] | ((c)[43] << 8))
   1154  1.30.32.1     mjf 
   1155  1.30.32.1     mjf #define	ISP2400_NVRAM_FIRMWARE_OPTIONS1(c)	\
   1156  1.30.32.1     mjf 	((c)[44] | ((c)[45] << 8) | ((c)[46] << 16) | ((c)[47] << 24))
   1157  1.30.32.1     mjf #define	ISP2400_NVRAM_FIRMWARE_OPTIONS2(c)	\
   1158  1.30.32.1     mjf 	((c)[48] | ((c)[49] << 8) | ((c)[50] << 16) | ((c)[51] << 24))
   1159  1.30.32.1     mjf #define	ISP2400_NVRAM_FIRMWARE_OPTIONS3(c)	\
   1160  1.30.32.1     mjf 	((c)[52] | ((c)[53] << 8) | ((c)[54] << 16) | ((c)[55] << 24))
   1161       1.27  mjacob 
   1162       1.27  mjacob /*
   1163       1.27  mjacob  * Firmware Crash Dump
   1164       1.27  mjacob  *
   1165       1.27  mjacob  * QLogic needs specific information format when they look at firmware crashes.
   1166       1.27  mjacob  *
   1167       1.27  mjacob  * This is incredibly kernel memory consumptive (to say the least), so this
   1168       1.27  mjacob  * code is only compiled in when needed.
   1169       1.27  mjacob  */
   1170       1.27  mjacob 
   1171       1.27  mjacob #define	QLA2200_RISC_IMAGE_DUMP_SIZE					\
   1172  1.30.32.1     mjf 	(1 * sizeof (uint16_t)) +	/* 'used' flag (also HBA type) */ \
   1173  1.30.32.1     mjf 	(352 * sizeof (uint16_t)) +	/* RISC registers */		\
   1174  1.30.32.1     mjf  	(61440 * sizeof (uint16_t))	/* RISC SRAM (offset 0x1000..0xffff) */
   1175       1.27  mjacob #define	QLA2300_RISC_IMAGE_DUMP_SIZE					\
   1176  1.30.32.1     mjf 	(1 * sizeof (uint16_t)) +	/* 'used' flag (also HBA type) */ \
   1177  1.30.32.1     mjf 	(464 * sizeof (uint16_t)) +	/* RISC registers */		\
   1178  1.30.32.1     mjf  	(63488 * sizeof (uint16_t)) +	/* RISC SRAM (0x0800..0xffff) */ \
   1179  1.30.32.1     mjf 	(4096 * sizeof (uint16_t)) +	/* RISC SRAM (0x10000..0x10FFF) */ \
   1180  1.30.32.1     mjf 	(61440 * sizeof (uint16_t))	/* RISC SRAM (0x11000..0x1FFFF) */
   1181       1.27  mjacob /* the larger of the two */
   1182       1.27  mjacob #define	ISP_CRASH_IMAGE_SIZE	QLA2300_RISC_IMAGE_DUMP_SIZE
   1183        1.1     cgd #endif	/* _ISPREG_H */
   1184