blob: 69d67b0b712c8d25bf611c41e64380c91ea3c09c [file] [log] [blame]
developerec4ebe42022-04-12 11:17:45 +08001DESCRIPTION = "Mediatek Wireless Drivers"
2SECTION = "kernel/modules"
3LICENSE = "GPLv2"
4LIC_FILES_CHKSUM = "file://COPYING;md5=c188eeeb69c0a05d0545816f1458a0c9"
5
6inherit module
7
8PV = "1.0"
9
developer9ac79da2022-10-31 14:57:29 +080010require mt76.inc
developerec4ebe42022-04-12 11:17:45 +080011SRC_URI = " \
12 git://git@github.com/openwrt/mt76.git;protocol=https \
13 file://COPYING;subdir=git \
developerddae1502022-11-16 18:00:20 +080014 file://0001-mt76-add-internal-wed_tiny-header-file.patch;apply=no \
developerec4ebe42022-04-12 11:17:45 +080015 "
developerbc7ed682022-04-15 13:47:16 +080016SRC_URI += " \
17 file://src \
18 "
developerec4ebe42022-04-12 11:17:45 +080019
developerddae1502022-11-16 18:00:20 +080020
21
developerec4ebe42022-04-12 11:17:45 +080022DEPENDS += "virtual/kernel"
23DEPENDS += "linux-mac80211"
24
25FILESEXTRAPATHS_prepend := "${THISDIR}/files/patches:"
developerbc7ed682022-04-15 13:47:16 +080026FILESEXTRAPATHS_prepend := "${THISDIR}/src:"
developerec4ebe42022-04-12 11:17:45 +080027
developerddae1502022-11-16 18:00:20 +080028#require files/patches/patches.inc
29SRC_URI += "file://*.patch;apply=no"
developerec4ebe42022-04-12 11:17:45 +080030
developerec4ebe42022-04-12 11:17:45 +080031S = "${WORKDIR}/git"
32
developerddae1502022-11-16 18:00:20 +080033do_mtk_patches() {
34 cd ${S}
35
36 DISTRO_FlowBlock_ENABLED="${@bb.utils.contains('DISTRO_FEATURES','flow_offload','true','false',d)}"
37
38 if [ ! -e mtk_wifi_patch_applied ]; then
39 for i in ${WORKDIR}/*.patch
40 do
41 if [ $DISTRO_FlowBlock_ENABLED = 'true' ]; then
42 patch -p1 < $i;
43 else
44 prefix=$(echo -n "${WORKDIR}"|wc -c)
45 patch_number_start=$(expr $prefix + 2)
46 patch_number_end=$(expr $patch_number_start + 3 )
47 patch_number=$(echo "$i" | cut -c"$patch_number_start"-"$patch_number_end")
48
49 if [ "$patch_number" -ge "3000" ]; then
50 continue;
51 else
52 patch -p1 < $i;
53 fi
54 fi
55 done
56 fi
57 touch mtk_wifi_patch_applied
58}
59addtask mtk_patches after do_patch before do_configure
60
developerec4ebe42022-04-12 11:17:45 +080061NOSTDINC_FLAGS = " \
62 -I${B} \
63 -I${STAGING_KERNEL_BUILDDIR}/usr/include/mac80211-backport/uapi \
64 -I${STAGING_KERNEL_BUILDDIR}/usr/include/mac80211-backport \
65 -I${STAGING_KERNEL_BUILDDIR}/usr/include/mac80211/uapi \
66 -I${STAGING_KERNEL_BUILDDIR}/usr/include/mac80211 \
67 -include backport/autoconf.h \
68 -include backport/backport.h \
69 "
70
71PKG_MAKE_FLAGS = " \
72 CONFIG_MAC80211_DEBUGFS=y \
73 CONFIG_NL80211_TESTMODE=y \
74 CONFIG_MT76_CONNAC_LIB=m \
75 CONFIG_MT7615_COMMON=m \
76 CONFIG_MT7915E=m \
77 CONFIG_MT7986_WMAC=y \
78 "
79
80NOSTDINC_FLAGS += " \
81 -DCONFIG_MAC80211_MESH \
82 -DCONFIG_NL80211_TESTMODE \
83 -DCONFIG_MAC80211_DEBUGFS \
84 -DCONFIG_MT7986_WMAC \
85 "
86
87EXTRA_OEMAKE = " \
88 -C ${STAGING_KERNEL_BUILDDIR}/ \
89 M=${S} \
90 ${PKG_MAKE_FLAGS} \
91 NOSTDINC_FLAGS="${NOSTDINC_FLAGS}" \
92 "
93
94MAKE_TARGETS = "modules"
95
96do_configure[noexec] = "1"
97
98# make_scripts requires kernel source directory to create
99# kernel scripts
100do_make_scripts[depends] += "virtual/kernel:do_shared_workdir"
101
102do_install() {
103 # Module
104 install -d ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/
105 install -d ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/mt7615/
106 install -d ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/mt7915/
107 install -m 0644 ${B}/mt76.ko ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/
108 install -m 0644 ${B}/mt76-connac-lib.ko ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/
109 install -m 0644 ${B}/mt7615/mt7615-common.ko ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/mt7615/
110 install -m 0644 ${B}/mt7915/mt7915e.ko ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/mt7915/
111}
112
developerbc7ed682022-04-15 13:47:16 +0800113do_install_append () {
114 install -d ${D}/${base_libdir}/firmware/mediatek/
115
116 install -m 644 ${WORKDIR}/src/firmware/mt7915_rom_patch.bin ${D}${base_libdir}/firmware/mediatek/
117 install -m 644 ${WORKDIR}/src/firmware/mt7915_wa.bin ${D}${base_libdir}/firmware/mediatek/
118 install -m 644 ${WORKDIR}/src/firmware/mt7915_wm.bin ${D}${base_libdir}/firmware/mediatek/
119 install -m 644 ${WORKDIR}/src/firmware/mt7915_eeprom.bin ${D}${base_libdir}/firmware/mediatek/
120 install -m 644 ${WORKDIR}/src/firmware/mt7915_eeprom_dbdc.bin ${D}${base_libdir}/firmware/mediatek/
121
developerf8dda1f2022-08-30 10:54:58 +0800122 install -m 644 ${WORKDIR}/src/firmware/mt7916_rom_patch.bin ${D}${base_libdir}/firmware/mediatek/
123 install -m 644 ${WORKDIR}/src/firmware/mt7916_wa.bin ${D}${base_libdir}/firmware/mediatek/
124 install -m 644 ${WORKDIR}/src/firmware/mt7916_wm.bin ${D}${base_libdir}/firmware/mediatek/
125 install -m 644 ${WORKDIR}/src/firmware/mt7916_eeprom.bin ${D}${base_libdir}/firmware/mediatek/
126
developerbc7ed682022-04-15 13:47:16 +0800127 install -m 644 ${WORKDIR}/src/firmware/mt7986_rom_patch.bin ${D}${base_libdir}/firmware/mediatek/
128 install -m 644 ${WORKDIR}/src/firmware/mt7986_rom_patch_mt7975.bin ${D}${base_libdir}/firmware/mediatek/
129 install -m 644 ${WORKDIR}/src/firmware/mt7986_wa.bin ${D}${base_libdir}/firmware/mediatek/
130 install -m 644 ${WORKDIR}/src/firmware/mt7986_wm.bin ${D}${base_libdir}/firmware/mediatek/
131 install -m 644 ${WORKDIR}/src/firmware/mt7986_wm_mt7975.bin ${D}${base_libdir}/firmware/mediatek/
132 install -m 644 ${WORKDIR}/src/firmware/mt7986_eeprom_mt7975_dual.bin ${D}${base_libdir}/firmware/mediatek/
133 install -m 644 ${WORKDIR}/src/firmware/mt7986_eeprom_mt7976_dbdc.bin ${D}${base_libdir}/firmware/mediatek/
134 install -m 644 ${WORKDIR}/src/firmware/mt7986_eeprom_mt7976.bin ${D}${base_libdir}/firmware/mediatek/
135 install -m 644 ${WORKDIR}/src/firmware/mt7986_eeprom_mt7976_dual.bin ${D}${base_libdir}/firmware/mediatek/
developer3262bf82022-07-12 11:37:54 +0800136 install -m 644 ${WORKDIR}/src/firmware/mt7986_wo_0.bin ${D}${base_libdir}/firmware/mediatek/
137 install -m 644 ${WORKDIR}/src/firmware/mt7986_wo_1.bin ${D}${base_libdir}/firmware/mediatek/
developerbc7ed682022-04-15 13:47:16 +0800138}
developerca2d55d2022-11-02 18:14:41 +0800139FILES_${PN} += "${base_libdir}/firmware/mediatek/*"
developerbc7ed682022-04-15 13:47:16 +0800140
developerbc7ed682022-04-15 13:47:16 +0800141# Make linux-mt76 depend on all of the split-out packages.
142python populate_packages_prepend () {
143 firmware_pkgs = oe.utils.packages_filter_out_system(d)
144 d.appendVar('RDEPENDS_linux-mt76', ' ' + ' '.join(firmware_pkgs))
145}
146
developerca2d55d2022-11-02 18:14:41 +0800147#RPROVIDES_${PN} += "kernel-module-${PN}-${KERNEL_VERSION}"
148#RPROVIDES_${PN} += "kernel-module-${PN}-connac-lib-${KERNEL_VERSION}"
149
developerec4ebe42022-04-12 11:17:45 +0800150KERNEL_MODULE_AUTOLOAD += "mt7915e"