From patchwork Wed May 28 10:50:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: archit taneja X-Patchwork-Id: 4254471 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 5316DBF90B for ; Wed, 28 May 2014 10:52:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 767D020279 for ; Wed, 28 May 2014 10:52:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7256B2026C for ; Wed, 28 May 2014 10:52:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752097AbaE1KwW (ORCPT ); Wed, 28 May 2014 06:52:22 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:53581 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751441AbaE1KwW (ORCPT ); Wed, 28 May 2014 06:52:22 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id s4SAqL5s000960; Wed, 28 May 2014 05:52:21 -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 s4SAqLMg001754; Wed, 28 May 2014 05:52:21 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.174.1; Wed, 28 May 2014 05:52:21 -0500 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s4SAqLAM011240; Wed, 28 May 2014 05:52:21 -0500 Received: from localhost (a0393947pc.apr.dhcp.ti.com [172.24.145.166]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id s4SAqJt19982; Wed, 28 May 2014 05:52:20 -0500 (CDT) From: Archit Taneja To: , , CC: Subject: [RFC v2 1/6] CLK: TI: clockdomain: add support for retrying init Date: Wed, 28 May 2014 16:20:50 +0530 Message-ID: <1401274255-16845-2-git-send-email-archit@ti.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1401274255-16845-1-git-send-email-archit@ti.com> References: <1397654063-8055-1-git-send-email-archit@ti.com> <1401274255-16845-1-git-send-email-archit@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=-7.5 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: Tero Kristo Retry init is needed if clockdomains are registered before the corresponding clocks are ready. In this case, the clockdomain info is added to a list which will be processed once the clockdomains for next PRCM module are processed. Signed-off-by: Tero Kristo --- arch/arm/mach-omap2/prm_common.c | 3 +- drivers/clk/ti/clockdomain.c | 77 ++++++++++++++++++++++++++++++++++------ include/linux/clk/ti.h | 2 +- 3 files changed, 68 insertions(+), 14 deletions(-) diff --git a/arch/arm/mach-omap2/prm_common.c b/arch/arm/mach-omap2/prm_common.c index b4c4ab9..56462af 100644 --- a/arch/arm/mach-omap2/prm_common.c +++ b/arch/arm/mach-omap2/prm_common.c @@ -523,10 +523,9 @@ int __init of_prcm_init(void) mem = of_iomap(np, 0); clk_memmaps[memmap_index] = mem; ti_dt_clk_init_provider(np, memmap_index); + ti_dt_clockdomains_setup(np); memmap_index++; } - ti_dt_clockdomains_setup(); - return 0; } diff --git a/drivers/clk/ti/clockdomain.c b/drivers/clk/ti/clockdomain.c index f1e0038..29fa543 100644 --- a/drivers/clk/ti/clockdomain.c +++ b/drivers/clk/ti/clockdomain.c @@ -24,26 +24,60 @@ #undef pr_fmt #define pr_fmt(fmt) "%s: " fmt, __func__ -static void __init of_ti_clockdomain_setup(struct device_node *node) +struct clkdm_init_item { + struct device_node *node; + int index; + struct list_head link; +}; + +static LIST_HEAD(retry_list); + +static int of_ti_init_clk_clkdm(struct device_node *node, int index) { struct clk *clk; struct clk_hw *clk_hw; - const char *clkdm_name = node->name; + + clk = of_clk_get(node, index); + + if (IS_ERR_OR_NULL(clk)) { + pr_debug("%s[%d] = %08x\n", node->name, index, (u32)clk); + return -EBUSY; + } + + if (__clk_get_flags(clk) & CLK_IS_BASIC) { + pr_warn("can't setup clkdm for basic clk %s\n", + __clk_get_name(clk)); + return -EINVAL; + } + + clk_hw = __clk_get_hw(clk); + to_clk_hw_omap(clk_hw)->clkdm_name = node->name; + omap2_init_clk_clkdm(clk_hw); + + return 0; +} + +static void __init of_ti_clockdomain_setup(struct device_node *node) +{ int i; int num_clks; + struct clkdm_init_item *retry; + int ret; num_clks = of_count_phandle_with_args(node, "clocks", "#clock-cells"); for (i = 0; i < num_clks; i++) { - clk = of_clk_get(node, i); - if (__clk_get_flags(clk) & CLK_IS_BASIC) { - pr_warn("can't setup clkdm for basic clk %s\n", - __clk_get_name(clk)); + ret = of_ti_init_clk_clkdm(node, i); + + if (ret == -EBUSY) { + retry = kzalloc(sizeof(*retry), GFP_KERNEL); + if (!retry) + return; + retry->node = node; + retry->index = i; + list_add(&retry->link, &retry_list); continue; } - clk_hw = __clk_get_hw(clk); - to_clk_hw_omap(clk_hw)->clkdm_name = clkdm_name; - omap2_init_clk_clkdm(clk_hw); } } @@ -61,10 +95,31 @@ static struct of_device_id ti_clkdm_match_table[] __initdata = { * called after rest of the DT clock init has completed and all * clock nodes have been registered. */ -void __init ti_dt_clockdomains_setup(void) +void __init ti_dt_clockdomains_setup(struct device_node *node) { struct device_node *np; - for_each_matching_node(np, ti_clkdm_match_table) { + struct device_node *clkdms; + struct clkdm_init_item *retry, *tmp; + int ret; + + clkdms = of_get_child_by_name(node, "clockdomains"); + if (!clkdms) + return; + + list_for_each_entry_safe(retry, tmp, &retry_list, link) { + pr_debug("retry-init: %s [%d]\n", retry->node->name, + retry->index); + ret = of_ti_init_clk_clkdm(retry->node, retry->index); + if (!ret) { + list_del(&retry->link); + kfree(retry); + } + } + + for_each_child_of_node(clkdms, np) { + if (!of_match_node(ti_clkdm_match_table, np)) + continue; + of_ti_clockdomain_setup(np); } } diff --git a/include/linux/clk/ti.h b/include/linux/clk/ti.h index 4a21a87..20dd7c0 100644 --- a/include/linux/clk/ti.h +++ b/include/linux/clk/ti.h @@ -263,7 +263,7 @@ void omap3_clk_lock_dpll5(void); void __iomem *ti_clk_get_reg_addr(struct device_node *node, int index); void ti_dt_clocks_register(struct ti_dt_clk *oclks); void ti_dt_clk_init_provider(struct device_node *np, int index); -void ti_dt_clockdomains_setup(void); +void ti_dt_clockdomains_setup(struct device_node *node); int ti_clk_retry_init(struct device_node *node, struct clk_hw *hw, ti_of_clk_init_cb_t func); int of_ti_clk_autoidle_setup(struct device_node *node);