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/efi.h> 16 #include <linux/memblock.h> 17 #include <linux/psci.h> 18 19 #include <asm/cputype.h> 20 #include <asm/io.h> 21 #include <asm/smp_plat.h> 22 #include <asm/tlbflush.h> 23 24 /* Macros for consistency checks of the GICC subtable of MADT */ 25 #define ACPI_MADT_GICC_LENGTH \ 26 (acpi_gbl_FADT.header.revision < 6 ? 76 : 80) 27 28 #define BAD_MADT_GICC_ENTRY(entry, end) \ 29 (!(entry) || (entry)->header.length != ACPI_MADT_GICC_LENGTH || \ 30 (unsigned long)(entry) + ACPI_MADT_GICC_LENGTH > (end)) 31 32 /* Basic configuration for ACPI */ 33 #ifdef CONFIG_ACPI 34 pgprot_t __acpi_get_mem_attribute(phys_addr_t addr); 35 36 /* ACPI table mapping after acpi_permanent_mmap is set */ 37 static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys, 38 acpi_size size) 39 { 40 /* For normal memory we already have a cacheable mapping. */ 41 if (memblock_is_map_memory(phys)) 42 return (void __iomem *)__phys_to_virt(phys); 43 44 /* 45 * We should still honor the memory's attribute here because 46 * crash dump kernel possibly excludes some ACPI (reclaim) 47 * regions from memblock list. 48 */ 49 return __ioremap(phys, size, __acpi_get_mem_attribute(phys)); 50 } 51 #define acpi_os_ioremap acpi_os_ioremap 52 53 typedef u64 phys_cpuid_t; 54 #define PHYS_CPUID_INVALID INVALID_HWID 55 56 #define acpi_strict 1 /* No out-of-spec workarounds on ARM64 */ 57 extern int acpi_disabled; 58 extern int acpi_noirq; 59 extern int acpi_pci_disabled; 60 61 static inline void disable_acpi(void) 62 { 63 acpi_disabled = 1; 64 acpi_pci_disabled = 1; 65 acpi_noirq = 1; 66 } 67 68 static inline void enable_acpi(void) 69 { 70 acpi_disabled = 0; 71 acpi_pci_disabled = 0; 72 acpi_noirq = 0; 73 } 74 75 /* 76 * The ACPI processor driver for ACPI core code needs this macro 77 * to find out this cpu was already mapped (mapping from CPU hardware 78 * ID to CPU logical ID) or not. 79 */ 80 #define cpu_physical_id(cpu) cpu_logical_map(cpu) 81 82 /* 83 * It's used from ACPI core in kdump to boot UP system with SMP kernel, 84 * with this check the ACPI core will not override the CPU index 85 * obtained from GICC with 0 and not print some error message as well. 86 * Since MADT must provide at least one GICC structure for GIC 87 * initialization, CPU will be always available in MADT on ARM64. 88 */ 89 static inline bool acpi_has_cpu_in_madt(void) 90 { 91 return true; 92 } 93 94 struct acpi_madt_generic_interrupt *acpi_cpu_get_madt_gicc(int cpu); 95 static inline u32 get_acpi_id_for_cpu(unsigned int cpu) 96 { 97 return acpi_cpu_get_madt_gicc(cpu)->uid; 98 } 99 100 static inline void arch_fix_phys_package_id(int num, u32 slot) { } 101 void __init acpi_init_cpus(void); 102 103 #else 104 static inline void acpi_init_cpus(void) { } 105 #endif /* CONFIG_ACPI */ 106 107 #ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL 108 bool acpi_parking_protocol_valid(int cpu); 109 void __init 110 acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor); 111 #else 112 static inline bool acpi_parking_protocol_valid(int cpu) { return false; } 113 static inline void 114 acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor) 115 {} 116 #endif 117 118 static inline const char *acpi_get_enable_method(int cpu) 119 { 120 if (acpi_psci_present()) 121 return "psci"; 122 123 if (acpi_parking_protocol_valid(cpu)) 124 return "parking-protocol"; 125 126 return NULL; 127 } 128 129 #ifdef CONFIG_ACPI_APEI 130 /* 131 * acpi_disable_cmcff is used in drivers/acpi/apei/hest.c for disabling 132 * IA-32 Architecture Corrected Machine Check (CMC) Firmware-First mode 133 * with a kernel command line parameter "acpi=nocmcoff". But we don't 134 * have this IA-32 specific feature on ARM64, this definition is only 135 * for compatibility. 136 */ 137 #define acpi_disable_cmcff 1 138 static inline pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr) 139 { 140 return __acpi_get_mem_attribute(addr); 141 } 142 #endif /* CONFIG_ACPI_APEI */ 143 144 #ifdef CONFIG_ACPI_NUMA 145 int arm64_acpi_numa_init(void); 146 int acpi_numa_get_nid(unsigned int cpu); 147 void acpi_map_cpus_to_nodes(void); 148 #else 149 static inline int arm64_acpi_numa_init(void) { return -ENOSYS; } 150 static inline int acpi_numa_get_nid(unsigned int cpu) { return NUMA_NO_NODE; } 151 static inline void acpi_map_cpus_to_nodes(void) { } 152 #endif /* CONFIG_ACPI_NUMA */ 153 154 #define ACPI_TABLE_UPGRADE_MAX_PHYS MEMBLOCK_ALLOC_ACCESSIBLE 155 156 #endif /*_ASM_ACPI_H*/ 157