Skip to content

Commit 5bfe406

Browse files
MrVanJassiBrar
authored andcommitted
mailbox: imx: support channel type tx doorbell v2
The Message Unit(MU) General Purpose Control registers are used for TX doorbell, but there is no hardware ACK support. The current TX doorbell channel is using tasklet to emulate hardware ACK support to kick the TX tick from controller driver side. The new added TX doorbell channel V2 not using tasklet to emulate the hardware ACK support. The behavior for the channel is just writing the GCR register, and no else. This will be used for SCMI mailbox. Signed-off-by: Peng Fan <peng.fan@nxp.com> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
1 parent 5dc1ec7 commit 5bfe406

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

drivers/mailbox/imx-mailbox.c

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
#include <linux/suspend.h>
2121
#include <linux/slab.h>
2222

23-
#define IMX_MU_CHANS 17
23+
#include "mailbox.h"
24+
25+
#define IMX_MU_CHANS 24
2426
/* TX0/RX0/RXDB[0-3] */
2527
#define IMX_MU_SCU_CHANS 6
2628
/* TX0/RX0 */
@@ -39,6 +41,7 @@ enum imx_mu_chan_type {
3941
IMX_MU_TYPE_TXDB = 2, /* Tx doorbell */
4042
IMX_MU_TYPE_RXDB = 3, /* Rx doorbell */
4143
IMX_MU_TYPE_RST = 4, /* Reset */
44+
IMX_MU_TYPE_TXDB_V2 = 5, /* Tx doorbell with S/W ACK */
4245
};
4346

4447
enum imx_mu_xcr {
@@ -226,6 +229,9 @@ static int imx_mu_generic_tx(struct imx_mu_priv *priv,
226229
imx_mu_xcr_rmw(priv, IMX_MU_GCR, IMX_MU_xCR_GIRn(priv->dcfg->type, cp->idx), 0);
227230
tasklet_schedule(&cp->txdb_tasklet);
228231
break;
232+
case IMX_MU_TYPE_TXDB_V2:
233+
imx_mu_xcr_rmw(priv, IMX_MU_GCR, IMX_MU_xCR_GIRn(priv->dcfg->type, cp->idx), 0);
234+
break;
229235
default:
230236
dev_warn_ratelimited(priv->dev, "Send data on wrong channel type: %d\n", cp->type);
231237
return -EINVAL;
@@ -554,6 +560,9 @@ static int imx_mu_startup(struct mbox_chan *chan)
554560
int ret;
555561

556562
pm_runtime_get_sync(priv->dev);
563+
if (cp->type == IMX_MU_TYPE_TXDB_V2)
564+
return 0;
565+
557566
if (cp->type == IMX_MU_TYPE_TXDB) {
558567
/* Tx doorbell don't have ACK support */
559568
tasklet_init(&cp->txdb_tasklet, imx_mu_txdb_tasklet,
@@ -595,6 +604,11 @@ static void imx_mu_shutdown(struct mbox_chan *chan)
595604
int ret;
596605
u32 sr;
597606

607+
if (cp->type == IMX_MU_TYPE_TXDB_V2) {
608+
pm_runtime_put_sync(priv->dev);
609+
return;
610+
}
611+
598612
if (cp->type == IMX_MU_TYPE_TXDB) {
599613
tasklet_kill(&cp->txdb_tasklet);
600614
pm_runtime_put_sync(priv->dev);
@@ -671,6 +685,7 @@ static struct mbox_chan *imx_mu_specific_xlate(struct mbox_controller *mbox,
671685
static struct mbox_chan * imx_mu_xlate(struct mbox_controller *mbox,
672686
const struct of_phandle_args *sp)
673687
{
688+
struct mbox_chan *p_chan;
674689
u32 type, idx, chan;
675690

676691
if (sp->args_count != 2) {
@@ -680,14 +695,25 @@ static struct mbox_chan * imx_mu_xlate(struct mbox_controller *mbox,
680695

681696
type = sp->args[0]; /* channel type */
682697
idx = sp->args[1]; /* index */
683-
chan = type * 4 + idx;
684698

699+
/* RST only supports 1 channel */
700+
if ((type == IMX_MU_TYPE_RST) && idx) {
701+
dev_err(mbox->dev, "Invalid RST channel %d\n", idx);
702+
return ERR_PTR(-EINVAL);
703+
}
704+
705+
chan = type * 4 + idx;
685706
if (chan >= mbox->num_chans) {
686707
dev_err(mbox->dev, "Not supported channel number: %d. (type: %d, idx: %d)\n", chan, type, idx);
687708
return ERR_PTR(-EINVAL);
688709
}
689710

690-
return &mbox->chans[chan];
711+
p_chan = &mbox->chans[chan];
712+
713+
if (type == IMX_MU_TYPE_TXDB_V2)
714+
p_chan->txdone_method = TXDONE_BY_ACK;
715+
716+
return p_chan;
691717
}
692718

693719
static struct mbox_chan *imx_mu_seco_xlate(struct mbox_controller *mbox,

0 commit comments

Comments
 (0)