diff options
author | Magnus Damm | 2014-06-06 12:44:43 +0200 |
---|---|---|
committer | Greg Kroah-Hartman | 2014-06-20 00:08:20 +0200 |
commit | 382063d91e15434ea3c7103934d47dcb480e0562 (patch) | |
tree | 70dd3542e78f36f356687b514641c3062f90424d /drivers/staging/board/board.c | |
parent | staging: emxx_udc: Add TODO file (diff) | |
download | kernel-qcow2-linux-382063d91e15434ea3c7103934d47dcb480e0562.tar.gz kernel-qcow2-linux-382063d91e15434ea3c7103934d47dcb480e0562.tar.xz kernel-qcow2-linux-382063d91e15434ea3c7103934d47dcb480e0562.zip |
staging: board: Initial board staging support
Add staging board base support to allow continuous upstream
in-tree development and integration of platform devices.
Helps developers integrate devices as platform devices for
device drivers that only provide platform device bindings.
This in turn allows for incremental development of both
hardware feature support and DT binding work in parallel.
Two separate pieces of board staging functionality is
provided to ease per-board staging board support:
- The board_staging() macro allows easy per-board callbacks
- The board_staging_dt_node_available() provides DT node checking
Tested on the KZM9D board with the emxx_udc staging driver.
Signed-off-by: Magnus Damm <damm+renesas@opensource.se>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/board/board.c')
-rw-r--r-- | drivers/staging/board/board.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c new file mode 100644 index 000000000000..6050fbdfd31f --- /dev/null +++ b/drivers/staging/board/board.c @@ -0,0 +1,41 @@ +#include <linux/init.h> +#include <linux/device.h> +#include <linux/kernel.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include "board.h" + +static bool find_by_address(u64 base_address) +{ + struct device_node *dn = of_find_all_nodes(NULL); + struct resource res; + + while (dn) { + if (of_can_translate_address(dn) + && !of_address_to_resource(dn, 0, &res)) { + if (res.start == base_address) { + of_node_put(dn); + return true; + } + } + dn = of_find_all_nodes(dn); + } + + return false; +} + +bool __init board_staging_dt_node_available(const struct resource *resource, + unsigned int num_resources) +{ + unsigned int i; + + for (i = 0; i < num_resources; i++) { + const struct resource *r = resource + i; + + if (resource_type(r) == IORESOURCE_MEM) + if (find_by_address(r->start)) + return true; /* DT node available */ + } + + return false; /* Nothing found */ +} |