Lines Matching refs:cal

267 void cal_quickdump_regs(struct cal_dev *cal)  in cal_quickdump_regs()  argument
271 cal_info(cal, "CAL Registers @ 0x%pa:\n", &cal->res->start); in cal_quickdump_regs()
273 (__force const void *)cal->base, in cal_quickdump_regs()
274 resource_size(cal->res), false); in cal_quickdump_regs()
276 for (i = 0; i < cal->data->num_csi2_phy; ++i) { in cal_quickdump_regs()
277 struct cal_camerarx *phy = cal->phy[i]; in cal_quickdump_regs()
279 cal_info(cal, "CSI2 Core %u Registers @ %pa:\n", i, in cal_quickdump_regs()
295 static int cal_reserve_pix_proc(struct cal_dev *cal) in cal_reserve_pix_proc() argument
299 spin_lock(&cal->v4l2_dev.lock); in cal_reserve_pix_proc()
301 ret = find_first_zero_bit(&cal->reserved_pix_proc_mask, CAL_MAX_PIX_PROC); in cal_reserve_pix_proc()
304 spin_unlock(&cal->v4l2_dev.lock); in cal_reserve_pix_proc()
308 cal->reserved_pix_proc_mask |= BIT(ret); in cal_reserve_pix_proc()
310 spin_unlock(&cal->v4l2_dev.lock); in cal_reserve_pix_proc()
315 static void cal_release_pix_proc(struct cal_dev *cal, unsigned int pix_proc_num) in cal_release_pix_proc() argument
317 spin_lock(&cal->v4l2_dev.lock); in cal_release_pix_proc()
319 cal->reserved_pix_proc_mask &= ~BIT(pix_proc_num); in cal_release_pix_proc()
321 spin_unlock(&cal->v4l2_dev.lock); in cal_release_pix_proc()
328 val = cal_read(ctx->cal, CAL_CSI2_CTX(ctx->phy->instance, ctx->csi2_ctx)); in cal_ctx_csi2_config()
344 cal_write(ctx->cal, CAL_CSI2_CTX(ctx->phy->instance, ctx->csi2_ctx), val); in cal_ctx_csi2_config()
347 cal_read(ctx->cal, CAL_CSI2_CTX(ctx->phy->instance, ctx->csi2_ctx))); in cal_ctx_csi2_config()
381 dev_warn_once(ctx->cal->dev, in cal_ctx_pix_proc_config()
389 val = cal_read(ctx->cal, CAL_PIX_PROC(ctx->pix_proc)); in cal_ctx_pix_proc_config()
396 cal_write(ctx->cal, CAL_PIX_PROC(ctx->pix_proc), val); in cal_ctx_pix_proc_config()
398 cal_read(ctx->cal, CAL_PIX_PROC(ctx->pix_proc))); in cal_ctx_pix_proc_config()
406 val = cal_read(ctx->cal, CAL_WR_DMA_CTRL(ctx->dma_ctx)); in cal_ctx_wr_dma_config()
415 cal_write(ctx->cal, CAL_WR_DMA_CTRL(ctx->dma_ctx), val); in cal_ctx_wr_dma_config()
417 cal_read(ctx->cal, CAL_WR_DMA_CTRL(ctx->dma_ctx))); in cal_ctx_wr_dma_config()
419 cal_write_field(ctx->cal, CAL_WR_DMA_OFST(ctx->dma_ctx), in cal_ctx_wr_dma_config()
422 cal_read(ctx->cal, CAL_WR_DMA_OFST(ctx->dma_ctx))); in cal_ctx_wr_dma_config()
424 val = cal_read(ctx->cal, CAL_WR_DMA_XSIZE(ctx->dma_ctx)); in cal_ctx_wr_dma_config()
433 cal_write(ctx->cal, CAL_WR_DMA_XSIZE(ctx->dma_ctx), val); in cal_ctx_wr_dma_config()
435 cal_read(ctx->cal, CAL_WR_DMA_XSIZE(ctx->dma_ctx))); in cal_ctx_wr_dma_config()
440 cal_write(ctx->cal, CAL_WR_DMA_ADDR(ctx->dma_ctx), addr); in cal_ctx_set_dma_addr()
445 u32 val = cal_read(ctx->cal, CAL_WR_DMA_CTRL(ctx->dma_ctx)); in cal_ctx_wr_dma_enable()
449 cal_write(ctx->cal, CAL_WR_DMA_CTRL(ctx->dma_ctx), val); in cal_ctx_wr_dma_enable()
454 u32 val = cal_read(ctx->cal, CAL_WR_DMA_CTRL(ctx->dma_ctx)); in cal_ctx_wr_dma_disable()
458 cal_write(ctx->cal, CAL_WR_DMA_CTRL(ctx->dma_ctx), val); in cal_ctx_wr_dma_disable()
482 dev_err(phy->cal->dev, in cal_get_remote_frame_desc_entry()
488 dev_err(phy->cal->dev, in cal_get_remote_frame_desc_entry()
495 dev_dbg(phy->cal->dev, in cal_get_remote_frame_desc_entry()
526 ret = cal_reserve_pix_proc(ctx->cal); in cal_ctx_prepare()
541 cal_release_pix_proc(ctx->cal, ctx->pix_proc); in cal_ctx_unprepare()
571 cal_write(ctx->cal, CAL_HL_IRQENABLE_SET(1), in cal_ctx_start()
573 cal_write(ctx->cal, CAL_HL_IRQENABLE_SET(2), in cal_ctx_start()
606 cal_write(ctx->cal, CAL_HL_IRQENABLE_CLR(1), in cal_ctx_stop()
608 cal_write(ctx->cal, CAL_HL_IRQENABLE_CLR(2), in cal_ctx_stop()
614 cal_write(ctx->cal, CAL_CSI2_CTX(ctx->phy->instance, ctx->csi2_ctx), 0); in cal_ctx_stop()
618 cal_write(ctx->cal, CAL_PIX_PROC(ctx->pix_proc), 0); in cal_ctx_stop()
633 struct cal_dev *cal = ctx->cal; in cal_update_seq_number() local
639 cal_read(cal, CAL_CSI2_STATUS(phy->instance, ctx->csi2_ctx)) & in cal_update_seq_number()
752 struct cal_dev *cal = data; in cal_irq() local
757 status[i] = cal_read(cal, CAL_HL_IRQSTATUS(i)); in cal_irq()
759 cal_write(cal, CAL_HL_IRQSTATUS(i), status[i]); in cal_irq()
764 dev_err_ratelimited(cal->dev, "OCPO ERROR\n"); in cal_irq()
766 for (i = 0; i < cal->data->num_csi2_phy; ++i) { in cal_irq()
768 u32 cio_stat = cal_read(cal, in cal_irq()
771 dev_err_ratelimited(cal->dev, in cal_irq()
774 cal_write(cal, CAL_CSI2_COMPLEXIO_IRQSTATUS(i), in cal_irq()
779 u32 vc_stat = cal_read(cal, CAL_CSI2_VC_IRQSTATUS(i)); in cal_irq()
781 dev_err_ratelimited(cal->dev, in cal_irq()
785 cal_write(cal, CAL_CSI2_VC_IRQSTATUS(i), vc_stat); in cal_irq()
790 for (i = 0; i < cal->num_contexts; ++i) { in cal_irq()
795 cal_irq_handle_wdma(cal->ctx[i], start, end); in cal_irq()
858 struct cal_dev *cal = container_of(notifier, struct cal_dev, notifier); in cal_async_notifier_complete() local
862 for (i = 0; i < cal->num_contexts; ++i) { in cal_async_notifier_complete()
863 ret = cal_ctx_v4l2_register(cal->ctx[i]); in cal_async_notifier_complete()
871 ret = v4l2_device_register_subdev_nodes(&cal->v4l2_dev); in cal_async_notifier_complete()
879 if (!cal->ctx[i - 1]) in cal_async_notifier_complete()
882 cal_ctx_v4l2_unregister(cal->ctx[i - 1]); in cal_async_notifier_complete()
893 static int cal_async_notifier_register(struct cal_dev *cal) in cal_async_notifier_register() argument
898 v4l2_async_nf_init(&cal->notifier); in cal_async_notifier_register()
899 cal->notifier.ops = &cal_async_notifier_ops; in cal_async_notifier_register()
901 for (i = 0; i < cal->data->num_csi2_phy; ++i) { in cal_async_notifier_register()
902 struct cal_camerarx *phy = cal->phy[i]; in cal_async_notifier_register()
910 casd = v4l2_async_nf_add_fwnode(&cal->notifier, in cal_async_notifier_register()
922 ret = v4l2_async_nf_register(&cal->v4l2_dev, &cal->notifier); in cal_async_notifier_register()
924 cal_err(cal, "Error registering async notifier\n"); in cal_async_notifier_register()
931 v4l2_async_nf_cleanup(&cal->notifier); in cal_async_notifier_register()
935 static void cal_async_notifier_unregister(struct cal_dev *cal) in cal_async_notifier_unregister() argument
937 v4l2_async_nf_unregister(&cal->notifier); in cal_async_notifier_unregister()
938 v4l2_async_nf_cleanup(&cal->notifier); in cal_async_notifier_unregister()
950 static int cal_media_register(struct cal_dev *cal) in cal_media_register() argument
954 ret = media_device_register(&cal->mdev); in cal_media_register()
956 cal_err(cal, "Failed to register media device\n"); in cal_media_register()
964 ret = cal_async_notifier_register(cal); in cal_media_register()
966 media_device_unregister(&cal->mdev); in cal_media_register()
977 static void cal_media_unregister(struct cal_dev *cal) in cal_media_unregister() argument
982 for (i = 0; i < cal->num_contexts; i++) in cal_media_unregister()
983 cal_ctx_v4l2_unregister(cal->ctx[i]); in cal_media_unregister()
985 cal_async_notifier_unregister(cal); in cal_media_unregister()
986 media_device_unregister(&cal->mdev); in cal_media_unregister()
993 static int cal_media_init(struct cal_dev *cal) in cal_media_init() argument
995 struct media_device *mdev = &cal->mdev; in cal_media_init()
998 mdev->dev = cal->dev; in cal_media_init()
999 mdev->hw_revision = cal->revision; in cal_media_init()
1007 cal->v4l2_dev.mdev = mdev; in cal_media_init()
1008 ret = v4l2_device_register(cal->dev, &cal->v4l2_dev); in cal_media_init()
1010 cal_err(cal, "Failed to register V4L2 device\n"); in cal_media_init()
1014 vb2_dma_contig_set_max_seg_size(cal->dev, DMA_BIT_MASK(32)); in cal_media_init()
1024 static void cal_media_cleanup(struct cal_dev *cal) in cal_media_cleanup() argument
1026 v4l2_device_unregister(&cal->v4l2_dev); in cal_media_cleanup()
1027 media_device_cleanup(&cal->mdev); in cal_media_cleanup()
1029 vb2_dma_contig_clear_max_seg_size(cal->dev); in cal_media_cleanup()
1037 static struct cal_ctx *cal_ctx_create(struct cal_dev *cal, int inst) in cal_ctx_create() argument
1046 ctx->cal = cal; in cal_ctx_create()
1047 ctx->phy = cal->phy[inst]; in cal_ctx_create()
1093 static void cal_get_hwinfo(struct cal_dev *cal) in cal_get_hwinfo() argument
1097 cal->revision = cal_read(cal, CAL_HL_REVISION); in cal_get_hwinfo()
1098 switch (FIELD_GET(CAL_HL_REVISION_SCHEME_MASK, cal->revision)) { in cal_get_hwinfo()
1100 cal_dbg(3, cal, "CAL HW revision %lu.%lu.%lu (0x%08x)\n", in cal_get_hwinfo()
1101 FIELD_GET(CAL_HL_REVISION_MAJOR_MASK, cal->revision), in cal_get_hwinfo()
1102 FIELD_GET(CAL_HL_REVISION_MINOR_MASK, cal->revision), in cal_get_hwinfo()
1103 FIELD_GET(CAL_HL_REVISION_RTL_MASK, cal->revision), in cal_get_hwinfo()
1104 cal->revision); in cal_get_hwinfo()
1109 cal_info(cal, "Unexpected CAL HW revision 0x%08x\n", in cal_get_hwinfo()
1110 cal->revision); in cal_get_hwinfo()
1114 hwinfo = cal_read(cal, CAL_HL_HWINFO); in cal_get_hwinfo()
1116 cal_info(cal, "CAL_HL_HWINFO = 0x%08x, expected 0x%08x\n", in cal_get_hwinfo()
1120 static int cal_init_camerarx_regmap(struct cal_dev *cal) in cal_init_camerarx_regmap() argument
1122 struct platform_device *pdev = to_platform_device(cal->dev); in cal_init_camerarx_regmap()
1123 struct device_node *np = cal->dev->of_node; in cal_init_camerarx_regmap()
1133 cal->syscon_camerrx = syscon; in cal_init_camerarx_regmap()
1134 cal->syscon_camerrx_offset = offset; in cal_init_camerarx_regmap()
1138 dev_warn(cal->dev, "failed to get ti,camerrx-control: %ld\n", in cal_init_camerarx_regmap()
1147 base = devm_ioremap_resource(cal->dev, res); in cal_init_camerarx_regmap()
1149 cal_err(cal, "failed to ioremap camerrx_control\n"); in cal_init_camerarx_regmap()
1153 cal_dbg(1, cal, "ioresource %s at %pa - %pa\n", in cal_init_camerarx_regmap()
1171 cal->syscon_camerrx = syscon; in cal_init_camerarx_regmap()
1172 cal->syscon_camerrx_offset = 0; in cal_init_camerarx_regmap()
1179 struct cal_dev *cal; in cal_probe() local
1185 cal = devm_kzalloc(&pdev->dev, sizeof(*cal), GFP_KERNEL); in cal_probe()
1186 if (!cal) in cal_probe()
1189 cal->data = of_device_get_match_data(&pdev->dev); in cal_probe()
1190 if (!cal->data) { in cal_probe()
1195 cal->dev = &pdev->dev; in cal_probe()
1196 platform_set_drvdata(pdev, cal); in cal_probe()
1199 cal->fclk = devm_clk_get(&pdev->dev, "fck"); in cal_probe()
1200 if (IS_ERR(cal->fclk)) { in cal_probe()
1202 return PTR_ERR(cal->fclk); in cal_probe()
1205 ret = cal_init_camerarx_regmap(cal); in cal_probe()
1209 cal->res = platform_get_resource_byname(pdev, IORESOURCE_MEM, in cal_probe()
1211 cal->base = devm_ioremap_resource(&pdev->dev, cal->res); in cal_probe()
1212 if (IS_ERR(cal->base)) in cal_probe()
1213 return PTR_ERR(cal->base); in cal_probe()
1215 cal_dbg(1, cal, "ioresource %s at %pa - %pa\n", in cal_probe()
1216 cal->res->name, &cal->res->start, &cal->res->end); in cal_probe()
1219 cal_dbg(1, cal, "got irq# %d\n", irq); in cal_probe()
1221 cal); in cal_probe()
1231 cal_get_hwinfo(cal); in cal_probe()
1235 ret = cal_media_init(cal); in cal_probe()
1240 for (i = 0; i < cal->data->num_csi2_phy; ++i) { in cal_probe()
1241 cal->phy[i] = cal_camerarx_create(cal, i); in cal_probe()
1242 if (IS_ERR(cal->phy[i])) { in cal_probe()
1243 ret = PTR_ERR(cal->phy[i]); in cal_probe()
1244 cal->phy[i] = NULL; in cal_probe()
1248 if (cal->phy[i]->source_node) in cal_probe()
1253 cal_err(cal, "Neither port is configured, no point in staying up\n"); in cal_probe()
1259 for (i = 0; i < cal->data->num_csi2_phy; ++i) { in cal_probe()
1260 if (!cal->phy[i]->source_node) in cal_probe()
1263 cal->ctx[cal->num_contexts] = cal_ctx_create(cal, i); in cal_probe()
1264 if (!cal->ctx[cal->num_contexts]) { in cal_probe()
1265 cal_err(cal, "Failed to create context %u\n", cal->num_contexts); in cal_probe()
1270 cal->num_contexts++; in cal_probe()
1274 ret = cal_media_register(cal); in cal_probe()
1281 for (i = 0; i < cal->num_contexts; i++) in cal_probe()
1282 cal_ctx_destroy(cal->ctx[i]); in cal_probe()
1285 for (i = 0; i < cal->data->num_csi2_phy; i++) in cal_probe()
1286 cal_camerarx_destroy(cal->phy[i]); in cal_probe()
1288 cal_media_cleanup(cal); in cal_probe()
1298 struct cal_dev *cal = platform_get_drvdata(pdev); in cal_remove() local
1302 cal_dbg(1, cal, "Removing %s\n", CAL_MODULE_NAME); in cal_remove()
1306 cal_media_unregister(cal); in cal_remove()
1308 for (i = 0; i < cal->data->num_csi2_phy; i++) in cal_remove()
1309 cal_camerarx_disable(cal->phy[i]); in cal_remove()
1311 for (i = 0; i < cal->num_contexts; i++) in cal_remove()
1312 cal_ctx_destroy(cal->ctx[i]); in cal_remove()
1314 for (i = 0; i < cal->data->num_csi2_phy; i++) in cal_remove()
1315 cal_camerarx_destroy(cal->phy[i]); in cal_remove()
1317 cal_media_cleanup(cal); in cal_remove()
1328 struct cal_dev *cal = dev_get_drvdata(dev); in cal_runtime_resume() local
1332 if (cal->data->flags & DRA72_CAL_PRE_ES2_LDO_DISABLE) { in cal_runtime_resume()
1337 for (i = 0; i < cal->data->num_csi2_phy; i++) in cal_runtime_resume()
1338 cal_camerarx_i913_errata(cal->phy[i]); in cal_runtime_resume()
1345 cal_write(cal, CAL_HL_IRQENABLE_SET(0), CAL_HL_IRQ_OCPO_ERR_MASK); in cal_runtime_resume()
1347 val = cal_read(cal, CAL_CTRL); in cal_runtime_resume()
1355 cal_write(cal, CAL_CTRL, val); in cal_runtime_resume()
1356 cal_dbg(3, cal, "CAL_CTRL = 0x%08x\n", cal_read(cal, CAL_CTRL)); in cal_runtime_resume()