From 471f2eefddaa715b9765b7572133c4dde3a25b0c Mon Sep 17 00:00:00 2001 From: Raul E Rangel Date: Thu, 28 Apr 2022 16:15:03 -0600 Subject: [PATCH] soc/amd/common/block/spi: Pretty print SPI status I find it difficult to constantly decode the registers when reading them. Let's print out something that's easier to parse. BUG=b:228289365 TEST=boot guybrush and see status codes printed Signed-off-by: Raul E Rangel Change-Id: I6c9d98cf43f340cf50e12c93b4c35187de9bb750 Reviewed-on: https://review.coreboot.org/c/coreboot/+/63938 Tested-by: build bot (Jenkins) Reviewed-by: Rob Barnes Reviewed-by: Fred Reitberger Reviewed-by: Felix Held --- src/soc/amd/common/block/spi/fch_spi_ctrl.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/soc/amd/common/block/spi/fch_spi_ctrl.c b/src/soc/amd/common/block/spi/fch_spi_ctrl.c index e8f20f3bc6..519503dc6d 100644 --- a/src/soc/amd/common/block/spi/fch_spi_ctrl.c +++ b/src/soc/amd/common/block/spi/fch_spi_ctrl.c @@ -39,6 +39,7 @@ static void dump_state(enum spi_dump_state_phase phase) { u8 dump_size; uintptr_t addr; + u32 status; if (!CONFIG(SOC_AMD_COMMON_BLOCK_SPI_DEBUG)) return; @@ -55,7 +56,17 @@ static void dump_state(enum spi_dump_state_phase phase) } printk(BIOS_DEBUG, "Cntrl0: %x\n", spi_read32(SPI_CNTRL0)); - printk(BIOS_DEBUG, "Status: %x\n", spi_read32(SPI_STATUS)); + + status = spi_read32(SPI_STATUS); + printk(BIOS_DEBUG, "Status: %x\n", status); + printk(BIOS_DEBUG, + " Busy: %u, FIFO Read Pointer: %u, FIFO Write Pointer: %u, Done Bytes: %u\n", + !!(status & SPI_BUSY), + (status >> SPI_FIFO_RD_PTR_SHIFT) & SPI_FIFO_RD_PTR_MASK, + (status >> SPI_FIFO_WR_PTR_SHIFT) & SPI_FIFO_WR_PTR_MASK, + (status >> SPI_DONE_BYTE_COUNT_SHIFT) & SPI_DONE_BYTE_COUNT_MASK); + + printk(BIOS_DEBUG, "CmdCode: %x\n", spi_read8(SPI_CMD_CODE)); addr = spi_get_bar() + SPI_FIFO; @@ -63,7 +74,6 @@ static void dump_state(enum spi_dump_state_phase phase) case SPI_DUMP_STATE_BEFORE_CMD: dump_size = spi_read8(SPI_TX_BYTE_COUNT); printk(BIOS_DEBUG, "TxByteCount: %x\n", dump_size); - printk(BIOS_DEBUG, "CmdCode: %x\n", spi_read8(SPI_CMD_CODE)); break; case SPI_DUMP_STATE_AFTER_CMD: dump_size = spi_read8(SPI_RX_BYTE_COUNT);