diff options
author | Jianlong Huang <jianlong.huang@starfivetech.com> | 2022-10-10 16:07:33 +0300 |
---|---|---|
committer | Jianlong Huang <jianlong.huang@starfivetech.com> | 2022-11-03 11:31:41 +0300 |
commit | a25a1eb135b59a0a9050156831dc2bb6f735f063 (patch) | |
tree | 75a327e0aecea8cc93a74b4da0970f7efd5aba1a /board | |
parent | bdae9f6eaef5c8ced3bf90f81be78dd16248c9d4 (diff) | |
download | u-boot-a25a1eb135b59a0a9050156831dc2bb6f735f063.tar.xz |
board: starfive: Add interface to get data from eeprom
Signed-off-by: Jianlong Huang <jianlong.huang@starfivetech.com>
Diffstat (limited to 'board')
-rw-r--r-- | board/starfive/visionfive2/visionfive2-i2c-eeprom.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/board/starfive/visionfive2/visionfive2-i2c-eeprom.c b/board/starfive/visionfive2/visionfive2-i2c-eeprom.c index 0fd3fb0f66..2effc13def 100644 --- a/board/starfive/visionfive2/visionfive2-i2c-eeprom.c +++ b/board/starfive/visionfive2/visionfive2-i2c-eeprom.c @@ -765,8 +765,38 @@ u8 get_pcb_revision_from_eeprom(void) { u8 pv = 0xFF; + if (read_eeprom(eeprom_wp_buff)) + return pv; + if (einfo.pcb_revision) { pv = *einfo.pcb_revision; } return pv; } + +/** + * get_data_from_eeprom + * + * Read data from eeprom, must use int mac_read_from_eeprom(void) first + * + * offset: offset of eeprom + * len: count of data + * data: return data + * + * return the len of valid data + */ +int get_data_from_eeprom(int offset, int len, unsigned char *data) +{ + int cp_len = -1; + + if (read_eeprom(eeprom_wp_buff)) + return cp_len; + + if (offset < STARFIVE_EEPROM_HATS_SIZE_MAX) { + cp_len = (offset + len > STARFIVE_EEPROM_HATS_SIZE_MAX) ? + (offset + len - STARFIVE_EEPROM_HATS_SIZE_MAX) : len; + memcpy(data, &eeprom_wp_buff[offset], cp_len); + } + + return cp_len; +}
\ No newline at end of file |