[PATCH v11 18/35] remoteproc: k3-m4: Introduce central function to release rproc from reset

Beleswar Padhi
2025-04-25T10:42:57Z

Currently, the TI K3 M4 remoteproc driver assumes all of the M4 devices
have local resets. Even though its true for all existing M4 devices,
keep room for future devices which possibly may not have local resets
and only have a module reset.

Therefore introduce a central function, k3_m4_rproc_release() which
handles both type of devices (with and without local resets), and use it
throughout the driver to release the remote processor from reset. Also,
for devices with local reset, Assert the module reset back in case the
local reset deassert operation failed.

This is done to align the reset release implementation with DSP
remoteproc driver and can be factored out later.

Signed-off-by: Beleswar Padhi <b-padhi@ti.com>
Tested-by: Judith Mendez <jm@ti.com>
---
v11: Changelog:
0. New patch in this series.
1. Split [v10 17/33] into [v11 18/35] and [v11 19/35].

Link to v10:
https://lore.kernel.org/all/20250417182001.3903905-18-b-padhi@ti.com/

drivers/remoteproc/ti_k3_m4_remoteproc.c | 33 +++++++++++++++++++-----
1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c
index 7d5b75be2e4f8..74f1b6c0a9562 100644
--- a/drivers/remoteproc/ti_k3_m4_remoteproc.c
+++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c
@@ -21,6 +21,30 @@
#include "ti_sci_proc.h"
#include "ti_k3_common.h"

+/* Release the M4 remote processor from reset */
+static int k3_m4_rproc_release(struct k3_rproc *kproc)
+{
+ struct device *dev = kproc->dev;
+ int ret;
+
+ if (kproc->data->uses_lreset) {
+ ret = reset_control_deassert(kproc->reset);
+ if (ret) {
+ dev_err(dev, "local-reset deassert failed, ret = %d\n", ret);
+ if (kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci,
+ kproc->ti_sci_id))
+ dev_warn(dev, "module-reset assert back failed\n");
+ }
+ } else {
+ ret = kproc->ti_sci->ops.dev_ops.get_device(kproc->ti_sci,
+ kproc->ti_sci_id);
+ if (ret)
+ dev_err(dev, "module-reset deassert failed, ret = %d\n", ret);
+ }
+
+ return ret;
+}
+
static int k3_m4_rproc_ping_mbox(struct k3_rproc *kproc)
{
struct device *dev = kproc->dev;
@@ -347,20 +371,15 @@ static void k3_m4_release_tsp(void *data)
static int k3_m4_rproc_start(struct rproc *rproc)
{
struct k3_rproc *kproc = rproc->priv;
- struct device *dev = kproc->dev;
int ret;

ret = k3_m4_rproc_ping_mbox(kproc);
if (ret)
return ret;

- ret = reset_control_deassert(kproc->reset);
- if (ret) {
- dev_err(dev, "local-reset deassert failed, ret = %d\n", ret);
- return ret;
- }
+ ret = k3_m4_rproc_release(kproc);

- return 0;
+ return ret;
}

/*
--
2.34.1