acpi.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. /* Macros for consistency checks of the GICC subtable of MADT */
  18. #define ACPI_MADT_GICC_LENGTH \
  19. (acpi_gbl_FADT.header.revision < 6 ? 76 : 80)
  20. #define BAD_MADT_GICC_ENTRY(entry, end) \
  21. (!(entry) || (entry)->header.length != ACPI_MADT_GICC_LENGTH || \
  22. (unsigned long)(entry) + ACPI_MADT_GICC_LENGTH > (end))
  23. /* Basic configuration for ACPI */
  24. #ifdef CONFIG_ACPI
  25. /* ACPI table mapping after acpi_gbl_permanent_mmap is set */
  26. static inline void __iomem *acpi_os_ioremap(acpi_physical_address phys,
  27. acpi_size size)
  28. {
  29. /*
  30. * EFI's reserve_regions() call adds memory with the WB attribute
  31. * to memblock via early_init_dt_add_memory_arch().
  32. */
  33. if (!memblock_is_memory(phys))
  34. return ioremap(phys, size);
  35. return ioremap_cache(phys, size);
  36. }
  37. #define acpi_os_ioremap acpi_os_ioremap
  38. typedef u64 phys_cpuid_t;
  39. #define PHYS_CPUID_INVALID INVALID_HWID
  40. #define acpi_strict 1 /* No out-of-spec workarounds on ARM64 */
  41. extern int acpi_disabled;
  42. extern int acpi_noirq;
  43. extern int acpi_pci_disabled;
  44. static inline void disable_acpi(void)
  45. {
  46. acpi_disabled = 1;
  47. acpi_pci_disabled = 1;
  48. acpi_noirq = 1;
  49. }
  50. static inline void enable_acpi(void)
  51. {
  52. acpi_disabled = 0;
  53. acpi_pci_disabled = 0;
  54. acpi_noirq = 0;
  55. }
  56. /*
  57. * The ACPI processor driver for ACPI core code needs this macro
  58. * to find out this cpu was already mapped (mapping from CPU hardware
  59. * ID to CPU logical ID) or not.
  60. */
  61. #define cpu_physical_id(cpu) cpu_logical_map(cpu)
  62. /*
  63. * It's used from ACPI core in kdump to boot UP system with SMP kernel,
  64. * with this check the ACPI core will not override the CPU index
  65. * obtained from GICC with 0 and not print some error message as well.
  66. * Since MADT must provide at least one GICC structure for GIC
  67. * initialization, CPU will be always available in MADT on ARM64.
  68. */
  69. static inline bool acpi_has_cpu_in_madt(void)
  70. {
  71. return true;
  72. }
  73. static inline void arch_fix_phys_package_id(int num, u32 slot) { }
  74. void __init acpi_init_cpus(void);
  75. #else
  76. static inline void acpi_init_cpus(void) { }
  77. #endif /* CONFIG_ACPI */
  78. #ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL
  79. bool acpi_parking_protocol_valid(int cpu);
  80. void __init
  81. acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor);
  82. #else
  83. static inline bool acpi_parking_protocol_valid(int cpu) { return false; }
  84. static inline void
  85. acpi_set_mailbox_entry(int cpu, struct acpi_madt_generic_interrupt *processor)
  86. {}
  87. #endif
  88. static inline const char *acpi_get_enable_method(int cpu)
  89. {
  90. if (acpi_psci_present())
  91. return "psci";
  92. if (acpi_parking_protocol_valid(cpu))
  93. return "parking-protocol";
  94. return NULL;
  95. }
  96. #ifdef CONFIG_ACPI_APEI
  97. pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr);
  98. #endif
  99. #ifdef CONFIG_ACPI_NUMA
  100. int arm64_acpi_numa_init(void);
  101. int acpi_numa_get_nid(unsigned int cpu, u64 hwid);
  102. #else
  103. static inline int arm64_acpi_numa_init(void) { return -ENOSYS; }
  104. static inline int acpi_numa_get_nid(unsigned int cpu, u64 hwid) { return NUMA_NO_NODE; }
  105. #endif /* CONFIG_ACPI_NUMA */
  106. #define ACPI_TABLE_UPGRADE_MAX_PHYS MEMBLOCK_ALLOC_ACCESSIBLE
  107. #endif /*_ASM_ACPI_H*/