Skip to content

Commit

Permalink
rtw89: add support for linux backports-6.1.24
Browse files Browse the repository at this point in the history
  • Loading branch information
lawrencetg committed Jun 10, 2023
1 parent 8baa8d1 commit 8d6ad42
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
From 3725851fc168414bb72b16335d75d9099e25206d Mon Sep 17 00:00:00 2001
From: Jensen Huang <jensenhuang@friendlyarm.com>
Date: Fri, 9 Jun 2023 16:36:57 +0800
Subject: [PATCH] rtw89: Add support for linux backports-6.1.24

Signed-off-by: Jensen Huang <jensenhuang@friendlyarm.com>
---
Makefile | 22 ++++++++++++++++++++++
core.h | 5 +++++
2 files changed, 27 insertions(+)

diff --git a/Makefile b/Makefile
index f1f40f0..c5b2d69 100644
--- a/Makefile
+++ b/Makefile
@@ -12,6 +12,28 @@ else
MODDESTDIR := /lib/modules/$(KVER)/kernel/drivers/net/wireless/rtw89
endif

+ifneq ($(BACKPORT_DIR),)
+include $(BACKPORT_DIR)/versions
+
+ifeq ($(BACKPORTED_LINUX_VERSION_CODE),)
+$(error "BACKPORTED_LINUX_VERSION_CODE is undefined")
+endif
+
+NOSTDINC_FLAGS += \
+ -I$(BACKPORT_DIR)/backport-include/ \
+ -I$(BACKPORT_DIR)/backport-include/uapi \
+ -I$(BACKPORT_DIR)/include/ \
+ -I$(BACKPORT_DIR)/include/uapi \
+ -include backport/backport.h \
+ $(call backport-cc-disable-warning, unused-but-set-variable) \
+ -DCPTCFG_VERSION=\"$(BACKPORTS_VERSION)\" \
+ -DCPTCFG_KERNEL_VERSION=\"$(BACKPORTED_KERNEL_VERSION)\" \
+ -DCPTCFG_KERNEL_NAME=\"$(BACKPORTED_KERNEL_NAME)\" \
+ -DCPTCFG_KERNEL_CODE=$(BACKPORTED_LINUX_VERSION_CODE)
+
+KBUILD_EXTRA_SYMBOLS += $(BACKPORT_DIR)/Module.symvers
+endif
+
#Handle the compression option for modules in 3.18+
ifneq ("","$(wildcard $(MODDESTDIR)/*.ko.gz)")
COMPRESS_GZIP := y
diff --git a/core.h b/core.h
index f932243..b433fe3 100644
--- a/core.h
+++ b/core.h
@@ -13,6 +13,11 @@
#include <net/mac80211.h>
#include <linux/version.h>

+#if defined(CPTCFG_KERNEL_CODE)
+#undef LINUX_VERSION_CODE
+#define LINUX_VERSION_CODE CPTCFG_KERNEL_CODE
+#endif
+
struct rtw89_dev;
struct rtw89_pci_info;

--
2.39.2

16 changes: 12 additions & 4 deletions scripts/wifi/add_rtl8852be.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
set -eu

top_path=$(pwd)
pushd kernel
kernel_ver=`make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 kernelrelease`
popd
Expand All @@ -9,8 +9,8 @@ modules_dir=$(readlink -f ./out/output_*_kmodules/lib/modules/${kernel_ver})
echo "please build kernel first."
exit 1
}
firmware_dir="$(pwd)/rtl8852be/lib/firmware/rtw89"
config_dir="$(pwd)/rtl8852be/etc/modules.d/"
firmware_dir="${top_path}/rtl8852be/lib/firmware/rtw89"
config_dir="${top_path}/rtl8852be/etc/modules.d/"
mkdir ${firmware_dir} ${config_dir} -p

# download firmware
Expand All @@ -26,7 +26,15 @@ git clone https://github.com/lwfinger/rtw89.git -b main
(cd rtw89 && {
git reset 38b8a48d04b8440266db6ea730e9b9cf84463981 --hard
export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64:$PATH
make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 -C ../kernel M=$(pwd)

if grep 'symbol:backport' ${modules_dir}/modules.symbols >/dev/null; then
# kernel with backports
git am ${top_path}/../scripts/wifi/0001-rtw89-Add-support-for-linux-backports-6.1.24.patch
make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 BACKPORT_DIR=${top_path}/out/backports -C ${top_path}/kernel M=$(pwd)
else
make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 -C ${top_path}/kernel M=$(pwd)
fi

cp *.ko ${modules_dir}/ -afv
})

Expand Down

0 comments on commit 8d6ad42

Please sign in to comment.