devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <marc.zyngier-5wv7dgnIgG8@public.gmane.org>
To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Subject: [RFC PATCH 1/4] dt: early platform devices support
Date: Fri, 24 Jun 2011 15:10:56 +0100	[thread overview]
Message-ID: <1308924659-31894-2-git-send-email-marc.zyngier@arm.com> (raw)
In-Reply-To: <1308924659-31894-1-git-send-email-marc.zyngier-5wv7dgnIgG8@public.gmane.org>

Add support for populating early platform devices from the device
tree, by walking the tree and adding nodes whose 'compatible'
property matches the 'class' string passed as a parameter.

This allows devices to be probed long before the whole device
infrastructure is available.

Signed-off-by: Marc Zyngier <marc.zyngier-5wv7dgnIgG8@public.gmane.org>
---
 drivers/of/platform.c       |   26 ++++++++++++++++++++++++++
 include/linux/of_platform.h |    1 +
 2 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index e75af39..2a323ee 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -458,4 +458,30 @@ int of_platform_populate(struct device_node *root,
 	of_node_put(root);
 	return rc;
 }
+
+/**
+ * of_early_platform_populate() - Populate early platform devices from DT
+ * @class: string to compare to the 'compatible' attributes
+ *
+ * This function walks the device tree and register devices whose
+ * 'compatible' property matches the 'class' parameter.
+ *
+ * Returns 0 on success, < 0 on failure.
+ */
+int of_early_platform_populate(const char *class)
+{
+	struct platform_device *pdev;
+	struct device_node *np = NULL;
+
+	while ((np = of_find_compatible_node(np, NULL, class))) {
+		pdev = of_device_alloc(np, NULL, NULL);
+		if (!pdev)
+			return -ENOMEM;
+		list_del(&pdev->dev.devres_head);
+		memset(&pdev->dev.devres_head, 0, sizeof(pdev->dev.devres_head));
+		early_platform_add_devices(&pdev, 1);
+	}
+
+	return 0;
+}
 #endif /* !CONFIG_SPARC */
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index 5a6f458..dd1dc90 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -95,6 +95,7 @@ extern int of_platform_populate(struct device_node *root,
 				const struct of_device_id *matches,
 				const struct of_dev_auxdata *lookup,
 				struct device *parent);
+extern int of_early_platform_populate(const char *class);
 #endif /* !CONFIG_SPARC */
 
 #endif /* CONFIG_OF_DEVICE */
-- 
1.7.0.4

  parent reply	other threads:[~2011-06-24 14:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-24 14:10 [RFC PATCH 0/4] DT support for ARM GIC and TWD Marc Zyngier
     [not found] ` <1308924659-31894-1-git-send-email-marc.zyngier-5wv7dgnIgG8@public.gmane.org>
2011-06-24 14:10   ` Marc Zyngier [this message]
     [not found]     ` <1308924659-31894-2-git-send-email-marc.zyngier-5wv7dgnIgG8@public.gmane.org>
2011-06-25  4:49       ` [RFC PATCH 1/4] dt: early platform devices support Grant Likely
2011-06-25 11:11         ` Marc Zyngier
     [not found]           ` <20110625121142.4c73ca70-cwr+A0SHHwyvmEsGQKTYaQ42X47YVq0KHZ5vskTnxNA@public.gmane.org>
2011-06-25 20:44             ` Grant Likely
2011-06-27  9:54               ` Marc Zyngier
2011-06-24 14:10   ` [RFC PATCH 2/4] ARM: dt: register local timers as early platform devices Marc Zyngier
2011-06-25 20:47     ` Grant Likely
     [not found]       ` <20110625204742.GB15026-e0URQFbLeQY2iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2011-06-25 21:20         ` Rob Herring
     [not found]           ` <4E06513B.4030706-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-06-26  7:00             ` Grant Likely
     [not found]               ` <BANLkTimy6iyQyyvNUK3Kc6skSKyVxBwWPA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-06-26 19:22                 ` "Early" devices and the DT Mitch Bradley
     [not found]                   ` <4E0786FF.9010002-D5eQfiDGL7eakBO8gow8eQ@public.gmane.org>
2011-06-26 21:24                     ` glikely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org
2011-06-24 14:10   ` [RFC PATCH 3/4] ARM: dt: add GIC bindings and driver support Marc Zyngier
     [not found]     ` <1308924659-31894-4-git-send-email-marc.zyngier-5wv7dgnIgG8@public.gmane.org>
2011-06-26  8:01       ` Grant Likely
     [not found]         ` <20110626080135.GC15026-e0URQFbLeQY2iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2011-06-27 10:27           ` Marc Zyngier
     [not found]             ` <4E085B2E.5030605-5wv7dgnIgG8@public.gmane.org>
2011-06-27 15:02               ` Grant Likely
2011-06-24 14:10   ` [RFC PATCH 4/4] ARM: dt: Add TWD " Marc Zyngier
     [not found]     ` <1308924659-31894-5-git-send-email-marc.zyngier-5wv7dgnIgG8@public.gmane.org>
2011-06-26  8:09       ` Grant Likely
     [not found]         ` <20110626080902.GA24241-e0URQFbLeQY2iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2011-06-27 10:39           ` Marc Zyngier

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=1308924659-31894-2-git-send-email-marc.zyngier@arm.com \
    --to=marc.zyngier-5wv7dgnigg8@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    /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).