|
| 1 | +/** |
| 2 | + * @file |
| 3 | + * @brief Network Processor Initialization for SiWx917. |
| 4 | + * |
| 5 | + * This file contains the initialization routine for the (ThreadArch) network processor |
| 6 | + * on the SiWx917 platform. The component is responsible for setting up the necessary |
| 7 | + * hardware and software components to enable network communication. |
| 8 | + * |
| 9 | + * Copyright (c) 2024 Silicon Laboratories Inc. |
| 10 | + * SPDX-License-Identifier: Apache-2.0 |
| 11 | + */ |
| 12 | + |
| 13 | +#include <zephyr/kernel.h> |
| 14 | + |
| 15 | +#include "sl_wifi.h" |
| 16 | +#include "sl_wifi_callback_framework.h" |
| 17 | +#ifdef CONFIG_BT_SIWX917 |
| 18 | +#include "rsi_ble_common_config.h" |
| 19 | +#endif |
| 20 | + |
| 21 | +#if defined(CONFIG_WIFI_SIWX917) && defined(CONFIG_BT_SIWX917) |
| 22 | +#define NWP_INIT_COEX_MODE SL_SI91X_WLAN_BLE_MODE |
| 23 | +#elif defined(CONFIG_WIFI_SIWX917) |
| 24 | +#define NWP_INIT_COEX_MODE SL_SI91X_WLAN_ONLY_MODE |
| 25 | +#elif defined(CONFIG_BT_SIWX917) |
| 26 | +#define NWP_INIT_COEX_MODE SL_SI91X_BLE_MODE |
| 27 | +#else |
| 28 | +#error "Not supported configuration!" |
| 29 | +#endif |
| 30 | + |
| 31 | +static int silabs_siwx917_nwp_init(void) |
| 32 | +{ |
| 33 | + sl_wifi_device_configuration_t network_config = { |
| 34 | + .boot_option = LOAD_NWP_FW, |
| 35 | + .band = SL_SI91X_WIFI_BAND_2_4GHZ, |
| 36 | + .region_code = DEFAULT_REGION, |
| 37 | + .boot_config = { |
| 38 | + .oper_mode = SL_SI91X_CLIENT_MODE, |
| 39 | + .coex_mode = NWP_INIT_COEX_MODE, |
| 40 | + .feature_bit_map = SL_SI91X_FEAT_SECURITY_OPEN | SL_SI91X_FEAT_WPS_DISABLE, |
| 41 | + .tcp_ip_feature_bit_map = SL_SI91X_TCP_IP_FEAT_EXTENSION_VALID, |
| 42 | + .ext_tcp_ip_feature_bit_map = SL_SI91X_CONFIG_FEAT_EXTENSION_VALID, |
| 43 | + .config_feature_bit_map = SL_SI91X_ENABLE_ENHANCED_MAX_PSP, |
| 44 | + .custom_feature_bit_map = SL_SI91X_CUSTOM_FEAT_EXTENSION_VALID, |
| 45 | + .ext_custom_feature_bit_map = |
| 46 | + MEMORY_CONFIG | SL_SI91X_EXT_FEAT_XTAL_CLK | |
| 47 | + SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0, |
| 48 | + }}; |
| 49 | + sl_si91x_boot_configuration_t *cfg = &network_config.boot_config; |
| 50 | + |
| 51 | +#ifdef CONFIG_WIFI_SIWX917 |
| 52 | + cfg->tcp_ip_feature_bit_map |= |
| 53 | +#ifdef CONFIG_NET_IPV6 |
| 54 | + SL_SI91X_TCP_IP_FEAT_DHCPV6_CLIENT | SL_SI91X_TCP_IP_FEAT_IPV6 | |
| 55 | +#endif |
| 56 | + SL_SI91X_TCP_IP_FEAT_DHCPV4_CLIENT | SL_SI91X_TCP_IP_FEAT_DNS_CLIENT | |
| 57 | + SL_SI91X_TCP_IP_FEAT_SSL | SL_SI91X_TCP_IP_FEAT_MDNSD | SL_SI91X_TCP_IP_FEAT_ICMP; |
| 58 | + cfg->ext_tcp_ip_feature_bit_map |= |
| 59 | + SL_SI91X_EXT_TCP_IP_WINDOW_SCALING | SL_SI91X_EXT_TCP_IP_TOTAL_SELECTS(10); |
| 60 | +#endif |
| 61 | + |
| 62 | +#ifdef CONFIG_BT_SIWX917 |
| 63 | + cfg->ext_custom_feature_bit_map |= SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE; |
| 64 | + cfg->bt_feature_bit_map |= SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL; |
| 65 | + cfg->ble_feature_bit_map |= SL_SI91X_BLE_MAX_NBR_PERIPHERALS(RSI_BLE_MAX_NBR_PERIPHERALS) | |
| 66 | + SL_SI91X_BLE_MAX_NBR_CENTRALS(RSI_BLE_MAX_NBR_CENTRALS) | |
| 67 | + SL_SI91X_BLE_MAX_NBR_ATT_SERV(RSI_BLE_MAX_NBR_ATT_SERV) | |
| 68 | + SL_SI91X_BLE_MAX_NBR_ATT_REC(RSI_BLE_MAX_NBR_ATT_REC) | |
| 69 | + SL_SI91X_BLE_PWR_INX(RSI_BLE_PWR_INX) | |
| 70 | + SL_SI91X_BLE_PWR_SAVE_OPTIONS(RSI_BLE_PWR_SAVE_OPTIONS) | |
| 71 | + SL_SI91X_916_BLE_COMPATIBLE_FEAT_ENABLE | |
| 72 | + SL_SI91X_FEAT_BLE_CUSTOM_FEAT_EXTENSION_VALID; |
| 73 | + cfg->ble_ext_feature_bit_map |= SL_SI91X_BLE_NUM_CONN_EVENTS(RSI_BLE_NUM_CONN_EVENTS) | |
| 74 | + SL_SI91X_BLE_NUM_REC_BYTES(RSI_BLE_NUM_REC_BYTES) | |
| 75 | + SL_SI91X_BLE_ENABLE_ADV_EXTN | |
| 76 | + SL_SI91X_BLE_AE_MAX_ADV_SETS(RSI_BLE_AE_MAX_ADV_SETS); |
| 77 | +#endif |
| 78 | + |
| 79 | + /* TODO: If sl_net_*_profile() functions will be needed for WiFi then call |
| 80 | + * sl_net_set_profile() here. Currently these are unused. |
| 81 | + */ |
| 82 | + return sl_wifi_init(&network_config, NULL, sl_wifi_default_event_handler); |
| 83 | +} |
| 84 | +SYS_INIT(silabs_siwx917_nwp_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE); |
| 85 | + |
| 86 | +/* IRQn 74 is used for communication with co-processor */ |
| 87 | +Z_ISR_DECLARE(74, ISR_FLAG_DIRECT, IRQ074_Handler, 0); |
| 88 | + |
| 89 | +/* Co-processor will use value stored in IVT to store its stack. |
| 90 | + * |
| 91 | + * FIXME: We can't use Z_ISR_DECLARE() to declare this entry |
| 92 | + * FIXME: Allow to configure size of buffer |
| 93 | + */ |
| 94 | +static uint8_t __aligned(8) nwp_stack[10 * 1024]; |
| 95 | +static Z_DECL_ALIGN(struct _isr_list) Z_GENERIC_SECTION(.intList) |
| 96 | + __used __isr_siwx917_coprocessor_stack_irq = { |
| 97 | + .irq = 30, |
| 98 | + .flags = ISR_FLAG_DIRECT, |
| 99 | + .func = &nwp_stack[sizeof(nwp_stack) - 1], |
| 100 | + }; |
0 commit comments