From patchwork Thu Nov 15 22:40:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 10685173 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 00AD7109C for ; Thu, 15 Nov 2018 22:41:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E54942D4C1 for ; Thu, 15 Nov 2018 22:41:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D88202D51E; Thu, 15 Nov 2018 22:41:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 710952D4C1 for ; Thu, 15 Nov 2018 22:41:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=2BFvNkk4xMiZtAt8iXBzKuOTBB8l9tYuDUUyVL3x16g=; b=NdQSxy/5+NmAcZ NdXRnPLCF5a9G8n65SYPD2Dz0mSBSoWcb5XMdvxCJkUXpd2gqvURzsDWcGA9PSwhB1IrzPTn855zo uGIIXnFLqagZ8y2Na6CVck3zg0Juog6tKV5HT1SG15IWSSi3afaltDAriRqWDr9NHZSgrBiTO/jDJ bFFnSwjpimiroKe2EOWKeo0LHlk+dQ2IeiUvJRPPcW6OfcbDzBFo4AniyOty9GDQzcbTxdJAL5R9R fk/mmyR1s2DOpJW8jhNDTWjxYODIbhrFYgD6WTL1Un5e3qLEMZv/HqjGkRPD66TEvt/vfv9UDvqb+ PgSqCiqlpHeWU0ftqUug==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gNQKI-0001RH-WC; Thu, 15 Nov 2018 22:41:31 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gNQKF-0001OR-S4; Thu, 15 Nov 2018 22:41:29 +0000 Received: by mail-wr1-x444.google.com with SMTP id p4so13735002wrt.7; Thu, 15 Nov 2018 14:41:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NLD4R/YTd5NWWNTehYtqzH5Sq5bxq2erjxwvS1xEomw=; b=U22yi4f2wIug/BioQ6kbNV9DzJTtnymid7OR/PdGJeYZfbnPtDcAjK2QhYPPzOPlNs 1hEignwcLuvg2kPY50/MSq3yowoL3vGCIGXy69/9XRnYRUcBI67IXoyQLbhwwOc7lwNT 6t+SjizLIrbwlcN8ResSrZ4nqzWCRdkShHDC+iuJOzRBnP70qC3I8hgNs5Uf+uxnCF1N 1MxdaAtOjJ0ymy5Nrc+BODHttmrKZRE1V6lGULAmwC8LIn0ZfLweOkwDszkXyVY9ruLv 1RtlPCD0ebJ57CiM0FJqNJAzqFPwaVUXx9s92DO4iObRf3XWNTvEVW6lYZKdKnKbRvNP ypGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=NLD4R/YTd5NWWNTehYtqzH5Sq5bxq2erjxwvS1xEomw=; b=hgE9jy+GukdGpJcmpbWwXxpWd4FUyd3DWh21cLwja6KviQlEHWcG5lraa2CX4RVJ5K B65Pj62/HiGJL0Y7vD/OYZbxsQZFPJeUO9Tc3Ulb8DEefYiS55vUdKuTyYtl8B5lChZi Ms6GpQLmNAY/NuxH5wrdORLuXZq+8AKnf4NH3yjAlaYeHNJTILY/Bo8BoaXb+T3lGVv/ gTAYY+p5KhLNu5Tp+7WAe/Wy+yGeDD/M1s2gC63qwj2JylX7BBoY+l2Kbj4NGCpsbO1G KDRSuDsIcfD/A6nemLLOQXoOZMritnPCLKMo6kE9rL0mdJjczEI6eFB1zJyl8SwUuJHJ 4zxA== X-Gm-Message-State: AGRZ1gLoAkaE9Tkf8Mx8ic9a2eaZP7dI8OzPMQJftu75ItUbUYD6DmOT DQVj+HoN2d8zAVo+XlS1iAX+AYvc X-Google-Smtp-Source: AJdET5dn1s4TNWp9jGt+hYCrFPzvZi+gLem1uvxYrP5ayF7rXlCNsbhhCIvxHu+5duhouh+F05O9nA== X-Received: by 2002:a5d:418b:: with SMTP id m11mr7136326wrp.8.1542321675486; Thu, 15 Nov 2018 14:41:15 -0800 (PST) Received: from blackbox.darklights.net (p200300DCD717A100B85ACE585A885C51.dip0.t-ipconnect.de. [2003:dc:d717:a100:b85a:ce58:5a88:5c51]) by smtp.googlemail.com with ESMTPSA id x12sm2076388wmc.37.2018.11.15.14.41.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 14:41:14 -0800 (PST) From: Martin Blumenstingl To: linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org, jbrunet@baylibre.com, narmstrong@baylibre.com Subject: [PATCH v2 0/6] Meson8b: make the CPU clock mutable Date: Thu, 15 Nov 2018 23:40:42 +0100 Message-Id: <20181115224048.13511-1-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181115_144127_907137_6032EA05 X-CRM114-Status: GOOD ( 15.53 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sboyd@kernel.org, Martin Blumenstingl , mturquette@baylibre.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This allows changing the CPU clock on the 32-bit Amlogic Meson SoCs (Meson8, Meson8b and Meson8m2). CPU frequency scaling will be enabled with a separate series by adding the CPU clock and the OPP tables to meson8.dtsi and meson8b.dtsi. While changing the CPU frequency (sys_pll or any of it's post-dividers) we need to run the CPU clock off the XTAL clock. Otherwise the system will lock up because we need to disable the sys_pll to change it's rate. This also makes the clk-pll's .enable hook a no-op if the clock is already enabled. Otherwise we're getting lockups when calling the first clk_{prepare_}enable on the sys_pll or any of it's children (as the CCF propagates the enable event up to the sys_pll). This is because the .enable hook unconditionally disables and enables the clock. However, we can't disable that clock (not even temporarily) if the CPU is running off sys_pll. Additionally this adds support for more M/N combinations in sys_pll to achieve all of the OPPs on Meson8b and all OPPs <= 1608 MHz on Meson8 and Meson8m2. Compared to Amlogic's 3.10 kernel there's one notable difference: we are actually allowing changes to the sys_pll. Amlogic's kernel sets sys_pll to a fixed rate during boot and then uses a timer generate a "virtual clock rate" by toggling between various dividers (for example: sys_pll is set to 1536MHz. to achieve 1008MHz they are toggling every 2500us between 1536MHZ and 768MHz so the average over is 1008MHz). I could reproduce any situation where changing sys_pll failed (for example due to high temperature). To prove that I ran "stress --cpu 4" for multiple hours and then cycled through all available CPU frequencies (while keeping "stress" running in the background). This worked fine on my Meson8b Odroid-C1 and EC-100 boards as well as my Meson8m2 board. Dependencies: This series is built on top of the latest clk-meson.git tree and the patches from my other series [1] "Meson8b: fixes for the cpu_scale_div clock". Changes since v1 at [0]: - re-ordered patches as suggested by Jerome: keep all fixes first, then the new "features" - squashed patches "clk-pll: check if the clock is already enabled" and "clk-pll: add the is_enabled function in the clk_ops". This also allows calling clk_hw_is_enabled() from meson_clk_pll_enable() instead of calling meson_clk_pll_is_enabled() directly (this matches the implementation of sclk-div.c) - documented the dependencies of this series in the cover-letter - dropped "RFC" prefix - collected Jerome's Acked-/Reviewed-by's (thanks for the quick response!) [0] https://patchwork.kernel.org/cover/10683317/ [1] https://patchwork.kernel.org/cover/10617617/ Martin Blumenstingl (6): clk: meson: clk-pll: check if the clock is already enabled clk: meson: meson8b: do not use cpu_div3 for cpu_scale_out_sel clk: meson: meson8b: mark the CPU clock as CLK_IS_CRITICAL clk: meson: meson8b: add support for more M/N values in sys_pll clk: meson: meson8b: run from the XTAL when changing the CPU frequency clk: meson: meson8b: allow changing the CPU clock tree drivers/clk/meson/clk-pll.c | 19 ++++++++ drivers/clk/meson/meson8b.c | 94 +++++++++++++++++++++++++++++++++---- 2 files changed, 104 insertions(+), 9 deletions(-)