From e8b04535ada9930497c8673809c000a81d597f36 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Sun, 20 Mar 2016 14:41:54 +0000 Subject: [PATCH] lantiq: use upstream mechanism to append device tree file Instead of using our patch-dtb program just place the device tree behind the kernel binary and then let the in kernel mechanism fetch it. This also adds support for having the device tree file in the boot loader. Signed-off-by: Hauke Mehrtens SVN-Revision: 49050 --- target/linux/lantiq/config-4.4 | 8 ++-- target/linux/lantiq/image/Makefile | 4 +- .../0002-MIPS-lantiq-dtb-image-hack.patch | 31 ------------ .../0036-owrt-generic-dtb-image-hack.patch | 32 ------------- ...support-for-device-tree-file-from-bo.patch | 48 +++++++++++++++++++ ...-it-possible-to-build-in-no-device-t.patch | 37 ++++++++++++++ 6 files changed, 91 insertions(+), 69 deletions(-) delete mode 100644 target/linux/lantiq/patches-4.4/0002-MIPS-lantiq-dtb-image-hack.patch delete mode 100644 target/linux/lantiq/patches-4.4/0036-owrt-generic-dtb-image-hack.patch create mode 100644 target/linux/lantiq/patches-4.4/0120-MIPS-lantiq-add-support-for-device-tree-file-from-bo.patch create mode 100644 target/linux/lantiq/patches-4.4/0121-MIPS-lantiq-make-it-possible-to-build-in-no-device-t.patch diff --git a/target/linux/lantiq/config-4.4 b/target/linux/lantiq/config-4.4 index 5d4b7cc815..cf3ec47429 100644 --- a/target/linux/lantiq/config-4.4 +++ b/target/linux/lantiq/config-4.4 @@ -38,7 +38,7 @@ CONFIG_CRYPTO_WORKQUEUE=y CONFIG_CSRC_R4K=y CONFIG_DMA_NONCOHERENT=y CONFIG_DTC=y -CONFIG_DT_EASY50712=y +# CONFIG_DT_EASY50712 is not set CONFIG_EARLY_PRINTK=y CONFIG_ETHERNET_PACKET_MANGLE=y CONFIG_GENERIC_ATOMIC64=y @@ -108,6 +108,7 @@ CONFIG_IRQ_FORCED_THREADING=y CONFIG_IRQ_MIPS_CPU=y CONFIG_IRQ_WORK=y CONFIG_LANTIQ=y +CONFIG_LANTIQ_DT_NONE=y CONFIG_LANTIQ_ETOP=y # CONFIG_LANTIQ_PHY is not set CONFIG_LANTIQ_WDT=y @@ -125,8 +126,8 @@ CONFIG_MIPS_CMDLINE_FROM_DTB=y CONFIG_MIPS_L1_CACHE_SHIFT=5 # CONFIG_MIPS_MACHINE is not set # CONFIG_MIPS_MT_SMP is not set -CONFIG_MIPS_NO_APPENDED_DTB=y -# CONFIG_MIPS_RAW_APPENDED_DTB is not set +# CONFIG_MIPS_NO_APPENDED_DTB is not set +CONFIG_MIPS_RAW_APPENDED_DTB=y CONFIG_MIPS_SPRAM=y # CONFIG_MIPS_VPE_LOADER is not set CONFIG_MODULES_USE_ELF_REL=y @@ -187,7 +188,6 @@ CONFIG_SPI=y CONFIG_SPI_LANTIQ=y CONFIG_SPI_MASTER=y CONFIG_SRCU=y -# CONFIG_SUNXI_SRAM is not set CONFIG_SWAP_IO_SPACE=y CONFIG_SWCONFIG=y CONFIG_SYSCTL_EXCEPTION_TRACE=y diff --git a/target/linux/lantiq/image/Makefile b/target/linux/lantiq/image/Makefile index 882fba80f8..c3cb48afdf 100644 --- a/target/linux/lantiq/image/Makefile +++ b/target/linux/lantiq/image/Makefile @@ -32,8 +32,8 @@ endef define PatchKernelLzma cp $(KDIR)/vmlinux$(2) $(KDIR)/vmlinux$(2)-$(1) $(LINUX_DIR)/scripts/dtc/dtc -O dtb -o $(KDIR)/$(1).dtb ../dts/$(1).dts - $(STAGING_DIR_HOST)/bin/patch-dtb $(KDIR)/vmlinux$(2)-$(1) $(KDIR)/$(1).dtb - $(call CompressLzma,$(KDIR)/vmlinux$(2)-$(1),$(KDIR)/vmlinux$(2)-$(1).lzma) + cat $(KDIR)/vmlinux$(2)-$(1) $(KDIR)/$(1).dtb > $(KDIR)/vmlinux$(2)-$(1).tmp + $(call CompressLzma,$(KDIR)/vmlinux$(2)-$(1).tmp,$(KDIR)/vmlinux$(2)-$(1).lzma) endef define MkBrnImage diff --git a/target/linux/lantiq/patches-4.4/0002-MIPS-lantiq-dtb-image-hack.patch b/target/linux/lantiq/patches-4.4/0002-MIPS-lantiq-dtb-image-hack.patch deleted file mode 100644 index 89a498d4c7..0000000000 --- a/target/linux/lantiq/patches-4.4/0002-MIPS-lantiq-dtb-image-hack.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 17348293f7f8103c97c8d2a6b0ef36eae06ec371 Mon Sep 17 00:00:00 2001 -From: John Crispin -Date: Wed, 13 Mar 2013 09:36:16 +0100 -Subject: [PATCH 02/36] MIPS: lantiq: dtb image hack - -Signed-off-by: John Crispin ---- - arch/mips/lantiq/Makefile | 2 -- - arch/mips/lantiq/prom.c | 4 +++- - 2 files changed, 3 insertions(+), 3 deletions(-) - ---- a/arch/mips/lantiq/prom.c -+++ b/arch/mips/lantiq/prom.c -@@ -63,6 +63,8 @@ static void __init prom_init_cmdline(voi - } - } - -+extern struct boot_param_header __image_dtb; -+ - void __init plat_mem_setup(void) - { - ioport_resource.start = IOPORT_RESOURCE_START; -@@ -76,7 +78,7 @@ void __init plat_mem_setup(void) - * Load the builtin devicetree. This causes the chosen node to be - * parsed resulting in our memory appearing - */ -- __dt_setup_arch(__dtb_start); -+ __dt_setup_arch(&__image_dtb); - } - - void __init device_tree_init(void) diff --git a/target/linux/lantiq/patches-4.4/0036-owrt-generic-dtb-image-hack.patch b/target/linux/lantiq/patches-4.4/0036-owrt-generic-dtb-image-hack.patch deleted file mode 100644 index 7a306b301e..0000000000 --- a/target/linux/lantiq/patches-4.4/0036-owrt-generic-dtb-image-hack.patch +++ /dev/null @@ -1,32 +0,0 @@ -From dba8578e06aedf1e67312ebfc6162e2fadc9448d Mon Sep 17 00:00:00 2001 -From: John Crispin -Date: Thu, 7 Aug 2014 18:32:12 +0200 -Subject: [PATCH 36/36] owrt: generic dtb image hack - -Signed-off-by: John Crispin ---- - arch/mips/kernel/head.S | 3 +++ - 1 file changed, 3 insertions(+) - ---- a/arch/mips/kernel/head.S -+++ b/arch/mips/kernel/head.S -@@ -86,6 +86,9 @@ EXPORT(__image_cmdline) - .fill 0x400 - #endif /* CONFIG_IMAGE_CMDLINE_HACK */ - -+ .ascii "OWRTDTB:" -+ EXPORT(__image_dtb) -+ .fill 0x4000 - __REF - - NESTED(kernel_entry, 16, sp) # kernel entry point ---- a/arch/mips/lantiq/Kconfig -+++ b/arch/mips/lantiq/Kconfig -@@ -32,7 +32,6 @@ choice - config DT_EASY50712 - bool "Easy50712" - depends on SOC_XWAY -- select BUILTIN_DTB - endchoice - - config PCI_LANTIQ diff --git a/target/linux/lantiq/patches-4.4/0120-MIPS-lantiq-add-support-for-device-tree-file-from-bo.patch b/target/linux/lantiq/patches-4.4/0120-MIPS-lantiq-add-support-for-device-tree-file-from-bo.patch new file mode 100644 index 0000000000..3c6fa238b2 --- /dev/null +++ b/target/linux/lantiq/patches-4.4/0120-MIPS-lantiq-add-support-for-device-tree-file-from-bo.patch @@ -0,0 +1,48 @@ +From a32285ed4ba970b868b7fb49b716d776f4410ef6 Mon Sep 17 00:00:00 2001 +From: Hauke Mehrtens +Date: Sat, 19 Mar 2016 16:52:46 +0100 +Subject: [PATCH] MIPS: lantiq: add support for device tree file from boot + loader + +This fetches the device tree file like it is specified in the MIPS UHI +interface if one was found. This is also used when the device tree file +was appended to the kernel image with cat. +This code is copied from arch/mips/bmips/setup.c. + +Signed-off-by: Hauke Mehrtens +--- + arch/mips/lantiq/prom.c | 13 +++++++++++-- + 1 file changed, 11 insertions(+), 2 deletions(-) + +--- a/arch/mips/lantiq/prom.c ++++ b/arch/mips/lantiq/prom.c +@@ -65,6 +65,8 @@ static void __init prom_init_cmdline(voi + + void __init plat_mem_setup(void) + { ++ void *dtb; ++ + ioport_resource.start = IOPORT_RESOURCE_START; + ioport_resource.end = IOPORT_RESOURCE_END; + iomem_resource.start = IOMEM_RESOURCE_START; +@@ -72,11 +74,18 @@ void __init plat_mem_setup(void) + + set_io_port_base((unsigned long) KSEG1); + ++ if (fw_arg0 == -2) /* UHI interface */ ++ dtb = (void *)fw_arg1; ++ else if (__dtb_start != __dtb_end) ++ dtb = (void *)__dtb_start; ++ else ++ panic("no dtb found"); ++ + /* +- * Load the builtin devicetree. This causes the chosen node to be ++ * Load the devicetree. This causes the chosen node to be + * parsed resulting in our memory appearing + */ +- __dt_setup_arch(__dtb_start); ++ __dt_setup_arch(dtb); + } + + void __init device_tree_init(void) diff --git a/target/linux/lantiq/patches-4.4/0121-MIPS-lantiq-make-it-possible-to-build-in-no-device-t.patch b/target/linux/lantiq/patches-4.4/0121-MIPS-lantiq-make-it-possible-to-build-in-no-device-t.patch new file mode 100644 index 0000000000..2b7b6f1ba0 --- /dev/null +++ b/target/linux/lantiq/patches-4.4/0121-MIPS-lantiq-make-it-possible-to-build-in-no-device-t.patch @@ -0,0 +1,37 @@ +From 8cfe01de7d5c974165c1383fcc9e1dad6953341d Mon Sep 17 00:00:00 2001 +From: Hauke Mehrtens +Date: Sat, 19 Mar 2016 17:06:00 +0100 +Subject: [PATCH 2/2] MIPS: lantiq: make it possible to build in no device tree + +Now it is possible to build in no device tree at all and depend on the +boot loader providing one or someone concatenating a device tree to the +end of the image. + +This was copied from arch/mips/bmips/Kconfig + +Signed-off-by: Hauke Mehrtens +--- + arch/mips/lantiq/Kconfig | 12 +++++++++++- + 1 file changed, 11 insertions(+), 1 deletion(-) + +--- a/arch/mips/lantiq/Kconfig ++++ b/arch/mips/lantiq/Kconfig +@@ -27,7 +27,17 @@ config SOC_FALCON + endchoice + + choice +- prompt "Devicetree" ++ prompt "Built-in device tree" ++ help ++ Legacy bootloaders do not pass a DTB pointer to the kernel, so ++ if a "wrapper" is not being used, the kernel will need to include ++ a device tree that matches the target board. ++ ++ The builtin DTB will only be used if the firmware does not supply ++ a valid DTB. ++ ++config LANTIQ_DT_NONE ++ bool "None" + + config DT_EASY50712 + bool "Easy50712" -- 2.30.2