configs: Add sam9x60ek_mmc_defconfig
[oweals/u-boot.git] / drivers / core / util.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (c) 2013 Google, Inc
4  */
5
6 #include <common.h>
7 #include <dm/ofnode.h>
8 #include <dm/util.h>
9 #include <linux/libfdt.h>
10 #include <vsprintf.h>
11
12 #ifdef CONFIG_DM_WARN
13 void 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 }
21 #endif
22
23 int 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 }
33
34 #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
35 bool dm_ofnode_pre_reloc(ofnode node)
36 {
37 #if defined(CONFIG_SPL_BUILD) || defined(CONFIG_TPL_BUILD)
38         /* for SPL and TPL the remaining nodes after the fdtgrep 1st pass
39          * had property dm-pre-reloc or u-boot,dm-spl/tpl.
40          * They are removed in final dtb (fdtgrep 2nd pass)
41          */
42         return true;
43 #else
44         if (ofnode_read_bool(node, "u-boot,dm-pre-reloc"))
45                 return true;
46         if (ofnode_read_bool(node, "u-boot,dm-pre-proper"))
47                 return true;
48
49         /*
50          * In regular builds individual spl and tpl handling both
51          * count as handled pre-relocation for later second init.
52          */
53         if (ofnode_read_bool(node, "u-boot,dm-spl") ||
54             ofnode_read_bool(node, "u-boot,dm-tpl"))
55                 return true;
56
57         return false;
58 #endif
59 }
60 #endif