From 5646a648dfc7fcc53ff4dc86ddbc40620ee4a86c Mon Sep 17 00:00:00 2001 From: Marshall Dawson Date: Sun, 19 Jan 2020 16:12:25 -0700 Subject: soc/amd/common/psp: Make common function to print status Consolidate commands' printing of status into one static function. BUG=b:130660285 TEST: Verify PSP functionality on google/grunt Change-Id: Id8abe0d1d4ac87f6d4f625593f47bf484729906f Signed-off-by: Marshall Dawson Reviewed-on: https://chromium-review.googlesource.com/2020363 Reviewed-by: Raul E Rangel Reviewed-by: Eric Peers Tested-by: Eric Peers Reviewed-on: https://review.coreboot.org/c/coreboot/+/39998 Reviewed-by: Raul Rangel Reviewed-by: Paul Menzel Reviewed-by: Angel Pons Tested-by: build bot (Jenkins) --- src/soc/amd/common/block/psp/psp.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src/soc') diff --git a/src/soc/amd/common/block/psp/psp.c b/src/soc/amd/common/block/psp/psp.c index cf25fd1b51..0294422c3d 100644 --- a/src/soc/amd/common/block/psp/psp.c +++ b/src/soc/amd/common/block/psp/psp.c @@ -225,6 +225,21 @@ static int send_psp_command(u32 command, void *buffer) 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. + */ +static void print_cmd_status(int cmd_status, struct mbox_default_buffer *buffer) +{ + if (buffer && rd_resp_sts(buffer)) + printk(BIOS_DEBUG, "buffer status=0x%x ", rd_resp_sts(buffer)); + + if (cmd_status) + printk(BIOS_DEBUG, "%s\n", status_to_string(cmd_status)); + else + printk(BIOS_DEBUG, "OK\n"); +} + /* * Notify the PSP that DRAM is present. Upon receiving this command, the PSP * will load its OS into fenced DRAM that is not accessible to the x86 cores. @@ -243,13 +258,7 @@ int psp_notify_dram(void) cmd_status = send_psp_command(MBOX_BIOS_CMD_DRAM_INFO, &buffer); /* buffer's status shouldn't change but report it if it does */ - if (rd_resp_sts(&buffer)) - printk(BIOS_DEBUG, "buffer status=0x%x ", - rd_resp_sts(&buffer)); - if (cmd_status) - printk(BIOS_DEBUG, "%s\n", status_to_string(cmd_status)); - else - printk(BIOS_DEBUG, "OK\n"); + print_cmd_status(cmd_status, &buffer); return cmd_status; } @@ -273,13 +282,7 @@ static void psp_notify_boot_done(void *unused) cmd_status = send_psp_command(MBOX_BIOS_CMD_BOOT_DONE, &buffer); /* buffer's status shouldn't change but report it if it does */ - if (rd_resp_sts(&buffer)) - printk(BIOS_DEBUG, "buffer status=0x%x ", - rd_resp_sts(&buffer)); - if (cmd_status) - printk(BIOS_DEBUG, "%s\n", status_to_string(cmd_status)); - else - printk(BIOS_DEBUG, "OK\n"); + print_cmd_status(cmd_status, &buffer); } /* @@ -305,10 +308,7 @@ static int psp_load_blob(int type, void *addr) /* Blob commands use the buffer registers as data, not pointer to buf */ cmd_status = send_psp_command(type, addr); - if (cmd_status) - printk(BIOS_DEBUG, "%s\n", status_to_string(cmd_status)); - else - printk(BIOS_DEBUG, "OK\n"); + print_cmd_status(cmd_status, NULL); return cmd_status; } -- cgit v1.2.3