blob: caafd63b8092d8102401112d811b1055f4cc3524 [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 Rutlandbff607922015-07-31 15:46:16 +010015#include <linux/mm.h>
16#include <linux/psci.h>
Tomasz Nowickid60fc382015-03-24 14:02:49 +000017
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 Stoneb6cfb272015-07-06 17:16:47 -060021/* Macros for consistency checks of the GICC subtable of MADT */
22#define ACPI_MADT_GICC_LENGTH \
23 (acpi_gbl_FADT.header.revision < 6 ? 76 : 80)
24
25#define BAD_MADT_GICC_ENTRY(entry, end) \
26 (!(entry) || (unsigned long)(entry) + sizeof(*(entry)) > (end) || \
27 (entry)->header.length != ACPI_MADT_GICC_LENGTH)
28
Al Stone37655162015-03-24 14:02:37 +000029/* Basic configuration for ACPI */
30#ifdef CONFIG_ACPI
Mark Salter652261a2015-03-24 14:02:38 +000031/* ACPI table mapping after acpi_gbl_permanent_mmap is set */
32static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
33 acpi_size size)
34{
35 if (!page_is_ram(phys >> PAGE_SHIFT))
36 return ioremap(phys, size);
37
38 return ioremap_cache(phys, size);
39}
40#define acpi_os_ioremap acpi_os_ioremap
41
Hanjun Guo020295b2015-03-24 14:02:47 +000042typedef u64 phys_cpuid_t;
43#define PHYS_CPUID_INVALID INVALID_HWID
44
Al Stone37655162015-03-24 14:02:37 +000045#define acpi_strict 1 /* No out-of-spec workarounds on ARM64 */
46extern int acpi_disabled;
47extern int acpi_noirq;
48extern int acpi_pci_disabled;
49
50static inline void disable_acpi(void)
51{
52 acpi_disabled = 1;
53 acpi_pci_disabled = 1;
54 acpi_noirq = 1;
55}
56
Al Stoneb10d79f2015-03-24 14:02:41 +000057static inline void enable_acpi(void)
58{
59 acpi_disabled = 0;
60 acpi_pci_disabled = 0;
61 acpi_noirq = 0;
62}
63
Al Stone37655162015-03-24 14:02:37 +000064/*
Hanjun Guo020295b2015-03-24 14:02:47 +000065 * The ACPI processor driver for ACPI core code needs this macro
66 * to find out this cpu was already mapped (mapping from CPU hardware
67 * ID to CPU logical ID) or not.
68 */
69#define cpu_physical_id(cpu) cpu_logical_map(cpu)
70
71/*
Al Stone37655162015-03-24 14:02:37 +000072 * It's used from ACPI core in kdump to boot UP system with SMP kernel,
73 * with this check the ACPI core will not override the CPU index
74 * obtained from GICC with 0 and not print some error message as well.
75 * Since MADT must provide at least one GICC structure for GIC
76 * initialization, CPU will be always available in MADT on ARM64.
77 */
78static inline bool acpi_has_cpu_in_madt(void)
79{
80 return true;
81}
82
83static inline void arch_fix_phys_package_id(int num, u32 slot) { }
Hanjun Guofccb9a82015-03-24 22:02:45 +080084void __init acpi_init_cpus(void);
Al Stone37655162015-03-24 14:02:37 +000085
Graeme Gregory7c59a3d2015-03-24 14:02:43 +000086#else
Hanjun Guofccb9a82015-03-24 22:02:45 +080087static inline void acpi_init_cpus(void) { }
Al Stone37655162015-03-24 14:02:37 +000088#endif /* CONFIG_ACPI */
89
Lorenzo Pieralisi0f078332015-05-13 14:12:47 +010090static inline const char *acpi_get_enable_method(int cpu)
91{
92 return acpi_psci_present() ? "psci" : NULL;
93}
Jonathan (Zhixiong) Zhang89e44b52015-09-04 14:11:41 +010094
95#ifdef CONFIG_ACPI_APEI
96pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr);
97#endif
98
Al Stone37655162015-03-24 14:02:37 +000099#endif /*_ASM_ACPI_H*/