From: Shunzhou Jiang Date: Fri, 7 Dec 2018 08:45:05 +0000 (+0800) Subject: mbox: g12a: add m4 mbox driver [1/3] X-Git-Tag: hardkernel-4.9.236-104~491 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=98cc86a2590f241b046e7df4a3713508d3f8bddd;p=platform%2Fkernel%2Flinux-amlogic.git mbox: g12a: add m4 mbox driver [1/3] 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 --- diff --git a/drivers/amlogic/mailbox/meson_mhu.c b/drivers/amlogic/mailbox/meson_mhu.c index 45f48e7..f4e363c 100644 --- a/drivers/amlogic/mailbox/meson_mhu.c +++ b/drivers/amlogic/mailbox/meson_mhu.c @@ -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; diff --git a/drivers/amlogic/mailbox/meson_mhu.h b/drivers/amlogic/mailbox/meson_mhu.h index 5303b7c0..48f4df4 100644 --- a/drivers/amlogic/mailbox/meson_mhu.h +++ b/drivers/amlogic/mailbox/meson_mhu.h @@ -31,3 +31,4 @@ struct mhu_data_buf { }; extern struct device *the_scpi_device; +extern u32 num_scp_chans; diff --git a/drivers/amlogic/mailbox/scpi_protocol.c b/drivers/amlogic/mailbox/scpi_protocol.c index 7158f3f..f2185e5 100644 --- a/drivers/amlogic/mailbox/scpi_protocol.c +++ b/drivers/amlogic/mailbox/scpi_protocol.c @@ -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; }