Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp197358imm; Thu, 30 Aug 2018 11:44:11 -0700 (PDT) X-Google-Smtp-Source: ANB0VdalRZw2lQPi89Gwfn061gZdTtRwqMbVHyp2Cce5ypmuEXxAvBQEFd/3X/muOgd7ZIVKwOkw X-Received: by 2002:a17:902:9045:: with SMTP id w5-v6mr11538089plz.10.1535654651943; Thu, 30 Aug 2018 11:44:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535654651; cv=none; d=google.com; s=arc-20160816; b=sXAGHwOWKr6FsUO0m9Rmi2qa2vM51HxYUi0JbIgNxS0mNzhEwbYlgIwcas+qC3Lq5O aSVY47Si1nQQ/jYqrTLcexryt3WsaKTC/crR2H0BJe6kO7qPmrOxmdVyRbCzrhCtSy1W 321OL0c4d1c16PNt89neEMEcElBUTaC/an548JeWlRnXjmyB2EWsj7uSLOZTnqpeyhzG tD/r4ppIn0vyafwkjg4I/RzskXJ2TJc+VLtG8VF653SPhQnoJZuLQcVuyEZqyR/fI8Z4 e7eRk9kgGJ451B5rH2v0bbTb3/ySn0uEZpyHogzfDfuJAoWq6DEtdmItpVq2Kn8vu4e0 B0dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=U7d9aO6dn5UyS3yhB9Ueq0CuQSS7ZBCmalaDKvVDuEU=; b=X1GMEVuSoFyz1Mbsro3uY3cVavGDF/xF4MwUgO0dsszR5NTsqbD5QztRegFhYDVQ4C tBX93OoyKDJy6AGlBnrJk/mJkkzzlM/gslDpDA/VmOvvgHy/8XAaofT+pc0rAsglVeYY EaN8/X6HzNMiQoZSu+xKkFLxWKCmZjj6ZbHYs9W17Ygs5imc5hU3Bo00bsISx3e5wPVG 2BURgKsXpxsg7pGV1NyYP2TC16mCyXSxGhXdLxe1p45rTEq193drE+8SJaVLxUA1Xzrg mdaukIS5Rk46kxSyixdaESu4Zi3iLnGVy+8rSPbVlGeR5/2Vy4be9ud0NFjWHiSoKewc KsaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YUDtkob9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d39-v6si7300169pla.41.2018.08.30.11.43.56; Thu, 30 Aug 2018 11:44:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YUDtkob9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728052AbeH3WqV (ORCPT + 99 others); Thu, 30 Aug 2018 18:46:21 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:37782 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726592AbeH3WqV (ORCPT ); Thu, 30 Aug 2018 18:46:21 -0400 Received: by mail-lf1-f65.google.com with SMTP id j8-v6so8013014lfb.4; Thu, 30 Aug 2018 11:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=U7d9aO6dn5UyS3yhB9Ueq0CuQSS7ZBCmalaDKvVDuEU=; b=YUDtkob9YQAmcjZg3NmA8YSytziHDTWLgrzSPrRtufGFFgqT/gE6ZTKAu/N8+3As4n Xr7H2RpbYVcjKjjMt6zTfNpdHkXGQHMHZKVWdXUOa8v9xLskb/ez0emtK9fEwKPEgCDo 4pleQGNjREleUXxTCrY+BrHsRBLpxciKFgTz+kQAIQIf0fyhmL0gH4ruJM7966fs5v50 UGXnjNn8E6Mb0ToCe8BubU3rWPB1LMPwuhcZDK8zsnzadnMNBkCjJPCnLVHfMZESoi63 miawomX39C0VIM9CCsUXQNVAekGX5Or/2C8IReWdekQlnXNxSicumL6lWUH+dtx0aOr2 eT7A== 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; bh=U7d9aO6dn5UyS3yhB9Ueq0CuQSS7ZBCmalaDKvVDuEU=; b=uQ2NxlidW5ufVRwKYgeMdAqfT4hgBY/yRat9okGGMEQODPq5H077L68Gw6ESCFpca8 Awz1vWRi8MQYBY/VjxxHcw4l3vL0wZwu+u3PwgCqd/EKNNMrEFkJ9VfHFaQgorbYFiu6 wicc0gpbcpcFp+63PtNemTyHLN4A1gGEuFmrxDMNW9DKx1minuyQzET09UX7df5176sc fFlm9ihj6vyhG75JZow5Gf23svD5sJJVItfxaPuhkCG1WGw/7k3xE5VnlggmGWxKuXwP xdyQ15SecvU7BN5CMHHeesV1maG3o9xg93zyQqZDvEMVbrIScrl7PoH3tDKJ8CRocY+s GVDQ== X-Gm-Message-State: APzg51AKBopxPsamUDNJBxz3N39xWY1zXMSVedCFfn0FvrO846sUFxa7 sMzXxBrwS8sgXMlbuAcjfF0= X-Received: by 2002:a19:655d:: with SMTP id c29-v6mr1869708lfj.138.1535654568953; Thu, 30 Aug 2018 11:42:48 -0700 (PDT) Received: from localhost.localdomain (109-252-90-13.nat.spd-mgts.ru. [109.252.90.13]) by smtp.gmail.com with ESMTPSA id m31-v6sm1446169lfi.17.2018.08.30.11.42.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 11:42:48 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Peter De Schrijver , Prashant Gaikwad , Michael Turquette , Stephen Boyd Cc: linux-clk@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] clk: tegra: Don't enable already enabled PLLs Date: Thu, 30 Aug 2018 21:42:09 +0300 Message-Id: <20180830184210.5369-1-digetx@gmail.com> X-Mailer: git-send-email 2.18.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Initially Common Clock Framework isn't aware of the clock-enable status, this results in enabling of clocks that were enabled by bootloader. This is not a big deal for a regular clock-gates, but for PLL's it may have some unpleasant consequences. Thus re-enabling PLLX (the main CPU parent clock) may result in extra long period of PLL re-locking. Signed-off-by: Dmitry Osipenko --- Changelog: v2: No change. drivers/clk/tegra/clk-pll.c | 50 +++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/drivers/clk/tegra/clk-pll.c b/drivers/clk/tegra/clk-pll.c index 830d1c87fa7c..ddb431247f08 100644 --- a/drivers/clk/tegra/clk-pll.c +++ b/drivers/clk/tegra/clk-pll.c @@ -444,6 +444,9 @@ static int clk_pll_enable(struct clk_hw *hw) unsigned long flags = 0; int ret; + if (clk_pll_is_enabled(hw)) + return 0; + if (pll->lock) spin_lock_irqsave(pll->lock, flags); @@ -939,11 +942,16 @@ static int clk_plle_training(struct tegra_clk_pll *pll) static int clk_plle_enable(struct clk_hw *hw) { struct tegra_clk_pll *pll = to_clk_pll(hw); - unsigned long input_rate = clk_hw_get_rate(clk_hw_get_parent(hw)); struct tegra_clk_pll_freq_table sel; + unsigned long input_rate; u32 val; int err; + if (clk_pll_is_enabled(hw)) + return 0; + + input_rate = clk_hw_get_rate(clk_hw_get_parent(hw)); + if (_get_table_rate(hw, &sel, pll->params->fixed_rate, input_rate)) return -EINVAL; @@ -1354,6 +1362,9 @@ static int clk_pllc_enable(struct clk_hw *hw) int ret; unsigned long flags = 0; + if (clk_pll_is_enabled(hw)) + return 0; + if (pll->lock) spin_lock_irqsave(pll->lock, flags); @@ -1566,7 +1577,12 @@ static int clk_plle_tegra114_enable(struct clk_hw *hw) u32 val; int ret; unsigned long flags = 0; - unsigned long input_rate = clk_hw_get_rate(clk_hw_get_parent(hw)); + unsigned long input_rate; + + if (clk_pll_is_enabled(hw)) + return 0; + + input_rate = clk_hw_get_rate(clk_hw_get_parent(hw)); if (_get_table_rate(hw, &sel, pll->params->fixed_rate, input_rate)) return -EINVAL; @@ -1703,6 +1719,9 @@ static int clk_pllu_tegra114_enable(struct clk_hw *hw) return -EINVAL; } + if (clk_pll_is_enabled(hw)) + return 0; + input_rate = clk_hw_get_rate(__clk_get_hw(osc)); if (pll->lock) @@ -2378,6 +2397,16 @@ struct clk *tegra_clk_register_pllre_tegra210(const char *name, return clk; } +static int clk_plle_tegra210_is_enabled(struct clk_hw *hw) +{ + struct tegra_clk_pll *pll = to_clk_pll(hw); + u32 val; + + val = pll_readl_base(pll); + + return val & PLLE_BASE_ENABLE ? 1 : 0; +} + static int clk_plle_tegra210_enable(struct clk_hw *hw) { struct tegra_clk_pll *pll = to_clk_pll(hw); @@ -2385,7 +2414,12 @@ static int clk_plle_tegra210_enable(struct clk_hw *hw) u32 val; int ret = 0; unsigned long flags = 0; - unsigned long input_rate = clk_hw_get_rate(clk_hw_get_parent(hw)); + unsigned long input_rate; + + if (clk_plle_tegra210_is_enabled(hw)) + return 0; + + input_rate = clk_hw_get_rate(clk_hw_get_parent(hw)); if (_get_table_rate(hw, &sel, pll->params->fixed_rate, input_rate)) return -EINVAL; @@ -2496,16 +2530,6 @@ static void clk_plle_tegra210_disable(struct clk_hw *hw) spin_unlock_irqrestore(pll->lock, flags); } -static int clk_plle_tegra210_is_enabled(struct clk_hw *hw) -{ - struct tegra_clk_pll *pll = to_clk_pll(hw); - u32 val; - - val = pll_readl_base(pll); - - return val & PLLE_BASE_ENABLE ? 1 : 0; -} - static const struct clk_ops tegra_clk_plle_tegra210_ops = { .is_enabled = clk_plle_tegra210_is_enabled, .enable = clk_plle_tegra210_enable, -- 2.18.0