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 AA3F8C77B61 for ; Mon, 1 May 2023 13:01:37 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BCA7486054; Mon, 1 May 2023 15:01:35 +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="hHBi3FAI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6876186232; Mon, 1 May 2023 15:01:34 +0200 (CEST) Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (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 24840859F2 for ; Mon, 1 May 2023 15:01:30 +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=nm@ti.com Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 341D1Rsu099988; Mon, 1 May 2023 08:01:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1682946087; bh=KHoCXpzC7dEFOz7ugnX2Tt33n5S8aAGHZUUgn4srDus=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=hHBi3FAImT4GRjnNpvAWzm44c1F8BT+1biZjpeSk6W6Xr+mhCLB02vUtxhtwzN1SU P2Hxv9h9kP2F1c4AY/3u+KfAi+zqA9aY5yevjf1TExDF0KtHFiaHMkXUNfuDifFg6y rE3UQ4cU4QoXWUf6UWB4kOJ6RkSJSxCuOWwaRu9A= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 341D1RRQ095498 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 1 May 2023 08:01:27 -0500 Received: from DFLE101.ent.ti.com (10.64.6.22) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Mon, 1 May 2023 08:01:27 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE101.ent.ti.com (10.64.6.22) 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; Mon, 1 May 2023 08:01:26 -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 341D1RLn085410; Mon, 1 May 2023 08:01:27 -0500 Date: Mon, 1 May 2023 08:01:27 -0500 From: Nishanth Menon To: Bryan Brattlof CC: Tom Rini , Vignesh Raghavendra , Vibhore Vardhan , Praneeth Bajjuri , UBoot Mailing List Subject: Re: [PATCH] arm: mach-k3: am625_init: Add Erratum WA for RTC startup Message-ID: <20230501130127.zybss2c6l57ticlh@mulch> References: <20230427192642.1115224-1-bb@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20230427192642.1115224-1-bb@ti.com> 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 On 14:26-20230427, Bryan Brattlof wrote: > 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 > --- It will be good to state in the diffstat that am62a7 or other k3 SoCs are not impacted: am62a7 has the hardware fix and other SoCs do not have this rtc. I dont think there is a need to respin the patch for that - just clarifying. > 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 > -- Regards, Nishanth Menon Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D