acpi.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  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. #ifndef _ASM_ACPI_H
  12. #define _ASM_ACPI_H
  13. #include <linux/memblock.h>
  14. #include <linux/psci.h>
  15. #include <asm/cputype.h>
  16. #include <asm/smp_plat.h>
  17. #include <asm/tlbflush.h>
  18. /* Macros for consistency checks of the GICC subtable of MADT */
  19. #define ACPI_MADT_GICC_LENGTH \
  20. (acpi_gbl_FADT.header.revision < 6 ? 76 : 80)
  21. #define BAD_MADT_GICC_ENTRY(entry, end) \
  22. (!(entry) || (unsigned long)(entry) + sizeof(*(entry)) > (end) || \
  23. (entry)->header.length != ACPI_MADT_GICC_LENGTH)
  24. /* Basic configuration for ACPI */
  25. #ifdef CONFIG_ACPI
  26. /* ACPI table mapping after acpi_permanent_mmap is set */
  27. static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
  28. acpi_size size)
  29. {
  30. /*
  31. * EFI's reserve_regions() call adds memory with the WB attribute
  32. * to memblock via early_init_dt_add_memory_arch().
  33. */
  34. if (!memblock_is_memory(phys))
  35. return ioremap(phys, size);
  36. return ioremap_cache(phys, size);
  37. }
  38. #define acpi_os_ioremap acpi_os_ioremap
  39. typedef u64 phys_cpuid_t;
  40. #define PHYS_CPUID_INVALID INVALID_HWID
  41. #define acpi_strict 1 /* No out-of-spec workarounds on ARM64 */
  42. extern int acpi_disabled;
  43. extern int acpi_noirq;
  44. extern int acpi_pci_disabled;
  45. static inline void disable_acpi(void)
  46. {
  47. acpi_disabled = 1;
  48. acpi_pci_disabled = 1;
  49. acpi_noirq = 1;
  50. }
  51. static inline void enable_acpi(void)
  52. {
  53. acpi_disabled = 0;
  54. acpi_pci_disabled = 0;
  55. acpi_noirq = 0;
  56. }
  57. /*
  58. * The ACPI processor driver for ACPI core code needs this macro
  59. * to find out this cpu was already mapped (mapping from CPU hardware
  60. * ID to CPU logical ID) or not.
  61. */
  62. #define cpu_physical_id(cpu) cpu_logical_map(cpu)
  63. /*
  64. * It's used from ACPI core in kdump to boot UP system with SMP kernel,
  65. * with this check the ACPI core will not override the CPU index
  66. * obtained from GICC with 0 and not print some error message as well.
  67. * Since MADT must provide at least one GICC structure for GIC
  68. * initialization, CPU will be always available in MADT on ARM64.
  69. */
  70. static inline bool acpi_has_cpu_in_madt(void)
  71. {
  72. return true;
  73. }
  74. static inline void arch_fix_phys_package_id(int num, u32 slot) { }
  75. void __init acpi_init_cpus(void);
  76. #else
  77. static inline void acpi_init_cpus(void) { }
  78. #endif /* CONFIG_ACPI */
  79. #ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL
  80. bool acpi_parking_protocol_valid(int cpu);
  81. void __init
  82. acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor);
  83. #else
  84. static inline bool acpi_parking_protocol_valid(int cpu) { return false; }
  85. static inline void
  86. acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor)
  87. {}
  88. #endif
  89. static inline const char *acpi_get_enable_method(int cpu)
  90. {
  91. if (acpi_psci_present())
  92. return "psci";
  93. if (acpi_parking_protocol_valid(cpu))
  94. return "parking-protocol";
  95. return NULL;
  96. }
  97. #ifdef CONFIG_ACPI_APEI
  98. /*
  99. * acpi_disable_cmcff is used in drivers/acpi/apei/hest.c for disabling
  100. * IA-32 Architecture Corrected Machine Check (CMC) Firmware-First mode
  101. * with a kernel command line parameter "acpi=nocmcoff". But we don't
  102. * have this IA-32 specific feature on ARM64, this definition is only
  103. * for compatibility.
  104. */
  105. #define acpi_disable_cmcff 1
  106. pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr);
  107. /*
  108. * Despite its name, this function must still broadcast the TLB
  109. * invalidation in order to ensure other CPUs don't end up with junk
  110. * entries as a result of speculation. Unusually, its also called in
  111. * IRQ context (ghes_iounmap_irq) so if we ever need to use IPIs for
  112. * TLB broadcasting, then we're in trouble here.
  113. */
  114. static inline void arch_apei_flush_tlb_one(unsigned long addr)
  115. {
  116. flush_tlb_kernel_range(addr, addr + PAGE_SIZE);
  117. }
  118. #endif /* CONFIG_ACPI_APEI */
  119. #ifdef CONFIG_ACPI_NUMA
  120. int arm64_acpi_numa_init(void);
  121. int acpi_numa_get_nid(unsigned int cpu, u64 hwid);
  122. #else
  123. static inline int arm64_acpi_numa_init(void) { return -ENOSYS; }
  124. static inline int acpi_numa_get_nid(unsigned int cpu, u64 hwid) { return NUMA_NO_NODE; }
  125. #endif /* CONFIG_ACPI_NUMA */
  126. #define ACPI_TABLE_UPGRADE_MAX_PHYS MEMBLOCK_ALLOC_ACCESSIBLE
  127. #endif /*_ASM_ACPI_H*/