blob: 754bd2b2ec731d4c108f4f3b4da2f4cd5396c667 [file] [log] [blame]
aurel32f652e6a2008-12-16 10:43:48 +00001/*
2 * Header with function prototypes to help device tree manipulation using
3 * libfdt. It also provides functions to read entries from device tree proc
4 * interface.
5 *
6 * Copyright 2008 IBM Corporation.
7 * Authors: Jerone Young <jyoung5@us.ibm.com>
8 * Hollis Blanchard <hollisb@us.ibm.com>
9 *
10 * This work is licensed under the GNU GPL license version 2 or later.
11 *
12 */
13
14#ifndef __DEVICE_TREE_H__
15#define __DEVICE_TREE_H__
16
pbrook7ec632b2009-04-10 16:23:59 +000017void *load_device_tree(const char *filename_path, int *sizep);
aurel32f652e6a2008-12-16 10:43:48 +000018
19int qemu_devtree_setprop(void *fdt, const char *node_path,
David Gibsonc4897492011-04-01 15:15:09 +110020 const char *property, void *val_array, int size);
aurel32f652e6a2008-12-16 10:43:48 +000021int qemu_devtree_setprop_cell(void *fdt, const char *node_path,
22 const char *property, uint32_t val);
23int qemu_devtree_setprop_string(void *fdt, const char *node_path,
24 const char *property, const char *string);
Alexander Graf8535ab12012-05-17 14:11:52 +020025int qemu_devtree_setprop_phandle(void *fdt, const char *node_path,
26 const char *property,
27 const char *target_node_path);
Alexander Grafd69a8e62011-07-21 01:52:57 +020028int qemu_devtree_nop_node(void *fdt, const char *node_path);
Alexander Graf80ad7812011-07-22 13:55:37 +020029int qemu_devtree_add_subnode(void *fdt, const char *name);
aurel32f652e6a2008-12-16 10:43:48 +000030
Alexander Graf7ae22912012-05-17 12:47:57 +020031#define qemu_devtree_setprop_cells(fdt, node_path, property, ...) \
32 do { \
33 uint32_t qdt_tmp[] = { __VA_ARGS__ }; \
34 int i; \
35 \
36 for (i = 0; i < ARRAY_SIZE(qdt_tmp); i++) { \
37 qdt_tmp[i] = cpu_to_be32(qdt_tmp[i]); \
38 } \
39 qemu_devtree_setprop(fdt, node_path, property, qdt_tmp, \
40 sizeof(qdt_tmp)); \
41 } while (0)
42
aurel32f652e6a2008-12-16 10:43:48 +000043#endif /* __DEVICE_TREE_H__ */