1d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 237655163SAl Stone /* 337655163SAl Stone * Copyright (C) 2013-2014, Linaro Ltd. 437655163SAl Stone * Author: Al Stone <al.stone@linaro.org> 537655163SAl Stone * Author: Graeme Gregory <graeme.gregory@linaro.org> 637655163SAl Stone * Author: Hanjun Guo <hanjun.guo@linaro.org> 737655163SAl Stone */ 837655163SAl Stone 937655163SAl Stone #ifndef _ASM_ACPI_H 1037655163SAl Stone #define _ASM_ACPI_H 1137655163SAl Stone 1209ffcb0dSAKASHI Takahiro #include <linux/efi.h> 13e7cd1903SAKASHI Takahiro #include <linux/memblock.h> 14bff60792SMark Rutland #include <linux/psci.h> 15a194c33fSNick Desaulniers #include <linux/stddef.h> 16d60fc389STomasz Nowicki 17020295b4SHanjun Guo #include <asm/cputype.h> 1809ffcb0dSAKASHI Takahiro #include <asm/io.h> 19d44f1b8dSJames Morse #include <asm/ptrace.h> 20020295b4SHanjun Guo #include <asm/smp_plat.h> 219f9a35a7STomasz Nowicki #include <asm/tlbflush.h> 22652261a7SMark Salter 23b6cfb277SAl Stone /* Macros for consistency checks of the GICC subtable of MADT */ 249eb1c92bSJeremy Linton 259eb1c92bSJeremy Linton /* 269eb1c92bSJeremy Linton * MADT GICC minimum length refers to the MADT GICC structure table length as 279eb1c92bSJeremy Linton * defined in the earliest ACPI version supported on arm64, ie ACPI 5.1. 289eb1c92bSJeremy Linton * 299eb1c92bSJeremy Linton * The efficiency_class member was added to the 309eb1c92bSJeremy Linton * struct acpi_madt_generic_interrupt to represent the MADT GICC structure 319eb1c92bSJeremy Linton * "Processor Power Efficiency Class" field, added in ACPI 6.0 whose offset 329eb1c92bSJeremy Linton * is therefore used to delimit the MADT GICC structure minimum length 339eb1c92bSJeremy Linton * appropriately. 349eb1c92bSJeremy Linton */ 35a194c33fSNick Desaulniers #define ACPI_MADT_GICC_MIN_LENGTH offsetof( \ 369eb1c92bSJeremy Linton struct acpi_madt_generic_interrupt, efficiency_class) 37b6cfb277SAl Stone 38b6cfb277SAl Stone #define BAD_MADT_GICC_ENTRY(entry, end) \ 399eb1c92bSJeremy Linton (!(entry) || (entry)->header.length < ACPI_MADT_GICC_MIN_LENGTH || \ 409eb1c92bSJeremy Linton (unsigned long)(entry) + (entry)->header.length > (end)) 41b6cfb277SAl Stone 42a194c33fSNick Desaulniers #define ACPI_MADT_GICC_SPE (offsetof(struct acpi_madt_generic_interrupt, \ 43d24a0c70SJeremy Linton spe_interrupt) + sizeof(u16)) 44d24a0c70SJeremy Linton 45*1aa3d027SAnshuman Khandual #define ACPI_MADT_GICC_TRBE (offsetof(struct acpi_madt_generic_interrupt, \ 46*1aa3d027SAnshuman Khandual trbe_interrupt) + sizeof(u16)) 47*1aa3d027SAnshuman Khandual 4837655163SAl Stone /* Basic configuration for ACPI */ 4937655163SAl Stone #ifdef CONFIG_ACPI 5009ffcb0dSAKASHI Takahiro pgprot_t __acpi_get_mem_attribute(phys_addr_t addr); 5109ffcb0dSAKASHI Takahiro 528d3523fbSLv Zheng /* ACPI table mapping after acpi_permanent_mmap is set */ 531583052dSArd Biesheuvel void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size); 54652261a7SMark Salter #define acpi_os_ioremap acpi_os_ioremap 55652261a7SMark Salter 56020295b4SHanjun Guo typedef u64 phys_cpuid_t; 57020295b4SHanjun Guo #define PHYS_CPUID_INVALID INVALID_HWID 58020295b4SHanjun Guo 5937655163SAl Stone #define acpi_strict 1 /* No out-of-spec workarounds on ARM64 */ 6037655163SAl Stone extern int acpi_disabled; 6137655163SAl Stone extern int acpi_noirq; 6237655163SAl Stone extern int acpi_pci_disabled; 6337655163SAl Stone 6437655163SAl Stone static inline void disable_acpi(void) 6537655163SAl Stone { 6637655163SAl Stone acpi_disabled = 1; 6737655163SAl Stone acpi_pci_disabled = 1; 6837655163SAl Stone acpi_noirq = 1; 6937655163SAl Stone } 7037655163SAl Stone 71b10d79f7SAl Stone static inline void enable_acpi(void) 72b10d79f7SAl Stone { 73b10d79f7SAl Stone acpi_disabled = 0; 74b10d79f7SAl Stone acpi_pci_disabled = 0; 75b10d79f7SAl Stone acpi_noirq = 0; 76b10d79f7SAl Stone } 77b10d79f7SAl Stone 7837655163SAl Stone /* 79020295b4SHanjun Guo * The ACPI processor driver for ACPI core code needs this macro 80020295b4SHanjun Guo * to find out this cpu was already mapped (mapping from CPU hardware 81020295b4SHanjun Guo * ID to CPU logical ID) or not. 82020295b4SHanjun Guo */ 83020295b4SHanjun Guo #define cpu_physical_id(cpu) cpu_logical_map(cpu) 84020295b4SHanjun Guo 85020295b4SHanjun Guo /* 8637655163SAl Stone * It's used from ACPI core in kdump to boot UP system with SMP kernel, 8737655163SAl Stone * with this check the ACPI core will not override the CPU index 8837655163SAl Stone * obtained from GICC with 0 and not print some error message as well. 8937655163SAl Stone * Since MADT must provide at least one GICC structure for GIC 9037655163SAl Stone * initialization, CPU will be always available in MADT on ARM64. 9137655163SAl Stone */ 9237655163SAl Stone static inline bool acpi_has_cpu_in_madt(void) 9337655163SAl Stone { 9437655163SAl Stone return true; 9537655163SAl Stone } 9637655163SAl Stone 97e0013aedSMark Rutland struct acpi_madt_generic_interrupt *acpi_cpu_get_madt_gicc(int cpu); 9830d87bfaSJeremy Linton static inline u32 get_acpi_id_for_cpu(unsigned int cpu) 9930d87bfaSJeremy Linton { 10030d87bfaSJeremy Linton return acpi_cpu_get_madt_gicc(cpu)->uid; 10130d87bfaSJeremy Linton } 102e0013aedSMark Rutland 10337655163SAl Stone static inline void arch_fix_phys_package_id(int num, u32 slot) { } 104fccb9a81SHanjun Guo void __init acpi_init_cpus(void); 105d44f1b8dSJames Morse int apei_claim_sea(struct pt_regs *regs); 1067c59a3dfSGraeme Gregory #else 107fccb9a81SHanjun Guo static inline void acpi_init_cpus(void) { } 108d44f1b8dSJames Morse static inline int apei_claim_sea(struct pt_regs *regs) { return -ENOENT; } 10937655163SAl Stone #endif /* CONFIG_ACPI */ 11037655163SAl Stone 1115e89c55eSLorenzo Pieralisi #ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL 1125e89c55eSLorenzo Pieralisi bool acpi_parking_protocol_valid(int cpu); 1135e89c55eSLorenzo Pieralisi void __init 1145e89c55eSLorenzo Pieralisi acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor); 1155e89c55eSLorenzo Pieralisi #else 1165e89c55eSLorenzo Pieralisi static inline bool acpi_parking_protocol_valid(int cpu) { return false; } 1175e89c55eSLorenzo Pieralisi static inline void 1185e89c55eSLorenzo Pieralisi acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor) 1195e89c55eSLorenzo Pieralisi {} 1205e89c55eSLorenzo Pieralisi #endif 1215e89c55eSLorenzo Pieralisi 1220f078336SLorenzo Pieralisi static inline const char *acpi_get_enable_method(int cpu) 1230f078336SLorenzo Pieralisi { 1245e89c55eSLorenzo Pieralisi if (acpi_psci_present()) 1255e89c55eSLorenzo Pieralisi return "psci"; 1265e89c55eSLorenzo Pieralisi 1275e89c55eSLorenzo Pieralisi if (acpi_parking_protocol_valid(cpu)) 1285e89c55eSLorenzo Pieralisi return "parking-protocol"; 1295e89c55eSLorenzo Pieralisi 1305e89c55eSLorenzo Pieralisi return NULL; 1310f078336SLorenzo Pieralisi } 13289e44b51SJonathan (Zhixiong) Zhang 13389e44b51SJonathan (Zhixiong) Zhang #ifdef CONFIG_ACPI_APEI 1349f9a35a7STomasz Nowicki /* 1359f9a35a7STomasz Nowicki * acpi_disable_cmcff is used in drivers/acpi/apei/hest.c for disabling 1369f9a35a7STomasz Nowicki * IA-32 Architecture Corrected Machine Check (CMC) Firmware-First mode 1379f9a35a7STomasz Nowicki * with a kernel command line parameter "acpi=nocmcoff". But we don't 1389f9a35a7STomasz Nowicki * have this IA-32 specific feature on ARM64, this definition is only 1399f9a35a7STomasz Nowicki * for compatibility. 1409f9a35a7STomasz Nowicki */ 1419f9a35a7STomasz Nowicki #define acpi_disable_cmcff 1 14209ffcb0dSAKASHI Takahiro static inline pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr) 14309ffcb0dSAKASHI Takahiro { 14409ffcb0dSAKASHI Takahiro return __acpi_get_mem_attribute(addr); 14509ffcb0dSAKASHI Takahiro } 1469f9a35a7STomasz Nowicki #endif /* CONFIG_ACPI_APEI */ 14789e44b51SJonathan (Zhixiong) Zhang 148d8b47fcaSHanjun Guo #ifdef CONFIG_ACPI_NUMA 149d8b47fcaSHanjun Guo int arm64_acpi_numa_init(void); 150e1896249SLorenzo Pieralisi int acpi_numa_get_nid(unsigned int cpu); 151e1896249SLorenzo Pieralisi void acpi_map_cpus_to_nodes(void); 152d8b47fcaSHanjun Guo #else 153d8b47fcaSHanjun Guo static inline int arm64_acpi_numa_init(void) { return -ENOSYS; } 154e1896249SLorenzo Pieralisi static inline int acpi_numa_get_nid(unsigned int cpu) { return NUMA_NO_NODE; } 155e1896249SLorenzo Pieralisi static inline void acpi_map_cpus_to_nodes(void) { } 156d8b47fcaSHanjun Guo #endif /* CONFIG_ACPI_NUMA */ 157d8b47fcaSHanjun Guo 15838b04a74SJon Masters #define ACPI_TABLE_UPGRADE_MAX_PHYS MEMBLOCK_ALLOC_ACCESSIBLE 15938b04a74SJon Masters 16037655163SAl Stone #endif /*_ASM_ACPI_H*/ 161