16494d708SSimon Glass /*
26494d708SSimon Glass * Copyright (c) 2013 Google, Inc
36494d708SSimon Glass *
46494d708SSimon Glass * SPDX-License-Identifier: GPL-2.0+
56494d708SSimon Glass */
66494d708SSimon Glass
76494d708SSimon Glass #include <common.h>
8766c28a5SMasahiro Yamada #include <dm/util.h>
9*0e00a84cSMasahiro Yamada #include <linux/libfdt.h>
106494d708SSimon Glass #include <vsprintf.h>
116494d708SSimon Glass
12766c28a5SMasahiro Yamada #ifdef CONFIG_DM_WARN
dm_warn(const char * fmt,...)136494d708SSimon Glass void dm_warn(const char *fmt, ...)
146494d708SSimon Glass {
156494d708SSimon Glass va_list args;
166494d708SSimon Glass
176494d708SSimon Glass va_start(args, fmt);
186494d708SSimon Glass vprintf(fmt, args);
196494d708SSimon Glass va_end(args);
206494d708SSimon Glass }
21766c28a5SMasahiro Yamada #endif
226494d708SSimon Glass
list_count_items(struct list_head * head)236494d708SSimon Glass int list_count_items(struct list_head *head)
246494d708SSimon Glass {
256494d708SSimon Glass struct list_head *node;
266494d708SSimon Glass int count = 0;
276494d708SSimon Glass
286494d708SSimon Glass list_for_each(node, head)
296494d708SSimon Glass count++;
306494d708SSimon Glass
316494d708SSimon Glass return count;
326494d708SSimon Glass }
3327326c7eSHeiko Stübner
dm_fdt_pre_reloc(const void * blob,int offset)34d905cf73SHeiko Stübner bool dm_fdt_pre_reloc(const void *blob, int offset)
3527326c7eSHeiko Stübner {
3627326c7eSHeiko Stübner if (fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL))
37d905cf73SHeiko Stübner return true;
3827326c7eSHeiko Stübner
3927326c7eSHeiko Stübner #ifdef CONFIG_TPL_BUILD
4027326c7eSHeiko Stübner if (fdt_getprop(blob, offset, "u-boot,dm-tpl", NULL))
41d905cf73SHeiko Stübner return true;
4227326c7eSHeiko Stübner #elif defined(CONFIG_SPL_BUILD)
4327326c7eSHeiko Stübner if (fdt_getprop(blob, offset, "u-boot,dm-spl", NULL))
44d905cf73SHeiko Stübner return true;
4527326c7eSHeiko Stübner #else
4627326c7eSHeiko Stübner /*
4727326c7eSHeiko Stübner * In regular builds individual spl and tpl handling both
4827326c7eSHeiko Stübner * count as handled pre-relocation for later second init.
4927326c7eSHeiko Stübner */
5027326c7eSHeiko Stübner if (fdt_getprop(blob, offset, "u-boot,dm-spl", NULL) ||
5127326c7eSHeiko Stübner fdt_getprop(blob, offset, "u-boot,dm-tpl", NULL))
52d905cf73SHeiko Stübner return true;
5327326c7eSHeiko Stübner #endif
5427326c7eSHeiko Stübner
55d905cf73SHeiko Stübner return false;
5627326c7eSHeiko Stübner }
57