From 027f86e6af023b338a0f1d8a999a8f33eeacb010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Fri, 2 Dec 2022 15:30:10 +0200 Subject: ACPI: Add usb_charge_mode_from_gnvs() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Early Chromebook generations stored the information about USB port power control for S3/S5 sleepstates in GNVS, although the configuration is static. Reduce code duplication and react to ACPI S4 as if it was ACPI S5 request. Change-Id: I7e6f37a023b0e9317dcf0355dfa70e28d51cdad9 Signed-off-by: Kyösti Mälkki Reviewed-on: https://review.coreboot.org/c/coreboot/+/74524 Tested-by: build bot (Jenkins) Reviewed-by: Matt DeVillier --- src/mainboard/google/stout/Kconfig | 1 + src/mainboard/google/stout/acpi_tables.c | 8 -------- src/mainboard/google/stout/smihandler.c | 7 ++++++- 3 files changed, 7 insertions(+), 9 deletions(-) (limited to 'src/mainboard/google/stout') diff --git a/src/mainboard/google/stout/Kconfig b/src/mainboard/google/stout/Kconfig index 152c57fc2d..d6ed754de3 100644 --- a/src/mainboard/google/stout/Kconfig +++ b/src/mainboard/google/stout/Kconfig @@ -2,6 +2,7 @@ if BOARD_GOOGLE_STOUT config BOARD_SPECIFIC_OPTIONS def_bool y + select ACPI_GNVS_USB_CHARGECTL select BOARD_ROMSIZE_KB_8192 select EC_QUANTA_IT8518 select GFX_GMA_PANEL_1_ON_LVDS diff --git a/src/mainboard/google/stout/acpi_tables.c b/src/mainboard/google/stout/acpi_tables.c index 0d5f06fd17..7e6d69cfbd 100644 --- a/src/mainboard/google/stout/acpi_tables.c +++ b/src/mainboard/google/stout/acpi_tables.c @@ -9,14 +9,6 @@ void mainboard_fill_gnvs(struct global_nvs *gnvs) { - /* Disable USB ports in S3 by default */ - gnvs->s3u0 = 0; - gnvs->s3u1 = 0; - - /* Disable USB ports in S5 by default */ - gnvs->s5u0 = 0; - gnvs->s5u1 = 0; - /* EC handles all thermal and fan control on Stout. */ gnvs->tcrt = CRITICAL_TEMPERATURE; gnvs->tpsv = PASSIVE_TEMPERATURE; diff --git a/src/mainboard/google/stout/smihandler.c b/src/mainboard/google/stout/smihandler.c index 30637ab8c5..b77c73b502 100644 --- a/src/mainboard/google/stout/smihandler.c +++ b/src/mainboard/google/stout/smihandler.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ +#include #include #include #include @@ -38,6 +39,8 @@ void mainboard_smi_gpi(u32 gpi_sts) void mainboard_smi_sleep(u8 slp_typ) { + bool usb0_disable = 0, usb1_disable = 0; + /* * Tell the EC to Enable USB power for S3 if requested. * Bit0 of 0x0D/Bit0 of 0x26 @@ -47,7 +50,9 @@ void mainboard_smi_sleep(u8 slp_typ) * charge smart phone. * 1/1 USB on, yellow port in AUTO mode and didn't support wake up system. */ - if (gnvs->s3u0 != 0 || gnvs->s3u1 != 0) { + usb_charge_mode_from_gnvs(3, &usb0_disable, &usb1_disable); + + if (!usb0_disable || !usb1_disable) { ec_write(EC_PERIPH_CNTL_3, ec_read(EC_PERIPH_CNTL_3) | 0x00); ec_write(EC_USB_S3_EN, ec_read(EC_USB_S3_EN) | 0x01); printk(BIOS_DEBUG, "USB wake from S3 enabled.\n"); -- cgit v1.2.3