Statistics
| Branch: | Revision:

root / device_tree.h @ f0aa713f

History | View | Annotate | Download (2.5 kB)

1 f652e6af aurel32
/*
2 f652e6af aurel32
 * Header with function prototypes to help device tree manipulation using
3 f652e6af aurel32
 * libfdt. It also provides functions to read entries from device tree proc
4 f652e6af aurel32
 * interface.
5 f652e6af aurel32
 *
6 f652e6af aurel32
 * Copyright 2008 IBM Corporation.
7 f652e6af aurel32
 * Authors: Jerone Young <jyoung5@us.ibm.com>
8 f652e6af aurel32
 *          Hollis Blanchard <hollisb@us.ibm.com>
9 f652e6af aurel32
 *
10 f652e6af aurel32
 * This work is licensed under the GNU GPL license version 2 or later.
11 f652e6af aurel32
 *
12 f652e6af aurel32
 */
13 f652e6af aurel32
14 f652e6af aurel32
#ifndef __DEVICE_TREE_H__
15 f652e6af aurel32
#define __DEVICE_TREE_H__
16 f652e6af aurel32
17 ce36252c Alexander Graf
void *create_device_tree(int *sizep);
18 7ec632b4 pbrook
void *load_device_tree(const char *filename_path, int *sizep);
19 f652e6af aurel32
20 f652e6af aurel32
int qemu_devtree_setprop(void *fdt, const char *node_path,
21 45e9dfb2 Alexander Graf
                         const char *property, const void *val_array, int size);
22 f652e6af aurel32
int qemu_devtree_setprop_cell(void *fdt, const char *node_path,
23 f652e6af aurel32
                              const char *property, uint32_t val);
24 bb28eb37 Alexander Graf
int qemu_devtree_setprop_u64(void *fdt, const char *node_path,
25 bb28eb37 Alexander Graf
                             const char *property, uint64_t val);
26 f652e6af aurel32
int qemu_devtree_setprop_string(void *fdt, const char *node_path,
27 f652e6af aurel32
                                const char *property, const char *string);
28 8535ab12 Alexander Graf
int qemu_devtree_setprop_phandle(void *fdt, const char *node_path,
29 8535ab12 Alexander Graf
                                 const char *property,
30 8535ab12 Alexander Graf
                                 const char *target_node_path);
31 f0aa713f Peter Maydell
const void *qemu_devtree_getprop(void *fdt, const char *node_path,
32 f0aa713f Peter Maydell
                                 const char *property, int *lenp);
33 f0aa713f Peter Maydell
uint32_t qemu_devtree_getprop_cell(void *fdt, const char *node_path,
34 f0aa713f Peter Maydell
                                   const char *property);
35 7d5fd108 Alexander Graf
uint32_t qemu_devtree_get_phandle(void *fdt, const char *path);
36 3601b572 Alexander Graf
uint32_t qemu_devtree_alloc_phandle(void *fdt);
37 d69a8e63 Alexander Graf
int qemu_devtree_nop_node(void *fdt, const char *node_path);
38 80ad7816 Alexander Graf
int qemu_devtree_add_subnode(void *fdt, const char *name);
39 f652e6af aurel32
40 7ae2291e Alexander Graf
#define qemu_devtree_setprop_cells(fdt, node_path, property, ...)             \
41 7ae2291e Alexander Graf
    do {                                                                      \
42 7ae2291e Alexander Graf
        uint32_t qdt_tmp[] = { __VA_ARGS__ };                                 \
43 7ae2291e Alexander Graf
        int i;                                                                \
44 7ae2291e Alexander Graf
                                                                              \
45 7ae2291e Alexander Graf
        for (i = 0; i < ARRAY_SIZE(qdt_tmp); i++) {                           \
46 7ae2291e Alexander Graf
            qdt_tmp[i] = cpu_to_be32(qdt_tmp[i]);                             \
47 7ae2291e Alexander Graf
        }                                                                     \
48 7ae2291e Alexander Graf
        qemu_devtree_setprop(fdt, node_path, property, qdt_tmp,               \
49 7ae2291e Alexander Graf
                             sizeof(qdt_tmp));                                \
50 7ae2291e Alexander Graf
    } while (0)
51 7ae2291e Alexander Graf
52 f652e6af aurel32
#endif /* __DEVICE_TREE_H__ */