[arch][riscv] Add basic support for SiFive HiFive Unleashed

Most of changes were moving around where macros were defined, plus the
following:
- Remove requirement for floating point on RV64 to support booting
  monitor core on U54 SoC.
- Add support for Debug LEDs on HiFive Unleashed Board
This commit is contained in:
Elliot Berman
2019-12-03 15:48:18 -08:00
committed by Travis Geiselbrecht
parent 128890f8a8
commit d239adf839
9 changed files with 90 additions and 6 deletions

View File

@@ -38,7 +38,7 @@ else ifeq ($(SUBARCH),64)
ifndef TOOLCHAIN_PREFIX ifndef TOOLCHAIN_PREFIX
TOOLCHAIN_PREFIX := riscv64-elf- TOOLCHAIN_PREFIX := riscv64-elf-
endif endif
ARCH_COMPILEFLAGS := -march=rv64imafdc -mabi=lp64d -mcmodel=medany ARCH_COMPILEFLAGS := -march=rv64imac -mabi=lp64 -mcmodel=medany
else else
$(error SUBARCH not set or set to something unknown) $(error SUBARCH not set or set to something unknown)

View File

@@ -26,9 +26,4 @@ endif
# sifive_e or _u? # sifive_e or _u?
GLOBAL_DEFINES += PLATFORM_${VARIANT}=1 GLOBAL_DEFINES += PLATFORM_${VARIANT}=1
# set some global defines based on capability
GLOBAL_DEFINES += PLATFORM_HAS_DYNAMIC_TIMER=1
GLOBAL_DEFINES += ARCH_RISCV_CLINT_BASE=0x02000000
GLOBAL_DEFINES += ARCH_RISCV_MTIME_RATE=32768
include make/module.mk include make/module.mk

View File

@@ -0,0 +1,2 @@
include project/target/sifive-unleashed.mk
include project/virtual/test.mk

View File

@@ -0,0 +1,3 @@
TARGET := sifive-unleashed
SUBARCH := 64

View File

@@ -13,5 +13,10 @@ GLOBAL_DEFINES += SIFIVE_FREQ=16000000
MODULE_SRCS := $(LOCAL_DIR)/target.c MODULE_SRCS := $(LOCAL_DIR)/target.c
# set some global defines based on capability
GLOBAL_DEFINES += PLATFORM_HAS_DYNAMIC_TIMER=1
GLOBAL_DEFINES += ARCH_RISCV_CLINT_BASE=0x02000000
GLOBAL_DEFINES += ARCH_RISCV_MTIME_RATE=32768
include make/module.mk include make/module.mk

View File

@@ -0,0 +1,22 @@
/*
* Copyright (c) 2019 Elliot Berman
*
* Use of this source code is governed by a MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT
*/
#pragma once
#define SIFIVE_IRQ_UART0 4
#define SIFIVE_IRQ_UART1 5
#define SIFIVE_NUM_IRQS 53
#define CLINT_BASE 0x02000000
#define PLIC_BASE 0x0c000000
#define PRCI_BASE 0x10000000
#define UART0_BASE 0x10010000
#define UART1_BASE 0x10011000
#define PWM0_BASE 0x10020000
#define PWM1_BASE 0x10021000
#define GPIO_BASE 0x10060000

View File

@@ -0,0 +1,19 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
MODULE := $(LOCAL_DIR)
PLATFORM := sifive
VARIANT := sifive_u
GLOBAL_DEFINES += SIFIVE_FREQ=500000000 # 500 MHz
MEMBASE ?= 0x080000000
MEMSIZE ?= 0x200000000 # 8 GiB
MODULE_SRCS := $(LOCAL_DIR)/target.c
# set some global defines based on capability
GLOBAL_DEFINES += TARGET_HAS_DEBUG_LED=1
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

View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) 2019 Elliot Berman
*
* Use of this source code is governed by a MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT
*/
#include <target.h>
#include <arch/arch_ops.h>
#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];
} *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);
}
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;
}