summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2011-05-10 11:59:04 -0700
committerSimon Glass <sjg@chromium.org>2011-08-24 10:01:31 -0700
commit20d8fe039fa7732aa71f1360adadfb6753687f8d (patch)
tree0d3c689503990f113eef69603cd30d9f78736b5e
parentfba3cfb94552efe566dbb2b1e595ec236c91b168 (diff)
fdt: Add support for embedded device tree (CONFIG_OF_EMBED)
This new option allows U-Boot to embed a binary device tree into its image to allow run-time control of peripherals. This device tree is for U-Boot's own use and is not necessarily the same one as is passed to the kernel. BUG=chromium-os:11623 TEST=build and boot U-Boot on Seaboard Change-Id: I024d01079a44395e122a8b53e3901ba9a007dc5a Reviewed-on: http://gerrit.chromium.org/gerrit/621 Reviewed-by: Doug Anderson <dianders@chromium.org> Tested-by: Simon Glass <sjg@chromium.org>
-rw-r--r--Makefile4
-rw-r--r--README11
-rw-r--r--arch/arm/lib/board.c7
-rw-r--r--config.mk1
-rw-r--r--dts/Makefile60
-rw-r--r--dts/README39
-rwxr-xr-xmkconfig5
7 files changed, 124 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index ac9776fdd58..2af059c0a6c 100644
--- a/Makefile
+++ b/Makefile
@@ -225,6 +225,9 @@ endif
ifeq ($(CPU),ixp)
LIBS += arch/arm/cpu/ixp/npe/libnpe.o
endif
+ifeq ($(CONFIG_OF_EMBED),y)
+LIBS += dts/dt.o
+endif
LIBS += arch/$(ARCH)/lib/lib$(ARCH).o
LIBS += fs/cramfs/libcramfs.o fs/fat/libfat.o fs/fdos/libfdos.o fs/jffs2/libjffs2.o \
fs/reiserfs/libreiserfs.o fs/ext2/libext2fs.o fs/yaffs2/libyaffs2.o \
@@ -1105,6 +1108,7 @@ clean:
@rm -f $(ONENAND_BIN)
@rm -f $(obj)onenand_ipl/u-boot.lds
@rm -f $(TIMESTAMP_FILE) $(VERSION_FILE)
+ @rm -f $(obj)dts/dt.dtb
@find $(OBJTREE) -type f \
\( -name 'core' -o -name '*.bak' -o -name '*~' \
-o -name '*.o' -o -name '*.a' -o -name '*.exe' \) -print \
diff --git a/README b/README
index c691fa7d0b9..0ab760bc5bc 100644
--- a/README
+++ b/README
@@ -754,8 +754,15 @@ The following options need to be configured:
experimental and only available on a few boards. The device
tree is available in the global data as gd->blob.
- U-Boot needs to get its device tree from somewhere. This will
- be enabled in a future patch.
+ U-Boot needs to get its device tree from somewhere. At present
+ the only way is to embed it in the image with CONFIG_OF_EMBED.
+
+ CONFIG_OF_EMBED
+ If this variable is defined, U-Boot will embed a device tree
+ binary in its image. This device tree file should be in the
+ board directory and called <soc>-<board>.dts. The binary file
+ is then picked up in board_init_f() and made available through
+ the global data structure as gd->blob.
- Watchdog:
CONFIG_WATCHDOG
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index c89fdd0fc17..24f4f0ccd09 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -270,6 +270,9 @@ void board_init_f (ulong bootflag)
init_fnc_t **init_fnc_ptr;
gd_t *id;
ulong addr, addr_sp;
+#ifdef CONFIG_OF_EMBED
+ extern u8 _binary_dt_dtb_start[];
+#endif
#ifdef CONFIG_TEGRA2
/*
@@ -290,6 +293,10 @@ void board_init_f (ulong bootflag)
memset ((void*)gd, 0, sizeof (gd_t));
gd->mon_len = _bss_end_ofs;
+#ifdef CONFIG_OF_EMBED
+ /* Get a pointer to the FDT */
+ gd->blob = _binary_dt_dtb_start;
+#endif
for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
if ((*init_fnc_ptr)() != 0) {
diff --git a/config.mk b/config.mk
index a0ee570acd5..7faaeab49bd 100644
--- a/config.mk
+++ b/config.mk
@@ -112,6 +112,7 @@ STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
RANLIB = $(CROSS_COMPILE)RANLIB
+DTC = dtc
#########################################################################
diff --git a/dts/Makefile b/dts/Makefile
new file mode 100644
index 00000000000..986a6b3ee30
--- /dev/null
+++ b/dts/Makefile
@@ -0,0 +1,60 @@
+#
+# Copyright (c) 2011 The Chromium OS Authors.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundatio; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB = $(obj)libdts.o
+
+# Use a constant name for this so we can access it from C code.
+# objcopy doesn't seem to allow us to set the symbol name independently of
+# the filename.
+DT_BIN := dt.dtb
+
+# TODO: get arch properly for objcopy line.
+dt.o: $(TOPDIR)/board/$(BOARDDIR)/$(DEVICE_TREE).dts
+ $(DTC) -R 4 -p 0x1000 -O dtb -o $(DT_BIN) $<
+ $(OBJCOPY) -B armv5te -I binary -O elf32-littlearm $(DT_BIN) dt.o
+ rm $(DT_BIN)
+
+OBJS := dt.o
+
+OBJS := $(addprefix $(obj),$(OBJS))
+
+all: $(obj).depend $(LIB)
+
+$(LIB): $(OBJS)
+ $(call cmd_link_o_target, $(OBJS))
+
+clean:
+ rm -f $(OBJS) $(LIB)
+ rm -f $(DT_BIN)
+
+distclean: clean
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/dts/README b/dts/README
new file mode 100644
index 00000000000..ad939b9e669
--- /dev/null
+++ b/dts/README
@@ -0,0 +1,39 @@
+#
+# Copyright (c) 2011 The Chromium OS Authors.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundatio; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+Emebdded Device Tree Support in U-Boot
+======================================
+
+This directory contains a Makefile for building the device tree blob and
+embedding it in your U-Boot image. This is useful since it allows U-Boot to
+configure itself according to what it finds there. If you have a number of
+similar boards with different peripherals, you can describe the features of
+each board in the device tree file, and have a single generic source base.
+
+Put your device tree file in board/<vendor>/dts/<soc>_<board>.dts. It will be
+picked up and built into the image.
+
+
+To do
+=====
+- Provide a way for U-Boot to find a device tree somewhere in memory on startup,
+similar to how the environment works.
diff --git a/mkconfig b/mkconfig
index 6ff533f3393..04ea12a4643 100755
--- a/mkconfig
+++ b/mkconfig
@@ -127,7 +127,10 @@ echo "BOARD = ${board}" >> config.mk
[ "${vendor}" ] && echo "VENDOR = ${vendor}" >> config.mk
-[ "${soc}" ] && echo "SOC = ${soc}" >> config.mk
+if [ -n "${soc}" ] ; then
+ echo "SOC = ${soc}" >> config.mk
+ echo "DEVICE_TREE = ${soc}-${board}" >> config.mk
+fi
# Assign board directory to BOARDIR variable
if [ -z "${vendor}" ] ; then