mt76: update to the latest version
[openwrt/openwrt.git] / package / kernel / mt76 / Makefile
1 include $(TOPDIR)/rules.mk
2
3 PKG_NAME:=mt76
4 PKG_RELEASE=4
5
6 PKG_LICENSE:=GPLv2
7 PKG_LICENSE_FILES:=
8
9 PKG_SOURCE_URL:=https://github.com/openwrt/mt76
10 PKG_SOURCE_PROTO:=git
11 PKG_SOURCE_DATE:=2021-10-11
12 PKG_SOURCE_VERSION:=5560b08f8e2dfe92aa920a9cf3c5655a309dd25b
13 PKG_MIRROR_HASH:=36359a85325a60230838e38e087f9aecc49cf7abca0ef55b2dbee86cf9194425
14
15 PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
16 PKG_USE_NINJA:=0
17 PKG_BUILD_PARALLEL:=1
18
19 PKG_CONFIG_DEPENDS += \
20 CONFIG_PACKAGE_kmod-mt76-usb \
21 CONFIG_PACKAGE_kmod-mt76x02-common \
22 CONFIG_PACKAGE_kmod-mt76x0-common \
23 CONFIG_PACKAGE_kmod-mt76x0u \
24 CONFIG_PACKAGE_kmod-mt76x2-common \
25 CONFIG_PACKAGE_kmod-mt76x2 \
26 CONFIG_PACKAGE_kmod-mt76x2u \
27 CONFIG_PACKAGE_kmod-mt7603 \
28 CONFIG_PACKAGE_CFG80211_TESTMODE
29
30 STAMP_CONFIGURED_DEPENDS := $(STAGING_DIR)/usr/include/mac80211-backport/backport/autoconf.h
31
32 include $(INCLUDE_DIR)/kernel.mk
33 include $(INCLUDE_DIR)/package.mk
34 include $(INCLUDE_DIR)/cmake.mk
35
36 CMAKE_SOURCE_DIR:=$(PKG_BUILD_DIR)/tools
37 CMAKE_BINARY_DIR:=$(PKG_BUILD_DIR)/tools
38
39 define KernelPackage/mt76-default
40 SUBMENU:=Wireless Drivers
41 DEPENDS:= \
42 +kmod-mac80211 \
43 +@DRIVER_11AC_SUPPORT +@DRIVER_11N_SUPPORT
44 endef
45
46 define KernelPackage/mt76
47 SUBMENU:=Wireless Drivers
48 TITLE:=MediaTek MT76x2/MT7603 wireless driver (metapackage)
49 DEPENDS:= \
50 +kmod-mt76-core +kmod-mt76x2 +kmod-mt7603
51 endef
52
53 define KernelPackage/mt76-core
54 $(KernelPackage/mt76-default)
55 TITLE:=MediaTek MT76xx wireless driver
56 HIDDEN:=1
57 FILES:=\
58 $(PKG_BUILD_DIR)/mt76.ko
59 endef
60
61 define KernelPackage/mt76-usb
62 $(KernelPackage/mt76-default)
63 TITLE:=MediaTek MT76xx wireless driver USB support
64 DEPENDS += +kmod-usb-core +kmod-mt76-core
65 HIDDEN:=1
66 FILES:=\
67 $(PKG_BUILD_DIR)/mt76-usb.ko
68 endef
69
70 define KernelPackage/mt76x02-usb
71 $(KernelPackage/mt76-default)
72 TITLE:=MediaTek MT76x0/MT76x2 USB wireless driver common code
73 DEPENDS+=+kmod-mt76-usb +kmod-mt76x02-common
74 HIDDEN:=1
75 FILES:=$(PKG_BUILD_DIR)/mt76x02-usb.ko
76 endef
77
78 define KernelPackage/mt76x02-common
79 $(KernelPackage/mt76-default)
80 TITLE:=MediaTek MT76x0/MT76x2 wireless driver common code
81 DEPENDS+=+kmod-mt76-core
82 HIDDEN:=1
83 FILES:=$(PKG_BUILD_DIR)/mt76x02-lib.ko
84 endef
85
86 define KernelPackage/mt76x0-common
87 $(KernelPackage/mt76-default)
88 TITLE:=MediaTek MT76x0 wireless driver common code
89 DEPENDS+=+kmod-mt76x02-common
90 HIDDEN:=1
91 FILES:=$(PKG_BUILD_DIR)/mt76x0/mt76x0-common.ko
92 endef
93
94 define KernelPackage/mt76x0e
95 $(KernelPackage/mt76-default)
96 TITLE:=MediaTek MT76x0E wireless driver
97 DEPENDS+=@PCI_SUPPORT +kmod-mt76x0-common
98 FILES:=\
99 $(PKG_BUILD_DIR)/mt76x0/mt76x0e.ko
100 AUTOLOAD:=$(call AutoProbe,mt76x0e)
101 endef
102
103 define KernelPackage/mt76x0u
104 $(KernelPackage/mt76-default)
105 TITLE:=MediaTek MT76x0U wireless driver
106 DEPENDS+=+kmod-mt76x0-common +kmod-mt76x02-usb
107 FILES:=\
108 $(PKG_BUILD_DIR)/mt76x0/mt76x0u.ko
109 AUTOLOAD:=$(call AutoProbe,mt76x0u)
110 endef
111
112 define KernelPackage/mt76x2-common
113 $(KernelPackage/mt76-default)
114 TITLE:=MediaTek MT76x2 wireless driver common code
115 DEPENDS+=+kmod-mt76-core +kmod-mt76x02-common
116 HIDDEN:=1
117 FILES:=$(PKG_BUILD_DIR)/mt76x2/mt76x2-common.ko
118 endef
119
120 define KernelPackage/mt76x2u
121 $(KernelPackage/mt76-default)
122 TITLE:=MediaTek MT76x2U wireless driver
123 DEPENDS+=+kmod-mt76x2-common +kmod-mt76x02-usb
124 FILES:=\
125 $(PKG_BUILD_DIR)/mt76x2/mt76x2u.ko
126 AUTOLOAD:=$(call AutoProbe,mt76x2u)
127 endef
128
129 define KernelPackage/mt76x2
130 $(KernelPackage/mt76-default)
131 TITLE:=MediaTek MT76x2 wireless driver
132 DEPENDS+=@PCI_SUPPORT +kmod-mt76x2-common
133 FILES:=\
134 $(PKG_BUILD_DIR)/mt76x2/mt76x2e.ko
135 AUTOLOAD:=$(call AutoProbe,mt76x2e)
136 endef
137
138 define KernelPackage/mt7603
139 $(KernelPackage/mt76-default)
140 TITLE:=MediaTek MT7603 wireless driver
141 DEPENDS+=@PCI_SUPPORT +kmod-mt76-core
142 FILES:=\
143 $(PKG_BUILD_DIR)/mt7603/mt7603e.ko
144 AUTOLOAD:=$(call AutoProbe,mt7603e)
145 endef
146
147 define KernelPackage/mt76-connac
148 $(KernelPackage/mt76-default)
149 TITLE:=MediaTek MT7615/MT79xx wireless driver common code
150 HIDDEN:=1
151 DEPENDS+=+kmod-mt76-core
152 FILES:= $(PKG_BUILD_DIR)/mt76-connac-lib.ko
153 endef
154
155 define KernelPackage/mt7615-common
156 $(KernelPackage/mt76-default)
157 TITLE:=MediaTek MT7615 wireless driver common code
158 HIDDEN:=1
159 DEPENDS+=@PCI_SUPPORT +kmod-mt76-core +kmod-mt76-connac +kmod-hwmon-core
160 FILES:= $(PKG_BUILD_DIR)/mt7615/mt7615-common.ko
161 endef
162
163 define KernelPackage/mt7615-firmware
164 $(KernelPackage/mt76-default)
165 TITLE:=MediaTek MT7615e firmware
166 DEFAULT:=PACKAGE_kmod-mt7615e
167 endef
168
169 define KernelPackage/mt7615e
170 $(KernelPackage/mt76-default)
171 TITLE:=MediaTek MT7615e wireless driver
172 DEPENDS+=@PCI_SUPPORT +kmod-mt7615-common
173 FILES:= $(PKG_BUILD_DIR)/mt7615/mt7615e.ko
174 AUTOLOAD:=$(call AutoProbe,mt7615e)
175 endef
176
177 define KernelPackage/mt7663-firmware-ap
178 $(KernelPackage/mt76-default)
179 TITLE:=MediaTek MT7663e firmware (optimized for AP)
180 endef
181
182 define KernelPackage/mt7663-firmware-sta
183 $(KernelPackage/mt76-default)
184 TITLE:=MediaTek MT7663e firmware (client mode offload)
185 endef
186
187 define KernelPackage/mt7663-usb-sdio
188 $(KernelPackage/mt76-default)
189 TITLE:=MediaTek MT7663 USB/SDIO shared code
190 DEPENDS+=+kmod-mt7615-common
191 HIDDEN:=1
192 FILES:= \
193 $(PKG_BUILD_DIR)/mt7615/mt7663-usb-sdio-common.ko
194 endef
195
196 define KernelPackage/mt7663s
197 $(KernelPackage/mt76-default)
198 TITLE:=MediaTek MT7663s wireless driver
199 DEPENDS+=+kmod-mmc +kmod-mt7615-common +kmod-mt7663-usb-sdio
200 FILES:= \
201 $(PKG_BUILD_DIR)/mt76-sdio.ko \
202 $(PKG_BUILD_DIR)/mt7615/mt7663s.ko
203 AUTOLOAD:=$(call AutoProbe,mt7663s)
204 endef
205
206 define KernelPackage/mt7663u
207 $(KernelPackage/mt76-default)
208 TITLE:=MediaTek MT7663u wireless driver
209 DEPENDS+=+kmod-mt76-usb +kmod-mt7615-common +kmod-mt7663-usb-sdio
210 FILES:= $(PKG_BUILD_DIR)/mt7615/mt7663u.ko
211 AUTOLOAD:=$(call AutoProbe,mt7663u)
212 endef
213
214 define KernelPackage/mt7915e
215 $(KernelPackage/mt76-default)
216 TITLE:=MediaTek MT7915e wireless driver
217 DEPENDS+=@PCI_SUPPORT +kmod-mt7615-common +kmod-hwmon-core +kmod-thermal +@DRIVER_11AX_SUPPORT
218 FILES:= $(PKG_BUILD_DIR)/mt7915/mt7915e.ko
219 AUTOLOAD:=$(call AutoProbe,mt7915e)
220 endef
221
222 define KernelPackage/mt7921e
223 $(KernelPackage/mt76-default)
224 TITLE:=MediaTek MT7921e wireless driver
225 DEPENDS+=@PCI_SUPPORT +kmod-mt76-connac
226 FILES:= $(PKG_BUILD_DIR)/mt7921/mt7921e.ko
227 AUTOLOAD:=$(call AutoProbe,mt7921e)
228 endef
229
230 define Package/mt76-test
231 SECTION:=devel
232 CATEGORY:=Development
233 TITLE:=mt76 testmode CLI
234 DEPENDS:=kmod-mt76-core +libnl-tiny
235 endef
236
237 TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include/libnl-tiny
238
239 NOSTDINC_FLAGS := \
240 $(KERNEL_NOSTDINC_FLAGS) \
241 -I$(PKG_BUILD_DIR) \
242 -I$(STAGING_DIR)/usr/include/mac80211-backport/uapi \
243 -I$(STAGING_DIR)/usr/include/mac80211-backport \
244 -I$(STAGING_DIR)/usr/include/mac80211/uapi \
245 -I$(STAGING_DIR)/usr/include/mac80211 \
246 -include backport/autoconf.h \
247 -include backport/backport.h
248
249 ifdef CONFIG_PACKAGE_MAC80211_MESH
250 NOSTDINC_FLAGS += -DCONFIG_MAC80211_MESH
251 endif
252
253 ifdef CONFIG_PACKAGE_CFG80211_TESTMODE
254 NOSTDINC_FLAGS += -DCONFIG_NL80211_TESTMODE
255 PKG_MAKE_FLAGS += CONFIG_NL80211_TESTMODE=y
256 endif
257
258 ifdef CONFIG_PACKAGE_kmod-mt76-usb
259 PKG_MAKE_FLAGS += CONFIG_MT76_USB=m
260 endif
261 ifdef CONFIG_PACKAGE_kmod-mt76x02-common
262 PKG_MAKE_FLAGS += CONFIG_MT76x02_LIB=m
263 endif
264 ifdef CONFIG_PACKAGE_kmod-mt76x02-usb
265 PKG_MAKE_FLAGS += CONFIG_MT76x02_USB=m
266 endif
267 ifdef CONFIG_PACKAGE_kmod-mt76x0-common
268 PKG_MAKE_FLAGS += CONFIG_MT76x0_COMMON=m
269 endif
270 ifdef CONFIG_PACKAGE_kmod-mt76x0e
271 PKG_MAKE_FLAGS += CONFIG_MT76x0E=m
272 endif
273 ifdef CONFIG_PACKAGE_kmod-mt76x0u
274 PKG_MAKE_FLAGS += CONFIG_MT76x0U=m
275 endif
276 ifdef CONFIG_PACKAGE_kmod-mt76x2-common
277 PKG_MAKE_FLAGS += CONFIG_MT76x2_COMMON=m
278 endif
279 ifdef CONFIG_PACKAGE_kmod-mt76x2
280 PKG_MAKE_FLAGS += CONFIG_MT76x2E=m
281 endif
282 ifdef CONFIG_PACKAGE_kmod-mt76x2u
283 PKG_MAKE_FLAGS += CONFIG_MT76x2U=m
284 endif
285 ifdef CONFIG_PACKAGE_kmod-mt7603
286 PKG_MAKE_FLAGS += CONFIG_MT7603E=m
287 endif
288 ifdef CONFIG_PACKAGE_kmod-mt76-connac
289 PKG_MAKE_FLAGS += CONFIG_MT76_CONNAC_LIB=m
290 endif
291 ifdef CONFIG_PACKAGE_kmod-mt7615-common
292 PKG_MAKE_FLAGS += CONFIG_MT7615_COMMON=m
293 endif
294 ifdef CONFIG_PACKAGE_kmod-mt7615e
295 PKG_MAKE_FLAGS += CONFIG_MT7615E=m
296 ifdef CONFIG_TARGET_mediatek_mt7622
297 PKG_MAKE_FLAGS += CONFIG_MT7622_WMAC=y
298 NOSTDINC_FLAGS += -DCONFIG_MT7622_WMAC
299 endif
300 endif
301 ifdef CONFIG_PACKAGE_kmod-mt7663-usb-sdio
302 PKG_MAKE_FLAGS += CONFIG_MT7663_USB_SDIO_COMMON=m
303 endif
304 ifdef CONFIG_PACKAGE_kmod-mt7663s
305 PKG_MAKE_FLAGS += CONFIG_MT76_SDIO=m
306 PKG_MAKE_FLAGS += CONFIG_MT7663S=m
307 endif
308 ifdef CONFIG_PACKAGE_kmod-mt7663u
309 PKG_MAKE_FLAGS += CONFIG_MT7663U=m
310 endif
311 ifdef CONFIG_PACKAGE_kmod-mt7915e
312 PKG_MAKE_FLAGS += CONFIG_MT7915E=m
313 endif
314 ifdef CONFIG_PACKAGE_kmod-mt7921e
315 PKG_MAKE_FLAGS += CONFIG_MT7921E=m
316 endif
317
318 define Build/Compile
319 +$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \
320 $(KERNEL_MAKE_FLAGS) \
321 $(PKG_MAKE_FLAGS) \
322 M="$(PKG_BUILD_DIR)" \
323 NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \
324 modules
325 $(MAKE) -C $(PKG_BUILD_DIR)/tools
326 endef
327
328 define Build/Install
329 :
330 endef
331
332 define Package/kmod-mt76/install
333 true
334 endef
335
336 define KernelPackage/mt76x0-common/install
337 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
338 cp \
339 $(PKG_BUILD_DIR)/firmware/mt7610e.bin \
340 $(1)/lib/firmware/mediatek
341 endef
342
343 define KernelPackage/mt76x2-common/install
344 $(INSTALL_DIR) $(1)/lib/firmware
345 cp \
346 $(PKG_BUILD_DIR)/firmware/mt7662_rom_patch.bin \
347 $(PKG_BUILD_DIR)/firmware/mt7662.bin \
348 $(1)/lib/firmware
349 endef
350
351 define KernelPackage/mt76x0u/install
352 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
353 ln -sf mt7610e.bin $(1)/lib/firmware/mediatek/mt7610u.bin
354 endef
355
356 define KernelPackage/mt76x2u/install
357 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
358 ln -sf ../mt7662.bin $(1)/lib/firmware/mediatek/mt7662u.bin
359 ln -sf ../mt7662_rom_patch.bin $(1)/lib/firmware/mediatek/mt7662u_rom_patch.bin
360 endef
361
362 define KernelPackage/mt7603/install
363 $(INSTALL_DIR) $(1)/lib/firmware
364 cp $(if $(CONFIG_TARGET_ramips_mt76x8), \
365 $(PKG_BUILD_DIR)/firmware/mt7628_e1.bin \
366 $(PKG_BUILD_DIR)/firmware/mt7628_e2.bin \
367 ,\
368 $(PKG_BUILD_DIR)/firmware/mt7603_e1.bin \
369 $(PKG_BUILD_DIR)/firmware/mt7603_e2.bin \
370 ) \
371 $(1)/lib/firmware
372 endef
373
374 define KernelPackage/mt7615-firmware/install
375 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
376 cp \
377 $(PKG_BUILD_DIR)/firmware/mt7615_cr4.bin \
378 $(PKG_BUILD_DIR)/firmware/mt7615_n9.bin \
379 $(PKG_BUILD_DIR)/firmware/mt7615_rom_patch.bin \
380 $(if $(CONFIG_TARGET_mediatek_mt7622), \
381 $(PKG_BUILD_DIR)/firmware/mt7622_n9.bin \
382 $(PKG_BUILD_DIR)/firmware/mt7622_rom_patch.bin) \
383 $(1)/lib/firmware/mediatek
384 endef
385
386 define KernelPackage/mt7663-firmware-ap/install
387 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
388 cp \
389 $(PKG_BUILD_DIR)/firmware/mt7663_n9_rebb.bin \
390 $(PKG_BUILD_DIR)/firmware/mt7663pr2h_rebb.bin \
391 $(1)/lib/firmware/mediatek
392 endef
393
394 define KernelPackage/mt7663-firmware-sta/install
395 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
396 cp \
397 $(PKG_BUILD_DIR)/firmware/mt7663_n9_v3.bin \
398 $(PKG_BUILD_DIR)/firmware/mt7663pr2h.bin \
399 $(1)/lib/firmware/mediatek
400 endef
401
402 define KernelPackage/mt7915e/install
403 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
404 cp \
405 $(PKG_BUILD_DIR)/firmware/mt7915_wa.bin \
406 $(PKG_BUILD_DIR)/firmware/mt7915_wm.bin \
407 $(PKG_BUILD_DIR)/firmware/mt7915_rom_patch.bin \
408 $(1)/lib/firmware/mediatek
409 endef
410
411 define KernelPackage/mt7921e/install
412 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
413 cp \
414 $(PKG_BUILD_DIR)/firmware/WIFI_MT7961_patch_mcu_1_2_hdr.bin \
415 $(PKG_BUILD_DIR)/firmware/WIFI_RAM_CODE_MT7961_1.bin \
416 $(1)/lib/firmware/mediatek
417 endef
418
419 define Package/mt76-test/install
420 mkdir -p $(1)/usr/sbin
421 $(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/mt76-test $(1)/usr/sbin
422 endef
423
424 $(eval $(call KernelPackage,mt76-core))
425 $(eval $(call KernelPackage,mt76-usb))
426 $(eval $(call KernelPackage,mt76x02-usb))
427 $(eval $(call KernelPackage,mt76x02-common))
428 $(eval $(call KernelPackage,mt76x0-common))
429 $(eval $(call KernelPackage,mt76x0e))
430 $(eval $(call KernelPackage,mt76x0u))
431 $(eval $(call KernelPackage,mt76x2-common))
432 $(eval $(call KernelPackage,mt76x2u))
433 $(eval $(call KernelPackage,mt76x2))
434 $(eval $(call KernelPackage,mt7603))
435 $(eval $(call KernelPackage,mt76-connac))
436 $(eval $(call KernelPackage,mt7615-common))
437 $(eval $(call KernelPackage,mt7615-firmware))
438 $(eval $(call KernelPackage,mt7615e))
439 $(eval $(call KernelPackage,mt7663-firmware-ap))
440 $(eval $(call KernelPackage,mt7663-firmware-sta))
441 $(eval $(call KernelPackage,mt7663-usb-sdio))
442 $(eval $(call KernelPackage,mt7663u))
443 $(eval $(call KernelPackage,mt7663s))
444 $(eval $(call KernelPackage,mt7915e))
445 $(eval $(call KernelPackage,mt7921e))
446 $(eval $(call KernelPackage,mt76))
447 $(eval $(call BuildPackage,mt76-test))