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: 2776361 Return-Path: X-Original-To: patchwork-linux-omap@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 464EE9F245 for ; Tue, 25 Jun 2013 12:39:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E95DE201D5 for ; Tue, 25 Jun 2013 12:39:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B295E201C2 for ; Tue, 25 Jun 2013 12:39:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751619Ab3FYMj1 (ORCPT ); Tue, 25 Jun 2013 08:39:27 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:51261 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751588Ab3FYMj0 (ORCPT ); Tue, 25 Jun 2013 08:39:26 -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 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: , , , , , CC: , 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 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 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