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>
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;
15 #include <linux/efi.h>
16 #include <linux/memblock.h>
17 #include <linux/psci.h>
19 #include <asm/cputype.h>
21 #include <asm/smp_plat.h>
22 #include <asm/tlbflush.h>
24 /* Macros for consistency checks of the GICC subtable of MADT */
27 * MADT GICC minimum length refers to the MADT GICC structure table length as
28 * defined in the earliest ACPI version supported on arm64, ie ACPI 5.1.
30 * The efficiency_class member was added to the
31 * struct acpi_madt_generic_interrupt to represent the MADT GICC structure
32 * "Processor Power Efficiency Class" field, added in ACPI 6.0 whose offset
33 * is therefore used to delimit the MADT GICC structure minimum length
36 #define ACPI_MADT_GICC_MIN_LENGTH ACPI_OFFSET( \
37 struct acpi_madt_generic_interrupt, efficiency_class)
39 #define BAD_MADT_GICC_ENTRY(entry, end) \
40 (!(entry) || (entry)->header.length < ACPI_MADT_GICC_MIN_LENGTH || \
41 (unsigned long)(entry) + (entry)->header.length > (end))
43 /* Basic configuration for ACPI */
45 pgprot_t __acpi_get_mem_attribute(phys_addr_t addr);
47 /* ACPI table mapping after acpi_permanent_mmap is set */
48 static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
51 /* For normal memory we already have a cacheable mapping. */
52 if (memblock_is_map_memory(phys))
53 return (void __iomem *)__phys_to_virt(phys);
56 * We should still honor the memory's attribute here because
57 * crash dump kernel possibly excludes some ACPI (reclaim)
58 * regions from memblock list.
60 return __ioremap(phys, size, __acpi_get_mem_attribute(phys));
62 #define acpi_os_ioremap acpi_os_ioremap
64 typedef u64 phys_cpuid_t;
65 #define PHYS_CPUID_INVALID INVALID_HWID
67 #define acpi_strict 1 /* No out-of-spec workarounds on ARM64 */
68 extern int acpi_disabled;
69 extern int acpi_noirq;
70 extern int acpi_pci_disabled;
72 static inline void disable_acpi(void)
75 acpi_pci_disabled = 1;
79 static inline void enable_acpi(void)
82 acpi_pci_disabled = 0;
87 * The ACPI processor driver for ACPI core code needs this macro
88 * to find out this cpu was already mapped (mapping from CPU hardware
89 * ID to CPU logical ID) or not.
91 #define cpu_physical_id(cpu) cpu_logical_map(cpu)
94 * It's used from ACPI core in kdump to boot UP system with SMP kernel,
95 * with this check the ACPI core will not override the CPU index
96 * obtained from GICC with 0 and not print some error message as well.
97 * Since MADT must provide at least one GICC structure for GIC
98 * initialization, CPU will be always available in MADT on ARM64.
100 static inline bool acpi_has_cpu_in_madt(void)
105 struct acpi_madt_generic_interrupt *acpi_cpu_get_madt_gicc(int cpu);
106 static inline u32 get_acpi_id_for_cpu(unsigned int cpu)
108 return acpi_cpu_get_madt_gicc(cpu)->uid;
111 static inline void arch_fix_phys_package_id(int num, u32 slot) { }
112 void __init acpi_init_cpus(void);
115 static inline void acpi_init_cpus(void) { }
116 #endif /* CONFIG_ACPI */
118 #ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL
119 bool acpi_parking_protocol_valid(int cpu);
121 acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor);
123 static inline bool acpi_parking_protocol_valid(int cpu) { return false; }
125 acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor)
129 static inline const char *acpi_get_enable_method(int cpu)
131 if (acpi_psci_present())
134 if (acpi_parking_protocol_valid(cpu))
135 return "parking-protocol";
140 #ifdef CONFIG_ACPI_APEI
142 * acpi_disable_cmcff is used in drivers/acpi/apei/hest.c for disabling
143 * IA-32 Architecture Corrected Machine Check (CMC) Firmware-First mode
144 * with a kernel command line parameter "acpi=nocmcoff". But we don't
145 * have this IA-32 specific feature on ARM64, this definition is only
148 #define acpi_disable_cmcff 1
149 static inline pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr)
151 return __acpi_get_mem_attribute(addr);
153 #endif /* CONFIG_ACPI_APEI */
155 #ifdef CONFIG_ACPI_NUMA
156 int arm64_acpi_numa_init(void);
157 int acpi_numa_get_nid(unsigned int cpu);
158 void acpi_map_cpus_to_nodes(void);
160 static inline int arm64_acpi_numa_init(void) { return -ENOSYS; }
161 static inline int acpi_numa_get_nid(unsigned int cpu) { return NUMA_NO_NODE; }
162 static inline void acpi_map_cpus_to_nodes(void) { }
163 #endif /* CONFIG_ACPI_NUMA */
165 #define ACPI_TABLE_UPGRADE_MAX_PHYS MEMBLOCK_ALLOC_ACCESSIBLE
167 #endif /*_ASM_ACPI_H*/