mt76: enable hostapd 802.11ax support if kmod-mt7915e is selected
[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-05-30
12 PKG_SOURCE_VERSION:=85c516081338d3d1454fb53b5741321c2adefbef
13 PKG_MIRROR_HASH:=a3e110700843ecfee10eba274ab6fe63b9d78a00eb96ee1634b145e0a9ae9a69
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
28 STAMP_CONFIGURED_DEPENDS := $(STAGING_DIR)/usr/include/mac80211-backport/backport/autoconf.h
29
30 include $(INCLUDE_DIR)/kernel.mk
31 include $(INCLUDE_DIR)/package.mk
32
33 define KernelPackage/mt76-default
34 SUBMENU:=Wireless Drivers
35 DEPENDS:= \
36 +kmod-mac80211 \
37 +@DRIVER_11AC_SUPPORT +@DRIVER_11N_SUPPORT +@DRIVER_11W_SUPPORT
38 endef
39
40 define KernelPackage/mt76
41 SUBMENU:=Wireless Drivers
42 TITLE:=MediaTek MT76x2/MT7603 wireless driver (metapackage)
43 DEPENDS:= \
44 +kmod-mt76-core +kmod-mt76x2 +kmod-mt7603
45 endef
46
47 define KernelPackage/mt76-core
48 $(KernelPackage/mt76-default)
49 TITLE:=MediaTek MT76xx wireless driver
50 HIDDEN:=1
51 FILES:=\
52 $(PKG_BUILD_DIR)/mt76.ko
53 endef
54
55 define KernelPackage/mt76-usb
56 $(KernelPackage/mt76-default)
57 TITLE:=MediaTek MT76xx wireless driver USB support
58 DEPENDS += +kmod-usb-core +kmod-mt76-core
59 HIDDEN:=1
60 FILES:=\
61 $(PKG_BUILD_DIR)/mt76-usb.ko
62 endef
63
64 define KernelPackage/mt76x02-usb
65 $(KernelPackage/mt76-default)
66 TITLE:=MediaTek MT76x0/MT76x2 USB wireless driver common code
67 DEPENDS+=+kmod-mt76-usb +kmod-mt76x02-common
68 HIDDEN:=1
69 FILES:=$(PKG_BUILD_DIR)/mt76x02-usb.ko
70 endef
71
72 define KernelPackage/mt76x02-common
73 $(KernelPackage/mt76-default)
74 TITLE:=MediaTek MT76x0/MT76x2 wireless driver common code
75 DEPENDS+=+kmod-mt76-core
76 HIDDEN:=1
77 FILES:=$(PKG_BUILD_DIR)/mt76x02-lib.ko
78 endef
79
80 define KernelPackage/mt76x0-common
81 $(KernelPackage/mt76-default)
82 TITLE:=MediaTek MT76x0 wireless driver common code
83 DEPENDS+=+kmod-mt76x02-common
84 HIDDEN:=1
85 FILES:=$(PKG_BUILD_DIR)/mt76x0/mt76x0-common.ko
86 endef
87
88 define KernelPackage/mt76x0e
89 $(KernelPackage/mt76-default)
90 TITLE:=MediaTek MT76x0E wireless driver
91 DEPENDS+=@PCI_SUPPORT +kmod-mt76x0-common
92 FILES:=\
93 $(PKG_BUILD_DIR)/mt76x0/mt76x0e.ko
94 AUTOLOAD:=$(call AutoProbe,mt76x0e)
95 endef
96
97 define KernelPackage/mt76x0u
98 $(KernelPackage/mt76-default)
99 TITLE:=MediaTek MT76x0U wireless driver
100 DEPENDS+=+kmod-mt76x0-common +kmod-mt76x02-usb
101 FILES:=\
102 $(PKG_BUILD_DIR)/mt76x0/mt76x0u.ko
103 AUTOLOAD:=$(call AutoProbe,mt76x0u)
104 endef
105
106 define KernelPackage/mt76x2-common
107 $(KernelPackage/mt76-default)
108 TITLE:=MediaTek MT76x2 wireless driver common code
109 DEPENDS+=+kmod-mt76-core +kmod-mt76x02-common
110 HIDDEN:=1
111 FILES:=$(PKG_BUILD_DIR)/mt76x2/mt76x2-common.ko
112 endef
113
114 define KernelPackage/mt76x2u
115 $(KernelPackage/mt76-default)
116 TITLE:=MediaTek MT76x2U wireless driver
117 DEPENDS+=+kmod-mt76x2-common +kmod-mt76x02-usb
118 FILES:=\
119 $(PKG_BUILD_DIR)/mt76x2/mt76x2u.ko
120 AUTOLOAD:=$(call AutoProbe,mt76x2u)
121 endef
122
123 define KernelPackage/mt76x2
124 $(KernelPackage/mt76-default)
125 TITLE:=MediaTek MT76x2 wireless driver
126 DEPENDS+=@PCI_SUPPORT +kmod-mt76x2-common
127 FILES:=\
128 $(PKG_BUILD_DIR)/mt76x2/mt76x2e.ko
129 AUTOLOAD:=$(call AutoProbe,mt76x2e)
130 endef
131
132 define KernelPackage/mt7603
133 $(KernelPackage/mt76-default)
134 TITLE:=MediaTek MT7603 wireless driver
135 DEPENDS+=@PCI_SUPPORT +kmod-mt76-core
136 FILES:=\
137 $(PKG_BUILD_DIR)/mt7603/mt7603e.ko
138 AUTOLOAD:=$(call AutoProbe,mt7603e)
139 endef
140
141 define KernelPackage/mt7615-common
142 $(KernelPackage/mt76-default)
143 TITLE:=MediaTek MT7615 wireless driver common code
144 HIDDEN:=1
145 DEPENDS+=@PCI_SUPPORT +kmod-mt76-core
146 FILES:= $(PKG_BUILD_DIR)/mt7615/mt7615-common.ko
147 endef
148
149 define KernelPackage/mt7615-firmware
150 $(KernelPackage/mt76-default)
151 TITLE:=MediaTek MT7615e firmware
152 DEFAULT:=PACKAGE_kmod-mt7615e
153 endef
154
155 define KernelPackage/mt7615e
156 $(KernelPackage/mt76-default)
157 TITLE:=MediaTek MT7615e wireless driver
158 DEPENDS+=@PCI_SUPPORT +kmod-mt7615-common
159 FILES:= $(PKG_BUILD_DIR)/mt7615/mt7615e.ko
160 AUTOLOAD:=$(call AutoProbe,mt7615e)
161 endef
162
163 define KernelPackage/mt7663-firmware-ap
164 $(KernelPackage/mt76-default)
165 TITLE:=MediaTek MT7663e firmware (optimized for AP)
166 endef
167
168 define KernelPackage/mt7663-firmware-sta
169 $(KernelPackage/mt76-default)
170 TITLE:=MediaTek MT7663e firmware (client mode offload)
171 endef
172
173 define KernelPackage/mt7663u
174 $(KernelPackage/mt76-default)
175 TITLE:=MediaTek MT7663u wireless driver
176 DEPENDS+=+kmod-mt76-usb +kmod-mt7615-common
177 FILES:= $(PKG_BUILD_DIR)/mt7615/mt7663u.ko
178 AUTOLOAD:=$(call AutoProbe,mt7663u)
179 endef
180
181 define KernelPackage/mt7915e
182 $(KernelPackage/mt76-default)
183 TITLE:=MediaTek MT7915e wireless driver
184 DEPENDS+=@PCI_SUPPORT +kmod-mt7615-common +@DRIVER_11AX_SUPPORT
185 FILES:= $(PKG_BUILD_DIR)/mt7915/mt7915e.ko
186 AUTOLOAD:=$(call AutoProbe,mt7915e)
187 endef
188
189 NOSTDINC_FLAGS = \
190 -I$(PKG_BUILD_DIR) \
191 -I$(STAGING_DIR)/usr/include/mac80211-backport/uapi \
192 -I$(STAGING_DIR)/usr/include/mac80211-backport \
193 -I$(STAGING_DIR)/usr/include/mac80211/uapi \
194 -I$(STAGING_DIR)/usr/include/mac80211 \
195 -include backport/autoconf.h \
196 -include backport/backport.h
197
198 ifdef CONFIG_PACKAGE_MAC80211_MESH
199 NOSTDINC_FLAGS += -DCONFIG_MAC80211_MESH
200 endif
201
202 ifdef CONFIG_PACKAGE_kmod-mt76-usb
203 PKG_MAKE_FLAGS += CONFIG_MT76_USB=m
204 endif
205 ifdef CONFIG_PACKAGE_kmod-mt76x02-common
206 PKG_MAKE_FLAGS += CONFIG_MT76x02_LIB=m
207 endif
208 ifdef CONFIG_PACKAGE_kmod-mt76x02-usb
209 PKG_MAKE_FLAGS += CONFIG_MT76x02_USB=m
210 endif
211 ifdef CONFIG_PACKAGE_kmod-mt76x0-common
212 PKG_MAKE_FLAGS += CONFIG_MT76x0_COMMON=m
213 endif
214 ifdef CONFIG_PACKAGE_kmod-mt76x0e
215 PKG_MAKE_FLAGS += CONFIG_MT76x0E=m
216 endif
217 ifdef CONFIG_PACKAGE_kmod-mt76x0u
218 PKG_MAKE_FLAGS += CONFIG_MT76x0U=m
219 endif
220 ifdef CONFIG_PACKAGE_kmod-mt76x2-common
221 PKG_MAKE_FLAGS += CONFIG_MT76x2_COMMON=m
222 endif
223 ifdef CONFIG_PACKAGE_kmod-mt76x2
224 PKG_MAKE_FLAGS += CONFIG_MT76x2E=m
225 endif
226 ifdef CONFIG_PACKAGE_kmod-mt76x2u
227 PKG_MAKE_FLAGS += CONFIG_MT76x2U=m
228 endif
229 ifdef CONFIG_PACKAGE_kmod-mt7603
230 PKG_MAKE_FLAGS += CONFIG_MT7603E=m
231 endif
232 ifdef CONFIG_PACKAGE_kmod-mt7615-common
233 PKG_MAKE_FLAGS += CONFIG_MT7615_COMMON=m
234 endif
235 ifdef CONFIG_PACKAGE_kmod-mt7615e
236 PKG_MAKE_FLAGS += CONFIG_MT7615E=m
237 ifdef CONFIG_TARGET_mediatek_mt7622
238 PKG_MAKE_FLAGS += CONFIG_MT7622_WMAC=y
239 NOSTDINC_FLAGS += -DCONFIG_MT7622_WMAC
240 endif
241 endif
242 ifdef CONFIG_PACKAGE_kmod-mt7663u
243 PKG_MAKE_FLAGS += CONFIG_MT7663U=m
244 endif
245 ifdef CONFIG_PACKAGE_kmod-mt7915e
246 PKG_MAKE_FLAGS += CONFIG_MT7915E=m
247 endif
248
249 define Build/Compile
250 +$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \
251 $(KERNEL_MAKE_FLAGS) \
252 $(PKG_MAKE_FLAGS) \
253 M="$(PKG_BUILD_DIR)" \
254 NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \
255 modules
256 endef
257
258 define Package/kmod-mt76/install
259 true
260 endef
261
262 define KernelPackage/mt76x0-common/install
263 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
264 cp \
265 $(PKG_BUILD_DIR)/firmware/mt7610e.bin \
266 $(1)/lib/firmware/mediatek
267 endef
268
269 define KernelPackage/mt76x2-common/install
270 $(INSTALL_DIR) $(1)/lib/firmware
271 cp \
272 $(PKG_BUILD_DIR)/firmware/mt7662_rom_patch.bin \
273 $(PKG_BUILD_DIR)/firmware/mt7662.bin \
274 $(1)/lib/firmware
275 endef
276
277 define KernelPackage/mt76x0u/install
278 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
279 ln -sf mt7610e.bin $(1)/lib/firmware/mediatek/mt7610u.bin
280 endef
281
282 define KernelPackage/mt76x2u/install
283 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
284 ln -sf ../mt7662.bin $(1)/lib/firmware/mediatek/mt7662u.bin
285 ln -sf ../mt7662_rom_patch.bin $(1)/lib/firmware/mediatek/mt7662u_rom_patch.bin
286 endef
287
288 define KernelPackage/mt7603/install
289 $(INSTALL_DIR) $(1)/lib/firmware
290 cp $(if $(CONFIG_TARGET_ramips_mt76x8), \
291 $(PKG_BUILD_DIR)/firmware/mt7628_e1.bin \
292 $(PKG_BUILD_DIR)/firmware/mt7628_e2.bin \
293 ,\
294 $(PKG_BUILD_DIR)/firmware/mt7603_e1.bin \
295 $(PKG_BUILD_DIR)/firmware/mt7603_e2.bin \
296 ) \
297 $(1)/lib/firmware
298 endef
299
300 define KernelPackage/mt7615-firmware/install
301 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
302 cp \
303 $(PKG_BUILD_DIR)/firmware/mt7615_cr4.bin \
304 $(PKG_BUILD_DIR)/firmware/mt7615_n9.bin \
305 $(PKG_BUILD_DIR)/firmware/mt7615_rom_patch.bin \
306 $(if $(CONFIG_TARGET_mediatek_mt7622), \
307 $(PKG_BUILD_DIR)/firmware/mt7622_n9.bin \
308 $(PKG_BUILD_DIR)/firmware/mt7622_rom_patch.bin) \
309 $(1)/lib/firmware/mediatek
310 endef
311
312 define KernelPackage/mt7663-firmware-ap/install
313 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
314 cp \
315 $(PKG_BUILD_DIR)/firmware/mt7663_n9_rebb.bin \
316 $(PKG_BUILD_DIR)/firmware/mt7663pr2h_rebb.bin \
317 $(1)/lib/firmware/mediatek
318 endef
319
320 define KernelPackage/mt7663-firmware-sta/install
321 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
322 cp \
323 $(PKG_BUILD_DIR)/firmware/mt7663_n9_v3.bin \
324 $(PKG_BUILD_DIR)/firmware/mt7663pr2h.bin \
325 $(1)/lib/firmware/mediatek
326 endef
327
328 define KernelPackage/mt7915e/install
329 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
330 cp \
331 $(PKG_BUILD_DIR)/firmware/mt7915_wa.bin \
332 $(PKG_BUILD_DIR)/firmware/mt7915_wm.bin \
333 $(PKG_BUILD_DIR)/firmware/mt7915_rom_patch.bin \
334 $(1)/lib/firmware/mediatek
335 endef
336
337 $(eval $(call KernelPackage,mt76-core))
338 $(eval $(call KernelPackage,mt76-usb))
339 $(eval $(call KernelPackage,mt76x02-usb))
340 $(eval $(call KernelPackage,mt76x02-common))
341 $(eval $(call KernelPackage,mt76x0-common))
342 $(eval $(call KernelPackage,mt76x0e))
343 $(eval $(call KernelPackage,mt76x0u))
344 $(eval $(call KernelPackage,mt76x2-common))
345 $(eval $(call KernelPackage,mt76x2u))
346 $(eval $(call KernelPackage,mt76x2))
347 $(eval $(call KernelPackage,mt7603))
348 $(eval $(call KernelPackage,mt7615-common))
349 $(eval $(call KernelPackage,mt7615-firmware))
350 $(eval $(call KernelPackage,mt7615e))
351 $(eval $(call KernelPackage,mt7663-firmware-ap))
352 $(eval $(call KernelPackage,mt7663-firmware-sta))
353 $(eval $(call KernelPackage,mt7663u))
354 $(eval $(call KernelPackage,mt7915e))
355 $(eval $(call KernelPackage,mt76))