dts: Added support for multiple dtbs in u-boot

dtbs are made as .o
a table specifying their machid and address is added
the dtbs and header are added to u-boot image in a seperate section
dtb will be chosen based on machid detected from SMEM

Change-Id: I50ac5b56da3a431c1a75cb9fc113fafaedbc09b8
Signed-off-by: Manoharan Vijaya Raghavan <mraghava@codeaurora.org>
This commit is contained in:
Manoharan Vijaya Raghavan 2016-06-21 17:52:04 +05:30 committed by Gerrit - the friendly Code Review server
parent 2a8bb9d7d7
commit 184e49acc6
8 changed files with 105 additions and 26 deletions

View file

@ -630,7 +630,7 @@ HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makef
libs-y += lib/
libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
libs-$(CONFIG_OF_EMBED) += dts/
libs-$(CONFIG_OF_COMBINE) += dts/
libs-$(CONFIG_OF_COMBINE) += arch/$(ARCH)/dts/
libs-y += fs/
libs-y += net/
libs-y += disk/
@ -753,7 +753,9 @@ endif
ALL-$(CONFIG_SPL) += spl/u-boot-spl.bin
ALL-$(CONFIG_SPL_FRAMEWORK) += u-boot.img
ALL-$(CONFIG_TPL) += tpl/u-boot-tpl.bin
ifeq ($(CONFIG_OF_COMBINE),)
ALL-$(CONFIG_OF_SEPARATE) += u-boot.dtb u-boot-dtb.bin
endif
ifeq ($(CONFIG_SPL_FRAMEWORK),y)
ALL-$(CONFIG_OF_SEPARATE) += u-boot-dtb.img
endif

View file

@ -78,6 +78,13 @@ SECTIONS
*(.data*)
}
#ifdef CONFIG_OF_COMBINE
. = ALIGN(4);
.dtb : {
KEEP(*(.dtb.combine*));
}
#endif
. = ALIGN(4);
. = .;
@ -144,13 +151,6 @@ SECTIONS
KEEP(*(.__bss_end));
}
#ifdef CONFIG_OF_COMBINE
. = ALIGN(4);
. = CONFIG_DTB_LOAD_ADDR;
.dtb : {
KEEP(*(.dtb.combine*));
}
#endif
.dynsym _image_binary_end : { *(.dynsym) }
.dynbss : { *(.dynbss) }
.dynstr : { *(.dynstr*) }

View file

@ -205,7 +205,22 @@ targets += $(dtb-y)
DTC_FLAGS +=
PHONY += dtbs
dtbs: $(addprefix $(obj)/, $(dtb-y))
ifneq ($(CONFIG_OF_COMBINE),)
%(obj)/%.dtb.comb.S: %(obj)/%.dtb
@:
clean-files := *.dtb
$(obj)/dtbtable.S: $(addsuffix .comb.o, $(addprefix $(obj)/, $(dtb-y)))
@:
obj-y := dtbtable.o $(addsuffix .comb.o, $(dtb-y))
targets += obj-$(CONFIG_OF_EMBED)
else
dtbs: $(addprefix $(obj)/, $(dtb-y))
@:
endif
clean-files := *.dtb *.o *.S

View file

@ -16,6 +16,7 @@
/ {
model ="QCA, IPQ807x-HK01";
compatible = "qca,ipq807x", "qca,ipq807x-hk01";
machid = <0x01010000>;
aliases {
console = "/serial@78af000";

View file

@ -37,16 +37,12 @@ arch-dtbs:
.SECONDARY: $(obj)/dt.dtb.S
.SECONDARY: $(obj)/dt_comb.dtb.S
obj-$(CONFIG_OF_EMBED) := dt.dtb.o
obj-$(CONFIG_OF_COMBINE) := dt_comb.dtb.o
dtbs: $(obj)/dt.dtb
@:
clean-files := dt.dtb.S dt_comb.dtb.S
clean-files := dt.dtb.S
# Let clean descend into dts directories
subdir- += ../arch/arm/dts ../arch/microblaze/dts ../arch/sandbox/dts ../arch/x86/dts

View file

@ -86,10 +86,7 @@
#define CONFIG_OF_COMBINE 1
#define CONFIG_DTB_LOAD_ADDR 0x4AE00000
#define CONFIG_EXTRA_ENV_SETTINGS "fdtcontroladdr=0x4AE00000\0"
#define CONFIG_QCA_SMEM_BASE 0x41000000
#define CONFIG_QCA_SMEM_BASE 0x4AB00000
/*
* SPI Flash Configs
*/

View file

@ -11,6 +11,7 @@
#include <fdtdec.h>
#include <asm/sections.h>
#include <linux/ctype.h>
#include <asm/arch-qcom-common/smem.h>
DECLARE_GLOBAL_DATA_PTR;
@ -1212,6 +1213,39 @@ int fdtdec_decode_display_timing(const void *blob, int parent, int index,
return 0;
}
#ifdef CONFIG_OF_COMBINE
extern unsigned long __dtb_table_start;
struct dtb_combined_hdr {
unsigned long machid;
unsigned long dtbaddr;
};
static int parse_combined_fdt(unsigned long machid)
{
unsigned long *ptr = NULL;
struct dtb_combined_hdr *fdt_table;
unsigned long ndtbs = 0;
ptr = &__dtb_table_start;
ndtbs = *ptr;
ptr++;
fdt_table = (struct dtb_combined_hdr *)ptr;
while(ndtbs && (fdt_table->machid != machid)) {
fdt_table++;
ndtbs--;
}
if(ndtbs == 0)
hang();
return fdt_table->dtbaddr;
}
#endif
int fdtdec_setup(void)
{
#if CONFIG_IS_ENABLED(OF_CONTROL)
@ -1226,8 +1260,13 @@ int fdtdec_setup(void)
else
gd->fdt_blob = (ulong *)&__bss_end;
# else
#ifdef CONFIG_OF_COMBINE
gd->fdt_blob = (ulong *)
parse_combined_fdt(smem_get_board_platform_type());
#else
/* FDT is at end of image */
gd->fdt_blob = (ulong *)&_end;
#endif
# endif
# elif defined(CONFIG_OF_HOSTFILE)
if (sandbox_read_fdt_from_file()) {

View file

@ -289,15 +289,44 @@ $(obj)/%.dtb.S: $(obj)/%.dtb
# Generate an assembly file to wrap the output of the device tree compiler
quiet_cmd_dt_comb_S_dtb= DTB_COMB $@
# Modified for U-Boot Combined ELF
#get the Magic
cmd_dt_comb_S_dtb= \
dtbmachid=`cat "$(obj)/$(*F).dts" | grep machid | \
cut -f 2 -d '<' | cut -f 1 -d '>'` ; \
if [ -e $$dtbmachid ]; \
then \
echo "Need to specify \"machid\" in dts $(obj)/$(*F).dts "; \
exit 1; \
fi; \
machiddec=`printf %d $$dtbmachid`; \
if [ ! -f $(obj)/dtbtable.S ]; \
then \
echo ".section .dtb.combine_table,\"a\"" > $(obj)/dtbtable.S; \
echo ".balign 16" >> $(obj)/dtbtable.S; \
echo ".global __dtb_table_start" >> $(obj)/dtbtable.S; \
echo "__dtb_table_start:" >> $(obj)/dtbtable.S; \
echo ".word 0" >> $(obj)/dtbtable.S; \
fi; \
echo ".extern __dtb_begin_$$machiddec " >> $(obj)/dtbtable.S ; \
echo ".word $$machiddec" >> $(obj)/dtbtable.S ; \
echo ".word __dtb_begin_$$machiddec " >> $(obj)/dtbtable.S ; \
num=`cat $(obj)/dtbtable.S | head -n 5 | tail -n 1 | cut -f 2 -d ' '`; \
num=$$(expr $$num + 1); \
sed -i '5 d' $(obj)/dtbtable.S; \
sed -i "5 i .word $$num" $(obj)/dtbtable.S; \
( \
echo '.section .dtb.combine,"a"'; \
dtbmachid=`cat "$(obj)/$(*F).dts" | grep machid | \
cut -f 2 -d '<' | cut -f 1 -d '>'` ; \
machiddec=`printf %d $$dtbmachid`; \
echo ".section .dtb.combine_$$machiddec,\"a\""; \
echo '.balign 16'; \
echo ".global __dtb_begin_$$machiddec"; \
echo "__dtb_begin_$$machiddec:"; \
echo '.incbin "$<" '; \
echo '.balign 16'; \
) > $@
$(obj)/%_comb.dtb.S: $(obj)/%.dtb
$(obj)/%.dtb.comb.S: $(obj)/%.dtb
$(call cmd,dt_comb_S_dtb)