Skip to content

Commit 23e16e2

Browse files
3V3RYONEmathieupoirier
authored andcommitted
remoteproc: k3: Refactor rproc_release() implementation into common driver
The rproc_release() implementations in TI K3 DSP and M4 remoteproc drivers deassert reset in the same way. Refactor the above function into the ti_k3_common.c driver as k3_rproc_release() and use it throughout DSP and M4 drivers for releasing the reset from the remote processor. 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 3b8127f commit 23e16e2

File tree

4 files changed

+28
-50
lines changed

4 files changed

+28
-50
lines changed

drivers/remoteproc/ti_k3_common.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,30 @@ int k3_rproc_reset(struct k3_rproc *kproc)
130130
}
131131
EXPORT_SYMBOL_GPL(k3_rproc_reset);
132132

133+
/* Release the remote processor from reset */
134+
int k3_rproc_release(struct k3_rproc *kproc)
135+
{
136+
struct device *dev = kproc->dev;
137+
int ret;
138+
139+
if (kproc->data->uses_lreset) {
140+
ret = reset_control_deassert(kproc->reset);
141+
if (ret) {
142+
dev_err(dev, "local-reset deassert failed, (%pe)\n", ERR_PTR(ret));
143+
if (kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci,
144+
kproc->ti_sci_id))
145+
dev_warn(dev, "module-reset assert back failed\n");
146+
}
147+
} else {
148+
ret = kproc->ti_sci->ops.dev_ops.get_device(kproc->ti_sci,
149+
kproc->ti_sci_id);
150+
if (ret)
151+
dev_err(dev, "module-reset deassert failed (%pe)\n", ERR_PTR(ret));
152+
}
153+
154+
return ret;
155+
}
156+
EXPORT_SYMBOL_GPL(k3_rproc_release);
157+
133158
MODULE_LICENSE("GPL");
134159
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
@@ -96,4 +96,5 @@ struct k3_rproc {
9696
void k3_rproc_mbox_callback(struct mbox_client *client, void *data);
9797
void k3_rproc_kick(struct rproc *rproc, int vqid);
9898
int k3_rproc_reset(struct k3_rproc *kproc);
99+
int k3_rproc_release(struct k3_rproc *kproc);
99100
#endif /* REMOTEPROC_TI_K3_COMMON_H */

drivers/remoteproc/ti_k3_dsp_remoteproc.c

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

2525
#define KEYSTONE_RPROC_LOCAL_ADDRESS_MASK (SZ_16M - 1)
2626

27-
/* Release the DSP processor from reset */
28-
static int k3_dsp_rproc_release(struct k3_rproc *kproc)
29-
{
30-
struct device *dev = kproc->dev;
31-
int ret;
32-
33-
if (kproc->data->uses_lreset) {
34-
ret = reset_control_deassert(kproc->reset);
35-
if (ret) {
36-
dev_err(dev, "local-reset deassert failed, (%pe)\n", ERR_PTR(ret));
37-
if (kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci,
38-
kproc->ti_sci_id))
39-
dev_warn(dev, "module-reset assert back failed\n");
40-
}
41-
} else {
42-
ret = kproc->ti_sci->ops.dev_ops.get_device(kproc->ti_sci,
43-
kproc->ti_sci_id);
44-
if (ret)
45-
dev_err(dev, "module-reset deassert failed (%pe)\n", ERR_PTR(ret));
46-
}
47-
48-
return ret;
49-
}
50-
5127
static int k3_dsp_rproc_request_mbox(struct rproc *rproc)
5228
{
5329
struct k3_rproc *kproc = rproc->priv;
@@ -156,7 +132,7 @@ static int k3_dsp_rproc_start(struct rproc *rproc)
156132
if (ret)
157133
return ret;
158134

159-
ret = k3_dsp_rproc_release(kproc);
135+
ret = k3_rproc_release(kproc);
160136
if (ret)
161137
return ret;
162138

drivers/remoteproc/ti_k3_m4_remoteproc.c

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

24-
/* Release the M4 remote processor from reset */
25-
static int k3_m4_rproc_release(struct k3_rproc *kproc)
26-
{
27-
struct device *dev = kproc->dev;
28-
int ret;
29-
30-
if (kproc->data->uses_lreset) {
31-
ret = reset_control_deassert(kproc->reset);
32-
if (ret) {
33-
dev_err(dev, "local-reset deassert failed, ret = %d\n", ret);
34-
if (kproc->ti_sci->ops.dev_ops.put_device(kproc->ti_sci,
35-
kproc->ti_sci_id))
36-
dev_warn(dev, "module-reset assert back failed\n");
37-
}
38-
} else {
39-
ret = kproc->ti_sci->ops.dev_ops.get_device(kproc->ti_sci,
40-
kproc->ti_sci_id);
41-
if (ret)
42-
dev_err(dev, "module-reset deassert failed, ret = %d\n", ret);
43-
}
44-
45-
return ret;
46-
}
47-
4824
static int k3_m4_rproc_ping_mbox(struct k3_rproc *kproc)
4925
{
5026
struct device *dev = kproc->dev;
@@ -377,7 +353,7 @@ static int k3_m4_rproc_start(struct rproc *rproc)
377353
if (ret)
378354
return ret;
379355

380-
ret = k3_m4_rproc_release(kproc);
356+
ret = k3_rproc_release(kproc);
381357

382358
return ret;
383359
}

0 commit comments

Comments
 (0)