diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/of.h | 29 | ||||
-rw-r--r-- | include/linux/of_address.h | 5 | ||||
-rw-r--r-- | include/linux/of_platform.h | 40 |
3 files changed, 73 insertions, 1 deletions
diff --git a/include/linux/of.h b/include/linux/of.h index bfc0ed1b0ced..bd716f8908de 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -195,6 +195,13 @@ extern struct device_node *of_find_node_with_property( extern struct property *of_find_property(const struct device_node *np, const char *name, int *lenp); +extern int of_property_read_u32_array(const struct device_node *np, + char *propname, + u32 *out_values, + size_t sz); + +extern int of_property_read_string(struct device_node *np, char *propname, + const char **out_string); extern int of_device_is_compatible(const struct device_node *device, const char *); extern int of_device_is_available(const struct device_node *device); @@ -227,12 +234,32 @@ extern void of_attach_node(struct device_node *); extern void of_detach_node(struct device_node *); #endif -#else +#else /* CONFIG_OF */ static inline bool of_have_populated_dt(void) { return false; } +static inline int of_property_read_u32_array(const struct device_node *np, + char *propname, u32 *out_values, size_t sz) +{ + return -ENOSYS; +} + +static inline int of_property_read_string(struct device_node *np, + char *propname, const char **out_string) +{ + return -ENOSYS; +} + #endif /* CONFIG_OF */ + +static inline int of_property_read_u32(const struct device_node *np, + char *propname, + u32 *out_value) +{ + return of_property_read_u32_array(np, propname, out_value, 1); +} + #endif /* _LINUX_OF_H */ diff --git a/include/linux/of_address.h b/include/linux/of_address.h index 2feda6ee6140..3118623c2c1f 100644 --- a/include/linux/of_address.h +++ b/include/linux/of_address.h @@ -1,11 +1,16 @@ #ifndef __OF_ADDRESS_H #define __OF_ADDRESS_H #include <linux/ioport.h> +#include <linux/errno.h> #include <linux/of.h> extern u64 of_translate_address(struct device_node *np, const __be32 *addr); extern int of_address_to_resource(struct device_node *dev, int index, struct resource *r); +extern struct device_node *of_find_matching_node_by_address( + struct device_node *from, + const struct of_device_id *matches, + u64 base_address); extern void __iomem *of_iomap(struct device_node *device, int index); /* Extract an address from a device, returns the region size and diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h index fb51ae38cea7..5a6f458a4bb7 100644 --- a/include/linux/of_platform.h +++ b/include/linux/of_platform.h @@ -20,6 +20,40 @@ #include <linux/platform_device.h> /** + * struct of_dev_auxdata - lookup table entry for device names & platform_data + * @compatible: compatible value of node to match against node + * @phys_addr: Start address of registers to match against node + * @name: Name to assign for matching nodes + * @platform_data: platform_data to assign for matching nodes + * + * This lookup table allows the caller of of_platform_populate() to override + * the names of devices when creating devices from the device tree. The table + * should be terminated with an empty entry. It also allows the platform_data + * pointer to be set. + * + * The reason for this functionality is that some Linux infrastructure uses + * the device name to look up a specific device, but the Linux-specific names + * are not encoded into the device tree, so the kernel needs to provide specific + * values. + * + * Note: Using an auxdata lookup table should be considered a last resort when + * converting a platform to use the DT. Normally the automatically generated + * device name will not matter, and drivers should obtain data from the device + * node instead of from an anonymouns platform_data pointer. + */ +struct of_dev_auxdata { + char *compatible; + resource_size_t phys_addr; + char *name; + void *platform_data; +}; + +/* Macro to simplify populating a lookup table */ +#define OF_DEV_AUXDATA(_compat,_phys,_name,_pdata) \ + { .compatible = _compat, .phys_addr = _phys, .name = _name, \ + .platform_data = _pdata } + +/** * of_platform_driver - Legacy of-aware driver for platform devices. * * An of_platform_driver driver is attached to a basic platform_device on @@ -40,6 +74,8 @@ struct of_platform_driver #define to_of_platform_driver(drv) \ container_of(drv,struct of_platform_driver, driver) +extern const struct of_device_id of_default_bus_match_table[]; + /* Platform drivers register/unregister */ extern struct platform_device *of_device_alloc(struct device_node *np, const char *bus_id, @@ -55,6 +91,10 @@ extern struct platform_device *of_platform_device_create(struct device_node *np, extern int of_platform_bus_probe(struct device_node *root, const struct of_device_id *matches, struct device *parent); +extern int of_platform_populate(struct device_node *root, + const struct of_device_id *matches, + const struct of_dev_auxdata *lookup, + struct device *parent); #endif /* !CONFIG_SPARC */ #endif /* CONFIG_OF_DEVICE */ |