Skip to content

Commit 8f1e6cb

Browse files
author
Thomas Stenersen
committed
drivers: add support for forcing out-of-tree drivers
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 `<DRIVER>_MUST_USE_OUT_OF_TREE_DRIVER` is added as a dependency for each `<DRIVER>`. For example, the out-of-tree subsystem will select `FLASH_MUST_USE_OUT_OF_TREE_DRIVER` to disable all in-tree drivers. 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 clock_control, entropy and flash. Signed-off-by: Thomas Stenersen <[email protected]>
1 parent f92154f commit 8f1e6cb

File tree

3 files changed

+27
-15
lines changed

3 files changed

+27
-15
lines changed

drivers/clock_control/Kconfig

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
#
1010
# Clock controller drivers
1111
#
12+
13+
config CLOCK_CONTROL_MUST_USE_OUT_OF_TREE_DRIVER
14+
bool
15+
help
16+
This option can be enabled by an out-of-tree library if it
17+
needs to take control over the clock controller.
18+
1219
menuconfig CLOCK_CONTROL
1320
bool "Hardware clock controller support"
1421
help
@@ -23,18 +30,15 @@ module = CLOCK_CONTROL
2330
module-str = clock control
2431
source "subsys/logging/Kconfig.template.log_config"
2532

26-
source "drivers/clock_control/Kconfig.nrf"
2733

34+
if !CLOCK_CONTROL_MUST_USE_OUT_OF_TREE_DRIVER
35+
source "drivers/clock_control/Kconfig.nrf"
2836
source "drivers/clock_control/Kconfig.quark_se"
29-
3037
source "drivers/clock_control/Kconfig.stm32"
31-
3238
source "drivers/clock_control/Kconfig.beetle"
33-
3439
source "drivers/clock_control/Kconfig.mcux_ccm"
35-
3640
source "drivers/clock_control/Kconfig.mcux_sim"
37-
3841
source "drivers/clock_control/Kconfig.rv32m1"
42+
endif # !CLOCK_CONTROL_MUST_USE_OUT_OF_TREE_DRIVER
3943

4044
endif # CLOCK_CONTROL

drivers/entropy/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,28 @@
66
# SPDX-License-Identifier: Apache-2.0
77
#
88

9+
config ENTROPY_MUST_USE_OUT_OF_TREE_DRIVER
10+
bool
11+
help
12+
This option can be enabled by an out-of-tree library if it
13+
needs to take control over the entropy driver.
14+
915
menuconfig ENTROPY_GENERATOR
1016
bool "Entropy Drivers"
1117
help
1218
Include entropy drivers in system config.
1319

20+
1421
if ENTROPY_GENERATOR
1522

23+
if !ENTROPY_MUST_USE_OUT_OF_TREE_DRIVER
1624
source "drivers/entropy/Kconfig.mcux"
1725
source "drivers/entropy/Kconfig.stm32"
1826
source "drivers/entropy/Kconfig.esp32"
1927
source "drivers/entropy/Kconfig.nrf5"
2028
source "drivers/entropy/Kconfig.sam"
2129
source "drivers/entropy/Kconfig.native_posix"
30+
endif # !ENTROPY_MUST_USE_OUT_OF_TREE_DRIVER
2231

2332
config ENTROPY_HAS_DRIVER
2433
bool

drivers/flash/Kconfig

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ config FLASH_HAS_PAGE_LAYOUT
2020
This option is enabled when the SoC flash driver supports
2121
retrieving the layout of flash memory pages.
2222

23+
config FLASH_MUST_USE_OUT_OF_TREE_DRIVER
24+
bool
25+
help
26+
This option can be enabled by an out-of-tree library if it
27+
needs to take control over the flash memory peripheral.
28+
2329
menuconfig FLASH
2430
bool "Flash hardware support"
2531
help
@@ -45,24 +51,17 @@ config FLASH_PAGE_LAYOUT
4551
help
4652
Enables API for retrieving the layout of flash memory pages.
4753

54+
if !FLASH_MUST_USE_OUT_OF_TREE_DRIVER
4855
source "drivers/flash/Kconfig.nrf"
49-
5056
source "drivers/flash/Kconfig.mcux"
51-
5257
source "drivers/flash/Kconfig.nios2_qspi"
53-
5458
source "drivers/flash/Kconfig.gecko"
55-
5659
source "drivers/flash/Kconfig.nor"
57-
5860
source "drivers/flash/Kconfig.qmsi"
59-
6061
source "drivers/flash/Kconfig.stm32"
61-
6262
source "drivers/flash/Kconfig.sam0"
63-
6463
source "drivers/flash/Kconfig.sam"
65-
6664
source "drivers/flash/Kconfig.w25qxxdv"
65+
endif # !FLASH_MUST_USE_OUT_OF_TREE_DRIVER
6766

6867
endif # FLASH

0 commit comments

Comments
 (0)