From: "Peng Fan (OSS)" <peng.fan@oss.nxp.com> To: ohad@wizery.com, bjorn.andersson@linaro.org, mathieu.poirier@linaro.org, o.rempel@pengutronix.de Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-remoteproc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Peng Fan <peng.fan@nxp.com> Subject: [PATCH 2/2] remoteproc: imx_rproc: support remote cores booted before Linux Kernel Date: Fri, 19 Mar 2021 18:47:08 +0800 [thread overview] Message-ID: <20210319104708.7754-2-peng.fan@oss.nxp.com> (raw) In-Reply-To: <20210319104708.7754-1-peng.fan@oss.nxp.com> From: Peng Fan <peng.fan@nxp.com> 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 <peng.fan@nxp.com> --- 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(&res); + 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, &val); + 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 = &pdev->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
WARNING: multiple messages have this Message-ID (diff)
From: "Peng Fan (OSS)" <peng.fan@oss.nxp.com> To: ohad@wizery.com, bjorn.andersson@linaro.org, mathieu.poirier@linaro.org, o.rempel@pengutronix.de Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, linux-remoteproc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Peng Fan <peng.fan@nxp.com> Subject: [PATCH 2/2] remoteproc: imx_rproc: support remote cores booted before Linux Kernel Date: Fri, 19 Mar 2021 18:47:08 +0800 [thread overview] Message-ID: <20210319104708.7754-2-peng.fan@oss.nxp.com> (raw) In-Reply-To: <20210319104708.7754-1-peng.fan@oss.nxp.com> From: Peng Fan <peng.fan@nxp.com> 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 <peng.fan@nxp.com> --- 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(&res); + 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, &val); + 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 = &pdev->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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-03-19 10:17 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-03-19 10:47 [PATCH 1/2] remoteproc: imx_rproc: enlarge IMX7D_RPROC_MEM_MAX Peng Fan (OSS) 2021-03-19 10:47 ` Peng Fan (OSS) 2021-03-19 10:47 ` Peng Fan (OSS) [this message] 2021-03-19 10:47 ` [PATCH 2/2] remoteproc: imx_rproc: support remote cores booted before Linux Kernel Peng Fan (OSS) 2021-03-25 23:58 ` Mathieu Poirier 2021-03-25 23:58 ` Mathieu Poirier 2021-03-25 23:00 ` [PATCH 1/2] remoteproc: imx_rproc: enlarge IMX7D_RPROC_MEM_MAX Mathieu Poirier 2021-03-25 23:00 ` Mathieu Poirier 2021-03-25 23:23 ` Mathieu Poirier 2021-03-25 23:23 ` Mathieu Poirier
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210319104708.7754-2-peng.fan@oss.nxp.com \ --to=peng.fan@oss.nxp.com \ --cc=bjorn.andersson@linaro.org \ --cc=festevam@gmail.com \ --cc=kernel@pengutronix.de \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-imx@nxp.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-remoteproc@vger.kernel.org \ --cc=mathieu.poirier@linaro.org \ --cc=o.rempel@pengutronix.de \ --cc=ohad@wizery.com \ --cc=peng.fan@nxp.com \ --cc=s.hauer@pengutronix.de \ --cc=shawnguo@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.