From 8a1fcf475401f32208c48376205a443a3acbf5c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Fri, 12 Feb 2021 18:43:36 +0200 Subject: vc/google/chromeos: Refactor GNVS init MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the support code for filling ChromeOS GNVS from acpi/chromeos-gnvs.c to vc/google/chromeos/gnvs.c. Change-Id: I7e92206561812eb3dc69739df49b6c3a93853858 Signed-off-by: Kyösti Mälkki Reviewed-on: https://review.coreboot.org/c/coreboot/+/50612 Reviewed-by: Tim Wawrzynczak Reviewed-by: Furquan Shaikh Reviewed-by: Angel Pons Reviewed-by: Lance Zhao Tested-by: build bot (Jenkins) --- src/vendorcode/google/chromeos/chromeos.h | 1 + src/vendorcode/google/chromeos/gnvs.c | 33 +++++++++++++++++++++++++++++-- src/vendorcode/google/chromeos/gnvs.h | 1 - src/vendorcode/google/chromeos/ramoops.c | 17 +--------------- 4 files changed, 33 insertions(+), 19 deletions(-) (limited to 'src/vendorcode') diff --git a/src/vendorcode/google/chromeos/chromeos.h b/src/vendorcode/google/chromeos/chromeos.h index 233078baea..2b7be90912 100644 --- a/src/vendorcode/google/chromeos/chromeos.h +++ b/src/vendorcode/google/chromeos/chromeos.h @@ -29,6 +29,7 @@ void mainboard_prepare_cr50_reset(void); void cbmem_add_vpd_calibration_data(void); void chromeos_set_me_hash(u32*, int); +void chromeos_set_ramoops(void *ram_oops, size_t size); /** * get_dsm_calibration_from_key - Gets value related to DSM calibration from VPD diff --git a/src/vendorcode/google/chromeos/gnvs.c b/src/vendorcode/google/chromeos/gnvs.c index 024dbe3bfa..6e0e9f82db 100644 --- a/src/vendorcode/google/chromeos/gnvs.c +++ b/src/vendorcode/google/chromeos/gnvs.c @@ -1,14 +1,17 @@ /* SPDX-License-Identifier: GPL-2.0-only */ +#include #include #include #include #include #include #include +#include #include #include #include +#include #include "chromeos.h" #include "gnvs.h" @@ -45,6 +48,12 @@ void chromeos_init_chromeos_acpi(chromeos_acpi_t *init) chromeos_acpi->vpd_rw_base = vpd_base; chromeos_acpi->vpd_rw_size = vpd_size; } + + /* EC can override to ECFW_RW. */ + chromeos_acpi->vbt2 = ACTIVE_ECFW_RO; + + if (CONFIG(EC_GOOGLE_CHROMEEC) && !google_ec_running_ro()) + chromeos_acpi->vbt2 = ACTIVE_ECFW_RW; } void chromeos_set_me_hash(u32 *hash, int len) @@ -57,7 +66,27 @@ void chromeos_set_me_hash(u32 *hash, int len) memcpy(chromeos_acpi->mehh, hash, len*sizeof(u32)); } -chromeos_acpi_t *chromeos_get_chromeos_acpi(void) +void chromeos_set_ramoops(void *ram_oops, size_t size) +{ + if (!chromeos_acpi) + return; + + printk(BIOS_DEBUG, "Ramoops buffer: 0x%zx@%p.\n", size, ram_oops); + chromeos_acpi->ramoops_base = (uintptr_t)ram_oops; + chromeos_acpi->ramoops_len = size; +} + +void gnvs_set_ecfw_rw(void) +{ + if (!chromeos_acpi) + return; + chromeos_acpi->vbt2 = ACTIVE_ECFW_RW; +} + +void smbios_type0_bios_version(uintptr_t address) { - return chromeos_acpi; + if (!chromeos_acpi) + return; + /* Location of smbios_type0.bios_version() string filled with spaces. */ + chromeos_acpi->vbt10 = address; } diff --git a/src/vendorcode/google/chromeos/gnvs.h b/src/vendorcode/google/chromeos/gnvs.h index 3f47a33f9a..8f8e259e8a 100644 --- a/src/vendorcode/google/chromeos/gnvs.h +++ b/src/vendorcode/google/chromeos/gnvs.h @@ -42,6 +42,5 @@ typedef struct { } __packed chromeos_acpi_t; void chromeos_init_chromeos_acpi(chromeos_acpi_t *init); -chromeos_acpi_t *chromeos_get_chromeos_acpi(void); #endif diff --git a/src/vendorcode/google/chromeos/ramoops.c b/src/vendorcode/google/chromeos/ramoops.c index 3b658b70e5..1e3d7f009f 100644 --- a/src/vendorcode/google/chromeos/ramoops.c +++ b/src/vendorcode/google/chromeos/ramoops.c @@ -7,22 +7,7 @@ #include #include #include -#include #include "chromeos.h" -#include "gnvs.h" - -static void set_ramoops(void *ram_oops, size_t size) -{ - chromeos_acpi_t *chromeos = chromeos_get_chromeos_acpi(); - if (chromeos == NULL) { - printk(BIOS_DEBUG, "chromeos gnvs is NULL. ramoops not set.\n"); - return; - } - - printk(BIOS_DEBUG, "Ramoops buffer: 0x%zx@%p.\n", size, ram_oops); - chromeos->ramoops_base = (uintptr_t)ram_oops; - chromeos->ramoops_len = size; -} static void ramoops_alloc(void *arg) { @@ -39,7 +24,7 @@ static void ramoops_alloc(void *arg) } if (CONFIG(CHROMEOS_NVS)) - set_ramoops(ram_oops, size); + chromeos_set_ramoops(ram_oops, size); } BOOT_STATE_INIT_ENTRY(BS_WRITE_TABLES, BS_ON_ENTRY, ramoops_alloc, NULL); -- cgit v1.2.3