Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp147194pxk; Wed, 9 Sep 2020 01:15:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzy5nOLp6ot+hZi92XwUw5Y5J4gID3mVcek8usDGoANz7sEf61ILmnL7X9qiisKUY7L6iP9 X-Received: by 2002:a17:906:941a:: with SMTP id q26mr2421707ejx.496.1599639304864; Wed, 09 Sep 2020 01:15:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599639304; cv=none; d=google.com; s=arc-20160816; b=DljGS1GpEyS5KYvnLA1usxzlpJQQCtnxh6r0TrU4Xd/jfAJRZcMiaVRBGq1slvX9dF elj1jLY7Jq9MV4l4uV81nWKgb3fKavq644lDdakqqofsR+jDekntsY/HQMS4nAvFqaP7 qPSTcCp0mV3LUzbe31CNEcEwXza07/d7+hLKUKSGM8Vp1IqBe9uxWEXg5d8DCxoZyPOe N8dFtTcnRaTPv7ockeUIq39/8BBMSr7b7lcvXJtoOslfRHyT6CsNA+9Vb3XJ/wddmm82 cCYgwQOuf9DX6DLU4J1/YOxmbLElM8qDdkdlmBMeaioY3kAT22++gJoLDOSvDhYfx7OA gsug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=IAEzbl+SzvO/z/0Woj6WCtxnqj0JWqFlSliqV8z6ucM=; b=ZI3PsbTfblfmng/tPVcYyT737dhAXSxB6x6NfuckgJh6VamMzmrG4wFxrcBRu27db4 DIqy3vFJuuK8o1PETJ6Q02G7Lu7nm6d7pVxQbJjsdrwVhljHVFUv/CuVJK9XuS+qVGMh iD2WfA29MywAun/Z2gM+wxyoh5lmlIG5DZIaSy65tLvA/Qn5AL+WYeUr/lK6zpis+WAW rALalIxpwnFaXNR9AziLv+NHpw3iSdUD/XxeUjSitApSCcyYdDWRAEC4zg4ubTfEgOyt Fy3g893L7bYfADlSs/V039TspUDrhhNYQ4x4PBFiMPRixZ5neGJ9t2F8nf1zgc2Pi+Dl LVZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=XhuVPjNQ; 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 i11si1070707edl.230.2020.09.09.01.14.42; Wed, 09 Sep 2020 01:15:04 -0700 (PDT) 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=XhuVPjNQ; 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 S1730192AbgIIILA (ORCPT + 99 others); Wed, 9 Sep 2020 04:11:00 -0400 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:11975 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729129AbgIIIKv (ORCPT ); Wed, 9 Sep 2020 04:10:51 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Wed, 09 Sep 2020 01:10:37 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Wed, 09 Sep 2020 01:10:50 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 09 Sep 2020 01:10:50 -0700 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 9 Sep 2020 08:10:47 +0000 Received: from rnnvemgw01.nvidia.com (10.128.109.123) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Wed, 9 Sep 2020 08:10:47 +0000 Received: from jckuo-lt.nvidia.com (Not Verified[10.19.100.126]) by rnnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Wed, 09 Sep 2020 01:10:47 -0700 From: JC Kuo To: , , , , CC: , , , , , JC Kuo Subject: [PATCH v3 01/15] clk: tegra: Add PLLE HW power sequencer control Date: Wed, 9 Sep 2020 16:10:27 +0800 Message-ID: <20200909081041.3190157-2-jckuo@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200909081041.3190157-1-jckuo@nvidia.com> References: <20200909081041.3190157-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=1599639037; bh=IAEzbl+SzvO/z/0Woj6WCtxnqj0JWqFlSliqV8z6ucM=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:X-NVConfidentiality: Content-Transfer-Encoding:Content-Type; b=XhuVPjNQrGuhfDRLwGlKo7g/gAbi0rt4lcMOBKC3Peh+mzh0EuMAcm9n08C45j9yx xx50twvIOIOCkEkwp9DdiLr/JkxIjdNPcD7CAy4GpjzKfeQ6xMMpUvOlEEW4EQY2yY RzECSedd2N1nR329eV/MaBJzjSm49XiEEuvCf4saML7c/rNbsTCg1phcsEYvoC5/wh jjW6vTCN2DJsgQj8JA3Z+oF37hWiXCVpaTIrh96LqKBJs5s0fkg2fMrPSNzoA1RItd A3uz+beIsAt6u/fVEjM7orZ04VZvPFH4LVEa6Aw+C+a6ruVEZ0ZVc0MTHeRoCS7OKf SFX+1h78oSbjA== Sender: linux-kernel-owner@vger.kernel.org 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 --- v3: rename 'val' with 'value drivers/clk/tegra/clk-tegra210.c | 51 ++++++++++++++++++++++++++++++++ include/linux/clk/tegra.h | 2 ++ 2 files changed, 53 insertions(+) diff --git a/drivers/clk/tegra/clk-tegra210.c b/drivers/clk/tegra/clk-tegra= 210.c index 68cbb98af567..a91bf9b9be7a 100644 --- a/drivers/clk/tegra/clk-tegra210.c +++ b/drivers/clk/tegra/clk-tegra210.c @@ -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..7a6b29ca3040 100644 --- a/include/linux/clk/tegra.h +++ b/include/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