1 // SPDX-License-Identifier: GPL-2.0+
3 * vsp1_drv.c -- R-Car VSP1 Driver
5 * Copyright (C) 2013-2015 Renesas Electronics Corporation
7 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
10 #include <linux/clk.h>
11 #include <linux/delay.h>
12 #include <linux/device.h>
13 #include <linux/interrupt.h>
14 #include <linux/module.h>
16 #include <linux/of_device.h>
17 #include <linux/platform_device.h>
18 #include <linux/pm_runtime.h>
19 #include <linux/videodev2.h>
21 #include <media/rcar-fcp.h>
22 #include <media/v4l2-subdev.h>
31 #include "vsp1_hsit.h"
34 #include "vsp1_pipe.h"
35 #include "vsp1_rwpf.h"
39 #include "vsp1_video.h"
41 /* -----------------------------------------------------------------------------
45 static irqreturn_t
vsp1_irq_handler(int irq
, void *data
)
47 u32 mask
= VI6_WFP_IRQ_STA_DFE
| VI6_WFP_IRQ_STA_FRE
;
48 struct vsp1_device
*vsp1
= data
;
49 irqreturn_t ret
= IRQ_NONE
;
53 for (i
= 0; i
< vsp1
->info
->wpf_count
; ++i
) {
54 struct vsp1_rwpf
*wpf
= vsp1
->wpf
[i
];
59 status
= vsp1_read(vsp1
, VI6_WPF_IRQ_STA(i
));
60 vsp1_write(vsp1
, VI6_WPF_IRQ_STA(i
), ~status
& mask
);
62 if (status
& VI6_WFP_IRQ_STA_DFE
) {
63 vsp1_pipeline_frame_end(wpf
->entity
.pipe
);
71 /* -----------------------------------------------------------------------------
76 * vsp1_create_sink_links - Create links from all sources to the given sink
78 * This function creates media links from all valid sources to the given sink
79 * pad. Links that would be invalid according to the VSP1 hardware capabilities
80 * are skipped. Those include all links
82 * - from a UDS to a UDS (UDS entities can't be chained)
83 * - from an entity to itself (no loops are allowed)
85 * Furthermore, the BRS can't be connected to histogram generators, but no
86 * special check is currently needed as all VSP instances that include a BRS
87 * have no histogram generator.
89 static int vsp1_create_sink_links(struct vsp1_device
*vsp1
,
90 struct vsp1_entity
*sink
)
92 struct media_entity
*entity
= &sink
->subdev
.entity
;
93 struct vsp1_entity
*source
;
97 list_for_each_entry(source
, &vsp1
->entities
, list_dev
) {
100 if (source
->type
== sink
->type
)
103 if (source
->type
== VSP1_ENTITY_HGO
||
104 source
->type
== VSP1_ENTITY_HGT
||
105 source
->type
== VSP1_ENTITY_LIF
||
106 source
->type
== VSP1_ENTITY_WPF
)
109 flags
= source
->type
== VSP1_ENTITY_RPF
&&
110 sink
->type
== VSP1_ENTITY_WPF
&&
111 source
->index
== sink
->index
112 ? MEDIA_LNK_FL_ENABLED
: 0;
114 for (pad
= 0; pad
< entity
->num_pads
; ++pad
) {
115 if (!(entity
->pads
[pad
].flags
& MEDIA_PAD_FL_SINK
))
118 ret
= media_create_pad_link(&source
->subdev
.entity
,
124 if (flags
& MEDIA_LNK_FL_ENABLED
)
132 static int vsp1_uapi_create_links(struct vsp1_device
*vsp1
)
134 struct vsp1_entity
*entity
;
138 list_for_each_entry(entity
, &vsp1
->entities
, list_dev
) {
139 if (entity
->type
== VSP1_ENTITY_LIF
||
140 entity
->type
== VSP1_ENTITY_RPF
)
143 ret
= vsp1_create_sink_links(vsp1
, entity
);
149 ret
= media_create_pad_link(&vsp1
->hgo
->histo
.entity
.subdev
.entity
,
151 &vsp1
->hgo
->histo
.video
.entity
, 0,
152 MEDIA_LNK_FL_ENABLED
|
153 MEDIA_LNK_FL_IMMUTABLE
);
159 ret
= media_create_pad_link(&vsp1
->hgt
->histo
.entity
.subdev
.entity
,
161 &vsp1
->hgt
->histo
.video
.entity
, 0,
162 MEDIA_LNK_FL_ENABLED
|
163 MEDIA_LNK_FL_IMMUTABLE
);
168 for (i
= 0; i
< vsp1
->info
->lif_count
; ++i
) {
172 ret
= media_create_pad_link(&vsp1
->wpf
[i
]->entity
.subdev
.entity
,
174 &vsp1
->lif
[i
]->entity
.subdev
.entity
,
180 for (i
= 0; i
< vsp1
->info
->rpf_count
; ++i
) {
181 struct vsp1_rwpf
*rpf
= vsp1
->rpf
[i
];
183 ret
= media_create_pad_link(&rpf
->video
->video
.entity
, 0,
184 &rpf
->entity
.subdev
.entity
,
186 MEDIA_LNK_FL_ENABLED
|
187 MEDIA_LNK_FL_IMMUTABLE
);
192 for (i
= 0; i
< vsp1
->info
->wpf_count
; ++i
) {
194 * Connect the video device to the WPF. All connections are
197 struct vsp1_rwpf
*wpf
= vsp1
->wpf
[i
];
199 ret
= media_create_pad_link(&wpf
->entity
.subdev
.entity
,
201 &wpf
->video
->video
.entity
, 0,
202 MEDIA_LNK_FL_IMMUTABLE
|
203 MEDIA_LNK_FL_ENABLED
);
211 static void vsp1_destroy_entities(struct vsp1_device
*vsp1
)
213 struct vsp1_entity
*entity
, *_entity
;
214 struct vsp1_video
*video
, *_video
;
216 list_for_each_entry_safe(entity
, _entity
, &vsp1
->entities
, list_dev
) {
217 list_del(&entity
->list_dev
);
218 vsp1_entity_destroy(entity
);
221 list_for_each_entry_safe(video
, _video
, &vsp1
->videos
, list
) {
222 list_del(&video
->list
);
223 vsp1_video_cleanup(video
);
226 v4l2_device_unregister(&vsp1
->v4l2_dev
);
227 if (vsp1
->info
->uapi
)
228 media_device_unregister(&vsp1
->media_dev
);
229 media_device_cleanup(&vsp1
->media_dev
);
231 if (!vsp1
->info
->uapi
)
232 vsp1_drm_cleanup(vsp1
);
235 static int vsp1_create_entities(struct vsp1_device
*vsp1
)
237 struct media_device
*mdev
= &vsp1
->media_dev
;
238 struct v4l2_device
*vdev
= &vsp1
->v4l2_dev
;
239 struct vsp1_entity
*entity
;
243 mdev
->dev
= vsp1
->dev
;
244 mdev
->hw_revision
= vsp1
->version
;
245 strscpy(mdev
->model
, vsp1
->info
->model
, sizeof(mdev
->model
));
246 snprintf(mdev
->bus_info
, sizeof(mdev
->bus_info
), "platform:%s",
247 dev_name(mdev
->dev
));
248 media_device_init(mdev
);
250 vsp1
->media_ops
.link_setup
= vsp1_entity_link_setup
;
252 * Don't perform link validation when the userspace API is disabled as
253 * the pipeline is configured internally by the driver in that case, and
254 * its configuration can thus be trusted.
256 if (vsp1
->info
->uapi
)
257 vsp1
->media_ops
.link_validate
= v4l2_subdev_link_validate
;
260 ret
= v4l2_device_register(vsp1
->dev
, vdev
);
262 dev_err(vsp1
->dev
, "V4L2 device registration failed (%d)\n",
267 /* Instantiate all the entities. */
268 if (vsp1_feature(vsp1
, VSP1_HAS_BRS
)) {
269 vsp1
->brs
= vsp1_brx_create(vsp1
, VSP1_ENTITY_BRS
);
270 if (IS_ERR(vsp1
->brs
)) {
271 ret
= PTR_ERR(vsp1
->brs
);
275 list_add_tail(&vsp1
->brs
->entity
.list_dev
, &vsp1
->entities
);
278 if (vsp1_feature(vsp1
, VSP1_HAS_BRU
)) {
279 vsp1
->bru
= vsp1_brx_create(vsp1
, VSP1_ENTITY_BRU
);
280 if (IS_ERR(vsp1
->bru
)) {
281 ret
= PTR_ERR(vsp1
->bru
);
285 list_add_tail(&vsp1
->bru
->entity
.list_dev
, &vsp1
->entities
);
288 if (vsp1_feature(vsp1
, VSP1_HAS_CLU
)) {
289 vsp1
->clu
= vsp1_clu_create(vsp1
);
290 if (IS_ERR(vsp1
->clu
)) {
291 ret
= PTR_ERR(vsp1
->clu
);
295 list_add_tail(&vsp1
->clu
->entity
.list_dev
, &vsp1
->entities
);
298 vsp1
->hsi
= vsp1_hsit_create(vsp1
, true);
299 if (IS_ERR(vsp1
->hsi
)) {
300 ret
= PTR_ERR(vsp1
->hsi
);
304 list_add_tail(&vsp1
->hsi
->entity
.list_dev
, &vsp1
->entities
);
306 vsp1
->hst
= vsp1_hsit_create(vsp1
, false);
307 if (IS_ERR(vsp1
->hst
)) {
308 ret
= PTR_ERR(vsp1
->hst
);
312 list_add_tail(&vsp1
->hst
->entity
.list_dev
, &vsp1
->entities
);
314 if (vsp1_feature(vsp1
, VSP1_HAS_HGO
) && vsp1
->info
->uapi
) {
315 vsp1
->hgo
= vsp1_hgo_create(vsp1
);
316 if (IS_ERR(vsp1
->hgo
)) {
317 ret
= PTR_ERR(vsp1
->hgo
);
321 list_add_tail(&vsp1
->hgo
->histo
.entity
.list_dev
,
325 if (vsp1_feature(vsp1
, VSP1_HAS_HGT
) && vsp1
->info
->uapi
) {
326 vsp1
->hgt
= vsp1_hgt_create(vsp1
);
327 if (IS_ERR(vsp1
->hgt
)) {
328 ret
= PTR_ERR(vsp1
->hgt
);
332 list_add_tail(&vsp1
->hgt
->histo
.entity
.list_dev
,
337 * The LIFs are only supported when used in conjunction with the DU, in
338 * which case the userspace API is disabled. If the userspace API is
339 * enabled skip the LIFs, even when present.
341 if (!vsp1
->info
->uapi
) {
342 for (i
= 0; i
< vsp1
->info
->lif_count
; ++i
) {
343 struct vsp1_lif
*lif
;
345 lif
= vsp1_lif_create(vsp1
, i
);
352 list_add_tail(&lif
->entity
.list_dev
, &vsp1
->entities
);
356 if (vsp1_feature(vsp1
, VSP1_HAS_LUT
)) {
357 vsp1
->lut
= vsp1_lut_create(vsp1
);
358 if (IS_ERR(vsp1
->lut
)) {
359 ret
= PTR_ERR(vsp1
->lut
);
363 list_add_tail(&vsp1
->lut
->entity
.list_dev
, &vsp1
->entities
);
366 for (i
= 0; i
< vsp1
->info
->rpf_count
; ++i
) {
367 struct vsp1_rwpf
*rpf
;
369 rpf
= vsp1_rpf_create(vsp1
, i
);
376 list_add_tail(&rpf
->entity
.list_dev
, &vsp1
->entities
);
378 if (vsp1
->info
->uapi
) {
379 struct vsp1_video
*video
= vsp1_video_create(vsp1
, rpf
);
382 ret
= PTR_ERR(video
);
386 list_add_tail(&video
->list
, &vsp1
->videos
);
390 if (vsp1_feature(vsp1
, VSP1_HAS_SRU
)) {
391 vsp1
->sru
= vsp1_sru_create(vsp1
);
392 if (IS_ERR(vsp1
->sru
)) {
393 ret
= PTR_ERR(vsp1
->sru
);
397 list_add_tail(&vsp1
->sru
->entity
.list_dev
, &vsp1
->entities
);
400 for (i
= 0; i
< vsp1
->info
->uds_count
; ++i
) {
401 struct vsp1_uds
*uds
;
403 uds
= vsp1_uds_create(vsp1
, i
);
410 list_add_tail(&uds
->entity
.list_dev
, &vsp1
->entities
);
413 for (i
= 0; i
< vsp1
->info
->uif_count
; ++i
) {
414 struct vsp1_uif
*uif
;
416 uif
= vsp1_uif_create(vsp1
, i
);
423 list_add_tail(&uif
->entity
.list_dev
, &vsp1
->entities
);
426 for (i
= 0; i
< vsp1
->info
->wpf_count
; ++i
) {
427 struct vsp1_rwpf
*wpf
;
429 wpf
= vsp1_wpf_create(vsp1
, i
);
436 list_add_tail(&wpf
->entity
.list_dev
, &vsp1
->entities
);
438 if (vsp1
->info
->uapi
) {
439 struct vsp1_video
*video
= vsp1_video_create(vsp1
, wpf
);
442 ret
= PTR_ERR(video
);
446 list_add_tail(&video
->list
, &vsp1
->videos
);
450 /* Register all subdevs. */
451 list_for_each_entry(entity
, &vsp1
->entities
, list_dev
) {
452 ret
= v4l2_device_register_subdev(&vsp1
->v4l2_dev
,
459 * Create links and register subdev nodes if the userspace API is
460 * enabled or initialize the DRM pipeline otherwise.
462 if (vsp1
->info
->uapi
) {
463 ret
= vsp1_uapi_create_links(vsp1
);
467 ret
= v4l2_device_register_subdev_nodes(&vsp1
->v4l2_dev
);
471 ret
= media_device_register(mdev
);
473 ret
= vsp1_drm_init(vsp1
);
478 vsp1_destroy_entities(vsp1
);
483 int vsp1_reset_wpf(struct vsp1_device
*vsp1
, unsigned int index
)
485 unsigned int timeout
;
488 status
= vsp1_read(vsp1
, VI6_STATUS
);
489 if (!(status
& VI6_STATUS_SYS_ACT(index
)))
492 vsp1_write(vsp1
, VI6_SRESET
, VI6_SRESET_SRTS(index
));
493 for (timeout
= 10; timeout
> 0; --timeout
) {
494 status
= vsp1_read(vsp1
, VI6_STATUS
);
495 if (!(status
& VI6_STATUS_SYS_ACT(index
)))
498 usleep_range(1000, 2000);
502 dev_err(vsp1
->dev
, "failed to reset wpf.%u\n", index
);
509 static int vsp1_device_init(struct vsp1_device
*vsp1
)
514 /* Reset any channel that might be running. */
515 for (i
= 0; i
< vsp1
->info
->wpf_count
; ++i
) {
516 ret
= vsp1_reset_wpf(vsp1
, i
);
521 vsp1_write(vsp1
, VI6_CLK_DCSWT
, (8 << VI6_CLK_DCSWT_CSTPW_SHIFT
) |
522 (8 << VI6_CLK_DCSWT_CSTRW_SHIFT
));
524 for (i
= 0; i
< vsp1
->info
->rpf_count
; ++i
)
525 vsp1_write(vsp1
, VI6_DPR_RPF_ROUTE(i
), VI6_DPR_NODE_UNUSED
);
527 for (i
= 0; i
< vsp1
->info
->uds_count
; ++i
)
528 vsp1_write(vsp1
, VI6_DPR_UDS_ROUTE(i
), VI6_DPR_NODE_UNUSED
);
530 for (i
= 0; i
< vsp1
->info
->uif_count
; ++i
)
531 vsp1_write(vsp1
, VI6_DPR_UIF_ROUTE(i
), VI6_DPR_NODE_UNUSED
);
533 vsp1_write(vsp1
, VI6_DPR_SRU_ROUTE
, VI6_DPR_NODE_UNUSED
);
534 vsp1_write(vsp1
, VI6_DPR_LUT_ROUTE
, VI6_DPR_NODE_UNUSED
);
535 vsp1_write(vsp1
, VI6_DPR_CLU_ROUTE
, VI6_DPR_NODE_UNUSED
);
536 vsp1_write(vsp1
, VI6_DPR_HST_ROUTE
, VI6_DPR_NODE_UNUSED
);
537 vsp1_write(vsp1
, VI6_DPR_HSI_ROUTE
, VI6_DPR_NODE_UNUSED
);
538 vsp1_write(vsp1
, VI6_DPR_BRU_ROUTE
, VI6_DPR_NODE_UNUSED
);
540 if (vsp1_feature(vsp1
, VSP1_HAS_BRS
))
541 vsp1_write(vsp1
, VI6_DPR_ILV_BRS_ROUTE
, VI6_DPR_NODE_UNUSED
);
543 vsp1_write(vsp1
, VI6_DPR_HGO_SMPPT
, (7 << VI6_DPR_SMPPT_TGW_SHIFT
) |
544 (VI6_DPR_NODE_UNUSED
<< VI6_DPR_SMPPT_PT_SHIFT
));
545 vsp1_write(vsp1
, VI6_DPR_HGT_SMPPT
, (7 << VI6_DPR_SMPPT_TGW_SHIFT
) |
546 (VI6_DPR_NODE_UNUSED
<< VI6_DPR_SMPPT_PT_SHIFT
));
548 vsp1_dlm_setup(vsp1
);
554 * vsp1_device_get - Acquire the VSP1 device
556 * Make sure the device is not suspended and initialize it if needed.
558 * Return 0 on success or a negative error code otherwise.
560 int vsp1_device_get(struct vsp1_device
*vsp1
)
564 ret
= pm_runtime_get_sync(vsp1
->dev
);
566 pm_runtime_put_noidle(vsp1
->dev
);
574 * vsp1_device_put - Release the VSP1 device
576 * Decrement the VSP1 reference count and cleanup the device if the last
577 * reference is released.
579 void vsp1_device_put(struct vsp1_device
*vsp1
)
581 pm_runtime_put_sync(vsp1
->dev
);
584 /* -----------------------------------------------------------------------------
588 static int __maybe_unused
vsp1_pm_suspend(struct device
*dev
)
590 struct vsp1_device
*vsp1
= dev_get_drvdata(dev
);
593 * When used as part of a display pipeline, the VSP is stopped and
594 * restarted explicitly by the DU.
597 vsp1_video_suspend(vsp1
);
599 pm_runtime_force_suspend(vsp1
->dev
);
604 static int __maybe_unused
vsp1_pm_resume(struct device
*dev
)
606 struct vsp1_device
*vsp1
= dev_get_drvdata(dev
);
608 pm_runtime_force_resume(vsp1
->dev
);
611 * When used as part of a display pipeline, the VSP is stopped and
612 * restarted explicitly by the DU.
615 vsp1_video_resume(vsp1
);
620 static int __maybe_unused
vsp1_pm_runtime_suspend(struct device
*dev
)
622 struct vsp1_device
*vsp1
= dev_get_drvdata(dev
);
624 rcar_fcp_disable(vsp1
->fcp
);
629 static int __maybe_unused
vsp1_pm_runtime_resume(struct device
*dev
)
631 struct vsp1_device
*vsp1
= dev_get_drvdata(dev
);
635 ret
= vsp1_device_init(vsp1
);
640 return rcar_fcp_enable(vsp1
->fcp
);
643 static const struct dev_pm_ops vsp1_pm_ops
= {
644 SET_SYSTEM_SLEEP_PM_OPS(vsp1_pm_suspend
, vsp1_pm_resume
)
645 SET_RUNTIME_PM_OPS(vsp1_pm_runtime_suspend
, vsp1_pm_runtime_resume
, NULL
)
648 /* -----------------------------------------------------------------------------
652 static const struct vsp1_device_info vsp1_device_infos
[] = {
654 .version
= VI6_IP_VERSION_MODEL_VSPS_H2
,
657 .features
= VSP1_HAS_BRU
| VSP1_HAS_CLU
| VSP1_HAS_HGO
658 | VSP1_HAS_HGT
| VSP1_HAS_LUT
| VSP1_HAS_SRU
659 | VSP1_HAS_WPF_VFLIP
,
666 .version
= VI6_IP_VERSION_MODEL_VSPR_H2
,
669 .features
= VSP1_HAS_BRU
| VSP1_HAS_SRU
| VSP1_HAS_WPF_VFLIP
,
676 .version
= VI6_IP_VERSION_MODEL_VSPD_GEN2
,
679 .features
= VSP1_HAS_BRU
| VSP1_HAS_HGO
| VSP1_HAS_LUT
,
687 .version
= VI6_IP_VERSION_MODEL_VSPS_M2
,
690 .features
= VSP1_HAS_BRU
| VSP1_HAS_CLU
| VSP1_HAS_HGO
691 | VSP1_HAS_HGT
| VSP1_HAS_LUT
| VSP1_HAS_SRU
692 | VSP1_HAS_WPF_VFLIP
,
699 .version
= VI6_IP_VERSION_MODEL_VSPS_V2H
,
702 .features
= VSP1_HAS_BRU
| VSP1_HAS_CLU
| VSP1_HAS_LUT
703 | VSP1_HAS_SRU
| VSP1_HAS_WPF_VFLIP
,
710 .version
= VI6_IP_VERSION_MODEL_VSPD_V2H
,
713 .features
= VSP1_HAS_BRU
| VSP1_HAS_CLU
| VSP1_HAS_LUT
,
721 .version
= VI6_IP_VERSION_MODEL_VSPI_GEN3
,
724 .features
= VSP1_HAS_CLU
| VSP1_HAS_HGO
| VSP1_HAS_HGT
725 | VSP1_HAS_LUT
| VSP1_HAS_SRU
| VSP1_HAS_WPF_HFLIP
726 | VSP1_HAS_WPF_VFLIP
,
732 .version
= VI6_IP_VERSION_MODEL_VSPBD_GEN3
,
735 .features
= VSP1_HAS_BRU
| VSP1_HAS_WPF_VFLIP
,
741 .version
= VI6_IP_VERSION_MODEL_VSPBC_GEN3
,
744 .features
= VSP1_HAS_BRU
| VSP1_HAS_CLU
| VSP1_HAS_HGO
745 | VSP1_HAS_LUT
| VSP1_HAS_WPF_VFLIP
,
751 .version
= VI6_IP_VERSION_MODEL_VSPBS_GEN3
,
754 .features
= VSP1_HAS_BRS
| VSP1_HAS_WPF_VFLIP
,
759 .version
= VI6_IP_VERSION_MODEL_VSPD_GEN3
,
762 .features
= VSP1_HAS_BRU
| VSP1_HAS_WPF_VFLIP
| VSP1_HAS_EXT_DL
,
769 .version
= VI6_IP_VERSION_MODEL_VSPD_V3
,
772 .features
= VSP1_HAS_BRS
| VSP1_HAS_BRU
,
779 .version
= VI6_IP_VERSION_MODEL_VSPDL_GEN3
,
782 .features
= VSP1_HAS_BRS
| VSP1_HAS_BRU
| VSP1_HAS_EXT_DL
,
791 static int vsp1_probe(struct platform_device
*pdev
)
793 struct vsp1_device
*vsp1
;
794 struct device_node
*fcp_node
;
795 struct resource
*irq
;
800 vsp1
= devm_kzalloc(&pdev
->dev
, sizeof(*vsp1
), GFP_KERNEL
);
804 vsp1
->dev
= &pdev
->dev
;
805 INIT_LIST_HEAD(&vsp1
->entities
);
806 INIT_LIST_HEAD(&vsp1
->videos
);
808 platform_set_drvdata(pdev
, vsp1
);
810 /* I/O and IRQ resources (clock managed by the clock PM domain). */
811 io
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
812 vsp1
->mmio
= devm_ioremap_resource(&pdev
->dev
, io
);
813 if (IS_ERR(vsp1
->mmio
))
814 return PTR_ERR(vsp1
->mmio
);
816 irq
= platform_get_resource(pdev
, IORESOURCE_IRQ
, 0);
818 dev_err(&pdev
->dev
, "missing IRQ\n");
822 ret
= devm_request_irq(&pdev
->dev
, irq
->start
, vsp1_irq_handler
,
823 IRQF_SHARED
, dev_name(&pdev
->dev
), vsp1
);
825 dev_err(&pdev
->dev
, "failed to request IRQ\n");
829 /* FCP (optional). */
830 fcp_node
= of_parse_phandle(pdev
->dev
.of_node
, "renesas,fcp", 0);
832 vsp1
->fcp
= rcar_fcp_get(fcp_node
);
833 of_node_put(fcp_node
);
834 if (IS_ERR(vsp1
->fcp
)) {
835 dev_dbg(&pdev
->dev
, "FCP not found (%ld)\n",
837 return PTR_ERR(vsp1
->fcp
);
841 * When the FCP is present, it handles all bus master accesses
842 * for the VSP and must thus be used in place of the VSP device
843 * to map DMA buffers.
845 vsp1
->bus_master
= rcar_fcp_get_device(vsp1
->fcp
);
847 vsp1
->bus_master
= vsp1
->dev
;
850 /* Configure device parameters based on the version register. */
851 pm_runtime_enable(&pdev
->dev
);
853 ret
= vsp1_device_get(vsp1
);
857 vsp1
->version
= vsp1_read(vsp1
, VI6_IP_VERSION
);
858 vsp1_device_put(vsp1
);
860 for (i
= 0; i
< ARRAY_SIZE(vsp1_device_infos
); ++i
) {
861 if ((vsp1
->version
& VI6_IP_VERSION_MODEL_MASK
) ==
862 vsp1_device_infos
[i
].version
) {
863 vsp1
->info
= &vsp1_device_infos
[i
];
869 dev_err(&pdev
->dev
, "unsupported IP version 0x%08x\n",
875 dev_dbg(&pdev
->dev
, "IP version 0x%08x\n", vsp1
->version
);
877 /* Instantiate entities. */
878 ret
= vsp1_create_entities(vsp1
);
880 dev_err(&pdev
->dev
, "failed to create entities\n");
886 pm_runtime_disable(&pdev
->dev
);
891 static int vsp1_remove(struct platform_device
*pdev
)
893 struct vsp1_device
*vsp1
= platform_get_drvdata(pdev
);
895 vsp1_destroy_entities(vsp1
);
896 rcar_fcp_put(vsp1
->fcp
);
898 pm_runtime_disable(&pdev
->dev
);
903 static const struct of_device_id vsp1_of_match
[] = {
904 { .compatible
= "renesas,vsp1" },
905 { .compatible
= "renesas,vsp2" },
908 MODULE_DEVICE_TABLE(of
, vsp1_of_match
);
910 static struct platform_driver vsp1_platform_driver
= {
912 .remove
= vsp1_remove
,
916 .of_match_table
= vsp1_of_match
,
920 module_platform_driver(vsp1_platform_driver
);
922 MODULE_ALIAS("vsp1");
923 MODULE_AUTHOR("Laurent Pinchart <laurent.pinchart@ideasonboard.com>");
924 MODULE_DESCRIPTION("Renesas VSP1 Driver");
925 MODULE_LICENSE("GPL");