aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm64/kernel
diff options
context:
space:
mode:
authorAl Stone <al.stone@linaro.org>2015-03-24 10:02:37 -0400
committerWill Deacon <will.deacon@arm.com>2015-03-25 07:49:30 -0400
commit37655163ce1a3ef2635a9bba0ad614f25e01484e (patch)
treeec0725acf80e782da0b945ac843ae110f2162853 /arch/arm64/kernel
parentb2cedba09dd7034c144c03eadc09ee1e4d791590 (diff)
ARM64 / ACPI: Get RSDP and ACPI boot-time tables
As we want to get ACPI tables to parse and then use the information for system initialization, we should get the RSDP (Root System Description Pointer) first, it then locates Extended Root Description Table (XSDT) which contains all the 64-bit physical address that pointer to other boot-time tables. Introduce acpi.c and its related head file in this patch to provide fundamental needs of extern variables and functions for ACPI core, and then get boot-time tables as needed. - asm/acenv.h for arch specific ACPICA environments and implementation, It is needed unconditionally by ACPI core; - asm/acpi.h for arch specific variables and functions needed by ACPI driver core; - acpi.c for ARM64 related ACPI implementation for ACPI driver core; acpi_boot_table_init() is introduced to get RSDP and boot-time tables, it will be called in setup_arch() before paging_init(), so we should use eary_memremap() mechanism here to get the RSDP and all the table pointers. FADT Major.Minor version was introduced in ACPI 5.1, it is the same as ACPI version. In ACPI 5.1, some major gaps are fixed for ARM, such as updates in MADT table for GIC and SMP init, without those updates, we can not get the MPIDR for SMP init, and GICv2/3 related init information, so we can't boot arm64 ACPI properly with table versions predating 5.1. If firmware provides ACPI tables with ACPI version less than 5.1, OS has no way to retrieve the configuration data that is necessary to init SMP boot protocol and the GIC properly, so disable ACPI if we get an FADT table with version less that 5.1 when acpi_boot_table_init() called. CC: Catalin Marinas <catalin.marinas@arm.com> CC: Will Deacon <will.deacon@arm.com> CC: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com> Tested-by: Yijing Wang <wangyijing@huawei.com> Tested-by: Mark Langsdorf <mlangsdo@redhat.com> Tested-by: Jon Masters <jcm@redhat.com> Tested-by: Timur Tabi <timur@codeaurora.org> Tested-by: Robert Richter <rrichter@cavium.com> Acked-by: Robert Richter <rrichter@cavium.com> Acked-by: Olof Johansson <olof@lixom.net> Acked-by: Grant Likely <grant.likely@linaro.org> Signed-off-by: Al Stone <al.stone@linaro.org> Signed-off-by: Graeme Gregory <graeme.gregory@linaro.org> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org> Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'arch/arm64/kernel')
-rw-r--r--arch/arm64/kernel/Makefile1
-rw-r--r--arch/arm64/kernel/acpi.c101
-rw-r--r--arch/arm64/kernel/setup.c5
3 files changed, 107 insertions, 0 deletions
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index 5ee07eee80c2..fdc7877f2a3c 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..7abac24d5584
--- /dev/null
+++ b/arch/arm64/kernel/acpi.c
@@ -0,0 +1,101 @@
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/smp.h>
26
27int acpi_noirq; /* skip ACPI IRQ initialization */
28int acpi_disabled;
29EXPORT_SYMBOL(acpi_disabled);
30
31int acpi_pci_disabled; /* skip ACPI PCI scan and IRQ initialization */
32EXPORT_SYMBOL(acpi_pci_disabled);
33
34/*
35 * __acpi_map_table() will be called before page_init(), so early_ioremap()
36 * or early_memremap() should be called here to for ACPI table mapping.
37 */
38char *__init __acpi_map_table(unsigned long phys, unsigned long size)
39{
40 if (!size)
41 return NULL;
42
43 return early_memremap(phys, size);
44}
45
46void __init __acpi_unmap_table(char *map, unsigned long size)
47{
48 if (!map || !size)
49 return;
50
51 early_memunmap(map, size);
52}
53
54static int __init acpi_parse_fadt(struct acpi_table_header *table)
55{
56 struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table;
57
58 /*
59 * Revision in table header is the FADT Major revision, and there
60 * is a minor revision of FADT which was introduced by ACPI 5.1,
61 * we only deal with ACPI 5.1 or newer revision to get GIC and SMP
62 * boot protocol configuration data, or we will disable ACPI.
63 */
64 if (table->revision > 5 ||
65 (table->revision == 5 && fadt->minor_revision >= 1))
66 return 0;
67
68 pr_warn("Unsupported FADT revision %d.%d, should be 5.1+, will disable ACPI\n",
69 table->revision, fadt->minor_revision);
70 disable_acpi();
71
72 return -EINVAL;
73}
74
75/*
76 * acpi_boot_table_init() called from setup_arch(), always.
77 * 1. find RSDP and get its address, and then find XSDT
78 * 2. extract all tables and checksums them all
79 * 3. check ACPI FADT revision
80 *
81 * We can parse ACPI boot-time tables such as MADT after
82 * this function is called.
83 */
84void __init acpi_boot_table_init(void)
85{
86 /* If acpi_disabled, bail out */
87 if (acpi_disabled)
88 return;
89
90 /* Initialize the ACPI boot-time table parser. */
91 if (acpi_table_init()) {
92 disable_acpi();
93 return;
94 }
95
96 if (acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt)) {
97 /* disable ACPI if no FADT is found */
98 disable_acpi();
99 pr_err("Can't find FADT\n");
100 }
101}
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index e8420f635bd4..4f1a014ace39 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>
@@ -380,6 +382,9 @@ void __init setup_arch(char **cmdline_p)
380 efi_init(); 382 efi_init();
381 arm64_memblock_init(); 383 arm64_memblock_init();
382 384
385 /* Parse the ACPI tables for possible boot-time configuration */
386 acpi_boot_table_init();
387
383 paging_init(); 388 paging_init();
384 request_standard_resources(); 389 request_standard_resources();
385 390