1# Makefile - Gecko SDK
2#
3# Copyright (c) 2017, Christian Taedcke
4# Copyright (c) 2021, Safran Passenger Innovations Germany GmbH
5# Copyright (c) 2022, Antmicro <www.antmicro.com>
6#
7# SPDX-License-Identifier: Apache-2.0
8#
9
10# Translate the SoC name and part number into the gecko device and cpu name
11# respectively.
12string(TOUPPER ${CONFIG_SOC_SERIES} SILABS_GECKO_DEVICE)
13
14# Get SoC series number, i.e. translate e.g. efr32bg22 -> 22
15string(SUBSTRING ${CONFIG_SOC_SERIES} 7 2 GECKO_SERIES_NUMBER)
16
17set(SILABS_GECKO_PART_NUMBER ${CONFIG_SOC_PART_NUMBER})
18
19function(add_prebuilt_library lib_name prebuilt_path)
20  add_library(${lib_name} STATIC IMPORTED GLOBAL)
21  set_target_properties(${lib_name} PROPERTIES
22	  IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../zephyr/blobs/${prebuilt_path}
23  )
24  zephyr_link_libraries(${lib_name})
25endfunction()
26
27if(${CONFIG_SOC_GECKO_HAS_RADIO})
28  if(${CONFIG_SOC_FAMILY_SILABS_S1})
29    zephyr_include_directories(
30      platform/radio/rail_lib/plugin/pa-conversions/efr32xg1x/config
31      platform/radio/rail_lib/chip/efr32/efr32xg1x
32    )
33  elseif(${CONFIG_SOC_FAMILY_SILABS_S2})
34    zephyr_include_directories(
35      platform/radio/rail_lib/plugin/pa-conversions/efr32xg${GECKO_SERIES_NUMBER}/config
36      platform/radio/rail_lib/chip/efr32/efr32xg2x
37    )
38  endif()
39
40  zephyr_include_directories(
41    platform/radio/rail_lib/common
42    platform/radio/rail_lib/plugin/pa-conversions
43    protocol/bluetooth/bgstack/ll/inc
44    )
45
46  if(CONFIG_BT_SILABS_HCI)
47    # sl_protocol_crypto
48    zephyr_sources(util/third_party/crypto/sl_component/sl_protocol_crypto/src/sli_protocol_crypto_crypto.c)
49    zephyr_sources(util/third_party/crypto/sl_component/sl_protocol_crypto/src/sli_radioaes_management.c)
50    zephyr_sources(util/third_party/crypto/sl_component/sl_protocol_crypto/src/sli_protocol_crypto_radioaes.c)
51
52    # prebuilt libs
53    add_prebuilt_library(liblinklayer gecko/protocol/bluetooth/bgstack/ll/lib/libbluetooth_controller_efr32xg${GECKO_SERIES_NUMBER}_gcc_release.a)
54    add_prebuilt_library(libbgcommon  gecko/protocol/bluetooth/bgcommon/lib/libbgcommon_efr32xg${GECKO_SERIES_NUMBER}_gcc_release.a)
55
56    # link mbedTLS
57    if(CONFIG_MBEDTLS)
58      zephyr_link_libraries(mbedTLS)
59    endif()
60  endif()
61
62  if(CONFIG_SOC_GECKO_USE_RAIL)
63    # rail
64    zephyr_sources(platform/radio/rail_lib/plugin/pa-conversions/pa_conversions_efr32.c)
65    zephyr_sources(platform/radio/rail_lib/plugin/pa-conversions/pa_curves_efr32.c)
66
67    # prebuilt libs
68    add_prebuilt_library(librail      gecko/platform/radio/rail_lib/autogen/librail_release/librail_efr32xg${GECKO_SERIES_NUMBER}_gcc_release.a)
69
70    if(CONFIG_SOC_GECKO_CUSTOM_RADIO_PHY)
71      zephyr_include_directories(
72        platform/radio/rail_lib/plugin/rail_util_init/config/proprietary
73        platform/radio/rail_lib/plugin/rail_util_callbacks
74        platform/radio/rail_lib/plugin/rail_util_callbacks/config
75        platform/radio/rail_lib/plugin/rail_util_protocol
76        platform/radio/rail_lib/plugin/rail_util_protocol/config/efr32xg${GECKO_SERIES_NUMBER}/
77        platform/radio/rail_lib/protocol/ble
78        platform/radio/rail_lib/protocol/ieee802154
79        platform/radio/rail_lib/protocol/zwave
80      )
81      zephyr_sources(platform/radio/rail_lib/plugin/rail_util_protocol/sl_rail_util_protocol.c)
82    endif()
83
84  endif()
85endif()
86
87zephyr_include_directories(
88  Device/SiliconLabs/${SILABS_GECKO_DEVICE}/Include
89  common/inc
90  emlib/inc
91  service/device_init/config/s2
92  service/device_init/config/s2/sdid${CONFIG_SOC_GECKO_SDID}
93  service/device_init/inc
94  service/hfxo_manager/config
95  service/hfxo_manager/inc
96  service/hfxo_manager/src
97  service/power_manager/config
98  service/power_manager/inc
99  service/power_manager/src
100  service/sleeptimer/config
101  service/sleeptimer/inc
102  service/sleeptimer/src
103  util/third_party/crypto/sl_component/sl_protocol_crypto/src
104  ${BOARD_DIR}
105  )
106
107# The gecko SDK uses the cpu name to include the matching device header.
108# See Device/SiliconLabs/$(SILABS_GECKO_DEVICE)/Include/em_device.h for an example.
109zephyr_compile_definitions(
110  ${SILABS_GECKO_PART_NUMBER}
111  )
112
113add_subdirectory_ifdef(CONFIG_SOC_GECKO_SE se_manager)
114
115zephyr_sources(                                    emlib/src/em_system.c)
116zephyr_sources_ifdef(CONFIG_SOC_GECKO_ADC          emlib/src/em_adc.c)
117zephyr_sources_ifdef(CONFIG_SOC_GECKO_IADC         emlib/src/em_iadc.c)
118zephyr_sources_ifdef(CONFIG_SOC_GECKO_BURTC        emlib/src/em_burtc.c)
119zephyr_sources_ifdef(CONFIG_SOC_GECKO_CMU          emlib/src/em_cmu.c)
120
121zephyr_sources_ifdef(CONFIG_SOC_GECKO_DEV_INIT     service/device_init/src/sl_device_init_dcdc_s2.c)
122zephyr_sources_ifdef(CONFIG_SOC_GECKO_DEV_INIT     service/device_init/src/sl_device_init_dpll_s2.c)
123zephyr_sources_ifdef(CONFIG_SOC_GECKO_DEV_INIT     service/device_init/src/sl_device_init_emu_s2.c)
124zephyr_sources_ifdef(CONFIG_SOC_GECKO_DEV_INIT     service/device_init/src/sl_device_init_hfrco.c)
125zephyr_sources_ifdef(CONFIG_SOC_GECKO_DEV_INIT     service/device_init/src/sl_device_init_hfxo_s2.c)
126zephyr_sources_ifdef(CONFIG_SOC_GECKO_DEV_INIT     service/device_init/src/sl_device_init_nvic.c)
127zephyr_sources_ifdef(CONFIG_SOC_GECKO_DEV_INIT     service/power_manager/src/sl_power_manager.c)
128zephyr_sources_ifdef(CONFIG_SOC_GECKO_DEV_INIT     service/power_manager/src/sl_power_manager_hal_s2.c)
129zephyr_sources_ifdef(CONFIG_SOC_GECKO_DEV_INIT     service/hfxo_manager/src/sl_hfxo_manager.c)
130zephyr_sources_ifdef(CONFIG_SOC_GECKO_DEV_INIT     service/hfxo_manager/src/sl_hfxo_manager_hal_s2.c)
131
132zephyr_sources_ifdef(CONFIG_SOC_GECKO_DEV_INIT     common/src/sl_slist.c)
133zephyr_sources_ifdef(CONFIG_SOC_GECKO_CORE         emlib/src/em_core.c)
134zephyr_sources_ifdef(CONFIG_SOC_GECKO_CRYOTIMER    emlib/src/em_cryotimer.c)
135zephyr_sources_ifdef(CONFIG_SOC_GECKO_EMU          emlib/src/em_emu.c)
136zephyr_sources_ifdef(CONFIG_SOC_GECKO_GPIO         emlib/src/em_gpio.c)
137zephyr_sources_ifdef(CONFIG_SOC_GECKO_I2C          emlib/src/em_i2c.c)
138zephyr_sources_ifdef(CONFIG_SOC_GECKO_LETIMER      emlib/src/em_letimer.c)
139zephyr_sources_ifdef(CONFIG_SOC_GECKO_LEUART       emlib/src/em_leuart.c)
140zephyr_sources_ifdef(CONFIG_SOC_GECKO_MSC          emlib/src/em_msc.c)
141zephyr_sources_ifdef(CONFIG_SOC_GECKO_PRS          emlib/src/em_prs.c)
142zephyr_sources_ifdef(CONFIG_SOC_GECKO_RMU          emlib/src/em_rmu.c)
143zephyr_sources_ifdef(CONFIG_SOC_GECKO_RTC          emlib/src/em_rtc.c)
144zephyr_sources_ifdef(CONFIG_SOC_GECKO_RTCC         emlib/src/em_rtcc.c)
145zephyr_sources_ifdef(CONFIG_COUNTER_GECKO_STIMER   service/sleeptimer/src/peripheral_sysrtc.c)
146zephyr_sources_ifdef(CONFIG_COUNTER_GECKO_STIMER   service/sleeptimer/src/sl_sleeptimer_hal_rtcc.c)
147zephyr_sources_ifdef(CONFIG_COUNTER_GECKO_STIMER   service/sleeptimer/src/sl_sleeptimer_hal_sysrtc.c)
148zephyr_sources_ifdef(CONFIG_COUNTER_GECKO_STIMER   service/sleeptimer/src/sl_sleeptimer.c)
149zephyr_sources_ifdef(CONFIG_SOC_GECKO_SE           emlib/src/em_se.c)
150zephyr_sources_ifdef(CONFIG_SOC_GECKO_TIMER        emlib/src/em_timer.c)
151zephyr_sources_ifdef(CONFIG_SOC_GECKO_USART        emlib/src/em_usart.c)
152zephyr_sources_ifdef(CONFIG_SOC_GECKO_WDOG         emlib/src/em_wdog.c)
153zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFM32WG     Device/SiliconLabs/EFM32WG/Source/system_efm32wg.c)
154zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFR32BG13P  Device/SiliconLabs/EFR32BG13P/Source/system_efr32bg13p.c)
155zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFR32BG22   Device/SiliconLabs/EFR32BG22/Source/system_efr32bg22.c)
156zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFR32BG27   Device/SiliconLabs/EFR32BG27/Source/system_efr32bg27.c)
157zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFR32FG1P   Device/SiliconLabs/EFR32FG1P/Source/system_efr32fg1p.c)
158zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFR32FG13P  Device/SiliconLabs/EFR32FG13P/Source/system_efr32fg13p.c)
159zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFM32HG     Device/SiliconLabs/EFM32HG/Source/system_efm32hg.c)
160zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFR32MG12P  Device/SiliconLabs/EFR32MG12P/Source/system_efr32mg12p.c)
161zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFM32PG12B  Device/SiliconLabs/EFM32PG12B/Source/system_efm32pg12b.c)
162zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFM32GG11B  Device/SiliconLabs/EFM32GG11B/Source/system_efm32gg11b.c)
163zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFM32GG12B  Device/SiliconLabs/EFM32GG12B/Source/system_efm32gg12b.c)
164zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFM32JG12B  Device/SiliconLabs/EFM32JG12B/Source/system_efm32jg12b.c)
165zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFR32MG21   Device/SiliconLabs/EFR32MG21/Source/system_efr32mg21.c)
166zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFM32PG1B   Device/SiliconLabs/EFM32PG1B/Source/system_efm32pg1b.c)
167zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFR32MG24   Device/SiliconLabs/EFR32MG24/Source/system_efr32mg24.c)
168