xref: /rk3399_ARM-atf/include/common/fdt_wrappers.h (revision be858cffa91fbcd5b8657200fbec1667c65bb1b7)
1 /*
2  * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 /* Helper functions to offer easier navigation of Device Tree Blob */
8 
9 #ifndef FDT_WRAPPERS_H
10 #define FDT_WRAPPERS_H
11 
12 /* Number of cells, given total length in bytes. Each cell is 4 bytes long */
13 #define NCELLS(len) ((len) / 4U)
14 
15 int fdt_read_uint32(const void *dtb, int node, const char *prop_name,
16 		    uint32_t *value);
17 uint32_t fdt_read_uint32_default(const void *dtb, int node,
18 				 const char *prop_name, uint32_t dflt_value);
19 int fdt_read_uint64(const void *dtb, int node, const char *prop_name,
20 		    uint64_t *value);
21 int fdt_read_uint32_array(const void *dtb, int node, const char *prop_name,
22 			  unsigned int cells, uint32_t *value);
23 int fdtw_read_string(const void *dtb, int node, const char *prop,
24 		char *str, size_t size);
25 int fdtw_write_inplace_cells(void *dtb, int node, const char *prop,
26 		unsigned int cells, void *value);
27 int fdtw_read_bytes(const void *dtb, int node, const char *prop,
28 		unsigned int length, void *value);
29 int fdtw_write_inplace_bytes(void *dtb, int node, const char *prop,
30 		unsigned int length, const void *data);
31 
32 #endif /* FDT_WRAPPERS_H */
33