From: Magnus Damm <magnus.damm@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: devel@driverdev.osuosl.org, linux-sh@vger.kernel.org,
gregkh@linuxfoundation.org, horms@verge.net.au,
geert@linux-m68k.org, laurent.pinchart@ideasonboard.com,
olof@lixom.net, Magnus Damm <magnus.damm@gmail.com>,
dan.carpenter@oracle.com
Subject: [PATCH v2 04/05] staging: board: Initial board staging support
Date: Thu, 29 May 2014 13:17:32 +0000 [thread overview]
Message-ID: <20140529131732.2329.50630.sendpatchset@w520> (raw)
In-Reply-To: <20140529131650.2329.3197.sendpatchset@w520>
From: Magnus Damm <damm+renesas@opensource.se>
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>
---
Changes since V1:
- New broken out staging board base support
- Added the function board_staging_dt_node_available()
- Added a TODO file
drivers/staging/Kconfig | 2 +
drivers/staging/Makefile | 1
drivers/staging/board/Kconfig | 7 ++++++
drivers/staging/board/Makefile | 1
drivers/staging/board/TODO | 2 +
drivers/staging/board/board.c | 41 ++++++++++++++++++++++++++++++++++++++++
drivers/staging/board/board.h | 20 +++++++++++++++++++
7 files changed, 74 insertions(+)
--- 0008/drivers/staging/Kconfig
+++ work/drivers/staging/Kconfig 2014-05-29 21:40:40.000000000 +0900
@@ -112,6 +112,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"
--- 0008/drivers/staging/Makefile
+++ work/drivers/staging/Makefile 2014-05-29 21:40:40.000000000 +0900
@@ -49,6 +49,7 @@ obj-$(CONFIG_TOUCHSCREEN_CLEARPAD_TM1217
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/
--- /dev/null
+++ work/drivers/staging/board/Kconfig 2014-05-29 21:40:41.000000000 +0900
@@ -0,0 +1,7 @@
+config STAGING_BOARD
+ boolean "Staging Board Support"
+ help
+ Select to enable per-board staging support code.
+
+ If in doubt, say N here.
+
--- /dev/null
+++ work/drivers/staging/board/Makefile 2014-05-29 21:40:41.000000000 +0900
@@ -0,0 +1 @@
+obj-y := board.o
--- /dev/null
+++ work/drivers/staging/board/TODO 2014-05-29 21:40:41.000000000 +0900
@@ -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
--- /dev/null
+++ work/drivers/staging/board/board.c 2014-05-29 21:46:32.000000000 +0900
@@ -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 */
+}
--- /dev/null
+++ work/drivers/staging/board/board.h 2014-05-29 21:40:41.000000000 +0900
@@ -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__ */
next prev parent reply other threads:[~2014-05-29 13:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-29 13:16 [PATCH v2 00/05] staging: Emma Mobile USB driver and KZM9D board code V2 Magnus Damm
2014-05-29 13:17 ` [PATCH v2 02/05] staging: emxx_udc: I/O memory and IRQ resource support Magnus Damm
2014-05-29 13:17 ` [PATCH v2 03/05] staging: emxx_udc: Add TODO file Magnus Damm
2014-05-29 13:17 ` Magnus Damm [this message]
2014-05-29 13:20 ` [PATCH v2 04/05] staging: board: Initial board staging support Dan Carpenter
2014-05-29 13:27 ` Magnus Damm
2014-05-29 13:53 ` Magnus Damm
2014-05-29 14:03 ` Paul Bolle
2014-05-30 6:23 ` Magnus Damm
2014-05-29 23:10 ` Simon Horman
2014-06-06 12:07 ` Magnus Damm
2014-06-10 1:56 ` Simon Horman
2014-05-29 13:17 ` [PATCH v2 05/05] staging: board: kzm9d: Board staging support for emxx_udc Magnus Damm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140529131732.2329.50630.sendpatchset@w520 \
--to=magnus.damm@gmail.com \
--cc=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=horms@verge.net.au \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=olof@lixom.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).