blob: 1240b867d4a2b427ef98b45cd6d17434f2abc9ba [file] [log] [blame]
Al Stone37655162015-03-24 14:02:37 +00001/*
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
Mark Salter652261a2015-03-24 14:02:38 +000015#include <linux/mm.h>
Tomasz Nowickid60fc382015-03-24 14:02:49 +000016#include <linux/irqchip/arm-gic-acpi.h>
17
Hanjun Guo020295b2015-03-24 14:02:47 +000018#include <asm/cputype.h>
19#include <asm/smp_plat.h>
Mark Salter652261a2015-03-24 14:02:38 +000020
Al Stone37655162015-03-24 14:02:37 +000021/* Basic configuration for ACPI */
22#ifdef CONFIG_ACPI
Mark Salter652261a2015-03-24 14:02:38 +000023/* ACPI table mapping after acpi_gbl_permanent_mmap is set */
24static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
25 acpi_size size)
26{
27 if (!page_is_ram(phys >> PAGE_SHIFT))
28 return ioremap(phys, size);
29
30 return ioremap_cache(phys, size);
31}
32#define acpi_os_ioremap acpi_os_ioremap
33
Hanjun Guo020295b2015-03-24 14:02:47 +000034typedef u64 phys_cpuid_t;
35#define PHYS_CPUID_INVALID INVALID_HWID
36
Al Stone37655162015-03-24 14:02:37 +000037#define acpi_strict 1 /* No out-of-spec workarounds on ARM64 */
38extern int acpi_disabled;
39extern int acpi_noirq;
40extern int acpi_pci_disabled;
41
Graeme Gregory7c59a3d2015-03-24 14:02:43 +000042/* 1 to indicate PSCI 0.2+ is implemented */
43static inline bool acpi_psci_present(void)
44{
45 return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_COMPLIANT;
46}
47
48/* 1 to indicate HVC must be used instead of SMC as the PSCI conduit */
49static inline bool acpi_psci_use_hvc(void)
50{
51 return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC;
52}
53
Al Stone37655162015-03-24 14:02:37 +000054static inline void disable_acpi(void)
55{
56 acpi_disabled = 1;
57 acpi_pci_disabled = 1;
58 acpi_noirq = 1;
59}
60
Al Stoneb10d79f2015-03-24 14:02:41 +000061static inline void enable_acpi(void)
62{
63 acpi_disabled = 0;
64 acpi_pci_disabled = 0;
65 acpi_noirq = 0;
66}
67
Al Stone37655162015-03-24 14:02:37 +000068/*
Hanjun Guo020295b2015-03-24 14:02:47 +000069 * The ACPI processor driver for ACPI core code needs this macro
70 * to find out this cpu was already mapped (mapping from CPU hardware
71 * ID to CPU logical ID) or not.
72 */
73#define cpu_physical_id(cpu) cpu_logical_map(cpu)
74
75/*
Al Stone37655162015-03-24 14:02:37 +000076 * It's used from ACPI core in kdump to boot UP system with SMP kernel,
77 * with this check the ACPI core will not override the CPU index
78 * obtained from GICC with 0 and not print some error message as well.
79 * Since MADT must provide at least one GICC structure for GIC
80 * initialization, CPU will be always available in MADT on ARM64.
81 */
82static inline bool acpi_has_cpu_in_madt(void)
83{
84 return true;
85}
86
87static inline void arch_fix_phys_package_id(int num, u32 slot) { }
Hanjun Guofccb9a82015-03-24 22:02:45 +080088void __init acpi_init_cpus(void);
Al Stone37655162015-03-24 14:02:37 +000089
Graeme Gregory7c59a3d2015-03-24 14:02:43 +000090#else
91static inline bool acpi_psci_present(void) { return false; }
92static inline bool acpi_psci_use_hvc(void) { return false; }
Hanjun Guofccb9a82015-03-24 22:02:45 +080093static inline void acpi_init_cpus(void) { }
Al Stone37655162015-03-24 14:02:37 +000094#endif /* CONFIG_ACPI */
95
Lorenzo Pieralisi0f078332015-05-13 14:12:47 +010096static inline const char *acpi_get_enable_method(int cpu)
97{
98 return acpi_psci_present() ? "psci" : NULL;
99}
Al Stone37655162015-03-24 14:02:37 +0000100#endif /*_ASM_ACPI_H*/