From db90e24326709678a6cfb21f57a14bd4c4e38a2f Mon Sep 17 00:00:00 2001 From: Thomas Stenersen Date: Thu, 21 Feb 2019 16:02:16 +0100 Subject: [PATCH] drivers: nrf: add support for forcing driver implementation An external project extending the Zephyr RTOS and its drivers may have subsystems that must use its own specific driver(s) when active. One example is the nRF5x NVMC that must be scheduled in between radio operations. A subsystem may also be dependent on its own drivers for security, real-time and/or because of hardware constrains. In order to not introduce non-Zephyr specific code into the Zephyr tree, an option is added to disable the in-tree drivers in Zephyr. Because Kconfig does not support a good way of de-selecting other symbols, a variable on the form `_FORCE_ALT` is added as a dependency for each ``. For example, the out-of-tree subsystem will select `FLASH_NRF_FORCE_ALT` to disable the in-tree driver. A solution for issue #8181 would open up for a more general solution, however #8181 requires significant effort. Support for out-of-tree drivers is added to Nordic drivers for clock_control, entropy and flash. A generic solution for this is desired. Issue #14527 is tracking that progress. Signed-off-by: Thomas Stenersen --- drivers/clock_control/Kconfig.nrf | 11 +++++++++++ drivers/entropy/Kconfig.nrf5 | 11 +++++++++++ drivers/flash/Kconfig.nrf | 11 +++++++++++ 3 files changed, 33 insertions(+) diff --git a/drivers/clock_control/Kconfig.nrf b/drivers/clock_control/Kconfig.nrf index 3fe072a4eb7..5f52c731ef0 100644 --- a/drivers/clock_control/Kconfig.nrf +++ b/drivers/clock_control/Kconfig.nrf @@ -4,6 +4,15 @@ # # SPDX-License-Identifier: Apache-2.0 +config CLOCK_CONTROL_NRF_FORCE_ALT + bool + depends on SOC_COMPATIBLE_NRF + help + This option can be enabled to force an alternative implementation + of the clock control driver. + +if !CLOCK_CONTROL_NRF_FORCE_ALT + menuconfig CLOCK_CONTROL_NRF bool "NRF Clock controller support" depends on SOC_COMPATIBLE_NRF @@ -67,3 +76,5 @@ config CLOCK_CONTROL_NRF_K32SRC_20PPM endchoice endif # CLOCK_CONTROL_NRF + +endif #!CLOCK_CONTROL_NRF_FORCE_ALT diff --git a/drivers/entropy/Kconfig.nrf5 b/drivers/entropy/Kconfig.nrf5 index 5185743f36d..8d9aefee6ff 100644 --- a/drivers/entropy/Kconfig.nrf5 +++ b/drivers/entropy/Kconfig.nrf5 @@ -5,6 +5,15 @@ # # SPDX-License-Identifier: Apache-2.0 +config ENTROPY_NRF_FORCE_ALT + bool + depends on SOC_COMPATIBLE_NRF + help + This option can be enabled to force an alternative implementation + of the entropy driver. + +if !ENTROPY_NRF_FORCE_ALT + menuconfig ENTROPY_NRF5_RNG bool "nRF5 RNG driver" depends on SOC_COMPATIBLE_NRF @@ -70,3 +79,5 @@ config ENTROPY_NRF5_PRI nRF5X RNG IRQ priority. endif # ENTROPY_NRF5_RNG + +endif # !ENTROPY_NRF_FORCE_ALT diff --git a/drivers/flash/Kconfig.nrf b/drivers/flash/Kconfig.nrf index 13e49f5cbc4..5ae519fcae9 100644 --- a/drivers/flash/Kconfig.nrf +++ b/drivers/flash/Kconfig.nrf @@ -1,3 +1,12 @@ +config FLASH_NRF_FORCE_ALT + bool + depends on SOC_COMPATIBLE_NRF + help + This option can be enabled to force an alternative implementation + of the flash driver. + +if !FLASH_NRF_FORCE_ALT + config SOC_FLASH_NRF bool "Nordic Semiconductor nRF flash driver" depends on SOC_FAMILY_NRF @@ -20,3 +29,5 @@ config SOC_FLASH_NRF_UICR help Enable operations on UICR. Once enabled UICR are written or read as ordinary flash memory. Erase is possible for whole UICR at once. + +endif #!FLASH_NRF_FORCE_ALT