- Fixes 7e249bc13a: ("riscv: Move all SMP related SBI calls to
SBI_v01") Move sbi_probe_extension() out of CONFIG_SBI_V01.
- SiFive FU540 support SPL.
This commit is contained in:
@@ -56,6 +56,7 @@ source "board/sifive/fu540/Kconfig"
|
||||
|
||||
# platform-specific options below
|
||||
source "arch/riscv/cpu/ax25/Kconfig"
|
||||
source "arch/riscv/cpu/fu540/Kconfig"
|
||||
source "arch/riscv/cpu/generic/Kconfig"
|
||||
|
||||
# architecture-specific options below
|
||||
|
||||
15
arch/riscv/cpu/fu540/Kconfig
Normal file
15
arch/riscv/cpu/fu540/Kconfig
Normal file
@@ -0,0 +1,15 @@
|
||||
# SPDX-License-Identifier: GPL-2.0+
|
||||
#
|
||||
# Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
|
||||
|
||||
config SIFIVE_FU540
|
||||
bool
|
||||
select ARCH_EARLY_INIT_R
|
||||
imply CPU
|
||||
imply CPU_RISCV
|
||||
imply RISCV_TIMER
|
||||
imply SIFIVE_CLINT if (RISCV_MMODE || SPL_RISCV_MMODE)
|
||||
imply CMD_CPU
|
||||
imply SPL_CPU_SUPPORT
|
||||
imply SPL_OPENSBI
|
||||
imply SPL_LOAD_FIT
|
||||
11
arch/riscv/cpu/fu540/Makefile
Normal file
11
arch/riscv/cpu/fu540/Makefile
Normal file
@@ -0,0 +1,11 @@
|
||||
# SPDX-License-Identifier: GPL-2.0+
|
||||
#
|
||||
# Copyright (C) 2020 SiFive, Inc
|
||||
# Pragnesh Patel <pragnesh.patel@sifive.com>
|
||||
|
||||
ifeq ($(CONFIG_SPL_BUILD),y)
|
||||
obj-y += spl.o
|
||||
else
|
||||
obj-y += dram.o
|
||||
obj-y += cpu.o
|
||||
endif
|
||||
22
arch/riscv/cpu/fu540/cpu.c
Normal file
22
arch/riscv/cpu/fu540/cpu.c
Normal file
@@ -0,0 +1,22 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
|
||||
*/
|
||||
|
||||
#include <irq_func.h>
|
||||
#include <asm/cache.h>
|
||||
|
||||
/*
|
||||
* cleanup_before_linux() is called just before we call linux
|
||||
* it prepares the processor for linux
|
||||
*
|
||||
* we disable interrupt and caches.
|
||||
*/
|
||||
int cleanup_before_linux(void)
|
||||
{
|
||||
disable_interrupts();
|
||||
|
||||
cache_flush();
|
||||
|
||||
return 0;
|
||||
}
|
||||
38
arch/riscv/cpu/fu540/dram.c
Normal file
38
arch/riscv/cpu/fu540/dram.c
Normal file
@@ -0,0 +1,38 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <fdtdec.h>
|
||||
#include <init.h>
|
||||
#include <linux/sizes.h>
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
int dram_init(void)
|
||||
{
|
||||
return fdtdec_setup_mem_size_base();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
23
arch/riscv/cpu/fu540/spl.c
Normal file
23
arch/riscv/cpu/fu540/spl.c
Normal file
@@ -0,0 +1,23 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Copyright (C) 2020 SiFive, Inc
|
||||
* Pragnesh Patel <pragnesh.patel@sifive.com>
|
||||
*/
|
||||
|
||||
#include <dm.h>
|
||||
#include <log.h>
|
||||
|
||||
int soc_spl_init(void)
|
||||
{
|
||||
int ret;
|
||||
struct udevice *dev;
|
||||
|
||||
/* DDR init */
|
||||
ret = uclass_get_device(UCLASS_RAM, 0, &dev);
|
||||
if (ret) {
|
||||
debug("DRAM init failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -72,6 +72,7 @@ SECTIONS
|
||||
. = ALIGN(4);
|
||||
|
||||
_end = .;
|
||||
_image_binary_end = .;
|
||||
|
||||
.bss : {
|
||||
__bss_start = .;
|
||||
|
||||
89
arch/riscv/dts/fu540-c000-u-boot.dtsi
Normal file
89
arch/riscv/dts/fu540-c000-u-boot.dtsi
Normal file
@@ -0,0 +1,89 @@
|
||||
// SPDX-License-Identifier: (GPL-2.0 OR MIT)
|
||||
/*
|
||||
* (C) Copyright 2019 SiFive, Inc
|
||||
*/
|
||||
|
||||
/ {
|
||||
cpus {
|
||||
assigned-clocks = <&prci PRCI_CLK_COREPLL>;
|
||||
assigned-clock-rates = <1000000000>;
|
||||
u-boot,dm-spl;
|
||||
cpu0: cpu@0 {
|
||||
clocks = <&prci PRCI_CLK_COREPLL>;
|
||||
u-boot,dm-spl;
|
||||
status = "okay";
|
||||
cpu0_intc: interrupt-controller {
|
||||
u-boot,dm-spl;
|
||||
};
|
||||
};
|
||||
cpu1: cpu@1 {
|
||||
clocks = <&prci PRCI_CLK_COREPLL>;
|
||||
u-boot,dm-spl;
|
||||
cpu1_intc: interrupt-controller {
|
||||
u-boot,dm-spl;
|
||||
};
|
||||
};
|
||||
cpu2: cpu@2 {
|
||||
clocks = <&prci PRCI_CLK_COREPLL>;
|
||||
u-boot,dm-spl;
|
||||
cpu2_intc: interrupt-controller {
|
||||
u-boot,dm-spl;
|
||||
};
|
||||
};
|
||||
cpu3: cpu@3 {
|
||||
clocks = <&prci PRCI_CLK_COREPLL>;
|
||||
u-boot,dm-spl;
|
||||
cpu3_intc: interrupt-controller {
|
||||
u-boot,dm-spl;
|
||||
};
|
||||
};
|
||||
cpu4: cpu@4 {
|
||||
clocks = <&prci PRCI_CLK_COREPLL>;
|
||||
u-boot,dm-spl;
|
||||
cpu4_intc: interrupt-controller {
|
||||
u-boot,dm-spl;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
soc {
|
||||
u-boot,dm-spl;
|
||||
otp: otp@10070000 {
|
||||
compatible = "sifive,fu540-c000-otp";
|
||||
reg = <0x0 0x10070000 0x0 0x0FFF>;
|
||||
fuse-count = <0x1000>;
|
||||
};
|
||||
clint@2000000 {
|
||||
compatible = "riscv,clint0";
|
||||
interrupts-extended = <&cpu0_intc 3 &cpu0_intc 7 &cpu1_intc 3 &cpu1_intc 7 &cpu2_intc 3 &cpu2_intc 7 &cpu3_intc 3 &cpu3_intc 7 &cpu4_intc 3 &cpu4_intc 7>;
|
||||
reg = <0x0 0x2000000 0x0 0xc0000>;
|
||||
u-boot,dm-spl;
|
||||
};
|
||||
dmc: dmc@100b0000 {
|
||||
compatible = "sifive,fu540-c000-ddr";
|
||||
reg = <0x0 0x100b0000 0x0 0x0800
|
||||
0x0 0x100b2000 0x0 0x2000
|
||||
0x0 0x100b8000 0x0 0x0fff>;
|
||||
clocks = <&prci PRCI_CLK_DDRPLL>;
|
||||
clock-frequency = <933333324>;
|
||||
u-boot,dm-spl;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&prci {
|
||||
u-boot,dm-spl;
|
||||
};
|
||||
|
||||
&uart0 {
|
||||
u-boot,dm-spl;
|
||||
};
|
||||
|
||||
&qspi2 {
|
||||
u-boot,dm-spl;
|
||||
};
|
||||
|
||||
ð0 {
|
||||
assigned-clocks = <&prci PRCI_CLK_GEMGXLPLL>;
|
||||
assigned-clock-rates = <125000000>;
|
||||
};
|
||||
@@ -54,6 +54,7 @@
|
||||
reg = <1>;
|
||||
riscv,isa = "rv64imafdc";
|
||||
tlb-split;
|
||||
next-level-cache = <&l2cache>;
|
||||
cpu1_intc: interrupt-controller {
|
||||
#interrupt-cells = <1>;
|
||||
compatible = "riscv,cpu-intc";
|
||||
@@ -77,6 +78,7 @@
|
||||
reg = <2>;
|
||||
riscv,isa = "rv64imafdc";
|
||||
tlb-split;
|
||||
next-level-cache = <&l2cache>;
|
||||
cpu2_intc: interrupt-controller {
|
||||
#interrupt-cells = <1>;
|
||||
compatible = "riscv,cpu-intc";
|
||||
@@ -100,6 +102,7 @@
|
||||
reg = <3>;
|
||||
riscv,isa = "rv64imafdc";
|
||||
tlb-split;
|
||||
next-level-cache = <&l2cache>;
|
||||
cpu3_intc: interrupt-controller {
|
||||
#interrupt-cells = <1>;
|
||||
compatible = "riscv,cpu-intc";
|
||||
@@ -123,6 +126,7 @@
|
||||
reg = <4>;
|
||||
riscv,isa = "rv64imafdc";
|
||||
tlb-split;
|
||||
next-level-cache = <&l2cache>;
|
||||
cpu4_intc: interrupt-controller {
|
||||
#interrupt-cells = <1>;
|
||||
compatible = "riscv,cpu-intc";
|
||||
@@ -162,6 +166,13 @@
|
||||
clocks = <&prci PRCI_CLK_TLCLK>;
|
||||
status = "disabled";
|
||||
};
|
||||
dma: dma@3000000 {
|
||||
compatible = "sifive,fu540-c000-pdma";
|
||||
reg = <0x0 0x3000000 0x0 0x8000>;
|
||||
interrupt-parent = <&plic0>;
|
||||
interrupts = <23 24 25 26 27 28 29 30>;
|
||||
#dma-cells = <1>;
|
||||
};
|
||||
uart1: serial@10011000 {
|
||||
compatible = "sifive,fu540-c000-uart", "sifive,uart0";
|
||||
reg = <0x0 0x10011000 0x0 0x1000>;
|
||||
@@ -246,6 +257,30 @@
|
||||
#pwm-cells = <3>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
l2cache: cache-controller@2010000 {
|
||||
compatible = "sifive,fu540-c000-ccache", "cache";
|
||||
cache-block-size = <64>;
|
||||
cache-level = <2>;
|
||||
cache-sets = <1024>;
|
||||
cache-size = <2097152>;
|
||||
cache-unified;
|
||||
interrupt-parent = <&plic0>;
|
||||
interrupts = <1 2 3>;
|
||||
reg = <0x0 0x2010000 0x0 0x1000>;
|
||||
};
|
||||
gpio: gpio@10060000 {
|
||||
compatible = "sifive,fu540-c000-gpio", "sifive,gpio0";
|
||||
interrupt-parent = <&plic0>;
|
||||
interrupts = <7>, <8>, <9>, <10>, <11>, <12>, <13>,
|
||||
<14>, <15>, <16>, <17>, <18>, <19>, <20>,
|
||||
<21>, <22>;
|
||||
reg = <0x0 0x10060000 0x0 0x1000>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
interrupt-controller;
|
||||
#interrupt-cells = <2>;
|
||||
clocks = <&prci PRCI_CLK_TLCLK>;
|
||||
status = "disabled";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
1489
arch/riscv/dts/fu540-hifive-unleashed-a00-ddr.dtsi
Normal file
1489
arch/riscv/dts/fu540-hifive-unleashed-a00-ddr.dtsi
Normal file
File diff suppressed because it is too large
Load Diff
@@ -3,9 +3,31 @@
|
||||
* Copyright (C) 2019 Jagan Teki <jagan@amarulasolutions.com>
|
||||
*/
|
||||
|
||||
#include "fu540-c000-u-boot.dtsi"
|
||||
#include "fu540-hifive-unleashed-a00-ddr.dtsi"
|
||||
|
||||
/ {
|
||||
aliases {
|
||||
spi0 = &qspi0;
|
||||
spi2 = &qspi2;
|
||||
};
|
||||
|
||||
hfclk {
|
||||
u-boot,dm-spl;
|
||||
};
|
||||
|
||||
rtcclk {
|
||||
u-boot,dm-spl;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
&qspi2 {
|
||||
mmc@0 {
|
||||
u-boot,dm-spl;
|
||||
};
|
||||
};
|
||||
|
||||
&gpio {
|
||||
u-boot,dm-spl;
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
/* Copyright (c) 2018-2019 SiFive, Inc */
|
||||
|
||||
#include "fu540-c000.dtsi"
|
||||
#include <dt-bindings/gpio/gpio.h>
|
||||
|
||||
/* Clock frequency (in Hz) of the PCB crystal for rtcclk */
|
||||
#define RTCCLK_FREQ 1000000
|
||||
@@ -41,6 +42,10 @@
|
||||
clock-frequency = <RTCCLK_FREQ>;
|
||||
clock-output-names = "rtcclk";
|
||||
};
|
||||
gpio-restart {
|
||||
compatible = "gpio-restart";
|
||||
gpios = <&gpio 10 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
};
|
||||
|
||||
&uart0 {
|
||||
@@ -94,3 +99,7 @@
|
||||
&pwm1 {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&gpio {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
14
arch/riscv/include/asm/arch-fu540/clk.h
Normal file
14
arch/riscv/include/asm/arch-fu540/clk.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright (c) 2020 SiFive Inc
|
||||
*
|
||||
* Authors:
|
||||
* Pragnesh Patel <pragnesh.patel@sifive.com>
|
||||
*/
|
||||
|
||||
#ifndef __CLK_SIFIVE_H
|
||||
#define __CLK_SIFIVE_H
|
||||
|
||||
/* Note: This is a placeholder header for driver compilation. */
|
||||
|
||||
#endif
|
||||
38
arch/riscv/include/asm/arch-fu540/gpio.h
Normal file
38
arch/riscv/include/asm/arch-fu540/gpio.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright (C) 2019 SiFive, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _GPIO_SIFIVE_H
|
||||
#define _GPIO_SIFIVE_H
|
||||
|
||||
#define GPIO_INPUT_VAL 0x00
|
||||
#define GPIO_INPUT_EN 0x04
|
||||
#define GPIO_OUTPUT_EN 0x08
|
||||
#define GPIO_OUTPUT_VAL 0x0C
|
||||
#define GPIO_RISE_IE 0x18
|
||||
#define GPIO_RISE_IP 0x1C
|
||||
#define GPIO_FALL_IE 0x20
|
||||
#define GPIO_FALL_IP 0x24
|
||||
#define GPIO_HIGH_IE 0x28
|
||||
#define GPIO_HIGH_IP 0x2C
|
||||
#define GPIO_LOW_IE 0x30
|
||||
#define GPIO_LOW_IP 0x34
|
||||
#define GPIO_OUTPUT_XOR 0x40
|
||||
|
||||
#define NR_GPIOS 16
|
||||
|
||||
enum gpio_state {
|
||||
LOW,
|
||||
HIGH
|
||||
};
|
||||
|
||||
/* Details about a GPIO bank */
|
||||
struct sifive_gpio_platdata {
|
||||
void *base; /* address of registers in physical memory */
|
||||
};
|
||||
|
||||
#define SIFIVE_GENERIC_GPIO_NR(port, index) \
|
||||
(((port) * NR_GPIOS) + ((index) & (NR_GPIOS - 1)))
|
||||
|
||||
#endif /* _GPIO_SIFIVE_H */
|
||||
14
arch/riscv/include/asm/arch-fu540/spl.h
Normal file
14
arch/riscv/include/asm/arch-fu540/spl.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright (C) 2020 SiFive, Inc.
|
||||
*
|
||||
* Authors:
|
||||
* Pragnesh Patel <pragnesh.patel@sifve.com>
|
||||
*/
|
||||
|
||||
#ifndef _SPL_SIFIVE_H
|
||||
#define _SPL_SIFIVE_H
|
||||
|
||||
int soc_spl_init(void);
|
||||
|
||||
#endif /* _SPL_SIFIVE_H */
|
||||
@@ -77,7 +77,6 @@ enum sbi_ext_rfence_fid {
|
||||
#define SBI_FID_REMOTE_SFENCE_VMA_ASID SBI_EXT_RFENCE_REMOTE_SFENCE_VMA_ASID
|
||||
#endif
|
||||
|
||||
#define SBI_SPEC_VERSION_DEFAULT 0x1
|
||||
#define SBI_SPEC_VERSION_MAJOR_SHIFT 24
|
||||
#define SBI_SPEC_VERSION_MAJOR_MASK 0x7f
|
||||
#define SBI_SPEC_VERSION_MINOR_MASK 0xffffff
|
||||
@@ -90,7 +89,6 @@ enum sbi_ext_rfence_fid {
|
||||
#define SBI_ERR_DENIED -4
|
||||
#define SBI_ERR_INVALID_ADDRESS -5
|
||||
|
||||
extern unsigned long sbi_spec_version;
|
||||
struct sbiret {
|
||||
long error;
|
||||
long value;
|
||||
|
||||
@@ -11,9 +11,6 @@
|
||||
#include <asm/encoding.h>
|
||||
#include <asm/sbi.h>
|
||||
|
||||
/* default SBI version is 0.1 */
|
||||
unsigned long sbi_spec_version = SBI_SPEC_VERSION_DEFAULT;
|
||||
|
||||
struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0,
|
||||
unsigned long arg1, unsigned long arg2,
|
||||
unsigned long arg3, unsigned long arg4,
|
||||
@@ -56,6 +53,25 @@ void sbi_set_timer(uint64_t stime_value)
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* sbi_probe_extension() - Check if an SBI extension ID is supported or not.
|
||||
* @extid: The extension ID to be probed.
|
||||
*
|
||||
* Return: Extension specific nonzero value f yes, -ENOTSUPP otherwise.
|
||||
*/
|
||||
int sbi_probe_extension(int extid)
|
||||
{
|
||||
struct sbiret ret;
|
||||
|
||||
ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_PROBE_EXT, extid,
|
||||
0, 0, 0, 0, 0);
|
||||
if (!ret.error)
|
||||
if (ret.value)
|
||||
return ret.value;
|
||||
|
||||
return -ENOTSUPP;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SBI_V01
|
||||
|
||||
/**
|
||||
@@ -165,22 +181,4 @@ void sbi_remote_sfence_vma_asid(const unsigned long *hart_mask,
|
||||
(unsigned long)hart_mask, start, size, asid, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* sbi_probe_extension() - Check if an SBI extension ID is supported or not.
|
||||
* @extid: The extension ID to be probed.
|
||||
*
|
||||
* Return: Extension specific nonzero value f yes, -ENOTSUPP otherwise.
|
||||
*/
|
||||
int sbi_probe_extension(int extid)
|
||||
{
|
||||
struct sbiret ret;
|
||||
|
||||
ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_PROBE_EXT, extid,
|
||||
0, 0, 0, 0, 0);
|
||||
if (!ret.error)
|
||||
if (ret.value)
|
||||
return ret.value;
|
||||
|
||||
return -ENOTSUPP;
|
||||
}
|
||||
#endif /* CONFIG_SBI_V01 */
|
||||
|
||||
Reference in New Issue
Block a user