Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DD79FC433EF for ; Tue, 26 Apr 2022 14:38:15 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C5F5083BDB; Tue, 26 Apr 2022 16:38:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1650983894; bh=Pnnan5dDzfhWktE4hn+9a1VnIjX/KWObhLB+7tvx+BA=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=UPW/1etzt0wowJo8uMvkBLBNit2K3L+PlmiSuvb7fBCWtisORLNQeW2LYC3b7t0IJ OVu8aSKFV3bmuWgFIf8RPN7OKTAXVus+DLpLr0v2ndiTkFz6EFmKilH+ioPrYxbkVA /UOd11ylXfSZkpoVMZUATFFnlGodP6I/vNHdP8zInvSE3bqh7FGKVocJWJ9mR8GuY+ sN6KwmICkEfScpE+UOC7K213gjk9lnXo2+lQdYxOVBNDK2uvwOrfS/JdWYqkfH/yd4 45+sVoRBVyX34yvGtuK1eWY0BIo4Sgc7jXYq9zz8GbhuQODbBzd5v9TR9Zx/xVGERV NsQ4m1cz/HZag== Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id C855E83DAC; Tue, 26 Apr 2022 16:38:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1650983890; bh=Pnnan5dDzfhWktE4hn+9a1VnIjX/KWObhLB+7tvx+BA=; h=From:To:Cc:Subject:Date:From; b=Y3YKS1HRmmAdZ/VwEE+te7805FKF+UyKzAnfNhZ4pfLRhyd7dRhwkSfp6AhsuVT5N 6UHU2dh5uTSYGK5kGsgSXzVwBGo4JjXzto+5IJz0dFOHDVqM/HMGzAy6kx5pIJ+Y0y vp6tC6CL/RlToBVwhQnhxG2RKoWMtdns9CvDl3L7GH9eKlfO3V0Jl8y7GnQJa/dDQZ 6Hg92cA/mNrf8TD2Z1C4DubSjEqrqFbKSXe/FmRzm3VpbfQ64arc9sJO9x1q0WxCG+ BluSOZ3BYyGxbsd+yvFDfSz57FbLL4+d7iyIfXyKKxX01z0UnRpZMEVnyQILbaUHkY Dpl8rH1HBVBaQ== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Patrick Delaunay , Patrice Chotard Subject: [PATCH v2] stm32mp: psci: Retain MCUDIVR, PLL3CR, PLL4CR, MSSCKSELR across suspend Date: Tue, 26 Apr 2022 16:38:05 +0200 Message-Id: <20220426143805.78362-1-marex@denx.de> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean The SoC seems to lose the values of MCUDIVR, PLL3CR, PLL4CR, RCC_MSSCKSELR during suspend/resume cycle, cache them and reinstate their values on resume. Signed-off-by: Marek Vasut Cc: Patrick Delaunay Cc: Patrice Chotard --- V2: Cache MCUDIVR as well --- arch/arm/mach-stm32mp/psci.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/arm/mach-stm32mp/psci.c b/arch/arm/mach-stm32mp/psci.c index 86c160987a9..1e69673e88b 100644 --- a/arch/arm/mach-stm32mp/psci.c +++ b/arch/arm/mach-stm32mp/psci.c @@ -26,6 +26,7 @@ #define PWR_MPUCR_CSSF BIT(9) /* RCC */ +#define RCC_MSSCKSELR 0x48 #define RCC_DDRITFCR 0xd8 #define RCC_DDRITFCR_DDRC1EN BIT(0) @@ -49,6 +50,10 @@ #define RCC_MP_CIFR 0x418 #define RCC_MP_CIFR_WKUPF BIT(20) +#define RCC_MCUDIVR 0x830 +#define RCC_PLL3CR 0x880 +#define RCC_PLL4CR 0x894 + /* SYSCFG */ #define SYSCFG_CMPCR 0x20 #define SYSCFG_CMPCR_SW_CTRL BIT(2) @@ -690,6 +695,7 @@ static void __secure ddr_sw_self_refresh_exit(void) void __secure psci_system_suspend(u32 __always_unused function_id, u32 ep, u32 context_id) { + u32 saved_mcudivr, saved_pll3cr, saved_pll4cr, saved_mssckselr; u32 saved_pwrctl, reg; /* Disable IO compensation */ @@ -708,6 +714,11 @@ void __secure psci_system_suspend(u32 __always_unused function_id, setbits_le32(STM32_PWR_BASE + PWR_MPUCR, PWR_MPUCR_CSSF | PWR_MPUCR_CSTDBYDIS | PWR_MPUCR_PDDS); + saved_mcudivr = readl(STM32_RCC_BASE + RCC_MCUDIVR); + saved_pll3cr = readl(STM32_RCC_BASE + RCC_PLL3CR); + saved_pll4cr = readl(STM32_RCC_BASE + RCC_PLL4CR); + saved_mssckselr = readl(STM32_RCC_BASE + RCC_MSSCKSELR); + psci_v7_flush_dcache_all(); ddr_sr_mode_ssr(&saved_pwrctl); ddr_sw_self_refresh_in(); @@ -724,6 +735,11 @@ void __secure psci_system_suspend(u32 __always_unused function_id, ddr_sw_self_refresh_exit(); ddr_sr_mode_restore(saved_pwrctl); + writel(saved_mcudivr, STM32_RCC_BASE + RCC_MCUDIVR); + writel(saved_pll3cr, STM32_RCC_BASE + RCC_PLL3CR); + writel(saved_pll4cr, STM32_RCC_BASE + RCC_PLL4CR); + writel(saved_mssckselr, STM32_RCC_BASE + RCC_MSSCKSELR); + writel(SYSCFG_CMPENR_MPUEN, STM32_SYSCFG_BASE + SYSCFG_CMPENSETR); clrbits_le32(STM32_SYSCFG_BASE + SYSCFG_CMPCR, SYSCFG_CMPCR_SW_CTRL); } -- 2.35.1