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 | |
Heiko Stübner | 20f938a | 2017-02-23 17:30:38 +0100 | [diff] [blame] | 40 | bool dm_fdt_pre_reloc(const void *blob, int offset) |
Heiko Stübner | 9a2cdca | 2017-02-18 19:46:21 +0100 | [diff] [blame] | 41 | { |
| 42 | if (fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL)) |
Heiko Stübner | 20f938a | 2017-02-23 17:30:38 +0100 | [diff] [blame] | 43 | return true; |
Heiko Stübner | 9a2cdca | 2017-02-18 19:46:21 +0100 | [diff] [blame] | 44 | |
| 45 | #ifdef CONFIG_TPL_BUILD |
| 46 | if (fdt_getprop(blob, offset, "u-boot,dm-tpl", NULL)) |
Heiko Stübner | 20f938a | 2017-02-23 17:30:38 +0100 | [diff] [blame] | 47 | return true; |
Heiko Stübner | 9a2cdca | 2017-02-18 19:46:21 +0100 | [diff] [blame] | 48 | #elif defined(CONFIG_SPL_BUILD) |
| 49 | if (fdt_getprop(blob, offset, "u-boot,dm-spl", NULL)) |
Heiko Stübner | 20f938a | 2017-02-23 17:30:38 +0100 | [diff] [blame] | 50 | return true; |
Heiko Stübner | 9a2cdca | 2017-02-18 19:46:21 +0100 | [diff] [blame] | 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)) |
Heiko Stübner | 20f938a | 2017-02-23 17:30:38 +0100 | [diff] [blame] | 58 | return true; |
Heiko Stübner | 9a2cdca | 2017-02-18 19:46:21 +0100 | [diff] [blame] | 59 | #endif |
| 60 | |
Heiko Stübner | 20f938a | 2017-02-23 17:30:38 +0100 | [diff] [blame] | 61 | return false; |
Heiko Stübner | 9a2cdca | 2017-02-18 19:46:21 +0100 | [diff] [blame] | 62 | } |