blob: 970937d62c0ec5114cdb242ce223279217a9f132 [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
developer9ac79da2022-10-31 14:57:29 +08008require mt76.inc
developerec4ebe42022-04-12 11:17:45 +08009SRC_URI = " \
10 git://git@github.com/openwrt/mt76.git;protocol=https \
11 file://COPYING;subdir=git \
developerddae1502022-11-16 18:00:20 +080012 file://0001-mt76-add-internal-wed_tiny-header-file.patch;apply=no \
developerec4ebe42022-04-12 11:17:45 +080013 "
developerbc7ed682022-04-15 13:47:16 +080014SRC_URI += " \
15 file://src \
16 "
developerec4ebe42022-04-12 11:17:45 +080017
developerddae1502022-11-16 18:00:20 +080018
19
developerec4ebe42022-04-12 11:17:45 +080020DEPENDS += "virtual/kernel"
21DEPENDS += "linux-mac80211"
22
23FILESEXTRAPATHS_prepend := "${THISDIR}/files/patches:"
developerbc7ed682022-04-15 13:47:16 +080024FILESEXTRAPATHS_prepend := "${THISDIR}/src:"
developerec4ebe42022-04-12 11:17:45 +080025
developerddae1502022-11-16 18:00:20 +080026#require files/patches/patches.inc
27SRC_URI += "file://*.patch;apply=no"
developerec4ebe42022-04-12 11:17:45 +080028
developerec4ebe42022-04-12 11:17:45 +080029S = "${WORKDIR}/git"
30
developerddae1502022-11-16 18:00:20 +080031do_mtk_patches() {
32 cd ${S}
33
34 DISTRO_FlowBlock_ENABLED="${@bb.utils.contains('DISTRO_FEATURES','flow_offload','true','false',d)}"
35
36 if [ ! -e mtk_wifi_patch_applied ]; then
37 for i in ${WORKDIR}/*.patch
38 do
39 if [ $DISTRO_FlowBlock_ENABLED = 'true' ]; then
40 patch -p1 < $i;
41 else
42 prefix=$(echo -n "${WORKDIR}"|wc -c)
43 patch_number_start=$(expr $prefix + 2)
44 patch_number_end=$(expr $patch_number_start + 3 )
45 patch_number=$(echo "$i" | cut -c"$patch_number_start"-"$patch_number_end")
46
47 if [ "$patch_number" -ge "3000" ]; then
48 continue;
49 else
50 patch -p1 < $i;
51 fi
52 fi
53 done
54 fi
55 touch mtk_wifi_patch_applied
56}
57addtask mtk_patches after do_patch before do_configure
58
developerec4ebe42022-04-12 11:17:45 +080059NOSTDINC_FLAGS = " \
60 -I${B} \
61 -I${STAGING_KERNEL_BUILDDIR}/usr/include/mac80211-backport/uapi \
62 -I${STAGING_KERNEL_BUILDDIR}/usr/include/mac80211-backport \
63 -I${STAGING_KERNEL_BUILDDIR}/usr/include/mac80211/uapi \
64 -I${STAGING_KERNEL_BUILDDIR}/usr/include/mac80211 \
65 -include backport/autoconf.h \
66 -include backport/backport.h \
67 "
68
69PKG_MAKE_FLAGS = " \
70 CONFIG_MAC80211_DEBUGFS=y \
71 CONFIG_NL80211_TESTMODE=y \
72 CONFIG_MT76_CONNAC_LIB=m \
73 CONFIG_MT7615_COMMON=m \
74 CONFIG_MT7915E=m \
75 CONFIG_MT7986_WMAC=y \
76 "
77
78NOSTDINC_FLAGS += " \
79 -DCONFIG_MAC80211_MESH \
80 -DCONFIG_NL80211_TESTMODE \
81 -DCONFIG_MAC80211_DEBUGFS \
82 -DCONFIG_MT7986_WMAC \
83 "
84
85EXTRA_OEMAKE = " \
86 -C ${STAGING_KERNEL_BUILDDIR}/ \
87 M=${S} \
88 ${PKG_MAKE_FLAGS} \
89 NOSTDINC_FLAGS="${NOSTDINC_FLAGS}" \
90 "
91
92MAKE_TARGETS = "modules"
93
94do_configure[noexec] = "1"
95
96# make_scripts requires kernel source directory to create
97# kernel scripts
98do_make_scripts[depends] += "virtual/kernel:do_shared_workdir"
99
100do_install() {
101 # Module
102 install -d ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/
103 install -d ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/mt7615/
104 install -d ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/mt7915/
105 install -m 0644 ${B}/mt76.ko ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/
106 install -m 0644 ${B}/mt76-connac-lib.ko ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/
107 install -m 0644 ${B}/mt7615/mt7615-common.ko ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/mt7615/
108 install -m 0644 ${B}/mt7915/mt7915e.ko ${D}/lib/modules/${KERNEL_VERSION}/updates/drivers/net/wireless/mediatek/mt76/mt7915/
109}
110
developerbc7ed682022-04-15 13:47:16 +0800111do_install_append () {
112 install -d ${D}/${base_libdir}/firmware/mediatek/
113
114 install -m 644 ${WORKDIR}/src/firmware/mt7915_rom_patch.bin ${D}${base_libdir}/firmware/mediatek/
115 install -m 644 ${WORKDIR}/src/firmware/mt7915_wa.bin ${D}${base_libdir}/firmware/mediatek/
116 install -m 644 ${WORKDIR}/src/firmware/mt7915_wm.bin ${D}${base_libdir}/firmware/mediatek/
117 install -m 644 ${WORKDIR}/src/firmware/mt7915_eeprom.bin ${D}${base_libdir}/firmware/mediatek/
118 install -m 644 ${WORKDIR}/src/firmware/mt7915_eeprom_dbdc.bin ${D}${base_libdir}/firmware/mediatek/
119
developerf8dda1f2022-08-30 10:54:58 +0800120 install -m 644 ${WORKDIR}/src/firmware/mt7916_rom_patch.bin ${D}${base_libdir}/firmware/mediatek/
121 install -m 644 ${WORKDIR}/src/firmware/mt7916_wa.bin ${D}${base_libdir}/firmware/mediatek/
122 install -m 644 ${WORKDIR}/src/firmware/mt7916_wm.bin ${D}${base_libdir}/firmware/mediatek/
123 install -m 644 ${WORKDIR}/src/firmware/mt7916_eeprom.bin ${D}${base_libdir}/firmware/mediatek/
developer5e697a22022-11-24 13:04:49 +0800124}
125
126do_install_append_mt7986 () {
127 install -d ${D}/${base_libdir}/firmware/mediatek/
developerf8dda1f2022-08-30 10:54:58 +0800128
developerbc7ed682022-04-15 13:47:16 +0800129 install -m 644 ${WORKDIR}/src/firmware/mt7986_rom_patch.bin ${D}${base_libdir}/firmware/mediatek/
130 install -m 644 ${WORKDIR}/src/firmware/mt7986_rom_patch_mt7975.bin ${D}${base_libdir}/firmware/mediatek/
131 install -m 644 ${WORKDIR}/src/firmware/mt7986_wa.bin ${D}${base_libdir}/firmware/mediatek/
132 install -m 644 ${WORKDIR}/src/firmware/mt7986_wm.bin ${D}${base_libdir}/firmware/mediatek/
133 install -m 644 ${WORKDIR}/src/firmware/mt7986_wm_mt7975.bin ${D}${base_libdir}/firmware/mediatek/
134 install -m 644 ${WORKDIR}/src/firmware/mt7986_eeprom_mt7975_dual.bin ${D}${base_libdir}/firmware/mediatek/
135 install -m 644 ${WORKDIR}/src/firmware/mt7986_eeprom_mt7976_dbdc.bin ${D}${base_libdir}/firmware/mediatek/
136 install -m 644 ${WORKDIR}/src/firmware/mt7986_eeprom_mt7976.bin ${D}${base_libdir}/firmware/mediatek/
137 install -m 644 ${WORKDIR}/src/firmware/mt7986_eeprom_mt7976_dual.bin ${D}${base_libdir}/firmware/mediatek/
developer3262bf82022-07-12 11:37:54 +0800138 install -m 644 ${WORKDIR}/src/firmware/mt7986_wo_0.bin ${D}${base_libdir}/firmware/mediatek/
139 install -m 644 ${WORKDIR}/src/firmware/mt7986_wo_1.bin ${D}${base_libdir}/firmware/mediatek/
developerbc7ed682022-04-15 13:47:16 +0800140}
developer5e697a22022-11-24 13:04:49 +0800141
developerca2d55d2022-11-02 18:14:41 +0800142FILES_${PN} += "${base_libdir}/firmware/mediatek/*"
developerbc7ed682022-04-15 13:47:16 +0800143
developerbc7ed682022-04-15 13:47:16 +0800144# Make linux-mt76 depend on all of the split-out packages.
145python populate_packages_prepend () {
146 firmware_pkgs = oe.utils.packages_filter_out_system(d)
147 d.appendVar('RDEPENDS_linux-mt76', ' ' + ' '.join(firmware_pkgs))
148}
149
developerca2d55d2022-11-02 18:14:41 +0800150#RPROVIDES_${PN} += "kernel-module-${PN}-${KERNEL_VERSION}"
151#RPROVIDES_${PN} += "kernel-module-${PN}-connac-lib-${KERNEL_VERSION}"
152
developerec4ebe42022-04-12 11:17:45 +0800153KERNEL_MODULE_AUTOLOAD += "mt7915e"