summaryrefslogtreecommitdiff
path: root/drivers/staging
diff options
context:
space:
mode:
authorMagnus Damm <damm+renesas@opensource.se>2014-06-06 19:44:43 +0900
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-06-19 15:08:20 -0700
commit382063d91e15434ea3c7103934d47dcb480e0562 (patch)
tree70dd3542e78f36f356687b514641c3062f90424d /drivers/staging
parent8a62956efdee95e4f2236e5da7c4dd725e68862f (diff)
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')
-rw-r--r--drivers/staging/Kconfig2
-rw-r--r--drivers/staging/Makefile1
-rw-r--r--drivers/staging/board/Kconfig8
-rw-r--r--drivers/staging/board/Makefile1
-rw-r--r--drivers/staging/board/TODO2
-rw-r--r--drivers/staging/board/board.c41
-rw-r--r--drivers/staging/board/board.h20
7 files changed, 75 insertions, 0 deletions
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index a511efc1b3c7..4030a0575172 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -110,6 +110,8 @@ source "drivers/staging/media/Kconfig"
source "drivers/staging/android/Kconfig"
+source "drivers/staging/board/Kconfig"
+
source "drivers/staging/ozwpan/Kconfig"
source "drivers/staging/gdm72xx/Kconfig"
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index e5039056266d..93bd37ed5e8e 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -48,6 +48,7 @@ obj-$(CONFIG_TOUCHSCREEN_CLEARPAD_TM1217) += cptm1217/
obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI4) += ste_rmi4/
obj-$(CONFIG_MFD_NVEC) += nvec/
obj-$(CONFIG_ANDROID) += android/
+obj-$(CONFIG_STAGING_BOARD) += board/
obj-$(CONFIG_USB_WPAN_HCD) += ozwpan/
obj-$(CONFIG_WIMAX_GDM72XX) += gdm72xx/
obj-$(CONFIG_LTE_GDM724X) += gdm724x/
diff --git a/drivers/staging/board/Kconfig b/drivers/staging/board/Kconfig
new file mode 100644
index 000000000000..09d94b48c9c9
--- /dev/null
+++ b/drivers/staging/board/Kconfig
@@ -0,0 +1,8 @@
+config STAGING_BOARD
+ boolean "Staging Board Support"
+ depends on OF_ADDRESS
+ help
+ Select to enable per-board staging support code.
+
+ If in doubt, say N here.
+
diff --git a/drivers/staging/board/Makefile b/drivers/staging/board/Makefile
new file mode 100644
index 000000000000..1550b5f5f16e
--- /dev/null
+++ b/drivers/staging/board/Makefile
@@ -0,0 +1 @@
+obj-y := board.o
diff --git a/drivers/staging/board/TODO b/drivers/staging/board/TODO
new file mode 100644
index 000000000000..8db70e10aa67
--- /dev/null
+++ b/drivers/staging/board/TODO
@@ -0,0 +1,2 @@
+* replace platform device code with DT nodes once the driver supports DT
+* remove staging board code when no more platform devices are needed
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 */
+}
diff --git a/drivers/staging/board/board.h b/drivers/staging/board/board.h
new file mode 100644
index 000000000000..2390ed6c31a4
--- /dev/null
+++ b/drivers/staging/board/board.h
@@ -0,0 +1,20 @@
+#ifndef __BOARD_H__
+#define __BOARD_H__
+#include <linux/init.h>
+#include <linux/of.h>
+
+bool board_staging_dt_node_available(const struct resource *resource,
+ unsigned int num_resources);
+
+#define board_staging(str, fn) \
+static int __init runtime_board_check(void) \
+{ \
+ if (of_machine_is_compatible(str)) \
+ fn(); \
+ \
+ return 0; \
+} \
+ \
+late_initcall(runtime_board_check)
+
+#endif /* __BOARD_H__ */