From patchwork Tue Jul 23 07:20:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 2831784 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 EFEA8C0319 for ; Tue, 23 Jul 2013 07:25:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AFBBB2011D for ; Tue, 23 Jul 2013 07:25:11 +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 4732F20117 for ; Tue, 23 Jul 2013 07:25:10 +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 1V1WwC-0003oO-Db; Tue, 23 Jul 2013 07:23: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 1V1Wvn-0000ln-Gk; Tue, 23 Jul 2013 07:22:47 +0000 Received: from bear.ext.ti.com ([192.94.94.41]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V1Wv3-0000d7-NX for linux-arm-kernel@lists.infradead.org; Tue, 23 Jul 2013 07:22:05 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id r6N7Lfgd005186; Tue, 23 Jul 2013 02:21:41 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r6N7Lf01025749; Tue, 23 Jul 2013 02:21:41 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.2.342.3; Tue, 23 Jul 2013 02:21:40 -0500 Received: from sokoban.tieu.ti.com (h79-8.vpn.ti.com [172.24.79.8]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r6N7LQtZ027090; Tue, 23 Jul 2013 02:21:38 -0500 From: Tero Kristo To: , , , , , , Subject: [PATCHv4 05/33] CLK: omap: add DT duplicate clock registration mechanism Date: Tue, 23 Jul 2013 10:20:00 +0300 Message-ID: <1374564028-11352-6-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1374564028-11352-1-git-send-email-t-kristo@ti.com> References: <1374564028-11352-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-20130723_032201_919431_C32FE5F9 X-CRM114-Status: GOOD ( 14.15 ) X-Spam-Score: -8.4 (--------) Cc: devicetree-discuss@lists.ozlabs.org, 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=-4.2 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 Some devices require their clocks to be available with a specific dev-id con-id mapping. With DT, the clocks can be found by default only with their name, or alternatively through the device node of the consumer. With drivers, that don't support DT fully yet, add mechanism to register specific clock names. Signed-off-by: Tero Kristo --- drivers/clk/omap/clk.c | 39 +++++++++++++++++++++++++++++++++++++++ include/linux/clk/omap.h | 17 +++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/drivers/clk/omap/clk.c b/drivers/clk/omap/clk.c index 1dafdaa..cd31a81 100644 --- a/drivers/clk/omap/clk.c +++ b/drivers/clk/omap/clk.c @@ -32,6 +32,45 @@ static const struct of_device_id clk_match[] = { {}, }; + /** + * omap_dt_clocks_register - register DT duplicate clocks during boot + * @oclks: list of clocks to register + * @cnt: number of clocks + * + * Register duplicate or non-standard DT clock entries during boot. By + * default, DT clocks are found based on their node name. If any + * additional con-id / dev-id -> clock mapping is required, use this + * function to list these. + */ +void __init omap_dt_clocks_register(struct omap_dt_clk oclks[], int cnt) +{ + struct omap_dt_clk *c; + struct device_node *n; + struct clk *clk; + struct of_phandle_args clkspec; + + for (c = oclks; c < oclks + cnt; c++) { + n = of_find_node_by_name(NULL, c->node_name); + + if (!n) { + pr_err("%s: %s not found!\n", __func__, c->node_name); + continue; + } + + clkspec.np = n; + + clk = of_clk_get_from_provider(&clkspec); + + if (!clk) { + pr_err("%s: %s has no clock!\n", __func__, + c->node_name); + continue; + } + c->lk.clk = clk; + clkdev_add(&c->lk); + } +} + /* FIXME - need to initialize early; skip real driver registration & probe */ int __init dt_omap_clk_init(void) { diff --git a/include/linux/clk/omap.h b/include/linux/clk/omap.h index cba892a..c39e775 100644 --- a/include/linux/clk/omap.h +++ b/include/linux/clk/omap.h @@ -19,6 +19,8 @@ #ifndef __LINUX_CLK_OMAP_H_ #define __LINUX_CLK_OMAP_H_ +#include + /** * struct dpll_data - DPLL registers and integration data * @mult_div1_reg: register containing the DPLL M and N bitfields @@ -146,6 +148,20 @@ struct clk_hw_omap_ops { void (*deny_idle)(struct clk_hw_omap *oclk); }; +struct omap_dt_clk { + struct clk_lookup lk; + const char *node_name; +}; + +#define DT_CLK(dev, con, name) \ + { \ + .lk = { \ + .dev_id = dev, \ + .con_id = con, \ + }, \ + .node_name = name, \ + } + void omap2_init_clk_hw_omap_clocks(struct clk *clk); int omap3_noncore_dpll_enable(struct clk_hw *hw); void omap3_noncore_dpll_disable(struct clk_hw *hw); @@ -174,6 +190,7 @@ extern const struct clk_hw_omap_ops clkhwops_omap4_dpllmx; /* DT functions */ int dt_omap_clk_init(void); +extern void omap_dt_clocks_register(struct omap_dt_clk *oclks, int cnt); void of_omap4_dpll_setup(struct device_node *node); #endif