1
2
3
4
5
6
7#ifndef __FDT_SUPPORT_H
8#define __FDT_SUPPORT_H
9
10#ifdef CONFIG_OF_LIBFDT
11
12#include <linux/libfdt.h>
13
14u32 fdt_getprop_u32_default_node(const void *fdt, int off, int cell,
15 const char *prop, const u32 dflt);
16u32 fdt_getprop_u32_default(const void *fdt, const char *path,
17 const char *prop, const u32 dflt);
18
19
20
21
22
23
24
25
26
27int fdt_root(void *fdt);
28
29
30
31
32
33
34
35
36
37int fdt_chosen(void *fdt);
38
39
40
41
42
43
44
45int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end);
46
47void do_fixup_by_path(void *fdt, const char *path, const char *prop,
48 const void *val, int len, int create);
49void do_fixup_by_path_u32(void *fdt, const char *path, const char *prop,
50 u32 val, int create);
51
52static inline void do_fixup_by_path_string(void *fdt, const char *path,
53 const char *prop, const char *status)
54{
55 do_fixup_by_path(fdt, path, prop, status, strlen(status) + 1, 1);
56}
57
58void do_fixup_by_prop(void *fdt,
59 const char *pname, const void *pval, int plen,
60 const char *prop, const void *val, int len,
61 int create);
62void do_fixup_by_prop_u32(void *fdt,
63 const char *pname, const void *pval, int plen,
64 const char *prop, u32 val, int create);
65void do_fixup_by_compat(void *fdt, const char *compat,
66 const char *prop, const void *val, int len, int create);
67void do_fixup_by_compat_u32(void *fdt, const char *compat,
68 const char *prop, u32 val, int create);
69
70
71
72
73
74
75
76
77
78
79int fdt_fixup_memory(void *blob, u64 start, u64 size);
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95#ifdef CONFIG_ARCH_FIXUP_FDT_MEMORY
96int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks);
97int fdt_set_usable_memory(void *blob, u64 start[], u64 size[], int banks);
98#else
99static inline int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[],
100 int banks)
101{
102 return 0;
103}
104#endif
105
106void fdt_fixup_ethernet(void *fdt);
107int fdt_find_and_setprop(void *fdt, const char *node, const char *prop,
108 const void *val, int len, int create);
109void fdt_fixup_qe_firmware(void *fdt);
110
111
112
113
114
115
116
117
118
119
120
121
122int fdt_fixup_display(void *blob, const char *path, const char *display);
123
124#if defined(CONFIG_USB_EHCI_FSL) || defined(CONFIG_USB_XHCI_FSL)
125void fsl_fdt_fixup_dr_usb(void *blob, bd_t *bd);
126#else
127static inline void fsl_fdt_fixup_dr_usb(void *blob, bd_t *bd) {}
128#endif
129
130#if defined(CONFIG_SYS_FSL_SEC_COMPAT)
131void fdt_fixup_crypto_node(void *blob, int sec_rev);
132#else
133static inline void fdt_fixup_crypto_node(void *blob, int sec_rev) {}
134#endif
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150int fdt_record_loadable(void *blob, u32 index, const char *name,
151 uintptr_t load_addr, u32 size, uintptr_t entry_point,
152 const char *type, const char *os);
153
154#ifdef CONFIG_PCI
155#include <pci.h>
156int fdt_pci_dma_ranges(void *blob, int phb_off, struct pci_controller *hose);
157#endif
158
159int fdt_find_or_add_subnode(void *fdt, int parentoffset, const char *name);
160
161
162
163
164
165
166
167
168
169
170
171int ft_board_setup(void *blob, bd_t *bd);
172
173
174
175
176
177
178
179void ft_board_setup_ex(void *blob, bd_t *bd);
180void ft_cpu_setup(void *blob, bd_t *bd);
181void ft_pci_setup(void *blob, bd_t *bd);
182
183
184
185
186
187
188
189
190
191
192
193int ft_system_setup(void *blob, bd_t *bd);
194
195void set_working_fdt_addr(ulong addr);
196
197
198
199
200
201
202
203
204int fdt_shrink_to_minimum(void *blob, uint extrasize);
205int fdt_increase_size(void *fdt, int add_len);
206
207int fdt_fixup_nor_flash_size(void *blob);
208
209struct node_info;
210#if defined(CONFIG_FDT_FIXUP_PARTITIONS)
211void fdt_fixup_mtdparts(void *fdt, const struct node_info *node_info,
212 int node_info_size);
213#else
214static inline void fdt_fixup_mtdparts(void *fdt,
215 const struct node_info *node_info,
216 int node_info_size)
217{
218}
219#endif
220
221void fdt_del_node_and_alias(void *blob, const char *alias);
222
223
224
225
226
227
228
229
230
231
232
233u64 fdt_translate_address(const void *blob, int node_offset,
234 const __be32 *in_addr);
235
236
237
238
239
240
241
242
243
244
245u64 fdt_translate_dma_address(const void *blob, int node_offset,
246 const __be32 *in_addr);
247
248int fdt_node_offset_by_compat_reg(void *blob, const char *compat,
249 phys_addr_t compat_off);
250int fdt_alloc_phandle(void *blob);
251int fdt_set_phandle(void *fdt, int nodeoffset, uint32_t phandle);
252unsigned int fdt_create_phandle(void *fdt, int nodeoffset);
253int fdt_add_edid(void *blob, const char *compat, unsigned char *buf);
254
255int fdt_verify_alias_address(void *fdt, int anode, const char *alias,
256 u64 addr);
257u64 fdt_get_base_address(const void *fdt, int node);
258int fdt_read_range(void *fdt, int node, int n, uint64_t *child_addr,
259 uint64_t *addr, uint64_t *len);
260
261enum fdt_status {
262 FDT_STATUS_OKAY,
263 FDT_STATUS_DISABLED,
264 FDT_STATUS_FAIL,
265 FDT_STATUS_FAIL_ERROR_CODE,
266};
267int fdt_set_node_status(void *fdt, int nodeoffset,
268 enum fdt_status status, unsigned int error_code);
269static inline int fdt_status_okay(void *fdt, int nodeoffset)
270{
271 return fdt_set_node_status(fdt, nodeoffset, FDT_STATUS_OKAY, 0);
272}
273static inline int fdt_status_disabled(void *fdt, int nodeoffset)
274{
275 return fdt_set_node_status(fdt, nodeoffset, FDT_STATUS_DISABLED, 0);
276}
277static inline int fdt_status_fail(void *fdt, int nodeoffset)
278{
279 return fdt_set_node_status(fdt, nodeoffset, FDT_STATUS_FAIL, 0);
280}
281
282int fdt_set_status_by_alias(void *fdt, const char *alias,
283 enum fdt_status status, unsigned int error_code);
284static inline int fdt_status_okay_by_alias(void *fdt, const char *alias)
285{
286 return fdt_set_status_by_alias(fdt, alias, FDT_STATUS_OKAY, 0);
287}
288static inline int fdt_status_disabled_by_alias(void *fdt, const char *alias)
289{
290 return fdt_set_status_by_alias(fdt, alias, FDT_STATUS_DISABLED, 0);
291}
292static inline int fdt_status_fail_by_alias(void *fdt, const char *alias)
293{
294 return fdt_set_status_by_alias(fdt, alias, FDT_STATUS_FAIL, 0);
295}
296
297
298static inline u64 fdt_read_number(const fdt32_t *cell, int size)
299{
300 u64 r = 0;
301 while (size--)
302 r = (r << 32) | fdt32_to_cpu(*(cell++));
303 return r;
304}
305
306void fdt_support_default_count_cells(const void *blob, int parentoffset,
307 int *addrc, int *sizec);
308int ft_verify_fdt(void *fdt);
309int arch_fixup_memory_node(void *blob);
310
311int fdt_setup_simplefb_node(void *fdt, int node, u64 base_address, u32 width,
312 u32 height, u32 stride, const char *format);
313
314int fdt_overlay_apply_verbose(void *fdt, void *fdto);
315
316
317
318
319
320
321
322
323
324int fdt_get_cells_len(const void *blob, char *nr_cells_name);
325
326#endif
327
328#ifdef USE_HOSTCC
329int fdtdec_get_int(const void *blob, int node, const char *prop_name,
330 int default_val);
331#endif
332#ifdef CONFIG_FMAN_ENET
333int fdt_update_ethernet_dt(void *blob);
334#endif
335#ifdef CONFIG_FSL_MC_ENET
336void fdt_fixup_board_enet(void *blob);
337#endif
338#endif
339