aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-12-11 16:06:58 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-11 16:06:58 -0500
commit7ef58b32f571bffb7763c6252ad7527562081f34 (patch)
tree6d1493304ec7a47e4d9e3e84dc9f6e53547dff91 /include
parent413fd0e3fbf52873f2310eb75bfa6c7b72847277 (diff)
parentc46ca3c8310b61d253a39ff1375ea97912794cd1 (diff)
Merge tag 'devicetree-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/glikely/linux
Pull devicetree changes from Grant Likely: "Lots of activity in the devicetree code for v3.18. Most of it is related to getting all of the overlay support code in place, but there are other important things in there. Highlights: - OF_RECONFIG notifiers for SPI, I2C and Platform devices. Those subsystems can now respond to live changes to the device tree. - CONFIG_OF_OVERLAY method for applying live changes to the device tree - Removal of the of_allnodes list. This used to be used to iterate over all the nodes in the device tree, but it is unnecessary because the same thing can be done by iterating over the list of child pointers. Getting rid of of_allnodes saves some memory and avoids the possibility of of_allnodes being sorted differently from the child lists. - Support for retrieving original DTB blob via sysfs. Needed by kexec. - More unittests - Documentation and minor bug fixes" * tag 'devicetree-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/glikely/linux: (42 commits) of: Delete unnecessary check before calling "of_node_put()" of: Drop ->next pointer from struct device_node spi: Check for spi_of_notifier when CONFIG_OF_DYNAMIC=y of: support passing console options with stdout-path of: add optional options parameter to of_find_node_by_path() of: Add bindings for chosen node, stdout-path of: Remove unneeded and incorrect MODULE_DEVICE_TABLE ARM: dt: fix up PL011 device tree bindings of: base, fix of_property_read_string_helper kernel-doc of: remove select of non-existant OF_DEVICE config symbol spi/of: Add OF notifier handler spi/of: Create new device registration method and accessors i2c/of: Add OF_RECONFIG notifier handler i2c/of: Factor out Devicetree registration code of/overlay: Add overlay unittests of/overlay: Introduce DT overlay support of/reconfig: Add OF_DYNAMIC notifier for platform_bus_type of/reconfig: Always use the same structure for notifiers of/reconfig: Add debug output for OF_RECONFIG notifiers of/reconfig: Add empty stubs for the of_reconfig methods ...
Diffstat (limited to 'include')
-rw-r--r--include/linux/of.h121
-rw-r--r--include/linux/of_address.h4
-rw-r--r--include/linux/of_pdt.h3
-rw-r--r--include/linux/of_platform.h6
4 files changed, 108 insertions, 26 deletions
diff --git a/include/linux/of.h b/include/linux/of.h
index b47096730dc5..dfde07e77a63 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -24,6 +24,7 @@
24#include <linux/topology.h> 24#include <linux/topology.h>
25#include <linux/notifier.h> 25#include <linux/notifier.h>
26#include <linux/property.h> 26#include <linux/property.h>
27#include <linux/list.h>
27 28
28#include <asm/byteorder.h> 29#include <asm/byteorder.h>
29#include <asm/errno.h> 30#include <asm/errno.h>
@@ -57,8 +58,6 @@ struct device_node {
57 struct device_node *parent; 58 struct device_node *parent;
58 struct device_node *child; 59 struct device_node *child;
59 struct device_node *sibling; 60 struct device_node *sibling;
60 struct device_node *next; /* next device of same type */
61 struct device_node *allnext; /* next in list of all nodes */
62 struct kobject kobj; 61 struct kobject kobj;
63 unsigned long _flags; 62 unsigned long _flags;
64 void *data; 63 void *data;
@@ -76,6 +75,12 @@ struct of_phandle_args {
76 uint32_t args[MAX_PHANDLE_ARGS]; 75 uint32_t args[MAX_PHANDLE_ARGS];
77}; 76};
78 77
78struct of_reconfig_data {
79 struct device_node *dn;
80 struct property *prop;
81 struct property *old_prop;
82};
83
79/* initialize a node */ 84/* initialize a node */
80extern struct kobj_type of_node_ktype; 85extern struct kobj_type of_node_ktype;
81static inline void of_node_init(struct device_node *node) 86static inline void of_node_init(struct device_node *node)
@@ -109,7 +114,7 @@ static inline void of_node_put(struct device_node *node) { }
109#endif /* !CONFIG_OF_DYNAMIC */ 114#endif /* !CONFIG_OF_DYNAMIC */
110 115
111/* Pointer for first entry in chain of all nodes. */ 116/* Pointer for first entry in chain of all nodes. */
112extern struct device_node *of_allnodes; 117extern struct device_node *of_root;
113extern struct device_node *of_chosen; 118extern struct device_node *of_chosen;
114extern struct device_node *of_aliases; 119extern struct device_node *of_aliases;
115extern struct device_node *of_stdout; 120extern struct device_node *of_stdout;
@@ -128,7 +133,7 @@ static inline struct device_node *of_node(struct fwnode_handle *fwnode)
128 133
129static inline bool of_have_populated_dt(void) 134static inline bool of_have_populated_dt(void)
130{ 135{
131 return of_allnodes != NULL; 136 return of_root != NULL;
132} 137}
133 138
134static inline bool of_node_is_root(const struct device_node *node) 139static inline bool of_node_is_root(const struct device_node *node)
@@ -172,6 +177,7 @@ static inline void of_property_clear_flag(struct property *p, unsigned long flag
172 clear_bit(flag, &p->_flags); 177 clear_bit(flag, &p->_flags);
173} 178}
174 179
180extern struct device_node *__of_find_all_nodes(struct device_node *prev);
175extern struct device_node *of_find_all_nodes(struct device_node *prev); 181extern struct device_node *of_find_all_nodes(struct device_node *prev);
176 182
177/* 183/*
@@ -227,8 +233,9 @@ static inline const char *of_node_full_name(const struct device_node *np)
227 return np ? np->full_name : "<no-node>"; 233 return np ? np->full_name : "<no-node>";
228} 234}
229 235
230#define for_each_of_allnodes(dn) \ 236#define for_each_of_allnodes_from(from, dn) \
231 for (dn = of_allnodes; dn; dn = dn->allnext) 237 for (dn = __of_find_all_nodes(from); dn; dn = __of_find_all_nodes(dn))
238#define for_each_of_allnodes(dn) for_each_of_allnodes_from(NULL, dn)
232extern struct device_node *of_find_node_by_name(struct device_node *from, 239extern struct device_node *of_find_node_by_name(struct device_node *from,
233 const char *name); 240 const char *name);
234extern struct device_node *of_find_node_by_type(struct device_node *from, 241extern struct device_node *of_find_node_by_type(struct device_node *from,
@@ -240,7 +247,13 @@ extern struct device_node *of_find_matching_node_and_match(
240 const struct of_device_id *matches, 247 const struct of_device_id *matches,
241 const struct of_device_id **match); 248 const struct of_device_id **match);
242 249
243extern struct device_node *of_find_node_by_path(const char *path); 250extern struct device_node *of_find_node_opts_by_path(const char *path,
251 const char **opts);
252static inline struct device_node *of_find_node_by_path(const char *path)
253{
254 return of_find_node_opts_by_path(path, NULL);
255}
256
244extern struct device_node *of_find_node_by_phandle(phandle handle); 257extern struct device_node *of_find_node_by_phandle(phandle handle);
245extern struct device_node *of_get_parent(const struct device_node *node); 258extern struct device_node *of_get_parent(const struct device_node *node);
246extern struct device_node *of_get_next_parent(struct device_node *node); 259extern struct device_node *of_get_next_parent(struct device_node *node);
@@ -291,7 +304,7 @@ extern int of_property_read_string_helper(struct device_node *np,
291 const char **out_strs, size_t sz, int index); 304 const char **out_strs, size_t sz, int index);
292extern int of_device_is_compatible(const struct device_node *device, 305extern int of_device_is_compatible(const struct device_node *device,
293 const char *); 306 const char *);
294extern int of_device_is_available(const struct device_node *device); 307extern bool of_device_is_available(const struct device_node *device);
295extern const void *of_get_property(const struct device_node *node, 308extern const void *of_get_property(const struct device_node *node,
296 const char *name, 309 const char *name,
297 int *lenp); 310 int *lenp);
@@ -333,16 +346,6 @@ extern int of_update_property(struct device_node *np, struct property *newprop);
333#define OF_RECONFIG_REMOVE_PROPERTY 0x0004 346#define OF_RECONFIG_REMOVE_PROPERTY 0x0004
334#define OF_RECONFIG_UPDATE_PROPERTY 0x0005 347#define OF_RECONFIG_UPDATE_PROPERTY 0x0005
335 348
336struct of_prop_reconfig {
337 struct device_node *dn;
338 struct property *prop;
339 struct property *old_prop;
340};
341
342extern int of_reconfig_notifier_register(struct notifier_block *);
343extern int of_reconfig_notifier_unregister(struct notifier_block *);
344extern int of_reconfig_notify(unsigned long, void *);
345
346extern int of_attach_node(struct device_node *); 349extern int of_attach_node(struct device_node *);
347extern int of_detach_node(struct device_node *); 350extern int of_detach_node(struct device_node *);
348 351
@@ -411,6 +414,12 @@ static inline struct device_node *of_find_node_by_path(const char *path)
411 return NULL; 414 return NULL;
412} 415}
413 416
417static inline struct device_node *of_find_node_opts_by_path(const char *path,
418 const char **opts)
419{
420 return NULL;
421}
422
414static inline struct device_node *of_get_parent(const struct device_node *node) 423static inline struct device_node *of_get_parent(const struct device_node *node)
415{ 424{
416 return NULL; 425 return NULL;
@@ -452,9 +461,9 @@ static inline int of_device_is_compatible(const struct device_node *device,
452 return 0; 461 return 0;
453} 462}
454 463
455static inline int of_device_is_available(const struct device_node *device) 464static inline bool of_device_is_available(const struct device_node *device)
456{ 465{
457 return 0; 466 return false;
458} 467}
459 468
460static inline struct property *of_find_property(const struct device_node *np, 469static inline struct property *of_find_property(const struct device_node *np,
@@ -793,6 +802,13 @@ static inline int of_property_read_u32(const struct device_node *np,
793 return of_property_read_u32_array(np, propname, out_value, 1); 802 return of_property_read_u32_array(np, propname, out_value, 1);
794} 803}
795 804
805static inline int of_property_read_s32(const struct device_node *np,
806 const char *propname,
807 s32 *out_value)
808{
809 return of_property_read_u32(np, propname, (u32*) out_value);
810}
811
796#define of_property_for_each_u32(np, propname, prop, p, u) \ 812#define of_property_for_each_u32(np, propname, prop, p, u) \
797 for (prop = of_find_property(np, propname, NULL), \ 813 for (prop = of_find_property(np, propname, NULL), \
798 p = of_prop_next_u32(prop, NULL, &u); \ 814 p = of_prop_next_u32(prop, NULL, &u); \
@@ -861,7 +877,7 @@ static inline int of_get_available_child_count(const struct device_node *np)
861 = { .compatible = compat, \ 877 = { .compatible = compat, \
862 .data = (fn == (fn_type)NULL) ? fn : fn } 878 .data = (fn == (fn_type)NULL) ? fn : fn }
863#else 879#else
864#define _OF_DECLARE(table, name, compat, fn, fn_type) \ 880#define _OF_DECLARE(table, name, compat, fn, fn_type) \
865 static const struct of_device_id __of_table_##name \ 881 static const struct of_device_id __of_table_##name \
866 __attribute__((unused)) \ 882 __attribute__((unused)) \
867 = { .compatible = compat, \ 883 = { .compatible = compat, \
@@ -912,7 +928,19 @@ struct of_changeset {
912 struct list_head entries; 928 struct list_head entries;
913}; 929};
914 930
931enum of_reconfig_change {
932 OF_RECONFIG_NO_CHANGE = 0,
933 OF_RECONFIG_CHANGE_ADD,
934 OF_RECONFIG_CHANGE_REMOVE,
935};
936
915#ifdef CONFIG_OF_DYNAMIC 937#ifdef CONFIG_OF_DYNAMIC
938extern int of_reconfig_notifier_register(struct notifier_block *);
939extern int of_reconfig_notifier_unregister(struct notifier_block *);
940extern int of_reconfig_notify(unsigned long, struct of_reconfig_data *rd);
941extern int of_reconfig_get_state_change(unsigned long action,
942 struct of_reconfig_data *arg);
943
916extern void of_changeset_init(struct of_changeset *ocs); 944extern void of_changeset_init(struct of_changeset *ocs);
917extern void of_changeset_destroy(struct of_changeset *ocs); 945extern void of_changeset_destroy(struct of_changeset *ocs);
918extern int of_changeset_apply(struct of_changeset *ocs); 946extern int of_changeset_apply(struct of_changeset *ocs);
@@ -950,7 +978,26 @@ static inline int of_changeset_update_property(struct of_changeset *ocs,
950{ 978{
951 return of_changeset_action(ocs, OF_RECONFIG_UPDATE_PROPERTY, np, prop); 979 return of_changeset_action(ocs, OF_RECONFIG_UPDATE_PROPERTY, np, prop);
952} 980}
953#endif 981#else /* CONFIG_OF_DYNAMIC */
982static inline int of_reconfig_notifier_register(struct notifier_block *nb)
983{
984 return -EINVAL;
985}
986static inline int of_reconfig_notifier_unregister(struct notifier_block *nb)
987{
988 return -EINVAL;
989}
990static inline int of_reconfig_notify(unsigned long action,
991 struct of_reconfig_data *arg)
992{
993 return -EINVAL;
994}
995static inline int of_reconfig_get_state_change(unsigned long action,
996 struct of_reconfig_data *arg)
997{
998 return -EINVAL;
999}
1000#endif /* CONFIG_OF_DYNAMIC */
954 1001
955/* CONFIG_OF_RESOLVE api */ 1002/* CONFIG_OF_RESOLVE api */
956extern int of_resolve_phandles(struct device_node *tree); 1003extern int of_resolve_phandles(struct device_node *tree);
@@ -966,4 +1013,34 @@ static inline bool of_device_is_system_power_controller(const struct device_node
966 return of_property_read_bool(np, "system-power-controller"); 1013 return of_property_read_bool(np, "system-power-controller");
967} 1014}
968 1015
1016/**
1017 * Overlay support
1018 */
1019
1020#ifdef CONFIG_OF_OVERLAY
1021
1022/* ID based overlays; the API for external users */
1023int of_overlay_create(struct device_node *tree);
1024int of_overlay_destroy(int id);
1025int of_overlay_destroy_all(void);
1026
1027#else
1028
1029static inline int of_overlay_create(struct device_node *tree)
1030{
1031 return -ENOTSUPP;
1032}
1033
1034static inline int of_overlay_destroy(int id)
1035{
1036 return -ENOTSUPP;
1037}
1038
1039static inline int of_overlay_destroy_all(void)
1040{
1041 return -ENOTSUPP;
1042}
1043
1044#endif
1045
969#endif /* _LINUX_OF_H */ 1046#endif /* _LINUX_OF_H */
diff --git a/include/linux/of_address.h b/include/linux/of_address.h
index 8cb14eb393d6..d88e81be6368 100644
--- a/include/linux/of_address.h
+++ b/include/linux/of_address.h
@@ -106,7 +106,7 @@ extern int of_address_to_resource(struct device_node *dev, int index,
106 struct resource *r); 106 struct resource *r);
107void __iomem *of_iomap(struct device_node *node, int index); 107void __iomem *of_iomap(struct device_node *node, int index);
108void __iomem *of_io_request_and_map(struct device_node *device, 108void __iomem *of_io_request_and_map(struct device_node *device,
109 int index, char *name); 109 int index, const char *name);
110#else 110#else
111 111
112#include <linux/io.h> 112#include <linux/io.h>
@@ -123,7 +123,7 @@ static inline void __iomem *of_iomap(struct device_node *device, int index)
123} 123}
124 124
125static inline void __iomem *of_io_request_and_map(struct device_node *device, 125static inline void __iomem *of_io_request_and_map(struct device_node *device,
126 int index, char *name) 126 int index, const char *name)
127{ 127{
128 return IOMEM_ERR_PTR(-EINVAL); 128 return IOMEM_ERR_PTR(-EINVAL);
129} 129}
diff --git a/include/linux/of_pdt.h b/include/linux/of_pdt.h
index c65a18a0cfdf..7e09244bb679 100644
--- a/include/linux/of_pdt.h
+++ b/include/linux/of_pdt.h
@@ -39,7 +39,6 @@ extern void *prom_early_alloc(unsigned long size);
39/* for building the device tree */ 39/* for building the device tree */
40extern void of_pdt_build_devicetree(phandle root_node, struct of_pdt_ops *ops); 40extern void of_pdt_build_devicetree(phandle root_node, struct of_pdt_ops *ops);
41 41
42extern void (*of_pdt_build_more)(struct device_node *dp, 42extern void (*of_pdt_build_more)(struct device_node *dp);
43 struct device_node ***nextp);
44 43
45#endif /* _LINUX_OF_PDT_H */ 44#endif /* _LINUX_OF_PDT_H */
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index c2b0627a2317..8a860f096c35 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -84,4 +84,10 @@ static inline int of_platform_populate(struct device_node *root,
84static inline void of_platform_depopulate(struct device *parent) { } 84static inline void of_platform_depopulate(struct device *parent) { }
85#endif 85#endif
86 86
87#ifdef CONFIG_OF_DYNAMIC
88extern void of_platform_register_reconfig_notifier(void);
89#else
90static inline void of_platform_register_reconfig_notifier(void) { }
91#endif
92
87#endif /* _LINUX_OF_PLATFORM_H */ 93#endif /* _LINUX_OF_PLATFORM_H */