From patchwork Fri Feb 7 16:16:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Emilio_L=C3=B3pez?= X-Patchwork-Id: 3606401 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 259629F344 for ; Fri, 7 Feb 2014 16:24:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3C7872012F for ; Fri, 7 Feb 2014 16:24:05 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1E5362012B for ; Fri, 7 Feb 2014 16:24:04 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WBoDZ-0006ZW-5j; Fri, 07 Feb 2014 16:23:53 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WBo8h-0007W6-Cw; Fri, 07 Feb 2014 16:18:51 +0000 Received: from yotta.elopez.com.ar ([2a00:1768:1004:d00d:c0de:4:f00d:cafe]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WBo8e-0007V4-Hx for linux-arm-kernel@lists.infradead.org; Fri, 07 Feb 2014 16:18:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=elopez.com.ar; s=mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:References:Subject:CC:To:MIME-Version:From:Date:Message-ID; bh=yyVmspBF2CQVGW2r1685mMs/b5bY5XpUkq6iV/U7RYc=; b=XVMwrtSXBLPdJwh/wjAG4XfEsOEIPH2PRcyBArRji5gEe/j5bYpUcLMeoqeVAFgUHLxuGUgrugd9vA+h379Hj8laPZwRrGhx4XUzVjDlRSuKnqeRUqPiMsurXAUssHNnZM/y60qkhWaO3KDwKPUP1g2TatJsSyBSBv4AJCA3lmlT6XcxW0sXLkwQBel0+OHdDv+7glMyCDUP/dr4rUMJWAksM297ebeCUu0ad3K3FKcgd3LMNd0Idku8B6qKOGk6x6T7i3tTZYheLCsqndFleI2NgudNEIx4yEVYwYbfM/v9Zk8FgT3qdi4nSEg2GyY+X7V766RAYeY5RVu5sm1TVw==; Received: from yotta.elopez.com.ar ([31.220.24.173] helo=[0.0.0.0]) by yotta.elopez.com.ar with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.82) id 1WBo8E-0001bq-4K; Fri, 07 Feb 2014 13:18:23 -0300 Message-ID: <52F506E4.8070900@elopez.com.ar> Date: Fri, 07 Feb 2014 13:16:36 -0300 From: =?UTF-8?B?RW1pbGlvIEzDs3Bleg==?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: Gregory CLEMENT , Ezequiel Garcia , Jason Cooper Subject: Re: [PATCH] clk: respect the clock dependencies in of_clk_init References: <1391554766-11285-1-git-send-email-gregory.clement@free-electrons.com> <52F4DA40.4090804@elopez.com.ar> <20140207142430.GU8533@titan.lakedaemon.net> <20140207144325.GA8218@localhost> <52F4F279.6010006@free-electrons.com> <52F4F502.2010703@elopez.com.ar> <52F4F7EF.7090900@free-electrons.com> In-Reply-To: <52F4F7EF.7090900@free-electrons.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140207_111848_905565_0C84427A X-CRM114-Status: GOOD ( 21.79 ) X-Spam-Score: -2.6 (--) Cc: Thomas Petazzoni , Andrew Lunn , Mike Turquette , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 Hi Gregory, El 07/02/14 12:12, Gregory CLEMENT escribió: > On 07/02/2014 16:00, Emilio López wrote: >> El 07/02/14 11:49, Gregory CLEMENT escribió: >>> On 07/02/2014 15:43, Ezequiel Garcia wrote: >>>> On Fri, Feb 07, 2014 at 09:24:30AM -0500, Jason Cooper wrote: >>>>> On Fri, Feb 07, 2014 at 10:06:08AM -0300, Emilio López wrote: >>>>> >>>>> [snip a great explanation] >>>>> >>>>> Guys, can I get some Tested-by's on this? >>>>> >>>> >>>> In case someone missed Emilio's comment about it, I gave his oneliner >>>> a test on A370 Reference Design. It worked just as well as Sebastian's. >>> >>> Well ok it's working but this patch is not better than Sebastian, it is >>> even worth. I don't think it is a good idea at all to totally ignore the >>> information given by the device tree. >> >> With a bit more work, you can replace the clk_get magic with a call to >> of_clk_get_parent_name() or similar to be able to keep overriding stuff >> from DT. This way it would completely match the behaviour on >> mvebu_coreclk_setup (default to "tclk", allow overriding with DT). >> > > I think you didn't have a look on our implementation: I did, several times in fact. > the name of the clock > are created by the driver during the initialization. The name of the clock is always "tclk", as hardcoded on the driver, unless overridden via clock-output-names from DT (see mvebu_coreclk_setup). Currently none of your DT that I can see does this, so in practice it's always "tclk". > That's why we need that > the parent clock are initialized before the gating clock. You don't really *need* that. The driver just does that because it may have been convenient at the time and it worked. Defaulting to "tclk" on mvebu_clk_gating_setup and overriding it if it turns out it has some other name on the DT (just like on mvebu_coreclk_setup!) should work as well, and doesn't require complex, bloaty, dependency management. Rough, untested patch below, so you get the idea. Cheers, Emilio --- drivers/clk/mvebu/common.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); diff --git a/drivers/clk/mvebu/common.c b/drivers/clk/mvebu/common.c index 25ceccf..730625b 100644 --- a/drivers/clk/mvebu/common.c +++ b/drivers/clk/mvebu/common.c @@ -119,19 +119,20 @@ void __init mvebu_clk_gating_setup(struct device_node *np, const struct clk_gating_soc_desc *desc) { struct clk_gating_ctrl *ctrl; - struct clk *clk; void __iomem *base; - const char *default_parent = NULL; + struct of_phandle_args clkspec; + const char *default_parent = "tclk"; int n; base = of_iomap(np, 0); if (WARN_ON(!base)) return; - clk = of_clk_get(np, 0); - if (!IS_ERR(clk)) { - default_parent = __clk_get_name(clk); - clk_put(clk); + if (!of_parse_phandle_with_args(np, "clocks", "#clock-cells", 0, &clkspec)) { + of_property_read_string_index(clkspec.np, "clock-output-names", + clkspec.args_count ? clkspec.args[0] : 0, + &default_parent); + of_node_put(clkspec.np); }