mt76: move mt76x2e firmware to kmod-mt76x2-common and use it for mt76x2u
[openwrt/openwrt.git] / package / kernel / mt76 / Makefile
1 include $(TOPDIR)/rules.mk
2
3 PKG_NAME:=mt76
4 PKG_RELEASE=1
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:=2018-10-05
12 PKG_SOURCE_VERSION:=d533f1351834ba2899897b090aa56a5f5b922bd7
13 PKG_MIRROR_HASH:=27e9c4cf876ad26a6f854d2b00d7e3b100980e820444f13986bf66f3f539eed3
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 @PCI_SUPPORT @!LINUX_3_18 \
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 +kmod-mt76x02-usb
84 HIDDEN:=1
85 FILES:=$(PKG_BUILD_DIR)/mt76x0/mt76x0-common.ko
86 endef
87
88 define KernelPackage/mt76x0u
89 $(KernelPackage/mt76-default)
90 TITLE:=MediaTek MT76x0U wireless driver
91 DEPENDS+=+kmod-mt76x0-common +kmod-mt76x02-usb
92 FILES:=\
93 $(PKG_BUILD_DIR)/mt76x0/mt76x0u.ko
94 AUTOLOAD:=$(call AutoProbe,mt76x0u)
95 endef
96
97 define KernelPackage/mt76x2-common
98 $(KernelPackage/mt76-default)
99 TITLE:=MediaTek MT76x2 wireless driver common code
100 DEPENDS+=+kmod-mt76-core +kmod-mt76x02-common
101 HIDDEN:=1
102 FILES:=$(PKG_BUILD_DIR)/mt76x2/mt76x2-common.ko
103 endef
104
105 define KernelPackage/mt76x2u
106 $(KernelPackage/mt76-default)
107 TITLE:=MediaTek MT76x2U wireless driver
108 DEPENDS+=+kmod-mt76x2-common +kmod-mt76x02-usb
109 FILES:=\
110 $(PKG_BUILD_DIR)/mt76x2/mt76x2u.ko
111 AUTOLOAD:=$(call AutoProbe,mt76x2u)
112 endef
113
114 define KernelPackage/mt76x2
115 $(KernelPackage/mt76-default)
116 TITLE:=MediaTek MT76x2 wireless driver
117 DEPENDS+=+kmod-mt76x2-common
118 FILES:=\
119 $(PKG_BUILD_DIR)/mt76x2/mt76x2e.ko
120 AUTOLOAD:=$(call AutoProbe,mt76x2e)
121 endef
122
123 define KernelPackage/mt7603
124 $(KernelPackage/mt76-default)
125 TITLE:=MediaTek MT7603 wireless driver
126 DEPENDS+=+kmod-mt76-core
127 FILES:=\
128 $(PKG_BUILD_DIR)/mt7603/mt7603e.ko
129 AUTOLOAD:=$(call AutoProbe,mt7603e)
130 endef
131
132 NOSTDINC_FLAGS = \
133 -I$(PKG_BUILD_DIR) \
134 -I$(STAGING_DIR)/usr/include/mac80211-backport/uapi \
135 -I$(STAGING_DIR)/usr/include/mac80211-backport \
136 -I$(STAGING_DIR)/usr/include/mac80211/uapi \
137 -I$(STAGING_DIR)/usr/include/mac80211 \
138 -include backport/autoconf.h \
139 -include backport/backport.h
140
141 ifdef CONFIG_PACKAGE_MAC80211_MESH
142 NOSTDINC_FLAGS += -DCONFIG_MAC80211_MESH
143 endif
144
145 ifdef CONFIG_PACKAGE_kmod-mt76-usb
146 PKG_MAKE_FLAGS += CONFIG_MT76_USB=m
147 endif
148 ifdef CONFIG_PACKAGE_kmod-mt76x02-common
149 PKG_MAKE_FLAGS += CONFIG_MT76x02_LIB=m
150 endif
151 ifdef CONFIG_PACKAGE_kmod-mt76x02-usb
152 PKG_MAKE_FLAGS += CONFIG_MT76x02_USB=m
153 endif
154 ifdef CONFIG_PACKAGE_kmod-mt76x0-common
155 PKG_MAKE_FLAGS += CONFIG_MT76x0_COMMON=m
156 endif
157 ifdef CONFIG_PACKAGE_kmod-mt76x0u
158 PKG_MAKE_FLAGS += CONFIG_MT76x0U=m
159 endif
160 ifdef CONFIG_PACKAGE_kmod-mt76x2-common
161 PKG_MAKE_FLAGS += CONFIG_MT76x2_COMMON=m
162 endif
163 ifdef CONFIG_PACKAGE_kmod-mt76x2
164 PKG_MAKE_FLAGS += CONFIG_MT76x2E=m
165 endif
166 ifdef CONFIG_PACKAGE_kmod-mt76x2u
167 PKG_MAKE_FLAGS += CONFIG_MT76x2U=m
168 endif
169 ifdef CONFIG_PACKAGE_kmod-mt7603
170 PKG_MAKE_FLAGS += CONFIG_MT7603E=m
171 endif
172
173 define Build/Compile
174 +$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \
175 $(KERNEL_MAKE_FLAGS) \
176 $(PKG_MAKE_FLAGS) \
177 SUBDIRS="$(PKG_BUILD_DIR)" \
178 NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \
179 modules
180 endef
181
182 define Package/kmod-mt76/install
183 true
184 endef
185
186 define KernelPackage/mt76x2-common/install
187 $(INSTALL_DIR) $(1)/lib/firmware
188 cp \
189 $(PKG_BUILD_DIR)/firmware/mt7662_rom_patch.bin \
190 $(PKG_BUILD_DIR)/firmware/mt7662.bin \
191 $(1)/lib/firmware
192 endef
193
194 define KernelPackage/mt76x2u/install
195 $(INSTALL_DIR) $(1)/lib/firmware/mediatek
196 ln -sf ../mt7662.bin $(1)/lib/firmware/mediatek/mt7662u.bin
197 ln -sf ../mt7662_rom_patch.bin $(1)/lib/firmware/mediatek/mt7662u_rom_patch.bin
198 endef
199
200 define KernelPackage/mt7603/install
201 $(INSTALL_DIR) $(1)/lib/firmware
202 cp $(if $(CONFIG_TARGET_ramips_mt76x8), \
203 $(PKG_BUILD_DIR)/firmware/mt7628_e1.bin \
204 $(PKG_BUILD_DIR)/firmware/mt7628_e2.bin \
205 ,\
206 $(PKG_BUILD_DIR)/firmware/mt7603_e1.bin \
207 $(PKG_BUILD_DIR)/firmware/mt7603_e2.bin \
208 ) \
209 $(1)/lib/firmware
210 endef
211
212 $(eval $(call KernelPackage,mt76-core))
213 $(eval $(call KernelPackage,mt76-usb))
214 $(eval $(call KernelPackage,mt76x02-usb))
215 $(eval $(call KernelPackage,mt76x02-common))
216 $(eval $(call KernelPackage,mt76x0-common))
217 $(eval $(call KernelPackage,mt76x0u))
218 $(eval $(call KernelPackage,mt76x2-common))
219 $(eval $(call KernelPackage,mt76x2u))
220 $(eval $(call KernelPackage,mt76x2))
221 $(eval $(call KernelPackage,mt7603))
222 $(eval $(call KernelPackage,mt76))