blob: 1a74a041a443b02fe7f4c86bed7ad69f1c979434 [file] [log] [blame]
Graeme Gregorydc81f2c2015-03-24 14:02:54 +00001ACPI on ARMv8 Servers
2---------------------
3ACPI can be used for ARMv8 general purpose servers designed to follow
4the ARM SBSA (Server Base System Architecture) [0] and SBBR (Server
5Base Boot Requirements) [1] specifications. Please note that the SBBR
6can be retrieved simply by visiting [1], but the SBSA is currently only
7available to those with an ARM login due to ARM IP licensing concerns.
8
9The ARMv8 kernel implements the reduced hardware model of ACPI version
105.1 or later. Links to the specification and all external documents
11it refers to are managed by the UEFI Forum. The specification is
12available at http://www.uefi.org/specifications and documents referenced
13by the specification can be found via http://www.uefi.org/acpi.
14
15If an ARMv8 system does not meet the requirements of the SBSA and SBBR,
16or cannot be described using the mechanisms defined in the required ACPI
17specifications, then ACPI may not be a good fit for the hardware.
18
19While the documents mentioned above set out the requirements for building
20industry-standard ARMv8 servers, they also apply to more than one operating
21system. The purpose of this document is to describe the interaction between
22ACPI and Linux only, on an ARMv8 system -- that is, what Linux expects of
23ACPI and what ACPI can expect of Linux.
24
25
26Why ACPI on ARM?
27----------------
28Before examining the details of the interface between ACPI and Linux, it is
29useful to understand why ACPI is being used. Several technologies already
30exist in Linux for describing non-enumerable hardware, after all. In this
31section we summarize a blog post [2] from Grant Likely that outlines the
32reasoning behind ACPI on ARMv8 servers. Actually, we snitch a good portion
33of the summary text almost directly, to be honest.
34
35The short form of the rationale for ACPI on ARM is:
36
Al Stone83ce0ef2016-06-13 15:41:55 -060037-- ACPI’s byte code (AML) allows the platform to encode hardware behavior,
Graeme Gregorydc81f2c2015-03-24 14:02:54 +000038 while DT explicitly does not support this. For hardware vendors, being
39 able to encode behavior is a key tool used in supporting operating
40 system releases on new hardware.
41
42-- ACPI’s OSPM defines a power management model that constrains what the
43 platform is allowed to do into a specific model, while still providing
44 flexibility in hardware design.
45
46-- In the enterprise server environment, ACPI has established bindings (such
47 as for RAS) which are currently used in production systems. DT does not.
48 Such bindings could be defined in DT at some point, but doing so means ARM
49 and x86 would end up using completely different code paths in both firmware
50 and the kernel.
51
52-- Choosing a single interface to describe the abstraction between a platform
53 and an OS is important. Hardware vendors would not be required to implement
54 both DT and ACPI if they want to support multiple operating systems. And,
55 agreeing on a single interface instead of being fragmented into per OS
56 interfaces makes for better interoperability overall.
57
58-- The new ACPI governance process works well and Linux is now at the same
59 table as hardware vendors and other OS vendors. In fact, there is no
Al Stone83ce0ef2016-06-13 15:41:55 -060060 longer any reason to feel that ACPI only belongs to Windows or that
Graeme Gregorydc81f2c2015-03-24 14:02:54 +000061 Linux is in any way secondary to Microsoft in this arena. The move of
62 ACPI governance into the UEFI forum has significantly opened up the
63 specification development process, and currently, a large portion of the
Al Stone83ce0ef2016-06-13 15:41:55 -060064 changes being made to ACPI are being driven by Linux.
Graeme Gregorydc81f2c2015-03-24 14:02:54 +000065
66Key to the use of ACPI is the support model. For servers in general, the
67responsibility for hardware behaviour cannot solely be the domain of the
68kernel, but rather must be split between the platform and the kernel, in
69order to allow for orderly change over time. ACPI frees the OS from needing
70to understand all the minute details of the hardware so that the OS doesn’t
71need to be ported to each and every device individually. It allows the
72hardware vendors to take responsibility for power management behaviour without
73depending on an OS release cycle which is not under their control.
74
75ACPI is also important because hardware and OS vendors have already worked
76out the mechanisms for supporting a general purpose computing ecosystem. The
77infrastructure is in place, the bindings are in place, and the processes are
78in place. DT does exactly what Linux needs it to when working with vertically
79integrated devices, but there are no good processes for supporting what the
80server vendors need. Linux could potentially get there with DT, but doing so
81really just duplicates something that already works. ACPI already does what
82the hardware vendors need, Microsoft won’t collaborate on DT, and hardware
83vendors would still end up providing two completely separate firmware
84interfaces -- one for Linux and one for Windows.
85
86
87Kernel Compatibility
88--------------------
89One of the primary motivations for ACPI is standardization, and using that
90to provide backward compatibility for Linux kernels. In the server market,
91software and hardware are often used for long periods. ACPI allows the
92kernel and firmware to agree on a consistent abstraction that can be
93maintained over time, even as hardware or software change. As long as the
94abstraction is supported, systems can be updated without necessarily having
95to replace the kernel.
96
97When a Linux driver or subsystem is first implemented using ACPI, it by
98definition ends up requiring a specific version of the ACPI specification
99-- it's baseline. ACPI firmware must continue to work, even though it may
100not be optimal, with the earliest kernel version that first provides support
101for that baseline version of ACPI. There may be a need for additional drivers,
102but adding new functionality (e.g., CPU power management) should not break
103older kernel versions. Further, ACPI firmware must also work with the most
104recent version of the kernel.
105
106
107Relationship with Device Tree
108-----------------------------
109ACPI support in drivers and subsystems for ARMv8 should never be mutually
110exclusive with DT support at compile time.
111
112At boot time the kernel will only use one description method depending on
Al Stone83ce0ef2016-06-13 15:41:55 -0600113parameters passed from the boot loader (including kernel bootargs).
Graeme Gregorydc81f2c2015-03-24 14:02:54 +0000114
115Regardless of whether DT or ACPI is used, the kernel must always be capable
116of booting with either scheme (in kernels with both schemes enabled at compile
117time).
118
119
120Booting using ACPI tables
121-------------------------
122The only defined method for passing ACPI tables to the kernel on ARMv8
123is via the UEFI system configuration table. Just so it is explicit, this
124means that ACPI is only supported on platforms that boot via UEFI.
125
126When an ARMv8 system boots, it can either have DT information, ACPI tables,
127or in some very unusual cases, both. If no command line parameters are used,
128the kernel will try to use DT for device enumeration; if there is no DT
129present, the kernel will try to use ACPI tables, but only if they are present.
130In neither is available, the kernel will not boot. If acpi=force is used
131on the command line, the kernel will attempt to use ACPI tables first, but
132fall back to DT if there are no ACPI tables present. The basic idea is that
133the kernel will not fail to boot unless it absolutely has no other choice.
134
135Processing of ACPI tables may be disabled by passing acpi=off on the kernel
136command line; this is the default behavior.
137
138In order for the kernel to load and use ACPI tables, the UEFI implementation
139MUST set the ACPI_20_TABLE_GUID to point to the RSDP table (the table with
140the ACPI signature "RSD PTR "). If this pointer is incorrect and acpi=force
141is used, the kernel will disable ACPI and try to use DT to boot instead; the
142kernel has, in effect, determined that ACPI tables are not present at that
143point.
144
145If the pointer to the RSDP table is correct, the table will be mapped into
146the kernel by the ACPI core, using the address provided by UEFI.
147
148The ACPI core will then locate and map in all other ACPI tables provided by
149using the addresses in the RSDP table to find the XSDT (eXtended System
150Description Table). The XSDT in turn provides the addresses to all other
151ACPI tables provided by the system firmware; the ACPI core will then traverse
152this table and map in the tables listed.
153
154The ACPI core will ignore any provided RSDT (Root System Description Table).
155RSDTs have been deprecated and are ignored on arm64 since they only allow
156for 32-bit addresses.
157
158Further, the ACPI core will only use the 64-bit address fields in the FADT
159(Fixed ACPI Description Table). Any 32-bit address fields in the FADT will
160be ignored on arm64.
161
Al Stone83ce0ef2016-06-13 15:41:55 -0600162Hardware reduced mode (see Section 4.1 of the ACPI 6.1 specification) will
Graeme Gregorydc81f2c2015-03-24 14:02:54 +0000163be enforced by the ACPI core on arm64. Doing so allows the ACPI core to
164run less complex code since it no longer has to provide support for legacy
165hardware from other architectures. Any fields that are not to be used for
166hardware reduced mode must be set to zero.
167
168For the ACPI core to operate properly, and in turn provide the information
169the kernel needs to configure devices, it expects to find the following
Al Stone83ce0ef2016-06-13 15:41:55 -0600170tables (all section numbers refer to the ACPI 6.1 specification):
Graeme Gregorydc81f2c2015-03-24 14:02:54 +0000171
172 -- RSDP (Root System Description Pointer), section 5.2.5
173
174 -- XSDT (eXtended System Description Table), section 5.2.8
175
176 -- FADT (Fixed ACPI Description Table), section 5.2.9
177
178 -- DSDT (Differentiated System Description Table), section
179 5.2.11.1
180
181 -- MADT (Multiple APIC Description Table), section 5.2.12
182
183 -- GTDT (Generic Timer Description Table), section 5.2.24
184
185 -- If PCI is supported, the MCFG (Memory mapped ConFiGuration
186 Table), section 5.2.6, specifically Table 5-31.
187
Al Stone83ce0ef2016-06-13 15:41:55 -0600188 -- If booting without a console=<device> kernel parameter is
189 supported, the SPCR (Serial Port Console Redirection table),
190 section 5.2.6, specifically Table 5-31.
191
192 -- If necessary to describe the I/O topology, SMMUs and GIC ITSs,
193 the IORT (Input Output Remapping Table, section 5.2.6, specifically
194 Table 5-31).
195
196 -- If NUMA is supported, the SRAT (System Resource Affinity Table)
197 and SLIT (System Locality distance Information Table), sections
198 5.2.16 and 5.2.17, respectively.
199
Graeme Gregorydc81f2c2015-03-24 14:02:54 +0000200If the above tables are not all present, the kernel may or may not be
201able to boot properly since it may not be able to configure all of the
Al Stone83ce0ef2016-06-13 15:41:55 -0600202devices available. This list of tables is not meant to be all inclusive;
203in some environments other tables may be needed (e.g., any of the APEI
204tables from section 18) to support specific functionality.
Graeme Gregorydc81f2c2015-03-24 14:02:54 +0000205
206
207ACPI Detection
208--------------
209Drivers should determine their probe() type by checking for a null
210value for ACPI_HANDLE, or checking .of_node, or other information in
211the device structure. This is detailed further in the "Driver
212Recommendations" section.
213
214In non-driver code, if the presence of ACPI needs to be detected at
Al Stone83ce0ef2016-06-13 15:41:55 -0600215run time, then check the value of acpi_disabled. If CONFIG_ACPI is not
Graeme Gregorydc81f2c2015-03-24 14:02:54 +0000216set, acpi_disabled will always be 1.
217
218
219Device Enumeration
220------------------
221Device descriptions in ACPI should use standard recognized ACPI interfaces.
222These may contain less information than is typically provided via a Device
223Tree description for the same device. This is also one of the reasons that
224ACPI can be useful -- the driver takes into account that it may have less
225detailed information about the device and uses sensible defaults instead.
226If done properly in the driver, the hardware can change and improve over
227time without the driver having to change at all.
228
229Clocks provide an excellent example. In DT, clocks need to be specified
230and the drivers need to take them into account. In ACPI, the assumption
231is that UEFI will leave the device in a reasonable default state, including
232any clock settings. If for some reason the driver needs to change a clock
233value, this can be done in an ACPI method; all the driver needs to do is
234invoke the method and not concern itself with what the method needs to do
235to change the clock. Changing the hardware can then take place over time
236by changing what the ACPI method does, and not the driver.
237
238In DT, the parameters needed by the driver to set up clocks as in the example
239above are known as "bindings"; in ACPI, these are known as "Device Properties"
240and provided to a driver via the _DSD object.
241
242ACPI tables are described with a formal language called ASL, the ACPI
243Source Language (section 19 of the specification). This means that there
244are always multiple ways to describe the same thing -- including device
245properties. For example, device properties could use an ASL construct
246that looks like this: Name(KEY0, "value0"). An ACPI device driver would
247then retrieve the value of the property by evaluating the KEY0 object.
248However, using Name() this way has multiple problems: (1) ACPI limits
249names ("KEY0") to four characters unlike DT; (2) there is no industry
Al Stone83ce0ef2016-06-13 15:41:55 -0600250wide registry that maintains a list of names, minimizing re-use; (3)
Graeme Gregorydc81f2c2015-03-24 14:02:54 +0000251there is also no registry for the definition of property values ("value0"),
252again making re-use difficult; and (4) how does one maintain backward
253compatibility as new hardware comes out? The _DSD method was created
254to solve precisely these sorts of problems; Linux drivers should ALWAYS
255use the _DSD method for device properties and nothing else.
256
257The _DSM object (ACPI Section 9.14.1) could also be used for conveying
258device properties to a driver. Linux drivers should only expect it to
259be used if _DSD cannot represent the data required, and there is no way
260to create a new UUID for the _DSD object. Note that there is even less
261regulation of the use of _DSM than there is of _DSD. Drivers that depend
262on the contents of _DSM objects will be more difficult to maintain over
263time because of this; as of this writing, the use of _DSM is the cause
264of quite a few firmware problems and is not recommended.
265
266Drivers should look for device properties in the _DSD object ONLY; the _DSD
267object is described in the ACPI specification section 6.2.5, but this only
268describes how to define the structure of an object returned via _DSD, and
269how specific data structures are defined by specific UUIDs. Linux should
270only use the _DSD Device Properties UUID [5]:
271
272 -- UUID: daffd814-6eba-4d8c-8a91-bc9bbf4aa301
273
274 -- http://www.uefi.org/sites/default/files/resources/_DSD-device-properties-UUID.pdf
275
276The UEFI Forum provides a mechanism for registering device properties [4]
277so that they may be used across all operating systems supporting ACPI.
278Device properties that have not been registered with the UEFI Forum should
279not be used.
280
281Before creating new device properties, check to be sure that they have not
282been defined before and either registered in the Linux kernel documentation
283as DT bindings, or the UEFI Forum as device properties. While we do not want
284to simply move all DT bindings into ACPI device properties, we can learn from
285what has been previously defined.
286
287If it is necessary to define a new device property, or if it makes sense to
288synthesize the definition of a binding so it can be used in any firmware,
289both DT bindings and ACPI device properties for device drivers have review
290processes. Use them both. When the driver itself is submitted for review
291to the Linux mailing lists, the device property definitions needed must be
292submitted at the same time. A driver that supports ACPI and uses device
293properties will not be considered complete without their definitions. Once
294the device property has been accepted by the Linux community, it must be
295registered with the UEFI Forum [4], which will review it again for consistency
296within the registry. This may require iteration. The UEFI Forum, though,
297will always be the canonical site for device property definitions.
298
299It may make sense to provide notice to the UEFI Forum that there is the
300intent to register a previously unused device property name as a means of
301reserving the name for later use. Other operating system vendors will
302also be submitting registration requests and this may help smooth the
303process.
304
305Once registration and review have been completed, the kernel provides an
306interface for looking up device properties in a manner independent of
307whether DT or ACPI is being used. This API should be used [6]; it can
308eliminate some duplication of code paths in driver probing functions and
309discourage divergence between DT bindings and ACPI device properties.
310
311
312Programmable Power Control Resources
313------------------------------------
314Programmable power control resources include such resources as voltage/current
315providers (regulators) and clock sources.
316
317With ACPI, the kernel clock and regulator framework is not expected to be used
318at all.
319
320The kernel assumes that power control of these resources is represented with
321Power Resource Objects (ACPI section 7.1). The ACPI core will then handle
322correctly enabling and disabling resources as they are needed. In order to
323get that to work, ACPI assumes each device has defined D-states and that these
324can be controlled through the optional ACPI methods _PS0, _PS1, _PS2, and _PS3;
325in ACPI, _PS0 is the method to invoke to turn a device full on, and _PS3 is for
326turning a device full off.
327
328There are two options for using those Power Resources. They can:
329
330 -- be managed in a _PSx method which gets called on entry to power
331 state Dx.
332
333 -- be declared separately as power resources with their own _ON and _OFF
334 methods. They are then tied back to D-states for a particular device
335 via _PRx which specifies which power resources a device needs to be on
336 while in Dx. Kernel then tracks number of devices using a power resource
337 and calls _ON/_OFF as needed.
338
339The kernel ACPI code will also assume that the _PSx methods follow the normal
340ACPI rules for such methods:
341
342 -- If either _PS0 or _PS3 is implemented, then the other method must also
343 be implemented.
344
345 -- If a device requires usage or setup of a power resource when on, the ASL
346 should organize that it is allocated/enabled using the _PS0 method.
347
348 -- Resources allocated or enabled in the _PS0 method should be disabled
349 or de-allocated in the _PS3 method.
350
351 -- Firmware will leave the resources in a reasonable state before handing
352 over control to the kernel.
353
354Such code in _PSx methods will of course be very platform specific. But,
355this allows the driver to abstract out the interface for operating the device
356and avoid having to read special non-standard values from ACPI tables. Further,
357abstracting the use of these resources allows the hardware to change over time
358without requiring updates to the driver.
359
360
361Clocks
362------
363ACPI makes the assumption that clocks are initialized by the firmware --
364UEFI, in this case -- to some working value before control is handed over
365to the kernel. This has implications for devices such as UARTs, or SoC-driven
366LCD displays, for example.
367
368When the kernel boots, the clocks are assumed to be set to reasonable
369working values. If for some reason the frequency needs to change -- e.g.,
370throttling for power management -- the device driver should expect that
371process to be abstracted out into some ACPI method that can be invoked
372(please see the ACPI specification for further recommendations on standard
373methods to be expected). The only exceptions to this are CPU clocks where
374CPPC provides a much richer interface than ACPI methods. If the clocks
375are not set, there is no direct way for Linux to control them.
376
377If an SoC vendor wants to provide fine-grained control of the system clocks,
378they could do so by providing ACPI methods that could be invoked by Linux
379drivers. However, this is NOT recommended and Linux drivers should NOT use
380such methods, even if they are provided. Such methods are not currently
381standardized in the ACPI specification, and using them could tie a kernel
382to a very specific SoC, or tie an SoC to a very specific version of the
383kernel, both of which we are trying to avoid.
384
385
386Driver Recommendations
387----------------------
388DO NOT remove any DT handling when adding ACPI support for a driver. The
389same device may be used on many different systems.
390
391DO try to structure the driver so that it is data-driven. That is, set up
392a struct containing internal per-device state based on defaults and whatever
393else must be discovered by the driver probe function. Then, have the rest
394of the driver operate off of the contents of that struct. Doing so should
395allow most divergence between ACPI and DT functionality to be kept local to
396the probe function instead of being scattered throughout the driver. For
397example:
398
399static int device_probe_dt(struct platform_device *pdev)
400{
401 /* DT specific functionality */
402 ...
403}
404
405static int device_probe_acpi(struct platform_device *pdev)
406{
407 /* ACPI specific functionality */
408 ...
409}
410
411static int device_probe(struct platform_device *pdev)
412{
413 ...
414 struct device_node node = pdev->dev.of_node;
415 ...
416
417 if (node)
418 ret = device_probe_dt(pdev);
419 else if (ACPI_HANDLE(&pdev->dev))
420 ret = device_probe_acpi(pdev);
421 else
422 /* other initialization */
423 ...
424 /* Continue with any generic probe operations */
425 ...
426}
427
428DO keep the MODULE_DEVICE_TABLE entries together in the driver to make it
429clear the different names the driver is probed for, both from DT and from
430ACPI:
431
432static struct of_device_id virtio_mmio_match[] = {
433 { .compatible = "virtio,mmio", },
434 { }
435};
436MODULE_DEVICE_TABLE(of, virtio_mmio_match);
437
438static const struct acpi_device_id virtio_mmio_acpi_match[] = {
439 { "LNRO0005", },
440 { }
441};
442MODULE_DEVICE_TABLE(acpi, virtio_mmio_acpi_match);
443
444
445ASWG
446----
447The ACPI specification changes regularly. During the year 2014, for instance,
448version 5.1 was released and version 6.0 substantially completed, with most of
449the changes being driven by ARM-specific requirements. Proposed changes are
450presented and discussed in the ASWG (ACPI Specification Working Group) which
Al Stone83ce0ef2016-06-13 15:41:55 -0600451is a part of the UEFI Forum. The current version of the ACPI specification
452is 6.1 release in January 2016.
Graeme Gregorydc81f2c2015-03-24 14:02:54 +0000453
454Participation in this group is open to all UEFI members. Please see
455http://www.uefi.org/workinggroup for details on group membership.
456
457It is the intent of the ARMv8 ACPI kernel code to follow the ACPI specification
458as closely as possible, and to only implement functionality that complies with
459the released standards from UEFI ASWG. As a practical matter, there will be
460vendors that provide bad ACPI tables or violate the standards in some way.
Al Stone83ce0ef2016-06-13 15:41:55 -0600461If this is because of errors, quirks and fix-ups may be necessary, but will
Graeme Gregorydc81f2c2015-03-24 14:02:54 +0000462be avoided if possible. If there are features missing from ACPI that preclude
463it from being used on a platform, ECRs (Engineering Change Requests) should be
464submitted to ASWG and go through the normal approval process; for those that
465are not UEFI members, many other members of the Linux community are and would
466likely be willing to assist in submitting ECRs.
467
468
469Linux Code
470----------
471Individual items specific to Linux on ARM, contained in the the Linux
472source code, are in the list that follows:
473
474ACPI_OS_NAME This macro defines the string to be returned when
475 an ACPI method invokes the _OS method. On ARM64
476 systems, this macro will be "Linux" by default.
477 The command line parameter acpi_os=<string>
478 can be used to set it to some other value. The
479 default value for other architectures is "Microsoft
480 Windows NT", for example.
481
482ACPI Objects
483------------
484Detailed expectations for ACPI tables and object are listed in the file
485Documentation/arm64/acpi_object_usage.txt.
486
487
488References
489----------
490[0] http://silver.arm.com -- document ARM-DEN-0029, or newer
491 "Server Base System Architecture", version 2.3, dated 27 Mar 2014
492
493[1] http://infocenter.arm.com/help/topic/com.arm.doc.den0044a/Server_Base_Boot_Requirements.pdf
494 Document ARM-DEN-0044A, or newer: "Server Base Boot Requirements, System
495 Software on ARM Platforms", dated 16 Aug 2014
496
497[2] http://www.secretlab.ca/archives/151, 10 Jan 2015, Copyright (c) 2015,
Al Stone83ce0ef2016-06-13 15:41:55 -0600498 Linaro Ltd., written by Grant Likely.
Graeme Gregorydc81f2c2015-03-24 14:02:54 +0000499
500[3] AMD ACPI for Seattle platform documentation:
501 http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2012/10/Seattle_ACPI_Guide.pdf
502
503[4] http://www.uefi.org/acpi -- please see the link for the "ACPI _DSD Device
504 Property Registry Instructions"
505
506[5] http://www.uefi.org/acpi -- please see the link for the "_DSD (Device
507 Specific Data) Implementation Guide"
508
509[6] Kernel code for the unified device property interface can be found in
510 include/linux/property.h and drivers/base/property.c.
511
512
513Authors
514-------
515Al Stone <al.stone@linaro.org>
516Graeme Gregory <graeme.gregory@linaro.org>
517Hanjun Guo <hanjun.guo@linaro.org>
518
519Grant Likely <grant.likely@linaro.org>, for the "Why ACPI on ARM?" section