]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
remoteproc: k3: Refactor .unprepare rproc ops into common driver
authorBeleswar Padhi <b-padhi@ti.com>
Tue, 13 May 2025 05:45:00 +0000 (11:15 +0530)
committerMathieu Poirier <mathieu.poirier@linaro.org>
Tue, 20 May 2025 17:19:11 +0000 (11:19 -0600)
The .unprepare rproc ops implementations in TI K3 DSP and M4 remoteproc
drivers assert the module reset on the remote processor. Refactor the
implementations into ti_k3_common.c driver as k3_rproc_unprepare() and
register this common function as .unprepare ops in DSP and M4 drivers.

Signed-off-by: Beleswar Padhi <b-padhi@ti.com>
Tested-by: Judith Mendez <jm@ti.com>
Reviewed-by: Andrew Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20250513054510.3439842-27-b-padhi@ti.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
drivers/remoteproc/ti_k3_common.c
drivers/remoteproc/ti_k3_common.h
drivers/remoteproc/ti_k3_dsp_remoteproc.c
drivers/remoteproc/ti_k3_m4_remoteproc.c

index 66839c694b693b7a0b313a1a49e4ccb3ccc81d8b..235f6fca675a3f5039d0fbaf5607c360d7bb319b 100644 (file)
@@ -237,5 +237,35 @@ int k3_rproc_prepare(struct rproc *rproc)
 }
 EXPORT_SYMBOL_GPL(k3_rproc_prepare);
 
+/*
+ * This function implements the .unprepare() ops and performs the complimentary
+ * operations to that of the .prepare() ops. The function is used to assert the
+ * global reset on applicable K3 DSP and M4 cores. This completes the second
+ * portion of powering down the remote core. The cores themselves are only
+ * halted in the .stop() callback through the local reset, and the .unprepare()
+ * ops is invoked by the remoteproc core after the remoteproc is stopped to
+ * balance the global reset.
+ */
+int k3_rproc_unprepare(struct rproc *rproc)
+{
+       struct k3_rproc *kproc = rproc->priv;
+       struct device *dev = kproc->dev;
+       int ret;
+
+       /* If the core is going to be detached do not assert the module reset */
+       if (rproc->state == RPROC_DETACHED)
+               return 0;
+
+       ret = kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci,
+                                                   kproc->ti_sci_id);
+       if (ret) {
+               dev_err(dev, "module-reset assert failed\n");
+               return ret;
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(k3_rproc_unprepare);
+
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("TI K3 common Remoteproc code");
index f1fce91190128e380006c63465a0b2abebf56a0b..e0909fe0578e823054daeb0e6e77fcb7de4238d8 100644 (file)
@@ -99,4 +99,5 @@ int k3_rproc_reset(struct k3_rproc *kproc);
 int k3_rproc_release(struct k3_rproc *kproc);
 int k3_rproc_request_mbox(struct rproc *rproc);
 int k3_rproc_prepare(struct rproc *rproc);
+int k3_rproc_unprepare(struct rproc *rproc);
 #endif /* REMOTEPROC_TI_K3_COMMON_H */
index 0f81e7c3e798e1c128499d163ef5f0b2279acf3c..5099d21ce066fb0285238c2437b1b8d971c3fe97 100644 (file)
 
 #define KEYSTONE_RPROC_LOCAL_ADDRESS_MASK      (SZ_16M - 1)
 
-/*
- * This function implements the .unprepare() ops and performs the complimentary
- * operations to that of the .prepare() ops. The function is used to assert the
- * global reset on applicable C66x cores. This completes the second portion of
- * powering down the C66x DSP cores. The cores themselves are only halted in the
- * .stop() callback through the local reset, and the .unprepare() ops is invoked
- * by the remoteproc core after the remoteproc is stopped to balance the global
- * reset. This callback is invoked only in remoteproc mode.
- */
-static int k3_dsp_rproc_unprepare(struct rproc *rproc)
-{
-       struct k3_rproc *kproc = rproc->priv;
-       struct device *dev = kproc->dev;
-       int ret;
-
-       /* If the core is running already no need to deassert the module reset */
-       if (rproc->state == RPROC_DETACHED)
-               return 0;
-
-       ret = kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci,
-                                                   kproc->ti_sci_id);
-       if (ret)
-               dev_err(dev, "module-reset assert failed (%pe)\n", ERR_PTR(ret));
-
-       return ret;
-}
-
 /*
  * Power up the DSP remote processor.
  *
@@ -384,7 +357,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)
        rproc->recovery_disabled = true;
        if (data->uses_lreset) {
                rproc->ops->prepare = k3_rproc_prepare;
-               rproc->ops->unprepare = k3_dsp_rproc_unprepare;
+               rproc->ops->unprepare = k3_rproc_unprepare;
        }
        kproc = rproc->priv;
        kproc->rproc = rproc;
index 7faa979f5caa9c072eb5ea8e789fc77bf49a36a0..6e7d78ff78941acfaf8370370119429a7ba62350 100644 (file)
 #include "ti_sci_proc.h"
 #include "ti_k3_common.h"
 
-/*
- * This function implements the .unprepare() ops and performs the complimentary
- * operations to that of the .prepare() ops. The function is used to assert the
- * global reset on applicable cores. This completes the second portion of
- * powering down the remote core. The cores themselves are only halted in the
- * .stop() callback through the local reset, and the .unprepare() ops is invoked
- * by the remoteproc core after the remoteproc is stopped to balance the global
- * reset.
- */
-static int k3_m4_rproc_unprepare(struct rproc *rproc)
-{
-       struct k3_rproc *kproc = rproc->priv;
-       struct device *dev = kproc->dev;
-       int ret;
-
-       /* If the core is going to be detached do not assert the module reset */
-       if (rproc->state == RPROC_DETACHED)
-               return 0;
-
-       ret = kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci,
-                                                   kproc->ti_sci_id);
-       if (ret) {
-               dev_err(dev, "module-reset assert failed\n");
-               return ret;
-       }
-
-       return 0;
-}
-
 /*
  * This function implements the .get_loaded_rsc_table() callback and is used
  * to provide the resource table for a booted remote processor in IPC-only
@@ -326,7 +297,7 @@ static int k3_m4_rproc_detach(struct rproc *rproc)
 
 static const struct rproc_ops k3_m4_rproc_ops = {
        .prepare = k3_rproc_prepare,
-       .unprepare = k3_m4_rproc_unprepare,
+       .unprepare = k3_rproc_unprepare,
        .start = k3_m4_rproc_start,
        .stop = k3_m4_rproc_stop,
        .attach = k3_m4_rproc_attach,