From 3504918b43544a0f8b79881e4e67b6badfecd08a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Niew=C3=B6hner?= Date: Sun, 28 Nov 2021 23:53:55 +0100 Subject: [PATCH] mb/clevo/l140mu: make use of the new clevo/it5570e ec driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hook up the new EC driver. Tested: - Fn hotkeys work (brightness, display, volume, tp toggle, ...) - Display lid - Sleep/wake - Camera (including Fn toggle) - Bluetooth (both CNVi and PCIe card) - Wi-Fi (both CNVi and PCIe card) - CMOS options Known issues: - Touchpad toggle needs OS setup; see CB:68791 - UCSI is not implemented; see CB:68791 Change-Id: I6c4637936761cd62571b5d19fe2afd65560f49a0 Signed-off-by: Michael Niewöhner Reviewed-on: https://review.coreboot.org/c/coreboot/+/59850 Reviewed-by: Angel Pons Tested-by: build bot (Jenkins) --- src/mainboard/clevo/tgl-u/Kconfig | 4 ++++ src/mainboard/clevo/tgl-u/Makefile.inc | 4 ++++ src/mainboard/clevo/tgl-u/bootblock.c | 12 +++++++++++ src/mainboard/clevo/tgl-u/cmos.default | 11 ++++++++++ src/mainboard/clevo/tgl-u/cmos.layout | 16 +++++++++++++++ src/mainboard/clevo/tgl-u/dsdt.asl | 5 +++++ src/mainboard/clevo/tgl-u/fadt.c | 10 ++++++++++ src/mainboard/clevo/tgl-u/smihandler.c | 20 +++++++++++++++++++ .../tgl-u/variants/l140mu/acpi/variant.asl | 6 ++++++ .../clevo/tgl-u/variants/l140mu/devicetree.cb | 4 ++++ 10 files changed, 92 insertions(+) create mode 100644 src/mainboard/clevo/tgl-u/fadt.c create mode 100644 src/mainboard/clevo/tgl-u/smihandler.c create mode 100644 src/mainboard/clevo/tgl-u/variants/l140mu/acpi/variant.asl diff --git a/src/mainboard/clevo/tgl-u/Kconfig b/src/mainboard/clevo/tgl-u/Kconfig index ecdd7c123f..fbede8e252 100644 --- a/src/mainboard/clevo/tgl-u/Kconfig +++ b/src/mainboard/clevo/tgl-u/Kconfig @@ -20,6 +20,7 @@ config BOARD_CLEVO_TGLU_COMMON config BOARD_CLEVO_L140MU select BOARD_CLEVO_TGLU_COMMON + select EC_CLEVO_IT5570E select HAVE_SPD_IN_CBFS if BOARD_CLEVO_TGLU_COMMON @@ -60,4 +61,7 @@ config SEABIOS_PS2_TIMEOUT config USE_PM_ACPI_TIMER default n +config EC_CLEVO_IT5570E_MEM_BASE + default 0xfe0b0000 + endif diff --git a/src/mainboard/clevo/tgl-u/Makefile.inc b/src/mainboard/clevo/tgl-u/Makefile.inc index 2909300f64..0d57383595 100644 --- a/src/mainboard/clevo/tgl-u/Makefile.inc +++ b/src/mainboard/clevo/tgl-u/Makefile.inc @@ -1,4 +1,5 @@ CPPFLAGS_common += -I$(src)/mainboard/$(MAINBOARDDIR)/include +CPPFLAGS_common += -I$(src)/mainboard/$(MAINBOARDDIR)/variants/$(VARIANT_DIR)/acpi bootblock-y += bootblock.c bootblock-y += variants/$(VARIANT_DIR)/gpio_early.c @@ -10,5 +11,8 @@ ramstage-y += ramstage.c ramstage-y += variants/$(VARIANT_DIR)/ramstage.c ramstage-y += variants/$(VARIANT_DIR)/gpio.c ramstage-y += variants/$(VARIANT_DIR)/hda_verb.c +ramstage-$(CONFIG_HAVE_ACPI_TABLES) += fadt.c + +smm-$(CONFIG_EC_CLEVO_IT5570E) += smihandler.c subdirs-y += variants/$(VARIANT_DIR) diff --git a/src/mainboard/clevo/tgl-u/bootblock.c b/src/mainboard/clevo/tgl-u/bootblock.c index b351fbd8ef..ee6c0b31ce 100644 --- a/src/mainboard/clevo/tgl-u/bootblock.c +++ b/src/mainboard/clevo/tgl-u/bootblock.c @@ -1,9 +1,21 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include +#include +#include #include void bootblock_mainboard_early_init(void) { variant_configure_early_gpios(); + + /* Open LGMR window for EC */ + if (CONFIG(EC_CLEVO_IT5570E)) + lpc_open_mmio_window(CONFIG_EC_CLEVO_IT5570E_MEM_BASE, 64 * KiB); +} + +void bootblock_mainboard_init(void) +{ + if (CONFIG(EC_CLEVO_IT5570E)) + ec_configure_kbled_booteffect(); } diff --git a/src/mainboard/clevo/tgl-u/cmos.default b/src/mainboard/clevo/tgl-u/cmos.default index f3330e5070..a20f1b187a 100644 --- a/src/mainboard/clevo/tgl-u/cmos.default +++ b/src/mainboard/clevo/tgl-u/cmos.default @@ -1,3 +1,14 @@ boot_option=Fallback debug_level=Debug power_on_after_fail=Disable + +# EC options +ac_fan_always_on=Disable +camera_boot_state=Keep +fn_win_swap=Disable +tp_toggle_mode=CtrlAltF9 +flexicharger_on=Disable +flexicharger_start=95 +flexicharger_stop=100 +kbled_booteffect=Disable +kbled_timeout=15 diff --git a/src/mainboard/clevo/tgl-u/cmos.layout b/src/mainboard/clevo/tgl-u/cmos.layout index 4f76221f91..b31964f0a9 100644 --- a/src/mainboard/clevo/tgl-u/cmos.layout +++ b/src/mainboard/clevo/tgl-u/cmos.layout @@ -19,6 +19,20 @@ entries # coreboot config options: southbridge 410 2 e 7 power_on_after_fail +# ----------------------------------------------------------------- +# EC options +500 1 e 1 ac_fan_always_on +502 2 e 7 camera_boot_state +504 1 e 1 fn_win_swap +505 1 e 8 tp_toggle_mode + +519 1 e 1 flexicharger_on +520 8 h 0 flexicharger_start +528 8 h 0 flexicharger_stop + +543 1 e 1 kbled_booteffect +544 16 h 0 kbled_timeout + # ----------------------------------------------------------------- # vboot nv area 800 128 r 0 vbnv @@ -50,6 +64,8 @@ enumerations 7 0 Disable 7 1 Enable 7 2 Keep +8 0 CtrlAltF9 +8 1 KeycodeF7F8 # ----------------------------------------------------------------- checksums diff --git a/src/mainboard/clevo/tgl-u/dsdt.asl b/src/mainboard/clevo/tgl-u/dsdt.asl index ac02fe9d6d..10ad9df6d9 100644 --- a/src/mainboard/clevo/tgl-u/dsdt.asl +++ b/src/mainboard/clevo/tgl-u/dsdt.asl @@ -29,4 +29,9 @@ DefinitionBlock( } #include + +#if CONFIG(EC_CLEVO_IT5570E) + #include + #include +#endif } diff --git a/src/mainboard/clevo/tgl-u/fadt.c b/src/mainboard/clevo/tgl-u/fadt.c new file mode 100644 index 0000000000..28ed7e97c3 --- /dev/null +++ b/src/mainboard/clevo/tgl-u/fadt.c @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include + +void mainboard_fill_fadt(acpi_fadt_t *fadt) +{ + /* Control method power button (EC) */ + fadt->flags |= ACPI_FADT_POWER_BUTTON; +} diff --git a/src/mainboard/clevo/tgl-u/smihandler.c b/src/mainboard/clevo/tgl-u/smihandler.c new file mode 100644 index 0000000000..e53ab452a6 --- /dev/null +++ b/src/mainboard/clevo/tgl-u/smihandler.c @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include +#include +#include + +void mainboard_smi_sleep(u8 slp_typ) +{ + printk(BIOS_DEBUG, "Mainboard SMI sleep handler: %02x\n", slp_typ); + ec_smi_sleep(slp_typ); +} + +int mainboard_smi_apmc(u8 apmc) +{ + printk(BIOS_DEBUG, "Mainboard SMI APMC handler: %02x\n", apmc); + ec_smi_apmc(apmc); + + return 0; +} diff --git a/src/mainboard/clevo/tgl-u/variants/l140mu/acpi/variant.asl b/src/mainboard/clevo/tgl-u/variants/l140mu/acpi/variant.asl new file mode 100644 index 0000000000..705769aa23 --- /dev/null +++ b/src/mainboard/clevo/tgl-u/variants/l140mu/acpi/variant.asl @@ -0,0 +1,6 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#define EC_GPE_SCI GPE0_ESPI /* eSPI SCI */ +#define EC_GPE_PWRB GPE0_DW2_03 /* GPD3 */ +#define EC_GPE_SLPB GPE0_PME /* PME via eSPI */ +#define EC_GPE_LID GPE0_PME /* PME via eSPI */ diff --git a/src/mainboard/clevo/tgl-u/variants/l140mu/devicetree.cb b/src/mainboard/clevo/tgl-u/variants/l140mu/devicetree.cb index 211ad4bb54..e194ba6473 100644 --- a/src/mainboard/clevo/tgl-u/variants/l140mu/devicetree.cb +++ b/src/mainboard/clevo/tgl-u/variants/l140mu/devicetree.cb @@ -203,6 +203,10 @@ chip soc/intel/tigerlake end end device ref pch_espi on + chip ec/clevo/it5570e + device generic 0 on end + register "pl2_on_battery" = "15" + end chip drivers/pc80/tpm device pnp 0c31.0 on end end