From patchwork Thu Aug 29 13:16:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 2851327 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 E7CB4BF546 for ; Thu, 29 Aug 2013 13:18:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B59C6201CB for ; Thu, 29 Aug 2013 13:18:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5E3EC201C8 for ; Thu, 29 Aug 2013 13:18:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754644Ab3H2NS1 (ORCPT ); Thu, 29 Aug 2013 09:18:27 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:48020 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754584Ab3H2NS0 (ORCPT ); Thu, 29 Aug 2013 09:18:26 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id r7TDI2f4010530; Thu, 29 Aug 2013 08:18:02 -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 r7TDI2Y2029610; Thu, 29 Aug 2013 08:18:02 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.2.342.3; Thu, 29 Aug 2013 08:18:01 -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 r7TDGkKO002988; Thu, 29 Aug 2013 08:18:00 -0500 From: Tero Kristo To: , , , , , CC: , Subject: [PATCHv6 31/45] ARM: OMAP2+: Add support to parse 'main_clk' info from DT Date: Thu, 29 Aug 2013 16:16:23 +0300 Message-ID: <1377782197-10611-32-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 the 'main_clk' 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 | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c index ef61582..838af96 100644 --- a/arch/arm/mach-omap2/omap_hwmod.c +++ b/arch/arm/mach-omap2/omap_hwmod.c @@ -730,14 +730,18 @@ static int _del_initiator_dep(struct omap_hwmod *oh, struct omap_hwmod *init_oh) * functional clock pointer) if a main_clk is present. Returns 0 on * success or -EINVAL on error. */ -static int _init_main_clk(struct omap_hwmod *oh) +static int _init_main_clk(struct omap_hwmod *oh, struct device_node *np) { int ret = 0; - if (!oh->main_clk) + if (!oh->main_clk && !of_get_property(np, "clocks", NULL)) return 0; - oh->_clk = clk_get(NULL, oh->main_clk); + if (oh->main_clk) + oh->_clk = clk_get(NULL, oh->main_clk); + else + oh->_clk = of_clk_get_by_name(np, "fck"); + if (IS_ERR(oh->_clk)) { pr_warning("omap_hwmod: %s: cannot clk_get main_clk %s\n", oh->name, oh->main_clk); @@ -1563,7 +1567,8 @@ static int _init_clkdm(struct omap_hwmod *oh) * Resolves all clock names embedded in the hwmod. Returns 0 on * success, or a negative error code on failure. */ -static int _init_clocks(struct omap_hwmod *oh, void *data) +static int _init_clocks(struct omap_hwmod *oh, void *data, + struct device_node *np) { int ret = 0; @@ -1575,7 +1580,7 @@ static int _init_clocks(struct omap_hwmod *oh, void *data) if (soc_ops.init_clkdm) ret |= soc_ops.init_clkdm(oh); - ret |= _init_main_clk(oh); + ret |= _init_main_clk(oh, np); ret |= _init_interface_clks(oh); ret |= _init_opt_clks(oh); @@ -2363,11 +2368,11 @@ static struct device_node *of_dev_hwmod_lookup(struct device_node *np, * are part of the device's address space can be ioremapped properly. * No return value. */ -static void __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data) +static void __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data, + struct device_node *np) { struct omap_hwmod_addr_space *mem; void __iomem *va_start = NULL; - struct device_node *np; if (!oh) return; @@ -2383,12 +2388,10 @@ static void __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data) oh->name); /* Extract the IO space from device tree blob */ - if (!of_have_populated_dt()) + if (!np) return; - np = of_dev_hwmod_lookup(of_find_node_by_name(NULL, "ocp"), oh); - if (np) - va_start = of_iomap(np, oh->mpu_rt_idx); + va_start = of_iomap(np, 0); } else { va_start = ioremap(mem->pa_start, mem->pa_end - mem->pa_start); } @@ -2420,14 +2423,19 @@ static void __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data) static int __init _init(struct omap_hwmod *oh, void *data) { int r; + struct device_node *np = NULL; if (oh->_state != _HWMOD_STATE_REGISTERED) return 0; + /* If booting with DT, parse the DT node for IO space/clocks etc */ + if (of_have_populated_dt()) + np = of_dev_hwmod_lookup(of_find_node_by_name(NULL, "ocp"), oh); + if (oh->class->sysc) - _init_mpu_rt_base(oh, NULL); + _init_mpu_rt_base(oh, NULL, np); - r = _init_clocks(oh, NULL); + r = _init_clocks(oh, NULL, np); if (r < 0) { WARN(1, "omap_hwmod: %s: couldn't init clocks\n", oh->name); return -EINVAL;