diff options
Diffstat (limited to 'include/linux/of.h')
| -rw-r--r-- | include/linux/of.h | 45 | 
1 files changed, 45 insertions, 0 deletions
diff --git a/include/linux/of.h b/include/linux/of.h index 29f0adc5f3e4..1a66b8881c01 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -23,6 +23,7 @@  #include <linux/spinlock.h>  #include <linux/topology.h>  #include <linux/notifier.h> +#include <linux/property.h>  #include <asm/byteorder.h>  #include <asm/errno.h> @@ -49,6 +50,7 @@ struct device_node {  	const char *type;  	phandle phandle;  	const char *full_name; +	struct fwnode_handle fwnode;  	struct	property *properties;  	struct	property *deadprops;	/* removed properties */ @@ -79,6 +81,7 @@ extern struct kobj_type of_node_ktype;  static inline void of_node_init(struct device_node *node)  {  	kobject_init(&node->kobj, &of_node_ktype); +	node->fwnode.type = FWNODE_OF;  }  /* true when node is initialized */ @@ -114,6 +117,16 @@ extern struct device_node *of_aliases;  extern struct device_node *of_stdout;  extern raw_spinlock_t devtree_lock; +static inline bool is_of_node(struct fwnode_handle *fwnode) +{ +	return fwnode && fwnode->type == FWNODE_OF; +} + +static inline struct device_node *of_node(struct fwnode_handle *fwnode) +{ +	return fwnode ? container_of(fwnode, struct device_node, fwnode) : NULL; +} +  static inline bool of_have_populated_dt(void)  {  	return of_allnodes != NULL; @@ -263,6 +276,10 @@ extern int of_property_read_u32_array(const struct device_node *np,  				      size_t sz);  extern int of_property_read_u64(const struct device_node *np,  				const char *propname, u64 *out_value); +extern int of_property_read_u64_array(const struct device_node *np, +				      const char *propname, +				      u64 *out_values, +				      size_t sz);  extern int of_property_read_string(struct device_node *np,  				   const char *propname, @@ -355,6 +372,16 @@ bool of_console_check(struct device_node *dn, char *name, int index);  #else /* CONFIG_OF */ +static inline bool is_of_node(struct fwnode_handle *fwnode) +{ +	return false; +} + +static inline struct device_node *of_node(struct fwnode_handle *fwnode) +{ +	return NULL; +} +  static inline const char* of_node_full_name(const struct device_node *np)  {  	return "<no-node>"; @@ -477,6 +504,13 @@ static inline int of_property_read_u32_array(const struct device_node *np,  	return -ENOSYS;  } +static inline int of_property_read_u64_array(const struct device_node *np, +					     const char *propname, +					     u64 *out_values, size_t sz) +{ +	return -ENOSYS; +} +  static inline int of_property_read_string(struct device_node *np,  					  const char *propname,  					  const char **out_string) @@ -922,4 +956,15 @@ static inline int of_changeset_update_property(struct of_changeset *ocs,  /* CONFIG_OF_RESOLVE api */  extern int of_resolve_phandles(struct device_node *tree); +/** + * of_device_is_system_power_controller - Tells if system-power-controller is found for device_node + * @np: Pointer to the given device_node + * + * return true if present false otherwise + */ +static inline bool of_device_is_system_power_controller(const struct device_node *np) +{ +	return of_property_read_bool(np, "system-power-controller"); +} +  #endif /* _LINUX_OF_H */  | 
