acpi.h 4.4 KB

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