1# Copyright (c) 2023 Cypress Semiconductor Corporation.
2#
3# SPDX-License-Identifier: Apache-2.0
4
5set(hal_dir                  ${ZEPHYR_HAL_INFINEON_MODULE_DIR})
6set(hal_wifi_dir             ${hal_dir}/wifi-host-driver)
7set(hal_wifi_dir_resources   ${hal_dir}/wifi-host-driver/WiFi_Host_Driver/resources)
8
9set(hal_blobs_dir            ${hal_dir}/zephyr/blobs/img/whd/resources)
10set(blob_gen_dir             ${ZEPHYR_BINARY_DIR}/include/generated)
11
12set(cyw43xx_fw_bin_gen_inc   ${blob_gen_dir}/cyw43xx_fw_blob.inc)
13set(cyw43xx_clm_bin_gen_inc  ${blob_gen_dir}/cyw43xx_clm_blob.inc)
14
15#########################################################################################
16# Wi-Fi Host driver
17#########################################################################################
18if(CONFIG_AIROC_WLAN_MFG_FIRMWARE)
19  zephyr_compile_definitions(WLAN_MFG_FIRMWARE)
20endif()
21
22# Add WHD includes
23zephyr_include_directories(${hal_wifi_dir})
24zephyr_include_directories(${hal_wifi_dir}/WiFi_Host_Driver/inc)
25zephyr_include_directories(${hal_wifi_dir}/WiFi_Host_Driver/src)
26zephyr_include_directories(${hal_wifi_dir}/WiFi_Host_Driver/src/include)
27zephyr_include_directories(${hal_wifi_dir}/WiFi_Host_Driver/resources/resource_imp)
28
29# src
30zephyr_library_sources(${hal_wifi_dir}/WiFi_Host_Driver/src/whd_ap.c)
31zephyr_library_sources(${hal_wifi_dir}/WiFi_Host_Driver/src/whd_buffer_api.c)
32zephyr_library_sources(${hal_wifi_dir}/WiFi_Host_Driver/src/whd_cdc_bdc.c)
33zephyr_library_sources(${hal_wifi_dir}/WiFi_Host_Driver/src/whd_chip.c)
34zephyr_library_sources(${hal_wifi_dir}/WiFi_Host_Driver/src/whd_chip_constants.c)
35zephyr_library_sources(${hal_wifi_dir}/WiFi_Host_Driver/src/whd_clm.c)
36zephyr_library_sources(${hal_wifi_dir}/WiFi_Host_Driver/src/whd_debug.c)
37zephyr_library_sources(${hal_wifi_dir}/WiFi_Host_Driver/src/whd_events.c)
38zephyr_library_sources(${hal_wifi_dir}/WiFi_Host_Driver/src/whd_logging.c)
39zephyr_library_sources(${hal_wifi_dir}/WiFi_Host_Driver/src/whd_management.c)
40zephyr_library_sources(${hal_wifi_dir}/WiFi_Host_Driver/src/whd_network_if.c)
41zephyr_library_sources(${hal_wifi_dir}/WiFi_Host_Driver/src/whd_resource_if.c)
42zephyr_library_sources(${hal_wifi_dir}/WiFi_Host_Driver/src/whd_sdpcm.c)
43zephyr_library_sources(${hal_wifi_dir}/WiFi_Host_Driver/src/whd_thread.c)
44zephyr_library_sources(${hal_wifi_dir}/WiFi_Host_Driver/src/whd_utils.c)
45zephyr_library_sources(${hal_wifi_dir}/WiFi_Host_Driver/src/whd_wifi.c)
46zephyr_library_sources(${hal_wifi_dir}/WiFi_Host_Driver/src/whd_wifi_api.c)
47zephyr_library_sources(${hal_wifi_dir}/WiFi_Host_Driver/src/whd_wifi_p2p.c)
48
49# src/bus_protocols
50zephyr_library_sources(${hal_wifi_dir}/WiFi_Host_Driver/src/bus_protocols/whd_bus.c)
51zephyr_library_sources(${hal_wifi_dir}/WiFi_Host_Driver/src/bus_protocols/whd_bus_common.c)
52zephyr_library_sources_ifdef(CONFIG_AIROC_WIFI_BUS_SDIO
53  ${hal_wifi_dir}/WiFi_Host_Driver/src/bus_protocols/whd_bus_sdio_protocol.c)
54zephyr_library_sources_ifdef(CONFIG_AIROC_WIFI_BUS_SPI
55  ${hal_wifi_dir}/WiFi_Host_Driver/src/bus_protocols/whd_bus_spi_protocol.c)
56
57# resources/resource_imp
58zephyr_library_sources(${hal_wifi_dir}/WiFi_Host_Driver/resources/resource_imp/whd_resources.c)
59
60# CYW43012 firmware
61if(CONFIG_CYW43012 AND NOT CONFIG_AIROC_WIFI_CUSTOM)
62  zephyr_include_directories(${hal_wifi_dir}/WiFi_Host_Driver/resources/firmware/COMPONENT_43012)
63
64  # firmware
65  if(CONFIG_AIROC_WLAN_MFG_FIRMWARE)
66    set(cyw43xx_fw_bin     ${hal_blobs_dir}/firmware/COMPONENT_43012/43012C0-mfgtest.bin)
67    zephyr_library_sources(${hal_wifi_dir_resources}/firmware/COMPONENT_43012/43012C0-mfgtest_bin.c)
68  else()
69    set(cyw43xx_fw_bin     ${hal_blobs_dir}/firmware/COMPONENT_43012/43012C0.bin)
70    zephyr_library_sources(${hal_wifi_dir_resources}/firmware/COMPONENT_43012/43012C0_bin.c)
71  endif()
72endif()
73
74# CYW4343W firmware
75if(CONFIG_CYW4343W AND NOT CONFIG_AIROC_WIFI_CUSTOM)
76  zephyr_include_directories(${hal_wifi_dir_resources}/firmware/COMPONENT_4343W)
77
78  # firmware
79  if(CONFIG_AIROC_WLAN_MFG_FIRMWARE)
80    set(cyw43xx_fw_bin     ${hal_blobs_dir}/firmware/COMPONENT_4343W/4343WA1-mfgtest.bin)
81    zephyr_library_sources(${hal_wifi_dir_resources}/firmware/COMPONENT_4343W/4343WA1-mfgtest_bin.c)
82  else()
83    set(cyw43xx_fw_bin     ${hal_blobs_dir}/firmware/COMPONENT_4343W/4343WA1.bin)
84    zephyr_library_sources(${hal_wifi_dir_resources}/firmware/COMPONENT_4343W/4343WA1_bin.c)
85  endif()
86endif()
87
88# CYW43438 firmware/clm
89if(CONFIG_CYW43438 AND NOT CONFIG_AIROC_WIFI_CUSTOM)
90  zephyr_include_directories(${hal_wifi_dir_resources}/firmware/COMPONENT_43438)
91  zephyr_include_directories(${hal_wifi_dir_resources}/clm/COMPONENT_43438)
92
93  # firmware/clm
94  if(CONFIG_AIROC_WLAN_MFG_FIRMWARE)
95    set(cyw43xx_fw_bin     ${hal_blobs_dir}/firmware/COMPONENT_43438/43438A1-mfgtest.bin)
96    set(cyw43xx_clm_bin    ${hal_blobs_dir}/clm/COMPONENT_43438/43438A1-mfgtest.clm_blob)
97
98    zephyr_library_sources(${hal_wifi_dir_resources}/firmware/COMPONENT_43438/43438A1-mfgtest_bin.c)
99    zephyr_library_sources(${hal_wifi_dir_resources}/clm/COMPONENT_43438/43438A1-mfgtest_clm_blob.c)
100  else()
101    set(cyw43xx_fw_bin     ${hal_blobs_dir}/firmware/COMPONENT_43438/43438A1.bin)
102    set(cyw43xx_clm_bin    ${hal_blobs_dir}/clm/COMPONENT_43438/43438A1.clm_blob)
103
104    zephyr_library_sources(${hal_wifi_dir_resources}/firmware/COMPONENT_43438/43438A1_bin.c)
105    zephyr_library_sources(${hal_wifi_dir_resources}/clm/COMPONENT_43438/43438A1_clm_blob.c)
106  endif()
107
108endif()
109
110# CYW43439 firmware
111if(CONFIG_CYW43439 AND NOT CONFIG_AIROC_WIFI_CUSTOM)
112  zephyr_include_directories(${hal_wifi_dir_resources}/firmware/COMPONENT_43439)
113
114  # firmware
115  if(CONFIG_AIROC_WLAN_MFG_FIRMWARE)
116    set(cyw43xx_fw_bin     ${hal_blobs_dir}/firmware/COMPONENT_43439/43439A0-mfgtest.bin)
117    zephyr_library_sources(${hal_wifi_dir_resources}/firmware/COMPONENT_43439/43439A0-mfgtest_bin.c)
118  else()
119    set(cyw43xx_fw_bin     ${hal_blobs_dir}/firmware/COMPONENT_43439/43439a0.bin)
120    zephyr_library_sources(${hal_wifi_dir_resources}/firmware/COMPONENT_43439/43439a0_bin.c)
121  endif()
122endif()
123
124# CYW4373 firmware
125if(CONFIG_CYW4373 AND NOT CONFIG_AIROC_WIFI_CUSTOM)
126  zephyr_include_directories(${hal_wifi_dir_resources}/firmware/COMPONENT_4373)
127
128  # firmware
129  if(CONFIG_AIROC_WLAN_MFG_FIRMWARE)
130    set(cyw43xx_fw_bin     ${hal_blobs_dir}/firmware/COMPONENT_4373/4373A0-mfgtest.bin)
131    zephyr_library_sources(${hal_wifi_dir_resources}/firmware/COMPONENT_4373/4373A0-mfgtest_bin.c)
132  else()
133    set(cyw43xx_fw_bin     ${hal_blobs_dir}/firmware/COMPONENT_4373/4373A0.bin)
134    zephyr_library_sources(${hal_wifi_dir_resources}/firmware/COMPONENT_4373/4373A0_bin.c)
135  endif()
136endif()
137
138
139# CYW43012_MURATA_1LV clm/nvram
140if(CONFIG_CYW43012_MURATA_1LV AND NOT CONFIG_AIROC_WIFI_CUSTOM)
141  zephyr_include_directories(${hal_wifi_dir}/WiFi_Host_Driver/resources/clm/COMPONENT_43012)
142
143  # clm
144  if(CONFIG_AIROC_WLAN_MFG_FIRMWARE)
145    set(cyw43xx_clm_bin    ${hal_blobs_dir}/clm/COMPONENT_43012/43012C0-mfgtest.clm_blob)
146
147    zephyr_library_sources(${hal_wifi_dir_resources}/clm/COMPONENT_43012/43012C0-mfgtest_clm_blob.c)
148  else()
149    set(cyw43xx_clm_bin    ${hal_blobs_dir}/clm/COMPONENT_43012/43012C0.clm_blob)
150
151    zephyr_library_sources(${hal_wifi_dir_resources}/clm/COMPONENT_43012/43012C0_clm_blob.c)
152  endif()
153
154  # nvram
155  zephyr_include_directories(${hal_wifi_dir_resources}/nvram/COMPONENT_43012/COMPONENT_MURATA-1LV)
156endif()
157
158# CYW4343W_MURATA_1DX clm/nvram
159if(CONFIG_CYW4343W_MURATA_1DX AND NOT CONFIG_AIROC_WIFI_CUSTOM)
160  zephyr_include_directories(${hal_wifi_dir_resources}/clm/COMPONENT_4343W)
161
162  # clm
163  if(CONFIG_AIROC_WLAN_MFG_FIRMWARE)
164    set(cyw43xx_clm_bin    ${hal_blobs_dir}/clm/COMPONENT_4343W/4343WA1-mfgtest.clm_blob)
165    zephyr_library_sources(${hal_wifi_dir_resources}/clm/COMPONENT_4343W/4343WA1-mfgtest_clm_blob.c)
166  else()
167    set(cyw43xx_clm_bin    ${hal_blobs_dir}/clm/COMPONENT_4343W/4343WA1.clm_blob)
168    zephyr_library_sources(${hal_wifi_dir_resources}/clm/COMPONENT_4343W/4343WA1_clm_blob.c)
169  endif()
170
171  # nvram
172  zephyr_include_directories(${hal_wifi_dir_resources}/nvram/COMPONENT_4343W/COMPONENT_MURATA-1DX)
173endif()
174
175# CYW43439_MURATA_1YN
176if(CONFIG_CYW43439_MURATA_1YN AND NOT CONFIG_AIROC_WIFI_CUSTOM)
177  zephyr_include_directories(${hal_wifi_dir_resources}/clm/COMPONENT_43439)
178
179  # clm
180  if(CONFIG_AIROC_WLAN_MFG_FIRMWARE)
181    set(cyw43xx_clm_bin    ${hal_blobs_dir}/clm/COMPONENT_43439/43439A0-mfgtest.clm_blob)
182    zephyr_library_sources(${hal_wifi_dir_resources}/clm/COMPONENT_43439/43439A0-mfgtest_clm_blob.c)
183  else()
184    set(cyw43xx_clm_bin    ${hal_blobs_dir}/clm/COMPONENT_43439/43439A0.clm_blob)
185    zephyr_library_sources(${hal_wifi_dir_resources}/clm/COMPONENT_43439/43439A0_clm_blob.c)
186  endif()
187
188  # nvram
189  zephyr_include_directories(${hal_wifi_dir_resources}/nvram/COMPONENT_43439/COMPONENT_MURATA-1YN)
190endif()
191
192# CYW4373_STERLING_LWB5PLUS
193if(CONFIG_CYW4373_STERLING_LWB5PLUS AND NOT CONFIG_AIROC_WIFI_CUSTOM)
194  zephyr_include_directories(${hal_wifi_dir_resources}/clm/COMPONENT_4373/COMPONENT_STERLING-LWB5plus)
195
196  # clm
197  if(CONFIG_AIROC_WLAN_MFG_FIRMWARE)
198    set(cyw43xx_clm_bin    ${hal_blobs_dir}/clm/COMPONENT_4373/COMPONENT_STERLING-LWB5plus/4373A0-mfgtest.clm_blob)
199    zephyr_library_sources(${hal_wifi_dir_resources}/clm/COMPONENT_4373/COMPONENT_STERLING-LWB5plus/4373A0-mfgtest_clm_blob.c)
200  else()
201    set(cyw43xx_clm_bin    ${hal_blobs_dir}/clm/COMPONENT_4373/COMPONENT_STERLING-LWB5plus/4373A0.clm_blob)
202    zephyr_library_sources(${hal_wifi_dir_resources}/clm/COMPONENT_4373/COMPONENT_STERLING-LWB5plus/4373A0_clm_blob.c)
203  endif()
204
205  # nvram
206  zephyr_include_directories_ifdef(${hal_wifi_dir_resources}/nvram/COMPONENT_4373/COMPONENT_STERLING-LWB5plus)
207endif()
208
209# generate FW inc_blob from fw_bin
210if(EXISTS ${cyw43xx_fw_bin})
211  message(INFO " generate include of blob FW file: ${cyw43xx_fw_bin}")
212  generate_inc_file_for_target(app ${cyw43xx_fw_bin} ${cyw43xx_fw_bin_gen_inc})
213endif()
214
215# generate CLM inc_blob from clm_bin
216if(EXISTS ${cyw43xx_clm_bin})
217  message(INFO " generate include of blob CLM file: ${cyw43xx_clm_bin}")
218  generate_inc_file_for_target(app ${cyw43xx_clm_bin} ${cyw43xx_clm_bin_gen_inc})
219endif()
220