From 1e06ba2328d94847bb6374afdf39715b5bc2865e Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Mon, 3 Jul 2023 19:39:10 +1000 Subject: [PATCH] soc: arm: nordic: handle nRF52832 anomaly 109 Enable workaround for anomaly 109 by default when affected peripherals are enabled. Signed-off-by: Jordan Yates --- modules/hal_nordic/nrfx/nrfx_config.h | 7 +++++++ soc/arm/nordic_nrf/nrf52/CMakeLists.txt | 8 ++++++++ soc/arm/nordic_nrf/nrf52/Kconfig.soc | 11 +++++++++++ 3 files changed, 26 insertions(+) diff --git a/modules/hal_nordic/nrfx/nrfx_config.h b/modules/hal_nordic/nrfx/nrfx_config.h index 4b7cabd7a98..a843e96c3ba 100644 --- a/modules/hal_nordic/nrfx/nrfx_config.h +++ b/modules/hal_nordic/nrfx/nrfx_config.h @@ -487,6 +487,13 @@ #define NRFX_WDT1_ENABLED 1 #endif +#ifdef CONFIG_NRF52_ANOMALY_109_WORKAROUND +#define NRFX_SPIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 1 +#define NRFX_SPIS_NRF52_ANOMALY_109_WORKAROUND_ENABLED 1 +#define NRFX_TWIM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 1 +#define NRFX_PWM_NRF52_ANOMALY_109_WORKAROUND_ENABLED 1 +#endif + #if defined(CONFIG_SOC_SERIES_BSIM_NRFXX) #include "nrfx_config_bsim.h" #endif diff --git a/soc/arm/nordic_nrf/nrf52/CMakeLists.txt b/soc/arm/nordic_nrf/nrf52/CMakeLists.txt index 06fddff5f06..24fdcf6093e 100644 --- a/soc/arm/nordic_nrf/nrf52/CMakeLists.txt +++ b/soc/arm/nordic_nrf/nrf52/CMakeLists.txt @@ -14,3 +14,11 @@ zephyr_library_include_directories( if(CONFIG_SOC_NRF52832_ALLOW_SPIM_DESPITE_PAN_58 AND CONFIG_SPI_NRFX_SPIM) message(WARNING "Both SOC_NRF52832_ALLOW_SPIM_DESPITE_PAN_58 and an NRF SPIM driver are enabled, therefore PAN 58 will apply if RXD.MAXCNT == 1 and TXD.MAXCNT <= 1") endif() + +if(CONFIG_SOC_NRF52832) + if(NOT CONFIG_NRF52_ANOMALY_109_WORKAROUND) + if (CONFIG_NRFX_SPIS OR CONFIG_NRFX_SPIM OR CONFIG_NRFX_TWIM OR CONFIG_NRFX_PWM) + message(WARNING "NRF52_ANOMALY_109_WORKAROUND disabled with SPIS, SPIM, TWIM or PWM enabled. This will occasionally cause the first byte transmitted to be incorrect") + endif() + endif() +endif() diff --git a/soc/arm/nordic_nrf/nrf52/Kconfig.soc b/soc/arm/nordic_nrf/nrf52/Kconfig.soc index 13a2fef932b..f1a337cbe12 100644 --- a/soc/arm/nordic_nrf/nrf52/Kconfig.soc +++ b/soc/arm/nordic_nrf/nrf52/Kconfig.soc @@ -129,4 +129,15 @@ config NRF52_ANOMALY_198_WORKAROUND This anomaly applies to IC revisions "Engineering B" up to "3", the most recent one. +config NRF52_ANOMALY_109_WORKAROUND + bool "Anomaly 109 workaround" + default y + depends on SOC_NRF52832 + depends on NRFX_SPIS || NRFX_SPIM || NRFX_TWIM || NRFX_PWM + help + Due to Anomaly 109 the first byte sent out by these peripherals is + sometimes wrong. This occurs when the system enters IDLE and stops the + 64MHz clock at the same time as the peripheral that is using DMA is started. + This anomaly applies to IC revisions up to "3", the most recent one. + endif # SOC_SERIES_NRF52X