coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
opregion.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #ifndef _COMMON_GMA_H_
4 #define _COMMON_GMA_H_
5 
6 #include <types.h>
7 #include <commonlib/helpers.h>
8 
9 /* IGD PCI Configuration register */
10 #define ASLS 0xfc /* OpRegion Base */
11 #define SWSCI 0xe8 /* SWSCI Register */
12 #define SWSMISCI 0xe0 /* SWSMISCI Register */
13 #define GSSCIE (1 << 0) /* SCI Event trigger */
14 #define SMISCISEL (1 << 15) /* Select SMI or SCI event source */
15 
16 /* mailbox 0: header */
17 typedef struct {
18  u8 signature[16]; /* Offset 0 OpRegion signature */
19  u32 size; /* Offset 16 OpRegion size */
25  } opver; /* Offset 20 OpRegion version structure */
26  u8 sbios_version[32]; /* Offset 24 System BIOS build version */
27  u8 vbios_version[16]; /* Offset 56 Video BIOS build version */
28  u8 driver_version[16]; /* Offset 72 Graphic drvr build version */
29  u32 mailboxes; /* Offset 88 Mailboxes supported */
30  u32 dmod; /* Offset 92 Driver Model */
31  u32 pcon; /* Offset 96 Platform Capabilities */
32  u16 dver[16]; /* Offset 100 GOP Version */
33  u8 reserved[124]; /* Offset 132 Reserved */
34 } __packed opregion_header_t;
35 
36 #define IGD_OPREGION_SIGNATURE "IntelGraphicsMem"
37 
38 #define IGD_MBOX1 (1 << 0)
39 #define IGD_MBOX2 (1 << 1)
40 #define IGD_MBOX3 (1 << 2)
41 #define IGD_MBOX4 (1 << 3)
42 #define IGD_MBOX5 (1 << 4)
43 
44 #define MAILBOXES_MOBILE (IGD_MBOX1 | IGD_MBOX2 | IGD_MBOX3 | \
45  IGD_MBOX4 | IGD_MBOX5)
46 #define MAILBOXES_DESKTOP (IGD_MBOX2 | IGD_MBOX4)
47 
48 #define SBIOS_VERSION_SIZE 32
49 
50 /* mailbox 1: public ACPI methods */
51 typedef struct {
52  u32 drdy; /* Offset 0 Driver readiness */
53  u32 csts; /* Offset 4 Status */
54  u32 cevt; /* Offset 8 Current event */
55  u8 reserved[20]; /* Offset 12 Reserved */
56  u32 didl; /* Offset 32 Supported display device 1 */
57  u32 ddl2; /* Offset 36 Supported display device 2 */
58  u32 ddl3; /* Offset 40 Supported display device 3 */
59  u32 ddl4; /* Offset 44 Supported display device 4 */
60  u32 ddl5; /* Offset 48 Supported display device 5 */
61  u32 ddl6; /* Offset 52 Supported display device 6 */
62  u32 ddl7; /* Offset 56 Supported display device 7 */
63  u32 ddl8; /* Offset 60 Supported display device 8 */
64  u32 cpdl; /* Offset 64 Currently present display device 1 */
65  u32 cpl2; /* Offset 68 Currently present display device 2 */
66  u32 cpl3; /* Offset 72 Currently present display device 3 */
67  u32 cpl4; /* Offset 76 Currently present display device 4 */
68  u32 cpl5; /* Offset 80 Currently present display device 5 */
69  u32 cpl6; /* Offset 84 Currently present display device 6 */
70  u32 cpl7; /* Offset 88 Currently present display device 7 */
71  u32 cpl8; /* Offset 92 Currently present display device 8 */
72  u32 cadl; /* Offset 96 Currently active display device 1 */
73  u32 cal2; /* Offset 100 Currently active display device 2 */
74  u32 cal3; /* Offset 104 Currently active display device 3 */
75  u32 cal4; /* Offset 108 Currently active display device 4 */
76  u32 cal5; /* Offset 112 Currently active display device 5 */
77  u32 cal6; /* Offset 116 Currently active display device 6 */
78  u32 cal7; /* Offset 120 Currently active display device 7 */
79  u32 cal8; /* Offset 124 Currently active display device 8 */
80  u32 nadl; /* Offset 128 Next active device 1 */
81  u32 ndl2; /* Offset 132 Next active device 2 */
82  u32 ndl3; /* Offset 136 Next active device 3 */
83  u32 ndl4; /* Offset 140 Next active device 4 */
84  u32 ndl5; /* Offset 144 Next active device 5 */
85  u32 ndl6; /* Offset 148 Next active device 6 */
86  u32 ndl7; /* Offset 152 Next active device 7 */
87  u32 ndl8; /* Offset 156 Next active device 8 */
88  u32 aslp; /* Offset 160 ASL sleep timeout */
89  u32 tidx; /* Offset 164 Toggle table index */
90  u32 chpd; /* Offset 168 Current hot plug enable indicator */
91  u32 clid; /* Offset 172 Current lid state indicator */
92  u32 cdck; /* Offset 176 Current docking state indicator */
93  u32 sxsw; /* Offset 180 Display Switch notification on Sx State
94  * resume
95  */
96  u32 evts; /* Offset 184 Events supported by ASL */
97  u32 cnot; /* Offset 188 Current OS Notification */
98  u32 nrdy; /* Offset 192 Reasons for DRDY = 0 */
99  u32 ddl9; /* Offset 196 Extended Supported display device 1 */
100  u32 dd10; /* Offset 200 Extended Supported display device 2 */
101  u32 dd11; /* Offset 204 Extended Supported display device 3 */
102  u32 dd12; /* Offset 208 Extended Supported display device 4 */
103  u32 dd13; /* Offset 212 Extended Supported display device 5 */
104  u32 dd14; /* Offset 216 Extended Supported display device 6 */
105  u32 dd15; /* Offset 220 Extended Supported display device 7 */
106  u32 cpl9; /* Offset 224 Extended Currently present device 1 */
107  u32 cp10; /* Offset 228 Extended Currently present device 2 */
108  u32 cp11; /* Offset 232 Extended Currently present device 3 */
109  u32 cp12; /* Offset 236 Extended Currently present device 4 */
110  u32 cp13; /* Offset 240 Extended Currently present device 5 */
111  u32 cp14; /* Offset 244 Extended Currently present device 6 */
112  u32 cp15; /* Offset 248 Extended Currently present device 7 */
113  u8 reserved2[4]; /* Offset 252 Reserved 4 bytes */
114 } __packed opregion_mailbox1_t;
115 
116 /* mailbox 2: software sci interface */
117 typedef struct {
118  u32 scic; /* Offset 0 Software SCI function number parameters */
119  u32 parm; /* Offset 4 Software SCI function number parameters */
120  u32 dslp; /* Offset 8 Driver sleep timeout */
121  u8 reserved[244]; /* Offset 12 Reserved */
122 } __packed opregion_mailbox2_t;
123 
124 /* mailbox 3: power conservation */
125 typedef struct {
126  u32 ardy; /* Offset 0 Driver readiness */
127  u32 aslc; /* Offset 4 ASLE interrupt command / status */
128  u32 tche; /* Offset 8 Technology enabled indicator */
129  u32 alsi; /* Offset 12 Current ALS illuminance reading */
130  u32 bclp; /* Offset 16 Backlight britness to set */
131  u32 pfit; /* Offset 20 Panel fitting Request */
132  u32 cblv; /* Offset 24 Brightness Current State */
133  u16 bclm[20]; /* Offset 28 Backlight Brightness Level Duty
134  * Cycle Mapping Table
135  */
136  u32 cpfm; /* Offset 68 Panel Fitting Current Mode */
137  u32 epfm; /* Offset 72 Enabled Panel Fitting Modes */
138  u8 plut[74]; /* Offset 76 Panel Look Up Table */
139  u32 pfmb; /* Offset 150 PWM Frequency and Minimum
140  * Brightness
141  */
142  u32 ccdv; /* Offset 154 Color Correction Default Values */
143  u32 pcft; /* Offset 158 Power Conservation Features */
144  u32 srot; /* Offset 162 Supported Rotation angle */
145  u32 iuer; /* Offset 166 Intel Ultrabook Event Register */
146  u64 fdsp; /* Offset 170 FFS Display Physical address */
147  u32 fdss; /* Offset 178 FFS Display Size */
148  u32 stat; /* Offset 182 State Indicator */
149  u64 rvda; /* Offset 186 (Igd opregion offset 0x3BAh)
150  * Physical(2.0) or relative opregion
151  * (2.1+) address of Raw VBT data
152  */
153  u32 rvds; /* Offset 194 (Igd opregion offset 0x3C2h)
154  * Size of Raw VBT data
155  */
156  u8 reserved[58]; /* Offset 198 Reserved */
157 } __packed opregion_mailbox3_t;
158 
159 #define IGD_BACKLIGHT_BRIGHTNESS 0xff
160 #define IGD_INITIAL_BRIGHTNESS 0x64
161 
162 #define IGD_FIELD_VALID (1UL << 31)
163 #define IGD_WORD_FIELD_VALID (1 << 15)
164 #define IGD_PFIT_STRETCH 6
165 
166 /* mailbox 4: vbt */
167 typedef struct {
168  u8 gvd1[6*KiB];
169 } __packed opregion_vbt_t;
170 
171 /* Mailbox 5: BIOS to Driver Notification Extension */
172 typedef struct {
173  u32 phed; /* Offset 7168 Panel Header */
174  u8 bddc[256]; /* Offset 7172 Panel EDID */
175  u8 reserved[764]; /* Offset 7428 764 bytes */
176 } __packed opregion_mailbox5_t;
177 
178 /* IGD OpRegion */
179 typedef struct {
180  opregion_header_t header;
181  opregion_mailbox1_t mailbox1;
182  opregion_mailbox2_t mailbox2;
183  opregion_mailbox3_t mailbox3;
184  opregion_vbt_t vbt;
185  opregion_mailbox5_t mailbox5;
186 
187 } __packed igd_opregion_t;
188 
189 /* Intel Video BIOS (Option ROM) */
190 typedef struct {
193  u8 reserved[21];
196 } __packed optionrom_header_t;
197 
198 #define OPROM_SIGNATURE 0xaa55
199 
200 typedef struct {
207  u8 classcode[3];
211  u8 indicator;
213 } __packed optionrom_pcir_t;
214 
215 typedef struct {
216  u8 hdr_signature[20];
223  u32 hdr_aim[4];
224  u8 datahdr_signature[16];
235  u8 coreblock_biosbuild[4];
236  u8 coreblock_biossignon[155];
237 } __packed optionrom_vbt_t;
238 
240 
241 /*
242  * Returns the CBFS filename of the VBT blob.
243  *
244  * The default implementation returns "vbt.bin", but other implementations can
245  * override this.
246  */
247 const char *mainboard_vbt_filename(void);
248 
249 /*
250  * locate vbt.bin file. Returns a pointer to its content.
251  * If vbt_size is non-NULL, also return the vbt's size.
252  */
253 void *locate_vbt(size_t *vbt_size);
254 
255 #endif /* _COMMON_GMA_H_ */
#define KiB
Definition: helpers.h:75
cb_err
coreboot error codes
Definition: cb_err.h:15
const char * mainboard_vbt_filename(void)
Definition: opregion.c:17
void * locate_vbt(size_t *vbt_size)
Definition: opregion.c:25
enum cb_err intel_gma_init_igd_opregion(void)
Definition: opregion.c:310
uint64_t u64
Definition: stdint.h:54
uint32_t u32
Definition: stdint.h:51
uint16_t u16
Definition: stdint.h:48
uint8_t u8
Definition: stdint.h:45
Definition: x86.c:23
u32 cp13
Definition: opregion.h:110
opregion_mailbox5_t mailbox5
Definition: opregion.h:185
u16 device
Definition: opregion.h:203
u32 didl
Definition: opregion.h:56
u16 hdr_vbt_size
Definition: opregion.h:219
u32 cpfm
Definition: opregion.h:136
u32 ndl2
Definition: opregion.h:81
u32 cp10
Definition: opregion.h:107
u32 alsi
Definition: opregion.h:129
u32 dd14
Definition: opregion.h:104
u32 pfit
Definition: opregion.h:131
u16 vendor
Definition: opregion.h:202
u32 cpl9
Definition: opregion.h:106
u32 evts
Definition: opregion.h:96
u8 coreblock_releasestatus
Definition: opregion.h:232
u8 coreblock_integratedhw
Definition: opregion.h:234
u16 reserved2
Definition: opregion.h:212
u32 tidx
Definition: opregion.h:89
u16 length
Definition: opregion.h:205
u32 ndl3
Definition: opregion.h:82
u32 cal7
Definition: opregion.h:78
u32 ndl7
Definition: opregion.h:86
u32 ndl5
Definition: opregion.h:84
u32 sxsw
Definition: opregion.h:93
u32 cal6
Definition: opregion.h:77
u32 ardy
Definition: opregion.h:126
u32 cpl4
Definition: opregion.h:67
u16 datahdr_size
Definition: opregion.h:226
u16 hdr_version
Definition: opregion.h:217
u32 cpl2
Definition: opregion.h:65
u32 dd12
Definition: opregion.h:102
opregion_mailbox1_t mailbox1
Definition: opregion.h:181
u8 coreblock_hwsupported
Definition: opregion.h:233
u32 cdck
Definition: opregion.h:92
u32 aslc
Definition: opregion.h:127
u8 size
Definition: opregion.h:192
u32 ddl7
Definition: opregion.h:62
u32 cnot
Definition: opregion.h:97
u32 pcft
Definition: opregion.h:143
u32 scic
Definition: opregion.h:118
u32 epfm
Definition: opregion.h:137
u32 ddl5
Definition: opregion.h:60
u32 dd10
Definition: opregion.h:100
u32 chpd
Definition: opregion.h:90
u32 cal8
Definition: opregion.h:79
u32 cpl8
Definition: opregion.h:71
u32 pcon
Definition: opregion.h:31
opregion_mailbox3_t mailbox3
Definition: opregion.h:183
u32 dd11
Definition: opregion.h:101
u8 coreblock_id
Definition: opregion.h:228
u64 fdsp
Definition: opregion.h:146
u16 pcir_offset
Definition: opregion.h:194
u8 revision
Definition: opregion.h:206
u64 rvda
Definition: opregion.h:149
u32 cblv
Definition: opregion.h:132
u8 hdr_vbt_checksum
Definition: opregion.h:220
u32 ddl9
Definition: opregion.h:99
u32 cal5
Definition: opregion.h:76
opregion_vbt_t vbt
Definition: opregion.h:184
u32 ddl6
Definition: opregion.h:61
u32 dd13
Definition: opregion.h:103
u32 phed
Definition: opregion.h:173
u32 clid
Definition: opregion.h:91
u32 dslp
Definition: opregion.h:120
u32 fdss
Definition: opregion.h:147
u32 cpl3
Definition: opregion.h:66
u32 cpdl
Definition: opregion.h:64
u32 iuer
Definition: opregion.h:145
u16 datahdr_datablocksize
Definition: opregion.h:227
u32 dd15
Definition: opregion.h:105
u32 mailboxes
Definition: opregion.h:29
u8 codetype
Definition: opregion.h:210
u32 ddl8
Definition: opregion.h:63
u32 aslp
Definition: opregion.h:88
u8 hdr_reserved
Definition: opregion.h:221
u32 nadl
Definition: opregion.h:80
u32 stat
Definition: opregion.h:148
u32 cp15
Definition: opregion.h:112
u32 cadl
Definition: opregion.h:72
u32 cp14
Definition: opregion.h:111
u32 cp11
Definition: opregion.h:108
u32 hdr_vbt_datablock
Definition: opregion.h:222
u16 coderevision
Definition: opregion.h:209
u32 pfmb
Definition: opregion.h:139
u16 datahdr_version
Definition: opregion.h:225
u32 tche
Definition: opregion.h:128
u32 parm
Definition: opregion.h:119
u32 ddl2
Definition: opregion.h:57
u16 coreblock_biossize
Definition: opregion.h:230
u16 imagelength
Definition: opregion.h:208
u32 signature
Definition: opregion.h:201
u32 cal4
Definition: opregion.h:75
u32 bclp
Definition: opregion.h:130
u32 cpl6
Definition: opregion.h:69
u32 cal2
Definition: opregion.h:73
u32 ccdv
Definition: opregion.h:142
u32 cp12
Definition: opregion.h:109
u32 drdy
Definition: opregion.h:52
u16 vbt_offset
Definition: opregion.h:195
u32 csts
Definition: opregion.h:53
u32 ndl6
Definition: opregion.h:85
u16 reserved1
Definition: opregion.h:204
u32 ddl3
Definition: opregion.h:58
u16 coreblock_size
Definition: opregion.h:229
u32 cpl7
Definition: opregion.h:70
opregion_mailbox2_t mailbox2
Definition: opregion.h:182
u32 rvds
Definition: opregion.h:153
u16 signature
Definition: opregion.h:191
u32 srot
Definition: opregion.h:144
u32 dmod
Definition: opregion.h:30
opregion_header_t header
Definition: opregion.h:180
u32 ddl4
Definition: opregion.h:59
u32 ndl4
Definition: opregion.h:83
u32 cpl5
Definition: opregion.h:68
u32 cevt
Definition: opregion.h:54
u32 ndl8
Definition: opregion.h:87
u32 cal3
Definition: opregion.h:74
u32 nrdy
Definition: opregion.h:98
u32 size
Definition: opregion.h:19
u8 coreblock_biostype
Definition: opregion.h:231
u16 hdr_size
Definition: opregion.h:218