From e6a89935e96d5277a6ca315b2089e4616e885a6c Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Tue, 11 Mar 2025 03:58:50 +0000 Subject: [PATCH] ec/google/chromeec: Override Lid State for Factory Netboot This patch modifies the get_lid_switch() function to allow faking the lid switch state when the GBB_FLAG_DISABLE_LID_SHUTDOWN Kconfig option is enabled. When GBB_FLAG_DISABLE_LID_SHUTDOWN is enabled, the function will always return 1 (lid open), bypassing the actual lid switch state retrieval from the Embedded Controller (EC). This functionality is specifically designed to facilitate factory processes, such as netboot image downloads, where devices need to remain operational regardless of the lid's closed state. This prevents intended shutdowns triggered by a closed lid during manufacturing and testing. By setting GBB_FLAG_DISABLE_LID_SHUTDOWN, we override the actual lid status with a simulated LID status is open, which is a prerequisite for display initialization. w/o this patch: ``` [ALERT] Graphics hand-off block not found ... [INFO ] NAME | PORT | POLARITY | VALUE [INFO ] lid | undefined | high | low ``` w/ this patch: ``` [INFO ] NAME | PORT | POLARITY | VALUE [INFO ] lid | undefined | high | high ... [INFO ] framebuffer_info: bytes_per_line: 7680, bits_per_pixel: 32 [INFO ] x_res x y_res: 1920 x 1200, size: 9216000 at 0xd0000000 ``` BUG=b:333982806 TEST=Verified lid switch behavior with and without `GBB_FLAG_DISABLE_LID_SHUTDOWN` enabled. Change-Id: I89d506ab50b421b93be13b0e5e36a7ef1247e2b9 Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/86807 Reviewed-by: Jayvik Desai Reviewed-by: Caveh Jalali Reviewed-by: Ren Kuo Tested-by: build bot (Jenkins) --- src/ec/google/chromeec/switches.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/ec/google/chromeec/switches.c b/src/ec/google/chromeec/switches.c index 15f4208c32..e35e7722ea 100644 --- a/src/ec/google/chromeec/switches.c +++ b/src/ec/google/chromeec/switches.c @@ -3,13 +3,33 @@ #include #include #include +#include #if CONFIG(EC_GOOGLE_CHROMEEC_LPC) +/* + * Retrieves the state of the lid switch. + * + * The get_lid_switch() function checks if lid switch functionality is enabled + * in the coreboot configuration. If the VBOOT_LID_SWITCH Kconfig option is + * enabled, it retrieves the lid switch state from the Embedded Controller (EC). + * + * If the GBB_FLAG_DISABLE_LID_SHUTDOWN Kconfig option is enabled, this function + * will always return 1 (lid open), effectively faking the lid status. This is + * intended for stages post-romstage, particularly during display-related + * initialization, where lid-based shutdown should be suppressed. + * + * @return 1 if the lid is open, 0 if the lid is closed, or -1 if the lid switch + * functionality is not configured (VBOOT_LID_SWITCH is disabled). + */ int get_lid_switch(void) { if (!CONFIG(VBOOT_LID_SWITCH)) return -1; + /* If GBB_FLAG_DISABLE_LID_SHUTDOWN is enabled, fake the lid status as always open. */ + if (!ENV_ROMSTAGE_OR_BEFORE && vboot_is_gbb_flag_set(VB2_GBB_FLAG_DISABLE_LID_SHUTDOWN)) + return 1; /* Always return 1 (lid open) */ + return !!(google_chromeec_get_switches() & EC_SWITCH_LID_OPEN); } #endif