• Home
  • Raw
  • Download

Lines Matching full:cal

3  * TI Camera Access Layer (CAL) - Driver
30 #include "cal.h"
33 MODULE_DESCRIPTION("TI CAL driver");
130 void cal_quickdump_regs(struct cal_dev *cal) in cal_quickdump_regs() argument
134 cal_info(cal, "CAL Registers @ 0x%pa:\n", &cal->res->start); in cal_quickdump_regs()
136 (__force const void *)cal->base, in cal_quickdump_regs()
137 resource_size(cal->res), false); in cal_quickdump_regs()
139 for (i = 0; i < ARRAY_SIZE(cal->phy); ++i) { in cal_quickdump_regs()
140 struct cal_camerarx *phy = cal->phy[i]; in cal_quickdump_regs()
145 cal_info(cal, "CSI2 Core %u Registers @ %pa:\n", i, in cal_quickdump_regs()
163 val = cal_read(ctx->cal, CAL_CSI2_CTX0(ctx->index)); in cal_ctx_csi2_config()
179 cal_write(ctx->cal, CAL_CSI2_CTX0(ctx->index), val); in cal_ctx_csi2_config()
181 cal_read(ctx->cal, CAL_CSI2_CTX0(ctx->index))); in cal_ctx_csi2_config()
215 dev_warn_once(ctx->cal->dev, in cal_ctx_pix_proc_config()
223 val = cal_read(ctx->cal, CAL_PIX_PROC(ctx->index)); in cal_ctx_pix_proc_config()
230 cal_write(ctx->cal, CAL_PIX_PROC(ctx->index), val); in cal_ctx_pix_proc_config()
232 cal_read(ctx->cal, CAL_PIX_PROC(ctx->index))); in cal_ctx_pix_proc_config()
240 val = cal_read(ctx->cal, CAL_WR_DMA_CTRL(ctx->index)); in cal_ctx_wr_dma_config()
250 cal_write(ctx->cal, CAL_WR_DMA_CTRL(ctx->index), val); in cal_ctx_wr_dma_config()
252 cal_read(ctx->cal, CAL_WR_DMA_CTRL(ctx->index))); in cal_ctx_wr_dma_config()
258 cal_write_field(ctx->cal, in cal_ctx_wr_dma_config()
263 cal_read(ctx->cal, CAL_WR_DMA_OFST(ctx->index))); in cal_ctx_wr_dma_config()
265 val = cal_read(ctx->cal, CAL_WR_DMA_XSIZE(ctx->index)); in cal_ctx_wr_dma_config()
274 cal_write(ctx->cal, CAL_WR_DMA_XSIZE(ctx->index), val); in cal_ctx_wr_dma_config()
276 cal_read(ctx->cal, CAL_WR_DMA_XSIZE(ctx->index))); in cal_ctx_wr_dma_config()
278 val = cal_read(ctx->cal, CAL_CTRL); in cal_ctx_wr_dma_config()
286 cal_write(ctx->cal, CAL_CTRL, val); in cal_ctx_wr_dma_config()
287 ctx_dbg(3, ctx, "CAL_CTRL = 0x%08x\n", cal_read(ctx->cal, CAL_CTRL)); in cal_ctx_wr_dma_config()
292 cal_write(ctx->cal, CAL_WR_DMA_ADDR(ctx->index), dmaaddr); in cal_ctx_wr_dma_addr()
326 struct cal_dev *cal = data; in cal_irq() local
331 status = cal_read(cal, CAL_HL_IRQSTATUS(0)); in cal_irq()
335 cal_write(cal, CAL_HL_IRQSTATUS(0), status); in cal_irq()
338 dev_err_ratelimited(cal->dev, "OCPO ERROR\n"); in cal_irq()
342 u32 cio_stat = cal_read(cal, in cal_irq()
345 dev_err_ratelimited(cal->dev, in cal_irq()
348 cal_write(cal, CAL_CSI2_COMPLEXIO_IRQSTATUS(i), in cal_irq()
355 status = cal_read(cal, CAL_HL_IRQSTATUS(1)); in cal_irq()
360 cal_write(cal, CAL_HL_IRQSTATUS(1), status); in cal_irq()
362 for (i = 0; i < ARRAY_SIZE(cal->ctx); ++i) { in cal_irq()
364 ctx = cal->ctx[i]; in cal_irq()
378 status = cal_read(cal, CAL_HL_IRQSTATUS(2)); in cal_irq()
383 cal_write(cal, CAL_HL_IRQSTATUS(2), status); in cal_irq()
385 for (i = 0; i < ARRAY_SIZE(cal->ctx); ++i) { in cal_irq()
387 ctx = cal->ctx[i]; in cal_irq()
439 struct cal_dev *cal = container_of(notifier, struct cal_dev, notifier); in cal_async_notifier_complete() local
442 for (i = 0; i < ARRAY_SIZE(cal->ctx); ++i) { in cal_async_notifier_complete()
443 if (cal->ctx[i]) in cal_async_notifier_complete()
444 cal_ctx_v4l2_register(cal->ctx[i]); in cal_async_notifier_complete()
455 static int cal_async_notifier_register(struct cal_dev *cal) in cal_async_notifier_register() argument
460 v4l2_async_notifier_init(&cal->notifier); in cal_async_notifier_register()
461 cal->notifier.ops = &cal_async_notifier_ops; in cal_async_notifier_register()
463 for (i = 0; i < ARRAY_SIZE(cal->phy); ++i) { in cal_async_notifier_register()
464 struct cal_camerarx *phy = cal->phy[i]; in cal_async_notifier_register()
473 asd = v4l2_async_notifier_add_fwnode_subdev(&cal->notifier, in cal_async_notifier_register()
486 ret = v4l2_async_notifier_register(&cal->v4l2_dev, &cal->notifier); in cal_async_notifier_register()
488 cal_err(cal, "Error registering async notifier\n"); in cal_async_notifier_register()
495 v4l2_async_notifier_cleanup(&cal->notifier); in cal_async_notifier_register()
499 static void cal_async_notifier_unregister(struct cal_dev *cal) in cal_async_notifier_unregister() argument
501 v4l2_async_notifier_unregister(&cal->notifier); in cal_async_notifier_unregister()
502 v4l2_async_notifier_cleanup(&cal->notifier); in cal_async_notifier_unregister()
514 static int cal_media_register(struct cal_dev *cal) in cal_media_register() argument
518 ret = media_device_register(&cal->mdev); in cal_media_register()
520 cal_err(cal, "Failed to register media device\n"); in cal_media_register()
528 ret = cal_async_notifier_register(cal); in cal_media_register()
530 media_device_unregister(&cal->mdev); in cal_media_register()
541 static void cal_media_unregister(struct cal_dev *cal) in cal_media_unregister() argument
546 for (i = 0; i < ARRAY_SIZE(cal->ctx); i++) { in cal_media_unregister()
547 if (cal->ctx[i]) in cal_media_unregister()
548 cal_ctx_v4l2_unregister(cal->ctx[i]); in cal_media_unregister()
551 cal_async_notifier_unregister(cal); in cal_media_unregister()
552 media_device_unregister(&cal->mdev); in cal_media_unregister()
559 static int cal_media_init(struct cal_dev *cal) in cal_media_init() argument
561 struct media_device *mdev = &cal->mdev; in cal_media_init()
564 mdev->dev = cal->dev; in cal_media_init()
565 mdev->hw_revision = cal->revision; in cal_media_init()
566 strscpy(mdev->model, "CAL", sizeof(mdev->model)); in cal_media_init()
575 cal->v4l2_dev.mdev = mdev; in cal_media_init()
576 ret = v4l2_device_register(cal->dev, &cal->v4l2_dev); in cal_media_init()
578 cal_err(cal, "Failed to register V4L2 device\n"); in cal_media_init()
582 vb2_dma_contig_set_max_seg_size(cal->dev, DMA_BIT_MASK(32)); in cal_media_init()
592 static void cal_media_cleanup(struct cal_dev *cal) in cal_media_cleanup() argument
596 for (i = 0; i < ARRAY_SIZE(cal->ctx); i++) { in cal_media_cleanup()
597 if (cal->ctx[i]) in cal_media_cleanup()
598 cal_ctx_v4l2_cleanup(cal->ctx[i]); in cal_media_cleanup()
601 v4l2_device_unregister(&cal->v4l2_dev); in cal_media_cleanup()
602 media_device_cleanup(&cal->mdev); in cal_media_cleanup()
604 vb2_dma_contig_clear_max_seg_size(cal->dev); in cal_media_cleanup()
612 static struct cal_ctx *cal_ctx_create(struct cal_dev *cal, int inst) in cal_ctx_create() argument
617 ctx = devm_kzalloc(cal->dev, sizeof(*ctx), GFP_KERNEL); in cal_ctx_create()
621 ctx->cal = cal; in cal_ctx_create()
622 ctx->phy = cal->phy[inst]; in cal_ctx_create()
635 .compatible = "ti,dra72-cal",
639 .compatible = "ti,dra72-pre-es2-cal",
643 .compatible = "ti,dra76-cal",
647 .compatible = "ti,am654-cal",
658 static void cal_get_hwinfo(struct cal_dev *cal) in cal_get_hwinfo() argument
662 cal->revision = cal_read(cal, CAL_HL_REVISION); in cal_get_hwinfo()
663 switch (FIELD_GET(CAL_HL_REVISION_SCHEME_MASK, cal->revision)) { in cal_get_hwinfo()
665 cal_dbg(3, cal, "CAL HW revision %lu.%lu.%lu (0x%08x)\n", in cal_get_hwinfo()
666 FIELD_GET(CAL_HL_REVISION_MAJOR_MASK, cal->revision), in cal_get_hwinfo()
667 FIELD_GET(CAL_HL_REVISION_MINOR_MASK, cal->revision), in cal_get_hwinfo()
668 FIELD_GET(CAL_HL_REVISION_RTL_MASK, cal->revision), in cal_get_hwinfo()
669 cal->revision); in cal_get_hwinfo()
674 cal_info(cal, "Unexpected CAL HW revision 0x%08x\n", in cal_get_hwinfo()
675 cal->revision); in cal_get_hwinfo()
679 hwinfo = cal_read(cal, CAL_HL_HWINFO); in cal_get_hwinfo()
681 cal_info(cal, "CAL_HL_HWINFO = 0x%08x, expected 0x%08x\n", in cal_get_hwinfo()
685 static int cal_init_camerarx_regmap(struct cal_dev *cal) in cal_init_camerarx_regmap() argument
687 struct platform_device *pdev = to_platform_device(cal->dev); in cal_init_camerarx_regmap()
688 struct device_node *np = cal->dev->of_node; in cal_init_camerarx_regmap()
698 cal->syscon_camerrx = syscon; in cal_init_camerarx_regmap()
699 cal->syscon_camerrx_offset = offset; in cal_init_camerarx_regmap()
703 dev_warn(cal->dev, "failed to get ti,camerrx-control: %ld\n", in cal_init_camerarx_regmap()
712 base = devm_ioremap_resource(cal->dev, res); in cal_init_camerarx_regmap()
714 cal_err(cal, "failed to ioremap camerrx_control\n"); in cal_init_camerarx_regmap()
718 cal_dbg(1, cal, "ioresource %s at %pa - %pa\n", in cal_init_camerarx_regmap()
736 cal->syscon_camerrx = syscon; in cal_init_camerarx_regmap()
737 cal->syscon_camerrx_offset = 0; in cal_init_camerarx_regmap()
744 struct cal_dev *cal; in cal_probe() local
751 cal = devm_kzalloc(&pdev->dev, sizeof(*cal), GFP_KERNEL); in cal_probe()
752 if (!cal) in cal_probe()
755 cal->data = of_device_get_match_data(&pdev->dev); in cal_probe()
756 if (!cal->data) { in cal_probe()
761 cal->dev = &pdev->dev; in cal_probe()
762 platform_set_drvdata(pdev, cal); in cal_probe()
765 cal->fclk = devm_clk_get(&pdev->dev, "fck"); in cal_probe()
766 if (IS_ERR(cal->fclk)) { in cal_probe()
767 dev_err(&pdev->dev, "cannot get CAL fclk\n"); in cal_probe()
768 return PTR_ERR(cal->fclk); in cal_probe()
771 ret = cal_init_camerarx_regmap(cal); in cal_probe()
775 cal->res = platform_get_resource_byname(pdev, IORESOURCE_MEM, in cal_probe()
777 cal->base = devm_ioremap_resource(&pdev->dev, cal->res); in cal_probe()
778 if (IS_ERR(cal->base)) in cal_probe()
779 return PTR_ERR(cal->base); in cal_probe()
781 cal_dbg(1, cal, "ioresource %s at %pa - %pa\n", in cal_probe()
782 cal->res->name, &cal->res->start, &cal->res->end); in cal_probe()
785 cal_dbg(1, cal, "got irq# %d\n", irq); in cal_probe()
787 cal); in cal_probe()
797 cal_get_hwinfo(cal); in cal_probe()
801 for (i = 0; i < cal->data->num_csi2_phy; ++i) { in cal_probe()
802 cal->phy[i] = cal_camerarx_create(cal, i); in cal_probe()
803 if (IS_ERR(cal->phy[i])) { in cal_probe()
804 ret = PTR_ERR(cal->phy[i]); in cal_probe()
805 cal->phy[i] = NULL; in cal_probe()
809 if (cal->phy[i]->sensor_node) in cal_probe()
814 cal_err(cal, "Neither port is configured, no point in staying up\n"); in cal_probe()
820 ret = cal_media_init(cal); in cal_probe()
825 for (i = 0; i < cal->data->num_csi2_phy; ++i) { in cal_probe()
826 if (!cal->phy[i]->sensor_node) in cal_probe()
829 cal->ctx[i] = cal_ctx_create(cal, i); in cal_probe()
830 if (!cal->ctx[i]) { in cal_probe()
831 cal_err(cal, "Failed to create context %u\n", i); in cal_probe()
838 ret = cal_media_register(cal); in cal_probe()
845 for (i = 0; i < ARRAY_SIZE(cal->ctx); i++) { in cal_probe()
846 ctx = cal->ctx[i]; in cal_probe()
851 cal_media_cleanup(cal); in cal_probe()
854 for (i = 0; i < ARRAY_SIZE(cal->phy); i++) in cal_probe()
855 cal_camerarx_destroy(cal->phy[i]); in cal_probe()
865 struct cal_dev *cal = platform_get_drvdata(pdev); in cal_remove() local
868 cal_dbg(1, cal, "Removing %s\n", CAL_MODULE_NAME); in cal_remove()
872 cal_media_unregister(cal); in cal_remove()
874 for (i = 0; i < ARRAY_SIZE(cal->phy); i++) { in cal_remove()
875 if (cal->phy[i]) in cal_remove()
876 cal_camerarx_disable(cal->phy[i]); in cal_remove()
879 cal_media_cleanup(cal); in cal_remove()
881 for (i = 0; i < ARRAY_SIZE(cal->phy); i++) in cal_remove()
882 cal_camerarx_destroy(cal->phy[i]); in cal_remove()
892 struct cal_dev *cal = dev_get_drvdata(dev); in cal_runtime_resume() local
894 if (cal->data->flags & DRA72_CAL_PRE_ES2_LDO_DISABLE) { in cal_runtime_resume()
899 cal_camerarx_i913_errata(cal->phy[0]); in cal_runtime_resume()
900 cal_camerarx_i913_errata(cal->phy[1]); in cal_runtime_resume()