2 * Copyright (c) 2013 ARM Limited
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
14 * Copyright (c) 2001-2005 The Regents of The University of Michigan
15 * All rights reserved.
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 * Device register definitions for a device's PCI config space
48 #include <sys/types.h>
50 #include "base/bitfield.hh"
51 #include "base/bitunion.hh"
65 uint8_t cacheLineSize
;
71 uint16_t subsystemVendorID
;
73 uint32_t expansionROM
;
74 uint8_t capabilityPtr
;
75 // Was 8 bytes in the legacy PCI spec, but to support PCIe
76 // this field is now 7 bytes with PCIe's addition of the
77 // capability list pointer.
79 uint8_t interruptLine
;
82 uint8_t maximumLatency
;
87 #define PCI_VENDOR_ID 0x00 // Vendor ID ro
88 #define PCI_DEVICE_ID 0x02 // Device ID ro
89 #define PCI_COMMAND 0x04 // Command rw
90 #define PCI_STATUS 0x06 // Status rw
91 #define PCI_REVISION_ID 0x08 // Revision ID ro
92 #define PCI_CLASS_CODE 0x09 // Class Code ro
93 #define PCI_SUB_CLASS_CODE 0x0A // Sub Class Code ro
94 #define PCI_BASE_CLASS_CODE 0x0B // Base Class Code ro
95 #define PCI_CACHE_LINE_SIZE 0x0C // Cache Line Size ro+
96 #define PCI_LATENCY_TIMER 0x0D // Latency Timer ro+
97 #define PCI_HEADER_TYPE 0x0E // Header Type ro
98 #define PCI_BIST 0x0F // Built in self test rw
100 // some pci command reg bitfields
101 #define PCI_CMD_BME 0x04 // Bus master function enable
102 #define PCI_CMD_MSE 0x02 // Memory Space Access enable
103 #define PCI_CMD_IOSE 0x01 // I/O space enable
105 // Type 0 PCI offsets
106 #define PCI0_BASE_ADDR0 0x10 // Base Address 0 rw
107 #define PCI0_BASE_ADDR1 0x14 // Base Address 1 rw
108 #define PCI0_BASE_ADDR2 0x18 // Base Address 2 rw
109 #define PCI0_BASE_ADDR3 0x1C // Base Address 3 rw
110 #define PCI0_BASE_ADDR4 0x20 // Base Address 4 rw
111 #define PCI0_BASE_ADDR5 0x24 // Base Address 5 rw
112 #define PCI0_CIS 0x28 // CardBus CIS Pointer ro
113 #define PCI0_SUB_VENDOR_ID 0x2C // Sub-Vendor ID ro
114 #define PCI0_SUB_SYSTEM_ID 0x2E // Sub-System ID ro
115 #define PCI0_ROM_BASE_ADDR 0x30 // Expansion ROM Base Address rw
116 #define PCI0_CAP_PTR 0x34 // Capability list pointer ro
117 #define PCI0_RESERVED 0x35
118 #define PCI0_INTERRUPT_LINE 0x3C // Interrupt Line rw
119 #define PCI0_INTERRUPT_PIN 0x3D // Interrupt Pin ro
120 #define PCI0_MINIMUM_GRANT 0x3E // Maximum Grant ro
121 #define PCI0_MAXIMUM_LATENCY 0x3F // Maximum Latency ro
123 // Type 1 PCI offsets
124 #define PCI1_BASE_ADDR0 0x10 // Base Address 0 rw
125 #define PCI1_BASE_ADDR1 0x14 // Base Address 1 rw
126 #define PCI1_PRI_BUS_NUM 0x18 // Primary Bus Number rw
127 #define PCI1_SEC_BUS_NUM 0x19 // Secondary Bus Number rw
128 #define PCI1_SUB_BUS_NUM 0x1A // Subordinate Bus Number rw
129 #define PCI1_SEC_LAT_TIMER 0x1B // Secondary Latency Timer ro+
130 #define PCI1_IO_BASE 0x1C // I/O Base rw
131 #define PCI1_IO_LIMIT 0x1D // I/O Limit rw
132 #define PCI1_SECONDARY_STATUS 0x1E // Secondary Status rw
133 #define PCI1_MEM_BASE 0x20 // Memory Base rw
134 #define PCI1_MEM_LIMIT 0x22 // Memory Limit rw
135 #define PCI1_PRF_MEM_BASE 0x24 // Prefetchable Memory Base rw
136 #define PCI1_PRF_MEM_LIMIT 0x26 // Prefetchable Memory Limit rw
137 #define PCI1_PRF_BASE_UPPER 0x28 // Prefetchable Base Upper 32 rw
138 #define PCI1_PRF_LIMIT_UPPER 0x2C // Prefetchable Limit Upper 32 rw
139 #define PCI1_IO_BASE_UPPER 0x30 // I/O Base Upper 16 bits rw
140 #define PCI1_IO_LIMIT_UPPER 0x32 // I/O Limit Upper 16 bits rw
141 #define PCI1_RESERVED 0x34 // Reserved ro
142 #define PCI1_ROM_BASE_ADDR 0x38 // Expansion ROM Base Address rw
143 #define PCI1_INTR_LINE 0x3C // Interrupt Line rw
144 #define PCI1_INTR_PIN 0x3D // Interrupt Pin ro
145 #define PCI1_BRIDGE_CTRL 0x3E // Bridge Control rw
147 // Device specific offsets
148 #define PCI_DEVICE_SPECIFIC 0x40 // 192 bytes
149 #define PCI_CONFIG_SIZE 0xFF
152 #define PCI_VENDOR_DEC 0x1011
153 #define PCI_VENDOR_NCR 0x101A
154 #define PCI_VENDOR_QLOGIC 0x1077
155 #define PCI_VENDOR_SIMOS 0x1291
158 #define PCI_PRODUCT_DEC_PZA 0x0008
159 #define PCI_PRODUCT_NCR_810 0x0001
160 #define PCI_PRODUCT_QLOGIC_ISP1020 0x1020
161 #define PCI_PRODUCT_SIMOS_SIMOS 0x1291
162 #define PCI_PRODUCT_SIMOS_ETHER 0x1292
165 * PCIe capability list offsets internal to the entry.
166 * Actual offsets in the PCI config space are defined in
167 * the python files setting up the system.
169 #define PMCAP_ID 0x00
170 #define PMCAP_PC 0x02
171 #define PMCAP_PMCS 0x04
172 #define PMCAP_SIZE 0x06
174 #define MSICAP_ID 0x00
175 #define MSICAP_MC 0x02
176 #define MSICAP_MA 0x04
177 #define MSICAP_MUA 0x08
178 #define MSICAP_MD 0x0C
179 #define MSICAP_MMASK 0x10
180 #define MSICAP_MPEND 0x14
181 #define MSICAP_SIZE 0x18
183 #define MSIXCAP_ID 0x00
184 #define MSIXCAP_MXC 0x02
185 #define MSIXCAP_MTAB 0x04
186 #define MSIXCAP_MPBA 0x08
187 #define MSIXCAP_SIZE 0x0C
189 #define PXCAP_ID 0x00
190 #define PXCAP_PXCAP 0x02
191 #define PXCAP_PXDCAP 0x04
192 #define PXCAP_PXDC 0x08
193 #define PXCAP_PXDS 0x0A
194 #define PXCAP_PXLCAP 0x0C
195 #define PXCAP_PXLC 0x10
196 #define PXCAP_PXLS 0x12
197 #define PXCAP_PXDCAP2 0x24
198 #define PXCAP_PXDC2 0x28
199 #define PXCAP_SIZE 0x30
202 * Defines the Power Management capability register and all its associated
203 * bitfields for a PCIe device.
208 uint16_t pid
; /* 0:7 cid
211 uint16_t pc
; /* 0:2 vs
220 uint16_t pmcs
; /* 0:1 ps
233 * Defines the MSI Capability register and its associated bitfields for
234 * the a PCI/PCIe device. Both the MSI capability and the MSIX capability
235 * can be filled in if a device model supports both, but only 1 of
236 * MSI/MSIX/INTx interrupt mode can be selected at a given time.
241 uint16_t mid
; /* 0:7 cid
244 uint16_t mc
; /* 0 msie;
251 uint32_t ma
; /* 0:1 reserved
262 * Defines the MSI-X Capability register and its associated bitfields for
268 uint16_t mxid
; /* 0:7 cid
271 uint16_t mxc
; /* 0:10 ts;
276 uint32_t mtab
; /* 0:2 tbir;
279 uint32_t mpba
; /* 0:2 pbir;
295 #define MSIXVECS_PER_PBA 64
296 struct MSIXPbaEntry
{
301 * Defines the PCI Express capability register and its associated bitfields
307 uint16_t pxid
; /* 0:7 cid
310 uint16_t pxcap
; /* 0:3 ver;
316 uint32_t pxdcap
; /* 0:2 mps;
329 uint16_t pxdc
; /* 0 cere;
342 uint16_t pxds
; /* 0 ced;
350 uint32_t pxlcap
; /* 0:3 sls;
362 uint16_t pxlc
; /* 0:1 aspmc;
372 uint16_t pxls
; /* 0:3 cls;
375 * 12 slot_clk_config;
378 uint8_t reserved
[20];
379 uint32_t pxdcap2
; /* 0:3 ctrs;
396 uint32_t pxdc2
; /* 0:3 ctv;
406 #endif // __PCIREG_H__