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