Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Al Stone | 3765516 | 2015-03-24 14:02:37 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2013-2014, Linaro Ltd. |
| 4 | * Author: Al Stone <al.stone@linaro.org> |
| 5 | * Author: Graeme Gregory <graeme.gregory@linaro.org> |
| 6 | * Author: Hanjun Guo <hanjun.guo@linaro.org> |
Al Stone | 3765516 | 2015-03-24 14:02:37 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #ifndef _ASM_ACPI_H |
| 10 | #define _ASM_ACPI_H |
| 11 | |
AKASHI Takahiro | 09ffcb0d | 2018-07-23 10:57:32 +0900 | [diff] [blame] | 12 | #include <linux/efi.h> |
AKASHI Takahiro | e7cd190 | 2016-08-22 15:55:24 +0900 | [diff] [blame] | 13 | #include <linux/memblock.h> |
Mark Rutland | bff6079 | 2015-07-31 15:46:16 +0100 | [diff] [blame] | 14 | #include <linux/psci.h> |
Tomasz Nowicki | d60fc38 | 2015-03-24 14:02:49 +0000 | [diff] [blame] | 15 | |
Hanjun Guo | 020295b | 2015-03-24 14:02:47 +0000 | [diff] [blame] | 16 | #include <asm/cputype.h> |
AKASHI Takahiro | 09ffcb0d | 2018-07-23 10:57:32 +0900 | [diff] [blame] | 17 | #include <asm/io.h> |
James Morse | d44f1b8 | 2019-01-29 18:48:50 +0000 | [diff] [blame] | 18 | #include <asm/ptrace.h> |
Hanjun Guo | 020295b | 2015-03-24 14:02:47 +0000 | [diff] [blame] | 19 | #include <asm/smp_plat.h> |
Tomasz Nowicki | 9f9a35a | 2016-12-01 21:51:12 +0800 | [diff] [blame] | 20 | #include <asm/tlbflush.h> |
Mark Salter | 652261a | 2015-03-24 14:02:38 +0000 | [diff] [blame] | 21 | |
Al Stone | b6cfb27 | 2015-07-06 17:16:47 -0600 | [diff] [blame] | 22 | /* Macros for consistency checks of the GICC subtable of MADT */ |
Jeremy Linton | 9eb1c92 | 2018-11-27 17:59:12 +0000 | [diff] [blame] | 23 | |
| 24 | /* |
| 25 | * MADT GICC minimum length refers to the MADT GICC structure table length as |
| 26 | * defined in the earliest ACPI version supported on arm64, ie ACPI 5.1. |
| 27 | * |
| 28 | * The efficiency_class member was added to the |
| 29 | * struct acpi_madt_generic_interrupt to represent the MADT GICC structure |
| 30 | * "Processor Power Efficiency Class" field, added in ACPI 6.0 whose offset |
| 31 | * is therefore used to delimit the MADT GICC structure minimum length |
| 32 | * appropriately. |
| 33 | */ |
| 34 | #define ACPI_MADT_GICC_MIN_LENGTH ACPI_OFFSET( \ |
| 35 | struct acpi_madt_generic_interrupt, efficiency_class) |
Al Stone | b6cfb27 | 2015-07-06 17:16:47 -0600 | [diff] [blame] | 36 | |
Lorenzo Pieralisi | cb7cf77 | 2017-05-26 17:40:02 +0100 | [diff] [blame] | 37 | #define BAD_MADT_GICC_ENTRY(entry, end) \ |
Jeremy Linton | 9eb1c92 | 2018-11-27 17:59:12 +0000 | [diff] [blame] | 38 | (!(entry) || (entry)->header.length < ACPI_MADT_GICC_MIN_LENGTH || \ |
| 39 | (unsigned long)(entry) + (entry)->header.length > (end)) |
Al Stone | b6cfb27 | 2015-07-06 17:16:47 -0600 | [diff] [blame] | 40 | |
Jeremy Linton | d24a0c7 | 2019-06-26 16:37:17 -0500 | [diff] [blame] | 41 | #define ACPI_MADT_GICC_SPE (ACPI_OFFSET(struct acpi_madt_generic_interrupt, \ |
| 42 | spe_interrupt) + sizeof(u16)) |
| 43 | |
Al Stone | 3765516 | 2015-03-24 14:02:37 +0000 | [diff] [blame] | 44 | /* Basic configuration for ACPI */ |
| 45 | #ifdef CONFIG_ACPI |
AKASHI Takahiro | 09ffcb0d | 2018-07-23 10:57:32 +0900 | [diff] [blame] | 46 | pgprot_t __acpi_get_mem_attribute(phys_addr_t addr); |
| 47 | |
Lv Zheng | 8d3523f | 2016-12-14 15:04:46 +0800 | [diff] [blame] | 48 | /* ACPI table mapping after acpi_permanent_mmap is set */ |
Mark Salter | 652261a | 2015-03-24 14:02:38 +0000 | [diff] [blame] | 49 | static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys, |
| 50 | acpi_size size) |
| 51 | { |
AKASHI Takahiro | 09ffcb0d | 2018-07-23 10:57:32 +0900 | [diff] [blame] | 52 | /* For normal memory we already have a cacheable mapping. */ |
| 53 | if (memblock_is_map_memory(phys)) |
| 54 | return (void __iomem *)__phys_to_virt(phys); |
Mark Salter | 652261a | 2015-03-24 14:02:38 +0000 | [diff] [blame] | 55 | |
AKASHI Takahiro | 09ffcb0d | 2018-07-23 10:57:32 +0900 | [diff] [blame] | 56 | /* |
| 57 | * We should still honor the memory's attribute here because |
| 58 | * crash dump kernel possibly excludes some ACPI (reclaim) |
| 59 | * regions from memblock list. |
| 60 | */ |
| 61 | return __ioremap(phys, size, __acpi_get_mem_attribute(phys)); |
Mark Salter | 652261a | 2015-03-24 14:02:38 +0000 | [diff] [blame] | 62 | } |
| 63 | #define acpi_os_ioremap acpi_os_ioremap |
| 64 | |
Hanjun Guo | 020295b | 2015-03-24 14:02:47 +0000 | [diff] [blame] | 65 | typedef u64 phys_cpuid_t; |
| 66 | #define PHYS_CPUID_INVALID INVALID_HWID |
| 67 | |
Al Stone | 3765516 | 2015-03-24 14:02:37 +0000 | [diff] [blame] | 68 | #define acpi_strict 1 /* No out-of-spec workarounds on ARM64 */ |
| 69 | extern int acpi_disabled; |
| 70 | extern int acpi_noirq; |
| 71 | extern int acpi_pci_disabled; |
| 72 | |
| 73 | static inline void disable_acpi(void) |
| 74 | { |
| 75 | acpi_disabled = 1; |
| 76 | acpi_pci_disabled = 1; |
| 77 | acpi_noirq = 1; |
| 78 | } |
| 79 | |
Al Stone | b10d79f | 2015-03-24 14:02:41 +0000 | [diff] [blame] | 80 | static inline void enable_acpi(void) |
| 81 | { |
| 82 | acpi_disabled = 0; |
| 83 | acpi_pci_disabled = 0; |
| 84 | acpi_noirq = 0; |
| 85 | } |
| 86 | |
Al Stone | 3765516 | 2015-03-24 14:02:37 +0000 | [diff] [blame] | 87 | /* |
Hanjun Guo | 020295b | 2015-03-24 14:02:47 +0000 | [diff] [blame] | 88 | * The ACPI processor driver for ACPI core code needs this macro |
| 89 | * to find out this cpu was already mapped (mapping from CPU hardware |
| 90 | * ID to CPU logical ID) or not. |
| 91 | */ |
| 92 | #define cpu_physical_id(cpu) cpu_logical_map(cpu) |
| 93 | |
| 94 | /* |
Al Stone | 3765516 | 2015-03-24 14:02:37 +0000 | [diff] [blame] | 95 | * It's used from ACPI core in kdump to boot UP system with SMP kernel, |
| 96 | * with this check the ACPI core will not override the CPU index |
| 97 | * obtained from GICC with 0 and not print some error message as well. |
| 98 | * Since MADT must provide at least one GICC structure for GIC |
| 99 | * initialization, CPU will be always available in MADT on ARM64. |
| 100 | */ |
| 101 | static inline bool acpi_has_cpu_in_madt(void) |
| 102 | { |
| 103 | return true; |
| 104 | } |
| 105 | |
Mark Rutland | e0013ae | 2017-04-11 09:39:54 +0100 | [diff] [blame] | 106 | struct acpi_madt_generic_interrupt *acpi_cpu_get_madt_gicc(int cpu); |
Jeremy Linton | 30d87bf | 2018-05-11 18:57:59 -0500 | [diff] [blame] | 107 | static inline u32 get_acpi_id_for_cpu(unsigned int cpu) |
| 108 | { |
| 109 | return acpi_cpu_get_madt_gicc(cpu)->uid; |
| 110 | } |
Mark Rutland | e0013ae | 2017-04-11 09:39:54 +0100 | [diff] [blame] | 111 | |
Al Stone | 3765516 | 2015-03-24 14:02:37 +0000 | [diff] [blame] | 112 | static inline void arch_fix_phys_package_id(int num, u32 slot) { } |
Hanjun Guo | fccb9a8 | 2015-03-24 22:02:45 +0800 | [diff] [blame] | 113 | void __init acpi_init_cpus(void); |
James Morse | d44f1b8 | 2019-01-29 18:48:50 +0000 | [diff] [blame] | 114 | int apei_claim_sea(struct pt_regs *regs); |
Graeme Gregory | 7c59a3d | 2015-03-24 14:02:43 +0000 | [diff] [blame] | 115 | #else |
Hanjun Guo | fccb9a8 | 2015-03-24 22:02:45 +0800 | [diff] [blame] | 116 | static inline void acpi_init_cpus(void) { } |
James Morse | d44f1b8 | 2019-01-29 18:48:50 +0000 | [diff] [blame] | 117 | static inline int apei_claim_sea(struct pt_regs *regs) { return -ENOENT; } |
Al Stone | 3765516 | 2015-03-24 14:02:37 +0000 | [diff] [blame] | 118 | #endif /* CONFIG_ACPI */ |
| 119 | |
Lorenzo Pieralisi | 5e89c55 | 2016-01-26 11:10:38 +0000 | [diff] [blame] | 120 | #ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL |
| 121 | bool acpi_parking_protocol_valid(int cpu); |
| 122 | void __init |
| 123 | acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor); |
| 124 | #else |
| 125 | static inline bool acpi_parking_protocol_valid(int cpu) { return false; } |
| 126 | static inline void |
| 127 | acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor) |
| 128 | {} |
| 129 | #endif |
| 130 | |
Lorenzo Pieralisi | 0f07833 | 2015-05-13 14:12:47 +0100 | [diff] [blame] | 131 | static inline const char *acpi_get_enable_method(int cpu) |
| 132 | { |
Lorenzo Pieralisi | 5e89c55 | 2016-01-26 11:10:38 +0000 | [diff] [blame] | 133 | if (acpi_psci_present()) |
| 134 | return "psci"; |
| 135 | |
| 136 | if (acpi_parking_protocol_valid(cpu)) |
| 137 | return "parking-protocol"; |
| 138 | |
| 139 | return NULL; |
Lorenzo Pieralisi | 0f07833 | 2015-05-13 14:12:47 +0100 | [diff] [blame] | 140 | } |
Jonathan (Zhixiong) Zhang | 89e44b5 | 2015-09-04 14:11:41 +0100 | [diff] [blame] | 141 | |
| 142 | #ifdef CONFIG_ACPI_APEI |
Tomasz Nowicki | 9f9a35a | 2016-12-01 21:51:12 +0800 | [diff] [blame] | 143 | /* |
| 144 | * acpi_disable_cmcff is used in drivers/acpi/apei/hest.c for disabling |
| 145 | * IA-32 Architecture Corrected Machine Check (CMC) Firmware-First mode |
| 146 | * with a kernel command line parameter "acpi=nocmcoff". But we don't |
| 147 | * have this IA-32 specific feature on ARM64, this definition is only |
| 148 | * for compatibility. |
| 149 | */ |
| 150 | #define acpi_disable_cmcff 1 |
AKASHI Takahiro | 09ffcb0d | 2018-07-23 10:57:32 +0900 | [diff] [blame] | 151 | static inline pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr) |
| 152 | { |
| 153 | return __acpi_get_mem_attribute(addr); |
| 154 | } |
Tomasz Nowicki | 9f9a35a | 2016-12-01 21:51:12 +0800 | [diff] [blame] | 155 | #endif /* CONFIG_ACPI_APEI */ |
Jonathan (Zhixiong) Zhang | 89e44b5 | 2015-09-04 14:11:41 +0100 | [diff] [blame] | 156 | |
Hanjun Guo | d8b47fc | 2016-05-24 15:35:44 -0700 | [diff] [blame] | 157 | #ifdef CONFIG_ACPI_NUMA |
| 158 | int arm64_acpi_numa_init(void); |
Lorenzo Pieralisi | e189624 | 2018-06-25 14:05:52 +0100 | [diff] [blame] | 159 | int acpi_numa_get_nid(unsigned int cpu); |
| 160 | void acpi_map_cpus_to_nodes(void); |
Hanjun Guo | d8b47fc | 2016-05-24 15:35:44 -0700 | [diff] [blame] | 161 | #else |
| 162 | static inline int arm64_acpi_numa_init(void) { return -ENOSYS; } |
Lorenzo Pieralisi | e189624 | 2018-06-25 14:05:52 +0100 | [diff] [blame] | 163 | static inline int acpi_numa_get_nid(unsigned int cpu) { return NUMA_NO_NODE; } |
| 164 | static inline void acpi_map_cpus_to_nodes(void) { } |
Hanjun Guo | d8b47fc | 2016-05-24 15:35:44 -0700 | [diff] [blame] | 165 | #endif /* CONFIG_ACPI_NUMA */ |
| 166 | |
Jon Masters | 38b04a7 | 2016-06-20 13:56:13 +0300 | [diff] [blame] | 167 | #define ACPI_TABLE_UPGRADE_MAX_PHYS MEMBLOCK_ALLOC_ACCESSIBLE |
| 168 | |
Al Stone | 3765516 | 2015-03-24 14:02:37 +0000 | [diff] [blame] | 169 | #endif /*_ASM_ACPI_H*/ |