From patchwork Wed Nov 14 22:57:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 10683321 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 DA79214D6 for ; Wed, 14 Nov 2018 22:58:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBA542BF88 for ; Wed, 14 Nov 2018 22:58:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFA2E2BF93; Wed, 14 Nov 2018 22:58:09 +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 5D05C2BF88 for ; Wed, 14 Nov 2018 22:58:09 +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=NgrKBguZABnJ/5Li1rfQeqHjz70KYx1Wgwxqu5tqtzo=; b=eulLYcGpMvWM1a 59C2pzoqgkaZ3+rTx0r6M89XX3WM7oLomhdw/7oWUInrpXqRH64LbsyG2p/WknYx0hYxk9m1BqsdI zSN80lZkg33cvEgv7tk/tqialuQju+KaF9zajeoytvz2theCijqZU3XLIjoRaQoDYoPRMHBJZ3lMw csojdOB2bBgn7CLPHAi6XWFYqUEQx2mQb4ClPEPe2RmSvt1BH1L1kxpy6cVZKVkRT7zPJ9R3q7e+x CqP0IvO8ubdz+IGI2Lz150IjoEVsgrrrZ0rlP4+oHvykzxaHyniC/JS2FL5Nx6hh2Pyy/8uiRiiNy eCM/BiVbNF6xnpBu+c2w==; 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 1gN46p-0008Cf-41; Wed, 14 Nov 2018 22:58:07 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gN46l-00087P-25; Wed, 14 Nov 2018 22:58:04 +0000 Received: by mail-wm1-x343.google.com with SMTP id f1-v6so14514415wmg.1; Wed, 14 Nov 2018 14:57:52 -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=4+/Hf7JsCBuVFCzuyYowMXG14ZwLezEzin4Fj9FD7+Y=; b=fl3hMS5DXZJKuKCmTl7flStFHW6obyR1q+8M9em0Cyq3Ht6dVS5np+lS732pKLacZR Ox1RkxwDL7zR732ujX1wO5NyMp5jmKWGKYRHDAY6NW3dn6pNCxS08G1I8UrHYwdYp4Aq feddQ+IXb7RNTEM+pHGGqtOx+O1+ajIOQiipU/AQRd7JExjzIFi2YjwC7GyuprNn2V+W DMqZvS7MPCXmEEjcwdMDTQtrmwkmSASsjbcNAN0WASSY3fUiieCTwrAai0sgKUnlBc5V Hir9xNBofSJhPDyia1VcHNKfQfV5uIavBJnO9B1MOkQCb2d27MIBHr5NxJMlI8mNyFdR eF2g== 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=4+/Hf7JsCBuVFCzuyYowMXG14ZwLezEzin4Fj9FD7+Y=; b=rbkud/ev8yaifC8dL5Tb36xPGs8sQiwKH4/b5yrTN+QjI0kNK6ScLppvh836rs1mAv zJpDF2cbEe4HEw3I5UmvQrSRMzKXYj7g88ZMTALPXAtKH29PKLeLvQg7S3j94W04dlCG zU/l8kzhthGe5gdOxWfppDSumAo5y4p1aIrKi2X3EzWsuM3cglQB4qCVVH2waSy0GW1b mRUxeIt3+99rqjuGGDxoOXGmWqLoy7O2ZNlyeMxI0To6Iqlu/BqMyVbjnL2AyypK4REk 9z6uUbTooPyyuaSO3ueJJRP+R/oK20AVtBcs9bSvXGtnrcoxjyvuWZma000G7qhkwzej hIqw== X-Gm-Message-State: AGRZ1gL+v62PH9Z8lUPrbpnnmngP36IvJOHebeOZjnE2dZblyVVyFuCK IdN0pRzjBBwnx/GyLtuJFHXst9MU X-Google-Smtp-Source: AJdET5crq9BB6HY4nUhLIqOpPWHXkDWwgo1fhSAvnEFbBQ75RtrRmUqur4fD+VedwDybx2XjKNSnJw== X-Received: by 2002:a1c:2ecf:: with SMTP id u198-v6mr3546573wmu.77.1542236270641; Wed, 14 Nov 2018 14:57:50 -0800 (PST) Received: from blackbox.darklights.net (p200300DCD717A100301AB549B11D5ACB.dip0.t-ipconnect.de. [2003:dc:d717:a100:301a:b549:b11d:5acb]) by smtp.googlemail.com with ESMTPSA id n7-v6sm18987784wrt.60.2018.11.14.14.57.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Nov 2018 14:57:49 -0800 (PST) From: Martin Blumenstingl To: linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org, jbrunet@baylibre.com, narmstrong@baylibre.com Subject: [RFC v1 0/7] Meson8b: make the CPU clock mutable Date: Wed, 14 Nov 2018 23:57:18 +0100 Message-Id: <20181114225725.2821-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-20181114_145803_108146_F93B3D97 X-CRM114-Status: GOOD ( 13.10 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=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. Martin Blumenstingl (7): clk: meson: meson8b: run from the XTAL when changing the CPU frequency clk: meson: meson8b: do not use cpu_div3 for cpu_scale_out_sel clk: meson: clk-pll: check if the clock is already enabled clk: meson: clk-pll: add the is_enabled function in the clk_ops 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: allow changing the CPU clock tree drivers/clk/meson/clk-pll.c | 23 +++++++++ drivers/clk/meson/meson8b.c | 94 +++++++++++++++++++++++++++++++++---- 2 files changed, 108 insertions(+), 9 deletions(-)