From: Yanhong Wang <yanhong.wang@starfivetech.com>
To: <u-boot@lists.denx.de>, Rick Chen <rick@andestech.com>,
Leo <ycliang@andestech.com>, Lukasz Majewski <lukma@denx.de>,
Sean Anderson <seanga2@gmail.com>
Cc: Lee Kuan Lim <kuanlim.lee@starfivetech.com>,
Jianlong Huang <jianlong.huang@starfivetech.com>,
Emil Renner Berthing <kernel@esmil.dk>,
Yanhong Wang <yanhong.wang@starfivetech.com>
Subject: [PATCH v3 01/17] riscv: cpu: jh7110: Add support for jh7110 SoC
Date: Fri, 3 Mar 2023 11:24:16 +0800 [thread overview]
Message-ID: <20230303032432.7837-2-yanhong.wang@starfivetech.com> (raw)
In-Reply-To: <20230303032432.7837-1-yanhong.wang@starfivetech.com>
Add StarFive JH7110 SoC to support RISC-V arch.
Signed-off-by: Yanhong Wang <yanhong.wang@starfivetech.com>
Reviewed-by: Rick Chen <rick@andestech.com>
---
arch/riscv/cpu/jh7110/Makefile | 10 ++++
arch/riscv/cpu/jh7110/cpu.c | 23 ++++++++
arch/riscv/cpu/jh7110/dram.c | 38 ++++++++++++++
arch/riscv/cpu/jh7110/spl.c | 64 +++++++++++++++++++++++
arch/riscv/include/asm/arch-jh7110/regs.h | 19 +++++++
arch/riscv/include/asm/arch-jh7110/spl.h | 12 +++++
6 files changed, 166 insertions(+)
create mode 100644 arch/riscv/cpu/jh7110/Makefile
create mode 100644 arch/riscv/cpu/jh7110/cpu.c
create mode 100644 arch/riscv/cpu/jh7110/dram.c
create mode 100644 arch/riscv/cpu/jh7110/spl.c
create mode 100644 arch/riscv/include/asm/arch-jh7110/regs.h
create mode 100644 arch/riscv/include/asm/arch-jh7110/spl.h
diff --git a/arch/riscv/cpu/jh7110/Makefile b/arch/riscv/cpu/jh7110/Makefile
new file mode 100644
index 0000000000..951c95631e
--- /dev/null
+++ b/arch/riscv/cpu/jh7110/Makefile
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2022 StarFive Technology Co., Ltd.
+
+ifeq ($(CONFIG_SPL_BUILD),y)
+obj-y += spl.o
+else
+obj-y += cpu.o
+obj-y += dram.o
+endif
diff --git a/arch/riscv/cpu/jh7110/cpu.c b/arch/riscv/cpu/jh7110/cpu.c
new file mode 100644
index 0000000000..1d7c026584
--- /dev/null
+++ b/arch/riscv/cpu/jh7110/cpu.c
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2022 StarFive Technology Co., Ltd.
+ * Author: Yanhong Wang <yanhong.wang@starfivetech.com>
+ */
+
+#include <asm/cache.h>
+#include <irq_func.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/arch/riscv/cpu/jh7110/dram.c b/arch/riscv/cpu/jh7110/dram.c
new file mode 100644
index 0000000000..2ad3f2044a
--- /dev/null
+++ b/arch/riscv/cpu/jh7110/dram.c
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2022 StarFive Technology Co., Ltd.
+ * Author: Yanhong Wang <yanhong.wang@starfivetech.com>
+ */
+
+#include <common.h>
+#include <fdtdec.h>
+#include <init.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();
+}
+
+phys_size_t board_get_usable_ram_top(phys_size_t 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 (IS_ENABLED(CONFIG_64BIT) && gd->ram_top > SZ_4G)
+ return SZ_4G;
+
+ return gd->ram_top;
+}
diff --git a/arch/riscv/cpu/jh7110/spl.c b/arch/riscv/cpu/jh7110/spl.c
new file mode 100644
index 0000000000..104f0fe949
--- /dev/null
+++ b/arch/riscv/cpu/jh7110/spl.c
@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2022 StarFive Technology Co., Ltd.
+ * Author: Yanhong Wang<yanhong.wang@starfivetech.com>
+ */
+
+#include <asm/csr.h>
+#include <asm/sections.h>
+#include <dm.h>
+#include <log.h>
+
+#define CSR_U74_FEATURE_DISABLE 0x7c1
+#define L2_LIM_MEM_END 0x81FFFFFUL
+
+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;
+}
+
+void harts_early_init(void)
+{
+ ulong *ptr;
+ u8 *tmp;
+ ulong len, remain;
+ /*
+ * Feature Disable CSR
+ *
+ * Clear feature disable CSR to '0' to turn on all features for
+ * each core. This operation must be in M-mode.
+ */
+ if (CONFIG_IS_ENABLED(RISCV_MMODE))
+ csr_write(CSR_U74_FEATURE_DISABLE, 0);
+
+ /* clear L2 LIM memory
+ * set __bss_end to 0x81FFFFF region to zero
+ * The L2 Cache Controller supports ECC. ECC is applied to SRAM.
+ * If it is not cleared, the ECC part is invalid, and an ECC error
+ * will be reported when reading data.
+ */
+ ptr = (ulong *)&__bss_end;
+ len = L2_LIM_MEM_END - (ulong)&__bss_end;
+ remain = len % sizeof(ulong);
+ len /= sizeof(ulong);
+
+ while (len--)
+ *ptr++ = 0;
+
+ /* clear the remain bytes */
+ if (remain) {
+ tmp = (u8 *)ptr;
+ while (remain--)
+ *tmp++ = 0;
+ }
+}
diff --git a/arch/riscv/include/asm/arch-jh7110/regs.h b/arch/riscv/include/asm/arch-jh7110/regs.h
new file mode 100644
index 0000000000..05026870a0
--- /dev/null
+++ b/arch/riscv/include/asm/arch-jh7110/regs.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2022 StarFive Technology Co., Ltd.
+ * Author: Yanhong Wang <yanhong.wang@starfivetech.com>
+ */
+
+#ifndef __STARFIVE_JH7110_REGS_H
+#define __STARFIVE_JH7110_REGS_H
+
+#define JH7110_SYS_CRG 0x13020000
+#define JH7110_SYS_SYSCON 0x13030000
+#define JH7110_SYS_IOMUX 0x13040000
+#define JH7110_AON_CRG 0x17000000
+#define JH7110_AON_SYSCON 0x17010000
+
+#define JH7110_BOOT_MODE_SELECT_REG 0x1702002c
+#define JH7110_BOOT_MODE_SELECT_MASK GENMASK(1, 0)
+
+#endif /* __STARFIVE_JH7110_REGS_H */
diff --git a/arch/riscv/include/asm/arch-jh7110/spl.h b/arch/riscv/include/asm/arch-jh7110/spl.h
new file mode 100644
index 0000000000..23ce8871b3
--- /dev/null
+++ b/arch/riscv/include/asm/arch-jh7110/spl.h
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2022 StarFive Technology Co., Ltd.
+ * Author: Yanhong Wang <yanhong.wang@starfivetech.com>
+ */
+
+#ifndef _SPL_STARFIVE_H
+#define _SPL_STARFIVE_H
+
+int spl_soc_init(void);
+
+#endif /* _SPL_STARFIVE_H */
--
2.17.1
next prev parent reply other threads:[~2023-03-03 3:24 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-03 3:24 [PATCH v3 00/17] Basic StarFive JH7110 RISC-V SoC support Yanhong Wang
2023-03-03 3:24 ` Yanhong Wang [this message]
2023-03-03 3:24 ` [PATCH v3 02/17] cache: starfive: Add StarFive JH7110 support Yanhong Wang
2023-03-03 21:07 ` Conor Dooley
2023-03-06 1:56 ` yanhong wang
2023-03-03 3:24 ` [PATCH v3 04/17] reset: starfive: jh7110: Add reset driver for StarFive JH7110 SoC Yanhong Wang
2023-03-03 3:24 ` [PATCH v3 05/17] dt-bindings: clock: Add StarFive JH7110 clock definitions Yanhong Wang
2023-03-03 3:24 ` [PATCH v3 06/17] clk: starfive: Add StarFive JH7110 clock driver Yanhong Wang
2023-03-03 3:24 ` [PATCH v3 07/17] dt-bindings: pinctrl: Add StarFive JH7110 pinctrl definitions Yanhong Wang
2023-03-03 3:24 ` [PATCH v3 08/17] pinctrl: starfive: Add StarFive JH7110 driver Yanhong Wang
2023-03-03 3:24 ` [PATCH v3 09/17] ram: starfive: add ddr driver Yanhong Wang
2023-03-03 3:24 ` [PATCH v3 10/17] board: starfive: add StarFive VisionFive v2 board support Yanhong Wang
2023-03-03 3:24 ` [PATCH v3 11/17] riscv: cpu: jh7110: Add Kconfig for StarFive JH7110 SoC Yanhong Wang
2023-03-03 3:24 ` [PATCH v3 12/17] board: starfive: Add Kconfig for StarFive VisionFive v2 Board Yanhong Wang
2023-03-03 3:24 ` [PATCH v3 13/17] board: starfive: Add TARGET_STARFIVE_VISIONFIVE2 to Kconfig Yanhong Wang
2023-03-03 3:24 ` [PATCH v3 14/17] riscv: dts: jh7110: Add initial StarFive JH7110 device tree Yanhong Wang
2023-03-03 21:16 ` Conor Dooley
2023-03-07 1:59 ` yanhong wang
2023-03-07 6:30 ` Conor Dooley
2023-03-07 18:07 ` Conor Dooley
2023-03-03 3:24 ` [PATCH v3 15/17] riscv: dts: jh7110: Add initial u-boot " Yanhong Wang
2023-03-03 3:24 ` [PATCH v3 16/17] riscv: dts: jh7110: Add initial StarFive VisionFive v2 board " Yanhong Wang
2023-03-03 21:20 ` Conor Dooley
2023-03-06 2:37 ` yanhong wang
2023-03-03 3:24 ` [PATCH v3 17/17] configs: starfive: add starfive_visionfive2_defconfig Yanhong Wang
2023-03-03 21:08 ` [PATCH v3 00/17] Basic StarFive JH7110 RISC-V SoC support Conor Dooley
2023-03-06 2:52 ` yanhong wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230303032432.7837-2-yanhong.wang@starfivetech.com \
--to=yanhong.wang@starfivetech.com \
--cc=jianlong.huang@starfivetech.com \
--cc=kernel@esmil.dk \
--cc=kuanlim.lee@starfivetech.com \
--cc=lukma@denx.de \
--cc=rick@andestech.com \
--cc=seanga2@gmail.com \
--cc=u-boot@lists.denx.de \
--cc=ycliang@andestech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.