Paweł Anikiel has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/78417?usp=email )
Change subject: drivers/wwan/fm: Wake up modem on PEWAKE# signal change ......................................................................
drivers/wwan/fm: Wake up modem on PEWAKE# signal change
Create an event handler for the PEWAKE# GPIO and notify the device driver to wake up the device.
Signed-off-by: Paweł Anikiel panikiel@google.com Change-Id: Ib5f4cdc2a3dcac419bda4ebb32c13807ac8b686d --- M src/drivers/wwan/fm/acpi_fm350gl.c 1 file changed, 58 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/17/78417/1
diff --git a/src/drivers/wwan/fm/acpi_fm350gl.c b/src/drivers/wwan/fm/acpi_fm350gl.c index 139fd15..c8db09e 100644 --- a/src/drivers/wwan/fm/acpi_fm350gl.c +++ b/src/drivers/wwan/fm/acpi_fm350gl.c @@ -2,6 +2,10 @@
#include <acpi/acpigen.h> #include <acpi/acpi_device.h> +#include <stdio.h> +#if CONFIG(GENERIC_GPIO_LIB) +#include <gpio.h> +#endif #include "chip.h" #include "soc/intel/common/block/include/intelblocks/acpi.h" #include "soc/intel/common/block/pcie/rtd3/chip.h" @@ -263,6 +267,57 @@ return "PXSX"; }
+static void +wwan_fm350gl_acpi_event_interrupts(const struct acpi_gpio *wake_gpio) +{ + acpigen_write_name("_AEI"); + acpigen_write_resourcetemplate_header(); + acpi_device_write_gpio(wake_gpio); + acpigen_write_resourcetemplate_footer(); +} + +static void +wwan_fm350gl_acpi_event_method(const struct device *dev, + const struct acpi_gpio *wake_gpio) +{ + char name[5]; + uint16_t pin; + + pin = wake_gpio->pins[0]; +#if CONFIG(GENERIC_GPIO_LIB) + pin = gpio_acpi_pin(pin); +#endif + + if (pin > 0xff) { + printk(BIOS_ERR, "%s: pins above 0xFF are unsupported\n", + __func__); + return; + } + + snprintf(name, sizeof(name), "_%c%02X", + wake_gpio->irq.mode == ACPI_IRQ_EDGE_TRIGGERED ? 'E' : 'L', pin); + + acpigen_write_method_serialized(name, 0); + acpigen_notify(acpi_device_path(dev), 0x02); /* NOTIFY_DEVICE_WAKE */ + acpigen_write_method_end(); +} + +static void wwan_fm350gl_acpi_gpio_events(const struct device *dev) +{ + const struct drivers_wwan_fm_config *config = config_of(dev); + const struct acpi_gpio *wake_gpio = &config->wake_gpio; + + /* Write into GPIO controller's scope */ +#if CONFIG(GENERIC_GPIO_LIB) + acpigen_write_scope(wake_gpio->resource ? : gpio_acpi_path(wake_gpio->pins[0])); +#else + acpigen_write_scope(wake_gpio->resource); +#endif + wwan_fm350gl_acpi_event_interrupts(wake_gpio); + wwan_fm350gl_acpi_event_method(dev, wake_gpio); + acpigen_write_scope_end(); +} + static void wwan_fm350gl_acpi_fill_ssdt(const struct device *dev) { const struct drivers_wwan_fm_config *config = config_of(dev); @@ -323,6 +378,9 @@ acpigen_write_device_end(); /* Device */ } acpigen_write_scope_end(); /* Scope */ + + if (config->wake_gpio.pin_count && config->wake_gpio.type == ACPI_GPIO_TYPE_INTERRUPT) + wwan_fm350gl_acpi_gpio_events(dev); }
static struct device_operations wwan_fm350gl_ops = {