Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2013 Google, Inc |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Masahiro Yamada | 3247fdb | 2017-06-22 16:50:01 +0900 | [diff] [blame] | 7 | #include <dm/util.h> |
Masahiro Yamada | 75f82d0 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 8 | #include <linux/libfdt.h> |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 9 | #include <vsprintf.h> |
| 10 | |
Masahiro Yamada | 3247fdb | 2017-06-22 16:50:01 +0900 | [diff] [blame] | 11 | #ifdef CONFIG_DM_WARN |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 12 | void dm_warn(const char *fmt, ...) |
| 13 | { |
| 14 | va_list args; |
| 15 | |
| 16 | va_start(args, fmt); |
| 17 | vprintf(fmt, args); |
| 18 | va_end(args); |
| 19 | } |
Masahiro Yamada | 3247fdb | 2017-06-22 16:50:01 +0900 | [diff] [blame] | 20 | #endif |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 21 | |
Simon Glass | dd6ab88 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 22 | int list_count_items(struct list_head *head) |
| 23 | { |
| 24 | struct list_head *node; |
| 25 | int count = 0; |
| 26 | |
| 27 | list_for_each(node, head) |
| 28 | count++; |
| 29 | |
| 30 | return count; |
| 31 | } |
Heiko Stübner | 9a2cdca | 2017-02-18 19:46:21 +0100 | [diff] [blame] | 32 | |
Heiko Stübner | 20f938a | 2017-02-23 17:30:38 +0100 | [diff] [blame] | 33 | bool dm_fdt_pre_reloc(const void *blob, int offset) |
Heiko Stübner | 9a2cdca | 2017-02-18 19:46:21 +0100 | [diff] [blame] | 34 | { |
| 35 | if (fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL)) |
Heiko Stübner | 20f938a | 2017-02-23 17:30:38 +0100 | [diff] [blame] | 36 | return true; |
Heiko Stübner | 9a2cdca | 2017-02-18 19:46:21 +0100 | [diff] [blame] | 37 | |
| 38 | #ifdef CONFIG_TPL_BUILD |
| 39 | if (fdt_getprop(blob, offset, "u-boot,dm-tpl", NULL)) |
Heiko Stübner | 20f938a | 2017-02-23 17:30:38 +0100 | [diff] [blame] | 40 | return true; |
Heiko Stübner | 9a2cdca | 2017-02-18 19:46:21 +0100 | [diff] [blame] | 41 | #elif defined(CONFIG_SPL_BUILD) |
| 42 | if (fdt_getprop(blob, offset, "u-boot,dm-spl", 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 | #else |
| 45 | /* |
| 46 | * In regular builds individual spl and tpl handling both |
| 47 | * count as handled pre-relocation for later second init. |
| 48 | */ |
| 49 | if (fdt_getprop(blob, offset, "u-boot,dm-spl", NULL) || |
| 50 | fdt_getprop(blob, offset, "u-boot,dm-tpl", NULL)) |
Heiko Stübner | 20f938a | 2017-02-23 17:30:38 +0100 | [diff] [blame] | 51 | return true; |
Heiko Stübner | 9a2cdca | 2017-02-18 19:46:21 +0100 | [diff] [blame] | 52 | #endif |
| 53 | |
Heiko Stübner | 20f938a | 2017-02-23 17:30:38 +0100 | [diff] [blame] | 54 | return false; |
Heiko Stübner | 9a2cdca | 2017-02-18 19:46:21 +0100 | [diff] [blame] | 55 | } |