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-23
12 PKG_SOURCE_VERSION:=1d01257662a6874e78b65c5e721ee1731ab006b3
13 PKG_MIRROR_HASH:=666ac5a6dfb3e73ace107815922766d661a2e2ea914a264c453ff8cae7839d3d
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/mt76-sdio
156 $(KernelPackage/mt76-default)
157 TITLE:=MediaTek MT7615/MT79xx SDIO driver common code
158 HIDDEN:=1
159 DEPENDS+=+kmod-mt76-core +kmod-mmc
160 FILES:= $(PKG_BUILD_DIR)/mt76-sdio.ko
161 endef
162
163 define KernelPackage/mt7615-common
164 $(KernelPackage/mt76-default)
165 TITLE:=MediaTek MT7615 wireless driver common code
166 HIDDEN:=1
167 DEPENDS+=@PCI_SUPPORT +kmod-mt76-core +kmod-mt76-connac +kmod-hwmon-core
168 FILES:= $(PKG_BUILD_DIR)/mt7615/mt7615-common.ko
169 endef
170
171 define KernelPackage/mt7615-firmware
172 $(KernelPackage/mt76-default)
173 TITLE:=MediaTek MT7615e firmware
174 DEFAULT:=PACKAGE_kmod-mt7615e
175 endef
176
177 define KernelPackage/mt7615e
178 $(KernelPackage/mt76-default)
179 TITLE:=MediaTek MT7615e wireless driver
180 DEPENDS+=@PCI_SUPPORT +kmod-mt7615-common
181 FILES:= $(PKG_BUILD_DIR)/mt7615/mt7615e.ko
182 AUTOLOAD:=$(call AutoProbe,mt7615e)
183 endef
184
185 define KernelPackage/mt7663-firmware-ap
186 $(KernelPackage/mt76-default)
187 TITLE:=MediaTek MT7663e firmware (optimized for AP)
188 endef
189
190 define KernelPackage/mt7663-firmware-sta
191 $(KernelPackage/mt76-default)
192 TITLE:=MediaTek MT7663e firmware (client mode offload)
193 endef
194
195 define KernelPackage/mt7663-usb-sdio
196 $(KernelPackage/mt76-default)
197 TITLE:=MediaTek MT7663 USB/SDIO shared code
198 DEPENDS+=+kmod-mt7615-common
199 HIDDEN:=1
200 FILES:= \
201 $(PKG_BUILD_DIR)/mt7615/mt7663-usb-sdio-common.ko
202 endef
203
204 define KernelPackage/mt7663s
205 $(KernelPackage/mt76-default)
206 TITLE:=MediaTek MT7663s wireless driver
207 DEPENDS+=+kmod-mt76-sdio +kmod-mt7615-common +kmod-mt7663-usb-sdio
208 FILES:= \
209 $(PKG_BUILD_DIR)/mt7615/mt7663s.ko
210 AUTOLOAD:=$(call AutoProbe,mt7663s)
211 endef
212
213 define KernelPackage/mt7663u
214 $(KernelPackage/mt76-default)
215 TITLE:=MediaTek MT7663u wireless driver
216 DEPENDS+=+kmod-mt76-usb +kmod-mt7615-common +kmod-mt7663-usb-sdio
217 FILES:= $(PKG_BUILD_DIR)/mt7615/mt7663u.ko
218 AUTOLOAD:=$(call AutoProbe,mt7663u)
219 endef
220
221 define KernelPackage/mt7915e
222 $(KernelPackage/mt76-default)
223 TITLE:=MediaTek MT7915e wireless driver
224 DEPENDS+=@PCI_SUPPORT +kmod-mt7615-common +kmod-hwmon-core +kmod-thermal +@DRIVER_11AX_SUPPORT
225 FILES:= $(PKG_BUILD_DIR)/mt7915/mt7915e.ko
226 AUTOLOAD:=$(call AutoProbe,mt7915e)
227 endef
228
229 define KernelPackage/mt7921-common
230 TITLE:=MediaTek MT7615 wireless driver common code
231 HIDDEN:=1
232 DEPENDS+=@PCI_SUPPORT +kmod-mt76-core +kmod-mt76-connac
233 FILES:= $(PKG_BUILD_DIR)/mt7921/mt7921-common.ko
234 endef
235
236 define KernelPackage/mt7921s
237 $(KernelPackage/mt76-default)
238 TITLE:=MediaTek MT7921s wireless driver
239 DEPENDS+=@PCI_SUPPORT +kmod-mt76-connac +kmod-mt76-sdio +kmod-mt7921-common
240 FILES:= $(PKG_BUILD_DIR)/mt7921/mt7921s.ko
241 AUTOLOAD:=$(call AutoProbe,mt7921s)
242 endef
243
244 define KernelPackage/mt7921e
245 $(KernelPackage/mt76-default)
246 TITLE:=MediaTek MT7921e wireless driver
247 DEPENDS+=@PCI_SUPPORT +kmod-mt76-connac +kmod-mt7921-common
248 FILES:= $(PKG_BUILD_DIR)/mt7921/mt7921e.ko
249 AUTOLOAD:=$(call AutoProbe,mt7921e)
250 endef
251
252 define Package/mt76-test
253 SECTION:=devel
254 CATEGORY:=Development
255 TITLE:=mt76 testmode CLI
256 DEPENDS:=kmod-mt76-core +libnl-tiny
257 endef
258
259 TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include/libnl-tiny
260
261 NOSTDINC_FLAGS := \
262 $(KERNEL_NOSTDINC_FLAGS) \
263 -I$(PKG_BUILD_DIR) \
264 -I$(STAGING_DIR)/usr/include/mac80211-backport/uapi \
265 -I$(STAGING_DIR)/usr/include/mac80211-backport \
266 -I$(STAGING_DIR)/usr/include/mac80211/uapi \
267 -I$(STAGING_DIR)/usr/include/mac80211 \
268 -include backport/autoconf.h \
269 -include backport/backport.h
270
271 ifdef CONFIG_PACKAGE_MAC80211_MESH
272 NOSTDINC_FLAGS += -DCONFIG_MAC80211_MESH
273 endif
274
275 ifdef CONFIG_PACKAGE_CFG80211_TESTMODE
276 NOSTDINC_FLAGS += -DCONFIG_NL80211_TESTMODE
277 PKG_MAKE_FLAGS += CONFIG_NL80211_TESTMODE=y
278 endif
279
280 ifdef CONFIG_PACKAGE_kmod-mt76-usb
281 PKG_MAKE_FLAGS += CONFIG_MT76_USB=m
282 endif
283 ifdef CONFIG_PACKAGE_kmod-mt76x02-common
284 PKG_MAKE_FLAGS += CONFIG_MT76x02_LIB=m
285 endif
286 ifdef CONFIG_PACKAGE_kmod-mt76x02-usb
287 PKG_MAKE_FLAGS += CONFIG_MT76x02_USB=m
288 endif
289 ifdef CONFIG_PACKAGE_kmod-mt76x0-common
290 PKG_MAKE_FLAGS += CONFIG_MT76x0_COMMON=m
291 endif
292 ifdef CONFIG_PACKAGE_kmod-mt76x0e
293 PKG_MAKE_FLAGS += CONFIG_MT76x0E=m
294 endif
295 ifdef CONFIG_PACKAGE_kmod-mt76x0u
296 PKG_MAKE_FLAGS += CONFIG_MT76x0U=m
297 endif
298 ifdef CONFIG_PACKAGE_kmod-mt76x2-common
299 PKG_MAKE_FLAGS += CONFIG_MT76x2_COMMON=m
300 endif
301 ifdef CONFIG_PACKAGE_kmod-mt76x2
302 PKG_MAKE_FLAGS += CONFIG_MT76x2E=m
303 endif
304 ifdef CONFIG_PACKAGE_kmod-mt76x2u
305 PKG_MAKE_FLAGS += CONFIG_MT76x2U=m
306 endif
307 ifdef CONFIG_PACKAGE_kmod-mt7603
308 PKG_MAKE_FLAGS += CONFIG_MT7603E=m
309 endif
310 ifdef CONFIG_PACKAGE_kmod-mt76-connac
311 PKG_MAKE_FLAGS += CONFIG_MT76_CONNAC_LIB=m
312 endif
313 ifdef CONFIG_PACKAGE_kmod-mt76-sdio
314 PKG_MAKE_FLAGS += CONFIG_MT76_SDIO=m
315 endif
316 ifdef CONFIG_PACKAGE_kmod-mt7615-common
317 PKG_MAKE_FLAGS += CONFIG_MT7615_COMMON=m
318 endif
319 ifdef CONFIG_PACKAGE_kmod-mt7615e
320 PKG_MAKE_FLAGS += CONFIG_MT7615E=m
321 ifdef CONFIG_TARGET_mediatek_mt7622
322 PKG_MAKE_FLAGS += CONFIG_MT7622_WMAC=y
323 NOSTDINC_FLAGS += -DCONFIG_MT7622_WMAC
324 endif
325 endif
326 ifdef CONFIG_PACKAGE_kmod-mt7663-usb-sdio
327 PKG_MAKE_FLAGS += CONFIG_MT7663_USB_SDIO_COMMON=m
328 endif
329 ifdef CONFIG_PACKAGE_kmod-mt7663s
330 PKG_MAKE_FLAGS += CONFIG_MT7663S=m
331 endif
332 ifdef CONFIG_PACKAGE_kmod-mt7663u
333 PKG_MAKE_FLAGS += CONFIG_MT7663U=m
334 endif
335 ifdef CONFIG_PACKAGE_kmod-mt7915e
336 PKG_MAKE_FLAGS += CONFIG_MT7915E=m
337 endif
338 ifdef CONFIG_PACKAGE_kmod-mt7921-common
339 PKG_MAKE_FLAGS += CONFIG_MT7921_COMMON=m
340 endif
341 ifdef CONFIG_PACKAGE_kmod-mt7921s
342 PKG_MAKE_FLAGS += CONFIG_MT7921S=m
343 endif
344 ifdef CONFIG_PACKAGE_kmod-mt7921e
345 PKG_MAKE_FLAGS += CONFIG_MT7921E=m
346 endif
347
348 define Build/Compile
349 +$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \
350 $(KERNEL_MAKE_FLAGS) \
351 $(PKG_MAKE_FLAGS) \
352 M="$(PKG_BUILD_DIR)" \
353 NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \
354 modules
355 $(MAKE) -C $(PKG_BUILD_DIR)/tools
356 endef
357
358 define Build/Install
359 :
360 endef
361
362 define Package/kmod-mt76/install
363 true
364 endef
365
366 define KernelPackage/mt76x0-common/install
367 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
368 cp \
369 $(PKG_BUILD_DIR)/firmware/mt7610e.bin \
370 $(1)/lib/firmware/mediatek
371 endef
372
373 define KernelPackage/mt76x2-common/install
374 $(INSTALL_DIR) $(1)/lib/firmware
375 cp \
376 $(PKG_BUILD_DIR)/firmware/mt7662_rom_patch.bin \
377 $(PKG_BUILD_DIR)/firmware/mt7662.bin \
378 $(1)/lib/firmware
379 endef
380
381 define KernelPackage/mt76x0u/install
382 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
383 ln -sf mt7610e.bin $(1)/lib/firmware/mediatek/mt7610u.bin
384 endef
385
386 define KernelPackage/mt76x2u/install
387 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
388 ln -sf ../mt7662.bin $(1)/lib/firmware/mediatek/mt7662u.bin
389 ln -sf ../mt7662_rom_patch.bin $(1)/lib/firmware/mediatek/mt7662u_rom_patch.bin
390 endef
391
392 define KernelPackage/mt7603/install
393 $(INSTALL_DIR) $(1)/lib/firmware
394 cp $(if $(CONFIG_TARGET_ramips_mt76x8), \
395 $(PKG_BUILD_DIR)/firmware/mt7628_e1.bin \
396 $(PKG_BUILD_DIR)/firmware/mt7628_e2.bin \
397 ,\
398 $(PKG_BUILD_DIR)/firmware/mt7603_e1.bin \
399 $(PKG_BUILD_DIR)/firmware/mt7603_e2.bin \
400 ) \
401 $(1)/lib/firmware
402 endef
403
404 define KernelPackage/mt7615-firmware/install
405 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
406 cp \
407 $(PKG_BUILD_DIR)/firmware/mt7615_cr4.bin \
408 $(PKG_BUILD_DIR)/firmware/mt7615_n9.bin \
409 $(PKG_BUILD_DIR)/firmware/mt7615_rom_patch.bin \
410 $(if $(CONFIG_TARGET_mediatek_mt7622), \
411 $(PKG_BUILD_DIR)/firmware/mt7622_n9.bin \
412 $(PKG_BUILD_DIR)/firmware/mt7622_rom_patch.bin) \
413 $(1)/lib/firmware/mediatek
414 endef
415
416 define KernelPackage/mt7663-firmware-ap/install
417 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
418 cp \
419 $(PKG_BUILD_DIR)/firmware/mt7663_n9_rebb.bin \
420 $(PKG_BUILD_DIR)/firmware/mt7663pr2h_rebb.bin \
421 $(1)/lib/firmware/mediatek
422 endef
423
424 define KernelPackage/mt7663-firmware-sta/install
425 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
426 cp \
427 $(PKG_BUILD_DIR)/firmware/mt7663_n9_v3.bin \
428 $(PKG_BUILD_DIR)/firmware/mt7663pr2h.bin \
429 $(1)/lib/firmware/mediatek
430 endef
431
432 define KernelPackage/mt7915e/install
433 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
434 cp \
435 $(PKG_BUILD_DIR)/firmware/mt7915_wa.bin \
436 $(PKG_BUILD_DIR)/firmware/mt7915_wm.bin \
437 $(PKG_BUILD_DIR)/firmware/mt7915_rom_patch.bin \
438 $(1)/lib/firmware/mediatek
439 endef
440
441 define KernelPackage/mt7921e/install
442 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
443 cp \
444 $(PKG_BUILD_DIR)/firmware/WIFI_MT7961_patch_mcu_1_2_hdr.bin \
445 $(PKG_BUILD_DIR)/firmware/WIFI_RAM_CODE_MT7961_1.bin \
446 $(1)/lib/firmware/mediatek
447 endef
448
449 define Package/mt76-test/install
450 mkdir -p $(1)/usr/sbin
451 $(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/mt76-test $(1)/usr/sbin
452 endef
453
454 $(eval $(call KernelPackage,mt76-core))
455 $(eval $(call KernelPackage,mt76-usb))
456 $(eval $(call KernelPackage,mt76x02-usb))
457 $(eval $(call KernelPackage,mt76x02-common))
458 $(eval $(call KernelPackage,mt76x0-common))
459 $(eval $(call KernelPackage,mt76x0e))
460 $(eval $(call KernelPackage,mt76x0u))
461 $(eval $(call KernelPackage,mt76x2-common))
462 $(eval $(call KernelPackage,mt76x2u))
463 $(eval $(call KernelPackage,mt76x2))
464 $(eval $(call KernelPackage,mt7603))
465 $(eval $(call KernelPackage,mt76-connac))
466 $(eval $(call KernelPackage,mt76-sdio))
467 $(eval $(call KernelPackage,mt7615-common))
468 $(eval $(call KernelPackage,mt7615-firmware))
469 $(eval $(call KernelPackage,mt7615e))
470 $(eval $(call KernelPackage,mt7663-firmware-ap))
471 $(eval $(call KernelPackage,mt7663-firmware-sta))
472 $(eval $(call KernelPackage,mt7663-usb-sdio))
473 $(eval $(call KernelPackage,mt7663u))
474 $(eval $(call KernelPackage,mt7663s))
475 $(eval $(call KernelPackage,mt7915e))
476 $(eval $(call KernelPackage,mt7921-common))
477 $(eval $(call KernelPackage,mt7921s))
478 $(eval $(call KernelPackage,mt7921e))
479 $(eval $(call KernelPackage,mt76))
480 $(eval $(call BuildPackage,mt76-test))