Skip to content

Commit df90789

Browse files
committed
[WIP] ec/google/chromeec: Check lid status at boot
Change-Id: I2ddd43e76850ac910e343e66ebc8b5c014ae0c5f Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
1 parent 8e4050a commit df90789

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

src/ec/google/chromeec/ec.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <security/vboot/vboot_common.h>
1818
#include <stdlib.h>
1919
#include <timer.h>
20+
#include <bootblock_common.h>
2021

2122
#include "ec.h"
2223

@@ -1441,6 +1442,23 @@ int google_chromeec_get_pd_port_caps(int port,
14411442
return 0;
14421443
}
14431444

1445+
static void google_chromeec_check_lid(void)
1446+
{
1447+
/* Check lid state - this should be called at the end of bootblock */
1448+
if (!acpi_is_wakeup_s3() && !(google_chromeec_get_switches() & EC_SWITCH_LID_OPEN)) {
1449+
/* On cold boot with lid closed, power off */
1450+
printk(BIOS_INFO, "EC: Lid is closed, powering off\n");
1451+
poweroff();
1452+
}
1453+
}
1454+
1455+
1456+
void bootblock_ec_init(void)
1457+
{
1458+
google_chromeec_check_lid();
1459+
1460+
}
1461+
14441462
void google_chromeec_init(void)
14451463
{
14461464
google_chromeec_log_uptimeinfo();

src/include/bootblock_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ void bootblock_mainboard_early_init(void);
1818
void bootblock_mainboard_init(void);
1919
void bootblock_soc_early_init(void);
2020
void bootblock_soc_init(void);
21+
void bootblock_ec_init(void);
2122

2223
/*
2324
* C code entry point for the boot block.

src/lib/bootblock.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ __weak void bootblock_mainboard_early_init(void) { /* no-op */ }
1717
__weak void bootblock_soc_early_init(void) { /* do nothing */ }
1818
__weak void bootblock_soc_init(void) { /* do nothing */ }
1919
__weak void bootblock_mainboard_init(void) { /* do nothing */ }
20+
__weak void bootblock_ec_init(void) { /* do nothing */ }
2021

2122
/*
2223
* This is a the same as the bootblock main(), with the difference that it does
@@ -58,6 +59,9 @@ void bootblock_main_with_timestamp(uint64_t base_timestamp,
5859
bootblock_soc_init();
5960
bootblock_mainboard_init();
6061

62+
/* Call EC initialization hook (weak function, can be overridden by mainboard) */
63+
bootblock_ec_init();
64+
6165
if (CONFIG(TPM_MEASURED_BOOT_INIT_BOOTBLOCK)) {
6266
bool s3resume = acpi_is_wakeup_s3();
6367
tpm_setup(s3resume);

0 commit comments

Comments
 (0)