Skip to contentSkip to conversation

SiFive FU540 Support

PATCH Superseded Anup Patel 6 participants 22 messages Feb 20, 2019 – Feb 22, 2019

Subsystems (5)

v8 of 10 Superseded Latest is v10 →

lore
Share & tools
lore

Anup Patel

author
#0 lore raw

v8 cover SiFive FU540 Support

This patchset adds SiFive Freedom Unleashed (FU540) support to RISC-V U-Boot.

The patches are based upon latest U-Boot source tree
(git://git.denx.de/u-boot.git) at v2019.04-rc2 commit id f14de0014c56093feecf42ca38b8ae5b3878f176

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 v7:
- Rebased patches to latest U-Boot source tree
- Rename "ret" to "rate" in clk_fixed_factor_get_rate() of PATCH9

Changes since v6:
- Rebased patches to latest U-Boot source tree
- Droped PATCH1 and PATCH2. Instead added a PATCH to select CREATE_ARCH_SYMLINK for RISC-V
- Few typo fixes in SiFive FU540 readme

Changes since v5:
- Added PATCH16 to fix INITRD passing to Linux using bootm for U-Boot RISC-V

Changes since v4:
- Removed #ifndef from macb_enable_clk() in PATCH7
- Updated test/dm/clk.c in PATCH10 to test fixed factor clock using sandbox

Changes since v3:
- Added patch to un-ignore arch/riscv/include/asm/arch
- Added patch to fix mrproper make target to only remove arch/*/include/asm/arch paths which are symlinks
- Added patch to have place-holder asm/arch/clk.h for RISC-V
- Removed "#ifndef CONFIG_RISCV" from macb clk API patch

Changes since v2:
- Fixed typo in PATCH3 comments
- Removed "#if" from clk_fixed_factor_ofdata_to_platdata() in PATCH7
- Added PATCH12 for SiFive FU540 README guide

Changes since v1:
- Re-ordered SoB in patches with multiple SoB
- Simplified board_get_usable_ram_top() added by PATCH3

Anup Patel (10):
riscv: Enable create symlink using kconfig
riscv: Rename cpu/qemu to cpu/generic
riscv: Add asm/dma-mapping.h for DMA mappings
riscv: Add place-holder asm/arch/clk.h for driver compilation
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
riscv: Enable CONFIG_SYS_BOOT_RAMDISK_HIGH for using initrd

Atish Patra (5):
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
doc: Add a readme guide for SiFive FU540

 arch/Kconfig                                  |   1 +
 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/arch-generic/clk.h     |  14 +
 arch/riscv/include/asm/config.h               |   1 +
 arch/riscv/include/asm/dma-mapping.h          |  38 ++
 arch/sandbox/dts/test.dts                     |   8 +
 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 +
 doc/README.sifive-fu540                       | 303 +++++++++
 drivers/clk/Kconfig                           |   1 +
 drivers/clk/Makefile                          |   5 +-
 drivers/clk/clk_fixed_factor.c                |  72 +++
 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                            |  11 +-
 drivers/serial/serial_sifive.c                |  60 +-
 include/configs/sifive-fu540.h                |  43 ++
 include/dt-bindings/clk/sifive-fu540-prci.h   |  29 +
 test/dm/clk.c                                 |   5 +-
 32 files changed, 1795 insertions(+), 66 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/arch-generic/clk.h
 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 doc/README.sifive-fu540
 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.h
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v8 1/15 riscv: Enable create symlink using kconfig

We select CREATE_ARCH_SYMLINK for RISC-V so that we can have include/asm/arch linked to include/asm/arch-xyz.

---
 arch/Kconfig | 1 +
 1 file changed, 1 insertion(+)
arch/Kconfig +1 -0
index 35e2712fce..4ebc66227e 100644
@@ -61,6 +61,7 @@ config PPC
 
 config RISCV
 	bool "RISC-V architecture"
+	select CREATE_ARCH_SYMLINK
 	select SUPPORT_OF_CONTROL
 	select OF_CONTROL
 	select DM
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH v8 2/15 riscv: Rename cpu/qemu to cpu/generic

In reply to Anup Patel

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
index c45e4d73a8..6879047ff7 100644
@@ -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
similarity index 91%
rename from arch/riscv/cpu/qemu/Kconfig
rename to arch/riscv/cpu/generic/Kconfig
index f48751e6de..1d6ab5032d 100644
@@ -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
similarity index 100%
rename from arch/riscv/cpu/qemu/Makefile
rename to arch/riscv/cpu/generic/Makefile
arch/riscv/cpu/generic/cpu.c renamed from arch/riscv/cpu/qemu/cpu.c +0 -0
similarity index 100%
rename from arch/riscv/cpu/qemu/cpu.c
rename to arch/riscv/cpu/generic/cpu.c
arch/riscv/cpu/generic/dram.c renamed from arch/riscv/cpu/qemu/dram.c +0 -0
similarity index 100%
rename from arch/riscv/cpu/qemu/dram.c
rename to arch/riscv/cpu/generic/dram.c
board/emulation/qemu-riscv/Kconfig +2 -2
index 0d865acf10..88d07d568e 100644
@@ -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
author
#3 lore raw

PATCH v8 3/15 riscv: Add asm/dma-mapping.h for DMA mappings

In reply to Anup Patel

This 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
new file mode 100644
index 0000000000..3d930c90ec
@@ -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
author
#4 lore raw

PATCH v8 4/15 riscv: Add place-holder asm/arch/clk.h for driver compilation

In reply to Anup Patel

Some of the drivers (such as Cadence MACB ethernet driver) expect asm/arch/clk.h to be provided by arch support so we add place-holder asm/arch-generic/clk.h for RISC-V generic CPU.

---
 arch/riscv/include/asm/arch-generic/clk.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
 create mode 100644 arch/riscv/include/asm/arch-generic/clk.h
arch/riscv/include/asm/arch-generic/clk.h new file +14 -0
new file mode 100644
index 0000000000..1631f5f0bd
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2019 Western Digital Corporation or its affiliates.
+ *
+ * Authors:
+ *   Anup Patel <[email protected]>
+ */
+
+#ifndef __ASM_RISCV_ARCH_CLK_H
+#define __ASM_RISCV_ARCH_CLK_H
+
+/* Note: This is a placeholder header for driver compilation. */
+
+#endif
Signature · 1 line
2.17.1
author
#5 lore raw

PATCH v8 5/15 riscv: generic: Ensure that U-Boot runs within 4GB for 64bit systems

In reply to 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_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
index 84d87d2a7f..b7b1207235 100644
@@ -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 capable
+	 * 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
author
#6 lore raw

PATCH v8 6/15 net: macb: Fix clk API usage for RISC-V systems

In reply to Anup Patel

Don't fail in macb_enable_clk() if clk_enable() returns -ENOSYS because we get -ENOSYS for fixed-rate clocks.

---
 drivers/net/macb.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/macb.c +4 -5
index c9ee22279a..0254e211e6 100644
@@ -1061,14 +1061,13 @@ static int macb_enable_clk(struct udevice *dev)
 		return -EINVAL;
 
 	/*
-	 * Zynq clock driver didn't support for enable or disable
-	 * clock. Hence, clk_enable() didn't apply for Zynq
+	 * If clock driver didn't support enable or disable then
+	 * we get -ENOSYS from clk_enable(). To handle this, we
+	 * don't fail for ret == -ENOSYS.
 	 */
-#ifndef CONFIG_MACB_ZYNQ
 	ret = clk_enable(&clk);
-	if (ret)
+	if (ret && ret != -ENOSYS)
 		return ret;
-#endif
 
 	clk_rate = clk_get_rate(&clk);
 	if (!clk_rate)
Signature · 1 line
2.17.1
author
#7 lore raw

PATCH v8 7/15 net: macb: Fix GEM hardware detection

In reply to 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

---
 drivers/net/macb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/macb.c +1 -1
index 0254e211e6..182331f61d 100644
@@ -143,7 +143,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
author
#8 lore raw

PATCH v8 8/15 clk: Add SiFive FU540 PRCI clock driver

In reply to 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 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
index 51c931b906..ff60fc5c45 100644
@@ -105,6 +105,7 @@ source "drivers/clk/mvebu/Kconfig"
 source "drivers/clk/owl/Kconfig"
 source "drivers/clk/renesas/Kconfig"
 source "drivers/clk/sunxi/Kconfig"
+source "drivers/clk/sifive/Kconfig"
 source "drivers/clk/tegra/Kconfig"
 source "drivers/clk/uniphier/Kconfig"
 
drivers/clk/Makefile +1 -0
index 6a4ff9143b..de3d60ed05 100644
@@ -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_ARCH_SUNXI) += sunxi/
 obj-$(CONFIG_CLK_STM32F) += clk_stm32f.o
 obj-$(CONFIG_CLK_STM32MP1) += clk_stm32mp1.o
drivers/clk/sifive/Kconfig new file +19 -0
new file mode 100644
index 0000000000..81fc9f8fda
@@ -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
new file mode 100644
index 0000000000..1155e07e37
@@ -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
new file mode 100644
index 0000000000..531523ea62
@@ -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
author
#9 lore raw

PATCH v8 9/15 clk: Add fixed-factor clock driver

In reply to 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.

---
 arch/sandbox/dts/test.dts      |  8 ++++
 drivers/clk/Makefile           |  4 +-
 drivers/clk/clk_fixed_factor.c | 72 ++++++++++++++++++++++++++++++++++
 test/dm/clk.c                  |  5 ++-
 4 files changed, 87 insertions(+), 2 deletions(-)
 create mode 100644 drivers/clk/clk_fixed_factor.c
arch/sandbox/dts/test.dts +8 -0
index 1d011ded7c..cb8d686e46 100644
@@ -203,6 +203,14 @@
 			#clock-cells = <0>;
 			clock-frequency = <1234>;
 		};
+
+		clk_fixed_factor: clk-fixed-factor {
+			compatible = "fixed-factor-clock";
+			#clock-cells = <0>;
+			clock-div = <3>;
+			clock-mult = <2>;
+			clocks = <&clk_fixed>;
+		};
 	};
 
 	clk_sandbox: clk-sbox {
drivers/clk/Makefile +3 -1
index de3d60ed05..1d9d725cae 100644
@@ -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 +72 -0

72 lines not on this page · raw message

test/dm/clk.c +4 -1
index 898c034e27..112d5cbbc9 100644
@@ -12,12 +12,15 @@
 
 static int dm_test_clk(struct unit_test_state *uts)
 {
-	struct udevice *dev_fixed, *dev_clk, *dev_test;
+	struct udevice *dev_fixed, *dev_fixed_factor, *dev_clk, *dev_test;
 	ulong rate;
 
 	ut_assertok(uclass_get_device_by_name(UCLASS_CLK, "clk-fixed",
 					      &dev_fixed));
 
+	ut_assertok(uclass_get_device_by_name(UCLASS_CLK, "clk-fixed-factor",
+					      &dev_fixed_factor));
+
 	ut_assertok(uclass_get_device_by_name(UCLASS_CLK, "clk-sbox",
 					      &dev_clk));
 	ut_asserteq(0, sandbox_clk_query_enable(dev_clk, SANDBOX_CLK_ID_SPI));
Signature · 1 line
2.17.1
#10 lore raw

PATCH v8 9/15 clk: Add fixed-factor clock driver

Hi,

Quoted 7 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
---
 arch/sandbox/dts/test.dts      |  8 ++++
 drivers/clk/Makefile           |  4 +-
 drivers/clk/clk_fixed_factor.c | 72 ++++++++++++++++++++++++++++++++++
 test/dm/clk.c                  |  5 ++-
 4 files changed, 87 insertions(+), 2 deletions(-)
 create mode 100644 drivers/clk/clk_fixed_factor.c

But please add the binding file for this/

Regards,
Simon

#11 lore raw

PATCH v8 9/15 clk: Add fixed-factor clock driver

Quoted 20 lines · Simon Glass

Hi,

Quoted 7 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
---
 arch/sandbox/dts/test.dts      |  8 ++++
 drivers/clk/Makefile           |  4 +-
 drivers/clk/clk_fixed_factor.c | 72 ++++++++++++++++++++++++++++++++++
 test/dm/clk.c                  |  5 ++-
 4 files changed, 87 insertions(+), 2 deletions(-)
 create mode 100644 drivers/clk/clk_fixed_factor.c
Quoted 3 lines

But please add the binding file for this/

Sure, I will add binding file from Linux sources.

Thanks,
Anup

author
#12 lore raw

PATCH v8 10/15 drivers: serial_sifive: Fix baud rate calculation

In reply to Anup Patel

From: 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
index 341728a690..ea4d35d48c 100644
@@ -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), &regs->div);
+	writel((uart_min_clk_divisor(clock, baud)), &regs->div);
 }
 
 static void _sifive_serial_init(struct uart_sifive *regs)
Signature · 1 line
2.17.1
author
#13 lore raw

PATCH v8 11/15 drivers: serial_sifive: Skip baudrate config if no input clock

In reply to 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.

---
 drivers/serial/serial_sifive.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
drivers/serial/serial_sifive.c +16 -16
index ea4d35d48c..537bc7a975 100644
@@ -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
author
#14 lore raw

PATCH v8 12/15 cpu: Bind timer driver for boot hart

In reply to 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.

---
 drivers/cpu/riscv_cpu.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/cpu/riscv_cpu.c +4 -3
index 5e15df590e..f77c126499 100644
@@ -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
author
#15 lore raw

PATCH v8 13/15 riscv: Add SiFive FU540 board support

In reply to 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.

---
 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
index 6879047ff7..36512a8995 100644
@@ -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
new file mode 100644
index 0000000000..702d803ad8
@@ -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
new file mode 100644
index 0000000000..6e1862c475
@@ -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
new file mode 100644
index 0000000000..5adc4a3d4a
@@ -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
new file mode 100644
index 0000000000..2f8cca9de0
@@ -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
author
#16 lore raw

PATCH v8 14/15 doc: Add a readme guide for SiFive FU540

In reply to Anup Patel

From: Atish Patra <[email protected]>

The readme guide describes the procedure to build, flash and boot Linux using U-Boot on HiFive Unleashed. It also explains the current state of U-boot support and future action items.

---
 doc/README.sifive-fu540 | 303 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 303 insertions(+)
 create mode 100644 doc/README.sifive-fu540
doc/README.sifive-fu540 new file +303 -0
new file mode 100644
index 0000000000..fd9f2a8e46
@@ -0,0 +1,303 @@
+FU540-C000 RISC-V SoC
+=====================
+The FU540-C000 is the world’s first 4+1 64-bit RISC‑V SoC from SiFive.
+
+The HiFive Unleashed development platform is based on FU540-C000 and capable
+of running Linux.
+
+Mainline support
+================
+The support for following drivers are already enabled:
+1. SiFive UART Driver.
+2. SiFive PRCI Driver for clock.
+3. Cadence MACB ethernet driver for networking support.
+
+TODO:
+1. SPI driver is still missing. So MMC card can't be used in U-Boot as of now.
+2. U-Boot expects the serial console device entry to be present under /chosen
+   DT node. Example:
+   chosen {
+        stdout-path = "/soc/serial at 10010000:115200";
+   };
+
+   Without a serial console U-Boot will panic.
+
+Building
+========
+1. Add the RISC-V toolchain to your PATH.
+2. Setup ARCH & cross compilation enviornment variable.
+   a. export ARCH=riscv
+   b. export CROSS_COMPILE=<riscv64 toolchain prefix>
+3. make sifive_fu540_defconfig
+4. make
+
+Flashing
+========
+The current U-Boot port is supported in S-mode only and loaded from DRAM.
+
+A prior stage (M-mode) firmware/bootloader (e.g OpenSBI or BBL) is required to
+load the u-boot.bin into memory and provide runtime services. The u-boot.bin
+can be given as a payload to the prior stage (M-mode) firmware/bootloader.
+
+The description of steps required to build the firmware is beyond the scope of
+this document. Please refer OpenSBI or BBL documenation.
+(Note: OpenSBI git repo is at https://github.com/riscv/opensbi.git)
+(Note: BBL git repo is at https://github.com/riscv/riscv-pk.git)
+
+Once the prior stage firmware/bootloader binary is generated, it should be
+copied to the first partition of the sdcard.
+
+sudo dd if=<prior_stage_firmware_binary> of=/dev/disk2s1 bs=1024
+
+Booting
+=======
+Once you plugin the sdcard and power up, you should see the U-Boot prompt.
+
+Sample boot log from HiFive Unleashed board
+===========================================
+U-Boot 2019.01-00019-gc7953536-dirty (Jan 22 2019 - 11:05:40 -0800)
+
+CPU:   rv64imafdc
+Model: sifive,hifive-unleashed-a00
+DRAM:  8 GiB
+In:    serial at 10010000
+Out:   serial at 10010000
+Err:   serial at 10010000
+Net:
+Warning: ethernet at 10090000 (eth0) using random MAC address - b6:75:4d:48:50:94
+eth0: ethernet at 10090000
+Hit any key to stop autoboot:  0
+=> version
+U-Boot 2019.01-00019-gc7953536-dirty (Jan 22 2019 - 11:05:40 -0800)
+
+riscv64-linux-gcc.br_real (Buildroot 2018.11-rc2-00003-ga0787e9) 8.2.0
+GNU ld (GNU Binutils) 2.31.1
+=>
+===============================================================================
+
+Now you can configure your networking, tftp server and use tftp boot method to
+load uImage.
+
+==========================================================================
+=> setenv ethaddr 70:B3:D5:92:F0:C2
+=> setenv ipaddr 10.196.157.189
+=> setenv serverip 10.11.143.218
+=> setenv gatewayip 10.196.156.1
+=> setenv netmask 255.255.252.0
+=> bdinfo
+boot_params = 0x0000000000000000
+DRAM bank   = 0x0000000000000000
+-> start    = 0x0000000080000000
+-> size     = 0x0000000200000000
+relocaddr   = 0x00000000fff90000
+reloc off   = 0x000000007fd90000
+ethaddr     = 70:B3:D5:92:F0:C2
+IP addr     = 10.196.157.189
+baudrate    = 115200 bps
+=> tftpboot uImage
+ethernet at 10090000: PHY present at 0
+ethernet at 10090000: Starting autonegotiation...
+ethernet at 10090000: Autonegotiation complete
+ethernet at 10090000: link up, 1000Mbps full-duplex (lpa: 0x3800)
+Using ethernet at 10090000 device
+TFTP from server 10.11.143.218; our IP address is 10.196.157.189; sending through gateway 10.196.156.1
+Filename 'uImage'.
+Load address: 0x80200000
+Loading: #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         #################################################################
+         ##########################################################
+         2.5 MiB/s
+done
+Bytes transferred = 14939132 (e3f3fc hex)
+=> bootm 0x80200000 - 0x82200000
+## Booting kernel from Legacy Image at 80200000 ...
+   Image Name:   Linux
+   Image Type:   RISC-V Linux Kernel Image (uncompressed)
+   Data Size:    14939068 Bytes = 14.2 MiB
+   Load Address: 80200000
+   Entry Point:  80200000
+   Verifying Checksum ... OK
+## Flattened Device Tree blob at 82200000
+   Booting using the fdt blob at 0x82200000
+   Loading Kernel Image ... OK
+   Using Device Tree in place at 0000000082200000, end 0000000082205c69
+
+Starting kernel ...
+
+[    0.000000] OF: fdt: Ignoring memory range 0x80000000 - 0x80200000
+[    0.000000] Linux version 5.0.0-rc1-00020-g4b51f736 (atish at jedi-01) (gcc version 7.2.0 (GCC)) #262 SMP Mon Jan 21 17:39:27 PST 2019
+[    0.000000] initrd not found or empty - disabling initrd
+[    0.000000] Zone ranges:
+[    0.000000]   DMA32    [mem 0x0000000080200000-0x00000000ffffffff]
+[    0.000000]   Normal   [mem 0x0000000100000000-0x000027ffffffffff]
+[    0.000000] Movable zone start for each node
+[    0.000000] Early memory node ranges
+[    0.000000]   node   0: [mem 0x0000000080200000-0x000000027fffffff]
+[    0.000000] Initmem setup node 0 [mem 0x0000000080200000-0x000000027fffffff]
+[    0.000000] software IO TLB: mapped [mem 0xfbfff000-0xfffff000] (64MB)
+[    0.000000] CPU with hartid=0 has a non-okay status of "masked"
+[    0.000000] CPU with hartid=0 has a non-okay status of "masked"
+[    0.000000] elf_hwcap is 0x112d
+[    0.000000] percpu: Embedded 15 pages/cpu @(____ptrval____) s29720 r0 d31720 u61440
+[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 2067975
+[    0.000000] Kernel command line: earlyprintk
+[    0.000000] Dentry cache hash table entries: 1048576 (order: 11, 8388608 bytes)
+[    0.000000] Inode-cache hash table entries: 524288 (order: 10, 4194304 bytes)
+[    0.000000] Sorting __ex_table...
+[    0.000000] Memory: 8178760K/8386560K available (3309K kernel code, 248K rwdata, 872K rodata, 9381K init, 763K bss, 207800K reserved, 0K cma-reserved)
+[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
+[    0.000000] rcu: Hierarchical RCU implementation.
+[    0.000000] rcu:     RCU event tracing is enabled.
+[    0.000000] rcu:     RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
+[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
+[    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=4
+[    0.000000] NR_IRQS: 0, nr_irqs: 0, preallocated irqs: 0
+[    0.000000] plic: mapped 53 interrupts to 4 (out of 9) handlers.
+[    0.000000] riscv_timer_init_dt: Registering clocksource cpuid [0] hartid [1]
+[    0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x1d854df40, max_idle_ns: 3526361616960 ns
+[    0.000008] sched_clock: 64 bits at 1000kHz, resolution 1000ns, wraps every 2199023255500ns
+[    0.000221] Console: colour dummy device 80x25
+[    0.000902] printk: console [tty0] enabled
+[    0.000963] Calibrating delay loop (skipped), value calculated using timer frequency.. 2.00 BogoMIPS (lpj=10000)
+[    0.001034] pid_max: default: 32768 minimum: 301
+[    0.001541] Mount-cache hash table entries: 16384 (order: 5, 131072 bytes)
+[    0.001912] Mountpoint-cache hash table entries: 16384 (order: 5, 131072 bytes)
+[    0.003542] rcu: Hierarchical SRCU implementation.
+[    0.004347] smp: Bringing up secondary CPUs ...
+[    1.040259] CPU1: failed to come online
+[    2.080483] CPU2: failed to come online
+[    3.120699] CPU3: failed to come online
+[    3.120765] smp: Brought up 1 node, 1 CPU
+[    3.121923] devtmpfs: initialized
+[    3.124649] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
+[    3.124727] futex hash table entries: 1024 (order: 4, 65536 bytes)
+[    3.125346] random: get_random_u32 called from bucket_table_alloc+0x72/0x172 with crng_init=0
+[    3.125578] NET: Registered protocol family 16
+[    3.126400] sifive-u54-prci 10000000.prci: Registered U54 core clocks
+[    3.126649] sifive-gemgxl-mgmt 100a0000.cadence-gemgxl-mgmt: Registered clock switch 'cadence-gemgxl-mgmt'
+[    3.135572] vgaarb: loaded
+[    3.135858] SCSI subsystem initialized
+[    3.136193] usbcore: registered new interface driver usbfs
+[    3.136266] usbcore: registered new interface driver hub
+[    3.136348] usbcore: registered new device driver usb
+[    3.136446] pps_core: LinuxPPS API ver. 1 registered
+[    3.136484] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <[email protected]>
+[    3.136575] PTP clock support registered
+[    3.137256] clocksource: Switched to clocksource riscv_clocksource
+[    3.142711] NET: Registered protocol family 2
+[    3.143322] tcp_listen_portaddr_hash hash table entries: 4096 (order: 4, 65536 bytes)
+[    3.143634] TCP established hash table entries: 65536 (order: 7, 524288 bytes)
+[    3.145799] TCP bind hash table entries: 65536 (order: 8, 1048576 bytes)
+[    3.149121] TCP: Hash tables configured (established 65536 bind 65536)
+[    3.149591] UDP hash table entries: 4096 (order: 5, 131072 bytes)
+[    3.150094] UDP-Lite hash table entries: 4096 (order: 5, 131072 bytes)
+[    3.150781] NET: Registered protocol family 1
+[    3.230693] workingset: timestamp_bits=62 max_order=21 bucket_order=0
+[    3.241224] io scheduler mq-deadline registered
+[    3.241269] io scheduler kyber registered
+[    3.242143] sifive_gpio 10060000.gpio: SiFive GPIO chip registered 16 GPIOs
+[    3.242357] pwm-sifivem 10020000.pwm: Unable to find controller clock
+[    3.242439] pwm-sifivem 10021000.pwm: Unable to find controller clock
+[    3.243228] xilinx-pcie 2000000000.pci: PCIe Link is DOWN
+[    3.243289] xilinx-pcie 2000000000.pci: host bridge /soc/pci at 2000000000 ranges:
+[    3.243360] xilinx-pcie 2000000000.pci:   No bus range found for /soc/pci at 2000000000, using [bus 00-ff]
+[    3.243447] xilinx-pcie 2000000000.pci:   MEM 0x40000000..0x5fffffff -> 0x40000000
+[    3.243591] xilinx-pcie 2000000000.pci: PCI host bridge to bus 0000:00
+[    3.243636] pci_bus 0000:00: root bus resource [bus 00-ff]
+[    3.243676] pci_bus 0000:00: root bus resource [mem 0x40000000-0x5fffffff]
+[    3.276547] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
+[    3.277689] 10010000.serial: ttySIF0 at MMIO 0x10010000 (irq = 39, base_baud = 0) is a SiFive UART v0
+[    3.786963] printk: console [ttySIF0] enabled
+[    3.791504] 10011000.serial: ttySIF1 at MMIO 0x10011000 (irq = 40, base_baud = 0) is a SiFive UART v0
+[    3.801251] sifive_spi 10040000.spi: mapped; irq=41, cs=1
+[    3.806362] m25p80 spi0.0: unrecognized JEDEC id bytes: 9d, 70, 19
+[    3.812084] m25p80: probe of spi0.0 failed with error -2
+[    3.817453] sifive_spi 10041000.spi: mapped; irq=42, cs=4
+[    3.823027] sifive_spi 10050000.spi: mapped; irq=43, cs=1
+[    3.828604] libphy: Fixed MDIO Bus: probed
+[    3.832623] macb: GEM doesn't support hardware ptp.
+[    3.837196] libphy: MACB_mii_bus: probed
+[    4.041156] Microsemi VSC8541 SyncE 10090000.ethernet-ffffffff:00: attached PHY driver [Microsemi VSC8541 SyncE] (mii_bus:phy_addr=10090000.ethernet-ffffffff:00, irq=POLL)
+[    4.055779] macb 10090000.ethernet eth0: Cadence GEM rev 0x10070109 at 0x10090000 irq 12 (70:b3:d5:92:f0:c2)
+[    4.065780] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
+[    4.072033] ehci-pci: EHCI PCI platform driver
+[    4.076521] usbcore: registered new interface driver usb-storage
+[    4.082843] softdog: initialized. soft_noboot=0 soft_margin=60 sec soft_panic=0 (nowayout=0)
+[    4.127465] mmc_spi spi2.0: SD/MMC host mmc0, no DMA, no WP, no poweroff
+[    4.133645] usbcore: registered new interface driver usbhid
+[    4.138980] usbhid: USB HID core driver
+[    4.143017] NET: Registered protocol family 17
+[    4.147885] pwm-sifivem 10020000.pwm: SiFive PWM chip registered 4 PWMs
+[    4.153945] pwm-sifivem 10021000.pwm: SiFive PWM chip registered 4 PWMs
+[    4.186407] Freeing unused kernel memory: 9380K
+[    4.190224] This architecture does not have kernel memory protection.
+[    4.196609] Run /init as init process
+Starting logging: OK
+Starting mdev...
+[    4.303785] mmc0: host does not support reading read-only switch, assuming write-enable
+[    4.311109] mmc0: new SDHC card on SPI
+[    4.317103] mmcblk0: mmc0:0000 SS08G 7.40 GiB
+[    4.386471]  mmcblk0: p1 p2
+sort: /sys/devices/platform/Fixed: No such file or directory
+modprobe: can't change directory to '/lib/modules': No such file or directory
+Initializing random[    4.759075] random: dd: uninitialized urandom read (512 bytes read)
+ number generator... done.
+Starting network...
+udhcpc (v1.24.2) started
+Sending discover...
+Sending discover...
+[    7.927510] macb 10090000.ethernet eth0: link up (1000/Full)
+Sending discover...
+Sending select for 10.196.157.190...
+Lease of 10.196.157.190 obtained, lease time 499743
+deleting routers
+adding dns 10.86.1.1
+adding dns 10.86.2.1
+/etc/init.d/S50dropbear
+Starting dropbear sshd: [   12.772393] random: dropbear: uninitialized urandom read (32 bytes read)
+OK
+
+Welcome to Buildroot
+buildroot login:
Signature · 1 line
2.17.1
author
#17 lore raw

PATCH v8 15/15 riscv: Enable CONFIG_SYS_BOOT_RAMDISK_HIGH for using initrd

In reply to Anup Patel

This patch enables CONFIG_SYS_BOOT_RAMDISK_HIGH for RISC-V because bootm will update initrd location in DTB only if CONFIG_SYS_BOOT_RAMDISK_HIGH is enabled. If we don't enable this option then bootm assumes DTB already has initrd details which is not the case most of the time.

---
 arch/riscv/include/asm/config.h | 1 +
 1 file changed, 1 insertion(+)
arch/riscv/include/asm/config.h +1 -0
index 81bc975d2e..156cb94dc0 100644
@@ -8,5 +8,6 @@
 #define _ASM_CONFIG_H_
 
 #define CONFIG_LMB
+#define CONFIG_SYS_BOOT_RAMDISK_HIGH
 
 #endif
Signature · 1 line
2.17.1
#18 lore raw

v8 cover SiFive FU540 Support

In reply to Anup Patel
Quoted 10 lines · Anup Patel

This patchset adds SiFive Freedom Unleashed (FU540) support to RISC-V U-Boot.

The patches are based upon latest U-Boot source tree
(git://git.denx.de/u-boot.git) at v2019.04-rc2 commit id f14de0014c56093feecf42ca38b8ae5b3878f176

All drivers namely: SiFive PRCI, SiFive Serial, and Cadance MACB Ethernet work fine on actual SiFive Unleashed board and QEMU sifive_u machine.

Is the sifive_u QEMU machine in upstream QEMU? If so, lets add it to the travis file and run tests. Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190221/5285a11f/attachment.sig>
#19 lore raw

v8 cover SiFive FU540 Support

Quoted 9 lines · trini at konsulko.com
Quoted 7 lines · Anup Patel

This patchset adds SiFive Freedom Unleashed (FU540) support to RISC-V U-Boot.

The patches are based upon latest U-Boot source tree
(git://git.denx.de/u-boot.git) at v2019.04-rc2 commit id f14de0014c56093feecf42ca38b8ae5b3878f176

Quoted 6 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_u machine.

Is the sifive_u QEMU machine in upstream QEMU? If so, lets add it to the travis file and run tests. Thanks!

It's been upstream for a while, though we might deprecate it in the future because the name is a bit ambiguous. There's nothing better right now, so it's probably a good bet to test against.

#20 lore raw

v8 cover SiFive FU540 Support

Quoted 14 lines · Palmer Dabbelt
Quoted 13 lines · trini at konsulko.com
Quoted 10 lines · Anup Patel

This patchset adds SiFive Freedom Unleashed (FU540) support to RISC-V U-Boot.

The patches are based upon latest U-Boot source tree
(git://git.denx.de/u-boot.git) at v2019.04-rc2 commit id f14de0014c56093feecf42ca38b8ae5b3878f176

All drivers namely: SiFive PRCI, SiFive Serial, and Cadance MACB Ethernet work fine on actual SiFive Unleashed board and QEMU sifive_u machine.

Quoted 6 lines
Quoted 2 lines

Is the sifive_u QEMU machine in upstream QEMU? If so, lets add it to the travis file and run tests. Thanks!

It's been upstream for a while, though we might deprecate it in the future because the name is a bit ambiguous. There's nothing better right now, so it's probably a good bet to test against.

Great! Then we should model something based on

    - name: "test/py qemu-x86"
      env:
        - TEST_PY_BD="qemu-x86"
          TEST_PY_TEST_SPEC="not sleep"
          QEMU_TARGET="i386-softmmu"
          BUILDMAN="^qemu-x86$"
          TOOLCHAIN="i386"
          BUILD_ROM="yes"

And an appropriate PR to https://github.com/swarren/uboot-test-hooks so that we can run the testsuite every time.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190221/70c401b1/attachment.sig>
#21 lore raw

v8 cover SiFive FU540 Support

Quoted 33 lines · Tom Rini
Quoted 14 lines · Palmer Dabbelt
Quoted 13 lines · trini at konsulko.com
Quoted 10 lines · Anup Patel

This patchset adds SiFive Freedom Unleashed (FU540) support to RISC-V U-Boot.

The patches are based upon latest U-Boot source tree
(git://git.denx.de/u-boot.git) at v2019.04-rc2 commit id f14de0014c56093feecf42ca38b8ae5b3878f176

All drivers namely: SiFive PRCI, SiFive Serial, and Cadance MACB Ethernet work fine on actual SiFive Unleashed board and QEMU sifive_u machine.

Quoted 6 lines
Quoted 2 lines

Is the sifive_u QEMU machine in upstream QEMU? If so, lets add it to the travis file and run tests. Thanks!

It's been upstream for a while, though we might deprecate it in the future because the name is a bit ambiguous. There's nothing better right now, so it's probably a good bet to test against.

Great! Then we should model something based on

    - name: "test/py qemu-x86"
      env:
        - TEST_PY_BD="qemu-x86"
          TEST_PY_TEST_SPEC="not sleep"
          QEMU_TARGET="i386-softmmu"
          BUILDMAN="^qemu-x86$"
          TOOLCHAIN="i386"
          BUILD_ROM="yes"
Quoted 3 lines

And an appropriate PR to https://github.com/swarren/uboot-test-hooks so that we can run the testsuite every time.

Yes, this has been on my todo list for a while when qemu-riscv was initially supported.

Regards,
Bin