SiFive FU540 Support
Subsystems (5)
v2 cover SiFive FU540 Support
This patchset adds SiFive Freedom Unleashed (FU540) support to RISC-V U-Boot.
The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id 91882c472d8c0aef4db699d3f2de55bf43d4ae4b
All drivers namely: SiFive PRCI, SiFive Serial, and Cadance MACB Ethernet work fine on actual SiFive Unleashed board and QEMU sifive_u machine.
Changes since v1:
- Re-ordered SoB in patches with multiple SoB
- Simplified board_get_usable_ram_top() added by PATCH3
Anup Patel (7):
riscv: Rename cpu/qemu to cpu/generic
riscv: Add asm/dma-mapping.h for DMA mappings
riscv: generic: Ensure that U-Boot runs within 4GB for 64bit systems
net: macb: Fix clk API usage for RISC-V systems
clk: Add SiFive FU540 PRCI clock driver
clk: Add fixed-factor clock driver
riscv: Add SiFive FU540 board support
Atish Patra (4):
net: macb: Fix GEM hardware detection
drivers: serial_sifive: Fix baud rate calculation
drivers: serial_sifive: Skip baudrate config if no input clock
cpu: Bind timer driver for boot hart
arch/riscv/Kconfig | 6 +-
arch/riscv/cpu/{qemu => generic}/Kconfig | 2 +-
arch/riscv/cpu/{qemu => generic}/Makefile | 0
arch/riscv/cpu/{qemu => generic}/cpu.c | 0
arch/riscv/cpu/generic/dram.c | 37 ++
arch/riscv/cpu/qemu/dram.c | 17 -
arch/riscv/include/asm/dma-mapping.h | 38 ++
board/emulation/qemu-riscv/Kconfig | 4 +-
.../qemu-riscv => sifive/fu540}/Kconfig | 36 +-
board/sifive/fu540/MAINTAINERS | 9 +
board/sifive/fu540/Makefile | 5 +
board/sifive/fu540/fu540.c | 17 +
configs/sifive_fu540_defconfig | 11 +
drivers/clk/Kconfig | 1 +
drivers/clk/Makefile | 5 +-
drivers/clk/clk_fixed_factor.c | 74 +++
drivers/clk/sifive/Kconfig | 19 +
drivers/clk/sifive/Makefile | 5 +
.../clk/sifive/analogbits-wrpll-cln28hpc.h | 101 +++
drivers/clk/sifive/fu540-prci.c | 604 ++++++++++++++++++
drivers/clk/sifive/wrpll-cln28hpc.c | 390 +++++++++++
drivers/cpu/riscv_cpu.c | 7 +-
drivers/net/macb.c | 6 +-
drivers/serial/serial_sifive.c | 60 +-
include/configs/sifive-fu540.h | 43 ++
include/dt-bindings/clk/sifive-fu540-prci.h | 29 +
26 files changed, 1465 insertions(+), 61 deletions(-)
rename arch/riscv/cpu/{qemu => generic}/Kconfig (91%)
rename arch/riscv/cpu/{qemu => generic}/Makefile (100%)
rename arch/riscv/cpu/{qemu => generic}/cpu.c (100%)
create mode 100644 arch/riscv/cpu/generic/dram.c
delete mode 100644 arch/riscv/cpu/qemu/dram.c
create mode 100644 arch/riscv/include/asm/dma-mapping.h
copy board/{emulation/qemu-riscv => sifive/fu540}/Kconfig (57%)
create mode 100644 board/sifive/fu540/MAINTAINERS
create mode 100644 board/sifive/fu540/Makefile
create mode 100644 board/sifive/fu540/fu540.c
create mode 100644 configs/sifive_fu540_defconfig
create mode 100644 drivers/clk/clk_fixed_factor.c
create mode 100644 drivers/clk/sifive/Kconfig
create mode 100644 drivers/clk/sifive/Makefile
create mode 100644 drivers/clk/sifive/analogbits-wrpll-cln28hpc.h
create mode 100644 drivers/clk/sifive/fu540-prci.c
create mode 100644 drivers/clk/sifive/wrpll-cln28hpc.c
create mode 100644 include/configs/sifive-fu540.h
create mode 100644 include/dt-bindings/clk/sifive-fu540-prci.hSignature · 1 line
2.17.1
PATCH v2 1/11 riscv: Rename cpu/qemu to cpu/generic
The QEMU CPU support under arch/riscv is pretty much generic and works fine for SiFive Unleashed as well. In fact, there will be quite a few RISC-V SOCs for which QEMU CPU support will work fine.
This patch renames cpu/qemu to cpu/generic to indicate the above fact. If there are SOC specific errata workarounds required in cpu/generic then those can be done at runtime in cpu/generic based on CPU vendor specific DT compatible string.
---
arch/riscv/Kconfig | 2 +-
arch/riscv/cpu/{qemu => generic}/Kconfig | 2 +-
arch/riscv/cpu/{qemu => generic}/Makefile | 0
arch/riscv/cpu/{qemu => generic}/cpu.c | 0
arch/riscv/cpu/{qemu => generic}/dram.c | 0
board/emulation/qemu-riscv/Kconfig | 4 ++--
6 files changed, 4 insertions(+), 4 deletions(-)
rename arch/riscv/cpu/{qemu => generic}/Kconfig (91%)
rename arch/riscv/cpu/{qemu => generic}/Makefile (100%)
rename arch/riscv/cpu/{qemu => generic}/cpu.c (100%)
rename arch/riscv/cpu/{qemu => generic}/dram.c (100%)arch/riscv/Kconfig +1 -1
@@ -22,7 +22,7 @@ source "board/emulation/qemu-riscv/Kconfig" # platform-specific options below source "arch/riscv/cpu/ax25/Kconfig" -source "arch/riscv/cpu/qemu/Kconfig" +source "arch/riscv/cpu/generic/Kconfig" # architecture-specific options below
arch/riscv/cpu/generic/Kconfig renamed from arch/riscv/cpu/qemu/Kconfig +1 -1
@@ -2,7 +2,7 @@ # # Copyright (C) 2018, Bin Meng <[email protected]> -config QEMU_RISCV +config GENERIC_RISCV bool select ARCH_EARLY_INIT_R imply CPU
arch/riscv/cpu/generic/Makefile renamed from arch/riscv/cpu/qemu/Makefile +0 -0
arch/riscv/cpu/generic/cpu.c renamed from arch/riscv/cpu/qemu/cpu.c +0 -0
arch/riscv/cpu/generic/dram.c renamed from arch/riscv/cpu/qemu/dram.c +0 -0
board/emulation/qemu-riscv/Kconfig +2 -2
@@ -7,7 +7,7 @@ config SYS_VENDOR default "emulation" config SYS_CPU - default "qemu" + default "generic" config SYS_CONFIG_NAME default "qemu-riscv"
@@ -18,7 +18,7 @@ config SYS_TEXT_BASE config BOARD_SPECIFIC_OPTIONS # dummy def_bool y - select QEMU_RISCV + select GENERIC_RISCV imply SYS_NS16550 imply VIRTIO_MMIO imply VIRTIO_NET
Signature · 1 line
2.17.1
Auer
PATCH v2 1/11 riscv: Rename cpu/qemu to cpu/generic
Quoted 13 lines · Anup Patel
The QEMU CPU support under
arch/riscvis pretty much generic and works fine for SiFive Unleashed as well. In fact, there will be quite a few RISC-V SOCs for which QEMU CPU support will work fine.This patch renames cpu/qemu to cpu/generic to indicate the above fact. If there are SOC specific errata workarounds required in cpu/generic then those can be done at runtime in cpu/generic based on CPU vendor specific DT compatible string.
Signed-off-by Anup Patel <[email protected]>Reviewed-by Alexander Graf <[email protected]>
Quoted 13 lines
---
arch/riscv/Kconfig | 2 +-
arch/riscv/cpu/{qemu => generic}/Kconfig | 2 +-
arch/riscv/cpu/{qemu => generic}/Makefile | 0
arch/riscv/cpu/{qemu => generic}/cpu.c | 0
arch/riscv/cpu/{qemu => generic}/dram.c | 0
board/emulation/qemu-riscv/Kconfig | 4 ++--
6 files changed, 4 insertions(+), 4 deletions(-)
rename arch/riscv/cpu/{qemu => generic}/Kconfig (91%)
rename arch/riscv/cpu/{qemu => generic}/Makefile (100%)
rename arch/riscv/cpu/{qemu => generic}/cpu.c (100%)
rename arch/riscv/cpu/{qemu => generic}/dram.c (100%)PATCH v2 1/11 riscv: Rename cpu/qemu to cpu/generic
In reply to Anup PatelQuoted 14 lines · Anup Patel
The QEMU CPU support under
arch/riscvis pretty much generic and works fine for SiFive Unleashed as well. In fact, there will be quite a few RISC-V SOCs for which QEMU CPU support will work fine.This patch renames cpu/qemu to cpu/generic to indicate the above fact. If there are SOC specific errata workarounds required in cpu/generic then those can be done at runtime in cpu/generic based on CPU vendor specific DT compatible string.
Signed-off-by Anup Patel <[email protected]>Reviewed-by Alexander Graf <[email protected]>
Quoted 13 lines
---
arch/riscv/Kconfig | 2 +-
arch/riscv/cpu/{qemu => generic}/Kconfig | 2 +-
arch/riscv/cpu/{qemu => generic}/Makefile | 0
arch/riscv/cpu/{qemu => generic}/cpu.c | 0
arch/riscv/cpu/{qemu => generic}/dram.c | 0
board/emulation/qemu-riscv/Kconfig | 4 ++--
6 files changed, 4 insertions(+), 4 deletions(-)
rename arch/riscv/cpu/{qemu => generic}/Kconfig (91%)
rename arch/riscv/cpu/{qemu => generic}/Makefile (100%)
rename arch/riscv/cpu/{qemu => generic}/cpu.c (100%)
rename arch/riscv/cpu/{qemu => generic}/dram.c (100%)PATCH v2 2/11 riscv: Add asm/dma-mapping.h for DMA mappings
In reply to Anup PatelThis patch adds asm/dma-mapping.h for Linux-like DMA mappings APIs required by some of the drivers (such as, Cadance MACB Ethernet driver).
--- arch/riscv/include/asm/dma-mapping.h | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 arch/riscv/include/asm/dma-mapping.h
arch/riscv/include/asm/dma-mapping.h new file +38 -0
@@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (c) 2018 Western Digital Corporation or its affiliates. +* +* Authors: +* Anup Patel <[email protected]> +*/ + +#ifndef __ASM_RISCV_DMA_MAPPING_H +#define __ASM_RISCV_DMA_MAPPING_H + +#include <linux/dma-direction.h> + +#define dma_mapping_error (x, y) 0 + +static inline void *dma_alloc_coherent (size_t len,unsigned long *handle) +{ + *handle = (unsigned long )memalign (ARCH_DMA_MINALIGN , len); +return (void *)*handle; +} + +static inline void dma_free_coherent (void *addr) +{ +free (addr); +} + +static inline unsigned long dma_map_single (volatile void *vaddr,size_t len, +enum dma_data_direction dir) +{ +return (unsigned long )vaddr; +} + +static inline void dma_unmap_single (volatile void *vaddr,size_t len, +unsigned long paddr) +{ +} + +#endif /* __ASM_RISCV_DMA_MAPPING_H */
Signature · 1 line
2.17.1
Auer
PATCH v2 2/11 riscv: Add asm/dma-mapping.h for DMA mappings
Quoted 4 lines · Anup Patel
This patch adds
asm/dma-mapping.hfor Linux-like DMA mappings APIs required by some of the drivers (such as, Cadance MACB Ethernet driver).
Quoted 9 lines
Signed-off-by Anup Patel <[email protected]>Reviewed-by Bin Meng <[email protected]>Reviewed-by Alexander Graf <[email protected]>--- arch/riscv/include/asm/dma-mapping.h | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 arch/riscv/include/asm/dma-mapping.h
PATCH v2 3/11 riscv: generic: Ensure that U-Boot runs within 4GB for 64bit systems
In reply to Anup PatelOn 64bit systems, the DRAM top can be easily beyond 4GB and U-Boot DMA mapping APIs will generate DMA addresses beyond 4GB. This breaks DMA programming in 32bit DMA capable devices (such as Cadence MACB ethernet). For example, If DRAM is more then 2GB on QEMU sifive_u machine then Cadence MACB ethernet stops working for U-Boot because it is a 32bit DMA capable device.
To handle 32bit DMA capable devices on 64bit systems, we provide custom implementation of board_get_usable_ram_top() which ensures that usable ram top is not more then 4GB. This in-turn ensures that U-Boot always runs within 4GB hence DMA addresses generated by DMA mapping APIs will be within 4GB too.
--- arch/riscv/cpu/generic/dram.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
arch/riscv/cpu/generic/dram.c +20 -0
@@ -5,6 +5,9 @@#include <common.h> #include <fdtdec.h> +#include <linux/sizes.h> + +DECLARE_GLOBAL_DATA_PTR ;int dram_init (void ) {
@@ -15,3 +18,20 @@ int dram_init_banksize(void) {return fdtdec_setup_memory_banksize (); } + +ulong board_get_usable_ram_top (ulong total_size) +{ +#ifdef CONFIG_64BIT +/* +* Ensure that we run from first 4GB so that all +* addresses used by U-Boot are 32bit addresses. +* +* This in-turn ensures that 32bit DMA capabale +* devices work fine because DMA mapping APIs will +* provide 32bit DMA addresses only. +*/ +if (gd->ram_top >SZ_4G ) +return SZ_4G ; +#endif +return gd->ram_top; +}
Signature · 1 line
2.17.1
Auer
PATCH v2 3/11 riscv: generic: Ensure that U-Boot runs within 4GB for 64bit systems
Quoted 13 lines · Anup Patel
On 64bit systems, the DRAM top can be easily beyond 4GB and U-Boot DMA mapping APIs will generate DMA addresses beyond 4GB. This breaks DMA programming in 32bit DMA capable devices (such as Cadence MACB ethernet). For example, If DRAM is more then 2GB on QEMU
sifive_umachine then Cadence MACB ethernet stops working for U-Boot because it is a 32bit DMA capable device.To handle 32bit DMA capable devices on 64bit systems, we provide custom implementation of
board_get_usable_ram_top()which ensures that usable ram top is not more then 4GB. This in-turn ensures that U-Boot always runs within 4GB hence DMA addresses generated by DMA mapping APIs will be within 4GB too.
Quoted 7 lines
Signed-off-by Atish Patra <[email protected]>Signed-off-by Anup Patel <[email protected]>Reviewed-by Alexander Graf <[email protected]>--- arch/riscv/cpu/generic/dram.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
With one nit below.
Quoted 18 lines
arch/riscv/cpu/generic/dram.c +3
-0@@ -5,6 +5,9 @@#include <common.h> #include <fdtdec.h> +#include <linux/sizes.h> + +DECLARE_GLOBAL_DATA_PTR ;int dram_init (void ) {@@ -15,3 +18,20 @@ int dram_init_banksize(void) {return fdtdec_setup_memory_banksize ();
arch/riscv/cpu/generic/dram.c int dram_init_banksize(void) · line 29
Quoted 10 lines
arch/riscv/cpu/generic/dram.c +9
-0} + +ulong board_get_usable_ram_top (ulong total_size) +{ +#ifdef CONFIG_64BIT +/* +* Ensure that we run from first 4GB so that all +* addresses used by U-Boot are 32bit addresses. +* +* This in-turn ensures that 32bit DMA capabale
nit: capable
Quoted 8 lines
arch/riscv/cpu/generic/dram.c +8
-0+* devices work fine because DMA mapping APIs will +* provide 32bit DMA addresses only. +*/ +if (gd->ram_top >SZ_4G ) +return SZ_4G ; +#endif +return gd->ram_top; +}
PATCH v2 3/11 riscv: generic: Ensure that U-Boot runs within 4GB for 64bit systems
Quoted 54 lines
-----Original Message-----
From: Auer, Lukas [mailto:lukas.auer at aisec.fraunhofer.de]
Sent: Monday, January 21, 2019 1:35 AM
To: sjg at chromium.org; bmeng.cn at gmail.com; rick at andestech.com; Anup Patel <[email protected]>; joe.hershberger at ni.com; yamada.masahiro at socionext.com
Cc: paul.walmsley at sifive.com; palmer at sifive.com; hch at infradead.org; u- boot at lists.denx.de; agraf at suse.de; Atish Patra <[email protected]>
Subject: Re: [PATCH v2 03/11] riscv: generic: Ensure that U-Boot runs within 4GB for 64bit systemsQuoted 1 line · Anup Patel
On 64bit systems, the DRAM top can be easily beyond 4GB and U-Boot
DMA
Quoted 4 lines
mapping APIs will generate DMA addresses beyond 4GB. This breaks DMA programming in 32bit DMA capable devices (such as Cadence MACB ethernet). For example, If DRAM is more then 2GB on QEMU
sifive_umachine then Cadence MACB ethernet stops working for U-Boot becauseit
Quoted 4 lines
is a 32bit DMA capable device.
To handle 32bit DMA capable devices on 64bit systems, we provide custom implementation of
board_get_usable_ram_top()which ensuresthat
Quoted 11 lines
usable ram top is not more then 4GB. This in-turn ensures that U-Boot always runs within 4GB hence DMA addresses generated by DMA mapping APIs will be within 4GB too.
Signed-off-by Atish Patra <[email protected]>Signed-off-by Anup Patel <[email protected]>Reviewed-by Alexander Graf <[email protected]>--- arch/riscv/cpu/generic/dram.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)Reviewed-by Lukas Auer <[email protected]>With one nit below.
Quoted 12 lines
(quoted diff) +0
-0
b/arch/riscv/cpu/generic/dram.cindex84d87d2a7f..5725d3c7ae100644arch/riscv/cpu/generic/dram.c +3
-0@@ -5,6 +5,9 @@#include <common.h> #include <fdtdec.h> +#include <linux/sizes.h> + +DECLARE_GLOBAL_DATA_PTR ;
Quoted 14 lines
arch/riscv/cpu/generic/dram.c int dram_init_banksize(void) { · line 26
Quoted 12 lines
arch/riscv/cpu/generic/dram.c +8
-0int dram_init (void ) {@@ -15,3 +18,20 @@ int dram_init_banksize(void) {return fdtdec_setup_memory_banksize (); } + +ulong board_get_usable_ram_top (ulong total_size) {#ifdef +CONFIG_64BIT +/* +* Ensure that we run from first 4GB so that all +* addresses used by U-Boot are 32bit addresses. +* +* This in-turn ensures that 32bit DMA capabale nit: capable
Sure, will update.
Quoted 9 lines
arch/riscv/cpu/generic/dram.c int dram_init_banksize(void) · line 37
Quoted 9 lines
arch/riscv/cpu/generic/dram.c +8
-0+* devices work fine because DMA mapping APIs will +* provide 32bit DMA addresses only. +*/ +if (gd->ram_top >SZ_4G ) +return SZ_4G ; +#endif +return gd->ram_top; +}
Regards,
Anup
PATCH v2 3/11 riscv: generic: Ensure that U-Boot runs within 4GB for 64bit systems
In reply to Anup PatelQuoted 14 lines · Anup Patel
On 64bit systems, the DRAM top can be easily beyond 4GB and U-Boot DMA mapping APIs will generate DMA addresses beyond 4GB. This breaks DMA programming in 32bit DMA capable devices (such as Cadence MACB ethernet). For example, If DRAM is more then 2GB on QEMU
sifive_umachine then Cadence MACB ethernet stops working for U-Boot because it is a 32bit DMA capable device.To handle 32bit DMA capable devices on 64bit systems, we provide custom implementation of
board_get_usable_ram_top()which ensures that usable ram top is not more then 4GB. This in-turn ensures that U-Boot always runs within 4GB hence DMA addresses generated by DMA mapping APIs will be within 4GB too.
Quoted 7 lines
Signed-off-by Atish Patra <[email protected]>Signed-off-by Anup Patel <[email protected]>Reviewed-by Alexander Graf <[email protected]>--- arch/riscv/cpu/generic/dram.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
But see one comment below:
Quoted 25 lines
arch/riscv/cpu/generic/dram.c +10
-0@@ -5,6 +5,9 @@#include <common.h> #include <fdtdec.h> +#include <linux/sizes.h> + +DECLARE_GLOBAL_DATA_PTR ;int dram_init (void ) {@@ -15,3 +18,20 @@ int dram_init_banksize(void) {return fdtdec_setup_memory_banksize (); } + +ulong board_get_usable_ram_top (ulong total_size) +{ +#ifdef CONFIG_64BIT +/* +* Ensure that we run from first 4GB so that all +* addresses used by U-Boot are 32bit addresses.
arch/riscv/cpu/generic/dram.c int dram_init_banksize(void) · line 37
Quoted 10 lines
arch/riscv/cpu/generic/dram.c +10
-0+* +* This in-turn ensures that 32bit DMA capabale +* devices work fine because DMA mapping APIs will +* provide 32bit DMA addresses only. +*/ +if (gd->ram_top >SZ_4G ) +return SZ_4G ; +#endif +return gd->ram_top; +}
I was wondering whether we should change this for 32-bit too, given it's a valid configuration to have more than 4GB memory in a 32-bit system.
Regards,
Bin
PATCH v2 3/11 riscv: generic: Ensure that U-Boot runs within 4GB for 64bit systems
Quoted 73 lines
-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Tuesday, January 22, 2019 7:37 AM
To: Anup Patel <[email protected]>
Cc: Rick Chen <[email protected]>; Joe Hershberger <[email protected]>; Lukas Auer <[email protected]>; Masahiro Yamada <[email protected]>; Simon Glass <[email protected]>; Alexander Graf <[email protected]>; Palmer Dabbelt <[email protected]>; Paul Walmsley <[email protected]>; Atish Patra <[email protected]>; Christoph Hellwig <[email protected]>; U- Boot Mailing List <[email protected]>
Subject: Re: [PATCH v2 03/11] riscv: generic: Ensure that U-Boot runs within 4GB for 64bit systemsQuoted 2 lines · Anup Patel
On 64bit systems, the DRAM top can be easily beyond 4GB and U-Boot
DMA
Quoted 4 lines
mapping APIs will generate DMA addresses beyond 4GB. This breaks DMA programming in 32bit DMA capable devices (such as Cadence MACB ethernet). For example, If DRAM is more then 2GB on QEMU
sifive_umachine then Cadence MACB ethernet stops working for U-Boot becauseit
Quoted 4 lines
is a 32bit DMA capable device.
To handle 32bit DMA capable devices on 64bit systems, we provide custom implementation of
board_get_usable_ram_top()which ensuresthat
Quoted 11 lines
usable ram top is not more then 4GB. This in-turn ensures that U-Boot always runs within 4GB hence DMA addresses generated by DMA mapping APIs will be within 4GB too.
Signed-off-by Atish Patra <[email protected]>Signed-off-by Anup Patel <[email protected]>Reviewed-by Alexander Graf <[email protected]>--- arch/riscv/cpu/generic/dram.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)Reviewed-by Bin Meng <[email protected]>But see one comment below:
Quoted 27 lines
(quoted diff) +0
-0
b/arch/riscv/cpu/generic/dram.cindex84d87d2a7f..5725d3c7ae100644arch/riscv/cpu/generic/dram.c +14
-0@@ -5,6 +5,9 @@#include <common.h> #include <fdtdec.h> +#include <linux/sizes.h> + +DECLARE_GLOBAL_DATA_PTR ;int dram_init (void ) {@@ -15,3 +18,20 @@ int dram_init_banksize(void) {return fdtdec_setup_memory_banksize (); } + +ulong board_get_usable_ram_top (ulong total_size) {#ifdef +CONFIG_64BIT +/* +* Ensure that we run from first 4GB so that all +* addresses used by U-Boot are 32bit addresses. +* +* This in-turn ensures that 32bit DMA capabale +* devices work fine because DMA mapping APIs will +* provide 32bit DMA addresses only. +*/
Quoted 8 lines
arch/riscv/cpu/generic/dram.c int dram_init_banksize(void) · line 37
Quoted 5 lines
arch/riscv/cpu/generic/dram.c +5
-0+if (gd->ram_top >SZ_4G ) +return SZ_4G ; +#endif +return gd->ram_top; +}I was wondering whether we should change this for 32-bit too, given it's a valid configuration to have more than 4GB memory in a 32-bit system.
We had considered this but "gd->ram_top" is "unsigned long" so on 32bit system it will be 32bit only. In other words, value of "gd->ram_top" on 32bit system can never exceed 4GB.
Regards,
Anup
PATCH v2 4/11 net: macb: Fix clk API usage for RISC-V systems
In reply to Anup PatelThis patch does following fixes in MACB ethernet driver for using it on RISC-V systems (particularly QEMU sifive_u machine):
1. asm/arch/clk.h is not available on RISC-V port so include it only for non-RISC-V systems.
2. Don't fail in macb_enable_clk() if clk_enable() returns -ENOSYS because we get -ENOSYS for fixed-rate clocks.
--- drivers/net/macb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/macb.c +3 -1
@@ -38,7 +38,9 @@#include <linux/mii.h> #include <asm/io.h> #include <asm/dma-mapping.h> +#ifndef CONFIG_RISCV #include <asm/arch/clk.h> +#endif #include <linux/errno.h> #include "macb.h"
@@ -1066,7 +1068,7 @@ static int macb_enable_clk(struct udevice *dev)*/ #ifndef CONFIG_MACB_ZYNQ ret =clk_enable (&clk); -if (ret) +if (ret && ret != -ENOSYS )return ret;#endif
Signature · 1 line
2.17.1
PATCH v2 5/11 net: macb: Fix GEM hardware detection
In reply to Anup PatelFrom: Atish Patra <[email protected]>
Fix MID bit field check to correctly identify all GEM hardwares.
The check is updated as per macb driver in Linux location:
<linux_sources>/drivers/net/ethernet/cadence/macb_main.c:259
--- drivers/net/macb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/macb.c +1 -1
@@ -145,7 +145,7 @@ struct macb_device {static int macb_is_gem (struct macb_device *macb) { -return MACB_BFEXT (IDNUM ,macb_readl (macb,MID )) ==0x2 ; +return MACB_BFEXT (IDNUM ,macb_readl (macb,MID )) >=0x2 ; }#ifndef cpu_is_sama5d2
Signature · 1 line
2.17.1
PATCH v2 5/11 net: macb: Fix GEM hardware detection
Quoted 8 lines · Anup Patel
From: Atish Patra <[email protected]>
Fix MID bit field check to correctly identify all GEM hardwares.
The check is updated as per macb driver in Linux location:
<linux_sources>/drivers/net/ethernet/cadence/macb_main.c:259Signed-off-by Atish Patra <[email protected]>
This is missing your SoB.
Alex
Quoted 19 lines
Reviewed-by Alexander Graf <[email protected]>--- drivers/net/macb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/macb.c +1
-1@@ -145,7 +145,7 @@ struct macb_device {static int macb_is_gem (struct macb_device *macb) { -return MACB_BFEXT (IDNUM ,macb_readl (macb,MID )) ==0x2 ; +return MACB_BFEXT (IDNUM ,macb_readl (macb,MID )) >=0x2 ; }#ifndef cpu_is_sama5d2
PATCH v2 5/11 net: macb: Fix GEM hardware detection
Quoted 21 lines
-----Original Message-----
From: Alexander Graf [mailto:agraf at suse.de]
Sent: Friday, January 18, 2019 5:22 PM
To: Anup Patel <[email protected]>; Rick Chen <[email protected]>; Bin Meng <[email protected]>; Joe Hershberger <[email protected]>; Lukas Auer <[email protected]>; Masahiro Yamada <[email protected]>; Simon Glass <[email protected]>
Cc: Palmer Dabbelt <[email protected]>; Paul Walmsley <[email protected]>; Atish Patra <[email protected]>; Christoph Hellwig <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>
Subject: Re: [PATCH v2 05/11] net: macb: Fix GEM hardware detectionQuoted 2 lines · Anup Patel
From: Atish Patra <[email protected]>
Quoted 8 lines
Quoted 6 lines
Fix MID bit field check to correctly identify all GEM hardwares.
The check is updated as per macb driver in Linux location:
<linux_sources>/drivers/net/ethernet/cadence/macb_main.c:259Signed-off-by Atish Patra <[email protected]>This is missing your SoB.
Sure, I will add my SoB.
Since the work was done by Atish independently, I thought my SoB is not required.
Regards,
Anup
PATCH v2 5/11 net: macb: Fix GEM hardware detection
Quoted 26 lines · Anup Patel
Quoted 26 lines
-----Original Message-----
From: Alexander Graf [mailto:agraf at suse.de]
Sent: Friday, January 18, 2019 5:22 PM
To: Anup Patel <[email protected]>; Rick Chen <[email protected]>; Bin Meng <[email protected]>; Joe Hershberger <[email protected]>; Lukas Auer <[email protected]>; Masahiro Yamada <[email protected]>; Simon Glass <[email protected]>
Cc: Palmer Dabbelt <[email protected]>; Paul Walmsley <[email protected]>; Atish Patra <[email protected]>; Christoph Hellwig <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>
Subject: Re: [PATCH v2 05/11] net: macb: Fix GEM hardware detectionQuoted 7 lines · Anup Patel
From: Atish Patra <[email protected]>
Fix MID bit field check to correctly identify all GEM hardwares.
The check is updated as per macb driver in Linux location:
<linux_sources>/drivers/net/ethernet/cadence/macb_main.c:259
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Atish Patra <[email protected]>This is missing your SoB.
Sure, I will add my SoB.
Since the work was done by Atish independently, I thought my SoB is not required.
Imagine the SoB as a marker for "this went through my hands". If you send a patch from someone else - even though you did modify a single line - it still went through your hands and thus your SoB should occur at the end.
Similarly the first SoB usually means "this was the original author".
So imagine you started to work on a patch, then Atish improved it and eventually you send it out, the SoB chain would look like this:
But you don't have to be too nit-picky about that part. The one thing people will care about is that the original author is in the SoB list and that your SoB is at the end of the list, because you are the one sending the patch set.
Alex
PATCH v2 5/11 net: macb: Fix GEM hardware detection
Quoted 64 lines
-----Original Message-----
From: Alexander Graf [mailto:agraf at suse.de]
Sent: Friday, January 18, 2019 6:41 PM
To: Anup Patel <[email protected]>; Rick Chen <[email protected]>; Bin Meng <[email protected]>; Joe Hershberger <[email protected]>; Lukas Auer <[email protected]>; Masahiro Yamada <[email protected]>; Simon Glass <[email protected]>
Cc: Palmer Dabbelt <[email protected]>; Paul Walmsley <[email protected]>; Atish Patra <[email protected]>; Christoph Hellwig <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>
Subject: Re: [PATCH v2 05/11] net: macb: Fix GEM hardware detectionQuoted 6 lines · Anup Patel
Quoted 6 lines
-----Original Message-----
From: Alexander Graf [mailto:agraf at suse.de]
Sent: Friday, January 18, 2019 5:22 PM
To: Anup Patel <[email protected]>; Rick ChenQuoted 20 lines
Quoted 20 lines
Bin Meng <[email protected]>; Joe Hershberger <[email protected]>; Lukas Auer <[email protected]>; Masahiro Yamada <[email protected]>; Simon Glass <[email protected]>
Cc: Palmer Dabbelt <[email protected]>; Paul Walmsley <[email protected]>; Atish Patra <[email protected]>; Christoph Hellwig <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>
Subject: Re: [PATCH v2 05/11] net: macb: Fix GEM hardware detectionQuoted 7 lines · Anup Patel
From: Atish Patra <[email protected]>
Fix MID bit field check to correctly identify all GEM hardwares.
The check is updated as per macb driver in Linux location:
<linux_sources>/drivers/net/ethernet/cadence/macb_main.c:259Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Atish Patra <[email protected]>This is missing your SoB.
Sure, I will add my SoB.
Since the work was done by Atish independently, I thought my SoB is not required.
Imagine the SoB as a marker for "this went through my hands". If you send a patch from someone else - even though you did modify a single line - it still went through your hands and thus your SoB should occur at the end.
Similarly the first SoB usually means "this was the original author".
So imagine you started to work on a patch, then Atish improved it and eventually you send it out, the SoB chain would look like this:
Quoted 7 lines
Signed-off-by Anup Patel <[email protected]>Signed-off-by Atish Patra <[email protected]>Signed-off-by Anup Patel <[email protected]>But you don't have to be too nit-picky about that part. The one thing people will care about is that the original author is in the SoB list and that your SoB is at the end of the list, because you are the one sending the patch set.
Thanks for the info.
I was not aware of this convention around SoB.
Regards,
Anup
Auer
PATCH v2 5/11 net: macb: Fix GEM hardware detection
In reply to Anup PatelQuoted 4 lines · Anup Patel
From: Atish Patra <[email protected]>
Fix MID bit field check to correctly identify all GEM hardwares.
Quoted 9 lines
The check is updated as per macb driver in Linux location:
<linux_sources>/drivers/net/ethernet/cadence/macb_main.c:259Signed-off-by Atish Patra <[email protected]>Reviewed-by Alexander Graf <[email protected]>--- drivers/net/macb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
PATCH v2 6/11 clk: Add SiFive FU540 PRCI clock driver
In reply to Anup PatelAdd driver code for the SiFive FU540 PRCI IP block. This IP block handles reset and clock control for the SiFive FU540 device and implements SoC-level clock tree controls and dividers.
Based on code written by Wesley Terpstra <[email protected]> found in commit 999529edf517ed75b56659d456d221b2ee56bb60 of:
https://github.com/riscv/riscv-linux
Boot and PLL rate change were tested on a SiFive HiFive Unleashed board.
--- drivers/clk/Kconfig | 1 + drivers/clk/Makefile | 1 + drivers/clk/sifive/Kconfig | 19 + drivers/clk/sifive/Makefile | 5 + .../clk/sifive/analogbits-wrpll-cln28hpc.h | 101 +++ drivers/clk/sifive/fu540-prci.c | 604 ++++++++++++++++++ drivers/clk/sifive/wrpll-cln28hpc.c | 390 +++++++++++ include/dt-bindings/clk/sifive-fu540-prci.h | 29 + 8 files changed, 1150 insertions(+) create mode 100644 drivers/clk/sifive/Kconfig create mode 100644 drivers/clk/sifive/Makefile create mode 100644 drivers/clk/sifive/analogbits-wrpll-cln28hpc.h create mode 100644 drivers/clk/sifive/fu540-prci.c create mode 100644 drivers/clk/sifive/wrpll-cln28hpc.c create mode 100644 include/dt-bindings/clk/sifive-fu540-prci.h
drivers/clk/Kconfig +1 -0
@@ -104,6 +104,7 @@ source "drivers/clk/imx/Kconfig" source "drivers/clk/mvebu/Kconfig" source "drivers/clk/owl/Kconfig" source "drivers/clk/renesas/Kconfig" +source "drivers/clk/sifive/Kconfig" source "drivers/clk/tegra/Kconfig" source "drivers/clk/uniphier/Kconfig"
drivers/clk/Makefile +1 -0
@@ -22,6 +22,7 @@ obj-$(CONFIG_CLK_HSDK) += clk-hsdk-cgu.o obj-$(CONFIG_CLK_MPC83XX) += mpc83xx_clk.o obj-$(CONFIG_CLK_OWL) += owl/ obj-$(CONFIG_CLK_RENESAS) += renesas/ +obj-$(CONFIG_CLK_SIFIVE) += sifive/ obj-$(CONFIG_CLK_STM32F) += clk_stm32f.o obj-$(CONFIG_CLK_STM32MP1) += clk_stm32mp1.o obj-$(CONFIG_CLK_UNIPHIER) += uniphier/
drivers/clk/sifive/Kconfig new file +19 -0
@@ -0,0 +1,19 @@ +# SPDX-License-Identifier: GPL-2.0 + +config CLK_ANALOGBITS_WRPLL_CLN28HPC + bool + +config CLK_SIFIVE + bool "SiFive SoC driver support" + depends on CLK + help + SoC drivers for SiFive Linux-capable SoCs. + +config CLK_SIFIVE_FU540_PRCI + bool "PRCI driver for SiFive FU540 SoCs" + depends on CLK_SIFIVE + select CLK_ANALOGBITS_WRPLL_CLN28HPC + help + Supports the Power Reset Clock interface (PRCI) IP block found in + FU540 SoCs. If this kernel is meant to run on a SiFive FU540 SoC, + enable this driver.
drivers/clk/sifive/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ + +obj-$(CONFIG_CLK_ANALOGBITS_WRPLL_CLN28HPC) += wrpll-cln28hpc.o + +obj-$(CONFIG_CLK_SIFIVE_FU540_PRCI) += fu540-prci.o
drivers/clk/sifive/analogbits-wrpll-cln28hpc.h new file +101 -0
101 lines not on this page · raw message
drivers/clk/sifive/fu540-prci.c new file +604 -0
604 lines not on this page · raw message
drivers/clk/sifive/wrpll-cln28hpc.c new file +390 -0
390 lines not on this page · raw message
include/dt-bindings/clk/sifive-fu540-prci.h new file +29 -0
@@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2019 Western Digital Corporation or its affiliates. +* +* Copyright (C) 2018 SiFive, Inc. +* Wesley Terpstra +* Paul Walmsley +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef __LINUX_CLK_SIFIVE_FU540_PRCI_H +#define __LINUX_CLK_SIFIVE_FU540_PRCI_H + +/* Clock indexes for use by Device Tree data */ + +#define PRCI_CLK_COREPLL 0 +#define PRCI_CLK_DDRPLL 1 +#define PRCI_CLK_GEMGXLPLL 2 +#define PRCI_CLK_TLCLK 3 + +#endif
Signature · 1 line
2.17.1
Auer
PATCH v2 6/11 clk: Add SiFive FU540 PRCI clock driver
Hi Anup,
Quoted 24 lines · Anup Patel
Add driver code for the SiFive FU540 PRCI IP block. This IP block handles reset and clock control for the SiFive FU540 device and implements SoC-level clock tree controls and dividers.
Based on code written by Wesley Terpstra <[email protected]> found in commit
999529edf517ed75b56659d456d221b2ee56bb60of:
https://github.com/riscv/riscv-linuxBoot and PLL rate change were tested on a SiFive HiFive Unleashed board.
Signed-off-by Paul Walmsley <[email protected]>Signed-off-by Atish Patra <[email protected]>Signed-off-by Anup Patel <[email protected]>Reviewed-by Alexander Graf <[email protected]>--- drivers/clk/Kconfig | 1 + drivers/clk/Makefile | 1 + drivers/clk/sifive/Kconfig | 19 + drivers/clk/sifive/Makefile | 5 + .../clk/sifive/analogbits-wrpll-cln28hpc.h | 101 +++ drivers/clk/sifive/fu540-prci.c | 604 ++++++++++++++++++ drivers/clk/sifive/wrpll-cln28hpc.c | 390 +++++++++++
Quoted 9 lines
include/dt-bindings/clk/sifive-fu540-prci.h | 29 + 8 files changed, 1150 insertions(+) create mode 100644 drivers/clk/sifive/Kconfig create mode 100644 drivers/clk/sifive/Makefile create mode 100644 drivers/clk/sifive/analogbits-wrpll-cln28hpc.h create mode 100644 drivers/clk/sifive/fu540-prci.c create mode 100644 drivers/clk/sifive/wrpll-cln28hpc.c create mode 100644 include/dt-bindings/clk/sifive-fu540-prci.h
The corresponding patch series for the Linux Kernel [1] includes code comments, which have not been addressed yet in this version of the driver. Are you planning on syncing it with the Linux driver once it is upstream, or incorporating the comments directly?
[1]:
https://patchwork.kernel.org/project/linux-clk/list/?series=33383&state=%2A&archive=both
Quoted 30 lines
drivers/clk/Kconfig +1
-0@@ -104,6 +104,7 @@ source "drivers/clk/imx/Kconfig" source "drivers/clk/mvebu/Kconfig" source "drivers/clk/owl/Kconfig" source "drivers/clk/renesas/Kconfig" +source "drivers/clk/sifive/Kconfig" source "drivers/clk/tegra/Kconfig" source "drivers/clk/uniphier/Kconfig"drivers/clk/Makefile +1
-0@@ -22,6 +22,7 @@ obj-$(CONFIG_CLK_HSDK) += clk-hsdk-cgu.o obj-$(CONFIG_CLK_MPC83XX) += mpc83xx_clk.o obj-$(CONFIG_CLK_OWL) += owl/ obj-$(CONFIG_CLK_RENESAS) += renesas/ +obj-$(CONFIG_CLK_SIFIVE) += sifive/ obj-$(CONFIG_CLK_STM32F) += clk_stm32f.o obj-$(CONFIG_CLK_STM32MP1) += clk_stm32mp1.o obj-$(CONFIG_CLK_UNIPHIER) += uniphier/drivers/clk/sifive/Kconfig new file +0
-0
drivers/clk/sifive/Kconfig line 4
Quoted 4 lines
drivers/clk/sifive/Kconfig new file +4
-0@@ -0,0 +1,19 @@ +# SPDX-License-Identifier: GPL-2.0 + +config CLK_ANALOGBITS_WRPLL_CLN28HPC + bool
The analogbits library is not specific to SiFive. The Linux Kernel patch series adds it as a standalone entry to make it available to other drivers. I think the same thing would also make sense here.
Thanks,
Lukas
PATCH v2 6/11 clk: Add SiFive FU540 PRCI clock driver
Quoted 49 lines
-----Original Message-----
From: Auer, Lukas [mailto:lukas.auer at aisec.fraunhofer.de]
Sent: Monday, January 21, 2019 1:43 AM
To: sjg at chromium.org; bmeng.cn at gmail.com; rick at andestech.com; Anup Patel <[email protected]>; joe.hershberger at ni.com; yamada.masahiro at socionext.com
Cc: paul.walmsley at sifive.com; palmer at sifive.com; hch at infradead.org; u- boot at lists.denx.de; agraf at suse.de; Atish Patra <[email protected]>
Subject: Re: [PATCH v2 06/11] clk: Add SiFive FU540 PRCI clock driverHi Anup,
Quoted 24 lines · Anup Patel
Add driver code for the SiFive FU540 PRCI IP block. This IP block handles reset and clock control for the SiFive FU540 device and implements SoC-level clock tree controls and dividers.
Based on code written by Wesley Terpstra <[email protected]> found in commit
999529edf517ed75b56659d456d221b2ee56bb60of:
https://github.com/riscv/riscv-linuxBoot and PLL rate change were tested on a SiFive HiFive Unleashed board.
Signed-off-by Paul Walmsley <[email protected]>Signed-off-by Atish Patra <[email protected]>Signed-off-by Anup Patel <[email protected]>Reviewed-by Alexander Graf <[email protected]>--- drivers/clk/Kconfig | 1 + drivers/clk/Makefile | 1 + drivers/clk/sifive/Kconfig | 19 + drivers/clk/sifive/Makefile | 5 + .../clk/sifive/analogbits-wrpll-cln28hpc.h | 101 +++ drivers/clk/sifive/fu540-prci.c | 604 ++++++++++++++++++ drivers/clk/sifive/wrpll-cln28hpc.c | 390 +++++++++++Quoted 9 lines
include/dt-bindings/clk/sifive-fu540-prci.h | 29 + 8 files changed, 1150 insertions(+) create mode 100644 drivers/clk/sifive/Kconfig create mode 100644 drivers/clk/sifive/Makefile create mode 100644 drivers/clk/sifive/analogbits-wrpll-cln28hpc.h create mode 100644 drivers/clk/sifive/fu540-prci.c create mode 100644 drivers/clk/sifive/wrpll-cln28hpc.c create mode 100644 include/dt-bindings/clk/sifive-fu540-prci.h
Quoted 8 lines
The corresponding patch series for the Linux Kernel [1] includes code comments, which have not been addressed yet in this version of the driver. Are you planning on syncing it with the Linux driver once it is upstream, or incorporating the comments directly?
[1]:
https://patchwork.kernel.org/project/linux-
clk/list/?series=33383&state=%2A&archive=both
Yes, the Linux patches might take some time to merge so unblock this patch series we took the first version as reference. Later once it is merged we will send one sync-up patch to U-Boot.
Quoted 30 lines
Quoted 30 lines
drivers/clk/Kconfig index renamed from drivers/clk/Kconfig +0
-0
eadf7f8250..ce462f5717100644drivers/clk/Kconfig +1
-0@@ -104,6 +104,7 @@ source "drivers/clk/imx/Kconfig" source "drivers/clk/mvebu/Kconfig" source "drivers/clk/owl/Kconfig" source "drivers/clk/renesas/Kconfig" +source "drivers/clk/sifive/Kconfig" source "drivers/clk/tegra/Kconfig" source "drivers/clk/uniphier/Kconfig"drivers/clk/Makefile index renamed from drivers/clk/Makefile +0
-0
9acbb1a650..2f4446568c100644drivers/clk/Makefile +1
-0@@ -22,6 +22,7 @@ obj-$(CONFIG_CLK_HSDK) += clk-hsdk-cgu.o obj-$(CONFIG_CLK_MPC83XX) += mpc83xx_clk.o obj-$(CONFIG_CLK_OWL) += owl/ obj-$(CONFIG_CLK_RENESAS) += renesas/ +obj-$(CONFIG_CLK_SIFIVE) += sifive/ obj-$(CONFIG_CLK_STM32F) += clk_stm32f.o obj-$(CONFIG_CLK_STM32MP1) += clk_stm32mp1.o obj-$(CONFIG_CLK_UNIPHIER) += uniphier/ diff --gita/drivers/clk/sifive/Kconfig b/drivers/clk/sifive/Kconfig new file mode 100644 index 0000000000..81fc9f8fda
drivers/clk/sifive/Kconfig new file +0
-0@@ -0,0 +1,19 @@
Quoted 8 lines
drivers/clk/sifive/Kconfig line 4
Quoted 4 lines
drivers/clk/sifive/Kconfig new file +4
-0+# SPDX-License-Identifier: GPL-2.0 + +config CLK_ANALOGBITS_WRPLL_CLN28HPC + boolThe analogbits library is not specific to SiFive. The Linux Kernel patch series adds it as a standalone entry to make it available to other drivers. I think the same thing would also make sense here.
Based on other CLK drivers, it seems analogbits library is not generic enough might require more work to become generic PLL library.
To unblock this patch series, we have made it SiFive specific. Later if it is accepted in Linux as standalone library then we will refactor here as well.
IMHO, analogbits library is not generic enough so might be difficult to take it as standalone library in Linux.
Regards,
Anup
Auer
PATCH v2 6/11 clk: Add SiFive FU540 PRCI clock driver
Quoted 61 lines · Anup Patel
Quoted 61 lines
-----Original Message-----
From: Auer, Lukas [mailto:lukas.auer at aisec.fraunhofer.de]
Sent: Monday, January 21, 2019 1:43 AM
To: sjg at chromium.org; bmeng.cn at gmail.com; rick at andestech.com; Anup Patel <[email protected]>; joe.hershberger at ni.com; yamada.masahiro at socionext.com
Cc: paul.walmsley at sifive.com; palmer at sifive.com; hch at infradead.org; u-
boot at lists.denx.de; agraf at suse.de; Atish Patra <[email protected]Quoted 1 line
Subject: Re: [PATCH v2 06/11] clk: Add SiFive FU540 PRCI clock driver
Hi Anup,
Quoted 27 lines · Anup Patel
Add driver code for the SiFive FU540 PRCI IP block. This IP block
handles reset and clock control for the SiFive FU540 device and implements SoC-level clock tree controls and dividers.Based on code written by Wesley Terpstra <[email protected]> found in
commit999529edf517ed75b56659d456d221b2ee56bb60of:
https://github.com/riscv/riscv-linuxBoot and PLL rate change were tested on a SiFive HiFive Unleashed board.
Signed-off-by Paul Walmsley <[email protected]>Signed-off-by Atish Patra <[email protected]>Signed-off-by Anup Patel <[email protected]>Reviewed-by Alexander Graf <[email protected]>--- drivers/clk/Kconfig | 1 + drivers/clk/Makefile | 1 + drivers/clk/sifive/Kconfig | 19 + drivers/clk/sifive/Makefile | 5 + .../clk/sifive/analogbits-wrpll-cln28hpc.h | 101 +++ drivers/clk/sifive/fu540-prci.c | 604 ++++++++++++++++++ drivers/clk/sifive/wrpll-cln28hpc.c | 390 +++++++++++ include/dt-bindings/clk/sifive-fu540-prci.h | 29 +Quoted 9 lines
8 files changed, 1150 insertions(+) create mode 100644 drivers/clk/sifive/Kconfig create mode 100644 drivers/clk/sifive/Makefile create mode 100644 drivers/clk/sifive/analogbits-wrpll-cln28hpc.h create mode 100644 drivers/clk/sifive/fu540-prci.c create mode 100644 drivers/clk/sifive/wrpll-cln28hpc.c create mode 100644 include/dt-bindings/clk/sifive-fu540-prci.hThe corresponding patch series for the Linux Kernel [1] includes code
comments, which have not been addressed yet in this version of the driver.
Are you planning on syncing it with the Linux driver once it is upstream, or
incorporating the comments directly?
Quoted 7 lines
Quoted 3 lines
[1]:
https://patchwork.kernel.org/project/linux-
clk/list/?series=33383&state=%2A&archive=bothYes, the Linux patches might take some time to merge so unblock this patch series we took the first version as reference. Later once it is merged we will send one sync-up patch to U-Boot.
That sounds good, thanks!
Quoted 46 lines
Quoted 33 lines
Quoted 33 lines
drivers/clk/Kconfig index renamed from drivers/clk/Kconfig +0
-0
eadf7f8250..ce462f5717100644drivers/clk/Kconfig +1
-0@@ -104,6 +104,7 @@ source "drivers/clk/imx/Kconfig" source "drivers/clk/mvebu/Kconfig" source "drivers/clk/owl/Kconfig" source "drivers/clk/renesas/Kconfig" +source "drivers/clk/sifive/Kconfig" source "drivers/clk/tegra/Kconfig" source "drivers/clk/uniphier/Kconfig"drivers/clk/Makefile index renamed from drivers/clk/Makefile +0
-0
9acbb1a650..2f4446568c100644drivers/clk/Makefile +1
-0@@ -22,6 +22,7 @@ obj-$(CONFIG_CLK_HSDK) += clk-hsdk-cgu.o obj-$(CONFIG_CLK_MPC83XX) += mpc83xx_clk.o obj-$(CONFIG_CLK_OWL) += owl/ obj-$(CONFIG_CLK_RENESAS) += renesas/ +obj-$(CONFIG_CLK_SIFIVE) += sifive/ obj-$(CONFIG_CLK_STM32F) += clk_stm32f.o obj-$(CONFIG_CLK_STM32MP1) += clk_stm32mp1.o obj-$(CONFIG_CLK_UNIPHIER) += uniphier/ diff --gita/drivers/clk/sifive/Kconfig b/drivers/clk/sifive/Kconfig new file
mode 100644 index 0000000000..81fc9f8fdadrivers/clk/sifive/Kconfig new file +2
-0@@ -0,0 +1,19 @@ +# SPDX-License-Identifier: GPL-2.0 +Quoted 8 lines
drivers/clk/sifive/Kconfig line 4
Quoted 2 lines
drivers/clk/sifive/Kconfig new file +2
-0+config CLK_ANALOGBITS_WRPLL_CLN28HPC + boolThe analogbits library is not specific to SiFive. The Linux Kernel patch series
adds it as a standalone entry to make it available to other drivers. I think the
same thing would also make sense here.Based on other CLK drivers, it seems analogbits library is not generic enough
might require more work to become generic PLL library.
Quoted 9 lines
To unblock this patch series, we have made it SiFive specific. Later if it is
accepted in Linux as standalone library then we will refactor here as well.IMHO, analogbits library is not generic enough so might be difficult to
take it as standalone library in Linux.
That makes sense. I agree, the best option will be to include the library the same way as in Linux.
Thanks,
Lukas
PATCH v2 7/11 clk: Add fixed-factor clock driver
In reply to Anup PatelThis patch adds fixed-factor clock driver which derives clock rate by dividing (div) and multiplying (mult) fixed factors to a parent clock.
--- drivers/clk/Makefile | 4 +- drivers/clk/clk_fixed_factor.c | 74 ++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/clk_fixed_factor.c
drivers/clk/Makefile +3 -1
@@ -4,7 +4,9 @@ # Wolfgang Denk, DENX Software Engineering, wd at denx.de. # -obj-$(CONFIG_$(SPL_TPL_)CLK) += clk-uclass.o clk_fixed_rate.o +obj-$(CONFIG_$(SPL_TPL_)CLK) += clk-uclass.o +obj-$(CONFIG_$(SPL_TPL_)CLK) += clk_fixed_rate.o +obj-$(CONFIG_$(SPL_TPL_)CLK) += clk_fixed_factor.o obj-y += imx/ obj-y += tegra/
drivers/clk/clk_fixed_factor.c new file +74 -0
74 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 7/11 clk: Add fixed-factor clock driver
Hi Anup,
Quoted 5 lines · Anup Patel
This patch adds fixed-factor clock driver which derives clock rate by dividing (div) and multiplying (mult) fixed factors to a parent clock.
Quoted 7 lines
Signed-off-by Atish Patra <[email protected]>Signed-off-by Anup Patel <[email protected]>--- drivers/clk/Makefile | 4 +- drivers/clk/clk_fixed_factor.c | 74 ++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 drivers/clk/clk_fixed_factor.c
Can you please update test/dm/clk.c to test this? You'll need to add this clock to sandbox.
Regards,
Simon
PATCH v2 7/11 clk: Add fixed-factor clock driver
Quoted 32 lines
-----Original Message-----
From: Simon Glass [mailto:sjg at chromium.org]
Sent: Thursday, January 31, 2019 3:34 PM
To: Anup Patel <[email protected]>
Cc: Rick Chen <[email protected]>; Bin Meng <[email protected]>; Joe Hershberger <[email protected]>; Lukas Auer <[email protected]>; Masahiro Yamada <[email protected]>; Alexander Graf <[email protected]>; Palmer Dabbelt <[email protected]>; Paul Walmsley <[email protected]>; Atish Patra <[email protected]>; Christoph Hellwig <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>
Subject: Re: [PATCH v2 07/11] clk: Add fixed-factor clock driverHi Anup,
Quoted 4 lines · Anup Patel
This patch adds fixed-factor clock driver which derives clock rate by dividing (div) and multiplying (mult) fixed factors to a parent clock.
Quoted 8 lines
Signed-off-by Atish Patra <[email protected]>Signed-off-by Anup Patel <[email protected]>--- drivers/clk/Makefile | 4 +- drivers/clk/clk_fixed_factor.c | 74 ++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644
drivers/clk/clk_fixed_factor.c
Quoted 2 lines
Can you please update
test/dm/clk.cto test this? You'll need to add this clock to sandbox.
Okay, will do.
Regards,
Anup
PATCH v2 8/11 drivers: serial_sifive: Fix baud rate calculation
In reply to Anup PatelFrom: Atish Patra <[email protected]>
Compute the baud rate multipler with more precision.
--- drivers/serial/serial_sifive.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)
drivers/serial/serial_sifive.c +26 -2
@@ -33,16 +33,40 @@ struct uart_sifive { };struct sifive_uart_platdata { -unsigned int clock; +unsigned long clock;int saved_input_char;struct uart_sifive *regs; }; +/** +* Find minimum divisor divides in_freq to max_target_hz; +* Based on uart driver n SiFive FSBL. +* +* f_baud = f_in / (div + 1) => div = (f_in / f_baud) - 1 +* The nearest integer solution requires rounding up as to not exceed +* max_target_hz. +* div = ceil(f_in / f_baud) - 1 +* = floor((f_in - 1 + f_baud) / f_baud) - 1 +* This should not overflow as long as (f_in - 1 + f_baud) does not exceed +* 2^32 - 1, which is unlikely since we represent frequencies in kHz. +*/ +static inline unsigned int uart_min_clk_divisor (unsigned long in_freq, +unsigned long max_target_hz) +{ +unsigned long quotient = + (in_freq + max_target_hz -1 ) / (max_target_hz); +/* Avoid underflow */ +if (quotient ==0 ) +return 0 ; +else +return quotient -1 ; +} +/* Set up the baud rate in gd struct */ static void _sifive_serial_setbrg (struct uart_sifive *regs,unsigned long clock,unsigned long baud) { -writel ((u32)((clock / baud) -1 ), ®s->div); +writel ((uart_min_clk_divisor (clock, baud)), ®s->div); }static void _sifive_serial_init (struct uart_sifive *regs)
Signature · 1 line
2.17.1
PATCH v2 8/11 drivers: serial_sifive: Fix baud rate calculation
Quoted 5 lines · Anup Patel
From: Atish Patra <[email protected]>
Compute the baud rate multipler with more precision.
Signed-off-by Atish Patra <[email protected]>
Same here.
Alex
PATCH v2 8/11 drivers: serial_sifive: Fix baud rate calculation
Quoted 21 lines
-----Original Message-----
From: Alexander Graf [mailto:agraf at suse.de]
Sent: Friday, January 18, 2019 5:22 PM
To: Anup Patel <[email protected]>; Rick Chen <[email protected]>; Bin Meng <[email protected]>; Joe Hershberger <[email protected]>; Lukas Auer <[email protected]>; Masahiro Yamada <[email protected]>; Simon Glass <[email protected]>
Cc: Palmer Dabbelt <[email protected]>; Paul Walmsley <[email protected]>; Atish Patra <[email protected]>; Christoph Hellwig <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>
Subject: Re: [PATCH v2 08/11] drivers:serial_sifive: Fix baud rate calculationQuoted 2 lines · Anup Patel
From: Atish Patra <[email protected]>
Quoted 7 lines
Quoted 3 lines
Compute the baud rate multipler with more precision.
Signed-off-by Atish Patra <[email protected]>Same here.
Alex
Sure, I will add my SoB.
Regards,
Anup
Auer
PATCH v2 8/11 drivers: serial_sifive: Fix baud rate calculation
In reply to Anup PatelQuoted 10 lines · Anup Patel
From: Atish Patra <[email protected]>
Compute the baud rate multipler with more precision.
Signed-off-by Atish Patra <[email protected]>Reviewed-by Alexander Graf <[email protected]>--- drivers/serial/serial_sifive.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)
PATCH v2 9/11 drivers: serial_sifive: Skip baudrate config if no input clock
In reply to Anup PatelFrom: Atish Patra <[email protected]>
It is possible that input clock is not available because clk device was not available and 'clock-frequency' DT property is also not available.
In this case, instead of failing we should just skip baudrate config by returning zero.
--- drivers/serial/serial_sifive.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
drivers/serial/serial_sifive.c +16 -16
@@ -99,27 +99,27 @@ static int _sifive_serial_getc(struct uart_sifive *regs)static int sifive_serial_setbrg (struct udevice *dev,int baudrate) { -int err; +int ret;struct clk clk;struct sifive_uart_platdata *platdata =dev_get_platdata (dev); +u32 clock =0 ; - err =clk_get_by_index (dev,0 , &clk); -if (!err) { - err =clk_get_rate (&clk); -if (!IS_ERR_VALUE (err)) - platdata->clock = err; - }else if (err != -ENOENT && err != -ENODEV && err != -ENOSYS ) { + ret =clk_get_by_index (dev,0 , &clk); +if (IS_ERR_VALUE (ret)) {debug ("SiFive UART failed to get clock\n" ); -return err; - } - -if (!platdata->clock) - platdata->clock =dev_read_u32_default (dev,"clock-frequency" ,0 ); -if (!platdata->clock) { -debug ("SiFive UART clock not defined\n" ); -return -EINVAL ; + ret =dev_read_u32 (dev,"clock-frequency" , &clock); +if (IS_ERR_VALUE (ret)) { +debug ("SiFive UART clock not defined\n" ); +return 0 ; + } + }else { + clock =clk_get_rate (&clk); +if (IS_ERR_VALUE (clock)) { +debug ("SiFive UART clock get rate failed\n" ); +return 0 ; + } } - + platdata->clock = clock;_sifive_serial_setbrg (platdata->regs, platdata->clock, baudrate);return 0 ;
Signature · 1 line
2.17.1
Auer
PATCH v2 9/11 drivers: serial_sifive: Skip baudrate config if no input clock
Hi Anup,
Quoted 5 lines · Anup Patel
From: Atish Patra <[email protected]>
It is possible that input clock is not available because clk device was not available and 'clock-frequency' DT property is also not available.
Why would the clock device not be available?
I suspect the problem is that the clock driver is not probed pre- relocation. Adding DM_FLAG_PRE_RELOC to the driver flags would fix this.
Quoted 3 lines
In this case, instead of failing we should just skip baudrate config by returning zero.
Won't this cause issues if an incorrect baudrate is set?
Thanks,
Lukas
Quoted 61 lines
Signed-off-by Atish Patra <[email protected]>Signed-off-by Anup Patel <[email protected]>Reviewed-by Alexander Graf <[email protected]>--- drivers/serial/serial_sifive.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)drivers/serial/serial_sifive.c +16
-16@@ -99,27 +99,27 @@ static int _sifive_serial_getc(struct uart_sifive *regs)static int sifive_serial_setbrg (struct udevice *dev,int baudrate) { -int err; +int ret;struct clk clk;struct sifive_uart_platdata *platdata =dev_get_platdata (dev); +u32 clock =0 ; - err =clk_get_by_index (dev,0 , &clk); -if (!err) { - err =clk_get_rate (&clk); -if (!IS_ERR_VALUE (err)) - platdata->clock = err; - }else if (err != -ENOENT && err != -ENODEV && err != -ENOSYS ) { + ret =clk_get_by_index (dev,0 , &clk); +if (IS_ERR_VALUE (ret)) {debug ("SiFive UART failed to get clock\n" ); -return err; - } - -if (!platdata->clock) - platdata->clock =dev_read_u32_default (dev,"clock- frequency", 0); -if (!platdata->clock) { -debug ("SiFive UART clock not defined\n" ); -return -EINVAL ; + ret =dev_read_u32 (dev,"clock-frequency" , &clock); +if (IS_ERR_VALUE (ret)) { +debug ("SiFive UART clock not defined\n" ); +return 0 ; + } + }else { + clock =clk_get_rate (&clk); +if (IS_ERR_VALUE (clock)) { +debug ("SiFive UART clock get rate failed\n" ); +return 0 ; + } } - + platdata->clock = clock;_sifive_serial_setbrg(platdata->regs,
platdata->clock,
baudrate);return 0;
PATCH v2 9/11 drivers: serial_sifive: Skip baudrate config if no input clock
Quoted 5 lines · Lukas
Hi Anup,
Quoted 2 lines · Anup Patel
From: Atish Patra <[email protected]>
Quoted 9 lines
Quoted 3 lines
It is possible that input clock is not available because clk device was not available and 'clock-frequency' DT property is also not available.
Why would the clock device not be available?
I suspect the problem is that the clock driver is not probed pre- relocation. AddingDM_FLAG_PRE_RELOCto the driver flags would fix this.
The problem is serial driver gets probed first before clock driver even if we add DM_FLAG_PRE_RELOC.
Quoted 6 lines
Quoted 3 lines
In this case, instead of failing we should just skip baudrate config by returning zero.
Won't this cause issues if an incorrect baudrate is set?
It might be possible that baudrate is configured by earlier boot stage. Thus, any early information can be displayed in console by the serial driver even if it is not configured correctly by u-boot.
Regards,
Atish
Quoted 65 lines
Thanks,
LukasQuoted 61 lines
Signed-off-by Atish Patra <[email protected]>Signed-off-by Anup Patel <[email protected]>Reviewed-by Alexander Graf <[email protected]>--- drivers/serial/serial_sifive.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)drivers/serial/serial_sifive.c +16
-16@@ -99,27 +99,27 @@ static int _sifive_serial_getc(struct uart_sifive *regs)static int sifive_serial_setbrg (struct udevice *dev,int baudrate) { -int err; +int ret;struct clk clk;struct sifive_uart_platdata *platdata =dev_get_platdata (dev); +u32 clock =0 ; - err =clk_get_by_index (dev,0 , &clk); -if (!err) { - err =clk_get_rate (&clk); -if (!IS_ERR_VALUE (err)) - platdata->clock = err; - }else if (err != -ENOENT && err != -ENODEV && err != -ENOSYS ) { + ret =clk_get_by_index (dev,0 , &clk); +if (IS_ERR_VALUE (ret)) {debug ("SiFive UART failed to get clock\n" ); -return err; - } - -if (!platdata->clock) - platdata->clock =dev_read_u32_default (dev,"clock- frequency", 0); -if (!platdata->clock) { -debug ("SiFive UART clock not defined\n" ); -return -EINVAL ; + ret =dev_read_u32 (dev,"clock-frequency" , &clock); +if (IS_ERR_VALUE (ret)) { +debug ("SiFive UART clock not defined\n" ); +return 0 ; + } + }else { + clock =clk_get_rate (&clk); +if (IS_ERR_VALUE (clock)) { +debug ("SiFive UART clock get rate failed\n" ); +return 0 ; + } } - + platdata->clock = clock;_sifive_serial_setbrg(platdata->regs,
platdata->clock,
baudrate);return 0;
Auer
PATCH v2 9/11 drivers: serial_sifive: Skip baudrate config if no input clock
Quoted 16 lines · Atish Patra
Quoted 5 lines · Lukas
Hi Anup,
Quoted 2 lines · Anup Patel
From: Atish Patra <[email protected]>
Quoted 9 lines
Quoted 3 lines
It is possible that input clock is not available because clk device was not available and 'clock-frequency' DT property is also not available.
Why would the clock device not be available?
I suspect the problem is that the clock driver is not probed pre- relocation. AddingDM_FLAG_PRE_RELOCto the driver flags would fix this.
Quoted 3 lines
The problem is serial driver gets probed first before clock driver even
if we addDM_FLAG_PRE_RELOC.
That makes sense. I just browsed through the code to see what other boards do here. The serial driver for the MPC83xx SoC series directly probes the clock driver (see get_serial_clock in driver/clk/mpc83xx_clk.c called from the serial driver). Maybe we should do something similar here?
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
In this case, instead of failing we should just skip baudrate config by returning zero.
Quoted 8 lines
Quoted 2 lines
Won't this cause issues if an incorrect baudrate is set?
It might be possible that baudrate is configured by earlier boot stage.
Thus, any early information can be displayed in console by the serial
driver even if it is not configured correctly by u-boot.
Yes, it is very likely not going to be a problem, but if we can fix it it would be great :)
Thanks,
Lukas
Quoted 70 lines
Regards,
AtishQuoted 67 lines
Thanks,
LukasQuoted 64 lines
Signed-off-by Atish Patra <[email protected]>Signed-off-by Anup Patel <[email protected]>Reviewed-by Alexander Graf <[email protected]>--- drivers/serial/serial_sifive.c | 32 ++++++++++++++++----------- ----- 1 file changed, 16 insertions(+), 16 deletions(-)drivers/serial/serial_sifive.c +0
-0@@ -99,27 +99,27 @@ static int _sifive_serial_getc(struct
uart_sifive
*regs)static int sifive_serial_setbrg(struct udevice *dev, int
baudrate)
{drivers/serial/serial_sifive.c +1
-1-int err; +int ret;struct clk clk; struct sifive_uart_platdata *platdata =
dev_get_platdata(dev);drivers/serial/serial_sifive.c +1
-6+u32 clock =0 ; - err =clk_get_by_index (dev,0 , &clk); -if (!err) { - err =clk_get_rate (&clk); -if (!IS_ERR_VALUE (err)) - platdata->clock = err; - }else if (err != -ENOENT && err != -ENODEV && err != -ENOSYS ){
drivers/serial/serial_sifive.c +2
-5+ ret =clk_get_by_index (dev,0 , &clk); +if (IS_ERR_VALUE (ret)) {debug ("SiFive UART failed to get clock\n" ); -return err; - } - -if (!platdata->clock) - platdata->clock = dev_read_u32_default(dev, "clock-frequency", 0);
drivers/serial/serial_sifive.c +12
-4-if (!platdata->clock) { -debug ("SiFive UART clock not defined\n" ); -return -EINVAL ; + ret =dev_read_u32 (dev,"clock-frequency" , &clock); +if (IS_ERR_VALUE (ret)) { +debug ("SiFive UART clock not defined\n" ); +return 0 ; + } + }else { + clock =clk_get_rate (&clk); +if (IS_ERR_VALUE (clock)) { +debug ("SiFive UART clock get rate failed\n" ); +return 0 ; + } } - + platdata->clock = clock; _sifive_serial_setbrg(platdata->regs, platdata->clock,baudrate);
return 0;
Auer
PATCH v2 9/11 drivers: serial_sifive: Skip baudrate config if no input clock
Quoted 22 lines · Lukas
Quoted 17 lines · Atish Patra
Quoted 9 lines · Lukas
Hi Anup,
Quoted 5 lines · Anup Patel
From: Atish Patra <[email protected]>
It is possible that input clock is not available because clk device was not available and 'clock-frequency' DT property is also not available.
Quoted 6 lines
Why would the clock device not be available?
I suspect the problem is that the clock driver is not probed pre- relocation. AddingDM_FLAG_PRE_RELOCto the driver flags would fix
this.Quoted 3 lines
The problem is serial driver gets probed first before clock driver even
if we addDM_FLAG_PRE_RELOC.
Quoted 6 lines
That makes sense. I just browsed through the code to see what other boards do here. The serial driver for the MPC83xx SoC series directly probes the clock driver (see
get_serial_clockindriver/clk/mpc83xx_clk.ccalled from the serial driver). Maybe we should do something similar here?
What are your thoughts on this, can you add something like it?
Thanks,
Lukas
Quoted 98 lines
Quoted 11 lines
Quoted 5 lines
Quoted 2 lines
In this case, instead of failing we should just skip baudrate config by returning zero.
Won't this cause issues if an incorrect baudrate is set?
It might be possible that baudrate is configured by earlier boot stage.
Thus, any early information can be displayed in console by the serial
driver even if it is not configured correctly by u-boot.Yes, it is very likely not going to be a problem, but if we can fix it
it would be great :)Thanks,
LukasQuoted 74 lines
Regards,
AtishQuoted 72 lines
Thanks,
LukasQuoted 69 lines
Signed-off-by Atish Patra <[email protected]>Signed-off-by Anup Patel <[email protected]>Reviewed-by Alexander Graf <[email protected]>--- drivers/serial/serial_sifive.c | 32 ++++++++++++++++--------- -- ----- 1 file changed, 16 insertions(+), 16 deletions(-)drivers/serial/serial_sifive.c +0
-0@@ -99,27 +99,27 @@ static int _sifive_serial_getc(struct
uart_sifive
*regs)static int sifive_serial_setbrg(struct udevice *dev, int
baudrate)
{drivers/serial/serial_sifive.c +1
-1-int err; +int ret;struct clk clk; struct sifive_uart_platdata *platdata =
dev_get_platdata(dev);drivers/serial/serial_sifive.c +1
-7+u32 clock =0 ; - err =clk_get_by_index (dev,0 , &clk); -if (!err) { - err =clk_get_rate (&clk); -if (!IS_ERR_VALUE (err)) - platdata->clock = err; - }else if (err != -ENOENT && err != -ENODEV && err != -ENOSYS ){
drivers/serial/serial_sifive.c +2
-5+ ret =clk_get_by_index (dev,0 , &clk); +if (IS_ERR_VALUE (ret)) {debug ("SiFive UART failed to get clock\n" ); -return err; - } - -if (!platdata->clock) - platdata->clock = dev_read_u32_default(dev,"clock-
frequency", 0);drivers/serial/serial_sifive.c +1
-3-if (!platdata->clock) { -debug ("SiFive UART clock not defined\n" ); -return -EINVAL ; + ret = dev_read_u32(dev, "clock-frequency",&clock);
drivers/serial/serial_sifive.c +2
-0+if (IS_ERR_VALUE (ret)) { + debug("SiFive UART clock notdefined\n");
drivers/serial/serial_sifive.c +6
-0+return 0 ; + } + }else { + clock =clk_get_rate (&clk); +if (IS_ERR_VALUE (clock)) { + debug("SiFive UART clock get ratefailed\n");
drivers/serial/serial_sifive.c +3
-1+return 0 ; + } } - + platdata->clock = clock; _sifive_serial_setbrg(platdata->regs, platdata->clock,baudrate);
Quoted 1 line
Quoted 1 line
Quoted 1 line
return 0;
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH v2 10/11 cpu: Bind timer driver for boot hart
In reply to Anup PatelFrom: Atish Patra <[email protected]>
Currently, timer driver is bound only for hart0.
There is no mandatory requirement that hart0 should always come up. In fact, HiFive Unleashed SoC hart0 doesn't boot in S-mode because it only has M-mode.
The timer driver should be bound for boot hart.
--- drivers/cpu/riscv_cpu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/cpu/riscv_cpu.c +4 -3
@@ -10,6 +10,8 @@#include <dm/device-internal.h> #include <dm/lists.h> +DECLARE_GLOBAL_DATA_PTR ; +static int riscv_cpu_get_desc (struct udevice *dev,char *buf,int size) {const char *isa;
@@ -62,7 +64,6 @@ static int riscv_cpu_bind(struct udevice *dev)/* save the hart id */ plat->cpu_id =dev_read_addr (dev); -/* first examine the property in current cpu node */ ret =dev_read_u32 (dev,"timebase-frequency" , &plat->timebase_freq);/* if not found, then look at the parent /cpus node */
@@ -71,7 +72,7 @@ static int riscv_cpu_bind(struct udevice *dev) &plat->timebase_freq);/* -* Bind riscv-timer driver on hart 0 +* Bind riscv-timer driver on boot hart. * * We only instantiate one timer device which is enough for U-Boot. * Pass the "timebase-frequency" value as the driver data for the
@@ -80,7 +81,7 @@ static int riscv_cpu_bind(struct udevice *dev)* Return value is not checked since it's possible that the timer * driver is not included. */ -if (!plat->cpu_id && plat->timebase_freq) { +if (plat->cpu_id == gd->arch.boot_hart && plat->timebase_freq) { drv =lists_driver_lookup_name ("riscv_timer" );if (!drv) {debug ("Cannot find the timer driver, not included?\n" );
Signature · 1 line
2.17.1
PATCH v2 10/11 cpu: Bind timer driver for boot hart
Quoted 11 lines · Anup Patel
From: Atish Patra <[email protected]>
Currently, timer driver is bound only for hart0.
There is no mandatory requirement that hart0 should always come up. In fact, HiFive Unleashed SoC hart0 doesn't boot in S-mode because it only has M-mode.
The timer driver should be bound for boot hart.
Signed-off-by Atish Patra <[email protected]>
... and here :)
Quoted 1 line
Reviewed-by Alexander Graf <[email protected]>
Alex
PATCH v2 10/11 cpu: Bind timer driver for boot hart
Quoted 27 lines
-----Original Message-----
From: Alexander Graf [mailto:agraf at suse.de]
Sent: Friday, January 18, 2019 5:22 PM
To: Anup Patel <[email protected]>; Rick Chen <[email protected]>; Bin Meng <[email protected]>; Joe Hershberger <[email protected]>; Lukas Auer <[email protected]>; Masahiro Yamada <[email protected]>; Simon Glass <[email protected]>
Cc: Palmer Dabbelt <[email protected]>; Paul Walmsley <[email protected]>; Atish Patra <[email protected]>; Christoph Hellwig <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>
Subject: Re: [PATCH v2 10/11] cpu: Bind timer driver for boot hartQuoted 8 lines · Anup Patel
From: Atish Patra <[email protected]>
Currently, timer driver is bound only for hart0.
There is no mandatory requirement that hart0 should always come up. In fact, HiFive Unleashed SoC hart0 doesn't boot in S-mode because it only has M-mode.
Quoted 6 lines
Quoted 3 lines
The timer driver should be bound for boot hart.
Signed-off-by Atish Patra <[email protected]>... and here :)
Sure, I will add my SoB.
Regards,
Anup
Auer
PATCH v2 10/11 cpu: Bind timer driver for boot hart
In reply to Anup PatelQuoted 8 lines · Anup Patel
From: Atish Patra <[email protected]>
Currently, timer driver is bound only for hart0.
There is no mandatory requirement that hart0 should always come up. In fact, HiFive Unleashed SoC hart0 doesn't boot in S-mode because it only has M-mode.
Quoted 8 lines
The timer driver should be bound for boot hart.
Signed-off-by Atish Patra <[email protected]>Reviewed-by Alexander Graf <[email protected]>--- drivers/cpu/riscv_cpu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
PATCH v2 10/11 cpu: Bind timer driver for boot hart
In reply to Anup PatelQuoted 9 lines · Anup Patel
From: Atish Patra <[email protected]>
Currently, timer driver is bound only for hart0.
There is no mandatory requirement that hart0 should always come up. In fact, HiFive Unleashed SoC hart0 doesn't boot in S-mode because it only has M-mode.
Quoted 8 lines
The timer driver should be bound for boot hart.
Signed-off-by Atish Patra <[email protected]>Reviewed-by Alexander Graf <[email protected]>--- drivers/cpu/riscv_cpu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
PATCH v2 11/11 riscv: Add SiFive FU540 board support
In reply to Anup PatelThis patch adds SiFive FU540 board support. For now, only SiFive serial, SiFive PRCI, and Cadance MACB drivers are only enabled. The SiFive FU540 defconfig by default builds U-Boot for S-Mode because U-Boot on SiFive FU540 will run in S-Mode as payload of BBL or OpenSBI.
--- arch/riscv/Kconfig | 4 ++++ board/sifive/fu540/Kconfig | 42 +++++++++++++++++++++++++++++++++ board/sifive/fu540/MAINTAINERS | 9 +++++++ board/sifive/fu540/Makefile | 5 ++++ board/sifive/fu540/fu540.c | 17 ++++++++++++++ configs/sifive_fu540_defconfig | 11 +++++++++ include/configs/sifive-fu540.h | 43 ++++++++++++++++++++++++++++++++++ 7 files changed, 131 insertions(+) create mode 100644 board/sifive/fu540/Kconfig create mode 100644 board/sifive/fu540/MAINTAINERS create mode 100644 board/sifive/fu540/Makefile create mode 100644 board/sifive/fu540/fu540.c create mode 100644 configs/sifive_fu540_defconfig create mode 100644 include/configs/sifive-fu540.h
arch/riscv/Kconfig +4 -0
@@ -14,11 +14,15 @@ config TARGET_AX25_AE350 config TARGET_QEMU_VIRT bool "Support QEMU Virt Board" +config TARGET_SIFIVE_FU540 + bool "Support SiFive FU540 Board" + endchoice # board-specific options below source "board/AndesTech/ax25-ae350/Kconfig" source "board/emulation/qemu-riscv/Kconfig" +source "board/sifive/fu540/Kconfig" # platform-specific options below source "arch/riscv/cpu/ax25/Kconfig"
board/sifive/fu540/Kconfig new file +42 -0
42 lines not on this page · raw message
board/sifive/fu540/MAINTAINERS new file +9 -0
@@ -0,0 +1,9 @@ +SiFive FU540 BOARD +M: Paul Walmsley <[email protected]> +M: Palmer Dabbelt <[email protected]> +M: Anup Patel <[email protected]> +M: Atish Patra <[email protected]> +S: Maintained +F: board/sifive/fu540/ +F: include/configs/sifive-fu540.h +F: configs/sifive_fu540_defconfig
board/sifive/fu540/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (c) 2019 Western Digital Corporation or its affiliates. + +obj-y += fu540.o
board/sifive/fu540/fu540.c new file +17 -0
@@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (c) 2019 Western Digital Corporation or its affiliates. +* +* Authors: +* Anup Patel <[email protected]> +*/ + +#include <common.h> +#include <dm.h> + +int board_init (void ) +{ +/* For now nothing to do here. */ + +return 0 ; +}
configs/sifive_fu540_defconfig new file +11 -0
@@ -0,0 +1,11 @@ +CONFIG_RISCV=y +CONFIG_TARGET_SIFIVE_FU540=y +CONFIG_RISCV_SMODE=y +CONFIG_ARCH_RV64I=y +CONFIG_DISTRO_DEFAULTS=y +CONFIG_NR_DRAM_BANKS=1 +CONFIG_FIT=y +CONFIG_DISPLAY_CPUINFO=y +CONFIG_DISPLAY_BOARDINFO=y +CONFIG_CMD_MII=y +CONFIG_OF_PRIOR_STAGE=y
include/configs/sifive-fu540.h new file +43 -0
43 lines not on this page · raw message
Signature · 1 line
2.17.1
Auer
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Hi Anup,
Quoted 18 lines · Anup Patel
This patch adds SiFive FU540 board support. For now, only SiFive serial, SiFive PRCI, and Cadance MACB drivers are only enabled. The SiFive FU540 defconfig by default builds U-Boot for S-Mode because U-Boot on SiFive FU540 will run in S-Mode as payload of BBL or OpenSBI.
Signed-off-by Atish Patra <[email protected]>Signed-off-by Anup Patel <[email protected]>Reviewed-by Alexander Graf <[email protected]>--- arch/riscv/Kconfig | 4 ++++ board/sifive/fu540/Kconfig | 42 +++++++++++++++++++++++++++++++++ board/sifive/fu540/MAINTAINERS | 9 +++++++ board/sifive/fu540/Makefile | 5 ++++ board/sifive/fu540/fu540.c | 17 ++++++++++++++ configs/sifive_fu540_defconfig | 11 +++++++++ include/configs/sifive-fu540.h | 43
Quoted 9 lines
++++++++++++++++++++++++++++++++++
7 files changed, 131 insertions(+) create mode 100644 board/sifive/fu540/Kconfig create mode 100644 board/sifive/fu540/MAINTAINERS create mode 100644 board/sifive/fu540/Makefile create mode 100644 board/sifive/fu540/fu540.c create mode 100644 configs/sifive_fu540_defconfig create mode 100644 include/configs/sifive-fu540.h
Can you add a short README on how to flash and use U-Boot on the HiFive Unleashed?
Please also see one more comment below.
Quoted 176 lines
arch/riscv/Kconfig +4
-0@@ -14,11 +14,15 @@ config TARGET_AX25_AE350 config TARGET_QEMU_VIRT bool "Support QEMU Virt Board" +config TARGET_SIFIVE_FU540 + bool "Support SiFive FU540 Board" + endchoice # board-specific options below source "board/AndesTech/ax25-ae350/Kconfig" source "board/emulation/qemu-riscv/Kconfig" +source "board/sifive/fu540/Kconfig" # platform-specific options below source "arch/riscv/cpu/ax25/Kconfig"board/sifive/fu540/Kconfig new file +42
-0@@ -0,0 +1,42 @@ +if TARGET_SIFIVE_FU540 + +config SYS_BOARD + default "fu540" + +config SYS_VENDOR + default "sifive" + +config SYS_CPU + default "generic" + +config SYS_CONFIG_NAME + default "sifive-fu540" + +config SYS_TEXT_BASE + default 0x80000000 if !RISCV_SMODE + default 0x80200000 if RISCV_SMODE + +config BOARD_SPECIFIC_OPTIONS # dummy + def_bool y + select GENERIC_RISCV + imply CMD_DHCP + imply CMD_EXT2 + imply CMD_EXT4 + imply CMD_FAT + imply CMD_FS_GENERIC + imply CMD_NET + imply CMD_PING + imply CLK_SIFIVE + imply CLK_SIFIVE_FU540_PRCI + imply DOS_PARTITION + imply EFI_PARTITION + imply IP_DYN + imply ISO_PARTITION + imply MACB + imply MII + imply NET_RANDOM_ETHADDR + imply PHY_LIB + imply PHY_MSCC + imply SIFIVE_SERIAL + +endifboard/sifive/fu540/MAINTAINERS new file +9
-0@@ -0,0 +1,9 @@ +SiFive FU540 BOARD +M: Paul Walmsley <[email protected]> +M: Palmer Dabbelt <[email protected]> +M: Anup Patel <[email protected]> +M: Atish Patra <[email protected]> +S: Maintained +F: board/sifive/fu540/ +F: include/configs/sifive-fu540.h +F: configs/sifive_fu540_defconfigboard/sifive/fu540/Makefile new file +5
-0@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (c) 2019 Western Digital Corporation or its affiliates. + +obj-y += fu540.oboard/sifive/fu540/fu540.c new file +17
-0@@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (c) 2019 Western Digital Corporation or its affiliates. +* +* Authors: +* Anup Patel <[email protected]> +*/ + +#include <common.h> +#include <dm.h> + +int board_init (void ) +{ +/* For now nothing to do here. */ + +return 0 ; +}configs/sifive_fu540_defconfig new file +11
-0@@ -0,0 +1,11 @@ +CONFIG_RISCV=y +CONFIG_TARGET_SIFIVE_FU540=y +CONFIG_RISCV_SMODE=y +CONFIG_ARCH_RV64I=y +CONFIG_DISTRO_DEFAULTS=y +CONFIG_NR_DRAM_BANKS=1 +CONFIG_FIT=y +CONFIG_DISPLAY_CPUINFO=y +CONFIG_DISPLAY_BOARDINFO=y +CONFIG_CMD_MII=y +CONFIG_OF_PRIOR_STAGE=yinclude/configs/sifive- renamed from include/configs/sifive-fu540.h +0
-0
fu540.h
new file mode 100644
index 0000000000..7007b5f6afinclude/configs/sifive-fu540.h new file +32
-0@@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (c) 2019 Western Digital Corporation or its affiliates. +* +* Authors: +* Anup Patel <[email protected]> +*/ + +#ifndef __CONFIG_H +#define __CONFIG_H + +#include <linux/sizes.h> + +#define CONFIG_SYS_SDRAM_BASE 0x80000000 +#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + SZ_2M) + +#define CONFIG_SYS_LOAD_ADDR (CONFIG_SYS_SDRAM_BASE + SZ_2M) + +#define CONFIG_SYS_MALLOC_LEN SZ_8M + +#define CONFIG_SYS_BOOTM_LEN SZ_16M + +#define CONFIG_STANDALONE_LOAD_ADDR 0x80200000 + +/* Environment options */ +#define CONFIG_ENV_SIZE SZ_4K + +#define BOOT_TARGET_DEVICES (func) \ + func(DHCP, dhcp, na) + +#include <config_distro_bootcmd.h>
include/configs/sifive-fu540.h line 42
Quoted 10 lines
include/configs/sifive-fu540.h new file +10
-0+ +#define CONFIG_EXTRA_ENV_SETTINGS \ + "fdt_high=0xffffffffffffffff\0" \ + "initrd_high=0xffffffffffffffff\0" \ + "kernel_addr_r=0x80600000\0" \ + "fdt_addr_r=0x82200000\0" \ + "scriptaddr=0x82300000\0" \ + "pxefile_addr_r=0x82400000\0" \ + "ramdisk_addr_r=0x82500000\0" \ + BOOTENV
I think it would be helpful to define the kernel command line using the bootargs environment variable here. For testing I used "bootargs=console=ttySI0 earlyprintk root=/dev/mmcblk0p2 rootwait" locally.
Thanks,
Lukas
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 31 lines · Lukas
Hi Anup,
Quoted 20 lines · Anup Patel
This patch adds SiFive FU540 board support. For now, only SiFive serial, SiFive PRCI, and Cadance MACB drivers are only enabled. The SiFive FU540 defconfig by default builds U-Boot for S-Mode because U-Boot on SiFive FU540 will run in S-Mode as payload of BBL or OpenSBI.
Signed-off-by Atish Patra <[email protected]>Signed-off-by Anup Patel <[email protected]>Reviewed-by Alexander Graf <[email protected]>--- arch/riscv/Kconfig | 4 ++++ board/sifive/fu540/Kconfig | 42 +++++++++++++++++++++++++++++++++ board/sifive/fu540/MAINTAINERS | 9 +++++++ board/sifive/fu540/Makefile | 5 ++++ board/sifive/fu540/fu540.c | 17 ++++++++++++++ configs/sifive_fu540_defconfig | 11 +++++++++ include/configs/sifive-fu540.h | 43 ++++++++++++++++++++++++++++++++++ 7 files changed, 131 insertions(+)Quoted 7 lines
create mode 100644 board/sifive/fu540/Kconfig create mode 100644 board/sifive/fu540/MAINTAINERS create mode 100644 board/sifive/fu540/Makefile create mode 100644
board/sifive/fu540/fu540.ccreate mode 100644 configs/sifive_fu540_defconfig create mode 100644include/configs/sifive-fu540.h
Quoted 5 lines
Reviewed-by Lukas Auer <[email protected]>Can you add a short README on how to flash and use U-Boot on the HiFive Unleashed?
Thanks for the review. Sure. We will add a README document.
Quoted 185 lines
Please also see one more comment below.
Quoted 183 lines
arch/riscv/Kconfig +4
-0@@ -14,11 +14,15 @@ config TARGET_AX25_AE350 config TARGET_QEMU_VIRT bool "Support QEMU Virt Board" +config TARGET_SIFIVE_FU540 + bool "Support SiFive FU540 Board" + endchoice # board-specific options below source "board/AndesTech/ax25-ae350/Kconfig" source "board/emulation/qemu-riscv/Kconfig" +source "board/sifive/fu540/Kconfig" # platform-specific options below source "arch/riscv/cpu/ax25/Kconfig"board/sifive/fu540/Kconfig new file +42
-0@@ -0,0 +1,42 @@ +if TARGET_SIFIVE_FU540 + +config SYS_BOARD + default "fu540" + +config SYS_VENDOR + default "sifive" + +config SYS_CPU + default "generic" + +config SYS_CONFIG_NAME + default "sifive-fu540" + +config SYS_TEXT_BASE + default 0x80000000 if !RISCV_SMODE + default 0x80200000 if RISCV_SMODE + +config BOARD_SPECIFIC_OPTIONS # dummy + def_bool y + select GENERIC_RISCV + imply CMD_DHCP + imply CMD_EXT2 + imply CMD_EXT4 + imply CMD_FAT + imply CMD_FS_GENERIC + imply CMD_NET + imply CMD_PING + imply CLK_SIFIVE + imply CLK_SIFIVE_FU540_PRCI + imply DOS_PARTITION + imply EFI_PARTITION + imply IP_DYN + imply ISO_PARTITION + imply MACB + imply MII + imply NET_RANDOM_ETHADDR + imply PHY_LIB + imply PHY_MSCC + imply SIFIVE_SERIAL + +endifboard/sifive/fu540/MAINTAINERS new file +9
-0@@ -0,0 +1,9 @@ +SiFive FU540 BOARD +M: Paul Walmsley <[email protected]> +M: Palmer Dabbelt <[email protected]> +M: Anup Patel <[email protected]> +M: Atish Patra <[email protected]> +S: Maintained +F: board/sifive/fu540/ +F: include/configs/sifive-fu540.h +F: configs/sifive_fu540_defconfigboard/sifive/fu540/Makefile new file +5
-0@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (c) 2019 Western Digital Corporation or its affiliates. + +obj-y += fu540.oboard/sifive/fu540/fu540.c new file +17
-0@@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (c) 2019 Western Digital Corporation or its affiliates. +* +* Authors: +* Anup Patel <[email protected]> +*/ + +#include <common.h> +#include <dm.h> + +int board_init (void ) +{ +/* For now nothing to do here. */ + +return 0 ; +}configs/sifive_fu540_defconfig new file +11
-0@@ -0,0 +1,11 @@ +CONFIG_RISCV=y +CONFIG_TARGET_SIFIVE_FU540=y +CONFIG_RISCV_SMODE=y +CONFIG_ARCH_RV64I=y +CONFIG_DISTRO_DEFAULTS=y +CONFIG_NR_DRAM_BANKS=1 +CONFIG_FIT=y +CONFIG_DISPLAY_CPUINFO=y +CONFIG_DISPLAY_BOARDINFO=y +CONFIG_CMD_MII=y +CONFIG_OF_PRIOR_STAGE=yinclude/configs/sifive- renamed from include/configs/sifive-fu540.h +0
-0
fu540.h
new file mode 100644
index 0000000000..7007b5f6afinclude/configs/sifive-fu540.h new file +39
-0@@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (c) 2019 Western Digital Corporation or its affiliates. +* +* Authors: +* Anup Patel <[email protected]> +*/ + +#ifndef __CONFIG_H +#define __CONFIG_H + +#include <linux/sizes.h> + +#define CONFIG_SYS_SDRAM_BASE 0x80000000 +#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + SZ_2M) + +#define CONFIG_SYS_LOAD_ADDR (CONFIG_SYS_SDRAM_BASE + SZ_2M) + +#define CONFIG_SYS_MALLOC_LEN SZ_8M + +#define CONFIG_SYS_BOOTM_LEN SZ_16M + +#define CONFIG_STANDALONE_LOAD_ADDR 0x80200000 + +/* Environment options */ +#define CONFIG_ENV_SIZE SZ_4K + +#define BOOT_TARGET_DEVICES (func) \ + func(DHCP, dhcp, na) + +#include <config_distro_bootcmd.h> + +#define CONFIG_EXTRA_ENV_SETTINGS \ + "fdt_high=0xffffffffffffffff\0" \ + "initrd_high=0xffffffffffffffff\0" \ + "kernel_addr_r=0x80600000\0" \ + "fdt_addr_r=0x82200000\0" \ + "scriptaddr=0x82300000\0" \
Quoted 9 lines
include/configs/sifive-fu540.h line 41
Quoted 3 lines
include/configs/sifive-fu540.h new file +3
-0+"pxefile_addr_r=0x82400000\0" \ +"ramdisk_addr_r=0x82500000\0" \ +BOOTENV I think it would be helpful to define the kernel command line using the bootargs environment variable here. For testing I used "bootargs=console=ttySI0 earlyprintk root=/dev/mmcblk0p2 rootwait" locally.
The root partition might be different in different setup. For example, if expansion board is connected, root partition might be on sata or nvme drive. Should we add a fixed root partition to the bootargs ?
Regards,
Atish
Quoted 3 lines
Thanks,
Lukas
Auer
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 243 lines · Atish Patra
Quoted 31 lines · Lukas
Hi Anup,
Quoted 20 lines · Anup Patel
This patch adds SiFive FU540 board support. For now, only SiFive serial, SiFive PRCI, and Cadance MACB drivers are only enabled. The SiFive FU540 defconfig by default builds U-Boot for S-Mode because U-Boot on SiFive FU540 will run in S-Mode as payload of BBL or OpenSBI.
Signed-off-by Atish Patra <[email protected]>Signed-off-by Anup Patel <[email protected]>Reviewed-by Alexander Graf <[email protected]>--- arch/riscv/Kconfig | 4 ++++ board/sifive/fu540/Kconfig | 42 +++++++++++++++++++++++++++++++++ board/sifive/fu540/MAINTAINERS | 9 +++++++ board/sifive/fu540/Makefile | 5 ++++ board/sifive/fu540/fu540.c | 17 ++++++++++++++ configs/sifive_fu540_defconfig | 11 +++++++++ include/configs/sifive-fu540.h | 43 ++++++++++++++++++++++++++++++++++ 7 files changed, 131 insertions(+)Quoted 7 lines
create mode 100644 board/sifive/fu540/Kconfig create mode 100644 board/sifive/fu540/MAINTAINERS create mode 100644 board/sifive/fu540/Makefile create mode 100644
board/sifive/fu540/fu540.ccreate mode 100644 configs/sifive_fu540_defconfig create mode 100644include/configs/sifive-fu540.hQuoted 6 lines
Reviewed-by Lukas Auer <[email protected]>Can you add a short README on how to flash and use U-Boot on the HiFive
Unleashed?Thanks for the review. Sure. We will add a README document.
Quoted 193 lines
Please also see one more comment below.
Quoted 191 lines
arch/riscv/Kconfig +4
-0@@ -14,11 +14,15 @@ config TARGET_AX25_AE350 config TARGET_QEMU_VIRT bool "Support QEMU Virt Board" +config TARGET_SIFIVE_FU540 + bool "Support SiFive FU540 Board" + endchoice # board-specific options below source "board/AndesTech/ax25-ae350/Kconfig" source "board/emulation/qemu-riscv/Kconfig" +source "board/sifive/fu540/Kconfig" # platform-specific options below source "arch/riscv/cpu/ax25/Kconfig"board/sifive/fu540/Kconfig new file +42
-0@@ -0,0 +1,42 @@ +if TARGET_SIFIVE_FU540 + +config SYS_BOARD + default "fu540" + +config SYS_VENDOR + default "sifive" + +config SYS_CPU + default "generic" + +config SYS_CONFIG_NAME + default "sifive-fu540" + +config SYS_TEXT_BASE + default 0x80000000 if !RISCV_SMODE + default 0x80200000 if RISCV_SMODE + +config BOARD_SPECIFIC_OPTIONS # dummy + def_bool y + select GENERIC_RISCV + imply CMD_DHCP + imply CMD_EXT2 + imply CMD_EXT4 + imply CMD_FAT + imply CMD_FS_GENERIC + imply CMD_NET + imply CMD_PING + imply CLK_SIFIVE + imply CLK_SIFIVE_FU540_PRCI + imply DOS_PARTITION + imply EFI_PARTITION + imply IP_DYN + imply ISO_PARTITION + imply MACB + imply MII + imply NET_RANDOM_ETHADDR + imply PHY_LIB + imply PHY_MSCC + imply SIFIVE_SERIAL + +endifboard/sifive/fu540/MAINTAINERS new file +9
-0@@ -0,0 +1,9 @@ +SiFive FU540 BOARD +M: Paul Walmsley <[email protected]> +M: Palmer Dabbelt <[email protected]> +M: Anup Patel <[email protected]> +M: Atish Patra <[email protected]> +S: Maintained +F: board/sifive/fu540/ +F: include/configs/sifive-fu540.h +F: configs/sifive_fu540_defconfigboard/sifive/fu540/Makefile new file +3
-0@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (c) 2019 Western Digital Corporation or itsaffiliates.
board/sifive/fu540/Makefile new file +2
-0+ +obj-y += fu540.oboard/sifive/fu540/fu540.c new file +3
-0@@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (c) 2019 Western Digital Corporation or its affiliates.
+ *
+ * Authors:
+ * Anup Patel <[email protected]>
+ */board/sifive/fu540/fu540.c new file +10
-0+ +#include <common.h> +#include <dm.h> + +int board_init (void ) +{ +/* For now nothing to do here. */ + +return 0 ; +}configs/sifive_fu540_defconfig new file +11
-0@@ -0,0 +1,11 @@ +CONFIG_RISCV=y +CONFIG_TARGET_SIFIVE_FU540=y +CONFIG_RISCV_SMODE=y +CONFIG_ARCH_RV64I=y +CONFIG_DISTRO_DEFAULTS=y +CONFIG_NR_DRAM_BANKS=1 +CONFIG_FIT=y +CONFIG_DISPLAY_CPUINFO=y +CONFIG_DISPLAY_BOARDINFO=y +CONFIG_CMD_MII=y +CONFIG_OF_PRIOR_STAGE=yinclude/configs/sifive- renamed from include/configs/sifive-fu540.h +0
-0
fu540.h
new file mode 100644
index 0000000000..7007b5f6afinclude/configs/sifive-fu540.h new file +3
-0@@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (c) 2019 Western Digital Corporation or its affiliates.
+ *
+ * Authors:
+ * Anup Patel <[email protected]>
+ */include/configs/sifive-fu540.h new file +34
-0+ +#ifndef __CONFIG_H +#define __CONFIG_H + +#include <linux/sizes.h> + +#define CONFIG_SYS_SDRAM_BASE 0x80000000 +#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + SZ_2M) + +#define CONFIG_SYS_LOAD_ADDR (CONFIG_SYS_SDRAM_BASE + SZ_2M) + +#define CONFIG_SYS_MALLOC_LEN SZ_8M + +#define CONFIG_SYS_BOOTM_LEN SZ_16M + +#define CONFIG_STANDALONE_LOAD_ADDR 0x80200000 + +/* Environment options */ +#define CONFIG_ENV_SIZE SZ_4K + +#define BOOT_TARGET_DEVICES (func) \ + func(DHCP, dhcp, na) + +#include <config_distro_bootcmd.h> + +#define CONFIG_EXTRA_ENV_SETTINGS \ + "fdt_high=0xffffffffffffffff\0" \ + "initrd_high=0xffffffffffffffff\0" \ + "kernel_addr_r=0x80600000\0" \ + "fdt_addr_r=0x82200000\0" \ + "scriptaddr=0x82300000\0" \ + "pxefile_addr_r=0x82400000\0" \Quoted 9 lines
include/configs/sifive-fu540.h line 41
Quoted 2 lines
include/configs/sifive-fu540.h new file +2
-0+"ramdisk_addr_r=0x82500000\0" \ +BOOTENV I think it would be helpful to define the kernel command line using the
bootargs environment variable here. For testing I used "bootargs=console=ttySI0 earlyprintk root=/dev/mmcblk0p2 rootwait" locally.
Quoted 6 lines
The root partition might be different in different setup. For example,
if expansion board is connected, root partition might be on sata or nvme
drive. Should we add a fixed root partition to the bootargs ?
Hm, good point. It's probably better to leave it as is and document it as part of the boot flow in the board README.
Thanks,
Lukas
PATCH v2 11/11 riscv: Add SiFive FU540 board support
In reply to Anup PatelQuoted 5 lines · Anup Patel
This patch adds SiFive FU540 board support. For now, only SiFive serial, SiFive PRCI, and Cadance MACB drivers are only enabled. The SiFive FU540 defconfig by default builds U-Boot for S-Mode because U-Boot on SiFive FU540 will run in S-Mode as payload of BBL or OpenSBI.
What am I expected to see when started with BBL? All I see is the logo, then nothing.
Andreas.
Signature · 3 lines
Andreas Schwab, SUSE Labs, schwab at suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 12 lines · Andreas Schwab
Quoted 5 lines · Anup Patel
This patch adds SiFive FU540 board support. For now, only SiFive serial, SiFive PRCI, and Cadance MACB drivers are only enabled. The SiFive FU540 defconfig by default builds U-Boot for S-Mode because U-Boot on SiFive FU540 will run in S-Mode as payload of BBL or OpenSBI.
What am I expected to see when started with BBL? All I see is the logo, then nothing.
Here's the log of BBL+U-Boot on QEMU sifive_u machine:
anup at anup-ubuntu64:~/Work/riscv-test$ qemu-system-riscv64 -M sifive_u -m 256M -display none -serial stdio -kernel build-riscv-pk-uboot/bbl bbl loader
U-Boot 2019.01-00018-gc3a9211ebc (Jan 21 2019 - 21:36:12 +0530)
CPU: rv64imafdcsu Model: ucbbar,spike-bare,qemu DRAM: 256 MiB In: uart at 10013000 Out: uart at 10013000 Err: uart at 10013000
Net:
Warning: ethernet at 100900fc (eth0) using random MAC address - 02:4a:de:c3:c8:80
eth0: ethernet at 100900fc
Hit any key to stop autoboot: 0
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 1000Mbps full-duplex (lpa: 0x7c00) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (2 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15
Filename 'boot.scr.uimg'.
Load address: 0x82300000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 1000Mbps full-duplex (lpa: 0x7c00) BOOTP broadcast 1
DHCP client bound to address 10.0.2.15 (0 ms)
Using ethernet at 100900fc device
TFTP from server 10.0.2.2; our IP address is 10.0.2.15
Filename 'boot.scr.uimg'.
Load address: 0x80600000
Loading: *
TFTP error: 'Access violation' (2)
Not retrying...
=> ping 10.0.2.2
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 1000Mbps full-duplex (lpa: 0x7c00) Using ethernet at 100900fc device
host 10.0.2.2 is alive
=>
ethernet at 100900fc: PHY present at 0
ethernet at 100900fc: link up, 1000Mbps full-duplex (lpa: 0x7c00) Using ethernet at 100900fc device
host 10.0.2.2 is alive
=> qemu-system-riscv64: terminating on signal 2
On real board, we generally boot OpenSBI+U-Boot. We will try and share log of BBL+U-Boot on real board but the log will look exactly like above.
Regards,
Anup
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 3 lines · Anup Patel
On real board, we generally boot OpenSBI+U-Boot. We will try and share log of BBL+U-Boot on real board but the log will look exactly like above.
Nothing is seen on the real board.
Andreas.
Signature · 3 lines
Andreas Schwab, SUSE Labs, schwab at suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 8 lines · Andreas Schwab
Quoted 3 lines · Anup Patel
On real board, we generally boot OpenSBI+U-Boot. We will try and share log of BBL+U-Boot on real board but the log will look exactly like above.
Nothing is seen on the real board.
There is a fix required in BBL for real board. We have not send this fix to riscv-pk.
BBL does not set "stdout-path" in /chosen DT node so you are not seeing any output from U-Boot on real board. On QEMU, "stdout-path" is set in DTB by QEMU itself so we don't see any issue on QEMU.
We typically run OpenSBI+U-Boot on real board and OpenSBI sets "stdout-path" properly before jumping to next stage (i.e. U-Boot) so even we don't see this issue at our end.
You can easily hack BBL for above fix at your end.
Regards,
Anup
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 2 lines · Anup Patel
There is a fix required in BBL for real board. We have not send this fix to riscv-pk.
Where can I find the patch?
Andreas.
Signature · 3 lines
Andreas Schwab, SUSE Labs, schwab at suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 7 lines · Andreas Schwab
Quoted 2 lines · Anup Patel
There is a fix required in BBL for real board. We have not send this fix to riscv-pk.
Where can I find the patch?
The fix is to set following DT prop in /chosen DT node:
stdout-path = "/soc/serial at 10010000:115200"
As we can see, the "stdout-path" is specific to SiFive FU540 board so setting it in BBL is a nasty hack hence we did not push it anywhere.
Ideally, we should set above mentioned stdout-path DT prop in SiFive FU540 DTS passed by FSBL.
Regards,
Anup
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 11 lines · Anup Patel
Quoted 7 lines · Andreas Schwab
Quoted 2 lines · Anup Patel
There is a fix required in BBL for real board. We have not send this fix to riscv-pk.
Where can I find the patch?
The fix is to set following DT prop in /chosen DT node:
stdout-path = "/soc/serial at 10010000:115200"
How can I do that? I cannot find any function in fdt.c to add new nodes.
Andreas.
Signature · 3 lines
Andreas Schwab, SUSE Labs, schwab at suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 9 lines · Andreas Schwab
Quoted 7 lines · Anup Patel
Quoted 6 lines · Andreas Schwab
Quoted 2 lines · Anup Patel
There is a fix required in BBL for real board. We have not send this fix to riscv-pk.
Just to clarify, we hacked U-boot to add the serial driver not BBL. Later, we modified the DT directly in OpenSBI to add the required node.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Where can I find the patch?
The fix is to set following DT prop in /chosen DT node:
stdout-path = "/soc/serial at 10010000:115200"How can I do that?I cannot find any function in
fdt.cto add new nodes.
There are several ways to do the hack.
BBL doesn't have libfdt included by default. Libfdt is included in u-boot. You can try adding that node in u-boot.
or
Here is another hack in U-boot until the OpenSBI is available (Early next week).
drivers/serial/serial-uclass.c +0 -0
@@ -54,6 +54,16 @@ static int serial_check_stdout(const void *blob,
struct udevice **devp)
}
if (node < 0)
node = fdt_path_offset(blob, "console");
+
+ if (node < 0) {
+ const char *sname;
+ sname = fdt_get_alias(blob, "serial0");
+ printf("sname = [%s]\n", sname);
+ if (sname)+ node = fdt_path_offset(blob, sname);
+ printf("node = [%d]\n", node);
+ }
+
if (!uclass_get_device_by_of_offset(UCLASS_SERIAL, node, devp))
return 0;
or you can try to edit the DT directly and update the FSBL if you are comfortable with it.
Apologies, for the inconvenience. Sending these patches to U-boot doesn't make any sense its very board specific. In an ideal world, DT should be fixed directly to address these issues.
Regards,
Atish
Quoted 2 lines
Andreas.
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 2 lines · Atish Patra
or you can try to edit the DT directly and update the FSBL if you are comfortable with it.
I think it would make sense to add the node in the board init function. That way it would work whether or not the FSBL is updated.
Andreas.
Signature · 3 lines
Andreas Schwab, SUSE Labs, schwab at suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 13 lines
-----Original Message-----
From: Andreas Schwab [mailto:schwab at suse.de]
Sent: Thursday, January 24, 2019 3:24 PM
To: Atish Patra <[email protected]>
Cc: Anup Patel <[email protected]>; Anup Patel <[email protected]>; Joe Hershberger <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>; Palmer Dabbelt <[email protected]>; Alexander Graf <[email protected]>; Christoph Hellwig <[email protected]>; Paul Walmsley <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 11/11] riscv: Add SiFive FU540 board support
Quoted 7 lines
Quoted 2 lines · Atish Patra
or you can try to edit the DT directly and update the FSBL if you are comfortable with it.
I think it would make sense to add the node in the board init function. That way it would work whether or not the FSBL is updated.
Best way is to either fix in DTS itself or BBL/OpenSBI.
For BBL it is difficult due to lack of matured FDT manipulation APIs. My bad for previous misinformation about BBL. I thought Atish had hacked this in BBL but he had hacked U-Boot.
We already have taken care of this in OpenSBI using LibFDT so with OpenSBI no hacks would be required.
We are just few days away from OpenSBI being made public so no point of adding work-around for "stdout-path" in U-Boot as well.
Regards,
Anup
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 27 lines · Anup Patel
Quoted 13 lines
-----Original Message-----
From: Andreas Schwab [mailto:schwab at suse.de]
Sent: Thursday, January 24, 2019 3:24 PM
To: Atish Patra <[email protected]>
Cc: Anup Patel <[email protected]>; Anup Patel <[email protected]>; Joe Hershberger <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>; Palmer Dabbelt <[email protected]>; Alexander Graf <[email protected]>; Christoph Hellwig <[email protected]>; Paul Walmsley <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 11/11] riscv: Add SiFive FU540 board supportQuoted 7 lines
Quoted 2 lines · Atish Patra
or you can try to edit the DT directly and update the FSBL if you are comfortable with it.
I think it would make sense to add the node in the board init function. That way it would work whether or not the FSBL is updated.
Best way is to either fix in DTS itself or BBL/OpenSBI.
For BBL it is difficult due to lack of matured FDT manipulation APIs. My bad for previous misinformation about BBL. I thought Atish had hacked this in BBL but he had hacked U-Boot.
Quoted 5 lines
We already have taken care of this in OpenSBI using LibFDT so with OpenSBI no hacks would be required.
We are just few days away from OpenSBI being made public so no point of adding work-around for "stdout-path" in U-Boot as well.
I disagree. We want people to easily use this code, and not use it as a means to push for the OpenSBI vs BBL discussion.
So IMHO a quirk that adds the stdout-path property in an early board init function is the best way to move forward here. That way the "good" case keeps behaving the same, but we stay compatible to current, existing previous stage firmware.
Please, don't *ever* consider DT something that you "just modify". If anything worked with a DT before, you are required to keep it that way. Otherwise you break the compatibility contract between your firmware layers.
Alex
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 40 lines · Alexander Graf
Quoted 27 lines · Anup Patel
Quoted 13 lines
-----Original Message-----
From: Andreas Schwab [mailto:schwab at suse.de]
Sent: Thursday, January 24, 2019 3:24 PM
To: Atish Patra <[email protected]>
Cc: Anup Patel <[email protected]>; Anup Patel <[email protected]>; Joe Hershberger <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>; Palmer Dabbelt <[email protected]>; Alexander Graf <[email protected]>; Christoph Hellwig <[email protected]>; Paul Walmsley <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 11/11] riscv: Add SiFive FU540 board supportQuoted 7 lines
Quoted 2 lines · Atish Patra
or you can try to edit the DT directly and update the FSBL if you are comfortable with it.
I think it would make sense to add the node in the board init function. That way it would work whether or not the FSBL is updated.
Best way is to either fix in DTS itself or BBL/OpenSBI.
For BBL it is difficult due to lack of matured FDT manipulation APIs. My bad for previous misinformation about BBL. I thought Atish had hacked this in BBL but he had hacked U-Boot.
Quoted 5 lines
We already have taken care of this in OpenSBI using LibFDT so with OpenSBI no hacks would be required.
We are just few days away from OpenSBI being made public so no point of adding work-around for "stdout-path" in U-Boot as well.
I disagree. We want people to easily use this code, and not use it as a means to push for the OpenSBI vs BBL discussion.
Quoted 8 lines
So IMHO a quirk that adds the stdout-path property in an early board init function is the best way to move forward here. That way the "good" case keeps behaving the same, but we stay compatible to current, existing previous stage firmware.
Please, don't *ever* consider DT something that you "just modify". If anything worked with a DT before, you are required to keep it that way. Otherwise you break the compatibility contract between your firmware layers.
No issues, I will try to add it board_init().
Regards,
Anup
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 46 lines · Anup Patel
Quoted 45 lines · Alexander Graf
Quoted 27 lines · Anup Patel
Quoted 13 lines
-----Original Message-----
From: Andreas Schwab [mailto:schwab at suse.de]
Sent: Thursday, January 24, 2019 3:24 PM
To: Atish Patra <[email protected]>
Cc: Anup Patel <[email protected]>; Anup Patel <[email protected]>; Joe Hershberger <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>; Palmer Dabbelt <[email protected]>; Alexander Graf <[email protected]>; Christoph Hellwig <[email protected]>; Paul Walmsley <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 11/11] riscv: Add SiFive FU540 board supportQuoted 7 lines
Quoted 2 lines · Atish Patra
or you can try to edit the DT directly and update the FSBL if you are comfortable with it.
I think it would make sense to add the node in the board init function. That way it would work whether or not the FSBL is updated.
Best way is to either fix in DTS itself or BBL/OpenSBI.
For BBL it is difficult due to lack of matured FDT manipulation APIs. My bad for previous misinformation about BBL. I thought Atish had hacked this in BBL but he had hacked U-Boot.
Quoted 5 lines
We already have taken care of this in OpenSBI using LibFDT so with OpenSBI no hacks would be required.
We are just few days away from OpenSBI being made public so no point of adding work-around for "stdout-path" in U-Boot as well.
I disagree. We want people to easily use this code, and not use it as a means to push for the OpenSBI vs BBL discussion.
So IMHO a quirk that adds the stdout-path property in an early board init function is the best way to move forward here. That way the "good" case keeps behaving the same, but we stay compatible to current, existing previous stage firmware.
Quoted 5 lines
Quoted 3 lines
Please, don't *ever* consider DT something that you "just modify". If anything worked with a DT before, you are required to keep it that way. Otherwise you break the compatibility contract between your firmware layers.
No issues, I will try to add it
board_init().
Board_init() is too late. This needs to go into early_board_init_f(). IIUC Andreas is prototyping that approach right now.
Alex
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 50 lines · Alexander Graf
Quoted 46 lines · Anup Patel
Quoted 45 lines · Alexander Graf
Quoted 27 lines · Anup Patel
Quoted 13 lines
-----Original Message-----
From: Andreas Schwab [mailto:schwab at suse.de]
Sent: Thursday, January 24, 2019 3:24 PM
To: Atish Patra <[email protected]>
Cc: Anup Patel <[email protected]>; Anup Patel <[email protected]>; Joe Hershberger <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>; Palmer Dabbelt <[email protected]>; Alexander Graf <[email protected]>; Christoph Hellwig <[email protected]>; Paul Walmsley <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 11/11] riscv: Add SiFive FU540 board supportQuoted 7 lines
Quoted 2 lines · Atish Patra
or you can try to edit the DT directly and update the FSBL if you are comfortable with it.
I think it would make sense to add the node in the board init function. That way it would work whether or not the FSBL is updated.
Best way is to either fix in DTS itself or BBL/OpenSBI.
For BBL it is difficult due to lack of matured FDT manipulation APIs. My bad for previous misinformation about BBL. I thought Atish had hacked this in BBL but he had hacked U-Boot.
Quoted 5 lines
We already have taken care of this in OpenSBI using LibFDT so with OpenSBI no hacks would be required.
We are just few days away from OpenSBI being made public so no point of adding work-around for "stdout-path" in U-Boot as well.
I disagree. We want people to easily use this code, and not use it as a means to push for the OpenSBI vs BBL discussion.
So IMHO a quirk that adds the stdout-path property in an early board init function is the best way to move forward here. That way the "good" case keeps behaving the same, but we stay compatible to current, existing previous stage firmware.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Please, don't *ever* consider DT something that you "just modify". If anything worked with a DT before, you are required to keep it that way. Otherwise you break the compatibility contract between your firmware layers.
No issues, I will try to add it
board_init().
Board_init()is too late. This needs to go intoearly_board_init_f(). IIUC Andreas is prototyping that approach right now.
Thanks Alex and Andreas.
My latest patches are in riscv_sifive_fu540_v4 branch of
https://github.com/avpatel/u-boot
I can include Andreas's patch in my v5. If he is fine with it.
Regards,
Anup
Quoted 3 lines
Alex
PATCH v2 11/11 riscv: Add SiFive FU540 board support
In reply to Alexander GrafQuoted 1 line · Alexander Graf
Board_init()is too late. This needs to go intoearly_board_init_f().
I don't think we can modify the DT that early.
Andreas.
Signature · 3 lines
Andreas Schwab, SUSE Labs, schwab at suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 5 lines · Andreas Schwab
Quoted 1 line · Alexander Graf
Board_init()is too late. This needs to go intoearly_board_init_f().I don't think we can modify the DT that early.
I'm sure we can. Worst case we have to copy it over to RAM first.
What obstacle exactly did you run into? Did you try to prototype the change in a QEMU environment first to get some better debugging insights?
Alex
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 8 lines · Alexander Graf
Quoted 5 lines · Andreas Schwab
Quoted 1 line · Alexander Graf
Board_init()is too late. This needs to go intoearly_board_init_f().I don't think we can modify the DT that early.
I'm sure we can. Worst case we have to copy it over to RAM first.
reserve_fdt is only called much later.
Andreas.
Signature · 3 lines
Andreas Schwab, SUSE Labs, schwab at suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 6 lines · Andreas Schwab
Quoted 3 lines · Alexander Graf
Quoted 2 lines · Andreas Schwab
On Jan 24 2019, Alexander Graf <[email protected]> wrote:
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Board_init()is too late. This needs to go intoearly_board_init_f().I don't think we can modify the DT that early.
I'm sure we can. Worst case we have to copy it over to RAM first.
reserve_fdtis only called much later.
OpenSBI is public now.
Can try with https://github.com/riscv/opensbi.git ?
There is README for SiFive FU540 at
<opensbi_sources>/docs/platform/sifive_fu540.md
Regards,
Anup
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 1 line · Anup Patel
Can try with https://github.com/riscv/opensbi.git ?
AS-DEP platform/sifive/fu540/firmware/fw_payload.dep/bin/sh: -g: command not found
Andreas.
Signature · 3 lines
Andreas Schwab, SUSE Labs, schwab at suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Probably your cross compilation is not set. Can you try this ?
export ARCH=riscv
export CROSS_COMPILE= <riscv cross compile prefix>
Sent from my iPhone
Quoted 15 lines · Andreas Schwab
Quoted 4 lines · Anup Patel
Can try with https://github.com/riscv/opensbi.git ?
AS-DEP platform/sifive/fu540/firmware/fw_payload.dep
/bin/sh: -g: command not foundAndreas.
Signature · 3 lines
Andreas Schwab, SUSE Labs, schwab at suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 4 lines · Atish Patra
Probably your cross compilation is not set. Can you try this ?
export ARCH=riscv
export CROSS_COMPILE= <riscv cross compile prefix>
There is no cross compile prefix.
Andreas.
Signature · 3 lines
Andreas Schwab, SUSE Labs, schwab at suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 10 lines · Andreas Schwab
Quoted 4 lines · Atish Patra
Probably your cross compilation is not set. Can you try this ?
export ARCH=riscv
export CROSS_COMPILE= <riscv cross compile prefix>There is no cross compile prefix.
The OpenSBI build is similar to Linux and U-Boot. We expect CROSS_COMPILE environment variable to be set.
Make sure, CROSS_COMPILE environment variable is set and exported before running make.
Example, if you cross-compiler is riscv64-unknown-linux-gnu-gcc then do:
# export CROSS_COMPILE=riscv64-unknown-linux-gnu-
Regards,
Anup
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 2 lines · Anup Patel
The OpenSBI build is similar to Linux and U-Boot. We expect
CROSS_COMPILEenvironment variable to be set.
Why? That doesn't make sense.
Quoted 1 line
Example, if you cross-compiler
I don't have a cross compiler.
Andreas.
Signature · 3 lines
Andreas Schwab, SUSE Labs, schwab at suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 7 lines · Andreas Schwab
Quoted 2 lines · Anup Patel
The OpenSBI build is similar to Linux and U-Boot. We expect
CROSS_COMPILEenvironment variable to be set.Why? That doesn't make sense.
Use of CROSS_COMPILE environment variable is pretty common across open-source projects to support cross compilation.
Quoted 4 lines
Quoted 2 lines
Example, if you cross-compiler
I don't have a cross compiler.
Okay, if you are doing native compilation then make sure CROSS_COMPILE is not set so that makefile will take native compiler instead of cross-compiler.
Regards.
Anup
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 4 lines · Anup Patel
Okay, if you are doing native compilation then
make sureCROSS_COMPILEis not set so that
makefile will take native compiler instead of
cross-compiler.
AS-DEP platform/sifive/fu540/firmware/fw_payload.dep/bin/sh: -g: command not found
Andreas.
Signature · 3 lines
Andreas Schwab, SUSE Labs, schwab at suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 10 lines · Andreas Schwab
Quoted 4 lines · Anup Patel
Okay, if you are doing native compilation then
make sureCROSS_COMPILEis not set so that
makefile will take native compiler instead of
cross-compiler.AS-DEP platform/sifive/fu540/firmware/fw_payload.dep
/bin/sh: -g: command not found
Can you share output of make with "V=1" parameter?
Regards,
Anup
PATCH v2 11/11 riscv: Add SiFive FU540 board support
mkdir -p dirname /net/hawking/daten/src/riscv/opensbi/build/platform/sifive/fu540/firmware/fw_payload.dep; echo " AS-DEP platform/sifive/fu540/firmware/fw_payload.dep"; echo -n dirname /net/hawking/daten/src/riscv/opensbi/build/platform/sifive/fu540/firmware/fw_payload.dep/ > /net/hawking/daten/src/riscv/opensbi/build/platform/sifive/fu540/firmware/fw_payload.dep && -g -Wall -nostdlib -D__ASSEMBLY__ -fno-omit-frame-pointer -fno-optimize-sibling-calls -mno-save-restore -mstrict-align -I/net/hawking/daten/src/riscv/opensbi/platform/sifive/fu540/include -I/net/hawking/daten/src/riscv/opensbi/platform/common/include -I/net/hawking/daten/src/riscv/opensbi/include -I/net/hawking/daten/src/riscv/opensbi/platform/common/libfdt/ -DFW_TEXT_START=0x80000000 -DFW_JUMP_ADDR=0x80200000 -DFW_JUMP_FDT_ADDR=0x82200000 -DFW_PAYLOAD_PATH=/boot/Image-5.0.0-rc5-00011-gcf1db34127ee -DFW_PAYLOAD_OFFSET=0x200000 -DFW_PAYLOAD_FDT_ADDR=0x82200000 -mabi=lp64 -march=rv64imafdc -mcmodel=medany -I/net/hawking/daten/src/riscv/opensbi/firmware -D__OBJNAME__=fw_payload.dep -MM /net/hawking/daten/src/riscv/opensbi/firmware/fw_payload.S >> /net/hawking/daten/src/riscv/opensbi/build/platform/sifive/fu540/firmware/fw_payload.dep || rm -f /net/hawking/daten/src/riscv/opensbi/build/platform/sifive/fu540/firmware/fw_payload.dep
Andreas.
Signature · 3 lines
Andreas Schwab, SUSE Labs, schwab at suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 2 lines · Andreas Schwab
mkdir -p
dirname /net/hawking/daten/src/riscv/opensbi/build/platform/sifive/fu540/firmware/fw_payload.dep; echo " AS-DEP platform/sifive/fu540/firmware/fw_payload.dep"; echo -ndirname /net/hawking/daten/src/riscv/opensbi/build/platform/sifive/fu540/firmware/fw_payload.dep/ > /net/hawking/daten/src/riscv/opensbi/build/platform/sifive/fu540/firmware/fw_payload.dep && -g -Wall -nostdlib -D__ASSEMBLY__ -fno-omit-frame-pointer -fno-optimize-sibling-calls -mno-save-restore -mstrict-align -I/net/hawking/daten/src/riscv/opensbi/platform/sifive/fu540/include -I/net/hawking/daten/src/riscv/opensbi/platform/common/include -I/net/hawking/daten/src/riscv/opensbi/include -I/net/hawking/daten/src/riscv/opensbi/platform/common/libfdt/ -DFW_TEXT_START=0x80000000 -DFW_JUMP_ADDR=0x80200000 -DFW_JUMP_FDT_ADDR=0x82200000 -DFW_PAYLOAD_PATH=/boot/Image-5.0.0-rc5-00011-gcf1db34127ee -DFW_PAYLOAD_OFFSET=0x200000 -DFW_PAYLOAD_FDT_ADDR=0x82200000 -mabi=lp64 -march=rv64imafdc -mcmodel=medany -I/net/hawking/daten/src/riscv/opensbi/firmware -D__OBJNAME__=fw_payload.dep -MM /net/hawking/daten/src/riscv/opensbi/firmware/fw_payload.S >> /net/hawking/daten/src/riscv/opensbi/build/platform/sifive/fu540/firmware/fw_payload.dep || rm -f /net/hawking/daten/src/riscv/opensbi/build/platform/sifive/fu540/firmware/fw_payload.dep
Ahh, looks like it is not picking up "CC" set by Makefile. This might be because you have removed "-R" from MAKEFLAGS.
CC should be either "$(CROSS_COMPILE)gcc" or "gcc".
Regards,
Anup
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 2 lines · Anup Patel
Ahh, looks like it is not picking up "CC" set by
Makefile. This might be because you have removed "-R" from MAKEFLAGS.
Nope. That fixed it.
Andreas.
Signature · 3 lines
Andreas Schwab, SUSE Labs, schwab at suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."
PATCH v2 11/11 riscv: Add SiFive FU540 board support
Quoted 7 lines · Andreas Schwab
Quoted 2 lines · Anup Patel
Ahh, looks like it is not picking up "CC" set by
Makefile. This might be because you have removed "-R" from MAKEFLAGS.Nope. That fixed it.
Cool, I had already approved your PR on OpenSBI Github.
Most of us just do cross-compilation so thanks for trying native compilation.
Regards,
Anup
PATCH v2 11/11 riscv: Add SiFive FU540 board support
In reply to Anup PatelQuoted 10 lines · Anup Patel
This patch adds SiFive FU540 board support. For now, only SiFive serial, SiFive PRCI, and Cadance MACB drivers are only enabled. The SiFive FU540 defconfig by default builds U-Boot for S-Mode because U-Boot on SiFive FU540 will run in S-Mode as payload of BBL or OpenSBI.
Signed-off-by Atish Patra <[email protected]>Signed-off-by Anup Patel <[email protected]>Reviewed-by Alexander Graf <[email protected]>
Quoted 16 lines
--- arch/riscv/Kconfig | 4 ++++ board/sifive/fu540/Kconfig | 42 +++++++++++++++++++++++++++++++++ board/sifive/fu540/MAINTAINERS | 9 +++++++ board/sifive/fu540/Makefile | 5 ++++ board/sifive/fu540/fu540.c | 17 ++++++++++++++ configs/sifive_fu540_defconfig | 11 +++++++++ include/configs/sifive-fu540.h | 43 ++++++++++++++++++++++++++++++++++ 7 files changed, 131 insertions(+) create mode 100644 board/sifive/fu540/Kconfig create mode 100644 board/sifive/fu540/MAINTAINERS create mode 100644 board/sifive/fu540/Makefile create mode 100644 board/sifive/fu540/fu540.c create mode 100644 configs/sifive_fu540_defconfig create mode 100644 include/configs/sifive-fu540.h
Auer
v2 cover SiFive FU540 Support
In reply to Anup PatelHi Anup,
Quoted 11 lines · Anup Patel
This patchset adds SiFive Freedom Unleashed (FU540) support to RISC-V U-Boot.
The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id91882c472d8c0aef4db699d3f2de55bf43d4ae4bAll drivers namely: SiFive PRCI, SiFive Serial, and Cadance MACB Ethernet work fine on actual SiFive Unleashed board and QEMU
sifive_umachine.
Thanks for working on this! Are you also planning on adding the features of the FSBL to U-Boot to remove it from the boot flow?
I was able to run U-Boot and boot Linux successfully on a SiFive HiFive Unleashed board with this patch series. I had to make one more change, because U-Boot was not able to find a serial driver and paniced as a result.
I fixed this by making the serial driver available pre-relocation. For this, the soc compatible has to be added to cpu/generic/cpu.c and the serial driver must have the DM_FLAG_PRE_RELOC flag set.
Another way would be to add a "stdout-path" property to the chosen node of the device tree.
Thanks,
Lukas
v2 cover SiFive FU540 Support
Quoted 10 lines · Lukas
Hi Anup,
Quoted 7 lines · Anup Patel
This patchset adds SiFive Freedom Unleashed (FU540) support to RISC-V U-Boot.
The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id91882c472d8c0aef4db699d3f2de55bf43d4ae4b
Quoted 8 lines
Quoted 4 lines
All drivers namely: SiFive PRCI, SiFive Serial, and Cadance MACB Ethernet work fine on actual SiFive Unleashed board and QEMU
sifive_umachine.Thanks for working on this! Are you also planning on adding the features of the FSBL to U-Boot to remove it from the boot flow?
That would also mean that adding M-mode capability in U-boot. As of now the expected boot flow is
ZSBL->FSBL------->BBL/OpenSBI--------->U-boot------------->Linux (M mode from ROM) (M mode from DRAM) (S Mode from DRAM) (S Mode from DRAM)
This is not the mandated boot flow but running the last stage boot loader from S-mode gives flexibility in virtualization in future.
Quoted 5 lines
I was able to run U-Boot and boot Linux successfully on a SiFive HiFive Unleashed board with this patch series. I had to make one more change, because U-Boot was not able to find a serial driver and paniced as a result.
Quoted 7 lines
I fixed this by making the serial driver available pre-relocation. For this, the soc compatible has to be added to
cpu/generic/cpu.cand the serial driver must have theDM_FLAG_PRE_RELOCflag set.Another way would be to add a "stdout-path" property to the chosen node of the device tree.
Currently, we modified the DT to add stdout-path in prior stage boot loader.
Regards,
Atish
Quoted 3 lines
Thanks,
Lukas
v2 cover SiFive FU540 Support
Quoted 36 lines
-----Original Message-----
From: Atish Patra [mailto:atish.patra at wdc.com]
Sent: Monday, January 21, 2019 7:07 AM
To: Auer, Lukas <[email protected]>; sjg at chromium.org; bmeng.cn at gmail.com; rick at andestech.com; Anup Patel <[email protected]>; joe.hershberger at ni.com;
yamada.masahiro at socionext.com
Cc: paul.walmsley at sifive.com; palmer at sifive.com; hch at infradead.org; u- boot at lists.denx.de; agraf at suse.de
Subject: Re: [PATCH v2 00/11] SiFive FU540 SupportQuoted 10 lines · Lukas
Hi Anup,
Quoted 7 lines · Anup Patel
This patchset adds SiFive Freedom Unleashed (FU540) support to RISC-V U-Boot.
The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id91882c472d8c0aef4db699d3f2de55bf43d4ae4bQuoted 8 lines
Quoted 4 lines
All drivers namely: SiFive PRCI, SiFive Serial, and Cadance MACB Ethernet work fine on actual SiFive Unleashed board and QEMU
sifive_umachine.Thanks for working on this! Are you also planning on adding the features of the FSBL to U-Boot to remove it from the boot flow?
That would also mean that adding M-mode capability in U-boot. As of now the expected boot flow is
Quoted 7 lines
ZSBL->FSBL------->BBL/OpenSBI--------->U-boot------------->Linux (M mode from ROM) (M mode from DRAM) (S Mode from DRAM) (S Mode from
DRAM)This is not the mandated boot flow but running the last stage boot loader from S-mode gives flexibility in virtualization in future.
To elaborate more on what Atish already mentioned, our rationale behind ZSBL->FSBL->BBL/OpenSBI->U-Boot(or Any other general bootloader) is as follows:
1. We don't want to replicate FSBL code (DRAM and other system-level init) in general purpose bootloaders (U-Boot, UEFI/Tianocore, etc)
2. We don't want to replicate SBI runtime implementation in general purpose bootloaders (U-Boot, UEFI/Tianocore, etc)
3. We want to use general purpose bootloader (U-Boot, UEFI/Tianocore, etc) inside Guest/VM (S-mode)
Of course, above boot flow is not mandatory. There could be RISC-V systems where prior booting stages (such as ZSBL and FSBL) don't exist so users have following options:
1. Run U-Boot in M-mode for such RISC-V systems and link to OpenSBI static library for SBI runtime services
2. Run U-Boot in S-mode but do most system-level initialization (including DRAM init) in OpenSBI firmware. In other words, use following booting flow:
OpenSBI (M-mode) -> U-Boot (S-mode)
For point1 above, we will first try it with U-Boot M-mode on QEMU Virt machine.
Quoted 10 lines
Quoted 10 lines
I was able to run U-Boot and boot Linux successfully on a SiFive HiFive Unleashed board with this patch series. I had to make one more change, because U-Boot was not able to find a serial driver and paniced as a result.
I fixed this by making the serial driver available pre-relocation. For this, the soc compatible has to be added to
cpu/generic/cpu.cand the serial driver must have theDM_FLAG_PRE_RELOCflag set.
Quoted 11 lines
Quoted 3 lines
Another way would be to add a "stdout-path" property to the chosen node of the device tree.
Currently, we modified the DT to add stdout-path in prior stage boot loader.
Regards,
AtishQuoted 3 lines
Thanks,
Lukas
Regards,
Anup
v2 cover SiFive FU540 Support
Hi Anup,
Quoted 64 lines · Anup Patel
Quoted 37 lines
-----Original Message-----
From: Atish Patra [mailto:atish.patra at wdc.com]
Sent: Monday, January 21, 2019 7:07 AM
To: Auer, Lukas <[email protected]>; sjg at chromium.org; bmeng.cn at gmail.com; rick at andestech.com; Anup Patel <[email protected]>; joe.hershberger at ni.com;
yamada.masahiro at socionext.com
Cc: paul.walmsley at sifive.com; palmer at sifive.com; hch at infradead.org; u- boot at lists.denx.de; agraf at suse.de
Subject: Re: [PATCH v2 00/11] SiFive FU540 SupportQuoted 10 lines · Lukas
Hi Anup,
Quoted 7 lines · Anup Patel
This patchset adds SiFive Freedom Unleashed (FU540) support to RISC-V U-Boot.
The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id91882c472d8c0aef4db699d3f2de55bf43d4ae4bQuoted 8 lines
Quoted 4 lines
All drivers namely: SiFive PRCI, SiFive Serial, and Cadance MACB Ethernet work fine on actual SiFive Unleashed board and QEMU
sifive_umachine.Thanks for working on this! Are you also planning on adding the features of the FSBL to U-Boot to remove it from the boot flow?
That would also mean that adding M-mode capability in U-boot. As of now the expected boot flow is
Quoted 7 lines
ZSBL->FSBL------->BBL/OpenSBI--------->U-boot------------->Linux (M mode from ROM) (M mode from DRAM) (S Mode from DRAM) (S Mode from
DRAM)This is not the mandated boot flow but running the last stage boot loader from S-mode gives flexibility in virtualization in future.
To elaborate more on what Atish already mentioned, our rationale behind ZSBL->FSBL->BBL/OpenSBI->U-Boot(or Any other general bootloader) is as follows:
1. We don't want to replicate FSBL code (DRAM and other system-level init) in general purpose bootloaders (U-Boot, UEFI/Tianocore, etc)
2. We don't want to replicate SBI runtime implementation in general purpose bootloaders (U-Boot, UEFI/Tianocore, etc)
3. We want to use general purpose bootloader (U-Boot, UEFI/Tianocore, etc) inside Guest/VM (S-mode)Of course, above boot flow is not mandatory. There could be RISC-V systems where prior booting stages (such as ZSBL and FSBL) don't exist so users have following options:
1. Run U-Boot in M-mode for such RISC-V systems and link to OpenSBI static library for SBI runtime services
2. Run U-Boot in S-mode but do most system-level initialization (including DRAM init) in OpenSBI firmware. In other words, use following booting flow:
OpenSBI (M-mode) -> U-Boot (S-mode)
Quoted 2 lines
For point1 above, we will first try it with U-Boot M-mode on QEMU Virt machine.
Has the OpenSBI project be started somewhere?
Regards,
Bin
v2 cover SiFive FU540 Support
Quoted 84 lines
-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Monday, January 21, 2019 11:44 AM
To: Anup Patel <[email protected]>
Cc: Atish Patra <[email protected]>; Auer, Lukas <[email protected]>; sjg at chromium.org; rick at andestech.com; joe.hershberger at ni.com; yamada.masahiro at socionext.com; paul.walmsley at sifive.com; palmer at sifive.com; hch at infradead.org; u-boot at lists.denx.de; agraf at suse.de
Subject: Re: [PATCH v2 00/11] SiFive FU540 SupportHi Anup,
Quoted 34 lines · Anup Patel
Quoted 34 lines
-----Original Message-----
From: Atish Patra [mailto:atish.patra at wdc.com]
Sent: Monday, January 21, 2019 7:07 AM
To: Auer, Lukas <[email protected]>; sjg at chromium.org; bmeng.cn at gmail.com; rick at andestech.com; Anup Patel <[email protected]>; joe.hershberger at ni.com;
yamada.masahiro at socionext.com
Cc: paul.walmsley at sifive.com; palmer at sifive.com; hch at infradead.org; u- boot at lists.denx.de; agraf at suse.de
Subject: Re: [PATCH v2 00/11] SiFive FU540 SupportQuoted 18 lines · Lukas
Hi Anup,
Quoted 11 lines · Anup Patel
This patchset adds SiFive Freedom Unleashed (FU540) support to RISC-V U-Boot.
The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id91882c472d8c0aef4db699d3f2de55bf43d4ae4bAll drivers namely: SiFive PRCI, SiFive Serial, and Cadance MACB Ethernet work fine on actual SiFive Unleashed board and QEMU
sifive_umachine.Thanks for working on this! Are you also planning on adding the features of the FSBL to U-Boot to remove it from the boot flow?
Quoted 5 lines
Quoted 5 lines
That would also mean that adding M-mode capability in U-boot. As of now the expected boot flow is
ZSBL->FSBL------->BBL/OpenSBI--------->U-boot------------->Linux (M mode from ROM) (M mode from DRAM) (S Mode from DRAM) (S
Mode
Quoted 26 lines
Quoted 5 lines
from
DRAM)This is not the mandated boot flow but running the last stage boot loader from S-mode gives flexibility in virtualization in future.
To elaborate more on what Atish already mentioned, our rationale behind
ZSBL->FSBL->BBL/OpenSBI->U-Boot(or Any other general bootloader) is as follows:
1. We don't want to replicate FSBL code (DRAM and other system-level init) in general purpose bootloaders (U-Boot, UEFI/Tianocore, etc) 2. We don't want to replicate SBI runtime implementation in general purpose bootloaders (U-Boot, UEFI/Tianocore, etc) 3. We want to use general purpose bootloader (U-Boot, UEFI/Tianocore, etc) inside Guest/VM (S-mode)Of course, above boot flow is not mandatory. There could be RISC-V systems where prior booting stages (such as ZSBL and FSBL) don't exist so users have following options:
1. Run U-Boot in M-mode for such RISC-V systems and link to OpenSBI static library for SBI runtime services 2. Run U-Boot in S-mode but do most system-level initialization (including DRAM init) in OpenSBI firmware. In other words, use following booting flow:
OpenSBI (M-mode) -> U-Boot (S-mode)
Quoted 4 lines
Quoted 2 lines
For point1 above, we will first try it with U-Boot M-mode on QEMU Virt machine.
Has the OpenSBI project be started somewhere?
Yes, it exist on Github under https://github.com/riscv
Currently, OpenSBI is at-par with BBL in-terms of SBI implementation but it is extensible and supports lot more boards/targets namely:
1. QEMU virt machine
2. QEMU sifive_u machine
3. SiFive FU540 Unleashed board
4. Kendryte K210 board
We are almost there and just need some more time for finishing touches. We will be making is Public very soon (few more days) so stay tuned.
Of course, we will need help from everyone to make OpenSBI better after all it be a community driver open-source project.
There is SBI extensions spec under discussion which will be added in OpenSBI once it is frozen.
All of us will be present at up-coming FOSDEM19 to talk about SBI extensions, OpenSBI project, and other stuff.
Best Regards,
Anup Patel
v2 cover SiFive FU540 Support
Hi Anup,
Quoted 85 lines · Anup Patel
Quoted 85 lines
-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Monday, January 21, 2019 11:44 AM
To: Anup Patel <[email protected]>
Cc: Atish Patra <[email protected]>; Auer, Lukas <[email protected]>; sjg at chromium.org; rick at andestech.com; joe.hershberger at ni.com; yamada.masahiro at socionext.com; paul.walmsley at sifive.com; palmer at sifive.com; hch at infradead.org; u-boot at lists.denx.de; agraf at suse.de
Subject: Re: [PATCH v2 00/11] SiFive FU540 SupportHi Anup,
Quoted 34 lines · Anup Patel
Quoted 34 lines
-----Original Message-----
From: Atish Patra [mailto:atish.patra at wdc.com]
Sent: Monday, January 21, 2019 7:07 AM
To: Auer, Lukas <[email protected]>; sjg at chromium.org; bmeng.cn at gmail.com; rick at andestech.com; Anup Patel <[email protected]>; joe.hershberger at ni.com;
yamada.masahiro at socionext.com
Cc: paul.walmsley at sifive.com; palmer at sifive.com; hch at infradead.org; u- boot at lists.denx.de; agraf at suse.de
Subject: Re: [PATCH v2 00/11] SiFive FU540 SupportQuoted 18 lines · Lukas
Hi Anup,
Quoted 11 lines · Anup Patel
This patchset adds SiFive Freedom Unleashed (FU540) support to RISC-V U-Boot.
The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id91882c472d8c0aef4db699d3f2de55bf43d4ae4bAll drivers namely: SiFive PRCI, SiFive Serial, and Cadance MACB Ethernet work fine on actual SiFive Unleashed board and QEMU
sifive_umachine.Thanks for working on this! Are you also planning on adding the features of the FSBL to U-Boot to remove it from the boot flow?
Quoted 5 lines
Quoted 5 lines
That would also mean that adding M-mode capability in U-boot. As of now the expected boot flow is
ZSBL->FSBL------->BBL/OpenSBI--------->U-boot------------->Linux (M mode from ROM) (M mode from DRAM) (S Mode from DRAM) (S
Mode
Quoted 26 lines
Quoted 5 lines
from
DRAM)This is not the mandated boot flow but running the last stage boot loader from S-mode gives flexibility in virtualization in future.
To elaborate more on what Atish already mentioned, our rationale behind
ZSBL->FSBL->BBL/OpenSBI->U-Boot(or Any other general bootloader) is as follows:
1. We don't want to replicate FSBL code (DRAM and other system-level init) in general purpose bootloaders (U-Boot, UEFI/Tianocore, etc) 2. We don't want to replicate SBI runtime implementation in general purpose bootloaders (U-Boot, UEFI/Tianocore, etc) 3. We want to use general purpose bootloader (U-Boot, UEFI/Tianocore, etc) inside Guest/VM (S-mode)Of course, above boot flow is not mandatory. There could be RISC-V systems where prior booting stages (such as ZSBL and FSBL) don't exist so users have following options:
1. Run U-Boot in M-mode for such RISC-V systems and link to OpenSBI static library for SBI runtime services 2. Run U-Boot in S-mode but do most system-level initialization (including DRAM init) in OpenSBI firmware. In other words, use following booting flow:
OpenSBI (M-mode) -> U-Boot (S-mode)
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
For point1 above, we will first try it with U-Boot M-mode on QEMU Virt machine.
Has the OpenSBI project be started somewhere?
Yes, it exist on Github under https://github.com/riscv
I did not find the project under https://github.com/riscv. Maybe it is an internal one at present?
Quoted 11 lines
Currently, OpenSBI is at-par with BBL in-terms of SBI implementation but it is extensible and supports lot more boards/targets namely:
1. QEMU virt machine
2. QEMUsifive_umachine
3. SiFive FU540 Unleashed board
4. Kendryte K210 boardWe are almost there and just need some more time for finishing touches. We will be making is Public very soon (few more days) so stay tuned.
Quoted 6 lines
Of course, we will need help from everyone to make OpenSBI better after all it be a community driver open-source project.
There is SBI extensions spec under discussion which will be added in OpenSBI once it is frozen.
I've recently posted an question regarding "mhartid" access from S-mode in the RISC-V ISA ML [1]. If we cannot fix the issue from the architecture level, then we may have to consider adding "mhartid" emulation in the SBI. I will copy you guys on that email thread.
Quoted 3 lines
All of us will be present at up-coming FOSDEM19 to talk about SBI extensions, OpenSBI project, and other stuff.
[1] https://groups.google.com/a/groups.riscv.org/forum/#!topic/isa-dev/13afxTuYIcc
Regards,
Bin
Auer
v2 cover SiFive FU540 Support
In reply to Anup PatelQuoted 75 lines · Anup Patel
Quoted 39 lines
-----Original Message-----
From: Atish Patra [mailto:atish.patra at wdc.com]
Sent: Monday, January 21, 2019 7:07 AM
To: Auer, Lukas <[email protected]>; sjg at chromium.org; bmeng.cn at gmail.com; rick at andestech.com; Anup Patel <[email protected]>; joe.hershberger at ni.com;
yamada.masahiro at socionext.com
Cc: paul.walmsley at sifive.com; palmer at sifive.com; hch at infradead.org; u-
boot at lists.denx.de; agraf at suse.de
Subject: Re: [PATCH v2 00/11] SiFive FU540 SupportQuoted 18 lines · Lukas
Hi Anup,
Quoted 8 lines · Anup Patel
This patchset adds SiFive Freedom Unleashed (FU540) support to RISC-V
U-Boot.The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id91882c472d8c0aef4db699d3f2de55bf43d4ae4bQuoted 6 lines
All drivers namely: SiFive PRCI, SiFive Serial, and Cadance MACB
Ethernet work fine on actual SiFive Unleashed board and QEMUsifive_u
machine.Quoted 3 lines
Thanks for working on this! Are you also planning on adding the features of the FSBL to U-Boot to remove it from the boot flow?
That would also mean that adding M-mode capability in U-boot. As of now
the expected boot flow isQuoted 8 lines
ZSBL->FSBL------->BBL/OpenSBI--------->U-boot------------->Linux (M mode from ROM) (M mode from DRAM) (S Mode from DRAM) (S Mode from
DRAM)This is not the mandated boot flow but running the last stage boot loader
from S-mode gives flexibility in virtualization in future.To elaborate more on what Atish already mentioned, our rationale behind
ZSBL->FSBL->BBL/OpenSBI->U-Boot(or Any other general bootloader) is as follows:
1. We don't want to replicate FSBL code (DRAM and other system-level init)
in general purpose bootloaders (U-Boot, UEFI/Tianocore, etc)
2. We don't want to replicate SBI runtime implementation in general purpose bootloaders (U-Boot, UEFI/Tianocore, etc)
3. We want to use general purpose bootloader (U-Boot, UEFI/Tianocore, etc)
inside Guest/VM (S-mode)Of course, above boot flow is not mandatory. There could be RISC-V systems
where prior booting stages (such as ZSBL and FSBL) don't exist so users have
following options:
1. Run U-Boot in M-mode for such RISC-V systems and link to OpenSBI static
library for SBI runtime services
2. Run U-Boot in S-mode but do most system-level initialization (including
DRAM init) in OpenSBI firmware. In other words, use following booting flow:
OpenSBI (M-mode) -> U-Boot (S-mode)
Quoted 4 lines
For point1 above, we will first try it with U-Boot M-mode on QEMU Virt
machine.
Thank you for the explanation, Anup and Atish!
I am actually less concerned about adding DRAM initialization into U-Boot (but that would be nice to have) and more about having a better separation of tasks. At the moment, bootloader tasks are included in both the FSBL (device trees) and BBL (disable the monitor hart). While the current implementation works fine, it will get complicated as soon as we have more boards (and importantly, more complicated boards) using these chips. At this point, the manufacturer will have at least two board specific software components to update, the FSBL and U-Boot. This is unneeded complexity, I think.
For the same reason, I agree with you that it does not make sense to implement the SBI in U-Boot. OpenSBI is better suited to handle this.
A boot flow that could be used in this case is the following.
ZSBL -> U-Boot SPL (M-mode) -> OpenSBI -> U-Boot proper (S-mode)
Thanks,
Lukas
Quoted 27 lines
Quoted 17 lines
Quoted 12 lines
I was able to run U-Boot and boot Linux successfully on a SiFive HiFive Unleashed board with this patch series. I had to make one more
change, because U-Boot was not able to find a serial driver and paniced as a result.I fixed this by making the serial driver available pre- relocation. For
this, the soc compatible has to be added tocpu/generic/cpu.cand the
serial driver must have theDM_FLAG_PRE_RELOCflag set.Quoted 4 lines
Another way would be to add a "stdout-path" property to the chosen
node of the device tree.Quoted 8 lines
Currently, we modified the DT to add stdout-path in prior stage boot loader.
Regards,
AtishQuoted 3 lines
Thanks,
LukasRegards,
Anup
v2 cover SiFive FU540 Support
Quoted 97 lines
-----Original Message-----
From: Auer, Lukas [mailto:lukas.auer at aisec.fraunhofer.de]
Sent: Tuesday, January 22, 2019 5:21 PM
To: sjg at chromium.org; bmeng.cn at gmail.com; rick at andestech.com; Anup Patel <[email protected]>; joe.hershberger at ni.com; yamada.masahiro at socionext.com; Atish Patra <[email protected]>
Cc: paul.walmsley at sifive.com; palmer at sifive.com; hch at infradead.org; u- boot at lists.denx.de; agraf at suse.de
Subject: Re: [PATCH v2 00/11] SiFive FU540 SupportQuoted 32 lines · Anup Patel
Quoted 32 lines
-----Original Message-----
From: Atish Patra [mailto:atish.patra at wdc.com]
Sent: Monday, January 21, 2019 7:07 AM
To: Auer, Lukas <[email protected]>; sjg at chromium.org; bmeng.cn at gmail.com; rick at andestech.com; Anup Patel <[email protected]>; joe.hershberger at ni.com;
yamada.masahiro at socionext.com
Cc: paul.walmsley at sifive.com; palmer at sifive.com; hch at infradead.org; u-
boot at lists.denx.de; agraf at suse.de
Subject: Re: [PATCH v2 00/11] SiFive FU540 SupportQuoted 18 lines · Lukas
Hi Anup,
Quoted 11 lines · Anup Patel
This patchset adds SiFive Freedom Unleashed (FU540) support to RISC-V U-Boot.
The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id91882c472d8c0aef4db699d3f2de55bf43d4ae4bAll drivers namely: SiFive PRCI, SiFive Serial, and Cadance MACB Ethernet work fine on actual SiFive Unleashed board and QEMU
sifive_umachine.Thanks for working on this! Are you also planning on adding the features of the FSBL to U-Boot to remove it from the boot flow?
Quoted 5 lines
Quoted 5 lines
That would also mean that adding M-mode capability in U-boot. As of now the expected boot flow is
ZSBL->FSBL------->BBL/OpenSBI--------->U-boot------------->Linux (M mode from ROM) (M mode from DRAM) (S Mode from DRAM) (S
Mode
Quoted 29 lines
Quoted 5 lines
from
DRAM)This is not the mandated boot flow but running the last stage boot loader from S-mode gives flexibility in virtualization in future.
To elaborate more on what Atish already mentioned, our rationale behind
ZSBL->FSBL->BBL/OpenSBI->U-Boot(or Any other general bootloader) is as follows:
1. We don't want to replicate FSBL code (DRAM and other system-level init)
in general purpose bootloaders (U-Boot, UEFI/Tianocore, etc) 2. We don't want to replicate SBI runtime implementation in general purpose bootloaders (U-Boot, UEFI/Tianocore, etc) 3. We want to use general purpose bootloader (U-Boot, UEFI/Tianocore,
etc)
inside Guest/VM (S-mode)Of course, above boot flow is not mandatory. There could be RISC-V systems where prior booting stages (such as ZSBL and FSBL) don't exist so users have following options:
1. Run U-Boot in M-mode for such RISC-V systems and link to OpenSBI static library for SBI runtime services 2. Run U-Boot in S-mode but do most system-level initialization (including DRAM init) in OpenSBI firmware. In other words, use following booting
flow:
OpenSBI (M-mode) -> U-Boot (S-mode)Quoted 3 lines
For point1 above, we will first try it with U-Boot M-mode on QEMU Virt machine.
Thank you for the explanation, Anup and Atish!
I am actually less concerned about adding DRAM initialization into U-Boot (but that would be nice to have) and more about having a better separation of tasks. At the moment, bootloader tasks are included in both the FSBL (device trees) and BBL (disable the monitor hart). While the current implementation works fine, it will get complicated as soon as we have more boards (and importantly, more complicated boards) using these chips. At this point, the manufacturer will have at least two board specific software components to update, the FSBL and U-Boot. This is unneeded complexity, I think.
For the same reason, I agree with you that it does not make sense to implement the SBI in U-Boot. OpenSBI is better suited to handle this.
Quoted 3 lines
A boot flow that could be used in this case is the following.
ZSBL -> U-Boot SPL (M-mode) -> OpenSBI -> U-Boot proper (S-mode)
In this boot flow we have U-Boot SPL in-place of FSBL. At very high-level it is very similar to the boot flow we mentioned.
If we use more generic names to describe the boot flow then it would be:
ROM (on-chip ROM, M-mode) -> LOADER (on-chip SRAM, M-mode) -> RUNTIME (DRAM, M-mode) -> BOOTLOADER (DRAM, S-mode)
I agree that ROM, LOADER, and RUNTIME will be mostly board specific But BOOTLOADER can be more generic such that it can run on multiple Boards.
For example:
All drivers for SiFive FU540 in U-Boot are DT-based. If we enable these drivers for QEMU RISC-V board then we have unified U-Boot image which works on QEMU virt machine, QEMU sifive_u machine, and SiFive FU540 board. We have tried this ourselves and this actually works.
We can certainly have a generic RISC-V board support in U-Boot where enabled drivers are DT-based. With this generic RISC-V board support we can aim for unified U-Boot images which works on multiple boards.
Regards,
Anup
Auer
v2 cover SiFive FU540 Support
Quoted 129 lines · Anup Patel
Quoted 125 lines
-----Original Message-----
From: Auer, Lukas [mailto:lukas.auer at aisec.fraunhofer.de]
Sent: Tuesday, January 22, 2019 5:21 PM
To: sjg at chromium.org; bmeng.cn at gmail.com; rick at andestech.com; Anup Patel <[email protected]>; joe.hershberger at ni.com; yamada.masahiro at socionext.com; Atish Patra <[email protected]>
Cc: paul.walmsley at sifive.com; palmer at sifive.com; hch at infradead.org; u-
boot at lists.denx.de; agraf at suse.de
Subject: Re: [PATCH v2 00/11] SiFive FU540 SupportQuoted 39 lines · Anup Patel
Quoted 39 lines
-----Original Message-----
From: Atish Patra [mailto:atish.patra at wdc.com]
Sent: Monday, January 21, 2019 7:07 AM
To: Auer, Lukas <[email protected]>; sjg at chromium.org;
bmeng.cn at gmail.com; rick at andestech.com; Anup Patel <[email protected]>; joe.hershberger at ni.com; yamada.masahiro at socionext.com
Cc: paul.walmsley at sifive.com; palmer at sifive.com; hch at infradead.org;
u-
boot at lists.denx.de; agraf at suse.de
Subject: Re: [PATCH v2 00/11] SiFive FU540 SupportQuoted 23 lines · Lukas
Hi Anup,
Quoted 8 lines · Anup Patel
This patchset adds SiFive Freedom Unleashed (FU540) support to
RISC-V U-Boot.The patches are based upon latest RISC-V U-Boot tree
(git://git.denx.de/u-boot-riscv.git) at commit id91882c472d8c0aef4db699d3f2de55bf43d4ae4bQuoted 6 lines
All drivers namely: SiFive PRCI, SiFive Serial, and Cadance MACB
Ethernet work fine on actual SiFive Unleashed board and QEMUsifive_umachine.Thanks for working on this! Are you also planning on adding the
features of the FSBL to U-Boot to remove it from the boot flow?Quoted 7 lines
Quoted 7 lines
That would also mean that adding M-mode capability in U-boot. As of
now the expected boot flow isZSBL->FSBL------->BBL/OpenSBI--------->U-boot-------------
Quoted 1 line
Linux
(M mode from ROM) (M mode from DRAM) (S Mode from DRAM) (S
Mode
Quoted 40 lines
Quoted 7 lines
from
DRAM)This is not the mandated boot flow but running the last stage boot
loader from S-mode gives flexibility in virtualization in future.To elaborate more on what Atish already mentioned, our rationale behind
ZSBL->FSBL->BBL/OpenSBI->U-Boot(or Any other general bootloader) is
as follows:
1. We don't want to replicate FSBL code (DRAM and other system- level
init)
in general purpose bootloaders (U-Boot, UEFI/Tianocore, etc) 2. We
don't want to replicate SBI runtime implementation in general purpose
bootloaders (U-Boot, UEFI/Tianocore, etc) 3. We want to use general
purpose bootloader (U-Boot, UEFI/Tianocore,
etc)
inside Guest/VM (S-mode)Of course, above boot flow is not mandatory. There could be RISC- V
systems where prior booting stages (such as ZSBL and FSBL) don't exist
so users have following options:
1. Run U-Boot in M-mode for such RISC-V systems and link to OpenSBI
static library for SBI runtime services 2. Run U-Boot in S-mode but do
most system-level initialization (including DRAM init) in OpenSBI firmware. In other words, use following booting
flow:
OpenSBI (M-mode) -> U-Boot (S-mode)Quoted 4 lines
For point1 above, we will first try it with U-Boot M-mode on QEMU Virt
machine.Thank you for the explanation, Anup and Atish!
I am actually less concerned about adding DRAM initialization into U-Boot (but that would be nice to have) and more about having a better
separation of tasks. At the moment, bootloader tasks are included in
both the FSBL (device trees) and BBL (disable the monitor hart). While
the current implementation works fine, it will get complicated as soon
as we have more boards (and importantly, more complicated boards) using
these chips. At this point, the manufacturer will have at least two board specific software components to update, the FSBL and U-Boot. This
is unneeded complexity, I think.
For the same reason, I agree with you that it does not make sense to
implement the SBI in U-Boot. OpenSBI is better suited to handle this.Quoted 3 lines
A boot flow that could be used in this case is the following.
ZSBL -> U-Boot SPL (M-mode) -> OpenSBI -> U-Boot proper (S-mode)
Quoted 8 lines
In this boot flow we have U-Boot SPL in-place of FSBL. At very high- level
it is very similar to the boot flow we mentioned.If we use more generic names to describe the boot flow then it would be:
ROM (on-chip ROM, M-mode) -> LOADER (on-chip SRAM, M-mode) -> RUNTIME (DRAM, M-mode) -> BOOTLOADER (DRAM, S-mode)
That's true, the boot flow is more or less the same. The big difference is that we have one less software project that must be tested and maintained. :)
Quoted 12 lines
I agree that ROM, LOADER, and RUNTIME will be mostly board specific But BOOTLOADER can be more generic such that it can run on multiple Boards.
For example:
All drivers for SiFive FU540 in U-Boot are DT-based. If we enable these
drivers for QEMU RISC-V board then we have unified U-Boot image which works on QEMU virt machine, QEMUsifive_umachine, and SiFive FU540 board. We have tried this ourselves and this actually works.
Quoted 6 lines
We can certainly have a generic RISC-V board support in U-Boot where enabled drivers are DT-based. With this generic RISC-V board support we can aim for unified U-Boot images which works on multiple boards.
Regards,
Anup
I do agree that a generic bootloader would be a very good thing to have and I think we should try to keep everything reasonably generic. However, I also think that we will likely need some degree of board- specific configuration, which can probably be limited to the device trees and U-Boot config.
Thanks,
Lukas
v2 cover SiFive FU540 Support
In reply to AuerQuoted 2 lines · Lukas
For the same reason, I agree with you that it does not make sense to implement the SBI in U-Boot. OpenSBI is better suited to handle this.
It should be possible to link the OpenSBI library with U-boot, then allow U-boot to use SBI services itself, and to expose the SBI services to whatever it boots. So the OpenSBI boot firmware wouldn't be used, but the underlying library code would be. That simplifies the boot flow, since the (separate) OpenSBI firmware would no longer be needed.
Quoted 3 lines
A boot flow that could be used in this case is the following.
ZSBL -> U-Boot SPL (M-mode) -> OpenSBI -> U-Boot proper (S-mode)
There are other boot flows that are common on ARM platforms:
- Boot ROM -> SPL -> U-boot -> Linux
- Boot ROM -> SPL -> U-boot -> (SBI implementation / TEE) -> Linux
It would be good if we could avoid prejudicing against any of these boot flows.
- Paul
Auer
v2 cover SiFive FU540 Support
Quoted 7 lines · Paul Walmsley
Quoted 4 lines · Lukas
For the same reason, I agree with you that it does not make sense to
implement the SBI in U-Boot. OpenSBI is better suited to handle this.
Quoted 9 lines
It should be possible to link the OpenSBI library with U-boot, then allow
U-boot to use SBI services itself, and to expose the SBI services to whatever it boots. So the OpenSBI boot firmware wouldn't be used, but the
underlying library code would be. That simplifies the boot flow, since
the (separate) OpenSBI firmware would no longer be needed.
Yes, that would also work. I am not at all against integrating the OpenSBI library into U-Boot. Having a separate SBI implementation instead of a shared one (OpenSBI) is what I think does not make sense.
Thanks,
Lukas
Quoted 15 lines
Quoted 3 lines
A boot flow that could be used in this case is the following.
ZSBL -> U-Boot SPL (M-mode) -> OpenSBI -> U-Boot proper (S-mode)
There are other boot flows that are common on ARM platforms:
- Boot ROM -> SPL -> U-boot -> Linux
- Boot ROM -> SPL -> U-boot -> (SBI implementation / TEE) -> LinuxIt would be good if we could avoid prejudicing against any of these boot
flows.- Paul