From patchwork Mon Feb 29 11:39:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sperl X-Patchwork-Id: 8452071 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 74F939F372 for ; Mon, 29 Feb 2016 11:42:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9C13F201B4 for ; Mon, 29 Feb 2016 11:42:53 +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 BF35A20263 for ; Mon, 29 Feb 2016 11:42:52 +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 1aaMCY-0002uN-GK; Mon, 29 Feb 2016 11:41:22 +0000 Received: from 212-186-180-163.dynamic.surfer.at ([212.186.180.163] helo=cgate.sperl.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aaMBK-00011A-U0; Mon, 29 Feb 2016 11:40:08 +0000 Received: from raspcm.intern.sperl.org (account martin@sperl.org [10.10.10.41] verified) by sperl.org (CommuniGate Pro SMTP 6.1.2) with ESMTPSA id 6394964; Mon, 29 Feb 2016 11:39:36 +0000 From: kernel@martin.sperl.org To: Michael Turquette , Stephen Boyd , Stephen Warren , Lee Jones , Eric Anholt , linux-clk@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/6] clk: bcm2835: enable clocks that have been enabled by firmware Date: Mon, 29 Feb 2016 11:39:19 +0000 Message-Id: <1456745963-2403-4-git-send-email-kernel@martin.sperl.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1456745963-2403-1-git-send-email-kernel@martin.sperl.org> References: <1456745963-2403-1-git-send-email-kernel@martin.sperl.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160229_034007_247298_E1C835B2 X-CRM114-Status: UNSURE ( 9.52 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.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: Martin Sperl MIME-Version: 1.0 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 From: Martin Sperl If a clock that has been enabled by the firmware gets disabled by a driver this may right now result in a crash of the system as then also the corresponding PLL_dividers as well as PLLs get disabled (if not used) - some of which are used by the VideoCore GPU (which also runs the firmware) This patch prepares/enables those clocks that have been configured by the firmware. Whenever the clock framework implements either CLK_IS_CRITICAL or HAND_OFF this can get changed to use this new mechanism. For this to be completely successful (i.e not missing a clock and subsequently a pll) it is recommended to add all the known clocks of the soc so that this can get applied to all clocks. Signed-off-by: Martin Sperl Reviewed-by: Eric Anholt --- drivers/clk/bcm/clk-bcm2835.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) -- 1.7.10.4 diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c index 30d6486..1fbb55d 100644 --- a/drivers/clk/bcm/clk-bcm2835.c +++ b/drivers/clk/bcm/clk-bcm2835.c @@ -37,6 +37,7 @@ * generator). */ +#include #include #include #include @@ -1478,6 +1479,7 @@ static struct clk *bcm2835_register_clock(struct bcm2835_cprman *cprman, struct clk_init_data init; const char *parents[1 << CM_SRC_BITS]; size_t i; + struct clk *clk; /* * Replace our "xosc" references with the oscillator's @@ -1511,7 +1513,18 @@ static struct clk *bcm2835_register_clock(struct bcm2835_cprman *cprman, clock->data = data; clock->hw.init = &init; - return devm_clk_register(cprman->dev, &clock->hw); + clk = devm_clk_register(cprman->dev, &clock->hw); + if (IS_ERR_OR_NULL(clk)) + return clk; + + /* enable/prepare if the clock is enabled by the firmware */ + if (cprman_read(cprman, data->ctl_reg) & CM_ENABLE) { + dev_info(cprman->dev, + "found firmware enabled clock %pC\n", clk); + clk_prepare_enable(clk); + } + + return clk; } static int bcm2835_clk_probe(struct platform_device *pdev)