@@ -32,10 +32,19 @@ BUILD_ASSERT(DT_REG_SIZE(DT_CHOSEN(zephyr_sram)) == KB(195) ||
32
32
DT_REG_SIZE (DT_CHOSEN (zephyr_sram )) == KB (255 ) ||
33
33
DT_REG_SIZE (DT_CHOSEN (zephyr_sram )) == KB (319 ));
34
34
35
+ extern const sli_si91x_set_region_ap_request_t default_US_region_2_4GHZ_configurations ;
36
+ extern const sli_si91x_set_region_ap_request_t default_EU_region_2_4GHZ_configurations ;
37
+ extern const sli_si91x_set_region_ap_request_t default_JP_region_2_4GHZ_configurations ;
38
+ extern const sli_si91x_set_region_ap_request_t default_KR_region_2_4GHZ_configurations ;
39
+ extern const sli_si91x_set_region_ap_request_t default_SG_region_2_4GHZ_configurations ;
40
+ extern const sli_si91x_set_region_ap_request_t default_CN_region_2_4GHZ_configurations ;
41
+
42
+ static char current_country_code [WIFI_COUNTRY_CODE_LEN ];
35
43
typedef struct {
36
44
const char * const * codes ;
37
45
size_t num_codes ;
38
46
sl_wifi_region_code_t region_code ;
47
+ const sli_si91x_set_region_ap_request_t * sdk_reg ;
39
48
} region_map_t ;
40
49
41
50
static const char * const us_codes [] = {
@@ -63,13 +72,31 @@ static const char *const kr_codes[] = {"KR", "KP"};
63
72
static const char * const cn_codes [] = {"CN" };
64
73
65
74
static const region_map_t region_maps [] = {
66
- {us_codes , ARRAY_SIZE (us_codes ), SL_WIFI_REGION_US },
67
- {eu_codes , ARRAY_SIZE (eu_codes ), SL_WIFI_REGION_EU },
68
- {jp_codes , ARRAY_SIZE (jp_codes ), SL_WIFI_REGION_JP },
69
- {kr_codes , ARRAY_SIZE (kr_codes ), SL_WIFI_REGION_KR },
70
- {cn_codes , ARRAY_SIZE (cn_codes ), SL_WIFI_REGION_CN },
75
+ {us_codes , ARRAY_SIZE (us_codes ), SL_WIFI_REGION_US ,
76
+ & default_US_region_2_4GHZ_configurations },
77
+ {eu_codes , ARRAY_SIZE (eu_codes ), SL_WIFI_REGION_EU ,
78
+ & default_EU_region_2_4GHZ_configurations },
79
+ {jp_codes , ARRAY_SIZE (jp_codes ), SL_WIFI_REGION_JP ,
80
+ & default_JP_region_2_4GHZ_configurations },
81
+ {kr_codes , ARRAY_SIZE (kr_codes ), SL_WIFI_REGION_KR ,
82
+ & default_KR_region_2_4GHZ_configurations },
83
+ {cn_codes , ARRAY_SIZE (cn_codes ), SL_WIFI_REGION_CN ,
84
+ & default_CN_region_2_4GHZ_configurations },
71
85
};
72
86
87
+ int siwx91x_store_country_code (const char * country_code )
88
+ {
89
+ __ASSERT (country_code , "country_code cannot be NULL" );
90
+
91
+ memcpy (current_country_code , country_code , WIFI_COUNTRY_CODE_LEN );
92
+ return 0 ;
93
+ }
94
+
95
+ const char * siwx91x_get_country_code (void )
96
+ {
97
+ return current_country_code ;
98
+ }
99
+
73
100
sl_wifi_region_code_t siwx91x_map_country_code_to_region (const char * country_code )
74
101
{
75
102
__ASSERT (country_code , "country_code cannot be NULL" );
@@ -85,6 +112,16 @@ sl_wifi_region_code_t siwx91x_map_country_code_to_region(const char *country_cod
85
112
return SL_WIFI_DEFAULT_REGION ;
86
113
}
87
114
115
+ const sli_si91x_set_region_ap_request_t * siwx91x_find_sdk_region_table (uint8_t region_code )
116
+ {
117
+ ARRAY_FOR_EACH (region_maps , i ) {
118
+ if (region_maps [i ].region_code == region_code ) {
119
+ return region_maps [i ].sdk_reg ;
120
+ }
121
+ }
122
+ return NULL ;
123
+ }
124
+
88
125
static void siwx91x_apply_sram_config (sl_si91x_boot_configuration_t * boot_config )
89
126
{
90
127
/* The size does not match exactly because 1 KB is reserved at the start of the RAM */
@@ -214,8 +251,8 @@ int siwx91x_get_nwp_config(sl_wifi_device_configuration_t *get_config, uint8_t w
214
251
bool hidden_ssid , uint8_t max_num_sta )
215
252
{
216
253
sl_wifi_device_configuration_t default_config = {
254
+ .region_code = siwx91x_map_country_code_to_region (DEFAULT_COUNTRY_CODE ),
217
255
.band = SL_SI91X_WIFI_BAND_2_4GHZ ,
218
- .region_code = DEFAULT_REGION ,
219
256
.boot_option = LOAD_NWP_FW ,
220
257
.boot_config = {
221
258
.feature_bit_map = SL_SI91X_FEAT_SECURITY_OPEN | SL_SI91X_FEAT_WPS_DISABLE |
@@ -246,6 +283,7 @@ int siwx91x_get_nwp_config(sl_wifi_device_configuration_t *get_config, uint8_t w
246
283
return - EINVAL ;
247
284
}
248
285
286
+ siwx91x_store_country_code (DEFAULT_COUNTRY_CODE );
249
287
siwx91x_apply_sram_config (boot_config );
250
288
251
289
switch (wifi_oper_mode ) {
0 commit comments