blob: f7a3e6cfc5fb33a139d9ef440860e8d21c8f393d [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
Alexander Grafce362522012-05-17 15:33:54 +020017void *create_device_tree(int *sizep);
pbrook7ec632b2009-04-10 16:23:59 +000018void *load_device_tree(const char *filename_path, int *sizep);
aurel32f652e6a2008-12-16 10:43:48 +000019
20int qemu_devtree_setprop(void *fdt, const char *node_path,
Alexander Graf45e9dfb2012-06-20 20:39:59 +020021 const char *property, const void *val_array, int size);
aurel32f652e6a2008-12-16 10:43:48 +000022int qemu_devtree_setprop_cell(void *fdt, const char *node_path,
23 const char *property, uint32_t val);
Alexander Grafbb28eb32012-05-18 01:53:01 +020024int qemu_devtree_setprop_u64(void *fdt, const char *node_path,
25 const char *property, uint64_t val);
aurel32f652e6a2008-12-16 10:43:48 +000026int qemu_devtree_setprop_string(void *fdt, const char *node_path,
27 const char *property, const char *string);
Alexander Graf8535ab12012-05-17 14:11:52 +020028int qemu_devtree_setprop_phandle(void *fdt, const char *node_path,
29 const char *property,
30 const char *target_node_path);
Peter Maydellf0aa7132012-07-20 13:34:50 +010031const void *qemu_devtree_getprop(void *fdt, const char *node_path,
32 const char *property, int *lenp);
33uint32_t qemu_devtree_getprop_cell(void *fdt, const char *node_path,
34 const char *property);
Alexander Graf7d5fd102012-05-17 15:23:39 +020035uint32_t qemu_devtree_get_phandle(void *fdt, const char *path);
Alexander Graf3601b572012-05-17 16:58:55 +020036uint32_t qemu_devtree_alloc_phandle(void *fdt);
Alexander Grafd69a8e62011-07-21 01:52:57 +020037int qemu_devtree_nop_node(void *fdt, const char *node_path);
Alexander Graf80ad7812011-07-22 13:55:37 +020038int qemu_devtree_add_subnode(void *fdt, const char *name);
aurel32f652e6a2008-12-16 10:43:48 +000039
Alexander Graf7ae22912012-05-17 12:47:57 +020040#define qemu_devtree_setprop_cells(fdt, node_path, property, ...) \
41 do { \
42 uint32_t qdt_tmp[] = { __VA_ARGS__ }; \
43 int i; \
44 \
45 for (i = 0; i < ARRAY_SIZE(qdt_tmp); i++) { \
46 qdt_tmp[i] = cpu_to_be32(qdt_tmp[i]); \
47 } \
48 qemu_devtree_setprop(fdt, node_path, property, qdt_tmp, \
49 sizeof(qdt_tmp)); \
50 } while (0)
51
aurel32f652e6a2008-12-16 10:43:48 +000052#endif /* __DEVICE_TREE_H__ */