Skip to contentSkip to conversation

riscv: Initial support for Lichee PI 4A board

PATCH In review Yixun Lan 2 participants 6 messages Jul 8, 2023 – Jul 13, 2023 RISC-V

lore
Share & tools
lore

Yixun Lan

author
#0 lore raw

v2 cover riscv: Initial support for Lichee PI 4A board

Sipeed's Lichee PI 4A board is based on T-HEAD's TH1520 SoC which consists of quad core XuanTie C910 CPU, plus one C906 CPU and one E902 CPU.

In this series, we add a basic device tree, including UART CPU, PLIC, make it capable of running into a serial console.

Please note that, we rely on pre shipped vendor u-boot which run in M-Mode to chain load this mainline u-boot either via eMMC storage or from tftp, thus the pinctrl and clock setting are not implemented in this series, which certainly can be improved later accordingly.

Also the device tree is borrowed from kernel which is already accepted by kernel upstream [1].

[1] https://lore.kernel.org/all/[email protected]

Changes since PATCH v1:
- sync device tree with mainline kernel's version
- update docs and also fix the build error
- fix missing <cpu_func.h> header file

PATCH v1:
https://lore.kernel.org/all/[email protected]

Yixun Lan (4):
riscv: t-head: licheepi4a: initial support added
riscv: dts: t-head: Add basic device tree for Sipeed Lichee PI 4A
board
configs: th1520_lpi4a_defconfig: Add initial config
doc: t-head: lpi4a: document Lichee PI 4A board

 arch/riscv/Kconfig                          |   5 +
 arch/riscv/dts/Makefile                     |   1 +
 arch/riscv/dts/th1520-lichee-module-4a.dtsi |  34 ++
 arch/riscv/dts/th1520-lichee-pi-4a.dts      |  32 ++
 arch/riscv/dts/th1520.dtsi                  | 406 ++++++++++++++++++++
 board/thead/th1520_lpi4a/Kconfig            |  42 ++
 board/thead/th1520_lpi4a/MAINTAINERS        |   7 +
 board/thead/th1520_lpi4a/Makefile           |   5 +
 board/thead/th1520_lpi4a/board.c            |  15 +
 configs/th1520_lpi4a_defconfig              |  82 ++++
 doc/board/index.rst                         |   1 +
 doc/board/thead/index.rst                   |   9 +
 doc/board/thead/lpi4a.rst                   | 129 +++++++
 include/configs/th1520_lpi4a.h              |  22 ++
 14 files changed, 790 insertions(+)
 create mode 100644 arch/riscv/dts/th1520-lichee-module-4a.dtsi
 create mode 100644 arch/riscv/dts/th1520-lichee-pi-4a.dts
 create mode 100644 arch/riscv/dts/th1520.dtsi
 create mode 100644 board/thead/th1520_lpi4a/Kconfig
 create mode 100644 board/thead/th1520_lpi4a/MAINTAINERS
 create mode 100644 board/thead/th1520_lpi4a/Makefile
 create mode 100644 board/thead/th1520_lpi4a/board.c
 create mode 100644 configs/th1520_lpi4a_defconfig
 create mode 100644 doc/board/thead/index.rst
 create mode 100644 doc/board/thead/lpi4a.rst
 create mode 100644 include/configs/th1520_lpi4a.h
Signature · 1 line
2.39.3
author
#1 lore raw

PATCH v2 1/4 riscv: t-head: licheepi4a: initial support added

Add support for Sipeed's Lichee Pi 4A board which based on T-HEAD's TH1520 SoC, only minimal device tree and serial console are enabled, so it's capable of chain booting from T-HEAD's vendor u-boot.

---
 arch/riscv/Kconfig                   |  5 ++++
 board/thead/th1520_lpi4a/Kconfig     | 42 ++++++++++++++++++++++++++++
 board/thead/th1520_lpi4a/MAINTAINERS |  7 +++++
 board/thead/th1520_lpi4a/Makefile    |  5 ++++
 board/thead/th1520_lpi4a/board.c     | 15 ++++++++++
 include/configs/th1520_lpi4a.h       | 22 +++++++++++++++
 6 files changed, 96 insertions(+)
 create mode 100644 board/thead/th1520_lpi4a/Kconfig
 create mode 100644 board/thead/th1520_lpi4a/MAINTAINERS
 create mode 100644 board/thead/th1520_lpi4a/Makefile
 create mode 100644 board/thead/th1520_lpi4a/board.c
 create mode 100644 include/configs/th1520_lpi4a.h
arch/riscv/Kconfig +5 -0
index f6ed05906a..419b6171a9 100644
@@ -27,6 +27,10 @@ config TARGET_SIFIVE_UNMATCHED
 config TARGET_STARFIVE_VISIONFIVE2
 	bool "Support StarFive VisionFive2 Board"
 
+config TARGET_TH1520_LPI4A
+	bool "Support Sipeed's TH1520 Lichee PI 4A Board"
+	select SYS_CACHE_SHIFT_6
+
 config TARGET_SIPEED_MAIX
 	bool "Support Sipeed Maix Board"
 	select SYS_CACHE_SHIFT_6
@@ -66,6 +70,7 @@ source "board/emulation/qemu-riscv/Kconfig"
 source "board/microchip/mpfs_icicle/Kconfig"
 source "board/sifive/unleashed/Kconfig"
 source "board/sifive/unmatched/Kconfig"
+source "board/thead/th1520_lpi4a/Kconfig"
 source "board/openpiton/riscv64/Kconfig"
 source "board/sipeed/maix/Kconfig"
 source "board/starfive/visionfive2/Kconfig"
board/thead/th1520_lpi4a/Kconfig new file +42 -0

42 lines not on this page · raw message

board/thead/th1520_lpi4a/MAINTAINERS new file +7 -0
new file mode 100644
index 0000000000..36c7ab7cc3
@@ -0,0 +1,7 @@
+Lichee PI 4A
+M:	Wei Fu <[email protected]>
+M:	Yixun Lan <[email protected]>
+S:	Maintained
+F:	board/thead/th1520_lpi4a/
+F:	configs/th1520_lpi4a_defconfig
+F:	doc/board/thead/lpi4a.rst
board/thead/th1520_lpi4a/Makefile new file +5 -0
new file mode 100644
index 0000000000..9671b3bbb0
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (c) 2023, Yixun Lan <[email protected]>
+
+obj-y += board.o
board/thead/th1520_lpi4a/board.c new file +15 -0
new file mode 100644
index 0000000000..16c3e456b3
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2023, Yixun Lan <[email protected]>
+ *
+ */
+
+#include <common.h>
+#include <cpu_func.h>
+
+int board_init(void)
+{
+	enable_caches();
+
+	return 0;
+}
include/configs/th1520_lpi4a.h new file +22 -0
new file mode 100644
index 0000000000..87496a52c4
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2023 Yixun Lan <[email protected]>
+ *
+ */
+
+#ifndef __TH1520_LPI4A_H
+#define __TH1520_LPI4A_H
+
+#include <linux/sizes.h>
+
+#define CFG_SYS_SDRAM_BASE		0x00000000
+
+#define UART_BASE	0xffe7014000
+#define UART_REG_WIDTH  32
+
+/* Environment options */
+
+#define CFG_EXTRA_ENV_SETTINGS \
+	"PS1=[LPi4A]# \0"
+
+#endif /* __TH1520_LPI4A_H */
Signature · 1 line
2.39.3
author
#2 lore raw

PATCH v2 2/4 riscv: dts: t-head: Add basic device tree for Sipeed Lichee PI 4A board

In reply to Yixun Lan

Only add basic support for CPU, PLIC UART and Timer.

---
 arch/riscv/dts/Makefile                     |   1 +
 arch/riscv/dts/th1520-lichee-module-4a.dtsi |  34 ++
 arch/riscv/dts/th1520-lichee-pi-4a.dts      |  32 ++
 arch/riscv/dts/th1520.dtsi                  | 406 ++++++++++++++++++++
 4 files changed, 473 insertions(+)
 create mode 100644 arch/riscv/dts/th1520-lichee-module-4a.dtsi
 create mode 100644 arch/riscv/dts/th1520-lichee-pi-4a.dts
 create mode 100644 arch/riscv/dts/th1520.dtsi
arch/riscv/dts/Makefile +1 -0
index 79a58694f5..72fd815a40 100644
@@ -9,6 +9,7 @@ dtb-$(CONFIG_TARGET_SIFIVE_UNMATCHED) += hifive-unmatched-a00.dtb
 dtb-$(CONFIG_TARGET_SIPEED_MAIX) += k210-maix-bit.dtb
 dtb-$(CONFIG_TARGET_STARFIVE_VISIONFIVE2) += jh7110-starfive-visionfive-2-v1.3b.dtb
 dtb-$(CONFIG_TARGET_STARFIVE_VISIONFIVE2) += jh7110-starfive-visionfive-2-v1.2a.dtb
+dtb-$(CONFIG_TARGET_TH1520_LPI4A) += th1520-lichee-pi-4a.dtb
 include $(srctree)/scripts/Makefile.dts
 
 targets += $(dtb-y)
arch/riscv/dts/th1520-lichee-module-4a.dtsi new file +34 -0
new file mode 100644
index 0000000000..dc00e3dfa0
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2023 Jisheng Zhang <[email protected]>
+ */
+
+/dts-v1/;
+
+#include "th1520.dtsi"
+
+/ {
+	model = "Sipeed Lichee Module 4A";
+	compatible = "sipeed,lichee-module-4a", "thead,th1520";
+
+	memory@0 {
+		device_type = "memory";
+		reg = <0x0 0x00000000 0x2 0x00000000>;
+	};
+};
+
+&osc {
+	clock-frequency = <24000000>;
+};
+
+&osc_32k {
+	clock-frequency = <32768>;
+};
+
+&apb_clk {
+	clock-frequency = <62500000>;
+};
+
+&uart_sclk {
+	clock-frequency = <100000000>;
+};
arch/riscv/dts/th1520-lichee-pi-4a.dts new file +32 -0
new file mode 100644
index 0000000000..a1248b2ee3
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2023 Jisheng Zhang <[email protected]>
+ */
+
+#include "th1520-lichee-module-4a.dtsi"
+
+/ {
+	model = "Sipeed Lichee Pi 4A";
+	compatible = "sipeed,lichee-pi-4a", "sipeed,lichee-module-4a", "thead,th1520";
+
+	aliases {
+		gpio0 = &gpio0;
+		gpio1 = &gpio1;
+		gpio2 = &gpio2;
+		gpio3 = &gpio3;
+		serial0 = &uart0;
+		serial1 = &uart1;
+		serial2 = &uart2;
+		serial3 = &uart3;
+		serial4 = &uart4;
+		serial5 = &uart5;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+};
+
+&uart0 {
+	status = "okay";
+};
arch/riscv/dts/th1520.dtsi new file +406 -0

406 lines not on this page · raw message

Signature · 1 line
2.39.3
author
#3 lore raw

PATCH v2 3/4 configs: th1520_lpi4a_defconfig: Add initial config

In reply to Yixun Lan

Add basic config for Sipeed Lichee PI 4A board which make it capable of booting into serial console.

---
 configs/th1520_lpi4a_defconfig | 82 ++++++++++++++++++++++++++++++++++
 1 file changed, 82 insertions(+)
 create mode 100644 configs/th1520_lpi4a_defconfig
configs/th1520_lpi4a_defconfig new file +82 -0
new file mode 100644
index 0000000000..710ec6abf5
@@ -0,0 +1,82 @@
+CONFIG_RISCV=y
+CONFIG_SYS_MALLOC_LEN=0x800000
+CONFIG_SYS_MALLOC_F_LEN=0x3000
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
+CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x80200000
+CONFIG_DEFAULT_DEVICE_TREE="th1520-lichee-pi-4a"
+CONFIG_SYS_PROMPT="LPI4A=> "
+CONFIG_SYS_LOAD_ADDR=0x80200000
+# CONFIG_SMP is not set
+CONFIG_TARGET_TH1520_LPI4A=y
+CONFIG_ARCH_RV64I=y
+CONFIG_OF_BOARD_FIXUP=y
+CONFIG_SYS_BOOT_GET_CMDLINE=y
+CONFIG_SYS_BOOT_GET_KBD=y
+CONFIG_FIT=y
+# CONFIG_FIT_FULL_CHECK is not set
+# CONFIG_FIT_PRINT is not set
+# CONFIG_BOOTSTD is not set
+# CONFIG_LEGACY_IMAGE_FORMAT is not set
+CONFIG_DISTRO_DEFAULTS=y
+CONFIG_BOOTARGS_SUBST=y
+CONFIG_BOOTCOMMAND=""
+CONFIG_DEFAULT_FDT_FILE="thead/th1520-lichee-pi-4a.dtb"
+CONFIG_LOG=y
+CONFIG_DISPLAY_CPUINFO=y
+CONFIG_DISPLAY_BOARDINFO=y
+CONFIG_DISPLAY_BOARDINFO_LATE=y
+CONFIG_SYS_CBSIZE=256
+CONFIG_SYS_PBSIZE=276
+CONFIG_CMD_CONFIG=y
+CONFIG_CMD_LICENSE=y
+CONFIG_CMD_BOOTZ=y
+# CONFIG_BOOTM_NETBSD is not set
+# CONFIG_BOOTM_PLAN9 is not set
+# CONFIG_BOOTM_RTEMS is not set
+# CONFIG_BOOTM_VXWORKS is not set
+CONFIG_SYS_BOOTM_LEN=0x4000000
+CONFIG_CMD_BOOTMENU=y
+# CONFIG_CMD_ELF is not set
+# CONFIG_CMD_IMI is not set
+# CONFIG_CMD_XIMG is not set
+# CONFIG_CMD_EXPORTENV is not set
+# CONFIG_CMD_IMPORTENV is not set
+# CONFIG_CMD_EDITENV is not set
+# CONFIG_CMD_SAVEENV is not set
+# CONFIG_CMD_CRC32 is not set
+# CONFIG_CMD_MEMORY is not set
+# CONFIG_CMD_LZMADEC is not set
+# CONFIG_CMD_UNLZ4 is not set
+# CONFIG_CMD_UNZIP is not set
+# CONFIG_CMD_LOADB is not set
+# CONFIG_CMD_LOADS is not set
+# CONFIG_CMD_ITEST is not set
+# CONFIG_CMD_SOURCE is not set
+# CONFIG_CMD_SETEXPR is not set
+# CONFIG_CMD_SLEEP is not set
+CONFIG_PARTITION_TYPE_GUID=y
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_VERSION_VARIABLE=y
+# CONFIG_NET is not set
+# CONFIG_BLOCK_CACHE is not set
+# CONFIG_GPIO is not set
+# CONFIG_I2C is not set
+# CONFIG_INPUT is not set
+# CONFIG_DM_MMC is not set
+# CONFIG_MTD is not set
+# CONFIG_POWER is not set
+CONFIG_SYS_NS16550=y
+CONFIG_RISCV_TIMER=y
+CONFIG_AES=y
+CONFIG_BLAKE2=y
+CONFIG_SHA512=y
+CONFIG_LZ4=y
+CONFIG_LZMA=y
+CONFIG_LZO=y
+CONFIG_ZLIB_UNCOMPRESS=y
+CONFIG_BZIP2=y
+CONFIG_ZSTD=y
+CONFIG_LIB_RATIONAL=y
+# CONFIG_EFI_LOADER is not set
+# CONFIG_LMB_USE_MAX_REGIONS is not set
Signature · 1 line
2.39.3
author
#4 lore raw

PATCH v2 4/4 doc: t-head: lpi4a: document Lichee PI 4A board

In reply to Yixun Lan
---
 doc/board/index.rst       |   1 +
 doc/board/thead/index.rst |   9 +++
 doc/board/thead/lpi4a.rst | 129 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 139 insertions(+)
 create mode 100644 doc/board/thead/index.rst
 create mode 100644 doc/board/thead/lpi4a.rst
doc/board/index.rst +1 -0
index 9ef25b1091..aadc90af89 100644
@@ -45,6 +45,7 @@ Board-specific doc
    starfive/index
    ste/index
    tbs/index
+   thead/index
    ti/index
    toradex/index
    variscite/index
doc/board/thead/index.rst new file +9 -0
new file mode 100644
index 0000000000..41566d3a36
@@ -0,0 +1,9 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+T-HEAD
+========
+
+.. toctree::
+   :maxdepth: 1
+
+   lpi4a
doc/board/thead/lpi4a.rst new file +129 -0

129 lines not on this page · raw message

Signature · 1 line
2.39.3
Reviewed-by on the v2 series
#5 lore raw
In reply to Yixun Lan

For this series:

Quoted 62 lines · Yixun Lan

Sipeed's Lichee PI 4A board is based on T-HEAD's TH1520 SoC which consists of quad core XuanTie C910 CPU, plus one C906 CPU and one E902 CPU.

In this series, we add a basic device tree, including UART CPU, PLIC, make it capable of running into a serial console.

Please note that, we rely on pre shipped vendor u-boot which run in M-Mode to chain load this mainline u-boot either via eMMC storage or from tftp, thus the pinctrl and clock setting are not implemented in this series, which certainly can be improved later accordingly.

Also the device tree is borrowed from kernel which is already accepted by kernel upstream [1].

[1] https://lore.kernel.org/all/[email protected]

Changes since PATCH v1:
- sync device tree with mainline kernel's version
- update docs and also fix the build error
- fix missing <cpu_func.h> header file

PATCH v1:
https://lore.kernel.org/all/[email protected]

Yixun Lan (4):
riscv: t-head: licheepi4a: initial support added
riscv: dts: t-head: Add basic device tree for Sipeed Lichee PI 4A
board
configs: th1520_lpi4a_defconfig: Add initial config
doc: t-head: lpi4a: document Lichee PI 4A board

 arch/riscv/Kconfig                          |   5 +
 arch/riscv/dts/Makefile                     |   1 +
 arch/riscv/dts/th1520-lichee-module-4a.dtsi |  34 ++
 arch/riscv/dts/th1520-lichee-pi-4a.dts      |  32 ++
 arch/riscv/dts/th1520.dtsi                  | 406 ++++++++++++++++++++
 board/thead/th1520_lpi4a/Kconfig            |  42 ++
 board/thead/th1520_lpi4a/MAINTAINERS        |   7 +
 board/thead/th1520_lpi4a/Makefile           |   5 +
 board/thead/th1520_lpi4a/board.c            |  15 +
 configs/th1520_lpi4a_defconfig              |  82 ++++
 doc/board/index.rst                         |   1 +
 doc/board/thead/index.rst                   |   9 +
 doc/board/thead/lpi4a.rst                   | 129 +++++++
 include/configs/th1520_lpi4a.h              |  22 ++
 14 files changed, 790 insertions(+)
 create mode 100644 arch/riscv/dts/th1520-lichee-module-4a.dtsi
 create mode 100644 arch/riscv/dts/th1520-lichee-pi-4a.dts
 create mode 100644 arch/riscv/dts/th1520.dtsi
 create mode 100644 board/thead/th1520_lpi4a/Kconfig
 create mode 100644 board/thead/th1520_lpi4a/MAINTAINERS
 create mode 100644 board/thead/th1520_lpi4a/Makefile
 create mode 100644 board/thead/th1520_lpi4a/board.c
 create mode 100644 configs/th1520_lpi4a_defconfig
 create mode 100644 doc/board/thead/index.rst
 create mode 100644 doc/board/thead/lpi4a.rst
 create mode 100644 include/configs/th1520_lpi4a.h

--
2.39.3

Signature · 2 lines
Best Regards
 Guo Ren