]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
dm: allow limiting pre-reloc markings to spl or tpl
authorHeiko Stübner <heiko@sntech.de>
Sat, 18 Feb 2017 18:46:21 +0000 (19:46 +0100)
committerSimon Glass <sjg@chromium.org>
Thu, 16 Mar 2017 22:03:44 +0000 (16:03 -0600)
Right now the u-boot,dm-pre-reloc flag will make each marked node
always appear in both spl and tpl. But systems needing an additional
tpl might have special constraints for each, like the spl needing to
be very tiny.

So introduce two additional flags to mark nodes for only spl or tpl
environments and introduce a function dm_fdt_pre_reloc to automate
the necessary checks in code instances checking for pre-relocation
flags.

The behaviour of the original flag stays untouched and still marks
a node for both spl and tpl.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Kever Yang <kever.yang@rock-chips.com>
doc/driver-model/README.txt
drivers/clk/at91/pmc.c
drivers/core/root.c
drivers/core/util.c
drivers/pinctrl/pinctrl-uclass.c
include/dm/util.h
scripts/Makefile.spl
tools/dtoc/dtoc.py

index fea324e25eee876f931a56807f9dfc360943ed71..0853477578ac7ce77aea3078a13224715f435f01 100644 (file)
@@ -825,6 +825,10 @@ drivers marked with DM_FLAG_PRE_RELOC or the device tree
 'u-boot,dm-pre-reloc' flag are initialised prior to relocation. This helps
 to reduce the driver model overhead.
 
+It is possible to limit this to specific relocation steps, by using
+the more specialized 'u-boot,dm-spl' and 'u-boot,dm-tpl' flags
+in the devicetree.
+
 Then post relocation we throw that away and re-init driver model again.
 For drivers which require some sort of continuity between pre- and
 post-relocation devices, we can provide access to the pre-relocation
index c73156a0df1e095f8b625097cd481d63f1b81b3a..fcd693a2f6fc6904d7ca1f6a388e60e60f9f94dd 100644 (file)
@@ -10,6 +10,7 @@
 #include <dm/device.h>
 #include <dm/lists.h>
 #include <dm/root.h>
+#include <dm/util.h>
 #include "pmc.h"
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -56,7 +57,7 @@ int at91_clk_sub_device_bind(struct udevice *dev, const char *drv_name)
             offset > 0;
             offset = fdt_next_subnode(fdt, offset)) {
                if (pre_reloc_only &&
-                   !fdt_getprop(fdt, offset, "u-boot,dm-pre-reloc", NULL))
+                   !dm_fdt_pre_reloc(fdt, offset))
                        continue;
                /*
                 * If this node has "compatible" property, this is not
index 175fd3fb252d494a5096b02d1a3a3b940879ca33..93ab568296809b23dab818fd0d9bdc0e78d17e98 100644 (file)
@@ -205,7 +205,7 @@ int dm_scan_fdt_node(struct udevice *parent, const void *blob, int offset,
             offset > 0;
             offset = fdt_next_subnode(blob, offset)) {
                if (pre_reloc_only &&
-                   !fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL))
+                   !dm_fdt_pre_reloc(blob, offset))
                        continue;
                if (!fdtdec_get_is_enabled(blob, offset)) {
                        dm_dbg("   - ignoring disabled device\n");
index e01dd06d282c5b5e43490d4826698e9e4e800ddb..bd4de7acd69873fc1ebcc1adb069d12282555194 100644 (file)
@@ -5,6 +5,7 @@
  */
 
 #include <common.h>
+#include <libfdt.h>
 #include <vsprintf.h>
 
 void dm_warn(const char *fmt, ...)
@@ -35,3 +36,27 @@ int list_count_items(struct list_head *head)
 
        return count;
 }
+
+int dm_fdt_pre_reloc(const void *blob, int offset)
+{
+       if (fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL))
+               return 1;
+
+#ifdef CONFIG_TPL_BUILD
+       if (fdt_getprop(blob, offset, "u-boot,dm-tpl", NULL))
+               return 1;
+#elif defined(CONFIG_SPL_BUILD)
+       if (fdt_getprop(blob, offset, "u-boot,dm-spl", NULL))
+               return 1;
+#else
+       /*
+        * In regular builds individual spl and tpl handling both
+        * count as handled pre-relocation for later second init.
+        */
+       if (fdt_getprop(blob, offset, "u-boot,dm-spl", NULL) ||
+           fdt_getprop(blob, offset, "u-boot,dm-tpl", NULL))
+               return 1;
+#endif
+
+       return 0;
+}
index 49afe91c24eff576e81adcb87e02e1ed78023235..9efad0623a31ce362a8c4420fc42397a6175701d 100644 (file)
@@ -12,6 +12,7 @@
 #include <dm/lists.h>
 #include <dm/pinctrl.h>
 #include <dm/uclass.h>
+#include <dm/util.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -131,7 +132,7 @@ static int pinconfig_post_bind(struct udevice *dev)
             offset > 0;
             offset = fdt_next_subnode(fdt, offset)) {
                if (pre_reloc_only &&
-                   !fdt_getprop(fdt, offset, "u-boot,dm-pre-reloc", NULL))
+                   !dm_fdt_pre_reloc(fdt, offset))
                        continue;
                /*
                 * If this node has "compatible" property, this is not
index 15daa3d19f1021a70d351095dfc46f7e9b5af38b..32060ab30eb467ff4427ac76d6dc7202d28f322b 100644 (file)
@@ -48,4 +48,30 @@ static inline void dm_dump_devres(void)
 }
 #endif
 
+/**
+ * Check if a dt node should be or was bound before relocation.
+ *
+ * Devicetree nodes can be marked as needed to be bound
+ * in the loader stages via special devicetree properties.
+ *
+ * Before relocation this function can be used to check if nodes
+ * are required in either SPL or TPL stages.
+ *
+ * After relocation and jumping into the real U-Boot binary
+ * it is possible to determine if a node was bound in one of
+ * SPL/TPL stages.
+ *
+ * There are 3 settings currently in use
+ * -
+ * - u-boot,dm-pre-reloc: legacy and indicates any of TPL or SPL
+ *   Existing platforms only use it to indicate nodes needee in
+ *   SPL. Should probably be replaced by u-boot,dm-spl for
+ *   existing platforms.
+ * @blob: devicetree
+ * @offset: node offset
+ *
+ * Returns true if node is needed in SPL/TL, false otherwise.
+ */
+int dm_fdt_pre_reloc(const void *blob, int offset);
+
 #endif
index b52f9963f7d0a52f062511acaef0f9af536345bd..5370648e853d2d2e9d211069f2dc5d3e12f0f765 100644 (file)
@@ -215,8 +215,13 @@ $(obj)/$(SPL_BIN)-pad.bin: $(obj)/$(SPL_BIN)
 # 'u-boot,dm-pre-reloc' property and thus are not needed by SPL. The second
 # pass removes various unused properties from the remaining nodes.
 # The output is typically a much smaller device tree file.
+ifeq ($(CONFIG_TPL_BUILD),y)
+fdtgrep_props := -b u-boot,dm-pre-reloc -b u-boot,dm-tpl
+else
+fdtgrep_props := -b u-boot,dm-pre-reloc -b u-boot,dm-spl
+endif
 quiet_cmd_fdtgrep = FDTGREP $@
-      cmd_fdtgrep = $(objtree)/tools/fdtgrep -b u-boot,dm-pre-reloc -RT $< \
+      cmd_fdtgrep = $(objtree)/tools/fdtgrep $(fdtgrep_props) -RT $< \
                -n /chosen -O dtb | \
        $(objtree)/tools/fdtgrep -r -O dtb - -o $@ \
                $(addprefix -P ,$(subst $\",,$(CONFIG_OF_SPL_REMOVE_PROPS)))
index 6df7b0da13ad845bdf8bbea9902be1fcd1462acf..bf67ec80ca1b845db4930bcf347e936a67938721 100755 (executable)
@@ -30,6 +30,8 @@ PROP_IGNORE_LIST = [
     "status",
     'phandle',
     'u-boot,dm-pre-reloc',
+    'u-boot,dm-tpl',
+    'u-boot,dm-spl',
 ]
 
 # C type declarations for the tyues we support