1 // SPDX-License-Identifier: GPL-2.0+
3 * vsp1_drv.c -- R-Car VSP1 Driver
5 * Copyright (C) 2013-2015 Renesas Electronics Corporation
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/platform_device.h>
17 #include <linux/pm_runtime.h>
18 #include <linux/reset.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_WPF_IRQ_STA_DFE | VI6_WPF_IRQ_STA_FRE |
49 struct vsp1_device *vsp1 = data;
50 irqreturn_t ret = IRQ_NONE;
54 for (i = 0; i < vsp1->info->wpf_count; ++i) {
55 struct vsp1_rwpf *wpf = vsp1->wpf[i];
60 status = vsp1_read(vsp1, VI6_WPF_IRQ_STA(i));
61 vsp1_write(vsp1, VI6_WPF_IRQ_STA(i), ~status & mask);
63 if ((status & VI6_WPF_IRQ_STA_UND) && wpf->entity.pipe) {
64 wpf->entity.pipe->underrun_count++;
66 dev_warn_ratelimited(vsp1->dev,
67 "Underrun occurred at WPF%u (total underruns %u)\n",
68 i, wpf->entity.pipe->underrun_count);
71 if (status & VI6_WPF_IRQ_STA_DFE) {
72 vsp1_pipeline_frame_end(wpf->entity.pipe);
80 /* -----------------------------------------------------------------------------
85 * vsp1_create_sink_links - Create links from all sources to the given sink
87 * This function creates media links from all valid sources to the given sink
88 * pad. Links that would be invalid according to the VSP1 hardware capabilities
89 * are skipped. Those include all links
91 * - from a UDS to a UDS (UDS entities can't be chained)
92 * - from an entity to itself (no loops are allowed)
94 * Furthermore, the BRS can't be connected to histogram generators, but no
95 * special check is currently needed as all VSP instances that include a BRS
96 * have no histogram generator.
98 static int vsp1_create_sink_links(struct vsp1_device *vsp1,
99 struct vsp1_entity *sink)
101 struct media_entity *entity = &sink->subdev.entity;
102 struct vsp1_entity *source;
106 list_for_each_entry(source, &vsp1->entities, list_dev) {
109 if (source->type == sink->type)
112 if (source->type == VSP1_ENTITY_HGO ||
113 source->type == VSP1_ENTITY_HGT ||
114 source->type == VSP1_ENTITY_LIF ||
115 source->type == VSP1_ENTITY_WPF)
118 flags = source->type == VSP1_ENTITY_RPF &&
119 sink->type == VSP1_ENTITY_WPF &&
120 source->index == sink->index
121 ? MEDIA_LNK_FL_ENABLED : 0;
123 for (pad = 0; pad < entity->num_pads; ++pad) {
124 if (!(entity->pads[pad].flags & MEDIA_PAD_FL_SINK))
127 ret = media_create_pad_link(&source->subdev.entity,
133 if (flags & MEDIA_LNK_FL_ENABLED)
141 static int vsp1_uapi_create_links(struct vsp1_device *vsp1)
143 struct vsp1_entity *entity;
147 list_for_each_entry(entity, &vsp1->entities, list_dev) {
148 if (entity->type == VSP1_ENTITY_LIF ||
149 entity->type == VSP1_ENTITY_RPF)
152 ret = vsp1_create_sink_links(vsp1, entity);
158 ret = media_create_pad_link(&vsp1->hgo->histo.entity.subdev.entity,
160 &vsp1->hgo->histo.video.entity, 0,
161 MEDIA_LNK_FL_ENABLED |
162 MEDIA_LNK_FL_IMMUTABLE);
168 ret = media_create_pad_link(&vsp1->hgt->histo.entity.subdev.entity,
170 &vsp1->hgt->histo.video.entity, 0,
171 MEDIA_LNK_FL_ENABLED |
172 MEDIA_LNK_FL_IMMUTABLE);
177 for (i = 0; i < vsp1->info->lif_count; ++i) {
181 ret = media_create_pad_link(&vsp1->wpf[i]->entity.subdev.entity,
183 &vsp1->lif[i]->entity.subdev.entity,
189 for (i = 0; i < vsp1->info->rpf_count; ++i) {
190 struct vsp1_rwpf *rpf = vsp1->rpf[i];
192 ret = media_create_pad_link(&rpf->video->video.entity, 0,
193 &rpf->entity.subdev.entity,
195 MEDIA_LNK_FL_ENABLED |
196 MEDIA_LNK_FL_IMMUTABLE);
201 for (i = 0; i < vsp1->info->wpf_count; ++i) {
203 * Connect the video device to the WPF. All connections are
206 struct vsp1_rwpf *wpf = vsp1->wpf[i];
208 ret = media_create_pad_link(&wpf->entity.subdev.entity,
210 &wpf->video->video.entity, 0,
211 MEDIA_LNK_FL_IMMUTABLE |
212 MEDIA_LNK_FL_ENABLED);
220 static void vsp1_destroy_entities(struct vsp1_device *vsp1)
222 struct vsp1_entity *entity, *_entity;
223 struct vsp1_video *video, *_video;
225 list_for_each_entry_safe(entity, _entity, &vsp1->entities, list_dev) {
226 list_del(&entity->list_dev);
227 vsp1_entity_destroy(entity);
230 list_for_each_entry_safe(video, _video, &vsp1->videos, list) {
231 list_del(&video->list);
232 vsp1_video_cleanup(video);
235 v4l2_device_unregister(&vsp1->v4l2_dev);
236 if (vsp1->info->uapi)
237 media_device_unregister(&vsp1->media_dev);
238 media_device_cleanup(&vsp1->media_dev);
240 if (!vsp1->info->uapi)
241 vsp1_drm_cleanup(vsp1);
244 static int vsp1_create_entities(struct vsp1_device *vsp1)
246 struct media_device *mdev = &vsp1->media_dev;
247 struct v4l2_device *vdev = &vsp1->v4l2_dev;
248 struct vsp1_entity *entity;
252 mdev->dev = vsp1->dev;
253 mdev->hw_revision = vsp1->version;
254 strscpy(mdev->model, vsp1->info->model, sizeof(mdev->model));
255 media_device_init(mdev);
257 vsp1->media_ops.link_setup = vsp1_entity_link_setup;
259 * Don't perform link validation when the userspace API is disabled as
260 * the pipeline is configured internally by the driver in that case, and
261 * its configuration can thus be trusted.
263 if (vsp1->info->uapi)
264 vsp1->media_ops.link_validate = v4l2_subdev_link_validate;
267 ret = v4l2_device_register(vsp1->dev, vdev);
269 dev_err(vsp1->dev, "V4L2 device registration failed (%d)\n",
274 /* Instantiate all the entities. */
275 if (vsp1_feature(vsp1, VSP1_HAS_BRS)) {
276 vsp1->brs = vsp1_brx_create(vsp1, VSP1_ENTITY_BRS);
277 if (IS_ERR(vsp1->brs)) {
278 ret = PTR_ERR(vsp1->brs);
282 list_add_tail(&vsp1->brs->entity.list_dev, &vsp1->entities);
285 if (vsp1_feature(vsp1, VSP1_HAS_BRU)) {
286 vsp1->bru = vsp1_brx_create(vsp1, VSP1_ENTITY_BRU);
287 if (IS_ERR(vsp1->bru)) {
288 ret = PTR_ERR(vsp1->bru);
292 list_add_tail(&vsp1->bru->entity.list_dev, &vsp1->entities);
295 if (vsp1_feature(vsp1, VSP1_HAS_CLU)) {
296 vsp1->clu = vsp1_clu_create(vsp1);
297 if (IS_ERR(vsp1->clu)) {
298 ret = PTR_ERR(vsp1->clu);
302 list_add_tail(&vsp1->clu->entity.list_dev, &vsp1->entities);
305 vsp1->hsi = vsp1_hsit_create(vsp1, true);
306 if (IS_ERR(vsp1->hsi)) {
307 ret = PTR_ERR(vsp1->hsi);
311 list_add_tail(&vsp1->hsi->entity.list_dev, &vsp1->entities);
313 vsp1->hst = vsp1_hsit_create(vsp1, false);
314 if (IS_ERR(vsp1->hst)) {
315 ret = PTR_ERR(vsp1->hst);
319 list_add_tail(&vsp1->hst->entity.list_dev, &vsp1->entities);
321 if (vsp1_feature(vsp1, VSP1_HAS_HGO) && vsp1->info->uapi) {
322 vsp1->hgo = vsp1_hgo_create(vsp1);
323 if (IS_ERR(vsp1->hgo)) {
324 ret = PTR_ERR(vsp1->hgo);
328 list_add_tail(&vsp1->hgo->histo.entity.list_dev,
332 if (vsp1_feature(vsp1, VSP1_HAS_HGT) && vsp1->info->uapi) {
333 vsp1->hgt = vsp1_hgt_create(vsp1);
334 if (IS_ERR(vsp1->hgt)) {
335 ret = PTR_ERR(vsp1->hgt);
339 list_add_tail(&vsp1->hgt->histo.entity.list_dev,
344 * The LIFs are only supported when used in conjunction with the DU, in
345 * which case the userspace API is disabled. If the userspace API is
346 * enabled skip the LIFs, even when present.
348 if (!vsp1->info->uapi) {
349 for (i = 0; i < vsp1->info->lif_count; ++i) {
350 struct vsp1_lif *lif;
352 lif = vsp1_lif_create(vsp1, i);
359 list_add_tail(&lif->entity.list_dev, &vsp1->entities);
363 if (vsp1_feature(vsp1, VSP1_HAS_LUT)) {
364 vsp1->lut = vsp1_lut_create(vsp1);
365 if (IS_ERR(vsp1->lut)) {
366 ret = PTR_ERR(vsp1->lut);
370 list_add_tail(&vsp1->lut->entity.list_dev, &vsp1->entities);
373 for (i = 0; i < vsp1->info->rpf_count; ++i) {
374 struct vsp1_rwpf *rpf;
376 rpf = vsp1_rpf_create(vsp1, i);
383 list_add_tail(&rpf->entity.list_dev, &vsp1->entities);
385 if (vsp1->info->uapi) {
386 struct vsp1_video *video = vsp1_video_create(vsp1, rpf);
389 ret = PTR_ERR(video);
393 list_add_tail(&video->list, &vsp1->videos);
397 if (vsp1_feature(vsp1, VSP1_HAS_SRU)) {
398 vsp1->sru = vsp1_sru_create(vsp1);
399 if (IS_ERR(vsp1->sru)) {
400 ret = PTR_ERR(vsp1->sru);
404 list_add_tail(&vsp1->sru->entity.list_dev, &vsp1->entities);
407 for (i = 0; i < vsp1->info->uds_count; ++i) {
408 struct vsp1_uds *uds;
410 uds = vsp1_uds_create(vsp1, i);
417 list_add_tail(&uds->entity.list_dev, &vsp1->entities);
420 for (i = 0; i < vsp1->info->uif_count; ++i) {
421 struct vsp1_uif *uif;
423 uif = vsp1_uif_create(vsp1, i);
430 list_add_tail(&uif->entity.list_dev, &vsp1->entities);
433 for (i = 0; i < vsp1->info->wpf_count; ++i) {
434 struct vsp1_rwpf *wpf;
436 wpf = vsp1_wpf_create(vsp1, i);
443 list_add_tail(&wpf->entity.list_dev, &vsp1->entities);
445 if (vsp1->info->uapi) {
446 struct vsp1_video *video = vsp1_video_create(vsp1, wpf);
449 ret = PTR_ERR(video);
453 list_add_tail(&video->list, &vsp1->videos);
457 /* Register all subdevs. */
458 list_for_each_entry(entity, &vsp1->entities, list_dev) {
459 ret = v4l2_device_register_subdev(&vsp1->v4l2_dev,
466 * Create links and register subdev nodes if the userspace API is
467 * enabled or initialize the DRM pipeline otherwise.
469 if (vsp1->info->uapi) {
470 ret = vsp1_uapi_create_links(vsp1);
474 ret = v4l2_device_register_subdev_nodes(&vsp1->v4l2_dev);
478 ret = media_device_register(mdev);
480 ret = vsp1_drm_init(vsp1);
485 vsp1_destroy_entities(vsp1);
490 int vsp1_reset_wpf(struct vsp1_device *vsp1, unsigned int index)
492 unsigned int timeout;
495 status = vsp1_read(vsp1, VI6_STATUS);
496 if (!(status & VI6_STATUS_SYS_ACT(index)))
499 vsp1_write(vsp1, VI6_SRESET, VI6_SRESET_SRTS(index));
500 for (timeout = 10; timeout > 0; --timeout) {
501 status = vsp1_read(vsp1, VI6_STATUS);
502 if (!(status & VI6_STATUS_SYS_ACT(index)))
505 usleep_range(1000, 2000);
509 dev_err(vsp1->dev, "failed to reset wpf.%u\n", index);
516 static int vsp1_device_init(struct vsp1_device *vsp1)
521 /* Reset any channel that might be running. */
522 for (i = 0; i < vsp1->info->wpf_count; ++i) {
523 ret = vsp1_reset_wpf(vsp1, i);
528 vsp1_write(vsp1, VI6_CLK_DCSWT, (8 << VI6_CLK_DCSWT_CSTPW_SHIFT) |
529 (8 << VI6_CLK_DCSWT_CSTRW_SHIFT));
531 for (i = 0; i < vsp1->info->rpf_count; ++i)
532 vsp1_write(vsp1, VI6_DPR_RPF_ROUTE(i), VI6_DPR_NODE_UNUSED);
534 for (i = 0; i < vsp1->info->uds_count; ++i)
535 vsp1_write(vsp1, VI6_DPR_UDS_ROUTE(i), VI6_DPR_NODE_UNUSED);
537 for (i = 0; i < vsp1->info->uif_count; ++i)
538 vsp1_write(vsp1, VI6_DPR_UIF_ROUTE(i), VI6_DPR_NODE_UNUSED);
540 vsp1_write(vsp1, VI6_DPR_SRU_ROUTE, VI6_DPR_NODE_UNUSED);
541 vsp1_write(vsp1, VI6_DPR_LUT_ROUTE, VI6_DPR_NODE_UNUSED);
542 vsp1_write(vsp1, VI6_DPR_CLU_ROUTE, VI6_DPR_NODE_UNUSED);
543 vsp1_write(vsp1, VI6_DPR_HST_ROUTE, VI6_DPR_NODE_UNUSED);
544 vsp1_write(vsp1, VI6_DPR_HSI_ROUTE, VI6_DPR_NODE_UNUSED);
545 vsp1_write(vsp1, VI6_DPR_BRU_ROUTE, VI6_DPR_NODE_UNUSED);
547 if (vsp1_feature(vsp1, VSP1_HAS_BRS))
548 vsp1_write(vsp1, VI6_DPR_ILV_BRS_ROUTE, VI6_DPR_NODE_UNUSED);
550 vsp1_write(vsp1, VI6_DPR_HGO_SMPPT, (7 << VI6_DPR_SMPPT_TGW_SHIFT) |
551 (VI6_DPR_NODE_UNUSED << VI6_DPR_SMPPT_PT_SHIFT));
552 vsp1_write(vsp1, VI6_DPR_HGT_SMPPT, (7 << VI6_DPR_SMPPT_TGW_SHIFT) |
553 (VI6_DPR_NODE_UNUSED << VI6_DPR_SMPPT_PT_SHIFT));
555 vsp1_dlm_setup(vsp1);
560 static void vsp1_mask_all_interrupts(struct vsp1_device *vsp1)
564 for (i = 0; i < vsp1->info->lif_count; ++i)
565 vsp1_write(vsp1, VI6_DISP_IRQ_ENB(i), 0);
566 for (i = 0; i < vsp1->info->wpf_count; ++i)
567 vsp1_write(vsp1, VI6_WPF_IRQ_ENB(i), 0);
571 * vsp1_device_get - Acquire the VSP1 device
573 * Make sure the device is not suspended and initialize it if needed.
575 * Return 0 on success or a negative error code otherwise.
577 int vsp1_device_get(struct vsp1_device *vsp1)
579 return pm_runtime_resume_and_get(vsp1->dev);
583 * vsp1_device_put - Release the VSP1 device
585 * Decrement the VSP1 reference count and cleanup the device if the last
586 * reference is released.
588 void vsp1_device_put(struct vsp1_device *vsp1)
590 pm_runtime_put_sync(vsp1->dev);
593 /* -----------------------------------------------------------------------------
597 static int __maybe_unused vsp1_pm_suspend(struct device *dev)
599 struct vsp1_device *vsp1 = dev_get_drvdata(dev);
602 * When used as part of a display pipeline, the VSP is stopped and
603 * restarted explicitly by the DU.
606 vsp1_video_suspend(vsp1);
608 pm_runtime_force_suspend(vsp1->dev);
613 static int __maybe_unused vsp1_pm_resume(struct device *dev)
615 struct vsp1_device *vsp1 = dev_get_drvdata(dev);
617 pm_runtime_force_resume(vsp1->dev);
620 * When used as part of a display pipeline, the VSP is stopped and
621 * restarted explicitly by the DU.
624 vsp1_video_resume(vsp1);
629 static int __maybe_unused vsp1_pm_runtime_suspend(struct device *dev)
631 struct vsp1_device *vsp1 = dev_get_drvdata(dev);
633 rcar_fcp_disable(vsp1->fcp);
634 reset_control_assert(vsp1->rstc);
639 static int __maybe_unused vsp1_pm_runtime_resume(struct device *dev)
641 struct vsp1_device *vsp1 = dev_get_drvdata(dev);
644 ret = reset_control_deassert(vsp1->rstc);
650 * On R-Car Gen2 and RZ/G1, vsp1 register access after deassert
651 * can cause lock-up. It is a special case and needs some delay
652 * to avoid this lock-up.
654 if (vsp1->info->gen == 2)
657 ret = vsp1_device_init(vsp1);
662 ret = rcar_fcp_enable(vsp1->fcp);
666 reset_control_assert(vsp1->rstc);
671 static const struct dev_pm_ops vsp1_pm_ops = {
672 SET_SYSTEM_SLEEP_PM_OPS(vsp1_pm_suspend, vsp1_pm_resume)
673 SET_RUNTIME_PM_OPS(vsp1_pm_runtime_suspend, vsp1_pm_runtime_resume, NULL)
676 /* -----------------------------------------------------------------------------
680 static const struct vsp1_device_info vsp1_device_infos[] = {
682 .version = VI6_IP_VERSION_MODEL_VSPS_H2,
685 .features = VSP1_HAS_BRU | VSP1_HAS_CLU | VSP1_HAS_HGO
686 | VSP1_HAS_HGT | VSP1_HAS_LUT | VSP1_HAS_SRU
687 | VSP1_HAS_WPF_VFLIP,
694 .version = VI6_IP_VERSION_MODEL_VSPR_H2,
697 .features = VSP1_HAS_BRU | VSP1_HAS_SRU | VSP1_HAS_WPF_VFLIP,
704 .version = VI6_IP_VERSION_MODEL_VSPD_GEN2,
707 .features = VSP1_HAS_BRU | VSP1_HAS_HGO | VSP1_HAS_LUT,
715 .version = VI6_IP_VERSION_MODEL_VSPS_M2,
718 .features = VSP1_HAS_BRU | VSP1_HAS_CLU | VSP1_HAS_HGO
719 | VSP1_HAS_HGT | VSP1_HAS_LUT | VSP1_HAS_SRU
720 | VSP1_HAS_WPF_VFLIP,
727 .version = VI6_IP_VERSION_MODEL_VSPS_V2H,
730 .features = VSP1_HAS_BRU | VSP1_HAS_CLU | VSP1_HAS_LUT
731 | VSP1_HAS_SRU | VSP1_HAS_WPF_VFLIP,
738 .version = VI6_IP_VERSION_MODEL_VSPD_V2H,
741 .features = VSP1_HAS_BRU | VSP1_HAS_CLU | VSP1_HAS_LUT,
749 .version = VI6_IP_VERSION_MODEL_VSPI_GEN3,
752 .features = VSP1_HAS_CLU | VSP1_HAS_HGO | VSP1_HAS_HGT
753 | VSP1_HAS_LUT | VSP1_HAS_SRU | VSP1_HAS_WPF_HFLIP
754 | VSP1_HAS_WPF_VFLIP,
760 .version = VI6_IP_VERSION_MODEL_VSPBD_GEN3,
763 .features = VSP1_HAS_BRU | VSP1_HAS_WPF_VFLIP,
769 .version = VI6_IP_VERSION_MODEL_VSPBC_GEN3,
772 .features = VSP1_HAS_BRU | VSP1_HAS_CLU | VSP1_HAS_HGO
773 | VSP1_HAS_LUT | VSP1_HAS_WPF_VFLIP,
779 .version = VI6_IP_VERSION_MODEL_VSPBS_GEN3,
782 .features = VSP1_HAS_BRS | VSP1_HAS_WPF_VFLIP,
787 .version = VI6_IP_VERSION_MODEL_VSPD_GEN3,
790 .features = VSP1_HAS_BRU | VSP1_HAS_WPF_VFLIP | VSP1_HAS_EXT_DL,
797 .version = VI6_IP_VERSION_MODEL_VSPD_V3,
799 .soc = VI6_IP_VERSION_SOC_V3H,
801 .features = VSP1_HAS_BRS | VSP1_HAS_BRU,
808 .version = VI6_IP_VERSION_MODEL_VSPD_V3,
810 .soc = VI6_IP_VERSION_SOC_V3M,
812 .features = VSP1_HAS_BRS | VSP1_HAS_BRU | VSP1_HAS_NON_ZERO_LBA,
819 .version = VI6_IP_VERSION_MODEL_VSPDL_GEN3,
822 .features = VSP1_HAS_BRS | VSP1_HAS_BRU | VSP1_HAS_EXT_DL,
829 .version = VI6_IP_VERSION_MODEL_VSPD_GEN4,
832 .features = VSP1_HAS_BRU | VSP1_HAS_EXT_DL,
841 static const struct vsp1_device_info rzg2l_vsp2_device_info = {
842 .version = VI6_IP_VERSION_MODEL_VSPD_RZG2L,
844 .soc = VI6_IP_VERSION_SOC_RZG2L,
846 .features = VSP1_HAS_BRS | VSP1_HAS_WPF_VFLIP | VSP1_HAS_EXT_DL
847 | VSP1_HAS_NON_ZERO_LBA,
853 static const struct vsp1_device_info *vsp1_lookup_info(struct vsp1_device *vsp1)
855 const struct vsp1_device_info *info;
861 * Try the info stored in match data first for devices that don't have
862 * a version register.
864 info = of_device_get_match_data(vsp1->dev);
866 vsp1->version = VI6_IP_VERSION_VSP_SW | info->version | info->soc;
870 vsp1->version = vsp1_read(vsp1, VI6_IP_VERSION);
871 model = vsp1->version & VI6_IP_VERSION_MODEL_MASK;
872 soc = vsp1->version & VI6_IP_VERSION_SOC_MASK;
874 for (i = 0; i < ARRAY_SIZE(vsp1_device_infos); ++i) {
875 info = &vsp1_device_infos[i];
877 if (model == info->version && (!info->soc || soc == info->soc))
881 dev_err(vsp1->dev, "unsupported IP version 0x%08x\n", vsp1->version);
886 static int vsp1_probe(struct platform_device *pdev)
888 struct vsp1_device *vsp1;
889 struct device_node *fcp_node;
893 vsp1 = devm_kzalloc(&pdev->dev, sizeof(*vsp1), GFP_KERNEL);
897 vsp1->dev = &pdev->dev;
898 INIT_LIST_HEAD(&vsp1->entities);
899 INIT_LIST_HEAD(&vsp1->videos);
901 platform_set_drvdata(pdev, vsp1);
903 /* I/O and IRQ resources (clock managed by the clock PM domain). */
904 vsp1->mmio = devm_platform_ioremap_resource(pdev, 0);
905 if (IS_ERR(vsp1->mmio))
906 return PTR_ERR(vsp1->mmio);
908 irq = platform_get_irq(pdev, 0);
912 vsp1->rstc = devm_reset_control_get_shared(&pdev->dev, NULL);
913 if (IS_ERR(vsp1->rstc))
914 return dev_err_probe(&pdev->dev, PTR_ERR(vsp1->rstc),
915 "failed to get reset control\n");
917 /* FCP (optional). */
918 fcp_node = of_parse_phandle(pdev->dev.of_node, "renesas,fcp", 0);
920 vsp1->fcp = rcar_fcp_get(fcp_node);
921 of_node_put(fcp_node);
922 if (IS_ERR(vsp1->fcp)) {
923 dev_dbg(&pdev->dev, "FCP not found (%ld)\n",
925 return PTR_ERR(vsp1->fcp);
929 * When the FCP is present, it handles all bus master accesses
930 * for the VSP and must thus be used in place of the VSP device
931 * to map DMA buffers.
933 vsp1->bus_master = rcar_fcp_get_device(vsp1->fcp);
935 vsp1->bus_master = vsp1->dev;
938 /* Configure device parameters based on the version register. */
939 pm_runtime_enable(&pdev->dev);
941 ret = vsp1_device_get(vsp1);
945 vsp1->info = vsp1_lookup_info(vsp1);
947 vsp1_device_put(vsp1);
952 dev_dbg(&pdev->dev, "IP version 0x%08x\n", vsp1->version);
955 * Previous use of the hardware (e.g. by the bootloader) could leave
956 * some interrupts enabled and pending.
958 * TODO: Investigate if this shouldn't be better handled by using the
959 * device reset provided by the CPG.
961 vsp1_mask_all_interrupts(vsp1);
963 vsp1_device_put(vsp1);
965 ret = devm_request_irq(&pdev->dev, irq, vsp1_irq_handler,
966 IRQF_SHARED, dev_name(&pdev->dev), vsp1);
968 dev_err(&pdev->dev, "failed to request IRQ\n");
972 /* Instantiate entities. */
973 ret = vsp1_create_entities(vsp1);
975 dev_err(&pdev->dev, "failed to create entities\n");
981 pm_runtime_disable(&pdev->dev);
982 rcar_fcp_put(vsp1->fcp);
988 static void vsp1_remove(struct platform_device *pdev)
990 struct vsp1_device *vsp1 = platform_get_drvdata(pdev);
992 vsp1_destroy_entities(vsp1);
993 rcar_fcp_put(vsp1->fcp);
995 pm_runtime_disable(&pdev->dev);
998 static const struct of_device_id vsp1_of_match[] = {
999 { .compatible = "renesas,vsp1" },
1000 { .compatible = "renesas,vsp2" },
1001 { .compatible = "renesas,r9a07g044-vsp2", .data = &rzg2l_vsp2_device_info },
1004 MODULE_DEVICE_TABLE(of, vsp1_of_match);
1006 static struct platform_driver vsp1_platform_driver = {
1007 .probe = vsp1_probe,
1008 .remove = vsp1_remove,
1012 .of_match_table = vsp1_of_match,
1016 module_platform_driver(vsp1_platform_driver);
1018 MODULE_ALIAS("vsp1");
1020 MODULE_DESCRIPTION("Renesas VSP1 Driver");
1021 MODULE_LICENSE("GPL");