xref: /openbmc/linux/Documentation/PCI/acpi-info.rst (revision 762f99f4f3cb41a775b5157dd761217beba65873)
1b66357f3SChangbin Du.. SPDX-License-Identifier: GPL-2.0
2b66357f3SChangbin Du
3b66357f3SChangbin Du========================================
4b66357f3SChangbin DuACPI considerations for PCI host bridges
5b66357f3SChangbin Du========================================
6b66357f3SChangbin Du
7b66357f3SChangbin DuThe general rule is that the ACPI namespace should describe everything the
8b66357f3SChangbin DuOS might use unless there's another way for the OS to find it [1, 2].
9b66357f3SChangbin Du
10b66357f3SChangbin DuFor example, there's no standard hardware mechanism for enumerating PCI
11b66357f3SChangbin Duhost bridges, so the ACPI namespace must describe each host bridge, the
12b66357f3SChangbin Dumethod for accessing PCI config space below it, the address space windows
13b66357f3SChangbin Duthe host bridge forwards to PCI (using _CRS), and the routing of legacy
14b66357f3SChangbin DuINTx interrupts (using _PRT).
15b66357f3SChangbin Du
16b66357f3SChangbin DuPCI devices, which are below the host bridge, generally do not need to be
17b66357f3SChangbin Dudescribed via ACPI.  The OS can discover them via the standard PCI
18b66357f3SChangbin Duenumeration mechanism, using config accesses to discover and identify
19b66357f3SChangbin Dudevices and read and size their BARs.  However, ACPI may describe PCI
20b66357f3SChangbin Dudevices if it provides power management or hotplug functionality for them
21b66357f3SChangbin Duor if the device has INTx interrupts connected by platform interrupt
22b66357f3SChangbin Ducontrollers and a _PRT is needed to describe those connections.
23b66357f3SChangbin Du
24b66357f3SChangbin DuACPI resource description is done via _CRS objects of devices in the ACPI
25*a557f67cSMauro Carvalho Chehabnamespace [2].   The _CRS is like a generalized PCI BAR: the OS can read
26b66357f3SChangbin Du_CRS and figure out what resource is being consumed even if it doesn't have
27*a557f67cSMauro Carvalho Chehaba driver for the device [3].  That's important because it means an old OS
28b66357f3SChangbin Ducan work correctly even on a system with new devices unknown to the OS.
29b66357f3SChangbin DuThe new devices might not do anything, but the OS can at least make sure no
30b66357f3SChangbin Duresources conflict with them.
31b66357f3SChangbin Du
32b66357f3SChangbin DuStatic tables like MCFG, HPET, ECDT, etc., are *not* mechanisms for
33b66357f3SChangbin Dureserving address space.  The static tables are for things the OS needs to
34b66357f3SChangbin Duknow early in boot, before it can parse the ACPI namespace.  If a new table
35b66357f3SChangbin Duis defined, an old OS needs to operate correctly even though it ignores the
36b66357f3SChangbin Dutable.  _CRS allows that because it is generic and understood by the old
37b66357f3SChangbin DuOS; a static table does not.
38b66357f3SChangbin Du
39b66357f3SChangbin DuIf the OS is expected to manage a non-discoverable device described via
40b66357f3SChangbin DuACPI, that device will have a specific _HID/_CID that tells the OS what
41b66357f3SChangbin Dudriver to bind to it, and the _CRS tells the OS and the driver where the
42b66357f3SChangbin Dudevice's registers are.
43b66357f3SChangbin Du
44*a557f67cSMauro Carvalho ChehabPCI host bridges are PNP0A03 or PNP0A08 devices.  Their _CRS should
45*a557f67cSMauro Carvalho Chehabdescribe all the address space they consume.  This includes all the windows
46b66357f3SChangbin Duthey forward down to the PCI bus, as well as registers of the host bridge
47*a557f67cSMauro Carvalho Chehabitself that are not forwarded to PCI.  The host bridge registers include
48b66357f3SChangbin Duthings like secondary/subordinate bus registers that determine the bus
49b66357f3SChangbin Durange below the bridge, window registers that describe the apertures, etc.
50b66357f3SChangbin DuThese are all device-specific, non-architected things, so the only way a
51b66357f3SChangbin DuPNP0A03/PNP0A08 driver can manage them is via _PRS/_CRS/_SRS, which contain
52*a557f67cSMauro Carvalho Chehabthe device-specific details.  The host bridge registers also include ECAM
53b66357f3SChangbin Duspace, since it is consumed by the host bridge.
54b66357f3SChangbin Du
55b66357f3SChangbin DuACPI defines a Consumer/Producer bit to distinguish the bridge registers
56b66357f3SChangbin Du("Consumer") from the bridge apertures ("Producer") [4, 5], but early
57b66357f3SChangbin DuBIOSes didn't use that bit correctly.  The result is that the current ACPI
58b66357f3SChangbin Duspec defines Consumer/Producer only for the Extended Address Space
59b66357f3SChangbin Dudescriptors; the bit should be ignored in the older QWord/DWord/Word
60b66357f3SChangbin DuAddress Space descriptors.  Consequently, OSes have to assume all
61b66357f3SChangbin DuQWord/DWord/Word descriptors are windows.
62b66357f3SChangbin Du
63b66357f3SChangbin DuPrior to the addition of Extended Address Space descriptors, the failure of
64b66357f3SChangbin DuConsumer/Producer meant there was no way to describe bridge registers in
65b66357f3SChangbin Duthe PNP0A03/PNP0A08 device itself.  The workaround was to describe the
66b66357f3SChangbin Dubridge registers (including ECAM space) in PNP0C02 catch-all devices [6].
67b66357f3SChangbin DuWith the exception of ECAM, the bridge register space is device-specific
68b66357f3SChangbin Duanyway, so the generic PNP0A03/PNP0A08 driver (pci_root.c) has no need to
69*a557f67cSMauro Carvalho Chehabknow about it.
70b66357f3SChangbin Du
71b66357f3SChangbin DuNew architectures should be able to use "Consumer" Extended Address Space
72b66357f3SChangbin Dudescriptors in the PNP0A03 device for bridge registers, including ECAM,
73b66357f3SChangbin Dualthough a strict interpretation of [6] might prohibit this.  Old x86 and
74b66357f3SChangbin Duia64 kernels assume all address space descriptors, including "Consumer"
75b66357f3SChangbin DuExtended Address Space ones, are windows, so it would not be safe to
76b66357f3SChangbin Dudescribe bridge registers this way on those architectures.
77b66357f3SChangbin Du
78*a557f67cSMauro Carvalho ChehabPNP0C02 "motherboard" devices are basically a catch-all.  There's no
79b66357f3SChangbin Duprogramming model for them other than "don't use these resources for
80*a557f67cSMauro Carvalho Chehabanything else."  So a PNP0C02 _CRS should claim any address space that is
81b66357f3SChangbin Du(1) not claimed by _CRS under any other device object in the ACPI namespace
82b66357f3SChangbin Duand (2) should not be assigned by the OS to something else.
83b66357f3SChangbin Du
84b66357f3SChangbin DuThe PCIe spec requires the Enhanced Configuration Access Method (ECAM)
85b66357f3SChangbin Duunless there's a standard firmware interface for config access, e.g., the
86b66357f3SChangbin Duia64 SAL interface [7].  A host bridge consumes ECAM memory address space
87b66357f3SChangbin Duand converts memory accesses into PCI configuration accesses.  The spec
88b66357f3SChangbin Dudefines the ECAM address space layout and functionality; only the base of
89b66357f3SChangbin Duthe address space is device-specific.  An ACPI OS learns the base address
90b66357f3SChangbin Dufrom either the static MCFG table or a _CBA method in the PNP0A03 device.
91b66357f3SChangbin Du
92b66357f3SChangbin DuThe MCFG table must describe the ECAM space of non-hot pluggable host
93b66357f3SChangbin Dubridges [8].  Since MCFG is a static table and can't be updated by hotplug,
94b66357f3SChangbin Dua _CBA method in the PNP0A03 device describes the ECAM space of a
95b66357f3SChangbin Duhot-pluggable host bridge [9].  Note that for both MCFG and _CBA, the base
96b66357f3SChangbin Duaddress always corresponds to bus 0, even if the bus range below the bridge
97b66357f3SChangbin Du(which is reported via _CRS) doesn't start at 0.
98b66357f3SChangbin Du
99b66357f3SChangbin Du
100b66357f3SChangbin Du[1] ACPI 6.2, sec 6.1:
101b66357f3SChangbin Du    For any device that is on a non-enumerable type of bus (for example, an
102b66357f3SChangbin Du    ISA bus), OSPM enumerates the devices' identifier(s) and the ACPI
103b66357f3SChangbin Du    system firmware must supply an _HID object ... for each device to
104b66357f3SChangbin Du    enable OSPM to do that.
105b66357f3SChangbin Du
106b66357f3SChangbin Du[2] ACPI 6.2, sec 3.7:
107b66357f3SChangbin Du    The OS enumerates motherboard devices simply by reading through the
108b66357f3SChangbin Du    ACPI Namespace looking for devices with hardware IDs.
109b66357f3SChangbin Du
110b66357f3SChangbin Du    Each device enumerated by ACPI includes ACPI-defined objects in the
111b66357f3SChangbin Du    ACPI Namespace that report the hardware resources the device could
112b66357f3SChangbin Du    occupy [_PRS], an object that reports the resources that are currently
113b66357f3SChangbin Du    used by the device [_CRS], and objects for configuring those resources
114b66357f3SChangbin Du    [_SRS].  The information is used by the Plug and Play OS (OSPM) to
115b66357f3SChangbin Du    configure the devices.
116b66357f3SChangbin Du
117b66357f3SChangbin Du[3] ACPI 6.2, sec 6.2:
118b66357f3SChangbin Du    OSPM uses device configuration objects to configure hardware resources
119b66357f3SChangbin Du    for devices enumerated via ACPI.  Device configuration objects provide
120b66357f3SChangbin Du    information about current and possible resource requirements, the
121b66357f3SChangbin Du    relationship between shared resources, and methods for configuring
122b66357f3SChangbin Du    hardware resources.
123b66357f3SChangbin Du
124b66357f3SChangbin Du    When OSPM enumerates a device, it calls _PRS to determine the resource
125b66357f3SChangbin Du    requirements of the device.  It may also call _CRS to find the current
126b66357f3SChangbin Du    resource settings for the device.  Using this information, the Plug and
127b66357f3SChangbin Du    Play system determines what resources the device should consume and
128b66357f3SChangbin Du    sets those resources by calling the device’s _SRS control method.
129b66357f3SChangbin Du
130b66357f3SChangbin Du    In ACPI, devices can consume resources (for example, legacy keyboards),
131b66357f3SChangbin Du    provide resources (for example, a proprietary PCI bridge), or do both.
132b66357f3SChangbin Du    Unless otherwise specified, resources for a device are assumed to be
133b66357f3SChangbin Du    taken from the nearest matching resource above the device in the device
134b66357f3SChangbin Du    hierarchy.
135b66357f3SChangbin Du
136b66357f3SChangbin Du[4] ACPI 6.2, sec 6.4.3.5.1, 2, 3, 4:
137b66357f3SChangbin Du    QWord/DWord/Word Address Space Descriptor (.1, .2, .3)
138b66357f3SChangbin Du      General Flags: Bit [0] Ignored
139b66357f3SChangbin Du
140b66357f3SChangbin Du    Extended Address Space Descriptor (.4)
141b66357f3SChangbin Du      General Flags: Bit [0] Consumer/Producer:
142b66357f3SChangbin Du
143b66357f3SChangbin Du        * 1 – This device consumes this resource
144b66357f3SChangbin Du        * 0 – This device produces and consumes this resource
145b66357f3SChangbin Du
146b66357f3SChangbin Du[5] ACPI 6.2, sec 19.6.43:
147b66357f3SChangbin Du    ResourceUsage specifies whether the Memory range is consumed by
148b66357f3SChangbin Du    this device (ResourceConsumer) or passed on to child devices
149b66357f3SChangbin Du    (ResourceProducer).  If nothing is specified, then
150b66357f3SChangbin Du    ResourceConsumer is assumed.
151b66357f3SChangbin Du
152b66357f3SChangbin Du[6] PCI Firmware 3.2, sec 4.1.2:
153b66357f3SChangbin Du    If the operating system does not natively comprehend reserving the
154b66357f3SChangbin Du    MMCFG region, the MMCFG region must be reserved by firmware.  The
155b66357f3SChangbin Du    address range reported in the MCFG table or by _CBA method (see Section
156b66357f3SChangbin Du    4.1.3) must be reserved by declaring a motherboard resource.  For most
157b66357f3SChangbin Du    systems, the motherboard resource would appear at the root of the ACPI
158b66357f3SChangbin Du    namespace (under \_SB) in a node with a _HID of EISAID (PNP0C02), and
159b66357f3SChangbin Du    the resources in this case should not be claimed in the root PCI bus’s
160b66357f3SChangbin Du    _CRS.  The resources can optionally be returned in Int15 E820 or
161b66357f3SChangbin Du    EFIGetMemoryMap as reserved memory but must always be reported through
162b66357f3SChangbin Du    ACPI as a motherboard resource.
163b66357f3SChangbin Du
164b66357f3SChangbin Du[7] PCI Express 4.0, sec 7.2.2:
165b66357f3SChangbin Du    For systems that are PC-compatible, or that do not implement a
166b66357f3SChangbin Du    processor-architecture-specific firmware interface standard that allows
167b66357f3SChangbin Du    access to the Configuration Space, the ECAM is required as defined in
168b66357f3SChangbin Du    this section.
169b66357f3SChangbin Du
170b66357f3SChangbin Du[8] PCI Firmware 3.2, sec 4.1.2:
171b66357f3SChangbin Du    The MCFG table is an ACPI table that is used to communicate the base
172b66357f3SChangbin Du    addresses corresponding to the non-hot removable PCI Segment Groups
173b66357f3SChangbin Du    range within a PCI Segment Group available to the operating system at
174b66357f3SChangbin Du    boot. This is required for the PC-compatible systems.
175b66357f3SChangbin Du
176b66357f3SChangbin Du    The MCFG table is only used to communicate the base addresses
177b66357f3SChangbin Du    corresponding to the PCI Segment Groups available to the system at
178b66357f3SChangbin Du    boot.
179b66357f3SChangbin Du
180b66357f3SChangbin Du[9] PCI Firmware 3.2, sec 4.1.3:
181b66357f3SChangbin Du    The _CBA (Memory mapped Configuration Base Address) control method is
182b66357f3SChangbin Du    an optional ACPI object that returns the 64-bit memory mapped
183b66357f3SChangbin Du    configuration base address for the hot plug capable host bridge. The
184b66357f3SChangbin Du    base address returned by _CBA is processor-relative address. The _CBA
185b66357f3SChangbin Du    control method evaluates to an Integer.
186b66357f3SChangbin Du
187b66357f3SChangbin Du    This control method appears under a host bridge object. When the _CBA
188b66357f3SChangbin Du    method appears under an active host bridge object, the operating system
189b66357f3SChangbin Du    evaluates this structure to identify the memory mapped configuration
190b66357f3SChangbin Du    base address corresponding to the PCI Segment Group for the bus number
191b66357f3SChangbin Du    range specified in _CRS method. An ACPI name space object that contains
192b66357f3SChangbin Du    the _CBA method must also contain a corresponding _SEG method.
193