diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-02-25 18:38:37 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-02-25 18:38:37 -0500 |
commit | 6ebdc661b608671e9ca572af8bb42d58108cc008 (patch) | |
tree | e99caacb964a27caeae699160fa5eddcb14526e9 /include | |
parent | d7930c9ef9cc67044f5ddaac54d06ca22645a012 (diff) | |
parent | df0edeb59eb559be0bee53452fda2f5cc0ae133f (diff) |
Merge branch 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6
* 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6: (41 commits)
of: remove undefined request_OF_resource & release_OF_resource
of/sparc: Remove sparc-local declaration of allnodes and devtree_lock
of: move definition of of_chosen into common code.
of: remove unused extern reference to devtree_lock
of: put default string compare and #a/s-cell values into common header
of/flattree: Don't assume HAVE_LMB
of: protect linux/of.h with CONFIG_OF
proc_devtree: fix THIS_MODULE without module.h
of: Remove old and misplaced function declarations
of/flattree: Make the kernel accept ePAPR style phandle information
of/flattree: endian-convert members of boot_param_header
of: assume big-endian properties, adding conversions where necessary
of: use __be32 for cell value accessors
of/flattree: use OF_ROOT_NODE_{SIZE,ADDR}_CELLS DEFAULT for fdt parsing
of/flattree: use callback to setup initrd from /chosen
proc_devtree: include linux/of.h
of: make set_node_proc_entry private to proc_devtree.c
of: include linux/proc_fs.h
of/flattree: merge early_init_dt_scan_memory() common code
of: add 'of_' prefix to machine_is_compatible()
...
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/of.h | 62 | ||||
-rw-r--r-- | include/linux/of_fdt.h | 75 |
2 files changed, 90 insertions, 47 deletions
diff --git a/include/linux/of.h b/include/linux/of.h index e7facd8fbce8..f6d9cbc39c9c 100644 --- a/include/linux/of.h +++ b/include/linux/of.h | |||
@@ -19,6 +19,11 @@ | |||
19 | #include <linux/bitops.h> | 19 | #include <linux/bitops.h> |
20 | #include <linux/kref.h> | 20 | #include <linux/kref.h> |
21 | #include <linux/mod_devicetable.h> | 21 | #include <linux/mod_devicetable.h> |
22 | #include <linux/spinlock.h> | ||
23 | |||
24 | #include <asm/byteorder.h> | ||
25 | |||
26 | #ifdef CONFIG_OF | ||
22 | 27 | ||
23 | typedef u32 phandle; | 28 | typedef u32 phandle; |
24 | typedef u32 ihandle; | 29 | typedef u32 ihandle; |
@@ -39,10 +44,7 @@ struct of_irq_controller; | |||
39 | struct device_node { | 44 | struct device_node { |
40 | const char *name; | 45 | const char *name; |
41 | const char *type; | 46 | const char *type; |
42 | phandle node; | 47 | phandle phandle; |
43 | #if !defined(CONFIG_SPARC) | ||
44 | phandle linux_phandle; | ||
45 | #endif | ||
46 | char *full_name; | 48 | char *full_name; |
47 | 49 | ||
48 | struct property *properties; | 50 | struct property *properties; |
@@ -63,6 +65,11 @@ struct device_node { | |||
63 | #endif | 65 | #endif |
64 | }; | 66 | }; |
65 | 67 | ||
68 | /* Pointer for first entry in chain of all nodes. */ | ||
69 | extern struct device_node *allnodes; | ||
70 | extern struct device_node *of_chosen; | ||
71 | extern rwlock_t devtree_lock; | ||
72 | |||
66 | static inline int of_node_check_flag(struct device_node *n, unsigned long flag) | 73 | static inline int of_node_check_flag(struct device_node *n, unsigned long flag) |
67 | { | 74 | { |
68 | return test_bit(flag, &n->_flags); | 75 | return test_bit(flag, &n->_flags); |
@@ -73,12 +80,6 @@ static inline void of_node_set_flag(struct device_node *n, unsigned long flag) | |||
73 | set_bit(flag, &n->_flags); | 80 | set_bit(flag, &n->_flags); |
74 | } | 81 | } |
75 | 82 | ||
76 | static inline void | ||
77 | set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de) | ||
78 | { | ||
79 | dn->pde = de; | ||
80 | } | ||
81 | |||
82 | extern struct device_node *of_find_all_nodes(struct device_node *prev); | 83 | extern struct device_node *of_find_all_nodes(struct device_node *prev); |
83 | 84 | ||
84 | #if defined(CONFIG_SPARC) | 85 | #if defined(CONFIG_SPARC) |
@@ -101,26 +102,36 @@ extern void of_node_put(struct device_node *node); | |||
101 | */ | 102 | */ |
102 | 103 | ||
103 | /* Helper to read a big number; size is in cells (not bytes) */ | 104 | /* Helper to read a big number; size is in cells (not bytes) */ |
104 | static inline u64 of_read_number(const u32 *cell, int size) | 105 | static inline u64 of_read_number(const __be32 *cell, int size) |
105 | { | 106 | { |
106 | u64 r = 0; | 107 | u64 r = 0; |
107 | while (size--) | 108 | while (size--) |
108 | r = (r << 32) | *(cell++); | 109 | r = (r << 32) | be32_to_cpu(*(cell++)); |
109 | return r; | 110 | return r; |
110 | } | 111 | } |
111 | 112 | ||
112 | /* Like of_read_number, but we want an unsigned long result */ | 113 | /* Like of_read_number, but we want an unsigned long result */ |
113 | #ifdef CONFIG_PPC32 | 114 | static inline unsigned long of_read_ulong(const __be32 *cell, int size) |
114 | static inline unsigned long of_read_ulong(const u32 *cell, int size) | ||
115 | { | 115 | { |
116 | return cell[size-1]; | 116 | /* toss away upper bits if unsigned long is smaller than u64 */ |
117 | return of_read_number(cell, size); | ||
117 | } | 118 | } |
118 | #else | ||
119 | #define of_read_ulong(cell, size) of_read_number(cell, size) | ||
120 | #endif | ||
121 | 119 | ||
122 | #include <asm/prom.h> | 120 | #include <asm/prom.h> |
123 | 121 | ||
122 | /* Default #address and #size cells. Allow arch asm/prom.h to override */ | ||
123 | #if !defined(OF_ROOT_NODE_ADDR_CELLS_DEFAULT) | ||
124 | #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1 | ||
125 | #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 | ||
126 | #endif | ||
127 | |||
128 | /* Default string compare functions, Allow arch asm/prom.h to override */ | ||
129 | #if !defined(of_compat_cmp) | ||
130 | #define of_compat_cmp(s1, s2, l) strncasecmp((s1), (s2), (l)) | ||
131 | #define of_prop_cmp(s1, s2) strcmp((s1), (s2)) | ||
132 | #define of_node_cmp(s1, s2) strcasecmp((s1), (s2)) | ||
133 | #endif | ||
134 | |||
124 | /* flag descriptions */ | 135 | /* flag descriptions */ |
125 | #define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */ | 136 | #define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */ |
126 | #define OF_DETACHED 2 /* node has been detached from the device tree */ | 137 | #define OF_DETACHED 2 /* node has been detached from the device tree */ |
@@ -187,4 +198,19 @@ extern int of_parse_phandles_with_args(struct device_node *np, | |||
187 | const char *list_name, const char *cells_name, int index, | 198 | const char *list_name, const char *cells_name, int index, |
188 | struct device_node **out_node, const void **out_args); | 199 | struct device_node **out_node, const void **out_args); |
189 | 200 | ||
201 | extern int of_machine_is_compatible(const char *compat); | ||
202 | |||
203 | extern int prom_add_property(struct device_node* np, struct property* prop); | ||
204 | extern int prom_remove_property(struct device_node *np, struct property *prop); | ||
205 | extern int prom_update_property(struct device_node *np, | ||
206 | struct property *newprop, | ||
207 | struct property *oldprop); | ||
208 | |||
209 | #if defined(CONFIG_OF_DYNAMIC) | ||
210 | /* For updating the device tree at runtime */ | ||
211 | extern void of_attach_node(struct device_node *); | ||
212 | extern void of_detach_node(struct device_node *); | ||
213 | #endif | ||
214 | |||
215 | #endif /* CONFIG_OF */ | ||
190 | #endif /* _LINUX_OF_H */ | 216 | #endif /* _LINUX_OF_H */ |
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index 41d432b13553..a1ca92ccb0ff 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h | |||
@@ -42,45 +42,62 @@ | |||
42 | * ends when size is 0 | 42 | * ends when size is 0 |
43 | */ | 43 | */ |
44 | struct boot_param_header { | 44 | struct boot_param_header { |
45 | u32 magic; /* magic word OF_DT_HEADER */ | 45 | __be32 magic; /* magic word OF_DT_HEADER */ |
46 | u32 totalsize; /* total size of DT block */ | 46 | __be32 totalsize; /* total size of DT block */ |
47 | u32 off_dt_struct; /* offset to structure */ | 47 | __be32 off_dt_struct; /* offset to structure */ |
48 | u32 off_dt_strings; /* offset to strings */ | 48 | __be32 off_dt_strings; /* offset to strings */ |
49 | u32 off_mem_rsvmap; /* offset to memory reserve map */ | 49 | __be32 off_mem_rsvmap; /* offset to memory reserve map */ |
50 | u32 version; /* format version */ | 50 | __be32 version; /* format version */ |
51 | u32 last_comp_version; /* last compatible version */ | 51 | __be32 last_comp_version; /* last compatible version */ |
52 | /* version 2 fields below */ | 52 | /* version 2 fields below */ |
53 | u32 boot_cpuid_phys; /* Physical CPU id we're booting on */ | 53 | __be32 boot_cpuid_phys; /* Physical CPU id we're booting on */ |
54 | /* version 3 fields below */ | 54 | /* version 3 fields below */ |
55 | u32 dt_strings_size; /* size of the DT strings block */ | 55 | __be32 dt_strings_size; /* size of the DT strings block */ |
56 | /* version 17 fields below */ | 56 | /* version 17 fields below */ |
57 | u32 dt_struct_size; /* size of the DT structure block */ | 57 | __be32 dt_struct_size; /* size of the DT structure block */ |
58 | }; | 58 | }; |
59 | 59 | ||
60 | /* TBD: Temporary export of fdt globals - remove when code fully merged */ | ||
61 | extern int __initdata dt_root_addr_cells; | ||
62 | extern int __initdata dt_root_size_cells; | ||
63 | extern struct boot_param_header *initial_boot_params; | ||
64 | |||
60 | /* For scanning the flat device-tree at boot time */ | 65 | /* For scanning the flat device-tree at boot time */ |
61 | extern int __init of_scan_flat_dt(int (*it)(unsigned long node, | 66 | extern char *find_flat_dt_string(u32 offset); |
62 | const char *uname, int depth, | 67 | extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname, |
63 | void *data), | 68 | int depth, void *data), |
64 | void *data); | 69 | void *data); |
65 | extern void __init *of_get_flat_dt_prop(unsigned long node, const char *name, | 70 | extern void *of_get_flat_dt_prop(unsigned long node, const char *name, |
66 | unsigned long *size); | 71 | unsigned long *size); |
67 | extern int __init of_flat_dt_is_compatible(unsigned long node, | 72 | extern int of_flat_dt_is_compatible(unsigned long node, const char *name); |
68 | const char *name); | 73 | extern unsigned long of_get_flat_dt_root(void); |
69 | extern unsigned long __init of_get_flat_dt_root(void); | 74 | extern void early_init_dt_scan_chosen_arch(unsigned long node); |
75 | extern int early_init_dt_scan_chosen(unsigned long node, const char *uname, | ||
76 | int depth, void *data); | ||
77 | extern void early_init_dt_check_for_initrd(unsigned long node); | ||
78 | extern int early_init_dt_scan_memory(unsigned long node, const char *uname, | ||
79 | int depth, void *data); | ||
80 | extern void early_init_dt_add_memory_arch(u64 base, u64 size); | ||
81 | extern u64 early_init_dt_alloc_memory_arch(u64 size, u64 align); | ||
82 | extern u64 dt_mem_next_cell(int s, __be32 **cellp); | ||
83 | |||
84 | /* | ||
85 | * If BLK_DEV_INITRD, the fdt early init code will call this function, | ||
86 | * to be provided by the arch code. start and end are specified as | ||
87 | * physical addresses. | ||
88 | */ | ||
89 | #ifdef CONFIG_BLK_DEV_INITRD | ||
90 | extern void early_init_dt_setup_initrd_arch(unsigned long start, | ||
91 | unsigned long end); | ||
92 | #endif | ||
93 | |||
94 | /* Early flat tree scan hooks */ | ||
95 | extern int early_init_dt_scan_root(unsigned long node, const char *uname, | ||
96 | int depth, void *data); | ||
70 | 97 | ||
71 | /* Other Prototypes */ | 98 | /* Other Prototypes */ |
72 | extern void finish_device_tree(void); | ||
73 | extern void unflatten_device_tree(void); | 99 | extern void unflatten_device_tree(void); |
74 | extern void early_init_devtree(void *); | 100 | extern void early_init_devtree(void *); |
75 | extern int machine_is_compatible(const char *compat); | ||
76 | extern void print_properties(struct device_node *node); | ||
77 | extern int prom_n_intr_cells(struct device_node* np); | ||
78 | extern void prom_get_irq_senses(unsigned char *senses, int off, int max); | ||
79 | extern int prom_add_property(struct device_node* np, struct property* prop); | ||
80 | extern int prom_remove_property(struct device_node *np, struct property *prop); | ||
81 | extern int prom_update_property(struct device_node *np, | ||
82 | struct property *newprop, | ||
83 | struct property *oldprop); | ||
84 | 101 | ||
85 | #endif /* __ASSEMBLY__ */ | 102 | #endif /* __ASSEMBLY__ */ |
86 | #endif /* _LINUX_OF_FDT_H */ | 103 | #endif /* _LINUX_OF_FDT_H */ |