Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux

Pull initial ACPI support for arm64 from Will Deacon:
"This series introduces preliminary ACPI 5.1 support to the arm64
kernel using the "hardware reduced" profile. We don't support any
peripherals yet, so it's fairly limited in scope:

- MEMORY init (UEFI)

- ACPI discovery (RSDP via UEFI)

- CPU init (FADT)

- GIC init (MADT)

- SMP boot (MADT + PSCI)

- ACPI Kconfig options (dependent on EXPERT)

ACPI for arm64 has been in development for a while now and hardware
has been available that can boot with either FDT or ACPI tables. This
has been made possible by both changes to the ACPI spec to cater for
ARM-based machines (known as "hardware-reduced" in ACPI parlance) but
also a Linaro-driven effort to get this supported on top of the Linux
kernel. This pull request is the result of that work.

These changes allow us to initialise the CPUs, interrupt controller,
and timers via ACPI tables, with memory information and cmdline coming
from EFI. We don't support a hybrid ACPI/FDT scheme. Of course,
there is still plenty of work to do (a serial console would be nice!)
but I expect that to happen on a per-driver basis after this core
series has been merged.

Anyway, the diff stat here is fairly horrible, but splitting this up
and merging it via all the different subsystems would have been
extremely painful. Instead, we've got all the relevant Acks in place
and I've not seen anything other than trivial (Kconfig) conflicts in
-next (for completeness, I've included my resolution below). Nearly
half of the insertions fall under Documentation/.

So, we'll see how this goes. Right now, it all depends on EXPERT and
I fully expect people to use FDT by default for the immediate future"

* tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: (31 commits)
ARM64 / ACPI: make acpi_map_gic_cpu_interface() as void function
ARM64 / ACPI: Ignore the return error value of acpi_map_gic_cpu_interface()
ARM64 / ACPI: fix usage of acpi_map_gic_cpu_interface
ARM64: kernel: acpi: honour acpi=force command line parameter
ARM64: kernel: acpi: refactor ACPI tables init and checks
ARM64: kernel: psci: let ACPI probe PSCI version
ARM64: kernel: psci: factor out probe function
ACPI: move arm64 GSI IRQ model to generic GSI IRQ layer
ARM64 / ACPI: Don't unflatten device tree if acpi=force is passed
ARM64 / ACPI: additions of ACPI documentation for arm64
Documentation: ACPI for ARM64
ARM64 / ACPI: Enable ARM64 in Kconfig
XEN / ACPI: Make XEN ACPI depend on X86
ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64
clocksource / arch_timer: Parse GTDT to initialize arch timer
irqchip: Add GICv2 specific ACPI boot support
ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi
ACPI / processor: Make it possible to get CPU hardware ID via GICC
ACPI / processor: Introduce phys_cpuid_t for CPU hardware ID
ARM64 / ACPI: Parse MADT for SMP initialization
...

+2217 -116
+593
Documentation/arm64/acpi_object_usage.txt
··· 1 + ACPI Tables 2 + ----------- 3 + The expectations of individual ACPI tables are discussed in the list that 4 + follows. 5 + 6 + If a section number is used, it refers to a section number in the ACPI 7 + specification where the object is defined. If "Signature Reserved" is used, 8 + the table signature (the first four bytes of the table) is the only portion 9 + of the table recognized by the specification, and the actual table is defined 10 + outside of the UEFI Forum (see Section 5.2.6 of the specification). 11 + 12 + For ACPI on arm64, tables also fall into the following categories: 13 + 14 + -- Required: DSDT, FADT, GTDT, MADT, MCFG, RSDP, SPCR, XSDT 15 + 16 + -- Recommended: BERT, EINJ, ERST, HEST, SSDT 17 + 18 + -- Optional: BGRT, CPEP, CSRT, DRTM, ECDT, FACS, FPDT, MCHI, MPST, 19 + MSCT, RASF, SBST, SLIT, SPMI, SRAT, TCPA, TPM2, UEFI 20 + 21 + -- Not supported: BOOT, DBG2, DBGP, DMAR, ETDT, HPET, IBFT, IVRS, 22 + LPIT, MSDM, RSDT, SLIC, WAET, WDAT, WDRT, WPBT 23 + 24 + 25 + Table Usage for ARMv8 Linux 26 + ----- ---------------------------------------------------------------- 27 + BERT Section 18.3 (signature == "BERT") 28 + == Boot Error Record Table == 29 + Must be supplied if RAS support is provided by the platform. It 30 + is recommended this table be supplied. 31 + 32 + BOOT Signature Reserved (signature == "BOOT") 33 + == simple BOOT flag table == 34 + Microsoft only table, will not be supported. 35 + 36 + BGRT Section 5.2.22 (signature == "BGRT") 37 + == Boot Graphics Resource Table == 38 + Optional, not currently supported, with no real use-case for an 39 + ARM server. 40 + 41 + CPEP Section 5.2.18 (signature == "CPEP") 42 + == Corrected Platform Error Polling table == 43 + Optional, not currently supported, and not recommended until such 44 + time as ARM-compatible hardware is available, and the specification 45 + suitably modified. 46 + 47 + CSRT Signature Reserved (signature == "CSRT") 48 + == Core System Resources Table == 49 + Optional, not currently supported. 50 + 51 + DBG2 Signature Reserved (signature == "DBG2") 52 + == DeBuG port table 2 == 53 + Microsoft only table, will not be supported. 54 + 55 + DBGP Signature Reserved (signature == "DBGP") 56 + == DeBuG Port table == 57 + Microsoft only table, will not be supported. 58 + 59 + DSDT Section 5.2.11.1 (signature == "DSDT") 60 + == Differentiated System Description Table == 61 + A DSDT is required; see also SSDT. 62 + 63 + ACPI tables contain only one DSDT but can contain one or more SSDTs, 64 + which are optional. Each SSDT can only add to the ACPI namespace, 65 + but cannot modify or replace anything in the DSDT. 66 + 67 + DMAR Signature Reserved (signature == "DMAR") 68 + == DMA Remapping table == 69 + x86 only table, will not be supported. 70 + 71 + DRTM Signature Reserved (signature == "DRTM") 72 + == Dynamic Root of Trust for Measurement table == 73 + Optional, not currently supported. 74 + 75 + ECDT Section 5.2.16 (signature == "ECDT") 76 + == Embedded Controller Description Table == 77 + Optional, not currently supported, but could be used on ARM if and 78 + only if one uses the GPE_BIT field to represent an IRQ number, since 79 + there are no GPE blocks defined in hardware reduced mode. This would 80 + need to be modified in the ACPI specification. 81 + 82 + EINJ Section 18.6 (signature == "EINJ") 83 + == Error Injection table == 84 + This table is very useful for testing platform response to error 85 + conditions; it allows one to inject an error into the system as 86 + if it had actually occurred. However, this table should not be 87 + shipped with a production system; it should be dynamically loaded 88 + and executed with the ACPICA tools only during testing. 89 + 90 + ERST Section 18.5 (signature == "ERST") 91 + == Error Record Serialization Table == 92 + On a platform supports RAS, this table must be supplied if it is not 93 + UEFI-based; if it is UEFI-based, this table may be supplied. When this 94 + table is not present, UEFI run time service will be utilized to save 95 + and retrieve hardware error information to and from a persistent store. 96 + 97 + ETDT Signature Reserved (signature == "ETDT") 98 + == Event Timer Description Table == 99 + Obsolete table, will not be supported. 100 + 101 + FACS Section 5.2.10 (signature == "FACS") 102 + == Firmware ACPI Control Structure == 103 + It is unlikely that this table will be terribly useful. If it is 104 + provided, the Global Lock will NOT be used since it is not part of 105 + the hardware reduced profile, and only 64-bit address fields will 106 + be considered valid. 107 + 108 + FADT Section 5.2.9 (signature == "FACP") 109 + == Fixed ACPI Description Table == 110 + Required for arm64. 111 + 112 + The HW_REDUCED_ACPI flag must be set. All of the fields that are 113 + to be ignored when HW_REDUCED_ACPI is set are expected to be set to 114 + zero. 115 + 116 + If an FACS table is provided, the X_FIRMWARE_CTRL field is to be 117 + used, not FIRMWARE_CTRL. 118 + 119 + If PSCI is used (as is recommended), make sure that ARM_BOOT_ARCH is 120 + filled in properly -- that the PSCI_COMPLIANT flag is set and that 121 + PSCI_USE_HVC is set or unset as needed (see table 5-37). 122 + 123 + For the DSDT that is also required, the X_DSDT field is to be used, 124 + not the DSDT field. 125 + 126 + FPDT Section 5.2.23 (signature == "FPDT") 127 + == Firmware Performance Data Table == 128 + Optional, not currently supported. 129 + 130 + GTDT Section 5.2.24 (signature == "GTDT") 131 + == Generic Timer Description Table == 132 + Required for arm64. 133 + 134 + HEST Section 18.3.2 (signature == "HEST") 135 + == Hardware Error Source Table == 136 + Until further error source types are defined, use only types 6 (AER 137 + Root Port), 7 (AER Endpoint), 8 (AER Bridge), or 9 (Generic Hardware 138 + Error Source). Firmware first error handling is possible if and only 139 + if Trusted Firmware is being used on arm64. 140 + 141 + Must be supplied if RAS support is provided by the platform. It 142 + is recommended this table be supplied. 143 + 144 + HPET Signature Reserved (signature == "HPET") 145 + == High Precision Event timer Table == 146 + x86 only table, will not be supported. 147 + 148 + IBFT Signature Reserved (signature == "IBFT") 149 + == iSCSI Boot Firmware Table == 150 + Microsoft defined table, support TBD. 151 + 152 + IVRS Signature Reserved (signature == "IVRS") 153 + == I/O Virtualization Reporting Structure == 154 + x86_64 (AMD) only table, will not be supported. 155 + 156 + LPIT Signature Reserved (signature == "LPIT") 157 + == Low Power Idle Table == 158 + x86 only table as of ACPI 5.1; future versions have been adapted for 159 + use with ARM and will be recommended in order to support ACPI power 160 + management. 161 + 162 + MADT Section 5.2.12 (signature == "APIC") 163 + == Multiple APIC Description Table == 164 + Required for arm64. Only the GIC interrupt controller structures 165 + should be used (types 0xA - 0xE). 166 + 167 + MCFG Signature Reserved (signature == "MCFG") 168 + == Memory-mapped ConFiGuration space == 169 + If the platform supports PCI/PCIe, an MCFG table is required. 170 + 171 + MCHI Signature Reserved (signature == "MCHI") 172 + == Management Controller Host Interface table == 173 + Optional, not currently supported. 174 + 175 + MPST Section 5.2.21 (signature == "MPST") 176 + == Memory Power State Table == 177 + Optional, not currently supported. 178 + 179 + MSDM Signature Reserved (signature == "MSDM") 180 + == Microsoft Data Management table == 181 + Microsoft only table, will not be supported. 182 + 183 + MSCT Section 5.2.19 (signature == "MSCT") 184 + == Maximum System Characteristic Table == 185 + Optional, not currently supported. 186 + 187 + RASF Section 5.2.20 (signature == "RASF") 188 + == RAS Feature table == 189 + Optional, not currently supported. 190 + 191 + RSDP Section 5.2.5 (signature == "RSD PTR") 192 + == Root System Description PoinTeR == 193 + Required for arm64. 194 + 195 + RSDT Section 5.2.7 (signature == "RSDT") 196 + == Root System Description Table == 197 + Since this table can only provide 32-bit addresses, it is deprecated 198 + on arm64, and will not be used. 199 + 200 + SBST Section 5.2.14 (signature == "SBST") 201 + == Smart Battery Subsystem Table == 202 + Optional, not currently supported. 203 + 204 + SLIC Signature Reserved (signature == "SLIC") 205 + == Software LIcensing table == 206 + Microsoft only table, will not be supported. 207 + 208 + SLIT Section 5.2.17 (signature == "SLIT") 209 + == System Locality distance Information Table == 210 + Optional in general, but required for NUMA systems. 211 + 212 + SPCR Signature Reserved (signature == "SPCR") 213 + == Serial Port Console Redirection table == 214 + Required for arm64. 215 + 216 + SPMI Signature Reserved (signature == "SPMI") 217 + == Server Platform Management Interface table == 218 + Optional, not currently supported. 219 + 220 + SRAT Section 5.2.16 (signature == "SRAT") 221 + == System Resource Affinity Table == 222 + Optional, but if used, only the GICC Affinity structures are read. 223 + To support NUMA, this table is required. 224 + 225 + SSDT Section 5.2.11.2 (signature == "SSDT") 226 + == Secondary System Description Table == 227 + These tables are a continuation of the DSDT; these are recommended 228 + for use with devices that can be added to a running system, but can 229 + also serve the purpose of dividing up device descriptions into more 230 + manageable pieces. 231 + 232 + An SSDT can only ADD to the ACPI namespace. It cannot modify or 233 + replace existing device descriptions already in the namespace. 234 + 235 + These tables are optional, however. ACPI tables should contain only 236 + one DSDT but can contain many SSDTs. 237 + 238 + TCPA Signature Reserved (signature == "TCPA") 239 + == Trusted Computing Platform Alliance table == 240 + Optional, not currently supported, and may need changes to fully 241 + interoperate with arm64. 242 + 243 + TPM2 Signature Reserved (signature == "TPM2") 244 + == Trusted Platform Module 2 table == 245 + Optional, not currently supported, and may need changes to fully 246 + interoperate with arm64. 247 + 248 + UEFI Signature Reserved (signature == "UEFI") 249 + == UEFI ACPI data table == 250 + Optional, not currently supported. No known use case for arm64, 251 + at present. 252 + 253 + WAET Signature Reserved (signature == "WAET") 254 + == Windows ACPI Emulated devices Table == 255 + Microsoft only table, will not be supported. 256 + 257 + WDAT Signature Reserved (signature == "WDAT") 258 + == Watch Dog Action Table == 259 + Microsoft only table, will not be supported. 260 + 261 + WDRT Signature Reserved (signature == "WDRT") 262 + == Watch Dog Resource Table == 263 + Microsoft only table, will not be supported. 264 + 265 + WPBT Signature Reserved (signature == "WPBT") 266 + == Windows Platform Binary Table == 267 + Microsoft only table, will not be supported. 268 + 269 + XSDT Section 5.2.8 (signature == "XSDT") 270 + == eXtended System Description Table == 271 + Required for arm64. 272 + 273 + 274 + ACPI Objects 275 + ------------ 276 + The expectations on individual ACPI objects are discussed in the list that 277 + follows: 278 + 279 + Name Section Usage for ARMv8 Linux 280 + ---- ------------ ------------------------------------------------- 281 + _ADR 6.1.1 Use as needed. 282 + 283 + _BBN 6.5.5 Use as needed; PCI-specific. 284 + 285 + _BDN 6.5.3 Optional; not likely to be used on arm64. 286 + 287 + _CCA 6.2.17 This method should be defined for all bus masters 288 + on arm64. While cache coherency is assumed, making 289 + it explicit ensures the kernel will set up DMA as 290 + it should. 291 + 292 + _CDM 6.2.1 Optional, to be used only for processor devices. 293 + 294 + _CID 6.1.2 Use as needed. 295 + 296 + _CLS 6.1.3 Use as needed. 297 + 298 + _CRS 6.2.2 Required on arm64. 299 + 300 + _DCK 6.5.2 Optional; not likely to be used on arm64. 301 + 302 + _DDN 6.1.4 This field can be used for a device name. However, 303 + it is meant for DOS device names (e.g., COM1), so be 304 + careful of its use across OSes. 305 + 306 + _DEP 6.5.8 Use as needed. 307 + 308 + _DIS 6.2.3 Optional, for power management use. 309 + 310 + _DLM 5.7.5 Optional. 311 + 312 + _DMA 6.2.4 Optional. 313 + 314 + _DSD 6.2.5 To be used with caution. If this object is used, try 315 + to use it within the constraints already defined by the 316 + Device Properties UUID. Only in rare circumstances 317 + should it be necessary to create a new _DSD UUID. 318 + 319 + In either case, submit the _DSD definition along with 320 + any driver patches for discussion, especially when 321 + device properties are used. A driver will not be 322 + considered complete without a corresponding _DSD 323 + description. Once approved by kernel maintainers, 324 + the UUID or device properties must then be registered 325 + with the UEFI Forum; this may cause some iteration as 326 + more than one OS will be registering entries. 327 + 328 + _DSM Do not use this method. It is not standardized, the 329 + return values are not well documented, and it is 330 + currently a frequent source of error. 331 + 332 + _DSW 7.2.1 Use as needed; power management specific. 333 + 334 + _EDL 6.3.1 Optional. 335 + 336 + _EJD 6.3.2 Optional. 337 + 338 + _EJx 6.3.3 Optional. 339 + 340 + _FIX 6.2.7 x86 specific, not used on arm64. 341 + 342 + \_GL 5.7.1 This object is not to be used in hardware reduced 343 + mode, and therefore should not be used on arm64. 344 + 345 + _GLK 6.5.7 This object requires a global lock be defined; there 346 + is no global lock on arm64 since it runs in hardware 347 + reduced mode. Hence, do not use this object on arm64. 348 + 349 + \_GPE 5.3.1 This namespace is for x86 use only. Do not use it 350 + on arm64. 351 + 352 + _GSB 6.2.7 Optional. 353 + 354 + _HID 6.1.5 Use as needed. This is the primary object to use in 355 + device probing, though _CID and _CLS may also be used. 356 + 357 + _HPP 6.2.8 Optional, PCI specific. 358 + 359 + _HPX 6.2.9 Optional, PCI specific. 360 + 361 + _HRV 6.1.6 Optional, use as needed to clarify device behavior; in 362 + some cases, this may be easier to use than _DSD. 363 + 364 + _INI 6.5.1 Not required, but can be useful in setting up devices 365 + when UEFI leaves them in a state that may not be what 366 + the driver expects before it starts probing. 367 + 368 + _IRC 7.2.15 Use as needed; power management specific. 369 + 370 + _LCK 6.3.4 Optional. 371 + 372 + _MAT 6.2.10 Optional; see also the MADT. 373 + 374 + _MLS 6.1.7 Optional, but highly recommended for use in 375 + internationalization. 376 + 377 + _OFF 7.1.2 It is recommended to define this method for any device 378 + that can be turned on or off. 379 + 380 + _ON 7.1.3 It is recommended to define this method for any device 381 + that can be turned on or off. 382 + 383 + \_OS 5.7.3 This method will return "Linux" by default (this is 384 + the value of the macro ACPI_OS_NAME on Linux). The 385 + command line parameter acpi_os=<string> can be used 386 + to set it to some other value. 387 + 388 + _OSC 6.2.11 This method can be a global method in ACPI (i.e., 389 + \_SB._OSC), or it may be associated with a specific 390 + device (e.g., \_SB.DEV0._OSC), or both. When used 391 + as a global method, only capabilities published in 392 + the ACPI specification are allowed. When used as 393 + a device-specific method, the process described for 394 + using _DSD MUST be used to create an _OSC definition; 395 + out-of-process use of _OSC is not allowed. That is, 396 + submit the device-specific _OSC usage description as 397 + part of the kernel driver submission, get it approved 398 + by the kernel community, then register it with the 399 + UEFI Forum. 400 + 401 + \_OSI 5.7.2 Deprecated on ARM64. Any invocation of this method 402 + will print a warning on the console and return false. 403 + That is, as far as ACPI firmware is concerned, _OSI 404 + cannot be used to determine what sort of system is 405 + being used or what functionality is provided. The 406 + _OSC method is to be used instead. 407 + 408 + _OST 6.3.5 Optional. 409 + 410 + _PDC 8.4.1 Deprecated, do not use on arm64. 411 + 412 + \_PIC 5.8.1 The method should not be used. On arm64, the only 413 + interrupt model available is GIC. 414 + 415 + _PLD 6.1.8 Optional. 416 + 417 + \_PR 5.3.1 This namespace is for x86 use only on legacy systems. 418 + Do not use it on arm64. 419 + 420 + _PRS 6.2.12 Optional. 421 + 422 + _PRT 6.2.13 Required as part of the definition of all PCI root 423 + devices. 424 + 425 + _PRW 7.2.13 Use as needed; power management specific. 426 + 427 + _PRx 7.2.8-11 Use as needed; power management specific. If _PR0 is 428 + defined, _PR3 must also be defined. 429 + 430 + _PSC 7.2.6 Use as needed; power management specific. 431 + 432 + _PSE 7.2.7 Use as needed; power management specific. 433 + 434 + _PSW 7.2.14 Use as needed; power management specific. 435 + 436 + _PSx 7.2.2-5 Use as needed; power management specific. If _PS0 is 437 + defined, _PS3 must also be defined. If clocks or 438 + regulators need adjusting to be consistent with power 439 + usage, change them in these methods. 440 + 441 + \_PTS 7.3.1 Use as needed; power management specific. 442 + 443 + _PXM 6.2.14 Optional. 444 + 445 + _REG 6.5.4 Use as needed. 446 + 447 + \_REV 5.7.4 Always returns the latest version of ACPI supported. 448 + 449 + _RMV 6.3.6 Optional. 450 + 451 + \_SB 5.3.1 Required on arm64; all devices must be defined in this 452 + namespace. 453 + 454 + _SEG 6.5.6 Use as needed; PCI-specific. 455 + 456 + \_SI 5.3.1, Optional. 457 + 9.1 458 + 459 + _SLI 6.2.15 Optional; recommended when SLIT table is in use. 460 + 461 + _STA 6.3.7, It is recommended to define this method for any device 462 + 7.1.4 that can be turned on or off. 463 + 464 + _SRS 6.2.16 Optional; see also _PRS. 465 + 466 + _STR 6.1.10 Recommended for conveying device names to end users; 467 + this is preferred over using _DDN. 468 + 469 + _SUB 6.1.9 Use as needed; _HID or _CID are preferred. 470 + 471 + _SUN 6.1.11 Optional. 472 + 473 + \_Sx 7.3.2 Use as needed; power management specific. 474 + 475 + _SxD 7.2.16-19 Use as needed; power management specific. 476 + 477 + _SxW 7.2.20-24 Use as needed; power management specific. 478 + 479 + _SWS 7.3.3 Use as needed; power management specific; this may 480 + require specification changes for use on arm64. 481 + 482 + \_TTS 7.3.4 Use as needed; power management specific. 483 + 484 + \_TZ 5.3.1 Optional. 485 + 486 + _UID 6.1.12 Recommended for distinguishing devices of the same 487 + class; define it if at all possible. 488 + 489 + \_WAK 7.3.5 Use as needed; power management specific. 490 + 491 + 492 + ACPI Event Model 493 + ---------------- 494 + Do not use GPE block devices; these are not supported in the hardware reduced 495 + profile used by arm64. Since there are no GPE blocks defined for use on ARM 496 + platforms, GPIO-signaled interrupts should be used for creating system events. 497 + 498 + 499 + ACPI Processor Control 500 + ---------------------- 501 + Section 8 of the ACPI specification is currently undergoing change that 502 + should be completed in the 6.0 version of the specification. Processor 503 + performance control will be handled differently for arm64 at that point 504 + in time. Processor aggregator devices (section 8.5) will not be used, 505 + for example, but another similar mechanism instead. 506 + 507 + While UEFI constrains what we can say until the release of 6.0, it is 508 + recommended that CPPC (8.4.5) be used as the primary model. This will 509 + still be useful into the future. C-states and P-states will still be 510 + provided, but most of the current design work appears to favor CPPC. 511 + 512 + Further, it is essential that the ARMv8 SoC provide a fully functional 513 + implementation of PSCI; this will be the only mechanism supported by ACPI 514 + to control CPU power state (including secondary CPU booting). 515 + 516 + More details will be provided on the release of the ACPI 6.0 specification. 517 + 518 + 519 + ACPI System Address Map Interfaces 520 + ---------------------------------- 521 + In Section 15 of the ACPI specification, several methods are mentioned as 522 + possible mechanisms for conveying memory resource information to the kernel. 523 + For arm64, we will only support UEFI for booting with ACPI, hence the UEFI 524 + GetMemoryMap() boot service is the only mechanism that will be used. 525 + 526 + 527 + ACPI Platform Error Interfaces (APEI) 528 + ------------------------------------- 529 + The APEI tables supported are described above. 530 + 531 + APEI requires the equivalent of an SCI and an NMI on ARMv8. The SCI is used 532 + to notify the OSPM of errors that have occurred but can be corrected and the 533 + system can continue correct operation, even if possibly degraded. The NMI is 534 + used to indicate fatal errors that cannot be corrected, and require immediate 535 + attention. 536 + 537 + Since there is no direct equivalent of the x86 SCI or NMI, arm64 handles 538 + these slightly differently. The SCI is handled as a normal GPIO-signaled 539 + interrupt; given that these are corrected (or correctable) errors being 540 + reported, this is sufficient. The NMI is emulated as the highest priority 541 + GPIO-signaled interrupt possible. This implies some caution must be used 542 + since there could be interrupts at higher privilege levels or even interrupts 543 + at the same priority as the emulated NMI. In Linux, this should not be the 544 + case but one should be aware it could happen. 545 + 546 + 547 + ACPI Objects Not Supported on ARM64 548 + ----------------------------------- 549 + While this may change in the future, there are several classes of objects 550 + that can be defined, but are not currently of general interest to ARM servers. 551 + 552 + These are not supported: 553 + 554 + -- Section 9.2: ambient light sensor devices 555 + 556 + -- Section 9.3: battery devices 557 + 558 + -- Section 9.4: lids (e.g., laptop lids) 559 + 560 + -- Section 9.8.2: IDE controllers 561 + 562 + -- Section 9.9: floppy controllers 563 + 564 + -- Section 9.10: GPE block devices 565 + 566 + -- Section 9.15: PC/AT RTC/CMOS devices 567 + 568 + -- Section 9.16: user presence detection devices 569 + 570 + -- Section 9.17: I/O APIC devices; all GICs must be enumerable via MADT 571 + 572 + -- Section 9.18: time and alarm devices (see 9.15) 573 + 574 + 575 + ACPI Objects Not Yet Implemented 576 + -------------------------------- 577 + While these objects have x86 equivalents, and they do make some sense in ARM 578 + servers, there is either no hardware available at present, or in some cases 579 + there may not yet be a non-ARM implementation. Hence, they are currently not 580 + implemented though that may change in the future. 581 + 582 + Not yet implemented are: 583 + 584 + -- Section 10: power source and power meter devices 585 + 586 + -- Section 11: thermal management 587 + 588 + -- Section 12: embedded controllers interface 589 + 590 + -- Section 13: SMBus interfaces 591 + 592 + -- Section 17: NUMA support (prototypes have been submitted for 593 + review)
+505
Documentation/arm64/arm-acpi.txt
··· 1 + ACPI on ARMv8 Servers 2 + --------------------- 3 + ACPI can be used for ARMv8 general purpose servers designed to follow 4 + the ARM SBSA (Server Base System Architecture) [0] and SBBR (Server 5 + Base Boot Requirements) [1] specifications. Please note that the SBBR 6 + can be retrieved simply by visiting [1], but the SBSA is currently only 7 + available to those with an ARM login due to ARM IP licensing concerns. 8 + 9 + The ARMv8 kernel implements the reduced hardware model of ACPI version 10 + 5.1 or later. Links to the specification and all external documents 11 + it refers to are managed by the UEFI Forum. The specification is 12 + available at http://www.uefi.org/specifications and documents referenced 13 + by the specification can be found via http://www.uefi.org/acpi. 14 + 15 + If an ARMv8 system does not meet the requirements of the SBSA and SBBR, 16 + or cannot be described using the mechanisms defined in the required ACPI 17 + specifications, then ACPI may not be a good fit for the hardware. 18 + 19 + While the documents mentioned above set out the requirements for building 20 + industry-standard ARMv8 servers, they also apply to more than one operating 21 + system. The purpose of this document is to describe the interaction between 22 + ACPI and Linux only, on an ARMv8 system -- that is, what Linux expects of 23 + ACPI and what ACPI can expect of Linux. 24 + 25 + 26 + Why ACPI on ARM? 27 + ---------------- 28 + Before examining the details of the interface between ACPI and Linux, it is 29 + useful to understand why ACPI is being used. Several technologies already 30 + exist in Linux for describing non-enumerable hardware, after all. In this 31 + section we summarize a blog post [2] from Grant Likely that outlines the 32 + reasoning behind ACPI on ARMv8 servers. Actually, we snitch a good portion 33 + of the summary text almost directly, to be honest. 34 + 35 + The short form of the rationale for ACPI on ARM is: 36 + 37 + -- ACPI’s bytecode (AML) allows the platform to encode hardware behavior, 38 + 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 60 + longer any reason to feel that ACPI is only belongs to Windows or that 61 + 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 64 + changes being made to ACPI is being driven by Linux. 65 + 66 + Key to the use of ACPI is the support model. For servers in general, the 67 + responsibility for hardware behaviour cannot solely be the domain of the 68 + kernel, but rather must be split between the platform and the kernel, in 69 + order to allow for orderly change over time. ACPI frees the OS from needing 70 + to understand all the minute details of the hardware so that the OS doesn’t 71 + need to be ported to each and every device individually. It allows the 72 + hardware vendors to take responsibility for power management behaviour without 73 + depending on an OS release cycle which is not under their control. 74 + 75 + ACPI is also important because hardware and OS vendors have already worked 76 + out the mechanisms for supporting a general purpose computing ecosystem. The 77 + infrastructure is in place, the bindings are in place, and the processes are 78 + in place. DT does exactly what Linux needs it to when working with vertically 79 + integrated devices, but there are no good processes for supporting what the 80 + server vendors need. Linux could potentially get there with DT, but doing so 81 + really just duplicates something that already works. ACPI already does what 82 + the hardware vendors need, Microsoft won’t collaborate on DT, and hardware 83 + vendors would still end up providing two completely separate firmware 84 + interfaces -- one for Linux and one for Windows. 85 + 86 + 87 + Kernel Compatibility 88 + -------------------- 89 + One of the primary motivations for ACPI is standardization, and using that 90 + to provide backward compatibility for Linux kernels. In the server market, 91 + software and hardware are often used for long periods. ACPI allows the 92 + kernel and firmware to agree on a consistent abstraction that can be 93 + maintained over time, even as hardware or software change. As long as the 94 + abstraction is supported, systems can be updated without necessarily having 95 + to replace the kernel. 96 + 97 + When a Linux driver or subsystem is first implemented using ACPI, it by 98 + definition ends up requiring a specific version of the ACPI specification 99 + -- it's baseline. ACPI firmware must continue to work, even though it may 100 + not be optimal, with the earliest kernel version that first provides support 101 + for that baseline version of ACPI. There may be a need for additional drivers, 102 + but adding new functionality (e.g., CPU power management) should not break 103 + older kernel versions. Further, ACPI firmware must also work with the most 104 + recent version of the kernel. 105 + 106 + 107 + Relationship with Device Tree 108 + ----------------------------- 109 + ACPI support in drivers and subsystems for ARMv8 should never be mutually 110 + exclusive with DT support at compile time. 111 + 112 + At boot time the kernel will only use one description method depending on 113 + parameters passed from the bootloader (including kernel bootargs). 114 + 115 + Regardless of whether DT or ACPI is used, the kernel must always be capable 116 + of booting with either scheme (in kernels with both schemes enabled at compile 117 + time). 118 + 119 + 120 + Booting using ACPI tables 121 + ------------------------- 122 + The only defined method for passing ACPI tables to the kernel on ARMv8 123 + is via the UEFI system configuration table. Just so it is explicit, this 124 + means that ACPI is only supported on platforms that boot via UEFI. 125 + 126 + When an ARMv8 system boots, it can either have DT information, ACPI tables, 127 + or in some very unusual cases, both. If no command line parameters are used, 128 + the kernel will try to use DT for device enumeration; if there is no DT 129 + present, the kernel will try to use ACPI tables, but only if they are present. 130 + In neither is available, the kernel will not boot. If acpi=force is used 131 + on the command line, the kernel will attempt to use ACPI tables first, but 132 + fall back to DT if there are no ACPI tables present. The basic idea is that 133 + the kernel will not fail to boot unless it absolutely has no other choice. 134 + 135 + Processing of ACPI tables may be disabled by passing acpi=off on the kernel 136 + command line; this is the default behavior. 137 + 138 + In order for the kernel to load and use ACPI tables, the UEFI implementation 139 + MUST set the ACPI_20_TABLE_GUID to point to the RSDP table (the table with 140 + the ACPI signature "RSD PTR "). If this pointer is incorrect and acpi=force 141 + is used, the kernel will disable ACPI and try to use DT to boot instead; the 142 + kernel has, in effect, determined that ACPI tables are not present at that 143 + point. 144 + 145 + If the pointer to the RSDP table is correct, the table will be mapped into 146 + the kernel by the ACPI core, using the address provided by UEFI. 147 + 148 + The ACPI core will then locate and map in all other ACPI tables provided by 149 + using the addresses in the RSDP table to find the XSDT (eXtended System 150 + Description Table). The XSDT in turn provides the addresses to all other 151 + ACPI tables provided by the system firmware; the ACPI core will then traverse 152 + this table and map in the tables listed. 153 + 154 + The ACPI core will ignore any provided RSDT (Root System Description Table). 155 + RSDTs have been deprecated and are ignored on arm64 since they only allow 156 + for 32-bit addresses. 157 + 158 + Further, 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 160 + be ignored on arm64. 161 + 162 + Hardware reduced mode (see Section 4.1 of the ACPI 5.1 specification) will 163 + be enforced by the ACPI core on arm64. Doing so allows the ACPI core to 164 + run less complex code since it no longer has to provide support for legacy 165 + hardware from other architectures. Any fields that are not to be used for 166 + hardware reduced mode must be set to zero. 167 + 168 + For the ACPI core to operate properly, and in turn provide the information 169 + the kernel needs to configure devices, it expects to find the following 170 + tables (all section numbers refer to the ACPI 5.1 specfication): 171 + 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 + 188 + If the above tables are not all present, the kernel may or may not be 189 + able to boot properly since it may not be able to configure all of the 190 + devices available. 191 + 192 + 193 + ACPI Detection 194 + -------------- 195 + Drivers should determine their probe() type by checking for a null 196 + value for ACPI_HANDLE, or checking .of_node, or other information in 197 + the device structure. This is detailed further in the "Driver 198 + Recommendations" section. 199 + 200 + In non-driver code, if the presence of ACPI needs to be detected at 201 + runtime, then check the value of acpi_disabled. If CONFIG_ACPI is not 202 + set, acpi_disabled will always be 1. 203 + 204 + 205 + Device Enumeration 206 + ------------------ 207 + Device descriptions in ACPI should use standard recognized ACPI interfaces. 208 + These may contain less information than is typically provided via a Device 209 + Tree description for the same device. This is also one of the reasons that 210 + ACPI can be useful -- the driver takes into account that it may have less 211 + detailed information about the device and uses sensible defaults instead. 212 + If done properly in the driver, the hardware can change and improve over 213 + time without the driver having to change at all. 214 + 215 + Clocks provide an excellent example. In DT, clocks need to be specified 216 + and the drivers need to take them into account. In ACPI, the assumption 217 + is that UEFI will leave the device in a reasonable default state, including 218 + any clock settings. If for some reason the driver needs to change a clock 219 + value, this can be done in an ACPI method; all the driver needs to do is 220 + invoke the method and not concern itself with what the method needs to do 221 + to change the clock. Changing the hardware can then take place over time 222 + by changing what the ACPI method does, and not the driver. 223 + 224 + In DT, the parameters needed by the driver to set up clocks as in the example 225 + above are known as "bindings"; in ACPI, these are known as "Device Properties" 226 + and provided to a driver via the _DSD object. 227 + 228 + ACPI tables are described with a formal language called ASL, the ACPI 229 + Source Language (section 19 of the specification). This means that there 230 + are always multiple ways to describe the same thing -- including device 231 + properties. For example, device properties could use an ASL construct 232 + that looks like this: Name(KEY0, "value0"). An ACPI device driver would 233 + then retrieve the value of the property by evaluating the KEY0 object. 234 + However, using Name() this way has multiple problems: (1) ACPI limits 235 + names ("KEY0") to four characters unlike DT; (2) there is no industry 236 + wide registry that maintains a list of names, minimzing re-use; (3) 237 + there is also no registry for the definition of property values ("value0"), 238 + again making re-use difficult; and (4) how does one maintain backward 239 + compatibility as new hardware comes out? The _DSD method was created 240 + to solve precisely these sorts of problems; Linux drivers should ALWAYS 241 + use the _DSD method for device properties and nothing else. 242 + 243 + The _DSM object (ACPI Section 9.14.1) could also be used for conveying 244 + device properties to a driver. Linux drivers should only expect it to 245 + be used if _DSD cannot represent the data required, and there is no way 246 + to create a new UUID for the _DSD object. Note that there is even less 247 + regulation of the use of _DSM than there is of _DSD. Drivers that depend 248 + on the contents of _DSM objects will be more difficult to maintain over 249 + time because of this; as of this writing, the use of _DSM is the cause 250 + of quite a few firmware problems and is not recommended. 251 + 252 + Drivers should look for device properties in the _DSD object ONLY; the _DSD 253 + object is described in the ACPI specification section 6.2.5, but this only 254 + describes how to define the structure of an object returned via _DSD, and 255 + how specific data structures are defined by specific UUIDs. Linux should 256 + only use the _DSD Device Properties UUID [5]: 257 + 258 + -- UUID: daffd814-6eba-4d8c-8a91-bc9bbf4aa301 259 + 260 + -- http://www.uefi.org/sites/default/files/resources/_DSD-device-properties-UUID.pdf 261 + 262 + The UEFI Forum provides a mechanism for registering device properties [4] 263 + so that they may be used across all operating systems supporting ACPI. 264 + Device properties that have not been registered with the UEFI Forum should 265 + not be used. 266 + 267 + Before creating new device properties, check to be sure that they have not 268 + been defined before and either registered in the Linux kernel documentation 269 + as DT bindings, or the UEFI Forum as device properties. While we do not want 270 + to simply move all DT bindings into ACPI device properties, we can learn from 271 + what has been previously defined. 272 + 273 + If it is necessary to define a new device property, or if it makes sense to 274 + synthesize the definition of a binding so it can be used in any firmware, 275 + both DT bindings and ACPI device properties for device drivers have review 276 + processes. Use them both. When the driver itself is submitted for review 277 + to the Linux mailing lists, the device property definitions needed must be 278 + submitted at the same time. A driver that supports ACPI and uses device 279 + properties will not be considered complete without their definitions. Once 280 + the device property has been accepted by the Linux community, it must be 281 + registered with the UEFI Forum [4], which will review it again for consistency 282 + within the registry. This may require iteration. The UEFI Forum, though, 283 + will always be the canonical site for device property definitions. 284 + 285 + It may make sense to provide notice to the UEFI Forum that there is the 286 + intent to register a previously unused device property name as a means of 287 + reserving the name for later use. Other operating system vendors will 288 + also be submitting registration requests and this may help smooth the 289 + process. 290 + 291 + Once registration and review have been completed, the kernel provides an 292 + interface for looking up device properties in a manner independent of 293 + whether DT or ACPI is being used. This API should be used [6]; it can 294 + eliminate some duplication of code paths in driver probing functions and 295 + discourage divergence between DT bindings and ACPI device properties. 296 + 297 + 298 + Programmable Power Control Resources 299 + ------------------------------------ 300 + Programmable power control resources include such resources as voltage/current 301 + providers (regulators) and clock sources. 302 + 303 + With ACPI, the kernel clock and regulator framework is not expected to be used 304 + at all. 305 + 306 + The kernel assumes that power control of these resources is represented with 307 + Power Resource Objects (ACPI section 7.1). The ACPI core will then handle 308 + correctly enabling and disabling resources as they are needed. In order to 309 + get that to work, ACPI assumes each device has defined D-states and that these 310 + can be controlled through the optional ACPI methods _PS0, _PS1, _PS2, and _PS3; 311 + in ACPI, _PS0 is the method to invoke to turn a device full on, and _PS3 is for 312 + turning a device full off. 313 + 314 + There are two options for using those Power Resources. They can: 315 + 316 + -- be managed in a _PSx method which gets called on entry to power 317 + state Dx. 318 + 319 + -- be declared separately as power resources with their own _ON and _OFF 320 + methods. They are then tied back to D-states for a particular device 321 + via _PRx which specifies which power resources a device needs to be on 322 + while in Dx. Kernel then tracks number of devices using a power resource 323 + and calls _ON/_OFF as needed. 324 + 325 + The kernel ACPI code will also assume that the _PSx methods follow the normal 326 + ACPI rules for such methods: 327 + 328 + -- If either _PS0 or _PS3 is implemented, then the other method must also 329 + be implemented. 330 + 331 + -- If a device requires usage or setup of a power resource when on, the ASL 332 + should organize that it is allocated/enabled using the _PS0 method. 333 + 334 + -- Resources allocated or enabled in the _PS0 method should be disabled 335 + or de-allocated in the _PS3 method. 336 + 337 + -- Firmware will leave the resources in a reasonable state before handing 338 + over control to the kernel. 339 + 340 + Such code in _PSx methods will of course be very platform specific. But, 341 + this allows the driver to abstract out the interface for operating the device 342 + and avoid having to read special non-standard values from ACPI tables. Further, 343 + abstracting the use of these resources allows the hardware to change over time 344 + without requiring updates to the driver. 345 + 346 + 347 + Clocks 348 + ------ 349 + ACPI makes the assumption that clocks are initialized by the firmware -- 350 + UEFI, in this case -- to some working value before control is handed over 351 + to the kernel. This has implications for devices such as UARTs, or SoC-driven 352 + LCD displays, for example. 353 + 354 + When the kernel boots, the clocks are assumed to be set to reasonable 355 + working values. If for some reason the frequency needs to change -- e.g., 356 + throttling for power management -- the device driver should expect that 357 + process to be abstracted out into some ACPI method that can be invoked 358 + (please see the ACPI specification for further recommendations on standard 359 + methods to be expected). The only exceptions to this are CPU clocks where 360 + CPPC provides a much richer interface than ACPI methods. If the clocks 361 + are not set, there is no direct way for Linux to control them. 362 + 363 + If an SoC vendor wants to provide fine-grained control of the system clocks, 364 + they could do so by providing ACPI methods that could be invoked by Linux 365 + drivers. However, this is NOT recommended and Linux drivers should NOT use 366 + such methods, even if they are provided. Such methods are not currently 367 + standardized in the ACPI specification, and using them could tie a kernel 368 + to a very specific SoC, or tie an SoC to a very specific version of the 369 + kernel, both of which we are trying to avoid. 370 + 371 + 372 + Driver Recommendations 373 + ---------------------- 374 + DO NOT remove any DT handling when adding ACPI support for a driver. The 375 + same device may be used on many different systems. 376 + 377 + DO try to structure the driver so that it is data-driven. That is, set up 378 + a struct containing internal per-device state based on defaults and whatever 379 + else must be discovered by the driver probe function. Then, have the rest 380 + of the driver operate off of the contents of that struct. Doing so should 381 + allow most divergence between ACPI and DT functionality to be kept local to 382 + the probe function instead of being scattered throughout the driver. For 383 + example: 384 + 385 + static int device_probe_dt(struct platform_device *pdev) 386 + { 387 + /* DT specific functionality */ 388 + ... 389 + } 390 + 391 + static int device_probe_acpi(struct platform_device *pdev) 392 + { 393 + /* ACPI specific functionality */ 394 + ... 395 + } 396 + 397 + static int device_probe(struct platform_device *pdev) 398 + { 399 + ... 400 + struct device_node node = pdev->dev.of_node; 401 + ... 402 + 403 + if (node) 404 + ret = device_probe_dt(pdev); 405 + else if (ACPI_HANDLE(&pdev->dev)) 406 + ret = device_probe_acpi(pdev); 407 + else 408 + /* other initialization */ 409 + ... 410 + /* Continue with any generic probe operations */ 411 + ... 412 + } 413 + 414 + DO keep the MODULE_DEVICE_TABLE entries together in the driver to make it 415 + clear the different names the driver is probed for, both from DT and from 416 + ACPI: 417 + 418 + static struct of_device_id virtio_mmio_match[] = { 419 + { .compatible = "virtio,mmio", }, 420 + { } 421 + }; 422 + MODULE_DEVICE_TABLE(of, virtio_mmio_match); 423 + 424 + static const struct acpi_device_id virtio_mmio_acpi_match[] = { 425 + { "LNRO0005", }, 426 + { } 427 + }; 428 + MODULE_DEVICE_TABLE(acpi, virtio_mmio_acpi_match); 429 + 430 + 431 + ASWG 432 + ---- 433 + The ACPI specification changes regularly. During the year 2014, for instance, 434 + version 5.1 was released and version 6.0 substantially completed, with most of 435 + the changes being driven by ARM-specific requirements. Proposed changes are 436 + presented and discussed in the ASWG (ACPI Specification Working Group) which 437 + is a part of the UEFI Forum. 438 + 439 + Participation in this group is open to all UEFI members. Please see 440 + http://www.uefi.org/workinggroup for details on group membership. 441 + 442 + It is the intent of the ARMv8 ACPI kernel code to follow the ACPI specification 443 + as closely as possible, and to only implement functionality that complies with 444 + the released standards from UEFI ASWG. As a practical matter, there will be 445 + vendors that provide bad ACPI tables or violate the standards in some way. 446 + If this is because of errors, quirks and fixups may be necessary, but will 447 + be avoided if possible. If there are features missing from ACPI that preclude 448 + it from being used on a platform, ECRs (Engineering Change Requests) should be 449 + submitted to ASWG and go through the normal approval process; for those that 450 + are not UEFI members, many other members of the Linux community are and would 451 + likely be willing to assist in submitting ECRs. 452 + 453 + 454 + Linux Code 455 + ---------- 456 + Individual items specific to Linux on ARM, contained in the the Linux 457 + source code, are in the list that follows: 458 + 459 + ACPI_OS_NAME This macro defines the string to be returned when 460 + an ACPI method invokes the _OS method. On ARM64 461 + systems, this macro will be "Linux" by default. 462 + The command line parameter acpi_os=<string> 463 + can be used to set it to some other value. The 464 + default value for other architectures is "Microsoft 465 + Windows NT", for example. 466 + 467 + ACPI Objects 468 + ------------ 469 + Detailed expectations for ACPI tables and object are listed in the file 470 + Documentation/arm64/acpi_object_usage.txt. 471 + 472 + 473 + References 474 + ---------- 475 + [0] http://silver.arm.com -- document ARM-DEN-0029, or newer 476 + "Server Base System Architecture", version 2.3, dated 27 Mar 2014 477 + 478 + [1] http://infocenter.arm.com/help/topic/com.arm.doc.den0044a/Server_Base_Boot_Requirements.pdf 479 + Document ARM-DEN-0044A, or newer: "Server Base Boot Requirements, System 480 + Software on ARM Platforms", dated 16 Aug 2014 481 + 482 + [2] http://www.secretlab.ca/archives/151, 10 Jan 2015, Copyright (c) 2015, 483 + Linaro Ltd., written by Grant Likely. A copy of the verbatim text (apart 484 + from formatting) is also in Documentation/arm64/why_use_acpi.txt. 485 + 486 + [3] AMD ACPI for Seattle platform documentation: 487 + http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2012/10/Seattle_ACPI_Guide.pdf 488 + 489 + [4] http://www.uefi.org/acpi -- please see the link for the "ACPI _DSD Device 490 + Property Registry Instructions" 491 + 492 + [5] http://www.uefi.org/acpi -- please see the link for the "_DSD (Device 493 + Specific Data) Implementation Guide" 494 + 495 + [6] Kernel code for the unified device property interface can be found in 496 + include/linux/property.h and drivers/base/property.c. 497 + 498 + 499 + Authors 500 + ------- 501 + Al Stone <al.stone@linaro.org> 502 + Graeme Gregory <graeme.gregory@linaro.org> 503 + Hanjun Guo <hanjun.guo@linaro.org> 504 + 505 + Grant Likely <grant.likely@linaro.org>, for the "Why ACPI on ARM?" section
+2 -1
Documentation/kernel-parameters.txt
··· 165 165 bytes respectively. Such letter suffixes can also be entirely omitted. 166 166 167 167 168 - acpi= [HW,ACPI,X86] 168 + acpi= [HW,ACPI,X86,ARM64] 169 169 Advanced Configuration and Power Interface 170 170 Format: { force | off | strict | noirq | rsdt } 171 171 force -- enable ACPI if default was off ··· 175 175 strictly ACPI specification compliant. 176 176 rsdt -- prefer RSDT over (default) XSDT 177 177 copy_dsdt -- copy DSDT to memory 178 + For ARM64, ONLY "acpi=off" or "acpi=force" are available 178 179 179 180 See also Documentation/power/runtime_pm.txt, pci=noacpi 180 181
+4
arch/arm64/Kconfig
··· 1 1 config ARM64 2 2 def_bool y 3 + select ACPI_GENERIC_GSI if ACPI 4 + select ACPI_REDUCED_HARDWARE_ONLY if ACPI 3 5 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE 4 6 select ARCH_HAS_ELF_RANDOMIZE 5 7 select ARCH_HAS_GCOV_PROFILE_ALL ··· 759 757 source "drivers/Kconfig" 760 758 761 759 source "drivers/firmware/Kconfig" 760 + 761 + source "drivers/acpi/Kconfig" 762 762 763 763 source "fs/Kconfig" 764 764
+18
arch/arm64/include/asm/acenv.h
··· 1 + /* 2 + * ARM64 specific ACPICA environments and implementation 3 + * 4 + * Copyright (C) 2014, Linaro Ltd. 5 + * Author: Hanjun Guo <hanjun.guo@linaro.org> 6 + * Author: Graeme Gregory <graeme.gregory@linaro.org> 7 + * 8 + * This program is free software; you can redistribute it and/or modify 9 + * it under the terms of the GNU General Public License version 2 as 10 + * published by the Free Software Foundation. 11 + */ 12 + 13 + #ifndef _ASM_ACENV_H 14 + #define _ASM_ACENV_H 15 + 16 + /* It is required unconditionally by ACPI core, update it when needed. */ 17 + 18 + #endif /* _ASM_ACENV_H */
+96
arch/arm64/include/asm/acpi.h
··· 1 + /* 2 + * Copyright (C) 2013-2014, Linaro Ltd. 3 + * Author: Al Stone <al.stone@linaro.org> 4 + * Author: Graeme Gregory <graeme.gregory@linaro.org> 5 + * Author: Hanjun Guo <hanjun.guo@linaro.org> 6 + * 7 + * This program is free software; you can redistribute it and/or modify 8 + * it under the terms of the GNU General Public License version 2 as 9 + * published by the Free Software Foundation; 10 + */ 11 + 12 + #ifndef _ASM_ACPI_H 13 + #define _ASM_ACPI_H 14 + 15 + #include <linux/mm.h> 16 + #include <linux/irqchip/arm-gic-acpi.h> 17 + 18 + #include <asm/cputype.h> 19 + #include <asm/smp_plat.h> 20 + 21 + /* Basic configuration for ACPI */ 22 + #ifdef CONFIG_ACPI 23 + /* ACPI table mapping after acpi_gbl_permanent_mmap is set */ 24 + static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys, 25 + acpi_size size) 26 + { 27 + if (!page_is_ram(phys >> PAGE_SHIFT)) 28 + return ioremap(phys, size); 29 + 30 + return ioremap_cache(phys, size); 31 + } 32 + #define acpi_os_ioremap acpi_os_ioremap 33 + 34 + typedef u64 phys_cpuid_t; 35 + #define PHYS_CPUID_INVALID INVALID_HWID 36 + 37 + #define acpi_strict 1 /* No out-of-spec workarounds on ARM64 */ 38 + extern int acpi_disabled; 39 + extern int acpi_noirq; 40 + extern int acpi_pci_disabled; 41 + 42 + /* 1 to indicate PSCI 0.2+ is implemented */ 43 + static inline bool acpi_psci_present(void) 44 + { 45 + return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_COMPLIANT; 46 + } 47 + 48 + /* 1 to indicate HVC must be used instead of SMC as the PSCI conduit */ 49 + static inline bool acpi_psci_use_hvc(void) 50 + { 51 + return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC; 52 + } 53 + 54 + static inline void disable_acpi(void) 55 + { 56 + acpi_disabled = 1; 57 + acpi_pci_disabled = 1; 58 + acpi_noirq = 1; 59 + } 60 + 61 + static inline void enable_acpi(void) 62 + { 63 + acpi_disabled = 0; 64 + acpi_pci_disabled = 0; 65 + acpi_noirq = 0; 66 + } 67 + 68 + /* 69 + * The ACPI processor driver for ACPI core code needs this macro 70 + * to find out this cpu was already mapped (mapping from CPU hardware 71 + * ID to CPU logical ID) or not. 72 + */ 73 + #define cpu_physical_id(cpu) cpu_logical_map(cpu) 74 + 75 + /* 76 + * It's used from ACPI core in kdump to boot UP system with SMP kernel, 77 + * with this check the ACPI core will not override the CPU index 78 + * obtained from GICC with 0 and not print some error message as well. 79 + * Since MADT must provide at least one GICC structure for GIC 80 + * initialization, CPU will be always available in MADT on ARM64. 81 + */ 82 + static inline bool acpi_has_cpu_in_madt(void) 83 + { 84 + return true; 85 + } 86 + 87 + static inline void arch_fix_phys_package_id(int num, u32 slot) { } 88 + void __init acpi_init_cpus(void); 89 + 90 + #else 91 + static inline bool acpi_psci_present(void) { return false; } 92 + static inline bool acpi_psci_use_hvc(void) { return false; } 93 + static inline void acpi_init_cpus(void) { } 94 + #endif /* CONFIG_ACPI */ 95 + 96 + #endif /*_ASM_ACPI_H*/
+1
arch/arm64/include/asm/cpu_ops.h
··· 66 66 extern const struct cpu_operations *cpu_ops[NR_CPUS]; 67 67 int __init cpu_read_ops(struct device_node *dn, int cpu); 68 68 void __init cpu_read_bootcpu_ops(void); 69 + const struct cpu_operations *cpu_get_ops(const char *name); 69 70 70 71 #endif /* ifndef __ASM_CPU_OPS_H */
+3
arch/arm64/include/asm/fixmap.h
··· 62 62 63 63 #define __early_set_fixmap __set_fixmap 64 64 65 + #define __late_set_fixmap __set_fixmap 66 + #define __late_clear_fixmap(idx) __set_fixmap((idx), 0, FIXMAP_PAGE_CLEAR) 67 + 65 68 extern void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot); 66 69 67 70 #include <asm-generic/fixmap.h>
+13
arch/arm64/include/asm/irq.h
··· 1 1 #ifndef __ASM_IRQ_H 2 2 #define __ASM_IRQ_H 3 3 4 + #include <linux/irqchip/arm-gic-acpi.h> 5 + 4 6 #include <asm-generic/irq.h> 5 7 6 8 struct pt_regs; 7 9 8 10 extern void migrate_irqs(void); 9 11 extern void set_handle_irq(void (*handle_irq)(struct pt_regs *)); 12 + 13 + static inline void acpi_irq_init(void) 14 + { 15 + /* 16 + * Hardcode ACPI IRQ chip initialization to GICv2 for now. 17 + * Proper irqchip infrastructure will be implemented along with 18 + * incoming GICv2m|GICv3|ITS bits. 19 + */ 20 + acpi_gic_init(); 21 + } 22 + #define acpi_irq_init acpi_irq_init 10 23 11 24 #endif
+6
arch/arm64/include/asm/pci.h
··· 27 27 extern int isa_dma_bridge_buggy; 28 28 29 29 #ifdef CONFIG_PCI 30 + static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) 31 + { 32 + /* no legacy IRQ on arm64 */ 33 + return -ENODEV; 34 + } 35 + 30 36 static inline int pci_proc_domain(struct pci_bus *bus) 31 37 { 32 38 return 1;
+2 -1
arch/arm64/include/asm/psci.h
··· 14 14 #ifndef __ASM_PSCI_H 15 15 #define __ASM_PSCI_H 16 16 17 - int psci_init(void); 17 + int psci_dt_init(void); 18 + int psci_acpi_init(void); 18 19 19 20 #endif /* __ASM_PSCI_H */
+3 -2
arch/arm64/include/asm/smp.h
··· 39 39 extern void handle_IPI(int ipinr, struct pt_regs *regs); 40 40 41 41 /* 42 - * Setup the set of possible CPUs (via set_cpu_possible) 42 + * Discover the set of possible CPUs and determine their 43 + * SMP operations. 43 44 */ 44 - extern void smp_init_cpus(void); 45 + extern void of_smp_init_cpus(void); 45 46 46 47 /* 47 48 * Provide a function to raise an IPI cross call on CPUs in callmap.
+1
arch/arm64/kernel/Makefile
··· 35 35 arm64-obj-$(CONFIG_EFI) += efi.o efi-stub.o efi-entry.o 36 36 arm64-obj-$(CONFIG_PCI) += pci.o 37 37 arm64-obj-$(CONFIG_ARMV8_DEPRECATED) += armv8_deprecated.o 38 + arm64-obj-$(CONFIG_ACPI) += acpi.o 38 39 39 40 obj-y += $(arm64-obj-y) vdso/ 40 41 obj-m += $(arm64-obj-m)
+345
arch/arm64/kernel/acpi.c
··· 1 + /* 2 + * ARM64 Specific Low-Level ACPI Boot Support 3 + * 4 + * Copyright (C) 2013-2014, Linaro Ltd. 5 + * Author: Al Stone <al.stone@linaro.org> 6 + * Author: Graeme Gregory <graeme.gregory@linaro.org> 7 + * Author: Hanjun Guo <hanjun.guo@linaro.org> 8 + * Author: Tomasz Nowicki <tomasz.nowicki@linaro.org> 9 + * Author: Naresh Bhat <naresh.bhat@linaro.org> 10 + * 11 + * This program is free software; you can redistribute it and/or modify 12 + * it under the terms of the GNU General Public License version 2 as 13 + * published by the Free Software Foundation. 14 + */ 15 + 16 + #define pr_fmt(fmt) "ACPI: " fmt 17 + 18 + #include <linux/acpi.h> 19 + #include <linux/bootmem.h> 20 + #include <linux/cpumask.h> 21 + #include <linux/init.h> 22 + #include <linux/irq.h> 23 + #include <linux/irqdomain.h> 24 + #include <linux/memblock.h> 25 + #include <linux/of_fdt.h> 26 + #include <linux/smp.h> 27 + 28 + #include <asm/cputype.h> 29 + #include <asm/cpu_ops.h> 30 + #include <asm/smp_plat.h> 31 + 32 + int acpi_noirq = 1; /* skip ACPI IRQ initialization */ 33 + int acpi_disabled = 1; 34 + EXPORT_SYMBOL(acpi_disabled); 35 + 36 + int acpi_pci_disabled = 1; /* skip ACPI PCI scan and IRQ initialization */ 37 + EXPORT_SYMBOL(acpi_pci_disabled); 38 + 39 + /* Processors with enabled flag and sane MPIDR */ 40 + static int enabled_cpus; 41 + 42 + /* Boot CPU is valid or not in MADT */ 43 + static bool bootcpu_valid __initdata; 44 + 45 + static bool param_acpi_off __initdata; 46 + static bool param_acpi_force __initdata; 47 + 48 + static int __init parse_acpi(char *arg) 49 + { 50 + if (!arg) 51 + return -EINVAL; 52 + 53 + /* "acpi=off" disables both ACPI table parsing and interpreter */ 54 + if (strcmp(arg, "off") == 0) 55 + param_acpi_off = true; 56 + else if (strcmp(arg, "force") == 0) /* force ACPI to be enabled */ 57 + param_acpi_force = true; 58 + else 59 + return -EINVAL; /* Core will print when we return error */ 60 + 61 + return 0; 62 + } 63 + early_param("acpi", parse_acpi); 64 + 65 + static int __init dt_scan_depth1_nodes(unsigned long node, 66 + const char *uname, int depth, 67 + void *data) 68 + { 69 + /* 70 + * Return 1 as soon as we encounter a node at depth 1 that is 71 + * not the /chosen node. 72 + */ 73 + if (depth == 1 && (strcmp(uname, "chosen") != 0)) 74 + return 1; 75 + return 0; 76 + } 77 + 78 + /* 79 + * __acpi_map_table() will be called before page_init(), so early_ioremap() 80 + * or early_memremap() should be called here to for ACPI table mapping. 81 + */ 82 + char *__init __acpi_map_table(unsigned long phys, unsigned long size) 83 + { 84 + if (!size) 85 + return NULL; 86 + 87 + return early_memremap(phys, size); 88 + } 89 + 90 + void __init __acpi_unmap_table(char *map, unsigned long size) 91 + { 92 + if (!map || !size) 93 + return; 94 + 95 + early_memunmap(map, size); 96 + } 97 + 98 + /** 99 + * acpi_map_gic_cpu_interface - generates a logical cpu number 100 + * and map to MPIDR represented by GICC structure 101 + */ 102 + static void __init 103 + acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor) 104 + { 105 + int i; 106 + u64 mpidr = processor->arm_mpidr & MPIDR_HWID_BITMASK; 107 + bool enabled = !!(processor->flags & ACPI_MADT_ENABLED); 108 + 109 + if (mpidr == INVALID_HWID) { 110 + pr_info("Skip MADT cpu entry with invalid MPIDR\n"); 111 + return; 112 + } 113 + 114 + total_cpus++; 115 + if (!enabled) 116 + return; 117 + 118 + if (enabled_cpus >= NR_CPUS) { 119 + pr_warn("NR_CPUS limit of %d reached, Processor %d/0x%llx ignored.\n", 120 + NR_CPUS, total_cpus, mpidr); 121 + return; 122 + } 123 + 124 + /* Check if GICC structure of boot CPU is available in the MADT */ 125 + if (cpu_logical_map(0) == mpidr) { 126 + if (bootcpu_valid) { 127 + pr_err("Firmware bug, duplicate CPU MPIDR: 0x%llx in MADT\n", 128 + mpidr); 129 + return; 130 + } 131 + 132 + bootcpu_valid = true; 133 + } 134 + 135 + /* 136 + * Duplicate MPIDRs are a recipe for disaster. Scan 137 + * all initialized entries and check for 138 + * duplicates. If any is found just ignore the CPU. 139 + */ 140 + for (i = 1; i < enabled_cpus; i++) { 141 + if (cpu_logical_map(i) == mpidr) { 142 + pr_err("Firmware bug, duplicate CPU MPIDR: 0x%llx in MADT\n", 143 + mpidr); 144 + return; 145 + } 146 + } 147 + 148 + if (!acpi_psci_present()) 149 + return; 150 + 151 + cpu_ops[enabled_cpus] = cpu_get_ops("psci"); 152 + /* CPU 0 was already initialized */ 153 + if (enabled_cpus) { 154 + if (!cpu_ops[enabled_cpus]) 155 + return; 156 + 157 + if (cpu_ops[enabled_cpus]->cpu_init(NULL, enabled_cpus)) 158 + return; 159 + 160 + /* map the logical cpu id to cpu MPIDR */ 161 + cpu_logical_map(enabled_cpus) = mpidr; 162 + } 163 + 164 + enabled_cpus++; 165 + } 166 + 167 + static int __init 168 + acpi_parse_gic_cpu_interface(struct acpi_subtable_header *header, 169 + const unsigned long end) 170 + { 171 + struct acpi_madt_generic_interrupt *processor; 172 + 173 + processor = (struct acpi_madt_generic_interrupt *)header; 174 + 175 + if (BAD_MADT_ENTRY(processor, end)) 176 + return -EINVAL; 177 + 178 + acpi_table_print_madt_entry(header); 179 + acpi_map_gic_cpu_interface(processor); 180 + return 0; 181 + } 182 + 183 + /* Parse GIC cpu interface entries in MADT for SMP init */ 184 + void __init acpi_init_cpus(void) 185 + { 186 + int count, i; 187 + 188 + /* 189 + * do a partial walk of MADT to determine how many CPUs 190 + * we have including disabled CPUs, and get information 191 + * we need for SMP init 192 + */ 193 + count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT, 194 + acpi_parse_gic_cpu_interface, 0); 195 + 196 + if (!count) { 197 + pr_err("No GIC CPU interface entries present\n"); 198 + return; 199 + } else if (count < 0) { 200 + pr_err("Error parsing GIC CPU interface entry\n"); 201 + return; 202 + } 203 + 204 + if (!bootcpu_valid) { 205 + pr_err("MADT missing boot CPU MPIDR, not enabling secondaries\n"); 206 + return; 207 + } 208 + 209 + for (i = 0; i < enabled_cpus; i++) 210 + set_cpu_possible(i, true); 211 + 212 + /* Make boot-up look pretty */ 213 + pr_info("%d CPUs enabled, %d CPUs total\n", enabled_cpus, total_cpus); 214 + } 215 + 216 + /* 217 + * acpi_fadt_sanity_check() - Check FADT presence and carry out sanity 218 + * checks on it 219 + * 220 + * Return 0 on success, <0 on failure 221 + */ 222 + static int __init acpi_fadt_sanity_check(void) 223 + { 224 + struct acpi_table_header *table; 225 + struct acpi_table_fadt *fadt; 226 + acpi_status status; 227 + acpi_size tbl_size; 228 + int ret = 0; 229 + 230 + /* 231 + * FADT is required on arm64; retrieve it to check its presence 232 + * and carry out revision and ACPI HW reduced compliancy tests 233 + */ 234 + status = acpi_get_table_with_size(ACPI_SIG_FADT, 0, &table, &tbl_size); 235 + if (ACPI_FAILURE(status)) { 236 + const char *msg = acpi_format_exception(status); 237 + 238 + pr_err("Failed to get FADT table, %s\n", msg); 239 + return -ENODEV; 240 + } 241 + 242 + fadt = (struct acpi_table_fadt *)table; 243 + 244 + /* 245 + * Revision in table header is the FADT Major revision, and there 246 + * is a minor revision of FADT which was introduced by ACPI 5.1, 247 + * we only deal with ACPI 5.1 or newer revision to get GIC and SMP 248 + * boot protocol configuration data. 249 + */ 250 + if (table->revision < 5 || 251 + (table->revision == 5 && fadt->minor_revision < 1)) { 252 + pr_err("Unsupported FADT revision %d.%d, should be 5.1+\n", 253 + table->revision, fadt->minor_revision); 254 + ret = -EINVAL; 255 + goto out; 256 + } 257 + 258 + if (!(fadt->flags & ACPI_FADT_HW_REDUCED)) { 259 + pr_err("FADT not ACPI hardware reduced compliant\n"); 260 + ret = -EINVAL; 261 + } 262 + 263 + out: 264 + /* 265 + * acpi_get_table_with_size() creates FADT table mapping that 266 + * should be released after parsing and before resuming boot 267 + */ 268 + early_acpi_os_unmap_memory(table, tbl_size); 269 + return ret; 270 + } 271 + 272 + /* 273 + * acpi_boot_table_init() called from setup_arch(), always. 274 + * 1. find RSDP and get its address, and then find XSDT 275 + * 2. extract all tables and checksums them all 276 + * 3. check ACPI FADT revision 277 + * 4. check ACPI FADT HW reduced flag 278 + * 279 + * We can parse ACPI boot-time tables such as MADT after 280 + * this function is called. 281 + * 282 + * On return ACPI is enabled if either: 283 + * 284 + * - ACPI tables are initialized and sanity checks passed 285 + * - acpi=force was passed in the command line and ACPI was not disabled 286 + * explicitly through acpi=off command line parameter 287 + * 288 + * ACPI is disabled on function return otherwise 289 + */ 290 + void __init acpi_boot_table_init(void) 291 + { 292 + /* 293 + * Enable ACPI instead of device tree unless 294 + * - ACPI has been disabled explicitly (acpi=off), or 295 + * - the device tree is not empty (it has more than just a /chosen node) 296 + * and ACPI has not been force enabled (acpi=force) 297 + */ 298 + if (param_acpi_off || 299 + (!param_acpi_force && of_scan_flat_dt(dt_scan_depth1_nodes, NULL))) 300 + return; 301 + 302 + /* 303 + * ACPI is disabled at this point. Enable it in order to parse 304 + * the ACPI tables and carry out sanity checks 305 + */ 306 + enable_acpi(); 307 + 308 + /* 309 + * If ACPI tables are initialized and FADT sanity checks passed, 310 + * leave ACPI enabled and carry on booting; otherwise disable ACPI 311 + * on initialization error. 312 + * If acpi=force was passed on the command line it forces ACPI 313 + * to be enabled even if its initialization failed. 314 + */ 315 + if (acpi_table_init() || acpi_fadt_sanity_check()) { 316 + pr_err("Failed to init ACPI tables\n"); 317 + if (!param_acpi_force) 318 + disable_acpi(); 319 + } 320 + } 321 + 322 + void __init acpi_gic_init(void) 323 + { 324 + struct acpi_table_header *table; 325 + acpi_status status; 326 + acpi_size tbl_size; 327 + int err; 328 + 329 + if (acpi_disabled) 330 + return; 331 + 332 + status = acpi_get_table_with_size(ACPI_SIG_MADT, 0, &table, &tbl_size); 333 + if (ACPI_FAILURE(status)) { 334 + const char *msg = acpi_format_exception(status); 335 + 336 + pr_err("Failed to get MADT table, %s\n", msg); 337 + return; 338 + } 339 + 340 + err = gic_v2_acpi_init(table); 341 + if (err) 342 + pr_err("Failed to initialize GIC IRQ controller"); 343 + 344 + early_acpi_os_unmap_memory((char *)table, tbl_size); 345 + }
+1 -1
arch/arm64/kernel/cpu_ops.c
··· 35 35 NULL, 36 36 }; 37 37 38 - static const struct cpu_operations * __init cpu_get_ops(const char *name) 38 + const struct cpu_operations * __init cpu_get_ops(const char *name) 39 39 { 40 40 const struct cpu_operations **ops = supported_cpu_ops; 41 41
+25
arch/arm64/kernel/pci.c
··· 10 10 * 11 11 */ 12 12 13 + #include <linux/acpi.h> 13 14 #include <linux/init.h> 14 15 #include <linux/io.h> 15 16 #include <linux/kernel.h> ··· 47 46 48 47 return 0; 49 48 } 49 + 50 + /* 51 + * raw_pci_read/write - Platform-specific PCI config space access. 52 + */ 53 + int raw_pci_read(unsigned int domain, unsigned int bus, 54 + unsigned int devfn, int reg, int len, u32 *val) 55 + { 56 + return -ENXIO; 57 + } 58 + 59 + int raw_pci_write(unsigned int domain, unsigned int bus, 60 + unsigned int devfn, int reg, int len, u32 val) 61 + { 62 + return -ENXIO; 63 + } 64 + 65 + #ifdef CONFIG_ACPI 66 + /* Root bridge scanning */ 67 + struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) 68 + { 69 + /* TODO: Should be revisited when implementing PCI on ACPI */ 70 + return NULL; 71 + } 72 + #endif
+79 -33
arch/arm64/kernel/psci.c
··· 15 15 16 16 #define pr_fmt(fmt) "psci: " fmt 17 17 18 + #include <linux/acpi.h> 18 19 #include <linux/init.h> 19 20 #include <linux/of.h> 20 21 #include <linux/smp.h> ··· 25 24 #include <linux/slab.h> 26 25 #include <uapi/linux/psci.h> 27 26 27 + #include <asm/acpi.h> 28 28 #include <asm/compiler.h> 29 29 #include <asm/cpu_ops.h> 30 30 #include <asm/errno.h> ··· 275 273 invoke_psci_fn(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0); 276 274 } 277 275 278 - /* 279 - * PSCI Function IDs for v0.2+ are well defined so use 280 - * standard values. 281 - */ 282 - static int __init psci_0_2_init(struct device_node *np) 276 + static void __init psci_0_2_set_functions(void) 283 277 { 284 - int err, ver; 285 - 286 - err = get_set_conduit_method(np); 287 - 288 - if (err) 289 - goto out_put_node; 290 - 291 - ver = psci_get_version(); 292 - 293 - if (ver == PSCI_RET_NOT_SUPPORTED) { 294 - /* PSCI v0.2 mandates implementation of PSCI_ID_VERSION. */ 295 - pr_err("PSCI firmware does not comply with the v0.2 spec.\n"); 296 - err = -EOPNOTSUPP; 297 - goto out_put_node; 298 - } else { 299 - pr_info("PSCIv%d.%d detected in firmware.\n", 300 - PSCI_VERSION_MAJOR(ver), 301 - PSCI_VERSION_MINOR(ver)); 302 - 303 - if (PSCI_VERSION_MAJOR(ver) == 0 && 304 - PSCI_VERSION_MINOR(ver) < 2) { 305 - err = -EINVAL; 306 - pr_err("Conflicting PSCI version detected.\n"); 307 - goto out_put_node; 308 - } 309 - } 310 - 311 278 pr_info("Using standard PSCI v0.2 function IDs\n"); 312 279 psci_function_id[PSCI_FN_CPU_SUSPEND] = PSCI_0_2_FN64_CPU_SUSPEND; 313 280 psci_ops.cpu_suspend = psci_cpu_suspend; ··· 300 329 arm_pm_restart = psci_sys_reset; 301 330 302 331 pm_power_off = psci_sys_poweroff; 332 + } 333 + 334 + /* 335 + * Probe function for PSCI firmware versions >= 0.2 336 + */ 337 + static int __init psci_probe(void) 338 + { 339 + int ver = psci_get_version(); 340 + 341 + if (ver == PSCI_RET_NOT_SUPPORTED) { 342 + /* 343 + * PSCI versions >=0.2 mandates implementation of 344 + * PSCI_VERSION. 345 + */ 346 + pr_err("PSCI firmware does not comply with the v0.2 spec.\n"); 347 + return -EOPNOTSUPP; 348 + } else { 349 + pr_info("PSCIv%d.%d detected in firmware.\n", 350 + PSCI_VERSION_MAJOR(ver), 351 + PSCI_VERSION_MINOR(ver)); 352 + 353 + if (PSCI_VERSION_MAJOR(ver) == 0 && 354 + PSCI_VERSION_MINOR(ver) < 2) { 355 + pr_err("Conflicting PSCI version detected.\n"); 356 + return -EINVAL; 357 + } 358 + } 359 + 360 + psci_0_2_set_functions(); 361 + 362 + return 0; 363 + } 364 + 365 + /* 366 + * PSCI init function for PSCI versions >=0.2 367 + * 368 + * Probe based on PSCI PSCI_VERSION function 369 + */ 370 + static int __init psci_0_2_init(struct device_node *np) 371 + { 372 + int err; 373 + 374 + err = get_set_conduit_method(np); 375 + 376 + if (err) 377 + goto out_put_node; 378 + /* 379 + * Starting with v0.2, the PSCI specification introduced a call 380 + * (PSCI_VERSION) that allows probing the firmware version, so 381 + * that PSCI function IDs and version specific initialization 382 + * can be carried out according to the specific version reported 383 + * by firmware 384 + */ 385 + err = psci_probe(); 303 386 304 387 out_put_node: 305 388 of_node_put(np); ··· 406 381 {}, 407 382 }; 408 383 409 - int __init psci_init(void) 384 + int __init psci_dt_init(void) 410 385 { 411 386 struct device_node *np; 412 387 const struct of_device_id *matched_np; ··· 419 394 420 395 init_fn = (psci_initcall_t)matched_np->data; 421 396 return init_fn(np); 397 + } 398 + 399 + /* 400 + * We use PSCI 0.2+ when ACPI is deployed on ARM64 and it's 401 + * explicitly clarified in SBBR 402 + */ 403 + int __init psci_acpi_init(void) 404 + { 405 + if (!acpi_psci_present()) { 406 + pr_info("is not implemented in ACPI.\n"); 407 + return -EOPNOTSUPP; 408 + } 409 + 410 + pr_info("probing for conduit method from ACPI.\n"); 411 + 412 + if (acpi_psci_use_hvc()) 413 + invoke_psci_fn = __invoke_psci_fn_hvc; 414 + else 415 + invoke_psci_fn = __invoke_psci_fn_smc; 416 + 417 + return psci_probe(); 422 418 } 423 419 424 420 #ifdef CONFIG_SMP
+17 -6
arch/arm64/kernel/setup.c
··· 17 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 18 */ 19 19 20 + #include <linux/acpi.h> 20 21 #include <linux/export.h> 21 22 #include <linux/kernel.h> 22 23 #include <linux/stddef.h> ··· 47 46 #include <linux/efi.h> 48 47 #include <linux/personality.h> 49 48 49 + #include <asm/acpi.h> 50 50 #include <asm/fixmap.h> 51 51 #include <asm/cpu.h> 52 52 #include <asm/cputype.h> ··· 397 395 efi_init(); 398 396 arm64_memblock_init(); 399 397 398 + /* Parse the ACPI tables for possible boot-time configuration */ 399 + acpi_boot_table_init(); 400 + 400 401 paging_init(); 401 402 request_standard_resources(); 402 403 403 404 early_ioremap_reset(); 404 405 405 - unflatten_device_tree(); 406 - 407 - psci_init(); 408 - 409 - cpu_read_bootcpu_ops(); 406 + if (acpi_disabled) { 407 + unflatten_device_tree(); 408 + psci_dt_init(); 409 + cpu_read_bootcpu_ops(); 410 410 #ifdef CONFIG_SMP 411 - smp_init_cpus(); 411 + of_smp_init_cpus(); 412 + #endif 413 + } else { 414 + psci_acpi_init(); 415 + acpi_init_cpus(); 416 + } 417 + 418 + #ifdef CONFIG_SMP 412 419 smp_build_mpidr_hash(); 413 420 #endif 414 421
+1 -1
arch/arm64/kernel/smp.c
··· 323 323 * cpu logical map array containing MPIDR values related to logical 324 324 * cpus. Assumes that cpu_logical_map(0) has already been initialized. 325 325 */ 326 - void __init smp_init_cpus(void) 326 + void __init of_smp_init_cpus(void) 327 327 { 328 328 struct device_node *dn = NULL; 329 329 unsigned int i, cpu = 1;
+7
arch/arm64/kernel/time.c
··· 35 35 #include <linux/delay.h> 36 36 #include <linux/clocksource.h> 37 37 #include <linux/clk-provider.h> 38 + #include <linux/acpi.h> 38 39 39 40 #include <clocksource/arm_arch_timer.h> 40 41 ··· 72 71 clocksource_of_init(); 73 72 74 73 tick_setup_hrtimer_broadcast(); 74 + 75 + /* 76 + * Since ACPI or FDT will only one be available in the system, 77 + * we can use acpi_generic_timer_init() here safely 78 + */ 79 + acpi_generic_timer_init(); 75 80 76 81 arch_timer_rate = arch_timer_get_rate(); 77 82 if (!arch_timer_rate)
+1
arch/ia64/Kconfig
··· 15 15 select ARCH_MIGHT_HAVE_PC_SERIO 16 16 select PCI if (!IA64_HP_SIM) 17 17 select ACPI if (!IA64_HP_SIM) 18 + select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI 18 19 select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI 19 20 select HAVE_UNSTABLE_SCHED_CLOCK 20 21 select HAVE_IDE
+1 -1
arch/ia64/kernel/acpi.c
··· 887 887 } 888 888 889 889 /* wrapper to silence section mismatch warning */ 890 - int __ref acpi_map_cpu(acpi_handle handle, int physid, int *pcpu) 890 + int __ref acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu) 891 891 { 892 892 return _acpi_map_lsapic(handle, physid, pcpu); 893 893 }
+1
arch/x86/Kconfig
··· 22 22 ### Arch settings 23 23 config X86 24 24 def_bool y 25 + select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI 25 26 select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI 26 27 select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS 27 28 select ARCH_HAS_FAST_MULTIPLIER
+1 -1
arch/x86/kernel/acpi/boot.c
··· 757 757 } 758 758 759 759 /* wrapper to silence section mismatch warning */ 760 - int __ref acpi_map_cpu(acpi_handle handle, int physid, int *pcpu) 760 + int __ref acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu) 761 761 { 762 762 return _acpi_map_lsapic(handle, physid, pcpu); 763 763 }
+9 -1
drivers/acpi/Kconfig
··· 5 5 menuconfig ACPI 6 6 bool "ACPI (Advanced Configuration and Power Interface) Support" 7 7 depends on !IA64_HP_SIM 8 - depends on IA64 || X86 8 + depends on IA64 || X86 || (ARM64 && EXPERT) 9 9 depends on PCI 10 10 select PNP 11 11 default y ··· 48 48 config ARCH_MIGHT_HAVE_ACPI_PDC 49 49 bool 50 50 51 + config ACPI_GENERIC_GSI 52 + bool 53 + 54 + config ACPI_SYSTEM_POWER_STATES_SUPPORT 55 + bool 56 + 51 57 config ACPI_SLEEP 52 58 bool 53 59 depends on SUSPEND || HIBERNATION 60 + depends on ACPI_SYSTEM_POWER_STATES_SUPPORT 54 61 default y 55 62 56 63 config ACPI_PROCFS_POWER ··· 170 163 tristate "Processor" 171 164 select THERMAL 172 165 select CPU_IDLE 166 + depends on X86 || IA64 173 167 default y 174 168 help 175 169 This driver installs ACPI as the idle handler for Linux and uses
+2 -1
drivers/acpi/Makefile
··· 23 23 24 24 # Power management related files 25 25 acpi-y += wakeup.o 26 - acpi-y += sleep.o 26 + acpi-$(CONFIG_ACPI_SYSTEM_POWER_STATES_SUPPORT) += sleep.o 27 27 acpi-y += device_pm.o 28 28 acpi-$(CONFIG_ACPI_SLEEP) += proc.o 29 29 ··· 56 56 acpi-y += video_detect.o 57 57 endif 58 58 acpi-y += acpi_lpat.o 59 + acpi-$(CONFIG_ACPI_GENERIC_GSI) += gsi.o 59 60 60 61 # These are (potentially) separate modules 61 62
+4 -3
drivers/acpi/acpi_processor.c
··· 170 170 acpi_status status; 171 171 int ret; 172 172 173 - if (pr->phys_id == -1) 173 + if (pr->phys_id == PHYS_CPUID_INVALID) 174 174 return -ENODEV; 175 175 176 176 status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta); ··· 215 215 union acpi_object object = { 0 }; 216 216 struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; 217 217 struct acpi_processor *pr = acpi_driver_data(device); 218 - int phys_id, cpu_index, device_declaration = 0; 218 + phys_cpuid_t phys_id; 219 + int cpu_index, device_declaration = 0; 219 220 acpi_status status = AE_OK; 220 221 static int cpu0_initialized; 221 222 unsigned long long value; ··· 264 263 } 265 264 266 265 phys_id = acpi_get_phys_id(pr->handle, device_declaration, pr->acpi_id); 267 - if (phys_id < 0) 266 + if (phys_id == PHYS_CPUID_INVALID) 268 267 acpi_handle_debug(pr->handle, "failed to get CPU physical ID.\n"); 269 268 pr->phys_id = phys_id; 270 269
+3
drivers/acpi/bus.c
··· 448 448 case ACPI_IRQ_MODEL_IOSAPIC: 449 449 message = "IOSAPIC"; 450 450 break; 451 + case ACPI_IRQ_MODEL_GIC: 452 + message = "GIC"; 453 + break; 451 454 case ACPI_IRQ_MODEL_PLATFORM: 452 455 message = "platform specific model"; 453 456 break;
+105
drivers/acpi/gsi.c
··· 1 + /* 2 + * ACPI GSI IRQ layer 3 + * 4 + * Copyright (C) 2015 ARM Ltd. 5 + * Author: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> 6 + * 7 + * This program is free software; you can redistribute it and/or modify 8 + * it under the terms of the GNU General Public License version 2 as 9 + * published by the Free Software Foundation. 10 + */ 11 + #include <linux/acpi.h> 12 + #include <linux/irq.h> 13 + #include <linux/irqdomain.h> 14 + 15 + enum acpi_irq_model_id acpi_irq_model; 16 + 17 + static unsigned int acpi_gsi_get_irq_type(int trigger, int polarity) 18 + { 19 + switch (polarity) { 20 + case ACPI_ACTIVE_LOW: 21 + return trigger == ACPI_EDGE_SENSITIVE ? 22 + IRQ_TYPE_EDGE_FALLING : 23 + IRQ_TYPE_LEVEL_LOW; 24 + case ACPI_ACTIVE_HIGH: 25 + return trigger == ACPI_EDGE_SENSITIVE ? 26 + IRQ_TYPE_EDGE_RISING : 27 + IRQ_TYPE_LEVEL_HIGH; 28 + case ACPI_ACTIVE_BOTH: 29 + if (trigger == ACPI_EDGE_SENSITIVE) 30 + return IRQ_TYPE_EDGE_BOTH; 31 + default: 32 + return IRQ_TYPE_NONE; 33 + } 34 + } 35 + 36 + /** 37 + * acpi_gsi_to_irq() - Retrieve the linux irq number for a given GSI 38 + * @gsi: GSI IRQ number to map 39 + * @irq: pointer where linux IRQ number is stored 40 + * 41 + * irq location updated with irq value [>0 on success, 0 on failure] 42 + * 43 + * Returns: linux IRQ number on success (>0) 44 + * -EINVAL on failure 45 + */ 46 + int acpi_gsi_to_irq(u32 gsi, unsigned int *irq) 47 + { 48 + /* 49 + * Only default domain is supported at present, always find 50 + * the mapping corresponding to default domain by passing NULL 51 + * as irq_domain parameter 52 + */ 53 + *irq = irq_find_mapping(NULL, gsi); 54 + /* 55 + * *irq == 0 means no mapping, that should 56 + * be reported as a failure 57 + */ 58 + return (*irq > 0) ? *irq : -EINVAL; 59 + } 60 + EXPORT_SYMBOL_GPL(acpi_gsi_to_irq); 61 + 62 + /** 63 + * acpi_register_gsi() - Map a GSI to a linux IRQ number 64 + * @dev: device for which IRQ has to be mapped 65 + * @gsi: GSI IRQ number 66 + * @trigger: trigger type of the GSI number to be mapped 67 + * @polarity: polarity of the GSI to be mapped 68 + * 69 + * Returns: a valid linux IRQ number on success 70 + * -EINVAL on failure 71 + */ 72 + int acpi_register_gsi(struct device *dev, u32 gsi, int trigger, 73 + int polarity) 74 + { 75 + unsigned int irq; 76 + unsigned int irq_type = acpi_gsi_get_irq_type(trigger, polarity); 77 + 78 + /* 79 + * There is no way at present to look-up the IRQ domain on ACPI, 80 + * hence always create mapping referring to the default domain 81 + * by passing NULL as irq_domain parameter 82 + */ 83 + irq = irq_create_mapping(NULL, gsi); 84 + if (!irq) 85 + return -EINVAL; 86 + 87 + /* Set irq type if specified and different than the current one */ 88 + if (irq_type != IRQ_TYPE_NONE && 89 + irq_type != irq_get_trigger_type(irq)) 90 + irq_set_irq_type(irq, irq_type); 91 + return irq; 92 + } 93 + EXPORT_SYMBOL_GPL(acpi_register_gsi); 94 + 95 + /** 96 + * acpi_unregister_gsi() - Free a GSI<->linux IRQ number mapping 97 + * @gsi: GSI IRQ number 98 + */ 99 + void acpi_unregister_gsi(u32 gsi) 100 + { 101 + int irq = irq_find_mapping(NULL, gsi); 102 + 103 + irq_dispose_mapping(irq); 104 + } 105 + EXPORT_SYMBOL_GPL(acpi_unregister_gsi);
+4
drivers/acpi/internal.h
··· 161 161 /*-------------------------------------------------------------------------- 162 162 Suspend/Resume 163 163 -------------------------------------------------------------------------- */ 164 + #ifdef CONFIG_ACPI_SYSTEM_POWER_STATES_SUPPORT 164 165 extern int acpi_sleep_init(void); 166 + #else 167 + static inline int acpi_sleep_init(void) { return -ENXIO; } 168 + #endif 165 169 166 170 #ifdef CONFIG_ACPI_SLEEP 167 171 int acpi_sleep_proc_init(void);
+3 -3
drivers/acpi/osl.c
··· 336 336 return NULL; 337 337 } 338 338 339 - #ifndef CONFIG_IA64 340 - #define should_use_kmap(pfn) page_is_ram(pfn) 341 - #else 339 + #if defined(CONFIG_IA64) || defined(CONFIG_ARM64) 342 340 /* ioremap will take care of cache attributes */ 343 341 #define should_use_kmap(pfn) 0 342 + #else 343 + #define should_use_kmap(pfn) page_is_ram(pfn) 344 344 #endif 345 345 346 346 static void __iomem *acpi_map(acpi_physical_address pg_off, unsigned long pg_sz)
+45 -15
drivers/acpi/processor_core.c
··· 32 32 } 33 33 34 34 static int map_lapic_id(struct acpi_subtable_header *entry, 35 - u32 acpi_id, int *apic_id) 35 + u32 acpi_id, phys_cpuid_t *apic_id) 36 36 { 37 37 struct acpi_madt_local_apic *lapic = 38 38 container_of(entry, struct acpi_madt_local_apic, header); ··· 48 48 } 49 49 50 50 static int map_x2apic_id(struct acpi_subtable_header *entry, 51 - int device_declaration, u32 acpi_id, int *apic_id) 51 + int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id) 52 52 { 53 53 struct acpi_madt_local_x2apic *apic = 54 54 container_of(entry, struct acpi_madt_local_x2apic, header); ··· 65 65 } 66 66 67 67 static int map_lsapic_id(struct acpi_subtable_header *entry, 68 - int device_declaration, u32 acpi_id, int *apic_id) 68 + int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id) 69 69 { 70 70 struct acpi_madt_local_sapic *lsapic = 71 71 container_of(entry, struct acpi_madt_local_sapic, header); ··· 83 83 return 0; 84 84 } 85 85 86 - static int map_madt_entry(int type, u32 acpi_id) 86 + /* 87 + * Retrieve the ARM CPU physical identifier (MPIDR) 88 + */ 89 + static int map_gicc_mpidr(struct acpi_subtable_header *entry, 90 + int device_declaration, u32 acpi_id, phys_cpuid_t *mpidr) 91 + { 92 + struct acpi_madt_generic_interrupt *gicc = 93 + container_of(entry, struct acpi_madt_generic_interrupt, header); 94 + 95 + if (!(gicc->flags & ACPI_MADT_ENABLED)) 96 + return -ENODEV; 97 + 98 + /* device_declaration means Device object in DSDT, in the 99 + * GIC interrupt model, logical processors are required to 100 + * have a Processor Device object in the DSDT, so we should 101 + * check device_declaration here 102 + */ 103 + if (device_declaration && (gicc->uid == acpi_id)) { 104 + *mpidr = gicc->arm_mpidr; 105 + return 0; 106 + } 107 + 108 + return -EINVAL; 109 + } 110 + 111 + static phys_cpuid_t map_madt_entry(int type, u32 acpi_id) 87 112 { 88 113 unsigned long madt_end, entry; 89 - int phys_id = -1; /* CPU hardware ID */ 114 + phys_cpuid_t phys_id = PHYS_CPUID_INVALID; /* CPU hardware ID */ 90 115 struct acpi_table_madt *madt; 91 116 92 117 madt = get_madt_table(); ··· 136 111 } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { 137 112 if (!map_lsapic_id(header, type, acpi_id, &phys_id)) 138 113 break; 114 + } else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) { 115 + if (!map_gicc_mpidr(header, type, acpi_id, &phys_id)) 116 + break; 139 117 } 140 118 entry += header->length; 141 119 } 142 120 return phys_id; 143 121 } 144 122 145 - static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id) 123 + static phys_cpuid_t map_mat_entry(acpi_handle handle, int type, u32 acpi_id) 146 124 { 147 125 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 148 126 union acpi_object *obj; 149 127 struct acpi_subtable_header *header; 150 - int phys_id = -1; 128 + phys_cpuid_t phys_id = PHYS_CPUID_INVALID; 151 129 152 130 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer))) 153 131 goto exit; ··· 171 143 map_lsapic_id(header, type, acpi_id, &phys_id); 172 144 else if (header->type == ACPI_MADT_TYPE_LOCAL_X2APIC) 173 145 map_x2apic_id(header, type, acpi_id, &phys_id); 146 + else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) 147 + map_gicc_mpidr(header, type, acpi_id, &phys_id); 174 148 175 149 exit: 176 150 kfree(buffer.pointer); 177 151 return phys_id; 178 152 } 179 153 180 - int acpi_get_phys_id(acpi_handle handle, int type, u32 acpi_id) 154 + phys_cpuid_t acpi_get_phys_id(acpi_handle handle, int type, u32 acpi_id) 181 155 { 182 - int phys_id; 156 + phys_cpuid_t phys_id; 183 157 184 158 phys_id = map_mat_entry(handle, type, acpi_id); 185 - if (phys_id == -1) 159 + if (phys_id == PHYS_CPUID_INVALID) 186 160 phys_id = map_madt_entry(type, acpi_id); 187 161 188 162 return phys_id; 189 163 } 190 164 191 - int acpi_map_cpuid(int phys_id, u32 acpi_id) 165 + int acpi_map_cpuid(phys_cpuid_t phys_id, u32 acpi_id) 192 166 { 193 167 #ifdef CONFIG_SMP 194 168 int i; 195 169 #endif 196 170 197 - if (phys_id == -1) { 171 + if (phys_id == PHYS_CPUID_INVALID) { 198 172 /* 199 173 * On UP processor, there is no _MAT or MADT table. 200 - * So above phys_id is always set to -1. 174 + * So above phys_id is always set to PHYS_CPUID_INVALID. 201 175 * 202 176 * BIOS may define multiple CPU handles even for UP processor. 203 177 * For example, ··· 220 190 if (nr_cpu_ids <= 1 && acpi_id == 0) 221 191 return acpi_id; 222 192 else 223 - return phys_id; 193 + return -1; 224 194 } 225 195 226 196 #ifdef CONFIG_SMP ··· 238 208 239 209 int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id) 240 210 { 241 - int phys_id; 211 + phys_cpuid_t phys_id; 242 212 243 213 phys_id = acpi_get_phys_id(handle, type, acpi_id); 244 214
+38 -14
drivers/acpi/tables.c
··· 23 23 * 24 24 */ 25 25 26 + /* Uncomment next line to get verbose printout */ 27 + /* #define DEBUG */ 26 28 #define pr_fmt(fmt) "ACPI: " fmt 27 29 28 30 #include <linux/init.h> ··· 63 61 { 64 62 struct acpi_madt_local_apic *p = 65 63 (struct acpi_madt_local_apic *)header; 66 - pr_info("LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n", 67 - p->processor_id, p->id, 68 - (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled"); 64 + pr_debug("LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n", 65 + p->processor_id, p->id, 66 + (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled"); 69 67 } 70 68 break; 71 69 ··· 73 71 { 74 72 struct acpi_madt_local_x2apic *p = 75 73 (struct acpi_madt_local_x2apic *)header; 76 - pr_info("X2APIC (apic_id[0x%02x] uid[0x%02x] %s)\n", 77 - p->local_apic_id, p->uid, 78 - (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled"); 74 + pr_debug("X2APIC (apic_id[0x%02x] uid[0x%02x] %s)\n", 75 + p->local_apic_id, p->uid, 76 + (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled"); 79 77 } 80 78 break; 81 79 ··· 83 81 { 84 82 struct acpi_madt_io_apic *p = 85 83 (struct acpi_madt_io_apic *)header; 86 - pr_info("IOAPIC (id[0x%02x] address[0x%08x] gsi_base[%d])\n", 87 - p->id, p->address, p->global_irq_base); 84 + pr_debug("IOAPIC (id[0x%02x] address[0x%08x] gsi_base[%d])\n", 85 + p->id, p->address, p->global_irq_base); 88 86 } 89 87 break; 90 88 ··· 157 155 { 158 156 struct acpi_madt_io_sapic *p = 159 157 (struct acpi_madt_io_sapic *)header; 160 - pr_info("IOSAPIC (id[0x%x] address[%p] gsi_base[%d])\n", 161 - p->id, (void *)(unsigned long)p->address, 162 - p->global_irq_base); 158 + pr_debug("IOSAPIC (id[0x%x] address[%p] gsi_base[%d])\n", 159 + p->id, (void *)(unsigned long)p->address, 160 + p->global_irq_base); 163 161 } 164 162 break; 165 163 ··· 167 165 { 168 166 struct acpi_madt_local_sapic *p = 169 167 (struct acpi_madt_local_sapic *)header; 170 - pr_info("LSAPIC (acpi_id[0x%02x] lsapic_id[0x%02x] lsapic_eid[0x%02x] %s)\n", 171 - p->processor_id, p->id, p->eid, 172 - (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled"); 168 + pr_debug("LSAPIC (acpi_id[0x%02x] lsapic_id[0x%02x] lsapic_eid[0x%02x] %s)\n", 169 + p->processor_id, p->id, p->eid, 170 + (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled"); 173 171 } 174 172 break; 175 173 ··· 182 180 mps_inti_flags_trigger[(p->inti_flags & ACPI_MADT_TRIGGER_MASK) >> 2], 183 181 p->type, p->id, p->eid, p->io_sapic_vector, 184 182 p->global_irq); 183 + } 184 + break; 185 + 186 + case ACPI_MADT_TYPE_GENERIC_INTERRUPT: 187 + { 188 + struct acpi_madt_generic_interrupt *p = 189 + (struct acpi_madt_generic_interrupt *)header; 190 + pr_debug("GICC (acpi_id[0x%04x] address[%llx] MPIDR[0x%llx] %s)\n", 191 + p->uid, p->base_address, 192 + p->arm_mpidr, 193 + (p->flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled"); 194 + 195 + } 196 + break; 197 + 198 + case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR: 199 + { 200 + struct acpi_madt_generic_distributor *p = 201 + (struct acpi_madt_generic_distributor *)header; 202 + pr_debug("GIC Distributor (gic_id[0x%04x] address[%llx] gsi_base[%d])\n", 203 + p->gic_id, p->base_address, 204 + p->global_irq_base); 185 205 } 186 206 break; 187 207
+105 -27
drivers/clocksource/arm_arch_timer.c
··· 22 22 #include <linux/io.h> 23 23 #include <linux/slab.h> 24 24 #include <linux/sched_clock.h> 25 + #include <linux/acpi.h> 25 26 26 27 #include <asm/arch_timer.h> 27 28 #include <asm/virt.h> ··· 372 371 if (arch_timer_rate) 373 372 return; 374 373 375 - /* Try to determine the frequency from the device tree or CNTFRQ */ 376 - if (of_property_read_u32(np, "clock-frequency", &arch_timer_rate)) { 374 + /* 375 + * Try to determine the frequency from the device tree or CNTFRQ, 376 + * if ACPI is enabled, get the frequency from CNTFRQ ONLY. 377 + */ 378 + if (!acpi_disabled || 379 + of_property_read_u32(np, "clock-frequency", &arch_timer_rate)) { 377 380 if (cntbase) 378 381 arch_timer_rate = readl_relaxed(cntbase + CNTFRQ); 379 382 else ··· 696 691 arch_timer_arch_init(); 697 692 } 698 693 699 - static void __init arch_timer_init(struct device_node *np) 694 + static void __init arch_timer_init(void) 700 695 { 701 - int i; 702 - 703 - if (arch_timers_present & ARCH_CP15_TIMER) { 704 - pr_warn("arch_timer: multiple nodes in dt, skipping\n"); 705 - return; 706 - } 707 - 708 - arch_timers_present |= ARCH_CP15_TIMER; 709 - for (i = PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++) 710 - arch_timer_ppi[i] = irq_of_parse_and_map(np, i); 711 - arch_timer_detect_rate(NULL, np); 712 - 713 - /* 714 - * If we cannot rely on firmware initializing the timer registers then 715 - * we should use the physical timers instead. 716 - */ 717 - if (IS_ENABLED(CONFIG_ARM) && 718 - of_property_read_bool(np, "arm,cpu-registers-not-fw-configured")) 719 - arch_timer_use_virtual = false; 720 - 721 696 /* 722 697 * If HYP mode is available, we know that the physical timer 723 698 * has been configured to be accessible from PL1. Use it, so ··· 716 731 } 717 732 } 718 733 719 - arch_timer_c3stop = !of_property_read_bool(np, "always-on"); 720 - 721 734 arch_timer_register(); 722 735 arch_timer_common_init(); 723 736 } 724 - CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_init); 725 - CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_init); 737 + 738 + static void __init arch_timer_of_init(struct device_node *np) 739 + { 740 + int i; 741 + 742 + if (arch_timers_present & ARCH_CP15_TIMER) { 743 + pr_warn("arch_timer: multiple nodes in dt, skipping\n"); 744 + return; 745 + } 746 + 747 + arch_timers_present |= ARCH_CP15_TIMER; 748 + for (i = PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++) 749 + arch_timer_ppi[i] = irq_of_parse_and_map(np, i); 750 + 751 + arch_timer_detect_rate(NULL, np); 752 + 753 + arch_timer_c3stop = !of_property_read_bool(np, "always-on"); 754 + 755 + /* 756 + * If we cannot rely on firmware initializing the timer registers then 757 + * we should use the physical timers instead. 758 + */ 759 + if (IS_ENABLED(CONFIG_ARM) && 760 + of_property_read_bool(np, "arm,cpu-registers-not-fw-configured")) 761 + arch_timer_use_virtual = false; 762 + 763 + arch_timer_init(); 764 + } 765 + CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_of_init); 766 + CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_of_init); 726 767 727 768 static void __init arch_timer_mem_init(struct device_node *np) 728 769 { ··· 815 804 } 816 805 CLOCKSOURCE_OF_DECLARE(armv7_arch_timer_mem, "arm,armv7-timer-mem", 817 806 arch_timer_mem_init); 807 + 808 + #ifdef CONFIG_ACPI 809 + static int __init map_generic_timer_interrupt(u32 interrupt, u32 flags) 810 + { 811 + int trigger, polarity; 812 + 813 + if (!interrupt) 814 + return 0; 815 + 816 + trigger = (flags & ACPI_GTDT_INTERRUPT_MODE) ? ACPI_EDGE_SENSITIVE 817 + : ACPI_LEVEL_SENSITIVE; 818 + 819 + polarity = (flags & ACPI_GTDT_INTERRUPT_POLARITY) ? ACPI_ACTIVE_LOW 820 + : ACPI_ACTIVE_HIGH; 821 + 822 + return acpi_register_gsi(NULL, interrupt, trigger, polarity); 823 + } 824 + 825 + /* Initialize per-processor generic timer */ 826 + static int __init arch_timer_acpi_init(struct acpi_table_header *table) 827 + { 828 + struct acpi_table_gtdt *gtdt; 829 + 830 + if (arch_timers_present & ARCH_CP15_TIMER) { 831 + pr_warn("arch_timer: already initialized, skipping\n"); 832 + return -EINVAL; 833 + } 834 + 835 + gtdt = container_of(table, struct acpi_table_gtdt, header); 836 + 837 + arch_timers_present |= ARCH_CP15_TIMER; 838 + 839 + arch_timer_ppi[PHYS_SECURE_PPI] = 840 + map_generic_timer_interrupt(gtdt->secure_el1_interrupt, 841 + gtdt->secure_el1_flags); 842 + 843 + arch_timer_ppi[PHYS_NONSECURE_PPI] = 844 + map_generic_timer_interrupt(gtdt->non_secure_el1_interrupt, 845 + gtdt->non_secure_el1_flags); 846 + 847 + arch_timer_ppi[VIRT_PPI] = 848 + map_generic_timer_interrupt(gtdt->virtual_timer_interrupt, 849 + gtdt->virtual_timer_flags); 850 + 851 + arch_timer_ppi[HYP_PPI] = 852 + map_generic_timer_interrupt(gtdt->non_secure_el2_interrupt, 853 + gtdt->non_secure_el2_flags); 854 + 855 + /* Get the frequency from CNTFRQ */ 856 + arch_timer_detect_rate(NULL, NULL); 857 + 858 + /* Always-on capability */ 859 + arch_timer_c3stop = !(gtdt->non_secure_el1_flags & ACPI_GTDT_ALWAYS_ON); 860 + 861 + arch_timer_init(); 862 + return 0; 863 + } 864 + 865 + /* Initialize all the generic timers presented in GTDT */ 866 + void __init acpi_generic_timer_init(void) 867 + { 868 + if (acpi_disabled) 869 + return; 870 + 871 + acpi_table_parse(ACPI_SIG_GTDT, arch_timer_acpi_init); 872 + } 873 + #endif
+104
drivers/irqchip/irq-gic.c
··· 33 33 #include <linux/of.h> 34 34 #include <linux/of_address.h> 35 35 #include <linux/of_irq.h> 36 + #include <linux/acpi.h> 36 37 #include <linux/irqdomain.h> 37 38 #include <linux/interrupt.h> 38 39 #include <linux/percpu.h> 39 40 #include <linux/slab.h> 40 41 #include <linux/irqchip/chained_irq.h> 41 42 #include <linux/irqchip/arm-gic.h> 43 + #include <linux/irqchip/arm-gic-acpi.h> 42 44 43 45 #include <asm/cputype.h> 44 46 #include <asm/irq.h> ··· 1108 1106 IRQCHIP_DECLARE(msm_8660_qgic, "qcom,msm-8660-qgic", gic_of_init); 1109 1107 IRQCHIP_DECLARE(msm_qgic2, "qcom,msm-qgic2", gic_of_init); 1110 1108 1109 + #endif 1110 + 1111 + #ifdef CONFIG_ACPI 1112 + static phys_addr_t dist_phy_base, cpu_phy_base __initdata; 1113 + 1114 + static int __init 1115 + gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header, 1116 + const unsigned long end) 1117 + { 1118 + struct acpi_madt_generic_interrupt *processor; 1119 + phys_addr_t gic_cpu_base; 1120 + static int cpu_base_assigned; 1121 + 1122 + processor = (struct acpi_madt_generic_interrupt *)header; 1123 + 1124 + if (BAD_MADT_ENTRY(processor, end)) 1125 + return -EINVAL; 1126 + 1127 + /* 1128 + * There is no support for non-banked GICv1/2 register in ACPI spec. 1129 + * All CPU interface addresses have to be the same. 1130 + */ 1131 + gic_cpu_base = processor->base_address; 1132 + if (cpu_base_assigned && gic_cpu_base != cpu_phy_base) 1133 + return -EINVAL; 1134 + 1135 + cpu_phy_base = gic_cpu_base; 1136 + cpu_base_assigned = 1; 1137 + return 0; 1138 + } 1139 + 1140 + static int __init 1141 + gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header, 1142 + const unsigned long end) 1143 + { 1144 + struct acpi_madt_generic_distributor *dist; 1145 + 1146 + dist = (struct acpi_madt_generic_distributor *)header; 1147 + 1148 + if (BAD_MADT_ENTRY(dist, end)) 1149 + return -EINVAL; 1150 + 1151 + dist_phy_base = dist->base_address; 1152 + return 0; 1153 + } 1154 + 1155 + int __init 1156 + gic_v2_acpi_init(struct acpi_table_header *table) 1157 + { 1158 + void __iomem *cpu_base, *dist_base; 1159 + int count; 1160 + 1161 + /* Collect CPU base addresses */ 1162 + count = acpi_parse_entries(ACPI_SIG_MADT, 1163 + sizeof(struct acpi_table_madt), 1164 + gic_acpi_parse_madt_cpu, table, 1165 + ACPI_MADT_TYPE_GENERIC_INTERRUPT, 0); 1166 + if (count <= 0) { 1167 + pr_err("No valid GICC entries exist\n"); 1168 + return -EINVAL; 1169 + } 1170 + 1171 + /* 1172 + * Find distributor base address. We expect one distributor entry since 1173 + * ACPI 5.1 spec neither support multi-GIC instances nor GIC cascade. 1174 + */ 1175 + count = acpi_parse_entries(ACPI_SIG_MADT, 1176 + sizeof(struct acpi_table_madt), 1177 + gic_acpi_parse_madt_distributor, table, 1178 + ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0); 1179 + if (count <= 0) { 1180 + pr_err("No valid GICD entries exist\n"); 1181 + return -EINVAL; 1182 + } else if (count > 1) { 1183 + pr_err("More than one GICD entry detected\n"); 1184 + return -EINVAL; 1185 + } 1186 + 1187 + cpu_base = ioremap(cpu_phy_base, ACPI_GIC_CPU_IF_MEM_SIZE); 1188 + if (!cpu_base) { 1189 + pr_err("Unable to map GICC registers\n"); 1190 + return -ENOMEM; 1191 + } 1192 + 1193 + dist_base = ioremap(dist_phy_base, ACPI_GICV2_DIST_MEM_SIZE); 1194 + if (!dist_base) { 1195 + pr_err("Unable to map GICD registers\n"); 1196 + iounmap(cpu_base); 1197 + return -ENOMEM; 1198 + } 1199 + 1200 + /* 1201 + * Initialize zero GIC instance (no multi-GIC support). Also, set GIC 1202 + * as default IRQ domain to allow for GSI registration and GSI to IRQ 1203 + * number translation (see acpi_register_gsi() and acpi_gsi_to_irq()). 1204 + */ 1205 + gic_init_bases(0, -1, dist_base, cpu_base, 0, NULL); 1206 + irq_set_default_host(gic_data[0].domain); 1207 + 1208 + acpi_irq_model = ACPI_IRQ_MODEL_GIC; 1209 + return 0; 1210 + } 1111 1211 #endif
+3
drivers/irqchip/irqchip.c
··· 8 8 * warranty of any kind, whether express or implied. 9 9 */ 10 10 11 + #include <linux/acpi_irq.h> 11 12 #include <linux/init.h> 12 13 #include <linux/of_irq.h> 13 14 #include <linux/irqchip.h> ··· 27 26 void __init irqchip_init(void) 28 27 { 29 28 of_irq_init(__irqchip_of_table); 29 + 30 + acpi_irq_init(); 30 31 }
+4
drivers/xen/Kconfig
··· 276 276 help 277 277 Support for auto-translated physmap guests. 278 278 279 + config XEN_ACPI 280 + def_bool y 281 + depends on X86 && ACPI 282 + 279 283 endmenu
+1 -1
drivers/xen/Makefile
··· 13 13 14 14 dom0-$(CONFIG_PCI) += pci.o 15 15 dom0-$(CONFIG_USB_SUPPORT) += dbgp.o 16 - dom0-$(CONFIG_ACPI) += acpi.o $(xen-pad-y) 16 + dom0-$(CONFIG_XEN_ACPI) += acpi.o $(xen-pad-y) 17 17 xen-pad-$(CONFIG_X86) += xen-acpi-pad.o 18 18 dom0-$(CONFIG_X86) += pcpu.o 19 19 obj-$(CONFIG_XEN_DOM0) += $(dom0-y)
+4
include/acpi/acpi_io.h
··· 3 3 4 4 #include <linux/io.h> 5 5 6 + #include <asm/acpi.h> 7 + 8 + #ifndef acpi_os_ioremap 6 9 static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys, 7 10 acpi_size size) 8 11 { 9 12 return ioremap_cache(phys, size); 10 13 } 14 + #endif 11 15 12 16 void __iomem *__init_refok 13 17 acpi_os_map_iomem(acpi_physical_address phys, acpi_size size);
+3 -3
include/acpi/processor.h
··· 196 196 struct acpi_processor { 197 197 acpi_handle handle; 198 198 u32 acpi_id; 199 - u32 phys_id; /* CPU hardware ID such as APIC ID for x86 */ 199 + phys_cpuid_t phys_id; /* CPU hardware ID such as APIC ID for x86 */ 200 200 u32 id; /* CPU logical ID allocated by OS */ 201 201 u32 pblk; 202 202 int performance_platform_limit; ··· 310 310 #endif /* CONFIG_CPU_FREQ */ 311 311 312 312 /* in processor_core.c */ 313 - int acpi_get_phys_id(acpi_handle, int type, u32 acpi_id); 314 - int acpi_map_cpuid(int phys_id, u32 acpi_id); 313 + phys_cpuid_t acpi_get_phys_id(acpi_handle, int type, u32 acpi_id); 314 + int acpi_map_cpuid(phys_cpuid_t phys_id, u32 acpi_id); 315 315 int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id); 316 316 317 317 /* in processor_pdc.c */
+7 -1
include/linux/acpi.h
··· 79 79 ACPI_IRQ_MODEL_IOAPIC, 80 80 ACPI_IRQ_MODEL_IOSAPIC, 81 81 ACPI_IRQ_MODEL_PLATFORM, 82 + ACPI_IRQ_MODEL_GIC, 82 83 ACPI_IRQ_MODEL_COUNT 83 84 }; 84 85 ··· 153 152 int acpi_numa_memory_affinity_init (struct acpi_srat_mem_affinity *ma); 154 153 void acpi_numa_arch_fixup(void); 155 154 155 + #ifndef PHYS_CPUID_INVALID 156 + typedef u32 phys_cpuid_t; 157 + #define PHYS_CPUID_INVALID (phys_cpuid_t)(-1) 158 + #endif 159 + 156 160 #ifdef CONFIG_ACPI_HOTPLUG_CPU 157 161 /* Arch dependent functions for cpu hotplug support */ 158 - int acpi_map_cpu(acpi_handle handle, int physid, int *pcpu); 162 + int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu); 159 163 int acpi_unmap_cpu(int cpu); 160 164 #endif /* CONFIG_ACPI_HOTPLUG_CPU */ 161 165
+10
include/linux/acpi_irq.h
··· 1 + #ifndef _LINUX_ACPI_IRQ_H 2 + #define _LINUX_ACPI_IRQ_H 3 + 4 + #include <linux/irq.h> 5 + 6 + #ifndef acpi_irq_init 7 + static inline void acpi_irq_init(void) { } 8 + #endif 9 + 10 + #endif /* _LINUX_ACPI_IRQ_H */
+6
include/linux/clocksource.h
··· 253 253 static inline void clocksource_of_init(void) {} 254 254 #endif 255 255 256 + #ifdef CONFIG_ACPI 257 + void acpi_generic_timer_init(void); 258 + #else 259 + static inline void acpi_generic_timer_init(void) { } 260 + #endif 261 + 256 262 #endif /* _LINUX_CLOCKSOURCE_H */
+31
include/linux/irqchip/arm-gic-acpi.h
··· 1 + /* 2 + * Copyright (C) 2014, Linaro Ltd. 3 + * Author: Tomasz Nowicki <tomasz.nowicki@linaro.org> 4 + * 5 + * This program is free software; you can redistribute it and/or modify 6 + * it under the terms of the GNU General Public License version 2 as 7 + * published by the Free Software Foundation. 8 + */ 9 + 10 + #ifndef ARM_GIC_ACPI_H_ 11 + #define ARM_GIC_ACPI_H_ 12 + 13 + #ifdef CONFIG_ACPI 14 + 15 + /* 16 + * Hard code here, we can not get memory size from MADT (but FDT does), 17 + * Actually no need to do that, because this size can be inferred 18 + * from GIC spec. 19 + */ 20 + #define ACPI_GICV2_DIST_MEM_SIZE (SZ_4K) 21 + #define ACPI_GIC_CPU_IF_MEM_SIZE (SZ_8K) 22 + 23 + struct acpi_table_header; 24 + 25 + int gic_v2_acpi_init(struct acpi_table_header *table); 26 + void acpi_gic_init(void); 27 + #else 28 + static inline void acpi_gic_init(void) { } 29 + #endif 30 + 31 + #endif /* ARM_GIC_ACPI_H_ */