12SN/A/*
29957SN/A * Copyright (c) 2013 ARM Limited
39957SN/A * All rights reserved
49957SN/A *
59957SN/A * The license below extends only to copyright in the software and shall
69957SN/A * not be construed as granting a license to any other intellectual
79957SN/A * property including but not limited to intellectual property relating
89957SN/A * to a hardware implementation of the functionality of the software
99957SN/A * licensed hereunder.  You may use the software subject to the license
109957SN/A * terms below provided that you ensure that this notice is replicated
119957SN/A * unmodified and in its entirety in all distributions of the software,
129957SN/A * modified or unmodified, in source code or in binary form.
139957SN/A *
141762SN/A * Copyright (c) 2001-2005 The Regents of The University of Michigan
152SN/A * All rights reserved.
162SN/A *
172SN/A * Redistribution and use in source and binary forms, with or without
182SN/A * modification, are permitted provided that the following conditions are
192SN/A * met: redistributions of source code must retain the above copyright
202SN/A * notice, this list of conditions and the following disclaimer;
212SN/A * redistributions in binary form must reproduce the above copyright
222SN/A * notice, this list of conditions and the following disclaimer in the
232SN/A * documentation and/or other materials provided with the distribution;
242SN/A * neither the name of the copyright holders nor the names of its
252SN/A * contributors may be used to endorse or promote products derived from
262SN/A * this software without specific prior written permission.
272SN/A *
282SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
292SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
302SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
312SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
322SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
332SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
342SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
352SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
362SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
372SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
382SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
392665SN/A *
402665SN/A * Authors: Nathan Binkert
412665SN/A *          Miguel Serrano
422SN/A */
432SN/A
442SN/A/* @file
452SN/A * Device register definitions for a device's PCI config space
462SN/A */
472SN/A
482SN/A#ifndef __PCIREG_H__
492SN/A#define __PCIREG_H__
502SN/A
512SN/A#include <sys/types.h>
522SN/A
539957SN/A#include "base/bitfield.hh"
549957SN/A#include "base/bitunion.hh"
559957SN/A
562SN/Aunion PCIConfig {
571817SN/A    uint8_t data[64];
582SN/A
591817SN/A    struct {
601817SN/A        uint16_t vendor;
611817SN/A        uint16_t device;
621817SN/A        uint16_t command;
631817SN/A        uint16_t status;
641817SN/A        uint8_t revision;
651817SN/A        uint8_t progIF;
661817SN/A        uint8_t subClassCode;
671817SN/A        uint8_t classCode;
681817SN/A        uint8_t cacheLineSize;
691817SN/A        uint8_t latencyTimer;
701817SN/A        uint8_t headerType;
711817SN/A        uint8_t bist;
723085SN/A        uint32_t baseAddr[6];
731817SN/A        uint32_t cardbusCIS;
741817SN/A        uint16_t subsystemVendorID;
751817SN/A        uint16_t subsystemID;
761817SN/A        uint32_t expansionROM;
779957SN/A        uint8_t capabilityPtr;
789957SN/A        // Was 8 bytes in the legacy PCI spec, but to support PCIe
799957SN/A        // this field is now 7 bytes with PCIe's addition of the
809957SN/A        // capability list pointer.
819957SN/A        uint8_t reserved[7];
821817SN/A        uint8_t interruptLine;
831817SN/A        uint8_t interruptPin;
841817SN/A        uint8_t minimumGrant;
851817SN/A        uint8_t maximumLatency;
861817SN/A    };
872SN/A};
882SN/A
892SN/A// Common PCI offsets
905543SN/A#define PCI_VENDOR_ID           0x00    // Vendor ID                    ro
915543SN/A#define PCI_DEVICE_ID           0x02    // Device ID                    ro
925543SN/A#define PCI_COMMAND             0x04    // Command                      rw
935543SN/A#define PCI_STATUS              0x06    // Status                       rw
945543SN/A#define PCI_REVISION_ID         0x08    // Revision ID                  ro
955543SN/A#define PCI_CLASS_CODE          0x09    // Class Code                   ro
965543SN/A#define PCI_SUB_CLASS_CODE      0x0A    // Sub Class Code               ro
975543SN/A#define PCI_BASE_CLASS_CODE     0x0B    // Base Class Code              ro
985543SN/A#define PCI_CACHE_LINE_SIZE     0x0C    // Cache Line Size              ro+
995543SN/A#define PCI_LATENCY_TIMER       0x0D    // Latency Timer                ro+
1005543SN/A#define PCI_HEADER_TYPE         0x0E    // Header Type                  ro
1015543SN/A#define PCI_BIST                0x0F    // Built in self test           rw
1022SN/A
103917SN/A// some pci command reg bitfields
104917SN/A#define PCI_CMD_BME     0x04 // Bus master function enable
105917SN/A#define PCI_CMD_MSE     0x02 // Memory Space Access enable
106917SN/A#define PCI_CMD_IOSE    0x01 // I/O space enable
107917SN/A
1082SN/A// Type 0 PCI offsets
1095543SN/A#define PCI0_BASE_ADDR0         0x10    // Base Address 0               rw
1105543SN/A#define PCI0_BASE_ADDR1         0x14    // Base Address 1               rw
1115543SN/A#define PCI0_BASE_ADDR2         0x18    // Base Address 2               rw
1125543SN/A#define PCI0_BASE_ADDR3         0x1C    // Base Address 3               rw
1135543SN/A#define PCI0_BASE_ADDR4         0x20    // Base Address 4               rw
1145543SN/A#define PCI0_BASE_ADDR5         0x24    // Base Address 5               rw
1155543SN/A#define PCI0_CIS                0x28    // CardBus CIS Pointer          ro
1165543SN/A#define PCI0_SUB_VENDOR_ID      0x2C    // Sub-Vendor ID                ro
1175543SN/A#define PCI0_SUB_SYSTEM_ID      0x2E    // Sub-System ID                ro
1185543SN/A#define PCI0_ROM_BASE_ADDR      0x30    // Expansion ROM Base Address   rw
1199957SN/A#define PCI0_CAP_PTR            0x34    // Capability list pointer      ro
1209957SN/A#define PCI0_RESERVED           0x35
1215543SN/A#define PCI0_INTERRUPT_LINE     0x3C    // Interrupt Line               rw
1225543SN/A#define PCI0_INTERRUPT_PIN      0x3D    // Interrupt Pin                ro
1235543SN/A#define PCI0_MINIMUM_GRANT      0x3E    // Maximum Grant                ro
1245543SN/A#define PCI0_MAXIMUM_LATENCY    0x3F    // Maximum Latency              ro
1252SN/A
1262SN/A// Type 1 PCI offsets
1275543SN/A#define PCI1_BASE_ADDR0         0x10    // Base Address 0               rw
1285543SN/A#define PCI1_BASE_ADDR1         0x14    // Base Address 1               rw
1295543SN/A#define PCI1_PRI_BUS_NUM        0x18    // Primary Bus Number           rw
1305543SN/A#define PCI1_SEC_BUS_NUM        0x19    // Secondary Bus Number         rw
1315543SN/A#define PCI1_SUB_BUS_NUM        0x1A    // Subordinate Bus Number       rw
1325543SN/A#define PCI1_SEC_LAT_TIMER      0x1B    // Secondary Latency Timer      ro+
1335543SN/A#define PCI1_IO_BASE            0x1C    // I/O Base                     rw
1345543SN/A#define PCI1_IO_LIMIT           0x1D    // I/O Limit                    rw
1355543SN/A#define PCI1_SECONDARY_STATUS   0x1E    // Secondary Status             rw
1365543SN/A#define PCI1_MEM_BASE           0x20    // Memory Base                  rw
1375543SN/A#define PCI1_MEM_LIMIT          0x22    // Memory Limit                 rw
1385543SN/A#define PCI1_PRF_MEM_BASE       0x24    // Prefetchable Memory Base     rw
1395543SN/A#define PCI1_PRF_MEM_LIMIT      0x26    // Prefetchable Memory Limit    rw
1405543SN/A#define PCI1_PRF_BASE_UPPER     0x28    // Prefetchable Base Upper 32   rw
1415543SN/A#define PCI1_PRF_LIMIT_UPPER    0x2C    // Prefetchable Limit Upper 32  rw
1425543SN/A#define PCI1_IO_BASE_UPPER      0x30    // I/O Base Upper 16 bits       rw
1435543SN/A#define PCI1_IO_LIMIT_UPPER     0x32    // I/O Limit Upper 16 bits      rw
1445543SN/A#define PCI1_RESERVED           0x34    // Reserved                     ro
1455543SN/A#define PCI1_ROM_BASE_ADDR      0x38    // Expansion ROM Base Address   rw
1465543SN/A#define PCI1_INTR_LINE          0x3C    // Interrupt Line               rw
1475543SN/A#define PCI1_INTR_PIN           0x3D    // Interrupt Pin                ro
1485543SN/A#define PCI1_BRIDGE_CTRL        0x3E    // Bridge Control               rw
1492SN/A
1502SN/A// Device specific offsets
1515543SN/A#define PCI_DEVICE_SPECIFIC             0x40    // 192 bytes
1522846SN/A#define PCI_CONFIG_SIZE         0xFF
1532SN/A
1542SN/A// Some Vendor IDs
1555543SN/A#define PCI_VENDOR_DEC                  0x1011
1565543SN/A#define PCI_VENDOR_NCR                  0x101A
1575543SN/A#define PCI_VENDOR_QLOGIC               0x1077
1585543SN/A#define PCI_VENDOR_SIMOS                0x1291
1592SN/A
1602SN/A// Some Product IDs
1615543SN/A#define PCI_PRODUCT_DEC_PZA             0x0008
1625543SN/A#define PCI_PRODUCT_NCR_810             0x0001
1635543SN/A#define PCI_PRODUCT_QLOGIC_ISP1020      0x1020
1645543SN/A#define PCI_PRODUCT_SIMOS_SIMOS         0x1291
1655543SN/A#define PCI_PRODUCT_SIMOS_ETHER         0x1292
1662SN/A
1679957SN/A/**
1689957SN/A * PCIe capability list offsets internal to the entry.
1699957SN/A * Actual offsets in the PCI config space are defined in
1709957SN/A * the python files setting up the system.
1719957SN/A */
1729957SN/A#define PMCAP_ID 0x00
1739957SN/A#define PMCAP_PC 0x02
1749957SN/A#define PMCAP_PMCS 0x04
1759957SN/A#define PMCAP_SIZE 0x06
1769957SN/A
1779957SN/A#define MSICAP_ID 0x00
1789957SN/A#define MSICAP_MC 0x02
1799957SN/A#define MSICAP_MA 0x04
1809957SN/A#define MSICAP_MUA 0x08
1819957SN/A#define MSICAP_MD 0x0C
1829957SN/A#define MSICAP_MMASK 0x10
1839957SN/A#define MSICAP_MPEND 0x14
1849957SN/A#define MSICAP_SIZE 0x18
1859957SN/A
1869957SN/A#define MSIXCAP_ID 0x00
1879957SN/A#define MSIXCAP_MXC 0x02
1889957SN/A#define MSIXCAP_MTAB 0x04
1899957SN/A#define MSIXCAP_MPBA 0x08
1909957SN/A#define MSIXCAP_SIZE 0x0C
1919957SN/A
1929957SN/A#define PXCAP_ID 0x00
1939957SN/A#define PXCAP_PXCAP 0x02
1949957SN/A#define PXCAP_PXDCAP 0x04
1959957SN/A#define PXCAP_PXDC 0x08
1969957SN/A#define PXCAP_PXDS 0x0A
1979957SN/A#define PXCAP_PXLCAP 0x0C
1989957SN/A#define PXCAP_PXLC 0x10
1999957SN/A#define PXCAP_PXLS 0x12
2009957SN/A#define PXCAP_PXDCAP2 0x24
2019957SN/A#define PXCAP_PXDC2 0x28
2029957SN/A#define PXCAP_SIZE 0x30
2039957SN/A
2049957SN/A/** @struct PMCAP
2059957SN/A *  Defines the Power Management capability register and all its associated
2069957SN/A *  bitfields for a PCIe device.
2079957SN/A */
20810479SN/Aunion PMCAP {
20910479SN/A    uint8_t data[6];
21010479SN/A    struct {
21110479SN/A        uint16_t pid;  /* 0:7  cid
21210479SN/A                        * 8:15 next
21310479SN/A                        */
21410479SN/A        uint16_t pc;   /* 0:2   vs
21510479SN/A                        * 3     pmec
21610479SN/A                        * 4     reserved
21710479SN/A                        * 5     dsi
21810479SN/A                        * 6:8   auxc
21910479SN/A                        * 9     d1s
22010479SN/A                        * 10    d2s
22110479SN/A                        * 11:15 psup
22210479SN/A                        */
22310479SN/A        uint16_t pmcs; /* 0:1   ps
22410479SN/A                        * 2     reserved
22510479SN/A                        * 3     nsfrst
22610479SN/A                        * 4:7   reserved
22710479SN/A                        * 8     pmee
22810479SN/A                        * 9:12  dse
22910479SN/A                        * 13:14 dsc
23010479SN/A                        * 15    pmes
23110479SN/A                        */
23210479SN/A    };
2339957SN/A};
2349957SN/A
2359957SN/A/** @struct MSICAP
2369957SN/A *  Defines the MSI Capability register and its associated bitfields for
2379957SN/A *  the a PCI/PCIe device.  Both the MSI capability and the MSIX capability
2389957SN/A *  can be filled in if a device model supports both, but only 1 of
2399957SN/A *  MSI/MSIX/INTx interrupt mode can be selected at a given time.
2409957SN/A */
24110479SN/Aunion MSICAP {
24210479SN/A    uint8_t data[24];
24310479SN/A    struct {
24410479SN/A        uint16_t mid;  /* 0:7  cid
24510479SN/A                        *  8:15 next
24610479SN/A                        */
24710479SN/A        uint16_t mc;   /* 0     msie;
24810479SN/A                        * 1:3   mmc;
24910479SN/A                        * 4:6   mme;
25010479SN/A                        * 7     c64;
25110479SN/A                        * 8     pvm;
25210479SN/A                        * 9:15  reserved;
25310479SN/A                        */
25410479SN/A        uint32_t ma;   /* 0:1  reserved
25510479SN/A                        * 2:31 addr
25610479SN/A                        */
25710479SN/A        uint32_t mua;
25810479SN/A        uint16_t md;
25910479SN/A        uint32_t mmask;
26010479SN/A        uint32_t mpend;
26110479SN/A   };
2629957SN/A};
2639957SN/A
2649957SN/A/** @struct MSIX
2659957SN/A *  Defines the MSI-X Capability register and its associated bitfields for
2669957SN/A *  a PCIe device.
2679957SN/A */
26810479SN/Aunion MSIXCAP {
26910479SN/A    uint8_t data[12];
27010479SN/A    struct {
27110479SN/A        uint16_t mxid; /* 0:7  cid
27210479SN/A                        *  8:15 next
27310479SN/A                        */
27410479SN/A        uint16_t mxc;  /* 0:10  ts;
27510479SN/A                        * 11:13 reserved;
27610479SN/A                        * 14    fm;
27710479SN/A                        * 15    mxe;
27810479SN/A                        */
27910479SN/A        uint32_t mtab; /* 0:2   tbir;
28010479SN/A                        * 3:31  to;
28110479SN/A                        */
28210479SN/A        uint32_t mpba; /* 0:2   pbir;
28310479SN/A                        * 3:31>  pbao;
28410479SN/A                        */
28510479SN/A    };
2869957SN/A};
2879957SN/A
2889957SN/Aunion MSIXTable {
2899957SN/A    struct {
2909957SN/A        uint32_t addr_lo;
2919957SN/A        uint32_t addr_hi;
2929957SN/A        uint32_t msg_data;
2939957SN/A        uint32_t vec_ctrl;
2949957SN/A    } fields;
2959957SN/A    uint32_t data[4];
2969957SN/A};
2979957SN/A
2989957SN/A#define MSIXVECS_PER_PBA 64
2999957SN/Astruct MSIXPbaEntry {
3009957SN/A    uint64_t bits;
3019957SN/A};
3029957SN/A
3039957SN/A/** @struct PXCAP
3049957SN/A *  Defines the PCI Express capability register and its associated bitfields
3059957SN/A *  for a PCIe device.
3069957SN/A */
3079957SN/Astruct PXCAP {
30810479SN/A    uint8_t data[48];
30910479SN/A    struct {
31010479SN/A        uint16_t pxid; /* 0:7  cid
31110479SN/A                        *  8:15 next
31210479SN/A                        */
31310479SN/A        uint16_t pxcap; /* 0:3   ver;
31410479SN/A                         * 4:7   dpt;
31510479SN/A                         * 8     si;
31610479SN/A                         * 9:13  imn;
31710479SN/A                         * 14:15 reserved;
31810479SN/A                         */
31910479SN/A        uint32_t pxdcap; /* 0:2   mps;
32010479SN/A                          * 3:4   pfs;
32110479SN/A                          * 5     etfs;
32210479SN/A                          * 6:8   l0sl;
32310479SN/A                          * 9:11  l1l;
32410479SN/A                          * 12:14 reserved;
32510479SN/A                          * 15    rer;
32610479SN/A                          * 16:17 reserved;
32710479SN/A                          * 18:25 csplv;
32810479SN/A                          * 26:27 cspls;
32910479SN/A                          * 28    flrc;
33010479SN/A                          * 29:31 reserved;
33110479SN/A                          */
33210479SN/A        uint16_t pxdc; /* 0     cere;
33310479SN/A                        * 1     nfere;
33410479SN/A                        * 2     fere;
33510479SN/A                        * 3     urre;
33610479SN/A                        * 4     ero;
33710479SN/A                        * 5:7   mps;
33810479SN/A                        * 8     ete;
33910479SN/A                        * 9     pfe;
34010479SN/A                        * 10    appme;
34110479SN/A                        * 11    ens;
34210479SN/A                        * 12:14 mrrs;
34310479SN/A                        * 15    func_reset;
34410479SN/A                        */
34510479SN/A        uint16_t pxds; /* 0     ced;
34610479SN/A                        * 1     nfed;
34710479SN/A                        * 2     fed;
34810479SN/A                        * 3     urd;
34910479SN/A                        * 4     apd;
35010479SN/A                        * 5     tp;
35110479SN/A                        * 6:15  reserved;
35210479SN/A                        */
35310479SN/A        uint32_t pxlcap; /* 0:3   sls;
35410479SN/A                          * 4:9   mlw;
35510479SN/A                          * 10:11 aspms;
35610479SN/A                          * 12:14 l0sel;
35710479SN/A                          * 15:17 l1el;
35810479SN/A                          * 18    cpm;
35910479SN/A                          * 19    sderc;
36010479SN/A                          * 20    dllla;
36110479SN/A                          * 21    lbnc;
36210479SN/A                          * 22:23 reserved;
36310479SN/A                          * 24:31 pn;
36410479SN/A                          */
36510479SN/A        uint16_t pxlc; /* 0:1   aspmc;
36610479SN/A                        * 2     reserved;
36710479SN/A                        * 3     rcb;
36810479SN/A                        * 4:5   reserved;
36910479SN/A                        * 6     ccc;
37010479SN/A                        * 7     es;
37110479SN/A                        * 8     ecpm;
37210479SN/A                        * 9     hawd;
37310479SN/A                        * 10:15 reserved;
37410479SN/A                        */
37510479SN/A        uint16_t pxls; /* 0:3   cls;
37610479SN/A                        * 4:9   nlw;
37710479SN/A                        * 10:11 reserved;
37810479SN/A                        * 12    slot_clk_config;
37910479SN/A                        * 13:15 reserved;
38010479SN/A                        */
38110479SN/A        uint8_t reserved[20];
38210479SN/A        uint32_t pxdcap2; /* 0:3   ctrs;
38310479SN/A                           * 4     ctds;
38410479SN/A                           * 5     arifs;
38510479SN/A                           * 6     aors;
38610479SN/A                           * 7     aocs32;
38710479SN/A                           * 8     aocs64;
38810479SN/A                           * 9     ccs128;
38910479SN/A                           * 10    nprpr;
39010479SN/A                           * 11    ltrs;
39110479SN/A                           * 12:13 tphcs;
39210479SN/A                           * 14:17 reserved;
39310479SN/A                           * 18:19 obffs;
39410479SN/A                           * 20    effs;
39510479SN/A                           * 21    eetps;
39610479SN/A                           * 22:23 meetp;
39710479SN/A                           * 24:31 reserved;
39810479SN/A                           */
39910479SN/A        uint32_t pxdc2; /* 0:3   ctv;
40010479SN/A                         * 4     ctd;
40110479SN/A                         * 5:9   reserved;
40210479SN/A                         * 10    ltrme;
40310479SN/A                         * 11:12 reserved;
40410479SN/A                         * 13:14 obffe;
40510479SN/A                         * 15:31 reserved;
40610479SN/A                         */
40710479SN/A    };
4089957SN/A};
4092SN/A#endif // __PCIREG_H__
410