coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
sense.c
Go to the documentation of this file.
1
/* SPDX-License-Identifier: GPL-2.0-only */
2
3
#include <
ec/acpi/ec.h
>
4
5
#include "
h8.h
"
6
7
/**
8
* Return the EC sense status register state.
9
*
10
* Observations showed the sense registers are all zero until the EC populates
11
* them after some time. Likely the EC sets all bits to it's valid state at
12
* once, but there's no prove as the firmware isn't available.
13
*
14
* Wait for any register having at least one bit set.
15
* Unlikely that all register will be zero after booting has finished.
16
*
17
* @return 1 if the EC provides valid data in sense status registers
18
*/
19
int
h8_get_sense_ready
(
void
)
20
{
21
static
const
u8
regs
[] = {
H8_STATUS0
,
H8_STATUS1
,
H8_STATUS2
,
22
H8_STATUS3
};
23
24
for
(
size_t
i = 0; i <
ARRAY_SIZE
(
regs
); i++) {
25
if
(
ec_read
(
regs
[i]))
26
return
1;
27
}
28
29
return
0;
30
}
31
32
/**
33
* Return the state of Fn key.
34
* Only valid if h8_get_sense_ready (see above) returns true.
35
*
36
* @return 1 if the key is pressed.
37
*/
38
int
h8_get_fn_key
(
void
)
39
{
40
return
ec_read
(
H8_STATUS0
) &
H8_STATUS0_FN_KEY_DOWN
;
41
}
ARRAY_SIZE
#define ARRAY_SIZE(a)
Definition:
helpers.h:12
ec_read
u8 ec_read(u8 addr)
Definition:
ec.c:107
ec.h
h8.h
H8_STATUS0_FN_KEY_DOWN
#define H8_STATUS0_FN_KEY_DOWN
Definition:
h8.h:130
H8_STATUS3
#define H8_STATUS3
Definition:
h8.h:133
H8_STATUS2
#define H8_STATUS2
Definition:
h8.h:132
H8_STATUS1
#define H8_STATUS1
Definition:
h8.h:131
H8_STATUS0
#define H8_STATUS0
Definition:
h8.h:129
h8_get_sense_ready
int h8_get_sense_ready(void)
Return the EC sense status register state.
Definition:
sense.c:19
h8_get_fn_key
int h8_get_fn_key(void)
Return the state of Fn key.
Definition:
sense.c:38
u8
uint8_t u8
Definition:
stdint.h:45
regs
Definition:
transition.h:92
src
ec
lenovo
h8
sense.c
Generated by
1.9.1