Let's take watchdog driver for example.
Make directory drivers/watchdog, and put your source code into it.
mkdir -p drivers/watchdog
Write Kconfig for your driver.
@code
config WATCHDOG bool "Watchdog driver" @endcode
Then add the following line to drivers/Kconfig. @code rsource "watchdog/Kconfig" @endcode
Write CMakeLists.txt for your driver.
@code
aml_library_include_directories( ${CMAKE_CURRENT_LIST_DIR} )
aml_library_sources_ifdef( CONFIG_WATCHDOG watchdog.c ) @endcode
Then add the following line to root CMakeLists.txt. @code add_subdirectory(watchdog) @endcode
Let's take boards/arm64/ad401_a113l for example.
Add the following line to boards/arm64/ad401_a113l/defconfig.
@code CONFIG_WATCHDOG=y @endcode
Add driver startup with DRIVER_INIT
#ifdef CONFIG_ARM64 #include "initcall.h" #endif void watch_dog_init(void) { vWatchdogInit(10000); vWatchdogEnable(); } #ifdef CONFIG_ARM64 DRIVER_INIT(watch_dog_init); #endif