From: Flora Fu <flora.fu@mediatek.com>
To: Matthias Brugger <matthias.bgg@gmail.com>,
Mark Brown <broonie@kernel.org>,
Sumit Semwal <sumit.semwal@linaro.org>
Cc: <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-mediatek@lists.infradead.org>,
<linux-media@vger.kernel.org>, <dri-devel@lists.freedesktop.org>,
<linaro-mm-sig@lists.linaro.org>,
Flora Fu <flora.fu@mediatek.com>, Yong Wu <yong.wu@mediatek.com>,
Pi-Cheng Chen <pi-cheng.chen@mediatek.com>
Subject: [RFC 06/13] soc: mediatek: apu: Add apu core driver
Date: Sat, 23 Oct 2021 19:14:02 +0800 [thread overview]
Message-ID: <20211023111409.30463-7-flora.fu@mediatek.com> (raw)
In-Reply-To: <20211023111409.30463-1-flora.fu@mediatek.com>
Add apu core driver.
The core driver will init the reset part of apu functions.
Signed-off-by: Flora Fu <flora.fu@mediatek.com>
---
drivers/soc/mediatek/Kconfig | 18 +++++
drivers/soc/mediatek/apusys/Makefile | 3 +
drivers/soc/mediatek/apusys/apu-core.c | 91 ++++++++++++++++++++++++++
drivers/soc/mediatek/apusys/apu-core.h | 11 ++++
4 files changed, 123 insertions(+)
create mode 100644 drivers/soc/mediatek/apusys/apu-core.c
create mode 100644 drivers/soc/mediatek/apusys/apu-core.h
diff --git a/drivers/soc/mediatek/Kconfig b/drivers/soc/mediatek/Kconfig
index d9bac2710494..074b0cf24c44 100644
--- a/drivers/soc/mediatek/Kconfig
+++ b/drivers/soc/mediatek/Kconfig
@@ -24,6 +24,24 @@ config MTK_APU_PM
APU power domain shall be enabled before accessing the
internal sub modules.
+config MTK_APU
+ tristate "MediaTek APUSYS Support"
+ select REGMAP
+ select MTK_APU_PM
+ select MTK_SCP
+ help
+ Say yes here to add support for the APU tinysys. The tinsys is
+ running on a micro processor in APU.
+ Its firmware is load and boot from Kernel side. Kernel and tinysys use
+ IPI to tx/rx messages.
+
+config MTK_APU_DEBUG
+ tristate "MediaTek APUSYS debug functions"
+ depends on MTK_APU
+ help
+ Say yes here to enalbe debug on APUSYS.
+ Disable it if you don't need them.
+
config MTK_CMDQ
tristate "MediaTek CMDQ Support"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/soc/mediatek/apusys/Makefile b/drivers/soc/mediatek/apusys/Makefile
index 8821c0f0b7b7..6b5249ec7064 100644
--- a/drivers/soc/mediatek/apusys/Makefile
+++ b/drivers/soc/mediatek/apusys/Makefile
@@ -1,2 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_MTK_APU_PM) += mtk-apu-pm.o
+
+obj-$(CONFIG_MTK_APU) += apu.o
+apu-objs += apu-core.o
diff --git a/drivers/soc/mediatek/apusys/apu-core.c b/drivers/soc/mediatek/apusys/apu-core.c
new file mode 100644
index 000000000000..c1db2394307f
--- /dev/null
+++ b/drivers/soc/mediatek/apusys/apu-core.c
@@ -0,0 +1,91 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ */
+
+#include <linux/debugfs.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+#include "apu-core.h"
+
+#define APUSYS_DEV_NAME "apusys"
+
+static struct apusys_core_info g_core_info;
+
+/*
+ * init function at other modulses
+ * call init function in order at apu.ko init stage
+ */
+static int (*apusys_init_func[])(struct apusys_core_info *) = {
+};
+
+/*
+ * exit function at other modulses
+ * call exit function in order at apu.ko exit stage
+ */
+static void (*apusys_exit_func[])(void) = {
+};
+
+static void create_dbg_root(void)
+{
+ g_core_info.dbg_root = debugfs_create_dir(APUSYS_DEV_NAME, NULL);
+
+ /* check dbg root create status */
+ if (IS_ERR_OR_NULL(g_core_info.dbg_root))
+ pr_info("failed to create debug dir.\n");
+}
+
+static void destroy_dbg_root(void)
+{
+ debugfs_remove_recursive(g_core_info.dbg_root);
+}
+
+static int __init apusys_init(void)
+{
+ int i, j, ret = 0;
+ int func_num = sizeof(apusys_init_func) / sizeof(int *);
+
+ /* init apusys_dev */
+ create_dbg_root();
+
+ /* call init func */
+ for (i = 0; i < func_num; i++) {
+ if (!apusys_init_func[i])
+ break;
+
+ ret = apusys_init_func[i](&g_core_info);
+ if (ret) {
+ pr_info("init function(%d) fail(%d)", i, ret);
+
+ /* exit device */
+ for (j = i - 1; j >= 0; j--)
+ apusys_exit_func[j]();
+
+ destroy_dbg_root();
+ break;
+ }
+ }
+
+ return 0;
+}
+
+static void __exit apusys_exit(void)
+{
+ int func_num = sizeof(apusys_exit_func) / sizeof(int *);
+ int i;
+
+ /* call release func */
+ for (i = 0; i < func_num; i++) {
+ if (!apusys_exit_func[i])
+ break;
+
+ apusys_exit_func[i]();
+ }
+
+ destroy_dbg_root();
+}
+
+module_init(apusys_init);
+module_exit(apusys_exit);
+MODULE_LICENSE("GPL");
diff --git a/drivers/soc/mediatek/apusys/apu-core.h b/drivers/soc/mediatek/apusys/apu-core.h
new file mode 100644
index 000000000000..bac730bbc7ea
--- /dev/null
+++ b/drivers/soc/mediatek/apusys/apu-core.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ */
+#ifndef APU_CORE_H
+#define APU_CORE_H
+
+struct apusys_core_info {
+ struct dentry *dbg_root;
+};
+#endif
--
2.18.0
next prev parent reply other threads:[~2021-10-23 11:15 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-23 11:13 [RFC 00/13] MediaTek MT8192 APU Flora Fu
2021-10-23 11:13 ` [RFC 01/13] dt-bindings: soc: mediatek: apusys: add mt8192 apu iommu bindings Flora Fu
2021-10-23 11:13 ` [RFC 02/13] dt-bindings: soc: mediatek: apusys: Add new document for APU power Flora Fu
2021-10-23 11:13 ` [RFC 03/13] dt-bindings: soc: mediatek: apusys: Add new document for APU tinysys Flora Fu
2021-10-23 11:14 ` [RFC 04/13] iommu/mediatek: Add APU iommu support Flora Fu
2021-10-26 15:17 ` AngeloGioacchino Del Regno
2021-10-23 11:14 ` [RFC 05/13] soc: mediatek: Add command for APU SMC call Flora Fu
2021-10-23 11:14 ` Flora Fu [this message]
2021-10-23 15:49 ` [RFC 06/13] soc: mediatek: apu: Add apu core driver Randy Dunlap
2021-10-26 15:17 ` AngeloGioacchino Del Regno
2021-10-23 11:14 ` [RFC 07/13] soc: mediatek: apu: Add apu power driver Flora Fu
2021-10-23 11:14 ` [RFC 08/13] soc: mediatek: apu: Add apusys rv driver Flora Fu
2021-10-26 15:21 ` AngeloGioacchino Del Regno
[not found] ` <0248142e6e0b55fe12f179e74b77375b386082ee.camel@mediatek.com>
2021-11-26 10:07 ` AngeloGioacchino Del Regno
2021-10-23 11:14 ` [RFC 09/13] soc: mediatek: apu: Add middleware driver Flora Fu
2021-10-23 11:14 ` [RFC 10/13] arm64: dts: mt8192: Add APU-IOMMU nodes Flora Fu
2021-10-23 11:14 ` [RFC 11/13] arm64: dts: mt8192: Add apu power nodes Flora Fu
2021-10-23 11:14 ` [RFC 12/13] arm64: dts: mt8192: Add apu tinysys Flora Fu
2021-10-26 15:18 ` AngeloGioacchino Del Regno
2021-10-23 11:14 ` [RFC 13/13] arm64: dts: mt8192: Add regulator for APU Flora Fu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211023111409.30463-7-flora.fu@mediatek.com \
--to=flora.fu@mediatek.com \
--cc=broonie@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=pi-cheng.chen@mediatek.com \
--cc=sumit.semwal@linaro.org \
--cc=yong.wu@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®