devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] OF: Add support for built in FDT blob
@ 2014-11-07 11:14 Alban Bedel
       [not found] ` <1415358849-25879-1-git-send-email-albeu-GANU6spQydw@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Alban Bedel @ 2014-11-07 11:14 UTC (permalink / raw)
  To: devicetree; +Cc: linux-kernel, Rob Herring, Grant Likely

Allow embedding an FDT blob in the kernel image, this is mostly
useful to run new kernels on boards with old bootloaders.

Signed-off-by: Alban Bedel <albeu@free.fr>
---
 drivers/of/Kconfig    | 16 ++++++++++++++++
 drivers/of/Makefile   |  8 ++++++++
 drivers/of/fdt.c      |  8 ++++++++
 drivers/of/fdt_blob.S | 17 +++++++++++++++++
 4 files changed, 49 insertions(+)
 create mode 100644 drivers/of/fdt_blob.S

diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index 1a13f5b..97c5d18 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -83,4 +83,20 @@ config OF_RESERVED_MEM
 config OF_RESOLVE
 	bool
 
+config OF_BUILTIN_FDT
+	bool "Include a FDT blob in the kernel"
+	help
+	  Include a FDT blob in the kernel to use as default when
+	  no blob has been passed by the bootloader. This is useful
+	  to use devicetree on boards with old bootloaders.
+
+	  If unsure, say N.
+
+config OF_BUILTIN_FDT_BLOB
+	string "FDT Blob name"
+	depends on OF_BUILTIN_FDT
+	help
+	  Name of the FDT blob to build in the kernel, from one of the
+	  dtbs available for the current platform.
+
 endmenu # OF
diff --git a/drivers/of/Makefile b/drivers/of/Makefile
index ca9209c..b96c6e9 100644
--- a/drivers/of/Makefile
+++ b/drivers/of/Makefile
@@ -14,6 +14,14 @@ obj-$(CONFIG_OF_PCI_IRQ)  += of_pci_irq.o
 obj-$(CONFIG_OF_MTD)	+= of_mtd.o
 obj-$(CONFIG_OF_RESERVED_MEM) += of_reserved_mem.o
 obj-$(CONFIG_OF_RESOLVE)  += resolver.o
+obj-$(CONFIG_OF_BUILTIN_FDT) += fdt_blob.o
 
 CFLAGS_fdt.o = -I$(src)/../../scripts/dtc/libfdt
 CFLAGS_fdt_address.o = -I$(src)/../../scripts/dtc/libfdt
+
+# The FDT blob to include
+FDT_BLOB := arch/$(ARCH)/boot/dts/$(CONFIG_OF_BUILTIN_FDT_BLOB:"%"=%).dtb
+# Undefine ARCH to avoid breaking the FDT path
+AFLAGS_fdt_blob.o += -U$(ARCH) -DFDT_BLOB=$(FDT_BLOB)
+# This dependency can't be automatically tracked
+$(obj)/fdt_blob.o: $(obj)/../../$(FDT_BLOB)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index d1ffca8..ffb86a7 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -26,6 +26,9 @@
 #include <asm/setup.h>  /* for COMMAND_LINE_SIZE */
 #include <asm/page.h>
 
+extern char __fdt_blob_start[];
+extern unsigned long __fdt_blob_size;
+
 /*
  * of_fdt_limit_memory - limit the number of regions in the /memory node
  * @limit: maximum entries
@@ -1064,6 +1067,11 @@ void __init unflatten_and_copy_device_tree(void)
 	int size;
 	void *dt;
 
+#ifdef CONFIG_OF_BUILTIN_FDT
+	if (!initial_boot_params && __fdt_blob_size > 0)
+		initial_boot_params = __fdt_blob_start;
+#endif
+
 	if (!initial_boot_params) {
 		pr_warn("No valid device tree found, continuing without\n");
 		return;
diff --git a/drivers/of/fdt_blob.S b/drivers/of/fdt_blob.S
new file mode 100644
index 0000000..fcaa2aa
--- /dev/null
+++ b/drivers/of/fdt_blob.S
@@ -0,0 +1,17 @@
+#include <linux/stringify.h>
+#include <asm-generic/vmlinux.lds.h>
+
+.align 4
+.section .init.fdt_blob,"a"
+.globl VMLINUX_SYMBOL(__fdt_blob_start)
+VMLINUX_SYMBOL(__fdt_blob_start):
+.incbin __stringify(FDT_BLOB)
+__fdt_blob_end:
+.section .init.fdt_blob.info,"a"
+.globl VMLINUX_SYMBOL(__fdt_blob_size)
+VMLINUX_SYMBOL(__fdt_blob_size):
+#ifdef CONFIG_64BIT
+        .quad __fdt_blob_end - __fdt_blob_start
+#else
+        .long __fdt_blob_end - __fdt_blob_start
+#endif
-- 
2.0.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-11-18 22:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-07 11:14 [PATCH] OF: Add support for built in FDT blob Alban Bedel
     [not found] ` <1415358849-25879-1-git-send-email-albeu-GANU6spQydw@public.gmane.org>
2014-11-07 12:09   ` Mark Rutland
2014-11-07 12:59     ` Alban
2014-11-07 14:56       ` Rob Herring
     [not found]         ` <CAL_Jsq+n8owZz6yas=surm4fTaGWgUuCLLEKXYKm8_02S8DdYA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-07 16:47           ` Mark Rutland
2014-11-18 22:16   ` Grant Likely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).