blob: fddcb356696528218073561e534208d9faa03344 [file] [log] [blame]
developerf11ee162022-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
developer17bb0a82022-12-13 15:52:04 +08008require mt76.inc
developerf11ee162022-04-12 11:17:45 +08009SRC_URI = " \
10 git://git@github.com/openwrt/mt76.git;protocol=https \
11 file://COPYING;subdir=git \
developere6cee7d2022-11-16 18:00:20 +080012 file://0001-mt76-add-internal-wed_tiny-header-file.patch;apply=no \
developerf11ee162022-04-12 11:17:45 +080013 "
developerbc4d8032022-04-15 13:47:16 +080014SRC_URI += " \
15 file://src \
16 "
developerf11ee162022-04-12 11:17:45 +080017
developere6cee7d2022-11-16 18:00:20 +080018
19
developerf11ee162022-04-12 11:17:45 +080020DEPENDS += "virtual/kernel"
21DEPENDS += "linux-mac80211"
22
developere2cfb522022-12-08 18:09:45 +080023FILESEXTRAPATHS_prepend := "${THISDIR}/files/patches-${PV}:"
developerbc4d8032022-04-15 13:47:16 +080024FILESEXTRAPATHS_prepend := "${THISDIR}/src:"
developerf11ee162022-04-12 11:17:45 +080025
developere6cee7d2022-11-16 18:00:20 +080026SRC_URI += "file://*.patch;apply=no"
developerf11ee162022-04-12 11:17:45 +080027
developerf11ee162022-04-12 11:17:45 +080028S = "${WORKDIR}/git"
29
developere6cee7d2022-11-16 18:00:20 +080030do_mtk_patches() {
31 cd ${S}
32
33 DISTRO_FlowBlock_ENABLED="${@bb.utils.contains('DISTRO_FEATURES','flow_offload','true','false',d)}"
34
35 if [ ! -e mtk_wifi_patch_applied ]; then
36 for i in ${WORKDIR}/*.patch
37 do
38 if [ $DISTRO_FlowBlock_ENABLED = 'true' ]; then
39 patch -p1 < $i;
40 else
41 prefix=$(echo -n "${WORKDIR}"|wc -c)
42 patch_number_start=$(expr $prefix + 2)
43 patch_number_end=$(expr $patch_number_start + 3 )
44 patch_number=$(echo "$i" | cut -c"$patch_number_start"-"$patch_number_end")
45
46 if [ "$patch_number" -ge "3000" ]; then
47 continue;
48 else
49 patch -p1 < $i;
50 fi
51 fi
52 done
53 fi
54 touch mtk_wifi_patch_applied
55}
56addtask mtk_patches after do_patch before do_configure
57
developerf11ee162022-04-12 11:17:45 +080058NOSTDINC_FLAGS = " \
59 -I${B} \
60 -I${STAGING_KERNEL_BUILDDIR}/usr/include/mac80211-backport/uapi \
61 -I${STAGING_KERNEL_BUILDDIR}/usr/include/mac80211-backport \
62 -I${STAGING_KERNEL_BUILDDIR}/usr/include/mac80211/uapi \
63 -I${STAGING_KERNEL_BUILDDIR}/usr/include/mac80211 \
64 -include backport/autoconf.h \
65 -include backport/backport.h \
66 "
67
68PKG_MAKE_FLAGS = " \
69 CONFIG_MAC80211_DEBUGFS=y \
70 CONFIG_NL80211_TESTMODE=y \
71 CONFIG_MT76_CONNAC_LIB=m \
developerf8dbcb32022-12-15 18:14:59 +080072 CONFIG_MT7996E=m \
developerf11ee162022-04-12 11:17:45 +080073 "
74
75NOSTDINC_FLAGS += " \
76 -DCONFIG_MAC80211_MESH \
77 -DCONFIG_NL80211_TESTMODE \
78 -DCONFIG_MAC80211_DEBUGFS \
developerf11ee162022-04-12 11:17:45 +080079 "
80
81EXTRA_OEMAKE = " \
82 -C ${STAGING_KERNEL_BUILDDIR}/ \
83 M=${S} \
84 ${PKG_MAKE_FLAGS} \
85 NOSTDINC_FLAGS="${NOSTDINC_FLAGS}" \
86 "
87
88MAKE_TARGETS = "modules"
89
90do_configure[noexec] = "1"
91
92# make_scripts requires kernel source directory to create
93# kernel scripts
94do_make_scripts[depends] += "virtual/kernel:do_shared_workdir"
95
96do_install() {
97 # Module
98 install -d ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/
99 install -d ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/mt7615/
100 install -d ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/mt7915/
101 install -m 0644 ${B}/mt76.ko ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/
102 install -m 0644 ${B}/mt76-connac-lib.ko ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/
developerf8dbcb32022-12-15 18:14:59 +0800103 install -m 0644 ${B}/mt7996/mt7996e.ko ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/
developerf11ee162022-04-12 11:17:45 +0800104}
105
developerbc4d8032022-04-15 13:47:16 +0800106do_install_append () {
107 install -d ${D}/${base_libdir}/firmware/mediatek/
108
109 install -m 644 ${WORKDIR}/src/firmware/mt7915_rom_patch.bin ${D}${base_libdir}/firmware/mediatek/
110 install -m 644 ${WORKDIR}/src/firmware/mt7915_wa.bin ${D}${base_libdir}/firmware/mediatek/
111 install -m 644 ${WORKDIR}/src/firmware/mt7915_wm.bin ${D}${base_libdir}/firmware/mediatek/
112 install -m 644 ${WORKDIR}/src/firmware/mt7915_eeprom.bin ${D}${base_libdir}/firmware/mediatek/
113 install -m 644 ${WORKDIR}/src/firmware/mt7915_eeprom_dbdc.bin ${D}${base_libdir}/firmware/mediatek/
114
developerce673142022-08-30 10:54:58 +0800115 install -m 644 ${WORKDIR}/src/firmware/mt7916_rom_patch.bin ${D}${base_libdir}/firmware/mediatek/
116 install -m 644 ${WORKDIR}/src/firmware/mt7916_wa.bin ${D}${base_libdir}/firmware/mediatek/
117 install -m 644 ${WORKDIR}/src/firmware/mt7916_wm.bin ${D}${base_libdir}/firmware/mediatek/
118 install -m 644 ${WORKDIR}/src/firmware/mt7916_eeprom.bin ${D}${base_libdir}/firmware/mediatek/
developerf8dbcb32022-12-15 18:14:59 +0800119
120 install -d ${D}/${base_libdir}/firmware/mediatek/mt7996
121 install -m 644 ${WORKDIR}/src/firmware/mt7996_wa.bin ${D}${base_libdir}/firmware/mediatek/mt7996
122 install -m 644 ${WORKDIR}/src/firmware/mt7996_wm.bin ${D}${base_libdir}/firmware/mediatek/mt7996
123 install -m 644 ${WORKDIR}/src/firmware/mt7996_rom_patch.bin ${D}${base_libdir}/firmware/mediatek/mt7996
124 install -m 644 ${WORKDIR}/src/firmware/mt7996_eeprom.bin ${D}${base_libdir}/firmware/mediatek/mt7996
developer6ba5f602022-11-24 13:04:49 +0800125}
126
developerf8dbcb32022-12-15 18:14:59 +0800127do_install_append_mt7988 () {
developer6ba5f602022-11-24 13:04:49 +0800128 install -d ${D}/${base_libdir}/firmware/mediatek/
developerce673142022-08-30 10:54:58 +0800129
developerf79ad452022-07-12 11:37:54 +0800130 install -m 644 ${WORKDIR}/src/firmware/mt7986_wo_0.bin ${D}${base_libdir}/firmware/mediatek/
131 install -m 644 ${WORKDIR}/src/firmware/mt7986_wo_1.bin ${D}${base_libdir}/firmware/mediatek/
developerbc4d8032022-04-15 13:47:16 +0800132}
developer6ba5f602022-11-24 13:04:49 +0800133
developer71d801e2022-11-02 18:14:41 +0800134FILES_${PN} += "${base_libdir}/firmware/mediatek/*"
developerbc4d8032022-04-15 13:47:16 +0800135
developerbc4d8032022-04-15 13:47:16 +0800136# Make linux-mt76 depend on all of the split-out packages.
137python populate_packages_prepend () {
138 firmware_pkgs = oe.utils.packages_filter_out_system(d)
139 d.appendVar('RDEPENDS_linux-mt76', ' ' + ' '.join(firmware_pkgs))
140}
141
developer71d801e2022-11-02 18:14:41 +0800142#RPROVIDES_${PN} += "kernel-module-${PN}-${KERNEL_VERSION}"
143#RPROVIDES_${PN} += "kernel-module-${PN}-connac-lib-${KERNEL_VERSION}"
144
developerf8dbcb32022-12-15 18:14:59 +0800145#KERNEL_MODULE_AUTOLOAD += "mt7915e"
146KERNEL_MODULE_AUTOLOAD += "mt7996e"