Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/46565 )
Change subject: mb/prodrive/hermes/eeprom: Move I2C address into eeprom.c ......................................................................
mb/prodrive/hermes/eeprom: Move I2C address into eeprom.c
There's no need to pass the I2C address, as there's only one eeprom that is being used to store the board settings.
Change-Id: I958304e6ed6df05af923139d44ff4fd1de204738 Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com --- M src/mainboard/prodrive/hermes/eeprom.c M src/mainboard/prodrive/hermes/mainboard.c M src/mainboard/prodrive/hermes/ramstage.c M src/mainboard/prodrive/hermes/romstage.c M src/mainboard/prodrive/hermes/variants/baseboard/include/eeprom.h 5 files changed, 19 insertions(+), 22 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/65/46565/1
diff --git a/src/mainboard/prodrive/hermes/eeprom.c b/src/mainboard/prodrive/hermes/eeprom.c index 5aee54a..f371b64 100644 --- a/src/mainboard/prodrive/hermes/eeprom.c +++ b/src/mainboard/prodrive/hermes/eeprom.c @@ -9,15 +9,17 @@ #include <string.h> #include "variants/baseboard/include/eeprom.h"
+#define I2C_ADDR_EEPROM 0x57 + /* * Check Signature in EEPROM (M24C32-FMN6TP) * If signature is there we assume that that the content is valid */ -int check_fsp_signature(u8 addr, size_t offset, uint64_t fsp_signature) +int check_fsp_signature(size_t offset, uint64_t fsp_signature) { u8 blob[8] = {0};
- if (!read_write_config(addr, blob, offset, 0, ARRAY_SIZE(blob))) { + if (!read_write_config(blob, offset, 0, ARRAY_SIZE(blob))) { // Check Signature if (*(uint64_t *)blob == fsp_signature) { printk(BIOS_DEBUG, "CFG EEPROM: Signature valid.\n"); @@ -33,13 +35,13 @@ * Check Checksum of board settings in EEPROM (M24C32-FMN6TP) * If signature is valid we assume that the settings are also sane. */ -int check_board_settings_signature(u8 addr) +int check_board_settings_signature(void) { const size_t off = offsetof(struct eeprom_layout, BoardSettings); struct eeprom_board_settings BoardSettings; uint32_t crc;
- if (read_write_config(addr, &BoardSettings, off, 0, sizeof(BoardSettings))) { + if (read_write_config(&BoardSettings, off, 0, sizeof(BoardSettings))) { printk(BIOS_ERR, "CFG EEPROM: Failed to read board settings\n"); return 0; } @@ -54,7 +56,7 @@ }
// Read data from offset and write it to offset in UPD -bool read_write_config(u8 addr, void *blob, size_t read_offset, size_t write_offset, +bool read_write_config(void *blob, size_t read_offset, size_t write_offset, size_t size) { int ret = 0; @@ -75,7 +77,7 @@ for (size_t i = 0; i < size; i = i + 2) { u8 tmp[2] = {0};
- ret = do_smbus_process_call(SMBUS_IO_BASE, addr, 0, + ret = do_smbus_process_call(SMBUS_IO_BASE, I2C_ADDR_EEPROM, 0, swab16(read_offset + i), (uint16_t *)&tmp[0]); if (ret < 0) break; diff --git a/src/mainboard/prodrive/hermes/mainboard.c b/src/mainboard/prodrive/hermes/mainboard.c index 9c263ee..22534c9 100644 --- a/src/mainboard/prodrive/hermes/mainboard.c +++ b/src/mainboard/prodrive/hermes/mainboard.c @@ -75,9 +75,8 @@ const char *method;
/* Disable USB power on S0->S5 transition */ - if (check_board_settings_signature(I2C_ADDR_EEPROM)) { - read_write_config(I2C_ADDR_EEPROM, &value, - offsetof(struct eeprom_layout, BoardSettings) + + if (check_board_settings_signature()) { + read_write_config(&value, offsetof(struct eeprom_layout, BoardSettings) + offsetof(struct eeprom_board_settings, usb_powered_in_s5), 0, sizeof(value)); } @@ -135,10 +134,10 @@ { uint8_t value = 0;
- if (!check_board_settings_signature(I2C_ADDR_EEPROM)) + if (!check_board_settings_signature()) return;
- read_write_config(I2C_ADDR_EEPROM, &value, + read_write_config(&value, offsetof(struct eeprom_layout, BoardSettings) + offsetof(struct eeprom_board_settings, deep_s5), 0, sizeof(value)); diff --git a/src/mainboard/prodrive/hermes/ramstage.c b/src/mainboard/prodrive/hermes/ramstage.c index 2962f58..b713d4a 100644 --- a/src/mainboard/prodrive/hermes/ramstage.c +++ b/src/mainboard/prodrive/hermes/ramstage.c @@ -23,13 +23,12 @@ params->SataLedEnable = 1;
// Overwrite params - if (!check_fsp_signature(I2C_ADDR_EEPROM, - offsetof(struct eeprom_layout, FSPS_UPD), + if (!check_fsp_signature(offsetof(struct eeprom_layout, FSPS_UPD), FSPS_UPD_SIGNATURE)) return;
for (size_t i = 0; i < ARRAY_SIZE(parmas_list); i++) { - ret = read_write_config(I2C_ADDR_EEPROM, params, + ret = read_write_config(params, parmas_list[i].eeprom_offset, parmas_list[i].fsp_upd_offset, parmas_list[i].size); diff --git a/src/mainboard/prodrive/hermes/romstage.c b/src/mainboard/prodrive/hermes/romstage.c index 9202ad8..6addac5 100644 --- a/src/mainboard/prodrive/hermes/romstage.c +++ b/src/mainboard/prodrive/hermes/romstage.c @@ -22,13 +22,12 @@ cannonlake_memcfg_init(&memupd->FspmConfig, variant_memcfg_config());
// Overwrite memupd - if (!check_fsp_signature(I2C_ADDR_EEPROM, - offsetof(struct eeprom_layout, FSPM_UPD), + if (!check_fsp_signature(offsetof(struct eeprom_layout, FSPM_UPD), FSPM_UPD_SIGNATURE)) return;
for (size_t i = 0; i < ARRAY_SIZE(parmas_list); i++) { - ret = read_write_config(I2C_ADDR_EEPROM, memupd, + ret = read_write_config(memupd, parmas_list[i].eeprom_offset, parmas_list[i].fsp_upd_offset, parmas_list[i].size); diff --git a/src/mainboard/prodrive/hermes/variants/baseboard/include/eeprom.h b/src/mainboard/prodrive/hermes/variants/baseboard/include/eeprom.h index 787830e..f9e9a71 100644 --- a/src/mainboard/prodrive/hermes/variants/baseboard/include/eeprom.h +++ b/src/mainboard/prodrive/hermes/variants/baseboard/include/eeprom.h @@ -3,8 +3,6 @@ #include <fsp/api.h> #include <fsp/util.h>
-#define I2C_ADDR_EEPROM 0x57 - struct eeprom_board_settings { uint32_t signature; uint8_t secureboot; @@ -47,7 +45,7 @@ #define GET_VALUE_FSP_S_CONFIG(x) GET_VALUE(x, FSP_S_CONFIG, FspsConfig, FSPS_UPD) #define GET_VALUE_FSP_S_TEST_CONFIG(x) GET_VALUE(x, FSP_S_TEST_CONFIG, FspsTestConfig, FSPS_UPD)
-bool read_write_config(u8 addr, void *blob, size_t read_offset, size_t write_offset, +bool read_write_config(void *blob, size_t read_offset, size_t write_offset, size_t size); -int check_fsp_signature(u8 addr, size_t offset, uint64_t fsp_signature); -int check_board_settings_signature(u8 addr); +int check_fsp_signature(size_t offset, uint64_t fsp_signature); +int check_board_settings_signature(void);