From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Sun, 28 May 2023 17:39:08 +0200 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q3IU9-0007Ma-TY for lore@lore.pengutronix.de; Sun, 28 May 2023 17:39:08 +0200 Received: from bombadil.infradead.org ([2607:7c80:54:3::133]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q3IU6-0004hB-Ko for lore@pengutronix.de; Sun, 28 May 2023 17:39:07 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=N8yL7HYiXHP7zGtqjhbLXDFIhxl7HplQzTPyv4LZOhQ=; b=AjjhH2nn1iw0MRedh0do4wi8fJ lxbmfKEQHhTY8iGTgmMV1h96l5BvF83jF+w+avnwkT2hbMxE0r00JPP1XIsUGye0patROptiGE6yT jmYxptGuofMdQuTUEqHWBztsBOrYjFEorpybJznw/zuDVEOUUxspyuc+GHS2xnG0XmPLXz7/+nr9M a/fCYVK+dQ6sL13j0TCxNI9DALmWCrzUBbGYIzs7JWB5OOcxLNRcO4xTGDpLG+x9/qxiMO5F+FdeU hjwgdqC+ozqyzbCoiyhB1VIaly0l00mfaSoiTfYu4yCXpQeaTEXM9vERRl/rCEX4B9EGrSf9UHOk3 6lE69uKA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3ISw-007zO4-0a; Sun, 28 May 2023 15:37:54 +0000 Received: from relay6-d.mail.gandi.net ([217.70.183.198]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q3ISr-007zMT-2E for barebox@lists.infradead.org; Sun, 28 May 2023 15:37:52 +0000 X-GND-Sasl: ahmad@a3f.at X-GND-Sasl: ahmad@a3f.at Received: by mail.gandi.net (Postfix) with ESMTPSA id B46C4C0002; Sun, 28 May 2023 15:37:41 +0000 (UTC) From: Ahmad Fatoum To: barebox@lists.infradead.org Cc: Lior Weintraub Date: Sun, 28 May 2023 17:37:35 +0200 Message-Id: <20230528153735.3315271-1-ahmad@a3f.at> X-Mailer: git-send-email 2.38.4 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230528_083750_009581_9E954B02 X-CRM114-Status: GOOD ( 22.88 ) X-BeenThere: barebox@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "barebox" X-SA-Exim-Connect-IP: 2607:7c80:54:3::133 X-SA-Exim-Mail-From: barebox-bounces+lore=pengutronix.de@lists.infradead.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.ext.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-5.2 required=4.0 tests=AWL,BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Subject: [PATCH v2] Porting barebox to a new SoC X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) From: Lior Weintraub Hi, I tried to follow the porting guide on https://www.barebox.org/doc/latest/devel/porting.html# but couldn't follow the instructions. I would like to port barebox to a new SoC (which is not a derivative of any known SoC). It has the following: * Single Cortex A53 * SRAM (4MB) located on address 0xC000000000 The below patch shows my initial test to try and have a starting point. I am setting env variables: export ARCH=arm64 export CROSS_COMPILE=/home/pliops/workspace/ARM/arm-gnu-toolchain/bin/aarch64-none-elf- Then I build with: make spider_defconfig && make This gives an error: aarch64-none-elf-gcc: error: unrecognized argument in option '-mabi=apcs-gnu' aarch64-none-elf-gcc: note: valid arguments to '-mabi=' are: ilp32 lp64 aarch64-none-elf-gcc: error: unrecognized command-line option '-msoft-float' aarch64-none-elf-gcc: error: unrecognized command-line option '-mno-unaligned-access' /home/pliops/workspace/simplest-linux-demo/barebox/scripts/Makefile.build:140: recipe for target 'scripts/mod/empty.o' failed make[2]: *** [scripts/mod/empty.o] Error 1 Not sure why the compiler flags get -mabi=apcs-gnu when I explicitly set CONFIG_CPU_V8 and the arch/arm/Makefile has: ifeq ($(CONFIG_CPU_V8), y) CFLAGS_ABI :=-mabi=lp64 The changes I did: >>From 848b5f9b18bb1bb96d197cbc1b368ee0a729d581 Mon Sep 17 00:00:00 2001 --- arch/arm/Kconfig | 13 ++++++++ arch/arm/Makefile | 1 + arch/arm/boards/Makefile | 1 + arch/arm/boards/spider-evk/Makefile | 4 +++ arch/arm/boards/spider-evk/board.c | 26 +++++++++++++++ arch/arm/boards/spider-evk/lowlevel.c | 30 +++++++++++++++++ arch/arm/configs/spider_defconfig | 8 +++++ arch/arm/dts/Makefile | 1 + arch/arm/dts/spider-mk1-evk.dts | 10 ++++++ arch/arm/dts/spider-mk1.dtsi | 46 +++++++++++++++++++++++++++ arch/arm/mach-spider/Kconfig | 16 ++++++++++ arch/arm/mach-spider/Makefile | 1 + arch/arm/mach-spider/lowlevel.c | 14 ++++++++ images/Makefile | 1 + images/Makefile.spider | 5 +++ include/mach/spider/lowlevel.h | 7 ++++ 16 files changed, 184 insertions(+) create mode 100644 arch/arm/boards/spider-evk/Makefile create mode 100644 arch/arm/boards/spider-evk/board.c create mode 100644 arch/arm/boards/spider-evk/lowlevel.c create mode 100644 arch/arm/configs/spider_defconfig create mode 100644 arch/arm/dts/spider-mk1-evk.dts create mode 100644 arch/arm/dts/spider-mk1.dtsi create mode 100644 arch/arm/mach-spider/Kconfig create mode 100644 arch/arm/mach-spider/Makefile create mode 100644 arch/arm/mach-spider/lowlevel.c create mode 100644 images/Makefile.spider create mode 100644 include/mach/spider/lowlevel.h diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index e76ee0f6dfe1..e5dcf128447e 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -255,6 +255,18 @@ config ARCH_ROCKCHIP select HAS_DEBUG_LL imply GPIO_ROCKCHIP +config ARCH_SPIDER + bool "Pliops Spider based" + depends on 64BIT + depends on ARCH_MULTIARCH + select GPIOLIB + select HAVE_PBL_MULTI_IMAGES + select COMMON_CLK + select CLKDEV_LOOKUP + select COMMON_CLK_OF_PROVIDER + select OFTREE + select OFDEVICE + config ARCH_STM32MP bool "STMicroelectronics STM32MP" depends on 32BIT @@ -331,6 +343,7 @@ source "arch/arm/mach-omap/Kconfig" source "arch/arm/mach-pxa/Kconfig" source "arch/arm/mach-rockchip/Kconfig" source "arch/arm/mach-socfpga/Kconfig" +source "arch/arm/mach-spider/Kconfig" source "arch/arm/mach-stm32mp/Kconfig" source "arch/arm/mach-versatile/Kconfig" source "arch/arm/mach-vexpress/Kconfig" diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 35ebc70f44e2..4c63dfee48f4 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -101,6 +101,7 @@ machine-$(CONFIG_ARCH_MXS) += mxs machine-$(CONFIG_ARCH_MVEBU) += mvebu machine-$(CONFIG_ARCH_NOMADIK) += nomadik machine-$(CONFIG_ARCH_OMAP) += omap +machine-$(CONFIG_ARCH_SPIDER) += spider machine-$(CONFIG_ARCH_PXA) += pxa machine-$(CONFIG_ARCH_ROCKCHIP) += rockchip machine-$(CONFIG_ARCH_SAMSUNG) += samsung diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile index 2877debad535..6fe0a90c81ea 100644 --- a/arch/arm/boards/Makefile +++ b/arch/arm/boards/Makefile @@ -135,6 +135,7 @@ obj-$(CONFIG_MACH_SOCFPGA_TERASIC_DE10_NANO) += terasic-de10-nano/ obj-$(CONFIG_MACH_SOCFPGA_TERASIC_SOCKIT) += terasic-sockit/ obj-$(CONFIG_MACH_SOLIDRUN_CUBOX) += solidrun-cubox/ obj-$(CONFIG_MACH_SOLIDRUN_MICROSOM) += solidrun-microsom/ +obj-$(CONFIG_MACH_SPIDER_MK1_EVK) += spider-evk/ obj-$(CONFIG_MACH_STM32MP15XX_DKX) += stm32mp15xx-dkx/ obj-$(CONFIG_MACH_STM32MP13XX_DK) += stm32mp13xx-dk/ obj-$(CONFIG_MACH_LXA_MC1) += lxa-mc1/ diff --git a/arch/arm/boards/spider-evk/Makefile b/arch/arm/boards/spider-evk/Makefile new file mode 100644 index 000000000000..da63d2625f7a --- /dev/null +++ b/arch/arm/boards/spider-evk/Makefile @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-only + +obj-y += board.o +lwl-y += lowlevel.o diff --git a/arch/arm/boards/spider-evk/board.c b/arch/arm/boards/spider-evk/board.c new file mode 100644 index 000000000000..3920e83b457d --- /dev/null +++ b/arch/arm/boards/spider-evk/board.c @@ -0,0 +1,26 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +static int spider_board_probe(struct device *dev) +{ + /* Do some board-specific setup */ + return 0; +} + +static const struct of_device_id spider_board_of_match[] = { + { .compatible = "pliops,spider-mk1-evk" }, + { /* sentinel */ }, +}; + +static struct driver spider_board_driver = { + .name = "board-spider", + .probe = spider_board_probe, + .of_compatible = spider_board_of_match, +}; +device_platform_driver(spider_board_driver); diff --git a/arch/arm/boards/spider-evk/lowlevel.c b/arch/arm/boards/spider-evk/lowlevel.c new file mode 100644 index 000000000000..e36fcde4208e --- /dev/null +++ b/arch/arm/boards/spider-evk/lowlevel.c @@ -0,0 +1,30 @@ +#include +#include +#include + +#define BASE_ADDR (0xD000307000) +#define GPRAM_ADDR (0xC000000000) +#define MY_STACK_TOP (0xC000000000 + SZ_2M) // Set the stack 2MB from GPRAM start (excatly in the middle) +static inline void spider_serial_putc(void *base, int c) +{ +// if (!(readl(base + UCR1) & UCR1_UARTEN)) +// return; +// +// while (!(readl(base + USR2) & USR2_TXDC)); +// +// writel(c, base + URTX0); +} + +ENTRY_FUNCTION_WITHSTACK(start_spider_mk1_evk, MY_STACK_TOP, r0, r1, r2) +{ + extern char __dtb_spider_mk1_evk_start[]; + + spider_lowlevel_init(); + + relocate_to_current_adr(); + setup_c(); + + pbl_set_putc(spider_serial_putc, (void *)BASE_ADDR); + + barebox_arm_entry(GPRAM_ADDR, SZ_2M, __dtb_spider_mk1_evk_start); +} diff --git a/arch/arm/configs/spider_defconfig b/arch/arm/configs/spider_defconfig new file mode 100644 index 000000000000..c91bb889d97f --- /dev/null +++ b/arch/arm/configs/spider_defconfig @@ -0,0 +1,8 @@ +CONFIG_ARCH_SPIDER=y +CONFIG_MACH_SPIDER_MK1_EVK=y +CONFIG_BOARD_ARM_GENERIC_DT=y +CONFIG_MALLOC_TLSF=y +CONFIG_KALLSYMS=y +CONFIG_RELOCATABLE=y +CONFIG_CONSOLE_ALLOW_COLOR=y +CONFIG_PBL_CONSOLE=y diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index 98f4c4e0194b..94b304d4878f 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -134,6 +134,7 @@ lwl-$(CONFIG_MACH_SOLIDRUN_CUBOX) += dove-cubox-bb.dtb.o lwl-$(CONFIG_MACH_SOLIDRUN_MICROSOM) += imx6dl-hummingboard.dtb.o imx6q-hummingboard.dtb.o \ imx6dl-hummingboard2.dtb.o imx6q-hummingboard2.dtb.o \ imx6q-h100.dtb.o +lwl-$(CONFIG_MACH_SPIDER_MK1_EVK) += spider-mk1-evk.dtb.o lwl-$(CONFIG_MACH_SKOV_IMX6) += imx6s-skov-imx6.dtb.o imx6dl-skov-imx6.dtb.o imx6q-skov-imx6.dtb.o lwl-$(CONFIG_MACH_SKOV_ARM9CPU) += at91-skov-arm9cpu.dtb.o lwl-$(CONFIG_MACH_SEEED_ODYSSEY) += stm32mp157c-odyssey.dtb.o diff --git a/arch/arm/dts/spider-mk1-evk.dts b/arch/arm/dts/spider-mk1-evk.dts new file mode 100644 index 000000000000..b8081cb85bf8 --- /dev/null +++ b/arch/arm/dts/spider-mk1-evk.dts @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0 OR X11 + +/dts-v1/; + +#include "spider-mk1.dtsi" + +/ { + model = "Pliops Spider MK-I EVK"; + compatible = "pliops,spider-mk1-evk"; +}; diff --git a/arch/arm/dts/spider-mk1.dtsi b/arch/arm/dts/spider-mk1.dtsi new file mode 100644 index 000000000000..d4613848169d --- /dev/null +++ b/arch/arm/dts/spider-mk1.dtsi @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: GPL-2.0 OR X11 + +/ { + #address-cells = <2>; + #size-cells = <2>; + + chosen { + stdout-path = &uart0; + }; + + aliases { + serial0 = &uart0; + }; + + cpus { + #address-cells = <1>; + #size-cells = <0>; + + cpu0: cpu@0 { + device_type = "cpu"; + compatible = "arm,cortex-a53"; + reg = <0x0>; + }; + }; + + memory@1000000 { + reg = <0x0 0x1000000 0x0 0x400000>; /* 128M */ + device_type = "memory"; + }; + + soc { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + sram@c000000000 { + compatible = "mmio-sram"; + reg = <0xc0 0x0 0x0 0x400000>; + }; + + uart0: serial@d000307000 { + compatible = "pliops,spider-uart"; + reg = <0xd0 0x307000 0 0x1000>; + }; + }; +}; diff --git a/arch/arm/mach-spider/Kconfig b/arch/arm/mach-spider/Kconfig new file mode 100644 index 000000000000..6d2f888a5fd8 --- /dev/null +++ b/arch/arm/mach-spider/Kconfig @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: GPL-2.0-only + +if ARCH_SPIDER + +config ARCH_SPIDER_MK1 + bool + select CPU_V8 + help + The first Cortex-A53-based SoC of the spider family. + This symbol is invisble and select by boards + +config MACH_SPIDER_MK1_EVK + bool "Pliops Spider Reference Design Board" + select ARCH_SPIDER_MK1 + +endif diff --git a/arch/arm/mach-spider/Makefile b/arch/arm/mach-spider/Makefile new file mode 100644 index 000000000000..b08c4a93ca27 --- /dev/null +++ b/arch/arm/mach-spider/Makefile @@ -0,0 +1 @@ +lwl-y += lowlevel.o diff --git a/arch/arm/mach-spider/lowlevel.c b/arch/arm/mach-spider/lowlevel.c new file mode 100644 index 000000000000..5d62ef0f39e5 --- /dev/null +++ b/arch/arm/mach-spider/lowlevel.c @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include +#include +#include + +void spider_lowlevel_init(void) +{ + arm_cpu_lowlevel_init(); + /* + * not yet relocated, only do writel/readl for stuff that's + * critical to run early. No global variables allowed. + */ +} diff --git a/images/Makefile b/images/Makefile index c93f9e268978..97521e713228 100644 --- a/images/Makefile +++ b/images/Makefile @@ -150,6 +150,7 @@ include $(srctree)/images/Makefile.mxs include $(srctree)/images/Makefile.omap3 include $(srctree)/images/Makefile.rockchip include $(srctree)/images/Makefile.socfpga +include $(srctree)/images/Makefile.spider include $(srctree)/images/Makefile.stm32mp include $(srctree)/images/Makefile.tegra include $(srctree)/images/Makefile.versatile diff --git a/images/Makefile.spider b/images/Makefile.spider new file mode 100644 index 000000000000..c32f2762df04 --- /dev/null +++ b/images/Makefile.spider @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-only + +pblb-$(CONFIG_MACH_SPIDER_MK1_EVK) += start_spider_mk1_evk +FILE_barebox-spider-mk1-evk.img = start_spider_mk1_evk.pblb +image-$(CONFIG_MACH_SPIDER_MK1_EVK) += barebox-spider-mk1-evk.img diff --git a/include/mach/spider/lowlevel.h b/include/mach/spider/lowlevel.h new file mode 100644 index 000000000000..6e0ce1c77f7e --- /dev/null +++ b/include/mach/spider/lowlevel.h @@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +#ifndef __MACH_SPIDER_H_ +#define __MACH_SPIDER_H_ + +void spider_lowlevel_init(void); + +#endif -- 2.38.4