- Sipeed Maix support S-mode.
- Provide command sbi.
- Use fdtdec_get_addr_size_auto_parent to get fu540 cache base address.
- Fix a compiler error with CONFIG_SPL_SMP=n.
- Fix sifive ram driver 32 compiler warnings.
- Fix kendryte/pll.h redefine nop() warning.
This commit is contained in:
Tom Rini 2020-08-25 08:18:50 -04:00
commit 078656186f
12 changed files with 197 additions and 5 deletions

View File

@ -35,7 +35,8 @@ int cache_enable_ways(void)
if (node < 0)
return node;
base = fdtdec_get_addr(blob, node, "reg");
base = fdtdec_get_addr_size_auto_parent(blob, 0, node, "reg", 0,
NULL, false);
if (base == FDT_ADDR_T_NONE)
return FDT_ADDR_T_NONE;

View File

@ -115,6 +115,8 @@ void sbi_remote_sfence_vma_asid(const unsigned long *hart_mask,
unsigned long asid);
#endif
void sbi_set_timer(uint64_t stime_value);
long sbi_get_spec_version(void);
int sbi_get_impl_id(void);
int sbi_probe_extension(int ext);
#endif

View File

@ -53,6 +53,42 @@ void sbi_set_timer(uint64_t stime_value)
#endif
}
/**
* sbi_get_spec_version() - get current SBI specification version
*
* Return: version id
*/
long sbi_get_spec_version(void)
{
struct sbiret ret;
ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_SPEC_VERSION,
0, 0, 0, 0, 0, 0);
if (!ret.error)
if (ret.value)
return ret.value;
return -ENOTSUPP;
}
/**
* sbi_get_impl_id() - get SBI implementation ID
*
* Return: implementation ID
*/
int sbi_get_impl_id(void)
{
struct sbiret ret;
ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_IMP_ID,
0, 0, 0, 0, 0, 0);
if (!ret.error)
if (ret.value)
return ret.value;
return -ENOTSUPP;
}
/**
* sbi_probe_extension() - Check if an SBI extension ID is supported or not.
* @extid: The extension ID to be probed.

View File

@ -39,7 +39,7 @@ void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
{
typedef void __noreturn (*image_entry_riscv_t)(ulong hart, void *dtb);
void *fdt_blob;
int ret;
__maybe_unused int ret;
#if CONFIG_IS_ENABLED(LOAD_FIT) || CONFIG_IS_ENABLED(LOAD_FIT_FULL)
fdt_blob = spl_image->fdt_addr;

View File

@ -4,7 +4,7 @@ S: Maintained
F: arch/riscv/dts/k210.dtsi
F: arch/riscv/dts/k210-maix-bit.dts
F: board/sipeed/maix/
F: configs/sipeed_maix_bitm_defconfig
F: configs/sipeed_maix*_defconfig
F: doc/board/sipeed/
F: include/configs/sipeed-maix.h
F: include/dt-bindings/*/k210-sysctl.h

View File

@ -270,6 +270,12 @@ config SPL_CMD_TLV_EEPROM
help
Read system EEPROM data block in ONIE Tlvinfo format from SPL.
config CMD_SBI
bool "sbi"
depends on RISCV_SMODE && SBI_V02
help
Display information about the SBI implementation.
endmenu
menu "Boot commands"

View File

@ -1,3 +1,4 @@
# SPDX-License-Identifier: GPL-2.0+
obj-$(CONFIG_CMD_EXCEPTION) += exception.o
obj-$(CONFIG_CMD_SBI) += sbi.o

82
cmd/riscv/sbi.c Normal file
View File

@ -0,0 +1,82 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* The 'sbi' command displays information about the SBI implementation.
*
* Copyright (c) 2020, Heinrich Schuchardt <xypron.glpk@gmx.de>
*/
#include <common.h>
#include <command.h>
#include <asm/sbi.h>
struct sbi_ext {
const u32 id;
const char *name;
};
static struct sbi_ext extensions[] = {
{ 0x00000000, "sbi_set_timer" },
{ 0x00000001, "sbi_console_putchar" },
{ 0x00000002, "sbi_console_getchar" },
{ 0x00000003, "sbi_clear_ipi" },
{ 0x00000004, "sbi_send_ipi" },
{ 0x00000005, "sbi_remote_fence_i" },
{ 0x00000006, "sbi_remote_sfence_vma" },
{ 0x00000007, "sbi_remote_sfence_vma_asid" },
{ 0x00000008, "sbi_shutdown" },
{ 0x00000010, "SBI Base Functionality" },
{ 0x54494D45, "Timer Extension" },
{ 0x00735049, "IPI Extension" },
{ 0x52464E43, "RFENCE Extension" },
{ 0x0048534D, "Hart State Management Extension" },
};
static int do_sbi(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
int i;
long ret;
ret = sbi_get_spec_version();
if (ret >= 0)
printf("SBI %ld.%ld\n", ret >> 24, ret & 0xffffff);
ret = sbi_get_impl_id();
if (ret >= 0) {
switch (ret) {
case 0:
printf("Berkeley Boot Loader (BBL)\n");
break;
case 1:
printf("OpenSBI\n");
break;
case 2:
printf("Xvisor\n");
break;
case 3:
printf("KVM\n");
break;
default:
printf("Unknown implementation\n");
break;
}
}
printf("Extensions:\n");
for (i = 0; i < ARRAY_SIZE(extensions); ++i) {
ret = sbi_probe_extension(extensions[i].id);
if (ret > 0)
printf(" %s\n", extensions[i].name);
}
return 0;
}
#ifdef CONFIG_SYS_LONGHELP
static char sbi_help_text[] =
"- display SBI spec version, implementation, and available extensions";
#endif
U_BOOT_CMD_COMPLETE(
sbi, 1, 0, do_sbi,
"display SBI information",
sbi_help_text, NULL
);

View File

@ -0,0 +1,10 @@
CONFIG_RISCV=y
CONFIG_SYS_TEXT_BASE=0x80020000
CONFIG_TARGET_SIPEED_MAIX=y
CONFIG_ARCH_RV64I=y
CONFIG_RISCV_SMODE=y
CONFIG_STACK_SIZE=0x100000
# CONFIG_NET is not set
# CONFIG_INPUT is not set
# CONFIG_DM_ETH is not set
# CONFIG_EFI_UNICODE_CAPITALIZATION is not set

View File

@ -75,6 +75,49 @@ console shall be opened immediately. Boot output should look like the following:
Err: serial@38000000
=>
OpenSBI
^^^^^^^
OpenSBI is an open source supervisor execution environment implementing the
RISC-V Supervisor Binary Interface Specification [1]. One of its features is
to intercept run-time exceptions, e.g. for unaligned access or illegal
instructions, and to emulate the failing instructions.
The OpenSBI source can be downloaded via:
.. code-block:: bash
git clone https://github.com/riscv/opensbi
As OpenSBI will be loaded at 0x80000000 we have to adjust the U-Boot text base.
Furthermore we have to enable building U-Boot for S-mode::
CONFIG_SYS_TEXT_BASE=0x80020000
CONFIG_RISCV_SMODE=y
Both settings are contained in sipeed_maix_smode_defconfig so we can build
U-Boot with:
.. code-block:: bash
make sipeed_maix_smode_defconfig
make
To build OpenSBI with U-Boot as a payload:
.. code-block:: bash
cd opensbi
make \
PLATFORM=kendryte/k210 \
FW_PAYLOAD=y \
FW_PAYLOAD_OFFSET=0x20000 \
FW_PAYLOAD_PATH=<path to U-Boot>/u-boot-dtb.bin
The value of FW_PAYLOAD_OFFSET must match CONFIG_SYS_TEXT_BASE - 0x80000000.
The file to flash is build/platform/kendryte/k210/firmware/fw_payload.bin.
Loading Images
^^^^^^^^^^^^^^
@ -363,3 +406,9 @@ Address Size Description
interrupts)
0x8801f000 0x1000 credits
========== ========= ===========
Links
-----
[1] https://github.com/riscv/riscv-sbi-doc
RISC-V Supervisor Binary Interface Specification

View File

@ -316,12 +316,12 @@ static int fu540_ddr_setup(struct udevice *dev)
priv->info.size = get_ram_size((long *)priv->info.base,
ddr_size);
debug("%s : %lx\n", __func__, priv->info.size);
debug("%s : %lx\n", __func__, (uintptr_t)priv->info.size);
/* check memory access for all memory */
if (priv->info.size != ddr_size) {
printf("DDR invalid size : 0x%lx, expected 0x%lx\n",
priv->info.size, (uintptr_t)ddr_size);
(uintptr_t)priv->info.size, (uintptr_t)ddr_size);
return -EINVAL;
}

View File

@ -7,6 +7,7 @@
#include <clk.h>
#include <test/export.h>
#include <asm/io.h>
#define K210_PLL_CLKR GENMASK(3, 0)
#define K210_PLL_CLKF GENMASK(9, 4)
@ -43,9 +44,13 @@ struct k210_pll_config {
#ifdef CONFIG_UNIT_TEST
TEST_STATIC int k210_pll_calc_config(u32 rate, u32 rate_in,
struct k210_pll_config *best);
#ifndef nop
#define nop()
#endif
#endif
extern const struct clk_ops k210_pll_ops;
struct clk *k210_register_pll_struct(const char *name, const char *parent_name,