From 583d531bd68366fb0eadc9799584318bf415a602 Mon Sep 17 00:00:00 2001 From: Felix Held Date: Tue, 9 Feb 2021 20:04:33 +0100 Subject: [PATCH] soc/amd/common/block/psp: factor out soc_get_psp_base_address Signed-off-by: Felix Held Change-Id: Ib73ac92e69f1be5852a1406ba714acb6a8a04989 Reviewed-on: https://review.coreboot.org/c/coreboot/+/50447 Tested-by: build bot (Jenkins) Reviewed-by: Raul Rangel --- src/soc/amd/common/block/psp/psp_gen2.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/soc/amd/common/block/psp/psp_gen2.c b/src/soc/amd/common/block/psp/psp_gen2.c index ef71d5b42a..0972131fb3 100644 --- a/src/soc/amd/common/block/psp/psp_gen2.c +++ b/src/soc/amd/common/block/psp/psp_gen2.c @@ -10,16 +10,19 @@ #define PSP_MAILBOX_OFFSET 0x10570 +static uintptr_t soc_get_psp_base_address(void) +{ + uintptr_t psp_mmio = rdmsr(MSR_PSP_ADDR).lo; + if (!psp_mmio) + printk(BIOS_WARNING, "PSP: MSR_PSP_ADDR uninitialized\n"); + return psp_mmio; +} + void *soc_get_mbox_address(void) { - uintptr_t psp_mmio; - - psp_mmio = rdmsr(MSR_PSP_ADDR).lo; - if (!psp_mmio) { - printk(BIOS_WARNING, "PSP: MSR_PSP_ADDR uninitialized\n"); + uintptr_t psp_mmio = soc_get_psp_base_address(); + if (!psp_mmio) return 0; - } - return (void *)(psp_mmio + PSP_MAILBOX_OFFSET); }