sfi.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
  2. /*
  3. * Copyright(c) 2009 Intel Corporation. All rights reserved.
  4. */
  5. #ifndef _LINUX_SFI_H
  6. #define _LINUX_SFI_H
  7. #include <errno.h>
  8. #include <linux/types.h>
  9. /* Table signatures reserved by the SFI specification */
  10. #define SFI_SIG_SYST "SYST"
  11. #define SFI_SIG_FREQ "FREQ"
  12. #define SFI_SIG_CPUS "CPUS"
  13. #define SFI_SIG_MTMR "MTMR"
  14. #define SFI_SIG_MRTC "MRTC"
  15. #define SFI_SIG_MMAP "MMAP"
  16. #define SFI_SIG_APIC "APIC"
  17. #define SFI_SIG_XSDT "XSDT"
  18. #define SFI_SIG_WAKE "WAKE"
  19. #define SFI_SIG_DEVS "DEVS"
  20. #define SFI_SIG_GPIO "GPIO"
  21. #define SFI_SIGNATURE_SIZE 4
  22. #define SFI_OEM_ID_SIZE 6
  23. #define SFI_OEM_TABLE_ID_SIZE 8
  24. #define SFI_NAME_LEN 16
  25. #define SFI_TABLE_MAX_ENTRIES 16
  26. #define SFI_GET_NUM_ENTRIES(ptable, entry_type) \
  27. ((ptable->header.len - sizeof(struct sfi_table_header)) / \
  28. (sizeof(entry_type)))
  29. /*
  30. * Table structures must be byte-packed to match the SFI specification,
  31. * as they are provided by the BIOS.
  32. */
  33. struct __packed sfi_table_header {
  34. char sig[SFI_SIGNATURE_SIZE];
  35. u32 len;
  36. u8 rev;
  37. u8 csum;
  38. char oem_id[SFI_OEM_ID_SIZE];
  39. char oem_table_id[SFI_OEM_TABLE_ID_SIZE];
  40. };
  41. struct __packed sfi_table_simple {
  42. struct sfi_table_header header;
  43. u64 pentry[1];
  44. };
  45. /* Comply with UEFI spec 2.1 */
  46. struct __packed sfi_mem_entry {
  47. u32 type;
  48. u64 phys_start;
  49. u64 virt_start;
  50. u64 pages;
  51. u64 attrib;
  52. };
  53. /* Memory type definitions */
  54. enum sfi_mem_type {
  55. SFI_MEM_RESERVED,
  56. SFI_LOADER_CODE,
  57. SFI_LOADER_DATA,
  58. SFI_BOOT_SERVICE_CODE,
  59. SFI_BOOT_SERVICE_DATA,
  60. SFI_RUNTIME_SERVICE_CODE,
  61. SFI_RUNTIME_SERVICE_DATA,
  62. SFI_MEM_CONV,
  63. SFI_MEM_UNUSABLE,
  64. SFI_ACPI_RECLAIM,
  65. SFI_ACPI_NVS,
  66. SFI_MEM_MMIO,
  67. SFI_MEM_IOPORT,
  68. SFI_PAL_CODE,
  69. SFI_MEM_TYPEMAX,
  70. };
  71. struct __packed sfi_cpu_table_entry {
  72. u32 apic_id;
  73. };
  74. struct __packed sfi_cstate_table_entry {
  75. u32 hint; /* MWAIT hint */
  76. u32 latency; /* latency in ms */
  77. };
  78. struct __packed sfi_apic_table_entry {
  79. u64 phys_addr; /* phy base addr for APIC reg */
  80. };
  81. struct __packed sfi_freq_table_entry {
  82. u32 freq_mhz; /* in MHZ */
  83. u32 latency; /* transition latency in ms */
  84. u32 ctrl_val; /* value to write to PERF_CTL */
  85. };
  86. struct __packed sfi_wake_table_entry {
  87. u64 phys_addr; /* pointer to where the wake vector locates */
  88. };
  89. struct __packed sfi_timer_table_entry {
  90. u64 phys_addr; /* phy base addr for the timer */
  91. u32 freq_hz; /* in HZ */
  92. u32 irq;
  93. };
  94. struct __packed sfi_rtc_table_entry {
  95. u64 phys_addr; /* phy base addr for the RTC */
  96. u32 irq;
  97. };
  98. struct __packed sfi_device_table_entry {
  99. u8 type; /* bus type, I2C, SPI or ...*/
  100. u8 host_num; /* attached to host 0, 1...*/
  101. u16 addr;
  102. u8 irq;
  103. u32 max_freq;
  104. char name[SFI_NAME_LEN];
  105. };
  106. enum {
  107. SFI_DEV_TYPE_SPI = 0,
  108. SFI_DEV_TYPE_I2C,
  109. SFI_DEV_TYPE_UART,
  110. SFI_DEV_TYPE_HSI,
  111. SFI_DEV_TYPE_IPC,
  112. SFI_DEV_TYPE_SD,
  113. };
  114. struct __packed sfi_gpio_table_entry {
  115. char controller_name[SFI_NAME_LEN];
  116. u16 pin_no;
  117. char pin_name[SFI_NAME_LEN];
  118. };
  119. struct sfi_xsdt_header {
  120. uint32_t oem_revision;
  121. uint32_t creator_id;
  122. uint32_t creator_revision;
  123. };
  124. typedef int (*sfi_table_handler) (struct sfi_table_header *table);
  125. /**
  126. * write_sfi_table() - Write Simple Firmware Interface tables
  127. *
  128. * @base: Address to write table to
  129. * @return address to use for the next table
  130. */
  131. ulong write_sfi_table(ulong base);
  132. #endif /*_LINUX_SFI_H */