1set(MCUX_SDK_PROJECT_NAME ${ZEPHYR_CURRENT_LIBRARY})
2# Translate the SoC name and part number into the mcux device and cpu
3# name respectively.
4string(TOUPPER ${CONFIG_SOC} MCUX_DEVICE)
5
6if("${MCUX_DEVICE}" STREQUAL "LPC51U68")
7  set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER})
8  set(MCUX_DEVICE LPC51U68)
9elseif("${MCUX_DEVICE}" STREQUAL "LPC54114")
10  set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER}_cm4)
11elseif("${MCUX_DEVICE}" STREQUAL "LPC54114_M0")
12  set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER}_cm0plus)
13  set(MCUX_DEVICE LPC54114)
14elseif("${MCUX_DEVICE}" STREQUAL "LPC55S16")
15  set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER})
16  set(MCUX_DEVICE LPC55S16)
17elseif("${MCUX_DEVICE}" STREQUAL "LPC55S28")
18  set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER})
19  set(MCUX_DEVICE LPC55S28)
20elseif("${MCUX_DEVICE}" STREQUAL "LPC55S69_CPU0")
21  set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER}_cm33_core0)
22  set(MCUX_DEVICE LPC55S69)
23elseif("${MCUX_DEVICE}" STREQUAL "LPC55S69_CPU1")
24  set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER}_cm33_core1)
25  set(MCUX_DEVICE LPC55S69)
26elseif("${MCUX_DEVICE}" STREQUAL "MIMXRT1052")
27  string(REGEX REPLACE "(.*)[AB]$" "CPU_\\1B" MCUX_CPU ${CONFIG_SOC_PART_NUMBER})
28elseif("${MCUX_DEVICE}" STREQUAL "MIMXRT595S_CM33")
29  set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER}_cm33)
30  set(MCUX_DEVICE MIMXRT595S)
31elseif("${MCUX_DEVICE}" STREQUAL "MIMXRT685S_CM33")
32  set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER}_cm33)
33  set(MCUX_DEVICE MIMXRT685S)
34elseif("${MCUX_DEVICE}" STREQUAL "MIMXRT1176_CM4")
35  set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER}_cm4)
36  set(MCUX_DEVICE MIMXRT1176)
37elseif("${MCUX_DEVICE}" STREQUAL "MIMXRT1176_CM7")
38  set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER}_cm7)
39  set(MCUX_DEVICE MIMXRT1176)
40elseif("${MCUX_DEVICE}" STREQUAL "MIMXRT1166_CM4")
41  set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER}_cm4)
42  set(MCUX_DEVICE MIMXRT1166)
43elseif("${MCUX_DEVICE}" STREQUAL "MIMXRT1166_CM7")
44  set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER}_cm7)
45  set(MCUX_DEVICE MIMXRT1166)
46else()
47  set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER})
48endif()
49
50zephyr_include_directories(mcux-sdk/devices/${MCUX_DEVICE})
51zephyr_include_directories(mcux-sdk/devices/${MCUX_DEVICE}/drivers)
52
53#include device specific drivers
54if (${MCUX_DEVICE} MATCHES "MIMXRT1[0-9][0-9][0-9]")
55  zephyr_include_directories(mcux-sdk/devices/${MCUX_DEVICE}/xip)
56endif()
57
58#include CMSIS of mcux-sdk for Cortex-A
59if (CONFIG_CPU_CORTEX_A)
60  zephyr_include_directories(mcux-sdk/CMSIS/Core_AArch64/Include)
61endif()
62
63# The mcux uses the cpu name to expose SoC-specific features of a
64# given peripheral. For example, the UART peripheral may be
65# instantiated with/without a hardware FIFO, and the size of that FIFO
66# may be different for each instance in a given SoC. See
67# fsl_device_registers.h and ${MCUX_DEVICE}_features.h
68zephyr_compile_definitions(${MCUX_CPU})
69
70# Build mcux device-specific objects. Although it is not normal
71# practice, drilling down like this avoids the need for repetitive
72# build scripts for every mcux device.
73zephyr_library_sources(mcux-sdk/devices/${MCUX_DEVICE}/drivers/fsl_clock.c)
74if (${MCUX_DEVICE} MATCHES "LPC|MIMXRT6|MIMXRT5")
75  zephyr_library_sources(mcux-sdk/devices/${MCUX_DEVICE}/drivers/fsl_power.c)
76  zephyr_library_sources(mcux-sdk/devices/${MCUX_DEVICE}/drivers/fsl_reset.c)
77endif()
78
79# RT11xx SOC initialization file requires additional drivers, import them
80if (${MCUX_DEVICE} MATCHES "MIMXRT11")
81  zephyr_library_sources(mcux-sdk/devices/${MCUX_DEVICE}/drivers/fsl_romapi.c)
82  zephyr_library_sources(mcux-sdk/devices/${MCUX_DEVICE}/drivers/fsl_pmu.c)
83  zephyr_library_sources(mcux-sdk/devices/${MCUX_DEVICE}/drivers/fsl_dcdc.c)
84  zephyr_library_sources(mcux-sdk/devices/${MCUX_DEVICE}/drivers/fsl_anatop_ai.c)
85endif()
86
87zephyr_library_sources_ifdef(CONFIG_HAS_MCUX_AUDIOMIX mcux-sdk/devices/${MCUX_DEVICE}/drivers/fsl_audiomix.c)
88
89add_subdirectory(components)
90
91add_subdirectory_ifdef(
92  CONFIG_IEEE802154_KW41Z
93  middleware/wireless/framework_5.3.3
94  )
95
96#Include Entry cmake component
97include(${CMAKE_CURRENT_LIST_DIR}/hal_nxp.cmake)
98enable_language(C ASM)
99
100zephyr_library_sources_ifdef(CONFIG_SOC_LPC54114_M4 mcux-sdk/devices/${MCUX_DEVICE}/gcc/startup_LPC54114_cm4.S)
101
102zephyr_linker_sources(RWDATA quick_access_data.ld)
103zephyr_linker_sources_ifdef(CONFIG_ARCH_HAS_RAMFUNC_SUPPORT
104  RAMFUNC_SECTION
105  quick_access_code.ld
106)
107zephyr_linker_sources_ifdef(CONFIG_NOCACHE_MEMORY
108  NOCACHE_SECTION
109  nocache.ld
110)
111zephyr_library_compile_definitions_ifdef(CONFIG_NOCACHE_MEMORY
112  __STARTUP_INITIALIZE_NONCACHEDATA
113)
114