From patchwork Tue Jun 21 13:46:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 901642 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p5LDl5Wo027955 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 21 Jun 2011 13:47:26 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QZ1I9-0008Bb-NU; Tue, 21 Jun 2011 13:46:57 +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 1QZ1I9-0005po-Bg; Tue, 21 Jun 2011 13:46:57 +0000 Received: from service87.mimecast.com ([94.185.240.25]) by canuck.infradead.org with smtp (Exim 4.76 #1 (Red Hat Linux)) id 1QZ1I1-0005pV-GZ for linux-arm-kernel@lists.infradead.org; Tue, 21 Jun 2011 13:46:54 +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 14:46:40 +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 14:46:30 +0100 Message-ID: <4E00A0BC.1090203@arm.com> Date: Tue, 21 Jun 2011 14:46:36 +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> <4E007CEB.6040104@arm.com> <4E0093CF.6030804@gmail.com> <4E009679.4010206@arm.com> <4E009A1E.1080903@gmail.com> In-Reply-To: <4E009A1E.1080903@gmail.com> X-Enigmail-Version: 1.1.2 X-OriginalArrivalTime: 21 Jun 2011 13:46:30.0427 (UTC) FILETIME=[A00AA6B0:01CC3019] X-MC-Unique: 111062114464002701 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110621_094649_906095_31F0E0AF X-CRM114-Status: GOOD ( 23.54 ) 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 , Grant Likely , 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 (demeter2.kernel.org [140.211.167.43]); Tue, 21 Jun 2011 13:47:26 +0000 (UTC) On 21/06/11 14:18, Rob Herring wrote: > On 06/21/2011 08:02 AM, Marc Zyngier wrote: >> On 21/06/11 13:51, Rob Herring wrote: >>> Marc, >>> >>> On 06/21/2011 06:13 AM, Marc Zyngier wrote: >>>> 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"; >>> >>> My understanding is device_type is only supposed to be used for devices >>> with real OpenFirmware. You could just add localtimer or timer as a 2nd >>> compatible string. I think localtimer is a bit of a Linux name, so just >>> timer may be better. >> >> Using "compatible" would not work. You'd have to add the same compatible >> string to all drivers, and get drivers probing the wrong device. Any >> other property we could use instead? > > No, I'm saying you have a compatible property like this: > > compatible = "arm,smp-twd", "timer"; > > You create the early platform device(s) based on matches with "timer", > but match the driver based on "arm,smp-twd". Right. What about the attached patch? Test-booted on the same VE with the above "compatible" property. M. From cc73614014b96f807552507d652ae7d91459f179 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 '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 --- 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..1ba304e 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 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; + int id = 0, rc = 0; + + while ((np = of_find_compatible_node(np, NULL, 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