sfi.h 2.9 KB

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