18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2013-2014, Linaro Ltd. 48c2ecf20Sopenharmony_ci * Author: Al Stone <al.stone@linaro.org> 58c2ecf20Sopenharmony_ci * Author: Graeme Gregory <graeme.gregory@linaro.org> 68c2ecf20Sopenharmony_ci * Author: Hanjun Guo <hanjun.guo@linaro.org> 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#ifndef _ASM_ACPI_H 108c2ecf20Sopenharmony_ci#define _ASM_ACPI_H 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <linux/efi.h> 138c2ecf20Sopenharmony_ci#include <linux/memblock.h> 148c2ecf20Sopenharmony_ci#include <linux/psci.h> 158c2ecf20Sopenharmony_ci#include <linux/stddef.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#include <asm/cputype.h> 188c2ecf20Sopenharmony_ci#include <asm/io.h> 198c2ecf20Sopenharmony_ci#include <asm/ptrace.h> 208c2ecf20Sopenharmony_ci#include <asm/smp_plat.h> 218c2ecf20Sopenharmony_ci#include <asm/tlbflush.h> 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci/* Macros for consistency checks of the GICC subtable of MADT */ 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci/* 268c2ecf20Sopenharmony_ci * MADT GICC minimum length refers to the MADT GICC structure table length as 278c2ecf20Sopenharmony_ci * defined in the earliest ACPI version supported on arm64, ie ACPI 5.1. 288c2ecf20Sopenharmony_ci * 298c2ecf20Sopenharmony_ci * The efficiency_class member was added to the 308c2ecf20Sopenharmony_ci * struct acpi_madt_generic_interrupt to represent the MADT GICC structure 318c2ecf20Sopenharmony_ci * "Processor Power Efficiency Class" field, added in ACPI 6.0 whose offset 328c2ecf20Sopenharmony_ci * is therefore used to delimit the MADT GICC structure minimum length 338c2ecf20Sopenharmony_ci * appropriately. 348c2ecf20Sopenharmony_ci */ 358c2ecf20Sopenharmony_ci#define ACPI_MADT_GICC_MIN_LENGTH offsetof( \ 368c2ecf20Sopenharmony_ci struct acpi_madt_generic_interrupt, efficiency_class) 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#define BAD_MADT_GICC_ENTRY(entry, end) \ 398c2ecf20Sopenharmony_ci (!(entry) || (entry)->header.length < ACPI_MADT_GICC_MIN_LENGTH || \ 408c2ecf20Sopenharmony_ci (unsigned long)(entry) + (entry)->header.length > (end)) 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci#define ACPI_MADT_GICC_SPE (offsetof(struct acpi_madt_generic_interrupt, \ 438c2ecf20Sopenharmony_ci spe_interrupt) + sizeof(u16)) 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci/* Basic configuration for ACPI */ 468c2ecf20Sopenharmony_ci#ifdef CONFIG_ACPI 478c2ecf20Sopenharmony_cipgprot_t __acpi_get_mem_attribute(phys_addr_t addr); 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci/* ACPI table mapping after acpi_permanent_mmap is set */ 508c2ecf20Sopenharmony_civoid __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size); 518c2ecf20Sopenharmony_ci#define acpi_os_ioremap acpi_os_ioremap 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_citypedef u64 phys_cpuid_t; 548c2ecf20Sopenharmony_ci#define PHYS_CPUID_INVALID INVALID_HWID 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#define acpi_strict 1 /* No out-of-spec workarounds on ARM64 */ 578c2ecf20Sopenharmony_ciextern int acpi_disabled; 588c2ecf20Sopenharmony_ciextern int acpi_noirq; 598c2ecf20Sopenharmony_ciextern int acpi_pci_disabled; 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_cistatic inline void disable_acpi(void) 628c2ecf20Sopenharmony_ci{ 638c2ecf20Sopenharmony_ci acpi_disabled = 1; 648c2ecf20Sopenharmony_ci acpi_pci_disabled = 1; 658c2ecf20Sopenharmony_ci acpi_noirq = 1; 668c2ecf20Sopenharmony_ci} 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_cistatic inline void enable_acpi(void) 698c2ecf20Sopenharmony_ci{ 708c2ecf20Sopenharmony_ci acpi_disabled = 0; 718c2ecf20Sopenharmony_ci acpi_pci_disabled = 0; 728c2ecf20Sopenharmony_ci acpi_noirq = 0; 738c2ecf20Sopenharmony_ci} 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci/* 768c2ecf20Sopenharmony_ci * The ACPI processor driver for ACPI core code needs this macro 778c2ecf20Sopenharmony_ci * to find out this cpu was already mapped (mapping from CPU hardware 788c2ecf20Sopenharmony_ci * ID to CPU logical ID) or not. 798c2ecf20Sopenharmony_ci */ 808c2ecf20Sopenharmony_ci#define cpu_physical_id(cpu) cpu_logical_map(cpu) 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci/* 838c2ecf20Sopenharmony_ci * It's used from ACPI core in kdump to boot UP system with SMP kernel, 848c2ecf20Sopenharmony_ci * with this check the ACPI core will not override the CPU index 858c2ecf20Sopenharmony_ci * obtained from GICC with 0 and not print some error message as well. 868c2ecf20Sopenharmony_ci * Since MADT must provide at least one GICC structure for GIC 878c2ecf20Sopenharmony_ci * initialization, CPU will be always available in MADT on ARM64. 888c2ecf20Sopenharmony_ci */ 898c2ecf20Sopenharmony_cistatic inline bool acpi_has_cpu_in_madt(void) 908c2ecf20Sopenharmony_ci{ 918c2ecf20Sopenharmony_ci return true; 928c2ecf20Sopenharmony_ci} 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_cistruct acpi_madt_generic_interrupt *acpi_cpu_get_madt_gicc(int cpu); 958c2ecf20Sopenharmony_cistatic inline u32 get_acpi_id_for_cpu(unsigned int cpu) 968c2ecf20Sopenharmony_ci{ 978c2ecf20Sopenharmony_ci return acpi_cpu_get_madt_gicc(cpu)->uid; 988c2ecf20Sopenharmony_ci} 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_cistatic inline void arch_fix_phys_package_id(int num, u32 slot) { } 1018c2ecf20Sopenharmony_civoid __init acpi_init_cpus(void); 1028c2ecf20Sopenharmony_ciint apei_claim_sea(struct pt_regs *regs); 1038c2ecf20Sopenharmony_ci#else 1048c2ecf20Sopenharmony_cistatic inline void acpi_init_cpus(void) { } 1058c2ecf20Sopenharmony_cistatic inline int apei_claim_sea(struct pt_regs *regs) { return -ENOENT; } 1068c2ecf20Sopenharmony_ci#endif /* CONFIG_ACPI */ 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci#ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL 1098c2ecf20Sopenharmony_cibool acpi_parking_protocol_valid(int cpu); 1108c2ecf20Sopenharmony_civoid __init 1118c2ecf20Sopenharmony_ciacpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor); 1128c2ecf20Sopenharmony_ci#else 1138c2ecf20Sopenharmony_cistatic inline bool acpi_parking_protocol_valid(int cpu) { return false; } 1148c2ecf20Sopenharmony_cistatic inline void 1158c2ecf20Sopenharmony_ciacpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor) 1168c2ecf20Sopenharmony_ci{} 1178c2ecf20Sopenharmony_ci#endif 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_cistatic inline const char *acpi_get_enable_method(int cpu) 1208c2ecf20Sopenharmony_ci{ 1218c2ecf20Sopenharmony_ci if (acpi_psci_present()) 1228c2ecf20Sopenharmony_ci return "psci"; 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci if (acpi_parking_protocol_valid(cpu)) 1258c2ecf20Sopenharmony_ci return "parking-protocol"; 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci return NULL; 1288c2ecf20Sopenharmony_ci} 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci#ifdef CONFIG_ACPI_APEI 1318c2ecf20Sopenharmony_ci/* 1328c2ecf20Sopenharmony_ci * acpi_disable_cmcff is used in drivers/acpi/apei/hest.c for disabling 1338c2ecf20Sopenharmony_ci * IA-32 Architecture Corrected Machine Check (CMC) Firmware-First mode 1348c2ecf20Sopenharmony_ci * with a kernel command line parameter "acpi=nocmcoff". But we don't 1358c2ecf20Sopenharmony_ci * have this IA-32 specific feature on ARM64, this definition is only 1368c2ecf20Sopenharmony_ci * for compatibility. 1378c2ecf20Sopenharmony_ci */ 1388c2ecf20Sopenharmony_ci#define acpi_disable_cmcff 1 1398c2ecf20Sopenharmony_cistatic inline pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr) 1408c2ecf20Sopenharmony_ci{ 1418c2ecf20Sopenharmony_ci return __acpi_get_mem_attribute(addr); 1428c2ecf20Sopenharmony_ci} 1438c2ecf20Sopenharmony_ci#endif /* CONFIG_ACPI_APEI */ 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ci#ifdef CONFIG_ACPI_NUMA 1468c2ecf20Sopenharmony_ciint arm64_acpi_numa_init(void); 1478c2ecf20Sopenharmony_ciint acpi_numa_get_nid(unsigned int cpu); 1488c2ecf20Sopenharmony_civoid acpi_map_cpus_to_nodes(void); 1498c2ecf20Sopenharmony_ci#else 1508c2ecf20Sopenharmony_cistatic inline int arm64_acpi_numa_init(void) { return -ENOSYS; } 1518c2ecf20Sopenharmony_cistatic inline int acpi_numa_get_nid(unsigned int cpu) { return NUMA_NO_NODE; } 1528c2ecf20Sopenharmony_cistatic inline void acpi_map_cpus_to_nodes(void) { } 1538c2ecf20Sopenharmony_ci#endif /* CONFIG_ACPI_NUMA */ 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_ci#define ACPI_TABLE_UPGRADE_MAX_PHYS MEMBLOCK_ALLOC_ACCESSIBLE 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci#endif /*_ASM_ACPI_H*/ 158