aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/platform/vsp1/vsp1.h1
-rw-r--r--drivers/media/platform/vsp1/vsp1_drv.c40
2 files changed, 36 insertions, 5 deletions
diff --git a/drivers/media/platform/vsp1/vsp1.h b/drivers/media/platform/vsp1/vsp1.h
index 11ac94bec3a3..d6c6ecd039ff 100644
--- a/drivers/media/platform/vsp1/vsp1.h
+++ b/drivers/media/platform/vsp1/vsp1.h
@@ -42,6 +42,7 @@ struct vsp1_device {
42 42
43 void __iomem *mmio; 43 void __iomem *mmio;
44 struct clk *clock; 44 struct clk *clock;
45 struct clk *rt_clock;
45 46
46 struct mutex lock; 47 struct mutex lock;
47 int ref_count; 48 int ref_count;
diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c
index aa8b9b288e61..1c9e771aa15c 100644
--- a/drivers/media/platform/vsp1/vsp1_drv.c
+++ b/drivers/media/platform/vsp1/vsp1_drv.c
@@ -290,6 +290,33 @@ static int vsp1_device_init(struct vsp1_device *vsp1)
290 return 0; 290 return 0;
291} 291}
292 292
293static int vsp1_clocks_enable(struct vsp1_device *vsp1)
294{
295 int ret;
296
297 ret = clk_prepare_enable(vsp1->clock);
298 if (ret < 0)
299 return ret;
300
301 if (IS_ERR(vsp1->rt_clock))
302 return 0;
303
304 ret = clk_prepare_enable(vsp1->rt_clock);
305 if (ret < 0) {
306 clk_disable_unprepare(vsp1->clock);
307 return ret;
308 }
309
310 return 0;
311}
312
313static void vsp1_clocks_disable(struct vsp1_device *vsp1)
314{
315 if (!IS_ERR(vsp1->rt_clock))
316 clk_disable_unprepare(vsp1->rt_clock);
317 clk_disable_unprepare(vsp1->clock);
318}
319
293/* 320/*
294 * vsp1_device_get - Acquire the VSP1 device 321 * vsp1_device_get - Acquire the VSP1 device
295 * 322 *
@@ -307,7 +334,7 @@ struct vsp1_device *vsp1_device_get(struct vsp1_device *vsp1)
307 if (vsp1->ref_count > 0) 334 if (vsp1->ref_count > 0)
308 goto done; 335 goto done;
309 336
310 ret = clk_prepare_enable(vsp1->clock); 337 ret = vsp1_clocks_enable(vsp1);
311 if (ret < 0) { 338 if (ret < 0) {
312 __vsp1 = NULL; 339 __vsp1 = NULL;
313 goto done; 340 goto done;
@@ -315,7 +342,7 @@ struct vsp1_device *vsp1_device_get(struct vsp1_device *vsp1)
315 342
316 ret = vsp1_device_init(vsp1); 343 ret = vsp1_device_init(vsp1);
317 if (ret < 0) { 344 if (ret < 0) {
318 clk_disable_unprepare(vsp1->clock); 345 vsp1_clocks_disable(vsp1);
319 __vsp1 = NULL; 346 __vsp1 = NULL;
320 goto done; 347 goto done;
321 } 348 }
@@ -339,7 +366,7 @@ void vsp1_device_put(struct vsp1_device *vsp1)
339 mutex_lock(&vsp1->lock); 366 mutex_lock(&vsp1->lock);
340 367
341 if (--vsp1->ref_count == 0) 368 if (--vsp1->ref_count == 0)
342 clk_disable_unprepare(vsp1->clock); 369 vsp1_clocks_disable(vsp1);
343 370
344 mutex_unlock(&vsp1->lock); 371 mutex_unlock(&vsp1->lock);
345} 372}
@@ -358,7 +385,7 @@ static int vsp1_pm_suspend(struct device *dev)
358 if (vsp1->ref_count == 0) 385 if (vsp1->ref_count == 0)
359 return 0; 386 return 0;
360 387
361 clk_disable_unprepare(vsp1->clock); 388 vsp1_clocks_disable(vsp1);
362 return 0; 389 return 0;
363} 390}
364 391
@@ -371,7 +398,7 @@ static int vsp1_pm_resume(struct device *dev)
371 if (vsp1->ref_count) 398 if (vsp1->ref_count)
372 return 0; 399 return 0;
373 400
374 return clk_prepare_enable(vsp1->clock); 401 return vsp1_clocks_enable(vsp1);
375} 402}
376#endif 403#endif
377 404
@@ -445,6 +472,9 @@ static int vsp1_probe(struct platform_device *pdev)
445 return PTR_ERR(vsp1->clock); 472 return PTR_ERR(vsp1->clock);
446 } 473 }
447 474
475 /* The RT clock is optional */
476 vsp1->rt_clock = devm_clk_get(&pdev->dev, "rt");
477
448 irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 478 irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
449 if (!irq) { 479 if (!irq) {
450 dev_err(&pdev->dev, "missing IRQ\n"); 480 dev_err(&pdev->dev, "missing IRQ\n");