From 7e1962a3cccbfce174d9e4d6d99c48def59d83f4 Mon Sep 17 00:00:00 2001 From: Matt DeVillier Date: Tue, 16 Dec 2025 19:35:47 -0600 Subject: [PATCH] mb/google/hatch: Make touchpad wake user-selectable via CFR Add CFR option "touchpad_wake" (default: false) to allow users to enable touchpad wake from sleep. Wake is disabled by default to prevent random wakeups when systems are moved while sleeping. Implementation: - Add touchpad_wake CFR option to System form - Add device alias "touchpad" to variant devicetree files - Conditionally disable wake in ramstage based on CFR option When the option is disabled (default), config->wake and config->irq.wake are set to 0, preventing the touchpad ACPI device from defining wake methods and capability. TEST=Build for KOHAKU, boot into mainline Linux (Fedora 43, kernel 6.18). Suspend the machine, close the lid, apply pressure to trackpad area. Ensure that system doesn't wake up. Change-Id: I620d7c0f0ebec8ca72ec018c93747f58735fd3e5 Co-authored-by: Alicja Michalska Signed-off-by: Matt DeVillier Reviewed-on: https://review.coreboot.org/c/coreboot/+/90491 Reviewed-by: Alicja Michalska Tested-by: build bot (Jenkins) --- src/mainboard/google/hatch/cfr.c | 14 ++++++++ src/mainboard/google/hatch/ramstage.c | 34 +++++++++++++++++++ .../hatch/variants/akemi/overridetree.cb | 2 +- .../hatch/variants/dratini/overridetree.cb | 2 +- .../hatch/variants/hatch/overridetree.cb | 2 +- .../hatch/variants/helios/overridetree.cb | 2 +- .../variants/helios_diskswap/overridetree.cb | 2 +- .../hatch/variants/jinlon/overridetree.cb | 2 +- .../hatch/variants/kindred/overridetree.cb | 2 +- .../hatch/variants/kohaku/overridetree.cb | 2 +- .../hatch/variants/mushu/overridetree.cb | 2 +- .../hatch/variants/nightfury/overridetree.cb | 2 +- .../hatch/variants/palkia/overridetree.cb | 2 +- 13 files changed, 59 insertions(+), 11 deletions(-) diff --git a/src/mainboard/google/hatch/cfr.c b/src/mainboard/google/hatch/cfr.c index 2de1ebbb7c..76f12e232c 100644 --- a/src/mainboard/google/hatch/cfr.c +++ b/src/mainboard/google/hatch/cfr.c @@ -7,6 +7,19 @@ #include #include +static const struct sm_object touchpad_wake = SM_DECLARE_ENUM({ + .opt_name = "touchpad_wake", + .ui_name = "Touchpad Wake", + .ui_helptext = "Enable or disable touchpad wake from sleep.\n" + "Disabled by default to prevent random wakeups when\n" + "the system is moved while sleeping.", + .default_value = 0, + .values = (const struct sm_enum_value[]) { + { "Disabled", 0 }, + { "Enabled", 1 }, + SM_ENUM_VALUE_END }, +}); + static struct sm_obj_form system = { .ui_name = "System", .obj_list = (const struct sm_object *[]) { @@ -21,6 +34,7 @@ static struct sm_obj_form system = { &pciexp_l1ss, &pciexp_speed, &s0ix_enable, + &touchpad_wake, &vtd, NULL }, diff --git a/src/mainboard/google/hatch/ramstage.c b/src/mainboard/google/hatch/ramstage.c index 6cce734c90..c91ce7c449 100644 --- a/src/mainboard/google/hatch/ramstage.c +++ b/src/mainboard/google/hatch/ramstage.c @@ -1,9 +1,15 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include +#include +#include +#include #include +#include +#include #include #include +#include #include void mainboard_silicon_init_params(FSPS_UPD *supd) @@ -26,6 +32,33 @@ void __weak variant_mainboard_enable(struct device *dev) /* Override mainboard settings per board */ } +static void update_touchpad_wake_config(void) +{ + const struct device *touchpad = DEV_PTR(touchpad); + if (!touchpad || !touchpad->chip_info) + return; + + /* Check CFR option for touchpad wake */ + unsigned int touchpad_wake_enabled = get_uint_option("touchpad_wake", 0); + + printk(BIOS_DEBUG, "Touchpad wake: %s\n", touchpad_wake_enabled?"enabled":"disabled"); + + /* Modify devicetree config directly */ + struct drivers_i2c_generic_config *config = + (struct drivers_i2c_generic_config *)touchpad->chip_info; + if (!touchpad_wake_enabled) { + /* Disable wake GPE and wake flag in IRQ descriptor */ + config->wake = 0; + config->irq.wake = 0; + + /* Reconfigure GPIO pad to remove wake capability */ + const struct pad_config touchpad_gpio[] = { + PAD_CFG_GPI_APIC(GPP_A21, NONE, DEEP, LEVEL, INVERT), + }; + gpio_configure_pads(touchpad_gpio, ARRAY_SIZE(touchpad_gpio)); + } +} + static void mainboard_init(struct device *dev) { mainboard_ec_init(); @@ -35,6 +68,7 @@ static void mainboard_enable(struct device *dev) { dev->ops->init = mainboard_init; variant_mainboard_enable(dev); + update_touchpad_wake_config(); } static void mainboard_chip_init(void *chip_info) diff --git a/src/mainboard/google/hatch/variants/akemi/overridetree.cb b/src/mainboard/google/hatch/variants/akemi/overridetree.cb index 1102c8731b..0510844e26 100644 --- a/src/mainboard/google/hatch/variants/akemi/overridetree.cb +++ b/src/mainboard/google/hatch/variants/akemi/overridetree.cb @@ -120,7 +120,7 @@ chip soc/intel/cannonlake register "irq" = "ACPI_IRQ_WAKE_LEVEL_LOW(GPP_A21_IRQ)" register "wake" = "GPE0_DW0_21" register "detect" = "1" - device i2c 15 on end + device i2c 15 alias touchpad on end end chip drivers/i2c/hid register "generic.hid" = ""SYNA0000"" diff --git a/src/mainboard/google/hatch/variants/dratini/overridetree.cb b/src/mainboard/google/hatch/variants/dratini/overridetree.cb index 5ae9481f7e..b160a9161a 100644 --- a/src/mainboard/google/hatch/variants/dratini/overridetree.cb +++ b/src/mainboard/google/hatch/variants/dratini/overridetree.cb @@ -80,7 +80,7 @@ chip soc/intel/cannonlake register "irq" = "ACPI_IRQ_WAKE_LEVEL_LOW(GPP_A21_IRQ)" register "wake" = "GPE0_DW0_21" register "detect" = "1" - device i2c 15 on end + device i2c 15 alias touchpad on end end end device ref i2c1 on diff --git a/src/mainboard/google/hatch/variants/hatch/overridetree.cb b/src/mainboard/google/hatch/variants/hatch/overridetree.cb index 36f489516b..23b0be2a98 100644 --- a/src/mainboard/google/hatch/variants/hatch/overridetree.cb +++ b/src/mainboard/google/hatch/variants/hatch/overridetree.cb @@ -79,7 +79,7 @@ chip soc/intel/cannonlake register "desc" = ""ELAN Touchpad"" register "irq" = "ACPI_IRQ_WAKE_LEVEL_LOW(GPP_A21_IRQ)" register "wake" = "GPE0_DW0_21" - device i2c 15 on end + device i2c 15 alias touchpad on end end end device ref i2c1 on diff --git a/src/mainboard/google/hatch/variants/helios/overridetree.cb b/src/mainboard/google/hatch/variants/helios/overridetree.cb index c9f0caeb0d..880ba21c18 100644 --- a/src/mainboard/google/hatch/variants/helios/overridetree.cb +++ b/src/mainboard/google/hatch/variants/helios/overridetree.cb @@ -90,7 +90,7 @@ chip soc/intel/cannonlake register "desc" = ""ELAN Touchpad"" register "irq" = "ACPI_IRQ_WAKE_LEVEL_LOW(GPP_A21_IRQ)" register "wake" = "GPE0_DW0_21" - device i2c 15 on end + device i2c 15 alias touchpad on end end end device ref i2c1 on diff --git a/src/mainboard/google/hatch/variants/helios_diskswap/overridetree.cb b/src/mainboard/google/hatch/variants/helios_diskswap/overridetree.cb index b4421b0ec6..91fa294619 100644 --- a/src/mainboard/google/hatch/variants/helios_diskswap/overridetree.cb +++ b/src/mainboard/google/hatch/variants/helios_diskswap/overridetree.cb @@ -104,7 +104,7 @@ chip soc/intel/cannonlake register "desc" = ""ELAN Touchpad"" register "irq" = "ACPI_IRQ_WAKE_LEVEL_LOW(GPP_A21_IRQ)" register "wake" = "GPE0_DW0_21" - device i2c 15 on end + device i2c 15 alias touchpad on end end end device ref i2c1 on diff --git a/src/mainboard/google/hatch/variants/jinlon/overridetree.cb b/src/mainboard/google/hatch/variants/jinlon/overridetree.cb index 4f861c9ba1..79e7aff362 100644 --- a/src/mainboard/google/hatch/variants/jinlon/overridetree.cb +++ b/src/mainboard/google/hatch/variants/jinlon/overridetree.cb @@ -110,7 +110,7 @@ chip soc/intel/cannonlake register "irq" = "ACPI_IRQ_WAKE_LEVEL_LOW(GPP_A21_IRQ)" register "wake" = "GPE0_DW0_21" register "detect" = "1" - device i2c 15 on end + device i2c 15 alias touchpad on end end end device ref i2c1 on diff --git a/src/mainboard/google/hatch/variants/kindred/overridetree.cb b/src/mainboard/google/hatch/variants/kindred/overridetree.cb index f47fce0405..c6c478ebb9 100644 --- a/src/mainboard/google/hatch/variants/kindred/overridetree.cb +++ b/src/mainboard/google/hatch/variants/kindred/overridetree.cb @@ -116,7 +116,7 @@ chip soc/intel/cannonlake register "irq" = "ACPI_IRQ_WAKE_LEVEL_LOW(GPP_A21_IRQ)" register "wake" = "GPE0_DW0_21" register "detect" = "1" - device i2c 15 on end + device i2c 15 alias touchpad on end end chip drivers/i2c/hid register "generic.hid" = ""SYNA0000"" diff --git a/src/mainboard/google/hatch/variants/kohaku/overridetree.cb b/src/mainboard/google/hatch/variants/kohaku/overridetree.cb index f00d9bb9d5..59704cafa1 100644 --- a/src/mainboard/google/hatch/variants/kohaku/overridetree.cb +++ b/src/mainboard/google/hatch/variants/kohaku/overridetree.cb @@ -129,7 +129,7 @@ chip soc/intel/cannonlake register "generic.detect" = "1" register "generic.wake" = "GPE0_DW0_21" register "hid_desc_reg_offset" = "0x20" - device i2c 0x20 on end + device i2c 0x20 alias touchpad on end end end device ref i2c1 on diff --git a/src/mainboard/google/hatch/variants/mushu/overridetree.cb b/src/mainboard/google/hatch/variants/mushu/overridetree.cb index 8766c9ec3a..f3b98ecc09 100644 --- a/src/mainboard/google/hatch/variants/mushu/overridetree.cb +++ b/src/mainboard/google/hatch/variants/mushu/overridetree.cb @@ -97,7 +97,7 @@ chip soc/intel/cannonlake register "desc" = ""ELAN Touchpad"" register "irq" = "ACPI_IRQ_WAKE_LEVEL_LOW(GPP_A21_IRQ)" register "wake" = "GPE0_DW0_21" - device i2c 15 on end + device i2c 15 alias touchpad on end end end device ref i2c1 on diff --git a/src/mainboard/google/hatch/variants/nightfury/overridetree.cb b/src/mainboard/google/hatch/variants/nightfury/overridetree.cb index f020f468c4..6b91bbdcdb 100644 --- a/src/mainboard/google/hatch/variants/nightfury/overridetree.cb +++ b/src/mainboard/google/hatch/variants/nightfury/overridetree.cb @@ -164,7 +164,7 @@ chip soc/intel/cannonlake register "irq" = "ACPI_IRQ_WAKE_LEVEL_LOW(GPP_A21_IRQ)" register "detect" = "1" register "wake" = "GPE0_DW0_21" - device i2c 0x15 on end + device i2c 0x15 alias touchpad on end end end device ref i2c1 on diff --git a/src/mainboard/google/hatch/variants/palkia/overridetree.cb b/src/mainboard/google/hatch/variants/palkia/overridetree.cb index 7fca6cc661..6c6b7470e4 100644 --- a/src/mainboard/google/hatch/variants/palkia/overridetree.cb +++ b/src/mainboard/google/hatch/variants/palkia/overridetree.cb @@ -101,7 +101,7 @@ chip soc/intel/cannonlake register "desc" = ""ELAN Touchpad"" register "irq" = "ACPI_IRQ_WAKE_LEVEL_LOW(GPP_A21_IRQ)" register "wake" = "GPE0_DW0_21" - device i2c 15 on end + device i2c 15 alias touchpad on end end end device ref i2c1 on