From patchwork Wed Apr 27 15:24:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sperl X-Patchwork-Id: 8959001 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 3E2A6BF29F for ; Wed, 27 Apr 2016 15:26:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 24D2420268 for ; Wed, 27 Apr 2016 15:26: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 406F220259 for ; Wed, 27 Apr 2016 15:26: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 1avRKi-0000wI-M0; Wed, 27 Apr 2016 15:24:56 +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 1avRKd-0000rb-6c; Wed, 27 Apr 2016 15:24:52 +0000 Received: from rasp3a.intern.sperl.org (account martin@sperl.org [10.10.10.43] verified) by sperl.org (CommuniGate Pro SMTP 6.1.2) with ESMTPSA id 6439166; Wed, 27 Apr 2016 15:24:28 +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 V3] clk: bcm2835: mark enabled clocks with CLK_ENABLE_HAND_OFF Date: Wed, 27 Apr 2016 15:24:24 +0000 Message-Id: <1461770664-29384-1-git-send-email-kernel@martin.sperl.org> X-Mailer: git-send-email 2.1.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160427_082451_654939_308F2CA4 X-CRM114-Status: UNSURE ( 7.99 ) 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=-5.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 The bcm2835 firmware enables several clocks and plls before booting the linux kernel. These plls should never get disabled as it may result in a stopped system clock and more. So during probing we check if the clock is enabled and if it is then mark that clock with CLK_ENABLE_HAND_OFF. As a consequence this will also enable the corresponding parent plls and pll-divs. Signed-off-by: Martin Sperl --- Note that this requires the following patches applied: * clk: introduce CLK_ENABLE_HAND_OFF flag * clk: per-user clk prepare & enable ref counts Here some detailed info: Registered clocks with hand-off: bcm2835-clk 20101000.cprman: found enabled clock timer - enabling hand off bcm2835-clk 20101000.cprman: found enabled clock otp - enabling hand off bcm2835-clk 20101000.cprman: found enabled clock uart - enabling hand off bcm2835-clk 20101000.cprman: found enabled clock v3d - enabling hand off bcm2835-clk 20101000.cprman: found enabled clock isp - enabling hand off bcm2835-clk 20101000.cprman: found enabled clock h264 - enabling hand off bcm2835-clk 20101000.cprman: found enabled clock vec - enabling hand off bcm2835-clk 20101000.cprman: found enabled clock tsens - enabling hand off bcm2835-clk 20101000.cprman: found enabled clock emmc - enabling hand off Enabled clock count: root@raspcm:~# grep -vE ^0 /sys/kernel/debug/clk/*/clk_enable_count /sys/kernel/debug/clk/apb_pclk/clk_enable_count:1 /sys/kernel/debug/clk/clock/clk_enable_count:1 /sys/kernel/debug/clk/core/clk_enable_count:3 /sys/kernel/debug/clk/emmc/clk_enable_count:1 /sys/kernel/debug/clk/h264/clk_enable_count:1 /sys/kernel/debug/clk/isp/clk_enable_count:1 /sys/kernel/debug/clk/osc/clk_enable_count:7 /sys/kernel/debug/clk/otp/clk_enable_count:1 /sys/kernel/debug/clk/plla/clk_enable_count:1 /sys/kernel/debug/clk/plla_core/clk_enable_count:3 /sys/kernel/debug/clk/pllc/clk_enable_count:1 /sys/kernel/debug/clk/pllc_per/clk_enable_count:1 /sys/kernel/debug/clk/plld/clk_enable_count:1 /sys/kernel/debug/clk/plld_per/clk_enable_count:1 /sys/kernel/debug/clk/pllh_aux/clk_enable_count:1 /sys/kernel/debug/clk/pllh_aux_prediv/clk_enable_count:1 /sys/kernel/debug/clk/pllh/clk_enable_count:1 /sys/kernel/debug/clk/timer/clk_enable_count:1 /sys/kernel/debug/clk/tsens/clk_enable_count:1 /sys/kernel/debug/clk/uart0_pclk/clk_enable_count:1 /sys/kernel/debug/clk/uart/clk_enable_count:1 /sys/kernel/debug/clk/v3d/clk_enable_count:1 /sys/kernel/debug/clk/vec/clk_enable_count:1 That is a setup where the clock bcm2835 is only referenced in the device tree for pcm (which was not loaded or running at the time I took the above). Using pcm-audio would trigger a machine halt before this patch. Now this does not happen. Changelog: V1 -> V2: swith to use CLK_IS_CRITICAL for enabled pll_div V2 -> V3: swith to use CLK_ENABLE_HAND_OFF for enabled clocks --- drivers/clk/bcm/clk-bcm2835.c | 8 ++++++++ 1 file changed, 8 insertions(+) 2.1.4 diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c index 35f8de7..65d62c2 100644 --- a/drivers/clk/bcm/clk-bcm2835.c +++ b/drivers/clk/bcm/clk-bcm2835.c @@ -1251,7 +1251,14 @@ static struct clk *bcm2835_register_clock(struct bcm2835_cprman *cprman, init.flags |= CLK_SET_RATE_GATE | CLK_SET_PARENT_GATE; } + /* if the clock is running then enable HAND_OFF */ + if (cprman_read(cprman, data->ctl_reg) & CM_ENABLE) { + dev_info(cprman->dev, + "found enabled clock %s - enabling hand off\n", + data->name); + init.flags |= CLK_ENABLE_HAND_OFF; + } + clock = devm_kzalloc(cprman->dev, sizeof(*clock), GFP_KERNEL); if (!clock) return NULL; --