From fcd2891d6f3720836912319ea1df7fa51279f1e5 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 21 Aug 2019 14:54:31 -0600 Subject: [PATCH] Implement EC init for kbl-u --- src/mainboard/system76/kbl-u/acpi/s76.asl | 20 ++++++++++++++++++++ src/mainboard/system76/kbl-u/ramstage.c | 19 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/mainboard/system76/kbl-u/acpi/s76.asl b/src/mainboard/system76/kbl-u/acpi/s76.asl index f0250b5035..b630951b85 100644 --- a/src/mainboard/system76/kbl-u/acpi/s76.asl +++ b/src/mainboard/system76/kbl-u/acpi/s76.asl @@ -23,6 +23,26 @@ Device (S76D) { Name (_HID, "17761776") Name (_UID, 0) + Method (INIT, 0, Serialized) { + Debug = "INIT" + If (^^PCI0.LPCB.EC0.ECOK) { + //TODO: Set flags to use software control + Return (0) + } Else { + Return (1) + } + } + + Method (FINI, 0, Serialized) { + Debug = "FINI" + If (^^PCI0.LPCB.EC0.ECOK) { + //TODO: Set flags to use hardware control + Return (0) + } Else { + Return (1) + } + } + // Get Airplane LED Method (GAPL, 0, Serialized) { If (^^PCI0.LPCB.EC0.ECOK) { diff --git a/src/mainboard/system76/kbl-u/ramstage.c b/src/mainboard/system76/kbl-u/ramstage.c index 40b37b9a87..d6a7f6776b 100644 --- a/src/mainboard/system76/kbl-u/ramstage.c +++ b/src/mainboard/system76/kbl-u/ramstage.c @@ -26,9 +26,28 @@ void mainboard_silicon_init_params(FSP_SIL_UPD *params) { gpio_configure_pads(gpio_table, ARRAY_SIZE(gpio_table)); } +static int ec_cmd(u8 data) { + int i = 1000000; + while ((inb(0x66) & 2) == 2 && i > 0) { + i -= 1; + } + if (i == 0) { + return 1; + } else { + outb(data, 0x66); + return 0; + } +} + static void mainboard_init(struct device *dev) { printk(BIOS_INFO, "system76: keyboard init\n"); pc_keyboard_init(NO_AUX_DEVICE); + + // Rescan for EC devices - fixes camera toggle + printk(BIOS_INFO, "system76: EC init\n"); + if (ec_cmd(0xA8)) { + printk(BIOS_ERR, "system76: failed to send EC command 0xA8\n"); + } } static void mainboard_enable(struct device *dev) {