From: Sean Anderson <seanga2@gmail.com>
To: Yanhong Wang <yanhong.wang@starfivetech.com>,
u-boot@lists.denx.de, Rick Chen <rick@andestech.com>,
Leo <ycliang@andestech.com>, Lukasz Majewski <lukma@denx.de>
Cc: Lee Kuan Lim <kuanlim.lee@starfivetech.com>,
Jianlong Huang <jianlong.huang@starfivetech.com>,
Emil Renner Berthing <kernel@esmil.dk>
Subject: Re: [PATCH v2 10/17] board: starfive: add StarFive VisionFive v2 board support
Date: Sat, 21 Jan 2023 12:38:35 -0500 [thread overview]
Message-ID: <2daa083f-acfc-eabd-b89d-67ed8c796520@gmail.com> (raw)
In-Reply-To: <20230118081132.31403-11-yanhong.wang@starfivetech.com>
On 1/18/23 03:11, Yanhong Wang wrote:
> Add board support for StarFive VisionFive v2.
>
> Signed-off-by: Yanhong Wang <yanhong.wang@starfivetech.com>
> ---
> board/starfive/visionfive2/MAINTAINERS | 7 ++
> board/starfive/visionfive2/Makefile | 7 ++
> board/starfive/visionfive2/spl.c | 118 ++++++++++++++++++
> .../visionfive2/starfive_visionfive2.c | 38 ++++++
> include/configs/starfive-visionfive2.h | 18 +++
> 5 files changed, 188 insertions(+)
> create mode 100644 board/starfive/visionfive2/MAINTAINERS
> create mode 100644 board/starfive/visionfive2/Makefile
> create mode 100644 board/starfive/visionfive2/spl.c
> create mode 100644 board/starfive/visionfive2/starfive_visionfive2.c
> create mode 100644 include/configs/starfive-visionfive2.h
>
> diff --git a/board/starfive/visionfive2/MAINTAINERS b/board/starfive/visionfive2/MAINTAINERS
> new file mode 100644
> index 0000000000..c5369086d8
> --- /dev/null
> +++ b/board/starfive/visionfive2/MAINTAINERS
> @@ -0,0 +1,7 @@
> +STARFIVE JH7110 VISIONFIVE2 BOARD
> +M: startfive
> +S: Maintained
> +F: arch/riscv/include/asm/arch-jh7110/
> +F: board/starfive/visionfive2/
> +F: include/configs/starfive-visionfive2.h
> +F: configs/starfive_visionfive2_defconfig
> diff --git a/board/starfive/visionfive2/Makefile b/board/starfive/visionfive2/Makefile
> new file mode 100644
> index 0000000000..66c854df39
> --- /dev/null
> +++ b/board/starfive/visionfive2/Makefile
> @@ -0,0 +1,7 @@
> +# SPDX-License-Identifier: GPL-2.0+
> +#
> +# Copyright (C) 2022 StarFive Technology Co., Ltd.
> +#
> +
> +obj-y := starfive_visionfive2.o
> +obj-$(CONFIG_SPL_BUILD) += spl.o
> diff --git a/board/starfive/visionfive2/spl.c b/board/starfive/visionfive2/spl.c
> new file mode 100644
> index 0000000000..9e14cd56af
> --- /dev/null
> +++ b/board/starfive/visionfive2/spl.c
> @@ -0,0 +1,118 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2022 StarFive Technology Co., Ltd.
> + * Author: Yanhong Wang<yanhong.wang@starfivetech.com>
> + */
> +
> +#include <common.h>
> +#include <asm/arch/regs.h>
> +#include <asm/arch/spl.h>
> +#include <asm/io.h>
> +#include <log.h>
> +#include <spl.h>
> +
> +#define JH7110_CLK_CPU_ROOT_OFFSET 0x0U
> +#define JH7110_CLK_CPU_ROOT_SHIFT 24
> +#define JH7110_CLK_CPU_ROOT_MASK GENMASK(29, 24)
> +#define JH7110_CLK_BUS_ROOT_OFFSET 0x14U
> +#define JH7110_CLK_BUS_ROOT_SHIFT 24
> +#define JH7110_CLK_BUS_ROOT_MASK GENMASK(29, 24)
> +#define JH7110_CLK_PERH_ROOT_OFFSET 0x10U
> +#define JH7110_CLK_PERH_ROOT_SHIFT 24
> +#define JH7110_CLK_PERH_ROOT_MASK GENMASK(29, 24)
> +#define JH7110_CLK_NOC_BUS_STG_AXI_OFFSET 0x180U
> +#define JH7110_CLK_NOC_BUS_STG_AXI_SHIFT 31
> +#define JH7110_CLK_NOC_BUS_STG_AXI_MASK BIT(31)
> +#define JH7110_CLK_AON_APB_FUNC_OFFSET 0x4U
> +#define JH7110_CLK_AON_APB_FUNC_SHIFT 24
> +#define JH7110_CLK_AON_APB_FUNC_MASK GENMASK(29, 24)
> +#define JH7110_CLK_QSPI_REF_OFFSET 0x168U
> +#define JH7110_CLK_QSPI_REF_SHIFT 24
> +#define JH7110_CLK_QSPI_REF_MASK GENMASK(29, 24)
> +
> +#define ASSIGNED_CLOCK_PARENTS(type, val) \
> + clrsetbits_le32(JH7110_SYS_CRG + JH7110_CLK_##type##_OFFSET, \
> + JH7110_CLK_##type##_MASK, \
> + ((val) << JH7110_CLK_##type##_SHIFT) & JH7110_CLK_##type##_MASK)
> +
> +int spl_board_init_f(void)
> +{
> + int ret;
> +
> + ret = spl_soc_init();
> + if (ret) {
> + debug("JH7110 SPL init failed: %d\n", ret);
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> +u32 spl_boot_device(void)
> +{
> + u32 mode;
> +
> + mode = in_le32(JH7110_BOOT_MODE_SELECT_REG)
> + & JH7110_BOOT_MODE_SELECT_MASK;
> + switch (mode) {
> + case 0:
> + return BOOT_DEVICE_SPI;
> +
> + case 1:
> + return BOOT_DEVICE_MMC2;
> +
> + case 2:
> + return BOOT_DEVICE_MMC1;
> +
> + case 3:
> + return BOOT_DEVICE_UART;
> +
> + default:
> + debug("Unsupported boot device 0x%x.\n", mode);
> + return BOOT_DEVICE_NONE;
> + }
> +}
> +
> +void board_init_f(ulong dummy)
> +{
> + int ret;
> +
> + ret = spl_early_init();
> + if (ret)
> + panic("spl_early_init() failed: %d\n", ret);
> +
> + riscv_cpu_setup(NULL, NULL);
> + preloader_console_init();
> +
> + /* select clk_pll0 by default */
> + ASSIGNED_CLOCK_PARENTS(CPU_ROOT, 1);
> +
> + /* select clk_pll2 by default */
> + ASSIGNED_CLOCK_PARENTS(BUS_ROOT, 1);
> +
> + /* select clk_pll2 by default */
> + ASSIGNED_CLOCK_PARENTS(PERH_ROOT, 1);
> +
> + ASSIGNED_CLOCK_PARENTS(NOC_BUS_STG_AXI, 1);
> +
> + clrsetbits_le32(JH7110_AON_CRG + JH7110_CLK_AON_APB_FUNC_OFFSET,
> + JH7110_CLK_AON_APB_FUNC_MASK,
> + BIT(JH7110_CLK_AON_APB_FUNC_SHIFT));
> +
> + /* select clk_pll0 by default */
> + ASSIGNED_CLOCK_PARENTS(QSPI_REF, 1);
Sorry, I guess I wasn't clear enough last time. I mean use the assigned-clocks
and assigned-clock-parents properties in the device tree. See [1] for details.
[1] https://github.com/devicetree-org/dt-schema/blob/main/dtschema/schemas/clock/clock.yaml/
> +
> + ret = spl_board_init_f();
> + if (ret) {
> + debug("spl_board_init_f init failed: %d\n", ret);
> + return;
> + }
> +}
> +
> +#if CONFIG_IS_ENABLED(SPL_LOAD_FIT)
> +int board_fit_config_name_match(const char *name)
> +{
> + /* boot using first FIT config */
> + return 0;
> +}
> +#endif
> diff --git a/board/starfive/visionfive2/starfive_visionfive2.c b/board/starfive/visionfive2/starfive_visionfive2.c
> new file mode 100644
> index 0000000000..57f1b6ea5d
> --- /dev/null
> +++ b/board/starfive/visionfive2/starfive_visionfive2.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 <asm/io.h>
> +#include <linux/bitops.h>
> +
> +#define JH7110_L2_PREFETCHER_BASE_ADDR 0x2030000
> +#define JH7110_L2_PREFETCHER_HART_OFFSET 0x2000
> +
> +/* enable U74-mc hart1~hart4 prefetcher */
> +static void enable_prefetcher(void)
> +{
> + u8 hart;
> + u32 *reg;
> +
> + /* JH7110 use U74MC CORE IP, it include five cores(one S7 and four U7),
> + * but only U7 cores support prefetcher configuration
> + */
> + for (hart = 1; hart < 5; hart++) {
> + reg = (void *)(u64)(JH7110_L2_PREFETCHER_BASE_ADDR
> + + hart * JH7110_L2_PREFETCHER_HART_OFFSET);
> +
> + mb(); /* memory barrier */
> + setbits_le32(reg, 0x1);
> + mb(); /* memory barrier */
> + }
> +}
> +
> +int board_init(void)
> +{
> + enable_prefetcher();
> +
> + return 0;
> +}
> diff --git a/include/configs/starfive-visionfive2.h b/include/configs/starfive-visionfive2.h
> new file mode 100644
> index 0000000000..a5fba1869b
> --- /dev/null
> +++ b/include/configs/starfive-visionfive2.h
> @@ -0,0 +1,18 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + * Copyright (C) 2022 StarFive Technology Co., Ltd.
> + * Author: Yanhong Wang<yanhong.wang@starfivetech.com>
> + *
> + */
> +
> +#ifndef _STARFIVE_VISIONFIVE2_H
> +#define _STARFIVE_VISIONFIVE2_H
> +
> +#define RISCV_MMODE_TIMERBASE 0x2000000
> +#define RISCV_MMODE_TIMER_FREQ 4000000
> +
> +#define RISCV_SMODE_TIMER_FREQ 4000000
> +
> +#define __io
> +
> +#endif /* _STARFIVE_VISIONFIVE2_H */
next prev parent reply other threads:[~2023-01-21 17:38 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-18 8:11 [PATCH v2 00/17] Basic StarFive JH7110 RISC-V SoC support Yanhong Wang
2023-01-18 8:11 ` [PATCH v2 01/17] riscv: cpu: jh7110: Add support for jh7110 SoC Yanhong Wang
2023-01-18 8:11 ` [PATCH v2 02/17] cache: starfive: Add StarFive JH7110 support Yanhong Wang
2023-01-18 8:11 ` [PATCH v2 03/17] dt-bindings: reset: Add StarFive JH7110 reset definitions Yanhong Wang
2023-01-18 8:11 ` [PATCH v2 04/17] reset: starfive: jh7110: Add reset driver for StarFive JH7110 SoC Yanhong Wang
2023-01-18 8:11 ` [PATCH v2 05/17] dt-bindings: clock: Add StarFive JH7110 clock definitions Yanhong Wang
2023-01-21 18:37 ` Sean Anderson
2023-01-18 8:11 ` [PATCH v2 06/17] clk: starfive: Add StarFive JH7110 clock driver Yanhong Wang
2023-01-21 18:56 ` Sean Anderson
2023-02-16 3:16 ` yanhong wang
2023-01-18 8:11 ` [PATCH v2 07/17] dt-bindings: pinctrl: Add StarFive JH7110 pinctrl definitions Yanhong Wang
2023-01-18 8:11 ` [PATCH v2 08/17] pinctrl: starfive: Add StarFive JH7110 driver Yanhong Wang
2023-01-18 8:11 ` [PATCH v2 09/17] ram: starfive: add ddr driver Yanhong Wang
2023-01-18 8:11 ` [PATCH v2 10/17] board: starfive: add StarFive VisionFive v2 board support Yanhong Wang
2023-01-21 17:38 ` Sean Anderson [this message]
2023-01-18 8:11 ` [PATCH v2 11/17] riscv: cpu: jh7110: Add Kconfig for StarFive JH7110 SoC Yanhong Wang
2023-01-18 8:11 ` [PATCH v2 13/17] board: starfive: Add TARGET_STARFIVE_VISIONFIVE2 to Kconfig Yanhong Wang
2023-01-18 8:11 ` [PATCH v2 14/17] riscv: dts: jh7110: Add initial StarFive JH7110 device tree Yanhong Wang
2023-01-19 6:18 ` David Abdurachmanov
2023-01-19 6:26 ` Sean Anderson
2023-01-19 18:30 ` Conor Dooley
2023-01-19 19:16 ` Sean Anderson
2023-01-19 19:25 ` Conor Dooley
2023-01-20 1:37 ` Sean Anderson
2023-02-16 5:50 ` yanhong wang
2023-01-18 8:11 ` [PATCH v2 15/17] riscv: dts: jh7110: Add initial u-boot " Yanhong Wang
2023-01-18 8:11 ` [PATCH v2 16/17] riscv: dts: jh7110: Add initial StarFive VisionFive v2 board " Yanhong Wang
2023-01-21 18:46 ` Sean Anderson
2023-02-16 6:20 ` yanhong wang
2023-01-18 8:11 ` [PATCH v2 17/17] configs: starfive: add starfive_visionfive2_defconfig Yanhong Wang
2023-01-23 14:53 ` Andreas Schwab
2023-02-16 7:28 ` yanhong wang
2023-02-16 14:17 ` Heinrich Schuchardt
2023-01-21 21:36 ` [PATCH v2 00/17] Basic StarFive JH7110 RISC-V SoC support Conor Dooley
2023-01-21 21:56 ` Sean Anderson
2023-01-21 22:05 ` Conor Dooley
2023-01-22 18:42 ` Conor Dooley
2023-02-10 17:41 ` Conor Dooley
2023-02-16 7:39 ` yanhong wang
2023-01-24 0:28 ` Heinrich Schuchardt
2023-02-16 9:01 ` yanhong wang
2023-01-24 14:46 ` Andreas Schwab
2023-02-06 7:38 ` Jan Kiszka
2023-02-07 15:46 ` Bin Meng
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=2daa083f-acfc-eabd-b89d-67ed8c796520@gmail.com \
--to=seanga2@gmail.com \
--cc=jianlong.huang@starfivetech.com \
--cc=kernel@esmil.dk \
--cc=kuanlim.lee@starfivetech.com \
--cc=lukma@denx.de \
--cc=rick@andestech.com \
--cc=u-boot@lists.denx.de \
--cc=yanhong.wang@starfivetech.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox