1111#include <linux/io.h>
1212#include <linux/module.h>
1313#include <linux/platform_device.h>
14- #include <linux/pm_runtime.h>
1514#include <linux/remoteproc.h>
1615
1716#include "remoteproc_internal.h"
@@ -62,6 +61,28 @@ struct vpu {
6261 struct device * dev ;
6362};
6463
64+ static int ingenic_rproc_prepare (struct rproc * rproc )
65+ {
66+ struct vpu * vpu = rproc -> priv ;
67+ int ret ;
68+
69+ /* The clocks must be enabled for the firmware to be loaded in TCSM */
70+ ret = clk_bulk_prepare_enable (ARRAY_SIZE (vpu -> clks ), vpu -> clks );
71+ if (ret )
72+ dev_err (vpu -> dev , "Unable to start clocks: %d\n" , ret );
73+
74+ return ret ;
75+ }
76+
77+ static int ingenic_rproc_unprepare (struct rproc * rproc )
78+ {
79+ struct vpu * vpu = rproc -> priv ;
80+
81+ clk_bulk_disable_unprepare (ARRAY_SIZE (vpu -> clks ), vpu -> clks );
82+
83+ return 0 ;
84+ }
85+
6586static int ingenic_rproc_start (struct rproc * rproc )
6687{
6788 struct vpu * vpu = rproc -> priv ;
@@ -115,6 +136,8 @@ static void *ingenic_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len)
115136}
116137
117138static struct rproc_ops ingenic_rproc_ops = {
139+ .prepare = ingenic_rproc_prepare ,
140+ .unprepare = ingenic_rproc_unprepare ,
118141 .start = ingenic_rproc_start ,
119142 .stop = ingenic_rproc_stop ,
120143 .kick = ingenic_rproc_kick ,
@@ -135,16 +158,6 @@ static irqreturn_t vpu_interrupt(int irq, void *data)
135158 return rproc_vq_interrupt (rproc , vring );
136159}
137160
138- static void ingenic_rproc_disable_clks (void * data )
139- {
140- struct vpu * vpu = data ;
141-
142- pm_runtime_resume (vpu -> dev );
143- pm_runtime_disable (vpu -> dev );
144-
145- clk_bulk_disable_unprepare (ARRAY_SIZE (vpu -> clks ), vpu -> clks );
146- }
147-
148161static int ingenic_rproc_probe (struct platform_device * pdev )
149162{
150163 struct device * dev = & pdev -> dev ;
@@ -206,35 +219,13 @@ static int ingenic_rproc_probe(struct platform_device *pdev)
206219
207220 disable_irq (vpu -> irq );
208221
209- /* The clocks must be enabled for the firmware to be loaded in TCSM */
210- ret = clk_bulk_prepare_enable (ARRAY_SIZE (vpu -> clks ), vpu -> clks );
211- if (ret ) {
212- dev_err (dev , "Unable to start clocks\n" );
213- return ret ;
214- }
215-
216- pm_runtime_irq_safe (dev );
217- pm_runtime_set_active (dev );
218- pm_runtime_enable (dev );
219- pm_runtime_get_sync (dev );
220- pm_runtime_use_autosuspend (dev );
221-
222- ret = devm_add_action_or_reset (dev , ingenic_rproc_disable_clks , vpu );
223- if (ret ) {
224- dev_err (dev , "Unable to register action\n" );
225- goto out_pm_put ;
226- }
227-
228222 ret = devm_rproc_add (dev , rproc );
229223 if (ret ) {
230224 dev_err (dev , "Failed to register remote processor\n" );
231- goto out_pm_put ;
225+ return ret ;
232226 }
233227
234- out_pm_put :
235- pm_runtime_put_autosuspend (dev );
236-
237- return ret ;
228+ return 0 ;
238229}
239230
240231static const struct of_device_id ingenic_rproc_of_matches [] = {
@@ -243,33 +234,10 @@ static const struct of_device_id ingenic_rproc_of_matches[] = {
243234};
244235MODULE_DEVICE_TABLE (of , ingenic_rproc_of_matches );
245236
246- static int __maybe_unused ingenic_rproc_suspend (struct device * dev )
247- {
248- struct vpu * vpu = dev_get_drvdata (dev );
249-
250- clk_bulk_disable (ARRAY_SIZE (vpu -> clks ), vpu -> clks );
251-
252- return 0 ;
253- }
254-
255- static int __maybe_unused ingenic_rproc_resume (struct device * dev )
256- {
257- struct vpu * vpu = dev_get_drvdata (dev );
258-
259- return clk_bulk_enable (ARRAY_SIZE (vpu -> clks ), vpu -> clks );
260- }
261-
262- static const struct dev_pm_ops __maybe_unused ingenic_rproc_pm = {
263- SET_RUNTIME_PM_OPS (ingenic_rproc_suspend , ingenic_rproc_resume , NULL )
264- };
265-
266237static struct platform_driver ingenic_rproc_driver = {
267238 .probe = ingenic_rproc_probe ,
268239 .driver = {
269240 .name = "ingenic-vpu" ,
270- #ifdef CONFIG_PM
271- .pm = & ingenic_rproc_pm ,
272- #endif
273241 .of_match_table = ingenic_rproc_of_matches ,
274242 },
275243};
0 commit comments