summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorHeiko Stübner <heiko@sntech.de>2017-02-18 19:46:21 +0100
committerSimon Glass <sjg@chromium.org>2017-03-16 16:03:44 -0600
commit27326c7ee269ff351bba8c2461e19f29d66b6a3a (patch)
treee64993fade9d4290d6ea79e24cdbe4885c469f52 /drivers
parent2adb981207b06d93633c1a546f882dbb4dc260e4 (diff)
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/clk/at91/pmc.c3
-rw-r--r--drivers/core/root.c2
-rw-r--r--drivers/core/util.c25
-rw-r--r--drivers/pinctrl/pinctrl-uclass.c3
4 files changed, 30 insertions, 3 deletions
diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
index c73156a0df..fcd693a2f6 100644
--- a/drivers/clk/at91/pmc.c
+++ b/drivers/clk/at91/pmc.c
@@ -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
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 175fd3fb25..93ab568296 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -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");
diff --git a/drivers/core/util.c b/drivers/core/util.c
index e01dd06d28..bd4de7acd6 100644
--- a/drivers/core/util.c
+++ b/drivers/core/util.c
@@ -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;
+}
diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c
index 49afe91c24..9efad0623a 100644
--- a/drivers/pinctrl/pinctrl-uclass.c
+++ b/drivers/pinctrl/pinctrl-uclass.c
@@ -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