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