Martin Roth has submitted this change. ( https://review.coreboot.org/c/coreboot/+/67483 )
Change subject: mb/prodrive/hermes: Write reset cause regs to EEPROM ......................................................................
mb/prodrive/hermes: Write reset cause regs to EEPROM
Write the value for reset cause registers to the EEPROM for debugging.
Change-Id: I827f38731fd868aac72103957e01aac8263f1cd3 Signed-off-by: Angel Pons th3fanbus@gmail.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/67483 Reviewed-by: Lean Sheng Tan sheng.tan@9elements.com Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/mainboard/prodrive/hermes/eeprom.c M src/mainboard/prodrive/hermes/eeprom.h M src/mainboard/prodrive/hermes/mainboard.c 3 files changed, 56 insertions(+), 2 deletions(-)
Approvals: build bot (Jenkins): Verified Lean Sheng Tan: Looks good to me, approved
diff --git a/src/mainboard/prodrive/hermes/eeprom.c b/src/mainboard/prodrive/hermes/eeprom.c index 4d67133..5defff6 100644 --- a/src/mainboard/prodrive/hermes/eeprom.c +++ b/src/mainboard/prodrive/hermes/eeprom.c @@ -153,7 +153,7 @@ * Write a single byte into the EEPROM at specified offset. * Returns true on error, false on success. */ -static bool eeprom_write_byte(const uint8_t data, const uint16_t write_offset) +bool eeprom_write_byte(const uint8_t data, const uint16_t write_offset) { int ret = 0;
diff --git a/src/mainboard/prodrive/hermes/eeprom.h b/src/mainboard/prodrive/hermes/eeprom.h index 97a1f48..6befd8e 100644 --- a/src/mainboard/prodrive/hermes/eeprom.h +++ b/src/mainboard/prodrive/hermes/eeprom.h @@ -38,6 +38,12 @@ _Static_assert(sizeof(struct eeprom_board_layout) == (617 + sizeof(uint32_t)), "struct eeprom_board_layout has invalid size!");
+struct __packed eeprom_reset_cause_regs { + uint32_t gblrst_cause0; + uint32_t gblrst_cause1; + uint32_t hpr_cause0; +}; + struct __packed eeprom_board_settings { uint32_t signature; union { @@ -89,7 +95,11 @@ uint8_t boot_order[0x200]; char board_part_number[HERMES_SN_PN_LENGTH]; char product_part_number[HERMES_SN_PN_LENGTH]; - uint8_t unused[0x680]; + union { + struct eeprom_reset_cause_regs reset_cause_regs; + uint8_t raw_reset_cause_registers[0x80]; + }; + uint8_t unused[0x600]; union { uint8_t raw_board_settings[0xf8]; struct eeprom_board_settings board_settings; @@ -111,6 +121,7 @@ const char *eeprom_read_serial(size_t offset, const char *fallback); uint8_t get_bmc_hsi(void); void report_eeprom_error(const size_t off); +bool eeprom_write_byte(const uint8_t data, const uint16_t write_offset); bool write_board_settings(const struct eeprom_board_layout *new_layout);
#define READ_EEPROM(section_type, section_name, dest, opt_name) \ diff --git a/src/mainboard/prodrive/hermes/mainboard.c b/src/mainboard/prodrive/hermes/mainboard.c index c2f8b63..e94a8bc 100644 --- a/src/mainboard/prodrive/hermes/mainboard.c +++ b/src/mainboard/prodrive/hermes/mainboard.c @@ -14,6 +14,7 @@ #include <intelblocks/pmclib.h> #include <smbios.h> #include <soc/gpio.h> +#include <soc/pm.h> #include <string.h> #include <types.h>
@@ -249,6 +250,31 @@ .enable_dev = mainboard_enable, };
+static void log_reset_causes(void) +{ + struct chipset_power_state *ps = pmc_get_power_state(); + + if (!ps) { + printk(BIOS_ERR, "chipset_power_state not found!\n"); + return; + } + + union { + struct eeprom_reset_cause_regs regs; + uint8_t raw[sizeof(struct eeprom_reset_cause_regs)]; + } reset_cause = { + .regs = { + .gblrst_cause0 = ps->gblrst_cause[0], + .gblrst_cause1 = ps->gblrst_cause[1], + .hpr_cause0 = ps->hpr_cause0, + }, + }; + + const size_t base = offsetof(struct eeprom_layout, reset_cause_regs); + for (size_t i = 0; i < ARRAY_SIZE(reset_cause.raw); i++) + eeprom_write_byte(reset_cause.raw[i], base + i); +} + /* Must happen before MPinit */ static void mainboard_early(void *unused) { @@ -273,6 +299,8 @@ READ_EEPROM_FSP_S((&supd), FspsConfig.TurboMode); config->cpu_turbo_disable = !supd.FspsConfig.TurboMode; } + + log_reset_causes(); }
BOOT_STATE_INIT_ENTRY(BS_PRE_DEVICE, BS_ON_EXIT, mainboard_early, NULL);