acpi.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2013-2014, Linaro Ltd.
  4. * Author: Al Stone <[email protected]>
  5. * Author: Graeme Gregory <[email protected]>
  6. * Author: Hanjun Guo <[email protected]>
  7. */
  8. #ifndef _ASM_ACPI_H
  9. #define _ASM_ACPI_H
  10. #include <linux/efi.h>
  11. #include <linux/memblock.h>
  12. #include <linux/psci.h>
  13. #include <linux/stddef.h>
  14. #include <asm/cputype.h>
  15. #include <asm/io.h>
  16. #include <asm/ptrace.h>
  17. #include <asm/smp_plat.h>
  18. #include <asm/tlbflush.h>
  19. /* Macros for consistency checks of the GICC subtable of MADT */
  20. /*
  21. * MADT GICC minimum length refers to the MADT GICC structure table length as
  22. * defined in the earliest ACPI version supported on arm64, ie ACPI 5.1.
  23. *
  24. * The efficiency_class member was added to the
  25. * struct acpi_madt_generic_interrupt to represent the MADT GICC structure
  26. * "Processor Power Efficiency Class" field, added in ACPI 6.0 whose offset
  27. * is therefore used to delimit the MADT GICC structure minimum length
  28. * appropriately.
  29. */
  30. #define ACPI_MADT_GICC_MIN_LENGTH offsetof( \
  31. struct acpi_madt_generic_interrupt, efficiency_class)
  32. #define BAD_MADT_GICC_ENTRY(entry, end) \
  33. (!(entry) || (entry)->header.length < ACPI_MADT_GICC_MIN_LENGTH || \
  34. (unsigned long)(entry) + (entry)->header.length > (end))
  35. #define ACPI_MADT_GICC_SPE (offsetof(struct acpi_madt_generic_interrupt, \
  36. spe_interrupt) + sizeof(u16))
  37. /* Basic configuration for ACPI */
  38. #ifdef CONFIG_ACPI
  39. pgprot_t __acpi_get_mem_attribute(phys_addr_t addr);
  40. /* ACPI table mapping after acpi_permanent_mmap is set */
  41. void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size);
  42. #define acpi_os_ioremap acpi_os_ioremap
  43. typedef u64 phys_cpuid_t;
  44. #define PHYS_CPUID_INVALID INVALID_HWID
  45. #define acpi_strict 1 /* No out-of-spec workarounds on ARM64 */
  46. extern int acpi_disabled;
  47. extern int acpi_noirq;
  48. extern int acpi_pci_disabled;
  49. static inline void disable_acpi(void)
  50. {
  51. acpi_disabled = 1;
  52. acpi_pci_disabled = 1;
  53. acpi_noirq = 1;
  54. }
  55. static inline void enable_acpi(void)
  56. {
  57. acpi_disabled = 0;
  58. acpi_pci_disabled = 0;
  59. acpi_noirq = 0;
  60. }
  61. /*
  62. * The ACPI processor driver for ACPI core code needs this macro
  63. * to find out this cpu was already mapped (mapping from CPU hardware
  64. * ID to CPU logical ID) or not.
  65. */
  66. #define cpu_physical_id(cpu) cpu_logical_map(cpu)
  67. /*
  68. * It's used from ACPI core in kdump to boot UP system with SMP kernel,
  69. * with this check the ACPI core will not override the CPU index
  70. * obtained from GICC with 0 and not print some error message as well.
  71. * Since MADT must provide at least one GICC structure for GIC
  72. * initialization, CPU will be always available in MADT on ARM64.
  73. */
  74. static inline bool acpi_has_cpu_in_madt(void)
  75. {
  76. return true;
  77. }
  78. struct acpi_madt_generic_interrupt *acpi_cpu_get_madt_gicc(int cpu);
  79. static inline u32 get_acpi_id_for_cpu(unsigned int cpu)
  80. {
  81. return acpi_cpu_get_madt_gicc(cpu)->uid;
  82. }
  83. static inline void arch_fix_phys_package_id(int num, u32 slot) { }
  84. void __init acpi_init_cpus(void);
  85. int apei_claim_sea(struct pt_regs *regs);
  86. #else
  87. static inline void acpi_init_cpus(void) { }
  88. static inline int apei_claim_sea(struct pt_regs *regs) { return -ENOENT; }
  89. #endif /* CONFIG_ACPI */
  90. #ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL
  91. bool acpi_parking_protocol_valid(int cpu);
  92. void __init
  93. acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor);
  94. #else
  95. static inline bool acpi_parking_protocol_valid(int cpu) { return false; }
  96. static inline void
  97. acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor)
  98. {}
  99. #endif
  100. static inline const char *acpi_get_enable_method(int cpu)
  101. {
  102. if (acpi_psci_present())
  103. return "psci";
  104. if (acpi_parking_protocol_valid(cpu))
  105. return "parking-protocol";
  106. return NULL;
  107. }
  108. #ifdef CONFIG_ACPI_APEI
  109. /*
  110. * acpi_disable_cmcff is used in drivers/acpi/apei/hest.c for disabling
  111. * IA-32 Architecture Corrected Machine Check (CMC) Firmware-First mode
  112. * with a kernel command line parameter "acpi=nocmcoff". But we don't
  113. * have this IA-32 specific feature on ARM64, this definition is only
  114. * for compatibility.
  115. */
  116. #define acpi_disable_cmcff 1
  117. static inline pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr)
  118. {
  119. return __acpi_get_mem_attribute(addr);
  120. }
  121. #endif /* CONFIG_ACPI_APEI */
  122. #ifdef CONFIG_ACPI_NUMA
  123. int arm64_acpi_numa_init(void);
  124. int acpi_numa_get_nid(unsigned int cpu);
  125. void acpi_map_cpus_to_nodes(void);
  126. #else
  127. static inline int arm64_acpi_numa_init(void) { return -ENOSYS; }
  128. static inline int acpi_numa_get_nid(unsigned int cpu) { return NUMA_NO_NODE; }
  129. static inline void acpi_map_cpus_to_nodes(void) { }
  130. #endif /* CONFIG_ACPI_NUMA */
  131. #define ACPI_TABLE_UPGRADE_MAX_PHYS MEMBLOCK_ALLOC_ACCESSIBLE
  132. #endif /*_ASM_ACPI_H*/