@@ -813,22 +813,22 @@ static int hantro_probe(struct platform_device *pdev)
}
}
+ ret = clk_bulk_prepare(vpu->variant->num_clocks, vpu->clocks);
+ if (ret) {
+ dev_err(&pdev->dev, "Failed to prepare clocks\n");
+ return ret;
+ }
+
ret = vpu->variant->init(vpu);
if (ret) {
dev_err(&pdev->dev, "Failed to init VPU hardware\n");
- return ret;
+ goto err_clk_unprepare;
}
pm_runtime_set_autosuspend_delay(vpu->dev, 100);
pm_runtime_use_autosuspend(vpu->dev);
pm_runtime_enable(vpu->dev);
- ret = clk_bulk_prepare(vpu->variant->num_clocks, vpu->clocks);
- if (ret) {
- dev_err(&pdev->dev, "Failed to prepare clocks\n");
- return ret;
- }
-
ret = v4l2_device_register(&pdev->dev, &vpu->v4l2_dev);
if (ret) {
dev_err(&pdev->dev, "Failed to register v4l2 device\n");
The fundamental idea is: clocks are prepared in the driver probe() then each use-case will enable/disable them as needed. Some variants like imx8mq need to have the clocks enabled during the HW init phase, so they will benefit from having the clocks prepared before the variant init callback to avoid duing a full prepare_enable/ unprepare_disable, so move the clk prepare a bit earlier. Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com> --- drivers/staging/media/hantro/hantro_drv.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)