misc: imx: S400_API: Move S400 MU and API to a common place

Since iMX9 uses S401 which shares the API with iMX8ULP. So move S400
MU driver and API to a common place and selected by CONFIG_IMX_SENTINEL

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index e839c08..a6da6e2 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -350,6 +350,13 @@
 	  To compile this driver as a module, choose M here: the module
 	  will be called npcm_otp.
 
+config IMX_SENTINEL
+	bool "Enable i.MX Sentinel MU driver and API"
+	depends on MISC && (ARCH_IMX9 || ARCH_IMX8ULP)
+	help
+	  If you say Y here to enable Message Unit driver to work with
+	  Sentinel core on some NXP i.MX processors.
+
 config NUVOTON_NCT6102D
 	bool "Enable Nuvoton NCT6102D Super I/O driver"
 	help
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 022e54e..31d639b 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -50,6 +50,8 @@
 obj-$(CONFIG_IHS_FPGA) += ihs_fpga.o
 obj-$(CONFIG_IMX8) += imx8/
 obj-$(CONFIG_IMX8ULP) += imx8ulp/
+obj-$(CONFIG_IMX8ULP) += imx8ulp/
+obj-$(CONFIG_IMX_SENTINEL) += sentinel/
 obj-$(CONFIG_LED_STATUS) += status_led.o
 obj-$(CONFIG_LED_STATUS_GPIO) += gpio_led.o
 obj-$(CONFIG_MPC83XX_SERDES) += mpc83xx_serdes.o
diff --git a/drivers/misc/imx8ulp/Makefile b/drivers/misc/imx8ulp/Makefile
index 927cc55..450e615 100644
--- a/drivers/misc/imx8ulp/Makefile
+++ b/drivers/misc/imx8ulp/Makefile
@@ -1,4 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0+
 
-obj-y += s400_api.o imx8ulp_mu.o
 obj-$(CONFIG_CMD_FUSE) += fuse.o
diff --git a/drivers/misc/imx8ulp/fuse.c b/drivers/misc/imx8ulp/fuse.c
index 090e702..83d2c25 100644
--- a/drivers/misc/imx8ulp/fuse.c
+++ b/drivers/misc/imx8ulp/fuse.c
@@ -10,7 +10,7 @@
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/imx-regs.h>
 #include <env.h>
-#include <asm/arch/s400_api.h>
+#include <asm/mach-imx/s400_api.h>
 #include <asm/global_data.h>
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/drivers/misc/sentinel/Makefile b/drivers/misc/sentinel/Makefile
new file mode 100644
index 0000000..3e2f623
--- /dev/null
+++ b/drivers/misc/sentinel/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-y += s400_api.o s4mu.o
diff --git a/drivers/misc/imx8ulp/s400_api.c b/drivers/misc/sentinel/s400_api.c
similarity index 98%
rename from drivers/misc/imx8ulp/s400_api.c
rename to drivers/misc/sentinel/s400_api.c
index 87f5880..3d791bc 100644
--- a/drivers/misc/imx8ulp/s400_api.c
+++ b/drivers/misc/sentinel/s400_api.c
@@ -9,7 +9,7 @@
 #include <malloc.h>
 #include <asm/io.h>
 #include <dm.h>
-#include <asm/arch/s400_api.h>
+#include <asm/mach-imx/s400_api.h>
 #include <misc.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -275,8 +275,8 @@
 int ahab_get_fw_version(u32 *fw_version, u32 *sha1, u32 *response)
 {
 	struct udevice *dev = gd->arch.s400_dev;
-	int size = sizeof(struct imx8ulp_s400_msg);
-	struct imx8ulp_s400_msg msg;
+	int size = sizeof(struct sentinel_msg);
+	struct sentinel_msg msg;
 	int ret;
 
 	if (!dev) {
diff --git a/drivers/misc/imx8ulp/imx8ulp_mu.c b/drivers/misc/sentinel/s4mu.c
similarity index 97%
rename from drivers/misc/imx8ulp/imx8ulp_mu.c
rename to drivers/misc/sentinel/s4mu.c
index 333ebdf..121a810 100644
--- a/drivers/misc/imx8ulp/imx8ulp_mu.c
+++ b/drivers/misc/sentinel/s4mu.c
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright 2020 NXP
+ * Copyright 2020-2022 NXP
  */
 
 #include <common.h>
@@ -9,7 +9,7 @@
 #include <dm/lists.h>
 #include <dm/root.h>
 #include <dm/device-internal.h>
-#include <asm/arch/s400_api.h>
+#include <asm/mach-imx/s400_api.h>
 #include <asm/arch/imx-regs.h>
 #include <linux/iopoll.h>
 #include <misc.h>