blob: 0db62a4cbce2d07b14fa53542aeecfe1ffc2746f [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
AKASHI Takahiroe7cd1902016-08-22 15:55:24 +090015#include <linux/memblock.h>
Mark Rutlandbff60792015-07-31 15:46:16 +010016#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>
Tomasz Nowicki9f9a35a2016-12-01 21:51:12 +080020#include <asm/tlbflush.h>
Mark Salter652261a2015-03-24 14:02:38 +000021
Al Stoneb6cfb272015-07-06 17:16:47 -060022/* Macros for consistency checks of the GICC subtable of MADT */
23#define ACPI_MADT_GICC_LENGTH \
24 (acpi_gbl_FADT.header.revision < 6 ? 76 : 80)
25
Lorenzo Pieralisicb7cf772017-05-26 17:40:02 +010026#define BAD_MADT_GICC_ENTRY(entry, end) \
27 (!(entry) || (entry)->header.length != ACPI_MADT_GICC_LENGTH || \
28 (unsigned long)(entry) + ACPI_MADT_GICC_LENGTH > (end))
Al Stoneb6cfb272015-07-06 17:16:47 -060029
Al Stone37655162015-03-24 14:02:37 +000030/* Basic configuration for ACPI */
31#ifdef CONFIG_ACPI
Lv Zheng8d3523f2016-12-14 15:04:46 +080032/* ACPI table mapping after acpi_permanent_mmap is set */
Mark Salter652261a2015-03-24 14:02:38 +000033static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
34 acpi_size size)
35{
AKASHI Takahiroe7cd1902016-08-22 15:55:24 +090036 /*
37 * EFI's reserve_regions() call adds memory with the WB attribute
38 * to memblock via early_init_dt_add_memory_arch().
39 */
40 if (!memblock_is_memory(phys))
Mark Salter652261a2015-03-24 14:02:38 +000041 return ioremap(phys, size);
42
43 return ioremap_cache(phys, size);
44}
45#define acpi_os_ioremap acpi_os_ioremap
46
Hanjun Guo020295b2015-03-24 14:02:47 +000047typedef u64 phys_cpuid_t;
48#define PHYS_CPUID_INVALID INVALID_HWID
49
Al Stone37655162015-03-24 14:02:37 +000050#define acpi_strict 1 /* No out-of-spec workarounds on ARM64 */
51extern int acpi_disabled;
52extern int acpi_noirq;
53extern int acpi_pci_disabled;
54
55static inline void disable_acpi(void)
56{
57 acpi_disabled = 1;
58 acpi_pci_disabled = 1;
59 acpi_noirq = 1;
60}
61
Al Stoneb10d79f2015-03-24 14:02:41 +000062static inline void enable_acpi(void)
63{
64 acpi_disabled = 0;
65 acpi_pci_disabled = 0;
66 acpi_noirq = 0;
67}
68
Al Stone37655162015-03-24 14:02:37 +000069/*
Hanjun Guo020295b2015-03-24 14:02:47 +000070 * The ACPI processor driver for ACPI core code needs this macro
71 * to find out this cpu was already mapped (mapping from CPU hardware
72 * ID to CPU logical ID) or not.
73 */
74#define cpu_physical_id(cpu) cpu_logical_map(cpu)
75
76/*
Al Stone37655162015-03-24 14:02:37 +000077 * It's used from ACPI core in kdump to boot UP system with SMP kernel,
78 * with this check the ACPI core will not override the CPU index
79 * obtained from GICC with 0 and not print some error message as well.
80 * Since MADT must provide at least one GICC structure for GIC
81 * initialization, CPU will be always available in MADT on ARM64.
82 */
83static inline bool acpi_has_cpu_in_madt(void)
84{
85 return true;
86}
87
Mark Rutlande0013ae2017-04-11 09:39:54 +010088struct acpi_madt_generic_interrupt *acpi_cpu_get_madt_gicc(int cpu);
Jeremy Linton30d87bf2018-05-11 18:57:59 -050089static inline u32 get_acpi_id_for_cpu(unsigned int cpu)
90{
91 return acpi_cpu_get_madt_gicc(cpu)->uid;
92}
Mark Rutlande0013ae2017-04-11 09:39:54 +010093
Al Stone37655162015-03-24 14:02:37 +000094static inline void arch_fix_phys_package_id(int num, u32 slot) { }
Hanjun Guofccb9a82015-03-24 22:02:45 +080095void __init acpi_init_cpus(void);
Al Stone37655162015-03-24 14:02:37 +000096
Graeme Gregory7c59a3d2015-03-24 14:02:43 +000097#else
Hanjun Guofccb9a82015-03-24 22:02:45 +080098static inline void acpi_init_cpus(void) { }
Al Stone37655162015-03-24 14:02:37 +000099#endif /* CONFIG_ACPI */
100
Lorenzo Pieralisi5e89c552016-01-26 11:10:38 +0000101#ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL
102bool acpi_parking_protocol_valid(int cpu);
103void __init
104acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor);
105#else
106static inline bool acpi_parking_protocol_valid(int cpu) { return false; }
107static inline void
108acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor)
109{}
110#endif
111
Lorenzo Pieralisi0f078332015-05-13 14:12:47 +0100112static inline const char *acpi_get_enable_method(int cpu)
113{
Lorenzo Pieralisi5e89c552016-01-26 11:10:38 +0000114 if (acpi_psci_present())
115 return "psci";
116
117 if (acpi_parking_protocol_valid(cpu))
118 return "parking-protocol";
119
120 return NULL;
Lorenzo Pieralisi0f078332015-05-13 14:12:47 +0100121}
Jonathan (Zhixiong) Zhang89e44b52015-09-04 14:11:41 +0100122
123#ifdef CONFIG_ACPI_APEI
Tomasz Nowicki9f9a35a2016-12-01 21:51:12 +0800124/*
125 * acpi_disable_cmcff is used in drivers/acpi/apei/hest.c for disabling
126 * IA-32 Architecture Corrected Machine Check (CMC) Firmware-First mode
127 * with a kernel command line parameter "acpi=nocmcoff". But we don't
128 * have this IA-32 specific feature on ARM64, this definition is only
129 * for compatibility.
130 */
131#define acpi_disable_cmcff 1
Jonathan (Zhixiong) Zhang89e44b52015-09-04 14:11:41 +0100132pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr);
Tomasz Nowicki9f9a35a2016-12-01 21:51:12 +0800133#endif /* CONFIG_ACPI_APEI */
Jonathan (Zhixiong) Zhang89e44b52015-09-04 14:11:41 +0100134
Hanjun Guod8b47fc2016-05-24 15:35:44 -0700135#ifdef CONFIG_ACPI_NUMA
136int arm64_acpi_numa_init(void);
137int acpi_numa_get_nid(unsigned int cpu, u64 hwid);
138#else
139static inline int arm64_acpi_numa_init(void) { return -ENOSYS; }
140static inline int acpi_numa_get_nid(unsigned int cpu, u64 hwid) { return NUMA_NO_NODE; }
141#endif /* CONFIG_ACPI_NUMA */
142
Jon Masters38b04a72016-06-20 13:56:13 +0300143#define ACPI_TABLE_UPGRADE_MAX_PHYS MEMBLOCK_ALLOC_ACCESSIBLE
144
Al Stone37655162015-03-24 14:02:37 +0000145#endif /*_ASM_ACPI_H*/