* [PATCH v2] arm: mach-k3: am625_init: Add Erratum WA for RTC startup
@ 2023-05-16 23:06 Bryan Brattlof
2023-06-01 19:48 ` Tom Rini
0 siblings, 1 reply; 2+ messages in thread
From: Bryan Brattlof @ 2023-05-16 23:06 UTC (permalink / raw)
To: Tom Rini; +Cc: Nishanth Menon, UBoot Mailing List, Bryan Brattlof
From: Nishanth Menon <nm@ti.com>
In the first silicon revision of the am62x family of SoCs, the hardware
wakeup event cannot be used if software is unable to unlock the RTC
device within one second after boot. To work around this limitation
unlock RTC as soon as possible in the boot flow to maximize our chance
of linux being able to use this device.
Add the erratum i2327 workaround to initialize the RTC.
Signed-off-by: Nishanth Menon <nm@ti.com>
[bb@ti.com: rebased from 2021.01 and expanded commit and code messages]
Signed-off-by: Bryan Brattlof <bb@ti.com>
---
arch/arm/mach-k3/am625_init.c | 46 +++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/arch/arm/mach-k3/am625_init.c b/arch/arm/mach-k3/am625_init.c
index 026c4f9c02d71..787fe9229552f 100644
--- a/arch/arm/mach-k3/am625_init.c
+++ b/arch/arm/mach-k3/am625_init.c
@@ -15,6 +15,15 @@
#include <dm/uclass-internal.h>
#include <dm/pinctrl.h>
+#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,42 @@ static __maybe_unused void enable_mcu_esm_reset(void)
writel(stat, CTRLMMR_MCU_RST_CTRL);
}
+#if defined(CONFIG_CPU_V7R)
+
+/*
+ * RTC Erratum i2327 Workaround for Silicon Revision 1
+ *
+ * Due to a bug in initial synchronization out of cold power on,
+ * IRQ status can get locked infinitely if we do not 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.
+ *
+ * https://www.ti.com/lit/er/sprz487c/sprz487c.pdf
+ */
+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 +123,7 @@ void board_init_f(ulong dummy)
#if defined(CONFIG_CPU_V7R)
setup_k3_mpu_regions();
+ rtc_erratumi2327_init();
#endif
/*
base-commit: 6e1852ca2c418e2536ead4b51c4d84a59926b3f1
--
2.40.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] arm: mach-k3: am625_init: Add Erratum WA for RTC startup
2023-05-16 23:06 [PATCH v2] arm: mach-k3: am625_init: Add Erratum WA for RTC startup Bryan Brattlof
@ 2023-06-01 19:48 ` Tom Rini
0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2023-06-01 19:48 UTC (permalink / raw)
To: Bryan Brattlof; +Cc: Nishanth Menon, UBoot Mailing List
[-- Attachment #1: Type: text/plain, Size: 720 bytes --]
On Tue, May 16, 2023 at 06:06:21PM -0500, Bryan Brattlof wrote:
> From: Nishanth Menon <nm@ti.com>
>
> In the first silicon revision of the am62x family of SoCs, the hardware
> wakeup event cannot be used if software is unable to unlock the RTC
> device within one second after boot. To work around this limitation
> unlock RTC as soon as possible in the boot flow to maximize our chance
> of linux being able to use this device.
>
> Add the erratum i2327 workaround to initialize the RTC.
>
> Signed-off-by: Nishanth Menon <nm@ti.com>
> [bb@ti.com: rebased from 2021.01 and expanded commit and code messages]
> Signed-off-by: Bryan Brattlof <bb@ti.com>
Applied to u-boot/next, thanks!
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-01 19:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-16 23:06 [PATCH v2] arm: mach-k3: am625_init: Add Erratum WA for RTC startup Bryan Brattlof
2023-06-01 19:48 ` Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox