Lines Matching +full:autoidle +full:- +full:shift
1 // SPDX-License-Identifier: GPL-2.0-only
5 * TI OMAP3 ISP - Core
7 * Copyright (C) 2006-2010 Nokia Corporation
8 * Copyright (C) 2007-2009 Texas Instruments, Inc.
17 * Stanimir Varbanov <svarbanov@mm-sol.com>
22 * Ivan T. Ivanov <iivanov@mm-sol.com>
23 * RaniSuneela <r-m@ti.com>
24 * Atanas Filipov <afilipov@mm-sol.com>
25 * Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
27 * Nayden Kanchev <nkanchev@mm-sol.com>
28 * Phil Carmody <ext-phil.2.carmody@nokia.com>
32 * Pallavi Kulkarni <p-kulkarni@ti.com>
39 * Troy Laramy <t-laramy@ti.com>
46 #include <linux/dma-mapping.h>
51 #include <linux/omap-iommu.h>
60 #include <asm/dma-iommu.h>
63 #include <media/v4l2-common.h>
64 #include <media/v4l2-fwnode.h>
65 #include <media/v4l2-device.h>
66 #include <media/v4l2-mc.h>
78 static unsigned int autoidle;
79 module_param(autoidle, int, 0444);
80 MODULE_PARM_DESC(autoidle, "Enable OMAP3ISP AUTOIDLE support");
138 * omap3isp_flush - Post pending L3 bus writes by doing a register readback
145 * https://www.mail-archive.com/linux-omap@vger.kernel.org/msg08149.html
153 /* -----------------------------------------------------------------------------
161 switch (xclk->id) {
163 isp_reg_clr_set(xclk->isp, OMAP3_ISP_IOMEM_MAIN, ISP_TCTRL_CTRL,
168 isp_reg_clr_set(xclk->isp, OMAP3_ISP_IOMEM_MAIN, ISP_TCTRL_CTRL,
179 omap3isp_get(xclk->isp);
188 omap3isp_put(xclk->isp);
196 spin_lock_irqsave(&xclk->lock, flags);
197 isp_xclk_update(xclk, xclk->divider);
198 xclk->enabled = true;
199 spin_unlock_irqrestore(&xclk->lock, flags);
209 spin_lock_irqsave(&xclk->lock, flags);
211 xclk->enabled = false;
212 spin_unlock_irqrestore(&xclk->lock, flags);
220 return parent_rate / xclk->divider;
237 divider = ISPTCTRL_CTRL_DIV_BYPASS - 1;
259 spin_lock_irqsave(&xclk->lock, flags);
261 xclk->divider = divider;
262 if (xclk->enabled)
265 spin_unlock_irqrestore(&xclk->lock, flags);
267 dev_dbg(xclk->isp->dev, "%s: cam_xclk%c set to %lu Hz (div %u)\n",
268 __func__, xclk->id == ISP_XCLK_A ? 'a' : 'b', rate, divider);
286 unsigned int idx = clkspec->args[0];
289 if (idx >= ARRAY_SIZE(isp->xclks))
290 return ERR_PTR(-ENOENT);
292 return isp->xclks[idx].clk;
297 struct device_node *np = isp->dev->of_node;
301 for (i = 0; i < ARRAY_SIZE(isp->xclks); ++i)
302 isp->xclks[i].clk = ERR_PTR(-EINVAL);
304 for (i = 0; i < ARRAY_SIZE(isp->xclks); ++i) {
305 struct isp_xclk *xclk = &isp->xclks[i];
307 xclk->isp = isp;
308 xclk->id = i == 0 ? ISP_XCLK_A : ISP_XCLK_B;
309 xclk->divider = 1;
310 spin_lock_init(&xclk->lock);
317 xclk->hw.init = &init;
324 xclk->clk = clk_register(NULL, &xclk->hw);
325 if (IS_ERR(xclk->clk))
326 return PTR_ERR(xclk->clk);
337 struct device_node *np = isp->dev->of_node;
343 for (i = 0; i < ARRAY_SIZE(isp->xclks); ++i) {
344 struct isp_xclk *xclk = &isp->xclks[i];
346 if (!IS_ERR(xclk->clk))
347 clk_unregister(xclk->clk);
351 /* -----------------------------------------------------------------------------
356 * isp_enable_interrupts - Enable ISP interrupts.
379 * isp_disable_interrupts - Disable ISP interrupts.
388 * isp_core_init - ISP core settings
396 * enabled, as the sensor might be free-running and the ISP default setting
405 ((isp->revision == ISP_REVISION_15_0) ?
410 (isp->autoidle ? ISPCTRL_SBL_AUTOIDLE : 0) |
429 unsigned int shift, unsigned int bridge)
443 ispctrl_val |= parcfg->clk_pol << ISPCTRL_PAR_CLK_POL_SHIFT;
444 shift += parcfg->data_lane_shift;
463 ispctrl_val |= ((shift/2) << ISPCTRL_SHIFT_SHIFT) & ISPCTRL_SHIFT_MASK;
470 if (omap3isp_ccdc_busy(&isp->isp_ccdc) ||
471 omap3isp_stat_pcr_busy(&isp->isp_hist)) {
473 atomic_set(&isp->isp_hist.buf_err, 1);
474 dev_dbg(isp->dev,
518 dev_dbg(isp->dev, "ISP IRQ: ");
529 struct device *dev = isp->dev;
545 pipe = to_isp_pipeline(&isp->isp_ccp2.subdev.entity);
547 pipe->error = true;
551 pipe = to_isp_pipeline(&isp->isp_csi2a.subdev.entity);
553 pipe->error = true;
557 pipe = to_isp_pipeline(&isp->isp_ccdc.subdev.entity);
559 pipe->error = true;
563 pipe = to_isp_pipeline(&isp->isp_prev.subdev.entity);
565 pipe->error = true;
572 pipe = to_isp_pipeline(&isp->isp_res.subdev.entity);
574 pipe->error = true;
578 omap3isp_stat_sbl_overflow(&isp->isp_af);
581 omap3isp_stat_sbl_overflow(&isp->isp_aewb);
585 * isp_isr - Interrupt Service Routine for Camera ISP module.
607 omap3isp_csi2_isr(&isp->isp_csi2a);
610 omap3isp_ccp2_isr(&isp->isp_ccp2);
613 if (isp->isp_ccdc.output & CCDC_OUTPUT_PREVIEW)
614 omap3isp_preview_isr_frame_sync(&isp->isp_prev);
615 if (isp->isp_ccdc.output & CCDC_OUTPUT_RESIZER)
616 omap3isp_resizer_isr_frame_sync(&isp->isp_res);
617 omap3isp_stat_isr_frame_sync(&isp->isp_aewb);
618 omap3isp_stat_isr_frame_sync(&isp->isp_af);
619 omap3isp_stat_isr_frame_sync(&isp->isp_hist);
623 omap3isp_ccdc_isr(&isp->isp_ccdc, irqstatus & ccdc_events);
626 if (isp->isp_prev.output & PREVIEW_OUTPUT_RESIZER)
627 omap3isp_resizer_isr_frame_sync(&isp->isp_res);
628 omap3isp_preview_isr(&isp->isp_prev);
632 omap3isp_resizer_isr(&isp->isp_res);
635 omap3isp_stat_isr(&isp->isp_aewb);
638 omap3isp_stat_isr(&isp->isp_af);
641 omap3isp_stat_isr(&isp->isp_hist);
656 /* -----------------------------------------------------------------------------
661 * isp_pipeline_enable - Enable streaming on a pipeline
674 struct isp_device *isp = pipe->output->isp;
686 if (media_entity_enum_intersects(&pipe->ent_enum, &isp->crashed))
687 return -EIO;
689 spin_lock_irqsave(&pipe->lock, flags);
690 pipe->state &= ~(ISP_PIPELINE_IDLE_INPUT | ISP_PIPELINE_IDLE_OUTPUT);
691 spin_unlock_irqrestore(&pipe->lock, flags);
693 pipe->do_propagation = false;
695 mutex_lock(&isp->media_dev.graph_mutex);
697 entity = &pipe->output->video.entity;
699 pad = &entity->pads[0];
700 if (!(pad->flags & MEDIA_PAD_FL_SINK))
704 if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
707 entity = pad->entity;
711 if (ret < 0 && ret != -ENOIOCTLCMD) {
712 mutex_unlock(&isp->media_dev.graph_mutex);
716 if (subdev == &isp->isp_ccdc.subdev) {
717 v4l2_subdev_call(&isp->isp_aewb.subdev, video,
719 v4l2_subdev_call(&isp->isp_af.subdev, video,
721 v4l2_subdev_call(&isp->isp_hist.subdev, video,
723 pipe->do_propagation = true;
726 /* Stop at the first external sub-device. */
727 if (subdev->dev != isp->dev)
731 mutex_unlock(&isp->media_dev.graph_mutex);
738 return omap3isp_resizer_busy(&isp->isp_res);
743 return omap3isp_preview_busy(&isp->isp_prev);
748 return omap3isp_stat_busy(&isp->isp_af)
749 || omap3isp_stat_busy(&isp->isp_aewb)
750 || omap3isp_stat_busy(&isp->isp_hist)
751 || omap3isp_ccdc_busy(&isp->isp_ccdc);
770 * isp_pipeline_disable - Disable streaming on a pipeline
777 * Return 0 if all modules have been properly stopped, or -ETIMEDOUT if a module
783 struct isp_device *isp = pipe->output->isp;
794 entity = &pipe->output->video.entity;
796 pad = &entity->pads[0];
797 if (!(pad->flags & MEDIA_PAD_FL_SINK))
801 if (!pad || !is_media_entity_v4l2_subdev(pad->entity))
804 entity = pad->entity;
807 if (subdev == &isp->isp_ccdc.subdev) {
808 v4l2_subdev_call(&isp->isp_aewb.subdev,
810 v4l2_subdev_call(&isp->isp_af.subdev,
812 v4l2_subdev_call(&isp->isp_hist.subdev,
818 /* Stop at the first external sub-device. */
819 if (subdev->dev != isp->dev)
822 if (subdev == &isp->isp_res.subdev)
824 else if (subdev == &isp->isp_prev.subdev)
826 else if (subdev == &isp->isp_ccdc.subdev)
842 dev_info(isp->dev, "Unable to stop %s\n", subdev->name);
843 isp->stop_failure = true;
844 if (subdev == &isp->isp_prev.subdev)
845 media_entity_enum_set(&isp->crashed,
846 &subdev->entity);
847 failure = -ETIMEDOUT;
855 * omap3isp_pipeline_set_stream - Enable/disable streaming on a pipeline
860 * single-shot or continuous mode.
877 pipe->stream_state = state;
883 * omap3isp_pipeline_cancel_stream - Cancel stream on a pipeline
893 if (pipe->input)
894 omap3isp_video_cancel_stream(pipe->input);
895 if (pipe->output)
896 omap3isp_video_cancel_stream(pipe->output);
900 * isp_pipeline_resume - Resume streaming on a pipeline
903 * Resume video output and input and re-enable pipeline.
907 int singleshot = pipe->stream_state == ISP_PIPELINE_STREAM_SINGLESHOT;
909 omap3isp_video_resume(pipe->output, !singleshot);
911 omap3isp_video_resume(pipe->input, 0);
912 isp_pipeline_enable(pipe, pipe->stream_state);
916 * isp_pipeline_suspend - Suspend streaming on a pipeline
927 * isp_pipeline_is_last - Verify if entity has an enabled link to the output
941 if (!pipe || pipe->stream_state == ISP_PIPELINE_STREAM_STOPPED)
943 pad = media_pad_remote_pad_first(&pipe->output->pad);
944 return pad->entity == me;
948 * isp_suspend_module_pipeline - Suspend pipeline to which belongs the module
962 * isp_resume_module_pipeline - Resume pipeline to which belongs the module
976 * isp_suspend_modules - Suspend ISP submodules.
986 omap3isp_stat_suspend(&isp->isp_aewb);
987 omap3isp_stat_suspend(&isp->isp_af);
988 omap3isp_stat_suspend(&isp->isp_hist);
989 isp_suspend_module_pipeline(&isp->isp_res.subdev.entity);
990 isp_suspend_module_pipeline(&isp->isp_prev.subdev.entity);
991 isp_suspend_module_pipeline(&isp->isp_ccdc.subdev.entity);
992 isp_suspend_module_pipeline(&isp->isp_csi2a.subdev.entity);
993 isp_suspend_module_pipeline(&isp->isp_ccp2.subdev.entity);
996 while (omap3isp_stat_busy(&isp->isp_af)
997 || omap3isp_stat_busy(&isp->isp_aewb)
998 || omap3isp_stat_busy(&isp->isp_hist)
999 || omap3isp_preview_busy(&isp->isp_prev)
1000 || omap3isp_resizer_busy(&isp->isp_res)
1001 || omap3isp_ccdc_busy(&isp->isp_ccdc)) {
1003 dev_info(isp->dev, "can't stop modules.\n");
1013 * isp_resume_modules - Resume ISP submodules.
1018 omap3isp_stat_resume(&isp->isp_aewb);
1019 omap3isp_stat_resume(&isp->isp_af);
1020 omap3isp_stat_resume(&isp->isp_hist);
1021 isp_resume_module_pipeline(&isp->isp_res.subdev.entity);
1022 isp_resume_module_pipeline(&isp->isp_prev.subdev.entity);
1023 isp_resume_module_pipeline(&isp->isp_ccdc.subdev.entity);
1024 isp_resume_module_pipeline(&isp->isp_csi2a.subdev.entity);
1025 isp_resume_module_pipeline(&isp->isp_ccp2.subdev.entity);
1029 * isp_reset - Reset ISP with a timeout wait for idle.
1043 dev_alert(isp->dev, "cannot reset ISP\n");
1044 return -ETIMEDOUT;
1049 isp->stop_failure = false;
1050 media_entity_enum_zero(&isp->crashed);
1055 * isp_save_context - Saves the values of the ISP module registers.
1065 for (; next->reg != ISP_TOK_TERM; next++)
1066 next->val = isp_reg_readl(isp, next->mmio_range, next->reg);
1070 * isp_restore_context - Restores the values of the ISP module registers.
1080 for (; next->reg != ISP_TOK_TERM; next++)
1081 isp_reg_writel(isp, next->val, next->mmio_range, next->reg);
1085 * isp_save_ctx - Saves ISP, CCDC, HIST, H3A, PREV, RESZ & MMU context.
1094 omap_iommu_save_ctx(isp->dev);
1098 * isp_restore_ctx - Restores ISP, CCDC, HIST, H3A, PREV, RESZ & MMU context.
1107 omap_iommu_restore_ctx(isp->dev);
1112 /* -----------------------------------------------------------------------------
1129 isp->sbl_resources |= res;
1131 if (isp->sbl_resources & OMAP3_ISP_SBL_CSI1_READ)
1134 if (isp->sbl_resources & OMAP3_ISP_SBL_CCDC_LSC_READ)
1137 if (isp->sbl_resources & OMAP3_ISP_SBL_CSI2C_WRITE)
1140 if (isp->sbl_resources & OMAP3_ISP_SBL_RESIZER_WRITE)
1143 if (isp->sbl_resources & OMAP3_ISP_SBL_WRITE)
1146 if (isp->sbl_resources & OMAP3_ISP_SBL_READ)
1156 isp->sbl_resources &= ~res;
1158 if (!(isp->sbl_resources & OMAP3_ISP_SBL_CSI1_READ))
1161 if (!(isp->sbl_resources & OMAP3_ISP_SBL_CCDC_LSC_READ))
1164 if (!(isp->sbl_resources & OMAP3_ISP_SBL_CSI2C_WRITE))
1167 if (!(isp->sbl_resources & OMAP3_ISP_SBL_RESIZER_WRITE))
1170 if (!(isp->sbl_resources & OMAP3_ISP_SBL_WRITE))
1173 if (!(isp->sbl_resources & OMAP3_ISP_SBL_READ))
1180 * isp_module_sync_idle - Helper to sync module with its idle state
1193 if (pipe->stream_state == ISP_PIPELINE_STREAM_STOPPED ||
1194 (pipe->stream_state == ISP_PIPELINE_STREAM_SINGLESHOT &&
1215 struct isp_video *video = pipe->output;
1217 spin_lock_irqsave(&video->irqlock, flags);
1218 if (video->dmaqueue_flags & ISP_VIDEO_DMAQUEUE_UNDERRUN) {
1219 spin_unlock_irqrestore(&video->irqlock, flags);
1224 spin_unlock_irqrestore(&video->irqlock, flags);
1229 return -ETIMEDOUT;
1237 * omap3isp_module_sync_is_stopping - Helper to verify if module was stopping
1256 /* --------------------------------------------------------------------------
1271 if (isp->subclk_resources &
1275 if (isp->subclk_resources & OMAP3_ISP_SUBCLK_HIST)
1278 if (isp->subclk_resources & OMAP3_ISP_SUBCLK_RESIZER)
1284 if (isp->subclk_resources & OMAP3_ISP_SUBCLK_CCDC)
1287 if (isp->subclk_resources & OMAP3_ISP_SUBCLK_PREVIEW)
1297 isp->subclk_resources |= res;
1305 isp->subclk_resources &= ~res;
1311 * isp_enable_clocks - Enable ISP clocks
1322 r = clk_prepare_enable(isp->clock[ISP_CLK_CAM_ICK]);
1324 dev_err(isp->dev, "failed to enable cam_ick clock\n");
1327 r = clk_set_rate(isp->clock[ISP_CLK_CAM_MCLK], CM_CAM_MCLK_HZ);
1329 dev_err(isp->dev, "clk_set_rate for cam_mclk failed\n");
1332 r = clk_prepare_enable(isp->clock[ISP_CLK_CAM_MCLK]);
1334 dev_err(isp->dev, "failed to enable cam_mclk clock\n");
1337 rate = clk_get_rate(isp->clock[ISP_CLK_CAM_MCLK]);
1339 dev_warn(isp->dev, "unexpected cam_mclk rate:\n"
1342 r = clk_prepare_enable(isp->clock[ISP_CLK_CSI2_FCK]);
1344 dev_err(isp->dev, "failed to enable csi2_fck clock\n");
1350 clk_disable_unprepare(isp->clock[ISP_CLK_CAM_MCLK]);
1352 clk_disable_unprepare(isp->clock[ISP_CLK_CAM_ICK]);
1358 * isp_disable_clocks - Disable ISP clocks
1363 clk_disable_unprepare(isp->clock[ISP_CLK_CAM_ICK]);
1364 clk_disable_unprepare(isp->clock[ISP_CLK_CAM_MCLK]);
1365 clk_disable_unprepare(isp->clock[ISP_CLK_CSI2_FCK]);
1381 clk = devm_clk_get(isp->dev, isp_clocks[i]);
1383 dev_err(isp->dev, "clk_get %s failed\n", isp_clocks[i]);
1387 isp->clock[i] = clk;
1394 * omap3isp_get - Acquire the ISP resource.
1399 * enable clocks and power-up all submodules.
1410 mutex_lock(&isp->isp_mutex);
1411 if (isp->ref_count > 0)
1420 if (isp->has_context)
1428 isp->ref_count++;
1429 mutex_unlock(&isp->isp_mutex);
1440 * omap3isp_put - Release the ISP
1443 * power-down all submodules, disable clocks and free temporary buffers.
1450 mutex_lock(&isp->isp_mutex);
1451 BUG_ON(isp->ref_count == 0);
1452 if (--isp->ref_count == 0) {
1456 isp->has_context = 1;
1461 if (!media_entity_enum_empty(&isp->crashed) ||
1462 isp->stop_failure)
1466 mutex_unlock(&isp->isp_mutex);
1474 /* --------------------------------------------------------------------------
1491 * ISP clocks get disabled in suspend(). Similarly, the clocks are re-enabled in
1502 WARN_ON(mutex_is_locked(&isp->isp_mutex));
1504 if (isp->ref_count == 0)
1520 WARN_ON(mutex_is_locked(&isp->isp_mutex));
1522 if (isp->ref_count)
1532 if (isp->ref_count == 0)
1542 if (isp->ref_count == 0)
1561 media_device_unregister(&isp->media_dev);
1563 omap3isp_csi2_unregister_entities(&isp->isp_csi2a);
1564 omap3isp_ccp2_unregister_entities(&isp->isp_ccp2);
1565 omap3isp_ccdc_unregister_entities(&isp->isp_ccdc);
1566 omap3isp_preview_unregister_entities(&isp->isp_prev);
1567 omap3isp_resizer_unregister_entities(&isp->isp_res);
1568 omap3isp_stat_unregister_entities(&isp->isp_aewb);
1569 omap3isp_stat_unregister_entities(&isp->isp_af);
1570 omap3isp_stat_unregister_entities(&isp->isp_hist);
1572 v4l2_device_unregister(&isp->v4l2_dev);
1573 media_device_cleanup(&isp->media_dev);
1592 input = &isp->isp_ccdc.subdev.entity;
1598 input = &isp->isp_csi2a.subdev.entity;
1605 input = &isp->isp_ccp2.subdev.entity;
1611 input = &isp->isp_csi2c.subdev.entity;
1617 dev_err(isp->dev, "%s: invalid interface type %u\n", __func__,
1619 return -EINVAL;
1624 * ISP. The sub-devices of those interfaces aren't initialised
1626 * non-zero.
1628 if (!input->num_pads) {
1629 dev_err(isp->dev, "%s: invalid input %u\n", entity->name,
1631 return -EINVAL;
1634 for (i = 0; i < entity->num_pads; i++) {
1635 if (entity->pads[i].flags & MEDIA_PAD_FL_SOURCE)
1638 if (i == entity->num_pads) {
1639 dev_err(isp->dev, "%s: no source pad in external entity %s\n",
1640 __func__, entity->name);
1641 return -EINVAL;
1651 isp->media_dev.dev = isp->dev;
1652 strscpy(isp->media_dev.model, "TI OMAP3 ISP",
1653 sizeof(isp->media_dev.model));
1654 isp->media_dev.hw_revision = isp->revision;
1655 isp->media_dev.ops = &isp_media_ops;
1656 media_device_init(&isp->media_dev);
1658 isp->v4l2_dev.mdev = &isp->media_dev;
1659 ret = v4l2_device_register(isp->dev, &isp->v4l2_dev);
1661 dev_err(isp->dev, "%s: V4L2 device registration failed (%d)\n",
1667 ret = omap3isp_ccp2_register_entities(&isp->isp_ccp2, &isp->v4l2_dev);
1671 ret = omap3isp_csi2_register_entities(&isp->isp_csi2a, &isp->v4l2_dev);
1675 ret = omap3isp_ccdc_register_entities(&isp->isp_ccdc, &isp->v4l2_dev);
1679 ret = omap3isp_preview_register_entities(&isp->isp_prev,
1680 &isp->v4l2_dev);
1684 ret = omap3isp_resizer_register_entities(&isp->isp_res, &isp->v4l2_dev);
1688 ret = omap3isp_stat_register_entities(&isp->isp_aewb, &isp->v4l2_dev);
1692 ret = omap3isp_stat_register_entities(&isp->isp_af, &isp->v4l2_dev);
1696 ret = omap3isp_stat_register_entities(&isp->isp_hist, &isp->v4l2_dev);
1708 * isp_create_links() - Create links for internal and external ISP entities
1722 &isp->isp_csi2a.subdev.entity, CSI2_PAD_SOURCE,
1723 &isp->isp_csi2a.video_out.video.entity, 0, 0);
1728 &isp->isp_ccp2.video_in.video.entity, 0,
1729 &isp->isp_ccp2.subdev.entity, CCP2_PAD_SINK, 0);
1734 &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_OF,
1735 &isp->isp_ccdc.video_out.video.entity, 0, 0);
1740 &isp->isp_prev.video_in.video.entity, 0,
1741 &isp->isp_prev.subdev.entity, PREV_PAD_SINK, 0);
1746 &isp->isp_prev.subdev.entity, PREV_PAD_SOURCE,
1747 &isp->isp_prev.video_out.video.entity, 0, 0);
1752 &isp->isp_res.video_in.video.entity, 0,
1753 &isp->isp_res.subdev.entity, RESZ_PAD_SINK, 0);
1758 &isp->isp_res.subdev.entity, RESZ_PAD_SOURCE,
1759 &isp->isp_res.video_out.video.entity, 0, 0);
1766 &isp->isp_csi2a.subdev.entity, CSI2_PAD_SOURCE,
1767 &isp->isp_ccdc.subdev.entity, CCDC_PAD_SINK, 0);
1772 &isp->isp_ccp2.subdev.entity, CCP2_PAD_SOURCE,
1773 &isp->isp_ccdc.subdev.entity, CCDC_PAD_SINK, 0);
1778 &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_VP,
1779 &isp->isp_prev.subdev.entity, PREV_PAD_SINK, 0);
1784 &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_OF,
1785 &isp->isp_res.subdev.entity, RESZ_PAD_SINK, 0);
1790 &isp->isp_prev.subdev.entity, PREV_PAD_SOURCE,
1791 &isp->isp_res.subdev.entity, RESZ_PAD_SINK, 0);
1796 &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_VP,
1797 &isp->isp_aewb.subdev.entity, 0,
1803 &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_VP,
1804 &isp->isp_af.subdev.entity, 0,
1810 &isp->isp_ccdc.subdev.entity, CCDC_PAD_SOURCE_VP,
1811 &isp->isp_hist.subdev.entity, 0,
1838 dev_err(isp->dev, "CSI PHY initialization failed\n");
1844 dev_err(isp->dev, "CSI2 initialization failed\n");
1850 dev_err_probe(isp->dev, ret, "CCP2 initialization failed\n");
1856 dev_err(isp->dev, "CCDC initialization failed\n");
1862 dev_err(isp->dev, "Preview initialization failed\n");
1868 dev_err(isp->dev, "Resizer initialization failed\n");
1874 dev_err(isp->dev, "Histogram initialization failed\n");
1880 dev_err(isp->dev, "H3A AEWB initialization failed\n");
1886 dev_err(isp->dev, "H3A AF initialization failed\n");
1915 arm_iommu_detach_device(isp->dev);
1916 arm_iommu_release_mapping(isp->mapping);
1917 isp->mapping = NULL;
1928 mapping = to_dma_iommu_mapping(isp->dev);
1930 arm_iommu_detach_device(isp->dev);
1938 mapping = arm_iommu_create_mapping(isp->dev, SZ_1G, SZ_2G);
1940 dev_err(isp->dev, "failed to create ARM IOMMU mapping\n");
1944 isp->mapping = mapping;
1947 ret = arm_iommu_attach_device(isp->dev, mapping);
1949 dev_err(isp->dev, "failed to attach device to VA mapping\n");
1956 arm_iommu_release_mapping(isp->mapping);
1957 isp->mapping = NULL;
1960 return -ENODEV;
1965 * isp_remove - Remove ISP platform device
1974 v4l2_async_nf_unregister(&isp->notifier);
1975 v4l2_async_nf_cleanup(&isp->notifier);
1984 media_entity_enum_cleanup(&isp->crashed);
2002 &container_of(asc, struct isp_async_subdev, asd)->bus;
2005 mutex_lock(&isp->media_dev.graph_mutex);
2006 ret = isp_link_entity(isp, &sd->entity, bus_cfg->interface);
2007 mutex_unlock(&isp->media_dev.graph_mutex);
2018 mutex_lock(&isp->media_dev.graph_mutex);
2019 ret = media_entity_enum_init(&isp->crashed, &isp->media_dev);
2020 mutex_unlock(&isp->media_dev.graph_mutex);
2024 ret = v4l2_device_register_subdev_nodes(&isp->v4l2_dev);
2028 return media_device_register(&isp->media_dev);
2035 buscfg->interface = ISP_INTERFACE_PARALLEL;
2036 buscfg->bus.parallel.data_lane_shift = vep->bus.parallel.data_shift;
2037 buscfg->bus.parallel.clk_pol =
2038 !!(vep->bus.parallel.flags & V4L2_MBUS_PCLK_SAMPLE_FALLING);
2039 buscfg->bus.parallel.hs_pol =
2040 !!(vep->bus.parallel.flags & V4L2_MBUS_VSYNC_ACTIVE_LOW);
2041 buscfg->bus.parallel.vs_pol =
2042 !!(vep->bus.parallel.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW);
2043 buscfg->bus.parallel.fld_pol =
2044 !!(vep->bus.parallel.flags & V4L2_MBUS_FIELD_EVEN_LOW);
2045 buscfg->bus.parallel.data_pol =
2046 !!(vep->bus.parallel.flags & V4L2_MBUS_DATA_ACTIVE_LOW);
2047 buscfg->bus.parallel.bt656 = vep->bus_type == V4L2_MBUS_BT656;
2056 buscfg->bus.csi2.lanecfg.clk.pos = vep->bus.mipi_csi2.clock_lane;
2057 buscfg->bus.csi2.lanecfg.clk.pol =
2058 vep->bus.mipi_csi2.lane_polarities[0];
2060 buscfg->bus.csi2.lanecfg.clk.pol,
2061 buscfg->bus.csi2.lanecfg.clk.pos);
2063 buscfg->bus.csi2.num_data_lanes = vep->bus.mipi_csi2.num_data_lanes;
2065 for (i = 0; i < buscfg->bus.csi2.num_data_lanes; i++) {
2066 buscfg->bus.csi2.lanecfg.data[i].pos =
2067 vep->bus.mipi_csi2.data_lanes[i];
2068 buscfg->bus.csi2.lanecfg.data[i].pol =
2069 vep->bus.mipi_csi2.lane_polarities[i + 1];
2072 buscfg->bus.csi2.lanecfg.data[i].pol,
2073 buscfg->bus.csi2.lanecfg.data[i].pos);
2079 buscfg->bus.csi2.crc = 1;
2086 buscfg->bus.ccp2.lanecfg.clk.pos = vep->bus.mipi_csi1.clock_lane;
2087 buscfg->bus.ccp2.lanecfg.clk.pol = vep->bus.mipi_csi1.lane_polarity[0];
2089 buscfg->bus.ccp2.lanecfg.clk.pol,
2090 buscfg->bus.ccp2.lanecfg.clk.pos);
2092 buscfg->bus.ccp2.lanecfg.data[0].pos = vep->bus.mipi_csi1.data_lane;
2093 buscfg->bus.ccp2.lanecfg.data[0].pol =
2094 vep->bus.mipi_csi1.lane_polarity[1];
2097 buscfg->bus.ccp2.lanecfg.data[0].pol,
2098 buscfg->bus.ccp2.lanecfg.data[0].pos);
2100 buscfg->bus.ccp2.strobe_clk_pol = vep->bus.mipi_csi1.clock_inv;
2101 buscfg->bus.ccp2.phy_layer = vep->bus.mipi_csi1.strobe;
2102 buscfg->bus.ccp2.ccp2_mode = vep->bus_type == V4L2_MBUS_CCP2;
2103 buscfg->bus.ccp2.vp_clk_pol = 1;
2105 buscfg->bus.ccp2.crc = 1;
2126 dev_fwnode(isp->dev), ISP_OF_PHY_PARALLEL, 0,
2135 dev_dbg(isp->dev, "parsing parallel interface\n");
2140 isd = v4l2_async_nf_add_fwnode_remote(&isp->notifier,
2144 isp_parse_of_parallel_endpoint(isp->dev, &vep, &isd->bus);
2157 dev_fwnode(isp->dev), isp_bus_interfaces[i].phy, 0,
2163 dev_dbg(isp->dev, "parsing serial interface %u, node %pOF\n", i,
2167 if (ret == -ENXIO) {
2172 if (ret == -ENXIO) {
2180 isd = v4l2_async_nf_add_fwnode_remote(&isp->notifier,
2188 isd->bus.interface =
2190 isp_parse_of_csi2_endpoint(isp->dev, &vep, &isd->bus);
2194 isd->bus.interface =
2196 isp_parse_of_csi1_endpoint(isp->dev, &vep,
2197 &isd->bus);
2217 * isp_probe - Probe ISP platform device
2221 * -ENOMEM if no memory available,
2222 * -ENODEV if no platform device resources found
2224 * -EINVAL if couldn't install ISR,
2236 dev_err(&pdev->dev, "could not allocate memory\n");
2237 return -ENOMEM;
2240 ret = fwnode_property_read_u32(of_fwnode_handle(pdev->dev.of_node),
2241 "ti,phy-type", &isp->phy_type);
2245 isp->syscon = syscon_regmap_lookup_by_phandle_args(pdev->dev.of_node,
2247 &isp->syscon_offset);
2248 if (IS_ERR(isp->syscon)) {
2249 ret = PTR_ERR(isp->syscon);
2253 isp->autoidle = autoidle;
2255 mutex_init(&isp->isp_mutex);
2256 spin_lock_init(&isp->stat_lock);
2257 isp->dev = &pdev->dev;
2259 isp->ref_count = 0;
2261 ret = dma_coerce_mask_and_coherent(isp->dev, DMA_BIT_MASK(32));
2268 isp->isp_csiphy1.vdd = devm_regulator_get(&pdev->dev, "vdd-csiphy1");
2269 if (IS_ERR(isp->isp_csiphy1.vdd)) {
2270 ret = PTR_ERR(isp->isp_csiphy1.vdd);
2274 isp->isp_csiphy2.vdd = devm_regulator_get(&pdev->dev, "vdd-csiphy2");
2275 if (IS_ERR(isp->isp_csiphy2.vdd)) {
2276 ret = PTR_ERR(isp->isp_csiphy2.vdd);
2282 * The ISP clock tree is revision-dependent. We thus need to enable ICLK
2293 isp->mmio_base[map_idx] =
2295 if (IS_ERR(isp->mmio_base[map_idx])) {
2296 ret = PTR_ERR(isp->mmio_base[map_idx]);
2305 ret = clk_enable(isp->clock[ISP_CLK_CAM_ICK]);
2309 isp->revision = isp_reg_readl(isp, OMAP3_ISP_IOMEM_MAIN, ISP_REVISION);
2310 dev_info(isp->dev, "Revision %d.%d found\n",
2311 (isp->revision & 0xf0) >> 4, isp->revision & 0x0f);
2313 clk_disable(isp->clock[ISP_CLK_CAM_ICK]);
2316 ret = -ENODEV;
2330 if (isp->revision == isp_res_maps[m].isp_rev)
2334 dev_err(isp->dev, "No resource map found for ISP rev %d.%d\n",
2335 (isp->revision & 0xf0) >> 4, isp->revision & 0xf);
2336 ret = -ENODEV;
2341 isp->mmio_base[i] =
2342 isp->mmio_base[0] + isp_res_maps[m].offset[i];
2345 isp->mmio_base[i] =
2346 isp->mmio_base[OMAP3_ISP_IOMEM_CSI2A_REGS1]
2349 isp->mmio_hist_base_phys =
2350 mem->start + isp_res_maps[m].offset[OMAP3_ISP_IOMEM_HIST];
2355 dev_err(&pdev->dev, "unable to attach to IOMMU\n");
2363 isp->irq_num = ret;
2365 if (devm_request_irq(isp->dev, isp->irq_num, isp_isr, IRQF_SHARED,
2367 dev_err(isp->dev, "Unable to request IRQ\n");
2368 ret = -EINVAL;
2385 isp->notifier.ops = &isp_subdev_notifier_ops;
2387 v4l2_async_nf_init(&isp->notifier, &isp->v4l2_dev);
2393 ret = v4l2_async_nf_register(&isp->notifier);
2403 v4l2_async_nf_cleanup(&isp->notifier);
2413 mutex_destroy(&isp->isp_mutex);
2434 { .compatible = "ti,omap3-isp" },