blob: 81b4c62ff7742ccd7cc7b600fb8bae4116dd412f [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
8PV = "1.0"
9
developer0447f742022-10-31 14:57:29 +080010require mt76.inc
developerf11ee162022-04-12 11:17:45 +080011SRC_URI = " \
12 git://git@github.com/openwrt/mt76.git;protocol=https \
13 file://COPYING;subdir=git \
developere6cee7d2022-11-16 18:00:20 +080014 file://0001-mt76-add-internal-wed_tiny-header-file.patch;apply=no \
developerf11ee162022-04-12 11:17:45 +080015 "
developerbc4d8032022-04-15 13:47:16 +080016SRC_URI += " \
17 file://src \
18 "
developerf11ee162022-04-12 11:17:45 +080019
developere6cee7d2022-11-16 18:00:20 +080020
21
developerf11ee162022-04-12 11:17:45 +080022DEPENDS += "virtual/kernel"
23DEPENDS += "linux-mac80211"
24
25FILESEXTRAPATHS_prepend := "${THISDIR}/files/patches:"
developerbc4d8032022-04-15 13:47:16 +080026FILESEXTRAPATHS_prepend := "${THISDIR}/src:"
developerf11ee162022-04-12 11:17:45 +080027
developere6cee7d2022-11-16 18:00:20 +080028#require files/patches/patches.inc
29SRC_URI += "file://*.patch;apply=no"
developerf11ee162022-04-12 11:17:45 +080030
developerf11ee162022-04-12 11:17:45 +080031S = "${WORKDIR}/git"
32
developere6cee7d2022-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
developerf11ee162022-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
developerbc4d8032022-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
developerce673142022-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/
developer6ba5f602022-11-24 13:04:49 +0800126}
127
128do_install_append_mt7986 () {
129 install -d ${D}/${base_libdir}/firmware/mediatek/
developerce673142022-08-30 10:54:58 +0800130
developerbc4d8032022-04-15 13:47:16 +0800131 install -m 644 ${WORKDIR}/src/firmware/mt7986_rom_patch.bin ${D}${base_libdir}/firmware/mediatek/
132 install -m 644 ${WORKDIR}/src/firmware/mt7986_rom_patch_mt7975.bin ${D}${base_libdir}/firmware/mediatek/
133 install -m 644 ${WORKDIR}/src/firmware/mt7986_wa.bin ${D}${base_libdir}/firmware/mediatek/
134 install -m 644 ${WORKDIR}/src/firmware/mt7986_wm.bin ${D}${base_libdir}/firmware/mediatek/
135 install -m 644 ${WORKDIR}/src/firmware/mt7986_wm_mt7975.bin ${D}${base_libdir}/firmware/mediatek/
136 install -m 644 ${WORKDIR}/src/firmware/mt7986_eeprom_mt7975_dual.bin ${D}${base_libdir}/firmware/mediatek/
137 install -m 644 ${WORKDIR}/src/firmware/mt7986_eeprom_mt7976_dbdc.bin ${D}${base_libdir}/firmware/mediatek/
138 install -m 644 ${WORKDIR}/src/firmware/mt7986_eeprom_mt7976.bin ${D}${base_libdir}/firmware/mediatek/
139 install -m 644 ${WORKDIR}/src/firmware/mt7986_eeprom_mt7976_dual.bin ${D}${base_libdir}/firmware/mediatek/
developerf79ad452022-07-12 11:37:54 +0800140 install -m 644 ${WORKDIR}/src/firmware/mt7986_wo_0.bin ${D}${base_libdir}/firmware/mediatek/
141 install -m 644 ${WORKDIR}/src/firmware/mt7986_wo_1.bin ${D}${base_libdir}/firmware/mediatek/
developerbc4d8032022-04-15 13:47:16 +0800142}
developer6ba5f602022-11-24 13:04:49 +0800143
developer71d801e2022-11-02 18:14:41 +0800144FILES_${PN} += "${base_libdir}/firmware/mediatek/*"
developerbc4d8032022-04-15 13:47:16 +0800145
developerbc4d8032022-04-15 13:47:16 +0800146# Make linux-mt76 depend on all of the split-out packages.
147python populate_packages_prepend () {
148 firmware_pkgs = oe.utils.packages_filter_out_system(d)
149 d.appendVar('RDEPENDS_linux-mt76', ' ' + ' '.join(firmware_pkgs))
150}
151
developer71d801e2022-11-02 18:14:41 +0800152#RPROVIDES_${PN} += "kernel-module-${PN}-${KERNEL_VERSION}"
153#RPROVIDES_${PN} += "kernel-module-${PN}-connac-lib-${KERNEL_VERSION}"
154
developerf11ee162022-04-12 11:17:45 +0800155KERNEL_MODULE_AUTOLOAD += "mt7915e"