From patchwork Fri Aug 2 16:25:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 2838043 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 930C2BF535 for ; Fri, 2 Aug 2013 16:27:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 83BE020299 for ; Fri, 2 Aug 2013 16:27:42 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 835B7202A7 for ; Fri, 2 Aug 2013 16:27:40 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V5IC7-0004sj-SD; Fri, 02 Aug 2013 16:27:12 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V5IBq-0007rN-A7; Fri, 02 Aug 2013 16:26:54 +0000 Received: from arroyo.ext.ti.com ([192.94.94.40]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V5IBX-0007lo-6A for linux-arm-kernel@lists.infradead.org; Fri, 02 Aug 2013 16:26:39 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id r72GQ775009111; Fri, 2 Aug 2013 11:26:07 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r72GQ78Y013082; Fri, 2 Aug 2013 11:26:07 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.2.342.3; Fri, 2 Aug 2013 11:26:07 -0500 Received: from sokoban.tieu.ti.com (h78-17.vpn.ti.com [172.24.78.17]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r72GQ2TO003114; Fri, 2 Aug 2013 11:26:05 -0500 From: Tero Kristo To: , , , , , Subject: [PATCHv5 01/31] CLK: clkdev: add support for looking up clocks from DT Date: Fri, 2 Aug 2013 19:25:20 +0300 Message-ID: <1375460751-23676-2-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1375460751-23676-1-git-send-email-t-kristo@ti.com> References: <1375460751-23676-1-git-send-email-t-kristo@ti.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130802_122635_924250_55F2C718 X-CRM114-Status: GOOD ( 11.44 ) X-Spam-Score: -8.4 (--------) Cc: devicetree@vger.kernel.org, Russell King , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP clk_get_sys / clk_get can now find clocks from device-tree. If a DT clock is found, an entry is added to the clk_lookup list also for subsequent searches. Signed-off-by: Tero Kristo Cc: Russell King --- drivers/clk/clkdev.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 442a313..cbeb252 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -93,6 +93,18 @@ struct clk *of_clk_get_by_name(struct device_node *np, const char *name) EXPORT_SYMBOL(of_clk_get_by_name); #endif +/** + * clkdev_add_nolock - add lookup entry for a clock + * @cl: pointer to new clock lookup entry + * + * Non-locking version, used internally by clk_find() to add DT based + * clock lookup entries. + */ +static void clkdev_add_nolock(struct clk_lookup *cl) +{ + list_add_tail(&cl->node, &clocks); +} + /* * Find the correct struct clk for the device and connection ID. * We do slightly fuzzy matching here: @@ -106,6 +118,9 @@ static struct clk_lookup *clk_find(const char *dev_id, const char *con_id) { struct clk_lookup *p, *cl = NULL; int match, best_found = 0, best_possible = 0; + struct device_node *node; + struct clk *clk; + struct of_phandle_args clkspec; if (dev_id) best_possible += 2; @@ -133,6 +148,24 @@ static struct clk_lookup *clk_find(const char *dev_id, const char *con_id) break; } } + + if (cl) + return cl; + + /* If clock was not found, attempt to look-up from DT */ + node = of_find_node_by_name(NULL, con_id); + + clkspec.np = node; + + clk = of_clk_get_from_provider(&clkspec); + + if (!IS_ERR(clk)) { + /* We found a clock, add node to clkdev */ + cl = clkdev_alloc(clk, con_id, dev_id); + if (cl) + clkdev_add_nolock(cl); + } + return cl; }