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
19if (${CONFIG_BOARD} STREQUAL "efr32_radio_brd4187c")
20  set(PRODUCT_NO "sdid215")
21endif()
22
23if (${CONFIG_BOARD} STREQUAL "efr32xg24_dk2601b")
24  set(SILABS_GECKO_BOARD "brd2601b")
25  set(PRODUCT_NO "sdid215")
26endif()
27
28if (${CONFIG_BOARD} STREQUAL "efr32bg22_brd4184a")
29  set(SILABS_GECKO_BOARD "brd4184a")
30  set(PRODUCT_NO "sdid205")
31endif()
32
33if (${CONFIG_BOARD} STREQUAL "efr32bg27_brd2602a")
34  set(SILABS_GECKO_BOARD "brd2602a")
35  set(PRODUCT_NO "sdid205")
36endif()
37
38zephyr_include_directories(
39  Device/SiliconLabs/${SILABS_GECKO_DEVICE}/Include
40  board/config/${SILABS_GECKO_BOARD}
41  board/inc
42  common/inc
43  emlib/inc
44  platform/radio/rail_lib/chip/efr32/efr32xg2x
45  platform/radio/rail_lib/common
46  platform/radio/rail_lib/plugin/pa-conversions
47  platform/radio/rail_lib/plugin/pa-conversions/efr32xg${GECKO_SERIES_NUMBER}/config
48  protocol/bluetooth//bgstack/ll/inc
49  service/device_init/config/s2
50  service/device_init/config/s2/${PRODUCT_NO}
51  service/device_init/inc
52  service/hfxo_manager/config
53  service/hfxo_manager/inc
54  service/hfxo_manager/src
55  service/power_manager/config
56  service/power_manager/inc
57  service/power_manager/src
58  service/sleeptimer/config
59  service/sleeptimer/inc
60  service/sleeptimer/src
61  util/third_party/crypto/sl_component/sl_protocol_crypto/src
62  )
63
64zephyr_include_directories(${BOARD_DIR})
65
66# The gecko SDK uses the cpu name to include the matching device header.
67# See Device/SiliconLabs/$(SILABS_GECKO_DEVICE)/Include/em_device.h for an example.
68zephyr_compile_definitions(
69  ${SILABS_GECKO_PART_NUMBER}
70  )
71
72add_subdirectory_ifdef(CONFIG_SOC_GECKO_SE se_manager)
73
74zephyr_sources(                                    emlib/src/em_system.c)
75zephyr_sources_ifdef(CONFIG_SOC_GECKO_ADC          emlib/src/em_adc.c)
76zephyr_sources_ifdef(CONFIG_SOC_GECKO_IADC         emlib/src/em_iadc.c)
77zephyr_sources_ifdef(CONFIG_SOC_GECKO_BURTC        emlib/src/em_burtc.c)
78zephyr_sources_ifdef(CONFIG_SOC_GECKO_CMU          emlib/src/em_cmu.c)
79
80zephyr_sources_ifdef(CONFIG_SOC_GECKO_DEV_INIT     service/device_init/src/sl_device_init_dcdc_s2.c)
81zephyr_sources_ifdef(CONFIG_SOC_GECKO_DEV_INIT     service/device_init/src/sl_device_init_dpll_s2.c)
82zephyr_sources_ifdef(CONFIG_SOC_GECKO_DEV_INIT     service/device_init/src/sl_device_init_emu_s2.c)
83zephyr_sources_ifdef(CONFIG_SOC_GECKO_DEV_INIT     service/device_init/src/sl_device_init_hfrco.c)
84zephyr_sources_ifdef(CONFIG_SOC_GECKO_DEV_INIT     service/device_init/src/sl_device_init_hfxo_s2.c)
85zephyr_sources_ifdef(CONFIG_SOC_GECKO_DEV_INIT     service/device_init/src/sl_device_init_nvic.c)
86zephyr_sources_ifdef(CONFIG_SOC_GECKO_DEV_INIT     service/power_manager/src/sl_power_manager.c)
87zephyr_sources_ifdef(CONFIG_SOC_GECKO_DEV_INIT     service/power_manager/src/sl_power_manager_hal_s2.c)
88zephyr_sources_ifdef(CONFIG_SOC_GECKO_DEV_INIT     service/hfxo_manager/src/sl_hfxo_manager.c)
89zephyr_sources_ifdef(CONFIG_SOC_GECKO_DEV_INIT     service/hfxo_manager/src/sl_hfxo_manager_hal_s2.c)
90
91zephyr_sources_ifdef(CONFIG_SOC_GECKO_DEV_INIT     common/src/sl_slist.c)
92zephyr_sources_ifdef(CONFIG_SOC_GECKO_CORE         emlib/src/em_core.c)
93zephyr_sources_ifdef(CONFIG_SOC_GECKO_CRYOTIMER    emlib/src/em_cryotimer.c)
94zephyr_sources_ifdef(CONFIG_SOC_GECKO_EMU          emlib/src/em_emu.c)
95zephyr_sources_ifdef(CONFIG_SOC_GECKO_GPIO         emlib/src/em_gpio.c)
96zephyr_sources_ifdef(CONFIG_SOC_GECKO_I2C          emlib/src/em_i2c.c)
97zephyr_sources_ifdef(CONFIG_SOC_GECKO_LETIMER      emlib/src/em_letimer.c)
98zephyr_sources_ifdef(CONFIG_SOC_GECKO_LEUART       emlib/src/em_leuart.c)
99zephyr_sources_ifdef(CONFIG_SOC_GECKO_MSC          emlib/src/em_msc.c)
100zephyr_sources_ifdef(CONFIG_SOC_GECKO_PRS          emlib/src/em_prs.c)
101zephyr_sources_ifdef(CONFIG_SOC_GECKO_RMU          emlib/src/em_rmu.c)
102zephyr_sources_ifdef(CONFIG_SOC_GECKO_RTC          emlib/src/em_rtc.c)
103zephyr_sources_ifdef(CONFIG_SOC_GECKO_RTCC         emlib/src/em_rtcc.c)
104zephyr_sources_ifdef(CONFIG_COUNTER_GECKO_STIMER   service/sleeptimer/src/peripheral_sysrtc.c)
105zephyr_sources_ifdef(CONFIG_COUNTER_GECKO_STIMER   service/sleeptimer/src/sl_sleeptimer_hal_rtcc.c)
106zephyr_sources_ifdef(CONFIG_COUNTER_GECKO_STIMER   service/sleeptimer/src/sl_sleeptimer.c)
107zephyr_sources_ifdef(CONFIG_SOC_GECKO_SE           emlib/src/em_se.c)
108zephyr_sources_ifdef(CONFIG_SOC_GECKO_TIMER        emlib/src/em_timer.c)
109zephyr_sources_ifdef(CONFIG_SOC_GECKO_USART        emlib/src/em_usart.c)
110zephyr_sources_ifdef(CONFIG_SOC_GECKO_WDOG         emlib/src/em_wdog.c)
111zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFM32WG     Device/SiliconLabs/EFM32WG/Source/system_efm32wg.c)
112zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFR32BG13P  Device/SiliconLabs/EFR32BG13P/Source/system_efr32bg13p.c)
113zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFR32BG22   Device/SiliconLabs/EFR32BG22/Source/system_efr32bg22.c)
114zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFR32BG27   Device/SiliconLabs/EFR32BG27/Source/system_efr32bg27.c)
115zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFR32FG1P   Device/SiliconLabs/EFR32FG1P/Source/system_efr32fg1p.c)
116zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFR32FG13P  Device/SiliconLabs/EFR32FG13P/Source/system_efr32fg13p.c)
117zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFM32HG     Device/SiliconLabs/EFM32HG/Source/system_efm32hg.c)
118zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFR32MG12P  Device/SiliconLabs/EFR32MG12P/Source/system_efr32mg12p.c)
119zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFM32PG12B  Device/SiliconLabs/EFM32PG12B/Source/system_efm32pg12b.c)
120zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFM32GG11B  Device/SiliconLabs/EFM32GG11B/Source/system_efm32gg11b.c)
121zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFM32JG12B  Device/SiliconLabs/EFM32JG12B/Source/system_efm32jg12b.c)
122zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFR32MG21   Device/SiliconLabs/EFR32MG21/Source/system_efr32mg21.c)
123zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFM32PG1B   Device/SiliconLabs/EFM32PG1B/Source/system_efm32pg1b.c)
124zephyr_sources_ifdef(CONFIG_SOC_SERIES_EFR32MG24   Device/SiliconLabs/EFR32MG24/Source/system_efr32mg24.c)
125
126function(add_prebuilt_library lib_name prebuilt_path)
127  add_library(${lib_name} STATIC IMPORTED GLOBAL)
128  set_target_properties(${lib_name} PROPERTIES
129	  IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../zephyr/blobs/${prebuilt_path}
130  )
131  zephyr_link_libraries(${lib_name})
132endfunction()
133
134if(CONFIG_BT_SILABS_HCI)
135  # rail
136  zephyr_sources(platform/radio/rail_lib/plugin/pa-conversions/pa_conversions_efr32.c)
137  zephyr_sources(platform/radio/rail_lib/plugin/pa-conversions/pa_curves_efr32.c)
138
139  # sl_protocol_crypto
140  zephyr_sources(util/third_party/crypto/sl_component/sl_protocol_crypto/src/sli_protocol_crypto_crypto.c)
141  zephyr_sources(util/third_party/crypto/sl_component/sl_protocol_crypto/src/sli_radioaes_management.c)
142  zephyr_sources(util/third_party/crypto/sl_component/sl_protocol_crypto/src/sli_protocol_crypto_radioaes.c)
143
144  # prebuilt libs
145  add_prebuilt_library(liblinklayer gecko/protocol/bluetooth/bgstack/ll/lib/libbluetooth_controller_efr32xg${GECKO_SERIES_NUMBER}_gcc_release.a)
146  add_prebuilt_library(libbgcommon  gecko/protocol/bluetooth/bgcommon/lib/libbgcommon_efr32xg${GECKO_SERIES_NUMBER}_gcc_release.a)
147  add_prebuilt_library(librail      gecko/platform/radio/rail_lib/autogen/librail_release/librail_efr32xg${GECKO_SERIES_NUMBER}_gcc_release.a)
148
149  # link mbedTLS
150  if(CONFIG_MBEDTLS)
151    zephyr_link_libraries(mbedTLS)
152  endif()
153endif()
154