xref: /openbmc/linux/drivers/scsi/qla2xxx/qla_nx.h (revision 9c2b297572bf3cc36d26520cd8f7e7ef4cb857f8)
1a9083016SGiridhar Malavali /*
2a9083016SGiridhar Malavali  * QLogic Fibre Channel HBA Driver
3a9083016SGiridhar Malavali  * Copyright (c)  2003-2008 QLogic Corporation
4a9083016SGiridhar Malavali  *
5a9083016SGiridhar Malavali  * See LICENSE.qla2xxx for copyright and licensing details.
6a9083016SGiridhar Malavali  */
7a9083016SGiridhar Malavali #ifndef __QLA_NX_H
8a9083016SGiridhar Malavali #define __QLA_NX_H
9a9083016SGiridhar Malavali 
10a9083016SGiridhar Malavali /*
11a9083016SGiridhar Malavali  * Following are the states of the Phantom. Phantom will set them and
12a9083016SGiridhar Malavali  * Host will read to check if the fields are correct.
13a9083016SGiridhar Malavali */
14a9083016SGiridhar Malavali #define PHAN_INITIALIZE_FAILED	      0xffff
15a9083016SGiridhar Malavali #define PHAN_INITIALIZE_COMPLETE      0xff01
16a9083016SGiridhar Malavali 
17a9083016SGiridhar Malavali /* Host writes the following to notify that it has done the init-handshake */
18a9083016SGiridhar Malavali #define PHAN_INITIALIZE_ACK	      0xf00f
19a9083016SGiridhar Malavali #define PHAN_PEG_RCV_INITIALIZED      0xff01
20a9083016SGiridhar Malavali 
21a9083016SGiridhar Malavali /*CRB_RELATED*/
22a9083016SGiridhar Malavali #define QLA82XX_CRB_BASE	QLA82XX_CAM_RAM(0x200)
23a9083016SGiridhar Malavali #define QLA82XX_REG(X)		(QLA82XX_CRB_BASE+(X))
24a9083016SGiridhar Malavali 
25a9083016SGiridhar Malavali #define CRB_CMDPEG_STATE		QLA82XX_REG(0x50)
26a9083016SGiridhar Malavali #define CRB_RCVPEG_STATE		QLA82XX_REG(0x13c)
27a9083016SGiridhar Malavali #define BOOT_LOADER_DIMM_STATUS		QLA82XX_REG(0x54)
28a9083016SGiridhar Malavali #define CRB_DMA_SHIFT			QLA82XX_REG(0xcc)
29a9083016SGiridhar Malavali 
30a9083016SGiridhar Malavali #define QLA82XX_HW_H0_CH_HUB_ADR    0x05
31a9083016SGiridhar Malavali #define QLA82XX_HW_H1_CH_HUB_ADR    0x0E
32a9083016SGiridhar Malavali #define QLA82XX_HW_H2_CH_HUB_ADR    0x03
33a9083016SGiridhar Malavali #define QLA82XX_HW_H3_CH_HUB_ADR    0x01
34a9083016SGiridhar Malavali #define QLA82XX_HW_H4_CH_HUB_ADR    0x06
35a9083016SGiridhar Malavali #define QLA82XX_HW_H5_CH_HUB_ADR    0x07
36a9083016SGiridhar Malavali #define QLA82XX_HW_H6_CH_HUB_ADR    0x08
37a9083016SGiridhar Malavali 
38a9083016SGiridhar Malavali /*  Hub 0 */
39a9083016SGiridhar Malavali #define QLA82XX_HW_MN_CRB_AGT_ADR   0x15
40a9083016SGiridhar Malavali #define QLA82XX_HW_MS_CRB_AGT_ADR   0x25
41a9083016SGiridhar Malavali 
42a9083016SGiridhar Malavali /*  Hub 1 */
43a9083016SGiridhar Malavali #define QLA82XX_HW_PS_CRB_AGT_ADR	0x73
44a9083016SGiridhar Malavali #define QLA82XX_HW_QMS_CRB_AGT_ADR	0x00
45a9083016SGiridhar Malavali #define QLA82XX_HW_RPMX3_CRB_AGT_ADR	0x0b
46a9083016SGiridhar Malavali #define QLA82XX_HW_SQGS0_CRB_AGT_ADR	0x01
47a9083016SGiridhar Malavali #define QLA82XX_HW_SQGS1_CRB_AGT_ADR	0x02
48a9083016SGiridhar Malavali #define QLA82XX_HW_SQGS2_CRB_AGT_ADR	0x03
49a9083016SGiridhar Malavali #define QLA82XX_HW_SQGS3_CRB_AGT_ADR	0x04
50a9083016SGiridhar Malavali #define QLA82XX_HW_C2C0_CRB_AGT_ADR	0x58
51a9083016SGiridhar Malavali #define QLA82XX_HW_C2C1_CRB_AGT_ADR	0x59
52a9083016SGiridhar Malavali #define QLA82XX_HW_C2C2_CRB_AGT_ADR	0x5a
53a9083016SGiridhar Malavali #define QLA82XX_HW_RPMX2_CRB_AGT_ADR	0x0a
54a9083016SGiridhar Malavali #define QLA82XX_HW_RPMX4_CRB_AGT_ADR	0x0c
55a9083016SGiridhar Malavali #define QLA82XX_HW_RPMX7_CRB_AGT_ADR	0x0f
56a9083016SGiridhar Malavali #define QLA82XX_HW_RPMX9_CRB_AGT_ADR	0x12
57a9083016SGiridhar Malavali #define QLA82XX_HW_SMB_CRB_AGT_ADR	0x18
58a9083016SGiridhar Malavali 
59a9083016SGiridhar Malavali /*  Hub 2 */
60a9083016SGiridhar Malavali #define QLA82XX_HW_NIU_CRB_AGT_ADR	0x31
61a9083016SGiridhar Malavali #define QLA82XX_HW_I2C0_CRB_AGT_ADR	0x19
62a9083016SGiridhar Malavali #define QLA82XX_HW_I2C1_CRB_AGT_ADR	0x29
63a9083016SGiridhar Malavali 
64a9083016SGiridhar Malavali #define QLA82XX_HW_SN_CRB_AGT_ADR	0x10
65a9083016SGiridhar Malavali #define QLA82XX_HW_I2Q_CRB_AGT_ADR	0x20
66a9083016SGiridhar Malavali #define QLA82XX_HW_LPC_CRB_AGT_ADR	0x22
67a9083016SGiridhar Malavali #define QLA82XX_HW_ROMUSB_CRB_AGT_ADR	0x21
68a9083016SGiridhar Malavali #define QLA82XX_HW_QM_CRB_AGT_ADR	0x66
69a9083016SGiridhar Malavali #define QLA82XX_HW_SQG0_CRB_AGT_ADR	0x60
70a9083016SGiridhar Malavali #define QLA82XX_HW_SQG1_CRB_AGT_ADR	0x61
71a9083016SGiridhar Malavali #define QLA82XX_HW_SQG2_CRB_AGT_ADR	0x62
72a9083016SGiridhar Malavali #define QLA82XX_HW_SQG3_CRB_AGT_ADR	0x63
73a9083016SGiridhar Malavali #define QLA82XX_HW_RPMX1_CRB_AGT_ADR	0x09
74a9083016SGiridhar Malavali #define QLA82XX_HW_RPMX5_CRB_AGT_ADR	0x0d
75a9083016SGiridhar Malavali #define QLA82XX_HW_RPMX6_CRB_AGT_ADR	0x0e
76a9083016SGiridhar Malavali #define QLA82XX_HW_RPMX8_CRB_AGT_ADR	0x11
77a9083016SGiridhar Malavali 
78a9083016SGiridhar Malavali /*  Hub 3 */
79a9083016SGiridhar Malavali #define QLA82XX_HW_PH_CRB_AGT_ADR	0x1A
80a9083016SGiridhar Malavali #define QLA82XX_HW_SRE_CRB_AGT_ADR	0x50
81a9083016SGiridhar Malavali #define QLA82XX_HW_EG_CRB_AGT_ADR	0x51
82a9083016SGiridhar Malavali #define QLA82XX_HW_RPMX0_CRB_AGT_ADR	0x08
83a9083016SGiridhar Malavali 
84a9083016SGiridhar Malavali /*  Hub 4 */
85a9083016SGiridhar Malavali #define QLA82XX_HW_PEGN0_CRB_AGT_ADR	0x40
86a9083016SGiridhar Malavali #define QLA82XX_HW_PEGN1_CRB_AGT_ADR	0x41
87a9083016SGiridhar Malavali #define QLA82XX_HW_PEGN2_CRB_AGT_ADR	0x42
88a9083016SGiridhar Malavali #define QLA82XX_HW_PEGN3_CRB_AGT_ADR	0x43
89a9083016SGiridhar Malavali #define QLA82XX_HW_PEGNI_CRB_AGT_ADR	0x44
90a9083016SGiridhar Malavali #define QLA82XX_HW_PEGND_CRB_AGT_ADR	0x45
91a9083016SGiridhar Malavali #define QLA82XX_HW_PEGNC_CRB_AGT_ADR	0x46
92a9083016SGiridhar Malavali #define QLA82XX_HW_PEGR0_CRB_AGT_ADR	0x47
93a9083016SGiridhar Malavali #define QLA82XX_HW_PEGR1_CRB_AGT_ADR	0x48
94a9083016SGiridhar Malavali #define QLA82XX_HW_PEGR2_CRB_AGT_ADR	0x49
95a9083016SGiridhar Malavali #define QLA82XX_HW_PEGR3_CRB_AGT_ADR	0x4a
96a9083016SGiridhar Malavali #define QLA82XX_HW_PEGN4_CRB_AGT_ADR	0x4b
97a9083016SGiridhar Malavali 
98a9083016SGiridhar Malavali /*  Hub 5 */
99a9083016SGiridhar Malavali #define QLA82XX_HW_PEGS0_CRB_AGT_ADR	0x40
100a9083016SGiridhar Malavali #define QLA82XX_HW_PEGS1_CRB_AGT_ADR	0x41
101a9083016SGiridhar Malavali #define QLA82XX_HW_PEGS2_CRB_AGT_ADR	0x42
102a9083016SGiridhar Malavali #define QLA82XX_HW_PEGS3_CRB_AGT_ADR	0x43
103a9083016SGiridhar Malavali #define QLA82XX_HW_PEGSI_CRB_AGT_ADR	0x44
104a9083016SGiridhar Malavali #define QLA82XX_HW_PEGSD_CRB_AGT_ADR	0x45
105a9083016SGiridhar Malavali #define QLA82XX_HW_PEGSC_CRB_AGT_ADR	0x46
106a9083016SGiridhar Malavali 
107a9083016SGiridhar Malavali /*  Hub 6 */
108a9083016SGiridhar Malavali #define QLA82XX_HW_CAS0_CRB_AGT_ADR	0x46
109a9083016SGiridhar Malavali #define QLA82XX_HW_CAS1_CRB_AGT_ADR	0x47
110a9083016SGiridhar Malavali #define QLA82XX_HW_CAS2_CRB_AGT_ADR	0x48
111a9083016SGiridhar Malavali #define QLA82XX_HW_CAS3_CRB_AGT_ADR	0x49
112a9083016SGiridhar Malavali #define QLA82XX_HW_NCM_CRB_AGT_ADR	0x16
113a9083016SGiridhar Malavali #define QLA82XX_HW_TMR_CRB_AGT_ADR	0x17
114a9083016SGiridhar Malavali #define QLA82XX_HW_XDMA_CRB_AGT_ADR	0x05
115a9083016SGiridhar Malavali #define QLA82XX_HW_OCM0_CRB_AGT_ADR	0x06
116a9083016SGiridhar Malavali #define QLA82XX_HW_OCM1_CRB_AGT_ADR	0x07
117a9083016SGiridhar Malavali 
118a9083016SGiridhar Malavali /*  This field defines PCI/X adr [25:20] of agents on the CRB */
119a9083016SGiridhar Malavali /*  */
120a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PH	0
121a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PS	1
122a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_MN	2
123a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_MS	3
124a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_SRE	5
125a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_NIU	6
126a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_QMN	7
127a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_SQN0	8
128a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_SQN1	9
129a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_SQN2	10
130a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_SQN3	11
131a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_QMS	12
132a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_SQS0	13
133a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_SQS1	14
134a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_SQS2	15
135a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_SQS3	16
136a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGN0	17
137a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGN1	18
138a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGN2	19
139a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGN3	20
140a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGN4	QLA82XX_HW_PX_MAP_CRB_SQS2
141a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGND	21
142a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGNI	22
143a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGS0	23
144a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGS1	24
145a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGS2	25
146a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGS3	26
147a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGSD	27
148a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGSI	28
149a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_SN	29
150a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_EG	31
151a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PH2	32
152a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PS2	33
153a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_CAM	34
154a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_CAS0	35
155a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_CAS1	36
156a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_CAS2	37
157a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_C2C0	38
158a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_C2C1	39
159a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_TIMR	40
160a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_RPMX1	42
161a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_RPMX2	43
162a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_RPMX3	44
163a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_RPMX4	45
164a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_RPMX5	46
165a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_RPMX6	47
166a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_RPMX7	48
167a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_XDMA	49
168a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_I2Q	50
169a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_ROMUSB	51
170a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_CAS3	52
171a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_RPMX0	53
172a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_RPMX8	54
173a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_RPMX9	55
174a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_OCM0	56
175a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_OCM1	57
176a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_SMB	58
177a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_I2C0	59
178a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_I2C1	60
179a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_LPC	61
180a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGNC	62
181a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGR0	63
182a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGR1	4
183a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGR2	30
184a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGR3	41
185a9083016SGiridhar Malavali 
186a9083016SGiridhar Malavali /*  This field defines CRB adr [31:20] of the agents */
187a9083016SGiridhar Malavali /*  */
188a9083016SGiridhar Malavali 
189a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_MN	    ((QLA82XX_HW_H0_CH_HUB_ADR << 7) | \
190a9083016SGiridhar Malavali 	QLA82XX_HW_MN_CRB_AGT_ADR)
191a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PH	    ((QLA82XX_HW_H0_CH_HUB_ADR << 7) | \
192a9083016SGiridhar Malavali 	QLA82XX_HW_PH_CRB_AGT_ADR)
193a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_MS	    ((QLA82XX_HW_H0_CH_HUB_ADR << 7) | \
194a9083016SGiridhar Malavali 	QLA82XX_HW_MS_CRB_AGT_ADR)
195a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PS	    ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
196a9083016SGiridhar Malavali 	QLA82XX_HW_PS_CRB_AGT_ADR)
197a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_SS	    ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
198a9083016SGiridhar Malavali 	QLA82XX_HW_SS_CRB_AGT_ADR)
199a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX3    ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
200a9083016SGiridhar Malavali 	QLA82XX_HW_RPMX3_CRB_AGT_ADR)
201a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_QMS	    ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
202a9083016SGiridhar Malavali 	QLA82XX_HW_QMS_CRB_AGT_ADR)
203a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_SQS0     ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
204a9083016SGiridhar Malavali 	QLA82XX_HW_SQGS0_CRB_AGT_ADR)
205a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_SQS1     ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
206a9083016SGiridhar Malavali 	QLA82XX_HW_SQGS1_CRB_AGT_ADR)
207a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_SQS2     ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
208a9083016SGiridhar Malavali 	QLA82XX_HW_SQGS2_CRB_AGT_ADR)
209a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_SQS3     ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
210a9083016SGiridhar Malavali 	QLA82XX_HW_SQGS3_CRB_AGT_ADR)
211a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_C2C0     ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
212a9083016SGiridhar Malavali 	QLA82XX_HW_C2C0_CRB_AGT_ADR)
213a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_C2C1     ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
214a9083016SGiridhar Malavali 	QLA82XX_HW_C2C1_CRB_AGT_ADR)
215a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX2    ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
216a9083016SGiridhar Malavali 	QLA82XX_HW_RPMX2_CRB_AGT_ADR)
217a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX4    ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
218a9083016SGiridhar Malavali 	QLA82XX_HW_RPMX4_CRB_AGT_ADR)
219a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX7    ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
220a9083016SGiridhar Malavali 	QLA82XX_HW_RPMX7_CRB_AGT_ADR)
221a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX9    ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
222a9083016SGiridhar Malavali 	QLA82XX_HW_RPMX9_CRB_AGT_ADR)
223a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_SMB	    ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
224a9083016SGiridhar Malavali 	QLA82XX_HW_SMB_CRB_AGT_ADR)
225a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_NIU	    ((QLA82XX_HW_H2_CH_HUB_ADR << 7) | \
226a9083016SGiridhar Malavali 	QLA82XX_HW_NIU_CRB_AGT_ADR)
227a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_I2C0     ((QLA82XX_HW_H2_CH_HUB_ADR << 7) | \
228a9083016SGiridhar Malavali 	QLA82XX_HW_I2C0_CRB_AGT_ADR)
229a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_I2C1     ((QLA82XX_HW_H2_CH_HUB_ADR << 7) | \
230a9083016SGiridhar Malavali 	QLA82XX_HW_I2C1_CRB_AGT_ADR)
231a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_SRE	    ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
232a9083016SGiridhar Malavali 	QLA82XX_HW_SRE_CRB_AGT_ADR)
233a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_EG	    ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
234a9083016SGiridhar Malavali 	QLA82XX_HW_EG_CRB_AGT_ADR)
235a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX0    ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
236a9083016SGiridhar Malavali 	QLA82XX_HW_RPMX0_CRB_AGT_ADR)
237a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_QMN	    ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
238a9083016SGiridhar Malavali 	QLA82XX_HW_QM_CRB_AGT_ADR)
239a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_SQN0     ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
240a9083016SGiridhar Malavali 	QLA82XX_HW_SQG0_CRB_AGT_ADR)
241a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_SQN1     ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
242a9083016SGiridhar Malavali 	QLA82XX_HW_SQG1_CRB_AGT_ADR)
243a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_SQN2     ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
244a9083016SGiridhar Malavali 	QLA82XX_HW_SQG2_CRB_AGT_ADR)
245a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_SQN3     ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
246a9083016SGiridhar Malavali 	QLA82XX_HW_SQG3_CRB_AGT_ADR)
247a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX1    ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
248a9083016SGiridhar Malavali 	QLA82XX_HW_RPMX1_CRB_AGT_ADR)
249a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX5    ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
250a9083016SGiridhar Malavali 	QLA82XX_HW_RPMX5_CRB_AGT_ADR)
251a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX6    ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
252a9083016SGiridhar Malavali 	QLA82XX_HW_RPMX6_CRB_AGT_ADR)
253a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX8    ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
254a9083016SGiridhar Malavali 	QLA82XX_HW_RPMX8_CRB_AGT_ADR)
255a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_CAS0     ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
256a9083016SGiridhar Malavali 	QLA82XX_HW_CAS0_CRB_AGT_ADR)
257a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_CAS1     ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
258a9083016SGiridhar Malavali 	QLA82XX_HW_CAS1_CRB_AGT_ADR)
259a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_CAS2     ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
260a9083016SGiridhar Malavali 	QLA82XX_HW_CAS2_CRB_AGT_ADR)
261a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_CAS3     ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
262a9083016SGiridhar Malavali 	QLA82XX_HW_CAS3_CRB_AGT_ADR)
263a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGNI     ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
264a9083016SGiridhar Malavali 	QLA82XX_HW_PEGNI_CRB_AGT_ADR)
265a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGND     ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
266a9083016SGiridhar Malavali 	QLA82XX_HW_PEGND_CRB_AGT_ADR)
267a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGN0     ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
268a9083016SGiridhar Malavali 	QLA82XX_HW_PEGN0_CRB_AGT_ADR)
269a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGN1     ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
270a9083016SGiridhar Malavali 	QLA82XX_HW_PEGN1_CRB_AGT_ADR)
271a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGN2     ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
272a9083016SGiridhar Malavali 	QLA82XX_HW_PEGN2_CRB_AGT_ADR)
273a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGN3     ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
274a9083016SGiridhar Malavali 	QLA82XX_HW_PEGN3_CRB_AGT_ADR)
275a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGN4	   ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
276a9083016SGiridhar Malavali 	QLA82XX_HW_PEGN4_CRB_AGT_ADR)
277a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGNC     ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
278a9083016SGiridhar Malavali 	QLA82XX_HW_PEGNC_CRB_AGT_ADR)
279a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGR0     ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
280a9083016SGiridhar Malavali 	QLA82XX_HW_PEGR0_CRB_AGT_ADR)
281a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGR1     ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
282a9083016SGiridhar Malavali 	QLA82XX_HW_PEGR1_CRB_AGT_ADR)
283a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGR2     ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
284a9083016SGiridhar Malavali 	QLA82XX_HW_PEGR2_CRB_AGT_ADR)
285a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGR3     ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
286a9083016SGiridhar Malavali 	QLA82XX_HW_PEGR3_CRB_AGT_ADR)
287a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGSI     ((QLA82XX_HW_H5_CH_HUB_ADR << 7) | \
288a9083016SGiridhar Malavali 	QLA82XX_HW_PEGSI_CRB_AGT_ADR)
289a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGSD     ((QLA82XX_HW_H5_CH_HUB_ADR << 7) | \
290a9083016SGiridhar Malavali 	QLA82XX_HW_PEGSD_CRB_AGT_ADR)
291a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGS0     ((QLA82XX_HW_H5_CH_HUB_ADR << 7) | \
292a9083016SGiridhar Malavali 	QLA82XX_HW_PEGS0_CRB_AGT_ADR)
293a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGS1     ((QLA82XX_HW_H5_CH_HUB_ADR << 7) | \
294a9083016SGiridhar Malavali 	QLA82XX_HW_PEGS1_CRB_AGT_ADR)
295a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGS2     ((QLA82XX_HW_H5_CH_HUB_ADR << 7) | \
296a9083016SGiridhar Malavali 	QLA82XX_HW_PEGS2_CRB_AGT_ADR)
297a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGS3     ((QLA82XX_HW_H5_CH_HUB_ADR << 7) | \
298a9083016SGiridhar Malavali 	QLA82XX_HW_PEGS3_CRB_AGT_ADR)
299a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGSC     ((QLA82XX_HW_H5_CH_HUB_ADR << 7) | \
300a9083016SGiridhar Malavali 	QLA82XX_HW_PEGSC_CRB_AGT_ADR)
301a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_CAM	    ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
302a9083016SGiridhar Malavali 	QLA82XX_HW_NCM_CRB_AGT_ADR)
303a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_TIMR     ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
304a9083016SGiridhar Malavali 	QLA82XX_HW_TMR_CRB_AGT_ADR)
305a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_XDMA     ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
306a9083016SGiridhar Malavali 	QLA82XX_HW_XDMA_CRB_AGT_ADR)
307a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_SN	    ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
308a9083016SGiridhar Malavali 	QLA82XX_HW_SN_CRB_AGT_ADR)
309a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_I2Q	    ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
310a9083016SGiridhar Malavali 	QLA82XX_HW_I2Q_CRB_AGT_ADR)
311a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_ROMUSB   ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
312a9083016SGiridhar Malavali 	QLA82XX_HW_ROMUSB_CRB_AGT_ADR)
313a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_OCM0     ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
314a9083016SGiridhar Malavali 	QLA82XX_HW_OCM0_CRB_AGT_ADR)
315a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_OCM1     ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
316a9083016SGiridhar Malavali 	QLA82XX_HW_OCM1_CRB_AGT_ADR)
317a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_LPC	    ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
318a9083016SGiridhar Malavali 	QLA82XX_HW_LPC_CRB_AGT_ADR)
319a9083016SGiridhar Malavali 
320a9083016SGiridhar Malavali #define ROMUSB_GLB				(QLA82XX_CRB_ROMUSB + 0x00000)
321a9083016SGiridhar Malavali #define QLA82XX_ROMUSB_GLB_PEGTUNE_DONE		(ROMUSB_GLB + 0x005c)
322a9083016SGiridhar Malavali #define QLA82XX_ROMUSB_GLB_STATUS		(ROMUSB_GLB + 0x0004)
323a9083016SGiridhar Malavali #define QLA82XX_ROMUSB_GLB_SW_RESET		(ROMUSB_GLB + 0x0008)
324a9083016SGiridhar Malavali #define QLA82XX_ROMUSB_ROM_ADDRESS		(ROMUSB_ROM + 0x0008)
325a9083016SGiridhar Malavali #define QLA82XX_ROMUSB_ROM_WDATA		(ROMUSB_ROM + 0x000c)
326a9083016SGiridhar Malavali #define QLA82XX_ROMUSB_ROM_ABYTE_CNT		(ROMUSB_ROM + 0x0010)
327a9083016SGiridhar Malavali #define QLA82XX_ROMUSB_ROM_DUMMY_BYTE_CNT	(ROMUSB_ROM + 0x0014)
328a9083016SGiridhar Malavali #define QLA82XX_ROMUSB_ROM_RDATA		(ROMUSB_ROM + 0x0018)
329a9083016SGiridhar Malavali 
330a9083016SGiridhar Malavali #define ROMUSB_ROM				(QLA82XX_CRB_ROMUSB + 0x10000)
331a9083016SGiridhar Malavali #define QLA82XX_ROMUSB_ROM_INSTR_OPCODE		(ROMUSB_ROM + 0x0004)
332a9083016SGiridhar Malavali #define QLA82XX_ROMUSB_GLB_CAS_RST		(ROMUSB_GLB + 0x0038)
333a9083016SGiridhar Malavali 
334a9083016SGiridhar Malavali /* Lock IDs for ROM lock */
335a9083016SGiridhar Malavali #define ROM_LOCK_DRIVER       0x0d417340
336a9083016SGiridhar Malavali 
337a9083016SGiridhar Malavali #define QLA82XX_PCI_CRB_WINDOWSIZE 0x00100000	 /* all are 1MB windows */
338a9083016SGiridhar Malavali #define QLA82XX_PCI_CRB_WINDOW(A) \
339a9083016SGiridhar Malavali 	(QLA82XX_PCI_CRBSPACE + (A)*QLA82XX_PCI_CRB_WINDOWSIZE)
340a9083016SGiridhar Malavali #define QLA82XX_CRB_C2C_0 \
341a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_C2C0)
342a9083016SGiridhar Malavali #define QLA82XX_CRB_C2C_1 \
343a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_C2C1)
344a9083016SGiridhar Malavali #define QLA82XX_CRB_C2C_2 \
345a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_C2C2)
346a9083016SGiridhar Malavali #define QLA82XX_CRB_CAM \
347a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_CAM)
348a9083016SGiridhar Malavali #define QLA82XX_CRB_CASPER \
349a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_CAS)
350a9083016SGiridhar Malavali #define QLA82XX_CRB_CASPER_0 \
351a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_CAS0)
352a9083016SGiridhar Malavali #define QLA82XX_CRB_CASPER_1 \
353a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_CAS1)
354a9083016SGiridhar Malavali #define QLA82XX_CRB_CASPER_2 \
355a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_CAS2)
356a9083016SGiridhar Malavali #define QLA82XX_CRB_DDR_MD \
357a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_MS)
358a9083016SGiridhar Malavali #define QLA82XX_CRB_DDR_NET \
359a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_MN)
360a9083016SGiridhar Malavali #define QLA82XX_CRB_EPG \
361a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_EG)
362a9083016SGiridhar Malavali #define QLA82XX_CRB_I2Q \
363a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_I2Q)
364a9083016SGiridhar Malavali #define QLA82XX_CRB_NIU \
365a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_NIU)
366a9083016SGiridhar Malavali 
367a9083016SGiridhar Malavali #define QLA82XX_CRB_PCIX_HOST \
368a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PH)
369a9083016SGiridhar Malavali #define QLA82XX_CRB_PCIX_HOST2 \
370a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PH2)
371a9083016SGiridhar Malavali #define QLA82XX_CRB_PCIX_MD \
372a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PS)
373a9083016SGiridhar Malavali #define QLA82XX_CRB_PCIE \
374a9083016SGiridhar Malavali 	QLA82XX_CRB_PCIX_MD
375a9083016SGiridhar Malavali 
376a9083016SGiridhar Malavali /* window 1 pcie slot */
377a9083016SGiridhar Malavali #define QLA82XX_CRB_PCIE2	 \
378a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PS2)
379a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_MD_0 \
380a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGS0)
381a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_MD_1 \
382a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGS1)
383a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_MD_2 \
384a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGS2)
385a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_MD_3 \
386a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGS3)
387a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_MD_3 \
388a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGS3)
389a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_MD_D \
390a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGSD)
391a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_MD_I \
392a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGSI)
393a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_NET_0 \
394a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGN0)
395a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_NET_1 \
396a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGN1)
397a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_NET_2 \
398a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGN2)
399a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_NET_3 \
400a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGN3)
401a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_NET_4 \
402a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGN4)
403a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_NET_D \
404a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGND)
405a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_NET_I \
406a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGNI)
407a9083016SGiridhar Malavali #define QLA82XX_CRB_PQM_MD \
408a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_QMS)
409a9083016SGiridhar Malavali #define QLA82XX_CRB_PQM_NET \
410a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_QMN)
411a9083016SGiridhar Malavali #define QLA82XX_CRB_QDR_MD \
412a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SS)
413a9083016SGiridhar Malavali #define QLA82XX_CRB_QDR_NET \
414a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SN)
415a9083016SGiridhar Malavali #define QLA82XX_CRB_ROMUSB \
416a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_ROMUSB)
417a9083016SGiridhar Malavali #define QLA82XX_CRB_RPMX_0 \
418a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_RPMX0)
419a9083016SGiridhar Malavali #define QLA82XX_CRB_RPMX_1 \
420a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_RPMX1)
421a9083016SGiridhar Malavali #define QLA82XX_CRB_RPMX_2 \
422a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_RPMX2)
423a9083016SGiridhar Malavali #define QLA82XX_CRB_RPMX_3 \
424a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_RPMX3)
425a9083016SGiridhar Malavali #define QLA82XX_CRB_RPMX_4 \
426a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_RPMX4)
427a9083016SGiridhar Malavali #define QLA82XX_CRB_RPMX_5 \
428a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_RPMX5)
429a9083016SGiridhar Malavali #define QLA82XX_CRB_RPMX_6 \
430a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_RPMX6)
431a9083016SGiridhar Malavali #define QLA82XX_CRB_RPMX_7 \
432a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_RPMX7)
433a9083016SGiridhar Malavali #define QLA82XX_CRB_SQM_MD_0 \
434a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SQS0)
435a9083016SGiridhar Malavali #define QLA82XX_CRB_SQM_MD_1 \
436a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SQS1)
437a9083016SGiridhar Malavali #define QLA82XX_CRB_SQM_MD_2 \
438a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SQS2)
439a9083016SGiridhar Malavali #define QLA82XX_CRB_SQM_MD_3 \
440a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SQS3)
441a9083016SGiridhar Malavali #define QLA82XX_CRB_SQM_NET_0 \
442a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SQN0)
443a9083016SGiridhar Malavali #define QLA82XX_CRB_SQM_NET_1 \
444a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SQN1)
445a9083016SGiridhar Malavali #define QLA82XX_CRB_SQM_NET_2 \
446a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SQN2)
447a9083016SGiridhar Malavali #define QLA82XX_CRB_SQM_NET_3 \
448a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SQN3)
449a9083016SGiridhar Malavali #define QLA82XX_CRB_SRE \
450a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SRE)
451a9083016SGiridhar Malavali #define QLA82XX_CRB_TIMER \
452a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_TIMR)
453a9083016SGiridhar Malavali #define QLA82XX_CRB_XDMA \
454a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_XDMA)
455a9083016SGiridhar Malavali #define QLA82XX_CRB_I2C0 \
456a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_I2C0)
457a9083016SGiridhar Malavali #define QLA82XX_CRB_I2C1 \
458a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_I2C1)
459a9083016SGiridhar Malavali #define QLA82XX_CRB_OCM0 \
460a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_OCM0)
461a9083016SGiridhar Malavali #define QLA82XX_CRB_SMB \
462a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SMB)
463a9083016SGiridhar Malavali #define QLA82XX_CRB_MAX \
464a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(64)
465a9083016SGiridhar Malavali 
466a9083016SGiridhar Malavali /*
467a9083016SGiridhar Malavali  * ====================== BASE ADDRESSES ON-CHIP ======================
468a9083016SGiridhar Malavali  * Base addresses of major components on-chip.
469a9083016SGiridhar Malavali  * ====================== BASE ADDRESSES ON-CHIP ======================
470a9083016SGiridhar Malavali  */
471a9083016SGiridhar Malavali #define QLA82XX_ADDR_DDR_NET		(0x0000000000000000ULL)
472a9083016SGiridhar Malavali #define QLA82XX_ADDR_DDR_NET_MAX	(0x000000000fffffffULL)
473a9083016SGiridhar Malavali 
474a9083016SGiridhar Malavali /* Imbus address bit used to indicate a host address. This bit is
475a9083016SGiridhar Malavali  * eliminated by the pcie bar and bar select before presentation
476a9083016SGiridhar Malavali  * over pcie. */
477a9083016SGiridhar Malavali /* host memory via IMBUS */
478a9083016SGiridhar Malavali #define QLA82XX_P2_ADDR_PCIE		(0x0000000800000000ULL)
479a9083016SGiridhar Malavali #define QLA82XX_P3_ADDR_PCIE		(0x0000008000000000ULL)
480a9083016SGiridhar Malavali #define QLA82XX_ADDR_PCIE_MAX		(0x0000000FFFFFFFFFULL)
481a9083016SGiridhar Malavali #define QLA82XX_ADDR_OCM0		(0x0000000200000000ULL)
482a9083016SGiridhar Malavali #define QLA82XX_ADDR_OCM0_MAX		(0x00000002000fffffULL)
483a9083016SGiridhar Malavali #define QLA82XX_ADDR_OCM1		(0x0000000200400000ULL)
484a9083016SGiridhar Malavali #define QLA82XX_ADDR_OCM1_MAX		(0x00000002004fffffULL)
485a9083016SGiridhar Malavali #define QLA82XX_ADDR_QDR_NET		(0x0000000300000000ULL)
486a9083016SGiridhar Malavali 
487a9083016SGiridhar Malavali #define QLA82XX_P2_ADDR_QDR_NET_MAX	(0x00000003001fffffULL)
488a9083016SGiridhar Malavali #define QLA82XX_P3_ADDR_QDR_NET_MAX	(0x0000000303ffffffULL)
489a9083016SGiridhar Malavali 
490a9083016SGiridhar Malavali #define QLA82XX_PCI_CRBSPACE		(unsigned long)0x06000000
491a9083016SGiridhar Malavali #define QLA82XX_PCI_DIRECT_CRB		(unsigned long)0x04400000
492a9083016SGiridhar Malavali #define QLA82XX_PCI_CAMQM		(unsigned long)0x04800000
493a9083016SGiridhar Malavali #define QLA82XX_PCI_CAMQM_MAX		(unsigned long)0x04ffffff
494a9083016SGiridhar Malavali #define QLA82XX_PCI_DDR_NET		(unsigned long)0x00000000
495a9083016SGiridhar Malavali #define QLA82XX_PCI_QDR_NET		(unsigned long)0x04000000
496a9083016SGiridhar Malavali #define QLA82XX_PCI_QDR_NET_MAX		(unsigned long)0x043fffff
497a9083016SGiridhar Malavali 
498a9083016SGiridhar Malavali /*
499a9083016SGiridhar Malavali  *   Register offsets for MN
500a9083016SGiridhar Malavali  */
501a9083016SGiridhar Malavali #define MIU_CONTROL			(0x000)
502a9083016SGiridhar Malavali #define MIU_TAG				(0x004)
503a9083016SGiridhar Malavali #define MIU_TEST_AGT_CTRL		(0x090)
504a9083016SGiridhar Malavali #define MIU_TEST_AGT_ADDR_LO		(0x094)
505a9083016SGiridhar Malavali #define MIU_TEST_AGT_ADDR_HI		(0x098)
506a9083016SGiridhar Malavali #define MIU_TEST_AGT_WRDATA_LO		(0x0a0)
507a9083016SGiridhar Malavali #define MIU_TEST_AGT_WRDATA_HI		(0x0a4)
508a9083016SGiridhar Malavali #define MIU_TEST_AGT_WRDATA(i)		(0x0a0+(4*(i)))
509a9083016SGiridhar Malavali #define MIU_TEST_AGT_RDDATA_LO		(0x0a8)
510a9083016SGiridhar Malavali #define MIU_TEST_AGT_RDDATA_HI		(0x0ac)
511a9083016SGiridhar Malavali #define MIU_TEST_AGT_RDDATA(i)		(0x0a8+(4*(i)))
512a9083016SGiridhar Malavali #define MIU_TEST_AGT_ADDR_MASK		0xfffffff8
513a9083016SGiridhar Malavali #define MIU_TEST_AGT_UPPER_ADDR(off)	(0)
514a9083016SGiridhar Malavali 
515a9083016SGiridhar Malavali /* MIU_TEST_AGT_CTRL flags. work for SIU as well */
516a9083016SGiridhar Malavali #define MIU_TA_CTL_START	1
517a9083016SGiridhar Malavali #define MIU_TA_CTL_ENABLE	2
518a9083016SGiridhar Malavali #define MIU_TA_CTL_WRITE	4
519a9083016SGiridhar Malavali #define MIU_TA_CTL_BUSY		8
520a9083016SGiridhar Malavali 
521a9083016SGiridhar Malavali /*CAM RAM */
522a9083016SGiridhar Malavali # define QLA82XX_CAM_RAM_BASE		(QLA82XX_CRB_CAM + 0x02000)
523a9083016SGiridhar Malavali # define QLA82XX_CAM_RAM(reg)		(QLA82XX_CAM_RAM_BASE + (reg))
524a9083016SGiridhar Malavali 
525a9083016SGiridhar Malavali #define QLA82XX_PEG_TUNE_MN_SPD_ZEROED	0x80000000
526a9083016SGiridhar Malavali #define QLA82XX_BOOT_LOADER_MN_ISSUE	0xff00ffff
527a9083016SGiridhar Malavali #define QLA82XX_PORT_MODE_ADDR		(QLA82XX_CAM_RAM(0x24))
528a9083016SGiridhar Malavali #define QLA82XX_PEG_HALT_STATUS1	(QLA82XX_CAM_RAM(0xa8))
529a9083016SGiridhar Malavali #define QLA82XX_PEG_HALT_STATUS2	(QLA82XX_CAM_RAM(0xac))
530a9083016SGiridhar Malavali #define QLA82XX_PEG_ALIVE_COUNTER	(QLA82XX_CAM_RAM(0xb0))
531a9083016SGiridhar Malavali 
532a9083016SGiridhar Malavali #define QLA82XX_CAMRAM_DB1		(QLA82XX_CAM_RAM(0x1b8))
533a9083016SGiridhar Malavali #define QLA82XX_CAMRAM_DB2		(QLA82XX_CAM_RAM(0x1bc))
534a9083016SGiridhar Malavali 
535a9083016SGiridhar Malavali #define HALT_STATUS_UNRECOVERABLE	0x80000000
536a9083016SGiridhar Malavali #define HALT_STATUS_RECOVERABLE		0x40000000
537a9083016SGiridhar Malavali 
538a9083016SGiridhar Malavali /* Driver Coexistence Defines */
539a9083016SGiridhar Malavali #define QLA82XX_CRB_DRV_ACTIVE	     (QLA82XX_CAM_RAM(0x138))
540a9083016SGiridhar Malavali #define QLA82XX_CRB_DEV_STATE	     (QLA82XX_CAM_RAM(0x140))
541a9083016SGiridhar Malavali #define QLA82XX_CRB_DRV_STATE	     (QLA82XX_CAM_RAM(0x144))
542a9083016SGiridhar Malavali #define QLA82XX_CRB_DRV_SCRATCH      (QLA82XX_CAM_RAM(0x148))
543a9083016SGiridhar Malavali #define QLA82XX_CRB_DEV_PART_INFO    (QLA82XX_CAM_RAM(0x14c))
544b963752fSGiridhar Malavali #define QLA82XX_CRB_DRV_IDC_VERSION  (QLA82XX_CAM_RAM(0x174))
545a9083016SGiridhar Malavali 
546a9083016SGiridhar Malavali /* Every driver should use these Device State */
547a9083016SGiridhar Malavali #define QLA82XX_DEV_COLD		1
548a9083016SGiridhar Malavali #define QLA82XX_DEV_INITIALIZING	2
549a9083016SGiridhar Malavali #define QLA82XX_DEV_READY		3
550a9083016SGiridhar Malavali #define QLA82XX_DEV_NEED_RESET		4
551a9083016SGiridhar Malavali #define QLA82XX_DEV_NEED_QUIESCENT	5
552a9083016SGiridhar Malavali #define QLA82XX_DEV_FAILED		6
553a9083016SGiridhar Malavali #define QLA82XX_DEV_QUIESCENT		7
554f1af6208SGiridhar Malavali #define	MAX_STATES			8 /* Increment if new state added */
555a9083016SGiridhar Malavali 
556a9083016SGiridhar Malavali #define QLA82XX_IDC_VERSION			1
557a9083016SGiridhar Malavali #define QLA82XX_ROM_DEV_INIT_TIMEOUT		30
558a9083016SGiridhar Malavali #define QLA82XX_ROM_DRV_RESET_ACK_TIMEOUT	10
559a9083016SGiridhar Malavali 
560a9083016SGiridhar Malavali #define QLA82XX_ROM_LOCK_ID		(QLA82XX_CAM_RAM(0x100))
561a9083016SGiridhar Malavali #define QLA82XX_CRB_WIN_LOCK_ID		(QLA82XX_CAM_RAM(0x124))
562a9083016SGiridhar Malavali #define QLA82XX_FW_VERSION_MAJOR	(QLA82XX_CAM_RAM(0x150))
563a9083016SGiridhar Malavali #define QLA82XX_FW_VERSION_MINOR	(QLA82XX_CAM_RAM(0x154))
564a9083016SGiridhar Malavali #define QLA82XX_FW_VERSION_SUB		(QLA82XX_CAM_RAM(0x158))
565a9083016SGiridhar Malavali #define QLA82XX_PCIE_REG(reg)		(QLA82XX_CRB_PCIE + (reg))
566a9083016SGiridhar Malavali 
567a9083016SGiridhar Malavali #define PCIE_CHICKEN3			(0x120c8)
568a9083016SGiridhar Malavali #define PCIE_SETUP_FUNCTION		(0x12040)
569a9083016SGiridhar Malavali #define PCIE_SETUP_FUNCTION2		(0x12048)
570a9083016SGiridhar Malavali 
571a9083016SGiridhar Malavali #define QLA82XX_PCIX_PS_REG(reg)	(QLA82XX_CRB_PCIX_MD + (reg))
572a9083016SGiridhar Malavali #define QLA82XX_PCIX_PS2_REG(reg)	(QLA82XX_CRB_PCIE2 + (reg))
573a9083016SGiridhar Malavali 
574a9083016SGiridhar Malavali #define PCIE_SEM2_LOCK	     (0x1c010)	/* Flash lock	*/
575a9083016SGiridhar Malavali #define PCIE_SEM2_UNLOCK     (0x1c014)	/* Flash unlock */
576a9083016SGiridhar Malavali #define PCIE_SEM5_LOCK	     (0x1c028)	/* Coexistence lock   */
577a9083016SGiridhar Malavali #define PCIE_SEM5_UNLOCK     (0x1c02c)	/* Coexistence unlock */
578a9083016SGiridhar Malavali #define PCIE_SEM7_LOCK	     (0x1c038)	/* crb win lock */
579a9083016SGiridhar Malavali #define PCIE_SEM7_UNLOCK     (0x1c03c)	/* crbwin unlock*/
580a9083016SGiridhar Malavali 
581a9083016SGiridhar Malavali /* Different drive state */
582a9083016SGiridhar Malavali #define QLA82XX_DRVST_NOT_RDY		0
583a9083016SGiridhar Malavali #define	QLA82XX_DRVST_RST_RDY		1
584a9083016SGiridhar Malavali #define QLA82XX_DRVST_QSNT_RDY		2
585a9083016SGiridhar Malavali 
586a9083016SGiridhar Malavali /*
587a9083016SGiridhar Malavali  * The PCI VendorID and DeviceID for our board.
588a9083016SGiridhar Malavali  */
589a9083016SGiridhar Malavali #define PCI_DEVICE_ID_QLOGIC_ISP8021		0x8021
590a9083016SGiridhar Malavali 
591a9083016SGiridhar Malavali #define QLA82XX_MSIX_TBL_SPACE			8192
592a9083016SGiridhar Malavali #define QLA82XX_PCI_REG_MSIX_TBL		0x44
593a9083016SGiridhar Malavali #define QLA82XX_PCI_MSIX_CONTROL		0x40
594a9083016SGiridhar Malavali 
595a9083016SGiridhar Malavali struct crb_128M_2M_sub_block_map {
596a9083016SGiridhar Malavali 	unsigned valid;
597a9083016SGiridhar Malavali 	unsigned start_128M;
598a9083016SGiridhar Malavali 	unsigned end_128M;
599a9083016SGiridhar Malavali 	unsigned start_2M;
600a9083016SGiridhar Malavali };
601a9083016SGiridhar Malavali 
602a9083016SGiridhar Malavali struct crb_128M_2M_block_map {
603a9083016SGiridhar Malavali 	struct crb_128M_2M_sub_block_map sub_block[16];
604a9083016SGiridhar Malavali };
605a9083016SGiridhar Malavali 
606a9083016SGiridhar Malavali struct crb_addr_pair {
607a9083016SGiridhar Malavali 	long addr;
608a9083016SGiridhar Malavali 	long data;
609a9083016SGiridhar Malavali };
610a9083016SGiridhar Malavali 
611a9083016SGiridhar Malavali #define ADDR_ERROR ((unsigned long) 0xffffffff)
612a9083016SGiridhar Malavali #define MAX_CTL_CHECK	1000
613a9083016SGiridhar Malavali 
614a9083016SGiridhar Malavali /***************************************************************************
615a9083016SGiridhar Malavali  *		PCI related defines.
616a9083016SGiridhar Malavali  **************************************************************************/
617a9083016SGiridhar Malavali 
618a9083016SGiridhar Malavali /*
619a9083016SGiridhar Malavali  * Interrupt related defines.
620a9083016SGiridhar Malavali  */
621a9083016SGiridhar Malavali #define PCIX_TARGET_STATUS	(0x10118)
622a9083016SGiridhar Malavali #define PCIX_TARGET_STATUS_F1	(0x10160)
623a9083016SGiridhar Malavali #define PCIX_TARGET_STATUS_F2	(0x10164)
624a9083016SGiridhar Malavali #define PCIX_TARGET_STATUS_F3	(0x10168)
625a9083016SGiridhar Malavali #define PCIX_TARGET_STATUS_F4	(0x10360)
626a9083016SGiridhar Malavali #define PCIX_TARGET_STATUS_F5	(0x10364)
627a9083016SGiridhar Malavali #define PCIX_TARGET_STATUS_F6	(0x10368)
628a9083016SGiridhar Malavali #define PCIX_TARGET_STATUS_F7	(0x1036c)
629a9083016SGiridhar Malavali 
630a9083016SGiridhar Malavali #define PCIX_TARGET_MASK	(0x10128)
631a9083016SGiridhar Malavali #define PCIX_TARGET_MASK_F1	(0x10170)
632a9083016SGiridhar Malavali #define PCIX_TARGET_MASK_F2	(0x10174)
633a9083016SGiridhar Malavali #define PCIX_TARGET_MASK_F3	(0x10178)
634a9083016SGiridhar Malavali #define PCIX_TARGET_MASK_F4	(0x10370)
635a9083016SGiridhar Malavali #define PCIX_TARGET_MASK_F5	(0x10374)
636a9083016SGiridhar Malavali #define PCIX_TARGET_MASK_F6	(0x10378)
637a9083016SGiridhar Malavali #define PCIX_TARGET_MASK_F7	(0x1037c)
638a9083016SGiridhar Malavali 
639a9083016SGiridhar Malavali /*
640a9083016SGiridhar Malavali  * Message Signaled Interrupts
641a9083016SGiridhar Malavali  */
642a9083016SGiridhar Malavali #define PCIX_MSI_F0		(0x13000)
643a9083016SGiridhar Malavali #define PCIX_MSI_F1		(0x13004)
644a9083016SGiridhar Malavali #define PCIX_MSI_F2		(0x13008)
645a9083016SGiridhar Malavali #define PCIX_MSI_F3		(0x1300c)
646a9083016SGiridhar Malavali #define PCIX_MSI_F4		(0x13010)
647a9083016SGiridhar Malavali #define PCIX_MSI_F5		(0x13014)
648a9083016SGiridhar Malavali #define PCIX_MSI_F6		(0x13018)
649a9083016SGiridhar Malavali #define PCIX_MSI_F7		(0x1301c)
650a9083016SGiridhar Malavali #define PCIX_MSI_F(FUNC)	(0x13000 + ((FUNC) * 4))
651a9083016SGiridhar Malavali #define PCIX_INT_VECTOR		(0x10100)
652a9083016SGiridhar Malavali #define PCIX_INT_MASK		(0x10104)
653a9083016SGiridhar Malavali 
654a9083016SGiridhar Malavali /*
655a9083016SGiridhar Malavali  * Interrupt state machine and other bits.
656a9083016SGiridhar Malavali  */
657a9083016SGiridhar Malavali #define PCIE_MISCCFG_RC		(0x1206c)
658a9083016SGiridhar Malavali 
659a9083016SGiridhar Malavali #define ISR_INT_TARGET_STATUS \
660a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_STATUS))
661a9083016SGiridhar Malavali #define ISR_INT_TARGET_STATUS_F1 \
662a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_STATUS_F1))
663a9083016SGiridhar Malavali #define ISR_INT_TARGET_STATUS_F2 \
664a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_STATUS_F2))
665a9083016SGiridhar Malavali #define ISR_INT_TARGET_STATUS_F3 \
666a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_STATUS_F3))
667a9083016SGiridhar Malavali #define ISR_INT_TARGET_STATUS_F4 \
668a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_STATUS_F4))
669a9083016SGiridhar Malavali #define ISR_INT_TARGET_STATUS_F5 \
670a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_STATUS_F5))
671a9083016SGiridhar Malavali #define ISR_INT_TARGET_STATUS_F6 \
672a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_STATUS_F6))
673a9083016SGiridhar Malavali #define ISR_INT_TARGET_STATUS_F7 \
674a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_STATUS_F7))
675a9083016SGiridhar Malavali 
676a9083016SGiridhar Malavali #define ISR_INT_TARGET_MASK \
677a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_MASK))
678a9083016SGiridhar Malavali #define ISR_INT_TARGET_MASK_F1 \
679a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_MASK_F1))
680a9083016SGiridhar Malavali #define ISR_INT_TARGET_MASK_F2 \
681a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_MASK_F2))
682a9083016SGiridhar Malavali #define ISR_INT_TARGET_MASK_F3 \
683a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_MASK_F3))
684a9083016SGiridhar Malavali #define ISR_INT_TARGET_MASK_F4 \
685a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_MASK_F4))
686a9083016SGiridhar Malavali #define ISR_INT_TARGET_MASK_F5 \
687a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_MASK_F5))
688a9083016SGiridhar Malavali #define ISR_INT_TARGET_MASK_F6 \
689a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_MASK_F6))
690a9083016SGiridhar Malavali #define ISR_INT_TARGET_MASK_F7 \
691a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_MASK_F7))
692a9083016SGiridhar Malavali 
693a9083016SGiridhar Malavali #define ISR_INT_VECTOR \
694a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_INT_VECTOR))
695a9083016SGiridhar Malavali #define ISR_INT_MASK \
696a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_INT_MASK))
697a9083016SGiridhar Malavali #define ISR_INT_STATE_REG \
698a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIE_MISCCFG_RC))
699a9083016SGiridhar Malavali 
700a9083016SGiridhar Malavali #define	ISR_MSI_INT_TRIGGER(FUNC) \
701a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_MSI_F(FUNC)))
702a9083016SGiridhar Malavali 
703a9083016SGiridhar Malavali #define	ISR_IS_LEGACY_INTR_IDLE(VAL)		(((VAL) & 0x300) == 0)
704a9083016SGiridhar Malavali #define	ISR_IS_LEGACY_INTR_TRIGGERED(VAL)	(((VAL) & 0x300) == 0x200)
705a9083016SGiridhar Malavali 
706a9083016SGiridhar Malavali /*
707a9083016SGiridhar Malavali  * PCI Interrupt Vector Values.
708a9083016SGiridhar Malavali  */
709a9083016SGiridhar Malavali #define	PCIX_INT_VECTOR_BIT_F0	0x0080
710a9083016SGiridhar Malavali #define	PCIX_INT_VECTOR_BIT_F1	0x0100
711a9083016SGiridhar Malavali #define	PCIX_INT_VECTOR_BIT_F2	0x0200
712a9083016SGiridhar Malavali #define	PCIX_INT_VECTOR_BIT_F3	0x0400
713a9083016SGiridhar Malavali #define	PCIX_INT_VECTOR_BIT_F4	0x0800
714a9083016SGiridhar Malavali #define	PCIX_INT_VECTOR_BIT_F5	0x1000
715a9083016SGiridhar Malavali #define	PCIX_INT_VECTOR_BIT_F6	0x2000
716a9083016SGiridhar Malavali #define	PCIX_INT_VECTOR_BIT_F7	0x4000
717a9083016SGiridhar Malavali 
718a9083016SGiridhar Malavali struct qla82xx_legacy_intr_set {
719a9083016SGiridhar Malavali 	uint32_t	int_vec_bit;
720a9083016SGiridhar Malavali 	uint32_t	tgt_status_reg;
721a9083016SGiridhar Malavali 	uint32_t	tgt_mask_reg;
722a9083016SGiridhar Malavali 	uint32_t	pci_int_reg;
723a9083016SGiridhar Malavali };
724a9083016SGiridhar Malavali 
725a9083016SGiridhar Malavali #define QLA82XX_LEGACY_INTR_CONFIG					\
726a9083016SGiridhar Malavali {									\
727a9083016SGiridhar Malavali 	{								\
728a9083016SGiridhar Malavali 		.int_vec_bit	=	PCIX_INT_VECTOR_BIT_F0,		\
729a9083016SGiridhar Malavali 		.tgt_status_reg =	ISR_INT_TARGET_STATUS,		\
730a9083016SGiridhar Malavali 		.tgt_mask_reg	=	ISR_INT_TARGET_MASK,		\
731a9083016SGiridhar Malavali 		.pci_int_reg	=	ISR_MSI_INT_TRIGGER(0) },	\
732a9083016SGiridhar Malavali 									\
733a9083016SGiridhar Malavali 	{								\
734a9083016SGiridhar Malavali 		.int_vec_bit	=	PCIX_INT_VECTOR_BIT_F1,		\
735a9083016SGiridhar Malavali 		.tgt_status_reg =	ISR_INT_TARGET_STATUS_F1,	\
736a9083016SGiridhar Malavali 		.tgt_mask_reg	=	ISR_INT_TARGET_MASK_F1,		\
737a9083016SGiridhar Malavali 		.pci_int_reg	=	ISR_MSI_INT_TRIGGER(1) },	\
738a9083016SGiridhar Malavali 									\
739a9083016SGiridhar Malavali 	{								\
740a9083016SGiridhar Malavali 		.int_vec_bit	=	PCIX_INT_VECTOR_BIT_F2,		\
741a9083016SGiridhar Malavali 		.tgt_status_reg =	ISR_INT_TARGET_STATUS_F2,	\
742a9083016SGiridhar Malavali 		.tgt_mask_reg	=	ISR_INT_TARGET_MASK_F2,		\
743a9083016SGiridhar Malavali 		.pci_int_reg	=	ISR_MSI_INT_TRIGGER(2) },	\
744a9083016SGiridhar Malavali 									\
745a9083016SGiridhar Malavali 	{								\
746a9083016SGiridhar Malavali 		.int_vec_bit	=	PCIX_INT_VECTOR_BIT_F3,		\
747a9083016SGiridhar Malavali 		.tgt_status_reg =	ISR_INT_TARGET_STATUS_F3,	\
748a9083016SGiridhar Malavali 		.tgt_mask_reg	=	ISR_INT_TARGET_MASK_F3,		\
749a9083016SGiridhar Malavali 		.pci_int_reg	=	ISR_MSI_INT_TRIGGER(3) },	\
750a9083016SGiridhar Malavali 									\
751a9083016SGiridhar Malavali 	{								\
752a9083016SGiridhar Malavali 		.int_vec_bit	=	PCIX_INT_VECTOR_BIT_F4,		\
753a9083016SGiridhar Malavali 		.tgt_status_reg =	ISR_INT_TARGET_STATUS_F4,	\
754a9083016SGiridhar Malavali 		.tgt_mask_reg	=	ISR_INT_TARGET_MASK_F4,		\
755a9083016SGiridhar Malavali 		.pci_int_reg	=	ISR_MSI_INT_TRIGGER(4) },	\
756a9083016SGiridhar Malavali 									\
757a9083016SGiridhar Malavali 	{								\
758a9083016SGiridhar Malavali 		.int_vec_bit	=	PCIX_INT_VECTOR_BIT_F5,		\
759a9083016SGiridhar Malavali 		.tgt_status_reg =	ISR_INT_TARGET_STATUS_F5,	\
760a9083016SGiridhar Malavali 		.tgt_mask_reg	=	ISR_INT_TARGET_MASK_F5,		\
761a9083016SGiridhar Malavali 		.pci_int_reg	=	ISR_MSI_INT_TRIGGER(5) },	\
762a9083016SGiridhar Malavali 									\
763a9083016SGiridhar Malavali 	{								\
764a9083016SGiridhar Malavali 		.int_vec_bit	=	PCIX_INT_VECTOR_BIT_F6,		\
765a9083016SGiridhar Malavali 		.tgt_status_reg =	ISR_INT_TARGET_STATUS_F6,	\
766a9083016SGiridhar Malavali 		.tgt_mask_reg	=	ISR_INT_TARGET_MASK_F6,		\
767a9083016SGiridhar Malavali 		.pci_int_reg	=	ISR_MSI_INT_TRIGGER(6) },	\
768a9083016SGiridhar Malavali 									\
769a9083016SGiridhar Malavali 	{								\
770a9083016SGiridhar Malavali 		.int_vec_bit	=	PCIX_INT_VECTOR_BIT_F7,		\
771a9083016SGiridhar Malavali 		.tgt_status_reg =	ISR_INT_TARGET_STATUS_F7,	\
772a9083016SGiridhar Malavali 		.tgt_mask_reg	=	ISR_INT_TARGET_MASK_F7,		\
773a9083016SGiridhar Malavali 		.pci_int_reg	=	ISR_MSI_INT_TRIGGER(7) },	\
774a9083016SGiridhar Malavali }
775a9083016SGiridhar Malavali 
776*9c2b2975SHarish Zunjarrao #define BRDCFG_START		0x4000
777a9083016SGiridhar Malavali #define	BOOTLD_START		0x10000
778a9083016SGiridhar Malavali #define	IMAGE_START		0x100000
779a9083016SGiridhar Malavali #define FLASH_ADDR_START	0x43000
780a9083016SGiridhar Malavali 
781a9083016SGiridhar Malavali /* Magic number to let user know flash is programmed */
782a9083016SGiridhar Malavali #define QLA82XX_BDINFO_MAGIC	0x12345678
783*9c2b2975SHarish Zunjarrao #define QLA82XX_FW_MAGIC_OFFSET	(BRDCFG_START + 0x128)
784a9083016SGiridhar Malavali #define FW_SIZE_OFFSET		(0x3e840c)
785*9c2b2975SHarish Zunjarrao #define QLA82XX_FW_MIN_SIZE	0x3fffff
786*9c2b2975SHarish Zunjarrao 
787*9c2b2975SHarish Zunjarrao /* UNIFIED ROMIMAGE START */
788*9c2b2975SHarish Zunjarrao #define QLA82XX_URI_FW_MIN_SIZE			0xc8000
789*9c2b2975SHarish Zunjarrao #define QLA82XX_URI_DIR_SECT_PRODUCT_TBL	0x0
790*9c2b2975SHarish Zunjarrao #define QLA82XX_URI_DIR_SECT_BOOTLD		0x6
791*9c2b2975SHarish Zunjarrao #define QLA82XX_URI_DIR_SECT_FW			0x7
792*9c2b2975SHarish Zunjarrao 
793*9c2b2975SHarish Zunjarrao /* Offsets */
794*9c2b2975SHarish Zunjarrao #define QLA82XX_URI_CHIP_REV_OFF	10
795*9c2b2975SHarish Zunjarrao #define QLA82XX_URI_FLAGS_OFF		11
796*9c2b2975SHarish Zunjarrao #define QLA82XX_URI_BIOS_VERSION_OFF	12
797*9c2b2975SHarish Zunjarrao #define QLA82XX_URI_BOOTLD_IDX_OFF	27
798*9c2b2975SHarish Zunjarrao #define QLA82XX_URI_FIRMWARE_IDX_OFF	29
799*9c2b2975SHarish Zunjarrao 
800*9c2b2975SHarish Zunjarrao struct qla82xx_uri_table_desc{
801*9c2b2975SHarish Zunjarrao 	uint32_t	findex;
802*9c2b2975SHarish Zunjarrao 	uint32_t	num_entries;
803*9c2b2975SHarish Zunjarrao 	uint32_t	entry_size;
804*9c2b2975SHarish Zunjarrao 	uint32_t	reserved[5];
805*9c2b2975SHarish Zunjarrao };
806*9c2b2975SHarish Zunjarrao 
807*9c2b2975SHarish Zunjarrao struct qla82xx_uri_data_desc{
808*9c2b2975SHarish Zunjarrao 	uint32_t	findex;
809*9c2b2975SHarish Zunjarrao 	uint32_t	size;
810*9c2b2975SHarish Zunjarrao 	uint32_t	reserved[5];
811*9c2b2975SHarish Zunjarrao };
812*9c2b2975SHarish Zunjarrao 
813*9c2b2975SHarish Zunjarrao /* UNIFIED ROMIMAGE END */
814*9c2b2975SHarish Zunjarrao 
815*9c2b2975SHarish Zunjarrao #define QLA82XX_UNIFIED_ROMIMAGE	3
816*9c2b2975SHarish Zunjarrao #define QLA82XX_FLASH_ROMIMAGE		4
817*9c2b2975SHarish Zunjarrao #define QLA82XX_UNKNOWN_ROMIMAGE	0xff
818a9083016SGiridhar Malavali 
819a9083016SGiridhar Malavali #define QLA82XX_IS_REVISION_P3PLUS(_rev_)	((_rev_) >= 0x50)
820a9083016SGiridhar Malavali #define MIU_TEST_AGT_WRDATA_UPPER_LO		(0x0b0)
821a9083016SGiridhar Malavali #define	MIU_TEST_AGT_WRDATA_UPPER_HI		(0x0b4)
822a9083016SGiridhar Malavali 
823a9083016SGiridhar Malavali #ifndef readq
824a9083016SGiridhar Malavali static inline u64 readq(void __iomem *addr)
825a9083016SGiridhar Malavali {
826a9083016SGiridhar Malavali 	return readl(addr) | (((u64) readl(addr + 4)) << 32LL);
827a9083016SGiridhar Malavali }
828a9083016SGiridhar Malavali #endif
829a9083016SGiridhar Malavali 
830a9083016SGiridhar Malavali #ifndef writeq
831a9083016SGiridhar Malavali static inline void writeq(u64 val, void __iomem *addr)
832a9083016SGiridhar Malavali {
833a9083016SGiridhar Malavali 	writel(((u32) (val)), (addr));
834a9083016SGiridhar Malavali 	writel(((u32) (val >> 32)), (addr + 4));
835a9083016SGiridhar Malavali }
836a9083016SGiridhar Malavali #endif
837a9083016SGiridhar Malavali 
838a9083016SGiridhar Malavali /* Request and response queue size */
839a9083016SGiridhar Malavali #define REQUEST_ENTRY_CNT_82XX		128	/* Number of request entries. */
840a9083016SGiridhar Malavali #define RESPONSE_ENTRY_CNT_82XX		128	/* Number of response entries.*/
841a9083016SGiridhar Malavali 
842a9083016SGiridhar Malavali /*
843a9083016SGiridhar Malavali  * ISP 8021 I/O Register Set structure definitions.
844a9083016SGiridhar Malavali  */
845a9083016SGiridhar Malavali struct device_reg_82xx {
846a9083016SGiridhar Malavali 	uint32_t req_q_out[64];		/* Request Queue out-Pointer (64 * 4) */
847a9083016SGiridhar Malavali 	uint32_t rsp_q_in[64];		/* Response Queue In-Pointer. */
848a9083016SGiridhar Malavali 	uint32_t rsp_q_out[64];		/* Response Queue Out-Pointer. */
849a9083016SGiridhar Malavali 
850a9083016SGiridhar Malavali 	uint16_t mailbox_in[32];	/* Mail box In registers */
851a9083016SGiridhar Malavali 	uint16_t unused_1[32];
852a9083016SGiridhar Malavali 	uint32_t hint;			/* Host interrupt register */
853a9083016SGiridhar Malavali #define	HINT_MBX_INT_PENDING	BIT_0
854a9083016SGiridhar Malavali 	uint16_t unused_2[62];
855a9083016SGiridhar Malavali 	uint16_t mailbox_out[32];	/* Mail box Out registers */
856a9083016SGiridhar Malavali 	uint32_t unused_3[48];
857a9083016SGiridhar Malavali 
858a9083016SGiridhar Malavali 	uint32_t host_status;		/* host status */
859a9083016SGiridhar Malavali #define HSRX_RISC_INT		BIT_15	/* RISC to Host interrupt. */
860a9083016SGiridhar Malavali #define HSRX_RISC_PAUSED	BIT_8	/* RISC Paused. */
861a9083016SGiridhar Malavali 	uint32_t host_int;		/* Interrupt status. */
862a9083016SGiridhar Malavali #define ISRX_NX_RISC_INT	BIT_0	/* RISC interrupt. */
863a9083016SGiridhar Malavali };
864a9083016SGiridhar Malavali 
865a9083016SGiridhar Malavali struct fcp_cmnd {
866a9083016SGiridhar Malavali 	struct scsi_lun lun;
867a9083016SGiridhar Malavali 	uint8_t crn;
868a9083016SGiridhar Malavali 	uint8_t task_attribute;
869a9083016SGiridhar Malavali 	uint8_t task_managment;
870a9083016SGiridhar Malavali 	uint8_t additional_cdb_len;
871a9083016SGiridhar Malavali 	uint8_t cdb[260]; /* 256 for CDB len and 4 for FCP_DL */
872a9083016SGiridhar Malavali };
873a9083016SGiridhar Malavali 
874a9083016SGiridhar Malavali struct dsd_dma {
875a9083016SGiridhar Malavali 	struct list_head list;
876a9083016SGiridhar Malavali 	dma_addr_t dsd_list_dma;
877a9083016SGiridhar Malavali 	void *dsd_addr;
878a9083016SGiridhar Malavali };
879a9083016SGiridhar Malavali 
880a9083016SGiridhar Malavali #define QLA_DSDS_PER_IOCB	37
881a9083016SGiridhar Malavali #define QLA_DSD_SIZE		12
882a9083016SGiridhar Malavali struct ct6_dsd {
883a9083016SGiridhar Malavali 	uint16_t fcp_cmnd_len;
884a9083016SGiridhar Malavali 	dma_addr_t fcp_cmnd_dma;
885a9083016SGiridhar Malavali 	struct fcp_cmnd *fcp_cmnd;
886a9083016SGiridhar Malavali 	int dsd_use_cnt;
887a9083016SGiridhar Malavali 	struct list_head dsd_list;
888a9083016SGiridhar Malavali };
889a9083016SGiridhar Malavali 
890a9083016SGiridhar Malavali #define MBC_TOGGLE_INTR			0x10
891a9083016SGiridhar Malavali 
892a9083016SGiridhar Malavali /* Flash  offset */
893a9083016SGiridhar Malavali #define FLT_REG_BOOTLOAD_82XX	0x72
894a9083016SGiridhar Malavali #define FLT_REG_BOOT_CODE_82XX	0x78
895a9083016SGiridhar Malavali #define FLT_REG_FW_82XX		0x74
896a9083016SGiridhar Malavali #define FLT_REG_GOLD_FW_82XX	0x75
897a9083016SGiridhar Malavali #define FLT_REG_VPD_82XX	0x81
898a9083016SGiridhar Malavali 
899a9083016SGiridhar Malavali #define	FA_VPD_SIZE_82XX	0x400
900a9083016SGiridhar Malavali 
901a9083016SGiridhar Malavali #define FA_FLASH_LAYOUT_ADDR_82	0xFC400
902a9083016SGiridhar Malavali 
903a9083016SGiridhar Malavali /******************************************************************************
904a9083016SGiridhar Malavali *
905a9083016SGiridhar Malavali *    Definitions specific to M25P flash
906a9083016SGiridhar Malavali *
907a9083016SGiridhar Malavali *******************************************************************************
908a9083016SGiridhar Malavali *   Instructions
909a9083016SGiridhar Malavali */
910a9083016SGiridhar Malavali #define M25P_INSTR_WREN		0x06
911a9083016SGiridhar Malavali #define M25P_INSTR_WRDI		0x04
912a9083016SGiridhar Malavali #define M25P_INSTR_RDID		0x9f
913a9083016SGiridhar Malavali #define M25P_INSTR_RDSR		0x05
914a9083016SGiridhar Malavali #define M25P_INSTR_WRSR		0x01
915a9083016SGiridhar Malavali #define M25P_INSTR_READ		0x03
916a9083016SGiridhar Malavali #define M25P_INSTR_FAST_READ	0x0b
917a9083016SGiridhar Malavali #define M25P_INSTR_PP		0x02
918a9083016SGiridhar Malavali #define M25P_INSTR_SE		0xd8
919a9083016SGiridhar Malavali #define M25P_INSTR_BE		0xc7
920a9083016SGiridhar Malavali #define M25P_INSTR_DP		0xb9
921a9083016SGiridhar Malavali #define M25P_INSTR_RES		0xab
922a9083016SGiridhar Malavali 
923a9083016SGiridhar Malavali #endif
924