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 <alicja.michalska@9elements.com>
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/90491
Reviewed-by: Alicja Michalska <ahplka19@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Matt DeVillier 2025-12-16 19:35:47 -06:00
commit 7e1962a3cc
13 changed files with 59 additions and 11 deletions

View file

@ -7,6 +7,19 @@
#include <intelblocks/cfr.h>
#include <soc/cfr.h>
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
},

View file

@ -1,9 +1,15 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <baseboard/variants.h>
#include <console/console.h>
#include <device/device.h>
#include <drivers/i2c/generic/chip.h>
#include <ec/ec.h>
#include <intelblocks/gpio.h>
#include <option.h>
#include <soc/gpio.h>
#include <soc/ramstage.h>
#include <static.h>
#include <variant/gpio.h>
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)

View file

@ -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""

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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""

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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