Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013 Google, Inc |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Heiko Stübner | 9a2cdca | 2017-02-18 19:46:21 +0100 | [diff] [blame] | 8 | #include <libfdt.h> |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 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 | } |
Heiko Stübner | 9a2cdca | 2017-02-18 19:46:21 +0100 | [diff] [blame] | 39 | |
| 40 | int dm_fdt_pre_reloc(const void *blob, int offset) |
| 41 | { |
| 42 | if (fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL)) |
| 43 | return 1; |
| 44 | |
| 45 | #ifdef CONFIG_TPL_BUILD |
| 46 | if (fdt_getprop(blob, offset, "u-boot,dm-tpl", NULL)) |
| 47 | return 1; |
| 48 | #elif defined(CONFIG_SPL_BUILD) |
| 49 | if (fdt_getprop(blob, offset, "u-boot,dm-spl", NULL)) |
| 50 | return 1; |
| 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 1; |
| 59 | #endif |
| 60 | |
| 61 | return 0; |
| 62 | } |