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>
This commit is contained in:
Angel Pons 2022-09-09 15:15:22 +02:00 committed by Martin Roth
parent c960564811
commit 373517cdeb
3 changed files with 41 additions and 2 deletions

View File

@ -153,7 +153,7 @@ void report_eeprom_error(const size_t off)
* 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;

View File

@ -38,6 +38,12 @@ struct __packed eeprom_board_layout {
_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 @@ struct __packed eeprom_layout {
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 @@ struct eeprom_bmc_settings *get_bmc_settings(void);
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) \

View File

@ -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 @@ struct chip_operations mainboard_ops = {
.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 @@ static void mainboard_early(void *unused)
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);