Re: [PATCH v2 5/7] remoteproc: qcom: q6v5: Add support for q6 rmb registers

Bjorn Andersson
2023-03-16T02:14:20Z

On Mon, Mar 06, 2023 at 03:12:00PM -0800, Melody Olvera wrote:
> When attaching a running Q6, the remoteproc driver needs a way
> to communicate with the Q6 using rmb registers, so allow the
> rmb register to be gotten from the device tree if present.
>
> Signed-off-by: Melody Olvera <quic_molvera@quicinc.com>
> ---
> drivers/remoteproc/qcom_q6v5.c | 9 +++++++++
> drivers/remoteproc/qcom_q6v5.h | 8 ++++++++
> 2 files changed, 17 insertions(+)
>
> diff --git a/drivers/remoteproc/qcom_q6v5.c b/drivers/remoteproc/qcom_q6v5.c
> index 192c7aa0e39e..e8c6be70ebfd 100644
> --- a/drivers/remoteproc/qcom_q6v5.c
> +++ b/drivers/remoteproc/qcom_q6v5.c
> @@ -254,6 +254,7 @@ int qcom_q6v5_init(struct qcom_q6v5 *q6v5, struct platform_device *pdev,
> void (*handover)(struct qcom_q6v5 *q6v5))
> {
> int ret;
> + struct resource *res;
>
> q6v5->rproc = rproc;
> q6v5->dev = &pdev->dev;
> @@ -263,6 +264,14 @@ int qcom_q6v5_init(struct qcom_q6v5 *q6v5, struct platform_device *pdev,
> init_completion(&q6v5->start_done);
> init_completion(&q6v5->stop_done);
>
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 1);

In addition to the PAS driver, __func__ is being invoked by the non-PAS
ADSP and MPSS drivers as well, which both uses reg[1] for other
purposes. So this won't work.

Perhaps I'm missing some possibility of reuse, but it seems reasonable
for this to move to the pas-driver.

Thanks,
Bjorn

> + if (res) {
> + q6v5->rmb_base = devm_ioremap_resource(&pdev->dev, res);
> + if (IS_ERR(q6v5->rmb_base))
> + q6v5->rmb_base = NULL;
> + } else
> + q6v5->rmb_base = NULL;
> +
> q6v5->wdog_irq = platform_get_irq_byname(pdev, "wdog");
> if (q6v5->wdog_irq < 0)
> return q6v5->wdog_irq;
> diff --git a/drivers/remoteproc/qcom_q6v5.h b/drivers/remoteproc/qcom_q6v5.h
> index 5a859c41896e..95824d5b64ce 100644
> --- a/drivers/remoteproc/qcom_q6v5.h
> +++ b/drivers/remoteproc/qcom_q6v5.h
> @@ -7,6 +7,12 @@
> #include <linux/completion.h>
> #include <linux/soc/qcom/qcom_aoss.h>
>
> +#define RMB_BOOT_WAIT_REG 0x8
> +#define RMB_BOOT_CONT_REG 0xC
> +#define RMB_Q6_BOOT_STATUS_REG 0x10
> +
> +#define RMB_POLL_MAX_TIMES 250
> +
> struct icc_path;
> struct rproc;
> struct qcom_smem_state;
> @@ -16,6 +22,8 @@ struct qcom_q6v5 {
> struct device *dev;
> struct rproc *rproc;
>
> + void __iomem *rmb_base;
> +
> struct qcom_smem_state *state;
> struct qmp *qmp;
>
> --
> 2.25.1
>