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