mb/prodrive/hermes: Rename EEPROM access functions

Change-Id: I84b9ef080f1ac91ea6f7273457b882677abf70d3
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/52885
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Angel Pons 2021-05-03 14:16:19 +02:00
parent f1e8535794
commit 10c65b4670
2 changed files with 10 additions and 10 deletions

View File

@ -21,7 +21,7 @@ int check_signature(const size_t offset, const uint64_t signature)
{ {
u8 blob[8] = {0}; u8 blob[8] = {0};
if (!read_write_config(blob, offset, ARRAY_SIZE(blob))) { if (!eeprom_read_buffer(blob, offset, ARRAY_SIZE(blob))) {
/* Check signature */ /* Check signature */
if (*(uint64_t *)blob == signature) { if (*(uint64_t *)blob == signature) {
printk(BIOS_DEBUG, "CFG EEPROM: Signature valid.\n"); printk(BIOS_DEBUG, "CFG EEPROM: Signature valid.\n");
@ -41,7 +41,7 @@ static bool get_board_settings_from_eeprom(struct eeprom_board_settings *board_c
{ {
const size_t board_settings_offset = offsetof(struct eeprom_layout, BoardSettings); const size_t board_settings_offset = offsetof(struct eeprom_layout, BoardSettings);
if (read_write_config(board_cfg, board_settings_offset, sizeof(*board_cfg))) { if (eeprom_read_buffer(board_cfg, board_settings_offset, sizeof(*board_cfg))) {
printk(BIOS_ERR, "CFG EEPROM: Failed to read board settings\n"); printk(BIOS_ERR, "CFG EEPROM: Failed to read board settings\n");
return false; return false;
} }
@ -79,7 +79,7 @@ struct eeprom_bmc_settings *get_bmc_settings(void)
static int valid = 0; static int valid = 0;
if (valid == 0) { if (valid == 0) {
if (read_write_config(&bmc_cfg, bmc_settings_offset, sizeof(bmc_cfg))) { if (eeprom_read_buffer(&bmc_cfg, bmc_settings_offset, sizeof(bmc_cfg))) {
printk(BIOS_ERR, "CFG EEPROM: Failed to read BMC settings\n"); printk(BIOS_ERR, "CFG EEPROM: Failed to read BMC settings\n");
return NULL; return NULL;
} }
@ -99,8 +99,8 @@ uint8_t get_bmc_hsi(void)
return hsi; return hsi;
} }
/* Read data from offset and write it to offset in UPD */ /* Read data from an EEPROM on SMBus and write it to a buffer */
bool read_write_config(void *blob, size_t read_offset, size_t size) bool eeprom_read_buffer(void *blob, size_t read_offset, size_t size)
{ {
int ret = 0; int ret = 0;
@ -141,7 +141,7 @@ void report_eeprom_error(const size_t off)
* Write a single byte into the EEPROM at specified offset. * Write a single byte into the EEPROM at specified offset.
* Returns true on error, false on success. * Returns true on error, false on success.
*/ */
static bool write_byte_eeprom(const uint8_t data, const uint16_t write_offset) static bool eeprom_write_byte(const uint8_t data, const uint16_t write_offset)
{ {
int ret = 0; int ret = 0;
@ -188,7 +188,7 @@ bool write_board_settings(const struct eeprom_board_layout *new_layout)
bool changed = false; bool changed = false;
/* Read old settings */ /* Read old settings */
if (read_write_config(&old_layout, off, sizeof(old_layout))) { if (eeprom_read_buffer(&old_layout, off, sizeof(old_layout))) {
printk(BIOS_ERR, "CFG EEPROM: Read operation failed\n"); printk(BIOS_ERR, "CFG EEPROM: Read operation failed\n");
return true; return true;
} }
@ -201,7 +201,7 @@ bool write_board_settings(const struct eeprom_board_layout *new_layout)
for (size_t i = 0; i < sizeof(old_layout); i++) { for (size_t i = 0; i < sizeof(old_layout); i++) {
if (old[i] != new[i]) { if (old[i] != new[i]) {
changed = true; changed = true;
if (write_byte_eeprom(new[i], off + i)) { if (eeprom_write_byte(new[i], off + i)) {
printk(BIOS_ERR, "CFG EEPROM: Write operation failed\n"); printk(BIOS_ERR, "CFG EEPROM: Write operation failed\n");
ret = true; ret = true;
break; break;

View File

@ -91,7 +91,7 @@ _Static_assert(sizeof(FSPM_UPD) <= 0x600, "FSPM_UPD too big");
_Static_assert(sizeof(FSPS_UPD) <= 0xC00, "FSPS_UPD too big"); _Static_assert(sizeof(FSPS_UPD) <= 0xC00, "FSPS_UPD too big");
_Static_assert(sizeof(struct eeprom_layout) == 0x2000, "EEPROM layout size mismatch"); _Static_assert(sizeof(struct eeprom_layout) == 0x2000, "EEPROM layout size mismatch");
bool read_write_config(void *blob, size_t read_offset, size_t size); bool eeprom_read_buffer(void *blob, size_t read_offset, size_t size);
int check_signature(const size_t offset, const uint64_t signature); int check_signature(const size_t offset, const uint64_t signature);
struct eeprom_board_settings *get_board_settings(void); struct eeprom_board_settings *get_board_settings(void);
struct eeprom_bmc_settings *get_bmc_settings(void); struct eeprom_bmc_settings *get_bmc_settings(void);
@ -103,7 +103,7 @@ bool write_board_settings(const struct eeprom_board_layout *new_layout);
do { \ do { \
typeof(dest->opt_name) __tmp; \ typeof(dest->opt_name) __tmp; \
size_t __off = offsetof(struct eeprom_layout, section_name); \ size_t __off = offsetof(struct eeprom_layout, section_name); \
bool ret = read_write_config(&__tmp, \ bool ret = eeprom_read_buffer(&__tmp, \
__off + offsetof(section_type, opt_name), \ __off + offsetof(section_type, opt_name), \
sizeof(__tmp)); \ sizeof(__tmp)); \
if (ret) { \ if (ret) { \