aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-07-22 17:53:38 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-07-22 17:53:38 -0400
commit8181780c163e7111f15619067cfa044172d532e1 (patch)
tree7eec99ddd1b20e9018edfba5c05a179b317c27fe /include/linux
parent7235dd74a4733d4b3651349b5261d2e06996427d (diff)
parent99ce39e359fa29e4b609a6a13485e7573eda5dfb (diff)
Merge branch 'devicetree/next' of git://git.secretlab.ca/git/linux-2.6
* 'devicetree/next' of git://git.secretlab.ca/git/linux-2.6: dt: include linux/errno.h in linux/of_address.h of/address: Add of_find_matching_node_by_address helper dt: remove extra xsysace platform_driver registration tty/serial: Add devicetree support for nVidia Tegra serial ports dt: add empty of_property_read_u32[_array] for non-dt dt: bindings: move SEC node under new crypto/ dt: add helper function to read u32 arrays tty/serial: change of_serial to use new of_property_read_u32() api dt: add 'const' for of_property_read_string parameter **out_string dt: add helper functions to read u32 and string property values tty: of_serial: support for 32 bit accesses dt: document the of_serial bindings dt/platform: allow device name to be overridden drivers/amba: create devices from device tree dt: add of_platform_populate() for creating device from the device tree dt: Add default match table for bus ids
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/of.h29
-rw-r--r--include/linux/of_address.h5
-rw-r--r--include/linux/of_platform.h40
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(
195extern struct property *of_find_property(const struct device_node *np, 195extern struct property *of_find_property(const struct device_node *np,
196 const char *name, 196 const char *name,
197 int *lenp); 197 int *lenp);
198extern int of_property_read_u32_array(const struct device_node *np,
199 char *propname,
200 u32 *out_values,
201 size_t sz);
202
203extern int of_property_read_string(struct device_node *np, char *propname,
204 const char **out_string);
198extern int of_device_is_compatible(const struct device_node *device, 205extern int of_device_is_compatible(const struct device_node *device,
199 const char *); 206 const char *);
200extern int of_device_is_available(const struct device_node *device); 207extern int of_device_is_available(const struct device_node *device);
@@ -227,12 +234,32 @@ extern void of_attach_node(struct device_node *);
227extern void of_detach_node(struct device_node *); 234extern void of_detach_node(struct device_node *);
228#endif 235#endif
229 236
230#else 237#else /* CONFIG_OF */
231 238
232static inline bool of_have_populated_dt(void) 239static inline bool of_have_populated_dt(void)
233{ 240{
234 return false; 241 return false;
235} 242}
236 243
244static inline int of_property_read_u32_array(const struct device_node *np,
245 char *propname, u32 *out_values, size_t sz)
246{
247 return -ENOSYS;
248}
249
250static inline int of_property_read_string(struct device_node *np,
251 char *propname, const char **out_string)
252{
253 return -ENOSYS;
254}
255
237#endif /* CONFIG_OF */ 256#endif /* CONFIG_OF */
257
258static inline int of_property_read_u32(const struct device_node *np,
259 char *propname,
260 u32 *out_value)
261{
262 return of_property_read_u32_array(np, propname, out_value, 1);
263}
264
238#endif /* _LINUX_OF_H */ 265#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 @@
1#ifndef __OF_ADDRESS_H 1#ifndef __OF_ADDRESS_H
2#define __OF_ADDRESS_H 2#define __OF_ADDRESS_H
3#include <linux/ioport.h> 3#include <linux/ioport.h>
4#include <linux/errno.h>
4#include <linux/of.h> 5#include <linux/of.h>
5 6
6extern u64 of_translate_address(struct device_node *np, const __be32 *addr); 7extern u64 of_translate_address(struct device_node *np, const __be32 *addr);
7extern int of_address_to_resource(struct device_node *dev, int index, 8extern int of_address_to_resource(struct device_node *dev, int index,
8 struct resource *r); 9 struct resource *r);
10extern struct device_node *of_find_matching_node_by_address(
11 struct device_node *from,
12 const struct of_device_id *matches,
13 u64 base_address);
9extern void __iomem *of_iomap(struct device_node *device, int index); 14extern void __iomem *of_iomap(struct device_node *device, int index);
10 15
11/* Extract an address from a device, returns the region size and 16/* 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 @@
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21 21
22/** 22/**
23 * struct of_dev_auxdata - lookup table entry for device names & platform_data
24 * @compatible: compatible value of node to match against node
25 * @phys_addr: Start address of registers to match against node
26 * @name: Name to assign for matching nodes
27 * @platform_data: platform_data to assign for matching nodes
28 *
29 * This lookup table allows the caller of of_platform_populate() to override
30 * the names of devices when creating devices from the device tree. The table
31 * should be terminated with an empty entry. It also allows the platform_data
32 * pointer to be set.
33 *
34 * The reason for this functionality is that some Linux infrastructure uses
35 * the device name to look up a specific device, but the Linux-specific names
36 * are not encoded into the device tree, so the kernel needs to provide specific
37 * values.
38 *
39 * Note: Using an auxdata lookup table should be considered a last resort when
40 * converting a platform to use the DT. Normally the automatically generated
41 * device name will not matter, and drivers should obtain data from the device
42 * node instead of from an anonymouns platform_data pointer.
43 */
44struct of_dev_auxdata {
45 char *compatible;
46 resource_size_t phys_addr;
47 char *name;
48 void *platform_data;
49};
50
51/* Macro to simplify populating a lookup table */
52#define OF_DEV_AUXDATA(_compat,_phys,_name,_pdata) \
53 { .compatible = _compat, .phys_addr = _phys, .name = _name, \
54 .platform_data = _pdata }
55
56/**
23 * of_platform_driver - Legacy of-aware driver for platform devices. 57 * of_platform_driver - Legacy of-aware driver for platform devices.
24 * 58 *
25 * An of_platform_driver driver is attached to a basic platform_device on 59 * An of_platform_driver driver is attached to a basic platform_device on
@@ -40,6 +74,8 @@ struct of_platform_driver
40#define to_of_platform_driver(drv) \ 74#define to_of_platform_driver(drv) \
41 container_of(drv,struct of_platform_driver, driver) 75 container_of(drv,struct of_platform_driver, driver)
42 76
77extern const struct of_device_id of_default_bus_match_table[];
78
43/* Platform drivers register/unregister */ 79/* Platform drivers register/unregister */
44extern struct platform_device *of_device_alloc(struct device_node *np, 80extern struct platform_device *of_device_alloc(struct device_node *np,
45 const char *bus_id, 81 const char *bus_id,
@@ -55,6 +91,10 @@ extern struct platform_device *of_platform_device_create(struct device_node *np,
55extern int of_platform_bus_probe(struct device_node *root, 91extern int of_platform_bus_probe(struct device_node *root,
56 const struct of_device_id *matches, 92 const struct of_device_id *matches,
57 struct device *parent); 93 struct device *parent);
94extern int of_platform_populate(struct device_node *root,
95 const struct of_device_id *matches,
96 const struct of_dev_auxdata *lookup,
97 struct device *parent);
58#endif /* !CONFIG_SPARC */ 98#endif /* !CONFIG_SPARC */
59 99
60#endif /* CONFIG_OF_DEVICE */ 100#endif /* CONFIG_OF_DEVICE */