[PATCH v2 06/12] ARM: vexpress: switch to DT probe and multi-image build

Lucas Stach l.stach at pengutronix.de
Thu Oct 12 03:26:52 PDT 2017


This switches the VExpress support to use an internal DT, instead
of probing the peripherals from a board file. It also switches to
a multi-iamge build with both CA9 and CA15 variants of the VExpress
board being supported.

Signed-off-by: Lucas Stach <l.stach at pengutronix.de>
---
 arch/arm/boards/vexpress/Makefile                  |   2 -
 .../arm/boards/vexpress/defaultenv-vexpress/config |  38 -------
 arch/arm/boards/vexpress/init.c                    | 115 +--------------------
 arch/arm/boards/vexpress/lowlevel.c                |  20 +++-
 arch/arm/dts/Makefile                              |   2 +
 arch/arm/dts/vexpress-v2p-ca15.dts                 |  27 +++++
 arch/arm/dts/vexpress-v2p-ca9.dts                  |  27 +++++
 arch/arm/mach-vexpress/Kconfig                     |   4 +
 arch/arm/mach-vexpress/Makefile                    |   1 -
 arch/arm/mach-vexpress/devices.c                   |  83 ---------------
 arch/arm/mach-vexpress/include/mach/devices.h      |   9 --
 arch/arm/mach-vexpress/v2m.c                       |  38 -------
 images/Makefile                                    |   1 +
 images/Makefile.vexpress                           |  11 ++
 14 files changed, 93 insertions(+), 285 deletions(-)
 delete mode 100644 arch/arm/boards/vexpress/defaultenv-vexpress/config
 create mode 100644 arch/arm/dts/vexpress-v2p-ca15.dts
 create mode 100644 arch/arm/dts/vexpress-v2p-ca9.dts
 delete mode 100644 arch/arm/mach-vexpress/devices.c
 create mode 100644 images/Makefile.vexpress

diff --git a/arch/arm/boards/vexpress/Makefile b/arch/arm/boards/vexpress/Makefile
index c89d7bf182d0..2da0494d49b3 100644
--- a/arch/arm/boards/vexpress/Makefile
+++ b/arch/arm/boards/vexpress/Makefile
@@ -1,4 +1,2 @@
 obj-y += init.o
-
 lwl-y += lowlevel.o
-bbenv-$(CONFIG_DEFAULT_ENVIRONMENT_GENERIC) += defaultenv-vexpress
diff --git a/arch/arm/boards/vexpress/defaultenv-vexpress/config b/arch/arm/boards/vexpress/defaultenv-vexpress/config
deleted file mode 100644
index 6c0abda40c12..000000000000
--- a/arch/arm/boards/vexpress/defaultenv-vexpress/config
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-
-# use 'dhcp' to do dhcp in barebox and in kernel
-# use 'none' if you want to skip kernel ip autoconfiguration
-ip=dhcp
-global.dhcp.vendor_id=barebox-${global.hostname}
-
-# or set your networking parameters here
-#eth0.ipaddr=a.b.c.d
-#eth0.netmask=a.b.c.d
-#eth0.gateway=a.b.c.d
-#eth0.serverip=a.b.c.d
-
-# can be either 'nfs', 'tftp' or 'nor'
-kernel_loc=tftp
-# can be either 'net', 'nor' or 'initrd'
-rootfs_loc=initrd
-
-# can be either 'jffs2' or 'ubifs'
-rootfs_type=ubifs
-rootfsimage=root.$rootfs_type
-
-kernelimage=zImage
-#kernelimage=uImage
-#kernelimage=Image
-#kernelimage=Image.lzo
-
-nfsroot="$eth0.serverip:/opt/work/busybox/arm9/rootfs_arm"
-
-nor_parts="256k(barebox)ro,64k(bareboxenv),1536k(kernel),-(root)"
-rootfs_mtdblock_nor=3
-
-autoboot_timeout=3
-
-bootargs="console=ttyAMA0,115200n8 CONSOLE=/dev/ttyAMA0"
-
-# set a fancy prompt (if support is compiled in)
-PS1="\e[1;31m[barebox@\h]:\w\e[0m\n# "
diff --git a/arch/arm/boards/vexpress/init.c b/arch/arm/boards/vexpress/init.c
index f89dff939231..1bbc8c347638 100644
--- a/arch/arm/boards/vexpress/init.c
+++ b/arch/arm/boards/vexpress/init.c
@@ -11,129 +11,23 @@
 #include <generated/mach-types.h>
 #include <mach/devices.h>
 #include <environment.h>
-#include <partition.h>
 #include <linux/sizes.h>
 #include <io.h>
 #include <envfs.h>
 #include <globalvar.h>
 #include <linux/amba/sp804.h>
-#include <mci.h>
-
-struct vexpress_init {
-	void (*core_init)(void);
-	void (*mem_init)(void);
-	void (*console_init)(void);
-	void (*devices_init)(void);
-};
-
-struct mmci_platform_data mmci_plat = {
-	.ocr_mask	= MMC_VDD_32_33 | MMC_VDD_33_34,
-	.clkdiv_init	= SDI_CLKCR_CLKDIV_INIT,
-};
-
-struct vexpress_init *v2m_init;
-
-static void vexpress_ax_mem_init(void)
-{
-	vexpress_add_ddram(SZ_512M);
-}
 
 #define V2M_SYS_FLASH	0x03c
 
-static void vexpress_ax_devices_init(void)
-{
-	add_cfi_flash_device(0, 0x08000000, SZ_64M, 0);
-	add_cfi_flash_device(1, 0x0c000000, SZ_64M, 0);
-	vexpress_register_mmc(&mmci_plat);
-	add_generic_device("smc911x", DEVICE_ID_DYNAMIC, NULL, 0x1a000000,
-			64 * 1024, IORESOURCE_MEM, NULL);
-}
-
-static void vexpress_ax_console_init(void)
-{
-	vexpress_register_uart(0);
-	vexpress_register_uart(1);
-	vexpress_register_uart(2);
-	vexpress_register_uart(3);
-}
-
-struct vexpress_init vexpress_init_ax = {
-	.core_init = vexpress_init,
-	.mem_init = vexpress_ax_mem_init,
-	.console_init = vexpress_ax_console_init,
-	.devices_init = vexpress_ax_devices_init,
-};
-
-static void vexpress_a9_legacy_mem_init(void)
-{
-	vexpress_a9_legacy_add_ddram(SZ_512M, SZ_512M);
-}
-
-static void vexpress_a9_legacy_devices_init(void)
-{
-	add_cfi_flash_device(0, 0x40000000, SZ_64M, 0);
-	add_cfi_flash_device(1, 0x44000000, SZ_64M, 0);
-	add_generic_device("smc911x", DEVICE_ID_DYNAMIC, NULL, 0x4e000000,
-			64 * 1024, IORESOURCE_MEM, NULL);
-	vexpress_a9_legacy_register_mmc(&mmci_plat);
-	armlinux_set_architecture(MACH_TYPE_VEXPRESS);
-}
-
-static void vexpress_a9_legacy_console_init(void)
-{
-	vexpress_a9_legacy_register_uart(0);
-	vexpress_a9_legacy_register_uart(1);
-	vexpress_a9_legacy_register_uart(2);
-	vexpress_a9_legacy_register_uart(3);
-}
-
-struct vexpress_init vexpress_init_a9_legacy = {
-	.core_init = vexpress_a9_legacy_init,
-	.mem_init = vexpress_a9_legacy_mem_init,
-	.console_init = vexpress_a9_legacy_console_init,
-	.devices_init = vexpress_a9_legacy_devices_init,
-};
-
-static int vexpress_mem_init(void)
-{
-	v2m_init->mem_init();
-
-	return 0;
-}
-mem_initcall(vexpress_mem_init);
-
-static int vexpress_devices_init(void)
-{
-	writel(1, v2m_sysreg_base + V2M_SYS_FLASH);
-	v2m_init->devices_init();
-
-	devfs_add_partition("nor0", 0x00000, 0x40000, DEVFS_PARTITION_FIXED, "self");
-	devfs_add_partition("nor0", 0x40000, 0x20000, DEVFS_PARTITION_FIXED, "env0");
-
-	if (IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT_GENERIC))
-		defaultenv_append_directory(defaultenv_vexpress);
-
-	return 0;
-}
-device_initcall(vexpress_devices_init);
-
-static int vexpress_console_init(void)
-{
-	v2m_init->console_init();
-
-	return 0;
-}
-console_initcall(vexpress_console_init);
-
 static int vexpress_core_init(void)
 {
 	char *hostname = "vexpress-unknown";
 
 	if (amba_is_arm_sp804(IOMEM(0x10011000))) {
-		v2m_init = &vexpress_init_a9_legacy;
+		vexpress_a9_legacy_init();
 		hostname = "vexpress-a9-legacy";
 	} else {
-		v2m_init = &vexpress_init_ax;
+		vexpress_init();
 		if (cpu_is_cortex_a5())
 			hostname = "vexpress-a5";
 		else if (cpu_is_cortex_a7())
@@ -144,10 +38,9 @@ static int vexpress_core_init(void)
 			hostname = "vexpress-a15";
 	}
 
-	barebox_set_model("ARM Vexpress");
-	barebox_set_hostname(hostname);
+	writel(1, v2m_sysreg_base + V2M_SYS_FLASH);
 
-	v2m_init->core_init();
+	barebox_set_hostname(hostname);
 
 	return 0;
 }
diff --git a/arch/arm/boards/vexpress/lowlevel.c b/arch/arm/boards/vexpress/lowlevel.c
index 204d29d8f098..0a226b295c2a 100644
--- a/arch/arm/boards/vexpress/lowlevel.c
+++ b/arch/arm/boards/vexpress/lowlevel.c
@@ -11,12 +11,26 @@
 #include <asm/system_info.h>
 #include <linux/amba/sp804.h>
 
-void __naked barebox_arm_reset_vector(void)
+static inline void start_vexpress_common(void *internal_dt)
 {
+	void *fdt = internal_dt - get_runtime_offset();
+
 	arm_cpu_lowlevel_init();
 
 	if (amba_is_arm_sp804(IOMEM(0x10011000)))
-		barebox_arm_entry(0x60000000, SZ_512M, NULL);
+		barebox_arm_entry(0x60000000, SZ_512M, fdt);
 	else
-		barebox_arm_entry(0x80000000, SZ_512M, NULL);
+		barebox_arm_entry(0x80000000, SZ_512M, fdt);
+}
+
+extern char __dtb_vexpress_v2p_ca9_start[];
+ENTRY_FUNCTION(start_vexpress_ca9, r0, r1, r2)
+{
+	start_vexpress_common(__dtb_vexpress_v2p_ca9_start);
+}
+
+extern char __dtb_vexpress_v2p_ca15_start[];
+ENTRY_FUNCTION(start_vexpress_ca15, r0, r1, r2)
+{
+	start_vexpress_common(__dtb_vexpress_v2p_ca15_start);
 }
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index cf9d8ea9402a..b5601a61c56d 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -91,6 +91,8 @@ pbl-dtb-$(CONFIG_MACH_TURRIS_OMNIA) += armada-385-turris-omnia-bb.dtb.o
 pbl-dtb-$(CONFIG_MACH_UDOO) += imx6q-udoo.dtb.o
 pbl-dtb-$(CONFIG_MACH_USI_TOPKICK) += kirkwood-topkick-bb.dtb.o
 pbl-dtb-$(CONFIG_MACH_VARISCITE_MX6) += imx6q-var-custom.dtb.o
+pbl-dtb-$(CONFIG_MACH_VEXPRESS) += vexpress-v2p-ca9.dtb.o
+pbl-dtb-$(CONFIG_MACH_VEXPRESS) += vexpress-v2p-ca15.dtb.o
 pbl-dtb-$(CONFIG_MACH_VSCOM_BALTOS) += am335x-baltos-minimal.dtb.o
 pbl-dtb-$(CONFIG_MACH_WARP7) += imx7s-warp.dtb.o
 pbl-dtb-$(CONFIG_MACH_VF610_TWR) += vf610-twr.dtb.o
diff --git a/arch/arm/dts/vexpress-v2p-ca15.dts b/arch/arm/dts/vexpress-v2p-ca15.dts
new file mode 100644
index 000000000000..211eaccb6238
--- /dev/null
+++ b/arch/arm/dts/vexpress-v2p-ca15.dts
@@ -0,0 +1,27 @@
+#include <arm/vexpress-v2p-ca15_a7.dts>
+
+/ {
+	barebox_environment {
+		compatible = "barebox,environment";
+		device-path = &barebox_env;
+	};
+
+	smb at 8000000 {
+		motherboard {
+			flash at 0,00000000 {
+				#address-cells = <1>;
+				#size-cells = <1>;
+
+				partition at 0 {
+					label = "barebox";
+					reg = <0x0 0x80000>;
+				};
+
+				barebox_env: partition at 80000 {
+					label = "barebox-environment";
+					reg = <0x80000 0x80000>;
+				};
+			};
+		};
+	};
+};
diff --git a/arch/arm/dts/vexpress-v2p-ca9.dts b/arch/arm/dts/vexpress-v2p-ca9.dts
new file mode 100644
index 000000000000..541840ae22dc
--- /dev/null
+++ b/arch/arm/dts/vexpress-v2p-ca9.dts
@@ -0,0 +1,27 @@
+#include <arm/vexpress-v2p-ca9.dts>
+
+/ {
+	barebox_environment {
+		compatible = "barebox,environment";
+		device-path = &barebox_env;
+	};
+
+	smb at 4000000 {
+		motherboard {
+			flash at 0,00000000 {
+				#address-cells = <1>;
+				#size-cells = <1>;
+
+				partition at 0 {
+					label = "barebox";
+					reg = <0x0 0x80000>;
+				};
+
+				barebox_env: partition at 80000 {
+					label = "barebox-environment";
+					reg = <0x80000 0x80000>;
+				};
+			};
+		};
+	};
+};
diff --git a/arch/arm/mach-vexpress/Kconfig b/arch/arm/mach-vexpress/Kconfig
index 1d5e293602f6..aaa535f073a5 100644
--- a/arch/arm/mach-vexpress/Kconfig
+++ b/arch/arm/mach-vexpress/Kconfig
@@ -10,6 +10,10 @@ choice
 config MACH_VEXPRESS
 	bool "ARM Vexpress"
 	select RELOCATABLE
+	select HAVE_PBL_MULTI_IMAGES
+	select OFTREE
+	select OFDEVICE
+	select COMMON_CLK_OF_PROVIDER
 
 endchoice
 
diff --git a/arch/arm/mach-vexpress/Makefile b/arch/arm/mach-vexpress/Makefile
index 74b4a0feb2e2..9a06e648a6f1 100644
--- a/arch/arm/mach-vexpress/Makefile
+++ b/arch/arm/mach-vexpress/Makefile
@@ -1,3 +1,2 @@
 obj-y += v2m.o
-obj-y += devices.o
 obj-y += reset.o
diff --git a/arch/arm/mach-vexpress/devices.c b/arch/arm/mach-vexpress/devices.c
deleted file mode 100644
index 5b530119245d..000000000000
--- a/arch/arm/mach-vexpress/devices.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnio at jcrosoft.com>
- *
- * GPLv2 only
- */
-
-#include <common.h>
-
-#include <linux/amba/bus.h>
-
-#include <asm/memory.h>
-
-#include <mach/devices.h>
-
-void vexpress_a9_legacy_add_ddram(u32 ddr0_size, u32 ddr1_size)
-{
-	arm_add_mem_device("ram0", 0x60000000, ddr0_size);
-
-	if (ddr1_size)
-		arm_add_mem_device("ram1", 0x80000000, ddr1_size);
-}
-
-void vexpress_a9_legacy_register_uart(unsigned id)
-{
-	resource_size_t start;
-
-	switch (id) {
-	case 0:
-		start = 0x10009000;
-		break;
-	case 1:
-		start = 0x1000a000;
-		break;
-	case 2:
-		start = 0x1000b000;
-		break;
-	case 3:
-		start = 0x1000c000;
-		break;
-	default:
-		return;
-	}
-	amba_apb_device_add(NULL, "uart-pl011", id, start, 4096, NULL, 0);
-}
-
-void vexpress_a9_legacy_register_mmc(struct mmci_platform_data *plat)
-{
-	amba_apb_device_add(NULL, "mmci-pl18x", DEVICE_ID_SINGLE, 0x10005000,
-	4096, plat, 0);
-}
-
-void vexpress_add_ddram(u32 size)
-{
-	arm_add_mem_device("ram1", 0x80000000, size);
-}
-
-void vexpress_register_uart(unsigned id)
-{
-	resource_size_t start;
-
-	switch (id) {
-	case 0:
-		start = 0x1c090000;
-		break;
-	case 1:
-		start = 0x1c0a0000;
-		break;
-	case 2:
-		start = 0x1c0b0000;
-		break;
-	case 3:
-		start = 0x1c0c0000;
-		break;
-	default:
-		return;
-	}
-	amba_apb_device_add(NULL, "uart-pl011", id, start, 4096, NULL, 0);
-}
-
-void vexpress_register_mmc(struct mmci_platform_data *plat)
-{
-	amba_apb_device_add(NULL, "mmci-pl18x", DEVICE_ID_SINGLE, 0x1c050000, 4096, plat, 0);
-}
diff --git a/arch/arm/mach-vexpress/include/mach/devices.h b/arch/arm/mach-vexpress/include/mach/devices.h
index 96d14005017e..bef8c8b94fb9 100644
--- a/arch/arm/mach-vexpress/include/mach/devices.h
+++ b/arch/arm/mach-vexpress/include/mach/devices.h
@@ -9,18 +9,9 @@
 
 #include <linux/amba/mmci.h>
 
-void vexpress_a9_legacy_add_ddram(u32 ddr0_size, u32 ddr1_size);
-void vexpress_add_ddram(u32 size);
-
-void vexpress_a9_legacy_register_uart(unsigned id);
-void vexpress_register_uart(unsigned id);
-
 void vexpress_a9_legacy_init(void);
 void vexpress_init(void);
 
-void vexpress_a9_legacy_register_mmc(struct mmci_platform_data *plat);
-void vexpress_register_mmc(struct mmci_platform_data *plat);
-
 extern void *v2m_wdt_base;
 extern void *v2m_sysreg_base;
 
diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
index 025bbb17fc6e..35352628482c 100644
--- a/arch/arm/mach-vexpress/v2m.c
+++ b/arch/arm/mach-vexpress/v2m.c
@@ -19,31 +19,6 @@
 
 void __iomem *v2m_sysreg_base;
 
-static const char *v2m_osc2_periphs[] = {
-	"mb:mmci",  "mmci-pl18x",	/* PL180 MMCI */
-	"mb:uart0", "uart-pl0110",	/* PL011 UART0 */
-	"mb:uart1", "uart-pl0111",	/* PL011 UART1 */
-	"mb:uart2", "uart-pl0112",	/* PL011 UART2 */
-	"mb:uart3", "uart-pl0113",	/* PL011 UART3 */
-};
-
-static void v2m_clk_init(void)
-{
-	struct clk *clk;
-	int i;
-
-	clk = clk_fixed("dummy_apb_pclk", 0);
-	clk_register_clkdev(clk, "apb_pclk", NULL);
-
-	clk = clk_fixed("mb:sp804_clk", 1000000);
-	clk_register_clkdev(clk, NULL, "sp804");
-
-	clk = clk_fixed("mb:osc2", 24000000);
-	for (i = 0; i < ARRAY_SIZE(v2m_osc2_periphs); i++)
-		clk_register_clkdev(clk, NULL, v2m_osc2_periphs[i]);
-
-}
-
 static void v2m_sysctl_init(void __iomem *base)
 {
 	u32 scctrl;
@@ -58,21 +33,11 @@ static void v2m_sysctl_init(void __iomem *base)
 	writel(scctrl, base + SCCTRL);
 }
 
-static void __init v2m_sp804_init(void __iomem *base)
-{
-	writel(0, base + TIMER_1_BASE + TIMER_CTRL);
-
-	amba_apb_device_add(NULL, "sp804", DEVICE_ID_SINGLE, (resource_size_t)base, 4096, NULL, 0);
-}
-
 void vexpress_a9_legacy_init(void)
 {
 	v2m_wdt_base = IOMEM(0x1000f000);
 	v2m_sysreg_base = IOMEM(0x10001000);
 	v2m_sysctl_init(IOMEM(0x10001000));
-	v2m_clk_init();
-
-	v2m_sp804_init(IOMEM(0x10011000));
 }
 
 void vexpress_init(void)
@@ -80,7 +45,4 @@ void vexpress_init(void)
 	v2m_wdt_base = IOMEM(0x1c0f0000);
 	v2m_sysreg_base = IOMEM(0x1c020000);
 	v2m_sysctl_init(IOMEM(0x1c020000));
-	v2m_clk_init();
-
-	v2m_sp804_init(IOMEM(0x1c110000));
 }
diff --git a/images/Makefile b/images/Makefile
index 705c8ad03eda..5c4d99ac5add 100644
--- a/images/Makefile
+++ b/images/Makefile
@@ -111,6 +111,7 @@ include $(srctree)/images/Makefile.omap3
 include $(srctree)/images/Makefile.rockchip
 include $(srctree)/images/Makefile.socfpga
 include $(srctree)/images/Makefile.tegra
+include $(srctree)/images/Makefile.vexpress
 include $(srctree)/images/Makefile.at91
 
 targets += $(image-y) pbl.lds barebox.x barebox.z
diff --git a/images/Makefile.vexpress b/images/Makefile.vexpress
new file mode 100644
index 000000000000..0f12dc12a534
--- /dev/null
+++ b/images/Makefile.vexpress
@@ -0,0 +1,11 @@
+#
+# barebox image generation Makefile for VExpress images
+#
+
+pblx-$(CONFIG_MACH_VEXPRESS) += start_vexpress_ca9
+FILE_barebox-vexpress-ca9.img = start_vexpress_ca9.pblx
+image-$(CONFIG_MACH_VEXPRESS) += barebox-vexpress-ca9.img
+
+pblx-$(CONFIG_MACH_VEXPRESS) += start_vexpress_ca15
+FILE_barebox-vexpress-ca15.img = start_vexpress_ca15.pblx
+image-$(CONFIG_MACH_VEXPRESS) += barebox-vexpress-ca15.img
-- 
2.11.0




More information about the barebox mailing list