aurel32 | f652e6a | 2008-12-16 10:43:48 +0000 | [diff] [blame] | 1 | /* |
| 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 Graf | ce36252 | 2012-05-17 15:33:54 +0200 | [diff] [blame^] | 17 | void *create_device_tree(int *sizep); |
pbrook | 7ec632b | 2009-04-10 16:23:59 +0000 | [diff] [blame] | 18 | void *load_device_tree(const char *filename_path, int *sizep); |
aurel32 | f652e6a | 2008-12-16 10:43:48 +0000 | [diff] [blame] | 19 | |
| 20 | int qemu_devtree_setprop(void *fdt, const char *node_path, |
David Gibson | c489749 | 2011-04-01 15:15:09 +1100 | [diff] [blame] | 21 | const char *property, void *val_array, int size); |
aurel32 | f652e6a | 2008-12-16 10:43:48 +0000 | [diff] [blame] | 22 | int qemu_devtree_setprop_cell(void *fdt, const char *node_path, |
| 23 | const char *property, uint32_t val); |
| 24 | int qemu_devtree_setprop_string(void *fdt, const char *node_path, |
| 25 | const char *property, const char *string); |
Alexander Graf | 8535ab1 | 2012-05-17 14:11:52 +0200 | [diff] [blame] | 26 | int qemu_devtree_setprop_phandle(void *fdt, const char *node_path, |
| 27 | const char *property, |
| 28 | const char *target_node_path); |
Alexander Graf | 7d5fd10 | 2012-05-17 15:23:39 +0200 | [diff] [blame] | 29 | uint32_t qemu_devtree_get_phandle(void *fdt, const char *path); |
Alexander Graf | d69a8e6 | 2011-07-21 01:52:57 +0200 | [diff] [blame] | 30 | int qemu_devtree_nop_node(void *fdt, const char *node_path); |
Alexander Graf | 80ad781 | 2011-07-22 13:55:37 +0200 | [diff] [blame] | 31 | int qemu_devtree_add_subnode(void *fdt, const char *name); |
aurel32 | f652e6a | 2008-12-16 10:43:48 +0000 | [diff] [blame] | 32 | |
Alexander Graf | 7ae2291 | 2012-05-17 12:47:57 +0200 | [diff] [blame] | 33 | #define qemu_devtree_setprop_cells(fdt, node_path, property, ...) \ |
| 34 | do { \ |
| 35 | uint32_t qdt_tmp[] = { __VA_ARGS__ }; \ |
| 36 | int i; \ |
| 37 | \ |
| 38 | for (i = 0; i < ARRAY_SIZE(qdt_tmp); i++) { \ |
| 39 | qdt_tmp[i] = cpu_to_be32(qdt_tmp[i]); \ |
| 40 | } \ |
| 41 | qemu_devtree_setprop(fdt, node_path, property, qdt_tmp, \ |
| 42 | sizeof(qdt_tmp)); \ |
| 43 | } while (0) |
| 44 | |
aurel32 | f652e6a | 2008-12-16 10:43:48 +0000 | [diff] [blame] | 45 | #endif /* __DEVICE_TREE_H__ */ |