| /* SPDX-License-Identifier: GPL-2.0-only */ | |
| /* | |
| * Copyright (C) 2013-2014, Linaro Ltd. | |
| * Author: Al Stone <al.stone@linaro.org> | |
| * Author: Graeme Gregory <graeme.gregory@linaro.org> | |
| * Author: Hanjun Guo <hanjun.guo@linaro.org> | |
| * | |
| * Copyright (C) 2021-2023, Ventana Micro Systems Inc. | |
| * Author: Sunil V L <sunilvl@ventanamicro.com> | |
| */ | |
| #ifndef _ASM_ACPI_H | |
| #define _ASM_ACPI_H | |
| #include <linux/cpuidle.h> | |
| /* Basic configuration for ACPI */ | |
| #ifdef CONFIG_ACPI | |
| typedef u64 phys_cpuid_t; | |
| #define PHYS_CPUID_INVALID INVALID_HARTID | |
| /* ACPI table mapping after acpi_permanent_mmap is set */ | |
| void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size); | |
| #define acpi_os_ioremap acpi_os_ioremap | |
| #define acpi_strict 1 /* No out-of-spec workarounds on RISC-V */ | |
| extern int acpi_disabled; | |
| extern int acpi_noirq; | |
| extern int acpi_pci_disabled; | |
| static inline void disable_acpi(void) | |
| { | |
| acpi_disabled = 1; | |
| acpi_pci_disabled = 1; | |
| acpi_noirq = 1; | |
| } | |
| static inline void enable_acpi(void) | |
| { | |
| acpi_disabled = 0; | |
| acpi_pci_disabled = 0; | |
| acpi_noirq = 0; | |
| } | |
| /* | |
| * The ACPI processor driver for ACPI core code needs this macro | |
| * to find out whether this cpu was already mapped (mapping from CPU hardware | |
| * ID to CPU logical ID) or not. | |
| */ | |
| #define cpu_physical_id(cpu) cpuid_to_hartid_map(cpu) | |
| /* | |
| * Since MADT must provide at least one RINTC structure, the | |
| * CPU will be always available in MADT on RISC-V. | |
| */ | |
| static inline bool acpi_has_cpu_in_madt(void) | |
| { | |
| return true; | |
| } | |
| static inline void arch_fix_phys_package_id(int num, u32 slot) { } | |
| void acpi_init_rintc_map(void); | |
| struct acpi_madt_rintc *acpi_cpu_get_madt_rintc(int cpu); | |
| int acpi_get_riscv_isa(struct acpi_table_header *table, | |
| unsigned int cpu, const char **isa); | |
| void acpi_get_cbo_block_size(struct acpi_table_header *table, u32 *cbom_size, | |
| u32 *cboz_size, u32 *cbop_size); | |
| acpi_handle acpi_get_riscv_gsi_handle(u32 gsi); | |
| /* | |
| * RISC-V Functional Fixed Hardware Specification Version v1.0.1, | |
| * Chapter 3.1.2, Table 4: Arch. Context Lost Flags | |
| */ | |
| #define RISCV_LPI_HART_TIMER_CTXT_LOST BIT(0) | |
| static inline unsigned int arch_get_idle_state_flags(u32 arch_flags) | |
| { | |
| if (arch_flags & RISCV_LPI_HART_TIMER_CTXT_LOST) | |
| return CPUIDLE_FLAG_TIMER_STOP; | |
| return 0; | |
| } | |
| #define arch_get_idle_state_flags arch_get_idle_state_flags | |
| #else | |
| static inline void acpi_init_rintc_map(void) { } | |
| static inline struct acpi_madt_rintc *acpi_cpu_get_madt_rintc(int cpu) | |
| { | |
| return NULL; | |
| } | |
| static inline int acpi_get_riscv_isa(struct acpi_table_header *table, | |
| unsigned int cpu, const char **isa) | |
| { | |
| return -EINVAL; | |
| } | |
| static inline void acpi_get_cbo_block_size(struct acpi_table_header *table, | |
| u32 *cbom_size, u32 *cboz_size, | |
| u32 *cbop_size) { } | |
| #endif /* CONFIG_ACPI */ | |
| #ifdef CONFIG_ACPI_NUMA | |
| void acpi_map_cpus_to_nodes(void); | |
| #else | |
| static inline void acpi_map_cpus_to_nodes(void) { } | |
| #endif /* CONFIG_ACPI_NUMA */ | |
| #define ACPI_TABLE_UPGRADE_MAX_PHYS MEMBLOCK_ALLOC_ACCESSIBLE | |
| #endif /*_ASM_ACPI_H*/ |