From 20eb3506ca3d29ef59de81fb0070628582682751 Mon Sep 17 00:00:00 2001 From: Angel Pons Date: Mon, 21 Dec 2020 19:46:03 +0100 Subject: mb/prodrive/hermes: Improve board config EEPROM handling * Check and print errors returned from reading from I2C * Rework offset calculation by using more macros * Get rid of stage-specific preprocessor code * Define the EEPROM layout as struct * Make use of the defined EEPROM layout to calculate offsets * Read the UPD to disable VT-d from EEPROM Change-Id: Iad77811318c7dfd3a3a4f8d523cfa0f457f168b6 Signed-off-by: Patrick Rudolph Signed-off-by: Angel Pons Reviewed-on: https://review.coreboot.org/c/coreboot/+/48808 Reviewed-by: Patrick Rudolph Tested-by: build bot (Jenkins) --- src/mainboard/prodrive/hermes/eeprom.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/mainboard/prodrive/hermes/eeprom.c') diff --git a/src/mainboard/prodrive/hermes/eeprom.c b/src/mainboard/prodrive/hermes/eeprom.c index bff834036a..8db63f8fe4 100644 --- a/src/mainboard/prodrive/hermes/eeprom.c +++ b/src/mainboard/prodrive/hermes/eeprom.c @@ -11,8 +11,6 @@ #define I2C_ADDR_EEPROM 0x57 -#define EEPROM_OFFSET_BOARD_SETTINGS 0x1f00 - /* * Check Signature in EEPROM (M24C32-FMN6TP) * If signature is there we assume that that the content is valid @@ -39,7 +37,9 @@ int check_signature(const size_t offset, const uint64_t signature) */ static bool get_board_settings_from_eeprom(struct eeprom_board_settings *board_cfg) { - if (read_write_config(board_cfg, EEPROM_OFFSET_BOARD_SETTINGS, 0, sizeof(*board_cfg))) { + const size_t board_settings_offset = offsetof(struct eeprom_layout, BoardSettings); + + if (read_write_config(board_cfg, board_settings_offset, 0, sizeof(*board_cfg))) { printk(BIOS_ERR, "CFG EEPROM: Failed to read board settings\n"); return false; } @@ -101,3 +101,8 @@ bool read_write_config(void *blob, size_t read_offset, size_t write_offset, size return ret; } + +void report_eeprom_error(const size_t off) +{ + printk(BIOS_ERR, "MB: Failed to read from EEPROM at addr. 0x%zx\n", off); +} -- cgit v1.2.3