To support CMDQ secure driver, move some reuseable definition to header.
- define: e.g. CMDQ_GCE_NUM_MAX, CMDQ_THR_BASE, CMDQ_THR_SIZE.
- struct: e.g. cmdq_thread, cmdq, cmdq_task.
- include: e.g. <linux/clk.h>.

Add "#include <linux/mailbox_controller.h>" for the function that takes
"struct mbox_chan * chan" as a parameter. That may occur a build error
if secure driver header includes the mtk-cmdq-mailbox.h.
- function: e.g. cmdq_get_shift_pa(struct mbox_chan *chan).

Signed-off-by: Jason-JH.Lin <jason-jh....@mediatek.com>
Signed-off-by: Hsiao Chien Sung <shawn.s...@mediatek.com>
---
 drivers/mailbox/mtk-cmdq-mailbox.c       | 30 ---------------------
 include/linux/mailbox/mtk-cmdq-mailbox.h | 33 ++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 30 deletions(-)

diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c 
b/drivers/mailbox/mtk-cmdq-mailbox.c
index 618023011d31..025e53549a45 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -3,7 +3,6 @@
 // Copyright (c) 2018 MediaTek Inc.
 
 #include <linux/bitops.h>
-#include <linux/clk.h>
 #include <linux/clk-provider.h>
 #include <linux/dma-mapping.h>
 #include <linux/errno.h>
@@ -22,13 +21,10 @@
 
 #define CMDQ_OP_CODE_MASK              (0xff << CMDQ_OP_CODE_SHIFT)
 #define CMDQ_NUM_CMD(t)                        (t->cmd_buf_size / 
CMDQ_INST_SIZE)
-#define CMDQ_GCE_NUM_MAX               (2)
 
 #define CMDQ_CURR_IRQ_STATUS           0x10
 #define CMDQ_SYNC_TOKEN_UPDATE         0x68
 #define CMDQ_THR_SLOT_CYCLES           0x30
-#define CMDQ_THR_BASE                  0x100
-#define CMDQ_THR_SIZE                  0x80
 #define CMDQ_THR_WARM_RESET            0x00
 #define CMDQ_THR_ENABLE_TASK           0x04
 #define CMDQ_THR_SUSPEND_TASK          0x08
@@ -59,32 +55,6 @@
 #define CMDQ_JUMP_BY_OFFSET            0x10000000
 #define CMDQ_JUMP_BY_PA                        0x10000001
 
-struct cmdq_thread {
-       struct mbox_chan        *chan;
-       void __iomem            *base;
-       struct list_head        task_busy_list;
-       u32                     priority;
-};
-
-struct cmdq_task {
-       struct cmdq             *cmdq;
-       struct list_head        list_entry;
-       dma_addr_t              pa_base;
-       struct cmdq_thread      *thread;
-       struct cmdq_pkt         *pkt; /* the packet sent from mailbox client */
-};
-
-struct cmdq {
-       struct mbox_controller  mbox;
-       void __iomem            *base;
-       int                     irq;
-       u32                     irq_mask;
-       const struct gce_plat   *pdata;
-       struct cmdq_thread      *thread;
-       struct clk_bulk_data    clocks[CMDQ_GCE_NUM_MAX];
-       bool                    suspended;
-};
-
 struct gce_plat {
        u32 thread_nr;
        u8 shift;
diff --git a/include/linux/mailbox/mtk-cmdq-mailbox.h 
b/include/linux/mailbox/mtk-cmdq-mailbox.h
index f78a08e7c6ed..43eae45a08c9 100644
--- a/include/linux/mailbox/mtk-cmdq-mailbox.h
+++ b/include/linux/mailbox/mtk-cmdq-mailbox.h
@@ -7,10 +7,17 @@
 #ifndef __MTK_CMDQ_MAILBOX_H__
 #define __MTK_CMDQ_MAILBOX_H__
 
+#include <linux/clk.h>
+#include <linux/mailbox_controller.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/types.h>
 
+#define CMDQ_GCE_NUM_MAX               2
+
+#define CMDQ_THR_BASE                  0x100
+#define CMDQ_THR_SIZE                  0x80
+
 #define CMDQ_INST_SIZE                 8 /* instruction is 64-bit */
 #define CMDQ_SUBSYS_SHIFT              16
 #define CMDQ_OP_CODE_SHIFT             24
@@ -79,6 +86,32 @@ struct cmdq_pkt {
        bool                    loop;
 };
 
+struct cmdq_thread {
+       struct mbox_chan        *chan;
+       void __iomem            *base;
+       struct list_head        task_busy_list;
+       u32                     priority;
+};
+
+struct cmdq {
+       struct mbox_controller  mbox;
+       void __iomem            *base;
+       int                     irq;
+       u32                     irq_mask;
+       const struct gce_plat   *pdata;
+       struct cmdq_thread      *thread;
+       struct clk_bulk_data    clocks[CMDQ_GCE_NUM_MAX];
+       bool                    suspended;
+};
+
+struct cmdq_task {
+       struct cmdq             *cmdq;
+       struct list_head        list_entry;
+       dma_addr_t              pa_base;
+       struct cmdq_thread      *thread;
+       struct cmdq_pkt         *pkt; /* the packet sent from mailbox client */
+};
+
 u8 cmdq_get_shift_pa(struct mbox_chan *chan);
 
 #endif /* __MTK_CMDQ_MAILBOX_H__ */
-- 
2.18.0

Reply via email to