Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  *  Copyright (C) 2013-2014, Linaro Ltd.
0004  *  Author: Al Stone <al.stone@linaro.org>
0005  *  Author: Graeme Gregory <graeme.gregory@linaro.org>
0006  *  Author: Hanjun Guo <hanjun.guo@linaro.org>
0007  */
0008 
0009 #ifndef _ASM_ACPI_H
0010 #define _ASM_ACPI_H
0011 
0012 #include <linux/efi.h>
0013 #include <linux/memblock.h>
0014 #include <linux/psci.h>
0015 #include <linux/stddef.h>
0016 
0017 #include <asm/cputype.h>
0018 #include <asm/io.h>
0019 #include <asm/ptrace.h>
0020 #include <asm/smp_plat.h>
0021 #include <asm/tlbflush.h>
0022 
0023 /* Macros for consistency checks of the GICC subtable of MADT */
0024 
0025 /*
0026  * MADT GICC minimum length refers to the MADT GICC structure table length as
0027  * defined in the earliest ACPI version supported on arm64, ie ACPI 5.1.
0028  *
0029  * The efficiency_class member was added to the
0030  * struct acpi_madt_generic_interrupt to represent the MADT GICC structure
0031  * "Processor Power Efficiency Class" field, added in ACPI 6.0 whose offset
0032  * is therefore used to delimit the MADT GICC structure minimum length
0033  * appropriately.
0034  */
0035 #define ACPI_MADT_GICC_MIN_LENGTH   offsetof(  \
0036     struct acpi_madt_generic_interrupt, efficiency_class)
0037 
0038 #define BAD_MADT_GICC_ENTRY(entry, end)                 \
0039     (!(entry) || (entry)->header.length < ACPI_MADT_GICC_MIN_LENGTH || \
0040     (unsigned long)(entry) + (entry)->header.length > (end))
0041 
0042 #define ACPI_MADT_GICC_SPE  (offsetof(struct acpi_madt_generic_interrupt, \
0043     spe_interrupt) + sizeof(u16))
0044 
0045 /* Basic configuration for ACPI */
0046 #ifdef  CONFIG_ACPI
0047 pgprot_t __acpi_get_mem_attribute(phys_addr_t addr);
0048 
0049 /* ACPI table mapping after acpi_permanent_mmap is set */
0050 void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size);
0051 #define acpi_os_ioremap acpi_os_ioremap
0052 
0053 typedef u64 phys_cpuid_t;
0054 #define PHYS_CPUID_INVALID INVALID_HWID
0055 
0056 #define acpi_strict 1   /* No out-of-spec workarounds on ARM64 */
0057 extern int acpi_disabled;
0058 extern int acpi_noirq;
0059 extern int acpi_pci_disabled;
0060 
0061 static inline void disable_acpi(void)
0062 {
0063     acpi_disabled = 1;
0064     acpi_pci_disabled = 1;
0065     acpi_noirq = 1;
0066 }
0067 
0068 static inline void enable_acpi(void)
0069 {
0070     acpi_disabled = 0;
0071     acpi_pci_disabled = 0;
0072     acpi_noirq = 0;
0073 }
0074 
0075 /*
0076  * The ACPI processor driver for ACPI core code needs this macro
0077  * to find out this cpu was already mapped (mapping from CPU hardware
0078  * ID to CPU logical ID) or not.
0079  */
0080 #define cpu_physical_id(cpu) cpu_logical_map(cpu)
0081 
0082 /*
0083  * It's used from ACPI core in kdump to boot UP system with SMP kernel,
0084  * with this check the ACPI core will not override the CPU index
0085  * obtained from GICC with 0 and not print some error message as well.
0086  * Since MADT must provide at least one GICC structure for GIC
0087  * initialization, CPU will be always available in MADT on ARM64.
0088  */
0089 static inline bool acpi_has_cpu_in_madt(void)
0090 {
0091     return true;
0092 }
0093 
0094 struct acpi_madt_generic_interrupt *acpi_cpu_get_madt_gicc(int cpu);
0095 static inline u32 get_acpi_id_for_cpu(unsigned int cpu)
0096 {
0097     return  acpi_cpu_get_madt_gicc(cpu)->uid;
0098 }
0099 
0100 static inline void arch_fix_phys_package_id(int num, u32 slot) { }
0101 void __init acpi_init_cpus(void);
0102 int apei_claim_sea(struct pt_regs *regs);
0103 #else
0104 static inline void acpi_init_cpus(void) { }
0105 static inline int apei_claim_sea(struct pt_regs *regs) { return -ENOENT; }
0106 #endif /* CONFIG_ACPI */
0107 
0108 #ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL
0109 bool acpi_parking_protocol_valid(int cpu);
0110 void __init
0111 acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor);
0112 #else
0113 static inline bool acpi_parking_protocol_valid(int cpu) { return false; }
0114 static inline void
0115 acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor)
0116 {}
0117 #endif
0118 
0119 static inline const char *acpi_get_enable_method(int cpu)
0120 {
0121     if (acpi_psci_present())
0122         return "psci";
0123 
0124     if (acpi_parking_protocol_valid(cpu))
0125         return "parking-protocol";
0126 
0127     return NULL;
0128 }
0129 
0130 #ifdef  CONFIG_ACPI_APEI
0131 /*
0132  * acpi_disable_cmcff is used in drivers/acpi/apei/hest.c for disabling
0133  * IA-32 Architecture Corrected Machine Check (CMC) Firmware-First mode
0134  * with a kernel command line parameter "acpi=nocmcoff". But we don't
0135  * have this IA-32 specific feature on ARM64, this definition is only
0136  * for compatibility.
0137  */
0138 #define acpi_disable_cmcff 1
0139 static inline pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr)
0140 {
0141     return __acpi_get_mem_attribute(addr);
0142 }
0143 #endif /* CONFIG_ACPI_APEI */
0144 
0145 #ifdef CONFIG_ACPI_NUMA
0146 int arm64_acpi_numa_init(void);
0147 int acpi_numa_get_nid(unsigned int cpu);
0148 void acpi_map_cpus_to_nodes(void);
0149 #else
0150 static inline int arm64_acpi_numa_init(void) { return -ENOSYS; }
0151 static inline int acpi_numa_get_nid(unsigned int cpu) { return NUMA_NO_NODE; }
0152 static inline void acpi_map_cpus_to_nodes(void) { }
0153 #endif /* CONFIG_ACPI_NUMA */
0154 
0155 #define ACPI_TABLE_UPGRADE_MAX_PHYS MEMBLOCK_ALLOC_ACCESSIBLE
0156 
0157 #endif /*_ASM_ACPI_H*/