diff options
author | Green Wan <green.wan@sifive.com> | 2021-05-27 06:52:13 -0700 |
---|---|---|
committer | Leo Yu-Chi Liang <ycliang@andestech.com> | 2021-05-31 16:35:55 +0800 |
commit | 70415e1e528db0856fedd4fa79b9f4a303a28c62 (patch) | |
tree | 5a03934be4bc3c6f15178e4fe4b3746d9d2c6ae9 /board/sifive | |
parent | 1c07b0c562348f9254c7efa0af69995a5aaa60bb (diff) | |
download | u-boot-70415e1e528db0856fedd4fa79b9f4a303a28c62.zip u-boot-70415e1e528db0856fedd4fa79b9f4a303a28c62.tar.gz u-boot-70415e1e528db0856fedd4fa79b9f4a303a28c62.tar.bz2 |
board: sifive: add HiFive Unmatched board support
Add defconfig and board support for HiFive Unmatched.
Signed-off-by: Green Wan <green.wan@sifive.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Rick Chen <rick@andestech.com>
Diffstat (limited to 'board/sifive')
-rw-r--r-- | board/sifive/unleashed/Kconfig | 1 | ||||
-rw-r--r-- | board/sifive/unmatched/Kconfig | 51 | ||||
-rw-r--r-- | board/sifive/unmatched/MAINTAINERS | 9 | ||||
-rw-r--r-- | board/sifive/unmatched/Makefile | 9 | ||||
-rw-r--r-- | board/sifive/unmatched/spl.c | 85 | ||||
-rw-r--r-- | board/sifive/unmatched/unmatched.c | 24 |
6 files changed, 179 insertions, 0 deletions
diff --git a/board/sifive/unleashed/Kconfig b/board/sifive/unleashed/Kconfig index 502916e..b3b4342 100644 --- a/board/sifive/unleashed/Kconfig +++ b/board/sifive/unleashed/Kconfig @@ -28,6 +28,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy select SIFIVE_FU540 select ENV_IS_IN_SPI_FLASH select BINMAN + select RESET_SIFIVE imply CMD_DHCP imply CMD_EXT2 imply CMD_EXT4 diff --git a/board/sifive/unmatched/Kconfig b/board/sifive/unmatched/Kconfig new file mode 100644 index 0000000..88b5883 --- /dev/null +++ b/board/sifive/unmatched/Kconfig @@ -0,0 +1,51 @@ +if TARGET_SIFIVE_UNMATCHED + +config SYS_BOARD + default "unmatched" + +config SYS_VENDOR + default "sifive" + +config SYS_CPU + default "fu740" + +config SYS_CONFIG_NAME + default "sifive-unmatched" + +config SYS_TEXT_BASE + default 0x80200000 if SPL + default 0x80000000 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 + def_bool y + select SIFIVE_FU740 + select SUPPORT_SPL + select RESET_SIFIVE + select BINMAN + imply CMD_DHCP + imply CMD_EXT2 + imply CMD_EXT4 + imply CMD_FAT + imply CMD_FS_GENERIC + imply CMD_GPT + imply PARTITION_TYPE_GUID + imply CMD_NET + imply CMD_PING + imply CMD_SF + imply DOS_PARTITION + imply EFI_PARTITION + imply IP_DYN + imply ISO_PARTITION + imply PHY_LIB + imply PHY_MSCC + imply SYSRESET + imply SYSRESET_GPIO + +endif diff --git a/board/sifive/unmatched/MAINTAINERS b/board/sifive/unmatched/MAINTAINERS new file mode 100644 index 0000000..94c9510 --- /dev/null +++ b/board/sifive/unmatched/MAINTAINERS @@ -0,0 +1,9 @@ +SiFive HiFive Unmatched FU740 BOARD +M: Paul Walmsley <paul.walmsley@sifive.com> +M: Pragnesh Patel <pragnesh.patel@sifive.com> +M: Green Wan <green.wan@sifive.com> +S: Maintained +F: board/sifive/unmatched/ +F: doc/board/sifive/hifive-unmatched-fu740.rst +F: include/configs/sifive-unmatched.h +F: configs/sifive_unmatched_defconfig diff --git a/board/sifive/unmatched/Makefile b/board/sifive/unmatched/Makefile new file mode 100644 index 0000000..6308c80 --- /dev/null +++ b/board/sifive/unmatched/Makefile @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (c) 2020-2021 SiFive, Inc + +obj-y += unmatched.o + +ifdef CONFIG_SPL_BUILD +obj-y += spl.o +endif diff --git a/board/sifive/unmatched/spl.c b/board/sifive/unmatched/spl.c new file mode 100644 index 0000000..5e1333b --- /dev/null +++ b/board/sifive/unmatched/spl.c @@ -0,0 +1,85 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2020-2021 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 <linux/io.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) + +#define MODE_SELECT_REG 0x1000 +#define MODE_SELECT_SD 0xb +#define MODE_SELECT_MASK GENMASK(3, 0) + +int spl_board_init_f(void) +{ + int ret; + + ret = spl_soc_init(); + if (ret) { + debug("HiFive Unmatched FU740 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; +} + +u32 spl_boot_device(void) +{ + u32 mode_select = readl((void *)MODE_SELECT_REG); + u32 boot_device = mode_select & MODE_SELECT_MASK; + + switch (boot_device) { + case MODE_SELECT_SD: + return BOOT_DEVICE_MMC1; + default: + debug("Unsupported boot device 0x%x but trying MMC1\n", + boot_device); + return BOOT_DEVICE_MMC1; + } +} + +#ifdef CONFIG_SPL_LOAD_FIT +int board_fit_config_name_match(const char *name) +{ + /* boot using first FIT config */ + return 0; +} +#endif diff --git a/board/sifive/unmatched/unmatched.c b/board/sifive/unmatched/unmatched.c new file mode 100644 index 0000000..6d60559 --- /dev/null +++ b/board/sifive/unmatched/unmatched.c @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2020-2021, SiFive Inc + * + * Authors: + * Pragnesh Patel <pragnesh.patel@sifive.com> + */ + +#include <common.h> +#include <dm.h> +#include <asm/arch/cache.h> + +int board_init(void) +{ + int ret; + + /* enable all cache ways */ + ret = cache_enable_ways(); + if (ret) { + debug("%s: could not enable cache ways\n", __func__); + return ret; + } + return 0; +} |