linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] mailbox: imx: support new tx doorbell
@ 2023-09-17 12:43 Peng Fan (OSS)
  2023-09-17 12:43 ` [PATCH 1/2] dt-bindings: mailbox: fsl,mu: add new tx doorbell channel Peng Fan (OSS)
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Peng Fan (OSS) @ 2023-09-17 12:43 UTC (permalink / raw)
  To: Jassi Brar, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Dong Aisheng
  Cc: linux-kernel, linux-arm-kernel, devicetree, Peng Fan

The new added channel type is for i.MX95 SCMI mailbox usage.

i.MX95 using TX doorbell and RX doorbell for the SCMI mailbox transport.
For TX doorbell, we relies on software reply from the other side in
SCMI driver side using mbox_client_txdone to drive the tx tick.

But the current MU tx doorbell using tasklet to emulate hardware ACK
from mailbox driver side, so add a new doorbell type to support i.MX95
SCMI mailbox transport.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
Peng Fan (2):
      dt-bindings: mailbox: fsl,mu: add new tx doorbell channel
      mailbox: imx: support channel type tx doorbell v2

 .../devicetree/bindings/mailbox/fsl,mu.yaml        |  5 ++--
 drivers/mailbox/imx-mailbox.c                      | 32 ++++++++++++++++++++--
 2 files changed, 32 insertions(+), 5 deletions(-)
---
base-commit: e143016b56ecb0fcda5bb6026b0a25fe55274f56
change-id: 20230916-imx95-mbox-88437c51ce54

Best regards,
-- 
Peng Fan <peng.fan@nxp.com>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/2] dt-bindings: mailbox: fsl,mu: add new tx doorbell channel
  2023-09-17 12:43 [PATCH 0/2] mailbox: imx: support new tx doorbell Peng Fan (OSS)
@ 2023-09-17 12:43 ` Peng Fan (OSS)
  2023-09-18 12:26   ` Krzysztof Kozlowski
  2023-09-17 12:43 ` [PATCH 2/2] mailbox: imx: support channel type tx doorbell v2 Peng Fan (OSS)
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Peng Fan (OSS) @ 2023-09-17 12:43 UTC (permalink / raw)
  To: Jassi Brar, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Dong Aisheng
  Cc: linux-kernel, linux-arm-kernel, devicetree, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Add new tx doorbell channel for i.MX95 SCMI mailbox usage.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 Documentation/devicetree/bindings/mailbox/fsl,mu.yaml | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/mailbox/fsl,mu.yaml b/Documentation/devicetree/bindings/mailbox/fsl,mu.yaml
index 191c1ce15009..12e7a7d536a3 100644
--- a/Documentation/devicetree/bindings/mailbox/fsl,mu.yaml
+++ b/Documentation/devicetree/bindings/mailbox/fsl,mu.yaml
@@ -72,9 +72,9 @@ properties:
       type      : Channel type
       channel   : Channel number
 
-      This MU support 5 type of unidirectional channels, each type
+      This MU support 6 type of unidirectional channels, each type
       has 4 channels except RST channel which only has 1 channel.
-      A total of 17 channels.  Following types are
+      A total of 21 channels.  Following types are
       supported:
       0 - TX channel with 32bit transmit register and IRQ transmit
           acknowledgment support.
@@ -82,6 +82,7 @@ properties:
       2 - TX doorbell channel. Without own register and no ACK support.
       3 - RX doorbell channel.
       4 - RST channel
+      5 - Tx doorbell channel. With S/W ACK from the other side.
     const: 2
 
   clocks:

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/2] mailbox: imx: support channel type tx doorbell v2
  2023-09-17 12:43 [PATCH 0/2] mailbox: imx: support new tx doorbell Peng Fan (OSS)
  2023-09-17 12:43 ` [PATCH 1/2] dt-bindings: mailbox: fsl,mu: add new tx doorbell channel Peng Fan (OSS)
@ 2023-09-17 12:43 ` Peng Fan (OSS)
  2023-09-18 10:36   ` Daniel Baluta
  2023-10-11 23:32 ` [PATCH 0/2] mailbox: imx: support new tx doorbell Peng Fan
  2023-10-12 12:26 ` Daniel Baluta
  3 siblings, 1 reply; 9+ messages in thread
From: Peng Fan (OSS) @ 2023-09-17 12:43 UTC (permalink / raw)
  To: Jassi Brar, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Dong Aisheng
  Cc: linux-kernel, linux-arm-kernel, devicetree, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

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>
---
 drivers/mailbox/imx-mailbox.c | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/drivers/mailbox/imx-mailbox.c b/drivers/mailbox/imx-mailbox.c
index 3ef4dd8adf5d..0af739ab571c 100644
--- a/drivers/mailbox/imx-mailbox.c
+++ b/drivers/mailbox/imx-mailbox.c
@@ -20,7 +20,9 @@
 #include <linux/suspend.h>
 #include <linux/slab.h>
 
-#define IMX_MU_CHANS		17
+#include "mailbox.h"
+
+#define IMX_MU_CHANS		24
 /* TX0/RX0/RXDB[0-3] */
 #define IMX_MU_SCU_CHANS	6
 /* TX0/RX0 */
@@ -39,6 +41,7 @@ enum imx_mu_chan_type {
 	IMX_MU_TYPE_TXDB	= 2, /* Tx doorbell */
 	IMX_MU_TYPE_RXDB	= 3, /* Rx doorbell */
 	IMX_MU_TYPE_RST		= 4, /* Reset */
+	IMX_MU_TYPE_TXDB_V2	= 5, /* Tx doorbell with S/W ACK */
 };
 
 enum imx_mu_xcr {
@@ -226,6 +229,9 @@ static int imx_mu_generic_tx(struct imx_mu_priv *priv,
 		imx_mu_xcr_rmw(priv, IMX_MU_GCR, IMX_MU_xCR_GIRn(priv->dcfg->type, cp->idx), 0);
 		tasklet_schedule(&cp->txdb_tasklet);
 		break;
+	case IMX_MU_TYPE_TXDB_V2:
+		imx_mu_xcr_rmw(priv, IMX_MU_GCR, IMX_MU_xCR_GIRn(priv->dcfg->type, cp->idx), 0);
+		break;
 	default:
 		dev_warn_ratelimited(priv->dev, "Send data on wrong channel type: %d\n", cp->type);
 		return -EINVAL;
@@ -554,6 +560,9 @@ static int imx_mu_startup(struct mbox_chan *chan)
 	int ret;
 
 	pm_runtime_get_sync(priv->dev);
+	if (cp->type == IMX_MU_TYPE_TXDB_V2)
+		return 0;
+
 	if (cp->type == IMX_MU_TYPE_TXDB) {
 		/* Tx doorbell don't have ACK support */
 		tasklet_init(&cp->txdb_tasklet, imx_mu_txdb_tasklet,
@@ -595,6 +604,11 @@ static void imx_mu_shutdown(struct mbox_chan *chan)
 	int ret;
 	u32 sr;
 
+	if (cp->type == IMX_MU_TYPE_TXDB_V2) {
+		pm_runtime_put_sync(priv->dev);
+		return;
+	}
+
 	if (cp->type == IMX_MU_TYPE_TXDB) {
 		tasklet_kill(&cp->txdb_tasklet);
 		pm_runtime_put_sync(priv->dev);
@@ -671,6 +685,7 @@ static struct mbox_chan *imx_mu_specific_xlate(struct mbox_controller *mbox,
 static struct mbox_chan * imx_mu_xlate(struct mbox_controller *mbox,
 				       const struct of_phandle_args *sp)
 {
+	struct mbox_chan *p_chan;
 	u32 type, idx, chan;
 
 	if (sp->args_count != 2) {
@@ -680,14 +695,25 @@ static struct mbox_chan * imx_mu_xlate(struct mbox_controller *mbox,
 
 	type = sp->args[0]; /* channel type */
 	idx = sp->args[1]; /* index */
-	chan = type * 4 + idx;
 
+	/* RST only supports 1 channel */
+	if ((type == IMX_MU_TYPE_RST) && idx) {
+		dev_err(mbox->dev, "Invalid RST channel %d\n", idx);
+		return ERR_PTR(-EINVAL);
+	}
+
+	chan = type * 4 + idx;
 	if (chan >= mbox->num_chans) {
 		dev_err(mbox->dev, "Not supported channel number: %d. (type: %d, idx: %d)\n", chan, type, idx);
 		return ERR_PTR(-EINVAL);
 	}
 
-	return &mbox->chans[chan];
+	p_chan = &mbox->chans[chan];
+
+	if (type == IMX_MU_TYPE_TXDB_V2)
+		p_chan->txdone_method = TXDONE_BY_ACK;
+
+	return p_chan;
 }
 
 static struct mbox_chan *imx_mu_seco_xlate(struct mbox_controller *mbox,

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] mailbox: imx: support channel type tx doorbell v2
  2023-09-17 12:43 ` [PATCH 2/2] mailbox: imx: support channel type tx doorbell v2 Peng Fan (OSS)
@ 2023-09-18 10:36   ` Daniel Baluta
  2023-09-18 12:01     ` Peng Fan
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Baluta @ 2023-09-18 10:36 UTC (permalink / raw)
  To: Peng Fan (OSS)
  Cc: Jassi Brar, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Dong Aisheng, linux-kernel, linux-arm-kernel,
	devicetree, Peng Fan

On Sun, Sep 17, 2023 at 5:45 PM Peng Fan (OSS) <peng.fan@oss.nxp.com> wrote:
>
> From: Peng Fan <peng.fan@nxp.com>
>
> 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>
> ---
>  drivers/mailbox/imx-mailbox.c | 32 +++++++++++++++++++++++++++++---
>  1 file changed, 29 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mailbox/imx-mailbox.c b/drivers/mailbox/imx-mailbox.c
> index 3ef4dd8adf5d..0af739ab571c 100644
> --- a/drivers/mailbox/imx-mailbox.c
> +++ b/drivers/mailbox/imx-mailbox.c
> @@ -20,7 +20,9 @@
>  #include <linux/suspend.h>
>  #include <linux/slab.h>
>
> -#define IMX_MU_CHANS           17
> +#include "mailbox.h"
> +
> +#define IMX_MU_CHANS           24
>  /* TX0/RX0/RXDB[0-3] */
>  #define IMX_MU_SCU_CHANS       6
>  /* TX0/RX0 */
> @@ -39,6 +41,7 @@ enum imx_mu_chan_type {
>         IMX_MU_TYPE_TXDB        = 2, /* Tx doorbell */
>         IMX_MU_TYPE_RXDB        = 3, /* Rx doorbell */
>         IMX_MU_TYPE_RST         = 4, /* Reset */
> +       IMX_MU_TYPE_TXDB_V2     = 5, /* Tx doorbell with S/W ACK */
>  };
>
>  enum imx_mu_xcr {
> @@ -226,6 +229,9 @@ static int imx_mu_generic_tx(struct imx_mu_priv *priv,
>                 imx_mu_xcr_rmw(priv, IMX_MU_GCR, IMX_MU_xCR_GIRn(priv->dcfg->type, cp->idx), 0);
>                 tasklet_schedule(&cp->txdb_tasklet);
>                 break;
> +       case IMX_MU_TYPE_TXDB_V2:
> +               imx_mu_xcr_rmw(priv, IMX_MU_GCR, IMX_MU_xCR_GIRn(priv->dcfg->type, cp->idx), 0);
> +               break;
>         default:
>                 dev_warn_ratelimited(priv->dev, "Send data on wrong channel type: %d\n", cp->type);
>                 return -EINVAL;
> @@ -554,6 +560,9 @@ static int imx_mu_startup(struct mbox_chan *chan)
>         int ret;
>
>         pm_runtime_get_sync(priv->dev);
> +       if (cp->type == IMX_MU_TYPE_TXDB_V2)
> +               return 0;
> +
>         if (cp->type == IMX_MU_TYPE_TXDB) {
>                 /* Tx doorbell don't have ACK support */
>                 tasklet_init(&cp->txdb_tasklet, imx_mu_txdb_tasklet,
> @@ -595,6 +604,11 @@ static void imx_mu_shutdown(struct mbox_chan *chan)
>         int ret;
>         u32 sr;
>
> +       if (cp->type == IMX_MU_TYPE_TXDB_V2) {
> +               pm_runtime_put_sync(priv->dev);
> +               return;
> +       }
> +
>         if (cp->type == IMX_MU_TYPE_TXDB) {
>                 tasklet_kill(&cp->txdb_tasklet);
>                 pm_runtime_put_sync(priv->dev);
> @@ -671,6 +685,7 @@ static struct mbox_chan *imx_mu_specific_xlate(struct mbox_controller *mbox,
>  static struct mbox_chan * imx_mu_xlate(struct mbox_controller *mbox,
>                                        const struct of_phandle_args *sp)
>  {
> +       struct mbox_chan *p_chan;
>         u32 type, idx, chan;
>
>         if (sp->args_count != 2) {
> @@ -680,14 +695,25 @@ static struct mbox_chan * imx_mu_xlate(struct mbox_controller *mbox,
>
>         type = sp->args[0]; /* channel type */
>         idx = sp->args[1]; /* index */
> -       chan = type * 4 + idx;
>
> +       /* RST only supports 1 channel */
> +       if ((type == IMX_MU_TYPE_RST) && idx) {
> +               dev_err(mbox->dev, "Invalid RST channel %d\n", idx);
> +               return ERR_PTR(-EINVAL);
> +       }

I don't understand how is this related to introduction of a new
doorbell channel. Can you please
add it in a separate patch with proper explanation?


> +
> +       chan = type * 4 + idx;
>         if (chan >= mbox->num_chans) {
>                 dev_err(mbox->dev, "Not supported channel number: %d. (type: %d, idx: %d)\n", chan, type, idx);
>                 return ERR_PTR(-EINVAL);
>         }
>
> -       return &mbox->chans[chan];
> +       p_chan = &mbox->chans[chan];
> +
> +       if (type == IMX_MU_TYPE_TXDB_V2)
> +               p_chan->txdone_method = TXDONE_BY_ACK;
> +
> +       return p_chan;
>  }
>
>  static struct mbox_chan *imx_mu_seco_xlate(struct mbox_controller *mbox,
>
> --
> 2.37.1
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH 2/2] mailbox: imx: support channel type tx doorbell v2
  2023-09-18 10:36   ` Daniel Baluta
@ 2023-09-18 12:01     ` Peng Fan
  2023-09-18 14:40       ` Daniel Baluta
  0 siblings, 1 reply; 9+ messages in thread
From: Peng Fan @ 2023-09-18 12:01 UTC (permalink / raw)
  To: Daniel Baluta, Peng Fan (OSS)
  Cc: Jassi Brar, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, dl-linux-imx, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Aisheng Dong, linux-kernel, linux-arm-kernel,
	devicetree

Hi Daniel,

> Subject: Re: [PATCH 2/2] mailbox: imx: support channel type tx doorbell v2
> 
> On Sun, Sep 17, 2023 at 5:45 PM Peng Fan (OSS) <peng.fan@oss.nxp.com>
> wrote:
> >
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > 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>
> > ---
> >  drivers/mailbox/imx-mailbox.c | 32 +++++++++++++++++++++++++++++---
> >  1 file changed, 29 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/mailbox/imx-mailbox.c
> > b/drivers/mailbox/imx-mailbox.c index 3ef4dd8adf5d..0af739ab571c
> > 100644
> > --- a/drivers/mailbox/imx-mailbox.c
> > +++ b/drivers/mailbox/imx-mailbox.c
> > @@ -20,7 +20,9 @@
> >  #include <linux/suspend.h>
> >  #include <linux/slab.h>
> >
> > -#define IMX_MU_CHANS           17
> > +#include "mailbox.h"
> > +
> > +#define IMX_MU_CHANS           24
> >  /* TX0/RX0/RXDB[0-3] */
> >  #define IMX_MU_SCU_CHANS       6
> >  /* TX0/RX0 */
> > @@ -39,6 +41,7 @@ enum imx_mu_chan_type {
> >         IMX_MU_TYPE_TXDB        = 2, /* Tx doorbell */
> >         IMX_MU_TYPE_RXDB        = 3, /* Rx doorbell */
> >         IMX_MU_TYPE_RST         = 4, /* Reset */
> > +       IMX_MU_TYPE_TXDB_V2     = 5, /* Tx doorbell with S/W ACK */
> >  };
> >
> >  enum imx_mu_xcr {
> > @@ -226,6 +229,9 @@ static int imx_mu_generic_tx(struct imx_mu_priv
> *priv,
> >                 imx_mu_xcr_rmw(priv, IMX_MU_GCR, IMX_MU_xCR_GIRn(priv-
> >dcfg->type, cp->idx), 0);
> >                 tasklet_schedule(&cp->txdb_tasklet);
> >                 break;
> > +       case IMX_MU_TYPE_TXDB_V2:
> > +               imx_mu_xcr_rmw(priv, IMX_MU_GCR, IMX_MU_xCR_GIRn(priv-
> >dcfg->type, cp->idx), 0);
> > +               break;
> >         default:
> >                 dev_warn_ratelimited(priv->dev, "Send data on wrong channel
> type: %d\n", cp->type);
> >                 return -EINVAL;
> > @@ -554,6 +560,9 @@ static int imx_mu_startup(struct mbox_chan *chan)
> >         int ret;
> >
> >         pm_runtime_get_sync(priv->dev);
> > +       if (cp->type == IMX_MU_TYPE_TXDB_V2)
> > +               return 0;
> > +
> >         if (cp->type == IMX_MU_TYPE_TXDB) {
> >                 /* Tx doorbell don't have ACK support */
> >                 tasklet_init(&cp->txdb_tasklet, imx_mu_txdb_tasklet,
> > @@ -595,6 +604,11 @@ static void imx_mu_shutdown(struct mbox_chan
> *chan)
> >         int ret;
> >         u32 sr;
> >
> > +       if (cp->type == IMX_MU_TYPE_TXDB_V2) {
> > +               pm_runtime_put_sync(priv->dev);
> > +               return;
> > +       }
> > +
> >         if (cp->type == IMX_MU_TYPE_TXDB) {
> >                 tasklet_kill(&cp->txdb_tasklet);
> >                 pm_runtime_put_sync(priv->dev); @@ -671,6 +685,7 @@
> > static struct mbox_chan *imx_mu_specific_xlate(struct mbox_controller
> > *mbox,  static struct mbox_chan * imx_mu_xlate(struct mbox_controller
> *mbox,
> >                                        const struct of_phandle_args
> > *sp)  {
> > +       struct mbox_chan *p_chan;
> >         u32 type, idx, chan;
> >
> >         if (sp->args_count != 2) {
> > @@ -680,14 +695,25 @@ static struct mbox_chan * imx_mu_xlate(struct
> > mbox_controller *mbox,
> >
> >         type = sp->args[0]; /* channel type */
> >         idx = sp->args[1]; /* index */
> > -       chan = type * 4 + idx;
> >
> > +       /* RST only supports 1 channel */
> > +       if ((type == IMX_MU_TYPE_RST) && idx) {
> > +               dev_err(mbox->dev, "Invalid RST channel %d\n", idx);
> > +               return ERR_PTR(-EINVAL);
> > +       }
> 
> I don't understand how is this related to introduction of a new doorbell
> channel. Can you please add it in a separate patch with proper explanation?

RST only supports 1 channel, but its value is 4, so here I extend to 4 channel
for RST in code, to make the calculation a bit easier to get TXDB_V2 channel
pointer. But from user side, nothing changed

IMX_MU_TYPE_RST         = 4, /* Reset */
IMX_MU_TYPE_TXDB_V2     = 5, /* Tx doorbell with S/W ACK */

It does not make much sense to separate this change, because this change
Would only make sense together with TXDB_V2 changes.

Thanks,
Peng.

> 
> 
> > +
> > +       chan = type * 4 + idx;
> >         if (chan >= mbox->num_chans) {
> >                 dev_err(mbox->dev, "Not supported channel number: %d.
> (type: %d, idx: %d)\n", chan, type, idx);
> >                 return ERR_PTR(-EINVAL);
> >         }
> >
> > -       return &mbox->chans[chan];
> > +       p_chan = &mbox->chans[chan];
> > +
> > +       if (type == IMX_MU_TYPE_TXDB_V2)
> > +               p_chan->txdone_method = TXDONE_BY_ACK;
> > +
> > +       return p_chan;
> >  }
> >
> >  static struct mbox_chan *imx_mu_seco_xlate(struct mbox_controller
> > *mbox,
> >
> > --
> > 2.37.1
> >

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] dt-bindings: mailbox: fsl,mu: add new tx doorbell channel
  2023-09-17 12:43 ` [PATCH 1/2] dt-bindings: mailbox: fsl,mu: add new tx doorbell channel Peng Fan (OSS)
@ 2023-09-18 12:26   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 9+ messages in thread
From: Krzysztof Kozlowski @ 2023-09-18 12:26 UTC (permalink / raw)
  To: Peng Fan (OSS),
	Jassi Brar, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Dong Aisheng
  Cc: linux-kernel, linux-arm-kernel, devicetree, Peng Fan

On 17/09/2023 14:43, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> Add new tx doorbell channel for i.MX95 SCMI mailbox usage.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---


Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] mailbox: imx: support channel type tx doorbell v2
  2023-09-18 12:01     ` Peng Fan
@ 2023-09-18 14:40       ` Daniel Baluta
  0 siblings, 0 replies; 9+ messages in thread
From: Daniel Baluta @ 2023-09-18 14:40 UTC (permalink / raw)
  To: Peng Fan
  Cc: Peng Fan (OSS),
	Jassi Brar, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, dl-linux-imx, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Aisheng Dong, linux-kernel, linux-arm-kernel,
	devicetree

On Mon, Sep 18, 2023 at 3:01 PM Peng Fan <peng.fan@nxp.com> wrote:
>
> Hi Daniel,
>
> > Subject: Re: [PATCH 2/2] mailbox: imx: support channel type tx doorbell v2
> >
> > On Sun, Sep 17, 2023 at 5:45 PM Peng Fan (OSS) <peng.fan@oss.nxp.com>
> > wrote:
> > >
> > > From: Peng Fan <peng.fan@nxp.com>
> > >
> > > 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>
> > > ---
> > >  drivers/mailbox/imx-mailbox.c | 32 +++++++++++++++++++++++++++++---
> > >  1 file changed, 29 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/mailbox/imx-mailbox.c
> > > b/drivers/mailbox/imx-mailbox.c index 3ef4dd8adf5d..0af739ab571c
> > > 100644
> > > --- a/drivers/mailbox/imx-mailbox.c
> > > +++ b/drivers/mailbox/imx-mailbox.c
> > > @@ -20,7 +20,9 @@
> > >  #include <linux/suspend.h>
> > >  #include <linux/slab.h>
> > >
> > > -#define IMX_MU_CHANS           17
> > > +#include "mailbox.h"
> > > +
> > > +#define IMX_MU_CHANS           24
> > >  /* TX0/RX0/RXDB[0-3] */
> > >  #define IMX_MU_SCU_CHANS       6
> > >  /* TX0/RX0 */
> > > @@ -39,6 +41,7 @@ enum imx_mu_chan_type {
> > >         IMX_MU_TYPE_TXDB        = 2, /* Tx doorbell */
> > >         IMX_MU_TYPE_RXDB        = 3, /* Rx doorbell */
> > >         IMX_MU_TYPE_RST         = 4, /* Reset */
> > > +       IMX_MU_TYPE_TXDB_V2     = 5, /* Tx doorbell with S/W ACK */
> > >  };
> > >
> > >  enum imx_mu_xcr {
> > > @@ -226,6 +229,9 @@ static int imx_mu_generic_tx(struct imx_mu_priv
> > *priv,
> > >                 imx_mu_xcr_rmw(priv, IMX_MU_GCR, IMX_MU_xCR_GIRn(priv-
> > >dcfg->type, cp->idx), 0);
> > >                 tasklet_schedule(&cp->txdb_tasklet);
> > >                 break;
> > > +       case IMX_MU_TYPE_TXDB_V2:
> > > +               imx_mu_xcr_rmw(priv, IMX_MU_GCR, IMX_MU_xCR_GIRn(priv-
> > >dcfg->type, cp->idx), 0);
> > > +               break;
> > >         default:
> > >                 dev_warn_ratelimited(priv->dev, "Send data on wrong channel
> > type: %d\n", cp->type);
> > >                 return -EINVAL;
> > > @@ -554,6 +560,9 @@ static int imx_mu_startup(struct mbox_chan *chan)
> > >         int ret;
> > >
> > >         pm_runtime_get_sync(priv->dev);
> > > +       if (cp->type == IMX_MU_TYPE_TXDB_V2)
> > > +               return 0;
> > > +
> > >         if (cp->type == IMX_MU_TYPE_TXDB) {
> > >                 /* Tx doorbell don't have ACK support */
> > >                 tasklet_init(&cp->txdb_tasklet, imx_mu_txdb_tasklet,
> > > @@ -595,6 +604,11 @@ static void imx_mu_shutdown(struct mbox_chan
> > *chan)
> > >         int ret;
> > >         u32 sr;
> > >
> > > +       if (cp->type == IMX_MU_TYPE_TXDB_V2) {
> > > +               pm_runtime_put_sync(priv->dev);
> > > +               return;
> > > +       }
> > > +
> > >         if (cp->type == IMX_MU_TYPE_TXDB) {
> > >                 tasklet_kill(&cp->txdb_tasklet);
> > >                 pm_runtime_put_sync(priv->dev); @@ -671,6 +685,7 @@
> > > static struct mbox_chan *imx_mu_specific_xlate(struct mbox_controller
> > > *mbox,  static struct mbox_chan * imx_mu_xlate(struct mbox_controller
> > *mbox,
> > >                                        const struct of_phandle_args
> > > *sp)  {
> > > +       struct mbox_chan *p_chan;
> > >         u32 type, idx, chan;
> > >
> > >         if (sp->args_count != 2) {
> > > @@ -680,14 +695,25 @@ static struct mbox_chan * imx_mu_xlate(struct
> > > mbox_controller *mbox,
> > >
> > >         type = sp->args[0]; /* channel type */
> > >         idx = sp->args[1]; /* index */
> > > -       chan = type * 4 + idx;
> > >
> > > +       /* RST only supports 1 channel */
> > > +       if ((type == IMX_MU_TYPE_RST) && idx) {
> > > +               dev_err(mbox->dev, "Invalid RST channel %d\n", idx);
> > > +               return ERR_PTR(-EINVAL);
> > > +       }
> >
> > I don't understand how is this related to introduction of a new doorbell
> > channel. Can you please add it in a separate patch with proper explanation?
>
> RST only supports 1 channel, but its value is 4, so here I extend to 4 channel
> for RST in code, to make the calculation a bit easier to get TXDB_V2 channel
> pointer. But from user side, nothing changed
>
> IMX_MU_TYPE_RST         = 4, /* Reset */
> IMX_MU_TYPE_TXDB_V2     = 5, /* Tx doorbell with S/W ACK */
>
> It does not make much sense to separate this change, because this change
> Would only make sense together with TXDB_V2 changes.


Ok, I see. Good for me, then.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH 0/2] mailbox: imx: support new tx doorbell
  2023-09-17 12:43 [PATCH 0/2] mailbox: imx: support new tx doorbell Peng Fan (OSS)
  2023-09-17 12:43 ` [PATCH 1/2] dt-bindings: mailbox: fsl,mu: add new tx doorbell channel Peng Fan (OSS)
  2023-09-17 12:43 ` [PATCH 2/2] mailbox: imx: support channel type tx doorbell v2 Peng Fan (OSS)
@ 2023-10-11 23:32 ` Peng Fan
  2023-10-12 12:26 ` Daniel Baluta
  3 siblings, 0 replies; 9+ messages in thread
From: Peng Fan @ 2023-10-11 23:32 UTC (permalink / raw)
  To: Jassi Brar, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, dl-linux-imx, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Aisheng Dong
  Cc: linux-kernel, linux-arm-kernel, devicetree

Hi Jassi,

> Subject: [PATCH 0/2] mailbox: imx: support new tx doorbell

Would you pick up this patchset? Or any comments?

Thanks,
Peng.

> 
> The new added channel type is for i.MX95 SCMI mailbox usage.
> 
> i.MX95 using TX doorbell and RX doorbell for the SCMI mailbox transport.
> For TX doorbell, we relies on software reply from the other side in SCMI driver
> side using mbox_client_txdone to drive the tx tick.
> 
> But the current MU tx doorbell using tasklet to emulate hardware ACK from
> mailbox driver side, so add a new doorbell type to support i.MX95 SCMI
> mailbox transport.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> Peng Fan (2):
>       dt-bindings: mailbox: fsl,mu: add new tx doorbell channel
>       mailbox: imx: support channel type tx doorbell v2
> 
>  .../devicetree/bindings/mailbox/fsl,mu.yaml        |  5 ++--
>  drivers/mailbox/imx-mailbox.c                      | 32 ++++++++++++++++++++--
>  2 files changed, 32 insertions(+), 5 deletions(-)
> ---
> base-commit: e143016b56ecb0fcda5bb6026b0a25fe55274f56
> change-id: 20230916-imx95-mbox-88437c51ce54
> 
> Best regards,
> --
> Peng Fan <peng.fan@nxp.com>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/2] mailbox: imx: support new tx doorbell
  2023-09-17 12:43 [PATCH 0/2] mailbox: imx: support new tx doorbell Peng Fan (OSS)
                   ` (2 preceding siblings ...)
  2023-10-11 23:32 ` [PATCH 0/2] mailbox: imx: support new tx doorbell Peng Fan
@ 2023-10-12 12:26 ` Daniel Baluta
  3 siblings, 0 replies; 9+ messages in thread
From: Daniel Baluta @ 2023-10-12 12:26 UTC (permalink / raw)
  To: Peng Fan (OSS)
  Cc: Jassi Brar, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Dong Aisheng, linux-kernel, linux-arm-kernel,
	devicetree, Peng Fan

On Sun, Sep 17, 2023 at 7:55 PM Peng Fan (OSS) <peng.fan@oss.nxp.com> wrote:
>
> The new added channel type is for i.MX95 SCMI mailbox usage.
>
> i.MX95 using TX doorbell and RX doorbell for the SCMI mailbox transport.
> For TX doorbell, we relies on software reply from the other side in
> SCMI driver side using mbox_client_txdone to drive the tx tick.
>
> But the current MU tx doorbell using tasklet to emulate hardware ACK
> from mailbox driver side, so add a new doorbell type to support i.MX95
> SCMI mailbox transport.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>

Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>


> ---
> Peng Fan (2):
>       dt-bindings: mailbox: fsl,mu: add new tx doorbell channel
>       mailbox: imx: support channel type tx doorbell v2
>
>  .../devicetree/bindings/mailbox/fsl,mu.yaml        |  5 ++--
>  drivers/mailbox/imx-mailbox.c                      | 32 ++++++++++++++++++++--
>  2 files changed, 32 insertions(+), 5 deletions(-)
> ---
> base-commit: e143016b56ecb0fcda5bb6026b0a25fe55274f56
> change-id: 20230916-imx95-mbox-88437c51ce54
>
> Best regards,
> --
> Peng Fan <peng.fan@nxp.com>
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-10-12 12:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-17 12:43 [PATCH 0/2] mailbox: imx: support new tx doorbell Peng Fan (OSS)
2023-09-17 12:43 ` [PATCH 1/2] dt-bindings: mailbox: fsl,mu: add new tx doorbell channel Peng Fan (OSS)
2023-09-18 12:26   ` Krzysztof Kozlowski
2023-09-17 12:43 ` [PATCH 2/2] mailbox: imx: support channel type tx doorbell v2 Peng Fan (OSS)
2023-09-18 10:36   ` Daniel Baluta
2023-09-18 12:01     ` Peng Fan
2023-09-18 14:40       ` Daniel Baluta
2023-10-11 23:32 ` [PATCH 0/2] mailbox: imx: support new tx doorbell Peng Fan
2023-10-12 12:26 ` Daniel Baluta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).