git: e8166d7f378b - main - LinuxKPI wlan drivers: update makefiles to not use WITH_
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 30 Mar 2026 04:05:22 UTC
The branch main has been updated by bz:
URL: https://cgit.FreeBSD.org/src/commit/?id=e8166d7f378bb449315aff535909c153f3e71daf
commit e8166d7f378bb449315aff535909c153f3e71daf
Author: Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2026-03-19 23:02:05 +0000
Commit: Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2026-03-30 03:53:51 +0000
LinuxKPI wlan drivers: update makefiles to not use WITH_
Up to now the LinuxKPI wlan drivers were using local variables starting
with a WITH_ prefix in their Makefiles.
That is likely to collide with other mechanisms like WITH_ and WITHOUT_
from src.conf.
Adjust the local variables to use a driver name prefix for now to control
what is built and what is not.
These variables are mainly for the time of development so we can
turn off/on a feature or bus attachment while working on it. Otherwise
they are there for documentation purposes. The only reason one would
change them locally would be if someone was to build a very custom
image and not want certain bits (e.g., USB support) being compiled into
the modules.
While here, try to harmonize some parts of the Makefiles.
Suggested by: imp
Discussed with: imp
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D55977
---
sys/modules/ath10k/Makefile | 38 ++++++++--------
sys/modules/ath11k/Makefile | 12 ++++-
sys/modules/ath12k/Makefile | 8 +++-
sys/modules/athk_common/Makefile | 13 +++---
sys/modules/brcm80211/brcmfmac/Makefile | 80 ++++++++++++++++++---------------
sys/modules/brcm80211/brcmutil/Makefile | 16 +++----
sys/modules/iwlwifi/Makefile | 18 ++++----
sys/modules/mt76/Makefile | 6 +++
sys/modules/mt76/Makefile.inc | 44 ++++++++++--------
sys/modules/mt76/core/Makefile | 34 +++++++-------
sys/modules/mt76/mt7615/Makefile | 23 ++++++----
sys/modules/mt76/mt7915/Makefile | 35 +++++++++------
sys/modules/mt76/mt7921/Makefile | 36 ++++++++-------
sys/modules/mt76/mt7925/Makefile | 24 +++++-----
sys/modules/mt76/mt7996/Makefile | 31 ++++++++-----
sys/modules/rtw88/Makefile | 58 ++++++++++++------------
sys/modules/rtw89/Makefile | 57 +++++++++++------------
17 files changed, 300 insertions(+), 233 deletions(-)
diff --git a/sys/modules/ath10k/Makefile b/sys/modules/ath10k/Makefile
index 16f481116357..2ffa8532ff47 100644
--- a/sys/modules/ath10k/Makefile
+++ b/sys/modules/ath10k/Makefile
@@ -3,11 +3,11 @@ DEVATH10KDIR= ${SRCTOP}/sys/contrib/dev/athk/ath10k
.PATH: ${DEVATH10KDIR}
# Bus attachments.
-WITH_PCI= 1
-WITH_USB= 0 # Never finished upstream, not working.
+ATH10K_PCI= 1
+ATH10K_USB= 0 # Currently not working again, upstream kaputt.
-WITH_CONFIG_FWLOG= 1
-WITH_LEDS= 0
+ATH10K_CONFIG_FWLOG= 1
+ATH10K_LEDS= 0
KMOD= if_ath10k
@@ -17,31 +17,32 @@ SRCS+= txrx.c wmi.c wmi-tlv.c
SRCS+= p2p.c swap.c
# PCI parts; PCI needs to be compiled into the kernel and cannot be loaded.
-.if defined(WITH_PCI) && ${WITH_PCI} > 0 && ${KERN_OPTS:MDEV_PCI}
+.if defined(ATH10K_PCI) && ${ATH10K_PCI} > 0 && ${KERN_OPTS:MDEV_PCI}
SRCS+= pci.c
.endif
# USB parts; USB can be loaded and is unconditional on any kernel config.
-.if defined(WITH_USB) && ${WITH_USB} > 0
+.if defined(ATH10K_USB) && ${ATH10K_USB} > 0
SRCS+= usb.c
.endif
-# Other
-SRCS+= ${LINUXKPI_GENSRCS}
-SRCS+= opt_wlan.h opt_inet6.h opt_inet.h opt_acpi.h
-
-.if defined(WITH_CONFIG_FWLOG) && ${WITH_CONFIG_FWLOG} > 0
+.if defined(ATH10K_CONFIG_FWLOG) && ${ATH10K_CONFIG_FWLOG} > 0
SRCS+= fwlog.c
-CFLAGS+= -DCONFIG_FWLOG=${WITH_CONFIG_FWLOG}
+CFLAGS+= -DCONFIG_FWLOG
.endif
-.if defined(WITH_LEDS) && ${WITH_LEDS} > 0
+.if defined(ATH10K_LEDS) && ${ATH10K_LEDS} > 0
CFLAGS+= -DCONFIG_ATH10K_LEDS
SRCS+= leds.c
.endif
-CFLAGS+= -DKBUILD_MODNAME='"ath10k"'
-CFLAGS+= -DLINUXKPI_VERSION=61900
+# Always on for now.
+CFLAGS+= -DCONFIG_ATH10K_DEBUG
+CFLAGS+= -DLINUXKPI_WANT_LINUX_ACPI
+
+# Other
+SRCS+= ${LINUXKPI_GENSRCS}
+SRCS+= opt_wlan.h opt_inet6.h opt_inet.h opt_acpi.h
CFLAGS+= -I${DEVATH10KDIR}
CFLAGS+= -I${DEVATH10KDIR}/..
@@ -49,9 +50,7 @@ CFLAGS+= ${LINUXKPI_INCLUDES}
# Helpful after fresh imports.
#CFLAGS+= -ferror-limit=0
-CFLAGS+= -DCONFIG_ATH10K_DEBUG
-CFLAGS+= -DLINUXKPI_WANT_LINUX_ACPI
-
+# TODO: further options and SRCS files.
#CFLAGS+= -DCONFIG_ATH10K_AHB
#CFLAGS+= -DCONFIG_ATH10K_DEBUGFS
#CFLAGS+= -DCONFIG_ATH10K_DFS_CERTIFIED
@@ -65,4 +64,7 @@ CFLAGS+= -DLINUXKPI_WANT_LINUX_ACPI
#CFLAGS+= -DCONFIG_PM_SLEEP
#CFLAGS+= -DCONFIG_THERMAL
+CFLAGS+= -DKBUILD_MODNAME='"ath10k"'
+CFLAGS+= -DLINUXKPI_VERSION=61900
+
.include <bsd.kmod.mk>
diff --git a/sys/modules/ath11k/Makefile b/sys/modules/ath11k/Makefile
index d17e76255802..b1eb2422cc3d 100644
--- a/sys/modules/ath11k/Makefile
+++ b/sys/modules/ath11k/Makefile
@@ -2,6 +2,9 @@ DEVATH11KDIR= ${SRCTOP}/sys/contrib/dev/athk/ath11k
.PATH: ${DEVATH11KDIR}
+ATH11K_PCI= 1
+ATH11K_AHB= 0
+
ATH11K_DEBUGFS= 0
ATH11K_TRACE= 0
ATH11K_THERMAL= 0
@@ -18,10 +21,15 @@ SRCS+= ce.c peer.c dbring.c hw.c pcic.c
SRCS+= fw.c p2p.c
# PCI
+.if defined(ATH11K_PCI) && ${ATH11K_PCI} > 0 && ${KERN_OPTS:MDEV_PCI}
SRCS+= mhi.c pci.c
+CFLAGS+= -DCONFIG_ATH11K_PCI
+.endif
-# AHB
-#SRCS+= ahb.c
+.if defined(ATH11K_AHB) && ${ATH11K_AHB} > 0
+SRCS+= ahb.c
+CFLAGS+= -DCONFIG_ATH11K_AHB
+.endif
.if defined(ATH11K_DEBUGFS) && ${ATH11K_DEBUGFS} > 0
SRCS+= debugfs.c debugfs_htt_stats.c debugfs_sta.c
diff --git a/sys/modules/ath12k/Makefile b/sys/modules/ath12k/Makefile
index ff61769bd99e..018504812995 100644
--- a/sys/modules/ath12k/Makefile
+++ b/sys/modules/ath12k/Makefile
@@ -2,8 +2,10 @@ DEVATH12KDIR= ${SRCTOP}/sys/contrib/dev/athk/ath12k
.PATH: ${DEVATH12KDIR}
-ATH12K_ACPI= 0
+ATH12K_PCI= 1
ATH12K_AHB= 0
+
+ATH12K_ACPI= 0
ATH12K_COREDUMP= 0
ATH12K_DEBUGFS= 0
ATH12K_PM= 0
@@ -16,7 +18,11 @@ SRCS+= wmi.c mac.c reg.c htc.c qmi.c
SRCS+= dp.c dp_tx.c dp_rx.c dp_mon.c debug.c
SRCS+= ce.c peer.c dbring.c hw.c fw.c p2p.c
+.if defined(ATH12K_PCI) && ${ATH12K_PCI} > 0 && ${KERN_OPTS:MDEV_PCI}
SRCS+= mhi.c pci.c
+.else
+.error ath12k requires PCI support compiled in at this point
+.endif
.if defined(ATH12K_AHB) && ${ATH12K_AHB} > 0
CFLAGS+= -DCONFIG_ATH12K_AHB
diff --git a/sys/modules/athk_common/Makefile b/sys/modules/athk_common/Makefile
index 5400cfa7723d..d058d19cbe80 100644
--- a/sys/modules/athk_common/Makefile
+++ b/sys/modules/athk_common/Makefile
@@ -4,19 +4,19 @@ DEVDIR= ${SRCTOP}/sys/contrib/dev/athk
KMOD= athk_common
-WITH_ATH_DEBUG= 1
-WITH_ATH_TRACEPOINTS= 0
+ATHK_COMMON_ATH_DEBUG= 1
+ATHK_COMMON_ATH_TRACEPOINTS= 0
SRCS= main.c
SRCS+= dfs_pattern_detector.c dfs_pri_detector.c
SRCS+= hw.c key.c regd.c
-.if defined(WITH_ATH_DEBUG) && ${WITH_ATH_DEBUG} > 0
+.if defined(ATHK_COMMON_ATH_DEBUG) && ${ATHK_COMMON_ATH_DEBUG} > 0
SRCS+= debug.c
CFLAGS+= -DCONFIG_ATH_DEBUG
.endif
-.if defined(WITH_ATH_TRACEPOINTS) && ${WITH_ATH_TRACEPOINTS} > 0
+.if defined(ATHK_COMMON_ATH_TRACEPOINTS) && ${ATHK_COMMON_ATH_TRACEPOINTS} > 0
SRCS+= trace.c
CFLAGS+= -DCONFIG_ATH_TRACEPOINTS
.endif
@@ -25,11 +25,12 @@ CFLAGS+= -DCONFIG_ATH_TRACEPOINTS
SRCS+= ${LINUXKPI_GENSRCS}
SRCS+= opt_wlan.h opt_inet6.h opt_inet.h opt_acpi.h
-CFLAGS+= -DKBUILD_MODNAME='"athk_common"'
-
CFLAGS+= -I${DEVDIR}
CFLAGS+= ${LINUXKPI_INCLUDES}
# Helpful after fresh imports.
#CFLAGS+= -ferror-limit=0
+CFLAGS+= -DKBUILD_MODNAME='"athk_common"'
+CFLAGS+= -DLINUXKPI_VERSION=61900
+
.include <bsd.kmod.mk>
diff --git a/sys/modules/brcm80211/brcmfmac/Makefile b/sys/modules/brcm80211/brcmfmac/Makefile
index b0c4d75a3d17..107914c2dc27 100644
--- a/sys/modules/brcm80211/brcmfmac/Makefile
+++ b/sys/modules/brcm80211/brcmfmac/Makefile
@@ -3,14 +3,16 @@ DEVDIR= ${SRCTOP}/sys/contrib/dev/broadcom/brcm80211/brcmfmac
.PATH: ${DEVDIR}
# Should split this up into a core driver and 3 more
-WITH_PCI=1
-WITH_SDIO=0
-WITH_USB=0
+BRCMFMAC_PCI= 1
+BRCMFMAC_USB= 0
+BRCMFMAC_SDIO= 0
-WITH_DMI=0
-WITH_OF=0
-WITH_DEBUG=1
-WITH_TRACING=0 # ftrace probes; simple enough to change possibly; keep 0!
+BRCMFMAC_PROTO_BCDC= 0 # SDIO, USB -- do not set manually
+BRCMFMAC_DEBUG= 1
+BRCMFMAC_TRACING= 0 # ftrace probes; simple enough to change possibly; keep 0!
+BRCMFMAC_OF= 0
+BRCMFMAC_DMI= 0
+BRCMFMAC_ACPI= 0
KMOD= if_brcmfmac
@@ -21,46 +23,57 @@ SRCS+= fweh.c fwil.c fwvid.c p2p.c pno.c proto.c vendor.c xtlv.c
SRCS+= wcc/core.c cyw/core.c bca/core.c
# PCI parts; PCI needs to be compiled into the kernel and cannot be loaded.
-.if defined(WITH_PCI) && ${WITH_PCI} > 0 && ${KERN_OPTS:MDEV_PCI}
-SRCS+= pcie.c msgbuf.c commonring.c flowring.c
-CFLAGS+= -DCONFIG_BRCMFMAC_PCIE=1
+.if defined(BRCMFMAC_PCI) && ${BRCMFMAC_PCI} > 0 && ${KERN_OPTS:MDEV_PCI}
+SRCS+= pcie.c
+CFLAGS+= -DCONFIG_BRCMFMAC_PCIE
+SRCS+= msgbuf.c commonring.c flowring.c
+CFLAGS+= -DCONFIG_BRCMFMAC_PROTO_MSGBUF
.endif
# SDIO parts; SDIO depends on an MMCCAM kernel.
-.if defined(WITH_SDIO) && ${WITH_SDIO} > 0 && ${KERN_OPTS:MMMCCAM}
+.if defined(BRCMFMAC_SDIO) && ${BRCMFMAC_SDIO} > 0 && ${KERN_OPTS:MMMCCAM}
SRCS+= sdio.c bcmsdh.c
SRCS+= sdio_if.h
SRCS+= sdiodevs.h
-CFLAGS+= -DCONFIG_BRCMFMAC_SDIO=1
+CFLAGS+= -DCONFIG_BRCMFMAC_SDIO
+BRCMFMAC_PROTO_BCDC= 1
.endif
# USB parts; USB can be loaded and is unconditional on any kernel config.
-.if defined(WITH_USB) && ${WITH_USB} > 0
+.if defined(BRCMFMAC_USB) && ${BRCMFMAC_USB} > 0
SRCS+= usb.c
-CFLAGS+= -DCONFIG_BRCMFMAC_USB=1
+CFLAGS+= -DCONFIG_BRCMFMAC_USB
+BRCMFMAC_PROTO_BCDC= 1
.endif
-.if (defined(WITH_SDIO) && ${WITH_SDIO} > 0) || \
- (defined(WITH_USB) && ${WITH_USB} > 0)
-CFLAGS+= -DCONFIG_BRCMFMAC_PROTO_BCDC=1
+.if defined(BRCMFMAC_PROTO_BCDC) && ${BRCMFMAC_PROTO_BCDC} > 0
+CFLAGS+= -DCONFIG_BRCMFMAC_PROTO_BCDC
SRCS+= bcdc.c fwsignal.c
.endif
-.if defined(WITH_DMI) && ${WITH_DMI} > 0
-SRCS+= dmi.c
+.if defined(BRCMFMAC_DEBUG) && ${BRCMFMAC_DEBUG} > 0
+CFLAGS+= -DDEBUG -DCONFIG_BRCMDBG
+SRCS+= debug.c
.endif
-.if defined(WITH_OF) && ${WITH_OF} > 0
+.if defined(BRCMFMAC_TRACING) && ${BRCMFMAC_TRACING} > 0
+SRCS+= tracepoint.c
+CFLAGS+= -DCONFIG_BRCM_TRACING
+.endif
+
+.if defined(BRCMFMAC_OF) && ${BRCMFMAC_OF} > 0
SRCS+= of.c
+CFLAGS+= -DCONFIG_OF
.endif
-.if defined(WITH_DEBUG) && ${WITH_DEBUG} > 0
-CFLAGS+= -DDEBUG=${WITH_DEBUG}
-SRCS+= debug.c
+.if defined(BRCMFMAC_DMI) && ${BRCMFMAC_DMI} > 0
+SRCS+= dmi.c
+CFLAGS+= -DCONFIG_DMI
.endif
-.if defined(WITH_TRACING) && ${WITH_TRACING} > 0
-SRCS+= tracepoint.c
+.if defined(BRCMFMAC_ACPI) && ${BRCMFMAC_ACPI} > 0
+SRCS+= acpi.c
+CFLAGS+= -DCONFIG_ACPI
.endif
# Other
@@ -68,25 +81,18 @@ SRCS+= bus_if.h device_if.h pci_if.h vnode_if.h
SRCS+= ${LINUXKPI_GENSRCS}
SRCS+= opt_wlan.h opt_inet6.h opt_inet.h opt_acpi.h
-CFLAGS+= -DKBUILD_MODNAME='"brcmfmac"'
-CFLAGS+= -DLINUXKPI_VERSION=61700
-
CFLAGS+= -I${DEVDIR}
CFLAGS+= -I${DEVDIR}/../include
CFLAGS+= ${LINUXKPI_INCLUDES}
-CFLAGS+= -ferror-limit=0
-
-#CFLAGS+= -DCONFIG_BRCM_TRACING=${WITH_TRACING}
-CFLAGS+= -DCONFIG_BRCMFMAC_PROTO_MSGBUF=${WITH_PCI}
-CFLAGS+= -DCONFIG_BRCMDBG=${WITH_DEBUG}
-
-#CFLAGS+= -DCONFIG_DMI=${WITH_DMI}
-#CFLAGS+= -DCONFIG_OF=${WITH_OF}
+# Helpful after fresh imports.
+#CFLAGS+= -ferror-limit=0
#CFLAGS+= -DCONFIG_PM_SLEEP=
-#CFLAGS+= -DCONFIG_ACPI=0
#CFLAGS+= -DCONFIG_PM
#CFLAGS+= -DCONFIG_IPV6=0
+CFLAGS+= -DKBUILD_MODNAME='"brcmfmac"'
+CFLAGS+= -DLINUXKPI_VERSION=61900
+
.include <bsd.kmod.mk>
diff --git a/sys/modules/brcm80211/brcmutil/Makefile b/sys/modules/brcm80211/brcmutil/Makefile
index 3fc01f4894fd..7ef89be18bf9 100644
--- a/sys/modules/brcm80211/brcmutil/Makefile
+++ b/sys/modules/brcm80211/brcmutil/Makefile
@@ -2,27 +2,27 @@ DEVDIR= ${SRCTOP}/sys/contrib/dev/broadcom/brcm80211/brcmutil
.PATH: ${DEVDIR}
-WITH_DEBUG=1
+BRCMUTIL_DEBUG= 1
KMOD= brcmutil
SRCS= d11.c utils.c
+.if defined(BRCMUTIL_DEBUG) && ${BRCMUTIL_DEBUG} > 0
+CFLAGS+= -DDEBUG
+.endif
+
# Other
SRCS+= ${LINUXKPI_GENSRCS}
SRCS+= bus_if.h device_if.h pci_if.h vnode_if.h
SRCS+= opt_wlan.h opt_inet6.h opt_inet.h
-CFLAGS+= -DKBUILD_MODNAME='"brcmutil"'
-CFLAGS+= -DLINUXKPI_VERSION=61700
-
-.if defined(WITH_DEBUG) && ${WITH_DEBUG} > 0
-CFLAGS+= -DDEBUG=${WITH_DEBUG}
-.endif
-
CFLAGS+= -I${DEVDIR}
CFLAGS+= -I${DEVDIR}/../include
CFLAGS+= ${LINUXKPI_INCLUDES}
#CFLAGS+= -ferror-limit=0
+CFLAGS+= -DKBUILD_MODNAME='"brcmutil"'
+CFLAGS+= -DLINUXKPI_VERSION=61900
+
.include <bsd.kmod.mk>
diff --git a/sys/modules/iwlwifi/Makefile b/sys/modules/iwlwifi/Makefile
index b5441744d77a..399e35b79d61 100644
--- a/sys/modules/iwlwifi/Makefile
+++ b/sys/modules/iwlwifi/Makefile
@@ -4,10 +4,10 @@ DEVIWLWIFIDIR= ${SRCTOP}/sys/contrib/dev/iwlwifi
.PATH: ${DEVIWLWIFIDIR}
-WITH_CONFIG_PM= 0
-WITH_DEBUGFS= 0
+IWLWIFI_CONFIG_PM= 0
+IWLWIFI_DEBUGFS= 0
.if ${KERN_OPTS:MDEV_ACPI}
-WITH_CONFIG_ACPI= 1
+IWLWIFI_CONFIG_ACPI= 1
.endif
KMOD= if_iwlwifi
@@ -49,21 +49,21 @@ SRCS+= mld/regulatory.c mld/roc.c mld/rx.c mld/scan.c
SRCS+= mld/session-protect.c mld/sta.c mld/stats.c mld/thermal.c
SRCS+= mld/time_sync.c mld/tlc.c mld/tx.c
-.if defined(WITH_DEBUGFS) && ${WITH_DEBUGFS} > 0
+.if defined(IWLWIFI_DEBUGFS) && ${IWLWIFI_DEBUGFS} > 0
SRCS+= fw/debugfs.c
SRCS+= mvm/debugfs.c mvm/debugfs-vif.c
SRCS+= mld/debugfs.c
CFLAGS+= -DCONFIG_IWLWIFI_DEBUGFS
CFLAGS+= -DCONFIG_MAC80211_DEBUGFS
.endif
-.if defined(WITH_CONFIG_PM) && ${WITH_CONFIG_PM} > 0
+.if defined(IWLWIFI_CONFIG_PM) && ${IWLWIFI_CONFIG_PM} > 0
SRCS+= mvm/d3.c
SRCS+= mld/d3.c
CFLAGS+= -DCONFIG_PM
CFLAGS+= -DCONFIG_PM_SLEEP
.endif
-.if defined(WITH_CONFIG_ACPI) && ${WITH_CONFIG_ACPI} > 0
+.if defined(IWLWIFI_CONFIG_ACPI) && ${IWLWIFI_CONFIG_ACPI} > 0
SRCS.DEV_ACPI+= fw/acpi.c
CFLAGS+= -DCONFIG_ACPI
.endif
@@ -74,9 +74,6 @@ CFLAGS+= -DLINUXKPI_WANT_LINUX_ACPI
SRCS+= ${LINUXKPI_GENSRCS}
SRCS+= opt_wlan.h opt_inet6.h opt_inet.h opt_acpi.h
-CFLAGS+= -DKBUILD_MODNAME='"iwlwifi"'
-CFLAGS+= -DLINUXKPI_VERSION=61700
-
CFLAGS+= -I${DEVIWLWIFIDIR}
CFLAGS+= ${LINUXKPI_INCLUDES}
CFLAGS+= -DCONFIG_IWLDVM=0
@@ -96,6 +93,9 @@ CFLAGS+= -DCONFIG_IWLWIFI_DEVICE_TRACING=1
#CFLAGS+= -DCONFIG_THERMAL=1
#CFLAGS+= -DCONFIG_EFI=1
+CFLAGS+= -DKBUILD_MODNAME='"iwlwifi"'
+CFLAGS+= -DLINUXKPI_VERSION=61900
+
CWARNFLAGS.clang.drv.c+= -Wno-initializer-overrides
CWARNFLAGS.drv.c+= -Wno-override-init ${CWARNFLAGS.${COMPILER_TYPE}.${.IMPSRC:T}}
diff --git a/sys/modules/mt76/Makefile b/sys/modules/mt76/Makefile
index 5abae4c5ad7c..726f7759e9be 100644
--- a/sys/modules/mt76/Makefile
+++ b/sys/modules/mt76/Makefile
@@ -1,8 +1,14 @@
+.include <kmod.opts.mk>
+
SUBDIR= core
SUBDIR+= mt7615
+.if ${KERN_OPTS:MDEV_PCI}
SUBDIR+= mt7915
+.endif
SUBDIR+= mt7921
SUBDIR+= mt7925
+.if ${KERN_OPTS:MDEV_PCI}
SUBDIR+= mt7996
+.endif
.include <bsd.subdir.mk>
diff --git a/sys/modules/mt76/Makefile.inc b/sys/modules/mt76/Makefile.inc
index 41b18651e985..b44dcd2e2e82 100644
--- a/sys/modules/mt76/Makefile.inc
+++ b/sys/modules/mt76/Makefile.inc
@@ -1,16 +1,21 @@
# Common information shared by all submodule builds.
COMMONDIR= ${SRCTOP}/sys/contrib/dev/mediatek/mt76
+DEVDIR= ${SRCTOP}/sys/contrib/dev/mediatek/mt76/${MT76_DRIVER_NAME}
-# Bus attachments.
-WITH_PCI= 1
-WITH_USB= 0
-WITH_SDIO= 0
+KMOD?= if_${MT76_DRIVER_NAME}
-# Options.
-WITH_CONFIG_PM= 0
-WITH_DEBUGFS= 0
-WITH_SOC_WED= 0
+# Bus attachment for the core part and that each driver can check
+# what the common code supports.
+MT76_PCI= 1
+MT76_SDIO= 0
+MT76_USB= 0
+
+# General options for common code so drivers can check.
+MT76_ACPI?= 0
+MT76_CONFIG_PM?= 0
+MT76_DEBUGFS?= 0
+MT76_SOC_WED?= 0
# Other
SRCS+= ${LINUXKPI_GENSRCS}
@@ -19,23 +24,26 @@ SRCS+= opt_wlan.h opt_inet6.h opt_inet.h
# This is true for all architectures we build for.
CFLAGS+= -DCONFIG_ARCH_DMA_ADDR_T_64BIT
-# Helpful after fresh imports.
-#CFLAGS+= -ferror-limit=0
-
-.if defined(WITH_CONFIG_PM) && ${WITH_CONFIG_PM} > 0
-CFLAGS+= -DCONFIG_PM=${WITH_CONFIG_PM}
+.if defined(MT76_CONFIG_PM) && ${MT76_CONFIG_PM} > 0
+CFLAGS+= -DCONFIG_PM
.endif
-.if defined(WITH_DEBUGFS) && ${WITH_DEBUGFS} > 0
-CFLAGS+= -DCONFIG_MAC80211_DEBUGFS=${WITH_DEBUGFS}
+.if defined(MT76_DEBUGFS) && ${MT76_DEBUGFS} > 0
+CFLAGS+= -DCONFIG_MAC80211_DEBUGFS
.endif
-.if defined(WITH_SOC_WED) && ${WITH_SOC_WED} > 0
-CFLAGS+= CONFIG_NET_MEDIATEK_SOC_WED
+.if defined(MT76_SOC_WED) && ${MT76_SOC_WED} > 0
+CFLAGS+= -DCONFIG_NET_MEDIATEK_SOC_WED
.endif
CFLAGS+= -I${COMMONDIR}
+.if ${MT76_DRIVER_NAME} != "mt76_core"
+CFLAGS+= -I${DEVDIR}
+.endif
CFLAGS+= ${LINUXKPI_INCLUDES}
+# Helpful after fresh imports.
+#CFLAGS+= -ferror-limit=0
+
+CFLAGS+= -DKBUILD_MODNAME='"${MT76_DRIVER_NAME}"'
CFLAGS+= -DLINUXKPI_VERSION=61900
-# end
diff --git a/sys/modules/mt76/core/Makefile b/sys/modules/mt76/core/Makefile
index f2aec9dfcf4c..e4e65d8e3c24 100644
--- a/sys/modules/mt76/core/Makefile
+++ b/sys/modules/mt76/core/Makefile
@@ -1,25 +1,30 @@
+MT76_DRIVER_NAME= mt76_core
+
.include <kmod.opts.mk>
-.PATH: ${COMMONDIR}
+KMOD= ${MT76_DRIVER_NAME}
-KMOD= mt76_core
+.PATH: ${COMMONDIR}
# Basic stuff.
-SRCS= mac80211.c mmio.c util.c dma.c eeprom.c tx.c agg-rx.c mcu.c
+SRCS+= mac80211.c mmio.c util.c dma.c eeprom.c tx.c agg-rx.c mcu.c
SRCS+= channel.c scan.c wed.c
-#SRCS+= trace.c
-# Bus stuff.
# PCI parts; PCI needs to be compiled into the kernel and cannot be loaded.
-.if defined(WITH_PCI) && ${WITH_PCI} > 0 && ${KERN_OPTS:MDEV_PCI}
+.if defined(MT76_PCI) && ${MT76_PCI} > 0 && ${KERN_OPTS:MDEV_PCI}
SRCS+= pci.c
.endif
-.if defined(WITH_USB) && ${WITH_USB} > 0
-SRCS+= usb.c # usb_trace.c
+# SDIO parts; SDIO depends on an MMCCAM kernel.
+.if defined(MT76_SDIO) && ${MT76_SDIO} > 0 && ${KERN_OPTS:MMMCCAM}
+SRCS+= sdio.c sdio_txrx.c
.endif
-#SRCS+= sdio.c sdio_txrx.c
+# USB parts; USB can be loaded and is unconditional on any kernel config.
+.if defined(MT76_USB) && ${MT76_USB} > 0
+SRCS+= usb.c
+#SRCS+= usb_trace.c
+.endif
# Connac-Lib stuff.
SRCS+= mt76_connac_mac.c mt76_connac_mcu.c mt76_connac3_mac.c
@@ -30,22 +35,21 @@ SRCS+= mt76_connac_mac.c mt76_connac_mcu.c mt76_connac3_mac.c
# MT792X-LIB stuff.
SRCS+= mt792x_core.c mt792x_mac.c mt792x_dma.c
#SRCS+= mt792x_trace.c
-.if defined(WITH_ACPI) && ${WITH_ACPI} > 0
+.if defined(MT76_ACPI) && ${MT76_ACPI} > 0
SRCS+= mt792x_acpi_sar.c
.endif
-.if defined(WITH_USB) && ${WITH_USB} > 0
+.if defined(MT76_USB) && ${MT76_USB} > 0
SRCS+= mt792x_usb.c
.endif
-.if defined(WITH_DEBUGFS) && ${WITH_DEBUGFS} > 0
+.if defined(MT76_DEBUGFS) && ${MT76_DEBUGFS} > 0
SRCS+= mt792x_debugfs.c
.endif
-.if defined(WITH_DEBUGFS) && ${WITH_DEBUGFS} > 0
+.if defined(MT76_DEBUGFS) && ${MT76_DEBUGFS} > 0
SRCS+= debugfs.c
.endif
-CFLAGS+= -DKBUILD_MODNAME='"mt76_core"'
-CFLAGS+= -DCONFIG_MAC80211_DEBUGFS=${WITH_DEBUGFS}
+#SRCS+= trace.c
EXPORT_SYMS= YES
diff --git a/sys/modules/mt76/mt7615/Makefile b/sys/modules/mt76/mt7615/Makefile
index 6d7cb945a32d..6eb650a8439a 100644
--- a/sys/modules/mt76/mt7615/Makefile
+++ b/sys/modules/mt76/mt7615/Makefile
@@ -1,26 +1,31 @@
-DEVDIR= ${SRCTOP}/sys/contrib/dev/mediatek/mt76/mt7615
+MT76_DRIVER_NAME= mt7615
+
+.include <kmod.opts.mk>
.PATH: ${DEVDIR}
-WITH_DEBUGFS= 0
-WITH_DEV_COREDUMP= 0
+MT7615_PCI= 1
-KMOD= if_mt7615
+MT7615_DEBUGFS= 0
+MT7615_DEV_COREDUMP= 0
# Common stuff.
-SRCS= init.c main.c mac.c mcu.c eeprom.c
+SRCS+= init.c main.c mac.c mcu.c eeprom.c
# PCIe (7622_WMAC ignored)
+.if defined(MT76_PCI) && ${MT76_PCI} > 0 && ${KERN_OPTS:MDEV_PCI} && \
+ defined(MT7615_PCI) && ${MT7615_PCI} > 0
SRCS+= dma.c mmio.c pci.c pci_init.c pci_mac.c
+.endif
# USB + SDIO ignored currently.
-.if defined(WITH_DEBUGFS) && ${WITH_DEBUGFS} > 0
+.if defined(MT7615_DEBUGFS) && ${MT7615_DEBUGFS} > 0
SRCS+= debugfs.c
-CFLAGS+= -DCONFIG_MT7915_DEBUGFS=${WITH_DEBUGFS}
+CFLAGS+= -DCONFIG_MT7915_DEBUGFS
.endif
-CFLAGS+= -DKBUILD_MODNAME='"mt7615"'
-CFLAGS+= -I${DEVDIR}
+.if defined(MT7615_DEV_COREDUMP) && ${MT7615_DEV_COREDUMP} > 0
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/mt76/mt7915/Makefile b/sys/modules/mt76/mt7915/Makefile
index 049c919949f6..580fde3b7aa7 100644
--- a/sys/modules/mt76/mt7915/Makefile
+++ b/sys/modules/mt76/mt7915/Makefile
@@ -1,30 +1,37 @@
-DEVDIR= ${SRCTOP}/sys/contrib/dev/mediatek/mt76/mt7915
+MT76_DRIVER_NAME= mt7915
+
+.include <kmod.opts.mk>
.PATH: ${DEVDIR}
-WITH_DEBUGFS= 0
-WITH_DEV_COREDUMP= 1
+MT7915_PCI= 1
+
+MT7915_WMAC= 0
+MT7915_DEBUGFS= 0
+MT7915_DEV_COREDUMP= 1
-KMOD= if_mt7915
+SRCS+= init.c main.c mac.c mcu.c mmio.c eeprom.c
-# Common stuff.
-SRCS= init.c main.c mac.c mcu.c mmio.c eeprom.c
+# PCI only driver so it better be there (otherwise nothing will attach at least).
+.if defined(MT76_PCI) && ${MT76_PCI} > 0 && ${KERN_OPTS:MDEV_PCI} && \
+ defined(MT7915_PCI) && ${MT7915_PCI} > 0
SRCS+= pci.c dma.c
+.endif
# SOC+6E stuff.
-#SRCS+= soc.c
+.if defined(MT7915_WMAC) && ${MT7915_WMAC} > 0
+SRCS+= soc.c
+CFLAGS+= -DCONFIG_MT798X_WMAC
+.endif
-.if defined(WITH_DEBUGFS) && ${WITH_DEBUGFS} > 0
+.if defined(MT7915_DEBUGFS) && ${MT7915_DEBUGFS} > 0
SRCS+= debugfs.c
-CFLAGS+= -DCONFIG_MT7915_DEBUGFS=${WITH_DEBUGFS}
+CFLAGS+= -DCONFIG_MT7915_DEBUGFS
.endif
-.if defined(WITH_DEV_COREDUMP) && ${WITH_DEV_COREDUMP} > 0
+.if defined(MT7915_DEV_COREDUMP) && ${MT7915_DEV_COREDUMP} > 0
SRCS+= coredump.c
-CFLAGS+= -DCONFIG_DEV_COREDUMP=${WITH_DEV_COREDUMP}
+CFLAGS+= -DCONFIG_DEV_COREDUMP
.endif
-CFLAGS+= -DKBUILD_MODNAME='"mt7915"'
-CFLAGS+= -I${DEVDIR}
-
.include <bsd.kmod.mk>
diff --git a/sys/modules/mt76/mt7921/Makefile b/sys/modules/mt76/mt7921/Makefile
index 1b53df04357c..b6dbe88204a3 100644
--- a/sys/modules/mt76/mt7921/Makefile
+++ b/sys/modules/mt76/mt7921/Makefile
@@ -1,35 +1,39 @@
-.include <kmod.opts.mk>
+MT76_DRIVER_NAME= mt7921
-DEVDIR= ${SRCTOP}/sys/contrib/dev/mediatek/mt76/mt7921
+.include <kmod.opts.mk>
.PATH: ${DEVDIR}
-KMOD= if_mt7921
+MT7921_PCI= 1
+MT7921_SDIO= 0
+MT7921_USB= 0
+
+MT7921_DEBUGFS= 0
# Common stuff.
-SRCS= init.c main.c mac.c mcu.c
+SRCS+= init.c main.c mac.c mcu.c
# PCI parts; PCI needs to be compiled into the kernel and cannot be loaded.
-.if defined(WITH_PCI) && ${WITH_PCI} > 0 && ${KERN_OPTS:MDEV_PCI}
+.if defined(MT76_PCI) && ${MT76_PCI} > 0 && ${KERN_OPTS:MDEV_PCI} && \
+ defined(MT7921_PCI) && ${MT7921_PCI} > 0
SRCS+= pci.c pci_mac.c pci_mcu.c
.endif
-# USB parts; USB can be loaded and is unconditional on any kernel config.
-.if defined(WITH_USB) && ${WITH_USB} > 0
-SRCS+= usb.c
-.endif
-
# SDIO parts; SDIO depends on an MMCCAM kernel.
-.if defined(WITH_SDIO) && ${WITH_SDIO} > 0 && ${KERN_OPTS:MMMCCAM}
+.if defined(MT76_SDIO) && ${MT76_SDIO} > 0 && ${KERN_OPTS:MMMCCAM} && \
+ defined(MT7921_SDIO) && ${MT7921_SDIO} > 0
SRCS+= sdio.c sdio_mac.c sdio_mcu.c
.endif
-.if defined(WITH_DEBUGFS) && ${WITH_DEBUGFS} > 0
-SRCS+= debugfs.c
-CFLAGS+= -DCONFIG_MT7921_DEBUGFS=${WITH_DEBUGFS}
+# USB parts; USB can be loaded and is unconditional on any kernel config.
+.if defined(MT76_USB) && ${MT76_USB} > 0 && \
+ defined(MT7921_USB) && ${MT7921_USB} > 0
+SRCS+= usb.c
.endif
-CFLAGS+= -DKBUILD_MODNAME='"mt7921"'
-CFLAGS+= -I${DEVDIR}
+.if defined(MT7921_DEBUGFS) && ${MT7921_DEBUGFS} > 0
+SRCS+= debugfs.c
+CFLAGS+= -DCONFIG_MT7921_DEBUGFS
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/mt76/mt7925/Makefile b/sys/modules/mt76/mt7925/Makefile
index ee79f09dba1c..c8477eadd7f5 100644
--- a/sys/modules/mt76/mt7925/Makefile
+++ b/sys/modules/mt76/mt7925/Makefile
@@ -1,30 +1,32 @@
-.include <kmod.opts.mk>
+MT76_DRIVER_NAME= mt7925
-DEVDIR= ${SRCTOP}/sys/contrib/dev/mediatek/mt76/mt7925
+.include <kmod.opts.mk>
.PATH: ${DEVDIR}
-KMOD= if_mt7925
+MT7925_PCI= 1
+MT7925_USB= 1
+
+MT7925_DEBUGFS= 0
# Common stuff.
-SRCS= init.c main.c mac.c mcu.c regd.c
+SRCS+= init.c main.c mac.c mcu.c regd.c
# PCI parts; PCI needs to be compiled into the kernel and cannot be loaded.
-.if defined(WITH_PCI) && ${WITH_PCI} > 0 && ${KERN_OPTS:MDEV_PCI}
+.if defined(MT76_PCI) && ${MT76_PCI} > 0 && ${KERN_OPTS:MDEV_PCI} && \
+ defined(MT7925_PCI) && ${MT7925_PCI} > 0
SRCS+= pci.c pci_mac.c pci_mcu.c
.endif
# USB parts; USB can be loaded and is unconditional on any kernel config.
-.if defined(WITH_USB) && ${WITH_USB} > 0
+.if defined(MT76_USB) && ${MT76_USB} > 0 && \
+ defined(MT7925_USB) && ${MT7925_USB} > 0
SRCS+= usb.c
.endif
-.if defined(WITH_DEBUGFS) && ${WITH_DEBUGFS} > 0
+.if defined(MT7925_DEBUGFS) && ${MT7925_DEBUGFS} > 0
SRCS+= debugfs.c
-CFLAGS+= -DCONFIG_MT7925_DEBUGFS=${WITH_DEBUGFS}
+CFLAGS+= -DCONFIG_MT7925_DEBUGFS
.endif
-CFLAGS+= -DKBUILD_MODNAME='"mt7925"'
-CFLAGS+= -I${DEVDIR}
-
.include <bsd.kmod.mk>
diff --git a/sys/modules/mt76/mt7996/Makefile b/sys/modules/mt76/mt7996/Makefile
index a43721b6079e..97de923c84ab 100644
--- a/sys/modules/mt76/mt7996/Makefile
+++ b/sys/modules/mt76/mt7996/Makefile
@@ -1,27 +1,36 @@
-DEVDIR= ${SRCTOP}/sys/contrib/dev/mediatek/mt76/mt7996
+MT76_DRIVER_NAME= mt7996
+
+.include <kmod.opts.mk>
.PATH: ${DEVDIR}
-WITH_DEBUGFS= 0
-WITH_DEV_COREDUMP= 1
+MT7996_PCI= 1
-KMOD= if_mt7996
+MT7996_DEBUGFS= 0
+MT7996_DEV_COREDUMP= 1
+MT7996_NPU= 0
# Common stuff.
-SRCS= init.c main.c mac.c mcu.c mmio.c eeprom.c
+SRCS+= init.c main.c mac.c mcu.c mmio.c eeprom.c
+# PCI only driver so it better be there (otherwise nothing will attach at least).
+.if defined(MT76_PCI) && ${MT76_PCI} > 0 && ${KERN_OPTS:MDEV_PCI} && \
+ defined(MT7996_PCI) && ${MT7996_PCI} > 0
SRCS+= pci.c dma.c
+.endif
-.if defined(WITH_DEBUGFS) && ${WITH_DEBUGFS} > 0
+.if defined(MT7996_DEBUGFS) && ${MT7996_DEBUGFS} > 0
SRCS+= debugfs.c
-CFLAGS+= -DCONFIG_MT7996_DEBUGFS=${WITH_DEBUGFS}
+CFLAGS+= -DCONFIG_MT7996_DEBUGFS
.endif
-.if defined(WITH_DEV_COREDUMP) && ${WITH_DEV_COREDUMP} > 0
+.if defined(MT7996_DEV_COREDUMP) && ${MT7996_DEV_COREDUMP} > 0
SRCS+= coredump.c
-CFLAGS+= -DCONFIG_DEV_COREDUMP=${WITH_DEV_COREDUMP}
+CFLAGS+= -DCONFIG_DEV_COREDUMP
.endif
-CFLAGS+= -DKBUILD_MODNAME='"mt7996"'
-CFLAGS+= -I${DEVDIR}
+.if defined(MT7996_NPU) && ${MT7996_NPU} > 0
+SRCS+= npu.c
+CFLAGS+= -DCONFIG_MT7996_NPU
+.endif
.include <bsd.kmod.mk>
diff --git a/sys/modules/rtw88/Makefile b/sys/modules/rtw88/Makefile
index 2347093db1a5..04000dd66e95 100644
--- a/sys/modules/rtw88/Makefile
+++ b/sys/modules/rtw88/Makefile
@@ -5,14 +5,14 @@ DEVRTW88DIR= ${SRCTOP}/sys/contrib/dev/rtw88
.PATH: ${DEVRTW88DIR}
# Bus attachments.
-WITH_PCI= 1
-WITH_USB= 0
-WITH_SDIO= 0
+RTW88_PCI= 1
+RTW88_SDIO= 0
+RTW88_USB= 0
# Options.
-WITH_CONFIG_PM= 0
-WITH_DEBUGFS= 1
-WITH_LEDS= 0
+RTW88_CONFIG_PM= 0
+RTW88_DEBUGFS= 1
+RTW88_LEDS= 0
KMOD= if_rtw88
@@ -22,11 +22,6 @@ SRCS+= bf.c coex.c debug.c efuse.c fw.c mac.c mac80211.c
SRCS+= phy.c ps.c regd.c
SRCS+= rx.c sar.c sec.c tx.c util.c
-.if defined(WITH_CONFIG_PM) && ${WITH_CONFIG_PM} > 0
-SRCS+= wow.c
-CFLAGS+= -DCONFIG_PM=${WITH_CONFIG_PM}
-.endif
-
# Common
SRCS+= rtw8723x.c # 87x3 common
SRCS+= rtw8703b.c rtw8703b_tables.c # 11n
@@ -37,7 +32,7 @@ SRCS+= rtw8822b.c rtw8822b_table.c # 11ac
SRCS+= rtw8822c.c rtw8822c_table.c # 11ac
# PCI parts; PCI needs to be compiled into the kernel and cannot be loaded.
-.if defined(WITH_PCI) && ${WITH_PCI} > 0 && ${KERN_OPTS:MDEV_PCI}
+.if defined(RTW88_PCI) && ${RTW88_PCI} > 0 && ${KERN_OPTS:MDEV_PCI}
SRCS+= pci.c
SRCS+= rtw8723de.c
SRCS+= rtw8814ae.c
@@ -46,8 +41,17 @@ SRCS+= rtw8822be.c
SRCS+= rtw8822ce.c
.endif
+# SDIO parts; SDIO depends on an MMCCAM kernel.
+.if defined(RTW88_SDIO) && ${RTW88_SDIO} > 0 && ${KERN_OPTS:MMMCCAM}
+SRCS+= rtw8723cs.c
+SRCS+= rtw8723ds.c
+SRCS+= rtw8821cs.c
+SRCS+= rtw8822bs.c
+SRCS+= rtw8822cs.c
+.endif
+
# USB parts; USB can be loaded and is unconditional on any kernel config.
-.if defined(WITH_USB) && ${WITH_USB} > 0
+.if defined(RTW88_USB) && ${RTW88_USB} > 0
SRCS+= usb.c
SRCS+= rtw8723du.c
SRCS+= rtw88xxa.c # 88xxa common
@@ -57,41 +61,35 @@ SRCS+= rtw8821a.c rtw8821a_table.c rtw8821au.c
SRCS+= rtw8821cu.c
SRCS+= rtw8822bu.c
SRCS+= rtw8822cu.c
-
CFLAGS+= -DCONFIG_RTW88_USB
.endif
-# SDIO parts; SDIO depends on an MMCCAM kernel.
-.if defined(WITH_SDIO) && ${WITH_SDIO} > 0 && ${KERN_OPTS:MMMCCAM}
-SRCS+= rtw8723cs.c
-SRCS+= rtw8723ds.c
-SRCS+= rtw8821cs.c
-SRCS+= rtw8822bs.c
-SRCS+= rtw8822cs.c
+.if defined(RTW88_CONFIG_PM) && ${RTW88_CONFIG_PM} > 0
+SRCS+= wow.c
+CFLAGS+= -DCONFIG_PM=${RTW88_CONFIG_PM}
.endif
-.if defined(WITH_LEDS) && ${WITH_LEDS} > 0
-CFLAGS+= -DCONFIG_RTW88_LEDS
*** 133 LINES SKIPPED ***