diff --git a/config/coreboot/default/patches/0045-ec-dell-mec5035-Add-S3-suspend-SMI-handler.patch b/config/coreboot/default/patches/0045-ec-dell-mec5035-Add-S3-suspend-SMI-handler.patch new file mode 100644 index 0000000..97f1431 --- /dev/null +++ b/config/coreboot/default/patches/0045-ec-dell-mec5035-Add-S3-suspend-SMI-handler.patch @@ -0,0 +1,117 @@ +From a8c4f7004ea1c9b8268a87dd0b700c250ec4747d Mon Sep 17 00:00:00 2001 +From: Nicholas Chin +Date: Fri, 3 May 2024 11:03:32 -0600 +Subject: [PATCH] ec/dell/mec5035: Add S3 suspend SMI handler + +Change-Id: I655868aba46911d128f6c24f410dc6fdf83f3070 +Signed-off-by: Nicholas Chin +--- + src/ec/dell/mec5035/Makefile.mk | 1 + + src/ec/dell/mec5035/mec5035.c | 14 ++++++++++++++ + src/ec/dell/mec5035/mec5035.h | 19 +++++++++++++++++++ + src/ec/dell/mec5035/smihandler.c | 17 +++++++++++++++++ + 4 files changed, 51 insertions(+) + create mode 100644 src/ec/dell/mec5035/smihandler.c + +diff --git a/src/ec/dell/mec5035/Makefile.mk b/src/ec/dell/mec5035/Makefile.mk +index 4ebdd811f9..be557e4599 100644 +--- a/src/ec/dell/mec5035/Makefile.mk ++++ b/src/ec/dell/mec5035/Makefile.mk +@@ -5,5 +5,6 @@ ifeq ($(CONFIG_EC_DELL_MEC5035),y) + bootblock-y += mec5035.c + romstage-y += mec5035.c + ramstage-y += mec5035.c ++smm-y += mec5035.c smihandler.c + + endif +diff --git a/src/ec/dell/mec5035/mec5035.c b/src/ec/dell/mec5035/mec5035.c +index 68b6b2f7fb..33bf046634 100644 +--- a/src/ec/dell/mec5035/mec5035.c ++++ b/src/ec/dell/mec5035/mec5035.c +@@ -94,6 +94,20 @@ void mec5035_control_radio(enum ec_radio_dev dev, enum ec_radio_state state) + ec_command(CMD_RADIO_CTRL); + } + ++void mec5035_sleep_enable(void) ++{ ++ u8 buf[SLEEP_EN_NUM_ARGS] = {3, 0}; ++ write_mailbox_regs(buf, 2, SLEEP_EN_NUM_ARGS); ++ ec_command(CMD_SLEEP_ENABLE); ++} ++ ++void mec5035_change_wake(u8 source, enum ec_wake_change change) ++{ ++ u8 buf[ACPI_WAKEUP_NUM_ARGS] = {change, source, 0, 0x40}; ++ write_mailbox_regs(buf, 2, ACPI_WAKEUP_NUM_ARGS); ++ ec_command(CMD_ACPI_WAKEUP_CHANGE); ++} ++ + void mec5035_early_init(void) + { + /* If this isn't sent the EC shuts down the system after about 15 +diff --git a/src/ec/dell/mec5035/mec5035.h b/src/ec/dell/mec5035/mec5035.h +index fa15a9d621..069616fbc5 100644 +--- a/src/ec/dell/mec5035/mec5035.h ++++ b/src/ec/dell/mec5035/mec5035.h +@@ -4,6 +4,7 @@ + #define _EC_DELL_MEC5035_H_ + + #include ++#include + + #define NUM_REGISTERS 32 + +@@ -29,9 +30,27 @@ enum ec_radio_state { + RADIO_ON + }; + ++#define CMD_ACPI_WAKEUP_CHANGE 0x4a ++#define ACPI_WAKEUP_NUM_ARGS 4 ++enum ec_wake_change { ++ WAKE_OFF = 0, ++ WAKE_ON ++}; ++enum ec_acpi_wake_events { ++ EC_ACPI_WAKE_PWRB = BIT(0), /* Wake up by power button */ ++ EC_ACPI_WAKE_LID = BIT(1), /* Wake up by lid switch */ ++ EC_ACPI_WAKE_RTC = BIT(5), /* Wake up by RTC */ ++}; ++ ++#define CMD_SLEEP_ENABLE 0x64 ++#define SLEEP_EN_NUM_ARGS 2 ++ + u8 mec5035_mouse_touchpad(u8 setting); + void mec5035_cpu_ok(void); + void mec5035_early_init(void); + void mec5035_control_radio(enum ec_radio_dev device, enum ec_radio_state state); ++void mec5035_sleep(int slp_type); ++void mec5035_change_wake(u8 source, enum ec_wake_change change); ++void mec5035_sleep_enable(void); + + #endif /* _EC_DELL_MEC5035_H_ */ +diff --git a/src/ec/dell/mec5035/smihandler.c b/src/ec/dell/mec5035/smihandler.c +new file mode 100644 +index 0000000000..1db834773d +--- /dev/null ++++ b/src/ec/dell/mec5035/smihandler.c +@@ -0,0 +1,17 @@ ++/* SPDX-License-Identifier: GPL-2.0-only */ ++ ++#include ++#include ++#include ++#include "mec5035.h" ++ ++void mec5035_sleep(int slp_type) ++{ ++ switch (slp_type) { ++ case ACPI_S3: ++ /* System does not yet resume properly if woken by lid */ ++ mec5035_change_wake(EC_ACPI_WAKE_LID, WAKE_OFF); ++ mec5035_sleep_enable(); ++ break; ++ } ++} +-- +2.44.0 + diff --git a/config/coreboot/default/patches/0046-mb-dell-Add-S3-SMI-handler-for-SNB-IVB-Latitudes.patch b/config/coreboot/default/patches/0046-mb-dell-Add-S3-SMI-handler-for-SNB-IVB-Latitudes.patch new file mode 100644 index 0000000..34d9227 --- /dev/null +++ b/config/coreboot/default/patches/0046-mb-dell-Add-S3-SMI-handler-for-SNB-IVB-Latitudes.patch @@ -0,0 +1,133 @@ +From 9ff35368733c5e5a852ebd6295f262710553913b Mon Sep 17 00:00:00 2001 +From: Nicholas Chin +Date: Fri, 3 May 2024 16:31:12 -0600 +Subject: [PATCH] mb/dell/: Add S3 SMI handler for SNB/IVB Latitudes + +This should fix S3 suspend on these systems + +Signed-off-by: Nicholas Chin +--- + src/mainboard/dell/e5420/smihandler.c | 9 +++++++++ + src/mainboard/dell/e5520/smihandler.c | 9 +++++++++ + src/mainboard/dell/e5530/smihandler.c | 9 +++++++++ + src/mainboard/dell/e6420/smihandler.c | 9 +++++++++ + src/mainboard/dell/e6430/smihandler.c | 9 +++++++++ + src/mainboard/dell/e6520/smihandler.c | 9 +++++++++ + src/mainboard/dell/e6530/smihandler.c | 9 +++++++++ + 7 files changed, 63 insertions(+) + create mode 100644 src/mainboard/dell/e5420/smihandler.c + create mode 100644 src/mainboard/dell/e5520/smihandler.c + create mode 100644 src/mainboard/dell/e5530/smihandler.c + create mode 100644 src/mainboard/dell/e6420/smihandler.c + create mode 100644 src/mainboard/dell/e6430/smihandler.c + create mode 100644 src/mainboard/dell/e6520/smihandler.c + create mode 100644 src/mainboard/dell/e6530/smihandler.c + +diff --git a/src/mainboard/dell/e5420/smihandler.c b/src/mainboard/dell/e5420/smihandler.c +new file mode 100644 +index 0000000000..334d7b1a5f +--- /dev/null ++++ b/src/mainboard/dell/e5420/smihandler.c +@@ -0,0 +1,9 @@ ++/* SPDX-License-Identifier: GPL-2.0-only */ ++ ++#include ++#include ++ ++void mainboard_smi_sleep(u8 slp_typ) ++{ ++ mec5035_sleep(slp_typ); ++} +diff --git a/src/mainboard/dell/e5520/smihandler.c b/src/mainboard/dell/e5520/smihandler.c +new file mode 100644 +index 0000000000..334d7b1a5f +--- /dev/null ++++ b/src/mainboard/dell/e5520/smihandler.c +@@ -0,0 +1,9 @@ ++/* SPDX-License-Identifier: GPL-2.0-only */ ++ ++#include ++#include ++ ++void mainboard_smi_sleep(u8 slp_typ) ++{ ++ mec5035_sleep(slp_typ); ++} +diff --git a/src/mainboard/dell/e5530/smihandler.c b/src/mainboard/dell/e5530/smihandler.c +new file mode 100644 +index 0000000000..334d7b1a5f +--- /dev/null ++++ b/src/mainboard/dell/e5530/smihandler.c +@@ -0,0 +1,9 @@ ++/* SPDX-License-Identifier: GPL-2.0-only */ ++ ++#include ++#include ++ ++void mainboard_smi_sleep(u8 slp_typ) ++{ ++ mec5035_sleep(slp_typ); ++} +diff --git a/src/mainboard/dell/e6420/smihandler.c b/src/mainboard/dell/e6420/smihandler.c +new file mode 100644 +index 0000000000..334d7b1a5f +--- /dev/null ++++ b/src/mainboard/dell/e6420/smihandler.c +@@ -0,0 +1,9 @@ ++/* SPDX-License-Identifier: GPL-2.0-only */ ++ ++#include ++#include ++ ++void mainboard_smi_sleep(u8 slp_typ) ++{ ++ mec5035_sleep(slp_typ); ++} +diff --git a/src/mainboard/dell/e6430/smihandler.c b/src/mainboard/dell/e6430/smihandler.c +new file mode 100644 +index 0000000000..334d7b1a5f +--- /dev/null ++++ b/src/mainboard/dell/e6430/smihandler.c +@@ -0,0 +1,9 @@ ++/* SPDX-License-Identifier: GPL-2.0-only */ ++ ++#include ++#include ++ ++void mainboard_smi_sleep(u8 slp_typ) ++{ ++ mec5035_sleep(slp_typ); ++} +diff --git a/src/mainboard/dell/e6520/smihandler.c b/src/mainboard/dell/e6520/smihandler.c +new file mode 100644 +index 0000000000..334d7b1a5f +--- /dev/null ++++ b/src/mainboard/dell/e6520/smihandler.c +@@ -0,0 +1,9 @@ ++/* SPDX-License-Identifier: GPL-2.0-only */ ++ ++#include ++#include ++ ++void mainboard_smi_sleep(u8 slp_typ) ++{ ++ mec5035_sleep(slp_typ); ++} +diff --git a/src/mainboard/dell/e6530/smihandler.c b/src/mainboard/dell/e6530/smihandler.c +new file mode 100644 +index 0000000000..334d7b1a5f +--- /dev/null ++++ b/src/mainboard/dell/e6530/smihandler.c +@@ -0,0 +1,9 @@ ++/* SPDX-License-Identifier: GPL-2.0-only */ ++ ++#include ++#include ++ ++void mainboard_smi_sleep(u8 slp_typ) ++{ ++ mec5035_sleep(slp_typ); ++} +-- +2.44.0 +