Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp21863pxb; Tue, 19 Jan 2021 23:38:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJxGbC/VDnkMFhHYgRZxW1rcAeUGTk0Odff/VWY4Vd4/017fAIQKKfzkwHJzYgQ2i7ZEk+Xu X-Received: by 2002:a17:906:5002:: with SMTP id s2mr5132361ejj.16.1611128305106; Tue, 19 Jan 2021 23:38:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611128305; cv=none; d=google.com; s=arc-20160816; b=UCDp2j6d1MCrj5miLF7SJp2Yp7Mna2qOBfx9vE6O1Lln3McU5LZRIuyl/M5iyJ+spF yjMDTxUA4ipPuN4abs0f/Gb47Y9sjs2xrbYH/xaoRTwyCXqynplAD94TzUkLV5Zi2mNf 7dyPjgY4WEsBRUkJjIIrWocRcTmE791j/KKLd8hUJfq8Qy/ZZSEOVfUHtXYQhgUMiYdj /kLJBxQTz/QaiNmXCP3JbSKsEZ8oC4tDkDygXcVN9mXSOeOcVidoptEGH3yCoLE0xbEG iWQiWSZyrnNcUGaYoIJbOtaOnGl9TMRyHh56VtdcHDobjbezKCQrEKBlCV1FR37t4soY uRHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=IanWnaEx5OqRKgwILKHYhSJRlNTCTZXeCWicG73uJRc=; b=cQoqtX8vlbjJ42am0iG6j3P36Q9GykKfvQ+P2pp9iScqhDeHi/SBBs6uWjJQN2K/n1 o2Kbb6W4Ry92LSFTVdK2fbDXQqYmiY7sd0+Jws80UeAEn3Y+SOWesAWSik0uScSrTQBJ 0UQCisqztHWFV6Zna+ir+tlE3jOLOIUOUWmbZYIHOl+Nb/JbPqXyKnjyzhhfBWUVpYoP pV2+yGacynaADEH+ZVi5HOwlgaedXqNJPekycQ+urF63CXASjAKnQVqLhHsGNpKzVW8/ 8jpuimlgxJB5IOe98JV287/rnhLHgDJewX30xYFkAw8WXUxjbYmfgR1mGvVGAMkt5isY xbRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=BqxAkSuy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j20si438430ejb.278.2021.01.19.23.38.01; Tue, 19 Jan 2021 23:38:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=BqxAkSuy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729005AbhATHft (ORCPT + 99 others); Wed, 20 Jan 2021 02:35:49 -0500 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:11171 "EHLO hqnvemgate25.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725827AbhATHfG (ORCPT ); Wed, 20 Jan 2021 02:35:06 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Tue, 19 Jan 2021 23:34:26 -0800 Received: from HQMAIL101.nvidia.com (172.20.187.10) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 20 Jan 2021 07:34:24 +0000 Received: from jckuo-lt.nvidia.com (172.20.145.6) by mail.nvidia.com (172.20.187.10) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Wed, 20 Jan 2021 07:34:20 +0000 From: JC Kuo To: , , , , , , CC: , , , , , , JC Kuo , Thierry Reding Subject: [PATCH v7 01/14] clk: tegra: Add PLLE HW power sequencer control Date: Wed, 20 Jan 2021 15:34:01 +0800 Message-ID: <20210120073414.69208-2-jckuo@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210120073414.69208-1-jckuo@nvidia.com> References: <20210120073414.69208-1-jckuo@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1611128066; bh=IanWnaEx5OqRKgwILKHYhSJRlNTCTZXeCWicG73uJRc=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:X-NVConfidentiality: Content-Transfer-Encoding:Content-Type; b=BqxAkSuyqdrwEBkShIXsul4YKeqzgLNkKmgGwv7JGTTQY8leFbvM8OF8dQbUJNd5v NmBdEhWPzCb5tge0+kvLLnprLUdC3Pg0a0/fVUeqhuMfYhpvqnQHkvDvVD302MosT9 zl0HKs4R1iA1T5J0yk9SJqz8PrajExQP0aFjlsM41stTf9fmN+ukIrVgal97xVPbC4 FVNhf0+ZZhmmnfd3LCVNg3g+5Ox5riPFbSRHh+PiQAUsr2fmkoFrTGmVKhNqRH3xKc loDDgrY/wCX9r9f9txJQTpBxgoKisfcBKu6BP5oQyVQ6eY7SNO7SlhNXPogTs+sQ5W rJh7j9bGyQm5A== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org PLLE has a hardware power sequencer logic which is a state machine that can power on/off PLLE without any software intervention. The sequencer has two inputs, one from XUSB UPHY PLL and the other from SATA UPHY PLL. PLLE provides reference clock to XUSB and SATA UPHY PLLs. When both of the downstream PLLs are powered-off, PLLE hardware power sequencer will automatically power off PLLE for power saving. XUSB and SATA UPHY PLLs also have their own hardware power sequencer logic. XUSB UPHY PLL is shared between XUSB SuperSpeed ports and PCIE controllers. The XUSB UPHY PLL hardware power sequencer has inputs from XUSB and PCIE. When all of the XUSB SuperSpeed ports and PCIE controllers are in low power state, XUSB UPHY PLL hardware power sequencer automatically power off PLL and flags idle to PLLE hardware power sequencer. Similar applies to SATA UPHY PLL. PLLE hardware power sequencer has to be enabled after both downstream sequencers are enabled. This commit adds two helper functions: 1. tegra210_plle_hw_sequence_start() for XUSB PADCTL driver to enable PLLE hardware sequencer at proper time. 2. tegra210_plle_hw_sequence_is_enabled() for XUSB PADCTL driver to check whether PLLE hardware sequencer has been enabled or not. Signed-off-by: JC Kuo Acked-by: Thierry Reding --- v7: no change v6: no change v5: no change v4: update copyright strings v3: rename 'val' with 'value drivers/clk/tegra/clk-tegra210.c | 53 +++++++++++++++++++++++++++++++- include/linux/clk/tegra.h | 4 ++- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/drivers/clk/tegra/clk-tegra210.c b/drivers/clk/tegra/clk-tegra= 210.c index 68cbb98af567..b9099012dc7b 100644 --- a/drivers/clk/tegra/clk-tegra210.c +++ b/drivers/clk/tegra/clk-tegra210.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2012-2014 NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2012-2020 NVIDIA CORPORATION. All rights reserved. */ =20 #include @@ -403,6 +403,14 @@ static unsigned long tegra210_input_freq[] =3D { #define PLLRE_BASE_DEFAULT_MASK 0x1c000000 #define PLLRE_MISC0_WRITE_MASK 0x67ffffff =20 +/* PLLE */ +#define PLLE_MISC_IDDQ_SW_CTRL (1 << 14) +#define PLLE_AUX_USE_LOCKDET (1 << 3) +#define PLLE_AUX_SS_SEQ_INCLUDE (1 << 31) +#define PLLE_AUX_ENABLE_SWCTL (1 << 4) +#define PLLE_AUX_SS_SWCTL (1 << 6) +#define PLLE_AUX_SEQ_ENABLE (1 << 24) + /* PLLX */ #define PLLX_USE_DYN_RAMP 1 #define PLLX_BASE_LOCK (1 << 27) @@ -489,6 +497,49 @@ static unsigned long tegra210_input_freq[] =3D { #define PLLU_MISC0_WRITE_MASK 0xbfffffff #define PLLU_MISC1_WRITE_MASK 0x00000007 =20 +bool tegra210_plle_hw_sequence_is_enabled(void) +{ + u32 value; + + value =3D readl_relaxed(clk_base + PLLE_AUX); + if (value & PLLE_AUX_SEQ_ENABLE) + return true; + + return false; +} +EXPORT_SYMBOL_GPL(tegra210_plle_hw_sequence_is_enabled); + +int tegra210_plle_hw_sequence_start(void) +{ + u32 value; + + if (tegra210_plle_hw_sequence_is_enabled()) + return 0; + + /* skip if PLLE is not enabled yet */ + value =3D readl_relaxed(clk_base + PLLE_MISC0); + if (!(value & PLLE_MISC_LOCK)) + return -EIO; + + value &=3D ~PLLE_MISC_IDDQ_SW_CTRL; + writel_relaxed(value, clk_base + PLLE_MISC0); + + value =3D readl_relaxed(clk_base + PLLE_AUX); + value |=3D (PLLE_AUX_USE_LOCKDET | PLLE_AUX_SS_SEQ_INCLUDE); + value &=3D ~(PLLE_AUX_ENABLE_SWCTL | PLLE_AUX_SS_SWCTL); + writel_relaxed(value, clk_base + PLLE_AUX); + + fence_udelay(1, clk_base); + + value |=3D PLLE_AUX_SEQ_ENABLE; + writel_relaxed(value, clk_base + PLLE_AUX); + + fence_udelay(1, clk_base); + + return 0; +} +EXPORT_SYMBOL_GPL(tegra210_plle_hw_sequence_start); + void tegra210_xusb_pll_hw_control_enable(void) { u32 val; diff --git a/include/linux/clk/tegra.h b/include/linux/clk/tegra.h index eb016fc9cc0b..f7ff722a03dd 100644 --- a/include/linux/clk/tegra.h +++ b/include/linux/clk/tegra.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2012-2020, NVIDIA CORPORATION. All rights reserved. */ =20 #ifndef __LINUX_CLK_TEGRA_H_ @@ -123,6 +123,8 @@ static inline void tegra_cpu_clock_resume(void) } #endif =20 +extern int tegra210_plle_hw_sequence_start(void); +extern bool tegra210_plle_hw_sequence_is_enabled(void); extern void tegra210_xusb_pll_hw_control_enable(void); extern void tegra210_xusb_pll_hw_sequence_start(void); extern void tegra210_sata_pll_hw_control_enable(void); --=20 2.25.1