Message ID | 8739b346507bd2f8a4f9c73f783eec4e849432dd.1625065973.git.zong.li@sifive.com |
---|---|
State | Accepted |
Commit | 05e254862f201ae93fdf1f2e4fc0de203d25d325 |
Delegated to: | Andes |
Headers | show |
Series | Support multi-dtb in SPL on Unmatched board | expand |
On Wed, Jun 30, 2021 at 11:23:48PM +0800, Zong Li wrote: > 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> > --- > arch/riscv/include/asm/arch-fu740/eeprom.h | 15 +++++++++ > .../unmatched/hifive-platform-i2c-eeprom.c | 32 +++++++++++++++++++ > 2 files changed, 47 insertions(+) > create mode 100644 arch/riscv/include/asm/arch-fu740/eeprom.h Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
diff --git a/arch/riscv/include/asm/arch-fu740/eeprom.h b/arch/riscv/include/asm/arch-fu740/eeprom.h new file mode 100644 index 0000000000..0e1220e558 --- /dev/null +++ b/arch/riscv/include/asm/arch-fu740/eeprom.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2021 SiFive, Inc. + * + * Zong Li <zong.li@sifve.com> + */ + +#ifndef _ASM_RISCV_EEPROM_H +#define _ASM_RISCV_EEPROM_H + +#define PCB_REVISION_REV3 0x3 + +u8 get_pcb_revision_from_eeprom(void); + +#endif /* _ASM_RISCV_EEPROM_H */ diff --git a/board/sifive/unmatched/hifive-platform-i2c-eeprom.c b/board/sifive/unmatched/hifive-platform-i2c-eeprom.c index 9a62d32453..a2151f15e0 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; +}
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> --- arch/riscv/include/asm/arch-fu740/eeprom.h | 15 +++++++++ .../unmatched/hifive-platform-i2c-eeprom.c | 32 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 arch/riscv/include/asm/arch-fu740/eeprom.h