Merge tag 'rproc-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc...
[linux-block.git] / drivers / remoteproc / qcom_q6v5_mss.c
index a2c231a17b2ba4a9c9ba04eb6fbca7da9216bf65..af217de75e4d9179ed73ab3319e7642b33262f84 100644 (file)
@@ -218,6 +218,7 @@ struct q6v5 {
        struct qcom_rproc_subdev smd_subdev;
        struct qcom_rproc_ssr ssr_subdev;
        struct qcom_sysmon *sysmon;
+       struct platform_device *bam_dmux;
        bool need_mem_protection;
        bool has_alt_reset;
        bool has_mba_logs;
@@ -1807,18 +1808,20 @@ static int q6v5_alloc_memory_region(struct q6v5 *qproc)
         * reserved memory regions from device's memory-region property.
         */
        child = of_get_child_by_name(qproc->dev->of_node, "mba");
-       if (!child)
+       if (!child) {
                node = of_parse_phandle(qproc->dev->of_node,
                                        "memory-region", 0);
-       else
+       } else {
                node = of_parse_phandle(child, "memory-region", 0);
+               of_node_put(child);
+       }
 
        ret = of_address_to_resource(node, 0, &r);
+       of_node_put(node);
        if (ret) {
                dev_err(qproc->dev, "unable to resolve mba region\n");
                return ret;
        }
-       of_node_put(node);
 
        qproc->mba_phys = r.start;
        qproc->mba_size = resource_size(&r);
@@ -1829,14 +1832,15 @@ static int q6v5_alloc_memory_region(struct q6v5 *qproc)
        } else {
                child = of_get_child_by_name(qproc->dev->of_node, "mpss");
                node = of_parse_phandle(child, "memory-region", 0);
+               of_node_put(child);
        }
 
        ret = of_address_to_resource(node, 0, &r);
+       of_node_put(node);
        if (ret) {
                dev_err(qproc->dev, "unable to resolve mpss region\n");
                return ret;
        }
-       of_node_put(node);
 
        qproc->mpss_phys = qproc->mpss_reloc = r.start;
        qproc->mpss_size = resource_size(&r);
@@ -1847,6 +1851,7 @@ static int q6v5_alloc_memory_region(struct q6v5 *qproc)
 static int q6v5_probe(struct platform_device *pdev)
 {
        const struct rproc_hexagon_res *desc;
+       struct device_node *node;
        struct q6v5 *qproc;
        struct rproc *rproc;
        const char *mba_image;
@@ -1990,6 +1995,10 @@ static int q6v5_probe(struct platform_device *pdev)
        if (ret)
                goto remove_sysmon_subdev;
 
+       node = of_get_compatible_child(pdev->dev.of_node, "qcom,bam-dmux");
+       qproc->bam_dmux = of_platform_device_create(node, NULL, &pdev->dev);
+       of_node_put(node);
+
        return 0;
 
 remove_sysmon_subdev:
@@ -2011,6 +2020,8 @@ static int q6v5_remove(struct platform_device *pdev)
        struct q6v5 *qproc = platform_get_drvdata(pdev);
        struct rproc *rproc = qproc->rproc;
 
+       if (qproc->bam_dmux)
+               of_platform_device_destroy(&qproc->bam_dmux->dev, NULL);
        rproc_del(rproc);
 
        qcom_q6v5_deinit(&qproc->q6v5);