xref: /openbmc/u-boot/drivers/core/util.c (revision 2399e401)
1 /*
2  * Copyright (c) 2013 Google, Inc
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  */
6 
7 #include <common.h>
8 #include <libfdt.h>
9 #include <vsprintf.h>
10 
11 void 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 
20 void 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 
29 int 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 }
39 
40 bool dm_fdt_pre_reloc(const void *blob, int offset)
41 {
42 	if (fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL))
43 		return true;
44 
45 #ifdef CONFIG_TPL_BUILD
46 	if (fdt_getprop(blob, offset, "u-boot,dm-tpl", NULL))
47 		return true;
48 #elif defined(CONFIG_SPL_BUILD)
49 	if (fdt_getprop(blob, offset, "u-boot,dm-spl", NULL))
50 		return true;
51 #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))
58 		return true;
59 #endif
60 
61 	return false;
62 }
63