xref: /freebsd/sys/dev/isp/ispreg.h (revision 10365e5a68725142a2a7effaec46ca1d8f5b273a)
1c3aac50fSPeter Wemm /* $FreeBSD$ */
2098ca2bdSWarner Losh /*-
36054c3f6SMatt Jacob  * Machine Independent (well, as best as possible) register
46054c3f6SMatt Jacob  * definitions for Qlogic ISP SCSI adapters.
56054c3f6SMatt Jacob  *
6e5265237SMatt Jacob  * Copyright (c) 1997-2006 by Matthew Jacob
76054c3f6SMatt Jacob  * All rights reserved.
84394c92fSMatt Jacob  *
96054c3f6SMatt Jacob  * Redistribution and use in source and binary forms, with or without
106054c3f6SMatt Jacob  * modification, are permitted provided that the following conditions
116054c3f6SMatt Jacob  * are met:
126054c3f6SMatt Jacob  * 1. Redistributions of source code must retain the above copyright
136054c3f6SMatt Jacob  *    notice immediately at the beginning of the file, without modification,
146054c3f6SMatt Jacob  *    this list of conditions, and the following disclaimer.
15aa57fd6fSMatt Jacob  * 2. The name of the author may not be used to endorse or promote products
166054c3f6SMatt Jacob  *    derived from this software without specific prior written permission.
176054c3f6SMatt Jacob  *
186054c3f6SMatt Jacob  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
196054c3f6SMatt Jacob  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
206054c3f6SMatt Jacob  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
216054c3f6SMatt Jacob  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
226054c3f6SMatt Jacob  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
236054c3f6SMatt Jacob  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
246054c3f6SMatt Jacob  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
256054c3f6SMatt Jacob  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
266054c3f6SMatt Jacob  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
276054c3f6SMatt Jacob  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
286054c3f6SMatt Jacob  * SUCH DAMAGE.
296054c3f6SMatt Jacob  */
306054c3f6SMatt Jacob #ifndef	_ISPREG_H
316054c3f6SMatt Jacob #define	_ISPREG_H
326054c3f6SMatt Jacob 
336054c3f6SMatt Jacob /*
346054c3f6SMatt Jacob  * Hardware definitions for the Qlogic ISP  registers.
356054c3f6SMatt Jacob  */
366054c3f6SMatt Jacob 
376054c3f6SMatt Jacob /*
386054c3f6SMatt Jacob  * This defines types of access to various registers.
396054c3f6SMatt Jacob  *
406054c3f6SMatt Jacob  *  	R:		Read Only
416054c3f6SMatt Jacob  *	W:		Write Only
426054c3f6SMatt Jacob  *	RW:		Read/Write
436054c3f6SMatt Jacob  *
446054c3f6SMatt Jacob  *	R*, W*, RW*:	Read Only, Write Only, Read/Write, but only
456054c3f6SMatt Jacob  *			if RISC processor in ISP is paused.
466054c3f6SMatt Jacob  */
476054c3f6SMatt Jacob 
486054c3f6SMatt Jacob /*
496054c3f6SMatt Jacob  * Offsets for various register blocks.
506054c3f6SMatt Jacob  *
516054c3f6SMatt Jacob  * Sad but true, different architectures have different offsets.
52981e6b25SMatt Jacob  *
53981e6b25SMatt Jacob  * Don't be alarmed if none of this makes sense. The original register
54981e6b25SMatt Jacob  * layout set some defines in a certain pattern. Everything else has been
55981e6b25SMatt Jacob  * grafted on since. For example, the ISP1080 manual will state that DMA
56981e6b25SMatt Jacob  * registers start at 0x80 from the base of the register address space.
57981e6b25SMatt Jacob  * That's true, but for our purposes, we define DMA_REGS_OFF for the 1080
58981e6b25SMatt Jacob  * to start at offset 0x60 because the DMA registers are all defined to
59981e6b25SMatt Jacob  * be DMA_BLOCK+0x20 and so on. Clear?
606054c3f6SMatt Jacob  */
616054c3f6SMatt Jacob 
626054c3f6SMatt Jacob #define	BIU_REGS_OFF			0x00
636054c3f6SMatt Jacob 
646054c3f6SMatt Jacob #define	PCI_MBOX_REGS_OFF		0x70
656054c3f6SMatt Jacob #define	PCI_MBOX_REGS2100_OFF		0x10
66126ec864SMatt Jacob #define	PCI_MBOX_REGS2300_OFF		0x40
6710365e5aSMatt Jacob #define	PCI_MBOX_REGS2400_OFF		0x80
686054c3f6SMatt Jacob #define	SBUS_MBOX_REGS_OFF		0x80
696054c3f6SMatt Jacob 
706054c3f6SMatt Jacob #define	PCI_SXP_REGS_OFF		0x80
716054c3f6SMatt Jacob #define	SBUS_SXP_REGS_OFF		0x200
726054c3f6SMatt Jacob 
736054c3f6SMatt Jacob #define	PCI_RISC_REGS_OFF		0x80
746054c3f6SMatt Jacob #define	SBUS_RISC_REGS_OFF		0x400
756054c3f6SMatt Jacob 
7657c801f5SMatt Jacob /* Bless me! Chip designers have putzed it again! */
7757c801f5SMatt Jacob #define	ISP1080_DMA_REGS_OFF		0x60
7857c801f5SMatt Jacob #define	DMA_REGS_OFF			0x00	/* same as BIU block */
7957c801f5SMatt Jacob 
80a6db0ba6SMatt Jacob #define	SBUS_REGSIZE			0x450
81a6db0ba6SMatt Jacob #define	PCI_REGSIZE			0x100
82a6db0ba6SMatt Jacob 
836054c3f6SMatt Jacob /*
846054c3f6SMatt Jacob  * NB:	The *_BLOCK definitions have no specific hardware meaning.
856054c3f6SMatt Jacob  *	They serve simply to note to the MD layer which block of
866054c3f6SMatt Jacob  *	registers offsets are being accessed.
876054c3f6SMatt Jacob  */
8857c801f5SMatt Jacob #define	_NREG_BLKS	5
8957c801f5SMatt Jacob #define	_BLK_REG_SHFT	13
9057c801f5SMatt Jacob #define	_BLK_REG_MASK	(7 << _BLK_REG_SHFT)
9157c801f5SMatt Jacob #define	BIU_BLOCK	(0 << _BLK_REG_SHFT)
9257c801f5SMatt Jacob #define	MBOX_BLOCK	(1 << _BLK_REG_SHFT)
9357c801f5SMatt Jacob #define	SXP_BLOCK	(2 << _BLK_REG_SHFT)
9457c801f5SMatt Jacob #define	RISC_BLOCK	(3 << _BLK_REG_SHFT)
9557c801f5SMatt Jacob #define	DMA_BLOCK	(4 << _BLK_REG_SHFT)
966054c3f6SMatt Jacob 
976054c3f6SMatt Jacob /*
986054c3f6SMatt Jacob  * Bus Interface Block Register Offsets
996054c3f6SMatt Jacob  */
10057c801f5SMatt Jacob 
10122e1dc85SMatt Jacob #define	BIU_ID_LO	(BIU_BLOCK+0x0)		/* R  : Bus ID, Low */
10222e1dc85SMatt Jacob #define		BIU2100_FLASH_ADDR	(BIU_BLOCK+0x0)
10322e1dc85SMatt Jacob #define	BIU_ID_HI	(BIU_BLOCK+0x2)		/* R  : Bus ID, High */
10422e1dc85SMatt Jacob #define		BIU2100_FLASH_DATA	(BIU_BLOCK+0x2)
10522e1dc85SMatt Jacob #define	BIU_CONF0	(BIU_BLOCK+0x4)		/* R  : Bus Configuration #0 */
10622e1dc85SMatt Jacob #define	BIU_CONF1	(BIU_BLOCK+0x6)		/* R  : Bus Configuration #1 */
10722e1dc85SMatt Jacob #define		BIU2100_CSR		(BIU_BLOCK+0x6)
10822e1dc85SMatt Jacob #define	BIU_ICR		(BIU_BLOCK+0x8)		/* RW : Bus Interface Ctrl */
10922e1dc85SMatt Jacob #define	BIU_ISR		(BIU_BLOCK+0xA)		/* R  : Bus Interface Status */
11022e1dc85SMatt Jacob #define	BIU_SEMA	(BIU_BLOCK+0xC)		/* RW : Bus Semaphore */
11122e1dc85SMatt Jacob #define	BIU_NVRAM	(BIU_BLOCK+0xE)		/* RW : Bus NVRAM */
112126ec864SMatt Jacob /*
113126ec864SMatt Jacob  * These are specific to the 2300.
114126ec864SMatt Jacob  */
115126ec864SMatt Jacob #define	BIU_REQINP	(BIU_BLOCK+0x10)	/* Request Queue In */
116126ec864SMatt Jacob #define	BIU_REQOUTP	(BIU_BLOCK+0x12)	/* Request Queue Out */
117126ec864SMatt Jacob #define	BIU_RSPINP	(BIU_BLOCK+0x14)	/* Response Queue In */
118126ec864SMatt Jacob #define	BIU_RSPOUTP	(BIU_BLOCK+0x16)	/* Response Queue Out */
119126ec864SMatt Jacob 
120126ec864SMatt Jacob #define	BIU_R2HSTSLO	(BIU_BLOCK+0x18)
121126ec864SMatt Jacob #define	BIU_R2HSTSHI	(BIU_BLOCK+0x1A)
122126ec864SMatt Jacob 
123126ec864SMatt Jacob #define	BIU_R2HST_INTR		(1 << 15)	/* RISC to Host Interrupt */
124126ec864SMatt Jacob #define	BIU_R2HST_PAUSED	(1 <<  8)	/* RISC paused */
125126ec864SMatt Jacob #define	BIU_R2HST_ISTAT_MASK	0x3f		/* intr information && status */
126126ec864SMatt Jacob #define		ISPR2HST_ROM_MBX_OK	0x1	/* ROM mailbox cmd done ok */
127126ec864SMatt Jacob #define		ISPR2HST_ROM_MBX_FAIL	0x2	/* ROM mailbox cmd done fail */
128126ec864SMatt Jacob #define		ISPR2HST_MBX_OK		0x10	/* mailbox cmd done ok */
129126ec864SMatt Jacob #define		ISPR2HST_MBX_FAIL	0x11	/* mailbox cmd done fail */
130126ec864SMatt Jacob #define		ISPR2HST_ASYNC_EVENT	0x12	/* Async Event */
131126ec864SMatt Jacob #define		ISPR2HST_RSPQ_UPDATE	0x13	/* Response Queue Update */
132126ec864SMatt Jacob #define		ISPR2HST_RQST_UPDATE	0x14	/* Resquest Queue Update */
133126ec864SMatt Jacob #define		ISPR2HST_RIO_16		0x15	/* RIO 1-16 */
134126ec864SMatt Jacob #define		ISPR2HST_FPOST		0x16	/* Low 16 bits fast post */
135126ec864SMatt Jacob #define		ISPR2HST_FPOST_CTIO	0x17	/* Low 16 bits fast post ctio */
136126ec864SMatt Jacob 
13710365e5aSMatt Jacob /* fifo command stuff- mostly for SPI */
13822e1dc85SMatt Jacob #define	DFIFO_COMMAND	(BIU_BLOCK+0x60)	/* RW : Command FIFO Port */
1396054c3f6SMatt Jacob #define		RDMA2100_CONTROL	DFIFO_COMMAND
14022e1dc85SMatt Jacob #define	DFIFO_DATA	(BIU_BLOCK+0x62)	/* RW : Data FIFO Port */
1416054c3f6SMatt Jacob 
1426054c3f6SMatt Jacob /*
14357c801f5SMatt Jacob  * Putzed DMA register layouts.
14457c801f5SMatt Jacob  */
14522e1dc85SMatt Jacob #define	CDMA_CONF	(DMA_BLOCK+0x20)	/* RW*: DMA Configuration */
14657c801f5SMatt Jacob #define		CDMA2100_CONTROL	CDMA_CONF
14722e1dc85SMatt Jacob #define	CDMA_CONTROL	(DMA_BLOCK+0x22)	/* RW*: DMA Control */
14822e1dc85SMatt Jacob #define	CDMA_STATUS 	(DMA_BLOCK+0x24)	/* R  : DMA Status */
14922e1dc85SMatt Jacob #define	CDMA_FIFO_STS	(DMA_BLOCK+0x26)	/* R  : DMA FIFO Status */
15022e1dc85SMatt Jacob #define	CDMA_COUNT	(DMA_BLOCK+0x28)	/* RW*: DMA Transfer Count */
15122e1dc85SMatt Jacob #define	CDMA_ADDR0	(DMA_BLOCK+0x2C)	/* RW*: DMA Address, Word 0 */
15222e1dc85SMatt Jacob #define	CDMA_ADDR1	(DMA_BLOCK+0x2E)	/* RW*: DMA Address, Word 1 */
15322e1dc85SMatt Jacob #define	CDMA_ADDR2	(DMA_BLOCK+0x30)	/* RW*: DMA Address, Word 2 */
15422e1dc85SMatt Jacob #define	CDMA_ADDR3	(DMA_BLOCK+0x32)	/* RW*: DMA Address, Word 3 */
15557c801f5SMatt Jacob 
15622e1dc85SMatt Jacob #define	DDMA_CONF	(DMA_BLOCK+0x40)	/* RW*: DMA Configuration */
15757c801f5SMatt Jacob #define		TDMA2100_CONTROL	DDMA_CONF
15822e1dc85SMatt Jacob #define	DDMA_CONTROL	(DMA_BLOCK+0x42)	/* RW*: DMA Control */
15922e1dc85SMatt Jacob #define	DDMA_STATUS	(DMA_BLOCK+0x44)	/* R  : DMA Status */
16022e1dc85SMatt Jacob #define	DDMA_FIFO_STS	(DMA_BLOCK+0x46)	/* R  : DMA FIFO Status */
16122e1dc85SMatt Jacob #define	DDMA_COUNT_LO	(DMA_BLOCK+0x48)	/* RW*: DMA Xfer Count, Low */
16222e1dc85SMatt Jacob #define	DDMA_COUNT_HI	(DMA_BLOCK+0x4A)	/* RW*: DMA Xfer Count, High */
16322e1dc85SMatt Jacob #define	DDMA_ADDR0	(DMA_BLOCK+0x4C)	/* RW*: DMA Address, Word 0 */
16422e1dc85SMatt Jacob #define	DDMA_ADDR1	(DMA_BLOCK+0x4E)	/* RW*: DMA Address, Word 1 */
16557c801f5SMatt Jacob /* these are for the 1040A cards */
16622e1dc85SMatt Jacob #define	DDMA_ADDR2	(DMA_BLOCK+0x50)	/* RW*: DMA Address, Word 2 */
16722e1dc85SMatt Jacob #define	DDMA_ADDR3	(DMA_BLOCK+0x52)	/* RW*: DMA Address, Word 3 */
16857c801f5SMatt Jacob 
16957c801f5SMatt Jacob 
17057c801f5SMatt Jacob /*
1716054c3f6SMatt Jacob  * Bus Interface Block Register Definitions
1726054c3f6SMatt Jacob  */
1736054c3f6SMatt Jacob /* BUS CONFIGURATION REGISTER #0 */
1746054c3f6SMatt Jacob #define	BIU_CONF0_HW_MASK		0x000F	/* Hardware revision mask */
1756054c3f6SMatt Jacob /* BUS CONFIGURATION REGISTER #1 */
1766054c3f6SMatt Jacob 
1776054c3f6SMatt Jacob #define	BIU_SBUS_CONF1_PARITY		0x0100 	/* Enable parity checking */
1786054c3f6SMatt Jacob #define	BIU_SBUS_CONF1_FCODE_MASK	0x00F0	/* Fcode cycle mask */
1796054c3f6SMatt Jacob 
1806054c3f6SMatt Jacob #define	BIU_PCI_CONF1_FIFO_128		0x0040	/* 128 bytes FIFO threshold */
1816054c3f6SMatt Jacob #define	BIU_PCI_CONF1_FIFO_64		0x0030	/* 64 bytes FIFO threshold */
1826054c3f6SMatt Jacob #define	BIU_PCI_CONF1_FIFO_32		0x0020	/* 32 bytes FIFO threshold */
1836054c3f6SMatt Jacob #define	BIU_PCI_CONF1_FIFO_16		0x0010	/* 16 bytes FIFO threshold */
1846054c3f6SMatt Jacob #define	BIU_BURST_ENABLE		0x0004	/* Global enable Bus bursts */
1856054c3f6SMatt Jacob #define	BIU_SBUS_CONF1_FIFO_64		0x0003	/* 64 bytes FIFO threshold */
1866054c3f6SMatt Jacob #define	BIU_SBUS_CONF1_FIFO_32		0x0002	/* 32 bytes FIFO threshold */
1876054c3f6SMatt Jacob #define	BIU_SBUS_CONF1_FIFO_16		0x0001	/* 16 bytes FIFO threshold */
1886054c3f6SMatt Jacob #define	BIU_SBUS_CONF1_FIFO_8		0x0000	/* 8 bytes FIFO threshold */
1896054c3f6SMatt Jacob #define	BIU_SBUS_CONF1_BURST8		0x0008 	/* Enable 8-byte  bursts */
1906054c3f6SMatt Jacob #define	BIU_PCI_CONF1_SXP		0x0008	/* SXP register select */
1916054c3f6SMatt Jacob 
19222e1dc85SMatt Jacob #define	BIU_PCI1080_CONF1_SXP0		0x0100	/* SXP bank #1 select */
19322e1dc85SMatt Jacob #define	BIU_PCI1080_CONF1_SXP1		0x0200	/* SXP bank #2 select */
19457c801f5SMatt Jacob #define	BIU_PCI1080_CONF1_DMA		0x0300	/* DMA bank select */
19557c801f5SMatt Jacob 
1966054c3f6SMatt Jacob /* ISP2100 Bus Control/Status Register */
1976054c3f6SMatt Jacob 
1986054c3f6SMatt Jacob #define	BIU2100_ICSR_REGBSEL		0x30	/* RW: register bank select */
1996054c3f6SMatt Jacob #define		BIU2100_RISC_REGS	(0 << 4)	/* RISC Regs */
2006054c3f6SMatt Jacob #define		BIU2100_FB_REGS		(1 << 4)	/* FrameBuffer Regs */
2016054c3f6SMatt Jacob #define		BIU2100_FPM0_REGS	(2 << 4)	/* FPM 0 Regs */
2026054c3f6SMatt Jacob #define		BIU2100_FPM1_REGS	(3 << 4)	/* FPM 1 Regs */
2038a97c03aSMatt Jacob #define	BIU2100_NVRAM_OFFSET		(1 << 14)
2048a97c03aSMatt Jacob #define	BIU2100_FLASH_UPPER_64K		0x04	/* RW: Upper 64K Bank Select */
2056054c3f6SMatt Jacob #define	BIU2100_FLASH_ENABLE		0x02	/* RW: Enable Flash RAM */
2066054c3f6SMatt Jacob #define	BIU2100_SOFT_RESET		0x01
2076054c3f6SMatt Jacob /* SOFT RESET FOR ISP2100 is same bit, but in this register, not ICR */
2086054c3f6SMatt Jacob 
2096054c3f6SMatt Jacob 
2106054c3f6SMatt Jacob /* BUS CONTROL REGISTER */
2116054c3f6SMatt Jacob #define	BIU_ICR_ENABLE_DMA_INT		0x0020	/* Enable DMA interrupts */
2126054c3f6SMatt Jacob #define	BIU_ICR_ENABLE_CDMA_INT		0x0010	/* Enable CDMA interrupts */
2136054c3f6SMatt Jacob #define	BIU_ICR_ENABLE_SXP_INT		0x0008	/* Enable SXP interrupts */
2146054c3f6SMatt Jacob #define	BIU_ICR_ENABLE_RISC_INT		0x0004	/* Enable Risc interrupts */
2156054c3f6SMatt Jacob #define	BIU_ICR_ENABLE_ALL_INTS		0x0002	/* Global enable all inter */
2166054c3f6SMatt Jacob #define	BIU_ICR_SOFT_RESET		0x0001	/* Soft Reset of ISP */
2176054c3f6SMatt Jacob 
21810365e5aSMatt Jacob #define	BIU_IMASK	(BIU_ICR_ENABLE_RISC_INT|BIU_ICR_ENABLE_ALL_INTS)
21910365e5aSMatt Jacob 
2206054c3f6SMatt Jacob #define	BIU2100_ICR_ENABLE_ALL_INTS	0x8000
2216054c3f6SMatt Jacob #define	BIU2100_ICR_ENA_FPM_INT		0x0020
2226054c3f6SMatt Jacob #define	BIU2100_ICR_ENA_FB_INT		0x0010
2236054c3f6SMatt Jacob #define	BIU2100_ICR_ENA_RISC_INT	0x0008
2246054c3f6SMatt Jacob #define	BIU2100_ICR_ENA_CDMA_INT	0x0004
2256054c3f6SMatt Jacob #define	BIU2100_ICR_ENABLE_RXDMA_INT	0x0002
2266054c3f6SMatt Jacob #define	BIU2100_ICR_ENABLE_TXDMA_INT	0x0001
2276054c3f6SMatt Jacob #define	BIU2100_ICR_DISABLE_ALL_INTS	0x0000
2286054c3f6SMatt Jacob 
22910365e5aSMatt Jacob #define	BIU2100_IMASK	(BIU2100_ICR_ENA_RISC_INT|BIU2100_ICR_ENABLE_ALL_INTS)
2306054c3f6SMatt Jacob 
2316054c3f6SMatt Jacob /* BUS STATUS REGISTER */
2326054c3f6SMatt Jacob #define	BIU_ISR_DMA_INT			0x0020	/* DMA interrupt pending */
2336054c3f6SMatt Jacob #define	BIU_ISR_CDMA_INT		0x0010	/* CDMA interrupt pending */
2346054c3f6SMatt Jacob #define	BIU_ISR_SXP_INT			0x0008	/* SXP interrupt pending */
2356054c3f6SMatt Jacob #define	BIU_ISR_RISC_INT		0x0004	/* Risc interrupt pending */
2366054c3f6SMatt Jacob #define	BIU_ISR_IPEND			0x0002	/* Global interrupt pending */
2376054c3f6SMatt Jacob 
2386054c3f6SMatt Jacob #define	BIU2100_ISR_INT_PENDING		0x8000	/* Global interrupt pending */
2396054c3f6SMatt Jacob #define	BIU2100_ISR_FPM_INT		0x0020	/* FPM interrupt pending */
2406054c3f6SMatt Jacob #define	BIU2100_ISR_FB_INT		0x0010	/* FB interrupt pending */
2416054c3f6SMatt Jacob #define	BIU2100_ISR_RISC_INT		0x0008	/* Risc interrupt pending */
2426054c3f6SMatt Jacob #define	BIU2100_ISR_CDMA_INT		0x0004	/* CDMA interrupt pending */
2436054c3f6SMatt Jacob #define	BIU2100_ISR_RXDMA_INT_PENDING	0x0002	/* Global interrupt pending */
2446054c3f6SMatt Jacob #define	BIU2100_ISR_TXDMA_INT_PENDING	0x0001	/* Global interrupt pending */
2456054c3f6SMatt Jacob 
24610365e5aSMatt Jacob #define	INT_PENDING(isp, isr)						\
24710365e5aSMatt Jacob  IS_FC(isp)?								\
24810365e5aSMatt Jacob   (IS_24XX(isp)? (isr & BIU2400_ISR_RISC_INT) : (isr & BIU2100_ISR_RISC_INT)) :\
24910365e5aSMatt Jacob   (isr & BIU_ISR_RISC_INT)
2506054c3f6SMatt Jacob 
25140e88de6SMatt Jacob #define	INT_PENDING_MASK(isp)	\
25210365e5aSMatt Jacob  (IS_FC(isp)? (IS_24XX(isp)? BIU2400_ISR_RISC_INT : BIU2100_ISR_RISC_INT) : \
25310365e5aSMatt Jacob  (BIU_ISR_RISC_INT))
25440e88de6SMatt Jacob 
2556054c3f6SMatt Jacob /* BUS SEMAPHORE REGISTER */
2566054c3f6SMatt Jacob #define	BIU_SEMA_STATUS		0x0002	/* Semaphore Status Bit */
2576054c3f6SMatt Jacob #define	BIU_SEMA_LOCK  		0x0001	/* Semaphore Lock Bit */
2586054c3f6SMatt Jacob 
259478f8a96SJustin T. Gibbs /* NVRAM SEMAPHORE REGISTER */
260478f8a96SJustin T. Gibbs #define	BIU_NVRAM_CLOCK		0x0001
261478f8a96SJustin T. Gibbs #define	BIU_NVRAM_SELECT	0x0002
262478f8a96SJustin T. Gibbs #define	BIU_NVRAM_DATAOUT	0x0004
263478f8a96SJustin T. Gibbs #define	BIU_NVRAM_DATAIN	0x0008
2648a97c03aSMatt Jacob #define	BIU_NVRAM_BUSY		0x0080	/* 2322/24xx only */
265478f8a96SJustin T. Gibbs #define		ISP_NVRAM_READ		6
2666054c3f6SMatt Jacob 
2676054c3f6SMatt Jacob /* COMNMAND && DATA DMA CONFIGURATION REGISTER */
2686054c3f6SMatt Jacob #define	DMA_ENABLE_SXP_DMA		0x0008	/* Enable SXP to DMA Data */
2696054c3f6SMatt Jacob #define	DMA_ENABLE_INTS			0x0004	/* Enable interrupts to RISC */
2706054c3f6SMatt Jacob #define	DMA_ENABLE_BURST		0x0002	/* Enable Bus burst trans */
2716054c3f6SMatt Jacob #define	DMA_DMA_DIRECTION		0x0001	/*
2726054c3f6SMatt Jacob 						 * Set DMA direction:
2736054c3f6SMatt Jacob 						 *	0 - DMA FIFO to host
2746054c3f6SMatt Jacob 						 *	1 - Host to DMA FIFO
2756054c3f6SMatt Jacob 						 */
2766054c3f6SMatt Jacob 
2776054c3f6SMatt Jacob /* COMMAND && DATA DMA CONTROL REGISTER */
2786054c3f6SMatt Jacob #define	DMA_CNTRL_SUSPEND_CHAN		0x0010	/* Suspend DMA transfer */
2796054c3f6SMatt Jacob #define	DMA_CNTRL_CLEAR_CHAN		0x0008	/*
2806054c3f6SMatt Jacob 						 * Clear FIFO and DMA Channel,
2816054c3f6SMatt Jacob 						 * reset DMA registers
2826054c3f6SMatt Jacob 						 */
2836054c3f6SMatt Jacob #define	DMA_CNTRL_CLEAR_FIFO		0x0004	/* Clear DMA FIFO */
2846054c3f6SMatt Jacob #define	DMA_CNTRL_RESET_INT		0x0002	/* Clear DMA interrupt */
2856054c3f6SMatt Jacob #define	DMA_CNTRL_STROBE		0x0001	/* Start DMA transfer */
2866054c3f6SMatt Jacob 
2876054c3f6SMatt Jacob /*
2886054c3f6SMatt Jacob  * Variants of same for 2100
2896054c3f6SMatt Jacob  */
2906054c3f6SMatt Jacob #define	DMA_CNTRL2100_CLEAR_CHAN	0x0004
2916054c3f6SMatt Jacob #define	DMA_CNTRL2100_RESET_INT		0x0002
2926054c3f6SMatt Jacob 
2936054c3f6SMatt Jacob 
2946054c3f6SMatt Jacob 
2956054c3f6SMatt Jacob /* DMA STATUS REGISTER */
2966054c3f6SMatt Jacob #define	DMA_SBUS_STATUS_PIPE_MASK	0x00C0	/* DMA Pipeline status mask */
2976054c3f6SMatt Jacob #define	DMA_SBUS_STATUS_CHAN_MASK	0x0030	/* Channel status mask */
2986054c3f6SMatt Jacob #define	DMA_SBUS_STATUS_BUS_PARITY	0x0008	/* Parity Error on bus */
2996054c3f6SMatt Jacob #define	DMA_SBUS_STATUS_BUS_ERR		0x0004	/* Error Detected on bus */
3006054c3f6SMatt Jacob #define	DMA_SBUS_STATUS_TERM_COUNT	0x0002	/* DMA Transfer Completed */
3016054c3f6SMatt Jacob #define	DMA_SBUS_STATUS_INTERRUPT	0x0001	/* Enable DMA channel inter */
3026054c3f6SMatt Jacob 
3036054c3f6SMatt Jacob #define	DMA_PCI_STATUS_INTERRUPT	0x8000	/* Enable DMA channel inter */
3046054c3f6SMatt Jacob #define	DMA_PCI_STATUS_RETRY_STAT	0x4000	/* Retry status */
3056054c3f6SMatt Jacob #define	DMA_PCI_STATUS_CHAN_MASK	0x3000	/* Channel status mask */
3066054c3f6SMatt Jacob #define	DMA_PCI_STATUS_FIFO_OVR		0x0100	/* DMA FIFO overrun cond */
3076054c3f6SMatt Jacob #define	DMA_PCI_STATUS_FIFO_UDR		0x0080	/* DMA FIFO underrun cond */
3086054c3f6SMatt Jacob #define	DMA_PCI_STATUS_BUS_ERR		0x0040	/* Error Detected on bus */
3096054c3f6SMatt Jacob #define	DMA_PCI_STATUS_BUS_PARITY	0x0020	/* Parity Error on bus */
3106054c3f6SMatt Jacob #define	DMA_PCI_STATUS_CLR_PEND		0x0010	/* DMA clear pending */
3116054c3f6SMatt Jacob #define	DMA_PCI_STATUS_TERM_COUNT	0x0008	/* DMA Transfer Completed */
3126054c3f6SMatt Jacob #define	DMA_PCI_STATUS_DMA_SUSP		0x0004	/* DMA suspended */
3136054c3f6SMatt Jacob #define	DMA_PCI_STATUS_PIPE_MASK	0x0003	/* DMA Pipeline status mask */
3146054c3f6SMatt Jacob 
3156054c3f6SMatt Jacob /* DMA Status Register, pipeline status bits */
3166054c3f6SMatt Jacob #define	DMA_SBUS_PIPE_FULL		0x00C0	/* Both pipeline stages full */
3176054c3f6SMatt Jacob #define	DMA_SBUS_PIPE_OVERRUN		0x0080	/* Pipeline overrun */
3186054c3f6SMatt Jacob #define	DMA_SBUS_PIPE_STAGE1		0x0040	/*
3196054c3f6SMatt Jacob 						 * Pipeline stage 1 Loaded,
3206054c3f6SMatt Jacob 						 * stage 2 empty
3216054c3f6SMatt Jacob 						 */
3226054c3f6SMatt Jacob #define	DMA_PCI_PIPE_FULL		0x0003	/* Both pipeline stages full */
3236054c3f6SMatt Jacob #define	DMA_PCI_PIPE_OVERRUN		0x0002	/* Pipeline overrun */
3246054c3f6SMatt Jacob #define	DMA_PCI_PIPE_STAGE1		0x0001	/*
3256054c3f6SMatt Jacob 						 * Pipeline stage 1 Loaded,
3266054c3f6SMatt Jacob 						 * stage 2 empty
3276054c3f6SMatt Jacob 						 */
3286054c3f6SMatt Jacob #define	DMA_PIPE_EMPTY			0x0000	/* All pipeline stages empty */
3296054c3f6SMatt Jacob 
3306054c3f6SMatt Jacob /* DMA Status Register, channel status bits */
3316054c3f6SMatt Jacob #define	DMA_SBUS_CHAN_SUSPEND	0x0030	/* Channel error or suspended */
3326054c3f6SMatt Jacob #define	DMA_SBUS_CHAN_TRANSFER	0x0020	/* Chan transfer in progress */
3336054c3f6SMatt Jacob #define	DMA_SBUS_CHAN_ACTIVE	0x0010	/* Chan trans to host active */
3346054c3f6SMatt Jacob #define	DMA_PCI_CHAN_TRANSFER	0x3000	/* Chan transfer in progress */
3356054c3f6SMatt Jacob #define	DMA_PCI_CHAN_SUSPEND	0x2000	/* Channel error or suspended */
3366054c3f6SMatt Jacob #define	DMA_PCI_CHAN_ACTIVE	0x1000	/* Chan trans to host active */
3376054c3f6SMatt Jacob #define	ISP_DMA_CHAN_IDLE	0x0000	/* Chan idle (normal comp) */
3386054c3f6SMatt Jacob 
3396054c3f6SMatt Jacob 
3406054c3f6SMatt Jacob /* DMA FIFO STATUS REGISTER */
3416054c3f6SMatt Jacob #define	DMA_FIFO_STATUS_OVERRUN		0x0200	/* FIFO Overrun Condition */
3426054c3f6SMatt Jacob #define	DMA_FIFO_STATUS_UNDERRUN	0x0100	/* FIFO Underrun Condition */
3436054c3f6SMatt Jacob #define	DMA_FIFO_SBUS_COUNT_MASK	0x007F	/* FIFO Byte count mask */
3446054c3f6SMatt Jacob #define	DMA_FIFO_PCI_COUNT_MASK		0x00FF	/* FIFO Byte count mask */
3456054c3f6SMatt Jacob 
3466054c3f6SMatt Jacob /*
34710365e5aSMatt Jacob  * 2400 Interface Offsets and Register Definitions
34810365e5aSMatt Jacob  *
34910365e5aSMatt Jacob  * The 2400 looks quite different in terms of registers from other QLogic cards.
35010365e5aSMatt Jacob  * It is getting to be a genuine pain and challenge to keep the same model
35110365e5aSMatt Jacob  * for all.
35210365e5aSMatt Jacob  */
35310365e5aSMatt Jacob #define	BIU2400_FLASH_ADDR	(BIU_BLOCK+0x00)
35410365e5aSMatt Jacob #define	BIU2400_FLASH_DATA	(BIU_BLOCK+0x04)
35510365e5aSMatt Jacob #define	BIU2400_CSR		(BIU_BLOCK+0x08)
35610365e5aSMatt Jacob #define	BIU2400_ICR		(BIU_BLOCK+0x0C)
35710365e5aSMatt Jacob #define	BIU2400_ISR		(BIU_BLOCK+0x10)
35810365e5aSMatt Jacob 
35910365e5aSMatt Jacob #define	BIU2400_REQINP		(BIU_BLOCK+0x1C) /* Request Queue In */
36010365e5aSMatt Jacob #define	BIU2400_REQOUTP		(BIU_BLOCK+0x20) /* Request Queue Out */
36110365e5aSMatt Jacob #define	BIU2400_RSPINP		(BIU_BLOCK+0x24) /* Response Queue In */
36210365e5aSMatt Jacob #define	BIU2400_RSPOUTP		(BIU_BLOCK+0x28) /* Response Queue Out */
36310365e5aSMatt Jacob #define	BIU2400_PRI_RQINP 	(BIU_BLOCK+0x2C) /* Priority Request Q In */
36410365e5aSMatt Jacob #define	BIU2400_PRI_RSPINP 	(BIU_BLOCK+0x30) /* Priority Request Q Out */
36510365e5aSMatt Jacob 
36610365e5aSMatt Jacob #define	BIU2400_ATIO_RSPINP	(BIU_BLOCK+0x3C)	/* ATIO Queue In */
36710365e5aSMatt Jacob #define	BIU2400_ATIO_REQINP	(BIU_BLOCK+0x40)	/* ATIO Queue Out */
36810365e5aSMatt Jacob 
36910365e5aSMatt Jacob #define	BIU2400_R2HSTSLO	(BIU_BLOCK+0x44)
37010365e5aSMatt Jacob #define	BIU2400_R2HSTSHI	(BIU_BLOCK+0x46)
37110365e5aSMatt Jacob 
37210365e5aSMatt Jacob #define	BIU2400_HCCR		(BIU_BLOCK+0x48)
37310365e5aSMatt Jacob #define	BIU2400_GPIOD		(BIU_BLOCK+0x4C)
37410365e5aSMatt Jacob #define	BIU2400_GPIOE		(BIU_BLOCK+0x50)
37510365e5aSMatt Jacob #define	BIU2400_HSEMA		(BIU_BLOCK+0x58)
37610365e5aSMatt Jacob 
37710365e5aSMatt Jacob /* BIU2400_FLASH_ADDR definitions */
37810365e5aSMatt Jacob #define	BIU2400_FLASH_DFLAG	(1 << 30)
37910365e5aSMatt Jacob 
38010365e5aSMatt Jacob /* BIU2400_CSR definitions */
38110365e5aSMatt Jacob #define	BIU2400_NVERR		(1 << 18)
38210365e5aSMatt Jacob #define	BIU2400_DMA_ACTIVE	(1 << 17)		/* RO */
38310365e5aSMatt Jacob #define	BIU2400_DMA_STOP	(1 << 16)
38410365e5aSMatt Jacob #define	BIU2400_FUNCTION	(1 << 15)		/* RO */
38510365e5aSMatt Jacob #define	BIU2400_PCIX_MODE(x)	(((x) >> 8) & 0xf)	/* RO */
38610365e5aSMatt Jacob #define	BIU2400_CSR_64BIT	(1 << 2)		/* RO */
38710365e5aSMatt Jacob #define	BIU2400_FLASH_ENABLE	(1 << 1)
38810365e5aSMatt Jacob #define	BIU2400_SOFT_RESET	(1 << 0)
38910365e5aSMatt Jacob 
39010365e5aSMatt Jacob /* BIU2400_ICR definitions */
39110365e5aSMatt Jacob #define	BIU2400_ICR_ENA_RISC_INT	0x8
39210365e5aSMatt Jacob #define	BIU2400_IMASK			(BIU2400_ICR_ENA_RISC_INT)
39310365e5aSMatt Jacob 
39410365e5aSMatt Jacob /* BIU2400_ISR definitions */
39510365e5aSMatt Jacob #define	BIU2400_ISR_RISC_INT		0x8
39610365e5aSMatt Jacob 
39710365e5aSMatt Jacob #define	BIU2400_R2HST_INTR		BIU_R2HST_INTR
39810365e5aSMatt Jacob #define	BIU2400_R2HST_PAUSED		BIU_R2HST_PAUSED
39910365e5aSMatt Jacob #define	BIU2400_R2HST_ISTAT_MASK	0x1f
40010365e5aSMatt Jacob /* interrupt status meanings */
40110365e5aSMatt Jacob #define	ISP2400R2HST_ROM_MBX_OK		0x1	/* ROM mailbox cmd done ok */
40210365e5aSMatt Jacob #define	ISP2400R2HST_ROM_MBX_FAIL	0x2	/* ROM mailbox cmd done fail */
40310365e5aSMatt Jacob #define	ISP2400R2HST_MBX_OK		0x10	/* mailbox cmd done ok */
40410365e5aSMatt Jacob #define	ISP2400R2HST_MBX_FAIL		0x11	/* mailbox cmd done fail */
40510365e5aSMatt Jacob #define	ISP2400R2HST_ASYNC_EVENT	0x12	/* Async Event */
40610365e5aSMatt Jacob #define	ISP2400R2HST_RSPQ_UPDATE	0x13	/* Response Queue Update */
40710365e5aSMatt Jacob #define	ISP2400R2HST_ATIO_RSPQ_UPDATE	0x1C	/* ATIO Response Queue Update */
40810365e5aSMatt Jacob #define	ISP2400R2HST_ATIO_RQST_UPDATE	0x1D	/* ATIO Request Queue Update */
40910365e5aSMatt Jacob 
41010365e5aSMatt Jacob /* BIU2400_HCCR definitions */
41110365e5aSMatt Jacob 
41210365e5aSMatt Jacob #define	HCCR_2400_CMD_NOP		(0x0 << 28)
41310365e5aSMatt Jacob #define	HCCR_2400_CMD_RESET		(0x1 << 28)
41410365e5aSMatt Jacob #define	HCCR_2400_CMD_CLEAR_RESET	(0x2 << 28)
41510365e5aSMatt Jacob #define	HCCR_2400_CMD_PAUSE		(0x3 << 28)
41610365e5aSMatt Jacob #define	HCCR_2400_CMD_RELEASE		(0x4 << 28)
41710365e5aSMatt Jacob #define	HCCR_2400_CMD_SET_HOST_INT	(0x5 << 28)
41810365e5aSMatt Jacob #define	HCCR_2400_CMD_CLEAR_HOST_INT	(0x6 << 28)
41910365e5aSMatt Jacob #define	HCCR_2400_CMD_CLEAR_RISC_INT	(0xA << 28)
42010365e5aSMatt Jacob 
42110365e5aSMatt Jacob #define	HCCR_2400_RISC_ERR(x)		(((x) >> 12) & 0x7)	/* RO */
42210365e5aSMatt Jacob #define	HCCR_2400_RISC2HOST_INT		(1 << 6)		/* RO */
42310365e5aSMatt Jacob #define	HCCR_2400_RISC_RESET		(1 << 5)		/* RO */
42410365e5aSMatt Jacob 
42510365e5aSMatt Jacob 
42610365e5aSMatt Jacob /*
4276054c3f6SMatt Jacob  * Mailbox Block Register Offsets
4286054c3f6SMatt Jacob  */
4296054c3f6SMatt Jacob 
43022e1dc85SMatt Jacob #define	INMAILBOX0	(MBOX_BLOCK+0x0)
43122e1dc85SMatt Jacob #define	INMAILBOX1	(MBOX_BLOCK+0x2)
43222e1dc85SMatt Jacob #define	INMAILBOX2	(MBOX_BLOCK+0x4)
43322e1dc85SMatt Jacob #define	INMAILBOX3	(MBOX_BLOCK+0x6)
43422e1dc85SMatt Jacob #define	INMAILBOX4	(MBOX_BLOCK+0x8)
43522e1dc85SMatt Jacob #define	INMAILBOX5	(MBOX_BLOCK+0xA)
43622e1dc85SMatt Jacob #define	INMAILBOX6	(MBOX_BLOCK+0xC)
43722e1dc85SMatt Jacob #define	INMAILBOX7	(MBOX_BLOCK+0xE)
4386054c3f6SMatt Jacob 
43922e1dc85SMatt Jacob #define	OUTMAILBOX0	(MBOX_BLOCK+0x0)
44022e1dc85SMatt Jacob #define	OUTMAILBOX1	(MBOX_BLOCK+0x2)
44122e1dc85SMatt Jacob #define	OUTMAILBOX2	(MBOX_BLOCK+0x4)
44222e1dc85SMatt Jacob #define	OUTMAILBOX3	(MBOX_BLOCK+0x6)
44322e1dc85SMatt Jacob #define	OUTMAILBOX4	(MBOX_BLOCK+0x8)
44422e1dc85SMatt Jacob #define	OUTMAILBOX5	(MBOX_BLOCK+0xA)
44522e1dc85SMatt Jacob #define	OUTMAILBOX6	(MBOX_BLOCK+0xC)
44622e1dc85SMatt Jacob #define	OUTMAILBOX7	(MBOX_BLOCK+0xE)
4476054c3f6SMatt Jacob 
448e5265237SMatt Jacob /*
449e5265237SMatt Jacob  * Strictly speaking, it's
450e5265237SMatt Jacob  *  SCSI && 2100 : 8 MBOX registers
451e5265237SMatt Jacob  *  2200: 24 MBOX registers
45210365e5aSMatt Jacob  *  2300/2400: 32 MBOX registers
453e5265237SMatt Jacob  */
45440e88de6SMatt Jacob #define	MBOX_OFF(n)	(MBOX_BLOCK + ((n) << 1))
4556054c3f6SMatt Jacob #define	NMBOX(isp)	\
4566054c3f6SMatt Jacob 	(((((isp)->isp_type & ISP_HA_SCSI) >= ISP_HA_SCSI_1040A) || \
457e5265237SMatt Jacob 	 ((isp)->isp_type & ISP_HA_FC))? 12 : 6)
45840e88de6SMatt Jacob #define	NMBOX_BMASK(isp)	\
45940e88de6SMatt Jacob 	(((((isp)->isp_type & ISP_HA_SCSI) >= ISP_HA_SCSI_1040A) || \
460e5265237SMatt Jacob 	 ((isp)->isp_type & ISP_HA_FC))? 0xfff : 0x3f)
46140e88de6SMatt Jacob 
462e5265237SMatt Jacob #define	MAX_MAILBOX(isp)	((IS_FC(isp))? 12 : 8)
463e5265237SMatt Jacob #define	MAILBOX_STORAGE		12
46410365e5aSMatt Jacob /* if timeout == 0, then default timeout is picked */
46510365e5aSMatt Jacob #define	MBCMD_DEFAULT_TIMEOUT	100000	/* 100 ms */
466e5265237SMatt Jacob typedef struct {
4671dae40ebSMatt Jacob 	uint16_t param[MAILBOX_STORAGE];
46810365e5aSMatt Jacob 	uint16_t ibits;
46910365e5aSMatt Jacob 	uint16_t obits;
47010365e5aSMatt Jacob 	uint32_t	: 28,
47110365e5aSMatt Jacob 		logval	: 4;
47210365e5aSMatt Jacob 	uint32_t timeout;
473e5265237SMatt Jacob } mbreg_t;
4746054c3f6SMatt Jacob 
4756054c3f6SMatt Jacob /*
476144ff119SMatt Jacob  * Fibre Protocol Module and Frame Buffer Register Offsets/Definitions (2X00).
477144ff119SMatt Jacob  * NB: The RISC processor must be paused and the appropriate register
478144ff119SMatt Jacob  * bank selected via BIU2100_CSR bits.
479144ff119SMatt Jacob  */
480144ff119SMatt Jacob 
481144ff119SMatt Jacob #define	FPM_DIAG_CONFIG	(BIU_BLOCK + 0x96)
482144ff119SMatt Jacob #define		FPM_SOFT_RESET		0x0100
483144ff119SMatt Jacob 
484144ff119SMatt Jacob #define	FBM_CMD		(BIU_BLOCK + 0xB8)
485144ff119SMatt Jacob #define		FBMCMD_FIFO_RESET_ALL	0xA000
486144ff119SMatt Jacob 
487144ff119SMatt Jacob 
488144ff119SMatt Jacob /*
4896054c3f6SMatt Jacob  * SXP Block Register Offsets
4906054c3f6SMatt Jacob  */
49122e1dc85SMatt Jacob #define	SXP_PART_ID	(SXP_BLOCK+0x0)		/* R  : Part ID Code */
49222e1dc85SMatt Jacob #define	SXP_CONFIG1	(SXP_BLOCK+0x2)		/* RW*: Configuration Reg #1 */
49322e1dc85SMatt Jacob #define	SXP_CONFIG2	(SXP_BLOCK+0x4)		/* RW*: Configuration Reg #2 */
49422e1dc85SMatt Jacob #define	SXP_CONFIG3	(SXP_BLOCK+0x6)		/* RW*: Configuration Reg #2 */
49522e1dc85SMatt Jacob #define	SXP_INSTRUCTION	(SXP_BLOCK+0xC)		/* RW*: Instruction Pointer */
49622e1dc85SMatt Jacob #define	SXP_RETURN_ADDR	(SXP_BLOCK+0x10)	/* RW*: Return Address */
49722e1dc85SMatt Jacob #define	SXP_COMMAND	(SXP_BLOCK+0x14)	/* RW*: Command */
49822e1dc85SMatt Jacob #define	SXP_INTERRUPT	(SXP_BLOCK+0x18)	/* R  : Interrupt */
49922e1dc85SMatt Jacob #define	SXP_SEQUENCE	(SXP_BLOCK+0x1C)	/* RW*: Sequence */
50022e1dc85SMatt Jacob #define	SXP_GROSS_ERR	(SXP_BLOCK+0x1E)	/* R  : Gross Error */
50122e1dc85SMatt Jacob #define	SXP_EXCEPTION	(SXP_BLOCK+0x20)	/* RW*: Exception Enable */
50222e1dc85SMatt Jacob #define	SXP_OVERRIDE	(SXP_BLOCK+0x24)	/* RW*: Override */
50322e1dc85SMatt Jacob #define	SXP_LIT_BASE	(SXP_BLOCK+0x28)	/* RW*: Literal Base */
50422e1dc85SMatt Jacob #define	SXP_USER_FLAGS	(SXP_BLOCK+0x2C)	/* RW*: User Flags */
50522e1dc85SMatt Jacob #define	SXP_USER_EXCEPT	(SXP_BLOCK+0x30)	/* RW*: User Exception */
50622e1dc85SMatt Jacob #define	SXP_BREAKPOINT	(SXP_BLOCK+0x34)	/* RW*: Breakpoint */
50722e1dc85SMatt Jacob #define	SXP_SCSI_ID	(SXP_BLOCK+0x40)	/* RW*: SCSI ID */
50822e1dc85SMatt Jacob #define	SXP_DEV_CONFIG1	(SXP_BLOCK+0x42)	/* RW*: Device Config Reg #1 */
50922e1dc85SMatt Jacob #define	SXP_DEV_CONFIG2	(SXP_BLOCK+0x44)	/* RW*: Device Config Reg #2 */
51022e1dc85SMatt Jacob #define	SXP_PHASE_PTR	(SXP_BLOCK+0x48)	/* RW*: SCSI Phase Pointer */
51122e1dc85SMatt Jacob #define	SXP_BUF_PTR	(SXP_BLOCK+0x4C)	/* RW*: SCSI Buffer Pointer */
51222e1dc85SMatt Jacob #define	SXP_BUF_CTR	(SXP_BLOCK+0x50)	/* RW*: SCSI Buffer Counter */
51322e1dc85SMatt Jacob #define	SXP_BUFFER	(SXP_BLOCK+0x52)	/* RW*: SCSI Buffer */
51422e1dc85SMatt Jacob #define	SXP_BUF_BYTE	(SXP_BLOCK+0x54)	/* RW*: SCSI Buffer Byte */
51522e1dc85SMatt Jacob #define	SXP_BUF_WD	(SXP_BLOCK+0x56)	/* RW*: SCSI Buffer Word */
51622e1dc85SMatt Jacob #define	SXP_BUF_WD_TRAN	(SXP_BLOCK+0x58)	/* RW*: SCSI Buffer Wd xlate */
51722e1dc85SMatt Jacob #define	SXP_FIFO	(SXP_BLOCK+0x5A)	/* RW*: SCSI FIFO */
51822e1dc85SMatt Jacob #define	SXP_FIFO_STATUS	(SXP_BLOCK+0x5C)	/* RW*: SCSI FIFO Status */
51922e1dc85SMatt Jacob #define	SXP_FIFO_TOP	(SXP_BLOCK+0x5E)	/* RW*: SCSI FIFO Top Resid */
52022e1dc85SMatt Jacob #define	SXP_FIFO_BOTTOM	(SXP_BLOCK+0x60)	/* RW*: SCSI FIFO Bot Resid */
52122e1dc85SMatt Jacob #define	SXP_TRAN_REG	(SXP_BLOCK+0x64)	/* RW*: SCSI Transferr Reg */
52222e1dc85SMatt Jacob #define	SXP_TRAN_CNT_LO	(SXP_BLOCK+0x68)	/* RW*: SCSI Trans Count */
52322e1dc85SMatt Jacob #define	SXP_TRAN_CNT_HI	(SXP_BLOCK+0x6A)	/* RW*: SCSI Trans Count */
52422e1dc85SMatt Jacob #define	SXP_TRAN_CTR_LO	(SXP_BLOCK+0x6C)	/* RW*: SCSI Trans Counter */
52522e1dc85SMatt Jacob #define	SXP_TRAN_CTR_HI	(SXP_BLOCK+0x6E)	/* RW*: SCSI Trans Counter */
52622e1dc85SMatt Jacob #define	SXP_ARB_DATA	(SXP_BLOCK+0x70)	/* R  : SCSI Arb Data */
52722e1dc85SMatt Jacob #define	SXP_PINS_CTRL	(SXP_BLOCK+0x72)	/* RW*: SCSI Control Pins */
52822e1dc85SMatt Jacob #define	SXP_PINS_DATA	(SXP_BLOCK+0x74)	/* RW*: SCSI Data Pins */
52922e1dc85SMatt Jacob #define	SXP_PINS_DIFF	(SXP_BLOCK+0x76)	/* RW*: SCSI Diff Pins */
53022e1dc85SMatt Jacob 
53122e1dc85SMatt Jacob /* for 1080/1280/1240 only */
53222e1dc85SMatt Jacob #define	SXP_BANK1_SELECT	0x100
5336054c3f6SMatt Jacob 
5346054c3f6SMatt Jacob 
5356054c3f6SMatt Jacob /* SXP CONF1 REGISTER */
5366054c3f6SMatt Jacob #define	SXP_CONF1_ASYNCH_SETUP		0xF000	/* Asynchronous setup time */
5376054c3f6SMatt Jacob #define	SXP_CONF1_SELECTION_UNIT	0x0000	/* Selection time unit */
5386054c3f6SMatt Jacob #define	SXP_CONF1_SELECTION_TIMEOUT	0x0600	/* Selection timeout */
5396054c3f6SMatt Jacob #define	SXP_CONF1_CLOCK_FACTOR		0x00E0	/* Clock factor */
5406054c3f6SMatt Jacob #define	SXP_CONF1_SCSI_ID		0x000F	/* SCSI id */
5416054c3f6SMatt Jacob 
5426054c3f6SMatt Jacob /* SXP CONF2 REGISTER */
5436054c3f6SMatt Jacob #define	SXP_CONF2_DISABLE_FILTER	0x0040	/* Disable SCSI rec filters */
5446054c3f6SMatt Jacob #define	SXP_CONF2_REQ_ACK_PULLUPS	0x0020	/* Enable req/ack pullups */
5456054c3f6SMatt Jacob #define	SXP_CONF2_DATA_PULLUPS		0x0010	/* Enable data pullups */
5466054c3f6SMatt Jacob #define	SXP_CONF2_CONFIG_AUTOLOAD	0x0008	/* Enable dev conf auto-load */
5476054c3f6SMatt Jacob #define	SXP_CONF2_RESELECT		0x0002	/* Enable reselection */
5486054c3f6SMatt Jacob #define	SXP_CONF2_SELECT		0x0001	/* Enable selection */
5496054c3f6SMatt Jacob 
5506054c3f6SMatt Jacob /* SXP INTERRUPT REGISTER */
5516054c3f6SMatt Jacob #define	SXP_INT_PARITY_ERR		0x8000	/* Parity error detected */
5526054c3f6SMatt Jacob #define	SXP_INT_GROSS_ERR		0x4000	/* Gross error detected */
5536054c3f6SMatt Jacob #define	SXP_INT_FUNCTION_ABORT		0x2000	/* Last cmd aborted */
5546054c3f6SMatt Jacob #define	SXP_INT_CONDITION_FAILED	0x1000	/* Last cond failed test */
5556054c3f6SMatt Jacob #define	SXP_INT_FIFO_EMPTY		0x0800	/* SCSI FIFO is empty */
5566054c3f6SMatt Jacob #define	SXP_INT_BUF_COUNTER_ZERO	0x0400	/* SCSI buf count == zero */
5576054c3f6SMatt Jacob #define	SXP_INT_XFER_ZERO		0x0200	/* SCSI trans count == zero */
5586054c3f6SMatt Jacob #define	SXP_INT_INT_PENDING		0x0080	/* SXP interrupt pending */
5596054c3f6SMatt Jacob #define	SXP_INT_CMD_RUNNING		0x0040	/* SXP is running a command */
5606054c3f6SMatt Jacob #define	SXP_INT_INT_RETURN_CODE		0x000F	/* Interrupt return code */
5616054c3f6SMatt Jacob 
5626054c3f6SMatt Jacob 
5636054c3f6SMatt Jacob /* SXP GROSS ERROR REGISTER */
5646054c3f6SMatt Jacob #define	SXP_GROSS_OFFSET_RESID		0x0040	/* Req/Ack offset not zero */
5656054c3f6SMatt Jacob #define	SXP_GROSS_OFFSET_UNDERFLOW	0x0020	/* Req/Ack offset underflow */
5666054c3f6SMatt Jacob #define	SXP_GROSS_OFFSET_OVERFLOW	0x0010	/* Req/Ack offset overflow */
5676054c3f6SMatt Jacob #define	SXP_GROSS_FIFO_UNDERFLOW	0x0008	/* SCSI FIFO underflow */
5686054c3f6SMatt Jacob #define	SXP_GROSS_FIFO_OVERFLOW		0x0004	/* SCSI FIFO overflow */
5696054c3f6SMatt Jacob #define	SXP_GROSS_WRITE_ERR		0x0002	/* SXP and RISC wrote to reg */
5706054c3f6SMatt Jacob #define	SXP_GROSS_ILLEGAL_INST		0x0001	/* Bad inst loaded into SXP */
5716054c3f6SMatt Jacob 
5726054c3f6SMatt Jacob /* SXP EXCEPTION REGISTER */
5736054c3f6SMatt Jacob #define	SXP_EXCEPT_USER_0		0x8000	/* Enable user exception #0 */
5746054c3f6SMatt Jacob #define	SXP_EXCEPT_USER_1		0x4000	/* Enable user exception #1 */
5756054c3f6SMatt Jacob #define	PCI_SXP_EXCEPT_SCAM		0x0400	/* SCAM Selection enable */
5766054c3f6SMatt Jacob #define	SXP_EXCEPT_BUS_FREE		0x0200	/* Enable Bus Free det */
5776054c3f6SMatt Jacob #define	SXP_EXCEPT_TARGET_ATN		0x0100	/* Enable TGT mode atten det */
5786054c3f6SMatt Jacob #define	SXP_EXCEPT_RESELECTED		0x0080	/* Enable ReSEL exc handling */
5796054c3f6SMatt Jacob #define	SXP_EXCEPT_SELECTED		0x0040	/* Enable SEL exc handling */
5806054c3f6SMatt Jacob #define	SXP_EXCEPT_ARBITRATION		0x0020	/* Enable ARB exc handling */
5816054c3f6SMatt Jacob #define	SXP_EXCEPT_GROSS_ERR		0x0010	/* Enable gross error except */
5826054c3f6SMatt Jacob #define	SXP_EXCEPT_BUS_RESET		0x0008	/* Enable Bus Reset except */
5836054c3f6SMatt Jacob 
5846054c3f6SMatt Jacob 	/* SXP OVERRIDE REGISTER */
5856054c3f6SMatt Jacob #define	SXP_ORIDE_EXT_TRIGGER		0x8000	/* Enable external trigger */
5866054c3f6SMatt Jacob #define	SXP_ORIDE_STEP			0x4000	/* Enable single step mode */
5876054c3f6SMatt Jacob #define	SXP_ORIDE_BREAKPOINT		0x2000	/* Enable breakpoint reg */
5886054c3f6SMatt Jacob #define	SXP_ORIDE_PIN_WRITE		0x1000	/* Enable write to SCSI pins */
5896054c3f6SMatt Jacob #define	SXP_ORIDE_FORCE_OUTPUTS		0x0800	/* Force SCSI outputs on */
5906054c3f6SMatt Jacob #define	SXP_ORIDE_LOOPBACK		0x0400	/* Enable SCSI loopback mode */
5916054c3f6SMatt Jacob #define	SXP_ORIDE_PARITY_TEST		0x0200	/* Enable parity test mode */
5926054c3f6SMatt Jacob #define	SXP_ORIDE_TRISTATE_ENA_PINS	0x0100	/* Tristate SCSI enable pins */
5936054c3f6SMatt Jacob #define	SXP_ORIDE_TRISTATE_PINS		0x0080	/* Tristate SCSI pins */
5946054c3f6SMatt Jacob #define	SXP_ORIDE_FIFO_RESET		0x0008	/* Reset SCSI FIFO */
5956054c3f6SMatt Jacob #define	SXP_ORIDE_CMD_TERMINATE		0x0004	/* Terminate cur SXP com */
5966054c3f6SMatt Jacob #define	SXP_ORIDE_RESET_REG		0x0002	/* Reset SXP registers */
5976054c3f6SMatt Jacob #define	SXP_ORIDE_RESET_MODULE		0x0001	/* Reset SXP module */
5986054c3f6SMatt Jacob 
5996054c3f6SMatt Jacob /* SXP COMMANDS */
6006054c3f6SMatt Jacob #define	SXP_RESET_BUS_CMD		0x300b
6016054c3f6SMatt Jacob 
6026054c3f6SMatt Jacob /* SXP SCSI ID REGISTER */
6036054c3f6SMatt Jacob #define	SXP_SELECTING_ID		0x0F00	/* (Re)Selecting id */
6046054c3f6SMatt Jacob #define	SXP_SELECT_ID			0x000F	/* Select id */
6056054c3f6SMatt Jacob 
6066054c3f6SMatt Jacob /* SXP DEV CONFIG1 REGISTER */
6076054c3f6SMatt Jacob #define	SXP_DCONF1_SYNC_HOLD		0x7000	/* Synchronous data hold */
6086054c3f6SMatt Jacob #define	SXP_DCONF1_SYNC_SETUP		0x0F00	/* Synchronous data setup */
6096054c3f6SMatt Jacob #define	SXP_DCONF1_SYNC_OFFSET		0x000F	/* Synchronous data offset */
6106054c3f6SMatt Jacob 
6116054c3f6SMatt Jacob 
6126054c3f6SMatt Jacob /* SXP DEV CONFIG2 REGISTER */
6136054c3f6SMatt Jacob #define	SXP_DCONF2_FLAGS_MASK		0xF000	/* Device flags */
6146054c3f6SMatt Jacob #define	SXP_DCONF2_WIDE			0x0400	/* Enable wide SCSI */
6156054c3f6SMatt Jacob #define	SXP_DCONF2_PARITY		0x0200	/* Enable parity checking */
6166054c3f6SMatt Jacob #define	SXP_DCONF2_BLOCK_MODE		0x0100	/* Enable blk mode xfr count */
6176054c3f6SMatt Jacob #define	SXP_DCONF2_ASSERTION_MASK	0x0007	/* Assersion period mask */
6186054c3f6SMatt Jacob 
6196054c3f6SMatt Jacob 
6206054c3f6SMatt Jacob /* SXP PHASE POINTER REGISTER */
6216054c3f6SMatt Jacob #define	SXP_PHASE_STATUS_PTR		0x1000	/* Status buffer offset */
6226054c3f6SMatt Jacob #define	SXP_PHASE_MSG_IN_PTR		0x0700	/* Msg in buffer offset */
6236054c3f6SMatt Jacob #define	SXP_PHASE_COM_PTR		0x00F0	/* Command buffer offset */
6246054c3f6SMatt Jacob #define	SXP_PHASE_MSG_OUT_PTR		0x0007	/* Msg out buffer offset */
6256054c3f6SMatt Jacob 
6266054c3f6SMatt Jacob 
6276054c3f6SMatt Jacob /* SXP FIFO STATUS REGISTER */
6286054c3f6SMatt Jacob #define	SXP_FIFO_TOP_RESID		0x8000	/* Top residue reg full */
6296054c3f6SMatt Jacob #define	SXP_FIFO_ACK_RESID		0x4000	/* Wide transfers odd resid */
6306054c3f6SMatt Jacob #define	SXP_FIFO_COUNT_MASK		0x001C	/* Words in SXP FIFO */
6316054c3f6SMatt Jacob #define	SXP_FIFO_BOTTOM_RESID		0x0001	/* Bottom residue reg full */
6326054c3f6SMatt Jacob 
6336054c3f6SMatt Jacob 
6346054c3f6SMatt Jacob /* SXP CONTROL PINS REGISTER */
6356054c3f6SMatt Jacob #define	SXP_PINS_CON_PHASE		0x8000	/* Scsi phase valid */
6366054c3f6SMatt Jacob #define	SXP_PINS_CON_PARITY_HI		0x0400	/* Parity pin */
6376054c3f6SMatt Jacob #define	SXP_PINS_CON_PARITY_LO		0x0200	/* Parity pin */
6386054c3f6SMatt Jacob #define	SXP_PINS_CON_REQ		0x0100	/* SCSI bus REQUEST */
6396054c3f6SMatt Jacob #define	SXP_PINS_CON_ACK		0x0080	/* SCSI bus ACKNOWLEDGE */
6406054c3f6SMatt Jacob #define	SXP_PINS_CON_RST		0x0040	/* SCSI bus RESET */
6416054c3f6SMatt Jacob #define	SXP_PINS_CON_BSY		0x0020	/* SCSI bus BUSY */
6426054c3f6SMatt Jacob #define	SXP_PINS_CON_SEL		0x0010	/* SCSI bus SELECT */
6436054c3f6SMatt Jacob #define	SXP_PINS_CON_ATN		0x0008	/* SCSI bus ATTENTION */
6446054c3f6SMatt Jacob #define	SXP_PINS_CON_MSG		0x0004	/* SCSI bus MESSAGE */
6456054c3f6SMatt Jacob #define	SXP_PINS_CON_CD 		0x0002	/* SCSI bus COMMAND */
6466054c3f6SMatt Jacob #define	SXP_PINS_CON_IO 		0x0001	/* SCSI bus INPUT */
6476054c3f6SMatt Jacob 
6486054c3f6SMatt Jacob /*
6496054c3f6SMatt Jacob  * Set the hold time for the SCSI Bus Reset to be 250 ms
6506054c3f6SMatt Jacob  */
6516054c3f6SMatt Jacob #define	SXP_SCSI_BUS_RESET_HOLD_TIME	250
6526054c3f6SMatt Jacob 
6536054c3f6SMatt Jacob /* SXP DIFF PINS REGISTER */
6546054c3f6SMatt Jacob #define	SXP_PINS_DIFF_SENSE		0x0200	/* DIFFSENS sig on SCSI bus */
6556054c3f6SMatt Jacob #define	SXP_PINS_DIFF_MODE		0x0100	/* DIFFM signal */
6566054c3f6SMatt Jacob #define	SXP_PINS_DIFF_ENABLE_OUTPUT	0x0080	/* Enable SXP SCSI data drv */
6576054c3f6SMatt Jacob #define	SXP_PINS_DIFF_PINS_MASK		0x007C	/* Differential control pins */
6586054c3f6SMatt Jacob #define	SXP_PINS_DIFF_TARGET		0x0002	/* Enable SXP target mode */
6596054c3f6SMatt Jacob #define	SXP_PINS_DIFF_INITIATOR		0x0001	/* Enable SXP initiator mode */
6606054c3f6SMatt Jacob 
66122e1dc85SMatt Jacob /* Ultra2 only */
6624394c92fSMatt Jacob #define	SXP_PINS_LVD_MODE		0x1000
6634394c92fSMatt Jacob #define	SXP_PINS_HVD_MODE		0x0800
6644394c92fSMatt Jacob #define	SXP_PINS_SE_MODE		0x0400
6654394c92fSMatt Jacob 
6664394c92fSMatt Jacob /* The above have to be put together with the DIFFM pin to make sense */
6674394c92fSMatt Jacob #define	ISP1080_LVD_MODE		(SXP_PINS_LVD_MODE)
6684394c92fSMatt Jacob #define	ISP1080_HVD_MODE		(SXP_PINS_HVD_MODE|SXP_PINS_DIFF_MODE)
6694394c92fSMatt Jacob #define	ISP1080_SE_MODE			(SXP_PINS_SE_MODE)
6704394c92fSMatt Jacob #define	ISP1080_MODE_MASK	\
6714394c92fSMatt Jacob     (SXP_PINS_LVD_MODE|SXP_PINS_HVD_MODE|SXP_PINS_SE_MODE|SXP_PINS_DIFF_MODE)
6724394c92fSMatt Jacob 
6736054c3f6SMatt Jacob /*
6746054c3f6SMatt Jacob  * RISC and Host Command and Control Block Register Offsets
6756054c3f6SMatt Jacob  */
6766054c3f6SMatt Jacob 
6776054c3f6SMatt Jacob #define	RISC_ACC	RISC_BLOCK+0x0	/* RW*: Accumulator */
6786054c3f6SMatt Jacob #define	RISC_R1		RISC_BLOCK+0x2	/* RW*: GP Reg R1  */
6796054c3f6SMatt Jacob #define	RISC_R2		RISC_BLOCK+0x4	/* RW*: GP Reg R2  */
6806054c3f6SMatt Jacob #define	RISC_R3		RISC_BLOCK+0x6	/* RW*: GP Reg R3  */
6816054c3f6SMatt Jacob #define	RISC_R4		RISC_BLOCK+0x8	/* RW*: GP Reg R4  */
6826054c3f6SMatt Jacob #define	RISC_R5		RISC_BLOCK+0xA	/* RW*: GP Reg R5  */
6836054c3f6SMatt Jacob #define	RISC_R6		RISC_BLOCK+0xC	/* RW*: GP Reg R6  */
6846054c3f6SMatt Jacob #define	RISC_R7		RISC_BLOCK+0xE	/* RW*: GP Reg R7  */
6856054c3f6SMatt Jacob #define	RISC_R8		RISC_BLOCK+0x10	/* RW*: GP Reg R8  */
6866054c3f6SMatt Jacob #define	RISC_R9		RISC_BLOCK+0x12	/* RW*: GP Reg R9  */
6876054c3f6SMatt Jacob #define	RISC_R10	RISC_BLOCK+0x14	/* RW*: GP Reg R10 */
6886054c3f6SMatt Jacob #define	RISC_R11	RISC_BLOCK+0x16	/* RW*: GP Reg R11 */
6896054c3f6SMatt Jacob #define	RISC_R12	RISC_BLOCK+0x18	/* RW*: GP Reg R12 */
6906054c3f6SMatt Jacob #define	RISC_R13	RISC_BLOCK+0x1a	/* RW*: GP Reg R13 */
6916054c3f6SMatt Jacob #define	RISC_R14	RISC_BLOCK+0x1c	/* RW*: GP Reg R14 */
6926054c3f6SMatt Jacob #define	RISC_R15	RISC_BLOCK+0x1e	/* RW*: GP Reg R15 */
6936054c3f6SMatt Jacob #define	RISC_PSR	RISC_BLOCK+0x20	/* RW*: Processor Status */
6946054c3f6SMatt Jacob #define	RISC_IVR	RISC_BLOCK+0x22	/* RW*: Interrupt Vector */
6956054c3f6SMatt Jacob #define	RISC_PCR	RISC_BLOCK+0x24	/* RW*: Processor Ctrl */
6966054c3f6SMatt Jacob #define	RISC_RAR0	RISC_BLOCK+0x26	/* RW*: Ram Address #0 */
6976054c3f6SMatt Jacob #define	RISC_RAR1	RISC_BLOCK+0x28	/* RW*: Ram Address #1 */
6986054c3f6SMatt Jacob #define	RISC_LCR	RISC_BLOCK+0x2a	/* RW*: Loop Counter */
6996054c3f6SMatt Jacob #define	RISC_PC		RISC_BLOCK+0x2c	/* R  : Program Counter */
7006054c3f6SMatt Jacob #define	RISC_MTR	RISC_BLOCK+0x2e	/* RW*: Memory Timing */
7016054c3f6SMatt Jacob #define		RISC_MTR2100	RISC_BLOCK+0x30
7026054c3f6SMatt Jacob 
7036054c3f6SMatt Jacob #define	RISC_EMB	RISC_BLOCK+0x30	/* RW*: Ext Mem Boundary */
704cbf57b47SMatt Jacob #define		DUAL_BANK	8
7056054c3f6SMatt Jacob #define	RISC_SP		RISC_BLOCK+0x32	/* RW*: Stack Pointer */
7066054c3f6SMatt Jacob #define	RISC_HRL	RISC_BLOCK+0x3e	/* R *: Hardware Rev Level */
7076054c3f6SMatt Jacob #define	HCCR		RISC_BLOCK+0x40	/* RW : Host Command & Ctrl */
7086054c3f6SMatt Jacob #define	BP0		RISC_BLOCK+0x42	/* RW : Processor Brkpt #0 */
7096054c3f6SMatt Jacob #define	BP1		RISC_BLOCK+0x44	/* RW : Processor Brkpt #1 */
7106054c3f6SMatt Jacob #define	TCR		RISC_BLOCK+0x46	/*  W : Test Control */
7116054c3f6SMatt Jacob #define	TMR		RISC_BLOCK+0x48	/*  W : Test Mode */
7126054c3f6SMatt Jacob 
7136054c3f6SMatt Jacob 
7146054c3f6SMatt Jacob /* PROCESSOR STATUS REGISTER */
7156054c3f6SMatt Jacob #define	RISC_PSR_FORCE_TRUE		0x8000
7166054c3f6SMatt Jacob #define	RISC_PSR_LOOP_COUNT_DONE	0x4000
7176054c3f6SMatt Jacob #define	RISC_PSR_RISC_INT		0x2000
7186054c3f6SMatt Jacob #define	RISC_PSR_TIMER_ROLLOVER		0x1000
7196054c3f6SMatt Jacob #define	RISC_PSR_ALU_OVERFLOW		0x0800
7206054c3f6SMatt Jacob #define	RISC_PSR_ALU_MSB		0x0400
7216054c3f6SMatt Jacob #define	RISC_PSR_ALU_CARRY		0x0200
7226054c3f6SMatt Jacob #define	RISC_PSR_ALU_ZERO		0x0100
723478f8a96SJustin T. Gibbs 
724478f8a96SJustin T. Gibbs #define	RISC_PSR_PCI_ULTRA		0x0080
725478f8a96SJustin T. Gibbs #define	RISC_PSR_SBUS_ULTRA		0x0020
726478f8a96SJustin T. Gibbs 
7276054c3f6SMatt Jacob #define	RISC_PSR_DMA_INT		0x0010
7286054c3f6SMatt Jacob #define	RISC_PSR_SXP_INT		0x0008
7296054c3f6SMatt Jacob #define	RISC_PSR_HOST_INT		0x0004
7306054c3f6SMatt Jacob #define	RISC_PSR_INT_PENDING		0x0002
7316054c3f6SMatt Jacob #define	RISC_PSR_FORCE_FALSE  		0x0001
7326054c3f6SMatt Jacob 
7336054c3f6SMatt Jacob 
7346054c3f6SMatt Jacob /* Host Command and Control */
7356054c3f6SMatt Jacob #define	HCCR_CMD_NOP			0x0000	/* NOP */
7366054c3f6SMatt Jacob #define	HCCR_CMD_RESET			0x1000	/* Reset RISC */
7376054c3f6SMatt Jacob #define	HCCR_CMD_PAUSE			0x2000	/* Pause RISC */
7386054c3f6SMatt Jacob #define	HCCR_CMD_RELEASE		0x3000	/* Release Paused RISC */
7396054c3f6SMatt Jacob #define	HCCR_CMD_STEP			0x4000	/* Single Step RISC */
740144ff119SMatt Jacob #define	HCCR_2X00_DISABLE_PARITY_PAUSE	0x4001	/*
741144ff119SMatt Jacob 						 * Disable RISC pause on FPM
742144ff119SMatt Jacob 						 * parity error.
743144ff119SMatt Jacob 						 */
7446054c3f6SMatt Jacob #define	HCCR_CMD_SET_HOST_INT		0x5000	/* Set Host Interrupt */
7456054c3f6SMatt Jacob #define	HCCR_CMD_CLEAR_HOST_INT		0x6000	/* Clear Host Interrupt */
7466054c3f6SMatt Jacob #define	HCCR_CMD_CLEAR_RISC_INT		0x7000	/* Clear RISC interrupt */
7476054c3f6SMatt Jacob #define	HCCR_CMD_BREAKPOINT		0x8000	/* Change breakpoint enables */
7486054c3f6SMatt Jacob #define	PCI_HCCR_CMD_BIOS		0x9000	/* Write BIOS (disable) */
7496054c3f6SMatt Jacob #define	PCI_HCCR_CMD_PARITY		0xA000	/* Write parity enable */
7506054c3f6SMatt Jacob #define	PCI_HCCR_CMD_PARITY_ERR		0xE000	/* Generate parity error */
7516054c3f6SMatt Jacob #define	HCCR_CMD_TEST_MODE		0xF000	/* Set Test Mode */
7526054c3f6SMatt Jacob 
75310365e5aSMatt Jacob 
7546054c3f6SMatt Jacob #define	ISP2100_HCCR_PARITY_ENABLE_2	0x0400
7556054c3f6SMatt Jacob #define	ISP2100_HCCR_PARITY_ENABLE_1	0x0200
7566054c3f6SMatt Jacob #define	ISP2100_HCCR_PARITY_ENABLE_0	0x0100
7576054c3f6SMatt Jacob #define	ISP2100_HCCR_PARITY		0x0001
7586054c3f6SMatt Jacob 
7596054c3f6SMatt Jacob #define	PCI_HCCR_PARITY			0x0400	/* Parity error flag */
7606054c3f6SMatt Jacob #define	PCI_HCCR_PARITY_ENABLE_1	0x0200	/* Parity enable bank 1 */
7616054c3f6SMatt Jacob #define	PCI_HCCR_PARITY_ENABLE_0	0x0100	/* Parity enable bank 0 */
7626054c3f6SMatt Jacob 
7636054c3f6SMatt Jacob #define	HCCR_HOST_INT			0x0080	/* R  : Host interrupt set */
7646054c3f6SMatt Jacob #define	HCCR_RESET			0x0040	/* R  : reset in progress */
7656054c3f6SMatt Jacob #define	HCCR_PAUSE			0x0020	/* R  : RISC paused */
7666054c3f6SMatt Jacob 
7676054c3f6SMatt Jacob #define	PCI_HCCR_BIOS			0x0001	/*  W : BIOS enable */
768478f8a96SJustin T. Gibbs 
769478f8a96SJustin T. Gibbs /*
77010365e5aSMatt Jacob  * Defines for Interrupts
77110365e5aSMatt Jacob  */
77210365e5aSMatt Jacob #define	ISP_INTS_ENABLED(isp)						\
77310365e5aSMatt Jacob  ((IS_SCSI(isp))?  							\
77410365e5aSMatt Jacob   (ISP_READ(isp, BIU_ICR) & BIU_IMASK) :				\
77510365e5aSMatt Jacob    (IS_24XX(isp)? (ISP_READ(isp, BIU2400_ICR) & BIU2400_IMASK) :	\
77610365e5aSMatt Jacob    (ISP_READ(isp, BIU_ICR) & BIU2100_IMASK)))
77710365e5aSMatt Jacob 
77810365e5aSMatt Jacob #define	ISP_ENABLE_INTS(isp)						\
77910365e5aSMatt Jacob  (IS_SCSI(isp) ?  							\
78010365e5aSMatt Jacob    ISP_WRITE(isp, BIU_ICR, BIU_IMASK) :					\
78110365e5aSMatt Jacob    (IS_24XX(isp) ?							\
78210365e5aSMatt Jacob     (ISP_WRITE(isp, BIU2400_ICR, BIU2400_IMASK)) :			\
78310365e5aSMatt Jacob     (ISP_WRITE(isp, BIU_ICR, BIU2100_IMASK))))
78410365e5aSMatt Jacob 
78510365e5aSMatt Jacob #define	ISP_DISABLE_INTS(isp)						\
78610365e5aSMatt Jacob  IS_24XX(isp)? ISP_WRITE(isp, BIU2400_ICR, 0) : ISP_WRITE(isp, BIU_ICR, 0)
78710365e5aSMatt Jacob 
78810365e5aSMatt Jacob /*
789981e6b25SMatt Jacob  * NVRAM Definitions (PCI cards only)
790981e6b25SMatt Jacob  */
791981e6b25SMatt Jacob 
792981e6b25SMatt Jacob #define	ISPBSMX(c, byte, shift, mask)	\
793981e6b25SMatt Jacob 	(((c)[(byte)] >> (shift)) & (mask))
794981e6b25SMatt Jacob /*
795981e6b25SMatt Jacob  * Qlogic 1020/1040 NVRAM is an array of 128 bytes.
796478f8a96SJustin T. Gibbs  *
797478f8a96SJustin T. Gibbs  * Some portion of the front of this is for general host adapter properties
798478f8a96SJustin T. Gibbs  * This is followed by an array of per-target parameters, and is tailed off
799478f8a96SJustin T. Gibbs  * with a checksum xor byte at offset 127. For non-byte entities data is
800478f8a96SJustin T. Gibbs  * stored in Little Endian order.
801478f8a96SJustin T. Gibbs  */
802478f8a96SJustin T. Gibbs 
803478f8a96SJustin T. Gibbs #define	ISP_NVRAM_SIZE	128
804478f8a96SJustin T. Gibbs 
805478f8a96SJustin T. Gibbs #define	ISP_NVRAM_VERSION(c)			(c)[4]
806478f8a96SJustin T. Gibbs #define	ISP_NVRAM_FIFO_THRESHOLD(c)		ISPBSMX(c, 5, 0, 0x03)
807478f8a96SJustin T. Gibbs #define	ISP_NVRAM_BIOS_DISABLE(c)		ISPBSMX(c, 5, 2, 0x01)
808478f8a96SJustin T. Gibbs #define	ISP_NVRAM_HBA_ENABLE(c)			ISPBSMX(c, 5, 3, 0x01)
809478f8a96SJustin T. Gibbs #define	ISP_NVRAM_INITIATOR_ID(c)		ISPBSMX(c, 5, 4, 0x0f)
810478f8a96SJustin T. Gibbs #define	ISP_NVRAM_BUS_RESET_DELAY(c)		(c)[6]
811478f8a96SJustin T. Gibbs #define	ISP_NVRAM_BUS_RETRY_COUNT(c)		(c)[7]
812478f8a96SJustin T. Gibbs #define	ISP_NVRAM_BUS_RETRY_DELAY(c)		(c)[8]
813478f8a96SJustin T. Gibbs #define	ISP_NVRAM_ASYNC_DATA_SETUP_TIME(c)	ISPBSMX(c, 9, 0, 0x0f)
814478f8a96SJustin T. Gibbs #define	ISP_NVRAM_REQ_ACK_ACTIVE_NEGATION(c)	ISPBSMX(c, 9, 4, 0x01)
815478f8a96SJustin T. Gibbs #define	ISP_NVRAM_DATA_LINE_ACTIVE_NEGATION(c)	ISPBSMX(c, 9, 5, 0x01)
816478f8a96SJustin T. Gibbs #define	ISP_NVRAM_DATA_DMA_BURST_ENABLE(c)	ISPBSMX(c, 9, 6, 0x01)
817478f8a96SJustin T. Gibbs #define	ISP_NVRAM_CMD_DMA_BURST_ENABLE(c)	ISPBSMX(c, 9, 7, 0x01)
818478f8a96SJustin T. Gibbs #define	ISP_NVRAM_TAG_AGE_LIMIT(c)		(c)[10]
819478f8a96SJustin T. Gibbs #define	ISP_NVRAM_LOWTRM_ENABLE(c)		ISPBSMX(c, 11, 0, 0x01)
820478f8a96SJustin T. Gibbs #define	ISP_NVRAM_HITRM_ENABLE(c)		ISPBSMX(c, 11, 1, 0x01)
821478f8a96SJustin T. Gibbs #define	ISP_NVRAM_PCMC_BURST_ENABLE(c)		ISPBSMX(c, 11, 2, 0x01)
822478f8a96SJustin T. Gibbs #define	ISP_NVRAM_ENABLE_60_MHZ(c)		ISPBSMX(c, 11, 3, 0x01)
823478f8a96SJustin T. Gibbs #define	ISP_NVRAM_SCSI_RESET_DISABLE(c)		ISPBSMX(c, 11, 4, 0x01)
824478f8a96SJustin T. Gibbs #define	ISP_NVRAM_ENABLE_AUTO_TERM(c)		ISPBSMX(c, 11, 5, 0x01)
825478f8a96SJustin T. Gibbs #define	ISP_NVRAM_FIFO_THRESHOLD_128(c)		ISPBSMX(c, 11, 6, 0x01)
826478f8a96SJustin T. Gibbs #define	ISP_NVRAM_AUTO_TERM_SUPPORT(c)		ISPBSMX(c, 11, 7, 0x01)
827478f8a96SJustin T. Gibbs #define	ISP_NVRAM_SELECTION_TIMEOUT(c)		(((c)[12]) | ((c)[13] << 8))
828478f8a96SJustin T. Gibbs #define	ISP_NVRAM_MAX_QUEUE_DEPTH(c)		(((c)[14]) | ((c)[15] << 8))
829478f8a96SJustin T. Gibbs #define	ISP_NVRAM_SCSI_BUS_SIZE(c)		ISPBSMX(c, 16, 0, 0x01)
830478f8a96SJustin T. Gibbs #define	ISP_NVRAM_SCSI_BUS_TYPE(c)		ISPBSMX(c, 16, 1, 0x01)
831478f8a96SJustin T. Gibbs #define	ISP_NVRAM_ADAPTER_CLK_SPEED(c)		ISPBSMX(c, 16, 2, 0x01)
832478f8a96SJustin T. Gibbs #define	ISP_NVRAM_SOFT_TERM_SUPPORT(c)		ISPBSMX(c, 16, 3, 0x01)
833478f8a96SJustin T. Gibbs #define	ISP_NVRAM_FLASH_ONBOARD(c)		ISPBSMX(c, 16, 4, 0x01)
834478f8a96SJustin T. Gibbs #define	ISP_NVRAM_FAST_MTTR_ENABLE(c)		ISPBSMX(c, 22, 0, 0x01)
835478f8a96SJustin T. Gibbs 
836478f8a96SJustin T. Gibbs #define	ISP_NVRAM_TARGOFF			28
83710365e5aSMatt Jacob #define	ISP_NVRAM_TARGSIZE			6
838478f8a96SJustin T. Gibbs #define	_IxT(tgt, tidx)			\
83910365e5aSMatt Jacob 	(ISP_NVRAM_TARGOFF + (ISP_NVRAM_TARGSIZE * (tgt)) + (tidx))
840478f8a96SJustin T. Gibbs #define	ISP_NVRAM_TGT_RENEG(c, t)		ISPBSMX(c, _IxT(t, 0), 0, 0x01)
841478f8a96SJustin T. Gibbs #define	ISP_NVRAM_TGT_QFRZ(c, t)		ISPBSMX(c, _IxT(t, 0), 1, 0x01)
842478f8a96SJustin T. Gibbs #define	ISP_NVRAM_TGT_ARQ(c, t)			ISPBSMX(c, _IxT(t, 0), 2, 0x01)
843478f8a96SJustin T. Gibbs #define	ISP_NVRAM_TGT_TQING(c, t)		ISPBSMX(c, _IxT(t, 0), 3, 0x01)
844478f8a96SJustin T. Gibbs #define	ISP_NVRAM_TGT_SYNC(c, t)		ISPBSMX(c, _IxT(t, 0), 4, 0x01)
845478f8a96SJustin T. Gibbs #define	ISP_NVRAM_TGT_WIDE(c, t)		ISPBSMX(c, _IxT(t, 0), 5, 0x01)
846478f8a96SJustin T. Gibbs #define	ISP_NVRAM_TGT_PARITY(c, t)		ISPBSMX(c, _IxT(t, 0), 6, 0x01)
847478f8a96SJustin T. Gibbs #define	ISP_NVRAM_TGT_DISC(c, t)		ISPBSMX(c, _IxT(t, 0), 7, 0x01)
848478f8a96SJustin T. Gibbs #define	ISP_NVRAM_TGT_EXEC_THROTTLE(c, t)	ISPBSMX(c, _IxT(t, 1), 0, 0xff)
849478f8a96SJustin T. Gibbs #define	ISP_NVRAM_TGT_SYNC_PERIOD(c, t)		ISPBSMX(c, _IxT(t, 2), 0, 0xff)
850478f8a96SJustin T. Gibbs #define	ISP_NVRAM_TGT_SYNC_OFFSET(c, t)		ISPBSMX(c, _IxT(t, 3), 0, 0x0f)
851478f8a96SJustin T. Gibbs #define	ISP_NVRAM_TGT_DEVICE_ENABLE(c, t)	ISPBSMX(c, _IxT(t, 3), 4, 0x01)
852478f8a96SJustin T. Gibbs #define	ISP_NVRAM_TGT_LUN_DISABLE(c, t)		ISPBSMX(c, _IxT(t, 3), 5, 0x01)
853478f8a96SJustin T. Gibbs 
854478f8a96SJustin T. Gibbs /*
855981e6b25SMatt Jacob  * Qlogic 1080/1240 NVRAM is an array of 256 bytes.
856981e6b25SMatt Jacob  *
857981e6b25SMatt Jacob  * Some portion of the front of this is for general host adapter properties
858981e6b25SMatt Jacob  * This is followed by an array of per-target parameters, and is tailed off
859981e6b25SMatt Jacob  * with a checksum xor byte at offset 256. For non-byte entities data is
860981e6b25SMatt Jacob  * stored in Little Endian order.
861981e6b25SMatt Jacob  */
862981e6b25SMatt Jacob 
863981e6b25SMatt Jacob #define	ISP1080_NVRAM_SIZE	256
864981e6b25SMatt Jacob 
865981e6b25SMatt Jacob #define	ISP1080_NVRAM_VERSION(c)		ISP_NVRAM_VERSION(c)
866981e6b25SMatt Jacob 
867981e6b25SMatt Jacob /* Offset 5 */
868981e6b25SMatt Jacob /*
8691dae40ebSMatt Jacob 	uint8_t bios_configuration_mode     :2;
8701dae40ebSMatt Jacob 	uint8_t bios_disable                :1;
8711dae40ebSMatt Jacob 	uint8_t selectable_scsi_boot_enable :1;
8721dae40ebSMatt Jacob 	uint8_t cd_rom_boot_enable          :1;
8731dae40ebSMatt Jacob 	uint8_t disable_loading_risc_code   :1;
8741dae40ebSMatt Jacob 	uint8_t enable_64bit_addressing     :1;
8751dae40ebSMatt Jacob 	uint8_t unused_7                    :1;
876981e6b25SMatt Jacob  */
877981e6b25SMatt Jacob 
878981e6b25SMatt Jacob /* Offsets 6, 7 */
879981e6b25SMatt Jacob /*
8801dae40ebSMatt Jacob         uint8_t boot_lun_number    :5;
8811dae40ebSMatt Jacob         uint8_t scsi_bus_number    :1;
8821dae40ebSMatt Jacob         uint8_t unused_6           :1;
8831dae40ebSMatt Jacob         uint8_t unused_7           :1;
8841dae40ebSMatt Jacob         uint8_t boot_target_number :4;
8851dae40ebSMatt Jacob         uint8_t unused_12          :1;
8861dae40ebSMatt Jacob         uint8_t unused_13          :1;
8871dae40ebSMatt Jacob         uint8_t unused_14          :1;
8881dae40ebSMatt Jacob         uint8_t unused_15          :1;
889981e6b25SMatt Jacob  */
890981e6b25SMatt Jacob 
891981e6b25SMatt Jacob #define	ISP1080_NVRAM_HBA_ENABLE(c)			ISPBSMX(c, 16, 3, 0x01)
892981e6b25SMatt Jacob 
893981e6b25SMatt Jacob #define	ISP1080_NVRAM_BURST_ENABLE(c)			ISPBSMX(c, 16, 1, 0x01)
894981e6b25SMatt Jacob #define	ISP1080_NVRAM_FIFO_THRESHOLD(c)			ISPBSMX(c, 16, 4, 0x0f)
895981e6b25SMatt Jacob 
896981e6b25SMatt Jacob #define	ISP1080_NVRAM_AUTO_TERM_SUPPORT(c)		ISPBSMX(c, 17, 7, 0x01)
897981e6b25SMatt Jacob #define	ISP1080_NVRAM_BUS0_TERM_MODE(c)			ISPBSMX(c, 17, 0, 0x03)
898981e6b25SMatt Jacob #define	ISP1080_NVRAM_BUS1_TERM_MODE(c)			ISPBSMX(c, 17, 2, 0x03)
899981e6b25SMatt Jacob 
900981e6b25SMatt Jacob #define	ISP1080_ISP_PARAMETER(c)			\
901981e6b25SMatt Jacob 	(((c)[18]) | ((c)[19] << 8))
902981e6b25SMatt Jacob 
903c211f23bSMatt Jacob #define	ISP1080_FAST_POST(c)				ISPBSMX(c, 20, 0, 0x01)
904c211f23bSMatt Jacob #define	ISP1080_REPORT_LVD_TRANSITION(c)		ISPBSMX(c, 20, 1, 0x01)
905981e6b25SMatt Jacob 
906981e6b25SMatt Jacob #define	ISP1080_BUS1_OFF				112
907981e6b25SMatt Jacob 
908981e6b25SMatt Jacob #define	ISP1080_NVRAM_INITIATOR_ID(c, b)		\
909981e6b25SMatt Jacob 	ISPBSMX(c, ((b == 0)? 0 : ISP1080_BUS1_OFF) + 24, 0, 0x0f)
910981e6b25SMatt Jacob #define	ISP1080_NVRAM_BUS_RESET_DELAY(c, b)		\
911981e6b25SMatt Jacob 	(c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 25]
912981e6b25SMatt Jacob #define	ISP1080_NVRAM_BUS_RETRY_COUNT(c, b)		\
913981e6b25SMatt Jacob 	(c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 26]
914981e6b25SMatt Jacob #define	ISP1080_NVRAM_BUS_RETRY_DELAY(c, b)		\
915981e6b25SMatt Jacob 	(c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 27]
916981e6b25SMatt Jacob 
917981e6b25SMatt Jacob #define	ISP1080_NVRAM_ASYNC_DATA_SETUP_TIME(c, b)	\
918981e6b25SMatt Jacob 	ISPBSMX(c, ((b == 0)? 0 : ISP1080_BUS1_OFF) + 28, 0, 0x0f)
919981e6b25SMatt Jacob #define	ISP1080_NVRAM_REQ_ACK_ACTIVE_NEGATION(c, b)	\
920981e6b25SMatt Jacob 	ISPBSMX(c, ((b == 0)? 0 : ISP1080_BUS1_OFF) + 28, 4, 0x01)
921981e6b25SMatt Jacob #define	ISP1080_NVRAM_DATA_LINE_ACTIVE_NEGATION(c, b)	\
922981e6b25SMatt Jacob 	ISPBSMX(c, ((b == 0)? 0 : ISP1080_BUS1_OFF) + 28, 5, 0x01)
923981e6b25SMatt Jacob #define	ISP1080_NVRAM_SELECTION_TIMEOUT(c, b)		\
924981e6b25SMatt Jacob 	(((c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 30]) | \
925981e6b25SMatt Jacob 	((c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 31] << 8))
926981e6b25SMatt Jacob #define	ISP1080_NVRAM_MAX_QUEUE_DEPTH(c, b)		\
927981e6b25SMatt Jacob 	(((c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 32]) | \
928981e6b25SMatt Jacob 	((c)[((b == 0)? 0 : ISP1080_BUS1_OFF) + 33] << 8))
929981e6b25SMatt Jacob 
930981e6b25SMatt Jacob #define	ISP1080_NVRAM_TARGOFF(b)		\
931981e6b25SMatt Jacob 	((b == 0)? 40: (40 + ISP1080_BUS1_OFF))
932981e6b25SMatt Jacob #define	ISP1080_NVRAM_TARGSIZE			6
933981e6b25SMatt Jacob #define	_IxT8(tgt, tidx, b)			\
934981e6b25SMatt Jacob 	(ISP1080_NVRAM_TARGOFF((b)) + (ISP1080_NVRAM_TARGSIZE * (tgt)) + (tidx))
935981e6b25SMatt Jacob 
936981e6b25SMatt Jacob #define	ISP1080_NVRAM_TGT_RENEG(c, t, b)		\
937981e6b25SMatt Jacob 	ISPBSMX(c, _IxT8(t, 0, (b)), 0, 0x01)
938981e6b25SMatt Jacob #define	ISP1080_NVRAM_TGT_QFRZ(c, t, b)			\
939981e6b25SMatt Jacob 	ISPBSMX(c, _IxT8(t, 0, (b)), 1, 0x01)
940981e6b25SMatt Jacob #define	ISP1080_NVRAM_TGT_ARQ(c, t, b)			\
941981e6b25SMatt Jacob 	ISPBSMX(c, _IxT8(t, 0, (b)), 2, 0x01)
942981e6b25SMatt Jacob #define	ISP1080_NVRAM_TGT_TQING(c, t, b)		\
943981e6b25SMatt Jacob 	ISPBSMX(c, _IxT8(t, 0, (b)), 3, 0x01)
944981e6b25SMatt Jacob #define	ISP1080_NVRAM_TGT_SYNC(c, t, b)			\
945981e6b25SMatt Jacob 	ISPBSMX(c, _IxT8(t, 0, (b)), 4, 0x01)
946981e6b25SMatt Jacob #define	ISP1080_NVRAM_TGT_WIDE(c, t, b)			\
947981e6b25SMatt Jacob 	ISPBSMX(c, _IxT8(t, 0, (b)), 5, 0x01)
948981e6b25SMatt Jacob #define	ISP1080_NVRAM_TGT_PARITY(c, t, b)		\
949981e6b25SMatt Jacob 	ISPBSMX(c, _IxT8(t, 0, (b)), 6, 0x01)
950981e6b25SMatt Jacob #define	ISP1080_NVRAM_TGT_DISC(c, t, b)			\
951981e6b25SMatt Jacob 	ISPBSMX(c, _IxT8(t, 0, (b)), 7, 0x01)
952981e6b25SMatt Jacob #define	ISP1080_NVRAM_TGT_EXEC_THROTTLE(c, t, b)	\
953981e6b25SMatt Jacob 	ISPBSMX(c, _IxT8(t, 1, (b)), 0, 0xff)
954981e6b25SMatt Jacob #define	ISP1080_NVRAM_TGT_SYNC_PERIOD(c, t, b)		\
955981e6b25SMatt Jacob 	ISPBSMX(c, _IxT8(t, 2, (b)), 0, 0xff)
956981e6b25SMatt Jacob #define	ISP1080_NVRAM_TGT_SYNC_OFFSET(c, t, b)		\
957981e6b25SMatt Jacob 	ISPBSMX(c, _IxT8(t, 3, (b)), 0, 0x0f)
958981e6b25SMatt Jacob #define	ISP1080_NVRAM_TGT_DEVICE_ENABLE(c, t, b)	\
959981e6b25SMatt Jacob 	ISPBSMX(c, _IxT8(t, 3, (b)), 4, 0x01)
960981e6b25SMatt Jacob #define	ISP1080_NVRAM_TGT_LUN_DISABLE(c, t, b)		\
961981e6b25SMatt Jacob 	ISPBSMX(c, _IxT8(t, 3, (b)), 5, 0x01)
962981e6b25SMatt Jacob 
963c211f23bSMatt Jacob #define	ISP12160_NVRAM_HBA_ENABLE	ISP1080_NVRAM_HBA_ENABLE
964c211f23bSMatt Jacob #define	ISP12160_NVRAM_BURST_ENABLE	ISP1080_NVRAM_BURST_ENABLE
965c211f23bSMatt Jacob #define	ISP12160_NVRAM_FIFO_THRESHOLD	ISP1080_NVRAM_FIFO_THRESHOLD
966c211f23bSMatt Jacob #define	ISP12160_NVRAM_AUTO_TERM_SUPPORT	ISP1080_NVRAM_AUTO_TERM_SUPPORT
967c211f23bSMatt Jacob #define	ISP12160_NVRAM_BUS0_TERM_MODE	ISP1080_NVRAM_BUS0_TERM_MODE
968c211f23bSMatt Jacob #define	ISP12160_NVRAM_BUS1_TERM_MODE	ISP1080_NVRAM_BUS1_TERM_MODE
969c211f23bSMatt Jacob #define	ISP12160_ISP_PARAMETER		ISP12160_ISP_PARAMETER
970c211f23bSMatt Jacob #define	ISP12160_FAST_POST		ISP1080_FAST_POST
971c211f23bSMatt Jacob #define	ISP12160_REPORT_LVD_TRANSITION	ISP1080_REPORT_LVD_TRANSTION
972c211f23bSMatt Jacob 
973c211f23bSMatt Jacob #define	ISP12160_NVRAM_INITIATOR_ID			\
974c211f23bSMatt Jacob 	ISP1080_NVRAM_INITIATOR_ID
975c211f23bSMatt Jacob #define	ISP12160_NVRAM_BUS_RESET_DELAY			\
976c211f23bSMatt Jacob 	ISP1080_NVRAM_BUS_RESET_DELAY
977c211f23bSMatt Jacob #define	ISP12160_NVRAM_BUS_RETRY_COUNT			\
978c211f23bSMatt Jacob 	ISP1080_NVRAM_BUS_RETRY_COUNT
979c211f23bSMatt Jacob #define	ISP12160_NVRAM_BUS_RETRY_DELAY			\
980c211f23bSMatt Jacob 	ISP1080_NVRAM_BUS_RETRY_DELAY
981c211f23bSMatt Jacob #define	ISP12160_NVRAM_ASYNC_DATA_SETUP_TIME		\
982c211f23bSMatt Jacob 	ISP1080_NVRAM_ASYNC_DATA_SETUP_TIME
983c211f23bSMatt Jacob #define	ISP12160_NVRAM_REQ_ACK_ACTIVE_NEGATION		\
984c211f23bSMatt Jacob 	ISP1080_NVRAM_REQ_ACK_ACTIVE_NEGATION
985c211f23bSMatt Jacob #define	ISP12160_NVRAM_DATA_LINE_ACTIVE_NEGATION	\
986c211f23bSMatt Jacob 	ISP1080_NVRAM_DATA_LINE_ACTIVE_NEGATION
987c211f23bSMatt Jacob #define	ISP12160_NVRAM_SELECTION_TIMEOUT		\
988c211f23bSMatt Jacob 	ISP1080_NVRAM_SELECTION_TIMEOUT
989c211f23bSMatt Jacob #define	ISP12160_NVRAM_MAX_QUEUE_DEPTH			\
990c211f23bSMatt Jacob 	ISP1080_NVRAM_MAX_QUEUE_DEPTH
991c211f23bSMatt Jacob 
992c211f23bSMatt Jacob 
993c211f23bSMatt Jacob #define	ISP12160_BUS0_OFF	24
994c211f23bSMatt Jacob #define	ISP12160_BUS1_OFF	136
995c211f23bSMatt Jacob 
996c211f23bSMatt Jacob #define	ISP12160_NVRAM_TARGOFF(b)		\
997c211f23bSMatt Jacob 	(((b == 0)? ISP12160_BUS0_OFF : ISP12160_BUS1_OFF) + 16)
998c211f23bSMatt Jacob 
999c211f23bSMatt Jacob #define	ISP12160_NVRAM_TARGSIZE			6
1000c211f23bSMatt Jacob #define	_IxT16(tgt, tidx, b)			\
1001c211f23bSMatt Jacob 	(ISP12160_NVRAM_TARGOFF((b))+(ISP12160_NVRAM_TARGSIZE * (tgt))+(tidx))
1002c211f23bSMatt Jacob 
1003c211f23bSMatt Jacob #define	ISP12160_NVRAM_TGT_RENEG(c, t, b)		\
1004c211f23bSMatt Jacob 	ISPBSMX(c, _IxT16(t, 0, (b)), 0, 0x01)
1005c211f23bSMatt Jacob #define	ISP12160_NVRAM_TGT_QFRZ(c, t, b)		\
1006c211f23bSMatt Jacob 	ISPBSMX(c, _IxT16(t, 0, (b)), 1, 0x01)
1007c211f23bSMatt Jacob #define	ISP12160_NVRAM_TGT_ARQ(c, t, b)			\
1008c211f23bSMatt Jacob 	ISPBSMX(c, _IxT16(t, 0, (b)), 2, 0x01)
1009c211f23bSMatt Jacob #define	ISP12160_NVRAM_TGT_TQING(c, t, b)		\
1010c211f23bSMatt Jacob 	ISPBSMX(c, _IxT16(t, 0, (b)), 3, 0x01)
1011c211f23bSMatt Jacob #define	ISP12160_NVRAM_TGT_SYNC(c, t, b)		\
1012c211f23bSMatt Jacob 	ISPBSMX(c, _IxT16(t, 0, (b)), 4, 0x01)
1013c211f23bSMatt Jacob #define	ISP12160_NVRAM_TGT_WIDE(c, t, b)		\
1014c211f23bSMatt Jacob 	ISPBSMX(c, _IxT16(t, 0, (b)), 5, 0x01)
1015c211f23bSMatt Jacob #define	ISP12160_NVRAM_TGT_PARITY(c, t, b)		\
1016c211f23bSMatt Jacob 	ISPBSMX(c, _IxT16(t, 0, (b)), 6, 0x01)
1017c211f23bSMatt Jacob #define	ISP12160_NVRAM_TGT_DISC(c, t, b)		\
1018c211f23bSMatt Jacob 	ISPBSMX(c, _IxT16(t, 0, (b)), 7, 0x01)
1019c211f23bSMatt Jacob 
1020c211f23bSMatt Jacob #define	ISP12160_NVRAM_TGT_EXEC_THROTTLE(c, t, b)	\
1021c211f23bSMatt Jacob 	ISPBSMX(c, _IxT16(t, 1, (b)), 0, 0xff)
1022c211f23bSMatt Jacob #define	ISP12160_NVRAM_TGT_SYNC_PERIOD(c, t, b)		\
1023c211f23bSMatt Jacob 	ISPBSMX(c, _IxT16(t, 2, (b)), 0, 0xff)
1024c211f23bSMatt Jacob 
1025c211f23bSMatt Jacob #define	ISP12160_NVRAM_TGT_SYNC_OFFSET(c, t, b)		\
1026c211f23bSMatt Jacob 	ISPBSMX(c, _IxT16(t, 3, (b)), 0, 0x1f)
1027c211f23bSMatt Jacob #define	ISP12160_NVRAM_TGT_DEVICE_ENABLE(c, t, b)	\
1028c211f23bSMatt Jacob 	ISPBSMX(c, _IxT16(t, 3, (b)), 5, 0x01)
1029c211f23bSMatt Jacob 
1030c211f23bSMatt Jacob #define	ISP12160_NVRAM_PPR_OPTIONS(c, t, b)		\
1031c211f23bSMatt Jacob 	ISPBSMX(c, _IxT16(t, 4, (b)), 0, 0x0f)
1032c211f23bSMatt Jacob #define	ISP12160_NVRAM_PPR_WIDTH(c, t, b)		\
1033c211f23bSMatt Jacob 	ISPBSMX(c, _IxT16(t, 4, (b)), 4, 0x03)
1034c211f23bSMatt Jacob #define	ISP12160_NVRAM_PPR_ENABLE(c, t, b)		\
1035c211f23bSMatt Jacob 	ISPBSMX(c, _IxT16(t, 4, (b)), 7, 0x01)
1036c211f23bSMatt Jacob 
1037981e6b25SMatt Jacob /*
103810365e5aSMatt Jacob  * Qlogic 2100 thru 2300 NVRAM is an array of 256 bytes.
1039478f8a96SJustin T. Gibbs  *
1040478f8a96SJustin T. Gibbs  * Some portion of the front of this is for general RISC engine parameters,
1041478f8a96SJustin T. Gibbs  * mostly reflecting the state of the last INITIALIZE FIRMWARE mailbox command.
1042478f8a96SJustin T. Gibbs  *
1043478f8a96SJustin T. Gibbs  * This is followed by some general host adapter parameters, and ends with
1044478f8a96SJustin T. Gibbs  * a checksum xor byte at offset 255. For non-byte entities data is stored
1045478f8a96SJustin T. Gibbs  * in Little Endian order.
1046478f8a96SJustin T. Gibbs  */
1047478f8a96SJustin T. Gibbs #define	ISP2100_NVRAM_SIZE	256
1048478f8a96SJustin T. Gibbs /* ISP_NVRAM_VERSION is in same overall place */
1049478f8a96SJustin T. Gibbs #define	ISP2100_NVRAM_RISCVER(c)		(c)[6]
10508a97c03aSMatt Jacob #define	ISP2100_NVRAM_OPTIONS(c)		((c)[8] | ((c)[9] << 8))
1051478f8a96SJustin T. Gibbs #define	ISP2100_NVRAM_MAXFRAMELENGTH(c)		(((c)[10]) | ((c)[11] << 8))
1052478f8a96SJustin T. Gibbs #define	ISP2100_NVRAM_MAXIOCBALLOCATION(c)	(((c)[12]) | ((c)[13] << 8))
1053478f8a96SJustin T. Gibbs #define	ISP2100_NVRAM_EXECUTION_THROTTLE(c)	(((c)[14]) | ((c)[15] << 8))
1054478f8a96SJustin T. Gibbs #define	ISP2100_NVRAM_RETRY_COUNT(c)		(c)[16]
1055478f8a96SJustin T. Gibbs #define	ISP2100_NVRAM_RETRY_DELAY(c)		(c)[17]
1056478f8a96SJustin T. Gibbs 
1057a96d513dSMatt Jacob #define	ISP2100_NVRAM_PORT_NAME(c)	(\
10581dae40ebSMatt Jacob 		(((uint64_t)(c)[18]) << 56) | \
10591dae40ebSMatt Jacob 		(((uint64_t)(c)[19]) << 48) | \
10601dae40ebSMatt Jacob 		(((uint64_t)(c)[20]) << 40) | \
10611dae40ebSMatt Jacob 		(((uint64_t)(c)[21]) << 32) | \
10621dae40ebSMatt Jacob 		(((uint64_t)(c)[22]) << 24) | \
10631dae40ebSMatt Jacob 		(((uint64_t)(c)[23]) << 16) | \
10641dae40ebSMatt Jacob 		(((uint64_t)(c)[24]) <<  8) | \
10651dae40ebSMatt Jacob 		(((uint64_t)(c)[25]) <<  0))
1066a96d513dSMatt Jacob 
10678a97c03aSMatt Jacob #define	ISP2100_NVRAM_HARDLOOPID(c)		((c)[26] | ((c)[27] << 8))
10688a97c03aSMatt Jacob #define	ISP2100_NVRAM_TOV(c)			((c)[29])
1069478f8a96SJustin T. Gibbs 
10708a97c03aSMatt Jacob #define	ISP2100_NVRAM_NODE_NAME(c)	(\
10711dae40ebSMatt Jacob 		(((uint64_t)(c)[30]) << 56) | \
10721dae40ebSMatt Jacob 		(((uint64_t)(c)[31]) << 48) | \
10731dae40ebSMatt Jacob 		(((uint64_t)(c)[32]) << 40) | \
10741dae40ebSMatt Jacob 		(((uint64_t)(c)[33]) << 32) | \
10751dae40ebSMatt Jacob 		(((uint64_t)(c)[34]) << 24) | \
10761dae40ebSMatt Jacob 		(((uint64_t)(c)[35]) << 16) | \
10771dae40ebSMatt Jacob 		(((uint64_t)(c)[36]) <<  8) | \
10781dae40ebSMatt Jacob 		(((uint64_t)(c)[37]) <<  0))
1079a96d513dSMatt Jacob 
10808a97c03aSMatt Jacob #define	ISP2100_XFW_OPTIONS(c)			((c)[38] | ((c)[39] << 8))
10818a97c03aSMatt Jacob 
10828a97c03aSMatt Jacob #define	ISP2100_RACC_TIMER(c)			(c)[40]
10838a97c03aSMatt Jacob #define	ISP2100_IDELAY_TIMER(c)			(c)[41]
10848a97c03aSMatt Jacob 
10858a97c03aSMatt Jacob #define	ISP2100_ZFW_OPTIONS(c)			((c)[42] | ((c)[43] << 8))
10868a97c03aSMatt Jacob 
10878a97c03aSMatt Jacob #define	ISP2100_SERIAL_LINK(c)			((c)[68] | ((c)[69] << 8))
10888a97c03aSMatt Jacob 
10898a97c03aSMatt Jacob #define	ISP2100_NVRAM_HBA_OPTIONS(c)		((c)[70] | ((c)[71] << 8))
1090478f8a96SJustin T. Gibbs #define	ISP2100_NVRAM_HBA_DISABLE(c)		ISPBSMX(c, 70, 0, 0x01)
1091478f8a96SJustin T. Gibbs #define	ISP2100_NVRAM_BIOS_DISABLE(c)		ISPBSMX(c, 70, 1, 0x01)
1092478f8a96SJustin T. Gibbs #define	ISP2100_NVRAM_LUN_DISABLE(c)		ISPBSMX(c, 70, 2, 0x01)
1093478f8a96SJustin T. Gibbs #define	ISP2100_NVRAM_ENABLE_SELECT_BOOT(c)	ISPBSMX(c, 70, 3, 0x01)
1094478f8a96SJustin T. Gibbs #define	ISP2100_NVRAM_DISABLE_CODELOAD(c)	ISPBSMX(c, 70, 4, 0x01)
1095478f8a96SJustin T. Gibbs #define	ISP2100_NVRAM_SET_CACHELINESZ(c)	ISPBSMX(c, 70, 5, 0x01)
1096478f8a96SJustin T. Gibbs 
1097478f8a96SJustin T. Gibbs #define	ISP2100_NVRAM_BOOT_NODE_NAME(c)	(\
10981dae40ebSMatt Jacob 		(((uint64_t)(c)[72]) << 56) | \
10991dae40ebSMatt Jacob 		(((uint64_t)(c)[73]) << 48) | \
11001dae40ebSMatt Jacob 		(((uint64_t)(c)[74]) << 40) | \
11011dae40ebSMatt Jacob 		(((uint64_t)(c)[75]) << 32) | \
11021dae40ebSMatt Jacob 		(((uint64_t)(c)[76]) << 24) | \
11031dae40ebSMatt Jacob 		(((uint64_t)(c)[77]) << 16) | \
11041dae40ebSMatt Jacob 		(((uint64_t)(c)[78]) <<  8) | \
11051dae40ebSMatt Jacob 		(((uint64_t)(c)[79]) <<  0))
110668ce4ba5SMatt Jacob 
1107478f8a96SJustin T. Gibbs #define	ISP2100_NVRAM_BOOT_LUN(c)		(c)[80]
11088a97c03aSMatt Jacob #define	ISP2100_RESET_DELAY(c)			(c)[81]
1109478f8a96SJustin T. Gibbs 
11108a97c03aSMatt Jacob #define	ISP2100_HBA_FEATURES(c)			((c)[232] | ((c)[233] << 8))
1111b8941882SMatt Jacob 
1112b8941882SMatt Jacob /*
111310365e5aSMatt Jacob  * Qlogic 2400 NVRAM is an array of 512 bytes with a 32 bit checksum.
111410365e5aSMatt Jacob  */
111510365e5aSMatt Jacob #define	ISP2400_NVRAM_PORT0_ADDR	0x80
111610365e5aSMatt Jacob #define	ISP2400_NVRAM_PORT1_ADDR	0x180
111710365e5aSMatt Jacob #define	ISP2400_NVRAM_SIZE		512
111810365e5aSMatt Jacob 
111910365e5aSMatt Jacob #define	ISP2400_NVRAM_VERSION(c)		((c)[4] | ((c)[5] << 8))
112010365e5aSMatt Jacob #define	ISP2400_NVRAM_MAXFRAMELENGTH(c)		(((c)[12]) | ((c)[13] << 8))
112110365e5aSMatt Jacob #define	ISP2400_NVRAM_EXECUTION_THROTTLE(c)	(((c)[14]) | ((c)[15] << 8))
112210365e5aSMatt Jacob #define	ISP2400_NVRAM_EXCHANGE_COUNT(c)		(((c)[16]) | ((c)[17] << 8))
112310365e5aSMatt Jacob #define	ISP2400_NVRAM_HARDLOOPID(c)		((c)[18] | ((c)[19] << 8))
112410365e5aSMatt Jacob 
112510365e5aSMatt Jacob #define	ISP2400_NVRAM_PORT_NAME(c)	(\
112610365e5aSMatt Jacob 		(((uint64_t)(c)[20]) << 56) | \
112710365e5aSMatt Jacob 		(((uint64_t)(c)[21]) << 48) | \
112810365e5aSMatt Jacob 		(((uint64_t)(c)[22]) << 40) | \
112910365e5aSMatt Jacob 		(((uint64_t)(c)[23]) << 32) | \
113010365e5aSMatt Jacob 		(((uint64_t)(c)[24]) << 24) | \
113110365e5aSMatt Jacob 		(((uint64_t)(c)[25]) << 16) | \
113210365e5aSMatt Jacob 		(((uint64_t)(c)[26]) <<  8) | \
113310365e5aSMatt Jacob 		(((uint64_t)(c)[27]) <<  0))
113410365e5aSMatt Jacob 
113510365e5aSMatt Jacob #define	ISP2400_NVRAM_NODE_NAME(c)	(\
113610365e5aSMatt Jacob 		(((uint64_t)(c)[28]) << 56) | \
113710365e5aSMatt Jacob 		(((uint64_t)(c)[29]) << 48) | \
113810365e5aSMatt Jacob 		(((uint64_t)(c)[30]) << 40) | \
113910365e5aSMatt Jacob 		(((uint64_t)(c)[31]) << 32) | \
114010365e5aSMatt Jacob 		(((uint64_t)(c)[32]) << 24) | \
114110365e5aSMatt Jacob 		(((uint64_t)(c)[33]) << 16) | \
114210365e5aSMatt Jacob 		(((uint64_t)(c)[34]) <<  8) | \
114310365e5aSMatt Jacob 		(((uint64_t)(c)[35]) <<  0))
114410365e5aSMatt Jacob 
114510365e5aSMatt Jacob #define	ISP2400_NVRAM_LOGIN_RETRY_CNT(c)	((c)[36] | ((c)[37] << 8))
114610365e5aSMatt Jacob #define	ISP2400_NVRAM_LINK_DOWN_ON_NOS(c)	((c)[38] | ((c)[39] << 8))
114710365e5aSMatt Jacob #define	ISP2400_NVRAM_INTERRUPT_DELAY(c)	((c)[40] | ((c)[41] << 8))
114810365e5aSMatt Jacob #define	ISP2400_NVRAM_LOGIN_TIMEOUT(c)		((c)[42] | ((c)[43] << 8))
114910365e5aSMatt Jacob 
115010365e5aSMatt Jacob #define	ISP2400_NVRAM_FIRMWARE_OPTIONS1(c)	\
115110365e5aSMatt Jacob 	((c)[44] | ((c)[45] << 8) | ((c)[46] << 16) | ((c)[47] << 24))
115210365e5aSMatt Jacob #define	ISP2400_NVRAM_FIRMWARE_OPTIONS2(c)	\
115310365e5aSMatt Jacob 	((c)[48] | ((c)[49] << 8) | ((c)[50] << 16) | ((c)[51] << 24))
115410365e5aSMatt Jacob #define	ISP2400_NVRAM_FIRMWARE_OPTIONS3(c)	\
115510365e5aSMatt Jacob 	((c)[52] | ((c)[53] << 8) | ((c)[54] << 16) | ((c)[55] << 24))
115610365e5aSMatt Jacob 
115710365e5aSMatt Jacob /*
1158b8941882SMatt Jacob  * Firmware Crash Dump
1159b8941882SMatt Jacob  *
1160b8941882SMatt Jacob  * QLogic needs specific information format when they look at firmware crashes.
1161b8941882SMatt Jacob  *
1162b8941882SMatt Jacob  * This is incredibly kernel memory consumptive (to say the least), so this
1163b8941882SMatt Jacob  * code is only compiled in when needed.
1164b8941882SMatt Jacob  */
1165b8941882SMatt Jacob 
1166b8941882SMatt Jacob #define	QLA2200_RISC_IMAGE_DUMP_SIZE					\
11671dae40ebSMatt Jacob 	(1 * sizeof (uint16_t)) +	/* 'used' flag (also HBA type) */ \
11681dae40ebSMatt Jacob 	(352 * sizeof (uint16_t)) +	/* RISC registers */		\
11691dae40ebSMatt Jacob  	(61440 * sizeof (uint16_t))	/* RISC SRAM (offset 0x1000..0xffff) */
1170b8941882SMatt Jacob #define	QLA2300_RISC_IMAGE_DUMP_SIZE					\
11711dae40ebSMatt Jacob 	(1 * sizeof (uint16_t)) +	/* 'used' flag (also HBA type) */ \
11721dae40ebSMatt Jacob 	(464 * sizeof (uint16_t)) +	/* RISC registers */		\
11731dae40ebSMatt Jacob  	(63488 * sizeof (uint16_t)) +	/* RISC SRAM (0x0800..0xffff) */ \
11741dae40ebSMatt Jacob 	(4096 * sizeof (uint16_t)) +	/* RISC SRAM (0x10000..0x10FFF) */ \
11751dae40ebSMatt Jacob 	(61440 * sizeof (uint16_t))	/* RISC SRAM (0x11000..0x1FFFF) */
1176b8941882SMatt Jacob /* the larger of the two */
1177b8941882SMatt Jacob #define	ISP_CRASH_IMAGE_SIZE	QLA2300_RISC_IMAGE_DUMP_SIZE
11786054c3f6SMatt Jacob #endif	/* _ISPREG_H */
1179