From patchwork Wed Nov 14 22:57:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 10683331 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 0E82B14D6 for ; Wed, 14 Nov 2018 22:58:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F337E2BF88 for ; Wed, 14 Nov 2018 22:58:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6C842BF93; Wed, 14 Nov 2018 22:58:28 +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 64AB42BF88 for ; Wed, 14 Nov 2018 22:58:28 +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:References:In-Reply-To: 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: List-Owner; bh=4zugTzjpDVQQPxtDLAAakF6JGJpwxeoP2KOxPz/6MtM=; b=Bl+LAEWWPVD6Mx cFh/5wxOwqw64oMqZcFrSGMZwCBwYE0Q4MnNmlmvK9x7YU/04JWazk+MpU/OqZpqRRbXRAe/GftZ4 xXkhVAa9PzSpq2JPf/AAzdPQd9Sh0ql2aVrDL3JWRZX1m9RzMHGnu/zJfd0unXCbHWctNgMUQFVOY JcA4pc0M+yf9Rl5b1fj10o4NAKoOkOK3Y48c/Ww3BBkai07/AM0NuedeZnZfM9MoQ074eT6xnR5MW VFNJkUsKy0EoLAqUh9rFUENacRgESwBFkMJFM5PSpc8vKeLZPjIWt0nn2z76yZW9FfrxhOMxGWJd6 6BdUQ7H/6HspwnVaa1EQ==; 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 1gN472-0008Sb-4D; Wed, 14 Nov 2018 22:58:20 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gN46l-000883-Nk; Wed, 14 Nov 2018 22:58:05 +0000 Received: by mail-wr1-x443.google.com with SMTP id v18-v6so19101590wrt.8; Wed, 14 Nov 2018 14:57:55 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=T0RIdbj41WMBGlBYmwnCzpr3eDQ3vT6i3efI49BspNg=; b=c81J09fZIRIfQ3NXnELmVnJBBeVW9yr3GcO4eY70fRJyu2oo53KuOcd1nYvYGZTc3G WzU0VhYZhnxKO1bFdT75qNyTGZK554yaewi/4Erf/C84yrbpiPrTR9ATte1b8LF0mGjH IPj+6fOuOrfguo5xyJK+NNjvRMygYKRyH7dYkm87Bft4U9Ld0BI/uG5AC9r3J3zuxCSD k7IMaoVO9ncLBbcclmNS0/AIRuXKOzcZNcvXlJIe3uU9d6axl9kh3vJQJiSgj+KO9pVr OZgDY+3AQ1vEEOSu2Qlnj45x7YUNb77jiBmJMjdc2jN3kIL2kt6+jmm+9dsJoy48TuYZ fyGw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=T0RIdbj41WMBGlBYmwnCzpr3eDQ3vT6i3efI49BspNg=; b=ueWnJ2teyMg0uKsuunNObA+IcYi5nWRhIDpj+jf6K4YE+ykaXBKQINJ+K5X/dZR+J2 fV7fiPGQB1tcSAktbcyHD3SlJTZa/SbZMCJk0YxZ2xW41qE+Elb/EKYxBNmJM3up+L2N cN5XHb/3y5iUS8jNaRxLzo2nUH1WPlhFjo5rQ+Q3Qe+CwAcMOnEKItnF7XsNCI/gqUa4 9ZmR59CUJO8jeIaNYTAhnrqa+GihwmvmuPCESG1SC/99whQ307Yu9BDybkvgvlNl5q2b cdBW4tBb2u5enWgUS1I5StQL86V6IkQXlnblbgN5jYdXqAkl1P+qzzriF0Rk6HXvrElF WuXg== X-Gm-Message-State: AGRZ1gJBXTZe4UoDD1KuOsD/GVoTi8dXpvRE9c7Xoti0dUJQRxkh2Qqv gk0KlE0145Y74+FdCsPSdhNU8wuT X-Google-Smtp-Source: AJdET5eXn94wuy/HY2p2+zPnGKIkkOJNDJlBio7vB/a+cY6KAKooRd7/MSGfpBV2ShZooSMr/5oRmw== X-Received: by 2002:adf:8264:: with SMTP id 91mr3625837wrb.312.1542236273997; Wed, 14 Nov 2018 14:57:53 -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.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Nov 2018 14:57:53 -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 3/7] clk: meson: clk-pll: check if the clock is already enabled Date: Wed, 14 Nov 2018 23:57:21 +0100 Message-Id: <20181114225725.2821-4-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181114225725.2821-1-martin.blumenstingl@googlemail.com> References: <20181114225725.2821-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181114_145803_769505_2FB58CA4 X-CRM114-Status: GOOD ( 12.70 ) 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 Since commit 6f888e7bc7bd58 ("clk: meson: clk-pll: add enable bit") our PLLs also support the "enable" bit. Currently meson_clk_pll_enable unconditionally resets the PLL, enables it, takes it out of reset and waits until it is locked. This works fine for our current clock trees. However, there will be a problem once we allow modifications to sys_pll on Meson8, Meson8b and Meson8m2 (which will be required for CPU frequency scaling): the CPU clock is derived from the sys_pll clock. Once clk_enable is called on the CPU clock this will be propagated by the common clock framework up until the sys_pll clock. If we reset the PLL unconditionally in meson_clk_pll_enable the CPU will be stopped (on Meson8, Meson8b and Meson8m2). To prevent this we simply check if the PLL is already enabled and do reset the PLL if it's already enabled and locked. Signed-off-by: Martin Blumenstingl Reviewed-by: Jerome Brunet --- drivers/clk/meson/clk-pll.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/clk/meson/clk-pll.c b/drivers/clk/meson/clk-pll.c index f5b5b3fabe3c..b46cca953f4f 100644 --- a/drivers/clk/meson/clk-pll.c +++ b/drivers/clk/meson/clk-pll.c @@ -200,11 +200,32 @@ static void meson_clk_pll_init(struct clk_hw *hw) } } +static int meson_clk_pll_is_enabled(struct clk_hw *hw) +{ + struct clk_regmap *clk = to_clk_regmap(hw); + struct meson_clk_pll_data *pll = meson_clk_pll_data(clk); + + if (meson_parm_read(clk->map, &pll->rst)) + return 0; + + if (!meson_parm_read(clk->map, &pll->en)) + return 0; + + if (!meson_parm_read(clk->map, &pll->l)) + return 0; + + return 1; +} + static int meson_clk_pll_enable(struct clk_hw *hw) { struct clk_regmap *clk = to_clk_regmap(hw); struct meson_clk_pll_data *pll = meson_clk_pll_data(clk); + /* do nothing if the PLL is already enabled */ + if (meson_clk_pll_is_enabled(hw)) + return 0; + /* Make sure the pll is in reset */ meson_parm_write(clk->map, &pll->rst, 1);