From patchwork Wed Jun 19 13:18:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 2749171 Return-Path: X-Original-To: patchwork-linux-omap@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 3673AC0AB1 for ; Wed, 19 Jun 2013 13:19:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1081F202B7 for ; Wed, 19 Jun 2013 13:19:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4113520279 for ; Wed, 19 Jun 2013 13:19:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756732Ab3FSNTl (ORCPT ); Wed, 19 Jun 2013 09:19:41 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:39502 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756739Ab3FSNTi (ORCPT ); Wed, 19 Jun 2013 09:19:38 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id r5JDJATX001938; Wed, 19 Jun 2013 08:19:10 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r5JDJAEu026129; Wed, 19 Jun 2013 08:19:10 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.2.342.3; Wed, 19 Jun 2013 08:19:09 -0500 Received: from sokoban.tieu.ti.com (h79-27.vpn.ti.com [172.24.79.27]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r5JDJ40W024678; Wed, 19 Jun 2013 08:19:08 -0500 From: Tero Kristo To: , , , , , CC: , Subject: [PATCHv2 01/11] CLK: clkdev: add support for looking up clocks from DT Date: Wed, 19 Jun 2013 16:18:52 +0300 Message-ID: <1371647942-4811-2-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1371647942-4811-1-git-send-email-t-kristo@ti.com> References: <1371647942-4811-1-git-send-email-t-kristo@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 --- drivers/clk/clkdev.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 442a313..e39f082 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,23 @@ 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); + clkdev_add_nolock(cl); + } + return cl; }