[RFC PATCH 0/3] Start of MStar/SigmaStar Arm v7 SoC support

The initial very basic support for MStar/SigmaStar's Arm v7 SoCs should land in Linux 5.9 so I want to start the ball rolling on the u-boot side of things.
This series does almost nothing aside from define the header needed for the binaries to boot.
In my tree everything is working to the point that booting from SPI NOR, ethernet, SD etc work and for one chip it's even possible to have a completely u-boot boot flow.
I'm working on cleaning those patches up but I'm not sure how much I need for this very first series. So I've put the bare minimum here and will pull more parts in based on feedback.
Daniel Palmer (3): arm: mstar: Initial MStar/SigmaStar Armv7 SoC support arm: mstar: Add option for loading the SPL from the IPL arm: mstar: Add boot0 header
MAINTAINERS | 6 +++++ arch/arm/Kconfig | 9 +++++++ arch/arm/Makefile | 1 + arch/arm/include/asm/arch-mstarv7/boot0.h | 29 ++++++++++++++++++++ arch/arm/mach-mstar/Kconfig | 32 +++++++++++++++++++++++ 5 files changed, 77 insertions(+) create mode 100644 arch/arm/include/asm/arch-mstarv7/boot0.h create mode 100644 arch/arm/mach-mstar/Kconfig

The patch adds a very basic skeleton for the MStar/SigmaStar Armv7 SoC to go into. It doesn't do anything yet.
Signed-off-by: Daniel Palmer daniel@0x0f.com --- MAINTAINERS | 5 +++++ arch/arm/Kconfig | 8 ++++++++ arch/arm/Makefile | 1 + arch/arm/mach-mstar/Kconfig | 17 +++++++++++++++++ 4 files changed, 31 insertions(+) create mode 100644 arch/arm/mach-mstar/Kconfig
diff --git a/MAINTAINERS b/MAINTAINERS index 101f4e185d..be621a614f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -293,6 +293,11 @@ F: arch/arm/mach-at91/ F: board/atmel/ F: drivers/misc/microchip_flexcom.c
+ARM MSTAR/SIGMASTAR V7 +M: Daniel Palmer daniel@thingy.jp +S: Maintained +F: arch/arm/mach-mstar/ + ARM NEXELL S5P4418 M: Stefan Bosch stefan_b@posteo.net S: Maintained diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 80702c23d3..7a25410ede 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1166,6 +1166,12 @@ config ARCH_ZYNQMP imply MP imply DM_USB_GADGET
+config ARCH_MSTARV7 + bool "MStar/SigmaStar ARM v7 SoCs" + select CPU_V7A + select SYS_NS16550 + imply SUPPORT_SPL + config ARCH_TEGRA bool "NVIDIA Tegra" imply DISTRO_DEFAULTS @@ -1927,6 +1933,8 @@ source "arch/arm/mach-versal/Kconfig"
source "arch/arm/mach-zynqmp-r5/Kconfig"
+source "arch/arm/mach-mstar/Kconfig" + source "arch/arm/cpu/armv7/Kconfig"
source "arch/arm/cpu/armv8/Kconfig" diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 28b523b37c..deeb08b989 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -87,6 +87,7 @@ machine-$(CONFIG_ARCH_VERSAL) += versal machine-$(CONFIG_ARCH_ZYNQ) += zynq machine-$(CONFIG_ARCH_ZYNQMP) += zynqmp machine-$(CONFIG_ARCH_ZYNQMP_R5) += zynqmp-r5 +machine-$(CONFIG_ARCH_MSTARV7) += mstar
machdirs := $(patsubst %,arch/arm/mach-%/,$(machine-y))
diff --git a/arch/arm/mach-mstar/Kconfig b/arch/arm/mach-mstar/Kconfig new file mode 100644 index 0000000000..ead9e126cc --- /dev/null +++ b/arch/arm/mach-mstar/Kconfig @@ -0,0 +1,17 @@ +menu "MStar/SigmaStar v7 options" + depends on ARCH_MSTARV7 + +endmenu + +if ARCH_MSTARV7 + +config DEBUG_UART_BASE + default 0x1f221000 + +config DEBUG_UART_CLOCK + default 172000000 + +config DEBUG_UART_SHIFT + default 3 + +endif

The boot process for MStar/Sigmastar Arm v7 SoCs involves a small boot rom, then an "IPL" which does hardware setup and loads another loader called "IPL Cust" that does more customer specific setup and that then finally loads maybe u-boot, Linux or an RTOS kernel.
At the moment DDR init isn't implemented in our SPL so we need to let the boot rom run the standard IPL to do that for us and then have it load the SPL so we can take over.
We probably can't just load u-boot proper from the IPL because we are limited to loading ~48KB.
This option will be used by boot0 to add the right magic string that the IPL expects for IPL Cust instead of the IPL string the boot rom wants so we can use the IPL until u-boot gets DDR init support.
Signed-off-by: Daniel Palmer daniel@0x0f.com --- arch/arm/mach-mstar/Kconfig | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/arch/arm/mach-mstar/Kconfig b/arch/arm/mach-mstar/Kconfig index ead9e126cc..a278c042e2 100644 --- a/arch/arm/mach-mstar/Kconfig +++ b/arch/arm/mach-mstar/Kconfig @@ -1,10 +1,22 @@ menu "MStar/SigmaStar v7 options" depends on ARCH_MSTARV7
+config MSTAR_IPL + bool "u-boot is being loaded by the vendor IPL" + help + Say y here if you are loading u-boot via the vendor + IPL. Note that the image can only be 48KB or less + for the IPL to load it so this only really applies + to a SPL/TPL. + endmenu
if ARCH_MSTARV7
+config SPL_TEXT_BASE + default 0x23c00000 if MSTAR_IPL + default 0xa0000000 + config DEBUG_UART_BASE default 0x1f221000

The Mstar/SigmaStar v7 boot rom and IPL second stage loader use the same header for the stage coming after them except for a slightly different magic string in the header.
This patch adds the header and sets up the right string depending on if the SPL is going to be loaded by the boot rom or by an IPL.
Signed-off-by: Daniel Palmer daniel@0x0f.com --- MAINTAINERS | 1 + arch/arm/Kconfig | 1 + arch/arm/include/asm/arch-mstarv7/boot0.h | 29 +++++++++++++++++++++++ arch/arm/mach-mstar/Kconfig | 3 +++ 4 files changed, 34 insertions(+) create mode 100644 arch/arm/include/asm/arch-mstarv7/boot0.h
diff --git a/MAINTAINERS b/MAINTAINERS index be621a614f..5f87ea55fd 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -297,6 +297,7 @@ ARM MSTAR/SIGMASTAR V7 M: Daniel Palmer daniel@thingy.jp S: Maintained F: arch/arm/mach-mstar/ +F: arch/arm/include/asm/arch-mstarv7/
ARM NEXELL S5P4418 M: Stefan Bosch stefan_b@posteo.net diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 7a25410ede..15cad7ff43 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1170,6 +1170,7 @@ config ARCH_MSTARV7 bool "MStar/SigmaStar ARM v7 SoCs" select CPU_V7A select SYS_NS16550 + select ENABLE_ARM_SOC_BOOT0_HOOK imply SUPPORT_SPL
config ARCH_TEGRA diff --git a/arch/arm/include/asm/arch-mstarv7/boot0.h b/arch/arm/include/asm/arch-mstarv7/boot0.h new file mode 100644 index 0000000000..0db6c568fb --- /dev/null +++ b/arch/arm/include/asm/arch-mstarv7/boot0.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Second stage (after bootrom) and Third stage (After IPL) + * header for MStar/SigmaStar Arm v7 SoCs. + * + * Copyright (c) 2020 Daniel Palmer daniel@thingy.jp. + */ + +/* The first 4 bytes should be an instruction */ + b reset + +#ifdef CONFIG_MSTAR_IPL + /* this is needed for the IPL to jump into our image */ + .ascii "IPLC" +#else + /* this is needed for the bootrom to jump into our image */ + .ascii "IPL_" +#endif + /* this is the size of the image to load */ + .2byte 0x0000 + + /* this seems to be the chip id */ + .byte 0x0 + + /* this is something to do with authentication */ + .byte 0x0 + + /* this is a checksum, doesn't always need to be right */ + .long 0x0000 diff --git a/arch/arm/mach-mstar/Kconfig b/arch/arm/mach-mstar/Kconfig index a278c042e2..cc1a68b191 100644 --- a/arch/arm/mach-mstar/Kconfig +++ b/arch/arm/mach-mstar/Kconfig @@ -26,4 +26,7 @@ config DEBUG_UART_CLOCK config DEBUG_UART_SHIFT default 3
+config SYS_SOC + default "mstarv7" + endif

On Mon, Sep 14, 2020 at 09:04:38PM +0900, Daniel Palmer wrote:
The initial very basic support for MStar/SigmaStar's Arm v7 SoCs should land in Linux 5.9 so I want to start the ball rolling on the u-boot side of things.
This series does almost nothing aside from define the header needed for the binaries to boot.
In my tree everything is working to the point that booting from SPI NOR, ethernet, SD etc work and for one chip it's even possible to have a completely u-boot boot flow.
I'm working on cleaning those patches up but I'm not sure how much I need for this very first series. So I've put the bare minimum here and will pull more parts in based on feedback.
Daniel Palmer (3): arm: mstar: Initial MStar/SigmaStar Armv7 SoC support arm: mstar: Add option for loading the SPL from the IPL arm: mstar: Add boot0 header
MAINTAINERS | 6 +++++ arch/arm/Kconfig | 9 +++++++ arch/arm/Makefile | 1 + arch/arm/include/asm/arch-mstarv7/boot0.h | 29 ++++++++++++++++++++ arch/arm/mach-mstar/Kconfig | 32 +++++++++++++++++++++++ 5 files changed, 77 insertions(+) create mode 100644 arch/arm/include/asm/arch-mstarv7/boot0.h create mode 100644 arch/arm/mach-mstar/Kconfig
What I see in the code so far is fine. This is a bit too little of a first series as there's nothing building. I would suggest aiming for a "boots to hush prompt on serial" for the first series as the goal and adding follow up series to add in IO. Thanks!

Hi Tom,
On Tue, 15 Sep 2020 at 03:56, Tom Rini trini@konsulko.com wrote:
What I see in the code so far is fine. This is a bit too little of a first series as there's nothing building. I would suggest aiming for a "boots to hush prompt on serial" for the first series as the goal and adding follow up series to add in IO. Thanks!
Thanks for taking a look. Originally I was intended to get to a prompt after loading from the SPL via ymodem for this first series but it was getting pretty big at about 20 patches and I didn't think that would be easy to review.
Anyhow I'll extend the series to actually build something. :)
Thanks,
Daniel
participants (2)
-
Daniel Palmer
-
Tom Rini