From 6492dcec6fa159aa9fb794d69c6abf8fc2b68203 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20R=C3=B8nningstad?= Date: Mon, 24 Feb 2020 16:42:44 +0100 Subject: [PATCH] soc: nrf53: soc: Add nrf53_has_erratum19() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit And add assert on bootup if workarounds are not enabled. Signed-off-by: Øyvind Rønningstad --- soc/arm/nordic_nrf/nrf53/soc.c | 29 +++++++++++++++++++++++++++++ soc/arm/nordic_nrf/nrf53/soc.h | 4 ++++ 2 files changed, 33 insertions(+) diff --git a/soc/arm/nordic_nrf/nrf53/soc.c b/soc/arm/nordic_nrf/nrf53/soc.c index 250ba5e2a45..64bd585c522 100644 --- a/soc/arm/nordic_nrf/nrf53/soc.c +++ b/soc/arm/nordic_nrf/nrf53/soc.c @@ -89,5 +89,34 @@ void z_platform_init(void) SystemInit(); } +#if defined(CONFIG_SOC_NRF5340_CPUAPP) && \ + !defined(CONFIG_TRUSTED_EXECUTION_NONSECURE) +bool nrf53_has_erratum19(void) +{ + if (NRF_FICR->INFO.PART == 0x5340) { + if (NRF_FICR->INFO.VARIANT == 0x41414142) { + return true; + } + } + return false; +} + +#ifndef CONFIG_NRF5340_CPUAPP_ERRATUM19 +static int check_erratum19(struct device *arg) +{ + ARG_UNUSED(arg); + if (nrf53_has_erratum19()) { + LOG_ERR("This device is affected by nRF53 Erratum 19,"); + LOG_ERR("but workarounds have not been enabled."); + LOG_ERR("See CONFIG_NRF5340_CPUAPP_ERRATUM19."); + k_panic(); + } + + return 0; +} + +SYS_INIT(check_erratum19, POST_KERNEL, CONFIG_APPLICATION_INIT_PRIORITY); +#endif +#endif SYS_INIT(nordicsemi_nrf53_init, PRE_KERNEL_1, 0); diff --git a/soc/arm/nordic_nrf/nrf53/soc.h b/soc/arm/nordic_nrf/nrf53/soc.h index 4a1c602e3aa..0322d74ee97 100644 --- a/soc/arm/nordic_nrf/nrf53/soc.h +++ b/soc/arm/nordic_nrf/nrf53/soc.h @@ -29,4 +29,8 @@ #define FLASH_PAGE_MAX_CNT 128UL #endif +#ifdef CONFIG_SOC_NRF5340_CPUAPP +bool nrf53_has_erratum19(void); +#endif + #endif /* _NORDICSEMI_NRF53_SOC_H_ */