diff options
-rw-r--r-- | src/ec/lenovo/h8/Makefile.inc | 1 | ||||
-rw-r--r-- | src/ec/lenovo/h8/acpi/thinkpad.asl | 37 | ||||
-rw-r--r-- | src/ec/lenovo/h8/h8.c | 11 | ||||
-rw-r--r-- | src/ec/lenovo/h8/h8.h | 2 | ||||
-rw-r--r-- | src/ec/lenovo/h8/ssdt.c | 51 |
5 files changed, 102 insertions, 0 deletions
diff --git a/src/ec/lenovo/h8/Makefile.inc b/src/ec/lenovo/h8/Makefile.inc index 3d218fde74..e4408f1ac1 100644 --- a/src/ec/lenovo/h8/Makefile.inc +++ b/src/ec/lenovo/h8/Makefile.inc @@ -8,6 +8,7 @@ endif ramstage-y += h8.c ramstage-y += bluetooth.c ramstage-y += wwan.c +ramstage-$(CONFIG_HAVE_ACPI_TABLES) += ssdt.c smm-y += smm.c endif diff --git a/src/ec/lenovo/h8/acpi/thinkpad.asl b/src/ec/lenovo/h8/acpi/thinkpad.asl index eb5b60e705..de2fe68192 100644 --- a/src/ec/lenovo/h8/acpi/thinkpad.asl +++ b/src/ec/lenovo/h8/acpi/thinkpad.asl @@ -153,4 +153,41 @@ Device (HKEY) { Return (\_SB.PCI0.LPCB.EC.GSTS) } + + /* + * Returns the current state: + * Bit 0: BT HW present + * Bit 1: BT radio enabled + * Bit 2: BT state at resume + */ + Method (GBDC, 0) + { + If (HBDC) { + Store(One, Local0) + If(\_SB.PCI0.LPCB.EC.BTEB) + { + Or(Local0, 2, Local0) + } + /* FIXME: Implement state at resume, for now Enabled */ + Or(Local0, 4, Local0) + Return (Local0) + } Else { + Return (0) + } + } + + /* + * Set the current state: + * Bit 1: BT radio enabled + * Bit 2: BT state at resume + */ + Method (SBDC, 1) + { + If (HBDC) { + ShiftRight (And(Arg0, 2), 1, Local0) + Store (Local0, \_SB.PCI0.LPCB.EC.BTEB) + + /* FIXME: Store state at resume */ + } + } } diff --git a/src/ec/lenovo/h8/h8.c b/src/ec/lenovo/h8/h8.c index 58bc3dbb49..1f1655dc40 100644 --- a/src/ec/lenovo/h8/h8.c +++ b/src/ec/lenovo/h8/h8.c @@ -181,10 +181,21 @@ static void h8_init(struct device *dev) pc_keyboard_init(NO_AUX_DEVICE); } +#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES) +static const char *h8_acpi_name(const struct device *dev) +{ + return "EC"; +} +#endif + struct device_operations h8_dev_ops = { #if IS_ENABLED(CONFIG_GENERATE_SMBIOS_TABLES) .get_smbios_strings = h8_smbios_strings, #endif +#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES) + .acpi_fill_ssdt_generator = h8_ssdt_generator, + .acpi_name = h8_acpi_name, +#endif .init = h8_init, }; diff --git a/src/ec/lenovo/h8/h8.h b/src/ec/lenovo/h8/h8.h index 19b9cf60d2..4ac395a098 100644 --- a/src/ec/lenovo/h8/h8.h +++ b/src/ec/lenovo/h8/h8.h @@ -39,6 +39,8 @@ void h8_wwan_enable(int on); bool h8_wwan_nv_enable(void); bool h8_has_wwan(struct device *dev); +void h8_ssdt_generator(struct device *dev); + /* EC registers */ #define H8_CONFIG0 0x00 #define H8_CONFIG0_EVENTS_ENABLE 0x02 diff --git a/src/ec/lenovo/h8/ssdt.c b/src/ec/lenovo/h8/ssdt.c new file mode 100644 index 0000000000..35570b0b72 --- /dev/null +++ b/src/ec/lenovo/h8/ssdt.c @@ -0,0 +1,51 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2017 Patrick Rudolph <siro@das-labor.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <console/console.h> +#include <arch/acpigen.h> +#include <string.h> + +#include "h8.h" +#include "chip.h" + +static char *h8_dsdt_scope(struct device *dev, const char *scope) +{ + static char buf[DEVICE_PATH_MAX] = {}; + const char *path = acpi_device_path(dev); + + memset(buf, 0, sizeof(buf)); + snprintf(buf, sizeof(buf) - 1, "%s.%s", path, scope); + + return buf; +} + +/* + * Generates EC SSDT. + */ +void h8_ssdt_generator(struct device *dev) +{ + if (!acpi_device_path(dev)) + return; + + printk(BIOS_INFO, "ACPI: * H8\n"); + + /* Scope HKEY */ + acpigen_write_scope(h8_dsdt_scope(dev, "HKEY")); + + /* Used by thinkpad_acpi */ + acpigen_write_name_byte("HBDC", h8_has_bdc(dev) ? ONE_OP : ZERO_OP); + + acpigen_pop_len(); /* Scope HKEY */ +} |