aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sfi.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/sfi.h')
-rw-r--r--include/linux/sfi.h206
1 files changed, 206 insertions, 0 deletions
diff --git a/include/linux/sfi.h b/include/linux/sfi.h
new file mode 100644
index 000000000000..9a6f7607174e
--- /dev/null
+++ b/include/linux/sfi.h
@@ -0,0 +1,206 @@
1/* sfi.h Simple Firmware Interface */
2
3/*
4
5 This file is provided under a dual BSD/GPLv2 license. When using or
6 redistributing this file, you may do so under either license.
7
8 GPL LICENSE SUMMARY
9
10 Copyright(c) 2009 Intel Corporation. All rights reserved.
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of version 2 of the GNU General Public License as
14 published by the Free Software Foundation.
15
16 This program is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
24 The full GNU General Public License is included in this distribution
25 in the file called LICENSE.GPL.
26
27 BSD LICENSE
28
29 Copyright(c) 2009 Intel Corporation. All rights reserved.
30
31 Redistribution and use in source and binary forms, with or without
32 modification, are permitted provided that the following conditions
33 are met:
34
35 * Redistributions of source code must retain the above copyright
36 notice, this list of conditions and the following disclaimer.
37 * Redistributions in binary form must reproduce the above copyright
38 notice, this list of conditions and the following disclaimer in
39 the documentation and/or other materials provided with the
40 distribution.
41 * Neither the name of Intel Corporation nor the names of its
42 contributors may be used to endorse or promote products derived
43 from this software without specific prior written permission.
44
45 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
46 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
47 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
48 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
49 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
50 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
51 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
52 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
53 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
54 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
55 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56
57*/
58
59#ifndef _LINUX_SFI_H
60#define _LINUX_SFI_H
61
62/* Table signatures reserved by the SFI specification */
63#define SFI_SIG_SYST "SYST"
64#define SFI_SIG_FREQ "FREQ"
65#define SFI_SIG_IDLE "IDLE"
66#define SFI_SIG_CPUS "CPUS"
67#define SFI_SIG_MTMR "MTMR"
68#define SFI_SIG_MRTC "MRTC"
69#define SFI_SIG_MMAP "MMAP"
70#define SFI_SIG_APIC "APIC"
71#define SFI_SIG_XSDT "XSDT"
72#define SFI_SIG_WAKE "WAKE"
73#define SFI_SIG_SPIB "SPIB"
74#define SFI_SIG_I2CB "I2CB"
75#define SFI_SIG_GPEM "GPEM"
76
77#define SFI_SIGNATURE_SIZE 4
78#define SFI_OEM_ID_SIZE 6
79#define SFI_OEM_TABLE_ID_SIZE 8
80
81#define SFI_SYST_SEARCH_BEGIN 0x000E0000
82#define SFI_SYST_SEARCH_END 0x000FFFFF
83
84#define SFI_GET_NUM_ENTRIES(ptable, entry_type) \
85 ((ptable->header.len - sizeof(struct sfi_table_header)) / \
86 (sizeof(entry_type)))
87/*
88 * Table structures must be byte-packed to match the SFI specification,
89 * as they are provided by the BIOS.
90 */
91struct sfi_table_header {
92 char sig[SFI_SIGNATURE_SIZE];
93 u32 len;
94 u8 rev;
95 u8 csum;
96 char oem_id[SFI_OEM_ID_SIZE];
97 char oem_table_id[SFI_OEM_TABLE_ID_SIZE];
98} __packed;
99
100struct sfi_table_simple {
101 struct sfi_table_header header;
102 u64 pentry[1];
103} __packed;
104
105/* Comply with UEFI spec 2.1 */
106struct sfi_mem_entry {
107 u32 type;
108 u64 phys_start;
109 u64 virt_start;
110 u64 pages;
111 u64 attrib;
112} __packed;
113
114struct sfi_cpu_table_entry {
115 u32 apic_id;
116} __packed;
117
118struct sfi_cstate_table_entry {
119 u32 hint; /* MWAIT hint */
120 u32 latency; /* latency in ms */
121} __packed;
122
123struct sfi_apic_table_entry {
124 u64 phys_addr; /* phy base addr for APIC reg */
125} __packed;
126
127struct sfi_freq_table_entry {
128 u32 freq_mhz; /* in MHZ */
129 u32 latency; /* transition latency in ms */
130 u32 ctrl_val; /* value to write to PERF_CTL */
131} __packed;
132
133struct sfi_wake_table_entry {
134 u64 phys_addr; /* pointer to where the wake vector locates */
135} __packed;
136
137struct sfi_timer_table_entry {
138 u64 phys_addr; /* phy base addr for the timer */
139 u32 freq_hz; /* in HZ */
140 u32 irq;
141} __packed;
142
143struct sfi_rtc_table_entry {
144 u64 phys_addr; /* phy base addr for the RTC */
145 u32 irq;
146} __packed;
147
148struct sfi_spi_table_entry {
149 u16 host_num; /* attached to host 0, 1...*/
150 u16 cs; /* chip select */
151 u16 irq_info;
152 char name[16];
153 u8 dev_info[10];
154} __packed;
155
156struct sfi_i2c_table_entry {
157 u16 host_num;
158 u16 addr; /* slave addr */
159 u16 irq_info;
160 char name[16];
161 u8 dev_info[10];
162} __packed;
163
164struct sfi_gpe_table_entry {
165 u16 logical_id; /* logical id */
166 u16 phys_id; /* physical GPE id */
167} __packed;
168
169
170typedef int (*sfi_table_handler) (struct sfi_table_header *table);
171
172#ifdef CONFIG_SFI
173extern void __init sfi_init(void);
174extern int __init sfi_platform_init(void);
175extern void __init sfi_init_late(void);
176extern int sfi_table_parse(char *signature, char *oem_id, char *oem_table_id,
177 sfi_table_handler handler);
178
179extern int sfi_disabled;
180static inline void disable_sfi(void)
181{
182 sfi_disabled = 1;
183}
184
185#else /* !CONFIG_SFI */
186
187static inline void sfi_init(void)
188{
189}
190
191static inline void sfi_init_late(void)
192{
193}
194
195#define sfi_disabled 0
196
197static inline int sfi_table_parse(char *signature, char *oem_id,
198 char *oem_table_id,
199 sfi_table_handler handler)
200{
201 return -1;
202}
203
204#endif /* !CONFIG_SFI */
205
206#endif /*_LINUX_SFI_H*/