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: 31051 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f72.google.com (mail-pb0-f72.google.com [209.85.160.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AD37C203C3 for ; Wed, 28 May 2014 10:52:25 +0000 (UTC) Received: by mail-pb0-f72.google.com with SMTP id ma3sf50677776pbc.11 for ; Wed, 28 May 2014 03:52:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=o0GB7rvHcZsEEzoLFcbHvTvYd4BoZKoV8JiArSBMT3M=; b=NHurU5mJ32XgxjMUlchgSEj8HB2OQB1jmewV/Xi0Bs0If8XThekS9ZgO4aO10h2Aw5 n6O0ME7O2yGjO7AIiusEPnLnDBKk1XwfFEnJ2U3EkUSMBtLK6DLlfjgQkm7BU4/YD2K5 7M6fH8iXd8lPpSzJEMjX3KWNwETP7DlvFMFLj+QACR0rDnnUGCAI3nkUVp5syaToha+N McKikfYV2FbZ2dVT89Gas6dv0/7EBoILqJcJAwTIrKW9O/zTzHVCyOliNx4k4zClKh1Q Dn4a5ph51EqkLdWCT8ZoTImAhmw9QdMvOX2R6zeQxCTTHmcw2GPfYKoul0HuTbtOwd9Q 59eg== X-Gm-Message-State: ALoCoQl3f3Nr04IQ3wGw6RpvTE47LhM6RkyDdtjUCxJgP+hVk/Ct9nbCbG8P8plyTP7bJ7W4WYRg X-Received: by 10.67.4.202 with SMTP id cg10mr15595640pad.42.1401274345046; Wed, 28 May 2014 03:52:25 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.41.166 with SMTP id z35ls26075qgz.93.gmail; Wed, 28 May 2014 03:52:24 -0700 (PDT) X-Received: by 10.58.201.5 with SMTP id jw5mr32360171vec.6.1401274344898; Wed, 28 May 2014 03:52:24 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id cj7si10158989vdb.40.2014.05.28.03.52.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 28 May 2014 03:52:24 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.173 as permitted sender) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id il7so12149855vcb.18 for ; Wed, 28 May 2014 03:52:24 -0700 (PDT) X-Received: by 10.221.30.14 with SMTP id sa14mr426106vcb.44.1401274344790; Wed, 28 May 2014 03:52:24 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp192001vcb; Wed, 28 May 2014 03:52:24 -0700 (PDT) X-Received: by 10.66.139.168 with SMTP id qz8mr43596796pab.3.1401274344001; Wed, 28 May 2014 03:52:24 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id vb6si23197136pac.58.2014.05.28.03.52.23; Wed, 28 May 2014 03:52:23 -0700 (PDT) Received-SPF: none (google.com: linux-omap-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752097AbaE1KwW (ORCPT + 6 others); 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: list List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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);