mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-07-04 13:22:31 +00:00
riscv: sifive: fu540: add SPL configuration
Add a support for SPL which will boot from L2 LIM (0x0800_0000) and then SPL will boot U-Boot FIT image (OpenSBI FW_DYNAMIC + u-boot.bin) from MMC boot devices. SPL related code is leveraged from FSBL (https://github.com/sifive/freedom-u540-c000-bootloader.git) Signed-off-by: Pragnesh Patel <pragnesh.patel@sifive.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Jagan Teki <jagan@amarulasolutions.com> Tested-by: Jagan Teki <jagan@amarulasolutions.com>
This commit is contained in:
parent
7c45fc9870
commit
01cdef22ee
9 changed files with 172 additions and 1 deletions
|
@ -3,5 +3,9 @@
|
||||||
# Copyright (C) 2020 SiFive, Inc
|
# Copyright (C) 2020 SiFive, Inc
|
||||||
# Pragnesh Patel <pragnesh.patel@sifive.com>
|
# Pragnesh Patel <pragnesh.patel@sifive.com>
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_SPL_BUILD),y)
|
||||||
|
obj-y += spl.o
|
||||||
|
else
|
||||||
obj-y += dram.o
|
obj-y += dram.o
|
||||||
obj-y += cpu.o
|
obj-y += cpu.o
|
||||||
|
endif
|
||||||
|
|
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;
|
||||||
|
}
|
|
@ -4,6 +4,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "fu540-c000-u-boot.dtsi"
|
#include "fu540-c000-u-boot.dtsi"
|
||||||
|
#include "fu540-hifive-unleashed-a00-ddr.dtsi"
|
||||||
|
|
||||||
/ {
|
/ {
|
||||||
aliases {
|
aliases {
|
||||||
|
@ -26,3 +27,7 @@
|
||||||
u-boot,dm-spl;
|
u-boot,dm-spl;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
&gpio {
|
||||||
|
u-boot,dm-spl;
|
||||||
|
};
|
||||||
|
|
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 */
|
|
@ -13,12 +13,20 @@ config SYS_CONFIG_NAME
|
||||||
default "sifive-fu540"
|
default "sifive-fu540"
|
||||||
|
|
||||||
config SYS_TEXT_BASE
|
config SYS_TEXT_BASE
|
||||||
|
default 0x80200000 if SPL
|
||||||
default 0x80000000 if !RISCV_SMODE
|
default 0x80000000 if !RISCV_SMODE
|
||||||
default 0x80200000 if RISCV_SMODE
|
default 0x80200000 if RISCV_SMODE
|
||||||
|
|
||||||
|
config SPL_TEXT_BASE
|
||||||
|
default 0x08000000
|
||||||
|
|
||||||
|
config SPL_OPENSBI_LOAD_ADDR
|
||||||
|
default 0x80000000
|
||||||
|
|
||||||
config BOARD_SPECIFIC_OPTIONS # dummy
|
config BOARD_SPECIFIC_OPTIONS # dummy
|
||||||
def_bool y
|
def_bool y
|
||||||
select GENERIC_RISCV
|
select SIFIVE_FU540
|
||||||
|
select SUPPORT_SPL
|
||||||
select RAM
|
select RAM
|
||||||
select SPL_RAM if SPL
|
select SPL_RAM if SPL
|
||||||
imply CMD_DHCP
|
imply CMD_DHCP
|
||||||
|
|
|
@ -3,3 +3,7 @@
|
||||||
# Copyright (c) 2019 Western Digital Corporation or its affiliates.
|
# Copyright (c) 2019 Western Digital Corporation or its affiliates.
|
||||||
|
|
||||||
obj-y += fu540.o
|
obj-y += fu540.o
|
||||||
|
|
||||||
|
ifdef CONFIG_SPL_BUILD
|
||||||
|
obj-y += spl.o
|
||||||
|
endif
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <misc.h>
|
#include <misc.h>
|
||||||
|
#include <spl.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This define is a value used for error/unknown serial.
|
* This define is a value used for error/unknown serial.
|
||||||
|
@ -117,3 +118,23 @@ int board_init(void)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_SPL
|
||||||
|
u32 spl_boot_device(void)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_SPL_MMC_SUPPORT
|
||||||
|
return BOOT_DEVICE_MMC1;
|
||||||
|
#else
|
||||||
|
puts("Unknown boot device\n");
|
||||||
|
hang();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_SPL_LOAD_FIT
|
||||||
|
int board_fit_config_name_match(const char *name)
|
||||||
|
{
|
||||||
|
/* boot using first FIT config */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
74
board/sifive/fu540/spl.c
Normal file
74
board/sifive/fu540/spl.c
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0+
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 SiFive, Inc
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Pragnesh Patel <pragnesh.patel@sifive.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <init.h>
|
||||||
|
#include <spl.h>
|
||||||
|
#include <misc.h>
|
||||||
|
#include <log.h>
|
||||||
|
#include <linux/delay.h>
|
||||||
|
#include <asm/gpio.h>
|
||||||
|
#include <asm/arch/gpio.h>
|
||||||
|
#include <asm/arch/spl.h>
|
||||||
|
|
||||||
|
#define GEM_PHY_RESET SIFIVE_GENERIC_GPIO_NR(0, 12)
|
||||||
|
|
||||||
|
int init_clk_and_ddr(void)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = soc_spl_init();
|
||||||
|
if (ret) {
|
||||||
|
debug("FU540 SPL init failed: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* GEMGXL init VSC8541 PHY reset sequence;
|
||||||
|
* leave pull-down active for 2ms
|
||||||
|
*/
|
||||||
|
udelay(2000);
|
||||||
|
ret = gpio_request(GEM_PHY_RESET, "gem_phy_reset");
|
||||||
|
if (ret) {
|
||||||
|
debug("gem_phy_reset gpio request failed: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set GPIO 12 (PHY NRESET) */
|
||||||
|
ret = gpio_direction_output(GEM_PHY_RESET, 1);
|
||||||
|
if (ret) {
|
||||||
|
debug("gem_phy_reset gpio direction set failed: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
udelay(1);
|
||||||
|
|
||||||
|
/* Reset PHY again to enter unmanaged mode */
|
||||||
|
gpio_set_value(GEM_PHY_RESET, 0);
|
||||||
|
udelay(1);
|
||||||
|
gpio_set_value(GEM_PHY_RESET, 1);
|
||||||
|
mdelay(15);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void board_init_f(ulong dummy)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = spl_early_init();
|
||||||
|
if (ret)
|
||||||
|
panic("spl_early_init() failed: %d\n", ret);
|
||||||
|
|
||||||
|
arch_cpu_init_dm();
|
||||||
|
|
||||||
|
preloader_console_init();
|
||||||
|
|
||||||
|
ret = init_clk_and_ddr();
|
||||||
|
if (ret)
|
||||||
|
panic("init_clk_and_ddr() failed: %d\n", ret);
|
||||||
|
}
|
|
@ -11,6 +11,22 @@
|
||||||
|
|
||||||
#include <linux/sizes.h>
|
#include <linux/sizes.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_SPL
|
||||||
|
|
||||||
|
#define CONFIG_SPL_MAX_SIZE 0x00100000
|
||||||
|
#define CONFIG_SPL_BSS_START_ADDR 0x85000000
|
||||||
|
#define CONFIG_SPL_BSS_MAX_SIZE 0x00100000
|
||||||
|
#define CONFIG_SYS_SPL_MALLOC_START (CONFIG_SPL_BSS_START_ADDR + \
|
||||||
|
CONFIG_SPL_BSS_MAX_SIZE)
|
||||||
|
#define CONFIG_SYS_SPL_MALLOC_SIZE 0x00100000
|
||||||
|
|
||||||
|
#define CONFIG_SPL_LOAD_FIT_ADDRESS 0x84000000
|
||||||
|
|
||||||
|
#define CONFIG_SPL_STACK (0x08000000 + 0x001D0000 - \
|
||||||
|
GENERATED_GBL_DATA_SIZE)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#define CONFIG_SYS_SDRAM_BASE 0x80000000
|
#define CONFIG_SYS_SDRAM_BASE 0x80000000
|
||||||
#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + SZ_2M)
|
#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + SZ_2M)
|
||||||
|
|
||||||
|
@ -24,6 +40,7 @@
|
||||||
|
|
||||||
/* Environment options */
|
/* Environment options */
|
||||||
|
|
||||||
|
#ifndef CONFIG_SPL_BUILD
|
||||||
#define BOOT_TARGET_DEVICES(func) \
|
#define BOOT_TARGET_DEVICES(func) \
|
||||||
func(MMC, mmc, 0) \
|
func(MMC, mmc, 0) \
|
||||||
func(DHCP, dhcp, na)
|
func(DHCP, dhcp, na)
|
||||||
|
@ -43,5 +60,6 @@
|
||||||
#define CONFIG_PREBOOT \
|
#define CONFIG_PREBOOT \
|
||||||
"setenv fdt_addr ${fdtcontroladdr};" \
|
"setenv fdt_addr ${fdtcontroladdr};" \
|
||||||
"fdt addr ${fdtcontroladdr};"
|
"fdt addr ${fdtcontroladdr};"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __CONFIG_H */
|
#endif /* __CONFIG_H */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue