RE: [PATCH] remoteproc: imx_rproc: Adjust phandle parsing issue while remapping optional addresses in imx_rproc_addr_init()

2024-06-06 Thread Peng Fan
Hi Aleksandr,

> Subject: [PATCH] remoteproc: imx_rproc: Adjust phandle parsing issue while
> remapping optional addresses in imx_rproc_addr_init()
> 
> In imx_rproc_addr_init() "nph = of_count_phandle_with_args()" just counts
> number of phandles. But phandles may be empty. So of_parse_phandle() in
> the parsing loop (0 < a < nph) may return NULL which is later dereferenced.
> Adjust this issue by adding NULL-return check.

It is good to add a check here. But I am not sure whether this will really
happen.

> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: a0ff4aa6f010 ("remoteproc: imx_rproc: add a NXP/Freescale imx_rproc
> driver")
> Signed-off-by: Aleksandr Mishin 

Anyway LGTM:
Reviewed-by: Peng Fan 

Thanks,
Peng.



RE: [PATCH] vhost: use pr_err for vq_err

2024-05-16 Thread Peng Fan
> Subject: Re: [PATCH] vhost: use pr_err for vq_err
> 
> On Thu, May 16, 2024 at 03:46:29PM +0800, Peng Fan (OSS) wrote:
> > From: Peng Fan 
> >
> > Use pr_err to print out error message without enabling DEBUG. This
> > could make people catch error easier.
> >
> > Signed-off-by: Peng Fan 
> 
> This isn't appropriate: pr_err must not be triggerable by userspace. If you 
> are
> debugging userspace, use a debugging kernel, it's that simple.

I see, then drop this patch.

Thanks,
Peng.
> 
> 
> > ---
> >  drivers/vhost/vhost.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index
> > bb75a292d50c..0bff436d1ce9 100644
> > --- a/drivers/vhost/vhost.h
> > +++ b/drivers/vhost/vhost.h
> > @@ -248,7 +248,7 @@ void vhost_iotlb_map_free(struct vhost_iotlb *iotlb,
> >   struct vhost_iotlb_map *map);
> >
> >  #define vq_err(vq, fmt, ...) do {  \
> > -   pr_debug(pr_fmt(fmt), ##__VA_ARGS__);   \
> > +   pr_err(pr_fmt(fmt), ##__VA_ARGS__);   \
> > if ((vq)->error_ctx)   \
> > eventfd_signal((vq)->error_ctx);\
> > } while (0)
> > --
> > 2.37.1




[PATCH] vhost: use pr_err for vq_err

2024-05-16 Thread Peng Fan (OSS)
From: Peng Fan 

Use pr_err to print out error message without enabling DEBUG. This could
make people catch error easier.

Signed-off-by: Peng Fan 
---
 drivers/vhost/vhost.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index bb75a292d50c..0bff436d1ce9 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -248,7 +248,7 @@ void vhost_iotlb_map_free(struct vhost_iotlb *iotlb,
  struct vhost_iotlb_map *map);
 
 #define vq_err(vq, fmt, ...) do {  \
-   pr_debug(pr_fmt(fmt), ##__VA_ARGS__);   \
+   pr_err(pr_fmt(fmt), ##__VA_ARGS__);   \
if ((vq)->error_ctx)   \
eventfd_signal((vq)->error_ctx);\
} while (0)
-- 
2.37.1




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, );
> > +   ret = res.a0;
> > +   break;
> > +   default:
> > +   return -EOPNOTSUPP;
> > +   }
> > +
> > if (ret)

[PATCH V4 7/8] remoteproc: imx_rproc: support i.MX7ULP

2021-04-15 Thread peng . fan
From: Peng Fan 

i.MX7ULP A7 core runs under control of M4 core, M4 core starts by ROM
and powers most serivces used by A7 core, so A7 core has no power to
start and stop M4 core. And the M4 core's state is default RPROC_DETACHED
and remoteproc framework not able to stop the M4 core.

Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 25 -
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 56dfcc1..0592865 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -136,6 +136,14 @@ static const struct imx_rproc_att imx_rproc_att_imx8mq[] = 
{
{ 0x4000, 0x4000, 0x8000, 0 },
 };
 
+static const struct imx_rproc_att imx_rproc_att_imx7ulp[] = {
+   {0x1FFD, 0x1FFD, 0x3, ATT_OWN},
+   {0x2000, 0x2000, 0x1, ATT_OWN},
+   {0x2F00, 0x2F00, 0x2, ATT_OWN},
+   {0x2F02, 0x2F02, 0x2, ATT_OWN},
+   {0x6000, 0x6000, 0x4000, 0}
+};
+
 static const struct imx_rproc_att imx_rproc_att_imx7d[] = {
/* dev addr , sys addr  , size  , flags */
/* OCRAM_S (M4 Boot code) - alias */
@@ -196,6 +204,12 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mq = {
.method = IMX_RPROC_MMIO,
 };
 
+static const struct imx_rproc_dcfg imx_rproc_cfg_imx7ulp = {
+   .att= imx_rproc_att_imx7ulp,
+   .att_size   = ARRAY_SIZE(imx_rproc_att_imx7ulp),
+   .method = IMX_RPROC_NONE,
+};
+
 static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = {
.src_reg= IMX7D_SRC_SCR,
.src_mask   = IMX7D_M4_RST_MASK,
@@ -238,6 +252,9 @@ static int imx_rproc_stop(struct rproc *rproc)
struct device *dev = priv->dev;
int ret;
 
+   if (dcfg->method == IMX_RPROC_NONE)
+   return -EOPNOTSUPP;
+
ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
 dcfg->src_mask, dcfg->src_stop);
if (ret)
@@ -580,8 +597,13 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)
int ret;
u32 val;
 
-   if (dcfg->method != IMX_RPROC_MMIO)
+   switch (dcfg->method) {
+   case IMX_RPROC_NONE:
+   priv->rproc->state = RPROC_DETACHED;
return 0;
+   default:
+   break;
+   }
 
regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "syscon");
if (IS_ERR(regmap)) {
@@ -726,6 +748,7 @@ static int imx_rproc_remove(struct platform_device *pdev)
 }
 
 static const struct of_device_id imx_rproc_of_match[] = {
+   { .compatible = "fsl,imx7ulp-cm4", .data = _rproc_cfg_imx7ulp },
{ .compatible = "fsl,imx7d-cm4", .data = _rproc_cfg_imx7d },
{ .compatible = "fsl,imx6sx-cm4", .data = _rproc_cfg_imx6sx },
{ .compatible = "fsl,imx8mq-cm4", .data = _rproc_cfg_imx8mq },
-- 
2.7.4



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

2021-04-15 Thread peng . fan
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 | 87 ++
 1 file changed, 80 insertions(+), 7 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 0592865..0ff16e3 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
@@ -108,6 +114,36 @@ struct imx_rproc {
void __iomem*rsc_table;
 };
 
+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 */
@@ -194,6 +230,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,
@@ -235,12 +277,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, );
+   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;
 }
@@ -250,15 +304,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;
 
-   if (dcfg->method == IMX_RPROC_NONE)
+   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, );
+   ret = res.a0;
+   if (res.a1)
+   dev_info(dev, "Not in wfi, force stopped\n");
+   break;
+   default:
return -EOPNOTSUPP;
+   }
 
-   ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
-dcfg->src_mask, dcfg->src_stop);
if (ret)
-   

[PATCH V4 6/8] remoteproc: imx_rproc: make clk optional

2021-04-15 Thread peng . fan
From: Peng Fan 

To i.MX7ULP, M4 is the master to control everything, no need to provide
clk from Linux side. So make clk optional when method is IMX_RPROC_NONE.

Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 46 --
 1 file changed, 31 insertions(+), 15 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 2b633fd..56dfcc1 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -606,6 +606,35 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)
return 0;
 }
 
+static int imx_rproc_clk_enable(struct imx_rproc *priv)
+{
+   const struct imx_rproc_dcfg *dcfg = priv->dcfg;
+   struct device *dev = priv->dev;
+   int ret;
+
+   /* Remote core is not under control of Linux */
+   if (dcfg->method == IMX_RPROC_NONE)
+   return 0;
+
+   priv->clk = devm_clk_get(dev, NULL);
+   if (IS_ERR(priv->clk)) {
+   dev_err(dev, "Failed to get clock\n");
+   return PTR_ERR(priv->clk);
+   }
+
+   /*
+* clk for M4 block including memory. Should be
+* enabled before .start for FW transfer.
+*/
+   ret = clk_prepare_enable(priv->clk);
+   if (ret) {
+   dev_err(dev, "Failed to enable clock\n");
+   return ret;
+   }
+
+   return 0;
+}
+
 static int imx_rproc_probe(struct platform_device *pdev)
 {
struct device *dev = >dev;
@@ -654,22 +683,9 @@ static int imx_rproc_probe(struct platform_device *pdev)
if (ret)
goto err_put_mbox;
 
-   priv->clk = devm_clk_get(dev, NULL);
-   if (IS_ERR(priv->clk)) {
-   dev_err(dev, "Failed to get clock\n");
-   ret = PTR_ERR(priv->clk);
-   goto err_put_mbox;
-   }
-
-   /*
-* clk for M4 block including memory. Should be
-* enabled before .start for FW transfer.
-*/
-   ret = clk_prepare_enable(priv->clk);
-   if (ret) {
-   dev_err(>dev, "Failed to enable clock\n");
+   ret = imx_rproc_clk_enable(priv);
+   if (ret)
goto err_put_mbox;
-   }
 
INIT_WORK(>rproc_work, imx_rproc_vq_work);
 
-- 
2.7.4



[PATCH V4 5/8] remoteproc: imx_rproc: initial support for mutilple start/stop method

2021-04-15 Thread peng . fan
From: Peng Fan 

Add three methods IMX_RPROC_NONE(no need start/stop), IMX_RPROC_MMIO
(start/stop through mmio) and IMX_RPROC_SMC(start/stop through ARM SMCCC).

The current SoCs supported are all using IMX_RPROC_MMIO, add a restrict
in imx_rproc_detect_mode that only SoCs using IMX_RPROC_MMIO needs syscon
regmap to access registers.

Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 51 +-
 1 file changed, 35 insertions(+), 16 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 06dac92..2b633fd 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -74,6 +74,15 @@ struct imx_rproc_att {
int flags;
 };
 
+/* Remote core start/stop method */
+enum imx_rproc_method {
+   IMX_RPROC_NONE,
+   /* Through syscon regmap */
+   IMX_RPROC_MMIO,
+   /* Through ARM SMCCC */
+   IMX_RPROC_SMC,
+};
+
 struct imx_rproc_dcfg {
u32 src_reg;
u32 src_mask;
@@ -81,6 +90,7 @@ struct imx_rproc_dcfg {
u32 src_stop;
const struct imx_rproc_att  *att;
size_t  att_size;
+   enum imx_rproc_method   method;
 };
 
 struct imx_rproc {
@@ -183,6 +193,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mq = {
.src_stop   = IMX7D_M4_STOP,
.att= imx_rproc_att_imx8mq,
.att_size   = ARRAY_SIZE(imx_rproc_att_imx8mq),
+   .method = IMX_RPROC_MMIO,
 };
 
 static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = {
@@ -192,6 +203,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = {
.src_stop   = IMX7D_M4_STOP,
.att= imx_rproc_att_imx7d,
.att_size   = ARRAY_SIZE(imx_rproc_att_imx7d),
+   .method = IMX_RPROC_MMIO,
 };
 
 static const struct imx_rproc_dcfg imx_rproc_cfg_imx6sx = {
@@ -201,6 +213,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx6sx = {
.src_stop   = IMX6SX_M4_STOP,
.att= imx_rproc_att_imx6sx,
.att_size   = ARRAY_SIZE(imx_rproc_att_imx6sx),
+   .method = IMX_RPROC_MMIO,
 };
 
 static int imx_rproc_start(struct rproc *rproc)
@@ -560,19 +573,35 @@ static void imx_rproc_free_mbox(struct rproc *rproc)
 
 static int imx_rproc_detect_mode(struct imx_rproc *priv)
 {
+   struct regmap_config config = { .name = "imx-rproc" };
const struct imx_rproc_dcfg *dcfg = priv->dcfg;
struct device *dev = priv->dev;
+   struct regmap *regmap;
int ret;
u32 val;
 
-   ret = regmap_read(priv->regmap, dcfg->src_reg, );
-   if (ret) {
-   dev_err(dev, "Failed to read src\n");
-   return ret;
+   if (dcfg->method != IMX_RPROC_MMIO)
+   return 0;
+
+   regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "syscon");
+   if (IS_ERR(regmap)) {
+   dev_err(dev, "failed to find syscon\n");
+   return PTR_ERR(regmap);
}
 
-   if (!(val & dcfg->src_stop))
-   priv->rproc->state = RPROC_DETACHED;
+   priv->regmap = regmap;
+   regmap_attach_dev(dev, regmap, );
+
+   if (regmap) {
+   ret = regmap_read(regmap, dcfg->src_reg, );
+   if (ret) {
+   dev_err(dev, "Failed to read src\n");
+   return ret;
+   }
+
+   if (!(val & dcfg->src_stop))
+   priv->rproc->state = RPROC_DETACHED;
+   }
 
return 0;
 }
@@ -583,18 +612,9 @@ static int imx_rproc_probe(struct platform_device *pdev)
struct device_node *np = dev->of_node;
struct imx_rproc *priv;
struct rproc *rproc;
-   struct regmap_config config = { .name = "imx-rproc" };
const struct imx_rproc_dcfg *dcfg;
-   struct regmap *regmap;
int ret;
 
-   regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
-   if (IS_ERR(regmap)) {
-   dev_err(dev, "failed to find syscon\n");
-   return PTR_ERR(regmap);
-   }
-   regmap_attach_dev(dev, regmap, );
-
/* set some other name then imx */
rproc = rproc_alloc(dev, "imx-rproc", _rproc_ops,
NULL, sizeof(*priv));
@@ -609,7 +629,6 @@ static int imx_rproc_probe(struct platform_device *pdev)
 
priv = rproc->priv;
priv->rproc = rproc;
-   priv->regmap = regmap;
priv->dcfg = dcfg;
priv->dev = dev;
 
-- 
2.7.4



[PATCH V4 4/8] remoteproc: imx_rproc: parse fsl,auto-boot

2021-04-15 Thread peng . fan
From: Peng Fan 

Parse fsl,auto-boot to indicate whether need remoteproc framework
auto boot or not.

When remote processor is booted before Linux Kernel up, do not parse
fsl,auto-boot, so only need to parse the property when rproc state is
RPROC_DETACHED.

Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index d633887..06dac92 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -654,6 +654,9 @@ static int imx_rproc_probe(struct platform_device *pdev)
 
INIT_WORK(>rproc_work, imx_rproc_vq_work);
 
+   if (rproc->state != RPROC_DETACHED)
+   rproc->auto_boot = of_property_read_bool(np, "fsl,auto-boot");
+
ret = rproc_add(rproc);
if (ret) {
dev_err(dev, "rproc_add failed\n");
-- 
2.7.4



[PATCH V4 3/8] dt-bindings: remoteproc: imx_rproc: support i.MX8MN/P

2021-04-15 Thread peng . fan
From: Peng Fan 

Add i.MX8MN/P remote processor(Cortex-M7) compatible string

Signed-off-by: Peng Fan 
Acked-by: Rob Herring 
---
 Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml 
b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
index 58bc2a2..1dc34cf 100644
--- a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
+++ b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
@@ -17,6 +17,8 @@ properties:
 enum:
   - fsl,imx8mq-cm4
   - fsl,imx8mm-cm4
+  - fsl,imx8mn-cm7
+  - fsl,imx8mp-cm7
   - fsl,imx7d-cm4
   - fsl,imx7ulp-cm4
   - fsl,imx6sx-cm4
-- 
2.7.4



[PATCH V4 2/8] dt-bindings: remoteproc: imx_rproc: add i.MX7ULP support

2021-04-15 Thread peng . fan
From: Peng Fan 

Add i.MX7ULP compatible.

We use i.MX7ULP dual mode and in which case i.MX7ULP A7 core runs under
control of M4 core, M4 core starts by ROM and powers most services used
by A7 core, so A7 core has no power to start and stop M4 core. So
clocks and syscon are not required.

Signed-off-by: Peng Fan 
Acked-by: Rob Herring 
---
 Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml 
b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
index b13bf8d..58bc2a2 100644
--- a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
+++ b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
@@ -18,6 +18,7 @@ properties:
   - fsl,imx8mq-cm4
   - fsl,imx8mm-cm4
   - fsl,imx7d-cm4
+  - fsl,imx7ulp-cm4
   - fsl,imx6sx-cm4
 
   clocks:
@@ -57,8 +58,6 @@ properties:
 
 required:
   - compatible
-  - clocks
-  - syscon
 
 additionalProperties: false
 
-- 
2.7.4



[PATCH V4 1/8] dt-bindings: remoteproc: imx_rproc: add fsl,auto-boot property

2021-04-15 Thread peng . fan
From: Peng Fan 

Add an optional property "fsl,auto-boot" to indicate remote processor
auto boot.

Signed-off-by: Peng Fan 
Acked-by: Rob Herring 
---
 Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml 
b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
index 208a628..b13bf8d 100644
--- a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
+++ b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
@@ -49,6 +49,12 @@ properties:
 minItems: 1
 maxItems: 32
 
+  fsl,auto-boot:
+$ref: /schemas/types.yaml#/definitions/flag
+description:
+  Indicate whether need to load the default firmware and start the remote
+  processor automatically.
+
 required:
   - compatible
   - clocks
-- 
2.7.4



[PATCH V4 0/8] remoteproc: imx_rproc: support i.MX7ULP/8MN/8MP

2021-04-15 Thread peng . fan
From: Peng Fan 

V4:
 Typo fix 
 patch 4: take state as a check condition
 patch 5: move regmap lookup/attach to imx_rproc_detect_mode
 patch 6: add imx_rproc_clk_enable for optional clk
 patch 8: use switch/case in imx_rproc_detect_mode
V3:
 Add A-b tag for Patch 1/2
 Fix the checkpatch warning for Patch 6,8

V2:
 Patch 1/8, use fsl as vendor, typo fix
 Because patchset [1] has v2 version, patch 5,6,7,8 are adapted that
 change.

This patchset is to support i.MX7ULP/8MN/8MP, also includes a patch to
parse fsl,auto-boot


Peng Fan (8):
  dt-bindings: remoteproc: imx_rproc: add fsl,auto-boot property
  dt-bindings: remoteproc: imx_rproc: add i.MX7ULP support
  dt-bindings: remoteproc: imx_rproc: support i.MX8MN/P
  remoteproc: imx_rproc: parse fsl,auto-boot
  remoteproc: imx_rproc: initial support for mutilple start/stop method
  remoteproc: imx_rproc: make clk optional
  remoteproc: imx_rproc: support i.MX7ULP
  remoteproc: imx_rproc: support i.MX8MN/P

 .../bindings/remoteproc/fsl,imx-rproc.yaml |  11 +-
 drivers/remoteproc/imx_rproc.c | 206 +
 2 files changed, 179 insertions(+), 38 deletions(-)

-- 
2.7.4



RE: [EXT] regression due to soc_device_match not handling defer (Was: [PATCH v4 4/4] soc: imx8m: change to use platform driver)

2021-04-14 Thread Peng Fan
> (Was: [PATCH v4 4/4] soc: imx8m: change to use platform driver)
> 
> Alice Guo (OSS) wrote on Tue, Mar 30, 2021 at 02:41:23AM +:
> > Thanks for reporting this issue, I'll check and add a fix to handle defer 
> > probe.
> 
> I haven't seen any follow up on this, have you had a chance to take a look?

We are trying to find a proper solution for this.

The proper method might be make soc_device_match return probe defer,
and take early soc attr into consideration, but I am not sure this would win
maintainer's vote.

> If this won't make it for 5.12 (in a couple of week probably?) would it make
> sense to revert 7d981405d0fd ("soc: imx8m: change to use platform
> driver") for now?

Please no. We are targeting android GKI, make driver as modules.
And reverting to original method will also break kexec.

I am on IRC #linux-imx, we could take more if you would like to.

Thanks,
Peng.

> 
> 
> 
> While looking at the code earlier I also have an unrelated, late-review on the
> patch itself:
> 
> > +static u32 __init imx8mq_soc_revision(struct device *dev)
> > [...]
> >  @@ -191,8 +223,16 @@ static int __init imx8_soc_init(void)
> > data = id->data;
> > if (data) {
> > soc_dev_attr->soc_id = data->name;
> > -   if (data->soc_revision)
> > -   soc_rev = data->soc_revision();
> > +   if (data->soc_revision) {
> > +   if (pdev) {
> > +   soc_rev =
> data->soc_revision(>dev);
> > +   ret = soc_rev;
> > +   if (ret < 0)
> 
> I appreciate current soc_revision are "small enough" (looking at
> include/soc/imx/revision.h we're talking < 256) so this actually works, but
> would it make sense to either make soc_rev signed, or to have
> soc_revision() return a s64, or have the revision filled in another *u32
> argument to make sure the error is an error and not just a large rev?
> 
> This is most definitely fine for now but that kind of code patterns can lead 
> to
> weird errors down the road.
> 
> Thanks,
> --
> Dominique


Re: [PATCH V2 0/8] remoteproc: imx_rproc: support i.MX7ULP/8MN/8MP

2021-04-07 Thread Peng Fan (OSS)




On 2021/4/8 0:18, Mathieu Poirier wrote:

On Tue, Mar 30, 2021 at 05:12:46PM +0800, peng@oss.nxp.com wrote:

From: Peng Fan 

V2:
  Patch 1/8, use fsl as vendor, typo fix
  Because patchset [1] has v2 version, patch 5,6,7,8 are adapted that change.

This patchset is to support i.MX7ULP/8MN/8MP, also includes a patch to parse
imx,auto-boot
This patchset depends on [1]

[1] 
https://patchwork.kernel.org/project/linux-remoteproc/cover/1617082235-15923-1-git-send-email-peng@oss.nxp.com/

Peng Fan (8):
   dt-bindings: remoteproc: imx_rproc: add fsl,auto-boot property
   dt-bindings: remoteproc: imx_rproc: add i.MX7ULP support
   dt-bindings: remoteproc: imx_rproc: support i.MX8MN/P
   remoteproc: imx_rproc: make clk optional
   remoteproc: imx_rproc: parse fsl,auto-boot
   remoteproc: imx_rproc: initial support for mutilple start/stop method
   remoteproc: imx_rproc: support i.MX7ULP
   remoteproc: imx_rproc: support i.MX8MN/P



There are glaring checkpatch warning on this set - the "DT compatible string"
ones are fine but the others are not negotiable.  As such I am dropping this set
entirely.


Ah, sorry for this. I just sent out V3 to address all the checkpatch 
warnings.


Thanks,
Peng.

  

  .../bindings/remoteproc/fsl,imx-rproc.yaml|  11 +-
  drivers/remoteproc/imx_rproc.c| 170 +++---
  2 files changed, 159 insertions(+), 22 deletions(-)

--
2.30.0



[PATCH V3 3/8] dt-bindings: remoteproc: imx_rproc: support i.MX8MN/P

2021-04-07 Thread peng . fan
From: Peng Fan 

Add i.MX8MN/P remote processor(Cortex-M7) compatible string

Signed-off-by: Peng Fan 
Acked-by: Rob Herring 
---
 Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml 
b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
index 58bc2a23f97b..1dc34cf5a4ea 100644
--- a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
+++ b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
@@ -17,6 +17,8 @@ properties:
 enum:
   - fsl,imx8mq-cm4
   - fsl,imx8mm-cm4
+  - fsl,imx8mn-cm7
+  - fsl,imx8mp-cm7
   - fsl,imx7d-cm4
   - fsl,imx7ulp-cm4
   - fsl,imx6sx-cm4
-- 
2.30.0



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

2021-04-07 Thread peng . fan
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, );
+   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, );
+   ret = res.a0;
+   if (res.a1)
+   dev_info(dev, "Not in wfi, force stopped\n");
+   break;
+   default:
+   return -EOPNOTSUPP;
+   }
+
if (ret)
-   dev_err(dev, "Failed to stop M4!\n&

[PATCH V3 7/8] remoteproc: imx_rproc: support i.MX7ULP

2021-04-07 Thread peng . fan
From: Peng Fan 

i.MX7ULP A7 core runs under control of M4 core, M4 core starts by ROM
and powers most serivces used by A7 core, so A7 core has no power to
start and stop M4 core.

Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 25 ++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index a7fa9d7fc2d1..b911a7539897 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -147,6 +147,14 @@ static const struct imx_rproc_att imx_rproc_att_imx8mq[] = 
{
{ 0x4000, 0x4000, 0x8000, 0 },
 };
 
+static const struct imx_rproc_att imx_rproc_att_imx7ulp[] = {
+   {0x1FFD, 0x1FFD, 0x3, ATT_OWN},
+   {0x2000, 0x2000, 0x1, ATT_OWN},
+   {0x2F00, 0x2F00, 0x2, ATT_OWN},
+   {0x2F02, 0x2F02, 0x2, ATT_OWN},
+   {0x6000, 0x6000, 0x4000, 0}
+};
+
 static const struct imx_rproc_att imx_rproc_att_imx7d[] = {
/* dev addr , sys addr  , size  , flags */
/* OCRAM_S (M4 Boot code) - alias */
@@ -207,6 +215,12 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mq = {
.method = IMX_RPROC_MMIO,
 };
 
+static const struct imx_rproc_dcfg imx_rproc_cfg_imx7ulp = {
+   .att= imx_rproc_att_imx7ulp,
+   .att_size   = ARRAY_SIZE(imx_rproc_att_imx7ulp),
+   .method = IMX_RPROC_NONE,
+};
+
 static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = {
.src_reg= IMX7D_SRC_SCR,
.src_mask   = IMX7D_M4_RST_MASK,
@@ -598,12 +612,16 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)
return ret;
}
 
-   if (!(val & dcfg->src_stop)) {
-   priv->rproc->state = RPROC_DETACHED;
+   if (!(val & dcfg->src_stop))
priv->mode = IMX_RPROC_EARLY_BOOT;
-   }
}
 
+   if (dcfg->method == IMX_RPROC_NONE)
+   priv->mode = IMX_RPROC_EARLY_BOOT;
+
+   if (priv->mode == IMX_RPROC_EARLY_BOOT)
+   priv->rproc->state = RPROC_DETACHED;
+
return 0;
 }
 
@@ -724,6 +742,7 @@ static int imx_rproc_remove(struct platform_device *pdev)
 }
 
 static const struct of_device_id imx_rproc_of_match[] = {
+   { .compatible = "fsl,imx7ulp-cm4", .data = _rproc_cfg_imx7ulp },
{ .compatible = "fsl,imx7d-cm4", .data = _rproc_cfg_imx7d },
{ .compatible = "fsl,imx6sx-cm4", .data = _rproc_cfg_imx6sx },
{ .compatible = "fsl,imx8mq-cm4", .data = _rproc_cfg_imx8mq },
-- 
2.30.0



[PATCH V3 5/8] remoteproc: imx_rproc: parse fsl,auto-boot

2021-04-07 Thread peng . fan
From: Peng Fan 

Parse fsl,auto-boot to indicate whether need remoteproc framework
auto boot or not.

When remote processor is booted before Linux Kernel up, do not parse
fsl,auto-boot. So add an entry to store the working mode of remote
processor. Currently only IMX_RPROC_NORMAL, IMX_RPROC_EARLY_BOOT.

Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index ca17f520d904..c576e12d3817 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -83,6 +83,16 @@ struct imx_rproc_dcfg {
size_t  att_size;
 };
 
+enum imx_rproc_mode {
+   /* Linux load/kick remote core */
+   IMX_RPROC_NORMAL,
+   /*
+* remote core booted before kicking Linux, and remote core
+* could be stopped & restarted by Linux
+*/
+   IMX_RPROC_EARLY_BOOT,
+};
+
 struct imx_rproc {
struct device   *dev;
struct regmap   *regmap;
@@ -96,6 +106,7 @@ struct imx_rproc {
struct work_struct  rproc_work;
struct workqueue_struct *workqueue;
void __iomem*rsc_table;
+   enum imx_rproc_mode mode;
 };
 
 static const struct imx_rproc_att imx_rproc_att_imx8mq[] = {
@@ -565,14 +576,18 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)
int ret;
u32 val;
 
+   priv->mode = IMX_RPROC_NORMAL;
+
ret = regmap_read(priv->regmap, dcfg->src_reg, );
if (ret) {
dev_err(dev, "Failed to read src\n");
return ret;
}
 
-   if (!(val & dcfg->src_stop))
+   if (!(val & dcfg->src_stop)) {
+   priv->mode = IMX_RPROC_EARLY_BOOT;
priv->rproc->state = RPROC_DETACHED;
+   }
 
return 0;
 }
@@ -654,6 +669,9 @@ static int imx_rproc_probe(struct platform_device *pdev)
 
INIT_WORK(>rproc_work, imx_rproc_vq_work);
 
+   if (priv->mode == IMX_RPROC_NORMAL)
+   rproc->auto_boot = of_property_read_bool(np, "fsl,auto-boot");
+
ret = rproc_add(rproc);
if (ret) {
dev_err(dev, "rproc_add failed\n");
-- 
2.30.0



[PATCH V3 6/8] remoteproc: imx_rproc: initial support for mutilple start/stop method

2021-04-07 Thread peng . fan
From: Peng Fan 

Add three methods IMX_RPROC_NONE(no need start/stop), IMX_RPROC_MMIO
(start/stop through mmio) and IMX_RPROC_SMC(start/stop through ARM SMCCC).

The current SoCs supported are all using IMX_RPROC_MMIO, add a restrict
in probe that only SoCs using IMX_RPROC_MMIO needs syscon regmap to
access registers.

Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 50 +++---
 1 file changed, 34 insertions(+), 16 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index c576e12d3817..a7fa9d7fc2d1 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -74,6 +74,15 @@ struct imx_rproc_att {
int flags;
 };
 
+/* Remote core start/stop method */
+enum imx_rproc_method {
+   IMX_RPROC_NONE,
+   /* Through syscon regmap */
+   IMX_RPROC_MMIO,
+   /* Through ARM SMCCC */
+   IMX_RPROC_SMC,
+};
+
 struct imx_rproc_dcfg {
u32 src_reg;
u32 src_mask;
@@ -81,6 +90,7 @@ struct imx_rproc_dcfg {
u32 src_stop;
const struct imx_rproc_att  *att;
size_t  att_size;
+   enum imx_rproc_method   method;
 };
 
 enum imx_rproc_mode {
@@ -194,6 +204,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mq = {
.src_stop   = IMX7D_M4_STOP,
.att= imx_rproc_att_imx8mq,
.att_size   = ARRAY_SIZE(imx_rproc_att_imx8mq),
+   .method = IMX_RPROC_MMIO,
 };
 
 static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = {
@@ -203,6 +214,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = {
.src_stop   = IMX7D_M4_STOP,
.att= imx_rproc_att_imx7d,
.att_size   = ARRAY_SIZE(imx_rproc_att_imx7d),
+   .method = IMX_RPROC_MMIO,
 };
 
 static const struct imx_rproc_dcfg imx_rproc_cfg_imx6sx = {
@@ -212,6 +224,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx6sx = {
.src_stop   = IMX6SX_M4_STOP,
.att= imx_rproc_att_imx6sx,
.att_size   = ARRAY_SIZE(imx_rproc_att_imx6sx),
+   .method = IMX_RPROC_MMIO,
 };
 
 static int imx_rproc_start(struct rproc *rproc)
@@ -578,15 +591,17 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)
 
priv->mode = IMX_RPROC_NORMAL;
 
-   ret = regmap_read(priv->regmap, dcfg->src_reg, );
-   if (ret) {
-   dev_err(dev, "Failed to read src\n");
-   return ret;
-   }
+   if (priv->regmap) {
+   ret = regmap_read(priv->regmap, dcfg->src_reg, );
+   if (ret) {
+   dev_err(dev, "Failed to read src\n");
+   return ret;
+   }
 
-   if (!(val & dcfg->src_stop)) {
-   priv->mode = IMX_RPROC_EARLY_BOOT;
-   priv->rproc->state = RPROC_DETACHED;
+   if (!(val & dcfg->src_stop)) {
+   priv->rproc->state = RPROC_DETACHED;
+   priv->mode = IMX_RPROC_EARLY_BOOT;
+   }
}
 
return 0;
@@ -600,16 +615,9 @@ static int imx_rproc_probe(struct platform_device *pdev)
struct rproc *rproc;
struct regmap_config config = { .name = "imx-rproc" };
const struct imx_rproc_dcfg *dcfg;
-   struct regmap *regmap;
+   struct regmap *regmap = NULL;
int ret;
 
-   regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
-   if (IS_ERR(regmap)) {
-   dev_err(dev, "failed to find syscon\n");
-   return PTR_ERR(regmap);
-   }
-   regmap_attach_dev(dev, regmap, );
-
/* set some other name then imx */
rproc = rproc_alloc(dev, "imx-rproc", _rproc_ops,
NULL, sizeof(*priv));
@@ -622,6 +630,16 @@ static int imx_rproc_probe(struct platform_device *pdev)
goto err_put_rproc;
}
 
+   if (dcfg->method == IMX_RPROC_MMIO) {
+   regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
+   if (IS_ERR(regmap)) {
+   dev_err(dev, "failed to find syscon\n");
+   ret = PTR_ERR(regmap);
+   goto err_put_rproc;
+   }
+   regmap_attach_dev(dev, regmap, );
+   }
+
priv = rproc->priv;
priv->rproc = rproc;
priv->regmap = regmap;
-- 
2.30.0



[PATCH V3 4/8] remoteproc: imx_rproc: make clk optional

2021-04-07 Thread peng . fan
From: Peng Fan 

To i.MX7ULP, M4 is the master to control everything, so it not need
clk from A7.

Reviewed-by: Richard Zhu 
Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index d6338872c6db..ca17f520d904 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -635,7 +635,7 @@ static int imx_rproc_probe(struct platform_device *pdev)
if (ret)
goto err_put_mbox;
 
-   priv->clk = devm_clk_get(dev, NULL);
+   priv->clk = devm_clk_get_optional(dev, NULL);
if (IS_ERR(priv->clk)) {
dev_err(dev, "Failed to get clock\n");
ret = PTR_ERR(priv->clk);
-- 
2.30.0



[PATCH V3 1/8] dt-bindings: remoteproc: imx_rproc: add fsl,auto-boot property

2021-04-07 Thread peng . fan
From: Peng Fan 

Add an optional property "fsl,auto-boot" to indicate remote processor
auto boot.

Signed-off-by: Peng Fan 
Acked-by: Rob Herring 
---
 .../devicetree/bindings/remoteproc/fsl,imx-rproc.yaml   | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml 
b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
index 208a628f8d6c..b13bf8d70488 100644
--- a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
+++ b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
@@ -49,6 +49,12 @@ properties:
 minItems: 1
 maxItems: 32
 
+  fsl,auto-boot:
+$ref: /schemas/types.yaml#/definitions/flag
+description:
+  Indicate whether need to load the default firmware and start the remote
+  processor automatically.
+
 required:
   - compatible
   - clocks
-- 
2.30.0



[PATCH V3 2/8] dt-bindings: remoteproc: imx_rproc: add i.MX7ULP support

2021-04-07 Thread peng . fan
From: Peng Fan 

Add i.MX7ULP compatible.

We use i.MX7ULP dual mode and in which case i.MX7ULP A7 core runs under
control of M4 core, M4 core starts by ROM and powers most serivces used
by A7 core, so A7 core has no power to start and stop M4 core. So
clocks and syscon are not required.

Signed-off-by: Peng Fan 
Acked-by: Rob Herring 
---
 .../devicetree/bindings/remoteproc/fsl,imx-rproc.yaml  | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml 
b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
index b13bf8d70488..58bc2a23f97b 100644
--- a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
+++ b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
@@ -18,6 +18,7 @@ properties:
   - fsl,imx8mq-cm4
   - fsl,imx8mm-cm4
   - fsl,imx7d-cm4
+  - fsl,imx7ulp-cm4
   - fsl,imx6sx-cm4
 
   clocks:
@@ -57,8 +58,6 @@ properties:
 
 required:
   - compatible
-  - clocks
-  - syscon
 
 additionalProperties: false
 
-- 
2.30.0



[PATCH V3 0/8] remoteproc: imx_rproc: support i.MX7ULP/8MN/8MP

2021-04-07 Thread peng . fan
From: Peng Fan 

V3:
 Add A-b tag for Patch 1/2
 Fix the checkpatch warning for Patch 6,8

V2:
 Patch 1/8, use fsl as vendor, typo fix
 Because patchset [1] has v2 version, patch 5,6,7,8 are adapted that
 change.

This patchset is to support i.MX7ULP/8MN/8MP, also includes a patch to
parse fsl,auto-boot
This patchset depends on [1]

[1] https://patchwork.kernel.org/project/linux-remoteproc/cover/
1617846289-13496-1-git-send-email-peng@oss.nxp.com/

Peng Fan (8):
  dt-bindings: remoteproc: imx_rproc: add fsl,auto-boot property
  dt-bindings: remoteproc: imx_rproc: add i.MX7ULP support
  dt-bindings: remoteproc: imx_rproc: support i.MX8MN/P
  remoteproc: imx_rproc: make clk optional
  remoteproc: imx_rproc: parse fsl,auto-boot
  remoteproc: imx_rproc: initial support for mutilple start/stop method
  remoteproc: imx_rproc: support i.MX7ULP
  remoteproc: imx_rproc: support i.MX8MN/P

 .../bindings/remoteproc/fsl,imx-rproc.yaml|  11 +-
 drivers/remoteproc/imx_rproc.c| 170 +++---
 2 files changed, 159 insertions(+), 22 deletions(-)

-- 
2.30.0



[PATCH V3 3/4] remoteproc: imx_rproc: move memory parsing to rproc_ops

2021-04-07 Thread peng . fan
From: Peng Fan 

Use the rproc_ops::prepare() hook for doing memory resources
reallocation when reattaching a remote procesor.

Suggested-by: Mathieu Poirier 
Reviewed-by: Mathieu Poirier 
Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index b05aae0ad7a2..7cd09971d1a4 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -317,7 +317,7 @@ static int imx_rproc_mem_release(struct rproc *rproc,
return 0;
 }
 
-static int imx_rproc_parse_memory_regions(struct rproc *rproc)
+static int imx_rproc_prepare(struct rproc *rproc)
 {
struct imx_rproc *priv = rproc->priv;
struct device_node *np = priv->dev->of_node;
@@ -363,10 +363,7 @@ static int imx_rproc_parse_memory_regions(struct rproc 
*rproc)
 
 static int imx_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
 {
-   int ret = imx_rproc_parse_memory_regions(rproc);
-
-   if (ret)
-   return ret;
+   int ret;
 
ret = rproc_elf_load_rsc_table(rproc, fw);
if (ret)
@@ -399,6 +396,7 @@ static void imx_rproc_kick(struct rproc *rproc, int vqid)
 }
 
 static const struct rproc_ops imx_rproc_ops = {
+   .prepare= imx_rproc_prepare,
.start  = imx_rproc_start,
.stop   = imx_rproc_stop,
.kick   = imx_rproc_kick,
-- 
2.30.0



[PATCH V3 4/4] remoteproc: imx_rproc: support remote cores booted before Linux Kernel

2021-04-07 Thread peng . fan
From: Peng Fan 

 - When remote cores are kicked before Linux Kernel, we are not able
   to get resource table from the firmware elf file, so we need to add
   rsc_table to hold the resource table published by remote cores and
   imx_rproc_get_loaded_rsc_table is to get the resource table.
 - Per remoteproc framework, add attach hook for processor in a detached
   state.
 - Add imx_rproc_detect_mode to detect remote cores' working mode to
   set the state which is required by remoteproc framework.

Reviewed-by: Mathieu Poirier 
Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 45 ++
 1 file changed, 45 insertions(+)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 7cd09971d1a4..d6338872c6db 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -95,6 +95,7 @@ struct imx_rproc {
struct mbox_chan*rx_ch;
struct work_struct  rproc_work;
struct workqueue_struct *workqueue;
+   void __iomem*rsc_table;
 };
 
 static const struct imx_rproc_att imx_rproc_att_imx8mq[] = {
@@ -395,8 +396,26 @@ static void imx_rproc_kick(struct rproc *rproc, int vqid)
__func__, vqid, err);
 }
 
+static int imx_rproc_attach(struct rproc *rproc)
+{
+   return 0;
+}
+
+static struct resource_table *imx_rproc_get_loaded_rsc_table(struct rproc 
*rproc, size_t *table_sz)
+{
+   struct imx_rproc *priv = rproc->priv;
+
+   /* The resource table has already been mapped in imx_rproc_addr_init */
+   if (!priv->rsc_table)
+   return NULL;
+
+   *table_sz = SZ_1K;
+   return (struct resource_table *)priv->rsc_table;
+}
+
 static const struct rproc_ops imx_rproc_ops = {
.prepare= imx_rproc_prepare,
+   .attach = imx_rproc_attach,
.start  = imx_rproc_start,
.stop   = imx_rproc_stop,
.kick   = imx_rproc_kick,
@@ -404,6 +423,7 @@ static const struct rproc_ops imx_rproc_ops = {
.load   = rproc_elf_load_segments,
.parse_fw   = imx_rproc_parse_fw,
.find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table,
+   .get_loaded_rsc_table = imx_rproc_get_loaded_rsc_table,
.sanity_check   = rproc_elf_sanity_check,
.get_boot_addr  = rproc_elf_get_boot_addr,
 };
@@ -470,6 +490,8 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
}
priv->mem[b].sys_addr = res.start;
priv->mem[b].size = resource_size();
+   if (!strcmp(node->name, "rsc_table"))
+   priv->rsc_table = priv->mem[b].cpu_addr;
b++;
}
 
@@ -536,6 +558,25 @@ static void imx_rproc_free_mbox(struct rproc *rproc)
mbox_free_channel(priv->rx_ch);
 }
 
+static int imx_rproc_detect_mode(struct imx_rproc *priv)
+{
+   const struct imx_rproc_dcfg *dcfg = priv->dcfg;
+   struct device *dev = priv->dev;
+   int ret;
+   u32 val;
+
+   ret = regmap_read(priv->regmap, dcfg->src_reg, );
+   if (ret) {
+   dev_err(dev, "Failed to read src\n");
+   return ret;
+   }
+
+   if (!(val & dcfg->src_stop))
+   priv->rproc->state = RPROC_DETACHED;
+
+   return 0;
+}
+
 static int imx_rproc_probe(struct platform_device *pdev)
 {
struct device *dev = >dev;
@@ -590,6 +631,10 @@ static int imx_rproc_probe(struct platform_device *pdev)
goto err_put_mbox;
}
 
+   ret = imx_rproc_detect_mode(priv);
+   if (ret)
+   goto err_put_mbox;
+
priv->clk = devm_clk_get(dev, NULL);
if (IS_ERR(priv->clk)) {
dev_err(dev, "Failed to get clock\n");
-- 
2.30.0



[PATCH V3 2/4] remoteproc: imx_rproc: enlarge IMX7D_RPROC_MEM_MAX

2021-04-07 Thread peng . fan
From: Peng Fan 

8 is not enough when we need more, such as resource table for remote cores
that booted before Linux Kernel, so enlarge IMX7D_RPROC_MEM_MAX to 32.
And also rename it to IMX_RPROC_MEM_MAX which make more sense.

Signed-off-by: Peng Fan 
Reviewed-by: Mathieu Poirier 
---
 drivers/remoteproc/imx_rproc.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 077413319f58..b05aae0ad7a2 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -48,7 +48,7 @@
 | IMX6SX_SW_M4C_NON_SCLR_RST \
 | IMX6SX_SW_M4C_RST)
 
-#define IMX7D_RPROC_MEM_MAX8
+#define IMX_RPROC_MEM_MAX  32
 
 /**
  * struct imx_rproc_mem - slim internal memory structure
@@ -88,7 +88,7 @@ struct imx_rproc {
struct regmap   *regmap;
struct rproc*rproc;
const struct imx_rproc_dcfg *dcfg;
-   struct imx_rproc_memmem[IMX7D_RPROC_MEM_MAX];
+   struct imx_rproc_memmem[IMX_RPROC_MEM_MAX];
struct clk  *clk;
struct mbox_client  cl;
struct mbox_chan*tx_ch;
@@ -272,7 +272,7 @@ static void *imx_rproc_da_to_va(struct rproc *rproc, u64 
da, size_t len, bool *i
if (imx_rproc_da_to_sys(priv, da, len, ))
return NULL;
 
-   for (i = 0; i < IMX7D_RPROC_MEM_MAX; i++) {
+   for (i = 0; i < IMX_RPROC_MEM_MAX; i++) {
if (sys >= priv->mem[i].sys_addr && sys + len <
priv->mem[i].sys_addr +  priv->mem[i].size) {
unsigned int offset = sys - priv->mem[i].sys_addr;
@@ -425,7 +425,7 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
if (!(att->flags & ATT_OWN))
continue;
 
-   if (b >= IMX7D_RPROC_MEM_MAX)
+   if (b >= IMX_RPROC_MEM_MAX)
break;
 
priv->mem[b].cpu_addr = devm_ioremap(>dev,
@@ -461,7 +461,7 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
 
of_node_put(node);
 
-   if (b >= IMX7D_RPROC_MEM_MAX)
+   if (b >= IMX_RPROC_MEM_MAX)
break;
 
/* Not use resource version, because we might share region */
-- 
2.30.0



[PATCH V3 1/4] remoteproc: imx_rproc: add missing of_node_put

2021-04-07 Thread peng . fan
From: Peng Fan 

After of_parse_phandle, we need of_node_put to decrease the refcount
of the device_node.

Reported-by: Mathieu Poirier 
Signed-off-by: Peng Fan 
Reviewed-by: Mathieu Poirier 
---
 drivers/remoteproc/imx_rproc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 6d3207ccbaef..077413319f58 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -459,6 +459,8 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
return err;
}
 
+   of_node_put(node);
+
if (b >= IMX7D_RPROC_MEM_MAX)
break;
 
-- 
2.30.0



[PATCH V3 0/4] remoteproc: imx_rproc: support remote cores booted early

2021-04-07 Thread peng . fan
From: Peng Fan 

V3:
 Add R-b tag
 Typo fix in Patch 3
 Align the patch subject using remoteproc: imx_rproc:
 Update commit msg in Patch 4

V2:
 Patch [1,3]/4 is new
 Patch 4/4: Update commit message, drop unneeded code that already implemented 
by core

This patchset is to support booted remote cores could be attached to linux.
- Add missing of_node_put to decrease device node refcount
- Enlarge IMX7D_RPROC_MEM_MAX because need more imx_rproc_mem, such as resource 
table.
- Following stm32 remoteproc practice, move memory parsing to rproc_ops
- Support attaching booted cores, by adding attach, get loaded resource table 
and etc.

Peng Fan (4):
  remoteproc: imx_rproc: add missing of_node_put
  remoteproc: imx_rproc: enlarge IMX7D_RPROC_MEM_MAX
  remoteproc: imx_rproc: move memory parsing to rproc_ops
  remoteproc: imx_rproc: support remote cores booted before Linux Kernel

 drivers/remoteproc/imx_rproc.c | 65 --
 1 file changed, 55 insertions(+), 10 deletions(-)

-- 
2.30.0



Re: [PATCH v1 0/7] imx-gpcv2 improvements

2021-04-07 Thread Peng Fan (OSS)

Hi Lucas,

On 2021/4/8 6:13, Lucas Stach wrote:

Hi Adrien,

I feel like I already mentioned to you some time ago that there is
already a much more complete patch series to add this functionality on
the list [1].

If you want this functionality to go upstream, please help test and
extend this patch series.

Regards,
Lucas

[1] 
https://lore.kernel.org/linux-arm-kernel/20201105174434.1817539-1-l.st...@pengutronix.de/


Would you share what's the issue that block this going forward?

Thanks,
Peng.



Am Mittwoch, dem 07.04.2021 um 23:21 +0200 schrieb Adrien Grassein:

Hi,

This patch set aims is to add the support of the i.MX8 MM power domains
on the mainline kernel.

To achieve this, I do several patches
   - Check errors when reading or writing registers (concerns i.MX8M base
 implementation);
   - Fix power up/down sequence. Handshake was not checked and it was
 not called at the appropriate time (concerns i.MX8M base
implementaions);
   - Allow domains without power sequence control like the HSIOMIX of the
 i.MX8MM.
   - Add some i.MX8MM domains (HSIO and OTGS);
   - Introduce quirks. For example, i.MX8MM OTG domains should not be
 powered off (seen n the source code of th i.MX ATF). Quirks are
easily upgrable for other cases.
   - Finally I defined power domains into the imx8mm.dtb file.

I know that this kind of patch is rejected by NXP ut the other way
(callin ATF directly) was also rejected.

I also know that NXP is concerned abou adding hundred lines of codes for
each new SOC but it' the way it works on Linux. And the "added code"
mainly consist of adding structures, defines and generic methods for
regmap.

If it's a real problem, maybe we can introduc a new "gpcv3" driver for
i.MX8MM, i.MX8MN and i.MX8MP.

Thanks,

Adrien Grassein (7):
   soc: imx: gpcv2: check for errors when r/w registers
   soc: imx: gpcv2: Fix power up/down sequence
   soc: imx: gpcv2: allow domains without power sequence control
   dt-bindings: power: fsl,imx-gpcv2: add definitions for i.MX8MM
   soc: imx: gpcv2: add HSIOMIX and USB domains for i.MX8MM
   soc: imx: gpcv2: add quirks to domains
   arm64: dts: imx8mm: add power-domains

  .../bindings/power/fsl,imx-gpcv2.yaml |   7 +-
  arch/arm64/boot/dts/freescale/imx8mm.dtsi |  35 ++
  drivers/soc/imx/gpcv2.c   | 336 ++
  include/dt-bindings/power/imx8mm-power.h  |  21 ++
  4 files changed, 333 insertions(+), 66 deletions(-)
  create mode 100644 include/dt-bindings/power/imx8mm-power.h






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

2021-03-30 Thread peng . fan
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..c0e96defe2c3 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, );
+   ret = res.a0;
+   break;
+   default:
+   return -ENOTSUPP;
+   }
+
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, );
+   ret = res.a0;
+   if (res.a1)
+   dev_info(dev, "Not in wfi, force stoped\n");
+   break;
+   default:
+   return -ENOTSUPP;
+   }
+
if (ret)
-   dev_err(dev, "Failed to stop M4!\n");
+ 

[PATCH V2 7/8] remoteproc: imx_rproc: support i.MX7ULP

2021-03-30 Thread peng . fan
From: Peng Fan 

i.MX7ULP A7 core runs under control of M4 core, M4 core starts by ROM
and powers most serivces used by A7 core, so A7 core has no power to
start and stop M4 core.

Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 25 ++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index a7fa9d7fc2d1..b911a7539897 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -147,6 +147,14 @@ static const struct imx_rproc_att imx_rproc_att_imx8mq[] = 
{
{ 0x4000, 0x4000, 0x8000, 0 },
 };
 
+static const struct imx_rproc_att imx_rproc_att_imx7ulp[] = {
+   {0x1FFD, 0x1FFD, 0x3, ATT_OWN},
+   {0x2000, 0x2000, 0x1, ATT_OWN},
+   {0x2F00, 0x2F00, 0x2, ATT_OWN},
+   {0x2F02, 0x2F02, 0x2, ATT_OWN},
+   {0x6000, 0x6000, 0x4000, 0}
+};
+
 static const struct imx_rproc_att imx_rproc_att_imx7d[] = {
/* dev addr , sys addr  , size  , flags */
/* OCRAM_S (M4 Boot code) - alias */
@@ -207,6 +215,12 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mq = {
.method = IMX_RPROC_MMIO,
 };
 
+static const struct imx_rproc_dcfg imx_rproc_cfg_imx7ulp = {
+   .att= imx_rproc_att_imx7ulp,
+   .att_size   = ARRAY_SIZE(imx_rproc_att_imx7ulp),
+   .method = IMX_RPROC_NONE,
+};
+
 static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = {
.src_reg= IMX7D_SRC_SCR,
.src_mask   = IMX7D_M4_RST_MASK,
@@ -598,12 +612,16 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)
return ret;
}
 
-   if (!(val & dcfg->src_stop)) {
-   priv->rproc->state = RPROC_DETACHED;
+   if (!(val & dcfg->src_stop))
priv->mode = IMX_RPROC_EARLY_BOOT;
-   }
}
 
+   if (dcfg->method == IMX_RPROC_NONE)
+   priv->mode = IMX_RPROC_EARLY_BOOT;
+
+   if (priv->mode == IMX_RPROC_EARLY_BOOT)
+   priv->rproc->state = RPROC_DETACHED;
+
return 0;
 }
 
@@ -724,6 +742,7 @@ static int imx_rproc_remove(struct platform_device *pdev)
 }
 
 static const struct of_device_id imx_rproc_of_match[] = {
+   { .compatible = "fsl,imx7ulp-cm4", .data = _rproc_cfg_imx7ulp },
{ .compatible = "fsl,imx7d-cm4", .data = _rproc_cfg_imx7d },
{ .compatible = "fsl,imx6sx-cm4", .data = _rproc_cfg_imx6sx },
{ .compatible = "fsl,imx8mq-cm4", .data = _rproc_cfg_imx8mq },
-- 
2.30.0



[PATCH V2 6/8] remoteproc: imx_rproc: initial support for mutilple start/stop method

2021-03-30 Thread peng . fan
From: Peng Fan 

Add three methods IMX_RPROC_NONE(no need start/stop), IMX_RPROC_MMIO(start/stop
through mmio) and IMX_RPROC_SMC(start/stop through ARM SMCCC).

The current SoCs supported are all using IMX_RPROC_MMIO, add a restrict
in probe that only SoCs using IMX_RPROC_MMIO needs syscon regmap to
access registers.

Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 50 +++---
 1 file changed, 34 insertions(+), 16 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index c576e12d3817..a7fa9d7fc2d1 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -74,6 +74,15 @@ struct imx_rproc_att {
int flags;
 };
 
+/* Remote core start/stop method */
+enum imx_rproc_method {
+   IMX_RPROC_NONE,
+   /* Through syscon regmap */
+   IMX_RPROC_MMIO,
+   /* Through ARM SMCCC */
+   IMX_RPROC_SMC,
+};
+
 struct imx_rproc_dcfg {
u32 src_reg;
u32 src_mask;
@@ -81,6 +90,7 @@ struct imx_rproc_dcfg {
u32 src_stop;
const struct imx_rproc_att  *att;
size_t  att_size;
+   enum imx_rproc_method   method;
 };
 
 enum imx_rproc_mode {
@@ -194,6 +204,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mq = {
.src_stop   = IMX7D_M4_STOP,
.att= imx_rproc_att_imx8mq,
.att_size   = ARRAY_SIZE(imx_rproc_att_imx8mq),
+   .method = IMX_RPROC_MMIO,
 };
 
 static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = {
@@ -203,6 +214,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = {
.src_stop   = IMX7D_M4_STOP,
.att= imx_rproc_att_imx7d,
.att_size   = ARRAY_SIZE(imx_rproc_att_imx7d),
+   .method = IMX_RPROC_MMIO,
 };
 
 static const struct imx_rproc_dcfg imx_rproc_cfg_imx6sx = {
@@ -212,6 +224,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx6sx = {
.src_stop   = IMX6SX_M4_STOP,
.att= imx_rproc_att_imx6sx,
.att_size   = ARRAY_SIZE(imx_rproc_att_imx6sx),
+   .method = IMX_RPROC_MMIO,
 };
 
 static int imx_rproc_start(struct rproc *rproc)
@@ -578,15 +591,17 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)
 
priv->mode = IMX_RPROC_NORMAL;
 
-   ret = regmap_read(priv->regmap, dcfg->src_reg, );
-   if (ret) {
-   dev_err(dev, "Failed to read src\n");
-   return ret;
-   }
+   if (priv->regmap) {
+   ret = regmap_read(priv->regmap, dcfg->src_reg, );
+   if (ret) {
+   dev_err(dev, "Failed to read src\n");
+   return ret;
+   }
 
-   if (!(val & dcfg->src_stop)) {
-   priv->mode = IMX_RPROC_EARLY_BOOT;
-   priv->rproc->state = RPROC_DETACHED;
+   if (!(val & dcfg->src_stop)) {
+   priv->rproc->state = RPROC_DETACHED;
+   priv->mode = IMX_RPROC_EARLY_BOOT;
+   }
}
 
return 0;
@@ -600,16 +615,9 @@ static int imx_rproc_probe(struct platform_device *pdev)
struct rproc *rproc;
struct regmap_config config = { .name = "imx-rproc" };
const struct imx_rproc_dcfg *dcfg;
-   struct regmap *regmap;
+   struct regmap *regmap = NULL;
int ret;
 
-   regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
-   if (IS_ERR(regmap)) {
-   dev_err(dev, "failed to find syscon\n");
-   return PTR_ERR(regmap);
-   }
-   regmap_attach_dev(dev, regmap, );
-
/* set some other name then imx */
rproc = rproc_alloc(dev, "imx-rproc", _rproc_ops,
NULL, sizeof(*priv));
@@ -622,6 +630,16 @@ static int imx_rproc_probe(struct platform_device *pdev)
goto err_put_rproc;
}
 
+   if (dcfg->method == IMX_RPROC_MMIO) {
+   regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
+   if (IS_ERR(regmap)) {
+   dev_err(dev, "failed to find syscon\n");
+   ret = PTR_ERR(regmap);
+   goto err_put_rproc;
+   }
+   regmap_attach_dev(dev, regmap, );
+   }
+
priv = rproc->priv;
priv->rproc = rproc;
priv->regmap = regmap;
-- 
2.30.0



[PATCH V2 5/8] remoteproc: imx_rproc: parse fsl,auto-boot

2021-03-30 Thread peng . fan
From: Peng Fan 

Parse fsl,auto-boot to indicate whether need remoteproc framework
auto boot or not.

When remote processor is booted before Linux Kernel up, do not parse
fsl,auto-boot. So add an entry to store the working mode of remote
processor. Currently only IMX_RPROC_NORMAL, IMX_RPROC_EARLY_BOOT.

Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 20 +++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index ca17f520d904..c576e12d3817 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -83,6 +83,16 @@ struct imx_rproc_dcfg {
size_t  att_size;
 };
 
+enum imx_rproc_mode {
+   /* Linux load/kick remote core */
+   IMX_RPROC_NORMAL,
+   /*
+* remote core booted before kicking Linux, and remote core
+* could be stopped & restarted by Linux
+*/
+   IMX_RPROC_EARLY_BOOT,
+};
+
 struct imx_rproc {
struct device   *dev;
struct regmap   *regmap;
@@ -96,6 +106,7 @@ struct imx_rproc {
struct work_struct  rproc_work;
struct workqueue_struct *workqueue;
void __iomem*rsc_table;
+   enum imx_rproc_mode mode;
 };
 
 static const struct imx_rproc_att imx_rproc_att_imx8mq[] = {
@@ -565,14 +576,18 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)
int ret;
u32 val;
 
+   priv->mode = IMX_RPROC_NORMAL;
+
ret = regmap_read(priv->regmap, dcfg->src_reg, );
if (ret) {
dev_err(dev, "Failed to read src\n");
return ret;
}
 
-   if (!(val & dcfg->src_stop))
+   if (!(val & dcfg->src_stop)) {
+   priv->mode = IMX_RPROC_EARLY_BOOT;
priv->rproc->state = RPROC_DETACHED;
+   }
 
return 0;
 }
@@ -654,6 +669,9 @@ static int imx_rproc_probe(struct platform_device *pdev)
 
INIT_WORK(>rproc_work, imx_rproc_vq_work);
 
+   if (priv->mode == IMX_RPROC_NORMAL)
+   rproc->auto_boot = of_property_read_bool(np, "fsl,auto-boot");
+
ret = rproc_add(rproc);
if (ret) {
dev_err(dev, "rproc_add failed\n");
-- 
2.30.0



[PATCH V2 4/8] remoteproc: imx_rproc: make clk optional

2021-03-30 Thread peng . fan
From: Peng Fan 

To i.MX7ULP, M4 is the master to control everything, so it not need
clk from A7.

Reviewed-by: Richard Zhu 
Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index d6338872c6db..ca17f520d904 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -635,7 +635,7 @@ static int imx_rproc_probe(struct platform_device *pdev)
if (ret)
goto err_put_mbox;
 
-   priv->clk = devm_clk_get(dev, NULL);
+   priv->clk = devm_clk_get_optional(dev, NULL);
if (IS_ERR(priv->clk)) {
dev_err(dev, "Failed to get clock\n");
ret = PTR_ERR(priv->clk);
-- 
2.30.0



[PATCH V2 3/8] dt-bindings: remoteproc: imx_rproc: support i.MX8MN/P

2021-03-30 Thread peng . fan
From: Peng Fan 

Add i.MX8MN/P remote processor(Cortex-M7) compatible string

Signed-off-by: Peng Fan 
Acked-by: Rob Herring 
---
 Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml 
b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
index 58bc2a23f97b..1dc34cf5a4ea 100644
--- a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
+++ b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
@@ -17,6 +17,8 @@ properties:
 enum:
   - fsl,imx8mq-cm4
   - fsl,imx8mm-cm4
+  - fsl,imx8mn-cm7
+  - fsl,imx8mp-cm7
   - fsl,imx7d-cm4
   - fsl,imx7ulp-cm4
   - fsl,imx6sx-cm4
-- 
2.30.0



[PATCH V2 1/8] dt-bindings: remoteproc: imx_rproc: add fsl,auto-boot property

2021-03-30 Thread peng . fan
From: Peng Fan 

Add an optional property "fsl,auto-boot" to indicate remote processor
auto boot.

Signed-off-by: Peng Fan 
---
 .../devicetree/bindings/remoteproc/fsl,imx-rproc.yaml   | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml 
b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
index 208a628f8d6c..b13bf8d70488 100644
--- a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
+++ b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
@@ -49,6 +49,12 @@ properties:
 minItems: 1
 maxItems: 32
 
+  fsl,auto-boot:
+$ref: /schemas/types.yaml#/definitions/flag
+description:
+  Indicate whether need to load the default firmware and start the remote
+  processor automatically.
+
 required:
   - compatible
   - clocks
-- 
2.30.0



[PATCH V2 2/8] dt-bindings: remoteproc: imx_rproc: add i.MX7ULP support

2021-03-30 Thread peng . fan
From: Peng Fan 

Add i.MX7ULP compatible.

We use i.MX7ULP dual mode and in which case i.MX7ULP A7 core runs under
control of M4 core, M4 core starts by ROM and powers most serivces used
by A7 core, so A7 core has no power to start and stop M4 core. So
clocks and syscon are not required.

Signed-off-by: Peng Fan 
---
 .../devicetree/bindings/remoteproc/fsl,imx-rproc.yaml  | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml 
b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
index b13bf8d70488..58bc2a23f97b 100644
--- a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
+++ b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
@@ -18,6 +18,7 @@ properties:
   - fsl,imx8mq-cm4
   - fsl,imx8mm-cm4
   - fsl,imx7d-cm4
+  - fsl,imx7ulp-cm4
   - fsl,imx6sx-cm4
 
   clocks:
@@ -57,8 +58,6 @@ properties:
 
 required:
   - compatible
-  - clocks
-  - syscon
 
 additionalProperties: false
 
-- 
2.30.0



[PATCH V2 0/8] remoteproc: imx_rproc: support i.MX7ULP/8MN/8MP

2021-03-30 Thread peng . fan
From: Peng Fan 

V2:
 Patch 1/8, use fsl as vendor, typo fix
 Because patchset [1] has v2 version, patch 5,6,7,8 are adapted that change.

This patchset is to support i.MX7ULP/8MN/8MP, also includes a patch to parse
imx,auto-boot
This patchset depends on [1]

[1] 
https://patchwork.kernel.org/project/linux-remoteproc/cover/1617082235-15923-1-git-send-email-peng@oss.nxp.com/

Peng Fan (8):
  dt-bindings: remoteproc: imx_rproc: add fsl,auto-boot property
  dt-bindings: remoteproc: imx_rproc: add i.MX7ULP support
  dt-bindings: remoteproc: imx_rproc: support i.MX8MN/P
  remoteproc: imx_rproc: make clk optional
  remoteproc: imx_rproc: parse fsl,auto-boot
  remoteproc: imx_rproc: initial support for mutilple start/stop method
  remoteproc: imx_rproc: support i.MX7ULP
  remoteproc: imx_rproc: support i.MX8MN/P

 .../bindings/remoteproc/fsl,imx-rproc.yaml|  11 +-
 drivers/remoteproc/imx_rproc.c| 170 +++---
 2 files changed, 159 insertions(+), 22 deletions(-)

-- 
2.30.0



[PATCH V2 3/4] remoteproc: imx: move memory parsing to rproc_ops

2021-03-29 Thread peng . fan
From: Peng Fan 

Use the rproc_ops::prepare() hook for doing memory resources
reallocation when reattach an remote procesor.

Suggested-by: Mathieu Poirier 
Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index b05aae0ad7a2..7cd09971d1a4 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -317,7 +317,7 @@ static int imx_rproc_mem_release(struct rproc *rproc,
return 0;
 }
 
-static int imx_rproc_parse_memory_regions(struct rproc *rproc)
+static int imx_rproc_prepare(struct rproc *rproc)
 {
struct imx_rproc *priv = rproc->priv;
struct device_node *np = priv->dev->of_node;
@@ -363,10 +363,7 @@ static int imx_rproc_parse_memory_regions(struct rproc 
*rproc)
 
 static int imx_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
 {
-   int ret = imx_rproc_parse_memory_regions(rproc);
-
-   if (ret)
-   return ret;
+   int ret;
 
ret = rproc_elf_load_rsc_table(rproc, fw);
if (ret)
@@ -399,6 +396,7 @@ static void imx_rproc_kick(struct rproc *rproc, int vqid)
 }
 
 static const struct rproc_ops imx_rproc_ops = {
+   .prepare= imx_rproc_prepare,
.start  = imx_rproc_start,
.stop   = imx_rproc_stop,
.kick   = imx_rproc_kick,
-- 
2.30.0



[PATCH V2 4/4] remoteproc: imx_rproc: support remote cores booted before Linux Kernel

2021-03-29 Thread peng . fan
From: Peng Fan 

 - Add rsc_table to hold the resource table published by remote cores.
 - Add attach hook.
 - Add imx_rproc_get_loaded_rsc_table to get resource table published by
   remote processors.
 - Add imx_rproc_detect_mode to detect remote cores' working mode.

Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 45 ++
 1 file changed, 45 insertions(+)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 7cd09971d1a4..d6338872c6db 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -95,6 +95,7 @@ struct imx_rproc {
struct mbox_chan*rx_ch;
struct work_struct  rproc_work;
struct workqueue_struct *workqueue;
+   void __iomem*rsc_table;
 };
 
 static const struct imx_rproc_att imx_rproc_att_imx8mq[] = {
@@ -395,8 +396,26 @@ static void imx_rproc_kick(struct rproc *rproc, int vqid)
__func__, vqid, err);
 }
 
+static int imx_rproc_attach(struct rproc *rproc)
+{
+   return 0;
+}
+
+static struct resource_table *imx_rproc_get_loaded_rsc_table(struct rproc 
*rproc, size_t *table_sz)
+{
+   struct imx_rproc *priv = rproc->priv;
+
+   /* The resource table has already been mapped in imx_rproc_addr_init */
+   if (!priv->rsc_table)
+   return NULL;
+
+   *table_sz = SZ_1K;
+   return (struct resource_table *)priv->rsc_table;
+}
+
 static const struct rproc_ops imx_rproc_ops = {
.prepare= imx_rproc_prepare,
+   .attach = imx_rproc_attach,
.start  = imx_rproc_start,
.stop   = imx_rproc_stop,
.kick   = imx_rproc_kick,
@@ -404,6 +423,7 @@ static const struct rproc_ops imx_rproc_ops = {
.load   = rproc_elf_load_segments,
.parse_fw   = imx_rproc_parse_fw,
.find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table,
+   .get_loaded_rsc_table = imx_rproc_get_loaded_rsc_table,
.sanity_check   = rproc_elf_sanity_check,
.get_boot_addr  = rproc_elf_get_boot_addr,
 };
@@ -470,6 +490,8 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
}
priv->mem[b].sys_addr = res.start;
priv->mem[b].size = resource_size();
+   if (!strcmp(node->name, "rsc_table"))
+   priv->rsc_table = priv->mem[b].cpu_addr;
b++;
}
 
@@ -536,6 +558,25 @@ static void imx_rproc_free_mbox(struct rproc *rproc)
mbox_free_channel(priv->rx_ch);
 }
 
+static int imx_rproc_detect_mode(struct imx_rproc *priv)
+{
+   const struct imx_rproc_dcfg *dcfg = priv->dcfg;
+   struct device *dev = priv->dev;
+   int ret;
+   u32 val;
+
+   ret = regmap_read(priv->regmap, dcfg->src_reg, );
+   if (ret) {
+   dev_err(dev, "Failed to read src\n");
+   return ret;
+   }
+
+   if (!(val & dcfg->src_stop))
+   priv->rproc->state = RPROC_DETACHED;
+
+   return 0;
+}
+
 static int imx_rproc_probe(struct platform_device *pdev)
 {
struct device *dev = >dev;
@@ -590,6 +631,10 @@ static int imx_rproc_probe(struct platform_device *pdev)
goto err_put_mbox;
}
 
+   ret = imx_rproc_detect_mode(priv);
+   if (ret)
+   goto err_put_mbox;
+
priv->clk = devm_clk_get(dev, NULL);
if (IS_ERR(priv->clk)) {
dev_err(dev, "Failed to get clock\n");
-- 
2.30.0



[PATCH V2 1/4] remoteproc: imx: add missing of_node_put

2021-03-29 Thread peng . fan
From: Peng Fan 

After of_parse_phandle, we need of_node_put to decrease the refcount
of the device_node.

Reported-by: Mathieu Poirier 
Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 6d3207ccbaef..077413319f58 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -459,6 +459,8 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
return err;
}
 
+   of_node_put(node);
+
if (b >= IMX7D_RPROC_MEM_MAX)
break;
 
-- 
2.30.0



[PATCH V2 2/4] remoteproc: imx_rproc: enlarge IMX7D_RPROC_MEM_MAX

2021-03-29 Thread peng . fan
From: Peng Fan 

8 is not enough when we need more, such as resource table for remote cores
that booted before Linux Kernel, so enlarge IMX7D_RPROC_MEM_MAX to 32.
And also rename it to IMX_RPROC_MEM_MAX which make more sense.

Signed-off-by: Peng Fan 
Reviewed-by: Mathieu Poirier 
---
 drivers/remoteproc/imx_rproc.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 077413319f58..b05aae0ad7a2 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -48,7 +48,7 @@
 | IMX6SX_SW_M4C_NON_SCLR_RST \
 | IMX6SX_SW_M4C_RST)
 
-#define IMX7D_RPROC_MEM_MAX8
+#define IMX_RPROC_MEM_MAX  32
 
 /**
  * struct imx_rproc_mem - slim internal memory structure
@@ -88,7 +88,7 @@ struct imx_rproc {
struct regmap   *regmap;
struct rproc*rproc;
const struct imx_rproc_dcfg *dcfg;
-   struct imx_rproc_memmem[IMX7D_RPROC_MEM_MAX];
+   struct imx_rproc_memmem[IMX_RPROC_MEM_MAX];
struct clk  *clk;
struct mbox_client  cl;
struct mbox_chan*tx_ch;
@@ -272,7 +272,7 @@ static void *imx_rproc_da_to_va(struct rproc *rproc, u64 
da, size_t len, bool *i
if (imx_rproc_da_to_sys(priv, da, len, ))
return NULL;
 
-   for (i = 0; i < IMX7D_RPROC_MEM_MAX; i++) {
+   for (i = 0; i < IMX_RPROC_MEM_MAX; i++) {
if (sys >= priv->mem[i].sys_addr && sys + len <
priv->mem[i].sys_addr +  priv->mem[i].size) {
unsigned int offset = sys - priv->mem[i].sys_addr;
@@ -425,7 +425,7 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
if (!(att->flags & ATT_OWN))
continue;
 
-   if (b >= IMX7D_RPROC_MEM_MAX)
+   if (b >= IMX_RPROC_MEM_MAX)
break;
 
priv->mem[b].cpu_addr = devm_ioremap(>dev,
@@ -461,7 +461,7 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
 
of_node_put(node);
 
-   if (b >= IMX7D_RPROC_MEM_MAX)
+   if (b >= IMX_RPROC_MEM_MAX)
break;
 
/* Not use resource version, because we might share region */
-- 
2.30.0



[PATCH V2 0/4] remoteproc: imx: support remote cores booted early

2021-03-29 Thread peng . fan
From: Peng Fan 

V2:
 Patch [1,3]/4 is new
 Patch 4/4: Update commit message, drop unneeded code that already implemented 
by core

This patchset is to support booted remote cores could be attached to linux.
- Add missing of_node_put to decrease device node refcount
- Enlarge IMX7D_RPROC_MEM_MAX because need more imx_rproc_mem, such as resource 
table.
- Following stm32 remoteproc practice, move memory parsing to rproc_ops
- Support attaching booted cores, by adding attach, get loaded resource table 
and etc.

Peng Fan (4):
  remoteproc: imx: add missing of_node_put
  remoteproc: imx_rproc: enlarge IMX7D_RPROC_MEM_MAX
  remoteproc: imx: move memory parsing to rproc_ops
  remoteproc: imx_rproc: support remote cores booted before Linux Kernel

 drivers/remoteproc/imx_rproc.c | 65 --
 1 file changed, 55 insertions(+), 10 deletions(-)

-- 
2.30.0



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

2021-03-22 Thread peng . fan
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 79a6b65d60b6..948139321330 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 {
void __iomem*rsc_table;
 };
 
+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, );
+   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, );
+   ret = res.a0;
+   if (res.a1)
+   dev_info(dev, "Not in wfi, force stopped\n");
+   break;
+   default:
+   return -EOPNOTSUPP;
+   }
+
if (ret)
-   dev_err(dev, "Fail

[PATCH 4/8] remoteproc: imx_rproc: make clk optional

2021-03-22 Thread peng . fan
From: Peng Fan 

To i.MX7ULP, M4 is the master to control everything, so it not need
clk from A7.

Reviewed-by: Richard Zhu 
Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index fdaaf7599cc8..e858c1af4353 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -654,7 +654,7 @@ static int imx_rproc_probe(struct platform_device *pdev)
if (ret)
goto err_put_mbox;
 
-   priv->clk = devm_clk_get(dev, NULL);
+   priv->clk = devm_clk_get_optional(dev, NULL);
if (IS_ERR(priv->clk)) {
dev_err(dev, "Failed to get clock\n");
ret = PTR_ERR(priv->clk);
-- 
2.30.0



[PATCH 6/8] remoteproc: imx_rproc: initial support for mutilple start/stop method

2021-03-22 Thread peng . fan
From: Peng Fan 

Add three methods IMX_RPROC_NONE(no need start/stop),
IMX_RPROC_MMIO(start/stop through mmio) and IMX_RPROC_SMC
(start/stop through ARM SMCCC).

The current SoCs supported are all using IMX_RPROC_MMIO, add a restrict
in probe that only SoCs using IMX_RPROC_MMIO needs syscon regmap to
access registers.

Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 52 +++---
 1 file changed, 35 insertions(+), 17 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index f31b258201c2..8e545b654e54 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -84,6 +84,15 @@ enum imx_rproc_mode {
IMX_RPROC_EARLY_BOOT,
 };
 
+/* Remote core start/stop method */
+enum imx_rproc_method {
+   IMX_RPROC_NONE,
+   /* Through syscon regmap */
+   IMX_RPROC_MMIO,
+   /* Through ARM SMCCC */
+   IMX_RPROC_SMC,
+};
+
 struct imx_rproc_dcfg {
u32 src_reg;
u32 src_mask;
@@ -91,6 +100,7 @@ struct imx_rproc_dcfg {
u32 src_stop;
const struct imx_rproc_att  *att;
size_t  att_size;
+   enum imx_rproc_method   method;
 };
 
 struct imx_rproc {
@@ -194,6 +204,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mq = {
.src_stop   = IMX7D_M4_STOP,
.att= imx_rproc_att_imx8mq,
.att_size   = ARRAY_SIZE(imx_rproc_att_imx8mq),
+   .method = IMX_RPROC_MMIO,
 };
 
 static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = {
@@ -203,6 +214,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = {
.src_stop   = IMX7D_M4_STOP,
.att= imx_rproc_att_imx7d,
.att_size   = ARRAY_SIZE(imx_rproc_att_imx7d),
+   .method = IMX_RPROC_MMIO,
 };
 
 static const struct imx_rproc_dcfg imx_rproc_cfg_imx6sx = {
@@ -212,6 +224,7 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx6sx = {
.src_stop   = IMX6SX_M4_STOP,
.att= imx_rproc_att_imx6sx,
.att_size   = ARRAY_SIZE(imx_rproc_att_imx6sx),
+   .method = IMX_RPROC_MMIO,
 };
 
 static int imx_rproc_start(struct rproc *rproc)
@@ -567,16 +580,18 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)
int ret;
u32 val;
 
-   ret = regmap_read(priv->regmap, dcfg->src_reg, );
-   if (ret) {
-   dev_err(dev, "Failed to read src\n");
-   return ret;
-   }
+   if (priv->regmap) {
+   ret = regmap_read(priv->regmap, dcfg->src_reg, );
+   if (ret) {
+   dev_err(dev, "Failed to read src\n");
+   return ret;
+   }
 
-   if (!(val & dcfg->src_stop))
-   priv->mode = IMX_RPROC_EARLY_BOOT;
-   else
-   priv->mode = IMX_RPROC_NORMAL;
+   if (!(val & dcfg->src_stop))
+   priv->mode = IMX_RPROC_EARLY_BOOT;
+   else
+   priv->mode = IMX_RPROC_NORMAL;
+   }
 
if (priv->mode == IMX_RPROC_EARLY_BOOT) {
priv->rproc->state = RPROC_DETACHED;
@@ -604,16 +619,9 @@ static int imx_rproc_probe(struct platform_device *pdev)
struct rproc *rproc;
struct regmap_config config = { .name = "imx-rproc" };
const struct imx_rproc_dcfg *dcfg;
-   struct regmap *regmap;
+   struct regmap *regmap = NULL;
int ret;
 
-   regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
-   if (IS_ERR(regmap)) {
-   dev_err(dev, "failed to find syscon\n");
-   return PTR_ERR(regmap);
-   }
-   regmap_attach_dev(dev, regmap, );
-
/* set some other name then imx */
rproc = rproc_alloc(dev, "imx-rproc", _rproc_ops,
NULL, sizeof(*priv));
@@ -626,6 +634,16 @@ static int imx_rproc_probe(struct platform_device *pdev)
goto err_put_rproc;
}
 
+   if (dcfg->method == IMX_RPROC_MMIO) {
+   regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
+   if (IS_ERR(regmap)) {
+   dev_err(dev, "failed to find syscon\n");
+   ret = PTR_ERR(regmap);
+   goto err_put_rproc;
+   }
+   regmap_attach_dev(dev, regmap, );
+   }
+
priv = rproc->priv;
priv->rproc = rproc;
priv->regmap = regmap;
-- 
2.30.0



[PATCH 7/8] remoteproc: imx_rproc: support i.MX7ULP

2021-03-22 Thread peng . fan
From: Peng Fan 

i.MX7ULP A7 core runs under control of M4 core, M4 core starts by ROM
and powers most serivces used by A7 core, so A7 core has no power to
start and stop M4 core.

Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 8e545b654e54..79a6b65d60b6 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -147,6 +147,14 @@ static const struct imx_rproc_att imx_rproc_att_imx8mq[] = 
{
{ 0x4000, 0x4000, 0x8000, 0 },
 };
 
+static const struct imx_rproc_att imx_rproc_att_imx7ulp[] = {
+   {0x1FFD, 0x1FFD, 0x3, ATT_OWN},
+   {0x2000, 0x2000, 0x1, ATT_OWN},
+   {0x2F00, 0x2F00, 0x2, ATT_OWN},
+   {0x2F02, 0x2F02, 0x2, ATT_OWN},
+   {0x6000, 0x6000, 0x4000, 0}
+};
+
 static const struct imx_rproc_att imx_rproc_att_imx7d[] = {
/* dev addr , sys addr  , size  , flags */
/* OCRAM_S (M4 Boot code) - alias */
@@ -207,6 +215,12 @@ static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mq = {
.method = IMX_RPROC_MMIO,
 };
 
+static const struct imx_rproc_dcfg imx_rproc_cfg_imx7ulp = {
+   .att= imx_rproc_att_imx7ulp,
+   .att_size   = ARRAY_SIZE(imx_rproc_att_imx7ulp),
+   .method = IMX_RPROC_NONE,
+};
+
 static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = {
.src_reg= IMX7D_SRC_SCR,
.src_mask   = IMX7D_M4_RST_MASK,
@@ -593,6 +607,9 @@ static int imx_rproc_detect_mode(struct imx_rproc *priv)
priv->mode = IMX_RPROC_NORMAL;
}
 
+   if (dcfg->method == IMX_RPROC_NONE)
+   priv->mode = IMX_RPROC_EARLY_BOOT;
+
if (priv->mode == IMX_RPROC_EARLY_BOOT) {
priv->rproc->state = RPROC_DETACHED;
 
@@ -728,6 +745,7 @@ static int imx_rproc_remove(struct platform_device *pdev)
 }
 
 static const struct of_device_id imx_rproc_of_match[] = {
+   { .compatible = "fsl,imx7ulp-cm4", .data = _rproc_cfg_imx7ulp },
{ .compatible = "fsl,imx7d-cm4", .data = _rproc_cfg_imx7d },
{ .compatible = "fsl,imx6sx-cm4", .data = _rproc_cfg_imx6sx },
{ .compatible = "fsl,imx8mq-cm4", .data = _rproc_cfg_imx8mq },
-- 
2.30.0



[PATCH 5/8] remoteproc: imx_rproc: parse imx,auto-boot

2021-03-22 Thread peng . fan
From: Peng Fan 

Parse imx,auto-boot to indicate whether need remoteproc framework
auto boot or not.

Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index e858c1af4353..f31b258201c2 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -673,6 +673,9 @@ static int imx_rproc_probe(struct platform_device *pdev)
 
INIT_WORK(>rproc_work, imx_rproc_vq_work);
 
+   if (priv->mode == IMX_RPROC_NORMAL)
+   rproc->auto_boot = of_property_read_bool(np, "imx,auto-boot");
+
ret = rproc_add(rproc);
if (ret) {
dev_err(dev, "rproc_add failed\n");
-- 
2.30.0



[PATCH 3/8] dt-bindings: remoteproc: imx_rproc: support i.MX8MN/P

2021-03-22 Thread peng . fan
From: Peng Fan 

Add i.MX8MN/P remote processor(Cortex-M7) compatible string

Signed-off-by: Peng Fan 
---
 Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml 
b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
index 3040420ad6a3..dea92538b983 100644
--- a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
+++ b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
@@ -17,6 +17,8 @@ properties:
 enum:
   - fsl,imx8mq-cm4
   - fsl,imx8mm-cm4
+  - fsl,imx8mn-cm7
+  - fsl,imx8mp-cm7
   - fsl,imx7d-cm4
   - fsl,imx7ulp-cm4
   - fsl,imx6sx-cm4
-- 
2.30.0



[PATCH 1/8] dt-bindings: remoteproc: imx_rproc: add imx,auto-boot property

2021-03-22 Thread peng . fan
From: Peng Fan 

Add an optional property "imx,auto-boot" to indicate remote processor
auto boot.

Signed-off-by: Peng Fan 
---
 .../devicetree/bindings/remoteproc/fsl,imx-rproc.yaml   | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml 
b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
index 208a628f8d6c..70aec1a2e86d 100644
--- a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
+++ b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
@@ -49,6 +49,12 @@ properties:
 minItems: 1
 maxItems: 32
 
+  imx,auto-boot:
+$ref: /schemas/types.yaml#/definitions/flag
+description:
+  Indicate whether need to loads the default firmware and starts the remote
+  processor automatically.
+
 required:
   - compatible
   - clocks
-- 
2.30.0



[PATCH 2/8] dt-bindings: remoteproc: imx_rproc: add i.MX7ULP support

2021-03-22 Thread peng . fan
From: Peng Fan 

Add i.MX7ULP compatible.

We use i.MX7ULP dual mode and in which case i.MX7ULP A7 core runs under
control of M4 core, M4 core starts by ROM and powers most serivces used
by A7 core, so A7 core has no power to start and stop M4 core. So
clocks and syscon are not required.

Signed-off-by: Peng Fan 
---
 .../devicetree/bindings/remoteproc/fsl,imx-rproc.yaml  | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml 
b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
index 70aec1a2e86d..3040420ad6a3 100644
--- a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
+++ b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
@@ -18,6 +18,7 @@ properties:
   - fsl,imx8mq-cm4
   - fsl,imx8mm-cm4
   - fsl,imx7d-cm4
+  - fsl,imx7ulp-cm4
   - fsl,imx6sx-cm4
 
   clocks:
@@ -57,8 +58,6 @@ properties:
 
 required:
   - compatible
-  - clocks
-  - syscon
 
 additionalProperties: false
 
-- 
2.30.0



[PATCH 0/8] remoteproc: imx_rproc: support i.MX7ULP/8MN/8MP

2021-03-22 Thread peng . fan
From: Peng Fan 

This patchset is to support i.MX7ULP/8MN/8MP, also includes a patch to parse
imx,auto-boot
This patchset depends on [1][2]

[1] 
https://patchwork.kernel.org/project/linux-remoteproc/patch/20210319104708.7754-1-peng@oss.nxp.com/
[2] 
https://patchwork.kernel.org/project/linux-remoteproc/patch/20210319104708.7754-2-peng@oss.nxp.com/

Peng Fan (8):
  dt-bindings: remoteproc: imx_rproc: add imx,auto-boot property
  dt-bindings: remoteproc: imx_rproc: add i.MX7ULP support
  dt-bindings: remoteproc: imx_rproc: support i.MX8MN/P
  remoteproc: imx_rproc: make clk optional
  remoteproc: imx_rproc: parse imx,auto-boot
  remoteproc: imx_rproc: initial support for mutilple start/stop method
  remoteproc: imx_rproc: support i.MX7ULP
  remoteproc: imx_rproc: support i.MX8MN/P

 .../bindings/remoteproc/fsl,imx-rproc.yaml|  11 +-
 drivers/remoteproc/imx_rproc.c| 158 +++---
 2 files changed, 145 insertions(+), 24 deletions(-)

-- 
2.30.0



RE: [PATCH 1/1] firmware: imx: scu-pd: add missed ADC1 pd

2021-03-21 Thread Peng Fan
> Subject: [PATCH 1/1] firmware: imx: scu-pd: add missed ADC1 pd
> 
> ADC1 is not defined in pd driver on 8QM.
> 
> Signed-off-by: Frank Li 
> Reviewed-by: Dong Aisheng 
> ---
>  drivers/firmware/imx/scu-pd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/firmware/imx/scu-pd.c b/drivers/firmware/imx/scu-pd.c
> index 338800d16c653..966de5e5fc44a 100644
> --- a/drivers/firmware/imx/scu-pd.c
> +++ b/drivers/firmware/imx/scu-pd.c
> @@ -136,7 +136,7 @@ static const struct imx_sc_pd_range
> imx8qxp_scu_pd_ranges[] = {
>   { "can", IMX_SC_R_CAN_0, 3, true, 0 },
>   { "ftm", IMX_SC_R_FTM_0, 2, true, 0 },
>   { "lpi2c", IMX_SC_R_I2C_0, 4, true, 0 },
> - { "adc", IMX_SC_R_ADC_0, 1, true, 0 },
> + { "adc", IMX_SC_R_ADC_0, 2, true, 0 },
>   { "lcd", IMX_SC_R_LCD_0, 1, true, 0 },
>       { "lcd0-pwm", IMX_SC_R_LCD_0_PWM_0, 1, true, 0 },
>   { "lpuart", IMX_SC_R_UART_0, 4, true, 0 },
> --

Reviewed-by: Peng Fan 


[PATCH 2/2] remoteproc: imx_rproc: support remote cores booted before Linux Kernel

2021-03-19 Thread Peng Fan (OSS)
From: Peng Fan 

Support remote cores booted before Linux Kernel booting.

Add rsc_table to hold the resource table published by remote cores
Add attach hook
Add imx_rproc_detect_mode to detect remote cores' working mode, and if
remote cores are booted before booting Linux Kernel, parse the memory
regions and initialize the table_ptr, table_sz, cached_table.

Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 64 ++
 1 file changed, 64 insertions(+)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 24275429a7cc..fdaaf7599cc8 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -74,6 +74,16 @@ struct imx_rproc_att {
int flags;
 };
 
+enum imx_rproc_mode {
+   /* Linux load/kick remote core */
+   IMX_RPROC_NORMAL,
+   /*
+* remote core booted before kicking Linux, and remote core
+* could be stopped & restarted by Linux
+*/
+   IMX_RPROC_EARLY_BOOT,
+};
+
 struct imx_rproc_dcfg {
u32 src_reg;
u32 src_mask;
@@ -95,6 +105,8 @@ struct imx_rproc {
struct mbox_chan*rx_ch;
struct work_struct  rproc_work;
struct workqueue_struct *workqueue;
+   enum imx_rproc_mode mode;
+   void __iomem*rsc_table;
 };
 
 static const struct imx_rproc_att imx_rproc_att_imx8mq[] = {
@@ -229,6 +241,9 @@ static int imx_rproc_stop(struct rproc *rproc)
if (ret)
dev_err(dev, "Failed to stop M4!\n");
 
+   if (priv->mode == IMX_RPROC_EARLY_BOOT)
+   priv->mode = IMX_RPROC_NORMAL;
+
return ret;
 }
 
@@ -398,9 +413,15 @@ static void imx_rproc_kick(struct rproc *rproc, int vqid)
__func__, vqid, err);
 }
 
+static int imx_rproc_attach(struct rproc *rproc)
+{
+   return 0;
+}
+
 static const struct rproc_ops imx_rproc_ops = {
.start  = imx_rproc_start,
.stop   = imx_rproc_stop,
+   .attach = imx_rproc_attach,
.kick   = imx_rproc_kick,
.da_to_va   = imx_rproc_da_to_va,
.load   = rproc_elf_load_segments,
@@ -470,6 +491,8 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
}
priv->mem[b].sys_addr = res.start;
priv->mem[b].size = resource_size();
+   if (!strcmp(node->name, "rsc_table"))
+   priv->rsc_table = priv->mem[b].cpu_addr;
b++;
}
 
@@ -536,6 +559,43 @@ static void imx_rproc_free_mbox(struct rproc *rproc)
mbox_free_channel(priv->rx_ch);
 }
 
+static int imx_rproc_detect_mode(struct imx_rproc *priv)
+{
+   const struct imx_rproc_dcfg *dcfg = priv->dcfg;
+   struct rproc *rproc = priv->rproc;
+   struct device *dev = priv->dev;
+   int ret;
+   u32 val;
+
+   ret = regmap_read(priv->regmap, dcfg->src_reg, );
+   if (ret) {
+   dev_err(dev, "Failed to read src\n");
+   return ret;
+   }
+
+   if (!(val & dcfg->src_stop))
+   priv->mode = IMX_RPROC_EARLY_BOOT;
+   else
+   priv->mode = IMX_RPROC_NORMAL;
+
+   if (priv->mode == IMX_RPROC_EARLY_BOOT) {
+   priv->rproc->state = RPROC_DETACHED;
+
+   ret = imx_rproc_parse_memory_regions(priv->rproc);
+   if (ret)
+   return ret;
+
+   if (!priv->rsc_table)
+   return 0;
+
+   rproc->table_ptr = (struct resource_table *)priv->rsc_table;
+   rproc->table_sz = SZ_1K;
+   rproc->cached_table = NULL;
+   }
+
+   return 0;
+}
+
 static int imx_rproc_probe(struct platform_device *pdev)
 {
struct device *dev = >dev;
@@ -590,6 +650,10 @@ static int imx_rproc_probe(struct platform_device *pdev)
goto err_put_mbox;
}
 
+   ret = imx_rproc_detect_mode(priv);
+   if (ret)
+   goto err_put_mbox;
+
priv->clk = devm_clk_get(dev, NULL);
if (IS_ERR(priv->clk)) {
dev_err(dev, "Failed to get clock\n");
-- 
2.30.0



[PATCH 1/2] remoteproc: imx_rproc: enlarge IMX7D_RPROC_MEM_MAX

2021-03-19 Thread Peng Fan (OSS)
From: Peng Fan 

8 is not enough when we need more, so enlarge IMX7D_RPROC_MEM_MAX to 32,
and also rename it to IMX_RPROC_MEM_MAX which make more sense.

Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 6d3207ccbaef..24275429a7cc 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -48,7 +48,7 @@
 | IMX6SX_SW_M4C_NON_SCLR_RST \
 | IMX6SX_SW_M4C_RST)
 
-#define IMX7D_RPROC_MEM_MAX8
+#define IMX_RPROC_MEM_MAX  32
 
 /**
  * struct imx_rproc_mem - slim internal memory structure
@@ -88,7 +88,7 @@ struct imx_rproc {
struct regmap   *regmap;
struct rproc*rproc;
const struct imx_rproc_dcfg *dcfg;
-   struct imx_rproc_memmem[IMX7D_RPROC_MEM_MAX];
+   struct imx_rproc_memmem[IMX_RPROC_MEM_MAX];
struct clk  *clk;
struct mbox_client  cl;
struct mbox_chan*tx_ch;
@@ -272,7 +272,7 @@ static void *imx_rproc_da_to_va(struct rproc *rproc, u64 
da, size_t len, bool *i
if (imx_rproc_da_to_sys(priv, da, len, ))
return NULL;
 
-   for (i = 0; i < IMX7D_RPROC_MEM_MAX; i++) {
+   for (i = 0; i < IMX_RPROC_MEM_MAX; i++) {
if (sys >= priv->mem[i].sys_addr && sys + len <
priv->mem[i].sys_addr +  priv->mem[i].size) {
unsigned int offset = sys - priv->mem[i].sys_addr;
@@ -425,7 +425,7 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
if (!(att->flags & ATT_OWN))
continue;
 
-   if (b >= IMX7D_RPROC_MEM_MAX)
+   if (b >= IMX_RPROC_MEM_MAX)
break;
 
priv->mem[b].cpu_addr = devm_ioremap(>dev,
@@ -459,7 +459,7 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
return err;
}
 
-   if (b >= IMX7D_RPROC_MEM_MAX)
+   if (b >= IMX_RPROC_MEM_MAX)
break;
 
/* Not use resource version, because we might share region */
-- 
2.30.0



RE: [PATCH V13 00/10] remoteproc: imx_rproc: support iMX8MQ/M

2021-03-10 Thread Peng Fan (OSS)
Mathieu,

> Subject: Re: [PATCH V13 00/10] remoteproc: imx_rproc: support iMX8MQ/M
> 
> On Sat, Mar 06, 2021 at 07:24:15PM +0800, peng@oss.nxp.com wrote:
> > From: Peng Fan 
> >
> > V13:
> >  Add R-b tag from Rob for patch 1.
> >  Drop the reserved memory node from patch 2 per Rob's comment.
> >  Mathieu, Bjorn
> >   Only patch 2 not have R-b/A-b tag, but since Rob's only has a minor
> comment, and
> >   addressed in this version, is it ok for you take into remoteproc next
> branch?
> >   Thanks.
> 
> As much as I want to, there is no way to move forward without an
> acknowledgement from Rob.

Rob has gave his R-b tag for patch 2/13, please help pick up this patchset.
I really wanna this feature in which has been for a long time. Then
I will move on to add new stuff.

Thanks,
Peng.


> 
> >
> > V12:
> >  Add maxItems to avoid dt_bindings_check fail  Rebased on top of
> > linux-next
> >
> > V11:
> >  Per Rob's comments, fix memory-region in patch 1/10  Rebased on top
> > of Linux-next
> >
> > V10:
> >  Per Rob's comments, fix patch 1/10
> >
> > V9:
> >  Per Mathieu's comments,
> >update the tile of yaml in patch 2/10
> >update the Kconfig and MODULE_DESCRIPTION, I merge this change in
> patch 8/10,
> >since this is a minor change, I still keep Mathieu's R-b tag. If any
> objection, I could remove.
> >Add R-b tag in Patch 10/10
> >
> >  Rob, please help review patch 1/10 and 2/10
> >
> > V8:
> >  Address sparse warning in patch 4/10 reported by kernel test robot
> >
> > V7:
> >  Add R-b tag from Mathieu
> >  vdevbuffer->vdev0buffer in patch 1/10, 7/10  correct err msg and
> > shutdown seq per Mathieu's comments in patch 10/10  Hope this version
> > is ok to be merged.
> >
> > V6:
> >  Add R-b tag from Mathieu
> >  Convert imx-rproc.txt to yaml and add dt-bindings support for
> > i.MX8MQ/M, patch 1/10 2/10  No other changes.
> >
> > V5:
> >  Apply on Linux next
> >  Add V5 subject prefix
> >  Add R-b tag from Bjorn for 1/8, 2/8, 3/8
> >
> > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatc
> >
> hwork.kernel.org%2Fproject%2Flinux-remoteproc%2Fcover%2F20201229033
> 019
> > .25899-1-peng.fan%40nxp.com%2Fdata=04%7C01%7Cpeng.fan%40n
> xp.com%7
> >
> C18c2709725e14cbab54408d8e24c6492%7C686ea1d3bc2b4c6fa92cd99c5c3
> 01635%7
> >
> C0%7C0%7C637508165016988280%7CUnknown%7CTWFpbGZsb3d8eyJWIjoi
> MC4wLjAwMD
> >
> AiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata
> =bwlT
> > uTk6iRuZke6SMhuyB2gxniStfxnX%2BKlVgm7MZuk%3Dreserved=0
> >
> > V4:
> >  According to Bjorn's comments, add is_iomem for da to va usage  1/8,
> > 2/8 is new patch  3/8, follow Bjorn's comments to correct/update the
> > err msg.
> >  6/8, new patch
> >  8/8, use dev_err_probe to simplify code, use queue_work instead
> > schedule_delayed_work
> >
> > V3:
> >  Since I was quite busy in the past days, V3 is late  Rebased on
> > Linux-next  Add R-b tags
> >  1/7: Add R-b tag of Mathieu, add comments
> >  4/7: Typo fix
> >  5/7: Add R-b tag of Mathieu, drop index Per Mathieu's comments
> >  6/7: Add R-b tag of Mathieu
> >  7/7: Add comment for vqid << 16, drop unneeded timeout settings of
> mailbox
> >   Use queue_work instead of schedule_delayed_work
> >   free mbox channels when remove
> >
> > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flkml
> > .org%2Flkml%2F2020%2F12%2F4%2F82data=04%7C01%7Cpeng.fan
> %40nxp.com
> > %7C18c2709725e14cbab54408d8e24c6492%7C686ea1d3bc2b4c6fa92cd9
> 9c5c301635
> > %7C0%7C0%7C637508165016988280%7CUnknown%7CTWFpbGZsb3d8eyJ
> WIjoiMC4wLjAw
> >
> MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sd
> ata=xQ
> >
> ReFFdUT2ZLhWyT2Vt2v0frG0xKq2psP1ExnLx%2BLXw%3Dreserved=0
> >
> > V2:
> >  Rebased on linux-next
> >  Dropped early boot feature to make patchset simple.
> >  Drop rsc-da
> >
> > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatc
> >
> hwork.kernel.org%2Fproject%2Flinux-remoteproc%2Fcover%2F20200927064
> 131
> > .24101-1-peng.fan%40nxp.com%2Fdata=04%7C01%7Cpeng.fan%40n
> xp.com%7
> >
> C18c2709725e14cbab54408d8e24c6492%7C686ea1d3bc2b4c6fa92cd99c5c3
> 01635%7
> >
> C0%7C0%7C637508165016988280%7CUnknown%7CTWFpbGZsb3d8eyJWIjoi
> MC4wLjAwMD
> >
> AiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata
> =BWGP
> >
> gbVtOjOa%2Bri

[PATCH V2] arm64: dts: imx8mp: add wdog2/3 nodes

2021-03-07 Thread peng . fan
From: Peng Fan 

There is wdog[2,3] in i.MX8MP, so add them.

Signed-off-by: Peng Fan 
---

V2:
 Update commit log

 arch/arm64/boot/dts/freescale/imx8mp.dtsi | 16 
 1 file changed, 16 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mp.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mp.dtsi
index c7523fd4eae9..05dd04116f2e 100644
--- a/arch/arm64/boot/dts/freescale/imx8mp.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mp.dtsi
@@ -312,6 +312,22 @@ wdog1: watchdog@3028 {
status = "disabled";
};
 
+   wdog2: watchdog@3029 {
+   compatible = "fsl,imx8mp-wdt", "fsl,imx21-wdt";
+   reg = <0x3029 0x1>;
+   interrupts = ;
+   clocks = < IMX8MP_CLK_WDOG2_ROOT>;
+   status = "disabled";
+   };
+
+   wdog3: watchdog@302a {
+   compatible = "fsl,imx8mp-wdt", "fsl,imx21-wdt";
+   reg = <0x302a 0x1>;
+   interrupts = ;
+   clocks = < IMX8MP_CLK_WDOG3_ROOT>;
+   status = "disabled";
+   };
+
iomuxc: pinctrl@3033 {
compatible = "fsl,imx8mp-iomuxc";
reg = <0x3033 0x1>;
-- 
2.30.0



[PATCH] arm64: dts: imx8mp: add wdog2/3 nodes

2021-03-06 Thread peng . fan
From: Peng Fan 

There is wdog[2,3] in i.MX8MP, so add them, all wdogs share the
same clock root, so use the wdog1 clk here.

Signed-off-by: Peng Fan 
---
 arch/arm64/boot/dts/freescale/imx8mp.dtsi | 16 
 1 file changed, 16 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx8mp.dtsi 
b/arch/arm64/boot/dts/freescale/imx8mp.dtsi
index c7523fd4eae9..05dd04116f2e 100644
--- a/arch/arm64/boot/dts/freescale/imx8mp.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8mp.dtsi
@@ -312,6 +312,22 @@ wdog1: watchdog@3028 {
status = "disabled";
};
 
+   wdog2: watchdog@3029 {
+   compatible = "fsl,imx8mp-wdt", "fsl,imx21-wdt";
+   reg = <0x3029 0x1>;
+   interrupts = ;
+   clocks = < IMX8MP_CLK_WDOG2_ROOT>;
+   status = "disabled";
+   };
+
+   wdog3: watchdog@302a {
+   compatible = "fsl,imx8mp-wdt", "fsl,imx21-wdt";
+   reg = <0x302a 0x1>;
+   interrupts = ;
+   clocks = < IMX8MP_CLK_WDOG3_ROOT>;
+   status = "disabled";
+   };
+
iomuxc: pinctrl@3033 {
compatible = "fsl,imx8mp-iomuxc";
reg = <0x3033 0x1>;
-- 
2.30.0



[PATCH V13 10/10] remoteproc: imx_proc: enable virtio/mailbox

2021-03-06 Thread peng . fan
From: Peng Fan 

Use virtio/mailbox to build connection between Remote Proccessors
and Linux. Add work queue to handle incoming messages.

Reviewed-by: Richard Zhu 
Reviewed-by: Mathieu Poirier 
Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 116 -
 1 file changed, 113 insertions(+), 3 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 3685bbd135b0..90471790bb24 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -7,6 +7,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -15,6 +16,9 @@
 #include 
 #include 
 #include 
+#include 
+
+#include "remoteproc_internal.h"
 
 #define IMX7D_SRC_SCR  0x0C
 #define IMX7D_ENABLE_M4BIT(3)
@@ -86,6 +90,11 @@ struct imx_rproc {
const struct imx_rproc_dcfg *dcfg;
struct imx_rproc_memmem[IMX7D_RPROC_MEM_MAX];
struct clk  *clk;
+   struct mbox_client  cl;
+   struct mbox_chan*tx_ch;
+   struct mbox_chan*rx_ch;
+   struct work_struct  rproc_work;
+   struct workqueue_struct *workqueue;
 };
 
 static const struct imx_rproc_att imx_rproc_att_imx8mq[] = {
@@ -366,9 +375,33 @@ static int imx_rproc_parse_fw(struct rproc *rproc, const 
struct firmware *fw)
return 0;
 }
 
+static void imx_rproc_kick(struct rproc *rproc, int vqid)
+{
+   struct imx_rproc *priv = rproc->priv;
+   int err;
+   __u32 mmsg;
+
+   if (!priv->tx_ch) {
+   dev_err(priv->dev, "No initialized mbox tx channel\n");
+   return;
+   }
+
+   /*
+* Send the index of the triggered virtqueue as the mu payload.
+* Let remote processor know which virtqueue is used.
+*/
+   mmsg = vqid << 16;
+
+   err = mbox_send_message(priv->tx_ch, (void *));
+   if (err < 0)
+   dev_err(priv->dev, "%s: failed (%d, err:%d)\n",
+   __func__, vqid, err);
+}
+
 static const struct rproc_ops imx_rproc_ops = {
.start  = imx_rproc_start,
.stop   = imx_rproc_stop,
+   .kick   = imx_rproc_kick,
.da_to_va   = imx_rproc_da_to_va,
.load   = rproc_elf_load_segments,
.parse_fw   = imx_rproc_parse_fw,
@@ -444,6 +477,66 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
return 0;
 }
 
+static void imx_rproc_vq_work(struct work_struct *work)
+{
+   struct imx_rproc *priv = container_of(work, struct imx_rproc,
+ rproc_work);
+
+   rproc_vq_interrupt(priv->rproc, 0);
+   rproc_vq_interrupt(priv->rproc, 1);
+}
+
+static void imx_rproc_rx_callback(struct mbox_client *cl, void *msg)
+{
+   struct rproc *rproc = dev_get_drvdata(cl->dev);
+   struct imx_rproc *priv = rproc->priv;
+
+   queue_work(priv->workqueue, >rproc_work);
+}
+
+static int imx_rproc_xtr_mbox_init(struct rproc *rproc)
+{
+   struct imx_rproc *priv = rproc->priv;
+   struct device *dev = priv->dev;
+   struct mbox_client *cl;
+   int ret;
+
+   if (!of_get_property(dev->of_node, "mbox-names", NULL))
+   return 0;
+
+   cl = >cl;
+   cl->dev = dev;
+   cl->tx_block = true;
+   cl->tx_tout = 100;
+   cl->knows_txdone = false;
+   cl->rx_callback = imx_rproc_rx_callback;
+
+   priv->tx_ch = mbox_request_channel_byname(cl, "tx");
+   if (IS_ERR(priv->tx_ch)) {
+   ret = PTR_ERR(priv->tx_ch);
+   return dev_err_probe(cl->dev, ret,
+"failed to request tx mailbox channel: 
%d\n", ret);
+   }
+
+   priv->rx_ch = mbox_request_channel_byname(cl, "rx");
+   if (IS_ERR(priv->rx_ch)) {
+   mbox_free_channel(priv->tx_ch);
+   ret = PTR_ERR(priv->rx_ch);
+   return dev_err_probe(cl->dev, ret,
+"failed to request rx mailbox channel: 
%d\n", ret);
+   }
+
+   return 0;
+}
+
+static void imx_rproc_free_mbox(struct rproc *rproc)
+{
+   struct imx_rproc *priv = rproc->priv;
+
+   mbox_free_channel(priv->tx_ch);
+   mbox_free_channel(priv->rx_ch);
+}
+
 static int imx_rproc_probe(struct platform_device *pdev)
 {
struct device *dev = >dev;
@@ -481,18 +574,28 @@ static int imx_rproc_probe(struct platform_device *pdev)
priv->dev = dev;
 
dev_set_drvdata(dev, rproc);
+   priv->workqueue = create_workqueue(dev_name(dev));
+   if (!priv->workqueue) {
+   dev_err(dev, "cannot create workqueue\n");
+  

[PATCH V13 08/10] remoteproc: imx_rproc: support i.MX8MQ/M

2021-03-06 Thread peng . fan
From: Peng Fan 

Add i.MX8MQ dev/sys addr map and configuration data structure
i.MX8MM share i.MX8MQ settings.

Reviewed-by: Richard Zhu 
Reviewed-by: Mathieu Poirier 
Signed-off-by: Peng Fan 
---
 drivers/remoteproc/Kconfig |  6 ++---
 drivers/remoteproc/imx_rproc.c | 41 +-
 2 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 15d1574d129b..7cf3d1b40c55 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -24,11 +24,11 @@ config REMOTEPROC_CDEV
  It's safe to say N if you don't want to use this interface.
 
 config IMX_REMOTEPROC
-   tristate "IMX6/7 remoteproc support"
+   tristate "i.MX remoteproc support"
depends on ARCH_MXC
help
- Say y here to support iMX's remote processors (Cortex M4
- on iMX7D) via the remote processor framework.
+ Say y here to support iMX's remote processors via the remote
+ processor framework.
 
  It's safe to say N here.
 
diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 5ae1f5209548..0124ebf69838 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -88,6 +88,34 @@ struct imx_rproc {
struct clk  *clk;
 };
 
+static const struct imx_rproc_att imx_rproc_att_imx8mq[] = {
+   /* dev addr , sys addr  , size  , flags */
+   /* TCML - alias */
+   { 0x, 0x007e, 0x0002, 0 },
+   /* OCRAM_S */
+   { 0x0018, 0x0018, 0x8000, 0 },
+   /* OCRAM */
+   { 0x0090, 0x0090, 0x0002, 0 },
+   /* OCRAM */
+   { 0x0092, 0x0092, 0x0002, 0 },
+   /* QSPI Code - alias */
+   { 0x0800, 0x0800, 0x0800, 0 },
+   /* DDR (Code) - alias */
+   { 0x1000, 0x8000, 0x0FFE, 0 },
+   /* TCML */
+   { 0x1FFE, 0x007E, 0x0002, ATT_OWN },
+   /* TCMU */
+   { 0x2000, 0x0080, 0x0002, ATT_OWN },
+   /* OCRAM_S */
+   { 0x2018, 0x0018, 0x8000, ATT_OWN },
+   /* OCRAM */
+   { 0x2020, 0x0090, 0x0002, ATT_OWN },
+   /* OCRAM */
+   { 0x2022, 0x0092, 0x0002, ATT_OWN },
+   /* DDR (Data) */
+   { 0x4000, 0x4000, 0x8000, 0 },
+};
+
 static const struct imx_rproc_att imx_rproc_att_imx7d[] = {
/* dev addr , sys addr  , size  , flags */
/* OCRAM_S (M4 Boot code) - alias */
@@ -138,6 +166,15 @@ static const struct imx_rproc_att imx_rproc_att_imx6sx[] = 
{
{ 0x8000, 0x8000, 0x6000, 0 },
 };
 
+static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mq = {
+   .src_reg= IMX7D_SRC_SCR,
+   .src_mask   = IMX7D_M4_RST_MASK,
+   .src_start  = IMX7D_M4_START,
+   .src_stop   = IMX7D_M4_STOP,
+   .att= imx_rproc_att_imx8mq,
+   .att_size   = ARRAY_SIZE(imx_rproc_att_imx8mq),
+};
+
 static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = {
.src_reg= IMX7D_SRC_SCR,
.src_mask   = IMX7D_M4_RST_MASK,
@@ -496,6 +533,8 @@ static int imx_rproc_remove(struct platform_device *pdev)
 static const struct of_device_id imx_rproc_of_match[] = {
{ .compatible = "fsl,imx7d-cm4", .data = _rproc_cfg_imx7d },
{ .compatible = "fsl,imx6sx-cm4", .data = _rproc_cfg_imx6sx },
+   { .compatible = "fsl,imx8mq-cm4", .data = _rproc_cfg_imx8mq },
+   { .compatible = "fsl,imx8mm-cm4", .data = _rproc_cfg_imx8mq },
{},
 };
 MODULE_DEVICE_TABLE(of, imx_rproc_of_match);
@@ -512,5 +551,5 @@ static struct platform_driver imx_rproc_driver = {
 module_platform_driver(imx_rproc_driver);
 
 MODULE_LICENSE("GPL v2");
-MODULE_DESCRIPTION("IMX6SX/7D remote processor control driver");
+MODULE_DESCRIPTION("i.MX remote processor control driver");
 MODULE_AUTHOR("Oleksij Rempel ");
-- 
2.30.0



[PATCH V13 09/10] remoteproc: imx_rproc: ignore mapping vdev regions

2021-03-06 Thread peng . fan
From: Peng Fan 

vdev regions are vdev0vring0, vdev0vring1, vdevbuffer and similar.
They are handled by remoteproc common code, no need to map in imx
rproc driver.

Signed-off-by: Peng Fan 
Reviewed-by: Mathieu Poirier 
---
 drivers/remoteproc/imx_rproc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 0124ebf69838..3685bbd135b0 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -417,6 +417,9 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
struct resource res;
 
node = of_parse_phandle(np, "memory-region", a);
+   /* Not map vdev region */
+   if (!strcmp(node->name, "vdev"))
+   continue;
err = of_address_to_resource(node, 0, );
if (err) {
dev_err(dev, "unable to resolve memory region\n");
-- 
2.30.0



[PATCH V13 06/10] remoteproc: imx_rproc: use devm_ioremap

2021-03-06 Thread peng . fan
From: Peng Fan 

We might need to map an region multiple times, becaue the region might
be shared between remote processors, such i.MX8QM with dual M4 cores.
So use devm_ioremap, not devm_ioremap_resource.

Reviewed-by: Oleksij Rempel 
Reviewed-by: Richard Zhu 
Signed-off-by: Peng Fan 
Reviewed-by: Mathieu Poirier 
---
 drivers/remoteproc/imx_rproc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 2a093cea4997..47fc1d06be6a 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -296,7 +296,8 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
if (b >= IMX7D_RPROC_MEM_MAX)
break;
 
-   priv->mem[b].cpu_addr = devm_ioremap_resource(>dev, );
+   /* Not use resource version, because we might share region */
+   priv->mem[b].cpu_addr = devm_ioremap(>dev, res.start, 
resource_size());
if (IS_ERR(priv->mem[b].cpu_addr)) {
dev_err(dev, "failed to remap %pr\n", );
err = PTR_ERR(priv->mem[b].cpu_addr);
-- 
2.30.0



[PATCH V13 07/10] remoteproc: imx_rproc: add i.MX specific parse fw hook

2021-03-06 Thread peng . fan
From: Peng Fan 

The hook is used to parse memory-regions and load resource table
from the address the remote processor published.

Reviewed-by: Richard Zhu 
Reviewed-by: Mathieu Poirier 
Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 93 ++
 1 file changed, 93 insertions(+)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 47fc1d06be6a..5ae1f5209548 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -241,10 +242,102 @@ static void *imx_rproc_da_to_va(struct rproc *rproc, u64 
da, size_t len, bool *i
return va;
 }
 
+static int imx_rproc_mem_alloc(struct rproc *rproc,
+  struct rproc_mem_entry *mem)
+{
+   struct device *dev = rproc->dev.parent;
+   void *va;
+
+   dev_dbg(dev, "map memory: %p+%zx\n", >dma, mem->len);
+   va = ioremap_wc(mem->dma, mem->len);
+   if (IS_ERR_OR_NULL(va)) {
+   dev_err(dev, "Unable to map memory region: %p+%zx\n",
+   >dma, mem->len);
+   return -ENOMEM;
+   }
+
+   /* Update memory entry va */
+   mem->va = va;
+
+   return 0;
+}
+
+static int imx_rproc_mem_release(struct rproc *rproc,
+struct rproc_mem_entry *mem)
+{
+   dev_dbg(rproc->dev.parent, "unmap memory: %pa\n", >dma);
+   iounmap(mem->va);
+
+   return 0;
+}
+
+static int imx_rproc_parse_memory_regions(struct rproc *rproc)
+{
+   struct imx_rproc *priv = rproc->priv;
+   struct device_node *np = priv->dev->of_node;
+   struct of_phandle_iterator it;
+   struct rproc_mem_entry *mem;
+   struct reserved_mem *rmem;
+   u32 da;
+
+   /* Register associated reserved memory regions */
+   of_phandle_iterator_init(, np, "memory-region", NULL, 0);
+   while (of_phandle_iterator_next() == 0) {
+   /*
+* Ignore the first memory region which will be used vdev 
buffer.
+* No need to do extra handlings, rproc_add_virtio_dev will 
handle it.
+*/
+   if (!strcmp(it.node->name, "vdev0buffer"))
+   continue;
+
+   rmem = of_reserved_mem_lookup(it.node);
+   if (!rmem) {
+   dev_err(priv->dev, "unable to acquire memory-region\n");
+   return -EINVAL;
+   }
+
+   /* No need to translate pa to da, i.MX use same map */
+   da = rmem->base;
+
+   /* Register memory region */
+   mem = rproc_mem_entry_init(priv->dev, NULL, 
(dma_addr_t)rmem->base, rmem->size, da,
+  imx_rproc_mem_alloc, 
imx_rproc_mem_release,
+  it.node->name);
+
+   if (mem)
+   rproc_coredump_add_segment(rproc, da, rmem->size);
+   else
+   return -ENOMEM;
+
+   rproc_add_carveout(rproc, mem);
+   }
+
+   return  0;
+}
+
+static int imx_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
+{
+   int ret = imx_rproc_parse_memory_regions(rproc);
+
+   if (ret)
+   return ret;
+
+   ret = rproc_elf_load_rsc_table(rproc, fw);
+   if (ret)
+   dev_info(>dev, "No resource table in elf\n");
+
+   return 0;
+}
+
 static const struct rproc_ops imx_rproc_ops = {
.start  = imx_rproc_start,
.stop   = imx_rproc_stop,
.da_to_va   = imx_rproc_da_to_va,
+   .load   = rproc_elf_load_segments,
+   .parse_fw   = imx_rproc_parse_fw,
+   .find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table,
+   .sanity_check   = rproc_elf_sanity_check,
+   .get_boot_addr  = rproc_elf_get_boot_addr,
 };
 
 static int imx_rproc_addr_init(struct imx_rproc *priv,
-- 
2.30.0



[PATCH V13 05/10] remoteproc: imx_rproc: correct err message

2021-03-06 Thread peng . fan
From: Peng Fan 

It is using devm_ioremap, so not devm_ioremap_resource. Correct
the error message and print out sa/size.

Reviewed-by: Bjorn Andersson 
Reviewed-by: Mathieu Poirier 
Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 6603e00bb6f4..2a093cea4997 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -268,7 +268,7 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
priv->mem[b].cpu_addr = devm_ioremap(>dev,
 att->sa, att->size);
if (!priv->mem[b].cpu_addr) {
-   dev_err(dev, "devm_ioremap_resource failed\n");
+   dev_err(dev, "failed to remap %#x bytes from %#x\n", 
att->size, att->sa);
return -ENOMEM;
}
priv->mem[b].sys_addr = att->sa;
@@ -298,7 +298,7 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
 
priv->mem[b].cpu_addr = devm_ioremap_resource(>dev, );
if (IS_ERR(priv->mem[b].cpu_addr)) {
-   dev_err(dev, "devm_ioremap_resource failed\n");
+   dev_err(dev, "failed to remap %pr\n", );
err = PTR_ERR(priv->mem[b].cpu_addr);
return err;
}
-- 
2.30.0



[PATCH V13 04/10] remoteproc: add is_iomem to da_to_va

2021-03-06 Thread peng . fan
From: Peng Fan 

Introduce an extra parameter is_iomem to da_to_va, then the caller
could take the memory as normal memory or io mapped memory.

Reviewed-by: Bjorn Andersson 
Reviewed-by: Mathieu Poirier 
Reported-by: kernel test robot 
Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c |  2 +-
 drivers/remoteproc/ingenic_rproc.c |  2 +-
 drivers/remoteproc/keystone_remoteproc.c   |  2 +-
 drivers/remoteproc/mtk_scp.c   |  6 +++---
 drivers/remoteproc/omap_remoteproc.c   |  2 +-
 drivers/remoteproc/pru_rproc.c |  2 +-
 drivers/remoteproc/qcom_q6v5_adsp.c|  2 +-
 drivers/remoteproc/qcom_q6v5_pas.c |  2 +-
 drivers/remoteproc/qcom_q6v5_wcss.c|  2 +-
 drivers/remoteproc/qcom_wcnss.c|  2 +-
 drivers/remoteproc/remoteproc_core.c   |  7 +--
 drivers/remoteproc/remoteproc_coredump.c   |  8 ++--
 drivers/remoteproc/remoteproc_debugfs.c|  2 +-
 drivers/remoteproc/remoteproc_elf_loader.c | 21 +++--
 drivers/remoteproc/remoteproc_internal.h   |  2 +-
 drivers/remoteproc/st_slim_rproc.c |  2 +-
 drivers/remoteproc/ti_k3_dsp_remoteproc.c  |  2 +-
 drivers/remoteproc/ti_k3_r5_remoteproc.c   |  2 +-
 drivers/remoteproc/wkup_m3_rproc.c |  2 +-
 include/linux/remoteproc.h |  2 +-
 20 files changed, 45 insertions(+), 29 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 8957ed271d20..6603e00bb6f4 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -208,7 +208,7 @@ static int imx_rproc_da_to_sys(struct imx_rproc *priv, u64 
da,
return -ENOENT;
 }
 
-static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len)
+static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool 
*is_iomem)
 {
struct imx_rproc *priv = rproc->priv;
void *va = NULL;
diff --git a/drivers/remoteproc/ingenic_rproc.c 
b/drivers/remoteproc/ingenic_rproc.c
index e2618c36eaab..a356738160a4 100644
--- a/drivers/remoteproc/ingenic_rproc.c
+++ b/drivers/remoteproc/ingenic_rproc.c
@@ -121,7 +121,7 @@ static void ingenic_rproc_kick(struct rproc *rproc, int 
vqid)
writel(vqid, vpu->aux_base + REG_CORE_MSG);
 }
 
-static void *ingenic_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len)
+static void *ingenic_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, 
bool *is_iomem)
 {
struct vpu *vpu = rproc->priv;
void __iomem *va = NULL;
diff --git a/drivers/remoteproc/keystone_remoteproc.c 
b/drivers/remoteproc/keystone_remoteproc.c
index cd266163a65f..54781f553f4e 100644
--- a/drivers/remoteproc/keystone_remoteproc.c
+++ b/drivers/remoteproc/keystone_remoteproc.c
@@ -246,7 +246,7 @@ static void keystone_rproc_kick(struct rproc *rproc, int 
vqid)
  * can be used either by the remoteproc core for loading (when using kernel
  * remoteproc loader), or by any rpmsg bus drivers.
  */
-static void *keystone_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len)
+static void *keystone_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, 
bool *is_iomem)
 {
struct keystone_rproc *ksproc = rproc->priv;
void __iomem *va = NULL;
diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c
index ce727598c41c..9679cc26895e 100644
--- a/drivers/remoteproc/mtk_scp.c
+++ b/drivers/remoteproc/mtk_scp.c
@@ -272,7 +272,7 @@ static int scp_elf_load_segments(struct rproc *rproc, const 
struct firmware *fw)
}
 
/* grab the kernel address for this device address */
-   ptr = (void __iomem *)rproc_da_to_va(rproc, da, memsz);
+   ptr = (void __iomem *)rproc_da_to_va(rproc, da, memsz, NULL);
if (!ptr) {
dev_err(dev, "bad phdr da 0x%x mem 0x%x\n", da, memsz);
ret = -EINVAL;
@@ -509,7 +509,7 @@ static void *mt8192_scp_da_to_va(struct mtk_scp *scp, u64 
da, size_t len)
return NULL;
 }
 
-static void *scp_da_to_va(struct rproc *rproc, u64 da, size_t len)
+static void *scp_da_to_va(struct rproc *rproc, u64 da, size_t len, bool 
*is_iomem)
 {
struct mtk_scp *scp = (struct mtk_scp *)rproc->priv;
 
@@ -627,7 +627,7 @@ void *scp_mapping_dm_addr(struct mtk_scp *scp, u32 mem_addr)
 {
void *ptr;
 
-   ptr = scp_da_to_va(scp->rproc, mem_addr, 0);
+   ptr = scp_da_to_va(scp->rproc, mem_addr, 0, NULL);
if (!ptr)
return ERR_PTR(-EINVAL);
 
diff --git a/drivers/remoteproc/omap_remoteproc.c 
b/drivers/remoteproc/omap_remoteproc.c
index d94b7391bf9d..43531caa1959 100644
--- a/drivers/remoteproc/omap_remoteproc.c
+++ b/drivers/remoteproc/omap_remoteproc.c
@@ -728,7 +728,7 @@ static int omap_rproc_stop(struct rproc *rproc)
  * Return: translated virtual address in kernel memory space on success,
  * or NULL on failure.
  */
-static void *omap_rproc_da_to

[PATCH V13 02/10] dt-bindings: remoteproc: imx_rproc: add i.MX8MQ/M support

2021-03-06 Thread peng . fan
From: Peng Fan 

Add i.MX8MQ/M support, also include mailbox for rpmsg/virtio usage.

Signed-off-by: Peng Fan 
---
 .../bindings/remoteproc/fsl,imx-rproc.yaml| 31 ++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml 
b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
index 54d2456530a6..208a628f8d6c 100644
--- a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
+++ b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
@@ -4,7 +4,7 @@
 $id: "http://devicetree.org/schemas/remoteproc/fsl,imx-rproc.yaml#;
 $schema: "http://devicetree.org/meta-schemas/core.yaml#;
 
-title: NXP iMX6SX/iMX7D Co-Processor Bindings
+title: NXP i.MX Co-Processor Bindings
 
 description:
   This binding provides support for ARM Cortex M4 Co-processor found on some 
NXP iMX SoCs.
@@ -15,6 +15,8 @@ maintainers:
 properties:
   compatible:
 enum:
+  - fsl,imx8mq-cm4
+  - fsl,imx8mm-cm4
   - fsl,imx7d-cm4
   - fsl,imx6sx-cm4
 
@@ -26,6 +28,20 @@ properties:
 description:
   Phandle to syscon block which provide access to System Reset Controller
 
+  mbox-names:
+items:
+  - const: tx
+  - const: rx
+  - const: rxdb
+
+  mboxes:
+description:
+  This property is required only if the rpmsg/virtio functionality is used.
+  List of < type channel> - 1 channel for TX, 1 channel for RX, 1 
channel for RXDB.
+  (see mailbox/fsl,mu.yaml)
+minItems: 1
+maxItems: 3
+
   memory-region:
 description:
   If present, a phandle for a reserved memory area that used for vdev 
buffer,
@@ -58,4 +74,17 @@ examples:
   clocks   = < IMX7D_ARM_M4_ROOT_CLK>;
 };
 
+  - |
+#include 
+
+imx8mm-cm4 {
+  compatible = "fsl,imx8mm-cm4";
+  clocks = < IMX8MM_CLK_M4_DIV>;
+  mbox-names = "tx", "rx", "rxdb";
+  mboxes = < 0 1
+ 1 1
+ 3 1>;
+  memory-region = <>, <>, <>, 
<_table>;
+  syscon = <>;
+};
 ...
-- 
2.30.0



[PATCH V13 03/10] remoteproc: introduce is_iomem to rproc_mem_entry

2021-03-06 Thread peng . fan
From: Peng Fan 

Introduce is_iomem to indicate this piece memory is iomem or not.

Reviewed-by: Bjorn Andersson 
Reviewed-by: Mathieu Poirier 
Signed-off-by: Peng Fan 
---
 include/linux/remoteproc.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index f28ee75d1005..a5f6d2d9cde2 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -315,6 +315,7 @@ struct rproc;
 /**
  * struct rproc_mem_entry - memory entry descriptor
  * @va:virtual address
+ * @is_iomem: io memory
  * @dma: dma address
  * @len: length, in bytes
  * @da: device address
@@ -329,6 +330,7 @@ struct rproc;
  */
 struct rproc_mem_entry {
void *va;
+   bool is_iomem;
dma_addr_t dma;
size_t len;
u32 da;
-- 
2.30.0



[PATCH V13 01/10] dt-bindings: remoteproc: convert imx rproc bindings to json-schema

2021-03-06 Thread peng . fan
From: Peng Fan 

Convert the imx rproc binding to DT schema format using json-schema.

Reviewed-by: Rob Herring 
Signed-off-by: Peng Fan 
---
 .../bindings/remoteproc/fsl,imx-rproc.yaml| 61 +++
 .../bindings/remoteproc/imx-rproc.txt | 33 --
 2 files changed, 61 insertions(+), 33 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
 delete mode 100644 Documentation/devicetree/bindings/remoteproc/imx-rproc.txt

diff --git a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml 
b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
new file mode 100644
index ..54d2456530a6
--- /dev/null
+++ b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/remoteproc/fsl,imx-rproc.yaml#;
+$schema: "http://devicetree.org/meta-schemas/core.yaml#;
+
+title: NXP iMX6SX/iMX7D Co-Processor Bindings
+
+description:
+  This binding provides support for ARM Cortex M4 Co-processor found on some 
NXP iMX SoCs.
+
+maintainers:
+  - Peng Fan 
+
+properties:
+  compatible:
+enum:
+  - fsl,imx7d-cm4
+  - fsl,imx6sx-cm4
+
+  clocks:
+maxItems: 1
+
+  syscon:
+$ref: /schemas/types.yaml#/definitions/phandle
+description:
+  Phandle to syscon block which provide access to System Reset Controller
+
+  memory-region:
+description:
+  If present, a phandle for a reserved memory area that used for vdev 
buffer,
+  resource table, vring region and others used by remote processor.
+minItems: 1
+maxItems: 32
+
+required:
+  - compatible
+  - clocks
+  - syscon
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+m4_reserved_sysmem1: cm4@8000 {
+  reg = <0x8000 0x8>;
+};
+
+m4_reserved_sysmem2: cm4@8100 {
+  reg = <0x8100 0x8>;
+};
+
+imx7d-cm4 {
+  compatible   = "fsl,imx7d-cm4";
+  memory-region= <_reserved_sysmem1>, <_reserved_sysmem2>;
+  syscon   = <>;
+  clocks   = < IMX7D_ARM_M4_ROOT_CLK>;
+};
+
+...
diff --git a/Documentation/devicetree/bindings/remoteproc/imx-rproc.txt 
b/Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
deleted file mode 100644
index fbcefd965dc4..
--- a/Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-NXP iMX6SX/iMX7D Co-Processor Bindings
-
-
-This binding provides support for ARM Cortex M4 Co-processor found on some
-NXP iMX SoCs.
-
-Required properties:
-- compatible   Should be one of:
-   "fsl,imx7d-cm4"
-   "fsl,imx6sx-cm4"
-- clocks   Clock for co-processor (See: 
../clock/clock-bindings.txt)
-- syscon   Phandle to syscon block which provide access to
-   System Reset Controller
-
-Optional properties:
-- memory-regionlist of phandels to the reserved memory regions.
-   (See: ../reserved-memory/reserved-memory.txt)
-
-Example:
-   m4_reserved_sysmem1: cm4@8000 {
-   reg = <0x8000 0x8>;
-   };
-
-   m4_reserved_sysmem2: cm4@8100 {
-   reg = <0x8100 0x8>;
-   };
-
-   imx7d-cm4 {
-   compatible  = "fsl,imx7d-cm4";
-   memory-region   = <_reserved_sysmem1>, 
<_reserved_sysmem2>;
-   syscon  = <>;
-   clocks  = < IMX7D_ARM_M4_ROOT_CLK>;
-   };
-- 
2.30.0



[PATCH V13 00/10] remoteproc: imx_rproc: support iMX8MQ/M

2021-03-06 Thread peng . fan
From: Peng Fan 

V13:
 Add R-b tag from Rob for patch 1.
 Drop the reserved memory node from patch 2 per Rob's comment.
 Mathieu, Bjorn
  Only patch 2 not have R-b/A-b tag, but since Rob's only has a minor comment, 
and
  addressed in this version, is it ok for you take into remoteproc next branch?
  Thanks.

V12:
 Add maxItems to avoid dt_bindings_check fail
 Rebased on top of linux-next

V11:
 Per Rob's comments, fix memory-region in patch 1/10
 Rebased on top of Linux-next

V10:
 Per Rob's comments, fix patch 1/10

V9:
 Per Mathieu's comments,
   update the tile of yaml in patch 2/10
   update the Kconfig and MODULE_DESCRIPTION, I merge this change in patch 8/10,
   since this is a minor change, I still keep Mathieu's R-b tag. If any 
objection, I could remove.
   Add R-b tag in Patch 10/10

 Rob, please help review patch 1/10 and 2/10

V8:
 Address sparse warning in patch 4/10 reported by kernel test robot

V7:
 Add R-b tag from Mathieu
 vdevbuffer->vdev0buffer in patch 1/10, 7/10
 correct err msg and shutdown seq per Mathieu's comments in patch 10/10
 Hope this version is ok to be merged.
 
V6:
 Add R-b tag from Mathieu
 Convert imx-rproc.txt to yaml and add dt-bindings support for i.MX8MQ/M, patch 
1/10 2/10
 No other changes.

V5:
 Apply on Linux next
 Add V5 subject prefix
 Add R-b tag from Bjorn for 1/8, 2/8, 3/8
 
https://patchwork.kernel.org/project/linux-remoteproc/cover/20201229033019.25899-1-peng@nxp.com/

V4:
 According to Bjorn's comments, add is_iomem for da to va usage
 1/8, 2/8 is new patch
 3/8, follow Bjorn's comments to correct/update the err msg.
 6/8, new patch
 8/8, use dev_err_probe to simplify code, use queue_work instead 
schedule_delayed_work

V3:
 Since I was quite busy in the past days, V3 is late
 Rebased on Linux-next
 Add R-b tags
 1/7: Add R-b tag of Mathieu, add comments
 4/7: Typo fix
 5/7: Add R-b tag of Mathieu, drop index Per Mathieu's comments
 6/7: Add R-b tag of Mathieu
 7/7: Add comment for vqid << 16, drop unneeded timeout settings of mailbox
  Use queue_work instead of schedule_delayed_work
  free mbox channels when remove
 https://lkml.org/lkml/2020/12/4/82

V2:
 Rebased on linux-next
 Dropped early boot feature to make patchset simple.
 Drop rsc-da
 
https://patchwork.kernel.org/project/linux-remoteproc/cover/20200927064131.24101-1-peng@nxp.com/

V1:
 https://patchwork.kernel.org/cover/11682461/

This patchset is to support i.MX8MQ/M coproc.
The early boot feature was dropped to make the patchset small in V2.

Since i.MX specific TCM memory requirement, add elf platform hook.
Several patches have got reviewed by Oleksij and Mathieu in v1.


Peng Fan (10):
  dt-bindings: remoteproc: convert imx rproc bindings to json-schema
  dt-bindings: remoteproc: imx_rproc: add i.MX8MQ/M support
  remoteproc: introduce is_iomem to rproc_mem_entry
  remoteproc: add is_iomem to da_to_va
  remoteproc: imx_rproc: correct err message
  remoteproc: imx_rproc: use devm_ioremap
  remoteproc: imx_rproc: add i.MX specific parse fw hook
  remoteproc: imx_rproc: support i.MX8MQ/M
  remoteproc: imx_rproc: ignore mapping vdev regions
  remoteproc: imx_proc: enable virtio/mailbox

 .../bindings/remoteproc/fsl,imx-rproc.yaml|  90 ++
 .../bindings/remoteproc/imx-rproc.txt |  33 ---
 drivers/remoteproc/Kconfig|   6 +-
 drivers/remoteproc/imx_rproc.c| 262 +-
 drivers/remoteproc/ingenic_rproc.c|   2 +-
 drivers/remoteproc/keystone_remoteproc.c  |   2 +-
 drivers/remoteproc/mtk_scp.c  |   6 +-
 drivers/remoteproc/omap_remoteproc.c  |   2 +-
 drivers/remoteproc/pru_rproc.c|   2 +-
 drivers/remoteproc/qcom_q6v5_adsp.c   |   2 +-
 drivers/remoteproc/qcom_q6v5_pas.c|   2 +-
 drivers/remoteproc/qcom_q6v5_wcss.c   |   2 +-
 drivers/remoteproc/qcom_wcnss.c   |   2 +-
 drivers/remoteproc/remoteproc_core.c  |   7 +-
 drivers/remoteproc/remoteproc_coredump.c  |   8 +-
 drivers/remoteproc/remoteproc_debugfs.c   |   2 +-
 drivers/remoteproc/remoteproc_elf_loader.c|  21 +-
 drivers/remoteproc/remoteproc_internal.h  |   2 +-
 drivers/remoteproc/st_slim_rproc.c|   2 +-
 drivers/remoteproc/ti_k3_dsp_remoteproc.c |   2 +-
 drivers/remoteproc/ti_k3_r5_remoteproc.c  |   2 +-
 drivers/remoteproc/wkup_m3_rproc.c|   2 +-
 include/linux/remoteproc.h|   4 +-
 23 files changed, 393 insertions(+), 72 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
 delete mode 100644 Documentation/devicetree/bindings/remoteproc/imx-rproc.txt

-- 
2.30.0



RE: [PATCH V3 4/5] dt-bindings: mmc: fsl-imx-esdhc: add clock bindings

2021-03-04 Thread Peng Fan
Hi Rob,

> Subject: Re: [PATCH V3 4/5] dt-bindings: mmc: fsl-imx-esdhc: add clock
> bindings
> 
> On Wed, Feb 24, 2021 at 9:23 PM  wrote:
> >
> > From: Peng Fan 
> >
> > Add clock bindings for fsl-imx-esdhc yaml
> >
> > Signed-off-by: Peng Fan 
> > ---
> >  .../devicetree/bindings/mmc/fsl-imx-esdhc.yaml| 11
> +++
> >  1 file changed, 11 insertions(+)
> 
> Looks like this landed in linux-next and introduces warnings:

Patch 2,3 has not been picked by Shawn. After patch 2, 3 picked up,
there will be no warnings.

Thanks,
Peng.

> 
> /builds/robherring/linux-dt-bindings/Documentation/devicetree/bindings/clo
> ck/imx8qxp-lpcg.example.dt.yaml:
> mmc@5b01: clock-names:1: 'ahb' was expected  From schema:
> /builds/robherring/linux-dt-bindings/Documentation/devicetree/bindings/m
> mc/fsl-imx-esdhc.yaml
> /builds/robherring/linux-dt-bindings/Documentation/devicetree/bindings/clo
> ck/imx8qxp-lpcg.example.dt.yaml:
> mmc@5b01: clock-names:2: 'per' was expected  From schema:
> /builds/robherring/linux-dt-bindings/Documentation/devicetree/bindings/m
> mc/fsl-imx-esdhc.yaml


RE: [PATCH V12 01/10] dt-bindings: remoteproc: convert imx rproc bindings to json-schema

2021-03-03 Thread Peng Fan (OSS)
Hi Rob,

> Subject: [PATCH V12 01/10] dt-bindings: remoteproc: convert imx rproc
> bindings to json-schema

Are you fine with patch 1, 2?

Thanks,
Peng.

> 
> From: Peng Fan 
> 
> Convert the imx rproc binding to DT schema format using json-schema.
> 
> Signed-off-by: Peng Fan 
> ---
>  .../bindings/remoteproc/fsl,imx-rproc.yaml| 61 +++
>  .../bindings/remoteproc/imx-rproc.txt | 33 --
>  2 files changed, 61 insertions(+), 33 deletions(-)  create mode 100644
> Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
>  delete mode 100644
> Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
> 
> diff --git
> a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
> b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
> new file mode 100644
> index ..54d2456530a6
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
> @@ -0,0 +1,61 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) %YAML 1.2
> +---
> +$id: "http://devicetree.org/schemas/remoteproc/fsl,imx-rproc.yaml#;
> +$schema: "http://devicetree.org/meta-schemas/core.yaml#;
> +
> +title: NXP iMX6SX/iMX7D Co-Processor Bindings
> +
> +description:
> +  This binding provides support for ARM Cortex M4 Co-processor found on
> some NXP iMX SoCs.
> +
> +maintainers:
> +  - Peng Fan 
> +
> +properties:
> +  compatible:
> +enum:
> +  - fsl,imx7d-cm4
> +  - fsl,imx6sx-cm4
> +
> +  clocks:
> +maxItems: 1
> +
> +  syscon:
> +$ref: /schemas/types.yaml#/definitions/phandle
> +description:
> +  Phandle to syscon block which provide access to System Reset
> + Controller
> +
> +  memory-region:
> +description:
> +  If present, a phandle for a reserved memory area that used for vdev
> buffer,
> +  resource table, vring region and others used by remote processor.
> +minItems: 1
> +maxItems: 32
> +
> +required:
> +  - compatible
> +  - clocks
> +  - syscon
> +
> +additionalProperties: false
> +
> +examples:
> +  - |
> +#include 
> +m4_reserved_sysmem1: cm4@8000 {
> +  reg = <0x8000 0x8>;
> +};
> +
> +m4_reserved_sysmem2: cm4@8100 {
> +  reg = <0x8100 0x8>;
> +};
> +
> +imx7d-cm4 {
> +  compatible = "fsl,imx7d-cm4";
> +  memory-region  = <_reserved_sysmem1>,
> <_reserved_sysmem2>;
> +  syscon = <>;
> +  clocks = < IMX7D_ARM_M4_ROOT_CLK>;
> +};
> +
> +...
> diff --git a/Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
> b/Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
> deleted file mode 100644
> index fbcefd965dc4..
> --- a/Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
> +++ /dev/null
> @@ -1,33 +0,0 @@
> -NXP iMX6SX/iMX7D Co-Processor Bindings
> -
> -
> -This binding provides support for ARM Cortex M4 Co-processor found on
> some -NXP iMX SoCs.
> -
> -Required properties:
> -- compatible Should be one of:
> - "fsl,imx7d-cm4"
> - "fsl,imx6sx-cm4"
> -- clocks Clock for co-processor (See: 
> ../clock/clock-bindings.txt)
> -- syscon Phandle to syscon block which provide access to
> - System Reset Controller
> -
> -Optional properties:
> -- memory-region  list of phandels to the reserved memory regions.
> - (See: ../reserved-memory/reserved-memory.txt)
> -
> -Example:
> - m4_reserved_sysmem1: cm4@8000 {
> - reg = <0x8000 0x8>;
> - };
> -
> - m4_reserved_sysmem2: cm4@8100 {
> - reg = <0x8100 0x8>;
> - };
> -
> - imx7d-cm4 {
> - compatible  = "fsl,imx7d-cm4";
> - memory-region   = <_reserved_sysmem1>,
> <_reserved_sysmem2>;
> - syscon  = <>;
> - clocks  = < IMX7D_ARM_M4_ROOT_CLK>;
> - };
> --
> 2.30.0



RE: [PATCH V3 0/5] imx esdhc dt/driver update

2021-03-03 Thread Peng Fan (OSS)
Hi Shawn,

> Subject: Re: [PATCH V3 0/5] imx esdhc dt/driver update
> 
> On Thu, 25 Feb 2021 at 04:22,  wrote:
> >
> > From: Peng Fan 
> >
> > V3:
> >  Patch 1, drop unneeded pinctrl-0/1/2
> >  Patch 2 is new to avoid break dt bindings check
> > V2:
> >  patch 1, 2, 3 is new
> >  patch 4 is not changed
> >
> >
> > Peng Fan (5):
> >   dt-bindings: mmc: fsl-imx-esdhc: add pinctrl bindings
> >   dt-bindings: clock: imx8qxp-lpcg: correct the example clock-names
> >   arm64: dts: imx8qxp: correct usdhc clock-names sequence
> >   dt-bindings: mmc: fsl-imx-esdhc: add clock bindings
> >   mmc: sdhci-esdhc-imx: validate pinctrl before use it
> >
> >  .../bindings/clock/imx8qxp-lpcg.yaml  |  6 +++---
> >  .../bindings/mmc/fsl-imx-esdhc.yaml   | 20
> +++
> >  arch/arm64/boot/dts/freescale/imx8qxp.dtsi| 18 -
> >  drivers/mmc/host/sdhci-esdhc-imx.c|  2 +-
> >  4 files changed, 33 insertions(+), 13 deletions(-)
> >
> > --
> > 2.30.0
> >
> 
> Applied patch 1, 4 and 5, thanks!


Would you pick patch 2,3?

Thanks,
Peng.

> 
> Kind regards
> Uffe


[PATCH V3 4/5] dt-bindings: mmc: fsl-imx-esdhc: add clock bindings

2021-02-24 Thread peng . fan
From: Peng Fan 

Add clock bindings for fsl-imx-esdhc yaml

Signed-off-by: Peng Fan 
---
 .../devicetree/bindings/mmc/fsl-imx-esdhc.yaml| 11 +++
 1 file changed, 11 insertions(+)

diff --git a/Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.yaml 
b/Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.yaml
index a7fbd8cc1e38..369471814496 100644
--- a/Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.yaml
+++ b/Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.yaml
@@ -103,6 +103,17 @@ properties:
   Only eMMC HS400 mode need to take care of this property.
 default: 0
 
+  clocks:
+maxItems: 3
+description:
+  Handle clocks for the sdhc controller.
+
+  clock-names:
+items:
+  - const: ipg
+  - const: ahb
+  - const: per
+
   pinctrl-names:
 minItems: 1
 maxItems: 4
-- 
2.30.0



[PATCH V3 3/5] arm64: dts: imx8qxp: correct usdhc clock-names sequence

2021-02-24 Thread peng . fan
From: Peng Fan 

Per dt-bindings, the clock-names sequence should be ipg ahb per to pass
dtbs_check.

Signed-off-by: Peng Fan 
---
 arch/arm64/boot/dts/freescale/imx8qxp.dtsi | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/arm64/boot/dts/freescale/imx8qxp.dtsi 
b/arch/arm64/boot/dts/freescale/imx8qxp.dtsi
index e46faac1fe71..1d522de7b017 100644
--- a/arch/arm64/boot/dts/freescale/imx8qxp.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8qxp.dtsi
@@ -366,9 +366,9 @@ usdhc1: mmc@5b01 {
interrupts = ;
reg = <0x5b01 0x1>;
clocks = <_lpcg IMX_CONN_LPCG_SDHC0_IPG_CLK>,
-<_lpcg IMX_CONN_LPCG_SDHC0_PER_CLK>,
-<_lpcg IMX_CONN_LPCG_SDHC0_HCLK>;
-   clock-names = "ipg", "per", "ahb";
+<_lpcg IMX_CONN_LPCG_SDHC0_HCLK>,
+<_lpcg IMX_CONN_LPCG_SDHC0_PER_CLK>;
+   clock-names = "ipg", "ahb", "per";
power-domains = < IMX_SC_R_SDHC_0>;
status = "disabled";
};
@@ -378,9 +378,9 @@ usdhc2: mmc@5b02 {
interrupts = ;
reg = <0x5b02 0x1>;
clocks = <_lpcg IMX_CONN_LPCG_SDHC1_IPG_CLK>,
-<_lpcg IMX_CONN_LPCG_SDHC1_PER_CLK>,
-<_lpcg IMX_CONN_LPCG_SDHC1_HCLK>;
-   clock-names = "ipg", "per", "ahb";
+<_lpcg IMX_CONN_LPCG_SDHC1_HCLK>,
+<_lpcg IMX_CONN_LPCG_SDHC1_PER_CLK>;
+   clock-names = "ipg", "ahb", "per";
power-domains = < IMX_SC_R_SDHC_1>;
fsl,tuning-start-tap = <20>;
fsl,tuning-step= <2>;
@@ -392,9 +392,9 @@ usdhc3: mmc@5b03 {
interrupts = ;
reg = <0x5b03 0x1>;
clocks = <_lpcg IMX_CONN_LPCG_SDHC2_IPG_CLK>,
-<_lpcg IMX_CONN_LPCG_SDHC2_PER_CLK>,
-<_lpcg IMX_CONN_LPCG_SDHC2_HCLK>;
-   clock-names = "ipg", "per", "ahb";
+<_lpcg IMX_CONN_LPCG_SDHC2_HCLK>,
+<_lpcg IMX_CONN_LPCG_SDHC2_PER_CLK>;
+   clock-names = "ipg", "ahb", "per";
power-domains = < IMX_SC_R_SDHC_2>;
status = "disabled";
};
-- 
2.30.0



[PATCH V3 1/5] dt-bindings: mmc: fsl-imx-esdhc: add pinctrl bindings

2021-02-24 Thread peng . fan
From: Peng Fan 

Add pinctrl bindings for fsl-imx-esdhc yaml

Signed-off-by: Peng Fan 
---
 Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.yaml | 9 +
 1 file changed, 9 insertions(+)

diff --git a/Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.yaml 
b/Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.yaml
index 802c9df23752..a7fbd8cc1e38 100644
--- a/Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.yaml
+++ b/Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.yaml
@@ -103,6 +103,15 @@ properties:
   Only eMMC HS400 mode need to take care of this property.
 default: 0
 
+  pinctrl-names:
+minItems: 1
+maxItems: 4
+items:
+  - const: default
+  - const: state_100mhz
+  - const: state_200mhz
+  - const: sleep
+
 required:
   - compatible
   - reg
-- 
2.30.0



[PATCH V3 2/5] dt-bindings: clock: imx8qxp-lpcg: correct the example clock-names

2021-02-24 Thread peng . fan
From: Peng Fan 

Align with all other i.MX using the mmc controller, align
the clock-names.

Signed-off-by: Peng Fan 
---
 Documentation/devicetree/bindings/clock/imx8qxp-lpcg.yaml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/clock/imx8qxp-lpcg.yaml 
b/Documentation/devicetree/bindings/clock/imx8qxp-lpcg.yaml
index 940486ef1051..0f6fe365ebf3 100644
--- a/Documentation/devicetree/bindings/clock/imx8qxp-lpcg.yaml
+++ b/Documentation/devicetree/bindings/clock/imx8qxp-lpcg.yaml
@@ -107,8 +107,8 @@ examples:
 interrupts = ;
 reg = <0x5b01 0x1>;
 clocks = <_lpcg IMX_LPCG_CLK_4>,
- <_lpcg IMX_LPCG_CLK_0>,
- <_lpcg IMX_LPCG_CLK_5>;
-clock-names = "ipg", "per", "ahb";
+ <_lpcg IMX_LPCG_CLK_5>,
+ <_lpcg IMX_LPCG_CLK_0>;
+clock-names = "ipg", "ahb", "per";
 power-domains = < IMX_SC_R_SDHC_0>;
 };
-- 
2.30.0



[PATCH V3 0/5] imx esdhc dt/driver update

2021-02-24 Thread peng . fan
From: Peng Fan 

V3:
 Patch 1, drop unneeded pinctrl-0/1/2
 Patch 2 is new to avoid break dt bindings check
V2:
 patch 1, 2, 3 is new
 patch 4 is not changed
 
https://patchwork.kernel.org/project/linux-arm-kernel/cover/1611198593-16287-1-git-send-email-peng@nxp.com/

Peng Fan (5):
  dt-bindings: mmc: fsl-imx-esdhc: add pinctrl bindings
  dt-bindings: clock: imx8qxp-lpcg: correct the example clock-names
  arm64: dts: imx8qxp: correct usdhc clock-names sequence
  dt-bindings: mmc: fsl-imx-esdhc: add clock bindings
  mmc: sdhci-esdhc-imx: validate pinctrl before use it

 .../bindings/clock/imx8qxp-lpcg.yaml  |  6 +++---
 .../bindings/mmc/fsl-imx-esdhc.yaml   | 20 +++
 arch/arm64/boot/dts/freescale/imx8qxp.dtsi| 18 -
 drivers/mmc/host/sdhci-esdhc-imx.c|  2 +-
 4 files changed, 33 insertions(+), 13 deletions(-)

-- 
2.30.0



[PATCH V3 5/5] mmc: sdhci-esdhc-imx: validate pinctrl before use it

2021-02-24 Thread peng . fan
From: Peng Fan 

When imx_data->pinctrl is not a valid pointer, pinctrl_lookup_state
will trigger kernel panic.

When we boot Dual OS on Jailhouse hypervisor, we let the 1st Linux to
configure pinmux ready for the 2nd OS, so the 2nd OS not have pinctrl
settings.

Similar to this commit b62eee9f804e ("mmc: sdhci-esdhc-imx: no fail when no 
pinctrl available").

Reviewed-by: Bough Chen 
Reviewed-by: Alice Guo 
Signed-off-by: Peng Fan 
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c 
b/drivers/mmc/host/sdhci-esdhc-imx.c
index a20459744d21..94327988da91 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -1488,7 +1488,7 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
 
mmc_of_parse_voltage(np, >ocr_mask);
 
-   if (esdhc_is_usdhc(imx_data)) {
+   if (esdhc_is_usdhc(imx_data) && !IS_ERR(imx_data->pinctrl)) {
imx_data->pins_100mhz = pinctrl_lookup_state(imx_data->pinctrl,
ESDHC_PINCTRL_STATE_100MHZ);
imx_data->pins_200mhz = pinctrl_lookup_state(imx_data->pinctrl,
-- 
2.30.0



[PATCH V12 10/10] remoteproc: imx_proc: enable virtio/mailbox

2021-02-17 Thread peng . fan
From: Peng Fan 

Use virtio/mailbox to build connection between Remote Proccessors
and Linux. Add work queue to handle incoming messages.

Reviewed-by: Richard Zhu 
Reviewed-by: Mathieu Poirier 
Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 116 -
 1 file changed, 113 insertions(+), 3 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 3685bbd135b0..90471790bb24 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -7,6 +7,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -15,6 +16,9 @@
 #include 
 #include 
 #include 
+#include 
+
+#include "remoteproc_internal.h"
 
 #define IMX7D_SRC_SCR  0x0C
 #define IMX7D_ENABLE_M4BIT(3)
@@ -86,6 +90,11 @@ struct imx_rproc {
const struct imx_rproc_dcfg *dcfg;
struct imx_rproc_memmem[IMX7D_RPROC_MEM_MAX];
struct clk  *clk;
+   struct mbox_client  cl;
+   struct mbox_chan*tx_ch;
+   struct mbox_chan*rx_ch;
+   struct work_struct  rproc_work;
+   struct workqueue_struct *workqueue;
 };
 
 static const struct imx_rproc_att imx_rproc_att_imx8mq[] = {
@@ -366,9 +375,33 @@ static int imx_rproc_parse_fw(struct rproc *rproc, const 
struct firmware *fw)
return 0;
 }
 
+static void imx_rproc_kick(struct rproc *rproc, int vqid)
+{
+   struct imx_rproc *priv = rproc->priv;
+   int err;
+   __u32 mmsg;
+
+   if (!priv->tx_ch) {
+   dev_err(priv->dev, "No initialized mbox tx channel\n");
+   return;
+   }
+
+   /*
+* Send the index of the triggered virtqueue as the mu payload.
+* Let remote processor know which virtqueue is used.
+*/
+   mmsg = vqid << 16;
+
+   err = mbox_send_message(priv->tx_ch, (void *));
+   if (err < 0)
+   dev_err(priv->dev, "%s: failed (%d, err:%d)\n",
+   __func__, vqid, err);
+}
+
 static const struct rproc_ops imx_rproc_ops = {
.start  = imx_rproc_start,
.stop   = imx_rproc_stop,
+   .kick   = imx_rproc_kick,
.da_to_va   = imx_rproc_da_to_va,
.load   = rproc_elf_load_segments,
.parse_fw   = imx_rproc_parse_fw,
@@ -444,6 +477,66 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
return 0;
 }
 
+static void imx_rproc_vq_work(struct work_struct *work)
+{
+   struct imx_rproc *priv = container_of(work, struct imx_rproc,
+ rproc_work);
+
+   rproc_vq_interrupt(priv->rproc, 0);
+   rproc_vq_interrupt(priv->rproc, 1);
+}
+
+static void imx_rproc_rx_callback(struct mbox_client *cl, void *msg)
+{
+   struct rproc *rproc = dev_get_drvdata(cl->dev);
+   struct imx_rproc *priv = rproc->priv;
+
+   queue_work(priv->workqueue, >rproc_work);
+}
+
+static int imx_rproc_xtr_mbox_init(struct rproc *rproc)
+{
+   struct imx_rproc *priv = rproc->priv;
+   struct device *dev = priv->dev;
+   struct mbox_client *cl;
+   int ret;
+
+   if (!of_get_property(dev->of_node, "mbox-names", NULL))
+   return 0;
+
+   cl = >cl;
+   cl->dev = dev;
+   cl->tx_block = true;
+   cl->tx_tout = 100;
+   cl->knows_txdone = false;
+   cl->rx_callback = imx_rproc_rx_callback;
+
+   priv->tx_ch = mbox_request_channel_byname(cl, "tx");
+   if (IS_ERR(priv->tx_ch)) {
+   ret = PTR_ERR(priv->tx_ch);
+   return dev_err_probe(cl->dev, ret,
+"failed to request tx mailbox channel: 
%d\n", ret);
+   }
+
+   priv->rx_ch = mbox_request_channel_byname(cl, "rx");
+   if (IS_ERR(priv->rx_ch)) {
+   mbox_free_channel(priv->tx_ch);
+   ret = PTR_ERR(priv->rx_ch);
+   return dev_err_probe(cl->dev, ret,
+"failed to request rx mailbox channel: 
%d\n", ret);
+   }
+
+   return 0;
+}
+
+static void imx_rproc_free_mbox(struct rproc *rproc)
+{
+   struct imx_rproc *priv = rproc->priv;
+
+   mbox_free_channel(priv->tx_ch);
+   mbox_free_channel(priv->rx_ch);
+}
+
 static int imx_rproc_probe(struct platform_device *pdev)
 {
struct device *dev = >dev;
@@ -481,18 +574,28 @@ static int imx_rproc_probe(struct platform_device *pdev)
priv->dev = dev;
 
dev_set_drvdata(dev, rproc);
+   priv->workqueue = create_workqueue(dev_name(dev));
+   if (!priv->workqueue) {
+   dev_err(dev, "cannot create workqueue\n");
+  

[PATCH V12 07/10] remoteproc: imx_rproc: add i.MX specific parse fw hook

2021-02-17 Thread peng . fan
From: Peng Fan 

The hook is used to parse memory-regions and load resource table
from the address the remote processor published.

Reviewed-by: Richard Zhu 
Reviewed-by: Mathieu Poirier 
Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 93 ++
 1 file changed, 93 insertions(+)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 47fc1d06be6a..5ae1f5209548 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -241,10 +242,102 @@ static void *imx_rproc_da_to_va(struct rproc *rproc, u64 
da, size_t len, bool *i
return va;
 }
 
+static int imx_rproc_mem_alloc(struct rproc *rproc,
+  struct rproc_mem_entry *mem)
+{
+   struct device *dev = rproc->dev.parent;
+   void *va;
+
+   dev_dbg(dev, "map memory: %p+%zx\n", >dma, mem->len);
+   va = ioremap_wc(mem->dma, mem->len);
+   if (IS_ERR_OR_NULL(va)) {
+   dev_err(dev, "Unable to map memory region: %p+%zx\n",
+   >dma, mem->len);
+   return -ENOMEM;
+   }
+
+   /* Update memory entry va */
+   mem->va = va;
+
+   return 0;
+}
+
+static int imx_rproc_mem_release(struct rproc *rproc,
+struct rproc_mem_entry *mem)
+{
+   dev_dbg(rproc->dev.parent, "unmap memory: %pa\n", >dma);
+   iounmap(mem->va);
+
+   return 0;
+}
+
+static int imx_rproc_parse_memory_regions(struct rproc *rproc)
+{
+   struct imx_rproc *priv = rproc->priv;
+   struct device_node *np = priv->dev->of_node;
+   struct of_phandle_iterator it;
+   struct rproc_mem_entry *mem;
+   struct reserved_mem *rmem;
+   u32 da;
+
+   /* Register associated reserved memory regions */
+   of_phandle_iterator_init(, np, "memory-region", NULL, 0);
+   while (of_phandle_iterator_next() == 0) {
+   /*
+* Ignore the first memory region which will be used vdev 
buffer.
+* No need to do extra handlings, rproc_add_virtio_dev will 
handle it.
+*/
+   if (!strcmp(it.node->name, "vdev0buffer"))
+   continue;
+
+   rmem = of_reserved_mem_lookup(it.node);
+   if (!rmem) {
+   dev_err(priv->dev, "unable to acquire memory-region\n");
+   return -EINVAL;
+   }
+
+   /* No need to translate pa to da, i.MX use same map */
+   da = rmem->base;
+
+   /* Register memory region */
+   mem = rproc_mem_entry_init(priv->dev, NULL, 
(dma_addr_t)rmem->base, rmem->size, da,
+  imx_rproc_mem_alloc, 
imx_rproc_mem_release,
+  it.node->name);
+
+   if (mem)
+   rproc_coredump_add_segment(rproc, da, rmem->size);
+   else
+   return -ENOMEM;
+
+   rproc_add_carveout(rproc, mem);
+   }
+
+   return  0;
+}
+
+static int imx_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
+{
+   int ret = imx_rproc_parse_memory_regions(rproc);
+
+   if (ret)
+   return ret;
+
+   ret = rproc_elf_load_rsc_table(rproc, fw);
+   if (ret)
+   dev_info(>dev, "No resource table in elf\n");
+
+   return 0;
+}
+
 static const struct rproc_ops imx_rproc_ops = {
.start  = imx_rproc_start,
.stop   = imx_rproc_stop,
.da_to_va   = imx_rproc_da_to_va,
+   .load   = rproc_elf_load_segments,
+   .parse_fw   = imx_rproc_parse_fw,
+   .find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table,
+   .sanity_check   = rproc_elf_sanity_check,
+   .get_boot_addr  = rproc_elf_get_boot_addr,
 };
 
 static int imx_rproc_addr_init(struct imx_rproc *priv,
-- 
2.30.0



[PATCH V12 05/10] remoteproc: imx_rproc: correct err message

2021-02-17 Thread peng . fan
From: Peng Fan 

It is using devm_ioremap, so not devm_ioremap_resource. Correct
the error message and print out sa/size.

Reviewed-by: Bjorn Andersson 
Reviewed-by: Mathieu Poirier 
Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 6603e00bb6f4..2a093cea4997 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -268,7 +268,7 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
priv->mem[b].cpu_addr = devm_ioremap(>dev,
 att->sa, att->size);
if (!priv->mem[b].cpu_addr) {
-   dev_err(dev, "devm_ioremap_resource failed\n");
+   dev_err(dev, "failed to remap %#x bytes from %#x\n", 
att->size, att->sa);
return -ENOMEM;
}
priv->mem[b].sys_addr = att->sa;
@@ -298,7 +298,7 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
 
priv->mem[b].cpu_addr = devm_ioremap_resource(>dev, );
if (IS_ERR(priv->mem[b].cpu_addr)) {
-   dev_err(dev, "devm_ioremap_resource failed\n");
+   dev_err(dev, "failed to remap %pr\n", );
err = PTR_ERR(priv->mem[b].cpu_addr);
return err;
}
-- 
2.30.0



[PATCH V12 06/10] remoteproc: imx_rproc: use devm_ioremap

2021-02-17 Thread peng . fan
From: Peng Fan 

We might need to map an region multiple times, becaue the region might
be shared between remote processors, such i.MX8QM with dual M4 cores.
So use devm_ioremap, not devm_ioremap_resource.

Reviewed-by: Oleksij Rempel 
Reviewed-by: Richard Zhu 
Signed-off-by: Peng Fan 
Reviewed-by: Mathieu Poirier 
---
 drivers/remoteproc/imx_rproc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 2a093cea4997..47fc1d06be6a 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -296,7 +296,8 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
if (b >= IMX7D_RPROC_MEM_MAX)
break;
 
-   priv->mem[b].cpu_addr = devm_ioremap_resource(>dev, );
+   /* Not use resource version, because we might share region */
+   priv->mem[b].cpu_addr = devm_ioremap(>dev, res.start, 
resource_size());
if (IS_ERR(priv->mem[b].cpu_addr)) {
dev_err(dev, "failed to remap %pr\n", );
err = PTR_ERR(priv->mem[b].cpu_addr);
-- 
2.30.0



[PATCH V12 03/10] remoteproc: introduce is_iomem to rproc_mem_entry

2021-02-17 Thread peng . fan
From: Peng Fan 

Introduce is_iomem to indicate this piece memory is iomem or not.

Reviewed-by: Bjorn Andersson 
Signed-off-by: Peng Fan 
Reviewed-by: Mathieu Poirier 
---
 include/linux/remoteproc.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index f28ee75d1005..a5f6d2d9cde2 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -315,6 +315,7 @@ struct rproc;
 /**
  * struct rproc_mem_entry - memory entry descriptor
  * @va:virtual address
+ * @is_iomem: io memory
  * @dma: dma address
  * @len: length, in bytes
  * @da: device address
@@ -329,6 +330,7 @@ struct rproc;
  */
 struct rproc_mem_entry {
void *va;
+   bool is_iomem;
dma_addr_t dma;
size_t len;
u32 da;
-- 
2.30.0



[PATCH V12 04/10] remoteproc: add is_iomem to da_to_va

2021-02-17 Thread peng . fan
From: Peng Fan 

Introduce an extra parameter is_iomem to da_to_va, then the caller
could take the memory as normal memory or io mapped memory.

Reviewed-by: Bjorn Andersson 
Reviewed-by: Mathieu Poirier 
Reported-by: kernel test robot 
Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c |  2 +-
 drivers/remoteproc/ingenic_rproc.c |  2 +-
 drivers/remoteproc/keystone_remoteproc.c   |  2 +-
 drivers/remoteproc/mtk_scp.c   |  6 +++---
 drivers/remoteproc/omap_remoteproc.c   |  2 +-
 drivers/remoteproc/pru_rproc.c |  2 +-
 drivers/remoteproc/qcom_q6v5_adsp.c|  2 +-
 drivers/remoteproc/qcom_q6v5_pas.c |  2 +-
 drivers/remoteproc/qcom_q6v5_wcss.c|  2 +-
 drivers/remoteproc/qcom_wcnss.c|  2 +-
 drivers/remoteproc/remoteproc_core.c   |  7 +--
 drivers/remoteproc/remoteproc_coredump.c   |  8 ++--
 drivers/remoteproc/remoteproc_debugfs.c|  2 +-
 drivers/remoteproc/remoteproc_elf_loader.c | 21 +++--
 drivers/remoteproc/remoteproc_internal.h   |  2 +-
 drivers/remoteproc/st_slim_rproc.c |  2 +-
 drivers/remoteproc/ti_k3_dsp_remoteproc.c  |  2 +-
 drivers/remoteproc/ti_k3_r5_remoteproc.c   |  2 +-
 drivers/remoteproc/wkup_m3_rproc.c |  2 +-
 include/linux/remoteproc.h |  2 +-
 20 files changed, 45 insertions(+), 29 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 8957ed271d20..6603e00bb6f4 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -208,7 +208,7 @@ static int imx_rproc_da_to_sys(struct imx_rproc *priv, u64 
da,
return -ENOENT;
 }
 
-static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len)
+static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool 
*is_iomem)
 {
struct imx_rproc *priv = rproc->priv;
void *va = NULL;
diff --git a/drivers/remoteproc/ingenic_rproc.c 
b/drivers/remoteproc/ingenic_rproc.c
index e2618c36eaab..a356738160a4 100644
--- a/drivers/remoteproc/ingenic_rproc.c
+++ b/drivers/remoteproc/ingenic_rproc.c
@@ -121,7 +121,7 @@ static void ingenic_rproc_kick(struct rproc *rproc, int 
vqid)
writel(vqid, vpu->aux_base + REG_CORE_MSG);
 }
 
-static void *ingenic_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len)
+static void *ingenic_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, 
bool *is_iomem)
 {
struct vpu *vpu = rproc->priv;
void __iomem *va = NULL;
diff --git a/drivers/remoteproc/keystone_remoteproc.c 
b/drivers/remoteproc/keystone_remoteproc.c
index cd266163a65f..54781f553f4e 100644
--- a/drivers/remoteproc/keystone_remoteproc.c
+++ b/drivers/remoteproc/keystone_remoteproc.c
@@ -246,7 +246,7 @@ static void keystone_rproc_kick(struct rproc *rproc, int 
vqid)
  * can be used either by the remoteproc core for loading (when using kernel
  * remoteproc loader), or by any rpmsg bus drivers.
  */
-static void *keystone_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len)
+static void *keystone_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, 
bool *is_iomem)
 {
struct keystone_rproc *ksproc = rproc->priv;
void __iomem *va = NULL;
diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c
index ce727598c41c..9679cc26895e 100644
--- a/drivers/remoteproc/mtk_scp.c
+++ b/drivers/remoteproc/mtk_scp.c
@@ -272,7 +272,7 @@ static int scp_elf_load_segments(struct rproc *rproc, const 
struct firmware *fw)
}
 
/* grab the kernel address for this device address */
-   ptr = (void __iomem *)rproc_da_to_va(rproc, da, memsz);
+   ptr = (void __iomem *)rproc_da_to_va(rproc, da, memsz, NULL);
if (!ptr) {
dev_err(dev, "bad phdr da 0x%x mem 0x%x\n", da, memsz);
ret = -EINVAL;
@@ -509,7 +509,7 @@ static void *mt8192_scp_da_to_va(struct mtk_scp *scp, u64 
da, size_t len)
return NULL;
 }
 
-static void *scp_da_to_va(struct rproc *rproc, u64 da, size_t len)
+static void *scp_da_to_va(struct rproc *rproc, u64 da, size_t len, bool 
*is_iomem)
 {
struct mtk_scp *scp = (struct mtk_scp *)rproc->priv;
 
@@ -627,7 +627,7 @@ void *scp_mapping_dm_addr(struct mtk_scp *scp, u32 mem_addr)
 {
void *ptr;
 
-   ptr = scp_da_to_va(scp->rproc, mem_addr, 0);
+   ptr = scp_da_to_va(scp->rproc, mem_addr, 0, NULL);
if (!ptr)
return ERR_PTR(-EINVAL);
 
diff --git a/drivers/remoteproc/omap_remoteproc.c 
b/drivers/remoteproc/omap_remoteproc.c
index d94b7391bf9d..43531caa1959 100644
--- a/drivers/remoteproc/omap_remoteproc.c
+++ b/drivers/remoteproc/omap_remoteproc.c
@@ -728,7 +728,7 @@ static int omap_rproc_stop(struct rproc *rproc)
  * Return: translated virtual address in kernel memory space on success,
  * or NULL on failure.
  */
-static void *omap_rproc_da_to

[PATCH V12 09/10] remoteproc: imx_rproc: ignore mapping vdev regions

2021-02-17 Thread peng . fan
From: Peng Fan 

vdev regions are vdev0vring0, vdev0vring1, vdevbuffer and similar.
They are handled by remoteproc common code, no need to map in imx
rproc driver.

Signed-off-by: Peng Fan 
Reviewed-by: Mathieu Poirier 
---
 drivers/remoteproc/imx_rproc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 0124ebf69838..3685bbd135b0 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -417,6 +417,9 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
struct resource res;
 
node = of_parse_phandle(np, "memory-region", a);
+   /* Not map vdev region */
+   if (!strcmp(node->name, "vdev"))
+   continue;
err = of_address_to_resource(node, 0, );
if (err) {
dev_err(dev, "unable to resolve memory region\n");
-- 
2.30.0



[PATCH V12 08/10] remoteproc: imx_rproc: support i.MX8MQ/M

2021-02-17 Thread peng . fan
From: Peng Fan 

Add i.MX8MQ dev/sys addr map and configuration data structure
i.MX8MM share i.MX8MQ settings.

Reviewed-by: Richard Zhu 
Reviewed-by: Mathieu Poirier 
Signed-off-by: Peng Fan 
---
 drivers/remoteproc/Kconfig |  6 ++---
 drivers/remoteproc/imx_rproc.c | 41 +-
 2 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 15d1574d129b..7cf3d1b40c55 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -24,11 +24,11 @@ config REMOTEPROC_CDEV
  It's safe to say N if you don't want to use this interface.
 
 config IMX_REMOTEPROC
-   tristate "IMX6/7 remoteproc support"
+   tristate "i.MX remoteproc support"
depends on ARCH_MXC
help
- Say y here to support iMX's remote processors (Cortex M4
- on iMX7D) via the remote processor framework.
+ Say y here to support iMX's remote processors via the remote
+ processor framework.
 
  It's safe to say N here.
 
diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 5ae1f5209548..0124ebf69838 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -88,6 +88,34 @@ struct imx_rproc {
struct clk  *clk;
 };
 
+static const struct imx_rproc_att imx_rproc_att_imx8mq[] = {
+   /* dev addr , sys addr  , size  , flags */
+   /* TCML - alias */
+   { 0x, 0x007e, 0x0002, 0 },
+   /* OCRAM_S */
+   { 0x0018, 0x0018, 0x8000, 0 },
+   /* OCRAM */
+   { 0x0090, 0x0090, 0x0002, 0 },
+   /* OCRAM */
+   { 0x0092, 0x0092, 0x0002, 0 },
+   /* QSPI Code - alias */
+   { 0x0800, 0x0800, 0x0800, 0 },
+   /* DDR (Code) - alias */
+   { 0x1000, 0x8000, 0x0FFE, 0 },
+   /* TCML */
+   { 0x1FFE, 0x007E, 0x0002, ATT_OWN },
+   /* TCMU */
+   { 0x2000, 0x0080, 0x0002, ATT_OWN },
+   /* OCRAM_S */
+   { 0x2018, 0x0018, 0x8000, ATT_OWN },
+   /* OCRAM */
+   { 0x2020, 0x0090, 0x0002, ATT_OWN },
+   /* OCRAM */
+   { 0x2022, 0x0092, 0x0002, ATT_OWN },
+   /* DDR (Data) */
+   { 0x4000, 0x4000, 0x8000, 0 },
+};
+
 static const struct imx_rproc_att imx_rproc_att_imx7d[] = {
/* dev addr , sys addr  , size  , flags */
/* OCRAM_S (M4 Boot code) - alias */
@@ -138,6 +166,15 @@ static const struct imx_rproc_att imx_rproc_att_imx6sx[] = 
{
{ 0x8000, 0x8000, 0x6000, 0 },
 };
 
+static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mq = {
+   .src_reg= IMX7D_SRC_SCR,
+   .src_mask   = IMX7D_M4_RST_MASK,
+   .src_start  = IMX7D_M4_START,
+   .src_stop   = IMX7D_M4_STOP,
+   .att= imx_rproc_att_imx8mq,
+   .att_size   = ARRAY_SIZE(imx_rproc_att_imx8mq),
+};
+
 static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = {
.src_reg= IMX7D_SRC_SCR,
.src_mask   = IMX7D_M4_RST_MASK,
@@ -496,6 +533,8 @@ static int imx_rproc_remove(struct platform_device *pdev)
 static const struct of_device_id imx_rproc_of_match[] = {
{ .compatible = "fsl,imx7d-cm4", .data = _rproc_cfg_imx7d },
{ .compatible = "fsl,imx6sx-cm4", .data = _rproc_cfg_imx6sx },
+   { .compatible = "fsl,imx8mq-cm4", .data = _rproc_cfg_imx8mq },
+   { .compatible = "fsl,imx8mm-cm4", .data = _rproc_cfg_imx8mq },
{},
 };
 MODULE_DEVICE_TABLE(of, imx_rproc_of_match);
@@ -512,5 +551,5 @@ static struct platform_driver imx_rproc_driver = {
 module_platform_driver(imx_rproc_driver);
 
 MODULE_LICENSE("GPL v2");
-MODULE_DESCRIPTION("IMX6SX/7D remote processor control driver");
+MODULE_DESCRIPTION("i.MX remote processor control driver");
 MODULE_AUTHOR("Oleksij Rempel ");
-- 
2.30.0



[PATCH V12 01/10] dt-bindings: remoteproc: convert imx rproc bindings to json-schema

2021-02-17 Thread peng . fan
From: Peng Fan 

Convert the imx rproc binding to DT schema format using json-schema.

Signed-off-by: Peng Fan 
---
 .../bindings/remoteproc/fsl,imx-rproc.yaml| 61 +++
 .../bindings/remoteproc/imx-rproc.txt | 33 --
 2 files changed, 61 insertions(+), 33 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
 delete mode 100644 Documentation/devicetree/bindings/remoteproc/imx-rproc.txt

diff --git a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml 
b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
new file mode 100644
index ..54d2456530a6
--- /dev/null
+++ b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/remoteproc/fsl,imx-rproc.yaml#;
+$schema: "http://devicetree.org/meta-schemas/core.yaml#;
+
+title: NXP iMX6SX/iMX7D Co-Processor Bindings
+
+description:
+  This binding provides support for ARM Cortex M4 Co-processor found on some 
NXP iMX SoCs.
+
+maintainers:
+  - Peng Fan 
+
+properties:
+  compatible:
+enum:
+  - fsl,imx7d-cm4
+  - fsl,imx6sx-cm4
+
+  clocks:
+maxItems: 1
+
+  syscon:
+$ref: /schemas/types.yaml#/definitions/phandle
+description:
+  Phandle to syscon block which provide access to System Reset Controller
+
+  memory-region:
+description:
+  If present, a phandle for a reserved memory area that used for vdev 
buffer,
+  resource table, vring region and others used by remote processor.
+minItems: 1
+maxItems: 32
+
+required:
+  - compatible
+  - clocks
+  - syscon
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+m4_reserved_sysmem1: cm4@8000 {
+  reg = <0x8000 0x8>;
+};
+
+m4_reserved_sysmem2: cm4@8100 {
+  reg = <0x8100 0x8>;
+};
+
+imx7d-cm4 {
+  compatible   = "fsl,imx7d-cm4";
+  memory-region= <_reserved_sysmem1>, <_reserved_sysmem2>;
+  syscon   = <>;
+  clocks   = < IMX7D_ARM_M4_ROOT_CLK>;
+};
+
+...
diff --git a/Documentation/devicetree/bindings/remoteproc/imx-rproc.txt 
b/Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
deleted file mode 100644
index fbcefd965dc4..
--- a/Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-NXP iMX6SX/iMX7D Co-Processor Bindings
-
-
-This binding provides support for ARM Cortex M4 Co-processor found on some
-NXP iMX SoCs.
-
-Required properties:
-- compatible   Should be one of:
-   "fsl,imx7d-cm4"
-   "fsl,imx6sx-cm4"
-- clocks   Clock for co-processor (See: 
../clock/clock-bindings.txt)
-- syscon   Phandle to syscon block which provide access to
-   System Reset Controller
-
-Optional properties:
-- memory-regionlist of phandels to the reserved memory regions.
-   (See: ../reserved-memory/reserved-memory.txt)
-
-Example:
-   m4_reserved_sysmem1: cm4@8000 {
-   reg = <0x8000 0x8>;
-   };
-
-   m4_reserved_sysmem2: cm4@8100 {
-   reg = <0x8100 0x8>;
-   };
-
-   imx7d-cm4 {
-   compatible  = "fsl,imx7d-cm4";
-   memory-region   = <_reserved_sysmem1>, 
<_reserved_sysmem2>;
-   syscon  = <>;
-   clocks  = < IMX7D_ARM_M4_ROOT_CLK>;
-   };
-- 
2.30.0



[PATCH V12 02/10] dt-bindings: remoteproc: imx_rproc: add i.MX8MQ/M support

2021-02-17 Thread peng . fan
From: Peng Fan 

Add i.MX8MQ/M support, also include mailbox for rpmsg/virtio usage.

Signed-off-by: Peng Fan 
---
 .../bindings/remoteproc/fsl,imx-rproc.yaml| 51 ++-
 1 file changed, 50 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml 
b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
index 54d2456530a6..52c8e523506d 100644
--- a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
+++ b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
@@ -4,7 +4,7 @@
 $id: "http://devicetree.org/schemas/remoteproc/fsl,imx-rproc.yaml#;
 $schema: "http://devicetree.org/meta-schemas/core.yaml#;
 
-title: NXP iMX6SX/iMX7D Co-Processor Bindings
+title: NXP i.MX Co-Processor Bindings
 
 description:
   This binding provides support for ARM Cortex M4 Co-processor found on some 
NXP iMX SoCs.
@@ -15,6 +15,8 @@ maintainers:
 properties:
   compatible:
 enum:
+  - fsl,imx8mq-cm4
+  - fsl,imx8mm-cm4
   - fsl,imx7d-cm4
   - fsl,imx6sx-cm4
 
@@ -26,6 +28,20 @@ properties:
 description:
   Phandle to syscon block which provide access to System Reset Controller
 
+  mbox-names:
+items:
+  - const: tx
+  - const: rx
+  - const: rxdb
+
+  mboxes:
+description:
+  This property is required only if the rpmsg/virtio functionality is used.
+  List of < type channel> - 1 channel for TX, 1 channel for RX, 1 
channel for RXDB.
+  (see mailbox/fsl,mu.yaml)
+minItems: 1
+maxItems: 3
+
   memory-region:
 description:
   If present, a phandle for a reserved memory area that used for vdev 
buffer,
@@ -58,4 +74,37 @@ examples:
   clocks   = < IMX7D_ARM_M4_ROOT_CLK>;
 };
 
+  - |
+#include 
+rsc_table: rsc_table@550ff000 {
+  no-map;
+  reg = <0x550ff000 0x1000>;
+};
+
+vdev0vring0: vdev0vring0@5500 {
+  no-map;
+  reg = <0x5500 0x8000>;
+};
+
+vdev0vring1: vdev0vring1@55008000 {
+  reg = <0x55008000 0x8000>;
+  no-map;
+};
+
+vdev0buffer: vdev0buffer@5540 {
+  compatible = "shared-dma-pool";
+  reg = <0x5540 0x10>;
+  no-map;
+};
+
+imx8mm-cm4 {
+  compatible = "fsl,imx8mm-cm4";
+  clocks = < IMX8MM_CLK_M4_DIV>;
+  mbox-names = "tx", "rx", "rxdb";
+  mboxes = < 0 1
+ 1 1
+ 3 1>;
+  memory-region = <>, <>, <>, 
<_table>;
+  syscon = <>;
+};
 ...
-- 
2.30.0



[PATCH V12 00/10] remoteproc: imx_rproc: support iMX8MQ/M

2021-02-17 Thread peng . fan
From: Peng Fan 

V12:
 Add maxItems to avoid dt_bindings_check fail
 Rebased on top of linux-next

V11:
 Per Rob's comments, fix memory-region in patch 1/10
 Rebased on top of Linux-next

V10:
 Per Rob's comments, fix patch 1/10

V9:
 Per Mathieu's comments,
   update the tile of yaml in patch 2/10
   update the Kconfig and MODULE_DESCRIPTION, I merge this change in patch 8/10,
   since this is a minor change, I still keep Mathieu's R-b tag. If any 
objection, I could remove.
   Add R-b tag in Patch 10/10

 Rob, please help review patch 1/10 and 2/10

V8:
 Address sparse warning in patch 4/10 reported by kernel test robot

V7:
 Add R-b tag from Mathieu
 vdevbuffer->vdev0buffer in patch 1/10, 7/10
 correct err msg and shutdown seq per Mathieu's comments in patch 10/10
 Hope this version is ok to be merged.
 
V6:
 Add R-b tag from Mathieu
 Convert imx-rproc.txt to yaml and add dt-bindings support for i.MX8MQ/M, patch 
1/10 2/10
 No other changes.

V5:
 Apply on Linux next
 Add V5 subject prefix
 Add R-b tag from Bjorn for 1/8, 2/8, 3/8
 
https://patchwork.kernel.org/project/linux-remoteproc/cover/20201229033019.25899-1-peng@nxp.com/

V4:
 According to Bjorn's comments, add is_iomem for da to va usage
 1/8, 2/8 is new patch
 3/8, follow Bjorn's comments to correct/update the err msg.
 6/8, new patch
 8/8, use dev_err_probe to simplify code, use queue_work instead 
schedule_delayed_work

V3:
 Since I was quite busy in the past days, V3 is late
 Rebased on Linux-next
 Add R-b tags
 1/7: Add R-b tag of Mathieu, add comments
 4/7: Typo fix
 5/7: Add R-b tag of Mathieu, drop index Per Mathieu's comments
 6/7: Add R-b tag of Mathieu
 7/7: Add comment for vqid << 16, drop unneeded timeout settings of mailbox
  Use queue_work instead of schedule_delayed_work
  free mbox channels when remove
 https://lkml.org/lkml/2020/12/4/82

V2:
 Rebased on linux-next
 Dropped early boot feature to make patchset simple.
 Drop rsc-da
 
https://patchwork.kernel.org/project/linux-remoteproc/cover/20200927064131.24101-1-peng@nxp.com/

V1:
 https://patchwork.kernel.org/cover/11682461/

This patchset is to support i.MX8MQ/M coproc.
The early boot feature was dropped to make the patchset small in V2.

Since i.MX specific TCM memory requirement, add elf platform hook.
Several patches have got reviewed by Oleksij and Mathieu in v1.


Peng Fan (10):
  dt-bindings: remoteproc: convert imx rproc bindings to json-schema
  dt-bindings: remoteproc: imx_rproc: add i.MX8MQ/M support
  remoteproc: introduce is_iomem to rproc_mem_entry
  remoteproc: add is_iomem to da_to_va
  remoteproc: imx_rproc: correct err message
  remoteproc: imx_rproc: use devm_ioremap
  remoteproc: imx_rproc: add i.MX specific parse fw hook
  remoteproc: imx_rproc: support i.MX8MQ/M
  remoteproc: imx_rproc: ignore mapping vdev regions
  remoteproc: imx_proc: enable virtio/mailbox

 .../bindings/remoteproc/fsl,imx-rproc.yaml| 110 
 .../bindings/remoteproc/imx-rproc.txt |  33 ---
 drivers/remoteproc/Kconfig|   6 +-
 drivers/remoteproc/imx_rproc.c| 262 +-
 drivers/remoteproc/ingenic_rproc.c|   2 +-
 drivers/remoteproc/keystone_remoteproc.c  |   2 +-
 drivers/remoteproc/mtk_scp.c  |   6 +-
 drivers/remoteproc/omap_remoteproc.c  |   2 +-
 drivers/remoteproc/pru_rproc.c|   2 +-
 drivers/remoteproc/qcom_q6v5_adsp.c   |   2 +-
 drivers/remoteproc/qcom_q6v5_pas.c|   2 +-
 drivers/remoteproc/qcom_q6v5_wcss.c   |   2 +-
 drivers/remoteproc/qcom_wcnss.c   |   2 +-
 drivers/remoteproc/remoteproc_core.c  |   7 +-
 drivers/remoteproc/remoteproc_coredump.c  |   8 +-
 drivers/remoteproc/remoteproc_debugfs.c   |   2 +-
 drivers/remoteproc/remoteproc_elf_loader.c|  21 +-
 drivers/remoteproc/remoteproc_internal.h  |   2 +-
 drivers/remoteproc/st_slim_rproc.c|   2 +-
 drivers/remoteproc/ti_k3_dsp_remoteproc.c |   2 +-
 drivers/remoteproc/ti_k3_r5_remoteproc.c  |   2 +-
 drivers/remoteproc/wkup_m3_rproc.c|   2 +-
 include/linux/remoteproc.h|   4 +-
 23 files changed, 413 insertions(+), 72 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
 delete mode 100644 Documentation/devicetree/bindings/remoteproc/imx-rproc.txt

-- 
2.30.0



[PATCH V10 08/10] remoteproc: imx_rproc: support i.MX8MQ/M

2021-02-15 Thread peng . fan
From: Peng Fan 

Add i.MX8MQ dev/sys addr map and configuration data structure
i.MX8MM share i.MX8MQ settings.

Reviewed-by: Richard Zhu 
Reviewed-by: Mathieu Poirier 
Signed-off-by: Peng Fan 
---
 drivers/remoteproc/Kconfig |  6 ++---
 drivers/remoteproc/imx_rproc.c | 41 +-
 2 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 15d1574d129b..7cf3d1b40c55 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -24,11 +24,11 @@ config REMOTEPROC_CDEV
  It's safe to say N if you don't want to use this interface.
 
 config IMX_REMOTEPROC
-   tristate "IMX6/7 remoteproc support"
+   tristate "i.MX remoteproc support"
depends on ARCH_MXC
help
- Say y here to support iMX's remote processors (Cortex M4
- on iMX7D) via the remote processor framework.
+ Say y here to support iMX's remote processors via the remote
+ processor framework.
 
  It's safe to say N here.
 
diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 5ae1f5209548..0124ebf69838 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -88,6 +88,34 @@ struct imx_rproc {
struct clk  *clk;
 };
 
+static const struct imx_rproc_att imx_rproc_att_imx8mq[] = {
+   /* dev addr , sys addr  , size  , flags */
+   /* TCML - alias */
+   { 0x, 0x007e, 0x0002, 0 },
+   /* OCRAM_S */
+   { 0x0018, 0x0018, 0x8000, 0 },
+   /* OCRAM */
+   { 0x0090, 0x0090, 0x0002, 0 },
+   /* OCRAM */
+   { 0x0092, 0x0092, 0x0002, 0 },
+   /* QSPI Code - alias */
+   { 0x0800, 0x0800, 0x0800, 0 },
+   /* DDR (Code) - alias */
+   { 0x1000, 0x8000, 0x0FFE, 0 },
+   /* TCML */
+   { 0x1FFE, 0x007E, 0x0002, ATT_OWN },
+   /* TCMU */
+   { 0x2000, 0x0080, 0x0002, ATT_OWN },
+   /* OCRAM_S */
+   { 0x2018, 0x0018, 0x8000, ATT_OWN },
+   /* OCRAM */
+   { 0x2020, 0x0090, 0x0002, ATT_OWN },
+   /* OCRAM */
+   { 0x2022, 0x0092, 0x0002, ATT_OWN },
+   /* DDR (Data) */
+   { 0x4000, 0x4000, 0x8000, 0 },
+};
+
 static const struct imx_rproc_att imx_rproc_att_imx7d[] = {
/* dev addr , sys addr  , size  , flags */
/* OCRAM_S (M4 Boot code) - alias */
@@ -138,6 +166,15 @@ static const struct imx_rproc_att imx_rproc_att_imx6sx[] = 
{
{ 0x8000, 0x8000, 0x6000, 0 },
 };
 
+static const struct imx_rproc_dcfg imx_rproc_cfg_imx8mq = {
+   .src_reg= IMX7D_SRC_SCR,
+   .src_mask   = IMX7D_M4_RST_MASK,
+   .src_start  = IMX7D_M4_START,
+   .src_stop   = IMX7D_M4_STOP,
+   .att= imx_rproc_att_imx8mq,
+   .att_size   = ARRAY_SIZE(imx_rproc_att_imx8mq),
+};
+
 static const struct imx_rproc_dcfg imx_rproc_cfg_imx7d = {
.src_reg= IMX7D_SRC_SCR,
.src_mask   = IMX7D_M4_RST_MASK,
@@ -496,6 +533,8 @@ static int imx_rproc_remove(struct platform_device *pdev)
 static const struct of_device_id imx_rproc_of_match[] = {
{ .compatible = "fsl,imx7d-cm4", .data = _rproc_cfg_imx7d },
{ .compatible = "fsl,imx6sx-cm4", .data = _rproc_cfg_imx6sx },
+   { .compatible = "fsl,imx8mq-cm4", .data = _rproc_cfg_imx8mq },
+   { .compatible = "fsl,imx8mm-cm4", .data = _rproc_cfg_imx8mq },
{},
 };
 MODULE_DEVICE_TABLE(of, imx_rproc_of_match);
@@ -512,5 +551,5 @@ static struct platform_driver imx_rproc_driver = {
 module_platform_driver(imx_rproc_driver);
 
 MODULE_LICENSE("GPL v2");
-MODULE_DESCRIPTION("IMX6SX/7D remote processor control driver");
+MODULE_DESCRIPTION("i.MX remote processor control driver");
 MODULE_AUTHOR("Oleksij Rempel ");
-- 
2.30.0



[PATCH V10 10/10] remoteproc: imx_proc: enable virtio/mailbox

2021-02-15 Thread peng . fan
From: Peng Fan 

Use virtio/mailbox to build connection between Remote Proccessors
and Linux. Add work queue to handle incoming messages.

Reviewed-by: Richard Zhu 
Reviewed-by: Mathieu Poirier 
Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 116 -
 1 file changed, 113 insertions(+), 3 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 3685bbd135b0..90471790bb24 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -7,6 +7,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -15,6 +16,9 @@
 #include 
 #include 
 #include 
+#include 
+
+#include "remoteproc_internal.h"
 
 #define IMX7D_SRC_SCR  0x0C
 #define IMX7D_ENABLE_M4BIT(3)
@@ -86,6 +90,11 @@ struct imx_rproc {
const struct imx_rproc_dcfg *dcfg;
struct imx_rproc_memmem[IMX7D_RPROC_MEM_MAX];
struct clk  *clk;
+   struct mbox_client  cl;
+   struct mbox_chan*tx_ch;
+   struct mbox_chan*rx_ch;
+   struct work_struct  rproc_work;
+   struct workqueue_struct *workqueue;
 };
 
 static const struct imx_rproc_att imx_rproc_att_imx8mq[] = {
@@ -366,9 +375,33 @@ static int imx_rproc_parse_fw(struct rproc *rproc, const 
struct firmware *fw)
return 0;
 }
 
+static void imx_rproc_kick(struct rproc *rproc, int vqid)
+{
+   struct imx_rproc *priv = rproc->priv;
+   int err;
+   __u32 mmsg;
+
+   if (!priv->tx_ch) {
+   dev_err(priv->dev, "No initialized mbox tx channel\n");
+   return;
+   }
+
+   /*
+* Send the index of the triggered virtqueue as the mu payload.
+* Let remote processor know which virtqueue is used.
+*/
+   mmsg = vqid << 16;
+
+   err = mbox_send_message(priv->tx_ch, (void *));
+   if (err < 0)
+   dev_err(priv->dev, "%s: failed (%d, err:%d)\n",
+   __func__, vqid, err);
+}
+
 static const struct rproc_ops imx_rproc_ops = {
.start  = imx_rproc_start,
.stop   = imx_rproc_stop,
+   .kick   = imx_rproc_kick,
.da_to_va   = imx_rproc_da_to_va,
.load   = rproc_elf_load_segments,
.parse_fw   = imx_rproc_parse_fw,
@@ -444,6 +477,66 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
return 0;
 }
 
+static void imx_rproc_vq_work(struct work_struct *work)
+{
+   struct imx_rproc *priv = container_of(work, struct imx_rproc,
+ rproc_work);
+
+   rproc_vq_interrupt(priv->rproc, 0);
+   rproc_vq_interrupt(priv->rproc, 1);
+}
+
+static void imx_rproc_rx_callback(struct mbox_client *cl, void *msg)
+{
+   struct rproc *rproc = dev_get_drvdata(cl->dev);
+   struct imx_rproc *priv = rproc->priv;
+
+   queue_work(priv->workqueue, >rproc_work);
+}
+
+static int imx_rproc_xtr_mbox_init(struct rproc *rproc)
+{
+   struct imx_rproc *priv = rproc->priv;
+   struct device *dev = priv->dev;
+   struct mbox_client *cl;
+   int ret;
+
+   if (!of_get_property(dev->of_node, "mbox-names", NULL))
+   return 0;
+
+   cl = >cl;
+   cl->dev = dev;
+   cl->tx_block = true;
+   cl->tx_tout = 100;
+   cl->knows_txdone = false;
+   cl->rx_callback = imx_rproc_rx_callback;
+
+   priv->tx_ch = mbox_request_channel_byname(cl, "tx");
+   if (IS_ERR(priv->tx_ch)) {
+   ret = PTR_ERR(priv->tx_ch);
+   return dev_err_probe(cl->dev, ret,
+"failed to request tx mailbox channel: 
%d\n", ret);
+   }
+
+   priv->rx_ch = mbox_request_channel_byname(cl, "rx");
+   if (IS_ERR(priv->rx_ch)) {
+   mbox_free_channel(priv->tx_ch);
+   ret = PTR_ERR(priv->rx_ch);
+   return dev_err_probe(cl->dev, ret,
+"failed to request rx mailbox channel: 
%d\n", ret);
+   }
+
+   return 0;
+}
+
+static void imx_rproc_free_mbox(struct rproc *rproc)
+{
+   struct imx_rproc *priv = rproc->priv;
+
+   mbox_free_channel(priv->tx_ch);
+   mbox_free_channel(priv->rx_ch);
+}
+
 static int imx_rproc_probe(struct platform_device *pdev)
 {
struct device *dev = >dev;
@@ -481,18 +574,28 @@ static int imx_rproc_probe(struct platform_device *pdev)
priv->dev = dev;
 
dev_set_drvdata(dev, rproc);
+   priv->workqueue = create_workqueue(dev_name(dev));
+   if (!priv->workqueue) {
+   dev_err(dev, "cannot create workqueue\n");
+  

[PATCH V10 09/10] remoteproc: imx_rproc: ignore mapping vdev regions

2021-02-15 Thread peng . fan
From: Peng Fan 

vdev regions are vdev0vring0, vdev0vring1, vdevbuffer and similar.
They are handled by remoteproc common code, no need to map in imx
rproc driver.

Signed-off-by: Peng Fan 
Reviewed-by: Mathieu Poirier 
---
 drivers/remoteproc/imx_rproc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 0124ebf69838..3685bbd135b0 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -417,6 +417,9 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
struct resource res;
 
node = of_parse_phandle(np, "memory-region", a);
+   /* Not map vdev region */
+   if (!strcmp(node->name, "vdev"))
+   continue;
err = of_address_to_resource(node, 0, );
if (err) {
dev_err(dev, "unable to resolve memory region\n");
-- 
2.30.0



[PATCH V10 07/10] remoteproc: imx_rproc: add i.MX specific parse fw hook

2021-02-15 Thread peng . fan
From: Peng Fan 

The hook is used to parse memory-regions and load resource table
from the address the remote processor published.

Reviewed-by: Richard Zhu 
Reviewed-by: Mathieu Poirier 
Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 93 ++
 1 file changed, 93 insertions(+)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 47fc1d06be6a..5ae1f5209548 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -241,10 +242,102 @@ static void *imx_rproc_da_to_va(struct rproc *rproc, u64 
da, size_t len, bool *i
return va;
 }
 
+static int imx_rproc_mem_alloc(struct rproc *rproc,
+  struct rproc_mem_entry *mem)
+{
+   struct device *dev = rproc->dev.parent;
+   void *va;
+
+   dev_dbg(dev, "map memory: %p+%zx\n", >dma, mem->len);
+   va = ioremap_wc(mem->dma, mem->len);
+   if (IS_ERR_OR_NULL(va)) {
+   dev_err(dev, "Unable to map memory region: %p+%zx\n",
+   >dma, mem->len);
+   return -ENOMEM;
+   }
+
+   /* Update memory entry va */
+   mem->va = va;
+
+   return 0;
+}
+
+static int imx_rproc_mem_release(struct rproc *rproc,
+struct rproc_mem_entry *mem)
+{
+   dev_dbg(rproc->dev.parent, "unmap memory: %pa\n", >dma);
+   iounmap(mem->va);
+
+   return 0;
+}
+
+static int imx_rproc_parse_memory_regions(struct rproc *rproc)
+{
+   struct imx_rproc *priv = rproc->priv;
+   struct device_node *np = priv->dev->of_node;
+   struct of_phandle_iterator it;
+   struct rproc_mem_entry *mem;
+   struct reserved_mem *rmem;
+   u32 da;
+
+   /* Register associated reserved memory regions */
+   of_phandle_iterator_init(, np, "memory-region", NULL, 0);
+   while (of_phandle_iterator_next() == 0) {
+   /*
+* Ignore the first memory region which will be used vdev 
buffer.
+* No need to do extra handlings, rproc_add_virtio_dev will 
handle it.
+*/
+   if (!strcmp(it.node->name, "vdev0buffer"))
+   continue;
+
+   rmem = of_reserved_mem_lookup(it.node);
+   if (!rmem) {
+   dev_err(priv->dev, "unable to acquire memory-region\n");
+   return -EINVAL;
+   }
+
+   /* No need to translate pa to da, i.MX use same map */
+   da = rmem->base;
+
+   /* Register memory region */
+   mem = rproc_mem_entry_init(priv->dev, NULL, 
(dma_addr_t)rmem->base, rmem->size, da,
+  imx_rproc_mem_alloc, 
imx_rproc_mem_release,
+  it.node->name);
+
+   if (mem)
+   rproc_coredump_add_segment(rproc, da, rmem->size);
+   else
+   return -ENOMEM;
+
+   rproc_add_carveout(rproc, mem);
+   }
+
+   return  0;
+}
+
+static int imx_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
+{
+   int ret = imx_rproc_parse_memory_regions(rproc);
+
+   if (ret)
+   return ret;
+
+   ret = rproc_elf_load_rsc_table(rproc, fw);
+   if (ret)
+   dev_info(>dev, "No resource table in elf\n");
+
+   return 0;
+}
+
 static const struct rproc_ops imx_rproc_ops = {
.start  = imx_rproc_start,
.stop   = imx_rproc_stop,
.da_to_va   = imx_rproc_da_to_va,
+   .load   = rproc_elf_load_segments,
+   .parse_fw   = imx_rproc_parse_fw,
+   .find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table,
+   .sanity_check   = rproc_elf_sanity_check,
+   .get_boot_addr  = rproc_elf_get_boot_addr,
 };
 
 static int imx_rproc_addr_init(struct imx_rproc *priv,
-- 
2.30.0



[PATCH V10 05/10] remoteproc: imx_rproc: correct err message

2021-02-15 Thread peng . fan
From: Peng Fan 

It is using devm_ioremap, so not devm_ioremap_resource. Correct
the error message and print out sa/size.

Reviewed-by: Bjorn Andersson 
Reviewed-by: Mathieu Poirier 
Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 6603e00bb6f4..2a093cea4997 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -268,7 +268,7 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
priv->mem[b].cpu_addr = devm_ioremap(>dev,
 att->sa, att->size);
if (!priv->mem[b].cpu_addr) {
-   dev_err(dev, "devm_ioremap_resource failed\n");
+   dev_err(dev, "failed to remap %#x bytes from %#x\n", 
att->size, att->sa);
return -ENOMEM;
}
priv->mem[b].sys_addr = att->sa;
@@ -298,7 +298,7 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
 
priv->mem[b].cpu_addr = devm_ioremap_resource(>dev, );
if (IS_ERR(priv->mem[b].cpu_addr)) {
-   dev_err(dev, "devm_ioremap_resource failed\n");
+   dev_err(dev, "failed to remap %pr\n", );
err = PTR_ERR(priv->mem[b].cpu_addr);
return err;
}
-- 
2.30.0



[PATCH V10 06/10] remoteproc: imx_rproc: use devm_ioremap

2021-02-15 Thread peng . fan
From: Peng Fan 

We might need to map an region multiple times, becaue the region might
be shared between remote processors, such i.MX8QM with dual M4 cores.
So use devm_ioremap, not devm_ioremap_resource.

Reviewed-by: Oleksij Rempel 
Reviewed-by: Richard Zhu 
Signed-off-by: Peng Fan 
Reviewed-by: Mathieu Poirier 
---
 drivers/remoteproc/imx_rproc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 2a093cea4997..47fc1d06be6a 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -296,7 +296,8 @@ static int imx_rproc_addr_init(struct imx_rproc *priv,
if (b >= IMX7D_RPROC_MEM_MAX)
break;
 
-   priv->mem[b].cpu_addr = devm_ioremap_resource(>dev, );
+   /* Not use resource version, because we might share region */
+   priv->mem[b].cpu_addr = devm_ioremap(>dev, res.start, 
resource_size());
if (IS_ERR(priv->mem[b].cpu_addr)) {
dev_err(dev, "failed to remap %pr\n", );
err = PTR_ERR(priv->mem[b].cpu_addr);
-- 
2.30.0



[PATCH V10 01/10] dt-bindings: remoteproc: convert imx rproc bindings to json-schema

2021-02-15 Thread peng . fan
From: Peng Fan 

Convert the imx rproc binding to DT schema format using json-schema.

Signed-off-by: Peng Fan 
---
 .../bindings/remoteproc/fsl,imx-rproc.yaml| 60 +++
 .../bindings/remoteproc/imx-rproc.txt | 33 --
 2 files changed, 60 insertions(+), 33 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
 delete mode 100644 Documentation/devicetree/bindings/remoteproc/imx-rproc.txt

diff --git a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml 
b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
new file mode 100644
index ..8427d0f6e471
--- /dev/null
+++ b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
@@ -0,0 +1,60 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/remoteproc/fsl,imx-rproc.yaml#;
+$schema: "http://devicetree.org/meta-schemas/core.yaml#;
+
+title: NXP iMX6SX/iMX7D Co-Processor Bindings
+
+description:
+  This binding provides support for ARM Cortex M4 Co-processor found on some 
NXP iMX SoCs.
+
+maintainers:
+  - Peng Fan 
+
+properties:
+  compatible:
+enum:
+  - fsl,imx7d-cm4
+  - fsl,imx6sx-cm4
+
+  clocks:
+maxItems: 1
+
+  syscon:
+$ref: /schemas/types.yaml#/definitions/phandle
+description:
+  Phandle to syscon block which provide access to System Reset Controller
+
+  memory-region:
+description:
+  If present, a phandle for a reserved memory area that used for vdev 
buffer,
+  resource table, vring region and others used by remote processor.
+minItems: 1
+
+required:
+  - compatible
+  - clocks
+  - syscon
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+m4_reserved_sysmem1: cm4@8000 {
+  reg = <0x8000 0x8>;
+};
+
+m4_reserved_sysmem2: cm4@8100 {
+  reg = <0x8100 0x8>;
+};
+
+imx7d-cm4 {
+  compatible   = "fsl,imx7d-cm4";
+  memory-region= <_reserved_sysmem1>, <_reserved_sysmem2>;
+  syscon   = <>;
+  clocks   = < IMX7D_ARM_M4_ROOT_CLK>;
+};
+
+...
diff --git a/Documentation/devicetree/bindings/remoteproc/imx-rproc.txt 
b/Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
deleted file mode 100644
index fbcefd965dc4..
--- a/Documentation/devicetree/bindings/remoteproc/imx-rproc.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-NXP iMX6SX/iMX7D Co-Processor Bindings
-
-
-This binding provides support for ARM Cortex M4 Co-processor found on some
-NXP iMX SoCs.
-
-Required properties:
-- compatible   Should be one of:
-   "fsl,imx7d-cm4"
-   "fsl,imx6sx-cm4"
-- clocks   Clock for co-processor (See: 
../clock/clock-bindings.txt)
-- syscon   Phandle to syscon block which provide access to
-   System Reset Controller
-
-Optional properties:
-- memory-regionlist of phandels to the reserved memory regions.
-   (See: ../reserved-memory/reserved-memory.txt)
-
-Example:
-   m4_reserved_sysmem1: cm4@8000 {
-   reg = <0x8000 0x8>;
-   };
-
-   m4_reserved_sysmem2: cm4@8100 {
-   reg = <0x8100 0x8>;
-   };
-
-   imx7d-cm4 {
-   compatible  = "fsl,imx7d-cm4";
-   memory-region   = <_reserved_sysmem1>, 
<_reserved_sysmem2>;
-   syscon  = <>;
-   clocks  = < IMX7D_ARM_M4_ROOT_CLK>;
-   };
-- 
2.30.0



[PATCH V10 04/10] remoteproc: add is_iomem to da_to_va

2021-02-15 Thread peng . fan
From: Peng Fan 

Introduce an extra parameter is_iomem to da_to_va, then the caller
could take the memory as normal memory or io mapped memory.

Reviewed-by: Bjorn Andersson 
Reviewed-by: Mathieu Poirier 
Reported-by: kernel test robot 
Signed-off-by: Peng Fan 
---
 drivers/remoteproc/imx_rproc.c |  2 +-
 drivers/remoteproc/ingenic_rproc.c |  2 +-
 drivers/remoteproc/keystone_remoteproc.c   |  2 +-
 drivers/remoteproc/mtk_scp.c   |  6 +++---
 drivers/remoteproc/omap_remoteproc.c   |  2 +-
 drivers/remoteproc/pru_rproc.c |  2 +-
 drivers/remoteproc/qcom_q6v5_adsp.c|  2 +-
 drivers/remoteproc/qcom_q6v5_pas.c |  2 +-
 drivers/remoteproc/qcom_q6v5_wcss.c|  2 +-
 drivers/remoteproc/qcom_wcnss.c|  2 +-
 drivers/remoteproc/remoteproc_core.c   |  7 +--
 drivers/remoteproc/remoteproc_coredump.c   |  8 ++--
 drivers/remoteproc/remoteproc_debugfs.c|  2 +-
 drivers/remoteproc/remoteproc_elf_loader.c | 21 +++--
 drivers/remoteproc/remoteproc_internal.h   |  2 +-
 drivers/remoteproc/st_slim_rproc.c |  2 +-
 drivers/remoteproc/ti_k3_dsp_remoteproc.c  |  2 +-
 drivers/remoteproc/ti_k3_r5_remoteproc.c   |  2 +-
 drivers/remoteproc/wkup_m3_rproc.c |  2 +-
 include/linux/remoteproc.h |  2 +-
 20 files changed, 45 insertions(+), 29 deletions(-)

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 8957ed271d20..6603e00bb6f4 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -208,7 +208,7 @@ static int imx_rproc_da_to_sys(struct imx_rproc *priv, u64 
da,
return -ENOENT;
 }
 
-static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len)
+static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool 
*is_iomem)
 {
struct imx_rproc *priv = rproc->priv;
void *va = NULL;
diff --git a/drivers/remoteproc/ingenic_rproc.c 
b/drivers/remoteproc/ingenic_rproc.c
index e2618c36eaab..a356738160a4 100644
--- a/drivers/remoteproc/ingenic_rproc.c
+++ b/drivers/remoteproc/ingenic_rproc.c
@@ -121,7 +121,7 @@ static void ingenic_rproc_kick(struct rproc *rproc, int 
vqid)
writel(vqid, vpu->aux_base + REG_CORE_MSG);
 }
 
-static void *ingenic_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len)
+static void *ingenic_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, 
bool *is_iomem)
 {
struct vpu *vpu = rproc->priv;
void __iomem *va = NULL;
diff --git a/drivers/remoteproc/keystone_remoteproc.c 
b/drivers/remoteproc/keystone_remoteproc.c
index cd266163a65f..54781f553f4e 100644
--- a/drivers/remoteproc/keystone_remoteproc.c
+++ b/drivers/remoteproc/keystone_remoteproc.c
@@ -246,7 +246,7 @@ static void keystone_rproc_kick(struct rproc *rproc, int 
vqid)
  * can be used either by the remoteproc core for loading (when using kernel
  * remoteproc loader), or by any rpmsg bus drivers.
  */
-static void *keystone_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len)
+static void *keystone_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, 
bool *is_iomem)
 {
struct keystone_rproc *ksproc = rproc->priv;
void __iomem *va = NULL;
diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c
index ce727598c41c..9679cc26895e 100644
--- a/drivers/remoteproc/mtk_scp.c
+++ b/drivers/remoteproc/mtk_scp.c
@@ -272,7 +272,7 @@ static int scp_elf_load_segments(struct rproc *rproc, const 
struct firmware *fw)
}
 
/* grab the kernel address for this device address */
-   ptr = (void __iomem *)rproc_da_to_va(rproc, da, memsz);
+   ptr = (void __iomem *)rproc_da_to_va(rproc, da, memsz, NULL);
if (!ptr) {
dev_err(dev, "bad phdr da 0x%x mem 0x%x\n", da, memsz);
ret = -EINVAL;
@@ -509,7 +509,7 @@ static void *mt8192_scp_da_to_va(struct mtk_scp *scp, u64 
da, size_t len)
return NULL;
 }
 
-static void *scp_da_to_va(struct rproc *rproc, u64 da, size_t len)
+static void *scp_da_to_va(struct rproc *rproc, u64 da, size_t len, bool 
*is_iomem)
 {
struct mtk_scp *scp = (struct mtk_scp *)rproc->priv;
 
@@ -627,7 +627,7 @@ void *scp_mapping_dm_addr(struct mtk_scp *scp, u32 mem_addr)
 {
void *ptr;
 
-   ptr = scp_da_to_va(scp->rproc, mem_addr, 0);
+   ptr = scp_da_to_va(scp->rproc, mem_addr, 0, NULL);
if (!ptr)
return ERR_PTR(-EINVAL);
 
diff --git a/drivers/remoteproc/omap_remoteproc.c 
b/drivers/remoteproc/omap_remoteproc.c
index d94b7391bf9d..43531caa1959 100644
--- a/drivers/remoteproc/omap_remoteproc.c
+++ b/drivers/remoteproc/omap_remoteproc.c
@@ -728,7 +728,7 @@ static int omap_rproc_stop(struct rproc *rproc)
  * Return: translated virtual address in kernel memory space on success,
  * or NULL on failure.
  */
-static void *omap_rproc_da_to

[PATCH V10 03/10] remoteproc: introduce is_iomem to rproc_mem_entry

2021-02-15 Thread peng . fan
From: Peng Fan 

Introduce is_iomem to indicate this piece memory is iomem or not.

Reviewed-by: Bjorn Andersson 
Signed-off-by: Peng Fan 
Reviewed-by: Mathieu Poirier 
---
 include/linux/remoteproc.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index f28ee75d1005..a5f6d2d9cde2 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -315,6 +315,7 @@ struct rproc;
 /**
  * struct rproc_mem_entry - memory entry descriptor
  * @va:virtual address
+ * @is_iomem: io memory
  * @dma: dma address
  * @len: length, in bytes
  * @da: device address
@@ -329,6 +330,7 @@ struct rproc;
  */
 struct rproc_mem_entry {
void *va;
+   bool is_iomem;
dma_addr_t dma;
size_t len;
u32 da;
-- 
2.30.0



[PATCH V10 02/10] dt-bindings: remoteproc: imx_rproc: add i.MX8MQ/M support

2021-02-15 Thread peng . fan
From: Peng Fan 

Add i.MX8MQ/M support, also include mailbox for rpmsg/virtio usage.

Signed-off-by: Peng Fan 
---
 .../bindings/remoteproc/fsl,imx-rproc.yaml| 51 ++-
 1 file changed, 50 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml 
b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
index 8427d0f6e471..f87e98d98413 100644
--- a/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
+++ b/Documentation/devicetree/bindings/remoteproc/fsl,imx-rproc.yaml
@@ -4,7 +4,7 @@
 $id: "http://devicetree.org/schemas/remoteproc/fsl,imx-rproc.yaml#;
 $schema: "http://devicetree.org/meta-schemas/core.yaml#;
 
-title: NXP iMX6SX/iMX7D Co-Processor Bindings
+title: NXP i.MX Co-Processor Bindings
 
 description:
   This binding provides support for ARM Cortex M4 Co-processor found on some 
NXP iMX SoCs.
@@ -15,6 +15,8 @@ maintainers:
 properties:
   compatible:
 enum:
+  - fsl,imx8mq-cm4
+  - fsl,imx8mm-cm4
   - fsl,imx7d-cm4
   - fsl,imx6sx-cm4
 
@@ -26,6 +28,20 @@ properties:
 description:
   Phandle to syscon block which provide access to System Reset Controller
 
+  mbox-names:
+items:
+  - const: tx
+  - const: rx
+  - const: rxdb
+
+  mboxes:
+description:
+  This property is required only if the rpmsg/virtio functionality is used.
+  List of < type channel> - 1 channel for TX, 1 channel for RX, 1 
channel for RXDB.
+  (see mailbox/fsl,mu.yaml)
+minItems: 1
+maxItems: 3
+
   memory-region:
 description:
   If present, a phandle for a reserved memory area that used for vdev 
buffer,
@@ -57,4 +73,37 @@ examples:
   clocks   = < IMX7D_ARM_M4_ROOT_CLK>;
 };
 
+  - |
+#include 
+rsc_table: rsc_table@550ff000 {
+  no-map;
+  reg = <0x550ff000 0x1000>;
+};
+
+vdev0vring0: vdev0vring0@5500 {
+  no-map;
+  reg = <0x5500 0x8000>;
+};
+
+vdev0vring1: vdev0vring1@55008000 {
+  reg = <0x55008000 0x8000>;
+  no-map;
+};
+
+vdev0buffer: vdev0buffer@5540 {
+  compatible = "shared-dma-pool";
+  reg = <0x5540 0x10>;
+  no-map;
+};
+
+imx8mm-cm4 {
+  compatible = "fsl,imx8mm-cm4";
+  clocks = < IMX8MM_CLK_M4_DIV>;
+  mbox-names = "tx", "rx", "rxdb";
+  mboxes = < 0 1
+ 1 1
+ 3 1>;
+  memory-region = <>, <>, <>, 
<_table>;
+  syscon = <>;
+};
 ...
-- 
2.30.0



  1   2   3   4   5   6   7   8   9   10   >