0001 =====================
0002 ACPI on ARMv8 Servers
0003 =====================
0004
0005 ACPI can be used for ARMv8 general purpose servers designed to follow
0006 the ARM SBSA (Server Base System Architecture) [0] and SBBR (Server
0007 Base Boot Requirements) [1] specifications. Please note that the SBBR
0008 can be retrieved simply by visiting [1], but the SBSA is currently only
0009 available to those with an ARM login due to ARM IP licensing concerns.
0010
0011 The ARMv8 kernel implements the reduced hardware model of ACPI version
0012 5.1 or later. Links to the specification and all external documents
0013 it refers to are managed by the UEFI Forum. The specification is
0014 available at http://www.uefi.org/specifications and documents referenced
0015 by the specification can be found via http://www.uefi.org/acpi.
0016
0017 If an ARMv8 system does not meet the requirements of the SBSA and SBBR,
0018 or cannot be described using the mechanisms defined in the required ACPI
0019 specifications, then ACPI may not be a good fit for the hardware.
0020
0021 While the documents mentioned above set out the requirements for building
0022 industry-standard ARMv8 servers, they also apply to more than one operating
0023 system. The purpose of this document is to describe the interaction between
0024 ACPI and Linux only, on an ARMv8 system -- that is, what Linux expects of
0025 ACPI and what ACPI can expect of Linux.
0026
0027
0028 Why ACPI on ARM?
0029 ----------------
0030 Before examining the details of the interface between ACPI and Linux, it is
0031 useful to understand why ACPI is being used. Several technologies already
0032 exist in Linux for describing non-enumerable hardware, after all. In this
0033 section we summarize a blog post [2] from Grant Likely that outlines the
0034 reasoning behind ACPI on ARMv8 servers. Actually, we snitch a good portion
0035 of the summary text almost directly, to be honest.
0036
0037 The short form of the rationale for ACPI on ARM is:
0038
0039 - ACPI’s byte code (AML) allows the platform to encode hardware behavior,
0040 while DT explicitly does not support this. For hardware vendors, being
0041 able to encode behavior is a key tool used in supporting operating
0042 system releases on new hardware.
0043
0044 - ACPI’s OSPM defines a power management model that constrains what the
0045 platform is allowed to do into a specific model, while still providing
0046 flexibility in hardware design.
0047
0048 - In the enterprise server environment, ACPI has established bindings (such
0049 as for RAS) which are currently used in production systems. DT does not.
0050 Such bindings could be defined in DT at some point, but doing so means ARM
0051 and x86 would end up using completely different code paths in both firmware
0052 and the kernel.
0053
0054 - Choosing a single interface to describe the abstraction between a platform
0055 and an OS is important. Hardware vendors would not be required to implement
0056 both DT and ACPI if they want to support multiple operating systems. And,
0057 agreeing on a single interface instead of being fragmented into per OS
0058 interfaces makes for better interoperability overall.
0059
0060 - The new ACPI governance process works well and Linux is now at the same
0061 table as hardware vendors and other OS vendors. In fact, there is no
0062 longer any reason to feel that ACPI only belongs to Windows or that
0063 Linux is in any way secondary to Microsoft in this arena. The move of
0064 ACPI governance into the UEFI forum has significantly opened up the
0065 specification development process, and currently, a large portion of the
0066 changes being made to ACPI are being driven by Linux.
0067
0068 Key to the use of ACPI is the support model. For servers in general, the
0069 responsibility for hardware behaviour cannot solely be the domain of the
0070 kernel, but rather must be split between the platform and the kernel, in
0071 order to allow for orderly change over time. ACPI frees the OS from needing
0072 to understand all the minute details of the hardware so that the OS doesn’t
0073 need to be ported to each and every device individually. It allows the
0074 hardware vendors to take responsibility for power management behaviour without
0075 depending on an OS release cycle which is not under their control.
0076
0077 ACPI is also important because hardware and OS vendors have already worked
0078 out the mechanisms for supporting a general purpose computing ecosystem. The
0079 infrastructure is in place, the bindings are in place, and the processes are
0080 in place. DT does exactly what Linux needs it to when working with vertically
0081 integrated devices, but there are no good processes for supporting what the
0082 server vendors need. Linux could potentially get there with DT, but doing so
0083 really just duplicates something that already works. ACPI already does what
0084 the hardware vendors need, Microsoft won’t collaborate on DT, and hardware
0085 vendors would still end up providing two completely separate firmware
0086 interfaces -- one for Linux and one for Windows.
0087
0088
0089 Kernel Compatibility
0090 --------------------
0091 One of the primary motivations for ACPI is standardization, and using that
0092 to provide backward compatibility for Linux kernels. In the server market,
0093 software and hardware are often used for long periods. ACPI allows the
0094 kernel and firmware to agree on a consistent abstraction that can be
0095 maintained over time, even as hardware or software change. As long as the
0096 abstraction is supported, systems can be updated without necessarily having
0097 to replace the kernel.
0098
0099 When a Linux driver or subsystem is first implemented using ACPI, it by
0100 definition ends up requiring a specific version of the ACPI specification
0101 -- it's baseline. ACPI firmware must continue to work, even though it may
0102 not be optimal, with the earliest kernel version that first provides support
0103 for that baseline version of ACPI. There may be a need for additional drivers,
0104 but adding new functionality (e.g., CPU power management) should not break
0105 older kernel versions. Further, ACPI firmware must also work with the most
0106 recent version of the kernel.
0107
0108
0109 Relationship with Device Tree
0110 -----------------------------
0111 ACPI support in drivers and subsystems for ARMv8 should never be mutually
0112 exclusive with DT support at compile time.
0113
0114 At boot time the kernel will only use one description method depending on
0115 parameters passed from the boot loader (including kernel bootargs).
0116
0117 Regardless of whether DT or ACPI is used, the kernel must always be capable
0118 of booting with either scheme (in kernels with both schemes enabled at compile
0119 time).
0120
0121
0122 Booting using ACPI tables
0123 -------------------------
0124 The only defined method for passing ACPI tables to the kernel on ARMv8
0125 is via the UEFI system configuration table. Just so it is explicit, this
0126 means that ACPI is only supported on platforms that boot via UEFI.
0127
0128 When an ARMv8 system boots, it can either have DT information, ACPI tables,
0129 or in some very unusual cases, both. If no command line parameters are used,
0130 the kernel will try to use DT for device enumeration; if there is no DT
0131 present, the kernel will try to use ACPI tables, but only if they are present.
0132 In neither is available, the kernel will not boot. If acpi=force is used
0133 on the command line, the kernel will attempt to use ACPI tables first, but
0134 fall back to DT if there are no ACPI tables present. The basic idea is that
0135 the kernel will not fail to boot unless it absolutely has no other choice.
0136
0137 Processing of ACPI tables may be disabled by passing acpi=off on the kernel
0138 command line; this is the default behavior.
0139
0140 In order for the kernel to load and use ACPI tables, the UEFI implementation
0141 MUST set the ACPI_20_TABLE_GUID to point to the RSDP table (the table with
0142 the ACPI signature "RSD PTR "). If this pointer is incorrect and acpi=force
0143 is used, the kernel will disable ACPI and try to use DT to boot instead; the
0144 kernel has, in effect, determined that ACPI tables are not present at that
0145 point.
0146
0147 If the pointer to the RSDP table is correct, the table will be mapped into
0148 the kernel by the ACPI core, using the address provided by UEFI.
0149
0150 The ACPI core will then locate and map in all other ACPI tables provided by
0151 using the addresses in the RSDP table to find the XSDT (eXtended System
0152 Description Table). The XSDT in turn provides the addresses to all other
0153 ACPI tables provided by the system firmware; the ACPI core will then traverse
0154 this table and map in the tables listed.
0155
0156 The ACPI core will ignore any provided RSDT (Root System Description Table).
0157 RSDTs have been deprecated and are ignored on arm64 since they only allow
0158 for 32-bit addresses.
0159
0160 Further, the ACPI core will only use the 64-bit address fields in the FADT
0161 (Fixed ACPI Description Table). Any 32-bit address fields in the FADT will
0162 be ignored on arm64.
0163
0164 Hardware reduced mode (see Section 4.1 of the ACPI 6.1 specification) will
0165 be enforced by the ACPI core on arm64. Doing so allows the ACPI core to
0166 run less complex code since it no longer has to provide support for legacy
0167 hardware from other architectures. Any fields that are not to be used for
0168 hardware reduced mode must be set to zero.
0169
0170 For the ACPI core to operate properly, and in turn provide the information
0171 the kernel needs to configure devices, it expects to find the following
0172 tables (all section numbers refer to the ACPI 6.1 specification):
0173
0174 - RSDP (Root System Description Pointer), section 5.2.5
0175
0176 - XSDT (eXtended System Description Table), section 5.2.8
0177
0178 - FADT (Fixed ACPI Description Table), section 5.2.9
0179
0180 - DSDT (Differentiated System Description Table), section
0181 5.2.11.1
0182
0183 - MADT (Multiple APIC Description Table), section 5.2.12
0184
0185 - GTDT (Generic Timer Description Table), section 5.2.24
0186
0187 - If PCI is supported, the MCFG (Memory mapped ConFiGuration
0188 Table), section 5.2.6, specifically Table 5-31.
0189
0190 - If booting without a console=<device> kernel parameter is
0191 supported, the SPCR (Serial Port Console Redirection table),
0192 section 5.2.6, specifically Table 5-31.
0193
0194 - If necessary to describe the I/O topology, SMMUs and GIC ITSs,
0195 the IORT (Input Output Remapping Table, section 5.2.6, specifically
0196 Table 5-31).
0197
0198 - If NUMA is supported, the SRAT (System Resource Affinity Table)
0199 and SLIT (System Locality distance Information Table), sections
0200 5.2.16 and 5.2.17, respectively.
0201
0202 If the above tables are not all present, the kernel may or may not be
0203 able to boot properly since it may not be able to configure all of the
0204 devices available. This list of tables is not meant to be all inclusive;
0205 in some environments other tables may be needed (e.g., any of the APEI
0206 tables from section 18) to support specific functionality.
0207
0208
0209 ACPI Detection
0210 --------------
0211 Drivers should determine their probe() type by checking for a null
0212 value for ACPI_HANDLE, or checking .of_node, or other information in
0213 the device structure. This is detailed further in the "Driver
0214 Recommendations" section.
0215
0216 In non-driver code, if the presence of ACPI needs to be detected at
0217 run time, then check the value of acpi_disabled. If CONFIG_ACPI is not
0218 set, acpi_disabled will always be 1.
0219
0220
0221 Device Enumeration
0222 ------------------
0223 Device descriptions in ACPI should use standard recognized ACPI interfaces.
0224 These may contain less information than is typically provided via a Device
0225 Tree description for the same device. This is also one of the reasons that
0226 ACPI can be useful -- the driver takes into account that it may have less
0227 detailed information about the device and uses sensible defaults instead.
0228 If done properly in the driver, the hardware can change and improve over
0229 time without the driver having to change at all.
0230
0231 Clocks provide an excellent example. In DT, clocks need to be specified
0232 and the drivers need to take them into account. In ACPI, the assumption
0233 is that UEFI will leave the device in a reasonable default state, including
0234 any clock settings. If for some reason the driver needs to change a clock
0235 value, this can be done in an ACPI method; all the driver needs to do is
0236 invoke the method and not concern itself with what the method needs to do
0237 to change the clock. Changing the hardware can then take place over time
0238 by changing what the ACPI method does, and not the driver.
0239
0240 In DT, the parameters needed by the driver to set up clocks as in the example
0241 above are known as "bindings"; in ACPI, these are known as "Device Properties"
0242 and provided to a driver via the _DSD object.
0243
0244 ACPI tables are described with a formal language called ASL, the ACPI
0245 Source Language (section 19 of the specification). This means that there
0246 are always multiple ways to describe the same thing -- including device
0247 properties. For example, device properties could use an ASL construct
0248 that looks like this: Name(KEY0, "value0"). An ACPI device driver would
0249 then retrieve the value of the property by evaluating the KEY0 object.
0250 However, using Name() this way has multiple problems: (1) ACPI limits
0251 names ("KEY0") to four characters unlike DT; (2) there is no industry
0252 wide registry that maintains a list of names, minimizing re-use; (3)
0253 there is also no registry for the definition of property values ("value0"),
0254 again making re-use difficult; and (4) how does one maintain backward
0255 compatibility as new hardware comes out? The _DSD method was created
0256 to solve precisely these sorts of problems; Linux drivers should ALWAYS
0257 use the _DSD method for device properties and nothing else.
0258
0259 The _DSM object (ACPI Section 9.14.1) could also be used for conveying
0260 device properties to a driver. Linux drivers should only expect it to
0261 be used if _DSD cannot represent the data required, and there is no way
0262 to create a new UUID for the _DSD object. Note that there is even less
0263 regulation of the use of _DSM than there is of _DSD. Drivers that depend
0264 on the contents of _DSM objects will be more difficult to maintain over
0265 time because of this; as of this writing, the use of _DSM is the cause
0266 of quite a few firmware problems and is not recommended.
0267
0268 Drivers should look for device properties in the _DSD object ONLY; the _DSD
0269 object is described in the ACPI specification section 6.2.5, but this only
0270 describes how to define the structure of an object returned via _DSD, and
0271 how specific data structures are defined by specific UUIDs. Linux should
0272 only use the _DSD Device Properties UUID [5]:
0273
0274 - UUID: daffd814-6eba-4d8c-8a91-bc9bbf4aa301
0275
0276 - https://www.uefi.org/sites/default/files/resources/_DSD-device-properties-UUID.pdf
0277
0278 The UEFI Forum provides a mechanism for registering device properties [4]
0279 so that they may be used across all operating systems supporting ACPI.
0280 Device properties that have not been registered with the UEFI Forum should
0281 not be used.
0282
0283 Before creating new device properties, check to be sure that they have not
0284 been defined before and either registered in the Linux kernel documentation
0285 as DT bindings, or the UEFI Forum as device properties. While we do not want
0286 to simply move all DT bindings into ACPI device properties, we can learn from
0287 what has been previously defined.
0288
0289 If it is necessary to define a new device property, or if it makes sense to
0290 synthesize the definition of a binding so it can be used in any firmware,
0291 both DT bindings and ACPI device properties for device drivers have review
0292 processes. Use them both. When the driver itself is submitted for review
0293 to the Linux mailing lists, the device property definitions needed must be
0294 submitted at the same time. A driver that supports ACPI and uses device
0295 properties will not be considered complete without their definitions. Once
0296 the device property has been accepted by the Linux community, it must be
0297 registered with the UEFI Forum [4], which will review it again for consistency
0298 within the registry. This may require iteration. The UEFI Forum, though,
0299 will always be the canonical site for device property definitions.
0300
0301 It may make sense to provide notice to the UEFI Forum that there is the
0302 intent to register a previously unused device property name as a means of
0303 reserving the name for later use. Other operating system vendors will
0304 also be submitting registration requests and this may help smooth the
0305 process.
0306
0307 Once registration and review have been completed, the kernel provides an
0308 interface for looking up device properties in a manner independent of
0309 whether DT or ACPI is being used. This API should be used [6]; it can
0310 eliminate some duplication of code paths in driver probing functions and
0311 discourage divergence between DT bindings and ACPI device properties.
0312
0313
0314 Programmable Power Control Resources
0315 ------------------------------------
0316 Programmable power control resources include such resources as voltage/current
0317 providers (regulators) and clock sources.
0318
0319 With ACPI, the kernel clock and regulator framework is not expected to be used
0320 at all.
0321
0322 The kernel assumes that power control of these resources is represented with
0323 Power Resource Objects (ACPI section 7.1). The ACPI core will then handle
0324 correctly enabling and disabling resources as they are needed. In order to
0325 get that to work, ACPI assumes each device has defined D-states and that these
0326 can be controlled through the optional ACPI methods _PS0, _PS1, _PS2, and _PS3;
0327 in ACPI, _PS0 is the method to invoke to turn a device full on, and _PS3 is for
0328 turning a device full off.
0329
0330 There are two options for using those Power Resources. They can:
0331
0332 - be managed in a _PSx method which gets called on entry to power
0333 state Dx.
0334
0335 - be declared separately as power resources with their own _ON and _OFF
0336 methods. They are then tied back to D-states for a particular device
0337 via _PRx which specifies which power resources a device needs to be on
0338 while in Dx. Kernel then tracks number of devices using a power resource
0339 and calls _ON/_OFF as needed.
0340
0341 The kernel ACPI code will also assume that the _PSx methods follow the normal
0342 ACPI rules for such methods:
0343
0344 - If either _PS0 or _PS3 is implemented, then the other method must also
0345 be implemented.
0346
0347 - If a device requires usage or setup of a power resource when on, the ASL
0348 should organize that it is allocated/enabled using the _PS0 method.
0349
0350 - Resources allocated or enabled in the _PS0 method should be disabled
0351 or de-allocated in the _PS3 method.
0352
0353 - Firmware will leave the resources in a reasonable state before handing
0354 over control to the kernel.
0355
0356 Such code in _PSx methods will of course be very platform specific. But,
0357 this allows the driver to abstract out the interface for operating the device
0358 and avoid having to read special non-standard values from ACPI tables. Further,
0359 abstracting the use of these resources allows the hardware to change over time
0360 without requiring updates to the driver.
0361
0362
0363 Clocks
0364 ------
0365 ACPI makes the assumption that clocks are initialized by the firmware --
0366 UEFI, in this case -- to some working value before control is handed over
0367 to the kernel. This has implications for devices such as UARTs, or SoC-driven
0368 LCD displays, for example.
0369
0370 When the kernel boots, the clocks are assumed to be set to reasonable
0371 working values. If for some reason the frequency needs to change -- e.g.,
0372 throttling for power management -- the device driver should expect that
0373 process to be abstracted out into some ACPI method that can be invoked
0374 (please see the ACPI specification for further recommendations on standard
0375 methods to be expected). The only exceptions to this are CPU clocks where
0376 CPPC provides a much richer interface than ACPI methods. If the clocks
0377 are not set, there is no direct way for Linux to control them.
0378
0379 If an SoC vendor wants to provide fine-grained control of the system clocks,
0380 they could do so by providing ACPI methods that could be invoked by Linux
0381 drivers. However, this is NOT recommended and Linux drivers should NOT use
0382 such methods, even if they are provided. Such methods are not currently
0383 standardized in the ACPI specification, and using them could tie a kernel
0384 to a very specific SoC, or tie an SoC to a very specific version of the
0385 kernel, both of which we are trying to avoid.
0386
0387
0388 Driver Recommendations
0389 ----------------------
0390 DO NOT remove any DT handling when adding ACPI support for a driver. The
0391 same device may be used on many different systems.
0392
0393 DO try to structure the driver so that it is data-driven. That is, set up
0394 a struct containing internal per-device state based on defaults and whatever
0395 else must be discovered by the driver probe function. Then, have the rest
0396 of the driver operate off of the contents of that struct. Doing so should
0397 allow most divergence between ACPI and DT functionality to be kept local to
0398 the probe function instead of being scattered throughout the driver. For
0399 example::
0400
0401 static int device_probe_dt(struct platform_device *pdev)
0402 {
0403 /* DT specific functionality */
0404 ...
0405 }
0406
0407 static int device_probe_acpi(struct platform_device *pdev)
0408 {
0409 /* ACPI specific functionality */
0410 ...
0411 }
0412
0413 static int device_probe(struct platform_device *pdev)
0414 {
0415 ...
0416 struct device_node node = pdev->dev.of_node;
0417 ...
0418
0419 if (node)
0420 ret = device_probe_dt(pdev);
0421 else if (ACPI_HANDLE(&pdev->dev))
0422 ret = device_probe_acpi(pdev);
0423 else
0424 /* other initialization */
0425 ...
0426 /* Continue with any generic probe operations */
0427 ...
0428 }
0429
0430 DO keep the MODULE_DEVICE_TABLE entries together in the driver to make it
0431 clear the different names the driver is probed for, both from DT and from
0432 ACPI::
0433
0434 static struct of_device_id virtio_mmio_match[] = {
0435 { .compatible = "virtio,mmio", },
0436 { }
0437 };
0438 MODULE_DEVICE_TABLE(of, virtio_mmio_match);
0439
0440 static const struct acpi_device_id virtio_mmio_acpi_match[] = {
0441 { "LNRO0005", },
0442 { }
0443 };
0444 MODULE_DEVICE_TABLE(acpi, virtio_mmio_acpi_match);
0445
0446
0447 ASWG
0448 ----
0449 The ACPI specification changes regularly. During the year 2014, for instance,
0450 version 5.1 was released and version 6.0 substantially completed, with most of
0451 the changes being driven by ARM-specific requirements. Proposed changes are
0452 presented and discussed in the ASWG (ACPI Specification Working Group) which
0453 is a part of the UEFI Forum. The current version of the ACPI specification
0454 is 6.1 release in January 2016.
0455
0456 Participation in this group is open to all UEFI members. Please see
0457 http://www.uefi.org/workinggroup for details on group membership.
0458
0459 It is the intent of the ARMv8 ACPI kernel code to follow the ACPI specification
0460 as closely as possible, and to only implement functionality that complies with
0461 the released standards from UEFI ASWG. As a practical matter, there will be
0462 vendors that provide bad ACPI tables or violate the standards in some way.
0463 If this is because of errors, quirks and fix-ups may be necessary, but will
0464 be avoided if possible. If there are features missing from ACPI that preclude
0465 it from being used on a platform, ECRs (Engineering Change Requests) should be
0466 submitted to ASWG and go through the normal approval process; for those that
0467 are not UEFI members, many other members of the Linux community are and would
0468 likely be willing to assist in submitting ECRs.
0469
0470
0471 Linux Code
0472 ----------
0473 Individual items specific to Linux on ARM, contained in the Linux
0474 source code, are in the list that follows:
0475
0476 ACPI_OS_NAME
0477 This macro defines the string to be returned when
0478 an ACPI method invokes the _OS method. On ARM64
0479 systems, this macro will be "Linux" by default.
0480 The command line parameter acpi_os=<string>
0481 can be used to set it to some other value. The
0482 default value for other architectures is "Microsoft
0483 Windows NT", for example.
0484
0485 ACPI Objects
0486 ------------
0487 Detailed expectations for ACPI tables and object are listed in the file
0488 Documentation/arm64/acpi_object_usage.rst.
0489
0490
0491 References
0492 ----------
0493 [0] http://silver.arm.com
0494 document ARM-DEN-0029, or newer:
0495 "Server Base System Architecture", version 2.3, dated 27 Mar 2014
0496
0497 [1] http://infocenter.arm.com/help/topic/com.arm.doc.den0044a/Server_Base_Boot_Requirements.pdf
0498 Document ARM-DEN-0044A, or newer: "Server Base Boot Requirements, System
0499 Software on ARM Platforms", dated 16 Aug 2014
0500
0501 [2] http://www.secretlab.ca/archives/151,
0502 10 Jan 2015, Copyright (c) 2015,
0503 Linaro Ltd., written by Grant Likely.
0504
0505 [3] AMD ACPI for Seattle platform documentation
0506 http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2012/10/Seattle_ACPI_Guide.pdf
0507
0508
0509 [4] http://www.uefi.org/acpi
0510 please see the link for the "ACPI _DSD Device
0511 Property Registry Instructions"
0512
0513 [5] http://www.uefi.org/acpi
0514 please see the link for the "_DSD (Device
0515 Specific Data) Implementation Guide"
0516
0517 [6] Kernel code for the unified device
0518 property interface can be found in
0519 include/linux/property.h and drivers/base/property.c.
0520
0521
0522 Authors
0523 -------
0524 - Al Stone <al.stone@linaro.org>
0525 - Graeme Gregory <graeme.gregory@linaro.org>
0526 - Hanjun Guo <hanjun.guo@linaro.org>
0527
0528 - Grant Likely <grant.likely@linaro.org>, for the "Why ACPI on ARM?" section