From patchwork Tue Jun 21 11:13:47 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 901132 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5LBENTD010355 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 21 Jun 2011 11:14:47 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QYyuJ-0006jj-4Q; Tue, 21 Jun 2011 11:14:11 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QYyuI-0002kP-Oz; Tue, 21 Jun 2011 11:14:10 +0000 Received: from service87.mimecast.com ([94.185.240.25]) by canuck.infradead.org with smtp (Exim 4.76 #1 (Red Hat Linux)) id 1QYyuB-0002k4-NG for linux-arm-kernel@lists.infradead.org; Tue, 21 Jun 2011 11:14:08 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Tue, 21 Jun 2011 12:13:50 +0100 Received: from [10.1.66.40] ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 21 Jun 2011 12:13:42 +0100 Message-ID: <4E007CEB.6040104@arm.com> Date: Tue, 21 Jun 2011 12:13:47 +0100 From: Marc Zyngier User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: Rob Herring Subject: Re: [RFC PATCH 00/16] Consolidation: move SMP local timers to driver/clocksource References: <1308251204-16719-1-git-send-email-marc.zyngier@arm.com> <201106171707.23989.arnd@arndb.de> <4DFB8E20.60802@gmail.com> In-Reply-To: <4DFB8E20.60802@gmail.com> X-Enigmail-Version: 1.1.2 X-OriginalArrivalTime: 21 Jun 2011 11:13:42.0818 (UTC) FILETIME=[47B88820:01CC3004] X-MC-Unique: 111062112135002401 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110621_071404_019898_7A9272DA X-CRM114-Status: GOOD ( 17.39 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [94.185.240.25 listed in list.dnswl.org] Cc: Kukjin Kim , Erik Gilling , Linus Walleij , Arnd Bergmann , Srinidhi Kasagar , Tony Lindgren , Magnus Damm , Stephen Boyd , Bryan Huntsman , Wim Van Sebroeck , Paul Mundt , Santosh Shilimkar , Ben Dooks , Colin Cross , Olof Johansson , Daniel Walker , Thomas Gleixner , David Brown , "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 21 Jun 2011 11:14:48 +0000 (UTC) On 17/06/11 18:25, Rob Herring wrote: > Also, device tree support for early platform devices would be useful for > this. What about the attached patch? I've used it to boot a VExpress board with the following DT snippet (and the corresponding support in the amp_smp_twd driver): localtimer@2c000600 { device_type = "localtimer"; compatible = "arm,smp-twd"; reg = <0x2c000600 0x1000>; interrupts = <29>; }; Cheers, M. From b707a3a80f51c7a5a30b97d33b8b637f318cf886 Mon Sep 17 00:00:00 2001 From: Marc Zyngier Date: Tue, 21 Jun 2011 11:40:51 +0100 Subject: [PATCH] dt: early platform devices support Add support for populating early platform devices from the device tree, by walking the tree and adding nodes whose 'device_type' property matches the 'class' string passed as a parameter. This allows devices to be probed long before the whole device insfrastructure is available. Signed-off-by: Marc Zyngier --- drivers/of/platform.c | 31 +++++++++++++++++++++++++++++++ include/linux/of_platform.h | 2 ++ 2 files changed, 33 insertions(+), 0 deletions(-) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 9b785be..976a9ea 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -326,4 +326,35 @@ 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 matching the device type to register + * + * This function walks the device tree and register devices whose + * 'device_type' 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; + int id = 0, rc = 0; + + while ((np = of_find_node_by_type(np, class))) { + pdev = kzalloc(sizeof(*pdev), GFP_KERNEL); + if (!pdev) { + of_node_put(np); + rc = -ENOMEM; + break; + } + pdev->name = np->name; + pdev->id = id++; + pdev->dev.of_node = of_node_get(np); + early_platform_add_devices(&pdev, 1); + } + + return rc; +} #endif /* !CONFIG_SPARC */ diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h index 43c723d..fee17f7 100644 --- a/include/linux/of_platform.h +++ b/include/linux/of_platform.h @@ -58,6 +58,8 @@ extern int of_platform_bus_probe(struct device_node *root, extern int of_platform_populate(struct device_node *root, const struct of_device_id *matches, struct device *parent); + +extern int of_early_platform_populate(const char *class); #endif /* !CONFIG_SPARC */ #endif /* CONFIG_OF_DEVICE */ -- 1.7.0.4