diff options
Diffstat (limited to 'roms/u-boot/arch/riscv/cpu/fu540')
-rw-r--r-- | roms/u-boot/arch/riscv/cpu/fu540/Kconfig | 52 | ||||
-rw-r--r-- | roms/u-boot/arch/riscv/cpu/fu540/Makefile | 12 | ||||
-rw-r--r-- | roms/u-boot/arch/riscv/cpu/fu540/cache.c | 55 | ||||
-rw-r--r-- | roms/u-boot/arch/riscv/cpu/fu540/cpu.c | 22 | ||||
-rw-r--r-- | roms/u-boot/arch/riscv/cpu/fu540/dram.c | 38 | ||||
-rw-r--r-- | roms/u-boot/arch/riscv/cpu/fu540/spl.c | 23 |
6 files changed, 202 insertions, 0 deletions
diff --git a/roms/u-boot/arch/riscv/cpu/fu540/Kconfig b/roms/u-boot/arch/riscv/cpu/fu540/Kconfig new file mode 100644 index 000000000..05463b262 --- /dev/null +++ b/roms/u-boot/arch/riscv/cpu/fu540/Kconfig @@ -0,0 +1,52 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com> + +config SIFIVE_FU540 + bool + select ARCH_EARLY_INIT_R + select SUPPORT_SPL + select RAM + select SPL_RAM if SPL + imply CPU + imply CPU_RISCV + imply RISCV_TIMER if (RISCV_SMODE || SPL_RISCV_SMODE) + imply SPL_SIFIVE_CLINT + imply CMD_CPU + imply SPL_CPU + imply SPL_OPENSBI + imply SPL_LOAD_FIT + imply SMP + imply CLK_SIFIVE + imply CLK_SIFIVE_PRCI + imply SIFIVE_SERIAL + imply MACB + imply MII + imply SPI + imply SPI_SIFIVE + imply MMC + imply MMC_SPI + imply MMC_BROKEN_CD + imply CMD_MMC + imply DM_GPIO + imply SIFIVE_GPIO + imply CMD_GPIO + imply MISC + imply SIFIVE_OTP + imply DM_PWM + imply PWM_SIFIVE + imply DM_I2C + imply SYS_I2C_OCORES + +if ENV_IS_IN_SPI_FLASH + +config ENV_OFFSET + default 0x505000 + +config ENV_SIZE + default 0x20000 + +config ENV_SECT_SIZE + default 0x10000 + +endif # ENV_IS_IN_SPI_FLASH diff --git a/roms/u-boot/arch/riscv/cpu/fu540/Makefile b/roms/u-boot/arch/riscv/cpu/fu540/Makefile new file mode 100644 index 000000000..088205ef5 --- /dev/null +++ b/roms/u-boot/arch/riscv/cpu/fu540/Makefile @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2020 SiFive, Inc +# Pragnesh Patel <pragnesh.patel@sifive.com> + +ifeq ($(CONFIG_SPL_BUILD),y) +obj-y += spl.o +else +obj-y += dram.o +obj-y += cpu.o +obj-y += cache.o +endif diff --git a/roms/u-boot/arch/riscv/cpu/fu540/cache.c b/roms/u-boot/arch/riscv/cpu/fu540/cache.c new file mode 100644 index 000000000..0fc4ef6c0 --- /dev/null +++ b/roms/u-boot/arch/riscv/cpu/fu540/cache.c @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2020 SiFive, Inc + * + * Authors: + * Pragnesh Patel <pragnesh.patel@sifive.com> + */ + +#include <common.h> +#include <asm/global_data.h> +#include <asm/io.h> +#include <linux/bitops.h> + +/* Register offsets */ +#define L2_CACHE_CONFIG 0x000 +#define L2_CACHE_ENABLE 0x008 + +#define MASK_NUM_WAYS GENMASK(15, 8) +#define NUM_WAYS_SHIFT 8 + +DECLARE_GLOBAL_DATA_PTR; + +int cache_enable_ways(void) +{ + const void *blob = gd->fdt_blob; + int node; + fdt_addr_t base; + u32 config; + u32 ways; + + volatile u32 *enable; + + node = fdt_node_offset_by_compatible(blob, -1, + "sifive,fu540-c000-ccache"); + + if (node < 0) + return node; + + 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; + + config = readl((volatile u32 *)base + L2_CACHE_CONFIG); + ways = (config & MASK_NUM_WAYS) >> NUM_WAYS_SHIFT; + + enable = (volatile u32 *)(base + L2_CACHE_ENABLE); + + /* memory barrier */ + mb(); + (*enable) = ways - 1; + /* memory barrier */ + mb(); + return 0; +} diff --git a/roms/u-boot/arch/riscv/cpu/fu540/cpu.c b/roms/u-boot/arch/riscv/cpu/fu540/cpu.c new file mode 100644 index 000000000..f13c18942 --- /dev/null +++ b/roms/u-boot/arch/riscv/cpu/fu540/cpu.c @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com> + */ + +#include <irq_func.h> +#include <asm/cache.h> + +/* + * cleanup_before_linux() is called just before we call linux + * it prepares the processor for linux + * + * we disable interrupt and caches. + */ +int cleanup_before_linux(void) +{ + disable_interrupts(); + + cache_flush(); + + return 0; +} diff --git a/roms/u-boot/arch/riscv/cpu/fu540/dram.c b/roms/u-boot/arch/riscv/cpu/fu540/dram.c new file mode 100644 index 000000000..1fdc7837b --- /dev/null +++ b/roms/u-boot/arch/riscv/cpu/fu540/dram.c @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com> + */ + +#include <common.h> +#include <fdtdec.h> +#include <init.h> +#include <asm/global_data.h> +#include <linux/sizes.h> + +DECLARE_GLOBAL_DATA_PTR; + +int dram_init(void) +{ + return fdtdec_setup_mem_size_base(); +} + +int dram_init_banksize(void) +{ + return fdtdec_setup_memory_banksize(); +} + +ulong board_get_usable_ram_top(ulong total_size) +{ + /* + * Ensure that we run from first 4GB so that all + * addresses used by U-Boot are 32bit addresses. + * + * This in-turn ensures that 32bit DMA capable + * devices work fine because DMA mapping APIs will + * provide 32bit DMA addresses only. + */ + if (gd->ram_top >= SZ_4G) + return SZ_4G - 1; + + return gd->ram_top; +} diff --git a/roms/u-boot/arch/riscv/cpu/fu540/spl.c b/roms/u-boot/arch/riscv/cpu/fu540/spl.c new file mode 100644 index 000000000..45657b790 --- /dev/null +++ b/roms/u-boot/arch/riscv/cpu/fu540/spl.c @@ -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 spl_soc_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; +} |