1 /* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
3 * Copyright(c) 2009 Intel Corporation. All rights reserved.
10 #include <linux/types.h>
12 /* Table signatures reserved by the SFI specification */
13 #define SFI_SIG_SYST "SYST"
14 #define SFI_SIG_FREQ "FREQ"
15 #define SFI_SIG_CPUS "CPUS"
16 #define SFI_SIG_MTMR "MTMR"
17 #define SFI_SIG_MRTC "MRTC"
18 #define SFI_SIG_MMAP "MMAP"
19 #define SFI_SIG_APIC "APIC"
20 #define SFI_SIG_XSDT "XSDT"
21 #define SFI_SIG_WAKE "WAKE"
22 #define SFI_SIG_DEVS "DEVS"
23 #define SFI_SIG_GPIO "GPIO"
25 #define SFI_SIGNATURE_SIZE 4
26 #define SFI_OEM_ID_SIZE 6
27 #define SFI_OEM_TABLE_ID_SIZE 8
29 #define SFI_NAME_LEN 16
30 #define SFI_TABLE_MAX_ENTRIES 16
32 #define SFI_GET_NUM_ENTRIES(ptable, entry_type) \
33 ((ptable->header.len - sizeof(struct sfi_table_header)) / \
36 * Table structures must be byte-packed to match the SFI specification,
37 * as they are provided by the BIOS.
39 struct __packed sfi_table_header {
40 char sig[SFI_SIGNATURE_SIZE];
44 char oem_id[SFI_OEM_ID_SIZE];
45 char oem_table_id[SFI_OEM_TABLE_ID_SIZE];
48 struct __packed sfi_table_simple {
49 struct sfi_table_header header;
53 /* Comply with UEFI spec 2.1 */
54 struct __packed sfi_mem_entry {
62 /* Memory type definitions */
67 SFI_BOOT_SERVICE_CODE,
68 SFI_BOOT_SERVICE_DATA,
69 SFI_RUNTIME_SERVICE_CODE,
70 SFI_RUNTIME_SERVICE_DATA,
81 struct __packed sfi_cpu_table_entry {
85 struct __packed sfi_cstate_table_entry {
86 u32 hint; /* MWAIT hint */
87 u32 latency; /* latency in ms */
90 struct __packed sfi_apic_table_entry {
91 u64 phys_addr; /* phy base addr for APIC reg */
94 struct __packed sfi_freq_table_entry {
95 u32 freq_mhz; /* in MHZ */
96 u32 latency; /* transition latency in ms */
97 u32 ctrl_val; /* value to write to PERF_CTL */
100 struct __packed sfi_wake_table_entry {
101 u64 phys_addr; /* pointer to where the wake vector locates */
104 struct __packed sfi_timer_table_entry {
105 u64 phys_addr; /* phy base addr for the timer */
106 u32 freq_hz; /* in HZ */
110 struct __packed sfi_rtc_table_entry {
111 u64 phys_addr; /* phy base addr for the RTC */
115 struct __packed sfi_device_table_entry {
116 u8 type; /* bus type, I2C, SPI or ...*/
117 u8 host_num; /* attached to host 0, 1...*/
121 char name[SFI_NAME_LEN];
125 SFI_DEV_TYPE_SPI = 0,
133 struct __packed sfi_gpio_table_entry {
134 char controller_name[SFI_NAME_LEN];
136 char pin_name[SFI_NAME_LEN];
139 struct sfi_xsdt_header {
140 uint32_t oem_revision;
142 uint32_t creator_revision;
145 typedef int (*sfi_table_handler) (struct sfi_table_header *table);
148 * write_sfi_table() - Write Simple Firmware Interface tables
150 * @base: Address to write table to
151 * @return address to use for the next table
153 ulong write_sfi_table(ulong base);
155 #endif /*_LINUX_SFI_H */