Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | 6494d70 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2013 Google, Inc |
Simon Glass | 6494d70 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Bin Meng | e601ab1 | 2018-10-10 22:06:57 -0700 | [diff] [blame] | 7 | #include <dm/ofnode.h> |
Masahiro Yamada | 766c28a | 2017-06-22 16:50:01 +0900 | [diff] [blame] | 8 | #include <dm/util.h> |
Masahiro Yamada | b08c8c4 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 9 | #include <linux/libfdt.h> |
Simon Glass | 6494d70 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 10 | #include <vsprintf.h> |
| 11 | |
Masahiro Yamada | 766c28a | 2017-06-22 16:50:01 +0900 | [diff] [blame] | 12 | #ifdef CONFIG_DM_WARN |
Simon Glass | 6494d70 | 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 | 766c28a | 2017-06-22 16:50:01 +0900 | [diff] [blame] | 21 | #endif |
Simon Glass | 6494d70 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 22 | |
Simon Glass | 6494d70 | 2014-02-26 15:59:18 -0700 | [diff] [blame] | 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 | } |
Heiko Stübner | 27326c7 | 2017-02-18 19:46:21 +0100 | [diff] [blame] | 33 | |
Marek Vasut | d7677bf | 2019-08-31 18:03:28 +0200 | [diff] [blame] | 34 | #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) |
Bin Meng | e601ab1 | 2018-10-10 22:06:57 -0700 | [diff] [blame] | 35 | bool dm_ofnode_pre_reloc(ofnode node) |
| 36 | { |
Patrick Delaunay | c7a88da | 2019-02-11 12:49:57 +0100 | [diff] [blame] | 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 |
Bin Meng | e601ab1 | 2018-10-10 22:06:57 -0700 | [diff] [blame] | 44 | if (ofnode_read_bool(node, "u-boot,dm-pre-reloc")) |
| 45 | return true; |
Patrick Delaunay | 6998974 | 2019-05-21 19:19:12 +0200 | [diff] [blame] | 46 | if (ofnode_read_bool(node, "u-boot,dm-pre-proper")) |
| 47 | return true; |
Bin Meng | e601ab1 | 2018-10-10 22:06:57 -0700 | [diff] [blame] | 48 | |
Bin Meng | e601ab1 | 2018-10-10 22:06:57 -0700 | [diff] [blame] | 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; |
Bin Meng | e601ab1 | 2018-10-10 22:06:57 -0700 | [diff] [blame] | 56 | |
| 57 | return false; |
Patrick Delaunay | c7a88da | 2019-02-11 12:49:57 +0100 | [diff] [blame] | 58 | #endif |
Bin Meng | e601ab1 | 2018-10-10 22:06:57 -0700 | [diff] [blame] | 59 | } |
Marek Vasut | d7677bf | 2019-08-31 18:03:28 +0200 | [diff] [blame] | 60 | #endif |