1# Translate the SoC name and part number into the mcux device and cpu
2# name respectively.
3string(TOUPPER ${CONFIG_SOC} MCUX_DEVICE)
4
5if("${MCUX_DEVICE}" STREQUAL "LPC54114")
6  set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER}_cm4)
7elseif("${MCUX_DEVICE}" STREQUAL "LPC54114_M0")
8  set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER}_cm0plus)
9  set(MCUX_DEVICE LPC54114)
10elseif("${MCUX_DEVICE}" STREQUAL "LPC55S16")
11  set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER})
12  set(MCUX_DEVICE LPC55S16)
13elseif("${MCUX_DEVICE}" STREQUAL "LPC55S28")
14  set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER})
15  set(MCUX_DEVICE LPC55S28)
16elseif("${MCUX_DEVICE}" STREQUAL "LPC55S69_CPU0")
17  set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER}_cm33_core0)
18  set(MCUX_DEVICE LPC55S69)
19elseif("${MCUX_DEVICE}" STREQUAL "LPC55S69_CPU1")
20  set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER}_cm33_core1)
21  set(MCUX_DEVICE LPC55S69)
22elseif("${MCUX_DEVICE}" STREQUAL "MIMXRT1052")
23  string(REGEX REPLACE "(.*)[AB]$" "CPU_\\1B" MCUX_CPU ${CONFIG_SOC_PART_NUMBER})
24elseif("${MCUX_DEVICE}" STREQUAL "MIMXRT685S_CM33")
25  set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER}_cm33)
26  set(MCUX_DEVICE MIMXRT685S)
27elseif("${MCUX_DEVICE}" STREQUAL "MIMXRT1176_CM4")
28  set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER}_cm4)
29  set(MCUX_DEVICE MIMXRT1176)
30elseif("${MCUX_DEVICE}" STREQUAL "MIMXRT1176_CM7")
31  set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER}_cm7)
32  set(MCUX_DEVICE MIMXRT1176)
33else()
34  set(MCUX_CPU CPU_${CONFIG_SOC_PART_NUMBER})
35endif()
36
37zephyr_include_directories(devices/${MCUX_DEVICE})
38
39# The mcux uses the cpu name to expose SoC-specific features of a
40# given peripheral. For example, the UART peripheral may be
41# instantiated with/without a hardware FIFO, and the size of that FIFO
42# may be different for each instance in a given SoC. See
43# fsl_device_registers.h and ${MCUX_DEVICE}_features.h
44zephyr_compile_definitions(${MCUX_CPU})
45
46# Build mcux device-specific objects. Although it is not normal
47# practice, drilling down like this avoids the need for repetitive
48# build scripts for every mcux device.
49zephyr_library_sources(devices/${MCUX_DEVICE}/fsl_clock.c)
50if (${MCUX_DEVICE} MATCHES "LPC|MIMXRT6")
51  zephyr_library_sources(devices/${MCUX_DEVICE}/fsl_power.c)
52  zephyr_library_sources(devices/${MCUX_DEVICE}/fsl_reset.c)
53
54  if ((${MCUX_DEVICE} MATCHES "MIMXRT6") AND (CONFIG_PM))
55    zephyr_code_relocate(devices/${MCUX_DEVICE}/fsl_power.c SRAM)
56  endif()
57endif()
58
59if (${MCUX_DEVICE} MATCHES "MIMXRT117")
60  zephyr_library_sources(devices/${MCUX_DEVICE}/fsl_romapi.c)
61  zephyr_library_sources(devices/${MCUX_DEVICE}/fsl_pmu.c)
62  zephyr_library_sources(devices/${MCUX_DEVICE}/fsl_dcdc.c)
63  zephyr_library_sources(devices/${MCUX_DEVICE}/fsl_anatop_ai.c)
64  if ("${MCUX_DEVICE}" STREQUAL "MIMXRT1176_CM4")
65    zephyr_include_directories(devices/${MCUX_DEVICE}/cm4/)
66    zephyr_library_sources_ifdef(
67      CONFIG_HAS_MCUX_CACHE
68      devices/${MCUX_DEVICE}/cm4/fsl_cache.c
69    )
70  endif()
71endif()
72
73# Build mcux drivers that can be used for multiple SoC's.
74add_subdirectory(boards)
75add_subdirectory(components)
76add_subdirectory(drivers)
77
78add_subdirectory_ifdef(
79  CONFIG_USB_DEVICE_DRIVER
80  middleware/usb
81  )
82
83add_subdirectory_ifdef(
84  CONFIG_IEEE802154_KW41Z
85  middleware/wireless/framework_5.3.3
86  )
87
88enable_language(C ASM)
89
90zephyr_library_sources_ifdef(CONFIG_SOC_LPC54114_M4 devices/${MCUX_DEVICE}/gcc/startup_LPC54114_cm4.S)
91zephyr_library_sources_ifdef(CONFIG_SOC_MIMXRT685S_CM33 devices/${MCUX_DEVICE}/system_MIMXRT685S_cm33.c)
92