dts: Introduce Kconfig.dts

Introduce a generated Kconfig.dts that sets a Kconfig symbol for
every compatible.

* We set DT_HAS_<compat>_ENABLED if the devicetree has a node with
  <compat> enabled. (status is okay...)

We can then use the Kconfig symbol in driver Kconfig to determine
if the driver should be available, and thus enabled by default.

Signed-off-by: Kumar Gala <galak@kernel.org>
This commit is contained in:
Kumar Gala 2022-07-12 13:41:03 -05:00 committed by Marti Bolivar
parent b109a0a9f7
commit c9aa63c0dc
2 changed files with 23 additions and 0 deletions

View file

@ -35,6 +35,10 @@ set(DTS_DEPS ${PROJECT_BINARY_DIR}/zephyr.dts.d)
# This is relative to each element of DTS_ROOT.
set(VENDOR_PREFIXES dts/bindings/vendor-prefixes.txt)
# Devicetree in Kconfig.
set(GEN_DRIVER_KCONFIG_SCRIPT ${ZEPHYR_BASE}/scripts/dts/gen_driver_kconfig_dts.py)
set(DTS_KCONFIG ${KCONFIG_BINARY_DIR}/Kconfig.dts)
# Devicetree in CMake.
set(DTS_CMAKE_SCRIPT ${ZEPHYR_BASE}/scripts/dts/gen_dts_cmake.py)
set(DTS_CMAKE ${PROJECT_BINARY_DIR}/dts.cmake)
@ -196,6 +200,7 @@ if(SUPPORTS_DTS)
CMAKE_CONFIGURE_DEPENDS
${include_files}
${GEN_DEFINES_SCRIPT}
${GEN_DRIVER_KCONFIG_SCRIPT}
${DTS_CMAKE_SCRIPT}
)
@ -233,6 +238,18 @@ if(SUPPORTS_DTS)
message(STATUS "Generated device_extern.h: ${DEVICE_EXTERN_H}")
endif()
execute_process(
COMMAND ${PYTHON_EXECUTABLE} ${GEN_DRIVER_KCONFIG_SCRIPT}
--kconfig-out ${DTS_KCONFIG}
--bindings-dirs ${DTS_ROOT_BINDINGS}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
RESULT_VARIABLE ret
)
if(NOT "${ret}" STREQUAL "0")
message(FATAL_ERROR "gen_driver_kconfig_dts.py failed with return code: ${ret}")
endif()
execute_process(
COMMAND ${PYTHON_EXECUTABLE} ${DTS_CMAKE_SCRIPT}
--edt-pickle ${EDT_PICKLE}

View file

@ -5,3 +5,9 @@ config HAS_DTS
help
This option specifies that the target platform supports device tree
configuration.
menu "Devicetree Info"
source "$(KCONFIG_BINARY_DIR)/Kconfig.dts"
endmenu