diff options
author | Zong Li | 2021-06-30 23:23:48 +0800 |
---|---|---|
committer | Leo Yu-Chi Liang | 2021-07-06 20:24:25 +0800 |
commit | 05e254862f201ae93fdf1f2e4fc0de203d25d325 (patch) | |
tree | 737e407e044b851a3e8d5b751615959b16235d95 /board/sifive | |
parent | 564d630e2653901f1f115a933a7390f884b9a24f (diff) |
board: sifive: Add an interface to get PCB revision
There are different DDR parameter settings for different board
revisions. Add a new interface to get the PCB revision to determine
which DT should be selected at runtime.
Signed-off-by: Zong Li <zong.li@sifive.com>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
Diffstat (limited to 'board/sifive')
-rw-r--r-- | board/sifive/unmatched/hifive-platform-i2c-eeprom.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/board/sifive/unmatched/hifive-platform-i2c-eeprom.c b/board/sifive/unmatched/hifive-platform-i2c-eeprom.c index 9a62d324531..a2151f15e04 100644 --- a/board/sifive/unmatched/hifive-platform-i2c-eeprom.c +++ b/board/sifive/unmatched/hifive-platform-i2c-eeprom.c @@ -540,3 +540,35 @@ int mac_read_from_eeprom(void) return 0; } + +/** + * get_pcb_revision_from_eeprom - get the PCB revision + * + * Read the EEPROM to determine the board revision. + * + * This function is called before relocation, so we need to read a private + * copy of the EEPROM into a local variable on the stack. + */ +u8 get_pcb_revision_from_eeprom(void) +{ + struct __attribute__ ((__packed__)) board_eeprom { + u8 magic[MAGIC_NUMBER_BYTES]; + u8 format_ver; + u16 product_id; + u8 pcb_revision; + } be; + + int ret; + struct udevice *dev; + + ret = i2c_get_chip_for_busnum(CONFIG_SYS_EEPROM_BUS_NUM, + CONFIG_SYS_I2C_EEPROM_ADDR, + 1, + &dev); + + if (!ret) + dm_i2c_read(dev, 0, (void *)&be, + sizeof(struct board_eeprom)); + + return be.pcb_revision; +} |