From patchwork Thu Jan 21 14:10:38 2016 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: 571166 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E2A59140B0E for ; Fri, 22 Jan 2016 01:13:33 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aMFy2-0005ZM-Vs; Thu, 21 Jan 2016 14:12:07 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aMFxz-0005SF-Qk for linux-arm-kernel@lists.infradead.org; Thu, 21 Jan 2016 14:12:04 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: emilio) with ESMTPSA id EA54C2612D9 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= To: mturquette@baylibre.com, sboyd@codeaurora.org, maxime.ripard@free-electrons.com, wens@csie.org, heiko@sntech.de Subject: [PATCH 1/2] clk: sunxi: delay protected clocks until arch initcall Date: Thu, 21 Jan 2016 11:10:38 -0300 Message-Id: <1453385439-10154-2-git-send-email-emilio.lopez@collabora.co.uk> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1453385439-10154-1-git-send-email-emilio.lopez@collabora.co.uk> References: <1453385439-10154-1-git-send-email-emilio.lopez@collabora.co.uk> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160121_061204_059004_0F498CFC X-CRM114-Status: GOOD ( 15.19 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Emilio=20L=C3=B3pez?= , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org Clocks are registered early on, and unused clocks get disabled on late initcall, so we can delay protecting important clocks a bit. If we do this too early, it may happen that some clocks are orphans and therefore enabling them may not work as intended. If we do this too late, a driver may reparent some clock and cause another important clock to be disabled as a byproduct. arch_initcall should be a good spot to do this, as clock drivers using the OF mechanisms will be all registered by then, and drivers won't have started probing yet. Signed-off-by: Emilio López --- drivers/clk/sunxi/clk-sunxi.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c index 5ba2188..285e8ee 100644 --- a/drivers/clk/sunxi/clk-sunxi.c +++ b/drivers/clk/sunxi/clk-sunxi.c @@ -1153,10 +1153,12 @@ static void __init of_sunxi_table_clock_setup(const struct of_device_id *clk_mat } } +/* By default, don't protect any clocks */ +static const char **protected_clocks __initdata; +static int protected_clocks_nr __initdata; + static void __init sunxi_init_clocks(const char *clocks[], int nclocks) { - unsigned int i; - /* Register divided output clocks */ of_sunxi_table_clock_setup(clk_divs_match, sunxi_divs_clk_setup); @@ -1169,14 +1171,26 @@ static void __init sunxi_init_clocks(const char *clocks[], int nclocks) /* Register mux clocks */ of_sunxi_table_clock_setup(clk_mux_match, sunxi_mux_clk_setup); + /* We shall protect these clocks when everything is ready */ + protected_clocks = clocks; + protected_clocks_nr = nclocks; +} + +static int __init sunxi_init_clock_protection(void) +{ + unsigned int i; + /* Protect the clocks that needs to stay on */ - for (i = 0; i < nclocks; i++) { - struct clk *clk = clk_get(NULL, clocks[i]); + for (i = 0; i < protected_clocks_nr; i++) { + struct clk *clk = clk_get(NULL, protected_clocks[i]); if (!IS_ERR(clk)) clk_prepare_enable(clk); } + + return 0; } +arch_initcall(sunxi_init_clock_protection); static const char *sun4i_a10_critical_clocks[] __initdata = { "pll5_ddr",