From patchwork Thu Aug 29 13:16:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 2851343 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 D2D01BF547 for ; Thu, 29 Aug 2013 13:19:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A90052030D for ; Thu, 29 Aug 2013 13:19:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 553FF201CB for ; Thu, 29 Aug 2013 13:19:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754886Ab3H2NSv (ORCPT ); Thu, 29 Aug 2013 09:18:51 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:55643 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754849Ab3H2NSs (ORCPT ); Thu, 29 Aug 2013 09:18:48 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id r7TDI43E016025; Thu, 29 Aug 2013 08:18:04 -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 r7TDI4KK029750; Thu, 29 Aug 2013 08:18:04 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.2.342.3; Thu, 29 Aug 2013 08:18:04 -0500 Received: from sokoban.tieu.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id r7TDGkKP002988; Thu, 29 Aug 2013 08:18:02 -0500 From: Tero Kristo To: , , , , , CC: , Subject: [PATCHv6 32/45] ARM: OMAP2+: Add support to parse optional clk info from DT Date: Thu, 29 Aug 2013 16:16:24 +0300 Message-ID: <1377782197-10611-33-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1377782197-10611-1-git-send-email-t-kristo@ti.com> References: <1377782197-10611-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=-9.4 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 From: Rajendra Nayak With clocks for OMAP moving to DT, its now possible to pass all optional clock data for each device from DT instead of having it in hwmod. Signed-off-by: Rajendra Nayak Signed-off-by: Tero Kristo --- arch/arm/mach-omap2/omap_hwmod.c | 66 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c index 838af96..116219e 100644 --- a/arch/arm/mach-omap2/omap_hwmod.c +++ b/arch/arm/mach-omap2/omap_hwmod.c @@ -807,6 +807,65 @@ static int _init_interface_clks(struct omap_hwmod *oh) return ret; } +static const char **_parse_opt_clks_dt(struct omap_hwmod *oh, + struct device_node *np, + int *opt_clks_cnt) +{ + int i, clks_cnt; + const char *clk_name; + const char **opt_clk_names; + + clks_cnt = of_property_count_strings(np, "clock-names"); + if (!clks_cnt) + return NULL; + + opt_clk_names = kzalloc(sizeof(char *)*clks_cnt, GFP_KERNEL); + if (!opt_clk_names) + return NULL; + + for (i = 0; i < clks_cnt; i++) { + of_property_read_string_index(np, "clock-names", i, &clk_name); + if (!strcmp(clk_name, "fck")) + continue; + opt_clks_cnt++; + opt_clk_names[i] = clk_name; + } + return opt_clk_names; +} + +static int _init_opt_clks_dt(struct omap_hwmod *oh, struct device_node *np) +{ + struct clk *c; + int i, opt_clks_cnt = 0; + int ret = 0; + const char **opt_clk_names; + + opt_clk_names = _parse_opt_clks_dt(oh, np, &opt_clks_cnt); + if (!opt_clk_names) + return -EINVAL; + + oh->opt_clks = kzalloc(sizeof(struct omap_hwmod_opt_clk *) + * opt_clks_cnt, GFP_KERNEL); + if (!oh->opt_clks) + return -ENOMEM; + + oh->opt_clks_cnt = opt_clks_cnt; + + for (i = 0; i < oh->opt_clks_cnt; i++) { + c = of_clk_get_by_name(np, opt_clk_names[i]); + if (IS_ERR(c)) { + pr_warn("omap_hwmod: %s: cannot clk_get opt_clk %s\n", + oh->name, opt_clk_names[i]); + ret = -EINVAL; + } + oh->opt_clks[i]._clk = c; + oh->opt_clks[i].role = opt_clk_names[i]; + oh->opt_clks_cnt++; + clk_prepare(oh->opt_clks[i]._clk); + } + return ret; +} + /** * _init_opt_clk - get a struct clk * for the the hwmod's optional clocks * @oh: struct omap_hwmod * @@ -814,13 +873,16 @@ static int _init_interface_clks(struct omap_hwmod *oh) * Called from _init_clocks(). Populates the @oh omap_hwmod_opt_clk * clock pointers. Returns 0 on success or -EINVAL on error. */ -static int _init_opt_clks(struct omap_hwmod *oh) +static int _init_opt_clks(struct omap_hwmod *oh, struct device_node *np) { struct omap_hwmod_opt_clk *oc; struct clk *c; int i; int ret = 0; + if (of_get_property(np, "clocks", NULL)) + return _init_opt_clks_dt(oh, np); + for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) { c = clk_get(NULL, oc->clk); if (IS_ERR(c)) { @@ -1582,7 +1644,7 @@ static int _init_clocks(struct omap_hwmod *oh, void *data, ret |= _init_main_clk(oh, np); ret |= _init_interface_clks(oh); - ret |= _init_opt_clks(oh); + ret |= _init_opt_clks(oh, np); if (!ret) oh->_state = _HWMOD_STATE_CLKS_INITED;