aboutsummaryrefslogtreecommitdiff
path: root/src/soc/amd/common/block/psp/psp.c
diff options
context:
space:
mode:
authorMarshall Dawson <marshall.dawson@amd.corp-partner.google.com>2020-03-05 11:44:24 -0700
committerFelix Held <felix-coreboot@felixheld.de>2020-04-13 12:39:12 +0000
commitd6b7236732d8cc74545849f4b81af1d33e8758e2 (patch)
tree8203c3ad9d18a49d4bc243e0bdbe02b0fad77be0 /src/soc/amd/common/block/psp/psp.c
parenta67c753d554c730c794726b1b65d07c9c383e264 (diff)
soc/amd/common/psp: Split mailbox support into v1 and v2
Family 17h redefines the PSP command and status, and therefore the steps required to send commands via the mailbox. Convert the existing version into a v1 and add a v2. New Kconfig options allow the soc to choose v1 vs. v2. The v2 PSP begins responding to the mailbox command when the full bit range is written. Define the new mailbox as a union of a u32 and a structure. Additional PSP details may be found in the NDA publication (#55758) AMD Platform Security Processor BIOS Architecture Design Guide for AMD Family 17h Processors Change the existing two soc functions that return pointers to void pointers. BUG=b:153677737 Signed-off-by: Marshall Dawson <marshalldawson3rd@gmail.com> Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: I4d358fdae07da471640856f57568059e9487f6a8 Reviewed-on: https://review.coreboot.org/c/coreboot/+/40293 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Diffstat (limited to 'src/soc/amd/common/block/psp/psp.c')
-rw-r--r--src/soc/amd/common/block/psp/psp.c85
1 files changed, 0 insertions, 85 deletions
diff --git a/src/soc/amd/common/block/psp/psp.c b/src/soc/amd/common/block/psp/psp.c
index c35f41b20c..22404be6d6 100644
--- a/src/soc/amd/common/block/psp/psp.c
+++ b/src/soc/amd/common/block/psp/psp.c
@@ -6,10 +6,8 @@
#include <cbfs.h>
#include <region_file.h>
#include <timer.h>
-#include <device/pci_def.h>
#include <bootstate.h>
#include <console/console.h>
-#include <device/pci_ops.h>
#include <amdblocks/psp.h>
#include <soc/iomap.h>
#include <soc/northbridge.h>
@@ -43,94 +41,11 @@ static const char *status_to_string(int err)
}
}
-static u32 rd_mbox_sts(struct psp_mbox *mbox)
-{
- return read32(&mbox->mbox_status);
-}
-
-static void wr_mbox_cmd(struct psp_mbox *mbox, u32 cmd)
-{
- write32(&mbox->mbox_command, cmd);
-}
-
-static u32 rd_mbox_cmd(struct psp_mbox *mbox)
-{
- return read32(&mbox->mbox_command);
-}
-
-static void wr_mbox_cmd_resp(struct psp_mbox *mbox, void *buffer)
-{
- write64(&mbox->cmd_response, (uintptr_t)buffer);
-}
-
static u32 rd_resp_sts(struct mbox_default_buffer *buffer)
{
return read32(&buffer->header.status);
}
-static int wait_initialized(struct psp_mbox *mbox)
-{
- struct stopwatch sw;
-
- stopwatch_init_msecs_expire(&sw, PSP_INIT_TIMEOUT);
-
- do {
- if (rd_mbox_sts(mbox) & STATUS_INITIALIZED)
- return 0;
- } while (!stopwatch_expired(&sw));
-
- return -PSPSTS_INIT_TIMEOUT;
-}
-
-static int wait_command(struct psp_mbox *mbox)
-{
- struct stopwatch sw;
-
- stopwatch_init_msecs_expire(&sw, PSP_CMD_TIMEOUT);
-
- do {
- if (!rd_mbox_cmd(mbox))
- return 0;
- } while (!stopwatch_expired(&sw));
-
- return -PSPSTS_CMD_TIMEOUT;
-}
-
-static int send_psp_command(u32 command, void *buffer)
-{
- struct psp_mbox *mbox = soc_get_mbox_address();
- if (!mbox)
- return -PSPSTS_NOBASE;
-
- /* check for PSP error conditions */
- if (rd_mbox_sts(mbox) & STATUS_HALT)
- return -PSPSTS_HALTED;
-
- if (rd_mbox_sts(mbox) & STATUS_RECOVERY)
- return -PSPSTS_RECOVERY;
-
- /* PSP must be finished with init and ready to accept a command */
- if (wait_initialized(mbox))
- return -PSPSTS_INIT_TIMEOUT;
-
- if (wait_command(mbox))
- return -PSPSTS_CMD_TIMEOUT;
-
- /* set address of command-response buffer and write command register */
- wr_mbox_cmd_resp(mbox, buffer);
- wr_mbox_cmd(mbox, command);
-
- /* PSP clears command register when complete */
- if (wait_command(mbox))
- return -PSPSTS_CMD_TIMEOUT;
-
- /* check delivery status */
- if (rd_mbox_sts(mbox) & (STATUS_ERROR | STATUS_TERMINATED))
- return -PSPSTS_SEND_ERROR;
-
- return 0;
-}
-
/*
* Print meaningful status to the console. Caller only passes a pointer to a
* buffer if it's expected to contain its own status.