RE: [PATCH V3 8/8] remoteproc: imx_rproc: support i.MX8MN/P

2021-04-15 Thread Peng Fan (OSS)
> Subject: Re: [PATCH V3 8/8] remoteproc: imx_rproc: support i.MX8MN/P

Hi Mathieu,

Your all comments are good suggestion in the patchset, I not reply your
comment one by one for each patch. In V4 patchset, hope I have fixed
all the issues you pointed.

Thanks for your reviewing.

Thanks,
Peng.

> 
> On Thu, Apr 08, 2021 at 09:54:58AM +0800, peng@oss.nxp.com wrote:
> > From: Peng Fan 
> >
> > Add i.MX8MN/P remote processor(Cortex-M7) support, we are using ARM
> > SMCCC to start/stop M core, not using regmap interface.
> >
> > Signed-off-by: Peng Fan 
> > ---
> >  drivers/remoteproc/imx_rproc.c | 89
> > +++---
> >  1 file changed, 82 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/remoteproc/imx_rproc.c
> > b/drivers/remoteproc/imx_rproc.c index b911a7539897..9351626f09c0
> > 100644
> > --- a/drivers/remoteproc/imx_rproc.c
> > +++ b/drivers/remoteproc/imx_rproc.c
> > @@ -3,6 +3,7 @@
> >   * Copyright (c) 2017 Pengutronix, Oleksij Rempel
> 
> >   */
> >
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -50,6 +51,11 @@
> >
> >  #define IMX_RPROC_MEM_MAX  32
> >
> > +#define IMX_SIP_RPROC  0xC205
> > +#define IMX_SIP_RPROC_START0x00
> > +#define IMX_SIP_RPROC_STARTED  0x01
> > +#define IMX_SIP_RPROC_STOP 0x02
> > +
> >  /**
> >   * struct imx_rproc_mem - slim internal memory structure
> >   * @cpu_addr: MPU virtual address of the memory region @@ -119,6
> > +125,36 @@ struct imx_rproc {
> > enum imx_rproc_mode mode;
> >  };
> >
> > +static const struct imx_rproc_att imx_rproc_att_imx8mn[] = {
> > +   /* dev addr , sys addr  , size  , flags */
> > +   /* ITCM   */
> > +   { 0x, 0x007E, 0x0002, ATT_OWN },
> > +   /* OCRAM_S */
> > +   { 0x0018, 0x0018, 0x9000, 0 },
> > +   /* OCRAM */
> > +   { 0x0090, 0x0090, 0x0002, 0 },
> > +   /* OCRAM */
> > +   { 0x0092, 0x0092, 0x0002, 0 },
> > +   /* OCRAM */
> > +   { 0x0094, 0x0094, 0x0005, 0 },
> > +   /* QSPI Code - alias */
> > +   { 0x0800, 0x0800, 0x0800, 0 },
> > +   /* DDR (Code) - alias */
> > +   { 0x1000, 0x4000, 0x0FFE, 0 },
> > +   /* DTCM */
> > +   { 0x2000, 0x0080, 0x0002, ATT_OWN },
> > +   /* OCRAM_S - alias */
> > +   { 0x2018, 0x0018, 0x8000, ATT_OWN },
> > +   /* OCRAM */
> > +   { 0x2020, 0x0090, 0x0002, ATT_OWN },
> > +   /* OCRAM */
> > +   { 0x2022, 0x0092, 0x0002, ATT_OWN },
> > +   /* OCRAM */
> > +   { 0x2024, 0x0094, 0x0004, ATT_OWN },
> > +   /* DDR (Data) */
> > +   { 0x4000, 0x4000, 0x8000, 0 }, };
> > +
> >  static const struct imx_rproc_att imx_rproc_att_imx8mq[] = {
> > /* dev addr , sys addr  , size  , flags */
> > /* TCML - alias */
> > @@ -205,6 +241,12 @@ static const struct imx_rproc_att
> imx_rproc_att_imx6sx[] = {
> > { 0x8000, 0x8000, 0x6000, 0 },  };
> >
> > +static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mn = {
> > +   .att= imx_rproc_att_imx8mn,
> > +   .att_size   = ARRAY_SIZE(imx_rproc_att_imx8mn),
> > +   .method = IMX_RPROC_SMC,
> > +};
> > +
> >  static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mq = {
> > .src_reg= IMX7D_SRC_SCR,
> > .src_mask   = IMX7D_M4_RST_MASK,
> > @@ -246,12 +288,24 @@ static int imx_rproc_start(struct rproc *rproc)
> > struct imx_rproc *priv = rproc->priv;
> > const struct imx_rproc_dcfg *dcfg = priv->dcfg;
> > struct device *dev = priv->dev;
> > +   struct arm_smccc_res res;
> > int ret;
> >
> > -   ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
> > -dcfg->src_mask, dcfg->src_start);
> > +   switch (dcfg->method) {
> > +   case IMX_RPROC_MMIO:
> > +   ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
> dcfg->src_mask,
> > +dcfg->src_start);
> > +   break;
> > +   case IMX_RPROC_SMC:
> > +   arm_smccc_smc(IMX_SIP_RPROC, IMX_SIP_RPROC_START, 0, 0, 0,
> 0, 0, 0, &res);
> > +   ret = res.a0;
> > +   break;
> > +   default:
> > +   return -EOPNOTSUPP;
> > +   }
> > +
> > if (

Re: [PATCH V3 8/8] remoteproc: imx_rproc: support i.MX8MN/P

2021-04-13 Thread Mathieu Poirier
On Thu, Apr 08, 2021 at 09:54:58AM +0800, peng@oss.nxp.com wrote:
> From: Peng Fan 
> 
> Add i.MX8MN/P remote processor(Cortex-M7) support, we are using ARM
> SMCCC to start/stop M core, not using regmap interface.
> 
> Signed-off-by: Peng Fan 
> ---
>  drivers/remoteproc/imx_rproc.c | 89 +++---
>  1 file changed, 82 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
> index b911a7539897..9351626f09c0 100644
> --- a/drivers/remoteproc/imx_rproc.c
> +++ b/drivers/remoteproc/imx_rproc.c
> @@ -3,6 +3,7 @@
>   * Copyright (c) 2017 Pengutronix, Oleksij Rempel 
>   */
>  
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -50,6 +51,11 @@
>  
>  #define IMX_RPROC_MEM_MAX32
>  
> +#define IMX_SIP_RPROC0xC205
> +#define IMX_SIP_RPROC_START  0x00
> +#define IMX_SIP_RPROC_STARTED0x01
> +#define IMX_SIP_RPROC_STOP   0x02
> +
>  /**
>   * struct imx_rproc_mem - slim internal memory structure
>   * @cpu_addr: MPU virtual address of the memory region
> @@ -119,6 +125,36 @@ struct imx_rproc {
>   enum imx_rproc_mode mode;
>  };
>  
> +static const struct imx_rproc_att imx_rproc_att_imx8mn[] = {
> + /* dev addr , sys addr  , size  , flags */
> + /* ITCM   */
> + { 0x, 0x007E, 0x0002, ATT_OWN },
> + /* OCRAM_S */
> + { 0x0018, 0x0018, 0x9000, 0 },
> + /* OCRAM */
> + { 0x0090, 0x0090, 0x0002, 0 },
> + /* OCRAM */
> + { 0x0092, 0x0092, 0x0002, 0 },
> + /* OCRAM */
> + { 0x0094, 0x0094, 0x0005, 0 },
> + /* QSPI Code - alias */
> + { 0x0800, 0x0800, 0x0800, 0 },
> + /* DDR (Code) - alias */
> + { 0x1000, 0x4000, 0x0FFE, 0 },
> + /* DTCM */
> + { 0x2000, 0x0080, 0x0002, ATT_OWN },
> + /* OCRAM_S - alias */
> + { 0x2018, 0x0018, 0x8000, ATT_OWN },
> + /* OCRAM */
> + { 0x2020, 0x0090, 0x0002, ATT_OWN },
> + /* OCRAM */
> + { 0x2022, 0x0092, 0x0002, ATT_OWN },
> + /* OCRAM */
> + { 0x2024, 0x0094, 0x0004, ATT_OWN },
> + /* DDR (Data) */
> + { 0x4000, 0x4000, 0x8000, 0 },
> +};
> +
>  static const struct imx_rproc_att imx_rproc_att_imx8mq[] = {
>   /* dev addr , sys addr  , size  , flags */
>   /* TCML - alias */
> @@ -205,6 +241,12 @@ static const struct imx_rproc_att imx_rproc_att_imx6sx[] 
> = {
>   { 0x8000, 0x8000, 0x6000, 0 },
>  };
>  
> +static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mn = {
> + .att= imx_rproc_att_imx8mn,
> + .att_size   = ARRAY_SIZE(imx_rproc_att_imx8mn),
> + .method = IMX_RPROC_SMC,
> +};
> +
>  static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mq = {
>   .src_reg= IMX7D_SRC_SCR,
>   .src_mask   = IMX7D_M4_RST_MASK,
> @@ -246,12 +288,24 @@ static int imx_rproc_start(struct rproc *rproc)
>   struct imx_rproc *priv = rproc->priv;
>   const struct imx_rproc_dcfg *dcfg = priv->dcfg;
>   struct device *dev = priv->dev;
> + struct arm_smccc_res res;
>   int ret;
>  
> - ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
> -  dcfg->src_mask, dcfg->src_start);
> + switch (dcfg->method) {
> + case IMX_RPROC_MMIO:
> + ret = regmap_update_bits(priv->regmap, dcfg->src_reg, 
> dcfg->src_mask,
> +  dcfg->src_start);
> + break;
> + case IMX_RPROC_SMC:
> + arm_smccc_smc(IMX_SIP_RPROC, IMX_SIP_RPROC_START, 0, 0, 0, 0, 
> 0, 0, &res);
> + ret = res.a0;
> + break;
> + default:
> + return -EOPNOTSUPP;
> + }
> +
>   if (ret)
> - dev_err(dev, "Failed to enable M4!\n");
> + dev_err(dev, "Failed to enable remote cores!\n");
>  
>   return ret;
>  }
> @@ -261,12 +315,26 @@ static int imx_rproc_stop(struct rproc *rproc)
>   struct imx_rproc *priv = rproc->priv;
>   const struct imx_rproc_dcfg *dcfg = priv->dcfg;
>   struct device *dev = priv->dev;
> + struct arm_smccc_res res;
>   int ret;
>  
> - ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
> -  dcfg->src_mask, dcfg->src_stop);
> + switch (dcfg->method) {
> + case IMX_RPROC_MMIO:
> + ret = regmap_update_bits(priv->regmap, dcfg->src_reg, 
> dcfg->src_mask,
> +  dcfg->src_stop);
> + break;
> + case IMX_RPROC_SMC:
> + arm_smccc_smc(IMX_SIP_RPROC, IMX_SIP_RPROC_STOP, 0, 0, 0, 0, 0, 
> 0, &res);
> + ret = res.a0;
> + if (res.a1)
> + dev_info(dev, "Not in wfi, force stopped\n");
> + break;
> + default:
> + return -EOPNO