From patchwork Mon Mar 31 15:15:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 27433 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 39F3B202E0 for ; Mon, 31 Mar 2014 15:17:40 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id f10sf20944283yha.7 for ; Mon, 31 Mar 2014 08:17:39 -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=s1OVgd0nBHeRKpa8X5hD6nuS2XADPVcsuDXI1VWyk2k=; b=CtDTWFjfSd2z/q3aHshWbrwuQfP+Dmn/ilfFBec3+7qKQesVp9QnwNmxhLn7tror3b xOdsJIeeXRxNyCE2x+oiH+nKed7YmL1pvA0Fs5IUjx4evVuARz21CyF8KJdyGhC9bgyE uHGWatv8KtYDbQlOhD3GvX0Wg3K2ZdsmYFWRTky7anrqApdtVciuOSCyK66KydVVeit8 mEnLqLQX/Y9OpHetU/kY8gZ2h0zj6i1R0g/OMgWBVBb5r0/MA573SZzzqsiK2CgzUYxG DWu3h2R8J95nuJthu6Q9/ueZWgTPKXjsPV8CdpCmYP+nud7mvevZWHmGLOCxsoJMN1Ov sQBg== X-Gm-Message-State: ALoCoQkY1hWhEDaXohs1amH4ikbD1cTEzjdYH0UfMiEznA8oEMn0E1VVkjFpK17XlzWszPNLAx2e X-Received: by 10.224.36.137 with SMTP id t9mr10155795qad.4.1396279059875; Mon, 31 Mar 2014 08:17:39 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.50.197 with SMTP id s63ls471595qga.39.gmail; Mon, 31 Mar 2014 08:17:39 -0700 (PDT) X-Received: by 10.58.150.68 with SMTP id ug4mr41245veb.50.1396279059778; Mon, 31 Mar 2014 08:17:39 -0700 (PDT) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id gs7si3017586vdc.74.2014.03.31.08.17.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 31 Mar 2014 08:17:39 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.177; Received: by mail-ve0-f177.google.com with SMTP id sa20so8034760veb.22 for ; Mon, 31 Mar 2014 08:17:39 -0700 (PDT) X-Received: by 10.221.22.71 with SMTP id qv7mr173909vcb.34.1396279059677; Mon, 31 Mar 2014 08:17:39 -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.12.8 with SMTP id v8csp150664vcv; Mon, 31 Mar 2014 08:17:39 -0700 (PDT) X-Received: by 10.66.144.227 with SMTP id sp3mr25978346pab.100.1396279058879; Mon, 31 Mar 2014 08:17:38 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cb4si4132536pbc.495.2014.03.31.08.17.38; Mon, 31 Mar 2014 08:17:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753514AbaCaPRg (ORCPT + 5 others); Mon, 31 Mar 2014 11:17:36 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:49799 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753424AbaCaPRf (ORCPT ); Mon, 31 Mar 2014 11:17:35 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id s2VFHCWI015161; Mon, 31 Mar 2014 10:17:12 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s2VFHCsN023235; Mon, 31 Mar 2014 10:17:12 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.174.1; Mon, 31 Mar 2014 10:17:12 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s2VFGm3w013169; Mon, 31 Mar 2014 10:17:08 -0500 From: Tero Kristo To: , , CC: Subject: [PATCH 11/55] CLK: TI: clockdomain: add support for retrying init Date: Mon, 31 Mar 2014 18:15:50 +0300 Message-ID: <1396278994-12624-12-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1396278994-12624-1-git-send-email-t-kristo@ti.com> References: <1396278994-12624-1-git-send-email-t-kristo@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: t-kristo@ti.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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: , 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 b4ef9e4..2d63196 100644 --- a/arch/arm/mach-omap2/prm_common.c +++ b/arch/arm/mach-omap2/prm_common.c @@ -521,11 +521,10 @@ 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 03decc2..86e8ae4 100644 --- a/include/linux/clk/ti.h +++ b/include/linux/clk/ti.h @@ -284,7 +284,7 @@ void omap2xxx_clkt_vps_init(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);