From a363007c3bb7df81d476968ea1ea6b816a858bc5 Mon Sep 17 00:00:00 2001 From: Nicholas Chin Date: Tue, 18 Jun 2024 21:31:08 -0600 Subject: [PATCH] ec/dell/mec5035: Route power button event to host Currently, pressing the power button results in the EC powering off the system without letting the OS cleanly execute its shutdown procedures. Sending command 0x3e with an argument of 1 to the EC tells it to route power button events to the host so that the OS can determine what to do. This command was found in the ec/google/wilco code in coreboot, which is used on Dell's Latitude Chromebooks. Based on the CONFIG_EC_GOOGLE_WILCO help text, the "Wilco" ECs run a modified version of Dell's typical Latitude EC firmware, so it is likely that the two implementations share commands. Examining LPC traffic on the Latitude E6400 did show that vendor firmware was sending a 0x3e command to the EC, and reimplementing it in coreboot allowed power button events to be handled by the OS. Change-Id: I5ded315270c0e1efbbc90cfa9d9d894b872e99a2 Signed-off-by: Nicholas Chin Reviewed-on: https://review.coreboot.org/c/coreboot/+/84878 Tested-by: build bot (Jenkins) Reviewed-by: Nicholas Sudsgaard Reviewed-by: Paul Menzel --- src/ec/dell/mec5035/mec5035.c | 8 ++++++++ src/ec/dell/mec5035/mec5035.h | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/src/ec/dell/mec5035/mec5035.c b/src/ec/dell/mec5035/mec5035.c index dffbb7960c..17ac2c1dab 100644 --- a/src/ec/dell/mec5035/mec5035.c +++ b/src/ec/dell/mec5035/mec5035.c @@ -94,6 +94,13 @@ void mec5035_control_radio(enum ec_radio_dev dev, enum ec_radio_state state) ec_command(CMD_RADIO_CTRL); } +static void mec5035_power_button_route(enum ec_power_button_route target) +{ + u8 buf = (u8)target; + write_mailbox_regs(&buf, 2, 1); + ec_command(CMD_POWER_BUTTON_TO_HOST); +} + void mec5035_early_init(void) { /* If this isn't sent the EC shuts down the system after about 15 @@ -107,6 +114,7 @@ static void mec5035_init(struct device *dev) /* Unconditionally use this argument for now as this setting is probably the most sensible default out of the 3 choices. */ mec5035_mouse_touchpad(TP_PS2_MOUSE); + mec5035_power_button_route(HOST); pc_keyboard_init(NO_AUX_DEVICE); diff --git a/src/ec/dell/mec5035/mec5035.h b/src/ec/dell/mec5035/mec5035.h index 32f791cb01..5fdf56631b 100644 --- a/src/ec/dell/mec5035/mec5035.h +++ b/src/ec/dell/mec5035/mec5035.h @@ -10,6 +10,7 @@ enum mec5035_cmd { CMD_MOUSE_TP = 0x1a, CMD_RADIO_CTRL = 0x2b, + CMD_POWER_BUTTON_TO_HOST = 0x3e, CMD_CPU_OK = 0xc2, }; @@ -33,6 +34,11 @@ enum ec_radio_state { RADIO_ON }; +enum ec_power_button_route { + EC = 0, + HOST +}; + u8 mec5035_mouse_touchpad(enum ec_mouse_setting setting); void mec5035_cpu_ok(void); void mec5035_early_init(void);