Lines Matching +full:csi +full:- +full:aclk

1 // SPDX-License-Identifier: (GPL-2.0+ OR MIT)
3 * Rockchip ISP1 Driver - Base driver
20 #include <media/v4l2-fwnode.h>
21 #include <media/v4l2-mc.h>
23 #include "rkisp1-common.h"
24 #include "rkisp1-csi.h"
28 * -----------
40 * -----------------
41 …* rkisp1-resizer.c rkisp1-cap…
43 * rkisp1-isp.c Main Picture Path
45 …* +-----------+ +--+--+--+--+ +--------+ +--------+ +--…
47 …* +--------+ |\ | | | | | | | -->| Crop |->| RSZ |------------->| …
48 …* | MIPI |--->| \ | | | | | | | | | | | | | …
49 …* +--------+ | | | | |IE|IE|IE|IE| | +--------+ +--------+ | …
50 …* |MUX|--->| ISP |->|0 |1 |2 |3 |---+ | I…
51 …* +--------+ | | | | | | | | | | +--------+ +--------+ +--------+ | …
52 …* |Parallel|--->| / | | | | | | | | | | | | | | | …
53 …* +--------+ |/ | | | | | | | -->| Crop |->| RSZ |->| RGB |->| …
55 …* +-----------+ +--+--+--+--+ +--------+ +--------+ +--------+ +--…
57 …* +--------+ | |======================================…
58 * | DMA |------------------------------------+ Self Picture Path
59 * +--------+
61 * rkisp1-stats.c rkisp1-params.c
63 * +---------------+ +---------------+
67 * +---------------+ +---------------+
71 * --------------
73 * +----------+ +----------+
75 * ------------ ... ------------
77 * +----------+ +----------+
79 * \----\ /----/
82 * +-------------+
84 * ---------------
85 * | CSI-2 RX |
86 * --------------- +-----------+
88 * +-------------+ | (output) |
89 * | +-----------+
91 * +------+------+ |
92 * | 0 | 1 |<---------+
93 * |------+------|
95 * |------+------|
96 * +-------------| 2 | 3 |----------+
97 * | +------+------+ |
100 * +- ---------+ +-----------+ +-----------+
102 * ------------- ------------- | (capture) |
103 * | Resizer | | Resizer | +-----------+
104 * ------------| ------------|
106 * +-----------+ +-----------+
109 * +-----------+ +-----------+
112 * +-----------+ +-----------+
121 /* ----------------------------------------------------------------------------
136 s_asd->sd = sd; in rkisp1_subdev_notifier_bound()
138 source_pad = media_entity_get_fwnode_pad(&sd->entity, s_asd->source_ep, in rkisp1_subdev_notifier_bound()
141 dev_err(rkisp1->dev, "failed to find source pad for %s\n", in rkisp1_subdev_notifier_bound()
142 sd->name); in rkisp1_subdev_notifier_bound()
146 if (s_asd->port == 0) in rkisp1_subdev_notifier_bound()
149 ret = media_create_pad_link(&sd->entity, source_pad, in rkisp1_subdev_notifier_bound()
150 &rkisp1->isp.sd.entity, in rkisp1_subdev_notifier_bound()
152 !s_asd->index ? MEDIA_LNK_FL_ENABLED : 0); in rkisp1_subdev_notifier_bound()
154 dev_err(rkisp1->dev, "failed to link source pad of %s\n", in rkisp1_subdev_notifier_bound()
155 sd->name); in rkisp1_subdev_notifier_bound()
167 return v4l2_device_register_subdev_nodes(&rkisp1->v4l2_dev); in rkisp1_subdev_notifier_complete()
175 fwnode_handle_put(rk_asd->source_ep); in rkisp1_subdev_notifier_destroy()
186 struct v4l2_async_notifier *ntf = &rkisp1->notifier; in rkisp1_subdev_notifier_register()
187 struct fwnode_handle *fwnode = dev_fwnode(rkisp1->dev); in rkisp1_subdev_notifier_register()
192 v4l2_async_nf_init(ntf, &rkisp1->v4l2_dev); in rkisp1_subdev_notifier_register()
194 ntf->ops = &rkisp1_subdev_notifier_ops; in rkisp1_subdev_notifier_register()
210 /* MIPI CSI-2 port */ in rkisp1_subdev_notifier_register()
212 dev_err(rkisp1->dev, in rkisp1_subdev_notifier_register()
213 "internal CSI must be available for port 0\n"); in rkisp1_subdev_notifier_register()
214 ret = -EINVAL; in rkisp1_subdev_notifier_register()
223 * Parallel port. The bus-type property in DT is in rkisp1_subdev_notifier_register()
234 dev_err(rkisp1->dev, "failed to parse endpoint %pfw\n", in rkisp1_subdev_notifier_register()
242 dev_err(rkisp1->dev, in rkisp1_subdev_notifier_register()
244 ret = -EINVAL; in rkisp1_subdev_notifier_register()
252 dev_err(rkisp1->dev, in rkisp1_subdev_notifier_register()
255 ret = -ENODEV; in rkisp1_subdev_notifier_register()
267 rk_asd->index = index++; in rkisp1_subdev_notifier_register()
268 rk_asd->source_ep = source; in rkisp1_subdev_notifier_register()
269 rk_asd->mbus_type = vep.bus_type; in rkisp1_subdev_notifier_register()
270 rk_asd->port = vep.base.port; in rkisp1_subdev_notifier_register()
273 rk_asd->mbus_flags = vep.bus.mipi_csi2.flags; in rkisp1_subdev_notifier_register()
274 rk_asd->lanes = vep.bus.mipi_csi2.num_data_lanes; in rkisp1_subdev_notifier_register()
276 rk_asd->mbus_flags = vep.bus.parallel.flags; in rkisp1_subdev_notifier_register()
279 dev_dbg(rkisp1->dev, "registered ep id %d, bus type %u, %u lanes\n", in rkisp1_subdev_notifier_register()
280 vep.base.id, rk_asd->mbus_type, rk_asd->lanes); in rkisp1_subdev_notifier_register()
290 dev_dbg(rkisp1->dev, "no remote subdevice found\n"); in rkisp1_subdev_notifier_register()
301 /* ----------------------------------------------------------------------------
309 rkisp1->irqs_enabled = false; in rkisp1_runtime_suspend()
318 for (unsigned int il = 0; il < ARRAY_SIZE(rkisp1->irqs); ++il) { in rkisp1_runtime_suspend()
319 if (rkisp1->irqs[il] == -1) in rkisp1_runtime_suspend()
323 if (il == 0 || rkisp1->irqs[il - 1] != rkisp1->irqs[il]) in rkisp1_runtime_suspend()
324 synchronize_irq(rkisp1->irqs[il]); in rkisp1_runtime_suspend()
327 clk_bulk_disable_unprepare(rkisp1->clk_size, rkisp1->clks); in rkisp1_runtime_suspend()
339 ret = clk_bulk_prepare_enable(rkisp1->clk_size, rkisp1->clks); in rkisp1_runtime_resume()
343 rkisp1->irqs_enabled = true; in rkisp1_runtime_resume()
356 /* ----------------------------------------------------------------------------
367 /* Link the CSI receiver to the ISP. */ in rkisp1_create_links()
368 ret = media_create_pad_link(&rkisp1->csi.sd.entity, in rkisp1_create_links()
370 &rkisp1->isp.sd.entity, in rkisp1_create_links()
377 /* create ISP->RSZ->CAP links */ in rkisp1_create_links()
380 &rkisp1->resizer_devs[i].sd.entity; in rkisp1_create_links()
382 &rkisp1->capture_devs[i].vnode.vdev.entity; in rkisp1_create_links()
384 ret = media_create_pad_link(&rkisp1->isp.sd.entity, in rkisp1_create_links()
400 ret = media_create_pad_link(&rkisp1->params.vnode.vdev.entity, 0, in rkisp1_create_links()
401 &rkisp1->isp.sd.entity, in rkisp1_create_links()
409 return media_create_pad_link(&rkisp1->isp.sd.entity, in rkisp1_create_links()
411 &rkisp1->stats.vnode.vdev.entity, 0, in rkisp1_create_links()
493 "aclk",
520 "aclk",
545 "aclk",
567 .compatible = "rockchip,px30-cif-isp",
571 .compatible = "rockchip,rk3399-cif-isp",
575 .compatible = "fsl,imx8mp-isp",
585 struct device *dev = &pdev->dev; in rkisp1_probe()
595 return -ENOMEM; in rkisp1_probe()
598 rkisp1->info = info; in rkisp1_probe()
601 rkisp1->dev = dev; in rkisp1_probe()
610 mutex_init(&rkisp1->stream_lock); in rkisp1_probe()
612 rkisp1->base_addr = devm_platform_ioremap_resource(pdev, 0); in rkisp1_probe()
613 if (IS_ERR(rkisp1->base_addr)) in rkisp1_probe()
614 return PTR_ERR(rkisp1->base_addr); in rkisp1_probe()
616 for (unsigned int il = 0; il < ARRAY_SIZE(rkisp1->irqs); ++il) in rkisp1_probe()
617 rkisp1->irqs[il] = -1; in rkisp1_probe()
619 for (i = 0; i < info->isr_size; i++) { in rkisp1_probe()
620 irq = info->isrs[i].name in rkisp1_probe()
621 ? platform_get_irq_byname(pdev, info->isrs[i].name) in rkisp1_probe()
626 for (unsigned int il = 0; il < ARRAY_SIZE(rkisp1->irqs); ++il) { in rkisp1_probe()
627 if (info->isrs[i].line_mask & BIT(il)) in rkisp1_probe()
628 rkisp1->irqs[il] = irq; in rkisp1_probe()
631 ret = devm_request_irq(dev, irq, info->isrs[i].isr, IRQF_SHARED, in rkisp1_probe()
639 for (i = 0; i < info->clk_size; i++) in rkisp1_probe()
640 rkisp1->clks[i].id = info->clks[i]; in rkisp1_probe()
641 ret = devm_clk_bulk_get(dev, info->clk_size, rkisp1->clks); in rkisp1_probe()
644 rkisp1->clk_size = info->clk_size; in rkisp1_probe()
646 if (info->isp_ver == RKISP1_V_IMX8MP) { in rkisp1_probe()
649 rkisp1->gasket = syscon_regmap_lookup_by_phandle_args(dev->of_node, in rkisp1_probe()
650 "fsl,blk-ctrl", in rkisp1_probe()
652 if (IS_ERR(rkisp1->gasket)) { in rkisp1_probe()
653 ret = PTR_ERR(rkisp1->gasket); in rkisp1_probe()
658 rkisp1->gasket_id = id; in rkisp1_probe()
661 pm_runtime_enable(&pdev->dev); in rkisp1_probe()
663 ret = pm_runtime_resume_and_get(&pdev->dev); in rkisp1_probe()
668 dev_dbg(rkisp1->dev, "CIF_ID 0x%08x\n", cif_id); in rkisp1_probe()
670 pm_runtime_put(&pdev->dev); in rkisp1_probe()
672 rkisp1->media_dev.hw_revision = info->isp_ver; in rkisp1_probe()
673 strscpy(rkisp1->media_dev.model, RKISP1_DRIVER_NAME, in rkisp1_probe()
674 sizeof(rkisp1->media_dev.model)); in rkisp1_probe()
675 rkisp1->media_dev.dev = &pdev->dev; in rkisp1_probe()
676 strscpy(rkisp1->media_dev.bus_info, RKISP1_BUS_INFO, in rkisp1_probe()
677 sizeof(rkisp1->media_dev.bus_info)); in rkisp1_probe()
678 media_device_init(&rkisp1->media_dev); in rkisp1_probe()
680 v4l2_dev = &rkisp1->v4l2_dev; in rkisp1_probe()
681 v4l2_dev->mdev = &rkisp1->media_dev; in rkisp1_probe()
682 strscpy(v4l2_dev->name, RKISP1_DRIVER_NAME, sizeof(v4l2_dev->name)); in rkisp1_probe()
684 ret = v4l2_device_register(rkisp1->dev, &rkisp1->v4l2_dev); in rkisp1_probe()
688 ret = media_device_register(&rkisp1->media_dev); in rkisp1_probe()
694 if (rkisp1->info->features & RKISP1_FEATURE_MIPI_CSI2) { in rkisp1_probe()
718 media_device_unregister(&rkisp1->media_dev); in rkisp1_probe()
720 v4l2_device_unregister(&rkisp1->v4l2_dev); in rkisp1_probe()
722 media_device_cleanup(&rkisp1->media_dev); in rkisp1_probe()
724 pm_runtime_disable(&pdev->dev); in rkisp1_probe()
732 v4l2_async_nf_unregister(&rkisp1->notifier); in rkisp1_remove()
733 v4l2_async_nf_cleanup(&rkisp1->notifier); in rkisp1_remove()
740 media_device_unregister(&rkisp1->media_dev); in rkisp1_remove()
741 v4l2_device_unregister(&rkisp1->v4l2_dev); in rkisp1_remove()
743 media_device_cleanup(&rkisp1->media_dev); in rkisp1_remove()
745 pm_runtime_disable(&pdev->dev); in rkisp1_remove()