Skip to content

Commit

Permalink
[build] add add_syterkit_driver function
Browse files Browse the repository at this point in the history
  • Loading branch information
SamulKyull authored and SamulKyull committed Dec 6, 2024
1 parent e8e9fff commit 13ca934
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 56 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ project(SyterKit VERSION 0.4.0 LANGUAGES C CXX ASM)

# Include other CMake modules
include(cmake/add_syterkit_app.cmake)
include(cmake/add_syterkit_driver.cmake)

# Get the name of the compiler
string(SUBSTRING ${CMAKE_C_COMPILER} 1 -1 COMPILER_NAME)
Expand Down
3 changes: 3 additions & 0 deletions cmake/add_syterkit_driver.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
macro(add_syterkit_driver target_name)
include(${target_name}/CMakeModule.cmake)
endmacro()
65 changes: 9 additions & 56 deletions src/drivers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,67 +1,20 @@
set(DRIVER_PMU "")
add_syterkit_driver(gpio)
add_syterkit_driver(intc)
add_syterkit_driver(pmu)
add_syterkit_driver(mtd)
add_syterkit_driver(usb)

if (CONFIG_CHIP_GPIO_V1)
set(DRIVER_GPIO gpio/sys-gpio-v1.c)
elseif(CONFIG_CHIP_GPIO_V2)
set(DRIVER_GPIO gpio/sys-gpio-v2.c)
elseif(CONFIG_CHIP_GPIO_V3)
set(DRIVER_GPIO gpio/sys-gpio-v3.c)
if (CONFIG_CHIP_MMC_V2)
add_syterkit_driver(mmc)
else()
set(DRIVER_GPIO gpio/sys-gpio-v2.c)
add_syterkit_driver(sdhci)
endif()

set(COMMON_DRIVER
sys-uart.c
${DRIVER_GPIO}
)

set(USB_DRIVER "")
if (CONFIG_CHIP_USB)
set(USB_DRIVER
usb/usb.c
usb/usb_controller.c
usb/usb_device.c
usb/usb_dma.c

usb/module/usb_detect.c
usb/module/usb_mass.c
)
endif()

set(GIC_DRIVER "")
if (CONFIG_CHIP_GIC)
set(GIC_DRIVER
intc/sys-gic.c
)
endif()

if (CONFIG_CHIP_WITHPMU)
set(DRIVER_PMU
pmu/axp.c
pmu/axp1530.c
pmu/axp2101.c
pmu/axp2202.c
)
endif()

if (CONFIG_CHIP_MMC_V2)
set(MMC_DRIVER
mmc/sys-mmc.c
mmc/sys-sdhci.c
mmc/sys-sdcard.c
)
else()
set(MMC_DRIVER
sdhci/sys-sdcard.c
sdhci/sys-sdhci.c
)
endif()

set(MTD_DRIVER
mtd/sys-spi-nand.c
mtd/sys-spi-nor.c
)

if (NOT CONFIG_CHIP_MINSYS)
set(COMMON_DRIVER
${COMMON_DRIVER}
Expand All @@ -73,7 +26,7 @@ if (NOT CONFIG_CHIP_MINSYS)
sys-i2c.c

${USB_DRIVER}
${GIC_DRIVER}
${INTC_DRIVER}
${MMC_DRIVER}
${MTD_DRIVER}
)
Expand Down
9 changes: 9 additions & 0 deletions src/drivers/gpio/CMakeModule.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
if (CONFIG_CHIP_GPIO_V1)
set(DRIVER_GPIO gpio/sys-gpio-v1.c)
elseif(CONFIG_CHIP_GPIO_V2)
set(DRIVER_GPIO gpio/sys-gpio-v2.c)
elseif(CONFIG_CHIP_GPIO_V3)
set(DRIVER_GPIO gpio/sys-gpio-v3.c)
else()
set(DRIVER_GPIO gpio/sys-gpio-v2.c)
endif()
6 changes: 6 additions & 0 deletions src/drivers/intc/CMakeModule.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
set(INTC_DRIVER "")
if (CONFIG_CHIP_GIC)
set(INTC_DRIVER
intc/sys-gic.c
)
endif()
5 changes: 5 additions & 0 deletions src/drivers/mmc/CMakeModule.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set(MMC_DRIVER
mmc/sys-mmc.c
mmc/sys-sdhci.c
mmc/sys-sdcard.c
)
4 changes: 4 additions & 0 deletions src/drivers/mtd/CMakeModule.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set(MTD_DRIVER
mtd/sys-spi-nand.c
mtd/sys-spi-nor.c
)
9 changes: 9 additions & 0 deletions src/drivers/pmu/CMakeModule.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
if (CONFIG_CHIP_WITHPMU)
set(DRIVER_PMU
pmu/axp.c
pmu/axp1530.c
pmu/axp2101.c
pmu/axp2202.c
pmu/axp8191.c
)
endif()
4 changes: 4 additions & 0 deletions src/drivers/sdhci/CMakeModule.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set(MMC_DRIVER
sdhci/sys-sdcard.c
sdhci/sys-sdhci.c
)
12 changes: 12 additions & 0 deletions src/drivers/usb/CMakeModule.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
set(USB_DRIVER "")
if (CONFIG_CHIP_USB)
set(USB_DRIVER
usb/usb.c
usb/usb_controller.c
usb/usb_device.c
usb/usb_dma.c

usb/module/usb_detect.c
usb/module/usb_mass.c
)
endif()

0 comments on commit 13ca934

Please sign in to comment.