summaryrefslogtreecommitdiff
path: root/src/mainboard
diff options
context:
space:
mode:
authorAngel Pons <th3fanbus@gmail.com>2022-01-08 12:52:27 +0100
committerFelix Held <felix-coreboot@felixheld.de>2022-01-11 14:03:16 +0000
commit29e33551a92368ae69063a8bff1cfd80904918c9 (patch)
tree419a5946806c4d5b371d1d1c876b161691260f86 /src/mainboard
parentc7fc9d6c4cdef96998393f6fb461431f8580e0a2 (diff)
mb/google/brya: Check if descriptor is writable
Copy the `is_descriptor_writeable()` function from the `intel/adlrvp` mainboard and use it in the `configure_pmc_descriptor()` function. With this change, this function is now identical for both mainboards. Change-Id: I2ff39682ed98c6b8bc60cc2218f36f4934b9903c Signed-off-by: Angel Pons <th3fanbus@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/60939 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Subrata Banik <subratabanik@google.com> Reviewed-by: Sheng Lean Tan <sheng.tan@9elements.com>
Diffstat (limited to 'src/mainboard')
-rw-r--r--src/mainboard/google/brya/bootblock.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/mainboard/google/brya/bootblock.c b/src/mainboard/google/brya/bootblock.c
index 1651337c49..bd7100a8dc 100644
--- a/src/mainboard/google/brya/bootblock.c
+++ b/src/mainboard/google/brya/bootblock.c
@@ -1,5 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
+#include <arch/mmio.h>
#include <baseboard/variants.h>
#include <bootblock_common.h>
#include <console/console.h>
@@ -13,6 +14,32 @@
#define SI_DESC_REGION_SZ 4096
#define PMC_DESC_7_BYTE3 0xc32
+/* Flash Master 1 : HOST/BIOS */
+#define FLMSTR1 0x80
+
+/* Flash signature Offset */
+#define FLASH_SIGN_OFFSET 0x10
+#define FLMSTR_WR_SHIFT_V2 20
+#define FLASH_VAL_SIGN 0xFF0A55A
+
+/* It checks whether host(Flash Master 1) has write access to the Descriptor Region or not */
+static int is_descriptor_writeable(uint8_t *desc)
+{
+ /* Check flash has valid signature */
+ if (read32((void *)(desc + FLASH_SIGN_OFFSET)) != FLASH_VAL_SIGN) {
+ printk(BIOS_DEBUG, "Flash Descriptor is not valid\n");
+ return 0;
+ }
+
+ /* Check host has write access to the Descriptor Region */
+ if (!((read32((void *)(desc + FLMSTR1)) >> FLMSTR_WR_SHIFT_V2) & BIT(0))) {
+ printk(BIOS_DEBUG, "Host doesn't have write access to Descriptor Region\n");
+ return 0;
+ }
+
+ return 1;
+}
+
/* It updates PMC Descriptor in the Descriptor Region */
static void configure_pmc_descriptor(void)
{
@@ -29,6 +56,9 @@ static void configure_pmc_descriptor(void)
return;
}
+ if (!is_descriptor_writeable(si_desc_buf))
+ return;
+
if (si_desc_buf[PMC_DESC_7_BYTE3] != 0x40) {
printk(BIOS_DEBUG, "Update of PMC Descriptor is not required!\n");
return;