blob: aaaed4ec022586692a9ff9fe87ff885a82a11074 [file] [log] [blame]
Simon Glass6494d702014-02-26 15:59:18 -07001/*
2 * Copyright (c) 2013 Google, Inc
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
Masahiro Yamada766c28a2017-06-22 16:50:01 +09008#include <dm/util.h>
Heiko Stübner27326c72017-02-18 19:46:21 +01009#include <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
Heiko Stübnerd905cf72017-02-23 17:30:38 +010034bool dm_fdt_pre_reloc(const void *blob, int offset)
Heiko Stübner27326c72017-02-18 19:46:21 +010035{
36 if (fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL))
Heiko Stübnerd905cf72017-02-23 17:30:38 +010037 return true;
Heiko Stübner27326c72017-02-18 19:46:21 +010038
39#ifdef CONFIG_TPL_BUILD
40 if (fdt_getprop(blob, offset, "u-boot,dm-tpl", NULL))
Heiko Stübnerd905cf72017-02-23 17:30:38 +010041 return true;
Heiko Stübner27326c72017-02-18 19:46:21 +010042#elif defined(CONFIG_SPL_BUILD)
43 if (fdt_getprop(blob, offset, "u-boot,dm-spl", NULL))
Heiko Stübnerd905cf72017-02-23 17:30:38 +010044 return true;
Heiko Stübner27326c72017-02-18 19:46:21 +010045#else
46 /*
47 * In regular builds individual spl and tpl handling both
48 * count as handled pre-relocation for later second init.
49 */
50 if (fdt_getprop(blob, offset, "u-boot,dm-spl", NULL) ||
51 fdt_getprop(blob, offset, "u-boot,dm-tpl", NULL))
Heiko Stübnerd905cf72017-02-23 17:30:38 +010052 return true;
Heiko Stübner27326c72017-02-18 19:46:21 +010053#endif
54
Heiko Stübnerd905cf72017-02-23 17:30:38 +010055 return false;
Heiko Stübner27326c72017-02-18 19:46:21 +010056}