xref: /rk3399_rockchip-uboot/include/dm/util.h (revision 27326c7ee269ff351bba8c2461e19f29d66b6a3a)
16494d708SSimon Glass /*
26494d708SSimon Glass  * Copyright (c) 2013 Google, Inc
36494d708SSimon Glass  *
46494d708SSimon Glass  * SPDX-License-Identifier:	GPL-2.0+
56494d708SSimon Glass  */
66494d708SSimon Glass 
76494d708SSimon Glass #ifndef __DM_UTIL_H
8b1799fcbSMasahiro Yamada #define __DM_UTIL_H
96494d708SSimon Glass 
10a94f468fSSimon Glass #ifdef CONFIG_DM_WARN
116494d708SSimon Glass void dm_warn(const char *fmt, ...);
12a94f468fSSimon Glass #else
13a94f468fSSimon Glass static inline void dm_warn(const char *fmt, ...)
14a94f468fSSimon Glass {
15a94f468fSSimon Glass }
16a94f468fSSimon Glass #endif
176494d708SSimon Glass 
186494d708SSimon Glass #ifdef DEBUG
196494d708SSimon Glass void dm_dbg(const char *fmt, ...);
206494d708SSimon Glass #else
216494d708SSimon Glass static inline void dm_dbg(const char *fmt, ...)
226494d708SSimon Glass {
236494d708SSimon Glass }
246494d708SSimon Glass #endif
256494d708SSimon Glass 
266494d708SSimon Glass struct list_head;
276494d708SSimon Glass 
286494d708SSimon Glass /**
296494d708SSimon Glass  * list_count_items() - Count number of items in a list
306494d708SSimon Glass  *
316494d708SSimon Glass  * @param head:		Head of list
326494d708SSimon Glass  * @return number of items, or 0 if empty
336494d708SSimon Glass  */
346494d708SSimon Glass int list_count_items(struct list_head *head);
356494d708SSimon Glass 
36304fbef1SSimon Glass /* Dump out a tree of all devices */
37304fbef1SSimon Glass void dm_dump_all(void);
38304fbef1SSimon Glass 
39304fbef1SSimon Glass /* Dump out a list of uclasses and their devices */
40304fbef1SSimon Glass void dm_dump_uclass(void);
41304fbef1SSimon Glass 
4240b6f2d0SMasahiro Yamada #ifdef CONFIG_DEBUG_DEVRES
4340b6f2d0SMasahiro Yamada /* Dump out a list of device resources */
4440b6f2d0SMasahiro Yamada void dm_dump_devres(void);
4540b6f2d0SMasahiro Yamada #else
4640b6f2d0SMasahiro Yamada static inline void dm_dump_devres(void)
4740b6f2d0SMasahiro Yamada {
4840b6f2d0SMasahiro Yamada }
4940b6f2d0SMasahiro Yamada #endif
5040b6f2d0SMasahiro Yamada 
51*27326c7eSHeiko Stübner /**
52*27326c7eSHeiko Stübner  * Check if a dt node should be or was bound before relocation.
53*27326c7eSHeiko Stübner  *
54*27326c7eSHeiko Stübner  * Devicetree nodes can be marked as needed to be bound
55*27326c7eSHeiko Stübner  * in the loader stages via special devicetree properties.
56*27326c7eSHeiko Stübner  *
57*27326c7eSHeiko Stübner  * Before relocation this function can be used to check if nodes
58*27326c7eSHeiko Stübner  * are required in either SPL or TPL stages.
59*27326c7eSHeiko Stübner  *
60*27326c7eSHeiko Stübner  * After relocation and jumping into the real U-Boot binary
61*27326c7eSHeiko Stübner  * it is possible to determine if a node was bound in one of
62*27326c7eSHeiko Stübner  * SPL/TPL stages.
63*27326c7eSHeiko Stübner  *
64*27326c7eSHeiko Stübner  * There are 3 settings currently in use
65*27326c7eSHeiko Stübner  * -
66*27326c7eSHeiko Stübner  * - u-boot,dm-pre-reloc: legacy and indicates any of TPL or SPL
67*27326c7eSHeiko Stübner  *   Existing platforms only use it to indicate nodes needee in
68*27326c7eSHeiko Stübner  *   SPL. Should probably be replaced by u-boot,dm-spl for
69*27326c7eSHeiko Stübner  *   existing platforms.
70*27326c7eSHeiko Stübner  * @blob: devicetree
71*27326c7eSHeiko Stübner  * @offset: node offset
72*27326c7eSHeiko Stübner  *
73*27326c7eSHeiko Stübner  * Returns true if node is needed in SPL/TL, false otherwise.
74*27326c7eSHeiko Stübner  */
75*27326c7eSHeiko Stübner int dm_fdt_pre_reloc(const void *blob, int offset);
76*27326c7eSHeiko Stübner 
776494d708SSimon Glass #endif
78