Commit 836ee487 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux

Pull initial ACPI support for arm64 from Will Deacon:
 "This series introduces preliminary ACPI 5.1 support to the arm64
  kernel using the "hardware reduced" profile.  We don't support any
  peripherals yet, so it's fairly limited in scope:

   - MEMORY init (UEFI)

   - ACPI discovery (RSDP via UEFI)

   - CPU init (FADT)

   - GIC init (MADT)

   - SMP boot (MADT + PSCI)

   - ACPI Kconfig options (dependent on EXPERT)

  ACPI for arm64 has been in development for a while now and hardware
  has been available that can boot with either FDT or ACPI tables.  This
  has been made possible by both changes to the ACPI spec to cater for
  ARM-based machines (known as "hardware-reduced" in ACPI parlance) but
  also a Linaro-driven effort to get this supported on top of the Linux
  kernel.  This pull request is the result of that work.

  These changes allow us to initialise the CPUs, interrupt controller,
  and timers via ACPI tables, with memory information and cmdline coming
  from EFI.  We don't support a hybrid ACPI/FDT scheme.  Of course,
  there is still plenty of work to do (a serial console would be nice!)
  but I expect that to happen on a per-driver basis after this core
  series has been merged.

  Anyway, the diff stat here is fairly horrible, but splitting this up
  and merging it via all the different subsystems would have been
  extremely painful.  Instead, we've got all the relevant Acks in place
  and I've not seen anything other than trivial (Kconfig) conflicts in
  -next (for completeness, I've included my resolution below).  Nearly
  half of the insertions fall under Documentation/.

  So, we'll see how this goes.  Right now, it all depends on EXPERT and
  I fully expect people to use FDT by default for the immediate future"

* tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: (31 commits)
  ARM64 / ACPI: make acpi_map_gic_cpu_interface() as void function
  ARM64 / ACPI: Ignore the return error value of acpi_map_gic_cpu_interface()
  ARM64 / ACPI: fix usage of acpi_map_gic_cpu_interface
  ARM64: kernel: acpi: honour acpi=force command line parameter
  ARM64: kernel: acpi: refactor ACPI tables init and checks
  ARM64: kernel: psci: let ACPI probe PSCI version
  ARM64: kernel: psci: factor out probe function
  ACPI: move arm64 GSI IRQ model to generic GSI IRQ layer
  ARM64 / ACPI: Don't unflatten device tree if acpi=force is passed
  ARM64 / ACPI: additions of ACPI documentation for arm64
  Documentation: ACPI for ARM64
  ARM64 / ACPI: Enable ARM64 in Kconfig
  XEN / ACPI: Make XEN ACPI depend on X86
  ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64
  clocksource / arch_timer: Parse GTDT to initialize arch timer
  irqchip: Add GICv2 specific ACPI boot support
  ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi
  ACPI / processor: Make it possible to get CPU hardware ID via GICC
  ACPI / processor: Introduce phys_cpuid_t for CPU hardware ID
  ARM64 / ACPI: Parse MADT for SMP initialization
  ...
parents fb65d872 7676fa70
This diff is collapsed.
This diff is collapsed.
...@@ -165,7 +165,7 @@ multipliers 'Kilo', 'Mega', and 'Giga', equalling 2^10, 2^20, and 2^30 ...@@ -165,7 +165,7 @@ multipliers 'Kilo', 'Mega', and 'Giga', equalling 2^10, 2^20, and 2^30
bytes respectively. Such letter suffixes can also be entirely omitted. bytes respectively. Such letter suffixes can also be entirely omitted.
acpi= [HW,ACPI,X86] acpi= [HW,ACPI,X86,ARM64]
Advanced Configuration and Power Interface Advanced Configuration and Power Interface
Format: { force | off | strict | noirq | rsdt } Format: { force | off | strict | noirq | rsdt }
force -- enable ACPI if default was off force -- enable ACPI if default was off
...@@ -175,6 +175,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted. ...@@ -175,6 +175,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
strictly ACPI specification compliant. strictly ACPI specification compliant.
rsdt -- prefer RSDT over (default) XSDT rsdt -- prefer RSDT over (default) XSDT
copy_dsdt -- copy DSDT to memory copy_dsdt -- copy DSDT to memory
For ARM64, ONLY "acpi=off" or "acpi=force" are available
See also Documentation/power/runtime_pm.txt, pci=noacpi See also Documentation/power/runtime_pm.txt, pci=noacpi
......
config ARM64 config ARM64
def_bool y def_bool y
select ACPI_GENERIC_GSI if ACPI
select ACPI_REDUCED_HARDWARE_ONLY if ACPI
select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_ELF_RANDOMIZE
select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_GCOV_PROFILE_ALL
...@@ -758,6 +760,8 @@ source "drivers/Kconfig" ...@@ -758,6 +760,8 @@ source "drivers/Kconfig"
source "drivers/firmware/Kconfig" source "drivers/firmware/Kconfig"
source "drivers/acpi/Kconfig"
source "fs/Kconfig" source "fs/Kconfig"
source "arch/arm64/kvm/Kconfig" source "arch/arm64/kvm/Kconfig"
......
/*
* ARM64 specific ACPICA environments and implementation
*
* Copyright (C) 2014, Linaro Ltd.
* Author: Hanjun Guo <hanjun.guo@linaro.org>
* Author: Graeme Gregory <graeme.gregory@linaro.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef _ASM_ACENV_H
#define _ASM_ACENV_H
/* It is required unconditionally by ACPI core, update it when needed. */
#endif /* _ASM_ACENV_H */
/*
* 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>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*/
#ifndef _ASM_ACPI_H
#define _ASM_ACPI_H
#include <linux/mm.h>
#include <linux/irqchip/arm-gic-acpi.h>
#include <asm/cputype.h>
#include <asm/smp_plat.h>
/* Basic configuration for ACPI */
#ifdef CONFIG_ACPI
/* ACPI table mapping after acpi_gbl_permanent_mmap is set */
static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
acpi_size size)
{
if (!page_is_ram(phys >> PAGE_SHIFT))
return ioremap(phys, size);
return ioremap_cache(phys, size);
}
#define acpi_os_ioremap acpi_os_ioremap
typedef u64 phys_cpuid_t;
#define PHYS_CPUID_INVALID INVALID_HWID
#define acpi_strict 1 /* No out-of-spec workarounds on ARM64 */
extern int acpi_disabled;
extern int acpi_noirq;
extern int acpi_pci_disabled;
/* 1 to indicate PSCI 0.2+ is implemented */
static inline bool acpi_psci_present(void)
{
return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_COMPLIANT;
}
/* 1 to indicate HVC must be used instead of SMC as the PSCI conduit */
static inline bool acpi_psci_use_hvc(void)
{
return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC;
}
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 this cpu was already mapped (mapping from CPU hardware
* ID to CPU logical ID) or not.
*/
#define cpu_physical_id(cpu) cpu_logical_map(cpu)
/*
* It's used from ACPI core in kdump to boot UP system with SMP kernel,
* with this check the ACPI core will not override the CPU index
* obtained from GICC with 0 and not print some error message as well.
* Since MADT must provide at least one GICC structure for GIC
* initialization, CPU will be always available in MADT on ARM64.
*/
static inline bool acpi_has_cpu_in_madt(void)
{
return true;
}
static inline void arch_fix_phys_package_id(int num, u32 slot) { }
void __init acpi_init_cpus(void);
#else
static inline bool acpi_psci_present(void) { return false; }
static inline bool acpi_psci_use_hvc(void) { return false; }
static inline void acpi_init_cpus(void) { }
#endif /* CONFIG_ACPI */
#endif /*_ASM_ACPI_H*/
...@@ -66,5 +66,6 @@ struct cpu_operations { ...@@ -66,5 +66,6 @@ struct cpu_operations {
extern const struct cpu_operations *cpu_ops[NR_CPUS]; extern const struct cpu_operations *cpu_ops[NR_CPUS];
int __init cpu_read_ops(struct device_node *dn, int cpu); int __init cpu_read_ops(struct device_node *dn, int cpu);
void __init cpu_read_bootcpu_ops(void); void __init cpu_read_bootcpu_ops(void);
const struct cpu_operations *cpu_get_ops(const char *name);
#endif /* ifndef __ASM_CPU_OPS_H */ #endif /* ifndef __ASM_CPU_OPS_H */
...@@ -62,6 +62,9 @@ void __init early_fixmap_init(void); ...@@ -62,6 +62,9 @@ void __init early_fixmap_init(void);
#define __early_set_fixmap __set_fixmap #define __early_set_fixmap __set_fixmap
#define __late_set_fixmap __set_fixmap
#define __late_clear_fixmap(idx) __set_fixmap((idx), 0, FIXMAP_PAGE_CLEAR)
extern void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot); extern void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot);
#include <asm-generic/fixmap.h> #include <asm-generic/fixmap.h>
......
#ifndef __ASM_IRQ_H #ifndef __ASM_IRQ_H
#define __ASM_IRQ_H #define __ASM_IRQ_H
#include <linux/irqchip/arm-gic-acpi.h>
#include <asm-generic/irq.h> #include <asm-generic/irq.h>
struct pt_regs; struct pt_regs;
...@@ -8,4 +10,15 @@ struct pt_regs; ...@@ -8,4 +10,15 @@ struct pt_regs;
extern void migrate_irqs(void); extern void migrate_irqs(void);
extern void set_handle_irq(void (*handle_irq)(struct pt_regs *)); extern void set_handle_irq(void (*handle_irq)(struct pt_regs *));
static inline void acpi_irq_init(void)
{
/*
* Hardcode ACPI IRQ chip initialization to GICv2 for now.
* Proper irqchip infrastructure will be implemented along with
* incoming GICv2m|GICv3|ITS bits.
*/
acpi_gic_init();
}
#define acpi_irq_init acpi_irq_init
#endif #endif
...@@ -27,6 +27,12 @@ ...@@ -27,6 +27,12 @@
extern int isa_dma_bridge_buggy; extern int isa_dma_bridge_buggy;
#ifdef CONFIG_PCI #ifdef CONFIG_PCI
static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
{
/* no legacy IRQ on arm64 */
return -ENODEV;
}
static inline int pci_proc_domain(struct pci_bus *bus) static inline int pci_proc_domain(struct pci_bus *bus)
{ {
return 1; return 1;
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#ifndef __ASM_PSCI_H #ifndef __ASM_PSCI_H
#define __ASM_PSCI_H #define __ASM_PSCI_H
int psci_init(void); int psci_dt_init(void);
int psci_acpi_init(void);
#endif /* __ASM_PSCI_H */ #endif /* __ASM_PSCI_H */
...@@ -39,9 +39,10 @@ extern void show_ipi_list(struct seq_file *p, int prec); ...@@ -39,9 +39,10 @@ extern void show_ipi_list(struct seq_file *p, int prec);
extern void handle_IPI(int ipinr, struct pt_regs *regs); extern void handle_IPI(int ipinr, struct pt_regs *regs);
/* /*
* Setup the set of possible CPUs (via set_cpu_possible) * Discover the set of possible CPUs and determine their
* SMP operations.
*/ */
extern void smp_init_cpus(void); extern void of_smp_init_cpus(void);
/* /*
* Provide a function to raise an IPI cross call on CPUs in callmap. * Provide a function to raise an IPI cross call on CPUs in callmap.
......
...@@ -35,6 +35,7 @@ arm64-obj-$(CONFIG_KGDB) += kgdb.o ...@@ -35,6 +35,7 @@ arm64-obj-$(CONFIG_KGDB) += kgdb.o
arm64-obj-$(CONFIG_EFI) += efi.o efi-stub.o efi-entry.o arm64-obj-$(CONFIG_EFI) += efi.o efi-stub.o efi-entry.o
arm64-obj-$(CONFIG_PCI) += pci.o arm64-obj-$(CONFIG_PCI) += pci.o
arm64-obj-$(CONFIG_ARMV8_DEPRECATED) += armv8_deprecated.o arm64-obj-$(CONFIG_ARMV8_DEPRECATED) += armv8_deprecated.o
arm64-obj-$(CONFIG_ACPI) += acpi.o
obj-y += $(arm64-obj-y) vdso/ obj-y += $(arm64-obj-y) vdso/
obj-m += $(arm64-obj-m) obj-m += $(arm64-obj-m)
......
/*
* ARM64 Specific Low-Level ACPI Boot Support
*
* 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>
* Author: Tomasz Nowicki <tomasz.nowicki@linaro.org>
* Author: Naresh Bhat <naresh.bhat@linaro.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#define pr_fmt(fmt) "ACPI: " fmt
#include <linux/acpi.h>
#include <linux/bootmem.h>
#include <linux/cpumask.h>
#include <linux/init.h>
#include <linux/irq.h>
#include <linux/irqdomain.h>
#include <linux/memblock.h>
#include <linux/of_fdt.h>
#include <linux/smp.h>
#include <asm/cputype.h>
#include <asm/cpu_ops.h>
#include <asm/smp_plat.h>
int acpi_noirq = 1; /* skip ACPI IRQ initialization */
int acpi_disabled = 1;
EXPORT_SYMBOL(acpi_disabled);
int acpi_pci_disabled = 1; /* skip ACPI PCI scan and IRQ initialization */
EXPORT_SYMBOL(acpi_pci_disabled);
/* Processors with enabled flag and sane MPIDR */
static int enabled_cpus;
/* Boot CPU is valid or not in MADT */
static bool bootcpu_valid __initdata;
static bool param_acpi_off __initdata;
static bool param_acpi_force __initdata;
static int __init parse_acpi(char *arg)
{
if (!arg)
return -EINVAL;
/* "acpi=off" disables both ACPI table parsing and interpreter */
if (strcmp(arg, "off") == 0)
param_acpi_off = true;
else if (strcmp(arg, "force") == 0) /* force ACPI to be enabled */
param_acpi_force = true;
else
return -EINVAL; /* Core will print when we return error */
return 0;
}
early_param("acpi", parse_acpi);
static int __init dt_scan_depth1_nodes(unsigned long node,
const char *uname, int depth,
void *data)
{
/*
* Return 1 as soon as we encounter a node at depth 1 that is
* not the /chosen node.
*/
if (depth == 1 && (strcmp(uname, "chosen") != 0))
return 1;
return 0;
}
/*
* __acpi_map_table() will be called before page_init(), so early_ioremap()
* or early_memremap() should be called here to for ACPI table mapping.
*/
char *__init __acpi_map_table(unsigned long phys, unsigned long size)
{
if (!size)
return NULL;
return early_memremap(phys, size);
}
void __init __acpi_unmap_table(char *map, unsigned long size)
{
if (!map || !size)
return;
early_memunmap(map, size);
}
/**
* acpi_map_gic_cpu_interface - generates a logical cpu number
* and map to MPIDR represented by GICC structure
*/
static void __init
acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
{
int i;
u64 mpidr = processor->arm_mpidr & MPIDR_HWID_BITMASK;
bool enabled = !!(processor->flags & ACPI_MADT_ENABLED);
if (mpidr == INVALID_HWID) {
pr_info("Skip MADT cpu entry with invalid MPIDR\n");
return;
}
total_cpus++;
if (!enabled)
return;
if (enabled_cpus >= NR_CPUS) {
pr_warn("NR_CPUS limit of %d reached, Processor %d/0x%llx ignored.\n",
NR_CPUS, total_cpus, mpidr);
return;
}
/* Check if GICC structure of boot CPU is available in the MADT */
if (cpu_logical_map(0) == mpidr) {
if (bootcpu_valid) {
pr_err("Firmware bug, duplicate CPU MPIDR: 0x%llx in MADT\n",
mpidr);
return;
}
bootcpu_valid = true;
}
/*
* Duplicate MPIDRs are a recipe for disaster. Scan
* all initialized entries and check for
* duplicates. If any is found just ignore the CPU.
*/
for (i = 1; i < enabled_cpus; i++) {
if (cpu_logical_map(i) == mpidr) {
pr_err("Firmware bug, duplicate CPU MPIDR: 0x%llx in MADT\n",
mpidr);
return;
}
}
if (!acpi_psci_present())
return;
cpu_ops[enabled_cpus] = cpu_get_ops("psci");
/* CPU 0 was already initialized */
if (enabled_cpus) {
if (!cpu_ops[enabled_cpus])
return;
if (cpu_ops[enabled_cpus]->cpu_init(NULL, enabled_cpus))
return;
/* map the logical cpu id to cpu MPIDR */
cpu_logical_map(enabled_cpus) = mpidr;
}
enabled_cpus++;
}
static int __init
acpi_parse_gic_cpu_interface(struct acpi_subtable_header *header,
const unsigned long end)
{
struct acpi_madt_generic_interrupt *processor;
processor = (struct acpi_madt_generic_interrupt *)header;
if (BAD_MADT_ENTRY(processor, end))
return -EINVAL;
acpi_table_print_madt_entry(header);
acpi_map_gic_cpu_interface(processor);
return 0;
}
/* Parse GIC cpu interface entries in MADT for SMP init */
void __init acpi_init_cpus(void)
{
int count, i;
/*
* do a partial walk of MADT to determine how many CPUs
* we have including disabled CPUs, and get information
* we need for SMP init
*/
count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT,
acpi_parse_gic_cpu_interface, 0);
if (!count) {
pr_err("No GIC CPU interface entries present\n");
return;
} else if (count < 0) {
pr_err("Error parsing GIC CPU interface entry\n");
return;
}
if (!bootcpu_valid) {
pr_err("MADT missing boot CPU MPIDR, not enabling secondaries\n");
return;
}
for (i = 0; i < enabled_cpus; i++)
set_cpu_possible(i, true);
/* Make boot-up look pretty */
pr_info("%d CPUs enabled, %d CPUs total\n", enabled_cpus, total_cpus);
}
/*
* acpi_fadt_sanity_check() - Check FADT presence and carry out sanity
* checks on it
*
* Return 0 on success, <0 on failure
*/
static int __init acpi_fadt_sanity_check(void)
{
struct acpi_table_header *table;
struct acpi_table_fadt *fadt;
acpi_status status;
acpi_size tbl_size;
int ret = 0;
/*
* FADT is required on arm64; retrieve it to check its presence
* and carry out revision and ACPI HW reduced compliancy tests
*/
status = acpi_get_table_with_size(ACPI_SIG_FADT, 0, &table, &tbl_size);
if (ACPI_FAILURE(status)) {
const char *msg = acpi_format_exception(status);
pr_err("Failed to get FADT table, %s\n", msg);
return -ENODEV;
}
fadt = (struct acpi_table_fadt *)table;
/*
* Revision in table header is the FADT Major revision, and there
* is a minor revision of FADT which was introduced by ACPI 5.1,
* we only deal with ACPI 5.1 or newer revision to get GIC and SMP
* boot protocol configuration data.
*/
if (table->revision < 5 ||
(table->revision == 5 && fadt->minor_revision < 1)) {
pr_err("Unsupported FADT revision %d.%d, should be 5.1+\n",
table->revision, fadt->minor_revision);
ret = -EINVAL;
goto out;
}
if (!(fadt->flags & ACPI_FADT_HW_REDUCED)) {
pr_err("FADT not ACPI hardware reduced compliant\n");
ret = -EINVAL;
}
out:
/*
* acpi_get_table_with_size() creates FADT table mapping that
* should be released after parsing and before resuming boot
*/
early_acpi_os_unmap_memory(table, tbl_size);
return ret;
}
/*
* acpi_boot_table_init() called from setup_arch(), always.
* 1. find RSDP and get its address, and then find XSDT
* 2. extract all tables and checksums them all
* 3. check ACPI FADT revision
* 4. check ACPI FADT HW reduced flag
*
* We can parse ACPI boot-time tables such as MADT after
* this function is called.
*
* On return ACPI is enabled if either:
*
* - ACPI tables are initialized and sanity checks passed
* - acpi=force was passed in the command line and ACPI was not disabled
* explicitly through acpi=off command line parameter
*
* ACPI is disabled on function return otherwise
*/
void __init acpi_boot_table_init(void)
{
/*
* Enable ACPI instead of device tree unless
* - ACPI has been disabled explicitly (acpi=off), or
* - the device tree is not empty (it has more than just a /chosen node)
* and ACPI has not been force enabled (acpi=force)
*/
if (param_acpi_off ||
(!param_acpi_force && of_scan_flat_dt(dt_scan_depth1_nodes, NULL)))
return;
/*
* ACPI is disabled at this point. Enable it in order to parse
* the ACPI tables and carry out sanity checks
*/
enable_acpi();
/*
* If ACPI tables are initialized and FADT sanity checks passed,
* leave ACPI enabled and carry on booting; otherwise disable ACPI
* on initialization error.
* If acpi=force was passed on the command line it forces ACPI
* to be enabled even if its initialization failed.
*/
if (acpi_table_init() || acpi_fadt_sanity_check()) {
pr_err("Failed to init ACPI tables\n");
if (!param_acpi_force)
disable_acpi();
}
}
void __init acpi_gic_init(void)
{
struct acpi_table_header *table;
acpi_status status;
acpi_size tbl_size;
int err;
if (acpi_disabled)
return;
status = acpi_get_table_with_size(ACPI_SIG_MADT, 0, &table, &tbl_size);
if (ACPI_FAILURE(status)) {
const char *msg = acpi_format_exception(status);
pr_err("Failed to get MADT table, %s\n", msg);
return;
}
err = gic_v2_acpi_init(table);
if (err)
pr_err("Failed to initialize GIC IRQ controller");
early_acpi_os_unmap_memory((char *)table, tbl_size);
}
...@@ -35,7 +35,7 @@ static const struct cpu_operations *supported_cpu_ops[] __initconst = { ...@@ -35,7 +35,7 @@ static const struct cpu_operations *supported_cpu_ops[] __initconst = {
NULL, NULL,
}; };
static const struct cpu_operations * __init cpu_get_ops(const char *name) const struct cpu_operations * __init cpu_get_ops(const char *name)
{ {
const struct cpu_operations **ops = supported_cpu_ops; const struct cpu_operations **ops = supported_cpu_ops;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
* *
*/ */
#include <linux/acpi.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -46,3 +47,27 @@ int pcibios_add_device(struct pci_dev *dev) ...@@ -46,3 +47,27 @@ int pcibios_add_device(struct pci_dev *dev)
return 0; return 0;
} }
/*
* raw_pci_read/write - Platform-specific PCI config space access.
*/
int raw_pci_read(unsigned int domain, unsigned int bus,
unsigned int devfn, int reg, int len, u32 *val)
{
return -ENXIO;
}
int raw_pci_write(unsigned int domain, unsigned int bus,
unsigned int devfn, int reg, int len, u32 val)
{
return -ENXIO;
}
#ifdef CONFIG_ACPI
/* Root bridge scanning */
struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
{
/* TODO: Should be revisited when implementing PCI on ACPI */
return NULL;
}
#endif
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#define pr_fmt(fmt) "psci: " fmt #define pr_fmt(fmt) "psci: " fmt
#include <linux/acpi.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/smp.h> #include <linux/smp.h>
...@@ -24,6 +25,7 @@ ...@@ -24,6 +25,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <uapi/linux/psci.h> #include <uapi/linux/psci.h>
#include <asm/acpi.h>
#include <asm/compiler.h> #include <asm/compiler.h>
#include <asm/cpu_ops.h> #include <asm/cpu_ops.h>
#include <asm/errno.h> #include <asm/errno.h>
...@@ -273,39 +275,8 @@ static void psci_sys_poweroff(void) ...@@ -273,39 +275,8 @@ static void psci_sys_poweroff(void)
invoke_psci_fn(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0); invoke_psci_fn(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0);
} }
/* static void __init psci_0_2_set_functions(void)
* PSCI Function IDs for v0.2+ are well defined so use
* standard values.
*/
static int __init psci_0_2_init(struct device_node *np)
{ {
int err, ver;
err = get_set_conduit_method(np);
if (err)
goto out_put_node;
ver = psci_get_version();
if (ver == PSCI_RET_NOT_SUPPORTED) {
/* PSCI v0.2 mandates implementation of PSCI_ID_VERSION. */
pr_err("PSCI firmware does not comply with the v0.2 spec.\n");
err = -EOPNOTSUPP;
goto out_put_node;
} else {
pr_info("PSCIv%d.%d detected in firmware.\n",
PSCI_VERSION_MAJOR(ver),
PSCI_VERSION_MINOR(ver));
if (PSCI_VERSION_MAJOR(ver) == 0 &&
PSCI_VERSION_MINOR(ver) < 2) {
err = -EINVAL;
pr_err("Conflicting PSCI version detected.\n");
goto out_put_node;
}
}
pr_info("Using standard PSCI v0.2 function IDs\n"); pr_info("Using standard PSCI v0.2 function IDs\n");
psci_function_id[PSCI_FN_CPU_SUSPEND] = PSCI_0_2_FN64_CPU_SUSPEND; psci_function_id[PSCI_FN_CPU_SUSPEND] = PSCI_0_2_FN64_CPU_SUSPEND;
psci_ops.cpu_suspend = psci_cpu_suspend; psci_ops.cpu_suspend = psci_cpu_suspend;
...@@ -329,6 +300,60 @@ static int __init psci_0_2_init(struct device_node *np) ...@@ -329,6 +300,60 @@ static int __init psci_0_2_init(struct device_node *np)
arm_pm_restart = psci_sys_reset; arm_pm_restart = psci_sys_reset;
pm_power_off = psci_sys_poweroff; pm_power_off = psci_sys_poweroff;
}
/*
* Probe function for PSCI firmware versions >= 0.2
*/
static int __init psci_probe(void)
{
int ver = psci_get_version();
if (ver == PSCI_RET_NOT_SUPPORTED) {
/*
* PSCI versions >=0.2 mandates implementation of
* PSCI_VERSION.
*/
pr_err("PSCI firmware does not comply with the v0.2 spec.\n");
return -EOPNOTSUPP;
} else {
pr_info("PSCIv%d.%d detected in firmware.\n",
PSCI_VERSION_MAJOR(ver),
PSCI_VERSION_MINOR(ver));
if (PSCI_VERSION_MAJOR(ver) == 0 &&
PSCI_VERSION_MINOR(ver) < 2) {
pr_err("Conflicting PSCI version detected.\n");
return -EINVAL;
}
}
psci_0_2_set_functions();
return 0;
}
/*
* PSCI init function for PSCI versions >=0.2
*
* Probe based on PSCI PSCI_VERSION function
*/
static int __init psci_0_2_init(struct device_node *np)
{
int err;
err = get_set_conduit_method(np);
if (err)
goto out_put_node;
/*
* Starting with v0.2, the PSCI specification introduced a call
* (PSCI_VERSION) that allows probing the firmware version, so
* that PSCI function IDs and version specific initialization
* can be carried out according to the specific version reported
* by firmware
*/
err = psci_probe();
out_put_node: out_put_node:
of_node_put(np); of_node_put(np);
...@@ -381,7 +406,7 @@ static const struct of_device_id psci_of_match[] __initconst = { ...@@ -381,7 +406,7 @@ static const struct of_device_id psci_of_match[] __initconst = {
{}, {},
}; };
int __init psci_init(void) int __init psci_dt_init(void)
{ {
struct device_node *np; struct device_node *np;
const struct of_device_id *matched_np; const struct of_device_id *matched_np;
...@@ -396,6 +421,27 @@ int __init psci_init(void) ...@@ -396,6 +421,27 @@ int __init psci_init(void)
return init_fn(np); return init_fn(np);
} }
/*
* We use PSCI 0.2+ when ACPI is deployed on ARM64 and it's
* explicitly clarified in SBBR
*/
int __init psci_acpi_init(void)
{
if (!acpi_psci_present()) {
pr_info("is not implemented in ACPI.\n");
return -EOPNOTSUPP;
}
pr_info("probing for conduit method from ACPI.\n");
if (acpi_psci_use_hvc())
invoke_psci_fn = __invoke_psci_fn_hvc;
else
invoke_psci_fn = __invoke_psci_fn_smc;
return psci_probe();
}
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
static int __init cpu_psci_cpu_init(struct device_node *dn, unsigned int cpu) static int __init cpu_psci_cpu_init(struct device_node *dn, unsigned int cpu)
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <linux/acpi.h>
#include <linux/export.h> #include <linux/export.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/stddef.h> #include <linux/stddef.h>
...@@ -46,6 +47,7 @@ ...@@ -46,6 +47,7 @@
#include <linux/efi.h> #include <linux/efi.h>
#include <linux/personality.h> #include <linux/personality.h>
#include <asm/acpi.h>
#include <asm/fixmap.h> #include <asm/fixmap.h>
#include <asm/cpu.h> #include <asm/cpu.h>
#include <asm/cputype.h> #include <asm/cputype.h>
...@@ -395,18 +397,27 @@ void __init setup_arch(char **cmdline_p) ...@@ -395,18 +397,27 @@ void __init setup_arch(char **cmdline_p)
efi_init(); efi_init();
arm64_memblock_init(); arm64_memblock_init();
/* Parse the ACPI tables for possible boot-time configuration */
acpi_boot_table_init();
paging_init(); paging_init();
request_standard_resources(); request_standard_resources();
early_ioremap_reset(); early_ioremap_reset();
if (acpi_disabled) {
unflatten_device_tree(); unflatten_device_tree();
psci_dt_init();
psci_init();
cpu_read_bootcpu_ops(); cpu_read_bootcpu_ops();
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
smp_init_cpus(); of_smp_init_cpus();
#endif
} else {
psci_acpi_init();
acpi_init_cpus();
}
#ifdef CONFIG_SMP
smp_build_mpidr_hash(); smp_build_mpidr_hash();
#endif #endif
......
...@@ -323,7 +323,7 @@ void __init smp_prepare_boot_cpu(void) ...@@ -323,7 +323,7 @@ void __init smp_prepare_boot_cpu(void)
* cpu logical map array containing MPIDR values related to logical * cpu logical map array containing MPIDR values related to logical
* cpus. Assumes that cpu_logical_map(0) has already been initialized. * cpus. Assumes that cpu_logical_map(0) has already been initialized.
*/ */
void __init smp_init_cpus(void) void __init of_smp_init_cpus(void)
{ {
struct device_node *dn = NULL; struct device_node *dn = NULL;
unsigned int i, cpu = 1; unsigned int i, cpu = 1;
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/clocksource.h> #include <linux/clocksource.h>
#include <linux/clk-provider.h> #include <linux/clk-provider.h>
#include <linux/acpi.h>
#include <clocksource/arm_arch_timer.h> #include <clocksource/arm_arch_timer.h>
...@@ -72,6 +73,12 @@ void __init time_init(void) ...@@ -72,6 +73,12 @@ void __init time_init(void)
tick_setup_hrtimer_broadcast(); tick_setup_hrtimer_broadcast();
/*
* Since ACPI or FDT will only one be available in the system,
* we can use acpi_generic_timer_init() here safely
*/
acpi_generic_timer_init();
arch_timer_rate = arch_timer_get_rate(); arch_timer_rate = arch_timer_get_rate();
if (!arch_timer_rate) if (!arch_timer_rate)
panic("Unable to initialise architected timer.\n"); panic("Unable to initialise architected timer.\n");
......
...@@ -15,6 +15,7 @@ config IA64 ...@@ -15,6 +15,7 @@ config IA64
select ARCH_MIGHT_HAVE_PC_SERIO select ARCH_MIGHT_HAVE_PC_SERIO
select PCI if (!IA64_HP_SIM) select PCI if (!IA64_HP_SIM)
select ACPI if (!IA64_HP_SIM) select ACPI if (!IA64_HP_SIM)
select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI
select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI
select HAVE_UNSTABLE_SCHED_CLOCK select HAVE_UNSTABLE_SCHED_CLOCK
select HAVE_IDE select HAVE_IDE
......
...@@ -887,7 +887,7 @@ static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu) ...@@ -887,7 +887,7 @@ static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
} }
/* wrapper to silence section mismatch warning */ /* wrapper to silence section mismatch warning */
int __ref acpi_map_cpu(acpi_handle handle, int physid, int *pcpu) int __ref acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu)
{ {
return _acpi_map_lsapic(handle, physid, pcpu); return _acpi_map_lsapic(handle, physid, pcpu);
} }
......
...@@ -22,6 +22,7 @@ config X86_64 ...@@ -22,6 +22,7 @@ config X86_64
### Arch settings ### Arch settings
config X86 config X86
def_bool y def_bool y
select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI
select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI select ARCH_MIGHT_HAVE_ACPI_PDC if ACPI
select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
select ARCH_HAS_FAST_MULTIPLIER select ARCH_HAS_FAST_MULTIPLIER
......
...@@ -757,7 +757,7 @@ static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu) ...@@ -757,7 +757,7 @@ static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
} }
/* wrapper to silence section mismatch warning */ /* wrapper to silence section mismatch warning */
int __ref acpi_map_cpu(acpi_handle handle, int physid, int *pcpu) int __ref acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu)
{ {
return _acpi_map_lsapic(handle, physid, pcpu); return _acpi_map_lsapic(handle, physid, pcpu);
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
menuconfig ACPI menuconfig ACPI
bool "ACPI (Advanced Configuration and Power Interface) Support" bool "ACPI (Advanced Configuration and Power Interface) Support"
depends on !IA64_HP_SIM depends on !IA64_HP_SIM
depends on IA64 || X86 depends on IA64 || X86 || (ARM64 && EXPERT)
depends on PCI depends on PCI
select PNP select PNP
default y default y
...@@ -48,9 +48,16 @@ config ACPI_LEGACY_TABLES_LOOKUP ...@@ -48,9 +48,16 @@ config ACPI_LEGACY_TABLES_LOOKUP
config ARCH_MIGHT_HAVE_ACPI_PDC config ARCH_MIGHT_HAVE_ACPI_PDC
bool bool
config ACPI_GENERIC_GSI
bool
config ACPI_SYSTEM_POWER_STATES_SUPPORT
bool
config ACPI_SLEEP config ACPI_SLEEP
bool bool
depends on SUSPEND || HIBERNATION depends on SUSPEND || HIBERNATION
depends on ACPI_SYSTEM_POWER_STATES_SUPPORT
default y default y
config ACPI_PROCFS_POWER config ACPI_PROCFS_POWER
...@@ -163,6 +170,7 @@ config ACPI_PROCESSOR ...@@ -163,6 +170,7 @@ config ACPI_PROCESSOR
tristate "Processor" tristate "Processor"
select THERMAL select THERMAL
select CPU_IDLE select CPU_IDLE
depends on X86 || IA64
default y default y
help help
This driver installs ACPI as the idle handler for Linux and uses This driver installs ACPI as the idle handler for Linux and uses
......
...@@ -23,7 +23,7 @@ acpi-y += nvs.o ...@@ -23,7 +23,7 @@ acpi-y += nvs.o
# Power management related files # Power management related files
acpi-y += wakeup.o acpi-y += wakeup.o
acpi-y += sleep.o acpi-$(CONFIG_ACPI_SYSTEM_POWER_STATES_SUPPORT) += sleep.o
acpi-y += device_pm.o acpi-y += device_pm.o
acpi-$(CONFIG_ACPI_SLEEP) += proc.o acpi-$(CONFIG_ACPI_SLEEP) += proc.o
...@@ -56,6 +56,7 @@ ifdef CONFIG_ACPI_VIDEO ...@@ -56,6 +56,7 @@ ifdef CONFIG_ACPI_VIDEO
acpi-y += video_detect.o acpi-y += video_detect.o
endif endif
acpi-y += acpi_lpat.o acpi-y += acpi_lpat.o
acpi-$(CONFIG_ACPI_GENERIC_GSI) += gsi.o
# These are (potentially) separate modules # These are (potentially) separate modules
......
...@@ -170,7 +170,7 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr) ...@@ -170,7 +170,7 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr)
acpi_status status; acpi_status status;
int ret; int ret;
if (pr->phys_id == -1) if (pr->phys_id == PHYS_CPUID_INVALID)
return -ENODEV; return -ENODEV;
status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta); status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta);
...@@ -215,7 +215,8 @@ static int acpi_processor_get_info(struct acpi_device *device) ...@@ -215,7 +215,8 @@ static int acpi_processor_get_info(struct acpi_device *device)
union acpi_object object = { 0 }; union acpi_object object = { 0 };
struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
struct acpi_processor *pr = acpi_driver_data(device); struct acpi_processor *pr = acpi_driver_data(device);
int phys_id, cpu_index, device_declaration = 0; phys_cpuid_t phys_id;
int cpu_index, device_declaration = 0;
acpi_status status = AE_OK; acpi_status status = AE_OK;
static int cpu0_initialized; static int cpu0_initialized;
unsigned long long value; unsigned long long value;
...@@ -263,7 +264,7 @@ static int acpi_processor_get_info(struct acpi_device *device) ...@@ -263,7 +264,7 @@ static int acpi_processor_get_info(struct acpi_device *device)
} }
phys_id = acpi_get_phys_id(pr->handle, device_declaration, pr->acpi_id); phys_id = acpi_get_phys_id(pr->handle, device_declaration, pr->acpi_id);
if (phys_id < 0) if (phys_id == PHYS_CPUID_INVALID)
acpi_handle_debug(pr->handle, "failed to get CPU physical ID.\n"); acpi_handle_debug(pr->handle, "failed to get CPU physical ID.\n");
pr->phys_id = phys_id; pr->phys_id = phys_id;
......
...@@ -448,6 +448,9 @@ static int __init acpi_bus_init_irq(void) ...@@ -448,6 +448,9 @@ static int __init acpi_bus_init_irq(void)
case ACPI_IRQ_MODEL_IOSAPIC: case ACPI_IRQ_MODEL_IOSAPIC:
message = "IOSAPIC"; message = "IOSAPIC";
break; break;
case ACPI_IRQ_MODEL_GIC:
message = "GIC";
break;
case ACPI_IRQ_MODEL_PLATFORM: case ACPI_IRQ_MODEL_PLATFORM:
message = "platform specific model"; message = "platform specific model";
break; break;
......
/*
* ACPI GSI IRQ layer
*
* Copyright (C) 2015 ARM Ltd.
* Author: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/acpi.h>
#include <linux/irq.h>
#include <linux/irqdomain.h>
enum acpi_irq_model_id acpi_irq_model;
static unsigned int acpi_gsi_get_irq_type(int trigger, int polarity)
{
switch (polarity) {
case ACPI_ACTIVE_LOW:
return trigger == ACPI_EDGE_SENSITIVE ?
IRQ_TYPE_EDGE_FALLING :
IRQ_TYPE_LEVEL_LOW;
case ACPI_ACTIVE_HIGH:
return trigger == ACPI_EDGE_SENSITIVE ?
IRQ_TYPE_EDGE_RISING :
IRQ_TYPE_LEVEL_HIGH;
case ACPI_ACTIVE_BOTH:
if (trigger == ACPI_EDGE_SENSITIVE)
return IRQ_TYPE_EDGE_BOTH;
default:
return IRQ_TYPE_NONE;
}
}
/**
* acpi_gsi_to_irq() - Retrieve the linux irq number for a given GSI
* @gsi: GSI IRQ number to map
* @irq: pointer where linux IRQ number is stored
*
* irq location updated with irq value [>0 on success, 0 on failure]
*
* Returns: linux IRQ number on success (>0)
* -EINVAL on failure
*/
int acpi_gsi_to_irq(u32 gsi, unsigned int *irq)
{
/*
* Only default domain is supported at present, always find
* the mapping corresponding to default domain by passing NULL
* as irq_domain parameter
*/
*irq = irq_find_mapping(NULL, gsi);
/*
* *irq == 0 means no mapping, that should
* be reported as a failure
*/
return (*irq > 0) ? *irq : -EINVAL;
}
EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);
/**
* acpi_register_gsi() - Map a GSI to a linux IRQ number
* @dev: device for which IRQ has to be mapped
* @gsi: GSI IRQ number
* @trigger: trigger type of the GSI number to be mapped
* @polarity: polarity of the GSI to be mapped
*
* Returns: a valid linux IRQ number on success
* -EINVAL on failure
*/
int acpi_register_gsi(struct device *dev, u32 gsi, int trigger,
int polarity)
{
unsigned int irq;
unsigned int irq_type = acpi_gsi_get_irq_type(trigger, polarity);
/*
* There is no way at present to look-up the IRQ domain on ACPI,
* hence always create mapping referring to the default domain
* by passing NULL as irq_domain parameter
*/
irq = irq_create_mapping(NULL, gsi);
if (!irq)
return -EINVAL;
/* Set irq type if specified and different than the current one */
if (irq_type != IRQ_TYPE_NONE &&
irq_type != irq_get_trigger_type(irq))
irq_set_irq_type(irq, irq_type);
return irq;
}
EXPORT_SYMBOL_GPL(acpi_register_gsi);
/**
* acpi_unregister_gsi() - Free a GSI<->linux IRQ number mapping
* @gsi: GSI IRQ number
*/
void acpi_unregister_gsi(u32 gsi)
{
int irq = irq_find_mapping(NULL, gsi);
irq_dispose_mapping(irq);
}
EXPORT_SYMBOL_GPL(acpi_unregister_gsi);
...@@ -161,7 +161,11 @@ void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit); ...@@ -161,7 +161,11 @@ void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit);
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
Suspend/Resume Suspend/Resume
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
#ifdef CONFIG_ACPI_SYSTEM_POWER_STATES_SUPPORT
extern int acpi_sleep_init(void); extern int acpi_sleep_init(void);
#else
static inline int acpi_sleep_init(void) { return -ENXIO; }
#endif
#ifdef CONFIG_ACPI_SLEEP #ifdef CONFIG_ACPI_SLEEP
int acpi_sleep_proc_init(void); int acpi_sleep_proc_init(void);
......
...@@ -336,11 +336,11 @@ acpi_map_lookup_virt(void __iomem *virt, acpi_size size) ...@@ -336,11 +336,11 @@ acpi_map_lookup_virt(void __iomem *virt, acpi_size size)
return NULL; return NULL;
} }
#ifndef CONFIG_IA64 #if defined(CONFIG_IA64) || defined(CONFIG_ARM64)
#define should_use_kmap(pfn) page_is_ram(pfn)
#else
/* ioremap will take care of cache attributes */ /* ioremap will take care of cache attributes */
#define should_use_kmap(pfn) 0 #define should_use_kmap(pfn) 0
#else
#define should_use_kmap(pfn) page_is_ram(pfn)
#endif #endif
static void __iomem *acpi_map(acpi_physical_address pg_off, unsigned long pg_sz) static void __iomem *acpi_map(acpi_physical_address pg_off, unsigned long pg_sz)
......
...@@ -32,7 +32,7 @@ static struct acpi_table_madt *get_madt_table(void) ...@@ -32,7 +32,7 @@ static struct acpi_table_madt *get_madt_table(void)
} }
static int map_lapic_id(struct acpi_subtable_header *entry, static int map_lapic_id(struct acpi_subtable_header *entry,
u32 acpi_id, int *apic_id) u32 acpi_id, phys_cpuid_t *apic_id)
{ {
struct acpi_madt_local_apic *lapic = struct acpi_madt_local_apic *lapic =
container_of(entry, struct acpi_madt_local_apic, header); container_of(entry, struct acpi_madt_local_apic, header);
...@@ -48,7 +48,7 @@ static int map_lapic_id(struct acpi_subtable_header *entry, ...@@ -48,7 +48,7 @@ static int map_lapic_id(struct acpi_subtable_header *entry,
} }
static int map_x2apic_id(struct acpi_subtable_header *entry, static int map_x2apic_id(struct acpi_subtable_header *entry,
int device_declaration, u32 acpi_id, int *apic_id) int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id)
{ {
struct acpi_madt_local_x2apic *apic = struct acpi_madt_local_x2apic *apic =
container_of(entry, struct acpi_madt_local_x2apic, header); container_of(entry, struct acpi_madt_local_x2apic, header);
...@@ -65,7 +65,7 @@ static int map_x2apic_id(struct acpi_subtable_header *entry, ...@@ -65,7 +65,7 @@ static int map_x2apic_id(struct acpi_subtable_header *entry,
} }
static int map_lsapic_id(struct acpi_subtable_header *entry, static int map_lsapic_id(struct acpi_subtable_header *entry,
int device_declaration, u32 acpi_id, int *apic_id) int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id)
{ {
struct acpi_madt_local_sapic *lsapic = struct acpi_madt_local_sapic *lsapic =
container_of(entry, struct acpi_madt_local_sapic, header); container_of(entry, struct acpi_madt_local_sapic, header);
...@@ -83,10 +83,35 @@ static int map_lsapic_id(struct acpi_subtable_header *entry, ...@@ -83,10 +83,35 @@ static int map_lsapic_id(struct acpi_subtable_header *entry,
return 0; return 0;
} }
static int map_madt_entry(int type, u32 acpi_id) /*
* Retrieve the ARM CPU physical identifier (MPIDR)
*/
static int map_gicc_mpidr(struct acpi_subtable_header *entry,
int device_declaration, u32 acpi_id, phys_cpuid_t *mpidr)
{
struct acpi_madt_generic_interrupt *gicc =
container_of(entry, struct acpi_madt_generic_interrupt, header);
if (!(gicc->flags & ACPI_MADT_ENABLED))
return -ENODEV;
/* device_declaration means Device object in DSDT, in the
* GIC interrupt model, logical processors are required to
* have a Processor Device object in the DSDT, so we should
* check device_declaration here
*/
if (device_declaration && (gicc->uid == acpi_id)) {
*mpidr = gicc->arm_mpidr;
return 0;
}
return -EINVAL;
}
static phys_cpuid_t map_madt_entry(int type, u32 acpi_id)
{ {
unsigned long madt_end, entry; unsigned long madt_end, entry;
int phys_id = -1; /* CPU hardware ID */ phys_cpuid_t phys_id = PHYS_CPUID_INVALID; /* CPU hardware ID */
struct acpi_table_madt *madt; struct acpi_table_madt *madt;
madt = get_madt_table(); madt = get_madt_table();
...@@ -111,18 +136,21 @@ static int map_madt_entry(int type, u32 acpi_id) ...@@ -111,18 +136,21 @@ static int map_madt_entry(int type, u32 acpi_id)
} else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) {
if (!map_lsapic_id(header, type, acpi_id, &phys_id)) if (!map_lsapic_id(header, type, acpi_id, &phys_id))
break; break;
} else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) {
if (!map_gicc_mpidr(header, type, acpi_id, &phys_id))
break;
} }
entry += header->length; entry += header->length;
} }
return phys_id; return phys_id;
} }
static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id) static phys_cpuid_t map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
{ {
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
union acpi_object *obj; union acpi_object *obj;
struct acpi_subtable_header *header; struct acpi_subtable_header *header;
int phys_id = -1; phys_cpuid_t phys_id = PHYS_CPUID_INVALID;
if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer))) if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
goto exit; goto exit;
...@@ -143,33 +171,35 @@ static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id) ...@@ -143,33 +171,35 @@ static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
map_lsapic_id(header, type, acpi_id, &phys_id); map_lsapic_id(header, type, acpi_id, &phys_id);
else if (header->type == ACPI_MADT_TYPE_LOCAL_X2APIC) else if (header->type == ACPI_MADT_TYPE_LOCAL_X2APIC)
map_x2apic_id(header, type, acpi_id, &phys_id); map_x2apic_id(header, type, acpi_id, &phys_id);
else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT)
map_gicc_mpidr(header, type, acpi_id, &phys_id);
exit: exit:
kfree(buffer.pointer); kfree(buffer.pointer);
return phys_id; return phys_id;
} }
int acpi_get_phys_id(acpi_handle handle, int type, u32 acpi_id) phys_cpuid_t acpi_get_phys_id(acpi_handle handle, int type, u32 acpi_id)
{ {
int phys_id; phys_cpuid_t phys_id;
phys_id = map_mat_entry(handle, type, acpi_id); phys_id = map_mat_entry(handle, type, acpi_id);
if (phys_id == -1) if (phys_id == PHYS_CPUID_INVALID)
phys_id = map_madt_entry(type, acpi_id); phys_id = map_madt_entry(type, acpi_id);
return phys_id; return phys_id;
} }
int acpi_map_cpuid(int phys_id, u32 acpi_id) int acpi_map_cpuid(phys_cpuid_t phys_id, u32 acpi_id)
{ {
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
int i; int i;
#endif #endif
if (phys_id == -1) { if (phys_id == PHYS_CPUID_INVALID) {
/* /*
* On UP processor, there is no _MAT or MADT table. * On UP processor, there is no _MAT or MADT table.
* So above phys_id is always set to -1. * So above phys_id is always set to PHYS_CPUID_INVALID.
* *
* BIOS may define multiple CPU handles even for UP processor. * BIOS may define multiple CPU handles even for UP processor.
* For example, * For example,
...@@ -190,7 +220,7 @@ int acpi_map_cpuid(int phys_id, u32 acpi_id) ...@@ -190,7 +220,7 @@ int acpi_map_cpuid(int phys_id, u32 acpi_id)
if (nr_cpu_ids <= 1 && acpi_id == 0) if (nr_cpu_ids <= 1 && acpi_id == 0)
return acpi_id; return acpi_id;
else else
return phys_id; return -1;
} }
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
...@@ -208,7 +238,7 @@ int acpi_map_cpuid(int phys_id, u32 acpi_id) ...@@ -208,7 +238,7 @@ int acpi_map_cpuid(int phys_id, u32 acpi_id)
int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id) int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
{ {
int phys_id; phys_cpuid_t phys_id;
phys_id = acpi_get_phys_id(handle, type, acpi_id); phys_id = acpi_get_phys_id(handle, type, acpi_id);
......
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
* *
*/ */
/* Uncomment next line to get verbose printout */
/* #define DEBUG */
#define pr_fmt(fmt) "ACPI: " fmt #define pr_fmt(fmt) "ACPI: " fmt
#include <linux/init.h> #include <linux/init.h>
...@@ -61,7 +63,7 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header) ...@@ -61,7 +63,7 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
{ {
struct acpi_madt_local_apic *p = struct acpi_madt_local_apic *p =
(struct acpi_madt_local_apic *)header; (struct acpi_madt_local_apic *)header;
pr_info("LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n", pr_debug("LAPIC (acpi_id[0x%02x] lapic_id[0x%02x] %s)\n",
p->processor_id, p->id, p->processor_id, p->id,
(p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled"); (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
} }
...@@ -71,7 +73,7 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header) ...@@ -71,7 +73,7 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
{ {
struct acpi_madt_local_x2apic *p = struct acpi_madt_local_x2apic *p =
(struct acpi_madt_local_x2apic *)header; (struct acpi_madt_local_x2apic *)header;
pr_info("X2APIC (apic_id[0x%02x] uid[0x%02x] %s)\n", pr_debug("X2APIC (apic_id[0x%02x] uid[0x%02x] %s)\n",
p->local_apic_id, p->uid, p->local_apic_id, p->uid,
(p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled"); (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
} }
...@@ -81,7 +83,7 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header) ...@@ -81,7 +83,7 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
{ {
struct acpi_madt_io_apic *p = struct acpi_madt_io_apic *p =
(struct acpi_madt_io_apic *)header; (struct acpi_madt_io_apic *)header;
pr_info("IOAPIC (id[0x%02x] address[0x%08x] gsi_base[%d])\n", pr_debug("IOAPIC (id[0x%02x] address[0x%08x] gsi_base[%d])\n",
p->id, p->address, p->global_irq_base); p->id, p->address, p->global_irq_base);
} }
break; break;
...@@ -155,7 +157,7 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header) ...@@ -155,7 +157,7 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
{ {
struct acpi_madt_io_sapic *p = struct acpi_madt_io_sapic *p =
(struct acpi_madt_io_sapic *)header; (struct acpi_madt_io_sapic *)header;
pr_info("IOSAPIC (id[0x%x] address[%p] gsi_base[%d])\n", pr_debug("IOSAPIC (id[0x%x] address[%p] gsi_base[%d])\n",
p->id, (void *)(unsigned long)p->address, p->id, (void *)(unsigned long)p->address,
p->global_irq_base); p->global_irq_base);
} }
...@@ -165,7 +167,7 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header) ...@@ -165,7 +167,7 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
{ {
struct acpi_madt_local_sapic *p = struct acpi_madt_local_sapic *p =
(struct acpi_madt_local_sapic *)header; (struct acpi_madt_local_sapic *)header;
pr_info("LSAPIC (acpi_id[0x%02x] lsapic_id[0x%02x] lsapic_eid[0x%02x] %s)\n", pr_debug("LSAPIC (acpi_id[0x%02x] lsapic_id[0x%02x] lsapic_eid[0x%02x] %s)\n",
p->processor_id, p->id, p->eid, p->processor_id, p->id, p->eid,
(p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled"); (p->lapic_flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
} }
...@@ -183,6 +185,28 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header) ...@@ -183,6 +185,28 @@ void acpi_table_print_madt_entry(struct acpi_subtable_header *header)
} }
break; break;
case ACPI_MADT_TYPE_GENERIC_INTERRUPT:
{
struct acpi_madt_generic_interrupt *p =
(struct acpi_madt_generic_interrupt *)header;
pr_debug("GICC (acpi_id[0x%04x] address[%llx] MPIDR[0x%llx] %s)\n",
p->uid, p->base_address,
p->arm_mpidr,
(p->flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
}
break;
case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR:
{
struct acpi_madt_generic_distributor *p =
(struct acpi_madt_generic_distributor *)header;
pr_debug("GIC Distributor (gic_id[0x%04x] address[%llx] gsi_base[%d])\n",
p->gic_id, p->base_address,
p->global_irq_base);
}
break;
default: default:
pr_warn("Found unsupported MADT entry (type = 0x%x)\n", pr_warn("Found unsupported MADT entry (type = 0x%x)\n",
header->type); header->type);
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/sched_clock.h> #include <linux/sched_clock.h>
#include <linux/acpi.h>
#include <asm/arch_timer.h> #include <asm/arch_timer.h>
#include <asm/virt.h> #include <asm/virt.h>
...@@ -371,8 +372,12 @@ arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np) ...@@ -371,8 +372,12 @@ arch_timer_detect_rate(void __iomem *cntbase, struct device_node *np)
if (arch_timer_rate) if (arch_timer_rate)
return; return;
/* Try to determine the frequency from the device tree or CNTFRQ */ /*
if (of_property_read_u32(np, "clock-frequency", &arch_timer_rate)) { * Try to determine the frequency from the device tree or CNTFRQ,
* if ACPI is enabled, get the frequency from CNTFRQ ONLY.
*/
if (!acpi_disabled ||
of_property_read_u32(np, "clock-frequency", &arch_timer_rate)) {
if (cntbase) if (cntbase)
arch_timer_rate = readl_relaxed(cntbase + CNTFRQ); arch_timer_rate = readl_relaxed(cntbase + CNTFRQ);
else else
...@@ -691,28 +696,8 @@ static void __init arch_timer_common_init(void) ...@@ -691,28 +696,8 @@ static void __init arch_timer_common_init(void)
arch_timer_arch_init(); arch_timer_arch_init();
} }
static void __init arch_timer_init(struct device_node *np) static void __init arch_timer_init(void)
{ {
int i;
if (arch_timers_present & ARCH_CP15_TIMER) {
pr_warn("arch_timer: multiple nodes in dt, skipping\n");
return;
}
arch_timers_present |= ARCH_CP15_TIMER;
for (i = PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++)
arch_timer_ppi[i] = irq_of_parse_and_map(np, i);
arch_timer_detect_rate(NULL, np);
/*
* If we cannot rely on firmware initializing the timer registers then
* we should use the physical timers instead.
*/
if (IS_ENABLED(CONFIG_ARM) &&
of_property_read_bool(np, "arm,cpu-registers-not-fw-configured"))
arch_timer_use_virtual = false;
/* /*
* If HYP mode is available, we know that the physical timer * If HYP mode is available, we know that the physical timer
* has been configured to be accessible from PL1. Use it, so * has been configured to be accessible from PL1. Use it, so
...@@ -731,13 +716,39 @@ static void __init arch_timer_init(struct device_node *np) ...@@ -731,13 +716,39 @@ static void __init arch_timer_init(struct device_node *np)
} }
} }
arch_timer_c3stop = !of_property_read_bool(np, "always-on");
arch_timer_register(); arch_timer_register();
arch_timer_common_init(); arch_timer_common_init();
} }
CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_init);
CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_init); static void __init arch_timer_of_init(struct device_node *np)
{
int i;
if (arch_timers_present & ARCH_CP15_TIMER) {
pr_warn("arch_timer: multiple nodes in dt, skipping\n");
return;
}
arch_timers_present |= ARCH_CP15_TIMER;
for (i = PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++)
arch_timer_ppi[i] = irq_of_parse_and_map(np, i);
arch_timer_detect_rate(NULL, np);
arch_timer_c3stop = !of_property_read_bool(np, "always-on");
/*
* If we cannot rely on firmware initializing the timer registers then
* we should use the physical timers instead.
*/
if (IS_ENABLED(CONFIG_ARM) &&
of_property_read_bool(np, "arm,cpu-registers-not-fw-configured"))
arch_timer_use_virtual = false;
arch_timer_init();
}
CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_of_init);
CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_of_init);
static void __init arch_timer_mem_init(struct device_node *np) static void __init arch_timer_mem_init(struct device_node *np)
{ {
...@@ -804,3 +815,70 @@ static void __init arch_timer_mem_init(struct device_node *np) ...@@ -804,3 +815,70 @@ static void __init arch_timer_mem_init(struct device_node *np)
} }
CLOCKSOURCE_OF_DECLARE(armv7_arch_timer_mem, "arm,armv7-timer-mem", CLOCKSOURCE_OF_DECLARE(armv7_arch_timer_mem, "arm,armv7-timer-mem",
arch_timer_mem_init); arch_timer_mem_init);
#ifdef CONFIG_ACPI
static int __init map_generic_timer_interrupt(u32 interrupt, u32 flags)
{
int trigger, polarity;
if (!interrupt)
return 0;
trigger = (flags & ACPI_GTDT_INTERRUPT_MODE) ? ACPI_EDGE_SENSITIVE
: ACPI_LEVEL_SENSITIVE;
polarity = (flags & ACPI_GTDT_INTERRUPT_POLARITY) ? ACPI_ACTIVE_LOW
: ACPI_ACTIVE_HIGH;
return acpi_register_gsi(NULL, interrupt, trigger, polarity);
}
/* Initialize per-processor generic timer */
static int __init arch_timer_acpi_init(struct acpi_table_header *table)
{
struct acpi_table_gtdt *gtdt;
if (arch_timers_present & ARCH_CP15_TIMER) {
pr_warn("arch_timer: already initialized, skipping\n");
return -EINVAL;
}
gtdt = container_of(table, struct acpi_table_gtdt, header);
arch_timers_present |= ARCH_CP15_TIMER;
arch_timer_ppi[PHYS_SECURE_PPI] =
map_generic_timer_interrupt(gtdt->secure_el1_interrupt,
gtdt->secure_el1_flags);
arch_timer_ppi[PHYS_NONSECURE_PPI] =
map_generic_timer_interrupt(gtdt->non_secure_el1_interrupt,
gtdt->non_secure_el1_flags);
arch_timer_ppi[VIRT_PPI] =
map_generic_timer_interrupt(gtdt->virtual_timer_interrupt,
gtdt->virtual_timer_flags);
arch_timer_ppi[HYP_PPI] =
map_generic_timer_interrupt(gtdt->non_secure_el2_interrupt,
gtdt->non_secure_el2_flags);
/* Get the frequency from CNTFRQ */
arch_timer_detect_rate(NULL, NULL);
/* Always-on capability */
arch_timer_c3stop = !(gtdt->non_secure_el1_flags & ACPI_GTDT_ALWAYS_ON);
arch_timer_init();
return 0;
}
/* Initialize all the generic timers presented in GTDT */
void __init acpi_generic_timer_init(void)
{
if (acpi_disabled)
return;
acpi_table_parse(ACPI_SIG_GTDT, arch_timer_acpi_init);
}
#endif
...@@ -33,12 +33,14 @@ ...@@ -33,12 +33,14 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_address.h> #include <linux/of_address.h>
#include <linux/of_irq.h> #include <linux/of_irq.h>
#include <linux/acpi.h>
#include <linux/irqdomain.h> #include <linux/irqdomain.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/percpu.h> #include <linux/percpu.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/irqchip/chained_irq.h> #include <linux/irqchip/chained_irq.h>
#include <linux/irqchip/arm-gic.h> #include <linux/irqchip/arm-gic.h>
#include <linux/irqchip/arm-gic-acpi.h>
#include <asm/cputype.h> #include <asm/cputype.h>
#include <asm/irq.h> #include <asm/irq.h>
...@@ -1107,3 +1109,105 @@ IRQCHIP_DECLARE(msm_8660_qgic, "qcom,msm-8660-qgic", gic_of_init); ...@@ -1107,3 +1109,105 @@ IRQCHIP_DECLARE(msm_8660_qgic, "qcom,msm-8660-qgic", gic_of_init);
IRQCHIP_DECLARE(msm_qgic2, "qcom,msm-qgic2", gic_of_init); IRQCHIP_DECLARE(msm_qgic2, "qcom,msm-qgic2", gic_of_init);
#endif #endif
#ifdef CONFIG_ACPI
static phys_addr_t dist_phy_base, cpu_phy_base __initdata;
static int __init
gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
const unsigned long end)
{
struct acpi_madt_generic_interrupt *processor;
phys_addr_t gic_cpu_base;
static int cpu_base_assigned;
processor = (struct acpi_madt_generic_interrupt *)header;
if (BAD_MADT_ENTRY(processor, end))
return -EINVAL;
/*
* There is no support for non-banked GICv1/2 register in ACPI spec.
* All CPU interface addresses have to be the same.
*/
gic_cpu_base = processor->base_address;
if (cpu_base_assigned && gic_cpu_base != cpu_phy_base)
return -EINVAL;
cpu_phy_base = gic_cpu_base;
cpu_base_assigned = 1;
return 0;
}
static int __init
gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header,
const unsigned long end)
{
struct acpi_madt_generic_distributor *dist;
dist = (struct acpi_madt_generic_distributor *)header;
if (BAD_MADT_ENTRY(dist, end))
return -EINVAL;
dist_phy_base = dist->base_address;
return 0;
}
int __init
gic_v2_acpi_init(struct acpi_table_header *table)
{
void __iomem *cpu_base, *dist_base;
int count;
/* Collect CPU base addresses */
count = acpi_parse_entries(ACPI_SIG_MADT,
sizeof(struct acpi_table_madt),
gic_acpi_parse_madt_cpu, table,
ACPI_MADT_TYPE_GENERIC_INTERRUPT, 0);
if (count <= 0) {
pr_err("No valid GICC entries exist\n");
return -EINVAL;
}
/*
* Find distributor base address. We expect one distributor entry since
* ACPI 5.1 spec neither support multi-GIC instances nor GIC cascade.
*/
count = acpi_parse_entries(ACPI_SIG_MADT,
sizeof(struct acpi_table_madt),
gic_acpi_parse_madt_distributor, table,
ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0);
if (count <= 0) {
pr_err("No valid GICD entries exist\n");
return -EINVAL;
} else if (count > 1) {
pr_err("More than one GICD entry detected\n");
return -EINVAL;
}
cpu_base = ioremap(cpu_phy_base, ACPI_GIC_CPU_IF_MEM_SIZE);
if (!cpu_base) {
pr_err("Unable to map GICC registers\n");
return -ENOMEM;
}
dist_base = ioremap(dist_phy_base, ACPI_GICV2_DIST_MEM_SIZE);
if (!dist_base) {
pr_err("Unable to map GICD registers\n");
iounmap(cpu_base);
return -ENOMEM;
}
/*
* Initialize zero GIC instance (no multi-GIC support). Also, set GIC
* as default IRQ domain to allow for GSI registration and GSI to IRQ
* number translation (see acpi_register_gsi() and acpi_gsi_to_irq()).
*/
gic_init_bases(0, -1, dist_base, cpu_base, 0, NULL);
irq_set_default_host(gic_data[0].domain);
acpi_irq_model = ACPI_IRQ_MODEL_GIC;
return 0;
}
#endif
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
* warranty of any kind, whether express or implied. * warranty of any kind, whether express or implied.
*/ */
#include <linux/acpi_irq.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/of_irq.h> #include <linux/of_irq.h>
#include <linux/irqchip.h> #include <linux/irqchip.h>
...@@ -26,4 +27,6 @@ extern struct of_device_id __irqchip_of_table[]; ...@@ -26,4 +27,6 @@ extern struct of_device_id __irqchip_of_table[];
void __init irqchip_init(void) void __init irqchip_init(void)
{ {
of_irq_init(__irqchip_of_table); of_irq_init(__irqchip_of_table);
acpi_irq_init();
} }
...@@ -276,4 +276,8 @@ config XEN_AUTO_XLATE ...@@ -276,4 +276,8 @@ config XEN_AUTO_XLATE
help help
Support for auto-translated physmap guests. Support for auto-translated physmap guests.
config XEN_ACPI
def_bool y
depends on X86 && ACPI
endmenu endmenu
...@@ -13,7 +13,7 @@ CFLAGS_efi.o += -fshort-wchar ...@@ -13,7 +13,7 @@ CFLAGS_efi.o += -fshort-wchar
dom0-$(CONFIG_PCI) += pci.o dom0-$(CONFIG_PCI) += pci.o
dom0-$(CONFIG_USB_SUPPORT) += dbgp.o dom0-$(CONFIG_USB_SUPPORT) += dbgp.o
dom0-$(CONFIG_ACPI) += acpi.o $(xen-pad-y) dom0-$(CONFIG_XEN_ACPI) += acpi.o $(xen-pad-y)
xen-pad-$(CONFIG_X86) += xen-acpi-pad.o xen-pad-$(CONFIG_X86) += xen-acpi-pad.o
dom0-$(CONFIG_X86) += pcpu.o dom0-$(CONFIG_X86) += pcpu.o
obj-$(CONFIG_XEN_DOM0) += $(dom0-y) obj-$(CONFIG_XEN_DOM0) += $(dom0-y)
......
...@@ -3,11 +3,15 @@ ...@@ -3,11 +3,15 @@
#include <linux/io.h> #include <linux/io.h>
#include <asm/acpi.h>
#ifndef acpi_os_ioremap
static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys, static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
acpi_size size) acpi_size size)
{ {
return ioremap_cache(phys, size); return ioremap_cache(phys, size);
} }
#endif
void __iomem *__init_refok void __iomem *__init_refok
acpi_os_map_iomem(acpi_physical_address phys, acpi_size size); acpi_os_map_iomem(acpi_physical_address phys, acpi_size size);
......
...@@ -196,7 +196,7 @@ struct acpi_processor_flags { ...@@ -196,7 +196,7 @@ struct acpi_processor_flags {
struct acpi_processor { struct acpi_processor {
acpi_handle handle; acpi_handle handle;
u32 acpi_id; u32 acpi_id;
u32 phys_id; /* CPU hardware ID such as APIC ID for x86 */ phys_cpuid_t phys_id; /* CPU hardware ID such as APIC ID for x86 */
u32 id; /* CPU logical ID allocated by OS */ u32 id; /* CPU logical ID allocated by OS */
u32 pblk; u32 pblk;
int performance_platform_limit; int performance_platform_limit;
...@@ -310,8 +310,8 @@ static inline int acpi_processor_get_bios_limit(int cpu, unsigned int *limit) ...@@ -310,8 +310,8 @@ static inline int acpi_processor_get_bios_limit(int cpu, unsigned int *limit)
#endif /* CONFIG_CPU_FREQ */ #endif /* CONFIG_CPU_FREQ */
/* in processor_core.c */ /* in processor_core.c */
int acpi_get_phys_id(acpi_handle, int type, u32 acpi_id); phys_cpuid_t acpi_get_phys_id(acpi_handle, int type, u32 acpi_id);
int acpi_map_cpuid(int phys_id, u32 acpi_id); int acpi_map_cpuid(phys_cpuid_t phys_id, u32 acpi_id);
int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id); int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id);
/* in processor_pdc.c */ /* in processor_pdc.c */
......
...@@ -79,6 +79,7 @@ enum acpi_irq_model_id { ...@@ -79,6 +79,7 @@ enum acpi_irq_model_id {
ACPI_IRQ_MODEL_IOAPIC, ACPI_IRQ_MODEL_IOAPIC,
ACPI_IRQ_MODEL_IOSAPIC, ACPI_IRQ_MODEL_IOSAPIC,
ACPI_IRQ_MODEL_PLATFORM, ACPI_IRQ_MODEL_PLATFORM,
ACPI_IRQ_MODEL_GIC,
ACPI_IRQ_MODEL_COUNT ACPI_IRQ_MODEL_COUNT
}; };
...@@ -152,9 +153,14 @@ void acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa); ...@@ -152,9 +153,14 @@ void acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa);
int acpi_numa_memory_affinity_init (struct acpi_srat_mem_affinity *ma); int acpi_numa_memory_affinity_init (struct acpi_srat_mem_affinity *ma);
void acpi_numa_arch_fixup(void); void acpi_numa_arch_fixup(void);
#ifndef PHYS_CPUID_INVALID
typedef u32 phys_cpuid_t;
#define PHYS_CPUID_INVALID (phys_cpuid_t)(-1)
#endif
#ifdef CONFIG_ACPI_HOTPLUG_CPU #ifdef CONFIG_ACPI_HOTPLUG_CPU
/* Arch dependent functions for cpu hotplug support */ /* Arch dependent functions for cpu hotplug support */
int acpi_map_cpu(acpi_handle handle, int physid, int *pcpu); int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, int *pcpu);
int acpi_unmap_cpu(int cpu); int acpi_unmap_cpu(int cpu);
#endif /* CONFIG_ACPI_HOTPLUG_CPU */ #endif /* CONFIG_ACPI_HOTPLUG_CPU */
......
#ifndef _LINUX_ACPI_IRQ_H
#define _LINUX_ACPI_IRQ_H
#include <linux/irq.h>
#ifndef acpi_irq_init
static inline void acpi_irq_init(void) { }
#endif
#endif /* _LINUX_ACPI_IRQ_H */
...@@ -253,4 +253,10 @@ extern void clocksource_of_init(void); ...@@ -253,4 +253,10 @@ extern void clocksource_of_init(void);
static inline void clocksource_of_init(void) {} static inline void clocksource_of_init(void) {}
#endif #endif
#ifdef CONFIG_ACPI
void acpi_generic_timer_init(void);
#else
static inline void acpi_generic_timer_init(void) { }
#endif
#endif /* _LINUX_CLOCKSOURCE_H */ #endif /* _LINUX_CLOCKSOURCE_H */
/*
* Copyright (C) 2014, Linaro Ltd.
* Author: Tomasz Nowicki <tomasz.nowicki@linaro.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef ARM_GIC_ACPI_H_
#define ARM_GIC_ACPI_H_
#ifdef CONFIG_ACPI
/*
* Hard code here, we can not get memory size from MADT (but FDT does),
* Actually no need to do that, because this size can be inferred
* from GIC spec.
*/
#define ACPI_GICV2_DIST_MEM_SIZE (SZ_4K)
#define ACPI_GIC_CPU_IF_MEM_SIZE (SZ_8K)
struct acpi_table_header;
int gic_v2_acpi_init(struct acpi_table_header *table);
void acpi_gic_init(void);
#else
static inline void acpi_gic_init(void) { }
#endif
#endif /* ARM_GIC_ACPI_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment