]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - rpmsg/rpmsg.git/commitdiff
remoteproc: add prepare and unprepare ops
authorLoic Pallardy <loic.pallardy@st.com>
Thu, 1 Mar 2018 16:23:55 +0000 (17:23 +0100)
committerSuman Anna <s-anna@ti.com>
Wed, 27 Feb 2019 20:35:17 +0000 (14:35 -0600)
On some SoC architecture, it is needed to enable HW like
clock, bus, regulator, memory region... before loading
co-processor firmware.

This patch introduces prepare and unprepare ops to execute
platform specific function before firmware loading and after
stop execution.

Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
[s-anna@ti.com: cherry-pick linux-remoteproc patchwork id '10251897']
Signed-off-by: Suman Anna <s-anna@ti.com>
drivers/remoteproc/remoteproc_core.c
include/linux/remoteproc.h

index 89580b957d66239ecdbde266ea4996c670965a50..c9be95b4e1ba84f1e94cbf4d0b13a6c1cedfafc5 100644 (file)
@@ -1119,12 +1119,22 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
                return ret;
        }
 
+       /* Prepare rproc for firmware loading if needed */
+       if (rproc->ops->prepare) {
+               ret = rproc->ops->prepare(rproc);
+               if (ret) {
+                       dev_err(dev, "can't prepare rproc %s: %d\n",
+                               rproc->name, ret);
+                       goto disable_iommu;
+               }
+       }
+
        rproc->bootaddr = rproc_get_boot_addr(rproc, fw);
 
        /* Load resource table, core dump segment list etc from the firmware */
        ret = rproc_parse_fw(rproc, fw);
        if (ret)
-               goto disable_iommu;
+               goto unprepare_rproc;
 
        /* reset max_notifyid */
        rproc->max_notifyid = -1;
@@ -1147,6 +1157,10 @@ clean_up_resources:
        kfree(rproc->cached_table);
        rproc->cached_table = NULL;
        rproc->table_ptr = NULL;
+unprepare_rproc:
+       /* release HW resources if needed */
+       if (rproc->ops->unprepare)
+               rproc->ops->unprepare(rproc);
 disable_iommu:
        rproc_disable_iommu(rproc);
        return ret;
@@ -1538,6 +1552,10 @@ void rproc_shutdown(struct rproc *rproc)
        /* clean up all acquired resources */
        rproc_resource_cleanup(rproc);
 
+       /* release HW resources if needed */
+       if (rproc->ops->unprepare)
+               rproc->ops->unprepare(rproc);
+
        rproc_disable_iommu(rproc);
 
        /* Free the copy of the resource table */
index e0baae1659c2ac3a20753b7db9e652bad99f29bb..5efeb757f182ae8916649804f825efd083c80ecd 100644 (file)
@@ -368,6 +368,8 @@ struct firmware;
 
 /**
  * struct rproc_ops - platform-specific device handlers
+ * @prepare:   prepare device for code loading
+ * @unprepare: unprepare device after stop
  * @start:     power on the device and boot it
  * @stop:      power off the device
  * @kick:      kick a virtqueue (virtqueue id given as a parameter)
@@ -381,6 +383,8 @@ struct firmware;
  * @get_boot_addr:     get boot address to entry point specified in firmware
  */
 struct rproc_ops {
+       int (*prepare)(struct rproc *rproc);
+       int (*unprepare)(struct rproc *rproc);
        int (*start)(struct rproc *rproc);
        int (*stop)(struct rproc *rproc);
        void (*kick)(struct rproc *rproc, int vqid);