SiFive FU540 Support
Subsystems (5)
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.
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: 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 | 39 ++
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, 1467 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 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
PATCH 1/11 riscv: Rename cpu/qemu to cpu/generic
Quoted 5 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.
Quoted 7 lines
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]>
Alex
PATCH 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
PATCH 2/11 riscv: Add asm/dma-mapping.h for DMA mappings
Quoted 6 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).Signed-off-by Anup Patel <[email protected]>Reviewed-by Bin Meng <[email protected]>
Alex
PATCH 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 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
arch/riscv/cpu/generic/dram.c +22 -0
@@ -6,6 +6,8 @@#include <common.h> #include <fdtdec.h> +DECLARE_GLOBAL_DATA_PTR ; +int dram_init (void ) {return fdtdec_setup_mem_size_base ();
@@ -15,3 +17,23 @@ 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 >0x100000000UL ) +return 0x100000000UL ; +else +return gd->ram_top; +#else +return gd->ram_top; +#endif +}
Signature · 1 line
2.17.1
PATCH 3/11 riscv: generic: Ensure that U-Boot runs within 4GB for 64bit systems
Quoted 7 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.
Quoted 8 lines
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.Signed-off-by Anup Patel <[email protected]>Signed-off-by Atish Patra <[email protected]>
You could probably write that with MIN() more easily, but this way works fine too.
Alex
PATCH 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 4/11 net: macb: Fix clk API usage for RISC-V systems
Quoted 29 lines · Anup Patel
This patch does following fixes in MACB ethernet driver for using it on RISC-V systems (particularly QEMU
sifive_umachine):
1.asm/arch/clk.his not available on RISC-V port so include it only for non-RISC-V systems.
2. Don't fail inmacb_enable_clk()ifclk_enable()returns-ENOSYSbecause we get-ENOSYSfor fixed-rate clocks.Signed-off-by Anup Patel <[email protected]>Reviewed-by Bin Meng <[email protected]>--- drivers/net/macb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/macb.c +2
-0@@ -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"
drivers/net/macb.c static int macb_enable_clk(struct udevice *dev) · line 1070
Quoted 3 lines
drivers/net/macb.c +0
-0@@ -1066,7 +1068,7 @@ static int macb_enable_clk(struct udevice *dev)*/ #ifndef CONFIG_MACB_ZYNQ ret =clk_enable (&clk);
If clk.h is not available, who exports clk_enable() then; and why is the included needed in the first place?
Alex
Quoted 5 lines
drivers/net/macb.c +1
-1-if (ret) +if (ret && ret != -ENOSYS )return ret;#endif
PATCH 4/11 net: macb: Fix clk API usage for RISC-V systems
Quoted 44 lines
-----Original Message-----
From: Alexander Graf [mailto:agraf at suse.de]
Sent: Thursday, January 17, 2019 11:37 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 04/11] net: macb: Fix clk API usage for RISC-V systemsQuoted 27 lines · Anup Patel
This patch does following fixes in MACB ethernet driver for using it on RISC-V systems (particularly QEMU
sifive_u
machine):
1.asm/arch/clk.his not available on RISC-V port so include it only for non-RISC-V systems.
2. Don't fail inmacb_enable_clk()ifclk_enable()returns-ENOSYSbecause we get-ENOSYSfor fixed-rate clocks.Signed-off-by Anup Patel <[email protected]>Reviewed-by Bin Meng <[email protected]>--- drivers/net/macb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/macb.c index renamed from drivers/net/macb.c +0
-0
94c89c762b..9a06b523cc100644drivers/net/macb.c +2
-0@@ -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>
Quoted 8 lines
drivers/net/macb.c static int macb_enable_clk(struct udevice *dev) · line 1070
Quoted 5 lines
drivers/net/macb.c +0
-0#include "macb.h" @@ -1066,7 +1068,7 @@ static int macb_enable_clk(struct udevice *dev)*/ #ifndef CONFIG_MACB_ZYNQ ret =clk_enable (&clk);If
clk.his not available, who exportsclk_enable()then; and why is the included needed in the first place?
For some of the ARM boards, clk instances are provided directly by arch/arm/mach-xyz sources. For such boards, asm/arch/clk.h is required. I think these boards should move to DT based clk drivers.
In all other cases, we use generic <clk.h> which provides clk instances using DT based clk drivers.
Regards,
Anup
PATCH 4/11 net: macb: Fix clk API usage for RISC-V systems
Quoted 57 lines
Am 18.01.2019 um 07:05 schrieb Anup Patel <[email protected]>:
Quoted 42 lines
-----Original Message-----
From: Alexander Graf [mailto:agraf at suse.de]
Sent: Thursday, January 17, 2019 11:37 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 04/11] net: macb: Fix clk API usage for RISC-V systemsQuoted 28 lines · Anup Patel
This patch does following fixes in MACB ethernet driver for using it on RISC-V systems (particularly QEMU
sifive_u
machine):
1.asm/arch/clk.his not available on RISC-V port so include it only for non-RISC-V systems.
2. Don't fail inmacb_enable_clk()ifclk_enable()returns-ENOSYSbecause we get-ENOSYSfor fixed-rate clocks.Signed-off-by Anup Patel <[email protected]>Reviewed-by Bin Meng <[email protected]>--- drivers/net/macb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/macb.c index renamed from drivers/net/macb.c +0
-0
94c89c762b..9a06b523cc100644drivers/net/macb.c +2
-0@@ -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> Quoted 8 lines
drivers/net/macb.c static int macb_enable_clk(struct udevice *dev) · line 1070
Quoted 5 lines
drivers/net/macb.c +0
-0#include "macb.h" @@ -1066,7 +1068,7 @@ static int macb_enable_clk(struct udevice *dev)*/ #ifndef CONFIG_MACB_ZYNQ ret =clk_enable (&clk);If
clk.his not available, who exportsclk_enable()then; and why is the included needed in the first place?
Quoted 4 lines
For some of the ARM boards, clk instances are provided directly by
arch/arm/mach-xyzsources. For such boards,asm/arch/clk.his required. I think these boards should move to DT based clk drivers.
Can you at least make this a positive #ifdef then rather than ifndef? We want to isolate the odd case, not the normal one.
Maybe you can even find a config option that isolates it further?
Alex
Quoted 6 lines
In all other cases, we use generic <
clk.h> which provides clk instances using DT based clk drivers.Regards,
Anup
PATCH 4/11 net: macb: Fix clk API usage for RISC-V systems
Quoted 76 lines
-----Original Message-----
From: Alexander Graf [mailto:agraf at suse.de]
Sent: Friday, January 18, 2019 5:05 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]>; Simon Glass <[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 04/11] net: macb: Fix clk API usage for RISC-V systemsQuoted 8 lines
Am 18.01.2019 um 07:05 schrieb Anup Patel <[email protected]>:
Quoted 4 lines
-----Original Message-----
From: Alexander Graf [mailto:agraf at suse.de]
Sent: Thursday, January 17, 2019 11:37 PM
To: Anup Patel <[email protected]>; Rick ChenQuoted 39 lines
Quoted 39 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 04/11] net: macb: Fix clk API usage for RISC-V systemsQuoted 28 lines · Anup Patel
This patch does following fixes in MACB ethernet driver for using it on RISC-V systems (particularly QEMU
sifive_u
machine):
1.asm/arch/clk.his not available on RISC-V port so include it only for non-RISC-V systems.
2. Don't fail inmacb_enable_clk()ifclk_enable()returns-ENOSYSbecause we get-ENOSYSfor fixed-rate clocks.Signed-off-by Anup Patel <[email protected]>Reviewed-by Bin Meng <[email protected]>--- drivers/net/macb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/macb.c index renamed from drivers/net/macb.c +0
-0
94c89c762b..9a06b523cc100644drivers/net/macb.c +2
-0@@ -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> Quoted 2 lines
Quoted 2 lines
drivers/net/macb.c static int macb_enable_clk(struct udevice
Quoted 2 lines
drivers/net/macb.c +0
-0#include "macb.h" @@ -1066,7 +1068,7 @@ static int macb_enable_clk(struct udevice*dev)
Quoted 7 lines
Quoted 6 lines
drivers/net/macb.c static int macb_enable_clk(struct udevice *dev) · line 1070
Quoted 3 lines
drivers/net/macb.c +0
-0*/ #ifndef CONFIG_MACB_ZYNQ ret =clk_enable (&clk);If
clk.his not available, who exportsclk_enable()then; and why is the included needed in the first place?
Quoted 8 lines
Quoted 3 lines
For some of the ARM boards, clk instances are provided directly by
arch/arm/mach-xyzsources. For such boards,asm/arch/clk.his required. I think these boards should move to DT based clk drivers.Can you at least make this a positive #ifdef then rather than ifndef? We want to isolate the odd case, not the normal one.
Maybe you can even find a config option that isolates it further?
With the additional check "ret != -ENOSYS", we don't require the #ifndef but someone with Zynq SOC board need to confirm that removing #ifndef won't hurt.
Regards,
Anup
PATCH 4/11 net: macb: Fix clk API usage for RISC-V systems
Quoted 80 lines · Anup Patel
Quoted 80 lines
-----Original Message-----
From: Alexander Graf [mailto:agraf at suse.de]
Sent: Friday, January 18, 2019 5:05 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]>; Simon Glass <[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 04/11] net: macb: Fix clk API usage for RISC-V systemsQuoted 8 lines
Am 18.01.2019 um 07:05 schrieb Anup Patel <[email protected]>:
Quoted 4 lines
-----Original Message-----
From: Alexander Graf [mailto:agraf at suse.de]
Sent: Thursday, January 17, 2019 11:37 PM
To: Anup Patel <[email protected]>; Rick ChenQuoted 39 lines
Quoted 39 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 04/11] net: macb: Fix clk API usage for RISC-V systemsQuoted 28 lines · Anup Patel
This patch does following fixes in MACB ethernet driver for using it on RISC-V systems (particularly QEMU
sifive_u
machine):
1.asm/arch/clk.his not available on RISC-V port so include it only for non-RISC-V systems.
2. Don't fail inmacb_enable_clk()ifclk_enable()returns-ENOSYSbecause we get-ENOSYSfor fixed-rate clocks.Signed-off-by Anup Patel <[email protected]>Reviewed-by Bin Meng <[email protected]>--- drivers/net/macb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/macb.c index renamed from drivers/net/macb.c +0
-0
94c89c762b..9a06b523cc100644drivers/net/macb.c +2
-0@@ -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> Quoted 2 lines
Quoted 2 lines
drivers/net/macb.c static int macb_enable_clk(struct udevice
Quoted 2 lines
drivers/net/macb.c +0
-0#include "macb.h" @@ -1066,7 +1068,7 @@ static int macb_enable_clk(struct udevice*dev)
Quoted 10 lines
Quoted 6 lines
drivers/net/macb.c static int macb_enable_clk(struct udevice *dev) · line 1070
Quoted 3 lines
drivers/net/macb.c +0
-0*/ #ifndef CONFIG_MACB_ZYNQ ret =clk_enable (&clk);If
clk.his not available, who exportsclk_enable()then; and why is the included needed in the first place?For some of the ARM boards, clk instances are provided directly by
arch/arm/mach-xyzsources. For such boards,asm/arch/clk.his required. I think these boards should move to DT based clk drivers.
Quoted 8 lines
Quoted 4 lines
Can you at least make this a positive #ifdef then rather than ifndef? We want to isolate the odd case, not the normal one.
Maybe you can even find a config option that isolates it further?
With the additional check "ret !=
-ENOSYS", we don't require the #ifndef but someone with Zynq SOC board need to confirm that removing #ifndef won't hurt.
In that case let's CC Michal :).
Alex
PATCH 4/11 net: macb: Fix clk API usage for RISC-V systems
Hi,
Quoted 87 lines · Alexander Graf
Quoted 83 lines · Anup Patel
Quoted 83 lines
-----Original Message-----
From: Alexander Graf [mailto:agraf at suse.de]
Sent: Friday, January 18, 2019 5:05 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]>; Simon Glass <[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 04/11] net: macb: Fix clk API usage for RISC-V systemsQuoted 8 lines
Am 18.01.2019 um 07:05 schrieb Anup Patel <[email protected]>:
Quoted 4 lines
-----Original Message-----
From: Alexander Graf [mailto:agraf at suse.de]
Sent: Thursday, January 17, 2019 11:37 PM
To: Anup Patel <[email protected]>; Rick ChenQuoted 39 lines
Quoted 39 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 04/11] net: macb: Fix clk API usage for RISC-V systemsQuoted 28 lines · Anup Patel
This patch does following fixes in MACB ethernet driver for using it on RISC-V systems (particularly QEMU
sifive_u
machine):
1.asm/arch/clk.his not available on RISC-V port so include it only for non-RISC-V systems.
2. Don't fail inmacb_enable_clk()ifclk_enable()returns-ENOSYSbecause we get-ENOSYSfor fixed-rate clocks.Signed-off-by Anup Patel <[email protected]>Reviewed-by Bin Meng <[email protected]>--- drivers/net/macb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/macb.c index renamed from drivers/net/macb.c +0
-0
94c89c762b..9a06b523cc100644drivers/net/macb.c +2
-0@@ -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> Quoted 2 lines
Quoted 2 lines
drivers/net/macb.c static int macb_enable_clk(struct udevice
Quoted 2 lines
drivers/net/macb.c +0
-0#include "macb.h" @@ -1066,7 +1068,7 @@ static int macb_enable_clk(struct udevice*dev)
Quoted 10 lines
Quoted 6 lines
drivers/net/macb.c static int macb_enable_clk(struct udevice *dev) · line 1070
Quoted 3 lines
drivers/net/macb.c +0
-0*/ #ifndef CONFIG_MACB_ZYNQ ret =clk_enable (&clk);If
clk.his not available, who exportsclk_enable()then; and why is the included needed in the first place?For some of the ARM boards, clk instances are provided directly by
arch/arm/mach-xyzsources. For such boards,asm/arch/clk.his required. I think these boards should move to DT based clk drivers.Can you at least make this a positive #ifdef then rather than ifndef? We want to isolate the odd case, not the normal one.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Maybe you can even find a config option that isolates it further?
With the additional check "ret !=
-ENOSYS", we don't require the #ifndef but someone with Zynq SOC board need to confirm that removing #ifndef won't hurt.In that case let's CC Michal :).
Yes, although putting an arch-specific #ifdef in a driver is not correct, so I think the onus would be on Michal to fix that if it were a problem.
Regards,
Simon
PATCH 4/11 net: macb: Fix clk API usage for RISC-V systems
Quoted 112 lines
-----Original Message-----
From: Simon Glass [mailto:sjg at chromium.org]
Sent: Thursday, January 31, 2019 3:34 PM
To: Alexander Graf <[email protected]>
Cc: Anup Patel <[email protected]>; Rick Chen <[email protected]>; Bin Meng <[email protected]>; Joe Hershberger <[email protected]>; Lukas Auer <[email protected]>; Masahiro Yamada <[email protected]>; Palmer Dabbelt <[email protected]>; Paul Walmsley <[email protected]>; Atish Patra <[email protected]>; Christoph Hellwig <[email protected]>; U- Boot Mailing List <[email protected]>; Michal Simek <[email protected]>
Subject: Re: [PATCH 04/11] net: macb: Fix clk API usage for RISC-V systemsHi,
Quoted 11 lines · Alexander Graf
Quoted 7 lines · Anup Patel
Quoted 7 lines
-----Original Message-----
From: Alexander Graf [mailto:agraf at suse.de]
Sent: Friday, January 18, 2019 5:05 PM
To: Anup Patel <[email protected]>
Cc: Rick Chen <[email protected]>; Bin MengQuoted 3 lines
Quoted 3 lines
Quoted 3 lines
Joe Hershberger <[email protected]>; Lukas Auer <[email protected]>; Masahiro Yamada <[email protected]>; Simon Glass
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
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 04/11] net: macb: Fix clk API usage for RISC-V systemsQuoted 8 lines
Am 18.01.2019 um 07:05 schrieb Anup Patel <[email protected]>:
Quoted 4 lines
-----Original Message-----
From: Alexander Graf [mailto:agraf at suse.de]
Sent: Thursday, January 17, 2019 11:37 PM
To: Anup Patel <[email protected]>; Rick ChenQuoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Bin Meng <[email protected]>; Joe Hershberger
<[email protected]>; Lukas Auer
<[email protected]>; Masahiro Yamada
<[email protected]>; Simon GlassQuoted 54 lines
Quoted 54 lines
Quoted 53 lines
Quoted 35 lines
Quoted 35 lines
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 04/11] net: macb: Fix clk API usage for RISC-V systemsQuoted 28 lines · Anup Patel
This patch does following fixes in MACB ethernet driver for using it on RISC-V systems (particularly QEMU
sifive_umachine):
1.asm/arch/clk.his not available on RISC-V port so include it only for non-RISC-V systems.
2. Don't fail inmacb_enable_clk()ifclk_enable()returns-ENOSYSbecause we get-ENOSYSfor fixed-rate clocks.Signed-off-by Anup Patel <[email protected]>Reviewed-by Bin Meng <[email protected]>--- drivers/net/macb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/net/macb.c index renamed from drivers/net/macb.c +0
-0
94c89c762b..9a06b523cc100644drivers/net/macb.c +2
-0@@ -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> Quoted 2 lines
Quoted 2 lines
drivers/net/macb.c static int macb_enable_clk(struct udevice
Quoted 2 lines
drivers/net/macb.c +0
-0#include "macb.h" @@ -1066,7 +1068,7 @@ static int macb_enable_clk(struct udevice*dev)
Quoted 10 lines
Quoted 6 lines
drivers/net/macb.c static int macb_enable_clk(struct udevice · line 1070
Quoted 3 lines
drivers/net/macb.c +0
-0*/ #ifndef CONFIG_MACB_ZYNQ ret =clk_enable (&clk);If
clk.his not available, who exportsclk_enable()then; and why is the included needed in the first place?For some of the ARM boards, clk instances are provided directly by
arch/arm/mach-xyzsources. For such boards,asm/arch/clk.his required. I think these boards should move to DT based clk drivers.Can you at least make this a positive #ifdef then rather than ifndef? We want to isolate the odd case, not the normal one.
Maybe you can even find a config option that isolates it further?
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
With the additional check "ret !=
-ENOSYS", we don't require the #ifndef but someone with Zynq SOC board need to confirm that removing #ifndef won't hurt.In that case let's CC Michal :).
Yes, although putting an arch-specific #ifdef in a driver is not correct, so I think the onus would be on Michal to fix that if it were a problem.
Okay, I will drop the #ifndef and if required Michal can fix it for Zynq SoC.
Regards,
Anup
PATCH 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 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]>
I found the respective Linux commit:361918970b7426bba97a64678ef2b2679c37199b.
Alex
PATCH 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
PATCH 6/11 clk: Add SiFive FU540 PRCI clock driver
Quoted 8 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-linux
Quoted 6 lines
Boot 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]>
Can't say much about how the device works or whether this is in 100% compliance to the U-Boot clk framework, but I didn't see anything obviously wrong :).
Alex
PATCH 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 7/11 clk: Add fixed-factor clock driver
Quoted 68 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.
Signed-off-by Anup Patel <[email protected]>Signed-off-by Atish Patra <[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.cdrivers/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 +35
-0@@ -0,0 +1,74 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (c) 2019 Western Digital Corporation or its affiliates. +* +* Author: Anup Patel <[email protected]> +*/ + +#include <common.h> +#include <clk-uclass.h> +#include <div64.h> +#include <dm.h> + +struct clk_fixed_factor { +struct clk parent; +unsigned int div; +unsigned int mult; +}; + +#define to_clk_fixed_factor (dev) \ + ((struct clk_fixed_factor *)dev_get_platdata(dev)) + +static ulong clk_fixed_factor_get_rate (struct clk *clk) +{ +int ret; +struct clk_fixed_factor *ff =to_clk_fixed_factor (clk->dev); + +if (clk->id !=0 ) +return -EINVAL ; + + ret =clk_get_rate (&ff->parent); +if (IS_ERR_VALUE (ret)) +return ret; + +do_div (ret, ff->div); +
drivers/clk/clk_fixed_factor.c line 45
Quoted 10 lines
drivers/clk/clk_fixed_factor.c new file +10
-0+return ret * ff->mult; +} + +const struct clk_ops clk_fixed_factor_ops = { + .get_rate = clk_fixed_factor_get_rate, +}; + +static int clk_fixed_factor_ofdata_to_platdata (struct udevice *dev) +{ +#if !CONFIG_IS_ENABLED (OF_PLATDATA )
Why do you need this?
Alex
Quoted 29 lines
drivers/clk/clk_fixed_factor.c new file +29
-0+int err; +struct clk_fixed_factor *ff =to_clk_fixed_factor (dev); + + err =clk_get_by_index (dev,0 , &ff->parent); +if (err) +return err; + + ff->div =dev_read_u32_default (dev,"clock-div" ,1 ); + ff->mult =dev_read_u32_default (dev,"clock-mult" ,1 ); +#endif + +return 0 ; +} + +static const struct udevice_id clk_fixed_factor_match[] = { + { + .compatible ="fixed-factor-clock" , + }, + {/* sentinel */ } +}; + +U_BOOT_DRIVER (clk_fixed_factor) = { + .name ="fixed_factor_clock" , + .id =UCLASS_CLK , + .of_match = clk_fixed_factor_match, + .ofdata_to_platdata = clk_fixed_factor_ofdata_to_platdata, + .platdata_auto_alloc_size =sizeof (struct clk_fixed_factor ), + .ops = &clk_fixed_factor_ops, +};
PATCH 7/11 clk: Add fixed-factor clock driver
Quoted 85 lines
-----Original Message-----
From: Alexander Graf [mailto:agraf at suse.de]
Sent: Thursday, January 17, 2019 11:51 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 07/11] clk: Add fixed-factor clock driverQuoted 8 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.
Signed-off-by Anup Patel <[email protected]>Signed-off-by Atish Patra <[email protected]>--- drivers/clk/Makefile | 4 +- drivers/clk/clk_fixed_factor.c | 74++++++++++++++++++++++++++++++++++
Quoted 59 lines
2 files changed, 77 insertions(+), 1 deletion(-)create mode 100644
drivers/clk/clk_fixed_factor.cdrivers/clk/Makefile index renamed from drivers/clk/Makefile +0
-0
2f4446568c..fa59259ea3100644drivers/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/(quoted diff) +0
-0
b/drivers/clk/clk_fixed_factor.cnew file mode 100644 index 0000000000..eab1724c26drivers/clk/clk_fixed_factor.c new file +35
-0@@ -0,0 +1,74 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (c) 2019 Western Digital Corporation or its affiliates. +* +* Author: Anup Patel <[email protected]> */ + +#include <common.h> +#include <clk-uclass.h> +#include <div64.h> +#include <dm.h> + +struct clk_fixed_factor { +struct clk parent; +unsigned int div; +unsigned int mult; +}; + +#define to_clk_fixed_factor (dev) \ + ((struct clk_fixed_factor *)dev_get_platdata(dev)) + +static ulong clk_fixed_factor_get_rate (struct clk *clk) { +int ret; +struct clk_fixed_factor *ff =to_clk_fixed_factor (clk->dev); + +if (clk->id !=0 ) +return -EINVAL ; + + ret =clk_get_rate (&ff->parent); +if (IS_ERR_VALUE (ret)) +return ret; + +do_div (ret, ff->div); + +return ret * ff->mult; +}
Quoted 8 lines
drivers/clk/clk_fixed_factor.c line 45
Quoted 6 lines
drivers/clk/clk_fixed_factor.c new file +6
-0+ +const struct clk_ops clk_fixed_factor_ops = { + .get_rate = clk_fixed_factor_get_rate, }; + +static int clk_fixed_factor_ofdata_to_platdata (struct udevice *dev) { +#if !CONFIG_IS_ENABLED (OF_PLATDATA )Why do you need this?
This is for boards/configuration where OF_PLATDATA is not enabled. For such boards, the board support code will provide platdata.
I saw similar thing in clk_fixed_rate.c too hence kept it here. Do you want me to drop this "#if"?
Quoted 23 lines
Alex
Quoted 20 lines
drivers/clk/clk_fixed_factor.c new file +20
-0+int err; +struct clk_fixed_factor *ff =to_clk_fixed_factor (dev); + + err =clk_get_by_index (dev,0 , &ff->parent); +if (err) +return err; + + ff->div =dev_read_u32_default (dev,"clock-div" ,1 ); + ff->mult =dev_read_u32_default (dev,"clock-mult" ,1 );#endif + +return 0 ; +} + +static const struct udevice_id clk_fixed_factor_match[] = { + { + .compatible ="fixed-factor-clock" , + }, + {/* sentinel */ } +}; +
Quoted 8 lines
drivers/clk/clk_fixed_factor.c line 74
Quoted 8 lines
drivers/clk/clk_fixed_factor.c new file +8
-0+U_BOOT_DRIVER (clk_fixed_factor) = { + .name ="fixed_factor_clock" , + .id =UCLASS_CLK , + .of_match = clk_fixed_factor_match, + .ofdata_to_platdata = clk_fixed_factor_ofdata_to_platdata, + .platdata_auto_alloc_size =sizeof (struct clk_fixed_factor ), + .ops = &clk_fixed_factor_ops, +};
Regards,
Anup
PATCH 7/11 clk: Add fixed-factor clock driver
Quoted 91 lines · Anup Patel
Quoted 83 lines
-----Original Message-----
From: Alexander Graf [mailto:agraf at suse.de]
Sent: Thursday, January 17, 2019 11:51 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 07/11] clk: Add fixed-factor clock driverQuoted 8 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.
Signed-off-by Anup Patel <[email protected]>Signed-off-by Atish Patra <[email protected]>--- drivers/clk/Makefile | 4 +- drivers/clk/clk_fixed_factor.c | 74++++++++++++++++++++++++++++++++++
Quoted 58 lines
2 files changed, 77 insertions(+), 1 deletion(-)create mode 100644
drivers/clk/clk_fixed_factor.cdrivers/clk/Makefile index renamed from drivers/clk/Makefile +0
-0
2f4446568c..fa59259ea3100644drivers/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/(quoted diff) +0
-0
b/drivers/clk/clk_fixed_factor.cnew file mode 100644 index 0000000000..eab1724c26drivers/clk/clk_fixed_factor.c new file +34
-0@@ -0,0 +1,74 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (c) 2019 Western Digital Corporation or its affiliates. +* +* Author: Anup Patel <[email protected]> */ + +#include <common.h> +#include <clk-uclass.h> +#include <div64.h> +#include <dm.h> + +struct clk_fixed_factor { +struct clk parent; +unsigned int div; +unsigned int mult; +}; + +#define to_clk_fixed_factor (dev) \ + ((struct clk_fixed_factor *)dev_get_platdata(dev)) + +static ulong clk_fixed_factor_get_rate (struct clk *clk) { +int ret; +struct clk_fixed_factor *ff =to_clk_fixed_factor (clk->dev); + +if (clk->id !=0 ) +return -EINVAL ; + + ret =clk_get_rate (&ff->parent); +if (IS_ERR_VALUE (ret)) +return ret; + +do_div (ret, ff->div); + +return ret * ff->mult;Quoted 8 lines
drivers/clk/clk_fixed_factor.c line 45
Quoted 7 lines
drivers/clk/clk_fixed_factor.c new file +7
-0+} + +const struct clk_ops clk_fixed_factor_ops = { + .get_rate = clk_fixed_factor_get_rate, }; + +static int clk_fixed_factor_ofdata_to_platdata (struct udevice *dev) { +#if !CONFIG_IS_ENABLED (OF_PLATDATA )Why do you need this?
Quoted 3 lines
This is for boards/configuration where
OF_PLATDATAis not enabled. For such boards, the board support code will provide platdata.I saw similar thing in
clk_fixed_rate.ctoo hence kept it here. Do you want me to drop this "#if"?
I would prefer if we don't advocate OF_PLATDATA more than we have to. So I'm all for making it harder to use it :). In other words, yes, please drop support for it for now.
Alex
PATCH 7/11 clk: Add fixed-factor clock driver
Quoted 110 lines
-----Original Message-----
From: Alexander Graf [mailto:agraf at suse.de]
Sent: Monday, January 21, 2019 7:49 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 07/11] clk: Add fixed-factor clock driverQuoted 5 lines · Anup Patel
Quoted 5 lines
-----Original Message-----
From: Alexander Graf [mailto:agraf at suse.de]
Sent: Thursday, January 17, 2019 11:51 PM
To: Anup Patel <[email protected]>; Rick ChenQuoted 86 lines
Quoted 78 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 07/11] clk: Add fixed-factor clock driverQuoted 8 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.
Signed-off-by Anup Patel <[email protected]>Signed-off-by Atish Patra <[email protected]>--- drivers/clk/Makefile | 4 +- drivers/clk/clk_fixed_factor.c | 74++++++++++++++++++++++++++++++++++
Quoted 58 lines
2 files changed, 77 insertions(+), 1 deletion(-)create mode 100644
drivers/clk/clk_fixed_factor.cdrivers/clk/Makefile index renamed from drivers/clk/Makefile +0
-0
2f4446568c..fa59259ea3100644drivers/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/(quoted diff) +0
-0
b/drivers/clk/clk_fixed_factor.cnew file mode 100644 index 0000000000..eab1724c26drivers/clk/clk_fixed_factor.c new file +34
-0@@ -0,0 +1,74 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (c) 2019 Western Digital Corporation or its affiliates. +* +* Author: Anup Patel <[email protected]> */ + +#include <common.h> +#include <clk-uclass.h> +#include <div64.h> +#include <dm.h> + +struct clk_fixed_factor { +struct clk parent; +unsigned int div; +unsigned int mult; +}; + +#define to_clk_fixed_factor (dev) \ + ((struct clk_fixed_factor *)dev_get_platdata(dev)) + +static ulong clk_fixed_factor_get_rate (struct clk *clk) { +int ret; +struct clk_fixed_factor *ff =to_clk_fixed_factor (clk->dev); + +if (clk->id !=0 ) +return -EINVAL ; + + ret =clk_get_rate (&ff->parent); +if (IS_ERR_VALUE (ret)) +return ret; + +do_div (ret, ff->div); + +return ret * ff->mult;Quoted 8 lines
drivers/clk/clk_fixed_factor.c
Quoted 7 lines
drivers/clk/clk_fixed_factor.c new file +7
-0+} + +const struct clk_ops clk_fixed_factor_ops = { + .get_rate = clk_fixed_factor_get_rate, }; + +static int clk_fixed_factor_ofdata_to_platdata (struct udevice *dev) +{#if !CONFIG_IS_ENABLED (OF_PLATDATA )Why do you need this?
Quoted 1 line
This is for boards/configuration where
OF_PLATDATAis not enabled. For
Quoted 8 lines
such boards, the board support code will provide platdata.
Quoted 2 lines
I saw similar thing in
clk_fixed_rate.ctoo hence kept it here. Do you wantme to drop this "#if"?
I would prefer if we don't advocate
OF_PLATDATAmore than we have to. So I'm all for making it harder to use it :). In other words, yes, please drop support for it for now.
Okay, I will drop the "#if".
Regards,
Anup
PATCH 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 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]>
Alex
PATCH 9/11 drivers: serial: 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
PATCH 9/11 drivers: serial: serial_sifive: Skip baudrate config if no input clock
Quoted 11 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.
In this case, instead of failing we should just skip baudrate config by returning zero.
Signed-off-by Atish Patra <[email protected]>Signed-off-by Anup Patel <[email protected]>
Alex
PATCH 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 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]>
Alex
PATCH 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
PATCH 11/11 riscv: Add SiFive FU540 board support
So I take it I could use my version of U-boot to load BBL, then your S-mode U-boot?
I've been holding off on refactoring or submitting anything from the MicroSemi U-boot that runs in M-mode and inits the DRAM until I have some decent method to regression test the whole system (bootloader, kernel, userspace). I also want to make sure we don't break any other RiscV platforms when we add new code.
It looks HiFive unleashed boards are available for purchase again, is there any place to get an AndesTech board?
(fyi, the *proof of concept* hacks for regression testing that work for me based on MicroSemi patches are at
https://github.com/tmagik/freedom-u-sdk/tree/regression/kernel4.15 )
Quoted 214 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 Anup Patel <[email protected]>Signed-off-by Atish Patra <[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(+) 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.harch/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-fu540.h new file +43
-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" \ + "pxefile_addr_r=0x82400000\0" \ + "ramdisk_addr_r=0x82500000\0" \ + BOOTENV + +#endif /* __CONFIG_H */ Signature · 6 lines
2.17.1 _______________________________________________ U-Boot mailing list U-Boot at lists.denx.de https://lists.denx.de/listinfo/u-boot
PATCH 11/11 riscv: Add SiFive FU540 board support
Quoted 3 lines · Troy Benjegerdes
So I take it I could use my version of U-boot to load BBL, then your S-mode U-boot?
No need of your version of U-boot to load BBL. This patchset intend to follow the standard boot flow.
ZSBL->FSBL->BBL/OpenSBI->U-boot->Linux.
(From ROM)--(M Mode)----(S Mode)-(S Mode)
Couple of Methods to boot Linux:
1. Create a combined image of u-boot and Linux. Give that combined image as a payload to BBL/OpenSBI. U-boot prompt should appear.
2. Just provide U-boot image as a payload to BBL/OpenSBI. U-boot prompt should appear. Use TFTP to load Linux.
bootm can be used to boot Linux afterwards.
As of now, there is no SMP support in u-boot. So you may want to bringup one cpu and test non-smp configuration.
Once we have SPI driver support in U-boot, we should be load images from MMC as well.
Quoted 7 lines
I've been holding off on refactoring or submitting anything from the MicroSemi U-boot that runs in M-mode and inits the DRAM until I have some decent method to regression test the whole system (bootloader, kernel, userspace). I also want to make sure we don't break any other RiscV platforms when we add new code.
I am hoping AndesTech guys will give a go at the patchset ;).
Quoted 3 lines
It looks HiFive unleashed boards are available for purchase again, is there any place to get an AndesTech board?
I am not aware of any AndesTech Dev boards.
Quoted 4 lines
(fyi, the *proof of concept* hacks for regression testing that work for me based on MicroSemi patches are at
https://github.com/tmagik/freedom-u-sdk/tree/regression/kernel4.15 )
cool.
Regards,
Atish
Quoted 220 lines · Anup Patel
Quoted 214 lines
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 Anup Patel <[email protected]>Signed-off-by Atish Patra <[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(+)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.harch/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-fu540.h new file +43
-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" \ + "pxefile_addr_r=0x82400000\0" \ + "ramdisk_addr_r=0x82500000\0" \ + BOOTENV + +#endif /* __CONFIG_H */ Signature · 6 lines
2.17.1 _______________________________________________ U-Boot mailing list U-Boot at lists.denx.de https://lists.denx.de/listinfo/u-boot_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH 11/11 riscv: Add SiFive FU540 board support
In reply to Anup PatelQuoted 8 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 Anup Patel <[email protected]>Signed-off-by Atish Patra <[email protected]>
Alex
cover SiFive FU540 Support
In reply to Anup PatelQuoted 10 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.
Great job, looks very clean to me!
Slight nitpick on the SoB lines though. Usually your SoB should always come at the end if it went through your fingers last.
I saw a few patches where Atish was either the sole person in SoB or is listed after you in the SoB order. This is slightly incorrect, as you as the sender of the patch set should always occur at the end of the SoB list.
Thanks a lot for cooking up this patch set, I'm looking very much forward to a world where running new kernels is easy on RISC-V :).
Alex
cover SiFive FU540 Support
Quoted 26 lines
-----Original Message-----
From: Alexander Graf [mailto:agraf at suse.de]
Sent: Friday, January 18, 2019 4:39 AM
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 00/11] SiFive FU540 SupportQuoted 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 5 lines
Quoted 3 lines
All drivers namely: SiFive PRCI, SiFive Serial, and Cadance MACB Ethernet work fine on actual SiFive Unleashed board and QEMU
sifive_umachine.Great job, looks very clean to me!
Thanks.
Quoted 7 lines
Slight nitpick on the SoB lines though. Usually your SoB should always come at the end if it went through your fingers last.
I saw a few patches where Atish was either the sole person in SoB or is listed after you in the SoB order. This is slightly incorrect, as you as the sender of the patch set should always occur at the end of the SoB list.
Sure, I will fix ordering of SoB
Quoted 3 lines
Thanks a lot for cooking up this patch set, I'm looking very much forward to a world where running new kernels is easy on RISC-V :).
Regards,
Anup