From patchwork Tue Jun 25 12:38:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 2776551 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9823F9F3A0 for ; Tue, 25 Jun 2013 13:06:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5F422201FE for ; Tue, 25 Jun 2013 13:06:53 +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 21E82201EE for ; Tue, 25 Jun 2013 13:06:49 +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 1UrSZh-0005Pw-Nl; Tue, 25 Jun 2013 12:42:22 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UrSYi-00077S-0U; Tue, 25 Jun 2013 12:41:20 +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 1UrSWk-0006yx-0C for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2013 12:39:23 +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 r5PCcxZJ006729; Tue, 25 Jun 2013 07:38:59 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r5PCcxw0003409; Tue, 25 Jun 2013 07:38:59 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.2.342.3; Tue, 25 Jun 2013 07:38:58 -0500 Received: from sokoban.tieu.ti.com (h78-3.vpn.ti.com [172.24.78.3]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r5PCcgdU024238; Tue, 25 Jun 2013 07:38:56 -0500 From: Tero Kristo To: , , , , , Subject: [PATCHv3 5/9] ARM: OMAP: clock: add DT duplicate clock registration mechanism Date: Tue, 25 Jun 2013 15:38:29 +0300 Message-ID: <1372163913-16566-6-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1372163913-16566-1-git-send-email-t-kristo@ti.com> References: <1372163913-16566-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-20130625_083918_195856_D72B7CEC X-CRM114-Status: GOOD ( 13.24 ) X-Spam-Score: -8.2 (--------) 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=-5.5 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 --- arch/arm/mach-omap2/clock.c | 39 +++++++++++++++++++++++++++++++++++++++ arch/arm/mach-omap2/clock.h | 16 ++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c index 0c38ca9..6fe14b5 100644 --- a/arch/arm/mach-omap2/clock.c +++ b/arch/arm/mach-omap2/clock.c @@ -584,6 +584,45 @@ void __init omap_clocks_register(struct omap_clk oclks[], int cnt) } /** + * 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); + } +} + +/** * omap2_clk_switch_mpurate_at_boot - switch ARM MPU rate by boot-time argument * @mpurate_ck_name: clk name of the clock to change rate * diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h index 3238c57..1c1fbe4 100644 --- a/arch/arm/mach-omap2/clock.h +++ b/arch/arm/mach-omap2/clock.h @@ -37,6 +37,21 @@ struct omap_clk { }, \ } +struct omap_dt_clk { + u16 cpu; + struct clk_lookup lk; + const char *node_name; +}; + +#define DT_CLK(dev, con, name) \ + { \ + .lk = { \ + .dev_id = dev, \ + .con_id = con, \ + }, \ + .node_name = name, \ + } + struct clockdomain; #define to_clk_hw_omap(_hw) container_of(_hw, struct clk_hw_omap, hw) @@ -316,4 +331,5 @@ extern const struct clksel_rate div31_1to31_rates[]; extern int am33xx_clk_init(void); extern void omap_clocks_register(struct omap_clk *oclks, int cnt); +extern void omap_dt_clocks_register(struct omap_dt_clk *oclks, int cnt); #endif