Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp289909pxb; Thu, 19 Nov 2020 00:55:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJys6K95TPyQIIrCCzwVy08376tPIGSsXPNaGsrNIKOWWDmgv9HHcVsCDEW8gbxnedmns4Hj X-Received: by 2002:a50:9f2e:: with SMTP id b43mr19751387edf.239.1605776155430; Thu, 19 Nov 2020 00:55:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605776155; cv=none; d=google.com; s=arc-20160816; b=MPPaURud9CtaJiDy+67D+Vr3F+AzNLf27AiCMz742S3i4QSYa0HCwgf4oH5VplTwMF DyPKUvkSDZtgi708u5r9gQWYrFmLRzffQzLxXobZKT+N8tfwyC+FV2KEsYbhhjl6D6+L 8mpGzgYlQtGqTYG6c9ytzbpkON8bUFDr2ZKrU1Ry+HMdajVhdzvDTdaEHgANeMZ2ALKU wKG0nFQiD8Y7SxhEVIhOkG4gWntxfLNQINql/DJ9KbWKD5A25BnpvTCR/vZFdP8IrIko 2QkiiYNLyh0vDej34o1WIjXz6yC5o8eUku6vKS0MD43vRQSPM/rNdpGcbuw6iTswQBy5 PfIQ== 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=DxTrqDpLoysadkj0e1K4igYk2DSegjtI0oRSePLIX0s=; b=MCThepSbkdNYAAQemFVp668aDAUwvQePPYhkJXHPthBXW1BrKWX0DCqnQAaqI2ciie v4lkoI4iRNycVaKNQ0tVeOzILbunPx06XmMuQImNc/zntZvQyR/s3hY8f9x43BLpKbGT dGr6ZJiQ+G1h0PKWIrp1UnKqGbLpOzP1RPOL6z3lZkkBbgqzBvhY7fr8TYeyDiYAtpNV 86/HWSHObwa/xM0jG9adLtl5Rhj8SSATI28zbZ4IbINX0wPQium+ODpm26hjBWIfsze1 trMebOR28qFzDvhUBFvWBQEyM0PijRnkR1lI6Vmk9FN6vz80dPXgrNdBU0t+YIzzzWa+ RdIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=Crf37Jw1; 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 p9si17464036edm.38.2020.11.19.00.55.32; Thu, 19 Nov 2020 00:55:55 -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=Crf37Jw1; 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 S1726511AbgKSIyO (ORCPT + 99 others); Thu, 19 Nov 2020 03:54:14 -0500 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:6166 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726375AbgKSIyN (ORCPT ); Thu, 19 Nov 2020 03:54:13 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Thu, 19 Nov 2020 00:54:17 -0800 Received: from HQMAIL101.nvidia.com (172.20.187.10) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 19 Nov 2020 08:54:11 +0000 Received: from jckuo-lt.nvidia.com (10.124.1.5) by mail.nvidia.com (172.20.187.10) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Thu, 19 Nov 2020 08:54:09 +0000 From: JC Kuo To: , , , , CC: , , , , , JC Kuo , Thierry Reding Subject: [PATCH v5 01/16] clk: tegra: Add PLLE HW power sequencer control Date: Thu, 19 Nov 2020 16:53:50 +0800 Message-ID: <20201119085405.556138-2-jckuo@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201119085405.556138-1-jckuo@nvidia.com> References: <20201119085405.556138-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=1605776057; bh=DxTrqDpLoysadkj0e1K4igYk2DSegjtI0oRSePLIX0s=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:X-NVConfidentiality: Content-Transfer-Encoding:Content-Type; b=Crf37Jw1kmYGrWmp0F5X9/nqxGLsbqsDtgC+8io7ZXjw1szZoNr+ZjQR2XJpJ2a19 jpEZe5Qmy+Tf2Mx1pK93myPjOAbnIk3AQlnAnMAbnHpwSeFaLcCWlo64mWxjTADL8C kfWsIxqoGx00GJewoEr70pQ9RiuU3cZJZdFZpGUFO98YPp7YHoxwTW3gOX5fotooJ3 M1hhqwyO9lO2Swn1ZutukSAMLAfW9UwUKjFp6sjKcoWUs/mMbD+rJUw7Iul6GBaEfC s/v/ssDqFsmjGV45Fs0v5ll6RBGmP+5VO9RXAioSFIBkGOPsyngGp08dFZ359UNc19 ckre0T9rUbocw== 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 --- 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 3f01d43f0598..7be477377ad3 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