xref: /rk3399_rockchip-uboot/include/dm/util.h (revision d42197e44e9091ec4553b74a54a8502a2415a09f)
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
dm_warn(const char * fmt,...)13a94f468fSSimon Glass static inline void dm_warn(const char *fmt, ...)
14a94f468fSSimon Glass {
15a94f468fSSimon Glass }
16a94f468fSSimon Glass #endif
176494d708SSimon Glass 
186494d708SSimon Glass struct list_head;
196494d708SSimon Glass 
206494d708SSimon Glass /**
216494d708SSimon Glass  * list_count_items() - Count number of items in a list
226494d708SSimon Glass  *
236494d708SSimon Glass  * @param head:		Head of list
246494d708SSimon Glass  * @return number of items, or 0 if empty
256494d708SSimon Glass  */
266494d708SSimon Glass int list_count_items(struct list_head *head);
276494d708SSimon Glass 
28304fbef1SSimon Glass /* Dump out a tree of all devices */
29304fbef1SSimon Glass void dm_dump_all(void);
30304fbef1SSimon Glass 
31304fbef1SSimon Glass /* Dump out a list of uclasses and their devices */
32304fbef1SSimon Glass void dm_dump_uclass(void);
33304fbef1SSimon Glass 
3440b6f2d0SMasahiro Yamada #ifdef CONFIG_DEBUG_DEVRES
3540b6f2d0SMasahiro Yamada /* Dump out a list of device resources */
3640b6f2d0SMasahiro Yamada void dm_dump_devres(void);
3740b6f2d0SMasahiro Yamada #else
dm_dump_devres(void)3840b6f2d0SMasahiro Yamada static inline void dm_dump_devres(void)
3940b6f2d0SMasahiro Yamada {
4040b6f2d0SMasahiro Yamada }
4140b6f2d0SMasahiro Yamada #endif
4240b6f2d0SMasahiro Yamada 
4327326c7eSHeiko Stübner /**
4427326c7eSHeiko Stübner  * Check if a dt node should be or was bound before relocation.
4527326c7eSHeiko Stübner  *
4627326c7eSHeiko Stübner  * Devicetree nodes can be marked as needed to be bound
4727326c7eSHeiko Stübner  * in the loader stages via special devicetree properties.
4827326c7eSHeiko Stübner  *
4927326c7eSHeiko Stübner  * Before relocation this function can be used to check if nodes
5027326c7eSHeiko Stübner  * are required in either SPL or TPL stages.
5127326c7eSHeiko Stübner  *
5227326c7eSHeiko Stübner  * After relocation and jumping into the real U-Boot binary
5327326c7eSHeiko Stübner  * it is possible to determine if a node was bound in one of
5427326c7eSHeiko Stübner  * SPL/TPL stages.
5527326c7eSHeiko Stübner  *
5627326c7eSHeiko Stübner  * There are 3 settings currently in use
5727326c7eSHeiko Stübner  * -
5827326c7eSHeiko Stübner  * - u-boot,dm-pre-reloc: legacy and indicates any of TPL or SPL
5927326c7eSHeiko Stübner  *   Existing platforms only use it to indicate nodes needee in
6027326c7eSHeiko Stübner  *   SPL. Should probably be replaced by u-boot,dm-spl for
6127326c7eSHeiko Stübner  *   existing platforms.
6227326c7eSHeiko Stübner  * @blob: devicetree
6327326c7eSHeiko Stübner  * @offset: node offset
6427326c7eSHeiko Stübner  *
6527326c7eSHeiko Stübner  * Returns true if node is needed in SPL/TL, false otherwise.
6627326c7eSHeiko Stübner  */
67*d905cf73SHeiko Stübner bool dm_fdt_pre_reloc(const void *blob, int offset);
6827326c7eSHeiko Stübner 
696494d708SSimon Glass #endif
70