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/ec/google/chromeec/smihandler.c | 14 ++++++++++++++ src/ec/google/chromeec/smm.h | 2 ++ 2 files changed, 16 insertions(+) (limited to 'src/ec') diff --git a/src/ec/google/chromeec/smihandler.c b/src/ec/google/chromeec/smihandler.c index b5ec3715ac..91b42319d5 100644 --- a/src/ec/google/chromeec/smihandler.c +++ b/src/ec/google/chromeec/smihandler.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include +#include #include #include #include @@ -45,6 +46,19 @@ static void clear_pending_events(void) ; } +void chromeec_set_usb_charge_mode(int slp_type) +{ + bool usb0_disable = 0, usb1_disable = 0; + + usb_charge_mode_from_gnvs(slp_type, &usb0_disable, &usb1_disable); + + if (usb0_disable) + google_chromeec_set_usb_charge_mode(0, USB_CHARGE_MODE_DISABLED); + + if (usb1_disable) + google_chromeec_set_usb_charge_mode(1, USB_CHARGE_MODE_DISABLED); +} + void chromeec_smi_sleep(int slp_type, uint64_t s3_mask, uint64_t s5_mask) { if (!google_chromeec_is_uhepi_supported()) { diff --git a/src/ec/google/chromeec/smm.h b/src/ec/google/chromeec/smm.h index 6f209a7061..895782d0d6 100644 --- a/src/ec/google/chromeec/smm.h +++ b/src/ec/google/chromeec/smm.h @@ -8,6 +8,8 @@ /* Process all events from the EC when EC triggered an SMI#. */ void chromeec_smi_process_events(void); +void chromeec_set_usb_charge_mode(int slp_type); + /* * Set wake masks according to sleep type, clear SCI and SMI masks, * and clear any pending events. -- cgit v1.2.3