Build module with cmake

Change-Id: I294f6ad22881254a8b0fef45b875fe0e12c91e7a
diff --git a/mailbox/CMakeLists.txt b/mailbox/CMakeLists.txt
index b0da45c..ac91374 100644
--- a/mailbox/CMakeLists.txt
+++ b/mailbox/CMakeLists.txt
@@ -32,12 +32,28 @@
 # Depend on all h and c files
 file(GLOB_RECURSE SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c" "*.h")
 
+file(GLOB_RECURSE OBJ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c")
+list(TRANSFORM OBJ REPLACE "^(.*)[.]c" "\\1.o")
+list(TRANSFORM OBJ PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/)
+
 # Build the kernel module
 add_custom_target(mailbox-module ALL
-                  COMMAND ${CMAKE_MAKE_PROGRAM} -C ${KDIR}
-                  M=${CMAKE_CURRENT_SOURCE_DIR} CONFIG_ARM_MHU=m
+    COMMAND ${CMAKE_MAKE_PROGRAM} -C ${KDIR}
+                  M=${CMAKE_CURRENT_SOURCE_DIR} CONFIG_ARM_MHU_V2=m CONFIG_ARM_MHU=m
                   CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 modules
-                  BYPRODUCTS arm_mhu.ko
+                  BYPRODUCTS
+                  ${CMAKE_CURRENT_SOURCE_DIR}/arm_mhu.ko
+                  ${CMAKE_CURRENT_SOURCE_DIR}/arm_mhu.o
+                  ${CMAKE_CURRENT_SOURCE_DIR}/arm_mhu.mod.o
+                  ${CMAKE_CURRENT_SOURCE_DIR}/arm_mhu.mod.c
+                  ${CMAKE_CURRENT_SOURCE_DIR}/arm_mhu_v2.ko
+                  ${CMAKE_CURRENT_SOURCE_DIR}/arm_mhu_v2.o
+                  ${CMAKE_CURRENT_SOURCE_DIR}/arm_mhu_v2.mod.o
+                  ${CMAKE_CURRENT_SOURCE_DIR}/arm_mhu_v2.mod.c
+                  ${CMAKE_CURRENT_SOURCE_DIR}/modules.order
+                  ${CMAKE_CURRENT_SOURCE_DIR}/Module.symvers
+                  ${OBJ}
                   DEPENDS ${SOURCES} Kbuild Kconfig
-                  COMMENT "Building arm_mhu.ko"
+                  COMMENT "Building arm_mhu.ko arm_mhu_v2.ko"
                   VERBATIM)
+
diff --git a/mailbox/Kbuild b/mailbox/Kbuild
index 5aacdcb..7476fcb 100644
--- a/mailbox/Kbuild
+++ b/mailbox/Kbuild
@@ -18,4 +18,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 #
 
-obj-$(CONFIG_ARM_MHU) = arm_mhu.o
+obj-$(CONFIG_ARM_MHU) += arm_mhu.o
+
+obj-$(CONFIG_ARM_MHU_V2) += arm_mhu_v2.o
diff --git a/mailbox/Kconfig b/mailbox/Kconfig
index 9cfce3e..e7a9cba 100644
--- a/mailbox/Kconfig
+++ b/mailbox/Kconfig
@@ -1,5 +1,5 @@
 #
-# (C) COPYRIGHT 2020 ARM Limited. All rights reserved.
+# (C) COPYRIGHT 2020 Arm Limited. All rights reserved.
 #
 # This program is free software and is provided to you under the terms of the
 # GNU General Public License version 2 as published by the Free Software
@@ -19,11 +19,17 @@
 #
 
 config ARM_MHU
-        tristate "ARM MHU Mailbox"
+        tristate "Arm MHU Mailbox"
         depends on ARM_AMBA
         help
-          Say Y here if you want to build the ARM MHU controller driver.
+          Say Y here if you want to build the Arm MHU controller driver.
           The controller has support for two versions of the controller.
 	  One with 3 mailbox channels, the last of which can be
           used in Secure mode only and one with a single channel.
 
+config ARM_MHU_V2
+	tristate "Arm MHUv2 Mailbox"
+	depends on ARM_AMBA
+	help
+	  Say Y here if you want to build the Arm MHUv2 controller driver,
+	  which provides unidirectional mailboxes between processing elements.