[target][sifive-unleashed] get working on a physical sifive unleashed

Only tested with SBI and supervisor mode, but that's all I have now.

Add checked in copies of the device tree needed for a uboot uimage
needed to start it.
This commit is contained in:
Travis Geiselbrecht
2020-03-28 20:23:43 -07:00
parent 17037d258d
commit dc1cfc0b33
8 changed files with 434 additions and 19 deletions

View File

@@ -0,0 +1,2 @@
Snapshot of device trees taken from linux source in openembedded build,
version 5.2.9+gitAUTOINC+aad39e30fb-r0.

View File

@@ -0,0 +1,242 @@
// SPDX-License-Identifier: (GPL-2.0 OR MIT)
/* Copyright (c) 2018-2019 SiFive, Inc */
/dts-v1/;
#include <dt-bindings/clock/sifive-fu540-prci.h>
/ {
#address-cells = <2>;
#size-cells = <2>;
compatible = "sifive,fu540-c000", "sifive,fu540";
aliases {
serial0 = &uart0;
serial1 = &uart1;
};
chosen {
};
cpus {
#address-cells = <1>;
#size-cells = <0>;
timebase-frequency = <1000000>;
cpu0: cpu@0 {
compatible = "sifive,e51", "sifive,rocket0", "riscv";
device_type = "cpu";
i-cache-block-size = <64>;
i-cache-sets = <128>;
i-cache-size = <16384>;
reg = <0>;
riscv,isa = "rv64imac";
clocks = <&prci PRCI_CLK_COREPLL>;
status = "disabled";
cpu0_intc: interrupt-controller {
#interrupt-cells = <1>;
compatible = "riscv,cpu-intc";
interrupt-controller;
};
};
cpu1: cpu@1 {
compatible = "sifive,u54-mc", "sifive,rocket0", "riscv";
d-cache-block-size = <64>;
d-cache-sets = <64>;
d-cache-size = <32768>;
d-tlb-sets = <1>;
d-tlb-size = <32>;
device_type = "cpu";
i-cache-block-size = <64>;
i-cache-sets = <64>;
i-cache-size = <32768>;
i-tlb-sets = <1>;
i-tlb-size = <32>;
mmu-type = "riscv,sv39";
reg = <1>;
riscv,isa = "rv64imafdc";
tlb-split;
clocks = <&prci PRCI_CLK_COREPLL>;
cpu1_intc: interrupt-controller {
#interrupt-cells = <1>;
compatible = "riscv,cpu-intc";
interrupt-controller;
};
};
cpu2: cpu@2 {
clock-frequency = <0>;
compatible = "sifive,u54-mc", "sifive,rocket0", "riscv";
d-cache-block-size = <64>;
d-cache-sets = <64>;
d-cache-size = <32768>;
d-tlb-sets = <1>;
d-tlb-size = <32>;
device_type = "cpu";
i-cache-block-size = <64>;
i-cache-sets = <64>;
i-cache-size = <32768>;
i-tlb-sets = <1>;
i-tlb-size = <32>;
mmu-type = "riscv,sv39";
reg = <2>;
riscv,isa = "rv64imafdc";
tlb-split;
clocks = <&prci PRCI_CLK_COREPLL>;
cpu2_intc: interrupt-controller {
#interrupt-cells = <1>;
compatible = "riscv,cpu-intc";
interrupt-controller;
};
};
cpu3: cpu@3 {
clock-frequency = <0>;
compatible = "sifive,u54-mc", "sifive,rocket0", "riscv";
d-cache-block-size = <64>;
d-cache-sets = <64>;
d-cache-size = <32768>;
d-tlb-sets = <1>;
d-tlb-size = <32>;
device_type = "cpu";
i-cache-block-size = <64>;
i-cache-sets = <64>;
i-cache-size = <32768>;
i-tlb-sets = <1>;
i-tlb-size = <32>;
mmu-type = "riscv,sv39";
reg = <3>;
riscv,isa = "rv64imafdc";
tlb-split;
clocks = <&prci PRCI_CLK_COREPLL>;
cpu3_intc: interrupt-controller {
#interrupt-cells = <1>;
compatible = "riscv,cpu-intc";
interrupt-controller;
};
};
cpu4: cpu@4 {
clock-frequency = <0>;
compatible = "sifive,u54-mc", "sifive,rocket0", "riscv";
d-cache-block-size = <64>;
d-cache-sets = <64>;
d-cache-size = <32768>;
d-tlb-sets = <1>;
d-tlb-size = <32>;
device_type = "cpu";
i-cache-block-size = <64>;
i-cache-sets = <64>;
i-cache-size = <32768>;
i-tlb-sets = <1>;
i-tlb-size = <32>;
mmu-type = "riscv,sv39";
reg = <4>;
riscv,isa = "rv64imafdc";
tlb-split;
clocks = <&prci PRCI_CLK_COREPLL>;
cpu4_intc: interrupt-controller {
#interrupt-cells = <1>;
compatible = "riscv,cpu-intc";
interrupt-controller;
};
};
};
soc {
#address-cells = <2>;
#size-cells = <2>;
compatible = "sifive,fu540-c000", "sifive,fu540", "simple-bus";
ranges;
plic0: interrupt-controller@c000000 {
#interrupt-cells = <1>;
compatible = "sifive,plic-1.0.0";
reg = <0x0 0xc000000 0x0 0x4000000>;
riscv,ndev = <53>;
interrupt-controller;
interrupts-extended = <
&cpu0_intc 0xffffffff
&cpu1_intc 0xffffffff &cpu1_intc 9
&cpu2_intc 0xffffffff &cpu2_intc 9
&cpu3_intc 0xffffffff &cpu3_intc 9
&cpu4_intc 0xffffffff &cpu4_intc 9>;
};
prci: clock-controller@10000000 {
compatible = "sifive,fu540-c000-prci";
reg = <0x0 0x10000000 0x0 0x1000>;
clocks = <&hfclk>, <&rtcclk>;
#clock-cells = <1>;
};
uart0: serial@10010000 {
compatible = "sifive,fu540-c000-uart", "sifive,uart0";
reg = <0x0 0x10010000 0x0 0x1000>;
interrupt-parent = <&plic0>;
interrupts = <4>;
clocks = <&prci PRCI_CLK_TLCLK>;
status = "disabled";
};
uart1: serial@10011000 {
compatible = "sifive,fu540-c000-uart", "sifive,uart0";
reg = <0x0 0x10011000 0x0 0x1000>;
interrupt-parent = <&plic0>;
interrupts = <5>;
clocks = <&prci PRCI_CLK_TLCLK>;
status = "disabled";
};
i2c0: i2c@10030000 {
compatible = "sifive,fu540-c000-i2c", "sifive,i2c0";
reg = <0x0 0x10030000 0x0 0x1000>;
interrupt-parent = <&plic0>;
interrupts = <50>;
clocks = <&prci PRCI_CLK_TLCLK>;
reg-shift = <2>;
reg-io-width = <1>;
#address-cells = <1>;
#size-cells = <0>;
status = "disabled";
};
qspi0: spi@10040000 {
compatible = "sifive,fu540-c000-spi", "sifive,spi0";
reg = <0x0 0x10040000 0x0 0x1000
0x0 0x20000000 0x0 0x10000000>;
interrupt-parent = <&plic0>;
interrupts = <51>;
clocks = <&prci PRCI_CLK_TLCLK>;
#address-cells = <1>;
#size-cells = <0>;
status = "disabled";
};
qspi1: spi@10041000 {
compatible = "sifive,fu540-c000-spi", "sifive,spi0";
reg = <0x0 0x10041000 0x0 0x1000
0x0 0x30000000 0x0 0x10000000>;
interrupt-parent = <&plic0>;
interrupts = <52>;
clocks = <&prci PRCI_CLK_TLCLK>;
#address-cells = <1>;
#size-cells = <0>;
status = "disabled";
};
qspi2: spi@10050000 {
compatible = "sifive,fu540-c000-spi", "sifive,spi0";
reg = <0x0 0x10050000 0x0 0x1000>;
interrupt-parent = <&plic0>;
interrupts = <6>;
clocks = <&prci PRCI_CLK_TLCLK>;
#address-cells = <1>;
#size-cells = <0>;
status = "disabled";
};
eth0: ethernet@10090000 {
compatible = "sifive,fu540-macb";
interrupt-parent = <&plic0>;
interrupts = <53>;
reg = <0x0 0x10090000 0x0 0x2000
0x0 0x100a0000 0x0 0x1000>;
reg-names = "control";
status = "disabled";
local-mac-address = [00 00 00 00 00 00];
clock-names = "pclk", "hclk";
clocks = <&prci PRCI_CLK_GEMGXLPLL>,
<&prci PRCI_CLK_GEMGXLPLL>;
#address-cells = <1>;
#size-cells = <0>;
};
};
};

View File

@@ -0,0 +1,28 @@
// SPDX-License-Identifier: (GPL-2.0 OR MIT)
#include "hifive-unleashed-a00.dts"
/ {
soc {
pcie: pcie@2030000000 {
#address-cells = <0x3>;
#interrupt-cells = <0x1>;
#size-cells = <0x2>;
compatible = "microsemi,ms-pf-axi-pcie-host";
device_type = "pci";
bus-range = <0x01 0x7f>;
interrupt-map = <0 0 0 1 &ms_pcie_intc 0 0 0 0 2 &ms_pcie_intc 1 0 0 0 3 &ms_pcie_intc 2 0 0 0 4 &ms_pcie_intc 3>;
interrupt-map-mask = <0 0 0 7>;
interrupt-parent = <&plic0>;
interrupts = <32>;
ranges = <0x3000000 0x0 0x40000000 0x0 0x40000000 0x0 0x20000000>;
reg = <0x20 0x30000000 0x0 0x4000000 0x20 0x0 0x0 0x100000>;
reg-names = "control", "apb";
ms_pcie_intc: interrupt-controller {
#address-cells = <0>;
#interrupt-cells = <1>;
interrupt-controller;
};
};
};
};

View File

@@ -0,0 +1,121 @@
// SPDX-License-Identifier: (GPL-2.0 OR MIT)
/* Copyright (c) 2018-2019 SiFive, Inc */
#include "fu540-c000.dtsi"
/* Clock frequency (in Hz) of the PCB crystal for rtcclk */
#define RTCCLK_FREQ 1000000
/ {
#address-cells = <2>;
#size-cells = <2>;
model = "SiFive HiFive Unleashed A00";
compatible = "sifive,hifive-unleashed-a00", "sifive,fu540-c000";
chosen {
};
cpus {
timebase-frequency = <RTCCLK_FREQ>;
};
memory@80000000 {
device_type = "memory";
reg = <0x0 0x80000000 0x2 0x00000000>;
};
soc {
};
hfclk: hfclk {
#clock-cells = <0>;
compatible = "fixed-clock";
clock-frequency = <33333333>;
clock-output-names = "hfclk";
};
rtcclk: rtcclk {
#clock-cells = <0>;
compatible = "fixed-clock";
clock-frequency = <RTCCLK_FREQ>;
clock-output-names = "rtcclk";
};
fu540_c000_opp_table: opp-table {
compatible = "operating-points-v2";
opp-shared;
opp-350000000 {
opp-hz = /bits/ 64 <350000000>;
};
opp-700000000 {
opp-hz = /bits/ 64 <700000000>;
};
opp-999999999 {
opp-hz = /bits/ 64 <999999999>;
};
opp-1400000000 {
opp-hz = /bits/ 64 <1400000000>;
};
};
};
&cpu0 {
operating-points-v2 = <&fu540_c000_opp_table>;
};
&cpu1 {
operating-points-v2 = <&fu540_c000_opp_table>;
};
&cpu2 {
operating-points-v2 = <&fu540_c000_opp_table>;
};
&cpu3 {
operating-points-v2 = <&fu540_c000_opp_table>;
};
&cpu4 {
operating-points-v2 = <&fu540_c000_opp_table>;
};
&uart0 {
status = "okay";
};
&uart1 {
status = "okay";
};
&i2c0 {
status = "okay";
};
&qspi0 {
status = "okay";
flash@0 {
compatible = "issi,is25wp256", "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <50000000>;
m25p,fast-read;
spi-tx-bus-width = <4>;
spi-rx-bus-width = <4>;
};
};
&qspi2 {
status = "okay";
mmc@0 {
compatible = "mmc-spi-slot";
reg = <0>;
spi-max-frequency = <20000000>;
voltage-ranges = <3300 3300>;
disable-wp;
};
};
&eth0 {
status = "okay";
phy-mode = "gmii";
phy-handle = <&phy1>;
phy1: ethernet-phy@0 {
reg = <0>;
};
};

View File

@@ -5,19 +5,23 @@ PLATFORM := sifive
VARIANT := sifive_u
WITH_SMP := 1
BOOT_HART := 1
RISCV_BOOT_HART := 1
# Hart 0 on this board is disabled in supervisor mode, so make sure
# there are enough hart slots for it
RISCV_MAX_HARTS := 5
GLOBAL_DEFINES += SIFIVE_FREQ=500000000 # 500 MHz
RISCV_MODE ?= machine
RISCV_MODE ?= supervisor
ifeq ($(RISCV_MODE),supervisor)
MEMBASE ?= 0x080200000
MEMBASE ?= 0x080300000
SMP_MAX_CPUS := 4
else
MEMBASE ?= 0x080000000
SMP_MAX_CPUS := 5
endif
MEMSIZE ?= 0x200000000 # 8 GiB
MODULE_SRCS := $(LOCAL_DIR)/target.c
@@ -27,4 +31,4 @@ GLOBAL_DEFINES += PLATFORM_HAS_DYNAMIC_TIMER=1
GLOBAL_DEFINES += ARCH_RISCV_CLINT_BASE=0x02000000
GLOBAL_DEFINES += ARCH_RISCV_MTIME_RATE=1000000 # 1 MHz
include make/module.mk
include make/module.mk

View File

@@ -11,28 +11,28 @@
#include <platform/sifive.h>
static volatile struct {
volatile uint32_t pwmcfg;
volatile uint32_t res0;
volatile uint32_t pwmcount;
volatile uint32_t res1;
volatile uint32_t pwms;
volatile uint32_t res2[3];
volatile uint32_t pwmcmp[4];
volatile uint32_t pwmcfg;
volatile uint32_t res0;
volatile uint32_t pwmcount;
volatile uint32_t res1;
volatile uint32_t pwms;
volatile uint32_t res2[3];
volatile uint32_t pwmcmp[4];
} *const pwm0_base = (void*)PWM0_BASE;
void target_early_init(void) {
pwm0_base->pwmcfg = 0x100f; // enable always and max scaling
target_set_debug_led(0, false);
target_set_debug_led(1, false);
target_set_debug_led(2, false);
target_set_debug_led(3, false);
pwm0_base->pwmcfg = 0x100f; // enable always and max scaling
target_set_debug_led(0, false);
target_set_debug_led(1, false);
target_set_debug_led(2, false);
target_set_debug_led(3, false);
}
void target_init(void) {
}
void target_set_debug_led(unsigned int led, bool on) {
if(led > 3)
return;
pwm0_base->pwmcmp[led] = (0xffff + on) & 0xffff;
if(led > 3)
return;
pwm0_base->pwmcmp[led] = (0xffff + on) & 0xffff;
}