Skip to content

Commit 3059abb

Browse files
3V3RYONEmathieupoirier
authored andcommitted
remoteproc: k3: Refactor .unprepare rproc ops into common driver
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 <[email protected]> Tested-by: Judith Mendez <[email protected]> Reviewed-by: Andrew Davis <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mathieu Poirier <[email protected]>
1 parent de27700 commit 3059abb

File tree

4 files changed

+33
-58
lines changed

4 files changed

+33
-58
lines changed

drivers/remoteproc/ti_k3_common.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,5 +237,35 @@ int k3_rproc_prepare(struct rproc *rproc)
237237
}
238238
EXPORT_SYMBOL_GPL(k3_rproc_prepare);
239239

240+
/*
241+
* This function implements the .unprepare() ops and performs the complimentary
242+
* operations to that of the .prepare() ops. The function is used to assert the
243+
* global reset on applicable K3 DSP and M4 cores. This completes the second
244+
* portion of powering down the remote core. The cores themselves are only
245+
* halted in the .stop() callback through the local reset, and the .unprepare()
246+
* ops is invoked by the remoteproc core after the remoteproc is stopped to
247+
* balance the global reset.
248+
*/
249+
int k3_rproc_unprepare(struct rproc *rproc)
250+
{
251+
struct k3_rproc *kproc = rproc->priv;
252+
struct device *dev = kproc->dev;
253+
int ret;
254+
255+
/* If the core is going to be detached do not assert the module reset */
256+
if (rproc->state == RPROC_DETACHED)
257+
return 0;
258+
259+
ret = kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci,
260+
kproc->ti_sci_id);
261+
if (ret) {
262+
dev_err(dev, "module-reset assert failed\n");
263+
return ret;
264+
}
265+
266+
return 0;
267+
}
268+
EXPORT_SYMBOL_GPL(k3_rproc_unprepare);
269+
240270
MODULE_LICENSE("GPL");
241271
MODULE_DESCRIPTION("TI K3 common Remoteproc code");

drivers/remoteproc/ti_k3_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,5 @@ int k3_rproc_reset(struct k3_rproc *kproc);
9999
int k3_rproc_release(struct k3_rproc *kproc);
100100
int k3_rproc_request_mbox(struct rproc *rproc);
101101
int k3_rproc_prepare(struct rproc *rproc);
102+
int k3_rproc_unprepare(struct rproc *rproc);
102103
#endif /* REMOTEPROC_TI_K3_COMMON_H */

drivers/remoteproc/ti_k3_dsp_remoteproc.c

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,6 @@
2424

2525
#define KEYSTONE_RPROC_LOCAL_ADDRESS_MASK (SZ_16M - 1)
2626

27-
/*
28-
* This function implements the .unprepare() ops and performs the complimentary
29-
* operations to that of the .prepare() ops. The function is used to assert the
30-
* global reset on applicable C66x cores. This completes the second portion of
31-
* powering down the C66x DSP cores. The cores themselves are only halted in the
32-
* .stop() callback through the local reset, and the .unprepare() ops is invoked
33-
* by the remoteproc core after the remoteproc is stopped to balance the global
34-
* reset. This callback is invoked only in remoteproc mode.
35-
*/
36-
static int k3_dsp_rproc_unprepare(struct rproc *rproc)
37-
{
38-
struct k3_rproc *kproc = rproc->priv;
39-
struct device *dev = kproc->dev;
40-
int ret;
41-
42-
/* If the core is running already no need to deassert the module reset */
43-
if (rproc->state == RPROC_DETACHED)
44-
return 0;
45-
46-
ret = kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci,
47-
kproc->ti_sci_id);
48-
if (ret)
49-
dev_err(dev, "module-reset assert failed (%pe)\n", ERR_PTR(ret));
50-
51-
return ret;
52-
}
53-
5427
/*
5528
* Power up the DSP remote processor.
5629
*
@@ -384,7 +357,7 @@ static int k3_dsp_rproc_probe(struct platform_device *pdev)
384357
rproc->recovery_disabled = true;
385358
if (data->uses_lreset) {
386359
rproc->ops->prepare = k3_rproc_prepare;
387-
rproc->ops->unprepare = k3_dsp_rproc_unprepare;
360+
rproc->ops->unprepare = k3_rproc_unprepare;
388361
}
389362
kproc = rproc->priv;
390363
kproc->rproc = rproc;

drivers/remoteproc/ti_k3_m4_remoteproc.c

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,6 @@
2121
#include "ti_sci_proc.h"
2222
#include "ti_k3_common.h"
2323

24-
/*
25-
* This function implements the .unprepare() ops and performs the complimentary
26-
* operations to that of the .prepare() ops. The function is used to assert the
27-
* global reset on applicable cores. This completes the second portion of
28-
* powering down the remote core. The cores themselves are only halted in the
29-
* .stop() callback through the local reset, and the .unprepare() ops is invoked
30-
* by the remoteproc core after the remoteproc is stopped to balance the global
31-
* reset.
32-
*/
33-
static int k3_m4_rproc_unprepare(struct rproc *rproc)
34-
{
35-
struct k3_rproc *kproc = rproc->priv;
36-
struct device *dev = kproc->dev;
37-
int ret;
38-
39-
/* If the core is going to be detached do not assert the module reset */
40-
if (rproc->state == RPROC_DETACHED)
41-
return 0;
42-
43-
ret = kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci,
44-
kproc->ti_sci_id);
45-
if (ret) {
46-
dev_err(dev, "module-reset assert failed\n");
47-
return ret;
48-
}
49-
50-
return 0;
51-
}
52-
5324
/*
5425
* This function implements the .get_loaded_rsc_table() callback and is used
5526
* 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)
326297

327298
static const struct rproc_ops k3_m4_rproc_ops = {
328299
.prepare = k3_rproc_prepare,
329-
.unprepare = k3_m4_rproc_unprepare,
300+
.unprepare = k3_rproc_unprepare,
330301
.start = k3_m4_rproc_start,
331302
.stop = k3_m4_rproc_stop,
332303
.attach = k3_m4_rproc_attach,

0 commit comments

Comments
 (0)