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: 8081761 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4EA6ABEEE5 for ; Thu, 21 Jan 2016 14:13:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7689320390 for ; Thu, 21 Jan 2016 14:13:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6A0AE20384 for ; Thu, 21 Jan 2016 14:13:23 +0000 (UTC) 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-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 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",