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 C57DDC77B73 for ; Thu, 27 Apr 2023 19:27:00 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D632B86171; Thu, 27 Apr 2023 21:26:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="MoX9DQif"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 74D8186171; Thu, 27 Apr 2023 21:26:57 +0200 (CEST) Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CDD1785E6A for ; Thu, 27 Apr 2023 21:26:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bb@ti.com Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 33RJQptX049453; Thu, 27 Apr 2023 14:26:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1682623611; bh=zt18oq3jTIt5hWYReQUoKhwlpeuWrfoTwezZvpQQkBc=; h=From:To:CC:Subject:Date; b=MoX9DQif4MjsZqcB469QE5iQsNvF00ay0q59ZttKiiyuWoDEGmufey5p4hdfk35sS 0shlo23Y4trpjDLmb4E/S1BSF3kL/Q+lgxDVz2goxQFSRjB46v1b8mgooWuCneW1c5 RAcSg/5Cdi+oUShDijj3a7SzUdITMxlkEPlBmZuc= Received: from DFLE107.ent.ti.com (dfle107.ent.ti.com [10.64.6.28]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 33RJQpbx020628 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 27 Apr 2023 14:26:51 -0500 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 27 Apr 2023 14:26:51 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Thu, 27 Apr 2023 14:26:51 -0500 Received: from localhost (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 33RJQpSe116838; Thu, 27 Apr 2023 14:26:51 -0500 From: Bryan Brattlof To: Tom Rini CC: Vignesh Raghavendra , Vibhore Vardhan , Nishanth Menon , Praneeth Bajjuri , UBoot Mailing List , Bryan Brattlof Subject: [PATCH] arm: mach-k3: am625_init: Add Erratum WA for RTC startup Date: Thu, 27 Apr 2023 14:26:42 -0500 Message-ID: <20230427192642.1115224-1-bb@ti.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2528; i=bb@ti.com; h=from:subject; bh=tumsNIcAYKZE2iGtuZyFLn8bpe+eBpLmPf3Gpe4Qovg=; b=owNCWmg5MUFZJlNZ2cwQ6QAAZH////7b/y/2/S+eOrb+3aZ+D3zv//+NndOH+3/f77p+1/2wA RsYIeoGgAAaBk0DQAaADTJoAA0DQAAABoDQPUAADEGm1DRiaeoyNPU9QNPGqGUDQAAGgaAA0ANM gZAAAM1AAB6jNJ6QMg0eoNND0geoDQaMnqAaDIaeo09QIaMjQxNA0aGgBkGhkaaZDQNDQ9TBAMh oYQaAAwINBpoDTQAGmEAyZMgBpoECWYYYAHCnkUBDCIdqQlH8AnBNJzdDihL5Uq31mCxtfRCyLz TmvEF4E5/YzAOQNboRH8X1X9KbcQqZYZQPM8ICUOEuES9a6iCLuzhGwq9uQw7FT6/K0zHqUic5h KBiXoFHHDKEKZOAvHPA4u7w+mtkwEC5FM2k7vDqsjLnSSTkmR5JEzIOcezowu+wfBSPNs56UDqL BbZWCg2GoTgIAs667+jbJUwFlmaMWrP9iw+x41YZZW54ZdOUlPj1wqgnr7El/5rGrMuS+su2kF2 b6PR2QIj5mWvEQU7iN6ZSIo+9AhVu5cAVgODC+Vqg/kNeKaW0gJos9IKMTKLCnHVkvkWa1NaSGX YDMe4gcJEhYkjpx/g2EMV9LOU4c6QCJAGAnxTRfyZ/hVeyZ9jCNcyWjKXnTAQGQ3FIwBEyB5+PA KAla/8XckU4UJDZzBDp X-Developer-Key: i=bb@ti.com; a=openpgp; fpr=D3D177E40A38DF4D1853FEEF41B90D5D71D56CE0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 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.8 at phobos.denx.de X-Virus-Status: Clean From: Nishanth Menon Add erratum i2327 work around for initialization for RTC interrupt where interrupt is stuck for ever at startup. Unfortunately, this workaround needs to be applied under 1 second of boot. Signed-off-by: Nishanth Menon [bb@ti.com: rebased from 2021.01] Signed-off-by: Bryan Brattlof --- arch/arm/mach-k3/am625_init.c | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/arch/arm/mach-k3/am625_init.c b/arch/arm/mach-k3/am625_init.c index a91c15ca4e188..e90c18fdcc118 100644 --- a/arch/arm/mach-k3/am625_init.c +++ b/arch/arm/mach-k3/am625_init.c @@ -15,6 +15,15 @@ #include #include +#define RTC_BASE_ADDRESS 0x2b1f0000 +#define REG_K3RTC_S_CNT_LSW (RTC_BASE_ADDRESS + 0x18) +#define REG_K3RTC_KICK0 (RTC_BASE_ADDRESS + 0x70) +#define REG_K3RTC_KICK1 (RTC_BASE_ADDRESS + 0x74) + +/* Magic values for lock/unlock */ +#define K3RTC_KICK0_UNLOCK_VALUE 0x83e70b13 +#define K3RTC_KICK1_UNLOCK_VALUE 0x95a4f1e0 + /* * This uninitialized global variable would normal end up in the .bss section, * but the .bss is cleared between writing and reading this variable, so move @@ -71,6 +80,40 @@ static __maybe_unused void enable_mcu_esm_reset(void) writel(stat, CTRLMMR_MCU_RST_CTRL); } +#if defined(CONFIG_CPU_V7R) + +/* + * RTC Erratum i2327 Workaround + * Due to a bug in initial synchronization out of cold power on, + * IRQ status can get locked infinitely if we do not: + * a) unlock RTC + * + * This workaround *must* be applied within 1 second of power on, + * So, this is closest point to be able to guarantee the max + * timing. + */ +void rtc_erratumi2327_init(void) +{ + u32 counter; + + /* + * If counter has gone past 1, nothing we can do, leave + * system locked! This is the only way we know if RTC + * can be used for all practical purposes. + */ + counter = readl(REG_K3RTC_S_CNT_LSW); + if (counter > 1) + return; + /* + * Need to set this up at the very start + * MUST BE DONE under 1 second of boot. + */ + writel(K3RTC_KICK0_UNLOCK_VALUE, REG_K3RTC_KICK0); + writel(K3RTC_KICK1_UNLOCK_VALUE, REG_K3RTC_KICK1); + return; +} +#endif + void board_init_f(ulong dummy) { struct udevice *dev; @@ -78,6 +121,7 @@ void board_init_f(ulong dummy) #if defined(CONFIG_CPU_V7R) setup_k3_mpu_regions(); + rtc_erratumi2327_init(); #endif /* base-commit: a25dcda452bf6a6de72764a8d990d72e5def643d -- 2.40.0