]> git.proxmox.com Git - mirror_edk2.git/blob - QuarkSocPkg/QuarkNorthCluster/Include/QNCCommonDefinitions.h
QuarkSocPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / QuarkSocPkg / QuarkNorthCluster / Include / QNCCommonDefinitions.h
1 /** @file
2 This header file provides common definitions just for MCH using to avoid including extra module's file.
3
4 Copyright (c) 2013-2015 Intel Corporation.
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #ifndef _QNC_COMMON_DEFINITIONS_H_
11 #define _QNC_COMMON_DEFINITIONS_H_
12
13 //
14 // PCI CONFIGURATION MAP REGISTER OFFSETS
15 //
16 #ifndef PCI_VID
17 #define PCI_VID 0x0000 // Vendor ID Register
18 #define PCI_DID 0x0002 // Device ID Register
19 #define PCI_CMD 0x0004 // PCI Command Register
20 #define PCI_STS 0x0006 // PCI Status Register
21 #define PCI_RID 0x0008 // Revision ID Register
22 #define PCI_IFT 0x0009 // Interface Type
23 #define PCI_SCC 0x000A // Sub Class Code Register
24 #define PCI_BCC 0x000B // Base Class Code Register
25 #define PCI_CLS 0x000C // Cache Line Size
26 #define PCI_PMLT 0x000D // Primary Master Latency Timer
27 #define PCI_HDR 0x000E // Header Type Register
28 #define PCI_BIST 0x000F // Built in Self Test Register
29 #define PCI_BAR0 0x0010 // Base Address Register 0
30 #define PCI_BAR1 0x0014 // Base Address Register 1
31 #define PCI_BAR2 0x0018 // Base Address Register 2
32 #define PCI_PBUS 0x0018 // Primary Bus Number Register
33 #define PCI_SBUS 0x0019 // Secondary Bus Number Register
34 #define PCI_SUBUS 0x001A // Subordinate Bus Number Register
35 #define PCI_SMLT 0x001B // Secondary Master Latency Timer
36 #define PCI_BAR3 0x001C // Base Address Register 3
37 #define PCI_IOBASE 0x001C // I/O base Register
38 #define PCI_IOLIMIT 0x001D // I/O Limit Register
39 #define PCI_SECSTATUS 0x001E // Secondary Status Register
40 #define PCI_BAR4 0x0020 // Base Address Register 4
41 #define PCI_MEMBASE 0x0020 // Memory Base Register
42 #define PCI_MEMLIMIT 0x0022 // Memory Limit Register
43 #define PCI_BAR5 0x0024 // Base Address Register 5
44 #define PCI_PRE_MEMBASE 0x0024 // Prefetchable memory Base register
45 #define PCI_PRE_MEMLIMIT 0x0026 // Prefetchable memory Limit register
46 #define PCI_PRE_MEMBASE_U 0x0028 // Prefetchable memory base upper 32 bits
47 #define PCI_PRE_MEMLIMIT_U 0x002C // Prefetchable memory limit upper 32 bits
48 #define PCI_SVID 0x002C // Subsystem Vendor ID
49 #define PCI_SID 0x002E // Subsystem ID
50 #define PCI_IOBASE_U 0x0030 // I/O base Upper Register
51 #define PCI_IOLIMIT_U 0x0032 // I/O Limit Upper Register
52 #define PCI_CAPP 0x0034 // Capabilities Pointer
53 #define PCI_EROM 0x0038 // Expansion ROM Base Address
54 #define PCI_INTLINE 0x003C // Interrupt Line Register
55 #define PCI_INTPIN 0x003D // Interrupt Pin Register
56 #define PCI_MAXGNT 0x003E // Max Grant Register
57 #define PCI_BRIDGE_CNTL 0x003E // Bridge Control Register
58 #define PCI_MAXLAT 0x003F // Max Latency Register
59 #endif
60 //
61 // Bit Difinitions
62 //
63 #ifndef BIT0
64 #define BIT0 0x0001
65 #define BIT1 0x0002
66 #define BIT2 0x0004
67 #define BIT3 0x0008
68 #define BIT4 0x0010
69 #define BIT5 0x0020
70 #define BIT6 0x0040
71 #define BIT7 0x0080
72 #define BIT8 0x0100
73 #define BIT9 0x0200
74 #define BIT10 0x0400
75 #define BIT11 0x0800
76 #define BIT12 0x1000
77 #define BIT13 0x2000
78 #define BIT14 0x4000
79 #define BIT15 0x8000
80 #define BIT16 0x00010000
81 #define BIT17 0x00020000
82 #define BIT18 0x00040000
83 #define BIT19 0x00080000
84 #define BIT20 0x00100000
85 #define BIT21 0x00200000
86 #define BIT22 0x00400000
87 #define BIT23 0x00800000
88 #define BIT24 0x01000000
89 #define BIT25 0x02000000
90 #define BIT26 0x04000000
91 #define BIT27 0x08000000
92 #define BIT28 0x10000000
93 #define BIT29 0x20000000
94 #define BIT30 0x40000000
95 #define BIT31 0x80000000
96 #endif
97
98
99 //
100 // Common Memory mapped Io access macros ------------------------------------------
101 //
102 #define QNCMmioAddress( BaseAddr, Register ) \
103 ( (UINTN)BaseAddr + \
104 (UINTN)(Register) \
105 )
106
107 //
108 // UINT64
109 //
110 #define QNCMmio64Ptr( BaseAddr, Register ) \
111 ( (volatile UINT64 *)QNCMmioAddress( BaseAddr, Register ) )
112
113 #define QNCMmio64( BaseAddr, Register ) \
114 *QNCMmio64Ptr( BaseAddr, Register )
115
116 #define QNCMmio64Or( BaseAddr, Register, OrData ) \
117 QNCMmio64( BaseAddr, Register ) = \
118 (UINT64) ( \
119 QNCMmio64( BaseAddr, Register ) | \
120 (UINT64)(OrData) \
121 )
122
123 #define QNCMmio64And( BaseAddr, Register, AndData ) \
124 QNCMmio64( BaseAddr, Register ) = \
125 (UINT64) ( \
126 QNCMmio64( BaseAddr, Register ) & \
127 (UINT64)(AndData) \
128 )
129
130 #define QNCMmio64AndThenOr( BaseAddr, Register, AndData, OrData ) \
131 QNCMmio64( BaseAddr, Register ) = \
132 (UINT64) ( \
133 ( QNCMmio64( BaseAddr, Register ) & \
134 (UINT64)(AndData) \
135 ) | \
136 (UINT64)(OrData) \
137 )
138
139 //
140 // UINT32
141 //
142 #define QNCMmio32Ptr( BaseAddr, Register ) \
143 ( (volatile UINT32 *)QNCMmioAddress( BaseAddr, Register ) )
144
145 #define QNCMmio32( BaseAddr, Register ) \
146 *QNCMmio32Ptr( BaseAddr, Register )
147
148 #define QNCMmio32Or( BaseAddr, Register, OrData ) \
149 QNCMmio32( BaseAddr, Register ) = \
150 (UINT32) ( \
151 QNCMmio32( BaseAddr, Register ) | \
152 (UINT32)(OrData) \
153 )
154
155 #define QNCMmio32And( BaseAddr, Register, AndData ) \
156 QNCMmio32( BaseAddr, Register ) = \
157 (UINT32) ( \
158 QNCMmio32( BaseAddr, Register ) & \
159 (UINT32)(AndData) \
160 )
161
162 #define QNCMmio32AndThenOr( BaseAddr, Register, AndData, OrData ) \
163 QNCMmio32( BaseAddr, Register ) = \
164 (UINT32) ( \
165 ( QNCMmio32( BaseAddr, Register ) & \
166 (UINT32)(AndData) \
167 ) | \
168 (UINT32)(OrData) \
169 )
170 //
171 // UINT16
172 //
173
174 #define QNCMmio16Ptr( BaseAddr, Register ) \
175 ( (volatile UINT16 *)QNCMmioAddress( BaseAddr, Register ) )
176
177 #define QNCMmio16( BaseAddr, Register ) \
178 *QNCMmio16Ptr( BaseAddr, Register )
179
180 #define QNCMmio16Or( BaseAddr, Register, OrData ) \
181 QNCMmio16( BaseAddr, Register ) = \
182 (UINT16) ( \
183 QNCMmio16( BaseAddr, Register ) | \
184 (UINT16)(OrData) \
185 )
186
187 #define QNCMmio16And( BaseAddr, Register, AndData ) \
188 QNCMmio16( BaseAddr, Register ) = \
189 (UINT16) ( \
190 QNCMmio16( BaseAddr, Register ) & \
191 (UINT16)(AndData) \
192 )
193
194 #define QNCMmio16AndThenOr( BaseAddr, Register, AndData, OrData ) \
195 QNCMmio16( BaseAddr, Register ) = \
196 (UINT16) ( \
197 ( QNCMmio16( BaseAddr, Register ) & \
198 (UINT16)(AndData) \
199 ) | \
200 (UINT16)(OrData) \
201 )
202 //
203 // UINT8
204 //
205 #define QNCMmio8Ptr( BaseAddr, Register ) \
206 ( (volatile UINT8 *)QNCMmioAddress( BaseAddr, Register ) )
207
208 #define QNCMmio8( BaseAddr, Register ) \
209 *QNCMmio8Ptr( BaseAddr, Register )
210
211 #define QNCMmio8Or( BaseAddr, Register, OrData ) \
212 QNCMmio8( BaseAddr, Register ) = \
213 (UINT8) ( \
214 QNCMmio8( BaseAddr, Register ) | \
215 (UINT8)(OrData) \
216 )
217
218 #define QNCMmio8And( BaseAddr, Register, AndData ) \
219 QNCMmio8( BaseAddr, Register ) = \
220 (UINT8) ( \
221 QNCMmio8( BaseAddr, Register ) & \
222 (UINT8)(AndData) \
223 )
224
225 #define QNCMmio8AndThenOr( BaseAddr, Register, AndData, OrData ) \
226 QNCMmio8( BaseAddr, Register ) = \
227 (UINT8) ( \
228 ( QNCMmio8( BaseAddr, Register ) & \
229 (UINT8)(AndData) \
230 ) | \
231 (UINT8)(OrData) \
232 )
233
234 //
235 // Common Memory mapped Pci access macros ------------------------------------------
236 //
237
238 #define QNCMmPciAddress( Segment, Bus, Device, Function, Register ) \
239 ( (UINTN) QncGetPciExpressBaseAddress() + \
240 (UINTN)(Bus << 20) + \
241 (UINTN)(Device << 15) + \
242 (UINTN)(Function << 12) + \
243 (UINTN)(Register) \
244 )
245
246 //
247 // Macro to calculate the Pci device's base memory mapped address
248 //
249 #define PciDeviceMmBase( Bus, Device, Function) \
250 ( (UINTN) QncGetPciExpressBaseAddress () + \
251 (UINTN)(Bus << 20) + \
252 (UINTN)(Device << 15) + \
253 (UINTN)(Function << 12) \
254 )
255
256 //
257 // UINT32
258 //
259 #define QNCMmPci32Ptr( Segment, Bus, Device, Function, Register ) \
260 ( (volatile UINT32 *)QNCMmPciAddress( Segment, Bus, Device, Function, Register ) )
261
262 #define QNCMmPci32( Segment, Bus, Device, Function, Register ) \
263 *QNCMmPci32Ptr( Segment, Bus, Device, Function, Register )
264
265 #define QNCMmPci32Or( Segment, Bus, Device, Function, Register, OrData ) \
266 QNCMmPci32( Segment, Bus, Device, Function, Register ) = \
267 (UINT32) ( \
268 QNCMmPci32( Segment, Bus, Device, Function, Register ) | \
269 (UINT32)(OrData) \
270 )
271
272 #define QNCMmPci32And( Segment, Bus, Device, Function, Register, AndData ) \
273 QNCMmPci32( Segment, Bus, Device, Function, Register ) = \
274 (UINT32) ( \
275 QNCMmPci32( Segment, Bus, Device, Function, Register ) & \
276 (UINT32)(AndData) \
277 )
278
279 #define QNCMmPci32AndThenOr( Segment, Bus, Device, Function, Register, AndData, OrData ) \
280 QNCMmPci32( Segment, Bus, Device, Function, Register ) = \
281 (UINT32) ( \
282 ( QNCMmPci32( Segment, Bus, Device, Function, Register ) & \
283 (UINT32)(AndData) \
284 ) | \
285 (UINT32)(OrData) \
286 )
287 //
288 // UINT16
289 //
290 #define QNCMmPci16Ptr( Segment, Bus, Device, Function, Register ) \
291 ( (volatile UINT16 *)QNCMmPciAddress( Segment, Bus, Device, Function, Register ) )
292
293 #define QNCMmPci16( Segment, Bus, Device, Function, Register ) \
294 *QNCMmPci16Ptr( Segment, Bus, Device, Function, Register )
295
296 #define QNCMmPci16Or( Segment, Bus, Device, Function, Register, OrData ) \
297 QNCMmPci16( Segment, Bus, Device, Function, Register ) = \
298 (UINT16) ( \
299 QNCMmPci16( Segment, Bus, Device, Function, Register ) | \
300 (UINT16)(OrData) \
301 )
302
303 #define QNCMmPci16And( Segment, Bus, Device, Function, Register, AndData ) \
304 QNCMmPci16( Segment, Bus, Device, Function, Register ) = \
305 (UINT16) ( \
306 QNCMmPci16( Segment, Bus, Device, Function, Register ) & \
307 (UINT16)(AndData) \
308 )
309
310 #define QNCMmPci16AndThenOr( Segment, Bus, Device, Function, Register, AndData, OrData ) \
311 QNCMmPci16( Segment, Bus, Device, Function, Register ) = \
312 (UINT16) ( \
313 ( QNCMmPci16( Segment, Bus, Device, Function, Register ) & \
314 (UINT16)(AndData) \
315 ) | \
316 (UINT16)(OrData) \
317 )
318 //
319 // UINT8
320 //
321 #define QNCMmPci8Ptr( Segment, Bus, Device, Function, Register ) \
322 ( (volatile UINT8 *)QNCMmPciAddress( Segment, Bus, Device, Function, Register ) )
323
324 #define QNCMmPci8( Segment, Bus, Device, Function, Register ) \
325 *QNCMmPci8Ptr( Segment, Bus, Device, Function, Register )
326
327 #define QNCMmPci8Or( Segment, Bus, Device, Function, Register, OrData ) \
328 QNCMmPci8( Segment, Bus, Device, Function, Register ) = \
329 (UINT8) ( \
330 QNCMmPci8( Segment, Bus, Device, Function, Register ) | \
331 (UINT8)(OrData) \
332 )
333
334 #define QNCMmPci8And( Segment, Bus, Device, Function, Register, AndData ) \
335 QNCMmPci8( Segment, Bus, Device, Function, Register ) = \
336 (UINT8) ( \
337 QNCMmPci8( Segment, Bus, Device, Function, Register ) & \
338 (UINT8)(AndData) \
339 )
340
341 #define QNCMmPci8AndThenOr( Segment, Bus, Device, Function, Register, AndData, OrData ) \
342 QNCMmPci8( Segment, Bus, Device, Function, Register ) = \
343 (UINT8) ( \
344 ( QNCMmPci8( Segment, Bus, Device, Function, Register ) & \
345 (UINT8)(AndData) \
346 ) | \
347 (UINT8)(OrData) \
348 )
349
350 #endif