blob: 96e47dc70709d473c134b4dc6427bc98035ff427 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glass6494d702014-02-26 15:59:18 -07002/*
3 * Copyright (c) 2013 Google, Inc
Simon Glass6494d702014-02-26 15:59:18 -07004 */
5
6#include <common.h>
Bin Menge601ab12018-10-10 22:06:57 -07007#include <dm/ofnode.h>
Masahiro Yamada766c28a2017-06-22 16:50:01 +09008#include <dm/util.h>
Masahiro Yamadab08c8c42018-03-05 01:20:11 +09009#include <linux/libfdt.h>
Simon Glass6494d702014-02-26 15:59:18 -070010#include <vsprintf.h>
11
Masahiro Yamada766c28a2017-06-22 16:50:01 +090012#ifdef CONFIG_DM_WARN
Simon Glass6494d702014-02-26 15:59:18 -070013void dm_warn(const char *fmt, ...)
14{
15 va_list args;
16
17 va_start(args, fmt);
18 vprintf(fmt, args);
19 va_end(args);
20}
Masahiro Yamada766c28a2017-06-22 16:50:01 +090021#endif
Simon Glass6494d702014-02-26 15:59:18 -070022
Simon Glass6494d702014-02-26 15:59:18 -070023int list_count_items(struct list_head *head)
24{
25 struct list_head *node;
26 int count = 0;
27
28 list_for_each(node, head)
29 count++;
30
31 return count;
32}
Heiko Stübner27326c72017-02-18 19:46:21 +010033
Bin Menge601ab12018-10-10 22:06:57 -070034bool dm_ofnode_pre_reloc(ofnode node)
35{
Patrick Delaunayc7a88da2019-02-11 12:49:57 +010036#if defined(CONFIG_SPL_BUILD) || defined(CONFIG_TPL_BUILD)
37 /* for SPL and TPL the remaining nodes after the fdtgrep 1st pass
38 * had property dm-pre-reloc or u-boot,dm-spl/tpl.
39 * They are removed in final dtb (fdtgrep 2nd pass)
40 */
41 return true;
42#else
Bin Menge601ab12018-10-10 22:06:57 -070043 if (ofnode_read_bool(node, "u-boot,dm-pre-reloc"))
44 return true;
45
Bin Menge601ab12018-10-10 22:06:57 -070046 /*
47 * In regular builds individual spl and tpl handling both
48 * count as handled pre-relocation for later second init.
49 */
50 if (ofnode_read_bool(node, "u-boot,dm-spl") ||
51 ofnode_read_bool(node, "u-boot,dm-tpl"))
52 return true;
Bin Menge601ab12018-10-10 22:06:57 -070053
54 return false;
Patrick Delaunayc7a88da2019-02-11 12:49:57 +010055#endif
Bin Menge601ab12018-10-10 22:06:57 -070056}