mbox: g12a: add m4 mbox driver [1/3]
authorShunzhou Jiang <shunzhou.jiang@amlogic.com>
Fri, 7 Dec 2018 08:45:05 +0000 (16:45 +0800)
committerTao Zeng <tao.zeng@amlogic.com>
Mon, 28 Oct 2019 01:39:10 +0000 (18:39 -0700)
PD#SWPL-12873

Problem:
add m4 mailbox driver

Solution:
add m4 mailbox driver

Verify:
test pass on sm1 skt

Change-Id: Ied77949482179014d9e695ffc606f2ac939c82ca
Signed-off-by: Shunzhou Jiang <shunzhou.jiang@amlogic.com>
drivers/amlogic/mailbox/meson_mhu.c
drivers/amlogic/mailbox/meson_mhu.h
drivers/amlogic/mailbox/scpi_protocol.c

index 45f48e7..f4e363c 100644 (file)
@@ -35,6 +35,8 @@
 #include "meson_mhu.h"
 
 struct device *the_scpi_device;
+u32 num_scp_chans;
+
 
 #define DRIVER_NAME            "meson_mhu"
 
@@ -59,15 +61,15 @@ struct device *the_scpi_device;
  * |  CPU_INTR_H_CLEAR  | 0x048 |  TX_CLEAR(H)  |
  * +--------------------+-------+---------------+
  */
-#define RX_OFFSET(chan)                (0x10 + (idx) * 0xc)
-#define RX_STATUS(chan)                (RX_OFFSET(chan) + 0x4)
-#define RX_SET(chan)                   RX_OFFSET(chan)
-#define RX_CLEAR(chan)         (RX_OFFSET(chan) + 0x8)
+#define RX_OFFSET(chan)     (0x10 + (chan) * 0xc)
+#define RX_STATUS(chan)     (RX_OFFSET(chan) + 0x4)
+#define RX_SET(chan)        RX_OFFSET(chan)
+#define RX_CLEAR(chan)      (RX_OFFSET(chan) + 0x8)
 
-#define TX_OFFSET(chan)                (0x34 + (idx) * 0xc)
-#define TX_STATUS(chan)                (TX_OFFSET(chan) + 0x4)
-#define TX_SET(chan)                   TX_OFFSET(chan)
-#define TX_CLEAR(chan)         (TX_OFFSET(chan) + 0x8)
+#define TX_OFFSET(chan)     (0x34 + (chan) * 0xc)
+#define TX_STATUS(chan)     (TX_OFFSET(chan) + 0x4)
+#define TX_SET(chan)        TX_OFFSET(chan)
+#define TX_CLEAR(chan)      (TX_OFFSET(chan) + 0x8)
 
 /*
  * +---------------+-------+----------------+
@@ -221,6 +223,11 @@ static int mhu_probe(struct platform_device *pdev)
        ctlr->dev = dev;
        platform_set_drvdata(pdev, ctlr);
 
+       num_scp_chans = 0;
+       of_property_read_u32(dev->of_node, "num-chans-to-scp", &num_scp_chans);
+       if (num_scp_chans == 0 || num_scp_chans > 2)
+               num_scp_chans = CHANNEL_MAX;
+
        l = devm_kzalloc(dev, sizeof(*l) * CHANNEL_MAX, GFP_KERNEL);
        if (!l)
                return -ENOMEM;
index 5303b7c..48f4df4 100644 (file)
@@ -31,3 +31,4 @@ struct mhu_data_buf {
 };
 
 extern struct device *the_scpi_device;
+extern u32 num_scp_chans;
index 7158f3f..f2185e5 100644 (file)
@@ -123,6 +123,8 @@ static int high_priority_cmds[] = {
        SCPI_CMD_INIT_DSP,
 };
 
+static int m4_cmds[] = {-1};
+
 static struct scpi_dvfs_info *scpi_opps[MAX_DVFS_DOMAINS];
 
 static int scpi_linux_errmap[SCPI_ERR_MAX] = {
@@ -140,11 +142,17 @@ static inline int scpi_to_linux_errno(int errno)
 
 static bool high_priority_chan_supported(int cmd)
 {
-       int idx;
-
-       for (idx = 0; idx < ARRAY_SIZE(high_priority_cmds); idx++)
-               if (cmd == high_priority_cmds[idx])
-                       return true;
+       unsigned int idx;
+
+       if (num_scp_chans == CHANNEL_MAX) {
+               for (idx = 0; idx < ARRAY_SIZE(high_priority_cmds); idx++)
+                       if (cmd == high_priority_cmds[idx])
+                               return true;
+       } else {
+               for (idx = 0; idx < ARRAY_SIZE(m4_cmds); idx++)
+                       if (cmd == m4_cmds[idx])
+                               return true;
+       }
        return false;
 }