xref: /openbmc/linux/drivers/scsi/qla2xxx/qla_nx.h (revision a865c50a64f1c0c27fc0be0652b6a352f537cb6f)
1a9083016SGiridhar Malavali /*
2a9083016SGiridhar Malavali  * QLogic Fibre Channel HBA Driver
346152cebSChad Dupuis  * Copyright (c)  2003-2012 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)
295988aeb2SGiridhar Malavali #define CRB_TEMP_STATE			QLA82XX_REG(0x1b4)
3077e334d2SGiridhar Malavali #define QLA82XX_DMA_SHIFT_VALUE		0x55555555
31a9083016SGiridhar Malavali 
32a9083016SGiridhar Malavali #define QLA82XX_HW_H0_CH_HUB_ADR    0x05
33a9083016SGiridhar Malavali #define QLA82XX_HW_H1_CH_HUB_ADR    0x0E
34a9083016SGiridhar Malavali #define QLA82XX_HW_H2_CH_HUB_ADR    0x03
35a9083016SGiridhar Malavali #define QLA82XX_HW_H3_CH_HUB_ADR    0x01
36a9083016SGiridhar Malavali #define QLA82XX_HW_H4_CH_HUB_ADR    0x06
37a9083016SGiridhar Malavali #define QLA82XX_HW_H5_CH_HUB_ADR    0x07
38a9083016SGiridhar Malavali #define QLA82XX_HW_H6_CH_HUB_ADR    0x08
39a9083016SGiridhar Malavali 
40a9083016SGiridhar Malavali /*  Hub 0 */
41a9083016SGiridhar Malavali #define QLA82XX_HW_MN_CRB_AGT_ADR   0x15
42a9083016SGiridhar Malavali #define QLA82XX_HW_MS_CRB_AGT_ADR   0x25
43a9083016SGiridhar Malavali 
44a9083016SGiridhar Malavali /*  Hub 1 */
45a9083016SGiridhar Malavali #define QLA82XX_HW_PS_CRB_AGT_ADR	0x73
46a9083016SGiridhar Malavali #define QLA82XX_HW_QMS_CRB_AGT_ADR	0x00
47a9083016SGiridhar Malavali #define QLA82XX_HW_RPMX3_CRB_AGT_ADR	0x0b
48a9083016SGiridhar Malavali #define QLA82XX_HW_SQGS0_CRB_AGT_ADR	0x01
49a9083016SGiridhar Malavali #define QLA82XX_HW_SQGS1_CRB_AGT_ADR	0x02
50a9083016SGiridhar Malavali #define QLA82XX_HW_SQGS2_CRB_AGT_ADR	0x03
51a9083016SGiridhar Malavali #define QLA82XX_HW_SQGS3_CRB_AGT_ADR	0x04
52a9083016SGiridhar Malavali #define QLA82XX_HW_C2C0_CRB_AGT_ADR	0x58
53a9083016SGiridhar Malavali #define QLA82XX_HW_C2C1_CRB_AGT_ADR	0x59
54a9083016SGiridhar Malavali #define QLA82XX_HW_C2C2_CRB_AGT_ADR	0x5a
55a9083016SGiridhar Malavali #define QLA82XX_HW_RPMX2_CRB_AGT_ADR	0x0a
56a9083016SGiridhar Malavali #define QLA82XX_HW_RPMX4_CRB_AGT_ADR	0x0c
57a9083016SGiridhar Malavali #define QLA82XX_HW_RPMX7_CRB_AGT_ADR	0x0f
58a9083016SGiridhar Malavali #define QLA82XX_HW_RPMX9_CRB_AGT_ADR	0x12
59a9083016SGiridhar Malavali #define QLA82XX_HW_SMB_CRB_AGT_ADR	0x18
60a9083016SGiridhar Malavali 
61a9083016SGiridhar Malavali /*  Hub 2 */
62a9083016SGiridhar Malavali #define QLA82XX_HW_NIU_CRB_AGT_ADR	0x31
63a9083016SGiridhar Malavali #define QLA82XX_HW_I2C0_CRB_AGT_ADR	0x19
64a9083016SGiridhar Malavali #define QLA82XX_HW_I2C1_CRB_AGT_ADR	0x29
65a9083016SGiridhar Malavali 
66a9083016SGiridhar Malavali #define QLA82XX_HW_SN_CRB_AGT_ADR	0x10
67a9083016SGiridhar Malavali #define QLA82XX_HW_I2Q_CRB_AGT_ADR	0x20
68a9083016SGiridhar Malavali #define QLA82XX_HW_LPC_CRB_AGT_ADR	0x22
69a9083016SGiridhar Malavali #define QLA82XX_HW_ROMUSB_CRB_AGT_ADR	0x21
70a9083016SGiridhar Malavali #define QLA82XX_HW_QM_CRB_AGT_ADR	0x66
71a9083016SGiridhar Malavali #define QLA82XX_HW_SQG0_CRB_AGT_ADR	0x60
72a9083016SGiridhar Malavali #define QLA82XX_HW_SQG1_CRB_AGT_ADR	0x61
73a9083016SGiridhar Malavali #define QLA82XX_HW_SQG2_CRB_AGT_ADR	0x62
74a9083016SGiridhar Malavali #define QLA82XX_HW_SQG3_CRB_AGT_ADR	0x63
75a9083016SGiridhar Malavali #define QLA82XX_HW_RPMX1_CRB_AGT_ADR	0x09
76a9083016SGiridhar Malavali #define QLA82XX_HW_RPMX5_CRB_AGT_ADR	0x0d
77a9083016SGiridhar Malavali #define QLA82XX_HW_RPMX6_CRB_AGT_ADR	0x0e
78a9083016SGiridhar Malavali #define QLA82XX_HW_RPMX8_CRB_AGT_ADR	0x11
79a9083016SGiridhar Malavali 
80a9083016SGiridhar Malavali /*  Hub 3 */
81a9083016SGiridhar Malavali #define QLA82XX_HW_PH_CRB_AGT_ADR	0x1A
82a9083016SGiridhar Malavali #define QLA82XX_HW_SRE_CRB_AGT_ADR	0x50
83a9083016SGiridhar Malavali #define QLA82XX_HW_EG_CRB_AGT_ADR	0x51
84a9083016SGiridhar Malavali #define QLA82XX_HW_RPMX0_CRB_AGT_ADR	0x08
85a9083016SGiridhar Malavali 
86a9083016SGiridhar Malavali /*  Hub 4 */
87a9083016SGiridhar Malavali #define QLA82XX_HW_PEGN0_CRB_AGT_ADR	0x40
88a9083016SGiridhar Malavali #define QLA82XX_HW_PEGN1_CRB_AGT_ADR	0x41
89a9083016SGiridhar Malavali #define QLA82XX_HW_PEGN2_CRB_AGT_ADR	0x42
90a9083016SGiridhar Malavali #define QLA82XX_HW_PEGN3_CRB_AGT_ADR	0x43
91a9083016SGiridhar Malavali #define QLA82XX_HW_PEGNI_CRB_AGT_ADR	0x44
92a9083016SGiridhar Malavali #define QLA82XX_HW_PEGND_CRB_AGT_ADR	0x45
93a9083016SGiridhar Malavali #define QLA82XX_HW_PEGNC_CRB_AGT_ADR	0x46
94a9083016SGiridhar Malavali #define QLA82XX_HW_PEGR0_CRB_AGT_ADR	0x47
95a9083016SGiridhar Malavali #define QLA82XX_HW_PEGR1_CRB_AGT_ADR	0x48
96a9083016SGiridhar Malavali #define QLA82XX_HW_PEGR2_CRB_AGT_ADR	0x49
97a9083016SGiridhar Malavali #define QLA82XX_HW_PEGR3_CRB_AGT_ADR	0x4a
98a9083016SGiridhar Malavali #define QLA82XX_HW_PEGN4_CRB_AGT_ADR	0x4b
99a9083016SGiridhar Malavali 
100a9083016SGiridhar Malavali /*  Hub 5 */
101a9083016SGiridhar Malavali #define QLA82XX_HW_PEGS0_CRB_AGT_ADR	0x40
102a9083016SGiridhar Malavali #define QLA82XX_HW_PEGS1_CRB_AGT_ADR	0x41
103a9083016SGiridhar Malavali #define QLA82XX_HW_PEGS2_CRB_AGT_ADR	0x42
104a9083016SGiridhar Malavali #define QLA82XX_HW_PEGS3_CRB_AGT_ADR	0x43
105a9083016SGiridhar Malavali #define QLA82XX_HW_PEGSI_CRB_AGT_ADR	0x44
106a9083016SGiridhar Malavali #define QLA82XX_HW_PEGSD_CRB_AGT_ADR	0x45
107a9083016SGiridhar Malavali #define QLA82XX_HW_PEGSC_CRB_AGT_ADR	0x46
108a9083016SGiridhar Malavali 
109a9083016SGiridhar Malavali /*  Hub 6 */
110a9083016SGiridhar Malavali #define QLA82XX_HW_CAS0_CRB_AGT_ADR	0x46
111a9083016SGiridhar Malavali #define QLA82XX_HW_CAS1_CRB_AGT_ADR	0x47
112a9083016SGiridhar Malavali #define QLA82XX_HW_CAS2_CRB_AGT_ADR	0x48
113a9083016SGiridhar Malavali #define QLA82XX_HW_CAS3_CRB_AGT_ADR	0x49
114a9083016SGiridhar Malavali #define QLA82XX_HW_NCM_CRB_AGT_ADR	0x16
115a9083016SGiridhar Malavali #define QLA82XX_HW_TMR_CRB_AGT_ADR	0x17
116a9083016SGiridhar Malavali #define QLA82XX_HW_XDMA_CRB_AGT_ADR	0x05
117a9083016SGiridhar Malavali #define QLA82XX_HW_OCM0_CRB_AGT_ADR	0x06
118a9083016SGiridhar Malavali #define QLA82XX_HW_OCM1_CRB_AGT_ADR	0x07
119a9083016SGiridhar Malavali 
120a9083016SGiridhar Malavali /*  This field defines PCI/X adr [25:20] of agents on the CRB */
121a9083016SGiridhar Malavali /*  */
122a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PH	0
123a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PS	1
124a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_MN	2
125a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_MS	3
126a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_SRE	5
127a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_NIU	6
128a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_QMN	7
129a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_SQN0	8
130a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_SQN1	9
131a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_SQN2	10
132a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_SQN3	11
133a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_QMS	12
134a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_SQS0	13
135a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_SQS1	14
136a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_SQS2	15
137a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_SQS3	16
138a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGN0	17
139a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGN1	18
140a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGN2	19
141a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGN3	20
142a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGN4	QLA82XX_HW_PX_MAP_CRB_SQS2
143a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGND	21
144a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGNI	22
145a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGS0	23
146a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGS1	24
147a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGS2	25
148a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGS3	26
149a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGSD	27
150a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGSI	28
151a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_SN	29
152a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_EG	31
153a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PH2	32
154a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PS2	33
155a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_CAM	34
156a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_CAS0	35
157a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_CAS1	36
158a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_CAS2	37
159a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_C2C0	38
160a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_C2C1	39
161a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_TIMR	40
162a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_RPMX1	42
163a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_RPMX2	43
164a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_RPMX3	44
165a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_RPMX4	45
166a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_RPMX5	46
167a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_RPMX6	47
168a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_RPMX7	48
169a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_XDMA	49
170a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_I2Q	50
171a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_ROMUSB	51
172a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_CAS3	52
173a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_RPMX0	53
174a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_RPMX8	54
175a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_RPMX9	55
176a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_OCM0	56
177a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_OCM1	57
178a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_SMB	58
179a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_I2C0	59
180a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_I2C1	60
181a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_LPC	61
182a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGNC	62
183a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGR0	63
184a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGR1	4
185a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGR2	30
186a9083016SGiridhar Malavali #define QLA82XX_HW_PX_MAP_CRB_PGR3	41
187a9083016SGiridhar Malavali 
188a9083016SGiridhar Malavali /*  This field defines CRB adr [31:20] of the agents */
189a9083016SGiridhar Malavali /*  */
190a9083016SGiridhar Malavali 
191a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_MN	    ((QLA82XX_HW_H0_CH_HUB_ADR << 7) | \
192a9083016SGiridhar Malavali 	QLA82XX_HW_MN_CRB_AGT_ADR)
193a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PH	    ((QLA82XX_HW_H0_CH_HUB_ADR << 7) | \
194a9083016SGiridhar Malavali 	QLA82XX_HW_PH_CRB_AGT_ADR)
195a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_MS	    ((QLA82XX_HW_H0_CH_HUB_ADR << 7) | \
196a9083016SGiridhar Malavali 	QLA82XX_HW_MS_CRB_AGT_ADR)
197a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PS	    ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
198a9083016SGiridhar Malavali 	QLA82XX_HW_PS_CRB_AGT_ADR)
199a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_SS	    ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
200a9083016SGiridhar Malavali 	QLA82XX_HW_SS_CRB_AGT_ADR)
201a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX3    ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
202a9083016SGiridhar Malavali 	QLA82XX_HW_RPMX3_CRB_AGT_ADR)
203a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_QMS	    ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
204a9083016SGiridhar Malavali 	QLA82XX_HW_QMS_CRB_AGT_ADR)
205a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_SQS0     ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
206a9083016SGiridhar Malavali 	QLA82XX_HW_SQGS0_CRB_AGT_ADR)
207a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_SQS1     ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
208a9083016SGiridhar Malavali 	QLA82XX_HW_SQGS1_CRB_AGT_ADR)
209a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_SQS2     ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
210a9083016SGiridhar Malavali 	QLA82XX_HW_SQGS2_CRB_AGT_ADR)
211a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_SQS3     ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
212a9083016SGiridhar Malavali 	QLA82XX_HW_SQGS3_CRB_AGT_ADR)
213a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_C2C0     ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
214a9083016SGiridhar Malavali 	QLA82XX_HW_C2C0_CRB_AGT_ADR)
215a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_C2C1     ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
216a9083016SGiridhar Malavali 	QLA82XX_HW_C2C1_CRB_AGT_ADR)
217a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX2    ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
218a9083016SGiridhar Malavali 	QLA82XX_HW_RPMX2_CRB_AGT_ADR)
219a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX4    ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
220a9083016SGiridhar Malavali 	QLA82XX_HW_RPMX4_CRB_AGT_ADR)
221a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX7    ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
222a9083016SGiridhar Malavali 	QLA82XX_HW_RPMX7_CRB_AGT_ADR)
223a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX9    ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
224a9083016SGiridhar Malavali 	QLA82XX_HW_RPMX9_CRB_AGT_ADR)
225a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_SMB	    ((QLA82XX_HW_H1_CH_HUB_ADR << 7) | \
226a9083016SGiridhar Malavali 	QLA82XX_HW_SMB_CRB_AGT_ADR)
227a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_NIU	    ((QLA82XX_HW_H2_CH_HUB_ADR << 7) | \
228a9083016SGiridhar Malavali 	QLA82XX_HW_NIU_CRB_AGT_ADR)
229a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_I2C0     ((QLA82XX_HW_H2_CH_HUB_ADR << 7) | \
230a9083016SGiridhar Malavali 	QLA82XX_HW_I2C0_CRB_AGT_ADR)
231a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_I2C1     ((QLA82XX_HW_H2_CH_HUB_ADR << 7) | \
232a9083016SGiridhar Malavali 	QLA82XX_HW_I2C1_CRB_AGT_ADR)
233a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_SRE	    ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
234a9083016SGiridhar Malavali 	QLA82XX_HW_SRE_CRB_AGT_ADR)
235a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_EG	    ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
236a9083016SGiridhar Malavali 	QLA82XX_HW_EG_CRB_AGT_ADR)
237a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX0    ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
238a9083016SGiridhar Malavali 	QLA82XX_HW_RPMX0_CRB_AGT_ADR)
239a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_QMN	    ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
240a9083016SGiridhar Malavali 	QLA82XX_HW_QM_CRB_AGT_ADR)
241a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_SQN0     ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
242a9083016SGiridhar Malavali 	QLA82XX_HW_SQG0_CRB_AGT_ADR)
243a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_SQN1     ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
244a9083016SGiridhar Malavali 	QLA82XX_HW_SQG1_CRB_AGT_ADR)
245a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_SQN2     ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
246a9083016SGiridhar Malavali 	QLA82XX_HW_SQG2_CRB_AGT_ADR)
247a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_SQN3     ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
248a9083016SGiridhar Malavali 	QLA82XX_HW_SQG3_CRB_AGT_ADR)
249a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX1    ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
250a9083016SGiridhar Malavali 	QLA82XX_HW_RPMX1_CRB_AGT_ADR)
251a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX5    ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
252a9083016SGiridhar Malavali 	QLA82XX_HW_RPMX5_CRB_AGT_ADR)
253a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX6    ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
254a9083016SGiridhar Malavali 	QLA82XX_HW_RPMX6_CRB_AGT_ADR)
255a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_RPMX8    ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
256a9083016SGiridhar Malavali 	QLA82XX_HW_RPMX8_CRB_AGT_ADR)
257a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_CAS0     ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
258a9083016SGiridhar Malavali 	QLA82XX_HW_CAS0_CRB_AGT_ADR)
259a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_CAS1     ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
260a9083016SGiridhar Malavali 	QLA82XX_HW_CAS1_CRB_AGT_ADR)
261a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_CAS2     ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
262a9083016SGiridhar Malavali 	QLA82XX_HW_CAS2_CRB_AGT_ADR)
263a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_CAS3     ((QLA82XX_HW_H3_CH_HUB_ADR << 7) | \
264a9083016SGiridhar Malavali 	QLA82XX_HW_CAS3_CRB_AGT_ADR)
265a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGNI     ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
266a9083016SGiridhar Malavali 	QLA82XX_HW_PEGNI_CRB_AGT_ADR)
267a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGND     ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
268a9083016SGiridhar Malavali 	QLA82XX_HW_PEGND_CRB_AGT_ADR)
269a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGN0     ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
270a9083016SGiridhar Malavali 	QLA82XX_HW_PEGN0_CRB_AGT_ADR)
271a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGN1     ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
272a9083016SGiridhar Malavali 	QLA82XX_HW_PEGN1_CRB_AGT_ADR)
273a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGN2     ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
274a9083016SGiridhar Malavali 	QLA82XX_HW_PEGN2_CRB_AGT_ADR)
275a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGN3     ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
276a9083016SGiridhar Malavali 	QLA82XX_HW_PEGN3_CRB_AGT_ADR)
277a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGN4	   ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
278a9083016SGiridhar Malavali 	QLA82XX_HW_PEGN4_CRB_AGT_ADR)
279a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGNC     ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
280a9083016SGiridhar Malavali 	QLA82XX_HW_PEGNC_CRB_AGT_ADR)
281a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGR0     ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
282a9083016SGiridhar Malavali 	QLA82XX_HW_PEGR0_CRB_AGT_ADR)
283a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGR1     ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
284a9083016SGiridhar Malavali 	QLA82XX_HW_PEGR1_CRB_AGT_ADR)
285a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGR2     ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
286a9083016SGiridhar Malavali 	QLA82XX_HW_PEGR2_CRB_AGT_ADR)
287a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGR3     ((QLA82XX_HW_H4_CH_HUB_ADR << 7) | \
288a9083016SGiridhar Malavali 	QLA82XX_HW_PEGR3_CRB_AGT_ADR)
289a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGSI     ((QLA82XX_HW_H5_CH_HUB_ADR << 7) | \
290a9083016SGiridhar Malavali 	QLA82XX_HW_PEGSI_CRB_AGT_ADR)
291a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGSD     ((QLA82XX_HW_H5_CH_HUB_ADR << 7) | \
292a9083016SGiridhar Malavali 	QLA82XX_HW_PEGSD_CRB_AGT_ADR)
293a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGS0     ((QLA82XX_HW_H5_CH_HUB_ADR << 7) | \
294a9083016SGiridhar Malavali 	QLA82XX_HW_PEGS0_CRB_AGT_ADR)
295a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGS1     ((QLA82XX_HW_H5_CH_HUB_ADR << 7) | \
296a9083016SGiridhar Malavali 	QLA82XX_HW_PEGS1_CRB_AGT_ADR)
297a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGS2     ((QLA82XX_HW_H5_CH_HUB_ADR << 7) | \
298a9083016SGiridhar Malavali 	QLA82XX_HW_PEGS2_CRB_AGT_ADR)
299a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGS3     ((QLA82XX_HW_H5_CH_HUB_ADR << 7) | \
300a9083016SGiridhar Malavali 	QLA82XX_HW_PEGS3_CRB_AGT_ADR)
301a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_PGSC     ((QLA82XX_HW_H5_CH_HUB_ADR << 7) | \
302a9083016SGiridhar Malavali 	QLA82XX_HW_PEGSC_CRB_AGT_ADR)
303a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_CAM	    ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
304a9083016SGiridhar Malavali 	QLA82XX_HW_NCM_CRB_AGT_ADR)
305a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_TIMR     ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
306a9083016SGiridhar Malavali 	QLA82XX_HW_TMR_CRB_AGT_ADR)
307a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_XDMA     ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
308a9083016SGiridhar Malavali 	QLA82XX_HW_XDMA_CRB_AGT_ADR)
309a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_SN	    ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
310a9083016SGiridhar Malavali 	QLA82XX_HW_SN_CRB_AGT_ADR)
311a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_I2Q	    ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
312a9083016SGiridhar Malavali 	QLA82XX_HW_I2Q_CRB_AGT_ADR)
313a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_ROMUSB   ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
314a9083016SGiridhar Malavali 	QLA82XX_HW_ROMUSB_CRB_AGT_ADR)
315a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_OCM0     ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
316a9083016SGiridhar Malavali 	QLA82XX_HW_OCM0_CRB_AGT_ADR)
317a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_OCM1     ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
318a9083016SGiridhar Malavali 	QLA82XX_HW_OCM1_CRB_AGT_ADR)
319a9083016SGiridhar Malavali #define QLA82XX_HW_CRB_HUB_AGT_ADR_LPC	    ((QLA82XX_HW_H6_CH_HUB_ADR << 7) | \
320a9083016SGiridhar Malavali 	QLA82XX_HW_LPC_CRB_AGT_ADR)
321a9083016SGiridhar Malavali 
322a9083016SGiridhar Malavali #define ROMUSB_GLB				(QLA82XX_CRB_ROMUSB + 0x00000)
323a9083016SGiridhar Malavali #define QLA82XX_ROMUSB_GLB_PEGTUNE_DONE		(ROMUSB_GLB + 0x005c)
324a9083016SGiridhar Malavali #define QLA82XX_ROMUSB_GLB_STATUS		(ROMUSB_GLB + 0x0004)
325a9083016SGiridhar Malavali #define QLA82XX_ROMUSB_GLB_SW_RESET		(ROMUSB_GLB + 0x0008)
326a9083016SGiridhar Malavali #define QLA82XX_ROMUSB_ROM_ADDRESS		(ROMUSB_ROM + 0x0008)
327a9083016SGiridhar Malavali #define QLA82XX_ROMUSB_ROM_WDATA		(ROMUSB_ROM + 0x000c)
328a9083016SGiridhar Malavali #define QLA82XX_ROMUSB_ROM_ABYTE_CNT		(ROMUSB_ROM + 0x0010)
329a9083016SGiridhar Malavali #define QLA82XX_ROMUSB_ROM_DUMMY_BYTE_CNT	(ROMUSB_ROM + 0x0014)
330a9083016SGiridhar Malavali #define QLA82XX_ROMUSB_ROM_RDATA		(ROMUSB_ROM + 0x0018)
331a9083016SGiridhar Malavali 
332a9083016SGiridhar Malavali #define ROMUSB_ROM				(QLA82XX_CRB_ROMUSB + 0x10000)
333a9083016SGiridhar Malavali #define QLA82XX_ROMUSB_ROM_INSTR_OPCODE		(ROMUSB_ROM + 0x0004)
334a9083016SGiridhar Malavali #define QLA82XX_ROMUSB_GLB_CAS_RST		(ROMUSB_GLB + 0x0038)
335a9083016SGiridhar Malavali 
336a9083016SGiridhar Malavali /* Lock IDs for ROM lock */
337a9083016SGiridhar Malavali #define ROM_LOCK_DRIVER       0x0d417340
338a9083016SGiridhar Malavali 
339a9083016SGiridhar Malavali #define QLA82XX_PCI_CRB_WINDOWSIZE 0x00100000	 /* all are 1MB windows */
340a9083016SGiridhar Malavali #define QLA82XX_PCI_CRB_WINDOW(A) \
341a9083016SGiridhar Malavali 	(QLA82XX_PCI_CRBSPACE + (A)*QLA82XX_PCI_CRB_WINDOWSIZE)
342a9083016SGiridhar Malavali #define QLA82XX_CRB_C2C_0 \
343a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_C2C0)
344a9083016SGiridhar Malavali #define QLA82XX_CRB_C2C_1 \
345a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_C2C1)
346a9083016SGiridhar Malavali #define QLA82XX_CRB_C2C_2 \
347a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_C2C2)
348a9083016SGiridhar Malavali #define QLA82XX_CRB_CAM \
349a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_CAM)
350a9083016SGiridhar Malavali #define QLA82XX_CRB_CASPER \
351a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_CAS)
352a9083016SGiridhar Malavali #define QLA82XX_CRB_CASPER_0 \
353a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_CAS0)
354a9083016SGiridhar Malavali #define QLA82XX_CRB_CASPER_1 \
355a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_CAS1)
356a9083016SGiridhar Malavali #define QLA82XX_CRB_CASPER_2 \
357a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_CAS2)
358a9083016SGiridhar Malavali #define QLA82XX_CRB_DDR_MD \
359a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_MS)
360a9083016SGiridhar Malavali #define QLA82XX_CRB_DDR_NET \
361a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_MN)
362a9083016SGiridhar Malavali #define QLA82XX_CRB_EPG \
363a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_EG)
364a9083016SGiridhar Malavali #define QLA82XX_CRB_I2Q \
365a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_I2Q)
366a9083016SGiridhar Malavali #define QLA82XX_CRB_NIU \
367a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_NIU)
368a9083016SGiridhar Malavali 
369a9083016SGiridhar Malavali #define QLA82XX_CRB_PCIX_HOST \
370a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PH)
371a9083016SGiridhar Malavali #define QLA82XX_CRB_PCIX_HOST2 \
372a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PH2)
373a9083016SGiridhar Malavali #define QLA82XX_CRB_PCIX_MD \
374a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PS)
375a9083016SGiridhar Malavali #define QLA82XX_CRB_PCIE \
376a9083016SGiridhar Malavali 	QLA82XX_CRB_PCIX_MD
377a9083016SGiridhar Malavali 
378a9083016SGiridhar Malavali /* window 1 pcie slot */
379a9083016SGiridhar Malavali #define QLA82XX_CRB_PCIE2	 \
380a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PS2)
381a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_MD_0 \
382a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGS0)
383a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_MD_1 \
384a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGS1)
385a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_MD_2 \
386a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGS2)
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_3 \
390a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGS3)
391a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_MD_D \
392a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGSD)
393a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_MD_I \
394a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGSI)
395a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_NET_0 \
396a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGN0)
397a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_NET_1 \
398a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGN1)
399a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_NET_2 \
400a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGN2)
401a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_NET_3 \
402a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGN3)
403a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_NET_4 \
404a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGN4)
405a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_NET_D \
406a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGND)
407a9083016SGiridhar Malavali #define QLA82XX_CRB_PEG_NET_I \
408a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_PGNI)
409a9083016SGiridhar Malavali #define QLA82XX_CRB_PQM_MD \
410a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_QMS)
411a9083016SGiridhar Malavali #define QLA82XX_CRB_PQM_NET \
412a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_QMN)
413a9083016SGiridhar Malavali #define QLA82XX_CRB_QDR_MD \
414a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SS)
415a9083016SGiridhar Malavali #define QLA82XX_CRB_QDR_NET \
416a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SN)
417a9083016SGiridhar Malavali #define QLA82XX_CRB_ROMUSB \
418a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_ROMUSB)
419a9083016SGiridhar Malavali #define QLA82XX_CRB_RPMX_0 \
420a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_RPMX0)
421a9083016SGiridhar Malavali #define QLA82XX_CRB_RPMX_1 \
422a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_RPMX1)
423a9083016SGiridhar Malavali #define QLA82XX_CRB_RPMX_2 \
424a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_RPMX2)
425a9083016SGiridhar Malavali #define QLA82XX_CRB_RPMX_3 \
426a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_RPMX3)
427a9083016SGiridhar Malavali #define QLA82XX_CRB_RPMX_4 \
428a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_RPMX4)
429a9083016SGiridhar Malavali #define QLA82XX_CRB_RPMX_5 \
430a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_RPMX5)
431a9083016SGiridhar Malavali #define QLA82XX_CRB_RPMX_6 \
432a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_RPMX6)
433a9083016SGiridhar Malavali #define QLA82XX_CRB_RPMX_7 \
434a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_RPMX7)
435a9083016SGiridhar Malavali #define QLA82XX_CRB_SQM_MD_0 \
436a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SQS0)
437a9083016SGiridhar Malavali #define QLA82XX_CRB_SQM_MD_1 \
438a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SQS1)
439a9083016SGiridhar Malavali #define QLA82XX_CRB_SQM_MD_2 \
440a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SQS2)
441a9083016SGiridhar Malavali #define QLA82XX_CRB_SQM_MD_3 \
442a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SQS3)
443a9083016SGiridhar Malavali #define QLA82XX_CRB_SQM_NET_0 \
444a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SQN0)
445a9083016SGiridhar Malavali #define QLA82XX_CRB_SQM_NET_1 \
446a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SQN1)
447a9083016SGiridhar Malavali #define QLA82XX_CRB_SQM_NET_2 \
448a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SQN2)
449a9083016SGiridhar Malavali #define QLA82XX_CRB_SQM_NET_3 \
450a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SQN3)
451a9083016SGiridhar Malavali #define QLA82XX_CRB_SRE \
452a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SRE)
453a9083016SGiridhar Malavali #define QLA82XX_CRB_TIMER \
454a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_TIMR)
455a9083016SGiridhar Malavali #define QLA82XX_CRB_XDMA \
456a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_XDMA)
457a9083016SGiridhar Malavali #define QLA82XX_CRB_I2C0 \
458a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_I2C0)
459a9083016SGiridhar Malavali #define QLA82XX_CRB_I2C1 \
460a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_I2C1)
461a9083016SGiridhar Malavali #define QLA82XX_CRB_OCM0 \
462a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_OCM0)
463a9083016SGiridhar Malavali #define QLA82XX_CRB_SMB \
464a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(QLA82XX_HW_PX_MAP_CRB_SMB)
465a9083016SGiridhar Malavali #define QLA82XX_CRB_MAX \
466a9083016SGiridhar Malavali 	QLA82XX_PCI_CRB_WINDOW(64)
467a9083016SGiridhar Malavali 
468a9083016SGiridhar Malavali /*
469a9083016SGiridhar Malavali  * ====================== BASE ADDRESSES ON-CHIP ======================
470a9083016SGiridhar Malavali  * Base addresses of major components on-chip.
471a9083016SGiridhar Malavali  * ====================== BASE ADDRESSES ON-CHIP ======================
472a9083016SGiridhar Malavali  */
473a9083016SGiridhar Malavali #define QLA82XX_ADDR_DDR_NET		(0x0000000000000000ULL)
474a9083016SGiridhar Malavali #define QLA82XX_ADDR_DDR_NET_MAX	(0x000000000fffffffULL)
475a9083016SGiridhar Malavali 
476a9083016SGiridhar Malavali /* Imbus address bit used to indicate a host address. This bit is
477a9083016SGiridhar Malavali  * eliminated by the pcie bar and bar select before presentation
478a9083016SGiridhar Malavali  * over pcie. */
479a9083016SGiridhar Malavali /* host memory via IMBUS */
480a9083016SGiridhar Malavali #define QLA82XX_P2_ADDR_PCIE		(0x0000000800000000ULL)
481a9083016SGiridhar Malavali #define QLA82XX_P3_ADDR_PCIE		(0x0000008000000000ULL)
482a9083016SGiridhar Malavali #define QLA82XX_ADDR_PCIE_MAX		(0x0000000FFFFFFFFFULL)
483a9083016SGiridhar Malavali #define QLA82XX_ADDR_OCM0		(0x0000000200000000ULL)
484a9083016SGiridhar Malavali #define QLA82XX_ADDR_OCM0_MAX		(0x00000002000fffffULL)
485a9083016SGiridhar Malavali #define QLA82XX_ADDR_OCM1		(0x0000000200400000ULL)
486a9083016SGiridhar Malavali #define QLA82XX_ADDR_OCM1_MAX		(0x00000002004fffffULL)
487a9083016SGiridhar Malavali #define QLA82XX_ADDR_QDR_NET		(0x0000000300000000ULL)
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_PORT_MODE_ADDR		(QLA82XX_CAM_RAM(0x24))
526a9083016SGiridhar Malavali #define QLA82XX_PEG_HALT_STATUS1	(QLA82XX_CAM_RAM(0xa8))
527a9083016SGiridhar Malavali #define QLA82XX_PEG_HALT_STATUS2	(QLA82XX_CAM_RAM(0xac))
528a9083016SGiridhar Malavali #define QLA82XX_PEG_ALIVE_COUNTER	(QLA82XX_CAM_RAM(0xb0))
529a9083016SGiridhar Malavali 
530a9083016SGiridhar Malavali #define QLA82XX_CAMRAM_DB1		(QLA82XX_CAM_RAM(0x1b8))
531a9083016SGiridhar Malavali #define QLA82XX_CAMRAM_DB2		(QLA82XX_CAM_RAM(0x1bc))
532a9083016SGiridhar Malavali 
533a9083016SGiridhar Malavali #define HALT_STATUS_UNRECOVERABLE	0x80000000
534a9083016SGiridhar Malavali #define HALT_STATUS_RECOVERABLE		0x40000000
535a9083016SGiridhar Malavali 
536a9083016SGiridhar Malavali /* Driver Coexistence Defines */
537a9083016SGiridhar Malavali #define QLA82XX_CRB_DRV_ACTIVE	     (QLA82XX_CAM_RAM(0x138))
538a9083016SGiridhar Malavali #define QLA82XX_CRB_DEV_STATE	     (QLA82XX_CAM_RAM(0x140))
539a9083016SGiridhar Malavali #define QLA82XX_CRB_DRV_STATE	     (QLA82XX_CAM_RAM(0x144))
540a9083016SGiridhar Malavali #define QLA82XX_CRB_DRV_SCRATCH      (QLA82XX_CAM_RAM(0x148))
541a9083016SGiridhar Malavali #define QLA82XX_CRB_DEV_PART_INFO    (QLA82XX_CAM_RAM(0x14c))
542b963752fSGiridhar Malavali #define QLA82XX_CRB_DRV_IDC_VERSION  (QLA82XX_CAM_RAM(0x174))
543a9083016SGiridhar Malavali 
544a9083016SGiridhar Malavali /* Every driver should use these Device State */
5457d613ac6SSantosh Vernekar #define QLA8XXX_DEV_COLD		1
5467d613ac6SSantosh Vernekar #define QLA8XXX_DEV_INITIALIZING	2
5477d613ac6SSantosh Vernekar #define QLA8XXX_DEV_READY		3
5487d613ac6SSantosh Vernekar #define QLA8XXX_DEV_NEED_RESET		4
5497d613ac6SSantosh Vernekar #define QLA8XXX_DEV_NEED_QUIESCENT	5
5507d613ac6SSantosh Vernekar #define QLA8XXX_DEV_FAILED		6
5517d613ac6SSantosh Vernekar #define QLA8XXX_DEV_QUIESCENT		7
552f1af6208SGiridhar Malavali #define	MAX_STATES			8 /* Increment if new state added */
5537d613ac6SSantosh Vernekar #define QLA8XXX_BAD_VALUE		0xbad0bad0
554a9083016SGiridhar Malavali 
555a9083016SGiridhar Malavali #define QLA82XX_IDC_VERSION			1
556a9083016SGiridhar Malavali #define QLA82XX_ROM_DEV_INIT_TIMEOUT		30
557a9083016SGiridhar Malavali #define QLA82XX_ROM_DRV_RESET_ACK_TIMEOUT	10
558a9083016SGiridhar Malavali 
559a9083016SGiridhar Malavali #define QLA82XX_ROM_LOCK_ID		(QLA82XX_CAM_RAM(0x100))
560a9083016SGiridhar Malavali #define QLA82XX_CRB_WIN_LOCK_ID		(QLA82XX_CAM_RAM(0x124))
561a9083016SGiridhar Malavali #define QLA82XX_FW_VERSION_MAJOR	(QLA82XX_CAM_RAM(0x150))
562a9083016SGiridhar Malavali #define QLA82XX_FW_VERSION_MINOR	(QLA82XX_CAM_RAM(0x154))
563a9083016SGiridhar Malavali #define QLA82XX_FW_VERSION_SUB		(QLA82XX_CAM_RAM(0x158))
564a9083016SGiridhar Malavali #define QLA82XX_PCIE_REG(reg)		(QLA82XX_CRB_PCIE + (reg))
565a9083016SGiridhar Malavali 
566a9083016SGiridhar Malavali #define PCIE_SETUP_FUNCTION		(0x12040)
567a9083016SGiridhar Malavali #define PCIE_SETUP_FUNCTION2		(0x12048)
568a9083016SGiridhar Malavali 
569a9083016SGiridhar Malavali #define QLA82XX_PCIX_PS_REG(reg)	(QLA82XX_CRB_PCIX_MD + (reg))
570a9083016SGiridhar Malavali #define QLA82XX_PCIX_PS2_REG(reg)	(QLA82XX_CRB_PCIE2 + (reg))
571a9083016SGiridhar Malavali 
572a9083016SGiridhar Malavali #define PCIE_SEM2_LOCK	     (0x1c010)	/* Flash lock	*/
573a9083016SGiridhar Malavali #define PCIE_SEM2_UNLOCK     (0x1c014)	/* Flash unlock */
574a9083016SGiridhar Malavali #define PCIE_SEM5_LOCK	     (0x1c028)	/* Coexistence lock   */
575a9083016SGiridhar Malavali #define PCIE_SEM5_UNLOCK     (0x1c02c)	/* Coexistence unlock */
576a9083016SGiridhar Malavali #define PCIE_SEM7_LOCK	     (0x1c038)	/* crb win lock */
577a9083016SGiridhar Malavali #define PCIE_SEM7_UNLOCK     (0x1c03c)	/* crbwin unlock*/
578a9083016SGiridhar Malavali 
579a9083016SGiridhar Malavali /* Different drive state */
580a9083016SGiridhar Malavali #define QLA82XX_DRVST_NOT_RDY		0
581a9083016SGiridhar Malavali #define	QLA82XX_DRVST_RST_RDY		1
582a9083016SGiridhar Malavali #define QLA82XX_DRVST_QSNT_RDY		2
583a9083016SGiridhar Malavali 
58477e334d2SGiridhar Malavali /* Different drive active state */
58577e334d2SGiridhar Malavali #define QLA82XX_DRV_NOT_ACTIVE		0
58677e334d2SGiridhar Malavali #define QLA82XX_DRV_ACTIVE		1
58777e334d2SGiridhar Malavali 
588a9083016SGiridhar Malavali /*
589a9083016SGiridhar Malavali  * The PCI VendorID and DeviceID for our board.
590a9083016SGiridhar Malavali  */
591a9083016SGiridhar Malavali #define PCI_DEVICE_ID_QLOGIC_ISP8021		0x8021
592a9083016SGiridhar Malavali 
593a9083016SGiridhar Malavali #define QLA82XX_MSIX_TBL_SPACE			8192
594a9083016SGiridhar Malavali #define QLA82XX_PCI_REG_MSIX_TBL		0x44
595a9083016SGiridhar Malavali #define QLA82XX_PCI_MSIX_CONTROL		0x40
596a9083016SGiridhar Malavali 
597a9083016SGiridhar Malavali struct crb_128M_2M_sub_block_map {
598a9083016SGiridhar Malavali 	unsigned valid;
599a9083016SGiridhar Malavali 	unsigned start_128M;
600a9083016SGiridhar Malavali 	unsigned end_128M;
601a9083016SGiridhar Malavali 	unsigned start_2M;
602a9083016SGiridhar Malavali };
603a9083016SGiridhar Malavali 
604a9083016SGiridhar Malavali struct crb_128M_2M_block_map {
605a9083016SGiridhar Malavali 	struct crb_128M_2M_sub_block_map sub_block[16];
606a9083016SGiridhar Malavali };
607a9083016SGiridhar Malavali 
608a9083016SGiridhar Malavali struct crb_addr_pair {
609a9083016SGiridhar Malavali 	long addr;
610a9083016SGiridhar Malavali 	long data;
611a9083016SGiridhar Malavali };
612a9083016SGiridhar Malavali 
613a9083016SGiridhar Malavali #define ADDR_ERROR ((unsigned long) 0xffffffff)
614a9083016SGiridhar Malavali #define MAX_CTL_CHECK	1000
615a9083016SGiridhar Malavali 
616a9083016SGiridhar Malavali /***************************************************************************
617a9083016SGiridhar Malavali  *		PCI related defines.
618a9083016SGiridhar Malavali  **************************************************************************/
619a9083016SGiridhar Malavali 
620a9083016SGiridhar Malavali /*
621a9083016SGiridhar Malavali  * Interrupt related defines.
622a9083016SGiridhar Malavali  */
623a9083016SGiridhar Malavali #define PCIX_TARGET_STATUS	(0x10118)
624a9083016SGiridhar Malavali #define PCIX_TARGET_STATUS_F1	(0x10160)
625a9083016SGiridhar Malavali #define PCIX_TARGET_STATUS_F2	(0x10164)
626a9083016SGiridhar Malavali #define PCIX_TARGET_STATUS_F3	(0x10168)
627a9083016SGiridhar Malavali #define PCIX_TARGET_STATUS_F4	(0x10360)
628a9083016SGiridhar Malavali #define PCIX_TARGET_STATUS_F5	(0x10364)
629a9083016SGiridhar Malavali #define PCIX_TARGET_STATUS_F6	(0x10368)
630a9083016SGiridhar Malavali #define PCIX_TARGET_STATUS_F7	(0x1036c)
631a9083016SGiridhar Malavali 
632a9083016SGiridhar Malavali #define PCIX_TARGET_MASK	(0x10128)
633a9083016SGiridhar Malavali #define PCIX_TARGET_MASK_F1	(0x10170)
634a9083016SGiridhar Malavali #define PCIX_TARGET_MASK_F2	(0x10174)
635a9083016SGiridhar Malavali #define PCIX_TARGET_MASK_F3	(0x10178)
636a9083016SGiridhar Malavali #define PCIX_TARGET_MASK_F4	(0x10370)
637a9083016SGiridhar Malavali #define PCIX_TARGET_MASK_F5	(0x10374)
638a9083016SGiridhar Malavali #define PCIX_TARGET_MASK_F6	(0x10378)
639a9083016SGiridhar Malavali #define PCIX_TARGET_MASK_F7	(0x1037c)
640a9083016SGiridhar Malavali 
641a9083016SGiridhar Malavali /*
642a9083016SGiridhar Malavali  * Message Signaled Interrupts
643a9083016SGiridhar Malavali  */
644a9083016SGiridhar Malavali #define PCIX_MSI_F0		(0x13000)
645a9083016SGiridhar Malavali #define PCIX_MSI_F1		(0x13004)
646a9083016SGiridhar Malavali #define PCIX_MSI_F2		(0x13008)
647a9083016SGiridhar Malavali #define PCIX_MSI_F3		(0x1300c)
648a9083016SGiridhar Malavali #define PCIX_MSI_F4		(0x13010)
649a9083016SGiridhar Malavali #define PCIX_MSI_F5		(0x13014)
650a9083016SGiridhar Malavali #define PCIX_MSI_F6		(0x13018)
651a9083016SGiridhar Malavali #define PCIX_MSI_F7		(0x1301c)
652a9083016SGiridhar Malavali #define PCIX_MSI_F(FUNC)	(0x13000 + ((FUNC) * 4))
653a9083016SGiridhar Malavali #define PCIX_INT_VECTOR		(0x10100)
654a9083016SGiridhar Malavali #define PCIX_INT_MASK		(0x10104)
655a9083016SGiridhar Malavali 
656a9083016SGiridhar Malavali /*
657a9083016SGiridhar Malavali  * Interrupt state machine and other bits.
658a9083016SGiridhar Malavali  */
659a9083016SGiridhar Malavali #define PCIE_MISCCFG_RC		(0x1206c)
660a9083016SGiridhar Malavali 
661a9083016SGiridhar Malavali #define ISR_INT_TARGET_STATUS \
662a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_STATUS))
663a9083016SGiridhar Malavali #define ISR_INT_TARGET_STATUS_F1 \
664a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_STATUS_F1))
665a9083016SGiridhar Malavali #define ISR_INT_TARGET_STATUS_F2 \
666a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_STATUS_F2))
667a9083016SGiridhar Malavali #define ISR_INT_TARGET_STATUS_F3 \
668a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_STATUS_F3))
669a9083016SGiridhar Malavali #define ISR_INT_TARGET_STATUS_F4 \
670a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_STATUS_F4))
671a9083016SGiridhar Malavali #define ISR_INT_TARGET_STATUS_F5 \
672a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_STATUS_F5))
673a9083016SGiridhar Malavali #define ISR_INT_TARGET_STATUS_F6 \
674a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_STATUS_F6))
675a9083016SGiridhar Malavali #define ISR_INT_TARGET_STATUS_F7 \
676a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_STATUS_F7))
677a9083016SGiridhar Malavali 
678a9083016SGiridhar Malavali #define ISR_INT_TARGET_MASK \
679a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_MASK))
680a9083016SGiridhar Malavali #define ISR_INT_TARGET_MASK_F1 \
681a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_MASK_F1))
682a9083016SGiridhar Malavali #define ISR_INT_TARGET_MASK_F2 \
683a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_MASK_F2))
684a9083016SGiridhar Malavali #define ISR_INT_TARGET_MASK_F3 \
685a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_MASK_F3))
686a9083016SGiridhar Malavali #define ISR_INT_TARGET_MASK_F4 \
687a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_MASK_F4))
688a9083016SGiridhar Malavali #define ISR_INT_TARGET_MASK_F5 \
689a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_MASK_F5))
690a9083016SGiridhar Malavali #define ISR_INT_TARGET_MASK_F6 \
691a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_MASK_F6))
692a9083016SGiridhar Malavali #define ISR_INT_TARGET_MASK_F7 \
693a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_TARGET_MASK_F7))
694a9083016SGiridhar Malavali 
695a9083016SGiridhar Malavali #define ISR_INT_VECTOR \
696a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_INT_VECTOR))
697a9083016SGiridhar Malavali #define ISR_INT_MASK \
698a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_INT_MASK))
699a9083016SGiridhar Malavali #define ISR_INT_STATE_REG \
700a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIE_MISCCFG_RC))
701a9083016SGiridhar Malavali 
702a9083016SGiridhar Malavali #define	ISR_MSI_INT_TRIGGER(FUNC) \
703a9083016SGiridhar Malavali 	(QLA82XX_PCIX_PS_REG(PCIX_MSI_F(FUNC)))
704a9083016SGiridhar Malavali 
705a9083016SGiridhar Malavali #define	ISR_IS_LEGACY_INTR_IDLE(VAL)		(((VAL) & 0x300) == 0)
706a9083016SGiridhar Malavali #define	ISR_IS_LEGACY_INTR_TRIGGERED(VAL)	(((VAL) & 0x300) == 0x200)
707a9083016SGiridhar Malavali 
708a9083016SGiridhar Malavali /*
709a9083016SGiridhar Malavali  * PCI Interrupt Vector Values.
710a9083016SGiridhar Malavali  */
711a9083016SGiridhar Malavali #define	PCIX_INT_VECTOR_BIT_F0	0x0080
712a9083016SGiridhar Malavali #define	PCIX_INT_VECTOR_BIT_F1	0x0100
713a9083016SGiridhar Malavali #define	PCIX_INT_VECTOR_BIT_F2	0x0200
714a9083016SGiridhar Malavali #define	PCIX_INT_VECTOR_BIT_F3	0x0400
715a9083016SGiridhar Malavali #define	PCIX_INT_VECTOR_BIT_F4	0x0800
716a9083016SGiridhar Malavali #define	PCIX_INT_VECTOR_BIT_F5	0x1000
717a9083016SGiridhar Malavali #define	PCIX_INT_VECTOR_BIT_F6	0x2000
718a9083016SGiridhar Malavali #define	PCIX_INT_VECTOR_BIT_F7	0x4000
719a9083016SGiridhar Malavali 
720a9083016SGiridhar Malavali struct qla82xx_legacy_intr_set {
721a9083016SGiridhar Malavali 	uint32_t	int_vec_bit;
722a9083016SGiridhar Malavali 	uint32_t	tgt_status_reg;
723a9083016SGiridhar Malavali 	uint32_t	tgt_mask_reg;
724a9083016SGiridhar Malavali 	uint32_t	pci_int_reg;
725a9083016SGiridhar Malavali };
726a9083016SGiridhar Malavali 
727a9083016SGiridhar Malavali #define QLA82XX_LEGACY_INTR_CONFIG					\
728a9083016SGiridhar Malavali {									\
729a9083016SGiridhar Malavali 	{								\
730a9083016SGiridhar Malavali 		.int_vec_bit	=	PCIX_INT_VECTOR_BIT_F0,		\
731a9083016SGiridhar Malavali 		.tgt_status_reg =	ISR_INT_TARGET_STATUS,		\
732a9083016SGiridhar Malavali 		.tgt_mask_reg	=	ISR_INT_TARGET_MASK,		\
733a9083016SGiridhar Malavali 		.pci_int_reg	=	ISR_MSI_INT_TRIGGER(0) },	\
734a9083016SGiridhar Malavali 									\
735a9083016SGiridhar Malavali 	{								\
736a9083016SGiridhar Malavali 		.int_vec_bit	=	PCIX_INT_VECTOR_BIT_F1,		\
737a9083016SGiridhar Malavali 		.tgt_status_reg =	ISR_INT_TARGET_STATUS_F1,	\
738a9083016SGiridhar Malavali 		.tgt_mask_reg	=	ISR_INT_TARGET_MASK_F1,		\
739a9083016SGiridhar Malavali 		.pci_int_reg	=	ISR_MSI_INT_TRIGGER(1) },	\
740a9083016SGiridhar Malavali 									\
741a9083016SGiridhar Malavali 	{								\
742a9083016SGiridhar Malavali 		.int_vec_bit	=	PCIX_INT_VECTOR_BIT_F2,		\
743a9083016SGiridhar Malavali 		.tgt_status_reg =	ISR_INT_TARGET_STATUS_F2,	\
744a9083016SGiridhar Malavali 		.tgt_mask_reg	=	ISR_INT_TARGET_MASK_F2,		\
745a9083016SGiridhar Malavali 		.pci_int_reg	=	ISR_MSI_INT_TRIGGER(2) },	\
746a9083016SGiridhar Malavali 									\
747a9083016SGiridhar Malavali 	{								\
748a9083016SGiridhar Malavali 		.int_vec_bit	=	PCIX_INT_VECTOR_BIT_F3,		\
749a9083016SGiridhar Malavali 		.tgt_status_reg =	ISR_INT_TARGET_STATUS_F3,	\
750a9083016SGiridhar Malavali 		.tgt_mask_reg	=	ISR_INT_TARGET_MASK_F3,		\
751a9083016SGiridhar Malavali 		.pci_int_reg	=	ISR_MSI_INT_TRIGGER(3) },	\
752a9083016SGiridhar Malavali 									\
753a9083016SGiridhar Malavali 	{								\
754a9083016SGiridhar Malavali 		.int_vec_bit	=	PCIX_INT_VECTOR_BIT_F4,		\
755a9083016SGiridhar Malavali 		.tgt_status_reg =	ISR_INT_TARGET_STATUS_F4,	\
756a9083016SGiridhar Malavali 		.tgt_mask_reg	=	ISR_INT_TARGET_MASK_F4,		\
757a9083016SGiridhar Malavali 		.pci_int_reg	=	ISR_MSI_INT_TRIGGER(4) },	\
758a9083016SGiridhar Malavali 									\
759a9083016SGiridhar Malavali 	{								\
760a9083016SGiridhar Malavali 		.int_vec_bit	=	PCIX_INT_VECTOR_BIT_F5,		\
761a9083016SGiridhar Malavali 		.tgt_status_reg =	ISR_INT_TARGET_STATUS_F5,	\
762a9083016SGiridhar Malavali 		.tgt_mask_reg	=	ISR_INT_TARGET_MASK_F5,		\
763a9083016SGiridhar Malavali 		.pci_int_reg	=	ISR_MSI_INT_TRIGGER(5) },	\
764a9083016SGiridhar Malavali 									\
765a9083016SGiridhar Malavali 	{								\
766a9083016SGiridhar Malavali 		.int_vec_bit	=	PCIX_INT_VECTOR_BIT_F6,		\
767a9083016SGiridhar Malavali 		.tgt_status_reg =	ISR_INT_TARGET_STATUS_F6,	\
768a9083016SGiridhar Malavali 		.tgt_mask_reg	=	ISR_INT_TARGET_MASK_F6,		\
769a9083016SGiridhar Malavali 		.pci_int_reg	=	ISR_MSI_INT_TRIGGER(6) },	\
770a9083016SGiridhar Malavali 									\
771a9083016SGiridhar Malavali 	{								\
772a9083016SGiridhar Malavali 		.int_vec_bit	=	PCIX_INT_VECTOR_BIT_F7,		\
773a9083016SGiridhar Malavali 		.tgt_status_reg =	ISR_INT_TARGET_STATUS_F7,	\
774a9083016SGiridhar Malavali 		.tgt_mask_reg	=	ISR_INT_TARGET_MASK_F7,		\
775a9083016SGiridhar Malavali 		.pci_int_reg	=	ISR_MSI_INT_TRIGGER(7) },	\
776a9083016SGiridhar Malavali }
777a9083016SGiridhar Malavali 
7789c2b2975SHarish Zunjarrao #define BRDCFG_START		0x4000
779a9083016SGiridhar Malavali #define	BOOTLD_START		0x10000
780a9083016SGiridhar Malavali #define	IMAGE_START		0x100000
781a9083016SGiridhar Malavali #define FLASH_ADDR_START	0x43000
782a9083016SGiridhar Malavali 
783a9083016SGiridhar Malavali /* Magic number to let user know flash is programmed */
784a9083016SGiridhar Malavali #define QLA82XX_BDINFO_MAGIC	0x12345678
7859c2b2975SHarish Zunjarrao #define QLA82XX_FW_MAGIC_OFFSET	(BRDCFG_START + 0x128)
786a9083016SGiridhar Malavali #define FW_SIZE_OFFSET		(0x3e840c)
7879c2b2975SHarish Zunjarrao #define QLA82XX_FW_MIN_SIZE	0x3fffff
7889c2b2975SHarish Zunjarrao 
7899c2b2975SHarish Zunjarrao /* UNIFIED ROMIMAGE START */
7909c2b2975SHarish Zunjarrao #define QLA82XX_URI_FW_MIN_SIZE			0xc8000
7919c2b2975SHarish Zunjarrao #define QLA82XX_URI_DIR_SECT_PRODUCT_TBL	0x0
7929c2b2975SHarish Zunjarrao #define QLA82XX_URI_DIR_SECT_BOOTLD		0x6
7939c2b2975SHarish Zunjarrao #define QLA82XX_URI_DIR_SECT_FW			0x7
7949c2b2975SHarish Zunjarrao 
7959c2b2975SHarish Zunjarrao /* Offsets */
7969c2b2975SHarish Zunjarrao #define QLA82XX_URI_CHIP_REV_OFF	10
7979c2b2975SHarish Zunjarrao #define QLA82XX_URI_FLAGS_OFF		11
7989c2b2975SHarish Zunjarrao #define QLA82XX_URI_BIOS_VERSION_OFF	12
7999c2b2975SHarish Zunjarrao #define QLA82XX_URI_BOOTLD_IDX_OFF	27
8009c2b2975SHarish Zunjarrao #define QLA82XX_URI_FIRMWARE_IDX_OFF	29
8019c2b2975SHarish Zunjarrao 
8029c2b2975SHarish Zunjarrao struct qla82xx_uri_table_desc{
8039c2b2975SHarish Zunjarrao 	uint32_t	findex;
8049c2b2975SHarish Zunjarrao 	uint32_t	num_entries;
8059c2b2975SHarish Zunjarrao 	uint32_t	entry_size;
8069c2b2975SHarish Zunjarrao 	uint32_t	reserved[5];
8079c2b2975SHarish Zunjarrao };
8089c2b2975SHarish Zunjarrao 
8099c2b2975SHarish Zunjarrao struct qla82xx_uri_data_desc{
8109c2b2975SHarish Zunjarrao 	uint32_t	findex;
8119c2b2975SHarish Zunjarrao 	uint32_t	size;
8129c2b2975SHarish Zunjarrao 	uint32_t	reserved[5];
8139c2b2975SHarish Zunjarrao };
8149c2b2975SHarish Zunjarrao 
8159c2b2975SHarish Zunjarrao /* UNIFIED ROMIMAGE END */
8169c2b2975SHarish Zunjarrao 
8179c2b2975SHarish Zunjarrao #define QLA82XX_UNIFIED_ROMIMAGE	3
8189c2b2975SHarish Zunjarrao #define QLA82XX_FLASH_ROMIMAGE		4
8199c2b2975SHarish Zunjarrao #define QLA82XX_UNKNOWN_ROMIMAGE	0xff
820a9083016SGiridhar Malavali 
821a9083016SGiridhar Malavali #define MIU_TEST_AGT_WRDATA_UPPER_LO		(0x0b0)
822a9083016SGiridhar Malavali #define	MIU_TEST_AGT_WRDATA_UPPER_HI		(0x0b4)
823a9083016SGiridhar Malavali 
824a9083016SGiridhar Malavali #ifndef readq
825a9083016SGiridhar Malavali static inline u64 readq(void __iomem *addr)
826a9083016SGiridhar Malavali {
827a9083016SGiridhar Malavali 	return readl(addr) | (((u64) readl(addr + 4)) << 32LL);
828a9083016SGiridhar Malavali }
829a9083016SGiridhar Malavali #endif
830a9083016SGiridhar Malavali 
831a9083016SGiridhar Malavali #ifndef writeq
832a9083016SGiridhar Malavali static inline void writeq(u64 val, void __iomem *addr)
833a9083016SGiridhar Malavali {
834a9083016SGiridhar Malavali 	writel(((u32) (val)), (addr));
835a9083016SGiridhar Malavali 	writel(((u32) (val >> 32)), (addr + 4));
836a9083016SGiridhar Malavali }
837a9083016SGiridhar Malavali #endif
838a9083016SGiridhar Malavali 
839a9083016SGiridhar Malavali /* Request and response queue size */
840a9083016SGiridhar Malavali #define REQUEST_ENTRY_CNT_82XX		128	/* Number of request entries. */
841a9083016SGiridhar Malavali #define RESPONSE_ENTRY_CNT_82XX		128	/* Number of response entries.*/
842a9083016SGiridhar Malavali 
843a9083016SGiridhar Malavali /*
844a9083016SGiridhar Malavali  * ISP 8021 I/O Register Set structure definitions.
845a9083016SGiridhar Malavali  */
846a9083016SGiridhar Malavali struct device_reg_82xx {
847a9083016SGiridhar Malavali 	uint32_t req_q_out[64];		/* Request Queue out-Pointer (64 * 4) */
848a9083016SGiridhar Malavali 	uint32_t rsp_q_in[64];		/* Response Queue In-Pointer. */
849a9083016SGiridhar Malavali 	uint32_t rsp_q_out[64];		/* Response Queue Out-Pointer. */
850a9083016SGiridhar Malavali 
851a9083016SGiridhar Malavali 	uint16_t mailbox_in[32];	/* Mail box In registers */
852a9083016SGiridhar Malavali 	uint16_t unused_1[32];
853a9083016SGiridhar Malavali 	uint32_t hint;			/* Host interrupt register */
854a9083016SGiridhar Malavali #define	HINT_MBX_INT_PENDING	BIT_0
855a9083016SGiridhar Malavali 	uint16_t unused_2[62];
856a9083016SGiridhar Malavali 	uint16_t mailbox_out[32];	/* Mail box Out registers */
857a9083016SGiridhar Malavali 	uint32_t unused_3[48];
858a9083016SGiridhar Malavali 
859a9083016SGiridhar Malavali 	uint32_t host_status;		/* host status */
860a9083016SGiridhar Malavali #define HSRX_RISC_INT		BIT_15	/* RISC to Host interrupt. */
861a9083016SGiridhar Malavali #define HSRX_RISC_PAUSED	BIT_8	/* RISC Paused. */
862a9083016SGiridhar Malavali 	uint32_t host_int;		/* Interrupt status. */
863a9083016SGiridhar Malavali #define ISRX_NX_RISC_INT	BIT_0	/* RISC interrupt. */
864a9083016SGiridhar Malavali };
865a9083016SGiridhar Malavali 
866a9083016SGiridhar Malavali struct fcp_cmnd {
867a9083016SGiridhar Malavali 	struct scsi_lun lun;
868a9083016SGiridhar Malavali 	uint8_t crn;
869a9083016SGiridhar Malavali 	uint8_t task_attribute;
87065155b37SUwe Kleine-König 	uint8_t task_management;
871a9083016SGiridhar Malavali 	uint8_t additional_cdb_len;
872a9083016SGiridhar Malavali 	uint8_t cdb[260]; /* 256 for CDB len and 4 for FCP_DL */
873a9083016SGiridhar Malavali };
874a9083016SGiridhar Malavali 
875a9083016SGiridhar Malavali struct dsd_dma {
876a9083016SGiridhar Malavali 	struct list_head list;
877a9083016SGiridhar Malavali 	dma_addr_t dsd_list_dma;
878a9083016SGiridhar Malavali 	void *dsd_addr;
879a9083016SGiridhar Malavali };
880a9083016SGiridhar Malavali 
881a9083016SGiridhar Malavali #define QLA_DSDS_PER_IOCB	37
882a9083016SGiridhar Malavali #define QLA_DSD_SIZE		12
883a9083016SGiridhar Malavali struct ct6_dsd {
884a9083016SGiridhar Malavali 	uint16_t fcp_cmnd_len;
885a9083016SGiridhar Malavali 	dma_addr_t fcp_cmnd_dma;
886a9083016SGiridhar Malavali 	struct fcp_cmnd *fcp_cmnd;
887a9083016SGiridhar Malavali 	int dsd_use_cnt;
888a9083016SGiridhar Malavali 	struct list_head dsd_list;
889a9083016SGiridhar Malavali };
890a9083016SGiridhar Malavali 
8913711333dSGiridhar Malavali #define MBC_TOGGLE_INTERRUPT	0x10
8926246b8a1SGiridhar Malavali #define MBC_SET_LED_CONFIG	0x125	/* FCoE specific LED control */
8936246b8a1SGiridhar Malavali #define MBC_GET_LED_CONFIG	0x126	/* FCoE specific LED control */
894a9083016SGiridhar Malavali 
895a9083016SGiridhar Malavali /* Flash  offset */
896a9083016SGiridhar Malavali #define FLT_REG_BOOTLOAD_82XX	0x72
897a9083016SGiridhar Malavali #define FLT_REG_BOOT_CODE_82XX	0x78
898a9083016SGiridhar Malavali #define FLT_REG_FW_82XX		0x74
899a9083016SGiridhar Malavali #define FLT_REG_GOLD_FW_82XX	0x75
900*a865c50aSSaurav Kashyap #define FLT_REG_VPD_8XXX	0x81
901a9083016SGiridhar Malavali 
902a9083016SGiridhar Malavali #define	FA_VPD_SIZE_82XX	0x400
903a9083016SGiridhar Malavali 
904a9083016SGiridhar Malavali #define FA_FLASH_LAYOUT_ADDR_82	0xFC400
905a9083016SGiridhar Malavali 
906a9083016SGiridhar Malavali /******************************************************************************
907a9083016SGiridhar Malavali *
908a9083016SGiridhar Malavali *    Definitions specific to M25P flash
909a9083016SGiridhar Malavali *
910a9083016SGiridhar Malavali *******************************************************************************
911a9083016SGiridhar Malavali *   Instructions
912a9083016SGiridhar Malavali */
913a9083016SGiridhar Malavali #define M25P_INSTR_WREN		0x06
914a9083016SGiridhar Malavali #define M25P_INSTR_WRDI		0x04
915a9083016SGiridhar Malavali #define M25P_INSTR_RDID		0x9f
916a9083016SGiridhar Malavali #define M25P_INSTR_RDSR		0x05
917a9083016SGiridhar Malavali #define M25P_INSTR_WRSR		0x01
918a9083016SGiridhar Malavali #define M25P_INSTR_READ		0x03
919a9083016SGiridhar Malavali #define M25P_INSTR_FAST_READ	0x0b
920a9083016SGiridhar Malavali #define M25P_INSTR_PP		0x02
921a9083016SGiridhar Malavali #define M25P_INSTR_SE		0xd8
922a9083016SGiridhar Malavali #define M25P_INSTR_BE		0xc7
923a9083016SGiridhar Malavali #define M25P_INSTR_DP		0xb9
924a9083016SGiridhar Malavali #define M25P_INSTR_RES		0xab
925a9083016SGiridhar Malavali 
92608de2844SGiridhar Malavali /* Minidump related */
92708de2844SGiridhar Malavali 
92808de2844SGiridhar Malavali /*
92908de2844SGiridhar Malavali  * Version of the template
93008de2844SGiridhar Malavali  * 4 Bytes
93108de2844SGiridhar Malavali  * X.Major.Minor.RELEASE
93208de2844SGiridhar Malavali  */
93308de2844SGiridhar Malavali #define QLA82XX_MINIDUMP_VERSION         0x10101
93408de2844SGiridhar Malavali 
93508de2844SGiridhar Malavali /*
93608de2844SGiridhar Malavali  * Entry Type Defines
93708de2844SGiridhar Malavali  */
93808de2844SGiridhar Malavali #define QLA82XX_RDNOP                   0
93908de2844SGiridhar Malavali #define QLA82XX_RDCRB                   1
94008de2844SGiridhar Malavali #define QLA82XX_RDMUX                   2
94108de2844SGiridhar Malavali #define QLA82XX_QUEUE                   3
94208de2844SGiridhar Malavali #define QLA82XX_BOARD                   4
94308de2844SGiridhar Malavali #define QLA82XX_RDSRE                   5
94408de2844SGiridhar Malavali #define QLA82XX_RDOCM                   6
94508de2844SGiridhar Malavali #define QLA82XX_CACHE                  10
94608de2844SGiridhar Malavali #define QLA82XX_L1DAT                  11
94708de2844SGiridhar Malavali #define QLA82XX_L1INS                  12
94808de2844SGiridhar Malavali #define QLA82XX_L2DTG                  21
94908de2844SGiridhar Malavali #define QLA82XX_L2ITG                  22
95008de2844SGiridhar Malavali #define QLA82XX_L2DAT                  23
95108de2844SGiridhar Malavali #define QLA82XX_L2INS                  24
95208de2844SGiridhar Malavali #define QLA82XX_RDROM                  71
95308de2844SGiridhar Malavali #define QLA82XX_RDMEM                  72
95408de2844SGiridhar Malavali #define QLA82XX_CNTRL                  98
95508de2844SGiridhar Malavali #define QLA82XX_TLHDR                  99
95608de2844SGiridhar Malavali #define QLA82XX_RDEND                  255
95708de2844SGiridhar Malavali 
95808de2844SGiridhar Malavali /*
95908de2844SGiridhar Malavali  * Opcodes for Control Entries.
96008de2844SGiridhar Malavali  * These Flags are bit fields.
96108de2844SGiridhar Malavali  */
96208de2844SGiridhar Malavali #define QLA82XX_DBG_OPCODE_WR        0x01
96308de2844SGiridhar Malavali #define QLA82XX_DBG_OPCODE_RW        0x02
96408de2844SGiridhar Malavali #define QLA82XX_DBG_OPCODE_AND       0x04
96508de2844SGiridhar Malavali #define QLA82XX_DBG_OPCODE_OR        0x08
96608de2844SGiridhar Malavali #define QLA82XX_DBG_OPCODE_POLL      0x10
96708de2844SGiridhar Malavali #define QLA82XX_DBG_OPCODE_RDSTATE   0x20
96808de2844SGiridhar Malavali #define QLA82XX_DBG_OPCODE_WRSTATE   0x40
96908de2844SGiridhar Malavali #define QLA82XX_DBG_OPCODE_MDSTATE   0x80
97008de2844SGiridhar Malavali 
97108de2844SGiridhar Malavali /*
97208de2844SGiridhar Malavali  * Template Header and Entry Header definitions start here.
97308de2844SGiridhar Malavali  */
97408de2844SGiridhar Malavali 
97508de2844SGiridhar Malavali /*
97608de2844SGiridhar Malavali  * Template Header
97708de2844SGiridhar Malavali  * Parts of the template header can be modified by the driver.
97808de2844SGiridhar Malavali  * These include the saved_state_array, capture_debug_level, driver_timestamp
97908de2844SGiridhar Malavali  */
98008de2844SGiridhar Malavali 
98108de2844SGiridhar Malavali #define QLA82XX_DBG_STATE_ARRAY_LEN        16
98208de2844SGiridhar Malavali #define QLA82XX_DBG_CAP_SIZE_ARRAY_LEN     8
98308de2844SGiridhar Malavali #define QLA82XX_DBG_RSVD_ARRAY_LEN         8
98408de2844SGiridhar Malavali 
98508de2844SGiridhar Malavali /*
98608de2844SGiridhar Malavali  * Driver Flags
98708de2844SGiridhar Malavali  */
98808de2844SGiridhar Malavali #define QLA82XX_DBG_SKIPPED_FLAG	0x80	/* driver skipped this entry */
98908de2844SGiridhar Malavali #define	QLA82XX_DEFAULT_CAP_MASK	0xFF	/* default capture mask */
99008de2844SGiridhar Malavali 
99108de2844SGiridhar Malavali struct qla82xx_md_template_hdr {
99208de2844SGiridhar Malavali 	uint32_t entry_type;
99308de2844SGiridhar Malavali 	uint32_t first_entry_offset;
99408de2844SGiridhar Malavali 	uint32_t size_of_template;
99508de2844SGiridhar Malavali 	uint32_t capture_debug_level;
99608de2844SGiridhar Malavali 
99708de2844SGiridhar Malavali 	uint32_t num_of_entries;
99808de2844SGiridhar Malavali 	uint32_t version;
99908de2844SGiridhar Malavali 	uint32_t driver_timestamp;
100008de2844SGiridhar Malavali 	uint32_t template_checksum;
100108de2844SGiridhar Malavali 
100208de2844SGiridhar Malavali 	uint32_t driver_capture_mask;
100308de2844SGiridhar Malavali 	uint32_t driver_info[3];
100408de2844SGiridhar Malavali 
100508de2844SGiridhar Malavali 	uint32_t saved_state_array[QLA82XX_DBG_STATE_ARRAY_LEN];
100608de2844SGiridhar Malavali 	uint32_t capture_size_array[QLA82XX_DBG_CAP_SIZE_ARRAY_LEN];
100708de2844SGiridhar Malavali 
100808de2844SGiridhar Malavali 	/*  markers_array used to capture some special locations on board */
100908de2844SGiridhar Malavali 	uint32_t markers_array[QLA82XX_DBG_RSVD_ARRAY_LEN];
101008de2844SGiridhar Malavali 	uint32_t num_of_free_entries;	/* For internal use */
101108de2844SGiridhar Malavali 	uint32_t free_entry_offset;	/* For internal use */
101208de2844SGiridhar Malavali 	uint32_t total_table_size;	/*  For internal use */
101308de2844SGiridhar Malavali 	uint32_t bkup_table_offset;	/*  For internal use */
101408de2844SGiridhar Malavali } __packed;
101508de2844SGiridhar Malavali 
101608de2844SGiridhar Malavali /*
101708de2844SGiridhar Malavali  * Entry Header:  Common to All Entry Types
101808de2844SGiridhar Malavali  */
101908de2844SGiridhar Malavali 
102008de2844SGiridhar Malavali /*
102108de2844SGiridhar Malavali  * Driver Code is for driver to write some info about the entry.
102208de2844SGiridhar Malavali  * Currently not used.
102308de2844SGiridhar Malavali  */
102408de2844SGiridhar Malavali typedef struct qla82xx_md_entry_hdr {
102508de2844SGiridhar Malavali 	uint32_t entry_type;
102608de2844SGiridhar Malavali 	uint32_t entry_size;
102708de2844SGiridhar Malavali 	uint32_t entry_capture_size;
102808de2844SGiridhar Malavali 	struct {
102908de2844SGiridhar Malavali 		uint8_t entry_capture_mask;
103008de2844SGiridhar Malavali 		uint8_t entry_code;
103108de2844SGiridhar Malavali 		uint8_t driver_code;
103208de2844SGiridhar Malavali 		uint8_t driver_flags;
103308de2844SGiridhar Malavali 	} d_ctrl;
103408de2844SGiridhar Malavali } __packed qla82xx_md_entry_hdr_t;
103508de2844SGiridhar Malavali 
103608de2844SGiridhar Malavali /*
103708de2844SGiridhar Malavali  *  Read CRB entry header
103808de2844SGiridhar Malavali  */
103908de2844SGiridhar Malavali struct qla82xx_md_entry_crb {
104008de2844SGiridhar Malavali 	qla82xx_md_entry_hdr_t h;
104108de2844SGiridhar Malavali 	uint32_t addr;
104208de2844SGiridhar Malavali 	struct {
104308de2844SGiridhar Malavali 		uint8_t addr_stride;
104408de2844SGiridhar Malavali 		uint8_t state_index_a;
104508de2844SGiridhar Malavali 		uint16_t poll_timeout;
104608de2844SGiridhar Malavali 	} crb_strd;
104708de2844SGiridhar Malavali 
104808de2844SGiridhar Malavali 	uint32_t data_size;
104908de2844SGiridhar Malavali 	uint32_t op_count;
105008de2844SGiridhar Malavali 
105108de2844SGiridhar Malavali 	struct {
105208de2844SGiridhar Malavali 		uint8_t opcode;
105308de2844SGiridhar Malavali 		uint8_t state_index_v;
105408de2844SGiridhar Malavali 		uint8_t shl;
105508de2844SGiridhar Malavali 		uint8_t shr;
105608de2844SGiridhar Malavali 	} crb_ctrl;
105708de2844SGiridhar Malavali 
105808de2844SGiridhar Malavali 	uint32_t value_1;
105908de2844SGiridhar Malavali 	uint32_t value_2;
106008de2844SGiridhar Malavali 	uint32_t value_3;
106108de2844SGiridhar Malavali } __packed;
106208de2844SGiridhar Malavali 
106308de2844SGiridhar Malavali /*
106408de2844SGiridhar Malavali  * Cache entry header
106508de2844SGiridhar Malavali  */
106608de2844SGiridhar Malavali struct qla82xx_md_entry_cache {
106708de2844SGiridhar Malavali 	qla82xx_md_entry_hdr_t h;
106808de2844SGiridhar Malavali 
106908de2844SGiridhar Malavali 	uint32_t tag_reg_addr;
107008de2844SGiridhar Malavali 	struct {
107108de2844SGiridhar Malavali 		uint16_t tag_value_stride;
107208de2844SGiridhar Malavali 		uint16_t init_tag_value;
107308de2844SGiridhar Malavali 	} addr_ctrl;
107408de2844SGiridhar Malavali 
107508de2844SGiridhar Malavali 	uint32_t data_size;
107608de2844SGiridhar Malavali 	uint32_t op_count;
107708de2844SGiridhar Malavali 
107808de2844SGiridhar Malavali 	uint32_t control_addr;
107908de2844SGiridhar Malavali 	struct {
108008de2844SGiridhar Malavali 		uint16_t write_value;
108108de2844SGiridhar Malavali 		uint8_t poll_mask;
108208de2844SGiridhar Malavali 		uint8_t poll_wait;
108308de2844SGiridhar Malavali 	} cache_ctrl;
108408de2844SGiridhar Malavali 
108508de2844SGiridhar Malavali 	uint32_t read_addr;
108608de2844SGiridhar Malavali 	struct {
108708de2844SGiridhar Malavali 		uint8_t read_addr_stride;
108808de2844SGiridhar Malavali 		uint8_t read_addr_cnt;
108908de2844SGiridhar Malavali 		uint16_t rsvd_1;
109008de2844SGiridhar Malavali 	} read_ctrl;
109108de2844SGiridhar Malavali } __packed;
109208de2844SGiridhar Malavali 
109308de2844SGiridhar Malavali /*
109408de2844SGiridhar Malavali  * Read OCM
109508de2844SGiridhar Malavali  */
109608de2844SGiridhar Malavali struct qla82xx_md_entry_rdocm {
109708de2844SGiridhar Malavali 	qla82xx_md_entry_hdr_t h;
109808de2844SGiridhar Malavali 
109908de2844SGiridhar Malavali 	uint32_t rsvd_0;
110008de2844SGiridhar Malavali 	uint32_t rsvd_1;
110108de2844SGiridhar Malavali 	uint32_t data_size;
110208de2844SGiridhar Malavali 	uint32_t op_count;
110308de2844SGiridhar Malavali 
110408de2844SGiridhar Malavali 	uint32_t rsvd_2;
110508de2844SGiridhar Malavali 	uint32_t rsvd_3;
110608de2844SGiridhar Malavali 	uint32_t read_addr;
110708de2844SGiridhar Malavali 	uint32_t read_addr_stride;
110808de2844SGiridhar Malavali 	uint32_t read_addr_cntrl;
110908de2844SGiridhar Malavali } __packed;
111008de2844SGiridhar Malavali 
111108de2844SGiridhar Malavali /*
111208de2844SGiridhar Malavali  * Read Memory
111308de2844SGiridhar Malavali  */
111408de2844SGiridhar Malavali struct qla82xx_md_entry_rdmem {
111508de2844SGiridhar Malavali 	qla82xx_md_entry_hdr_t h;
111608de2844SGiridhar Malavali 	uint32_t rsvd[6];
111708de2844SGiridhar Malavali 	uint32_t read_addr;
111808de2844SGiridhar Malavali 	uint32_t read_data_size;
111908de2844SGiridhar Malavali } __packed;
112008de2844SGiridhar Malavali 
112108de2844SGiridhar Malavali /*
112208de2844SGiridhar Malavali  * Read ROM
112308de2844SGiridhar Malavali  */
112408de2844SGiridhar Malavali struct qla82xx_md_entry_rdrom {
112508de2844SGiridhar Malavali 	qla82xx_md_entry_hdr_t h;
112608de2844SGiridhar Malavali 	uint32_t rsvd[6];
112708de2844SGiridhar Malavali 	uint32_t read_addr;
112808de2844SGiridhar Malavali 	uint32_t read_data_size;
112908de2844SGiridhar Malavali } __packed;
113008de2844SGiridhar Malavali 
113108de2844SGiridhar Malavali struct qla82xx_md_entry_mux {
113208de2844SGiridhar Malavali 	qla82xx_md_entry_hdr_t h;
113308de2844SGiridhar Malavali 
113408de2844SGiridhar Malavali 	uint32_t select_addr;
113508de2844SGiridhar Malavali 	uint32_t rsvd_0;
113608de2844SGiridhar Malavali 	uint32_t data_size;
113708de2844SGiridhar Malavali 	uint32_t op_count;
113808de2844SGiridhar Malavali 
113908de2844SGiridhar Malavali 	uint32_t select_value;
114008de2844SGiridhar Malavali 	uint32_t select_value_stride;
114108de2844SGiridhar Malavali 	uint32_t read_addr;
114208de2844SGiridhar Malavali 	uint32_t rsvd_1;
114308de2844SGiridhar Malavali } __packed;
114408de2844SGiridhar Malavali 
114508de2844SGiridhar Malavali struct qla82xx_md_entry_queue {
114608de2844SGiridhar Malavali 	qla82xx_md_entry_hdr_t h;
114708de2844SGiridhar Malavali 
114808de2844SGiridhar Malavali 	uint32_t select_addr;
114908de2844SGiridhar Malavali 	struct {
115008de2844SGiridhar Malavali 		uint16_t queue_id_stride;
115108de2844SGiridhar Malavali 		uint16_t rsvd_0;
115208de2844SGiridhar Malavali 	} q_strd;
115308de2844SGiridhar Malavali 
115408de2844SGiridhar Malavali 	uint32_t data_size;
115508de2844SGiridhar Malavali 	uint32_t op_count;
115608de2844SGiridhar Malavali 	uint32_t rsvd_1;
115708de2844SGiridhar Malavali 	uint32_t rsvd_2;
115808de2844SGiridhar Malavali 
115908de2844SGiridhar Malavali 	uint32_t read_addr;
116008de2844SGiridhar Malavali 	struct {
116108de2844SGiridhar Malavali 		uint8_t read_addr_stride;
116208de2844SGiridhar Malavali 		uint8_t read_addr_cnt;
116308de2844SGiridhar Malavali 		uint16_t rsvd_3;
116408de2844SGiridhar Malavali 	} rd_strd;
116508de2844SGiridhar Malavali } __packed;
116608de2844SGiridhar Malavali 
116708de2844SGiridhar Malavali #define MBC_DIAGNOSTIC_MINIDUMP_TEMPLATE 0x129
116808de2844SGiridhar Malavali #define RQST_TMPLT_SIZE	0x0
116908de2844SGiridhar Malavali #define RQST_TMPLT 0x1
117008de2844SGiridhar Malavali #define MD_DIRECT_ROM_WINDOW	0x42110030
117108de2844SGiridhar Malavali #define MD_DIRECT_ROM_READ_BASE	0x42150000
117208de2844SGiridhar Malavali #define MD_MIU_TEST_AGT_CTRL		0x41000090
117308de2844SGiridhar Malavali #define MD_MIU_TEST_AGT_ADDR_LO		0x41000094
117408de2844SGiridhar Malavali #define MD_MIU_TEST_AGT_ADDR_HI		0x41000098
117508de2844SGiridhar Malavali 
117608de2844SGiridhar Malavali static const int MD_MIU_TEST_AGT_RDDATA[] = { 0x410000A8, 0x410000AC,
117708de2844SGiridhar Malavali 	0x410000B8, 0x410000BC };
117863154916SGiridhar Malavali 
117963154916SGiridhar Malavali #define CRB_NIU_XG_PAUSE_CTL_P0        0x1
118063154916SGiridhar Malavali #define CRB_NIU_XG_PAUSE_CTL_P1        0x8
118163154916SGiridhar Malavali 
11825988aeb2SGiridhar Malavali #define qla82xx_get_temp_val(x)          ((x) >> 16)
11835988aeb2SGiridhar Malavali #define qla82xx_get_temp_state(x)        ((x) & 0xffff)
11845988aeb2SGiridhar Malavali #define qla82xx_encode_temp(val, state)  (((val) << 16) | (state))
11855988aeb2SGiridhar Malavali 
11865988aeb2SGiridhar Malavali /*
11875988aeb2SGiridhar Malavali  * Temperature control.
11885988aeb2SGiridhar Malavali  */
11895988aeb2SGiridhar Malavali enum {
11905988aeb2SGiridhar Malavali 	QLA82XX_TEMP_NORMAL = 0x1, /* Normal operating range */
11915988aeb2SGiridhar Malavali 	QLA82XX_TEMP_WARN,	   /* Sound alert, temperature getting high */
11925988aeb2SGiridhar Malavali 	QLA82XX_TEMP_PANIC	   /* Fatal error, hardware has shut down. */
11935988aeb2SGiridhar Malavali };
1194a9083016SGiridhar Malavali #endif
1195