Support multi-dtb in SPL on Unmatched board
Subsystems (2)
cover Support multi-dtb in SPL on Unmatched board
This patch set contains the support I2C platform EEPROM and multi-dtb mechanism on Unmatched board. There are two revisions of Unmatched with different DDR timing respectively, so we'd like to support multi-dtb in SPL, then it can select the right DTB at runtime according to PCB revision in I2C EEPROM to initialize the right DDR timing.
The I2C EEPROM support is refactored based on Paul Welmsley's porting and adopt many suggestions from David Abdurachmanov.
Zong Li (6):
board: sifive: unmatched: add initial support for a platform ID EEPROM
riscv: sifive: fu740: kconfig: Enable support for Opencores I2C
controller
riscv: sifive: fu740: Support i2c in spl
board: sifive: Add an interface to get PCB revision
riscv: dts: add dts for unmatched rev1
board: sifive: support spl multi-dtb on unmatched board
arch/riscv/cpu/fu740/Kconfig | 3 + arch/riscv/dts/Makefile | 2 +- arch/riscv/dts/fu740-c000-u-boot.dtsi | 4 + .../fu740-hifive-unmatched-a00-ddr-rev1.dtsi | 1489 +++++++++++++++++ .../dts/hifive-unmatched-a00-rev1-u-boot.dtsi | 7 + arch/riscv/dts/hifive-unmatched-a00-rev1.dts | 4 + arch/riscv/include/asm/arch-fu740/eeprom.h | 15 + board/sifive/unmatched/Kconfig | 1 + board/sifive/unmatched/Makefile | 1 + .../unmatched/hifive-platform-i2c-eeprom.c | 574 +++++++ board/sifive/unmatched/spl.c | 28 +- configs/sifive_unmatched_defconfig | 4 + include/configs/sifive-unmatched.h | 6 + 13 files changed, 2135 insertions(+), 3 deletions(-) create mode 100644 arch/riscv/dts/fu740-hifive-unmatched-a00-ddr-rev1.dtsi create mode 100644 arch/riscv/dts/hifive-unmatched-a00-rev1-u-boot.dtsi create mode 100644 arch/riscv/dts/hifive-unmatched-a00-rev1.dts create mode 100644 arch/riscv/include/asm/arch-fu740/eeprom.h create mode 100644 board/sifive/unmatched/hifive-platform-i2c-eeprom.c
Signature · 1 line
2.31.1
PATCH 1/6 board: sifive: unmatched: add initial support for a platform ID EEPROM
Add initial support for the PCB description EEPROM for SiFive HiFive Unmatched boards.
This implementation is refactored based on Paul Walmsley's porting and adopt the suggestions from David Abdurachmanov.
--- board/sifive/unmatched/Makefile | 1 + .../unmatched/hifive-platform-i2c-eeprom.c | 542 ++++++++++++++++++ include/configs/sifive-unmatched.h | 6 + 3 files changed, 549 insertions(+) create mode 100644 board/sifive/unmatched/hifive-platform-i2c-eeprom.c
board/sifive/unmatched/Makefile +1 -0
@@ -3,6 +3,7 @@ # Copyright (c) 2020-2021 SiFive, Inc obj-y += unmatched.o +obj-$(CONFIG_ID_EEPROM) += hifive-platform-i2c-eeprom.o ifdef CONFIG_SPL_BUILD obj-y += spl.o
board/sifive/unmatched/hifive-platform-i2c-eeprom.c new file +542 -0
542 lines not on this page · raw message
include/configs/sifive-unmatched.h +6 -0
@@ -80,4 +80,10 @@ "fdt addr ${fdtcontroladdr};"#endif /* CONFIG_SPL_BUILD */ +#define CONFIG_SYS_EEPROM_BUS_NUM 0 +#define CONFIG_SYS_I2C_EEPROM_ADDR 0x54 +#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 0x1 + +#define CONFIG_ID_EEPROM +#endif /* __SIFIVE_UNMATCHED_H */
Signature · 1 line
2.31.1
Re: [PATCH 1/6] board: sifive: unmatched: add initial support for a platform ID EEPROM
Quoted 9 lines · Zong Li
Add initial support for the PCB description EEPROM for SiFive HiFive Unmatched boards.
This implementation is refactored based on Paul Walmsley's porting and adopt the suggestions from David Abdurachmanov.
Signed-off-by Paul Walmsley <[email protected]>Signed-off-by David Abdurachmanov <[email protected]>Signed-off-by Zong Li <[email protected]>
Quoted 6 lines
--- board/sifive/unmatched/Makefile | 1 + .../unmatched/hifive-platform-i2c-eeprom.c | 542 ++++++++++++++++++ include/configs/sifive-unmatched.h | 6 + 3 files changed, 549 insertions(+) create mode 100644 board/sifive/unmatched/hifive-platform-i2c-eeprom.c
PATCH 2/6 riscv: sifive: fu740: kconfig: Enable support for Opencores I2C controller
In reply to Zong LiEnable the Opencores I2C controller on FU740
--- arch/riscv/cpu/fu740/Kconfig | 2 ++ board/sifive/unmatched/Kconfig | 1 + 2 files changed, 3 insertions(+)
arch/riscv/cpu/fu740/Kconfig +2 -0
@@ -35,3 +35,5 @@ config SIFIVE_FU740 imply SIFIVE_OTP imply DM_PWM imply PWM_SIFIVE + imply DM_I2C + imply SYS_I2C_OCORES
board/sifive/unmatched/Kconfig +1 -0
@@ -47,5 +47,6 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply PHY_MSCC imply SYSRESET imply SYSRESET_GPIO + imply CMD_I2C endif
Signature · 1 line
2.31.1
Re: [PATCH 2/6] riscv: sifive: fu740: kconfig: Enable support for Opencores I2C controller
Quoted 8 lines · Zong Li
Enable the Opencores I2C controller on FU740
Signed-off-by Zong Li <[email protected]>--- arch/riscv/cpu/fu740/Kconfig | 2 ++ board/sifive/unmatched/Kconfig | 1 + 2 files changed, 3 insertions(+)
PATCH 3/6 riscv: sifive: fu740: Support i2c in spl
In reply to Zong LiEnable SPL_I2C_SUPPORT for fu740, and add 'u-boot,dm-spl' property in i2c node.
--- arch/riscv/cpu/fu740/Kconfig | 1 + arch/riscv/dts/fu740-c000-u-boot.dtsi | 4 ++++ 2 files changed, 5 insertions(+)
arch/riscv/cpu/fu740/Kconfig +1 -0
@@ -37,3 +37,4 @@ config SIFIVE_FU740 imply PWM_SIFIVE imply DM_I2C imply SYS_I2C_OCORES + imply SPL_I2C_SUPPORT
arch/riscv/dts/fu740-c000-u-boot.dtsi +4 -0
@@ -95,6 +95,10 @@ u-boot,dm-spl; }; +&i2c0 { + u-boot,dm-spl; +}; + ð0 { assigned-clocks = <&prci PRCI_CLK_GEMGXLPLL>; assigned-clock-rates = <125125000>;
Signature · 1 line
2.31.1
Re: [PATCH 3/6] riscv: sifive: fu740: Support i2c in spl
Quoted 8 lines · Zong Li
Enable
SPL_I2C_SUPPORTfor fu740, and add 'u-boot,dm-spl' property in i2c node.Signed-off-by Zong Li <[email protected]>--- arch/riscv/cpu/fu740/Kconfig | 1 + arch/riscv/dts/fu740-c000-u-boot.dtsi | 4 ++++ 2 files changed, 5 insertions(+)
PATCH 4/6 board: sifive: Add an interface to get PCB revision
In reply to Zong LiThere 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.
--- 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
arch/riscv/include/asm/arch-fu740/eeprom.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2021 SiFive, Inc. +* +* Zong Li <[email protected]> +*/ + +#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 */
board/sifive/unmatched/hifive-platform-i2c-eeprom.c +32 -0
@@ -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; +}
Signature · 1 line
2.31.1
Re: [PATCH 4/6] board: sifive: Add an interface to get PCB revision
Quoted 10 lines · Zong Li
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 <[email protected]>--- 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
PATCH 5/6 riscv: dts: add dts for unmatched rev1
In reply to Zong LiThe difference between unmatched rev3 and rev1 is DDR timing, the rev3 uses 1866 MT/s for 16GiB, and rev1 uses 2133 MT/s for 8GiB.
--- arch/riscv/dts/Makefile | 2 +- .../fu740-hifive-unmatched-a00-ddr-rev1.dtsi | 1489 +++++++++++++++++ .../dts/hifive-unmatched-a00-rev1-u-boot.dtsi | 7 + arch/riscv/dts/hifive-unmatched-a00-rev1.dts | 4 + 4 files changed, 1501 insertions(+), 1 deletion(-) create mode 100644 arch/riscv/dts/fu740-hifive-unmatched-a00-ddr-rev1.dtsi create mode 100644 arch/riscv/dts/hifive-unmatched-a00-rev1-u-boot.dtsi create mode 100644 arch/riscv/dts/hifive-unmatched-a00-rev1.dts
arch/riscv/dts/Makefile +1 -1
@@ -4,7 +4,7 @@ dtb-$(CONFIG_TARGET_AX25_AE350) += ae350_32.dtb ae350_64.dtb dtb-$(CONFIG_TARGET_MICROCHIP_ICICLE) += microchip-mpfs-icicle-kit.dtb dtb-$(CONFIG_TARGET_QEMU_VIRT) += qemu-virt.dtb dtb-$(CONFIG_TARGET_SIFIVE_UNLEASHED) += hifive-unleashed-a00.dtb -dtb-$(CONFIG_TARGET_SIFIVE_UNMATCHED) += hifive-unmatched-a00.dtb +dtb-$(CONFIG_TARGET_SIFIVE_UNMATCHED) += hifive-unmatched-a00.dtb hifive-unmatched-a00-rev1.dtb dtb-$(CONFIG_TARGET_SIPEED_MAIX) += k210-maix-bit.dtb targets += $(dtb-y)
arch/riscv/dts/fu740-hifive-unmatched-a00-ddr-rev1.dtsi new file +1489 -0
1,489 lines not on this page · raw message
arch/riscv/dts/hifive-unmatched-a00-rev1-u-boot.dtsi new file +7 -0
@@ -0,0 +1,7 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/* + * Copyright (C) 2021 SiFive, Inc + */ + +#include "hifive-unmatched-a00-u-boot.dtsi" +#include "fu740-hifive-unmatched-a00-ddr-rev1.dtsi"
arch/riscv/dts/hifive-unmatched-a00-rev1.dts new file +4 -0
@@ -0,0 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* Copyright (c) 2021 SiFive, Inc */ + +#include "hifive-unmatched-a00.dts"
Signature · 1 line
2.31.1
Re: [PATCH 5/6] riscv: dts: add dts for unmatched rev1
Quoted 4 lines · Zong Li
The difference between unmatched rev3 and rev1 is DDR timing, the rev3 uses 1866 MT/s for 16GiB, and rev1 uses 2133 MT/s for 8GiB.
Signed-off-by Zong Li <[email protected]>
Quoted 9 lines
--- arch/riscv/dts/Makefile | 2 +- .../fu740-hifive-unmatched-a00-ddr-rev1.dtsi | 1489 +++++++++++++++++ .../dts/hifive-unmatched-a00-rev1-u-boot.dtsi | 7 + arch/riscv/dts/hifive-unmatched-a00-rev1.dts | 4 + 4 files changed, 1501 insertions(+), 1 deletion(-) create mode 100644 arch/riscv/dts/fu740-hifive-unmatched-a00-ddr-rev1.dtsi create mode 100644 arch/riscv/dts/hifive-unmatched-a00-rev1-u-boot.dtsi create mode 100644 arch/riscv/dts/hifive-unmatched-a00-rev1.dts
PATCH 6/6 board: sifive: support spl multi-dtb on unmatched board
In reply to Zong LiThere are two revisions of unmatched board with different DDR timing, we'd like to support multi-dtb mechanism in SPL, then it selects the right DTB at runtime according to PCB revision in I2C EEPROM.
--- board/sifive/unmatched/spl.c | 28 ++++++++++++++++++++++++++-- configs/sifive_unmatched_defconfig | 4 ++++ 2 files changed, 30 insertions(+), 2 deletions(-)
board/sifive/unmatched/spl.c +26 -2
@@ -10,11 +10,14 @@#include <spl.h> #include <misc.h> #include <log.h> +#include <fdtdec.h> +#include <dm/root.h> #include <linux/delay.h> #include <linux/io.h> #include <asm/gpio.h> #include <asm/arch/gpio.h> #include <asm/arch/spl.h> +#include <asm/arch/eeprom.h> #define GEM_PHY_RESET SIFIVE_GENERIC_GPIO_NR(0, 12)
@@ -26,6 +29,16 @@ int spl_board_init_f(void) {int ret; +#if defined(CONFIG_SPL_BUILD ) && defined(CONFIG_SPL_MULTI_DTB_FIT ) +int rescan; + + ret =fdtdec_resetup (&rescan); +if (!ret && rescan) { +dm_uninit (); +dm_init_and_scan (true); + } +#endif + ret =spl_soc_init ();if (ret) {debug ("HiFive Unmatched FU740 SPL init failed: %d\n" , ret);
@@ -79,7 +92,18 @@ u32 spl_boot_device(void)#ifdef CONFIG_SPL_LOAD_FIT int board_fit_config_name_match (const char *name) { -/* boot using first FIT config */ -return 0 ; +/* +* Apply different DDR params on different board revision. +* Use PCB revision which is byte 0x7 in I2C platform EEPROM +* to distinguish that. +*/ +if (get_pcb_revision_from_eeprom () ==PCB_REVISION_REV3 && + !strcmp (name,"hifive-unmatched-a00" )) +return 0 ; +else if (get_pcb_revision_from_eeprom () !=PCB_REVISION_REV3 && + !strcmp (name,"hifive-unmatched-a00-rev1" )) +return 0 ; + +return -1 ; }#endif
configs/sifive_unmatched_defconfig +4 -0
@@ -40,3 +40,7 @@ CONFIG_USB=y CONFIG_DM_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_PCI=y +CONFIG_SPL_MULTI_DTB_FIT=y +CONFIG_SPL_MULTI_DTB_FIT_NO_COMPRESSION=y +CONFIG_SPL_OF_LIST="hifive-unmatched-a00 hifive-unmatched-a00-rev1" +CONFIG_SPL_SYS_MALLOC_F_LEN=0x100000
Signature · 1 line
2.31.1
Re: [PATCH 6/6] board: sifive: support spl multi-dtb on unmatched board
Quoted 9 lines · Zong Li
There are two revisions of unmatched board with different DDR timing, we'd like to support multi-dtb mechanism in SPL, then it selects the right DTB at runtime according to PCB revision in I2C EEPROM.
Signed-off-by Zong Li <[email protected]>--- board/sifive/unmatched/spl.c | 28 ++++++++++++++++++++++++++-- configs/sifive_unmatched_defconfig | 4 ++++ 2 files changed, 30 insertions(+), 2 deletions(-)