xref: /OK3568_Linux_fs/u-boot/include/dm/util.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright (c) 2013 Google, Inc
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * SPDX-License-Identifier:	GPL-2.0+
5*4882a593Smuzhiyun  */
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun #ifndef __DM_UTIL_H
8*4882a593Smuzhiyun #define __DM_UTIL_H
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun #ifdef CONFIG_DM_WARN
11*4882a593Smuzhiyun void dm_warn(const char *fmt, ...);
12*4882a593Smuzhiyun #else
dm_warn(const char * fmt,...)13*4882a593Smuzhiyun static inline void dm_warn(const char *fmt, ...)
14*4882a593Smuzhiyun {
15*4882a593Smuzhiyun }
16*4882a593Smuzhiyun #endif
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun struct list_head;
19*4882a593Smuzhiyun 
20*4882a593Smuzhiyun /**
21*4882a593Smuzhiyun  * list_count_items() - Count number of items in a list
22*4882a593Smuzhiyun  *
23*4882a593Smuzhiyun  * @param head:		Head of list
24*4882a593Smuzhiyun  * @return number of items, or 0 if empty
25*4882a593Smuzhiyun  */
26*4882a593Smuzhiyun int list_count_items(struct list_head *head);
27*4882a593Smuzhiyun 
28*4882a593Smuzhiyun /* Dump out a tree of all devices */
29*4882a593Smuzhiyun void dm_dump_all(void);
30*4882a593Smuzhiyun 
31*4882a593Smuzhiyun /* Dump out a list of uclasses and their devices */
32*4882a593Smuzhiyun void dm_dump_uclass(void);
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun #ifdef CONFIG_DEBUG_DEVRES
35*4882a593Smuzhiyun /* Dump out a list of device resources */
36*4882a593Smuzhiyun void dm_dump_devres(void);
37*4882a593Smuzhiyun #else
dm_dump_devres(void)38*4882a593Smuzhiyun static inline void dm_dump_devres(void)
39*4882a593Smuzhiyun {
40*4882a593Smuzhiyun }
41*4882a593Smuzhiyun #endif
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun /**
44*4882a593Smuzhiyun  * Check if a dt node should be or was bound before relocation.
45*4882a593Smuzhiyun  *
46*4882a593Smuzhiyun  * Devicetree nodes can be marked as needed to be bound
47*4882a593Smuzhiyun  * in the loader stages via special devicetree properties.
48*4882a593Smuzhiyun  *
49*4882a593Smuzhiyun  * Before relocation this function can be used to check if nodes
50*4882a593Smuzhiyun  * are required in either SPL or TPL stages.
51*4882a593Smuzhiyun  *
52*4882a593Smuzhiyun  * After relocation and jumping into the real U-Boot binary
53*4882a593Smuzhiyun  * it is possible to determine if a node was bound in one of
54*4882a593Smuzhiyun  * SPL/TPL stages.
55*4882a593Smuzhiyun  *
56*4882a593Smuzhiyun  * There are 3 settings currently in use
57*4882a593Smuzhiyun  * -
58*4882a593Smuzhiyun  * - u-boot,dm-pre-reloc: legacy and indicates any of TPL or SPL
59*4882a593Smuzhiyun  *   Existing platforms only use it to indicate nodes needee in
60*4882a593Smuzhiyun  *   SPL. Should probably be replaced by u-boot,dm-spl for
61*4882a593Smuzhiyun  *   existing platforms.
62*4882a593Smuzhiyun  * @blob: devicetree
63*4882a593Smuzhiyun  * @offset: node offset
64*4882a593Smuzhiyun  *
65*4882a593Smuzhiyun  * Returns true if node is needed in SPL/TL, false otherwise.
66*4882a593Smuzhiyun  */
67*4882a593Smuzhiyun bool dm_fdt_pre_reloc(const void *blob, int offset);
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun #endif
70