Commit 5513023cb74e56b3d6205f3ccc2d6a9ec8866369

Authored by Heiko Stübner
Committed by Lokesh Vutla
1 parent af27d08464

dm: allow limiting pre-reloc markings to spl or tpl

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>

Showing 8 changed files with 68 additions and 4 deletions Side-by-side Diff

doc/driver-model/README.txt
... ... @@ -825,6 +825,10 @@
825 825 'u-boot,dm-pre-reloc' flag are initialised prior to relocation. This helps
826 826 to reduce the driver model overhead.
827 827  
  828 +It is possible to limit this to specific relocation steps, by using
  829 +the more specialized 'u-boot,dm-spl' and 'u-boot,dm-tpl' flags
  830 +in the devicetree.
  831 +
828 832 Then post relocation we throw that away and re-init driver model again.
829 833 For drivers which require some sort of continuity between pre- and
830 834 post-relocation devices, we can provide access to the pre-relocation
drivers/clk/at91/pmc.c
... ... @@ -10,6 +10,7 @@
10 10 #include <dm/device.h>
11 11 #include <dm/lists.h>
12 12 #include <dm/root.h>
  13 +#include <dm/util.h>
13 14 #include "pmc.h"
14 15  
15 16 DECLARE_GLOBAL_DATA_PTR;
... ... @@ -56,7 +57,7 @@
56 57 offset > 0;
57 58 offset = fdt_next_subnode(fdt, offset)) {
58 59 if (pre_reloc_only &&
59   - !fdt_getprop(fdt, offset, "u-boot,dm-pre-reloc", NULL))
  60 + !dm_fdt_pre_reloc(fdt, offset))
60 61 continue;
61 62 /*
62 63 * If this node has "compatible" property, this is not
... ... @@ -207,7 +207,7 @@
207 207 offset > 0;
208 208 offset = fdt_next_subnode(blob, offset)) {
209 209 if (pre_reloc_only &&
210   - !fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL))
  210 + !dm_fdt_pre_reloc(blob, offset))
211 211 continue;
212 212 if (!fdtdec_get_is_enabled(blob, offset)) {
213 213 dm_dbg(" - ignoring disabled device\n");
... ... @@ -5,6 +5,7 @@
5 5 */
6 6  
7 7 #include <common.h>
  8 +#include <libfdt.h>
8 9 #include <vsprintf.h>
9 10  
10 11 void dm_warn(const char *fmt, ...)
... ... @@ -34,5 +35,29 @@
34 35 count++;
35 36  
36 37 return count;
  38 +}
  39 +
  40 +int dm_fdt_pre_reloc(const void *blob, int offset)
  41 +{
  42 + if (fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL))
  43 + return 1;
  44 +
  45 +#ifdef CONFIG_TPL_BUILD
  46 + if (fdt_getprop(blob, offset, "u-boot,dm-tpl", NULL))
  47 + return 1;
  48 +#elif defined(CONFIG_SPL_BUILD)
  49 + if (fdt_getprop(blob, offset, "u-boot,dm-spl", NULL))
  50 + return 1;
  51 +#else
  52 + /*
  53 + * In regular builds individual spl and tpl handling both
  54 + * count as handled pre-relocation for later second init.
  55 + */
  56 + if (fdt_getprop(blob, offset, "u-boot,dm-spl", NULL) ||
  57 + fdt_getprop(blob, offset, "u-boot,dm-tpl", NULL))
  58 + return 1;
  59 +#endif
  60 +
  61 + return 0;
37 62 }
drivers/pinctrl/pinctrl-uclass.c
... ... @@ -12,6 +12,7 @@
12 12 #include <dm/lists.h>
13 13 #include <dm/pinctrl.h>
14 14 #include <dm/uclass.h>
  15 +#include <dm/util.h>
15 16  
16 17 DECLARE_GLOBAL_DATA_PTR;
17 18  
... ... @@ -131,7 +132,7 @@
131 132 offset > 0;
132 133 offset = fdt_next_subnode(fdt, offset)) {
133 134 if (pre_reloc_only &&
134   - !fdt_getprop(fdt, offset, "u-boot,dm-pre-reloc", NULL))
  135 + !dm_fdt_pre_reloc(fdt, offset))
135 136 continue;
136 137 /*
137 138 * If this node has "compatible" property, this is not
... ... @@ -48,5 +48,31 @@
48 48 }
49 49 #endif
50 50  
  51 +/**
  52 + * Check if a dt node should be or was bound before relocation.
  53 + *
  54 + * Devicetree nodes can be marked as needed to be bound
  55 + * in the loader stages via special devicetree properties.
  56 + *
  57 + * Before relocation this function can be used to check if nodes
  58 + * are required in either SPL or TPL stages.
  59 + *
  60 + * After relocation and jumping into the real U-Boot binary
  61 + * it is possible to determine if a node was bound in one of
  62 + * SPL/TPL stages.
  63 + *
  64 + * There are 3 settings currently in use
  65 + * -
  66 + * - u-boot,dm-pre-reloc: legacy and indicates any of TPL or SPL
  67 + * Existing platforms only use it to indicate nodes needee in
  68 + * SPL. Should probably be replaced by u-boot,dm-spl for
  69 + * existing platforms.
  70 + * @blob: devicetree
  71 + * @offset: node offset
  72 + *
  73 + * Returns true if node is needed in SPL/TL, false otherwise.
  74 + */
  75 +int dm_fdt_pre_reloc(const void *blob, int offset);
  76 +
51 77 #endif
scripts/Makefile.spl
... ... @@ -206,8 +206,13 @@
206 206 # 'u-boot,dm-pre-reloc' property and thus are not needed by SPL. The second
207 207 # pass removes various unused properties from the remaining nodes.
208 208 # The output is typically a much smaller device tree file.
  209 +ifeq ($(CONFIG_TPL_BUILD),y)
  210 +fdtgrep_props := -b u-boot,dm-pre-reloc -b u-boot,dm-tpl
  211 +else
  212 +fdtgrep_props := -b u-boot,dm-pre-reloc -b u-boot,dm-spl
  213 +endif
209 214 quiet_cmd_fdtgrep = FDTGREP $@
210   - cmd_fdtgrep = $(objtree)/tools/fdtgrep -b u-boot,dm-pre-reloc -RT $< \
  215 + cmd_fdtgrep = $(objtree)/tools/fdtgrep $(fdtgrep_props) -RT $< \
211 216 -n /chosen -O dtb | \
212 217 $(objtree)/tools/fdtgrep -r -O dtb - -o $@ \
213 218 $(addprefix -P ,$(subst $\",,$(CONFIG_OF_SPL_REMOVE_PROPS)))
... ... @@ -30,6 +30,8 @@
30 30 "status",
31 31 'phandle',
32 32 'u-boot,dm-pre-reloc',
  33 + 'u-boot,dm-tpl',
  34 + 'u-boot,dm-spl',
33 35 ]
34 36  
35 37 # C type declarations for the tyues we support