blob: 5ceac8bbb15b9572a9e8e76ebcd3b9794550bcbc [file] [log] [blame]
Simon Glassdd6ab882014-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>
Heiko Stübner9a2cdca2017-02-18 19:46:21 +01008#include <libfdt.h>
Simon Glassdd6ab882014-02-26 15:59:18 -07009#include <vsprintf.h>
10
11void dm_warn(const char *fmt, ...)
12{
13 va_list args;
14
15 va_start(args, fmt);
16 vprintf(fmt, args);
17 va_end(args);
18}
19
20void dm_dbg(const char *fmt, ...)
21{
22 va_list args;
23
24 va_start(args, fmt);
25 vprintf(fmt, args);
26 va_end(args);
27}
28
29int list_count_items(struct list_head *head)
30{
31 struct list_head *node;
32 int count = 0;
33
34 list_for_each(node, head)
35 count++;
36
37 return count;
38}
Heiko Stübner9a2cdca2017-02-18 19:46:21 +010039
Heiko Stübner20f938a2017-02-23 17:30:38 +010040bool dm_fdt_pre_reloc(const void *blob, int offset)
Heiko Stübner9a2cdca2017-02-18 19:46:21 +010041{
42 if (fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL))
Heiko Stübner20f938a2017-02-23 17:30:38 +010043 return true;
Heiko Stübner9a2cdca2017-02-18 19:46:21 +010044
45#ifdef CONFIG_TPL_BUILD
46 if (fdt_getprop(blob, offset, "u-boot,dm-tpl", NULL))
Heiko Stübner20f938a2017-02-23 17:30:38 +010047 return true;
Heiko Stübner9a2cdca2017-02-18 19:46:21 +010048#elif defined(CONFIG_SPL_BUILD)
49 if (fdt_getprop(blob, offset, "u-boot,dm-spl", NULL))
Heiko Stübner20f938a2017-02-23 17:30:38 +010050 return true;
Heiko Stübner9a2cdca2017-02-18 19:46:21 +010051#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))
Heiko Stübner20f938a2017-02-23 17:30:38 +010058 return true;
Heiko Stübner9a2cdca2017-02-18 19:46:21 +010059#endif
60
Heiko Stübner20f938a2017-02-23 17:30:38 +010061 return false;
Heiko Stübner9a2cdca2017-02-18 19:46:21 +010062}