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> |
Masahiro Yamada | 3247fdb | 2017-06-22 16:50:01 +0900 | [diff] [blame] | 8 | #include <dm/util.h> |
Heiko Stübner | 9a2cdca | 2017-02-18 19:46:21 +0100 | [diff] [blame] | 9 | #include <libfdt.h> |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 10 | #include <vsprintf.h> |
| 11 | |
Masahiro Yamada | 3247fdb | 2017-06-22 16:50:01 +0900 | [diff] [blame] | 12 | #ifdef CONFIG_DM_WARN |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 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 | } |
Masahiro Yamada | 3247fdb | 2017-06-22 16:50:01 +0900 | [diff] [blame] | 21 | #endif |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 22 | |
Masahiro Yamada | 3247fdb | 2017-06-22 16:50:01 +0900 | [diff] [blame] | 23 | #ifdef DEBUG |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 24 | void dm_dbg(const char *fmt, ...) |
| 25 | { |
| 26 | va_list args; |
| 27 | |
| 28 | va_start(args, fmt); |
| 29 | vprintf(fmt, args); |
| 30 | va_end(args); |
| 31 | } |
Masahiro Yamada | 3247fdb | 2017-06-22 16:50:01 +0900 | [diff] [blame] | 32 | #endif |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 33 | |
| 34 | int list_count_items(struct list_head *head) |
| 35 | { |
| 36 | struct list_head *node; |
| 37 | int count = 0; |
| 38 | |
| 39 | list_for_each(node, head) |
| 40 | count++; |
| 41 | |
| 42 | return count; |
| 43 | } |
Heiko Stübner | 9a2cdca | 2017-02-18 19:46:21 +0100 | [diff] [blame] | 44 | |
Heiko Stübner | 20f938a | 2017-02-23 17:30:38 +0100 | [diff] [blame] | 45 | bool dm_fdt_pre_reloc(const void *blob, int offset) |
Heiko Stübner | 9a2cdca | 2017-02-18 19:46:21 +0100 | [diff] [blame] | 46 | { |
| 47 | if (fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL)) |
Heiko Stübner | 20f938a | 2017-02-23 17:30:38 +0100 | [diff] [blame] | 48 | return true; |
Heiko Stübner | 9a2cdca | 2017-02-18 19:46:21 +0100 | [diff] [blame] | 49 | |
| 50 | #ifdef CONFIG_TPL_BUILD |
| 51 | if (fdt_getprop(blob, offset, "u-boot,dm-tpl", NULL)) |
Heiko Stübner | 20f938a | 2017-02-23 17:30:38 +0100 | [diff] [blame] | 52 | return true; |
Heiko Stübner | 9a2cdca | 2017-02-18 19:46:21 +0100 | [diff] [blame] | 53 | #elif defined(CONFIG_SPL_BUILD) |
| 54 | if (fdt_getprop(blob, offset, "u-boot,dm-spl", NULL)) |
Heiko Stübner | 20f938a | 2017-02-23 17:30:38 +0100 | [diff] [blame] | 55 | return true; |
Heiko Stübner | 9a2cdca | 2017-02-18 19:46:21 +0100 | [diff] [blame] | 56 | #else |
| 57 | /* |
| 58 | * In regular builds individual spl and tpl handling both |
| 59 | * count as handled pre-relocation for later second init. |
| 60 | */ |
| 61 | if (fdt_getprop(blob, offset, "u-boot,dm-spl", NULL) || |
| 62 | fdt_getprop(blob, offset, "u-boot,dm-tpl", NULL)) |
Heiko Stübner | 20f938a | 2017-02-23 17:30:38 +0100 | [diff] [blame] | 63 | return true; |
Heiko Stübner | 9a2cdca | 2017-02-18 19:46:21 +0100 | [diff] [blame] | 64 | #endif |
| 65 | |
Heiko Stübner | 20f938a | 2017-02-23 17:30:38 +0100 | [diff] [blame] | 66 | return false; |
Heiko Stübner | 9a2cdca | 2017-02-18 19:46:21 +0100 | [diff] [blame] | 67 | } |