return 0;
}
+static int vsp1_clocks_enable(struct vsp1_device *vsp1)
+{
+ int ret;
+
+ ret = clk_prepare_enable(vsp1->clock);
+ if (ret < 0)
+ return ret;
+
+ if (IS_ERR(vsp1->rt_clock))
+ return 0;
+
+ ret = clk_prepare_enable(vsp1->rt_clock);
+ if (ret < 0) {
+ clk_disable_unprepare(vsp1->clock);
+ return ret;
+ }
+
+ return 0;
+}
+
+static void vsp1_clocks_disable(struct vsp1_device *vsp1)
+{
+ if (!IS_ERR(vsp1->rt_clock))
+ clk_disable_unprepare(vsp1->rt_clock);
+ clk_disable_unprepare(vsp1->clock);
+}
+
/*
* vsp1_device_get - Acquire the VSP1 device
*
if (vsp1->ref_count > 0)
goto done;
- ret = clk_prepare_enable(vsp1->clock);
+ ret = vsp1_clocks_enable(vsp1);
if (ret < 0) {
__vsp1 = NULL;
goto done;
ret = vsp1_device_init(vsp1);
if (ret < 0) {
- clk_disable_unprepare(vsp1->clock);
+ vsp1_clocks_disable(vsp1);
__vsp1 = NULL;
goto done;
}
mutex_lock(&vsp1->lock);
if (--vsp1->ref_count == 0)
- clk_disable_unprepare(vsp1->clock);
+ vsp1_clocks_disable(vsp1);
mutex_unlock(&vsp1->lock);
}
if (vsp1->ref_count == 0)
return 0;
- clk_disable_unprepare(vsp1->clock);
+ vsp1_clocks_disable(vsp1);
return 0;
}
if (vsp1->ref_count)
return 0;
- return clk_prepare_enable(vsp1->clock);
+ return vsp1_clocks_enable(vsp1);
}
#endif
return PTR_ERR(vsp1->clock);
}
+ /* The RT clock is optional */
+ vsp1->rt_clock = devm_clk_get(&pdev->dev, "rt");
+
irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!irq) {
dev_err(&pdev->dev, "missing IRQ\n");