aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2011-03-28 21:20:53 -0600
committerGrant Likely <grant.likely@secretlab.ca>2011-03-28 21:20:53 -0600
commitc3cf74a53764b234937837e8be0a10cdb6d5ca40 (patch)
tree44406ac6cdfe266b58ca421c57ba6b35e9e28c2e /include
parent3a1a90a4cf4f0870bb6ee8065092e2c0ea7d72aa (diff)
dt: add of_platform_prepare() to match nodes with static platform_devices
This patch implements an alternate method for using device tree data for populating machine device registration. Traditionally, board support has directly generated and registered devices based on nodes in the device tree. The board support code starts at the root of the tree and begins allocating devices for each device node it finds. Similarly, bus drivers (i2c, spi, etc.) use their child nodes to register child devices. This model can be seen in almost all the powerpc board ports (arch/powerpc/platforms/*). However, for many of the ARM SoCs, there already exists complete board support for many SoCs that have their own code for registering the basic set of platform devices with non-trivial dependencies on clock structure and machine specific platform code. While starting at the base of the tree and working up is certainly possible, it requires modifying a lot of machine support code to get it working. This patch adds the function of_platform_prepare() to declare which nodes will be used to create platform_devices without actually creating them yet. Then it uses a bus notifier to inspect platform_device registrations. If any match a node declared with of_platform_prepare(), it will set the of_node pointer before the device gets bound to a driver, making the device tree data available at probe time. After all the static devices are registered, the platform code can still call either of_platform_populate or of_platform_bus_probe() on the same nodes that were declared with of_platform_prepare(). Any nodes that *were not* matched to a static platform_device will get created in the normal way. Note: Board ports using this facility are still required to provide a fully populated device tree blob. It is not a shortcut to providing an accurate device tree model of the machine to the point that it would be reasonably possible to switch to a direct registration model for all devices without change the device tree. ie. The SoC still needs to be correctly identified and there should be nodes for all the discrete devices. v2: Complete revamp to make of_platform_populate() and of_platform_bus_probe() respect the prepared nodes. Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'include')
-rw-r--r--include/linux/of_address.h1
-rw-r--r--include/linux/of_platform.h2
2 files changed, 3 insertions, 0 deletions
diff --git a/include/linux/of_address.h b/include/linux/of_address.h
index 2feda6ee614..6711d5f8bcb 100644
--- a/include/linux/of_address.h
+++ b/include/linux/of_address.h
@@ -3,6 +3,7 @@
#include <linux/ioport.h>
#include <linux/of.h>
+extern int of_address_count(struct device_node *np);
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);
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index fb9d21bdfc0..bc111d589be 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -68,6 +68,8 @@ extern struct platform_device *of_platform_device_create(struct device_node *np,
const char *bus_id,
struct device *parent);
+extern void of_platform_prepare(struct device_node *root,
+ const struct of_device_id *matches);
extern int of_platform_bus_probe(struct device_node *root,
const struct of_device_id *matches,
struct device *parent);