Lines Matching refs:csi2dc

159  * @csi2dc_sd:		v4l2 subdevice for the csi2dc device
160 * This is the subdevice that the csi2dc device itself
162 * @dev: struct device for this csi2dc device
171 * @pads: Media entity pads for the csi2dc subdevice
177 * subdevice to the csi2dc subdevice
179 * csi2dc subdevice
181 * to the csi2dc subdevice sink pad.
231 struct csi2dc_device *csi2dc = csi2dc_sd_to_csi2dc_device(csi2dc_sd);
242 format->format = csi2dc->format;
251 struct csi2dc_device *csi2dc = csi2dc_sd_to_csi2dc_device(csi2dc_sd);
274 dev_dbg(csi2dc->dev,
298 csi2dc->format = req_fmt->format;
301 csi2dc->cur_fmt = try_fmt;
303 dev_dbg(csi2dc->dev, "new format set: 0x%x @%dx%d\n",
304 csi2dc->format.code, csi2dc->format.width,
305 csi2dc->format.height);
310 static int csi2dc_power(struct csi2dc_device *csi2dc, int on)
315 ret = clk_prepare_enable(csi2dc->pclk);
317 dev_err(csi2dc->dev, "failed to enable pclk:%d\n", ret);
321 ret = clk_prepare_enable(csi2dc->scck);
323 dev_err(csi2dc->dev, "failed to enable scck:%d\n", ret);
324 clk_disable_unprepare(csi2dc->pclk);
329 csi2dc_writel(csi2dc, CSI2DC_GCTLR, CSI2DC_GCTLR_SWRST);
332 csi2dc_writel(csi2dc, CSI2DC_GCTLR, 0);
334 clk_disable_unprepare(csi2dc->scck);
335 clk_disable_unprepare(csi2dc->pclk);
341 static int csi2dc_get_mbus_config(struct csi2dc_device *csi2dc)
346 ret = v4l2_subdev_call(csi2dc->input_sd, pad, get_mbus_config,
347 csi2dc->remote_pad, &mbus_config);
349 dev_dbg(csi2dc->dev,
355 dev_err(csi2dc->dev,
360 dev_dbg(csi2dc->dev, "subdev sending on channel %d\n", csi2dc->vc);
362 csi2dc->clk_gated = mbus_config.bus.parallel.flags &
365 dev_dbg(csi2dc->dev, "mbus_config: %s clock\n",
366 csi2dc->clk_gated ? "gated" : "free running");
371 static void csi2dc_vp_update(struct csi2dc_device *csi2dc)
375 if (!csi2dc->video_pipe) {
376 dev_err(csi2dc->dev, "video pipeline unavailable\n");
380 if (csi2dc->parallel_mode) {
382 gcfg = csi2dc_readl(csi2dc, CSI2DC_GCFG);
384 csi2dc_writel(csi2dc, CSI2DC_GCFG, gcfg);
390 csi2dc_writel(csi2dc, CSI2DC_GCFG,
392 (csi2dc->clk_gated ? 0 : CSI2DC_GCFG_MIPIFRN));
394 vp = CSI2DC_VPCFG_DT(csi2dc->cur_fmt->dt) & CSI2DC_VPCFG_DT_MASK;
395 vp |= CSI2DC_VPCFG_VC(csi2dc->vc) & CSI2DC_VPCFG_VC_MASK;
402 csi2dc_writel(csi2dc, CSI2DC_VPCFG, vp);
403 csi2dc_writel(csi2dc, CSI2DC_VPE, CSI2DC_VPE_ENABLE);
404 csi2dc_writel(csi2dc, CSI2DC_PU, CSI2DC_PU_VP);
409 struct csi2dc_device *csi2dc = csi2dc_sd_to_csi2dc_device(csi2dc_sd);
413 ret = pm_runtime_resume_and_get(csi2dc->dev);
417 csi2dc_get_mbus_config(csi2dc);
419 csi2dc_vp_update(csi2dc);
421 return v4l2_subdev_call(csi2dc->input_sd, video, s_stream,
425 dev_dbg(csi2dc->dev,
427 csi2dc_readl(csi2dc, CSI2DC_VPCOL),
428 csi2dc_readl(csi2dc, CSI2DC_VPROW),
429 csi2dc_readl(csi2dc, CSI2DC_VPISR));
432 ret = v4l2_subdev_call(csi2dc->input_sd, video, s_stream, false);
434 pm_runtime_put_sync(csi2dc->dev);
481 struct csi2dc_device *csi2dc = container_of(notifier,
486 csi2dc->input_sd = subdev;
491 dev_err(csi2dc->dev, "Failed to find pad for %s\n",
496 csi2dc->remote_pad = pad;
498 ret = media_create_pad_link(&csi2dc->input_sd->entity,
499 csi2dc->remote_pad,
500 &csi2dc->csi2dc_sd.entity, 0,
503 dev_err(csi2dc->dev,
505 csi2dc->input_sd->entity.name,
506 csi2dc->csi2dc_sd.entity.name);
510 dev_dbg(csi2dc->dev, "link with %s pad: %d\n",
511 csi2dc->input_sd->name, csi2dc->remote_pad);
520 static int csi2dc_prepare_notifier(struct csi2dc_device *csi2dc,
526 v4l2_async_subdev_nf_init(&csi2dc->notifier, &csi2dc->csi2dc_sd);
528 asd = v4l2_async_nf_add_fwnode_remote(&csi2dc->notifier,
536 dev_err(csi2dc->dev,
539 v4l2_async_nf_cleanup(&csi2dc->notifier);
543 csi2dc->notifier.ops = &csi2dc_async_ops;
545 ret = v4l2_async_nf_register(&csi2dc->notifier);
547 dev_err(csi2dc->dev, "fail to register async notifier: %d\n",
549 v4l2_async_nf_cleanup(&csi2dc->notifier);
555 static int csi2dc_of_parse(struct csi2dc_device *csi2dc,
566 dev_err(csi2dc->dev,
574 dev_err(csi2dc->dev, "endpoint not defined at %pOF\n", of_node);
580 csi2dc->parallel_mode = true;
581 dev_dbg(csi2dc->dev,
586 csi2dc->clk_gated = input_endpoint.bus.mipi_csi2.flags &
588 dev_dbg(csi2dc->dev,
590 dev_dbg(csi2dc->dev, "DT: %s clock\n",
591 csi2dc->clk_gated ? "gated" : "free running");
604 dev_info(csi2dc->dev,
610 dev_err(csi2dc->dev,
616 csi2dc->video_pipe = true;
618 dev_dbg(csi2dc->dev,
626 return csi2dc_prepare_notifier(csi2dc, input_fwnode);
633 static void csi2dc_default_format(struct csi2dc_device *csi2dc)
635 csi2dc->cur_fmt = &csi2dc_formats[0];
637 csi2dc->format.height = 480;
638 csi2dc->format.width = 640;
639 csi2dc->format.code = csi2dc_formats[0].mbus_code;
640 csi2dc->format.colorspace = V4L2_COLORSPACE_SRGB;
641 csi2dc->format.field = V4L2_FIELD_NONE;
642 csi2dc->format.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT;
643 csi2dc->format.quantization = V4L2_QUANTIZATION_DEFAULT;
644 csi2dc->format.xfer_func = V4L2_XFER_FUNC_DEFAULT;
650 struct csi2dc_device *csi2dc;
654 csi2dc = devm_kzalloc(dev, sizeof(*csi2dc), GFP_KERNEL);
655 if (!csi2dc)
658 csi2dc->dev = dev;
660 csi2dc->base = devm_platform_ioremap_resource(pdev, 0);
661 if (IS_ERR(csi2dc->base)) {
663 return PTR_ERR(csi2dc->base);
666 csi2dc->pclk = devm_clk_get(dev, "pclk");
667 if (IS_ERR(csi2dc->pclk)) {
668 ret = PTR_ERR(csi2dc->pclk);
673 csi2dc->scck = devm_clk_get(dev, "scck");
674 if (IS_ERR(csi2dc->scck)) {
675 ret = PTR_ERR(csi2dc->scck);
680 v4l2_subdev_init(&csi2dc->csi2dc_sd, &csi2dc_subdev_ops);
682 csi2dc->csi2dc_sd.owner = THIS_MODULE;
683 csi2dc->csi2dc_sd.dev = dev;
684 snprintf(csi2dc->csi2dc_sd.name, sizeof(csi2dc->csi2dc_sd.name),
685 "csi2dc");
687 csi2dc->csi2dc_sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
688 csi2dc->csi2dc_sd.entity.function = MEDIA_ENT_F_VID_IF_BRIDGE;
689 csi2dc->csi2dc_sd.entity.ops = &csi2dc_entity_ops;
691 platform_set_drvdata(pdev, csi2dc);
693 ret = csi2dc_of_parse(csi2dc, dev->of_node);
697 csi2dc->pads[CSI2DC_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
698 if (csi2dc->video_pipe)
699 csi2dc->pads[CSI2DC_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
701 ret = media_entity_pads_init(&csi2dc->csi2dc_sd.entity,
702 csi2dc->video_pipe ? CSI2DC_PADS_NUM : 1,
703 csi2dc->pads);
709 csi2dc_default_format(csi2dc);
712 ret = csi2dc_power(csi2dc, true);
718 ver = csi2dc_readl(csi2dc, CSI2DC_VERSION);
725 ret = v4l2_async_register_subdev(&csi2dc->csi2dc_sd);
727 dev_err(csi2dc->dev, "failed to register the subdevice\n");
736 v4l2_async_nf_cleanup(&csi2dc->notifier);
738 media_entity_cleanup(&csi2dc->csi2dc_sd.entity);
745 struct csi2dc_device *csi2dc = platform_get_drvdata(pdev);
749 v4l2_async_unregister_subdev(&csi2dc->csi2dc_sd);
750 v4l2_async_nf_unregister(&csi2dc->notifier);
751 v4l2_async_nf_cleanup(&csi2dc->notifier);
752 media_entity_cleanup(&csi2dc->csi2dc_sd.entity);
757 struct csi2dc_device *csi2dc = dev_get_drvdata(dev);
759 return csi2dc_power(csi2dc, false);
764 struct csi2dc_device *csi2dc = dev_get_drvdata(dev);
766 return csi2dc_power(csi2dc, true);
774 { .compatible = "microchip,sama7g5-csi2dc" },
784 .name = "microchip-csi2dc",