git: 242cd60a0a67 - main - cgem: Support building as a loadable kernel module

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Sun, 03 Apr 2022 15:30:21 UTC
The branch main has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=242cd60a0a670ff7cc446436bedd129fbdce062c

commit 242cd60a0a670ff7cc446436bedd129fbdce062c
Author:     Milan Obuch <bsd@dino.sk>
AuthorDate: 2022-04-02 16:53:37 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2022-04-03 15:28:37 +0000

    cgem: Support building as a loadable kernel module
    
    For development, building a driver as kernel module is both convenient
    and a time saver (no need for reboot on some change, testing it requires
    just kldunload and kldload, a matter of seconds). For some special
    cases, it may be even desirable to postpone initializing the network
    interface after some action is done (loading a FPGA bitstream may be
    required for Zynq/ZynqMP based hardware as an example).
    
    Building is limited to ARM, ARM64 and RISC-V architectures (for Zynq,
    ZynqMP, PolarFire Soc based boards, and HiFive based boards are known to
    use CGEM at the moment).
    
    Reviewed by:    mhorne
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D34687
---
 sys/modules/Makefile         | 6 ++++++
 sys/modules/if_cgem/Makefile | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/sys/modules/Makefile b/sys/modules/Makefile
index 3731e9c1e453..944a76163748 100644
--- a/sys/modules/Makefile
+++ b/sys/modules/Makefile
@@ -147,6 +147,7 @@ SUBDIR=	\
 	${_ice_ddp} \
 	${_ida} \
 	if_bridge \
+	${_if_cgem} \
 	if_disc \
 	if_edsc \
 	${_if_enc} \
@@ -575,6 +576,11 @@ _ice_ddp=	ice_ddp
 .endif
 .endif
 
+.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "arm" || \
+	${MACHINE_CPUARCH} == "riscv"
+_if_cgem=	if_cgem
+.endif
+
 # These rely on 64bit atomics
 .if ${MACHINE_ARCH} != "powerpc" && ${MACHINE_ARCH} != "powerpcspe"
 _mps=		mps
diff --git a/sys/modules/if_cgem/Makefile b/sys/modules/if_cgem/Makefile
new file mode 100644
index 000000000000..5d552994449a
--- /dev/null
+++ b/sys/modules/if_cgem/Makefile
@@ -0,0 +1,7 @@
+.PATH: ${SRCTOP}/sys/dev/cadence
+
+KMOD=	if_cgem
+SRCS=	if_cgem.c
+SRCS+=	bus_if.h device_if.h miibus_if.h ofw_bus_if.h
+
+.include <bsd.kmod.mk>