0001 .. SPDX-License-Identifier: GPL-2.0
0002 .. include:: <isonum.txt>
0003
0004 ===================================================
0005 ACPI Device Tree - Representation of ACPI Namespace
0006 ===================================================
0007
0008 :Copyright: |copy| 2013, Intel Corporation
0009
0010 :Author: Lv Zheng <lv.zheng@intel.com>
0011
0012 :Credit: Thanks for the help from Zhang Rui <rui.zhang@intel.com> and
0013 Rafael J.Wysocki <rafael.j.wysocki@intel.com>.
0014
0015 Abstract
0016 ========
0017 The Linux ACPI subsystem converts ACPI namespace objects into a Linux
0018 device tree under the /sys/devices/LNXSYSTEM:00 and updates it upon
0019 receiving ACPI hotplug notification events. For each device object
0020 in this hierarchy there is a corresponding symbolic link in the
0021 /sys/bus/acpi/devices.
0022
0023 This document illustrates the structure of the ACPI device tree.
0024
0025 ACPI Definition Blocks
0026 ======================
0027
0028 The ACPI firmware sets up RSDP (Root System Description Pointer) in the
0029 system memory address space pointing to the XSDT (Extended System
0030 Description Table). The XSDT always points to the FADT (Fixed ACPI
0031 Description Table) using its first entry, the data within the FADT
0032 includes various fixed-length entries that describe fixed ACPI features
0033 of the hardware. The FADT contains a pointer to the DSDT
0034 (Differentiated System Descripition Table). The XSDT also contains
0035 entries pointing to possibly multiple SSDTs (Secondary System
0036 Description Table).
0037
0038 The DSDT and SSDT data is organized in data structures called definition
0039 blocks that contain definitions of various objects, including ACPI
0040 control methods, encoded in AML (ACPI Machine Language). The data block
0041 of the DSDT along with the contents of SSDTs represents a hierarchical
0042 data structure called the ACPI namespace whose topology reflects the
0043 structure of the underlying hardware platform.
0044
0045 The relationships between ACPI System Definition Tables described above
0046 are illustrated in the following diagram::
0047
0048 +---------+ +-------+ +--------+ +------------------------+
0049 | RSDP | +->| XSDT | +->| FADT | | +-------------------+ |
0050 +---------+ | +-------+ | +--------+ +-|->| DSDT | |
0051 | Pointer | | | Entry |-+ | ...... | | | +-------------------+ |
0052 +---------+ | +-------+ | X_DSDT |--+ | | Definition Blocks | |
0053 | Pointer |-+ | ..... | | ...... | | +-------------------+ |
0054 +---------+ +-------+ +--------+ | +-------------------+ |
0055 | Entry |------------------|->| SSDT | |
0056 +- - - -+ | +-------------------| |
0057 | Entry | - - - - - - - -+ | | Definition Blocks | |
0058 +- - - -+ | | +-------------------+ |
0059 | | +- - - - - - - - - -+ |
0060 +-|->| SSDT | |
0061 | +-------------------+ |
0062 | | Definition Blocks | |
0063 | +- - - - - - - - - -+ |
0064 +------------------------+
0065 |
0066 OSPM Loading |
0067 \|/
0068 +----------------+
0069 | ACPI Namespace |
0070 +----------------+
0071
0072 Figure 1. ACPI Definition Blocks
0073
0074 .. note:: RSDP can also contain a pointer to the RSDT (Root System
0075 Description Table). Platforms provide RSDT to enable
0076 compatibility with ACPI 1.0 operating systems. The OS is expected
0077 to use XSDT, if present.
0078
0079
0080 Example ACPI Namespace
0081 ======================
0082
0083 All definition blocks are loaded into a single namespace. The namespace
0084 is a hierarchy of objects identified by names and paths.
0085 The following naming conventions apply to object names in the ACPI
0086 namespace:
0087
0088 1. All names are 32 bits long.
0089 2. The first byte of a name must be one of 'A' - 'Z', '_'.
0090 3. Each of the remaining bytes of a name must be one of 'A' - 'Z', '0'
0091 - '9', '_'.
0092 4. Names starting with '_' are reserved by the ACPI specification.
0093 5. The '\' symbol represents the root of the namespace (i.e. names
0094 prepended with '\' are relative to the namespace root).
0095 6. The '^' symbol represents the parent of the current namespace node
0096 (i.e. names prepended with '^' are relative to the parent of the
0097 current namespace node).
0098
0099 The figure below shows an example ACPI namespace::
0100
0101 +------+
0102 | \ | Root
0103 +------+
0104 |
0105 | +------+
0106 +-| _PR | Scope(_PR): the processor namespace
0107 | +------+
0108 | |
0109 | | +------+
0110 | +-| CPU0 | Processor(CPU0): the first processor
0111 | +------+
0112 |
0113 | +------+
0114 +-| _SB | Scope(_SB): the system bus namespace
0115 | +------+
0116 | |
0117 | | +------+
0118 | +-| LID0 | Device(LID0); the lid device
0119 | | +------+
0120 | | |
0121 | | | +------+
0122 | | +-| _HID | Name(_HID, "PNP0C0D"): the hardware ID
0123 | | | +------+
0124 | | |
0125 | | | +------+
0126 | | +-| _STA | Method(_STA): the status control method
0127 | | +------+
0128 | |
0129 | | +------+
0130 | +-| PCI0 | Device(PCI0); the PCI root bridge
0131 | +------+
0132 | |
0133 | | +------+
0134 | +-| _HID | Name(_HID, "PNP0A08"): the hardware ID
0135 | | +------+
0136 | |
0137 | | +------+
0138 | +-| _CID | Name(_CID, "PNP0A03"): the compatible ID
0139 | | +------+
0140 | |
0141 | | +------+
0142 | +-| RP03 | Scope(RP03): the PCI0 power scope
0143 | | +------+
0144 | | |
0145 | | | +------+
0146 | | +-| PXP3 | PowerResource(PXP3): the PCI0 power resource
0147 | | +------+
0148 | |
0149 | | +------+
0150 | +-| GFX0 | Device(GFX0): the graphics adapter
0151 | +------+
0152 | |
0153 | | +------+
0154 | +-| _ADR | Name(_ADR, 0x00020000): the PCI bus address
0155 | | +------+
0156 | |
0157 | | +------+
0158 | +-| DD01 | Device(DD01): the LCD output device
0159 | +------+
0160 | |
0161 | | +------+
0162 | +-| _BCL | Method(_BCL): the backlight control method
0163 | +------+
0164 |
0165 | +------+
0166 +-| _TZ | Scope(_TZ): the thermal zone namespace
0167 | +------+
0168 | |
0169 | | +------+
0170 | +-| FN00 | PowerResource(FN00): the FAN0 power resource
0171 | | +------+
0172 | |
0173 | | +------+
0174 | +-| FAN0 | Device(FAN0): the FAN0 cooling device
0175 | | +------+
0176 | | |
0177 | | | +------+
0178 | | +-| _HID | Name(_HID, "PNP0A0B"): the hardware ID
0179 | | +------+
0180 | |
0181 | | +------+
0182 | +-| TZ00 | ThermalZone(TZ00); the FAN thermal zone
0183 | +------+
0184 |
0185 | +------+
0186 +-| _GPE | Scope(_GPE): the GPE namespace
0187 +------+
0188
0189 Figure 2. Example ACPI Namespace
0190
0191
0192 Linux ACPI Device Objects
0193 =========================
0194
0195 The Linux kernel's core ACPI subsystem creates struct acpi_device
0196 objects for ACPI namespace objects representing devices, power resources
0197 processors, thermal zones. Those objects are exported to user space via
0198 sysfs as directories in the subtree under /sys/devices/LNXSYSTM:00. The
0199 format of their names is <bus_id:instance>, where 'bus_id' refers to the
0200 ACPI namespace representation of the given object and 'instance' is used
0201 for distinguishing different object of the same 'bus_id' (it is
0202 two-digit decimal representation of an unsigned integer).
0203
0204 The value of 'bus_id' depends on the type of the object whose name it is
0205 part of as listed in the table below::
0206
0207 +---+-----------------+-------+----------+
0208 | | Object/Feature | Table | bus_id |
0209 +---+-----------------+-------+----------+
0210 | N | Root | xSDT | LNXSYSTM |
0211 +---+-----------------+-------+----------+
0212 | N | Device | xSDT | _HID |
0213 +---+-----------------+-------+----------+
0214 | N | Processor | xSDT | LNXCPU |
0215 +---+-----------------+-------+----------+
0216 | N | ThermalZone | xSDT | LNXTHERM |
0217 +---+-----------------+-------+----------+
0218 | N | PowerResource | xSDT | LNXPOWER |
0219 +---+-----------------+-------+----------+
0220 | N | Other Devices | xSDT | device |
0221 +---+-----------------+-------+----------+
0222 | F | PWR_BUTTON | FADT | LNXPWRBN |
0223 +---+-----------------+-------+----------+
0224 | F | SLP_BUTTON | FADT | LNXSLPBN |
0225 +---+-----------------+-------+----------+
0226 | M | Video Extension | xSDT | LNXVIDEO |
0227 +---+-----------------+-------+----------+
0228 | M | ATA Controller | xSDT | LNXIOBAY |
0229 +---+-----------------+-------+----------+
0230 | M | Docking Station | xSDT | LNXDOCK |
0231 +---+-----------------+-------+----------+
0232
0233 Table 1. ACPI Namespace Objects Mapping
0234
0235 The following rules apply when creating struct acpi_device objects on
0236 the basis of the contents of ACPI System Description Tables (as
0237 indicated by the letter in the first column and the notation in the
0238 second column of the table above):
0239
0240 N:
0241 The object's source is an ACPI namespace node (as indicated by the
0242 named object's type in the second column). In that case the object's
0243 directory in sysfs will contain the 'path' attribute whose value is
0244 the full path to the node from the namespace root.
0245 F:
0246 The struct acpi_device object is created for a fixed hardware
0247 feature (as indicated by the fixed feature flag's name in the second
0248 column), so its sysfs directory will not contain the 'path'
0249 attribute.
0250 M:
0251 The struct acpi_device object is created for an ACPI namespace node
0252 with specific control methods (as indicated by the ACPI defined
0253 device's type in the second column). The 'path' attribute containing
0254 its namespace path will be present in its sysfs directory. For
0255 example, if the _BCL method is present for an ACPI namespace node, a
0256 struct acpi_device object with LNXVIDEO 'bus_id' will be created for
0257 it.
0258
0259 The third column of the above table indicates which ACPI System
0260 Description Tables contain information used for the creation of the
0261 struct acpi_device objects represented by the given row (xSDT means DSDT
0262 or SSDT).
0263
0264 The fourth column of the above table indicates the 'bus_id' generation
0265 rule of the struct acpi_device object:
0266
0267 _HID:
0268 _HID in the last column of the table means that the object's bus_id
0269 is derived from the _HID/_CID identification objects present under
0270 the corresponding ACPI namespace node. The object's sysfs directory
0271 will then contain the 'hid' and 'modalias' attributes that can be
0272 used to retrieve the _HID and _CIDs of that object.
0273 LNXxxxxx:
0274 The 'modalias' attribute is also present for struct acpi_device
0275 objects having bus_id of the "LNXxxxxx" form (pseudo devices), in
0276 which cases it contains the bus_id string itself.
0277 device:
0278 'device' in the last column of the table indicates that the object's
0279 bus_id cannot be determined from _HID/_CID of the corresponding
0280 ACPI namespace node, although that object represents a device (for
0281 example, it may be a PCI device with _ADR defined and without _HID
0282 or _CID). In that case the string 'device' will be used as the
0283 object's bus_id.
0284
0285
0286 Linux ACPI Physical Device Glue
0287 ===============================
0288
0289 ACPI device (i.e. struct acpi_device) objects may be linked to other
0290 objects in the Linux' device hierarchy that represent "physical" devices
0291 (for example, devices on the PCI bus). If that happens, it means that
0292 the ACPI device object is a "companion" of a device otherwise
0293 represented in a different way and is used (1) to provide configuration
0294 information on that device which cannot be obtained by other means and
0295 (2) to do specific things to the device with the help of its ACPI
0296 control methods. One ACPI device object may be linked this way to
0297 multiple "physical" devices.
0298
0299 If an ACPI device object is linked to a "physical" device, its sysfs
0300 directory contains the "physical_node" symbolic link to the sysfs
0301 directory of the target device object. In turn, the target device's
0302 sysfs directory will then contain the "firmware_node" symbolic link to
0303 the sysfs directory of the companion ACPI device object.
0304 The linking mechanism relies on device identification provided by the
0305 ACPI namespace. For example, if there's an ACPI namespace object
0306 representing a PCI device (i.e. a device object under an ACPI namespace
0307 object representing a PCI bridge) whose _ADR returns 0x00020000 and the
0308 bus number of the parent PCI bridge is 0, the sysfs directory
0309 representing the struct acpi_device object created for that ACPI
0310 namespace object will contain the 'physical_node' symbolic link to the
0311 /sys/devices/pci0000:00/0000:00:02:0/ sysfs directory of the
0312 corresponding PCI device.
0313
0314 The linking mechanism is generally bus-specific. The core of its
0315 implementation is located in the drivers/acpi/glue.c file, but there are
0316 complementary parts depending on the bus types in question located
0317 elsewhere. For example, the PCI-specific part of it is located in
0318 drivers/pci/pci-acpi.c.
0319
0320
0321 Example Linux ACPI Device Tree
0322 =================================
0323
0324 The sysfs hierarchy of struct acpi_device objects corresponding to the
0325 example ACPI namespace illustrated in Figure 2 with the addition of
0326 fixed PWR_BUTTON/SLP_BUTTON devices is shown below::
0327
0328 +--------------+---+-----------------+
0329 | LNXSYSTEM:00 | \ | acpi:LNXSYSTEM: |
0330 +--------------+---+-----------------+
0331 |
0332 | +-------------+-----+----------------+
0333 +-| LNXPWRBN:00 | N/A | acpi:LNXPWRBN: |
0334 | +-------------+-----+----------------+
0335 |
0336 | +-------------+-----+----------------+
0337 +-| LNXSLPBN:00 | N/A | acpi:LNXSLPBN: |
0338 | +-------------+-----+----------------+
0339 |
0340 | +-----------+------------+--------------+
0341 +-| LNXCPU:00 | \_PR_.CPU0 | acpi:LNXCPU: |
0342 | +-----------+------------+--------------+
0343 |
0344 | +-------------+-------+----------------+
0345 +-| LNXSYBUS:00 | \_SB_ | acpi:LNXSYBUS: |
0346 | +-------------+-------+----------------+
0347 | |
0348 | | +- - - - - - - +- - - - - - +- - - - - - - -+
0349 | +-| PNP0C0D:00 | \_SB_.LID0 | acpi:PNP0C0D: |
0350 | | +- - - - - - - +- - - - - - +- - - - - - - -+
0351 | |
0352 | | +------------+------------+-----------------------+
0353 | +-| PNP0A08:00 | \_SB_.PCI0 | acpi:PNP0A08:PNP0A03: |
0354 | +------------+------------+-----------------------+
0355 | |
0356 | | +-----------+-----------------+-----+
0357 | +-| device:00 | \_SB_.PCI0.RP03 | N/A |
0358 | | +-----------+-----------------+-----+
0359 | | |
0360 | | | +-------------+----------------------+----------------+
0361 | | +-| LNXPOWER:00 | \_SB_.PCI0.RP03.PXP3 | acpi:LNXPOWER: |
0362 | | +-------------+----------------------+----------------+
0363 | |
0364 | | +-------------+-----------------+----------------+
0365 | +-| LNXVIDEO:00 | \_SB_.PCI0.GFX0 | acpi:LNXVIDEO: |
0366 | +-------------+-----------------+----------------+
0367 | |
0368 | | +-----------+-----------------+-----+
0369 | +-| device:01 | \_SB_.PCI0.DD01 | N/A |
0370 | +-----------+-----------------+-----+
0371 |
0372 | +-------------+-------+----------------+
0373 +-| LNXSYBUS:01 | \_TZ_ | acpi:LNXSYBUS: |
0374 +-------------+-------+----------------+
0375 |
0376 | +-------------+------------+----------------+
0377 +-| LNXPOWER:0a | \_TZ_.FN00 | acpi:LNXPOWER: |
0378 | +-------------+------------+----------------+
0379 |
0380 | +------------+------------+---------------+
0381 +-| PNP0C0B:00 | \_TZ_.FAN0 | acpi:PNP0C0B: |
0382 | +------------+------------+---------------+
0383 |
0384 | +-------------+------------+----------------+
0385 +-| LNXTHERM:00 | \_TZ_.TZ00 | acpi:LNXTHERM: |
0386 +-------------+------------+----------------+
0387
0388 Figure 3. Example Linux ACPI Device Tree
0389
0390 .. note:: Each node is represented as "object/path/modalias", where:
0391
0392 1. 'object' is the name of the object's directory in sysfs.
0393 2. 'path' is the ACPI namespace path of the corresponding
0394 ACPI namespace object, as returned by the object's 'path'
0395 sysfs attribute.
0396 3. 'modalias' is the value of the object's 'modalias' sysfs
0397 attribute (as described earlier in this document).
0398
0399 .. note:: N/A indicates the device object does not have the 'path' or the
0400 'modalias' attribute.