aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-04-24 11:23:45 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-24 11:23:45 -0400
commit836ee4874e201a5907f9658fb2bf3527dd952d30 (patch)
tree34a9e521bbba61d127794278e7b14d96797273f4
parentfb65d872d7a8dc629837a49513911d0281577bfd (diff)
parent7676fa70feb2f3bcdd4b854a553a57d8ef8505aa (diff)
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 ...
-rw-r--r--Documentation/arm64/acpi_object_usage.txt593
-rw-r--r--Documentation/arm64/arm-acpi.txt505
-rw-r--r--Documentation/kernel-parameters.txt3
-rw-r--r--arch/arm64/Kconfig4
-rw-r--r--arch/arm64/include/asm/acenv.h18
-rw-r--r--arch/arm64/include/asm/acpi.h96
-rw-r--r--arch/arm64/include/asm/cpu_ops.h1
-rw-r--r--arch/arm64/include/asm/fixmap.h3
-rw-r--r--arch/arm64/include/asm/irq.h13
-rw-r--r--arch/arm64/include/asm/pci.h6
-rw-r--r--arch/arm64/include/asm/psci.h3
-rw-r--r--arch/arm64/include/asm/smp.h5
-rw-r--r--arch/arm64/kernel/Makefile1
-rw-r--r--arch/arm64/kernel/acpi.c345
-rw-r--r--arch/arm64/kernel/cpu_ops.c2
-rw-r--r--arch/arm64/kernel/pci.c25
-rw-r--r--arch/arm64/kernel/psci.c112
-rw-r--r--arch/arm64/kernel/setup.c21
-rw-r--r--arch/arm64/kernel/smp.c2
-rw-r--r--arch/arm64/kernel/time.c7
-rw-r--r--arch/ia64/Kconfig1
-rw-r--r--arch/ia64/kernel/acpi.c2
-rw-r--r--arch/x86/Kconfig1
-rw-r--r--arch/x86/kernel/acpi/boot.c2
-rw-r--r--drivers/acpi/Kconfig10
-rw-r--r--drivers/acpi/Makefile3
-rw-r--r--drivers/acpi/acpi_processor.c7
-rw-r--r--drivers/acpi/bus.c3
-rw-r--r--drivers/acpi/gsi.c105
-rw-r--r--drivers/acpi/internal.h4
-rw-r--r--drivers/acpi/osl.c6
-rw-r--r--drivers/acpi/processor_core.c60
-rw-r--r--drivers/acpi/tables.c52
-rw-r--r--drivers/clocksource/arm_arch_timer.c132
-rw-r--r--drivers/irqchip/irq-gic.c104
-rw-r--r--drivers/irqchip/irqchip.c3
-rw-r--r--drivers/xen/Kconfig4
-rw-r--r--drivers/xen/Makefile2
-rw-r--r--include/acpi/acpi_io.h4
-rw-r--r--include/acpi/processor.h6
-rw-r--r--include/linux/acpi.h8
-rw-r--r--include/linux/acpi_irq.h10
-rw-r--r--include/linux/clocksource.h6
-rw-r--r--include/linux/irqchip/arm-gic-acpi.h31
44 files changed, 2216 insertions, 115 deletions
diff --git a/Documentation/arm64/acpi_object_usage.txt b/Documentation/arm64/acpi_object_usage.txt
new file mode 100644
index 000000000000..a6e1a1805e51
--- /dev/null
+++ b/Documentation/arm64/acpi_object_usage.txt
@@ -0,0 +1,593 @@
1ACPI Tables
2-----------
3The expectations of individual ACPI tables are discussed in the list that
4follows.
5
6If a section number is used, it refers to a section number in the ACPI
7specification where the object is defined. If "Signature Reserved" is used,
8the table signature (the first four bytes of the table) is the only portion
9of the table recognized by the specification, and the actual table is defined
10outside of the UEFI Forum (see Section 5.2.6 of the specification).
11
12For 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
25Table Usage for ARMv8 Linux
26----- ----------------------------------------------------------------
27BERT 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
32BOOT Signature Reserved (signature == "BOOT")
33 == simple BOOT flag table ==
34 Microsoft only table, will not be supported.
35
36BGRT 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
41CPEP 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
47CSRT Signature Reserved (signature == "CSRT")
48 == Core System Resources Table ==
49 Optional, not currently supported.
50
51DBG2 Signature Reserved (signature == "DBG2")
52 == DeBuG port table 2 ==
53 Microsoft only table, will not be supported.
54
55DBGP Signature Reserved (signature == "DBGP")
56 == DeBuG Port table ==
57 Microsoft only table, will not be supported.
58
59DSDT 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
67DMAR Signature Reserved (signature == "DMAR")
68 == DMA Remapping table ==
69 x86 only table, will not be supported.
70
71DRTM Signature Reserved (signature == "DRTM")
72 == Dynamic Root of Trust for Measurement table ==
73 Optional, not currently supported.
74
75ECDT 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
82EINJ 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
90ERST 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
97ETDT Signature Reserved (signature == "ETDT")
98 == Event Timer Description Table ==
99 Obsolete table, will not be supported.
100
101FACS 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
108FADT 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
126FPDT Section 5.2.23 (signature == "FPDT")
127 == Firmware Performance Data Table ==
128 Optional, not currently supported.
129
130GTDT Section 5.2.24 (signature == "GTDT")
131 == Generic Timer Description Table ==
132 Required for arm64.
133
134HEST 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
144HPET Signature Reserved (signature == "HPET")
145 == High Precision Event timer Table ==
146 x86 only table, will not be supported.
147
148IBFT Signature Reserved (signature == "IBFT")
149 == iSCSI Boot Firmware Table ==
150 Microsoft defined table, support TBD.
151
152IVRS Signature Reserved (signature == "IVRS")
153 == I/O Virtualization Reporting Structure ==
154 x86_64 (AMD) only table, will not be supported.
155
156LPIT 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
162MADT 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
167MCFG Signature Reserved (signature == "MCFG")
168 == Memory-mapped ConFiGuration space ==
169 If the platform supports PCI/PCIe, an MCFG table is required.
170
171MCHI Signature Reserved (signature == "MCHI")
172 == Management Controller Host Interface table ==
173 Optional, not currently supported.
174
175MPST Section 5.2.21 (signature == "MPST")
176 == Memory Power State Table ==
177 Optional, not currently supported.
178
179MSDM Signature Reserved (signature == "MSDM")
180 == Microsoft Data Management table ==
181 Microsoft only table, will not be supported.
182
183MSCT Section 5.2.19 (signature == "MSCT")
184 == Maximum System Characteristic Table ==
185 Optional, not currently supported.
186
187RASF Section 5.2.20 (signature == "RASF")
188 == RAS Feature table ==
189 Optional, not currently supported.
190
191RSDP Section 5.2.5 (signature == "RSD PTR")
192 == Root System Description PoinTeR ==
193 Required for arm64.
194
195RSDT 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
200SBST Section 5.2.14 (signature == "SBST")
201 == Smart Battery Subsystem Table ==
202 Optional, not currently supported.
203
204SLIC Signature Reserved (signature == "SLIC")
205 == Software LIcensing table ==
206 Microsoft only table, will not be supported.
207
208SLIT Section 5.2.17 (signature == "SLIT")
209 == System Locality distance Information Table ==
210 Optional in general, but required for NUMA systems.
211
212SPCR Signature Reserved (signature == "SPCR")
213 == Serial Port Console Redirection table ==
214 Required for arm64.
215
216SPMI Signature Reserved (signature == "SPMI")
217 == Server Platform Management Interface table ==
218 Optional, not currently supported.
219
220SRAT 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
225SSDT 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
238TCPA 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
243TPM2 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
248UEFI Signature Reserved (signature == "UEFI")
249 == UEFI ACPI data table ==
250 Optional, not currently supported. No known use case for arm64,
251 at present.
252
253WAET Signature Reserved (signature == "WAET")
254 == Windows ACPI Emulated devices Table ==
255 Microsoft only table, will not be supported.
256
257WDAT Signature Reserved (signature == "WDAT")
258 == Watch Dog Action Table ==
259 Microsoft only table, will not be supported.
260
261WDRT Signature Reserved (signature == "WDRT")
262 == Watch Dog Resource Table ==
263 Microsoft only table, will not be supported.
264
265WPBT Signature Reserved (signature == "WPBT")
266 == Windows Platform Binary Table ==
267 Microsoft only table, will not be supported.
268
269XSDT Section 5.2.8 (signature == "XSDT")
270 == eXtended System Description Table ==
271 Required for arm64.
272
273
274ACPI Objects
275------------
276The expectations on individual ACPI objects are discussed in the list that
277follows:
278
279Name 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
492ACPI Event Model
493----------------
494Do not use GPE block devices; these are not supported in the hardware reduced
495profile used by arm64. Since there are no GPE blocks defined for use on ARM
496platforms, GPIO-signaled interrupts should be used for creating system events.
497
498
499ACPI Processor Control
500----------------------
501Section 8 of the ACPI specification is currently undergoing change that
502should be completed in the 6.0 version of the specification. Processor
503performance control will be handled differently for arm64 at that point
504in time. Processor aggregator devices (section 8.5) will not be used,
505for example, but another similar mechanism instead.
506
507While UEFI constrains what we can say until the release of 6.0, it is
508recommended that CPPC (8.4.5) be used as the primary model. This will
509still be useful into the future. C-states and P-states will still be
510provided, but most of the current design work appears to favor CPPC.
511
512Further, it is essential that the ARMv8 SoC provide a fully functional
513implementation of PSCI; this will be the only mechanism supported by ACPI
514to control CPU power state (including secondary CPU booting).
515
516More details will be provided on the release of the ACPI 6.0 specification.
517
518
519ACPI System Address Map Interfaces
520----------------------------------
521In Section 15 of the ACPI specification, several methods are mentioned as
522possible mechanisms for conveying memory resource information to the kernel.
523For arm64, we will only support UEFI for booting with ACPI, hence the UEFI
524GetMemoryMap() boot service is the only mechanism that will be used.
525
526
527ACPI Platform Error Interfaces (APEI)
528-------------------------------------
529The APEI tables supported are described above.
530
531APEI requires the equivalent of an SCI and an NMI on ARMv8. The SCI is used
532to notify the OSPM of errors that have occurred but can be corrected and the
533system can continue correct operation, even if possibly degraded. The NMI is
534used to indicate fatal errors that cannot be corrected, and require immediate
535attention.
536
537Since there is no direct equivalent of the x86 SCI or NMI, arm64 handles
538these slightly differently. The SCI is handled as a normal GPIO-signaled
539interrupt; given that these are corrected (or correctable) errors being
540reported, this is sufficient. The NMI is emulated as the highest priority
541GPIO-signaled interrupt possible. This implies some caution must be used
542since there could be interrupts at higher privilege levels or even interrupts
543at the same priority as the emulated NMI. In Linux, this should not be the
544case but one should be aware it could happen.
545
546
547ACPI Objects Not Supported on ARM64
548-----------------------------------
549While this may change in the future, there are several classes of objects
550that can be defined, but are not currently of general interest to ARM servers.
551
552These 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
575ACPI Objects Not Yet Implemented
576--------------------------------
577While these objects have x86 equivalents, and they do make some sense in ARM
578servers, there is either no hardware available at present, or in some cases
579there may not yet be a non-ARM implementation. Hence, they are currently not
580implemented though that may change in the future.
581
582Not 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)
diff --git a/Documentation/arm64/arm-acpi.txt b/Documentation/arm64/arm-acpi.txt
new file mode 100644
index 000000000000..570a4f8e1a01
--- /dev/null
+++ b/Documentation/arm64/arm-acpi.txt
@@ -0,0 +1,505 @@
1ACPI on ARMv8 Servers
2---------------------
3ACPI can be used for ARMv8 general purpose servers designed to follow
4the ARM SBSA (Server Base System Architecture) [0] and SBBR (Server
5Base Boot Requirements) [1] specifications. Please note that the SBBR
6can be retrieved simply by visiting [1], but the SBSA is currently only
7available to those with an ARM login due to ARM IP licensing concerns.
8
9The ARMv8 kernel implements the reduced hardware model of ACPI version
105.1 or later. Links to the specification and all external documents
11it refers to are managed by the UEFI Forum. The specification is
12available at http://www.uefi.org/specifications and documents referenced
13by the specification can be found via http://www.uefi.org/acpi.
14
15If an ARMv8 system does not meet the requirements of the SBSA and SBBR,
16or cannot be described using the mechanisms defined in the required ACPI
17specifications, then ACPI may not be a good fit for the hardware.
18
19While the documents mentioned above set out the requirements for building
20industry-standard ARMv8 servers, they also apply to more than one operating
21system. The purpose of this document is to describe the interaction between
22ACPI and Linux only, on an ARMv8 system -- that is, what Linux expects of
23ACPI and what ACPI can expect of Linux.
24
25
26Why ACPI on ARM?
27----------------
28Before examining the details of the interface between ACPI and Linux, it is
29useful to understand why ACPI is being used. Several technologies already
30exist in Linux for describing non-enumerable hardware, after all. In this
31section we summarize a blog post [2] from Grant Likely that outlines the
32reasoning behind ACPI on ARMv8 servers. Actually, we snitch a good portion
33of the summary text almost directly, to be honest.
34
35The short form of the rationale for ACPI on ARM is:
36
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
66Key to the use of ACPI is the support model. For servers in general, the
67responsibility for hardware behaviour cannot solely be the domain of the
68kernel, but rather must be split between the platform and the kernel, in
69order to allow for orderly change over time. ACPI frees the OS from needing
70to understand all the minute details of the hardware so that the OS doesn’t
71need to be ported to each and every device individually. It allows the
72hardware vendors to take responsibility for power management behaviour without
73depending on an OS release cycle which is not under their control.
74
75ACPI is also important because hardware and OS vendors have already worked
76out the mechanisms for supporting a general purpose computing ecosystem. The
77infrastructure is in place, the bindings are in place, and the processes are
78in place. DT does exactly what Linux needs it to when working with vertically
79integrated devices, but there are no good processes for supporting what the
80server vendors need. Linux could potentially get there with DT, but doing so
81really just duplicates something that already works. ACPI already does what
82the hardware vendors need, Microsoft won’t collaborate on DT, and hardware
83vendors would still end up providing two completely separate firmware
84interfaces -- one for Linux and one for Windows.
85
86
87Kernel Compatibility
88--------------------
89One of the primary motivations for ACPI is standardization, and using that
90to provide backward compatibility for Linux kernels. In the server market,
91software and hardware are often used for long periods. ACPI allows the
92kernel and firmware to agree on a consistent abstraction that can be
93maintained over time, even as hardware or software change. As long as the
94abstraction is supported, systems can be updated without necessarily having
95to replace the kernel.
96
97When a Linux driver or subsystem is first implemented using ACPI, it by
98definition ends up requiring a specific version of the ACPI specification
99-- it's baseline. ACPI firmware must continue to work, even though it may
100not be optimal, with the earliest kernel version that first provides support
101for that baseline version of ACPI. There may be a need for additional drivers,
102but adding new functionality (e.g., CPU power management) should not break
103older kernel versions. Further, ACPI firmware must also work with the most
104recent version of the kernel.
105
106
107Relationship with Device Tree
108-----------------------------
109ACPI support in drivers and subsystems for ARMv8 should never be mutually
110exclusive with DT support at compile time.
111
112At boot time the kernel will only use one description method depending on
113parameters passed from the bootloader (including kernel bootargs).
114
115Regardless of whether DT or ACPI is used, the kernel must always be capable
116of booting with either scheme (in kernels with both schemes enabled at compile
117time).
118
119
120Booting using ACPI tables
121-------------------------
122The only defined method for passing ACPI tables to the kernel on ARMv8
123is via the UEFI system configuration table. Just so it is explicit, this
124means that ACPI is only supported on platforms that boot via UEFI.
125
126When an ARMv8 system boots, it can either have DT information, ACPI tables,
127or in some very unusual cases, both. If no command line parameters are used,
128the kernel will try to use DT for device enumeration; if there is no DT
129present, the kernel will try to use ACPI tables, but only if they are present.
130In neither is available, the kernel will not boot. If acpi=force is used
131on the command line, the kernel will attempt to use ACPI tables first, but
132fall back to DT if there are no ACPI tables present. The basic idea is that
133the kernel will not fail to boot unless it absolutely has no other choice.
134
135Processing of ACPI tables may be disabled by passing acpi=off on the kernel
136command line; this is the default behavior.
137
138In order for the kernel to load and use ACPI tables, the UEFI implementation
139MUST set the ACPI_20_TABLE_GUID to point to the RSDP table (the table with
140the ACPI signature "RSD PTR "). If this pointer is incorrect and acpi=force
141is used, the kernel will disable ACPI and try to use DT to boot instead; the
142kernel has, in effect, determined that ACPI tables are not present at that
143point.
144
145If the pointer to the RSDP table is correct, the table will be mapped into
146the kernel by the ACPI core, using the address provided by UEFI.
147
148The ACPI core will then locate and map in all other ACPI tables provided by
149using the addresses in the RSDP table to find the XSDT (eXtended System
150Description Table). The XSDT in turn provides the addresses to all other
151ACPI tables provided by the system firmware; the ACPI core will then traverse
152this table and map in the tables listed.
153
154The ACPI core will ignore any provided RSDT (Root System Description Table).
155RSDTs have been deprecated and are ignored on arm64 since they only allow
156for 32-bit addresses.
157
158Further, the ACPI core will only use the 64-bit address fields in the FADT
159(Fixed ACPI Description Table). Any 32-bit address fields in the FADT will
160be ignored on arm64.
161
162Hardware reduced mode (see Section 4.1 of the ACPI 5.1 specification) will
163be enforced by the ACPI core on arm64. Doing so allows the ACPI core to
164run less complex code since it no longer has to provide support for legacy
165hardware from other architectures. Any fields that are not to be used for
166hardware reduced mode must be set to zero.
167
168For the ACPI core to operate properly, and in turn provide the information
169the kernel needs to configure devices, it expects to find the following
170tables (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
188If the above tables are not all present, the kernel may or may not be
189able to boot properly since it may not be able to configure all of the
190devices available.
191
192
193ACPI Detection
194--------------
195Drivers should determine their probe() type by checking for a null
196value for ACPI_HANDLE, or checking .of_node, or other information in
197the device structure. This is detailed further in the "Driver
198Recommendations" section.
199
200In non-driver code, if the presence of ACPI needs to be detected at
201runtime, then check the value of acpi_disabled. If CONFIG_ACPI is not
202set, acpi_disabled will always be 1.
203
204
205Device Enumeration
206------------------
207Device descriptions in ACPI should use standard recognized ACPI interfaces.
208These may contain less information than is typically provided via a Device
209Tree description for the same device. This is also one of the reasons that
210ACPI can be useful -- the driver takes into account that it may have less
211detailed information about the device and uses sensible defaults instead.
212If done properly in the driver, the hardware can change and improve over
213time without the driver having to change at all.
214
215Clocks provide an excellent example. In DT, clocks need to be specified
216and the drivers need to take them into account. In ACPI, the assumption
217is that UEFI will leave the device in a reasonable default state, including
218any clock settings. If for some reason the driver needs to change a clock
219value, this can be done in an ACPI method; all the driver needs to do is
220invoke the method and not concern itself with what the method needs to do
221to change the clock. Changing the hardware can then take place over time
222by changing what the ACPI method does, and not the driver.
223
224In DT, the parameters needed by the driver to set up clocks as in the example
225above are known as "bindings"; in ACPI, these are known as "Device Properties"
226and provided to a driver via the _DSD object.
227
228ACPI tables are described with a formal language called ASL, the ACPI
229Source Language (section 19 of the specification). This means that there
230are always multiple ways to describe the same thing -- including device
231properties. For example, device properties could use an ASL construct
232that looks like this: Name(KEY0, "value0"). An ACPI device driver would
233then retrieve the value of the property by evaluating the KEY0 object.
234However, using Name() this way has multiple problems: (1) ACPI limits
235names ("KEY0") to four characters unlike DT; (2) there is no industry
236wide registry that maintains a list of names, minimzing re-use; (3)
237there is also no registry for the definition of property values ("value0"),
238again making re-use difficult; and (4) how does one maintain backward
239compatibility as new hardware comes out? The _DSD method was created
240to solve precisely these sorts of problems; Linux drivers should ALWAYS
241use the _DSD method for device properties and nothing else.
242
243The _DSM object (ACPI Section 9.14.1) could also be used for conveying
244device properties to a driver. Linux drivers should only expect it to
245be used if _DSD cannot represent the data required, and there is no way
246to create a new UUID for the _DSD object. Note that there is even less
247regulation of the use of _DSM than there is of _DSD. Drivers that depend
248on the contents of _DSM objects will be more difficult to maintain over
249time because of this; as of this writing, the use of _DSM is the cause
250of quite a few firmware problems and is not recommended.
251
252Drivers should look for device properties in the _DSD object ONLY; the _DSD
253object is described in the ACPI specification section 6.2.5, but this only
254describes how to define the structure of an object returned via _DSD, and
255how specific data structures are defined by specific UUIDs. Linux should
256only 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
262The UEFI Forum provides a mechanism for registering device properties [4]
263so that they may be used across all operating systems supporting ACPI.
264Device properties that have not been registered with the UEFI Forum should
265not be used.
266
267Before creating new device properties, check to be sure that they have not
268been defined before and either registered in the Linux kernel documentation
269as DT bindings, or the UEFI Forum as device properties. While we do not want
270to simply move all DT bindings into ACPI device properties, we can learn from
271what has been previously defined.
272
273If it is necessary to define a new device property, or if it makes sense to
274synthesize the definition of a binding so it can be used in any firmware,
275both DT bindings and ACPI device properties for device drivers have review
276processes. Use them both. When the driver itself is submitted for review
277to the Linux mailing lists, the device property definitions needed must be
278submitted at the same time. A driver that supports ACPI and uses device
279properties will not be considered complete without their definitions. Once
280the device property has been accepted by the Linux community, it must be
281registered with the UEFI Forum [4], which will review it again for consistency
282within the registry. This may require iteration. The UEFI Forum, though,
283will always be the canonical site for device property definitions.
284
285It may make sense to provide notice to the UEFI Forum that there is the
286intent to register a previously unused device property name as a means of
287reserving the name for later use. Other operating system vendors will
288also be submitting registration requests and this may help smooth the
289process.
290
291Once registration and review have been completed, the kernel provides an
292interface for looking up device properties in a manner independent of
293whether DT or ACPI is being used. This API should be used [6]; it can
294eliminate some duplication of code paths in driver probing functions and
295discourage divergence between DT bindings and ACPI device properties.
296
297
298Programmable Power Control Resources
299------------------------------------
300Programmable power control resources include such resources as voltage/current
301providers (regulators) and clock sources.
302
303With ACPI, the kernel clock and regulator framework is not expected to be used
304at all.
305
306The kernel assumes that power control of these resources is represented with
307Power Resource Objects (ACPI section 7.1). The ACPI core will then handle
308correctly enabling and disabling resources as they are needed. In order to
309get that to work, ACPI assumes each device has defined D-states and that these
310can be controlled through the optional ACPI methods _PS0, _PS1, _PS2, and _PS3;
311in ACPI, _PS0 is the method to invoke to turn a device full on, and _PS3 is for
312turning a device full off.
313
314There 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
325The kernel ACPI code will also assume that the _PSx methods follow the normal
326ACPI 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
340Such code in _PSx methods will of course be very platform specific. But,
341this allows the driver to abstract out the interface for operating the device
342and avoid having to read special non-standard values from ACPI tables. Further,
343abstracting the use of these resources allows the hardware to change over time
344without requiring updates to the driver.
345
346
347Clocks
348------
349ACPI makes the assumption that clocks are initialized by the firmware --
350UEFI, in this case -- to some working value before control is handed over
351to the kernel. This has implications for devices such as UARTs, or SoC-driven
352LCD displays, for example.
353
354When the kernel boots, the clocks are assumed to be set to reasonable
355working values. If for some reason the frequency needs to change -- e.g.,
356throttling for power management -- the device driver should expect that
357process to be abstracted out into some ACPI method that can be invoked
358(please see the ACPI specification for further recommendations on standard
359methods to be expected). The only exceptions to this are CPU clocks where
360CPPC provides a much richer interface than ACPI methods. If the clocks
361are not set, there is no direct way for Linux to control them.
362
363If an SoC vendor wants to provide fine-grained control of the system clocks,
364they could do so by providing ACPI methods that could be invoked by Linux
365drivers. However, this is NOT recommended and Linux drivers should NOT use
366such methods, even if they are provided. Such methods are not currently
367standardized in the ACPI specification, and using them could tie a kernel
368to a very specific SoC, or tie an SoC to a very specific version of the
369kernel, both of which we are trying to avoid.
370
371
372Driver Recommendations
373----------------------
374DO NOT remove any DT handling when adding ACPI support for a driver. The
375same device may be used on many different systems.
376
377DO try to structure the driver so that it is data-driven. That is, set up
378a struct containing internal per-device state based on defaults and whatever
379else must be discovered by the driver probe function. Then, have the rest
380of the driver operate off of the contents of that struct. Doing so should
381allow most divergence between ACPI and DT functionality to be kept local to
382the probe function instead of being scattered throughout the driver. For
383example:
384
385static int device_probe_dt(struct platform_device *pdev)
386{
387 /* DT specific functionality */
388 ...
389}
390
391static int device_probe_acpi(struct platform_device *pdev)
392{
393 /* ACPI specific functionality */
394 ...
395}
396
397static 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
414DO keep the MODULE_DEVICE_TABLE entries together in the driver to make it
415clear the different names the driver is probed for, both from DT and from
416ACPI:
417
418static struct of_device_id virtio_mmio_match[] = {
419 { .compatible = "virtio,mmio", },
420 { }
421};
422MODULE_DEVICE_TABLE(of, virtio_mmio_match);
423
424static const struct acpi_device_id virtio_mmio_acpi_match[] = {
425 { "LNRO0005", },
426 { }
427};
428MODULE_DEVICE_TABLE(acpi, virtio_mmio_acpi_match);
429
430
431ASWG
432----
433The ACPI specification changes regularly. During the year 2014, for instance,
434version 5.1 was released and version 6.0 substantially completed, with most of
435the changes being driven by ARM-specific requirements. Proposed changes are
436presented and discussed in the ASWG (ACPI Specification Working Group) which
437is a part of the UEFI Forum.
438
439Participation in this group is open to all UEFI members. Please see
440http://www.uefi.org/workinggroup for details on group membership.
441
442It is the intent of the ARMv8 ACPI kernel code to follow the ACPI specification
443as closely as possible, and to only implement functionality that complies with
444the released standards from UEFI ASWG. As a practical matter, there will be
445vendors that provide bad ACPI tables or violate the standards in some way.
446If this is because of errors, quirks and fixups may be necessary, but will
447be avoided if possible. If there are features missing from ACPI that preclude
448it from being used on a platform, ECRs (Engineering Change Requests) should be
449submitted to ASWG and go through the normal approval process; for those that
450are not UEFI members, many other members of the Linux community are and would
451likely be willing to assist in submitting ECRs.
452
453
454Linux Code
455----------
456Individual items specific to Linux on ARM, contained in the the Linux
457source code, are in the list that follows:
458
459ACPI_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
467ACPI Objects
468------------
469Detailed expectations for ACPI tables and object are listed in the file
470Documentation/arm64/acpi_object_usage.txt.
471
472
473References
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
499Authors
500-------
501Al Stone <al.stone@linaro.org>
502Graeme Gregory <graeme.gregory@linaro.org>
503Hanjun Guo <hanjun.guo@linaro.org>
504
505Grant Likely <grant.likely@linaro.org>, for the "Why ACPI on ARM?" section
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 84960c66c77b..f6befa9855c1 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -165,7 +165,7 @@ multipliers 'Kilo', 'Mega', and 'Giga', equalling 2^10, 2^20, and 2^30
165bytes respectively. Such letter suffixes can also be entirely omitted. 165bytes 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 Advanced Configuration and Power Interface 169 Advanced Configuration and Power Interface
170 Format: { force | off | strict | noirq | rsdt } 170 Format: { force | off | strict | noirq | rsdt }
171 force -- enable ACPI if default was off 171 force -- enable ACPI if default was off
@@ -175,6 +175,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
175 strictly ACPI specification compliant. 175 strictly ACPI specification compliant.
176 rsdt -- prefer RSDT over (default) XSDT 176 rsdt -- prefer RSDT over (default) XSDT
177 copy_dsdt -- copy DSDT to memory 177 copy_dsdt -- copy DSDT to memory
178 For ARM64, ONLY "acpi=off" or "acpi=force" are available
178 179
179 See also Documentation/power/runtime_pm.txt, pci=noacpi 180 See also Documentation/power/runtime_pm.txt, pci=noacpi
180 181
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index da5f20e8cc50..4269dba63cf1 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -1,5 +1,7 @@
1config ARM64 1config ARM64
2 def_bool y 2 def_bool y
3 select ACPI_GENERIC_GSI if ACPI
4 select ACPI_REDUCED_HARDWARE_ONLY if ACPI
3 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE 5 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
4 select ARCH_HAS_ELF_RANDOMIZE 6 select ARCH_HAS_ELF_RANDOMIZE
5 select ARCH_HAS_GCOV_PROFILE_ALL 7 select ARCH_HAS_GCOV_PROFILE_ALL
@@ -758,6 +760,8 @@ source "drivers/Kconfig"
758 760
759source "drivers/firmware/Kconfig" 761source "drivers/firmware/Kconfig"
760 762
763source "drivers/acpi/Kconfig"
764
761source "fs/Kconfig" 765source "fs/Kconfig"
762 766
763source "arch/arm64/kvm/Kconfig" 767source "arch/arm64/kvm/Kconfig"
diff --git a/arch/arm64/include/asm/acenv.h b/arch/arm64/include/asm/acenv.h
new file mode 100644
index 000000000000..b49166fde7ea
--- /dev/null
+++ b/arch/arm64/include/asm/acenv.h
@@ -0,0 +1,18 @@
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 */
diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
new file mode 100644
index 000000000000..59c05d8ea4a0
--- /dev/null
+++ b/arch/arm64/include/asm/acpi.h
@@ -0,0 +1,96 @@
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 */
24static 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
34typedef u64 phys_cpuid_t;
35#define PHYS_CPUID_INVALID INVALID_HWID
36
37#define acpi_strict 1 /* No out-of-spec workarounds on ARM64 */
38extern int acpi_disabled;
39extern int acpi_noirq;
40extern int acpi_pci_disabled;
41
42/* 1 to indicate PSCI 0.2+ is implemented */
43static 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 */
49static inline bool acpi_psci_use_hvc(void)
50{
51 return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC;
52}
53
54static inline void disable_acpi(void)
55{
56 acpi_disabled = 1;
57 acpi_pci_disabled = 1;
58 acpi_noirq = 1;
59}
60
61static 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 */
82static inline bool acpi_has_cpu_in_madt(void)
83{
84 return true;
85}
86
87static inline void arch_fix_phys_package_id(int num, u32 slot) { }
88void __init acpi_init_cpus(void);
89
90#else
91static inline bool acpi_psci_present(void) { return false; }
92static inline bool acpi_psci_use_hvc(void) { return false; }
93static inline void acpi_init_cpus(void) { }
94#endif /* CONFIG_ACPI */
95
96#endif /*_ASM_ACPI_H*/
diff --git a/arch/arm64/include/asm/cpu_ops.h b/arch/arm64/include/asm/cpu_ops.h
index da301ee7395c..5a31d6716914 100644
--- a/arch/arm64/include/asm/cpu_ops.h
+++ b/arch/arm64/include/asm/cpu_ops.h
@@ -66,5 +66,6 @@ struct cpu_operations {
66extern const struct cpu_operations *cpu_ops[NR_CPUS]; 66extern const struct cpu_operations *cpu_ops[NR_CPUS];
67int __init cpu_read_ops(struct device_node *dn, int cpu); 67int __init cpu_read_ops(struct device_node *dn, int cpu);
68void __init cpu_read_bootcpu_ops(void); 68void __init cpu_read_bootcpu_ops(void);
69const struct cpu_operations *cpu_get_ops(const char *name);
69 70
70#endif /* ifndef __ASM_CPU_OPS_H */ 71#endif /* ifndef __ASM_CPU_OPS_H */
diff --git a/arch/arm64/include/asm/fixmap.h b/arch/arm64/include/asm/fixmap.h
index 926495686554..95e6b6dcbe37 100644
--- a/arch/arm64/include/asm/fixmap.h
+++ b/arch/arm64/include/asm/fixmap.h
@@ -62,6 +62,9 @@ void __init early_fixmap_init(void);
62 62
63#define __early_set_fixmap __set_fixmap 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
65extern void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot); 68extern void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot);
66 69
67#include <asm-generic/fixmap.h> 70#include <asm-generic/fixmap.h>
diff --git a/arch/arm64/include/asm/irq.h b/arch/arm64/include/asm/irq.h
index 94c53674a31d..bbb251b14746 100644
--- a/arch/arm64/include/asm/irq.h
+++ b/arch/arm64/include/asm/irq.h
@@ -1,6 +1,8 @@
1#ifndef __ASM_IRQ_H 1#ifndef __ASM_IRQ_H
2#define __ASM_IRQ_H 2#define __ASM_IRQ_H
3 3
4#include <linux/irqchip/arm-gic-acpi.h>
5
4#include <asm-generic/irq.h> 6#include <asm-generic/irq.h>
5 7
6struct pt_regs; 8struct pt_regs;
@@ -8,4 +10,15 @@ struct pt_regs;
8extern void migrate_irqs(void); 10extern void migrate_irqs(void);
9extern void set_handle_irq(void (*handle_irq)(struct pt_regs *)); 11extern void set_handle_irq(void (*handle_irq)(struct pt_regs *));
10 12
13static 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
23
11#endif 24#endif
diff --git a/arch/arm64/include/asm/pci.h b/arch/arm64/include/asm/pci.h
index 872ba939fcb2..b008a72f8bc0 100644
--- a/arch/arm64/include/asm/pci.h
+++ b/arch/arm64/include/asm/pci.h
@@ -27,6 +27,12 @@
27extern int isa_dma_bridge_buggy; 27extern int isa_dma_bridge_buggy;
28 28
29#ifdef CONFIG_PCI 29#ifdef CONFIG_PCI
30static 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
30static inline int pci_proc_domain(struct pci_bus *bus) 36static inline int pci_proc_domain(struct pci_bus *bus)
31{ 37{
32 return 1; 38 return 1;
diff --git a/arch/arm64/include/asm/psci.h b/arch/arm64/include/asm/psci.h
index e5312ea0ec1a..2454bc59c916 100644
--- a/arch/arm64/include/asm/psci.h
+++ b/arch/arm64/include/asm/psci.h
@@ -14,6 +14,7 @@
14#ifndef __ASM_PSCI_H 14#ifndef __ASM_PSCI_H
15#define __ASM_PSCI_H 15#define __ASM_PSCI_H
16 16
17int psci_init(void); 17int psci_dt_init(void);
18int psci_acpi_init(void);
18 19
19#endif /* __ASM_PSCI_H */ 20#endif /* __ASM_PSCI_H */
diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h
index 780f82c827b6..bf22650b1a78 100644
--- a/arch/arm64/include/asm/smp.h
+++ b/arch/arm64/include/asm/smp.h
@@ -39,9 +39,10 @@ extern void show_ipi_list(struct seq_file *p, int prec);
39extern void handle_IPI(int ipinr, struct pt_regs *regs); 39extern 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 */
44extern void smp_init_cpus(void); 45extern void of_smp_init_cpus(void);
45 46
46/* 47/*
47 * Provide a function to raise an IPI cross call on CPUs in callmap. 48 * Provide a function to raise an IPI cross call on CPUs in callmap.
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index b12e15b80516..426d0763c81b 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -35,6 +35,7 @@ arm64-obj-$(CONFIG_KGDB) += kgdb.o
35arm64-obj-$(CONFIG_EFI) += efi.o efi-stub.o efi-entry.o 35arm64-obj-$(CONFIG_EFI) += efi.o efi-stub.o efi-entry.o
36arm64-obj-$(CONFIG_PCI) += pci.o 36arm64-obj-$(CONFIG_PCI) += pci.o
37arm64-obj-$(CONFIG_ARMV8_DEPRECATED) += armv8_deprecated.o 37arm64-obj-$(CONFIG_ARMV8_DEPRECATED) += armv8_deprecated.o
38arm64-obj-$(CONFIG_ACPI) += acpi.o
38 39
39obj-y += $(arm64-obj-y) vdso/ 40obj-y += $(arm64-obj-y) vdso/
40obj-m += $(arm64-obj-m) 41obj-m += $(arm64-obj-m)
diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
new file mode 100644
index 000000000000..8b839558838e
--- /dev/null
+++ b/arch/arm64/kernel/acpi.c
@@ -0,0 +1,345 @@
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
32int acpi_noirq = 1; /* skip ACPI IRQ initialization */
33int acpi_disabled = 1;
34EXPORT_SYMBOL(acpi_disabled);
35
36int acpi_pci_disabled = 1; /* skip ACPI PCI scan and IRQ initialization */
37EXPORT_SYMBOL(acpi_pci_disabled);
38
39/* Processors with enabled flag and sane MPIDR */
40static int enabled_cpus;
41
42/* Boot CPU is valid or not in MADT */
43static bool bootcpu_valid __initdata;
44
45static bool param_acpi_off __initdata;
46static bool param_acpi_force __initdata;
47
48static 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}
63early_param("acpi", parse_acpi);
64
65static 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 */
82char *__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
90void __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 */
102static void __init
103acpi_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
167static int __init
168acpi_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 */
184void __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 */
222static 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
263out:
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 */
290void __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
322void __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}
diff --git a/arch/arm64/kernel/cpu_ops.c b/arch/arm64/kernel/cpu_ops.c
index cce952440c64..fb8ff9ba467a 100644
--- a/arch/arm64/kernel/cpu_ops.c
+++ b/arch/arm64/kernel/cpu_ops.c
@@ -35,7 +35,7 @@ static const struct cpu_operations *supported_cpu_ops[] __initconst = {
35 NULL, 35 NULL,
36}; 36};
37 37
38static const struct cpu_operations * __init cpu_get_ops(const char *name) 38const struct cpu_operations * __init cpu_get_ops(const char *name)
39{ 39{
40 const struct cpu_operations **ops = supported_cpu_ops; 40 const struct cpu_operations **ops = supported_cpu_ops;
41 41
diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
index 6f93c24ca801..4095379dc069 100644
--- a/arch/arm64/kernel/pci.c
+++ b/arch/arm64/kernel/pci.c
@@ -10,6 +10,7 @@
10 * 10 *
11 */ 11 */
12 12
13#include <linux/acpi.h>
13#include <linux/init.h> 14#include <linux/init.h>
14#include <linux/io.h> 15#include <linux/io.h>
15#include <linux/kernel.h> 16#include <linux/kernel.h>
@@ -46,3 +47,27 @@ int pcibios_add_device(struct pci_dev *dev)
46 47
47 return 0; 48 return 0;
48} 49}
50
51/*
52 * raw_pci_read/write - Platform-specific PCI config space access.
53 */
54int raw_pci_read(unsigned int domain, unsigned int bus,
55 unsigned int devfn, int reg, int len, u32 *val)
56{
57 return -ENXIO;
58}
59
60int raw_pci_write(unsigned int domain, unsigned int bus,
61 unsigned int devfn, int reg, int len, u32 val)
62{
63 return -ENXIO;
64}
65
66#ifdef CONFIG_ACPI
67/* Root bridge scanning */
68struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
69{
70 /* TODO: Should be revisited when implementing PCI on ACPI */
71 return NULL;
72}
73#endif
diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c
index 9b8a70ae64a1..ea18cb53921e 100644
--- a/arch/arm64/kernel/psci.c
+++ b/arch/arm64/kernel/psci.c
@@ -15,6 +15,7 @@
15 15
16#define pr_fmt(fmt) "psci: " fmt 16#define pr_fmt(fmt) "psci: " fmt
17 17
18#include <linux/acpi.h>
18#include <linux/init.h> 19#include <linux/init.h>
19#include <linux/of.h> 20#include <linux/of.h>
20#include <linux/smp.h> 21#include <linux/smp.h>
@@ -24,6 +25,7 @@
24#include <linux/slab.h> 25#include <linux/slab.h>
25#include <uapi/linux/psci.h> 26#include <uapi/linux/psci.h>
26 27
28#include <asm/acpi.h>
27#include <asm/compiler.h> 29#include <asm/compiler.h>
28#include <asm/cpu_ops.h> 30#include <asm/cpu_ops.h>
29#include <asm/errno.h> 31#include <asm/errno.h>
@@ -273,39 +275,8 @@ static void psci_sys_poweroff(void)
273 invoke_psci_fn(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0); 275 invoke_psci_fn(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0);
274} 276}
275 277
276/* 278static void __init psci_0_2_set_functions(void)
277 * PSCI Function IDs for v0.2+ are well defined so use
278 * standard values.
279 */
280static int __init psci_0_2_init(struct device_node *np)
281{ 279{
282 int err, ver;
283
284 err = get_set_conduit_method(np);
285
286 if (err)
287 goto out_put_node;
288
289 ver = psci_get_version();
290
291 if (ver == PSCI_RET_NOT_SUPPORTED) {
292 /* PSCI v0.2 mandates implementation of PSCI_ID_VERSION. */
293 pr_err("PSCI firmware does not comply with the v0.2 spec.\n");
294 err = -EOPNOTSUPP;
295 goto out_put_node;
296 } else {
297 pr_info("PSCIv%d.%d detected in firmware.\n",
298 PSCI_VERSION_MAJOR(ver),
299 PSCI_VERSION_MINOR(ver));
300
301 if (PSCI_VERSION_MAJOR(ver) == 0 &&
302 PSCI_VERSION_MINOR(ver) < 2) {
303 err = -EINVAL;
304 pr_err("Conflicting PSCI version detected.\n");
305 goto out_put_node;
306 }
307 }
308
309 pr_info("Using standard PSCI v0.2 function IDs\n"); 280 pr_info("Using standard PSCI v0.2 function IDs\n");
310 psci_function_id[PSCI_FN_CPU_SUSPEND] = PSCI_0_2_FN64_CPU_SUSPEND; 281 psci_function_id[PSCI_FN_CPU_SUSPEND] = PSCI_0_2_FN64_CPU_SUSPEND;
311 psci_ops.cpu_suspend = psci_cpu_suspend; 282 psci_ops.cpu_suspend = psci_cpu_suspend;
@@ -329,6 +300,60 @@ static int __init psci_0_2_init(struct device_node *np)
329 arm_pm_restart = psci_sys_reset; 300 arm_pm_restart = psci_sys_reset;
330 301
331 pm_power_off = psci_sys_poweroff; 302 pm_power_off = psci_sys_poweroff;
303}
304
305/*
306 * Probe function for PSCI firmware versions >= 0.2
307 */
308static int __init psci_probe(void)
309{
310 int ver = psci_get_version();
311
312 if (ver == PSCI_RET_NOT_SUPPORTED) {
313 /*
314 * PSCI versions >=0.2 mandates implementation of
315 * PSCI_VERSION.
316 */
317 pr_err("PSCI firmware does not comply with the v0.2 spec.\n");
318 return -EOPNOTSUPP;
319 } else {
320 pr_info("PSCIv%d.%d detected in firmware.\n",
321 PSCI_VERSION_MAJOR(ver),
322 PSCI_VERSION_MINOR(ver));
323
324 if (PSCI_VERSION_MAJOR(ver) == 0 &&
325 PSCI_VERSION_MINOR(ver) < 2) {
326 pr_err("Conflicting PSCI version detected.\n");
327 return -EINVAL;
328 }
329 }
330
331 psci_0_2_set_functions();
332
333 return 0;
334}
335
336/*
337 * PSCI init function for PSCI versions >=0.2
338 *
339 * Probe based on PSCI PSCI_VERSION function
340 */
341static int __init psci_0_2_init(struct device_node *np)
342{
343 int err;
344
345 err = get_set_conduit_method(np);
346
347 if (err)
348 goto out_put_node;
349 /*
350 * Starting with v0.2, the PSCI specification introduced a call
351 * (PSCI_VERSION) that allows probing the firmware version, so
352 * that PSCI function IDs and version specific initialization
353 * can be carried out according to the specific version reported
354 * by firmware
355 */
356 err = psci_probe();
332 357
333out_put_node: 358out_put_node:
334 of_node_put(np); 359 of_node_put(np);
@@ -381,7 +406,7 @@ static const struct of_device_id psci_of_match[] __initconst = {
381 {}, 406 {},
382}; 407};
383 408
384int __init psci_init(void) 409int __init psci_dt_init(void)
385{ 410{
386 struct device_node *np; 411 struct device_node *np;
387 const struct of_device_id *matched_np; 412 const struct of_device_id *matched_np;
@@ -396,6 +421,27 @@ int __init psci_init(void)
396 return init_fn(np); 421 return init_fn(np);
397} 422}
398 423
424/*
425 * We use PSCI 0.2+ when ACPI is deployed on ARM64 and it's
426 * explicitly clarified in SBBR
427 */
428int __init psci_acpi_init(void)
429{
430 if (!acpi_psci_present()) {
431 pr_info("is not implemented in ACPI.\n");
432 return -EOPNOTSUPP;
433 }
434
435 pr_info("probing for conduit method from ACPI.\n");
436
437 if (acpi_psci_use_hvc())
438 invoke_psci_fn = __invoke_psci_fn_hvc;
439 else
440 invoke_psci_fn = __invoke_psci_fn_smc;
441
442 return psci_probe();
443}
444
399#ifdef CONFIG_SMP 445#ifdef CONFIG_SMP
400 446
401static int __init cpu_psci_cpu_init(struct device_node *dn, unsigned int cpu) 447static int __init cpu_psci_cpu_init(struct device_node *dn, unsigned int cpu)
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 51ef97274b52..74753132c3ac 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -17,6 +17,7 @@
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */ 18 */
19 19
20#include <linux/acpi.h>
20#include <linux/export.h> 21#include <linux/export.h>
21#include <linux/kernel.h> 22#include <linux/kernel.h>
22#include <linux/stddef.h> 23#include <linux/stddef.h>
@@ -46,6 +47,7 @@
46#include <linux/efi.h> 47#include <linux/efi.h>
47#include <linux/personality.h> 48#include <linux/personality.h>
48 49
50#include <asm/acpi.h>
49#include <asm/fixmap.h> 51#include <asm/fixmap.h>
50#include <asm/cpu.h> 52#include <asm/cpu.h>
51#include <asm/cputype.h> 53#include <asm/cputype.h>
@@ -395,18 +397,27 @@ void __init setup_arch(char **cmdline_p)
395 efi_init(); 397 efi_init();
396 arm64_memblock_init(); 398 arm64_memblock_init();
397 399
400 /* Parse the ACPI tables for possible boot-time configuration */
401 acpi_boot_table_init();
402
398 paging_init(); 403 paging_init();
399 request_standard_resources(); 404 request_standard_resources();
400 405
401 early_ioremap_reset(); 406 early_ioremap_reset();
402 407
403 unflatten_device_tree(); 408 if (acpi_disabled) {
404 409 unflatten_device_tree();
405 psci_init(); 410 psci_dt_init();
411 cpu_read_bootcpu_ops();
412#ifdef CONFIG_SMP
413 of_smp_init_cpus();
414#endif
415 } else {
416 psci_acpi_init();
417 acpi_init_cpus();
418 }
406 419
407 cpu_read_bootcpu_ops();
408#ifdef CONFIG_SMP 420#ifdef CONFIG_SMP
409 smp_init_cpus();
410 smp_build_mpidr_hash(); 421 smp_build_mpidr_hash();
411#endif 422#endif
412 423
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index 714411f62391..2cb008177252 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -323,7 +323,7 @@ void __init smp_prepare_boot_cpu(void)
323 * cpu logical map array containing MPIDR values related to logical 323 * cpu logical map array containing MPIDR values related to logical
324 * cpus. Assumes that cpu_logical_map(0) has already been initialized. 324 * cpus. Assumes that cpu_logical_map(0) has already been initialized.
325 */ 325 */
326void __init smp_init_cpus(void) 326void __init of_smp_init_cpus(void)
327{ 327{
328 struct device_node *dn = NULL; 328 struct device_node *dn = NULL;
329 unsigned int i, cpu = 1; 329 unsigned int i, cpu = 1;
diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c
index 1a7125c3099b..42f9195cf2f8 100644
--- a/arch/arm64/kernel/time.c
+++ b/arch/arm64/kernel/time.c
@@ -35,6 +35,7 @@
35#include <linux/delay.h> 35#include <linux/delay.h>
36#include <linux/clocksource.h> 36#include <linux/clocksource.h>
37#include <linux/clk-provider.h> 37#include <linux/clk-provider.h>
38#include <linux/acpi.h>
38 39
39#include <clocksource/arm_arch_timer.h> 40#include <clocksource/arm_arch_timer.h>
40 41
@@ -72,6 +73,12 @@ void __init time_init(void)
72 73
73 tick_setup_hrtimer_broadcast(); 74 tick_setup_hrtimer_broadcast();
74 75
76 /*
77 * Since ACPI or FDT will only one be available in the system,
78 * we can use acpi_generic_timer_init() here safely
79 */
80 acpi_generic_timer_init();
81
75 arch_timer_rate = arch_timer_get_rate(); 82 arch_timer_rate = arch_timer_get_rate();
76 if (!arch_timer_rate) 83 if (!arch_timer_rate)
77 panic("Unable to initialise architected timer.\n"); 84 panic("Unable to initialise architected timer.\n");
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 4f9a6661491b..76d25b2cfbbe 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -15,6 +15,7 @@ config IA64
15 select ARCH_MIGHT_HAVE_PC_SERIO 15 select ARCH_MIGHT_HAVE_PC_SERIO
16 select PCI if (!IA64_HP_SIM) 16 select PCI if (!IA64_HP_SIM)
17 select ACPI if (!IA64_HP_SIM) 17 select ACPI if (!IA64_HP_SIM)
18 select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI
18 select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI 19 select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI
19 select HAVE_UNSTABLE_SCHED_CLOCK 20 select HAVE_UNSTABLE_SCHED_CLOCK
20 select HAVE_IDE 21 select HAVE_IDE
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index 35bf22cc71b7..b1698bc042c8 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -887,7 +887,7 @@ static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
887} 887}
888 888
889/* wrapper to silence section mismatch warning */ 889/* wrapper to silence section mismatch warning */
890int __ref acpi_map_cpu(acpi_handle handle, int physid, int *pcpu) 890int __ref acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu)
891{ 891{
892 return _acpi_map_lsapic(handle, physid, pcpu); 892 return _acpi_map_lsapic(handle, physid, pcpu);
893} 893}
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 6049d587599e..226d5696e1d1 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -22,6 +22,7 @@ config X86_64
22### Arch settings 22### Arch settings
23config X86 23config X86
24 def_bool y 24 def_bool y
25 select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI
25 select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI 26 select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI
26 select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS 27 select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
27 select ARCH_HAS_FAST_MULTIPLIER 28 select ARCH_HAS_FAST_MULTIPLIER
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 803b684676ff..dbe76a14c3c9 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -757,7 +757,7 @@ static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
757} 757}
758 758
759/* wrapper to silence section mismatch warning */ 759/* wrapper to silence section mismatch warning */
760int __ref acpi_map_cpu(acpi_handle handle, int physid, int *pcpu) 760int __ref acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu)
761{ 761{
762 return _acpi_map_lsapic(handle, physid, pcpu); 762 return _acpi_map_lsapic(handle, physid, pcpu);
763} 763}
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index e6c3ddd92665..ab2cbb51c6aa 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -5,7 +5,7 @@
5menuconfig ACPI 5menuconfig ACPI
6 bool "ACPI (Advanced Configuration and Power Interface) Support" 6 bool "ACPI (Advanced Configuration and Power Interface) Support"
7 depends on !IA64_HP_SIM 7 depends on !IA64_HP_SIM
8 depends on IA64 || X86 8 depends on IA64 || X86 || (ARM64 && EXPERT)
9 depends on PCI 9 depends on PCI
10 select PNP 10 select PNP
11 default y 11 default y
@@ -48,9 +48,16 @@ config ACPI_LEGACY_TABLES_LOOKUP
48config ARCH_MIGHT_HAVE_ACPI_PDC 48config ARCH_MIGHT_HAVE_ACPI_PDC
49 bool 49 bool
50 50
51config ACPI_GENERIC_GSI
52 bool
53
54config ACPI_SYSTEM_POWER_STATES_SUPPORT
55 bool
56
51config ACPI_SLEEP 57config ACPI_SLEEP
52 bool 58 bool
53 depends on SUSPEND || HIBERNATION 59 depends on SUSPEND || HIBERNATION
60 depends on ACPI_SYSTEM_POWER_STATES_SUPPORT
54 default y 61 default y
55 62
56config ACPI_PROCFS_POWER 63config ACPI_PROCFS_POWER
@@ -163,6 +170,7 @@ config ACPI_PROCESSOR
163 tristate "Processor" 170 tristate "Processor"
164 select THERMAL 171 select THERMAL
165 select CPU_IDLE 172 select CPU_IDLE
173 depends on X86 || IA64
166 default y 174 default y
167 help 175 help
168 This driver installs ACPI as the idle handler for Linux and uses 176 This driver installs ACPI as the idle handler for Linux and uses
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 623b117ad1a2..8a063e276530 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -23,7 +23,7 @@ acpi-y += nvs.o
23 23
24# Power management related files 24# Power management related files
25acpi-y += wakeup.o 25acpi-y += wakeup.o
26acpi-y += sleep.o 26acpi-$(CONFIG_ACPI_SYSTEM_POWER_STATES_SUPPORT) += sleep.o
27acpi-y += device_pm.o 27acpi-y += device_pm.o
28acpi-$(CONFIG_ACPI_SLEEP) += proc.o 28acpi-$(CONFIG_ACPI_SLEEP) += proc.o
29 29
@@ -56,6 +56,7 @@ ifdef CONFIG_ACPI_VIDEO
56acpi-y += video_detect.o 56acpi-y += video_detect.o
57endif 57endif
58acpi-y += acpi_lpat.o 58acpi-y += acpi_lpat.o
59acpi-$(CONFIG_ACPI_GENERIC_GSI) += gsi.o
59 60
60# These are (potentially) separate modules 61# These are (potentially) separate modules
61 62
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index 1020b1b53a17..58f335ca2e75 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -170,7 +170,7 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr)
170 acpi_status status; 170 acpi_status status;
171 int ret; 171 int ret;
172 172
173 if (pr->phys_id == -1) 173 if (pr->phys_id == PHYS_CPUID_INVALID)
174 return -ENODEV; 174 return -ENODEV;
175 175
176 status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta); 176 status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta);
@@ -215,7 +215,8 @@ static int acpi_processor_get_info(struct acpi_device *device)
215 union acpi_object object = { 0 }; 215 union acpi_object object = { 0 };
216 struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; 216 struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
217 struct acpi_processor *pr = acpi_driver_data(device); 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 acpi_status status = AE_OK; 220 acpi_status status = AE_OK;
220 static int cpu0_initialized; 221 static int cpu0_initialized;
221 unsigned long long value; 222 unsigned long long value;
@@ -263,7 +264,7 @@ static int acpi_processor_get_info(struct acpi_device *device)
263 } 264 }
264 265
265 phys_id = acpi_get_phys_id(pr->handle, device_declaration, pr->acpi_id); 266 phys_id = acpi_get_phys_id(pr->handle, device_declaration, pr->acpi_id);
266 if (phys_id < 0) 267 if (phys_id == PHYS_CPUID_INVALID)
267 acpi_handle_debug(pr->handle, "failed to get CPU physical ID.\n"); 268 acpi_handle_debug(pr->handle, "failed to get CPU physical ID.\n");
268 pr->phys_id = phys_id; 269 pr->phys_id = phys_id;
269 270
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 8b67bd0f6bb5..c412fdb28d34 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -448,6 +448,9 @@ static int __init acpi_bus_init_irq(void)
448 case ACPI_IRQ_MODEL_IOSAPIC: 448 case ACPI_IRQ_MODEL_IOSAPIC:
449 message = "IOSAPIC"; 449 message = "IOSAPIC";
450 break; 450 break;
451 case ACPI_IRQ_MODEL_GIC:
452 message = "GIC";
453 break;
451 case ACPI_IRQ_MODEL_PLATFORM: 454 case ACPI_IRQ_MODEL_PLATFORM:
452 message = "platform specific model"; 455 message = "platform specific model";
453 break; 456 break;
diff --git a/drivers/acpi/gsi.c b/drivers/acpi/gsi.c
new file mode 100644
index 000000000000..38208f2d0e69
--- /dev/null
+++ b/drivers/acpi/gsi.c
@@ -0,0 +1,105 @@
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
15enum acpi_irq_model_id acpi_irq_model;
16
17static 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 */
46int 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}
60EXPORT_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 */
72int 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}
93EXPORT_SYMBOL_GPL(acpi_register_gsi);
94
95/**
96 * acpi_unregister_gsi() - Free a GSI<->linux IRQ number mapping
97 * @gsi: GSI IRQ number
98 */
99void acpi_unregister_gsi(u32 gsi)
100{
101 int irq = irq_find_mapping(NULL, gsi);
102
103 irq_dispose_mapping(irq);
104}
105EXPORT_SYMBOL_GPL(acpi_unregister_gsi);
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 56b321aa2b1c..ba4a61e964be 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -161,7 +161,11 @@ void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit);
161/*-------------------------------------------------------------------------- 161/*--------------------------------------------------------------------------
162 Suspend/Resume 162 Suspend/Resume
163 -------------------------------------------------------------------------- */ 163 -------------------------------------------------------------------------- */
164#ifdef CONFIG_ACPI_SYSTEM_POWER_STATES_SUPPORT
164extern int acpi_sleep_init(void); 165extern int acpi_sleep_init(void);
166#else
167static inline int acpi_sleep_init(void) { return -ENXIO; }
168#endif
165 169
166#ifdef CONFIG_ACPI_SLEEP 170#ifdef CONFIG_ACPI_SLEEP
167int acpi_sleep_proc_init(void); 171int acpi_sleep_proc_init(void);
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index f9eeae871593..39748bb3a543 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -336,11 +336,11 @@ acpi_map_lookup_virt(void __iomem *virt, acpi_size size)
336 return NULL; 336 return NULL;
337} 337}
338 338
339#ifndef CONFIG_IA64 339#if defined(CONFIG_IA64) || defined(CONFIG_ARM64)
340#define should_use_kmap(pfn) page_is_ram(pfn)
341#else
342/* ioremap will take care of cache attributes */ 340/* ioremap will take care of cache attributes */
343#define should_use_kmap(pfn) 0 341#define should_use_kmap(pfn) 0
342#else
343#define should_use_kmap(pfn) page_is_ram(pfn)
344#endif 344#endif
345 345
346static void __iomem *acpi_map(acpi_physical_address pg_off, unsigned long pg_sz) 346static void __iomem *acpi_map(acpi_physical_address pg_off, unsigned long pg_sz)
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 7962651cdbd4..b1ec78b8a645 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -32,7 +32,7 @@ static struct acpi_table_madt *get_madt_table(void)
32} 32}
33 33
34static int map_lapic_id(struct acpi_subtable_header *entry, 34static 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 struct acpi_madt_local_apic *lapic = 37 struct acpi_madt_local_apic *lapic =
38 container_of(entry, struct acpi_madt_local_apic, header); 38 container_of(entry, struct acpi_madt_local_apic, header);
@@ -48,7 +48,7 @@ static int map_lapic_id(struct acpi_subtable_header *entry,
48} 48}
49 49
50static int map_x2apic_id(struct acpi_subtable_header *entry, 50static 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 struct acpi_madt_local_x2apic *apic = 53 struct acpi_madt_local_x2apic *apic =
54 container_of(entry, struct acpi_madt_local_x2apic, header); 54 container_of(entry, struct acpi_madt_local_x2apic, header);
@@ -65,7 +65,7 @@ static int map_x2apic_id(struct acpi_subtable_header *entry,
65} 65}
66 66
67static int map_lsapic_id(struct acpi_subtable_header *entry, 67static 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 struct acpi_madt_local_sapic *lsapic = 70 struct acpi_madt_local_sapic *lsapic =
71 container_of(entry, struct acpi_madt_local_sapic, header); 71 container_of(entry, struct acpi_madt_local_sapic, header);
@@ -83,10 +83,35 @@ static int map_lsapic_id(struct acpi_subtable_header *entry,
83 return 0; 83 return 0;
84} 84}
85 85
86static int map_madt_entry(int type, u32 acpi_id) 86/*
87 * Retrieve the ARM CPU physical identifier (MPIDR)
88 */
89static 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
111static phys_cpuid_t map_madt_entry(int type, u32 acpi_id)
87{ 112{
88 unsigned long madt_end, entry; 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 struct acpi_table_madt *madt; 115 struct acpi_table_madt *madt;
91 116
92 madt = get_madt_table(); 117 madt = get_madt_table();
@@ -111,18 +136,21 @@ static int map_madt_entry(int type, u32 acpi_id)
111 } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { 136 } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) {
112 if (!map_lsapic_id(header, type, acpi_id, &phys_id)) 137 if (!map_lsapic_id(header, type, acpi_id, &phys_id))
113 break; 138 break;
139 } else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) {
140 if (!map_gicc_mpidr(header, type, acpi_id, &phys_id))
141 break;
114 } 142 }
115 entry += header->length; 143 entry += header->length;
116 } 144 }
117 return phys_id; 145 return phys_id;
118} 146}
119 147
120static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id) 148static phys_cpuid_t map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
121{ 149{
122 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 150 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
123 union acpi_object *obj; 151 union acpi_object *obj;
124 struct acpi_subtable_header *header; 152 struct acpi_subtable_header *header;
125 int phys_id = -1; 153 phys_cpuid_t phys_id = PHYS_CPUID_INVALID;
126 154
127 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer))) 155 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
128 goto exit; 156 goto exit;
@@ -143,33 +171,35 @@ static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
143 map_lsapic_id(header, type, acpi_id, &phys_id); 171 map_lsapic_id(header, type, acpi_id, &phys_id);
144 else if (header->type == ACPI_MADT_TYPE_LOCAL_X2APIC) 172 else if (header->type == ACPI_MADT_TYPE_LOCAL_X2APIC)
145 map_x2apic_id(header, type, acpi_id, &phys_id); 173 map_x2apic_id(header, type, acpi_id, &phys_id);
174 else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT)
175 map_gicc_mpidr(header, type, acpi_id, &phys_id);
146 176
147exit: 177exit:
148 kfree(buffer.pointer); 178 kfree(buffer.pointer);
149 return phys_id; 179 return phys_id;
150} 180}
151 181
152int acpi_get_phys_id(acpi_handle handle, int type, u32 acpi_id) 182phys_cpuid_t acpi_get_phys_id(acpi_handle handle, int type, u32 acpi_id)
153{ 183{
154 int phys_id; 184 phys_cpuid_t phys_id;
155 185
156 phys_id = map_mat_entry(handle, type, acpi_id); 186 phys_id = map_mat_entry(handle, type, acpi_id);
157 if (phys_id == -1) 187 if (phys_id == PHYS_CPUID_INVALID)
158 phys_id = map_madt_entry(type, acpi_id); 188 phys_id = map_madt_entry(type, acpi_id);
159 189
160 return phys_id; 190 return phys_id;
161} 191}
162 192
163int acpi_map_cpuid(int phys_id, u32 acpi_id) 193int acpi_map_cpuid(phys_cpuid_t phys_id, u32 acpi_id)
164{ 194{
165#ifdef CONFIG_SMP 195#ifdef CONFIG_SMP
166 int i; 196 int i;
167#endif 197#endif
168 198
169 if (phys_id == -1) { 199 if (phys_id == PHYS_CPUID_INVALID) {
170 /* 200 /*
171 * On UP processor, there is no _MAT or MADT table. 201 * On UP processor, there is no _MAT or MADT table.
172 * So above phys_id is always set to -1. 202 * So above phys_id is always set to PHYS_CPUID_INVALID.
173 * 203 *
174 * BIOS may define multiple CPU handles even for UP processor. 204 * BIOS may define multiple CPU handles even for UP processor.
175 * For example, 205 * For example,
@@ -190,7 +220,7 @@ int acpi_map_cpuid(int phys_id, u32 acpi_id)
190 if (nr_cpu_ids <= 1 && acpi_id == 0) 220 if (nr_cpu_ids <= 1 && acpi_id == 0)
191 return acpi_id; 221 return acpi_id;
192 else 222 else
193 return phys_id; 223 return -1;
194 } 224 }
195 225
196#ifdef CONFIG_SMP 226#ifdef CONFIG_SMP
@@ -208,7 +238,7 @@ int acpi_map_cpuid(int phys_id, u32 acpi_id)
208 238
209int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id) 239int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
210{ 240{
211 int phys_id; 241 phys_cpuid_t phys_id;
212 242
213 phys_id = acpi_get_phys_id(handle, type, acpi_id); 243 phys_id = acpi_get_phys_id(handle, type, acpi_id);
214 244
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index 93b81523a2fe..2e19189da0ee 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -23,6 +23,8 @@
23 * 23 *
24 */ 24 */
25 25
26/* Uncomment next line to get verbose printout */
27/* #define DEBUG */
26#define pr_fmt(fmt) "ACPI: " fmt 28#define pr_fmt(fmt) "ACPI: " fmt
27 29
28#include <linux/init.h> 30#include <linux/init.h>
@@ -61,9 +63,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
61 { 63 {
62 struct acpi_madt_local_apic *p = 64 struct acpi_madt_local_apic *p =
63 (struct acpi_madt_local_apic *)header; 65 (struct acpi_madt_local_apic *)header;
64 pr_info("LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n", 66 pr_debug("LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n",
65 p->processor_id, p->id, 67 p->processor_id, p->id,
66 (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled"); 68 (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
67 } 69 }
68 break; 70 break;
69 71
@@ -71,9 +73,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
71 { 73 {
72 struct acpi_madt_local_x2apic *p = 74 struct acpi_madt_local_x2apic *p =
73 (struct acpi_madt_local_x2apic *)header; 75 (struct acpi_madt_local_x2apic *)header;
74 pr_info("X2APIC (apic_id[0x%02x] uid[0x%02x] %s)\n", 76 pr_debug("X2APIC (apic_id[0x%02x] uid[0x%02x] %s)\n",
75 p->local_apic_id, p->uid, 77 p->local_apic_id, p->uid,
76 (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled"); 78 (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
77 } 79 }
78 break; 80 break;
79 81
@@ -81,8 +83,8 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
81 { 83 {
82 struct acpi_madt_io_apic *p = 84 struct acpi_madt_io_apic *p =
83 (struct acpi_madt_io_apic *)header; 85 (struct acpi_madt_io_apic *)header;
84 pr_info("IOAPIC (id[0x%02x] address[0x%08x] gsi_base[%d])\n", 86 pr_debug("IOAPIC (id[0x%02x] address[0x%08x] gsi_base[%d])\n",
85 p->id, p->address, p->global_irq_base); 87 p->id, p->address, p->global_irq_base);
86 } 88 }
87 break; 89 break;
88 90
@@ -155,9 +157,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
155 { 157 {
156 struct acpi_madt_io_sapic *p = 158 struct acpi_madt_io_sapic *p =
157 (struct acpi_madt_io_sapic *)header; 159 (struct acpi_madt_io_sapic *)header;
158 pr_info("IOSAPIC (id[0x%x] address[%p] gsi_base[%d])\n", 160 pr_debug("IOSAPIC (id[0x%x] address[%p] gsi_base[%d])\n",
159 p->id, (void *)(unsigned long)p->address, 161 p->id, (void *)(unsigned long)p->address,
160 p->global_irq_base); 162 p->global_irq_base);
161 } 163 }
162 break; 164 break;
163 165
@@ -165,9 +167,9 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
165 { 167 {
166 struct acpi_madt_local_sapic *p = 168 struct acpi_madt_local_sapic *p =
167 (struct acpi_madt_local_sapic *)header; 169 (struct acpi_madt_local_sapic *)header;
168 pr_info("LSAPIC (acpi_id[0x%02x] lsapic_id[0x%02x] lsapic_eid[0x%02x] %s)\n", 170 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, 171 p->processor_id, p->id, p->eid,
170 (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled"); 172 (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
171 } 173 }
172 break; 174 break;
173 175
@@ -183,6 +185,28 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
183 } 185 }
184 break; 186 break;
185 187
188 case ACPI_MADT_TYPE_GENERIC_INTERRUPT:
189 {
190 struct acpi_madt_generic_interrupt *p =
191 (struct acpi_madt_generic_interrupt *)header;
192 pr_debug("GICC (acpi_id[0x%04x] address[%llx] MPIDR[0x%llx] %s)\n",
193 p->uid, p->base_address,
194 p->arm_mpidr,
195 (p->flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
196
197 }
198 break;
199
200 case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR:
201 {
202 struct acpi_madt_generic_distributor *p =
203 (struct acpi_madt_generic_distributor *)header;
204 pr_debug("GIC Distributor (gic_id[0x%04x] address[%llx] gsi_base[%d])\n",
205 p->gic_id, p->base_address,
206 p->global_irq_base);
207 }
208 break;
209
186 default: 210 default:
187 pr_warn("Found unsupported MADT entry (type = 0x%x)\n", 211 pr_warn("Found unsupported MADT entry (type = 0x%x)\n",
188 header->type); 212 header->type);
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index 266469691e58..0aa135ddbf80 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -22,6 +22,7 @@
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/sched_clock.h> 24#include <linux/sched_clock.h>
25#include <linux/acpi.h>
25 26
26#include <asm/arch_timer.h> 27#include <asm/arch_timer.h>
27#include <asm/virt.h> 28#include <asm/virt.h>
@@ -371,8 +372,12 @@ arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np)
371 if (arch_timer_rate) 372 if (arch_timer_rate)
372 return; 373 return;
373 374
374 /* Try to determine the frequency from the device tree or CNTFRQ */ 375 /*
375 if (of_property_read_u32(np, "clock-frequency", &arch_timer_rate)) { 376 * Try to determine the frequency from the device tree or CNTFRQ,
377 * if ACPI is enabled, get the frequency from CNTFRQ ONLY.
378 */
379 if (!acpi_disabled ||
380 of_property_read_u32(np, "clock-frequency", &arch_timer_rate)) {
376 if (cntbase) 381 if (cntbase)
377 arch_timer_rate = readl_relaxed(cntbase + CNTFRQ); 382 arch_timer_rate = readl_relaxed(cntbase + CNTFRQ);
378 else 383 else
@@ -691,28 +696,8 @@ static void __init arch_timer_common_init(void)
691 arch_timer_arch_init(); 696 arch_timer_arch_init();
692} 697}
693 698
694static void __init arch_timer_init(struct device_node *np) 699static void __init arch_timer_init(void)
695{ 700{
696 int i;
697
698 if (arch_timers_present & ARCH_CP15_TIMER) {
699 pr_warn("arch_timer: multiple nodes in dt, skipping\n");
700 return;
701 }
702
703 arch_timers_present |= ARCH_CP15_TIMER;
704 for (i = PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++)
705 arch_timer_ppi[i] = irq_of_parse_and_map(np, i);
706 arch_timer_detect_rate(NULL, np);
707
708 /*
709 * If we cannot rely on firmware initializing the timer registers then
710 * we should use the physical timers instead.
711 */
712 if (IS_ENABLED(CONFIG_ARM) &&
713 of_property_read_bool(np, "arm,cpu-registers-not-fw-configured"))
714 arch_timer_use_virtual = false;
715
716 /* 701 /*
717 * If HYP mode is available, we know that the physical timer 702 * If HYP mode is available, we know that the physical timer
718 * has been configured to be accessible from PL1. Use it, so 703 * has been configured to be accessible from PL1. Use it, so
@@ -731,13 +716,39 @@ static void __init arch_timer_init(struct device_node *np)
731 } 716 }
732 } 717 }
733 718
734 arch_timer_c3stop = !of_property_read_bool(np, "always-on");
735
736 arch_timer_register(); 719 arch_timer_register();
737 arch_timer_common_init(); 720 arch_timer_common_init();
738} 721}
739CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_init); 722
740CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_init); 723static void __init arch_timer_of_init(struct device_node *np)
724{
725 int i;
726
727 if (arch_timers_present & ARCH_CP15_TIMER) {
728 pr_warn("arch_timer: multiple nodes in dt, skipping\n");
729 return;
730 }
731
732 arch_timers_present |= ARCH_CP15_TIMER;
733 for (i = PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++)
734 arch_timer_ppi[i] = irq_of_parse_and_map(np, i);
735
736 arch_timer_detect_rate(NULL, np);
737
738 arch_timer_c3stop = !of_property_read_bool(np, "always-on");
739
740 /*
741 * If we cannot rely on firmware initializing the timer registers then
742 * we should use the physical timers instead.
743 */
744 if (IS_ENABLED(CONFIG_ARM) &&
745 of_property_read_bool(np, "arm,cpu-registers-not-fw-configured"))
746 arch_timer_use_virtual = false;
747
748 arch_timer_init();
749}
750CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_of_init);
751CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_of_init);
741 752
742static void __init arch_timer_mem_init(struct device_node *np) 753static void __init arch_timer_mem_init(struct device_node *np)
743{ 754{
@@ -804,3 +815,70 @@ static void __init arch_timer_mem_init(struct device_node *np)
804} 815}
805CLOCKSOURCE_OF_DECLARE(armv7_arch_timer_mem, "arm,armv7-timer-mem", 816CLOCKSOURCE_OF_DECLARE(armv7_arch_timer_mem, "arm,armv7-timer-mem",
806 arch_timer_mem_init); 817 arch_timer_mem_init);
818
819#ifdef CONFIG_ACPI
820static int __init map_generic_timer_interrupt(u32 interrupt, u32 flags)
821{
822 int trigger, polarity;
823
824 if (!interrupt)
825 return 0;
826
827 trigger = (flags & ACPI_GTDT_INTERRUPT_MODE) ? ACPI_EDGE_SENSITIVE
828 : ACPI_LEVEL_SENSITIVE;
829
830 polarity = (flags & ACPI_GTDT_INTERRUPT_POLARITY) ? ACPI_ACTIVE_LOW
831 : ACPI_ACTIVE_HIGH;
832
833 return acpi_register_gsi(NULL, interrupt, trigger, polarity);
834}
835
836/* Initialize per-processor generic timer */
837static int __init arch_timer_acpi_init(struct acpi_table_header *table)
838{
839 struct acpi_table_gtdt *gtdt;
840
841 if (arch_timers_present & ARCH_CP15_TIMER) {
842 pr_warn("arch_timer: already initialized, skipping\n");
843 return -EINVAL;
844 }
845
846 gtdt = container_of(table, struct acpi_table_gtdt, header);
847
848 arch_timers_present |= ARCH_CP15_TIMER;
849
850 arch_timer_ppi[PHYS_SECURE_PPI] =
851 map_generic_timer_interrupt(gtdt->secure_el1_interrupt,
852 gtdt->secure_el1_flags);
853
854 arch_timer_ppi[PHYS_NONSECURE_PPI] =
855 map_generic_timer_interrupt(gtdt->non_secure_el1_interrupt,
856 gtdt->non_secure_el1_flags);
857
858 arch_timer_ppi[VIRT_PPI] =
859 map_generic_timer_interrupt(gtdt->virtual_timer_interrupt,
860 gtdt->virtual_timer_flags);
861
862 arch_timer_ppi[HYP_PPI] =
863 map_generic_timer_interrupt(gtdt->non_secure_el2_interrupt,
864 gtdt->non_secure_el2_flags);
865
866 /* Get the frequency from CNTFRQ */
867 arch_timer_detect_rate(NULL, NULL);
868
869 /* Always-on capability */
870 arch_timer_c3stop = !(gtdt->non_secure_el1_flags & ACPI_GTDT_ALWAYS_ON);
871
872 arch_timer_init();
873 return 0;
874}
875
876/* Initialize all the generic timers presented in GTDT */
877void __init acpi_generic_timer_init(void)
878{
879 if (acpi_disabled)
880 return;
881
882 acpi_table_parse(ACPI_SIG_GTDT, arch_timer_acpi_init);
883}
884#endif
diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
index a6ce3476834e..7b315e385ba3 100644
--- a/drivers/irqchip/irq-gic.c
+++ b/drivers/irqchip/irq-gic.c
@@ -33,12 +33,14 @@
33#include <linux/of.h> 33#include <linux/of.h>
34#include <linux/of_address.h> 34#include <linux/of_address.h>
35#include <linux/of_irq.h> 35#include <linux/of_irq.h>
36#include <linux/acpi.h>
36#include <linux/irqdomain.h> 37#include <linux/irqdomain.h>
37#include <linux/interrupt.h> 38#include <linux/interrupt.h>
38#include <linux/percpu.h> 39#include <linux/percpu.h>
39#include <linux/slab.h> 40#include <linux/slab.h>
40#include <linux/irqchip/chained_irq.h> 41#include <linux/irqchip/chained_irq.h>
41#include <linux/irqchip/arm-gic.h> 42#include <linux/irqchip/arm-gic.h>
43#include <linux/irqchip/arm-gic-acpi.h>
42 44
43#include <asm/cputype.h> 45#include <asm/cputype.h>
44#include <asm/irq.h> 46#include <asm/irq.h>
@@ -1107,3 +1109,105 @@ IRQCHIP_DECLARE(msm_8660_qgic, "qcom,msm-8660-qgic", gic_of_init);
1107IRQCHIP_DECLARE(msm_qgic2, "qcom,msm-qgic2", gic_of_init); 1109IRQCHIP_DECLARE(msm_qgic2, "qcom,msm-qgic2", gic_of_init);
1108 1110
1109#endif 1111#endif
1112
1113#ifdef CONFIG_ACPI
1114static phys_addr_t dist_phy_base, cpu_phy_base __initdata;
1115
1116static int __init
1117gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
1118 const unsigned long end)
1119{
1120 struct acpi_madt_generic_interrupt *processor;
1121 phys_addr_t gic_cpu_base;
1122 static int cpu_base_assigned;
1123
1124 processor = (struct acpi_madt_generic_interrupt *)header;
1125
1126 if (BAD_MADT_ENTRY(processor, end))
1127 return -EINVAL;
1128
1129 /*
1130 * There is no support for non-banked GICv1/2 register in ACPI spec.
1131 * All CPU interface addresses have to be the same.
1132 */
1133 gic_cpu_base = processor->base_address;
1134 if (cpu_base_assigned && gic_cpu_base != cpu_phy_base)
1135 return -EINVAL;
1136
1137 cpu_phy_base = gic_cpu_base;
1138 cpu_base_assigned = 1;
1139 return 0;
1140}
1141
1142static int __init
1143gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header,
1144 const unsigned long end)
1145{
1146 struct acpi_madt_generic_distributor *dist;
1147
1148 dist = (struct acpi_madt_generic_distributor *)header;
1149
1150 if (BAD_MADT_ENTRY(dist, end))
1151 return -EINVAL;
1152
1153 dist_phy_base = dist->base_address;
1154 return 0;
1155}
1156
1157int __init
1158gic_v2_acpi_init(struct acpi_table_header *table)
1159{
1160 void __iomem *cpu_base, *dist_base;
1161 int count;
1162
1163 /* Collect CPU base addresses */
1164 count = acpi_parse_entries(ACPI_SIG_MADT,
1165 sizeof(struct acpi_table_madt),
1166 gic_acpi_parse_madt_cpu, table,
1167 ACPI_MADT_TYPE_GENERIC_INTERRUPT, 0);
1168 if (count <= 0) {
1169 pr_err("No valid GICC entries exist\n");
1170 return -EINVAL;
1171 }
1172
1173 /*
1174 * Find distributor base address. We expect one distributor entry since
1175 * ACPI 5.1 spec neither support multi-GIC instances nor GIC cascade.
1176 */
1177 count = acpi_parse_entries(ACPI_SIG_MADT,
1178 sizeof(struct acpi_table_madt),
1179 gic_acpi_parse_madt_distributor, table,
1180 ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0);
1181 if (count <= 0) {
1182 pr_err("No valid GICD entries exist\n");
1183 return -EINVAL;
1184 } else if (count > 1) {
1185 pr_err("More than one GICD entry detected\n");
1186 return -EINVAL;
1187 }
1188
1189 cpu_base = ioremap(cpu_phy_base, ACPI_GIC_CPU_IF_MEM_SIZE);
1190 if (!cpu_base) {
1191 pr_err("Unable to map GICC registers\n");
1192 return -ENOMEM;
1193 }
1194
1195 dist_base = ioremap(dist_phy_base, ACPI_GICV2_DIST_MEM_SIZE);
1196 if (!dist_base) {
1197 pr_err("Unable to map GICD registers\n");
1198 iounmap(cpu_base);
1199 return -ENOMEM;
1200 }
1201
1202 /*
1203 * Initialize zero GIC instance (no multi-GIC support). Also, set GIC
1204 * as default IRQ domain to allow for GSI registration and GSI to IRQ
1205 * number translation (see acpi_register_gsi() and acpi_gsi_to_irq()).
1206 */
1207 gic_init_bases(0, -1, dist_base, cpu_base, 0, NULL);
1208 irq_set_default_host(gic_data[0].domain);
1209
1210 acpi_irq_model = ACPI_IRQ_MODEL_GIC;
1211 return 0;
1212}
1213#endif
diff --git a/drivers/irqchip/irqchip.c b/drivers/irqchip/irqchip.c
index 0fe2f718d81c..afd1af3dfe5a 100644
--- a/drivers/irqchip/irqchip.c
+++ b/drivers/irqchip/irqchip.c
@@ -8,6 +8,7 @@
8 * warranty of any kind, whether express or implied. 8 * warranty of any kind, whether express or implied.
9 */ 9 */
10 10
11#include <linux/acpi_irq.h>
11#include <linux/init.h> 12#include <linux/init.h>
12#include <linux/of_irq.h> 13#include <linux/of_irq.h>
13#include <linux/irqchip.h> 14#include <linux/irqchip.h>
@@ -26,4 +27,6 @@ extern struct of_device_id __irqchip_of_table[];
26void __init irqchip_init(void) 27void __init irqchip_init(void)
27{ 28{
28 of_irq_init(__irqchip_of_table); 29 of_irq_init(__irqchip_of_table);
30
31 acpi_irq_init();
29} 32}
diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
index a270004c9605..7cd226da15fe 100644
--- a/drivers/xen/Kconfig
+++ b/drivers/xen/Kconfig
@@ -276,4 +276,8 @@ config XEN_AUTO_XLATE
276 help 276 help
277 Support for auto-translated physmap guests. 277 Support for auto-translated physmap guests.
278 278
279config XEN_ACPI
280 def_bool y
281 depends on X86 && ACPI
282
279endmenu 283endmenu
diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
index 40edd1cbb60d..e293bc507cbc 100644
--- a/drivers/xen/Makefile
+++ b/drivers/xen/Makefile
@@ -13,7 +13,7 @@ CFLAGS_efi.o += -fshort-wchar
13 13
14dom0-$(CONFIG_PCI) += pci.o 14dom0-$(CONFIG_PCI) += pci.o
15dom0-$(CONFIG_USB_SUPPORT) += dbgp.o 15dom0-$(CONFIG_USB_SUPPORT) += dbgp.o
16dom0-$(CONFIG_ACPI) += acpi.o $(xen-pad-y) 16dom0-$(CONFIG_XEN_ACPI) += acpi.o $(xen-pad-y)
17xen-pad-$(CONFIG_X86) += xen-acpi-pad.o 17xen-pad-$(CONFIG_X86) += xen-acpi-pad.o
18dom0-$(CONFIG_X86) += pcpu.o 18dom0-$(CONFIG_X86) += pcpu.o
19obj-$(CONFIG_XEN_DOM0) += $(dom0-y) 19obj-$(CONFIG_XEN_DOM0) += $(dom0-y)
diff --git a/include/acpi/acpi_io.h b/include/acpi/acpi_io.h
index 444671e9c65d..dd86c5fc102d 100644
--- a/include/acpi/acpi_io.h
+++ b/include/acpi/acpi_io.h
@@ -3,11 +3,15 @@
3 3
4#include <linux/io.h> 4#include <linux/io.h>
5 5
6#include <asm/acpi.h>
7
8#ifndef acpi_os_ioremap
6static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys, 9static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
7 acpi_size size) 10 acpi_size size)
8{ 11{
9 return ioremap_cache(phys, size); 12 return ioremap_cache(phys, size);
10} 13}
14#endif
11 15
12void __iomem *__init_refok 16void __iomem *__init_refok
13acpi_os_map_iomem(acpi_physical_address phys, acpi_size size); 17acpi_os_map_iomem(acpi_physical_address phys, acpi_size size);
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index b95dc32a6e6b..4188a4d3b597 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -196,7 +196,7 @@ struct acpi_processor_flags {
196struct acpi_processor { 196struct acpi_processor {
197 acpi_handle handle; 197 acpi_handle handle;
198 u32 acpi_id; 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 u32 id; /* CPU logical ID allocated by OS */ 200 u32 id; /* CPU logical ID allocated by OS */
201 u32 pblk; 201 u32 pblk;
202 int performance_platform_limit; 202 int performance_platform_limit;
@@ -310,8 +310,8 @@ static inline int acpi_processor_get_bios_limit(int cpu, unsigned int *limit)
310#endif /* CONFIG_CPU_FREQ */ 310#endif /* CONFIG_CPU_FREQ */
311 311
312/* in processor_core.c */ 312/* in processor_core.c */
313int acpi_get_phys_id(acpi_handle, int type, u32 acpi_id); 313phys_cpuid_t acpi_get_phys_id(acpi_handle, int type, u32 acpi_id);
314int acpi_map_cpuid(int phys_id, u32 acpi_id); 314int acpi_map_cpuid(phys_cpuid_t phys_id, u32 acpi_id);
315int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id); 315int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id);
316 316
317/* in processor_pdc.c */ 317/* in processor_pdc.c */
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index dd12127f171c..e4da5e35e29c 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -79,6 +79,7 @@ enum acpi_irq_model_id {
79 ACPI_IRQ_MODEL_IOAPIC, 79 ACPI_IRQ_MODEL_IOAPIC,
80 ACPI_IRQ_MODEL_IOSAPIC, 80 ACPI_IRQ_MODEL_IOSAPIC,
81 ACPI_IRQ_MODEL_PLATFORM, 81 ACPI_IRQ_MODEL_PLATFORM,
82 ACPI_IRQ_MODEL_GIC,
82 ACPI_IRQ_MODEL_COUNT 83 ACPI_IRQ_MODEL_COUNT
83}; 84};
84 85
@@ -152,9 +153,14 @@ void acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa);
152int acpi_numa_memory_affinity_init (struct acpi_srat_mem_affinity *ma); 153int acpi_numa_memory_affinity_init (struct acpi_srat_mem_affinity *ma);
153void acpi_numa_arch_fixup(void); 154void acpi_numa_arch_fixup(void);
154 155
156#ifndef PHYS_CPUID_INVALID
157typedef u32 phys_cpuid_t;
158#define PHYS_CPUID_INVALID (phys_cpuid_t)(-1)
159#endif
160
155#ifdef CONFIG_ACPI_HOTPLUG_CPU 161#ifdef CONFIG_ACPI_HOTPLUG_CPU
156/* Arch dependent functions for cpu hotplug support */ 162/* Arch dependent functions for cpu hotplug support */
157int acpi_map_cpu(acpi_handle handle, int physid, int *pcpu); 163int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu);
158int acpi_unmap_cpu(int cpu); 164int acpi_unmap_cpu(int cpu);
159#endif /* CONFIG_ACPI_HOTPLUG_CPU */ 165#endif /* CONFIG_ACPI_HOTPLUG_CPU */
160 166
diff --git a/include/linux/acpi_irq.h b/include/linux/acpi_irq.h
new file mode 100644
index 000000000000..f10c87265855
--- /dev/null
+++ b/include/linux/acpi_irq.h
@@ -0,0 +1,10 @@
1#ifndef _LINUX_ACPI_IRQ_H
2#define _LINUX_ACPI_IRQ_H
3
4#include <linux/irq.h>
5
6#ifndef acpi_irq_init
7static inline void acpi_irq_init(void) { }
8#endif
9
10#endif /* _LINUX_ACPI_IRQ_H */
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index 135509821c39..d27d0152271f 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -253,4 +253,10 @@ extern void clocksource_of_init(void);
253static inline void clocksource_of_init(void) {} 253static inline void clocksource_of_init(void) {}
254#endif 254#endif
255 255
256#ifdef CONFIG_ACPI
257void acpi_generic_timer_init(void);
258#else
259static inline void acpi_generic_timer_init(void) { }
260#endif
261
256#endif /* _LINUX_CLOCKSOURCE_H */ 262#endif /* _LINUX_CLOCKSOURCE_H */
diff --git a/include/linux/irqchip/arm-gic-acpi.h b/include/linux/irqchip/arm-gic-acpi.h
new file mode 100644
index 000000000000..de3419ed3937
--- /dev/null
+++ b/include/linux/irqchip/arm-gic-acpi.h
@@ -0,0 +1,31 @@
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
23struct acpi_table_header;
24
25int gic_v2_acpi_init(struct acpi_table_header *table);
26void acpi_gic_init(void);
27#else
28static inline void acpi_gic_init(void) { }
29#endif
30
31#endif /* ARM_GIC_ACPI_H_ */