1# Copyright (c) 2024 Silicon Laboratories Inc.
2# SPDX-License-Identifier: Apache-2.0
3
4set(SISDK_DIR ${ZEPHYR_HAL_SILABS_MODULE_DIR}/simplicity_sdk)
5set(WISECONNECT_DIR ${ZEPHYR_HAL_SILABS_MODULE_DIR}/wiseconnect)
6
7# Keep these values sync with
8# components/device/silabs/si91x/mcu/core/chip/component/siwg917*.slcc
9zephyr_compile_definitions(
10  SL_SI91X_ENABLE_LITTLE_ENDIAN
11  SLI_SI91X_MCU_COMMON_FLASH_MODE
12  SLI_SI91X_MCU_CONFIG_RADIO_BOARD_VER2
13  SLI_SI91X_MCU_CONFIG_RADIO_BOARD_BASE_VER
14  SLI_SI91X_MCU_ENABLE_FLASH_BASED_EXECUTION
15  SLI_SI91X_MCU_ENABLE_IPMU_APIS
16  SLI_SI91X_MCU_INTERFACE
17  SLI_SI917
18  SLI_SI917B0
19  CLOCK_ROMDRIVER_PRESENT
20)
21
22zephyr_include_directories(
23  ${SISDK_DIR}/platform/common/inc
24  ${SISDK_DIR}/platform/common/config
25  ${WISECONNECT_DIR}/components/board/silabs/inc
26  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/core/config
27  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/core/chip/inc
28  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/core/chip/config
29  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/rom_driver/inc
30  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/inc
31  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/service/clock_manager/inc
32  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/systemlevel/inc
33  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/unified_api/inc
34  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/unified_peripheral_drivers/inc
35  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/cmsis_driver/config
36  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/cmsis_driver
37  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/cmsis_driver/CMSIS/Driver/Include
38)
39
40zephyr_library_sources(
41  ${SISDK_DIR}/platform/common/src/sl_core_cortexm.c
42  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/core/chip/src/rsi_deepsleep_soc.c
43  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/core/chip/src/system_si91x.c
44  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/clock_update.c
45  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/rsi_pwm.c
46  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/rsi_sysrtc.c
47  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/systemlevel/src/rsi_ipmu.c
48  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/systemlevel/src/rsi_pll.c
49  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/systemlevel/src/rsi_ulpss_clk.c
50  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/systemlevel/src/rsi_wwdt.c
51  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/service/clock_manager/src/sl_si91x_clock_manager.c
52  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_driver_gpio.c
53  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_pwm.c
54  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/unified_peripheral_drivers/src/sl_si91x_peripheral_gpio.c
55  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/core/chip/src/iPMU_prog/iPMU_dotc/ipmu_apis.c
56  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/core/chip/src/iPMU_prog/iPMU_dotc/rsi_system_config_917.c
57)
58
59zephyr_library_sources_ifdef(CONFIG_ENTROPY_SILABS_SIWX91X
60  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/peripheral_drivers/src/rsi_rng.c
61)
62
63zephyr_compile_definitions_ifdef(CONFIG_DMA_SILABS_SIWX91X
64  UDMA_ROMDRIVER_PRESENT
65)
66
67zephyr_library_sources_ifdef(CONFIG_DMA_SILABS_SIWX91X
68  ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/rom_driver/src/rsi_rom_table_si91x.c
69)
70
71if(CONFIG_WIFI_SILABS_SIWX91X)
72  zephyr_library_sources(
73    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/sl_net/src/sl_si91x_net_credentials.c
74    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/sl_net/src/sl_si91x_net_internal_stack.c
75    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/sl_net/src/sl_net_si91x_integration_handler.c
76    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/sl_net/src/sl_net_rsi_utility.c
77    ${WISECONNECT_DIR}/components/protocol/wifi/src/sl_wifi_basic_credentials.c
78    ${WISECONNECT_DIR}/components/service/network_manager/si91x/sl_net_si91x.c
79    ${WISECONNECT_DIR}/components/service/network_manager/src/sl_net_basic_profiles.c
80    ${WISECONNECT_DIR}/components/service/network_manager/src/sl_net_credentials.c
81  )
82  zephyr_compile_definitions_ifdef(CONFIG_NET_IPV6
83    SLI_SI91X_ENABLE_IPV6
84  )
85  zephyr_compile_definitions_ifdef(CONFIG_WIFI_SILABS_SIWX91X_NET_STACK_OFFLOAD
86    SLI_SI91X_OFFLOAD_NETWORK_STACK
87    SLI_SI91X_SOCKETS
88  )
89  zephyr_include_directories_ifdef(CONFIG_WIFI_SILABS_SIWX91X_NET_STACK_OFFLOAD
90    # Needed for <sys/socket.h>
91    ${ZEPHYR_BASE}/include/zephyr/posix
92  )
93  zephyr_library_sources_ifdef(CONFIG_WIFI_SILABS_SIWX91X_NET_STACK_OFFLOAD
94    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/socket/src/sl_si91x_socket_utility.c
95    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/asynchronous_socket/src/sl_si91x_socket.c
96    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/sl_net/src/sl_net_si91x_callback_framework.c
97    ${WISECONNECT_DIR}/components/service/network_manager/src/sl_net.c
98  )
99endif() # CONFIG_WIFI_SILABS_SIWX91X
100
101if(CONFIG_BT_SILABS_SIWX91X)
102  zephyr_compile_definitions(
103    SLI_SI91X_ENABLE_BLE
104  )
105  zephyr_include_directories(
106    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/ble/inc
107  )
108  zephyr_library_sources(
109    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/ble/src/rsi_bt_ble.c
110    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/ble/src/rsi_common_apis.c
111    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/ble/src/rsi_utils.c
112  )
113endif() # CONFIG_BT_SILABS_SIWX91X
114
115if(CONFIG_WISECONNECT_NETWORK_STACK)
116  zephyr_compile_definitions(
117    SLI_SI91X_ENABLE_OS
118    SL_SI91X_SI917_RAM_MEM_CONFIG=1
119    SL_WIFI_COMPONENT_INCLUDED # Depite de the name, required for everything
120  )
121  zephyr_include_directories(
122    # FIXME: find why this directory is not included when CMSIS_RTOS_V2=y
123    ${ZEPHYR_BASE}/include/zephyr/portability
124    ${SISDK_DIR}/platform/emlib/inc
125    ${WISECONNECT_DIR}/resources/defaults
126    ${WISECONNECT_DIR}/components/common/inc
127    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/inc
128    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/sl_net/inc
129    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/socket/inc
130    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/asynchronous_socket/inc
131    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/ahb_interface/inc
132    ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/core/chip/config
133    ${WISECONNECT_DIR}/components/protocol/wifi/inc
134    ${WISECONNECT_DIR}/components/service/network_manager/inc
135  )
136  zephyr_library_sources(
137    ${WISECONNECT_DIR}/components/common/src/sl_utility.c
138    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/ahb_interface/src/rsi_hal_mcu_m4_ram.c
139    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/ahb_interface/src/rsi_hal_mcu_m4_rom.c
140    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/ahb_interface/src/sli_siwx917_soc.c
141    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/ahb_interface/src/sl_platform.c
142    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/ahb_interface/src/sl_platform_wireless.c
143    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/ahb_interface/src/sl_si91x_bus.c
144    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/host_mcu/si91x/siwx917_soc_ncp_host.c
145    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/memory/malloc_buffers.c
146    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/src/sl_rsi_utility.c
147    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/src/sl_si91x_driver.c
148    ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/threading/sli_si91x_multithreaded.c
149    ${WISECONNECT_DIR}/components/protocol/wifi/si91x/sl_wifi.c
150    ${WISECONNECT_DIR}/components/protocol/wifi/src/sl_wifi_callback_framework.c
151  )
152endif() # CONFIG_WISECONNECT_NETWORK_STACK
153
154zephyr_linker_sources(ROM_SECTIONS linker/code_classification_text.ld)
155zephyr_linker_sources(RAMFUNC_SECTION linker/code_classification_ramfunc.ld)
156