1
2
3
4
5
6
7
8#ifndef _DM_OF_H
9#define _DM_OF_H
10
11#include <asm/u-boot.h>
12#include <asm/global_data.h>
13
14
15typedef u32 phandle;
16
17
18
19
20
21
22
23
24
25struct property {
26 char *name;
27 int length;
28 void *value;
29 struct property *next;
30};
31
32
33
34
35
36
37
38
39
40
41
42
43
44struct device_node {
45 const char *name;
46 const char *type;
47 phandle phandle;
48 const char *full_name;
49
50 struct property *properties;
51 struct device_node *parent;
52 struct device_node *child;
53 struct device_node *sibling;
54};
55
56#define OF_MAX_PHANDLE_ARGS 16
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81struct of_phandle_args {
82 struct device_node *np;
83 int args_count;
84 uint32_t args[OF_MAX_PHANDLE_ARGS];
85};
86
87DECLARE_GLOBAL_DATA_PTR;
88
89
90
91
92
93
94#ifdef CONFIG_OF_LIVE
95static inline bool of_live_active(void)
96{
97 return gd->of_root != NULL;
98}
99#else
100static inline bool of_live_active(void)
101{
102 return false;
103}
104#endif
105
106#define OF_BAD_ADDR ((u64)-1)
107
108static inline const char *of_node_full_name(const struct device_node *np)
109{
110 return np ? np->full_name : "<no-node>";
111}
112
113
114#if !defined(OF_ROOT_NODE_ADDR_CELLS_DEFAULT)
115#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1
116#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
117#endif
118
119
120#if !defined(of_compat_cmp)
121#define of_compat_cmp(s1, s2, l) strcasecmp((s1), (s2))
122#define of_prop_cmp(s1, s2) strcmp((s1), (s2))
123#define of_node_cmp(s1, s2) strcasecmp((s1), (s2))
124#endif
125
126
127static inline u64 of_read_number(const __be32 *cell, int size)
128{
129 u64 r = 0;
130 while (size--)
131 r = (r << 32) | be32_to_cpu(*(cell++));
132 return r;
133}
134
135
136static inline unsigned long of_read_ulong(const __be32 *cell, int size)
137{
138
139 return of_read_number(cell, size);
140}
141
142#endif
143