Lines Matching refs:isys
105 isys_complete_ext_device_registration(struct ipu6_isys *isys, in isys_complete_ext_device_registration() argument
109 struct device *dev = &isys->adev->auxdev.dev; in isys_complete_ext_device_registration()
125 &isys->csi2[csi2->port].asd.sd.entity, in isys_complete_ext_device_registration()
133 isys->csi2[csi2->port].nlanes = csi2->nlanes; in isys_complete_ext_device_registration()
143 static void isys_stream_init(struct ipu6_isys *isys) in isys_stream_init() argument
148 mutex_init(&isys->streams[i].mutex); in isys_stream_init()
149 init_completion(&isys->streams[i].stream_open_completion); in isys_stream_init()
150 init_completion(&isys->streams[i].stream_close_completion); in isys_stream_init()
151 init_completion(&isys->streams[i].stream_start_completion); in isys_stream_init()
152 init_completion(&isys->streams[i].stream_stop_completion); in isys_stream_init()
153 INIT_LIST_HEAD(&isys->streams[i].queues); in isys_stream_init()
154 isys->streams[i].isys = isys; in isys_stream_init()
155 isys->streams[i].stream_handle = i; in isys_stream_init()
156 isys->streams[i].vc = INVALID_VC_ID; in isys_stream_init()
160 static void isys_csi2_unregister_subdevices(struct ipu6_isys *isys) in isys_csi2_unregister_subdevices() argument
163 &isys->pdata->ipdata->csi2; in isys_csi2_unregister_subdevices()
167 ipu6_isys_csi2_cleanup(&isys->csi2[i]); in isys_csi2_unregister_subdevices()
170 static int isys_csi2_register_subdevices(struct ipu6_isys *isys) in isys_csi2_register_subdevices() argument
173 &isys->pdata->ipdata->csi2; in isys_csi2_register_subdevices()
178 ret = ipu6_isys_csi2_init(&isys->csi2[i], isys, in isys_csi2_register_subdevices()
179 isys->pdata->base + in isys_csi2_register_subdevices()
184 isys->isr_csi2_bits |= IPU6_ISYS_UNISPART_IRQ_CSI2(i); in isys_csi2_register_subdevices()
191 ipu6_isys_csi2_cleanup(&isys->csi2[i]); in isys_csi2_register_subdevices()
196 static int isys_csi2_create_media_links(struct ipu6_isys *isys) in isys_csi2_create_media_links() argument
199 &isys->pdata->ipdata->csi2; in isys_csi2_create_media_links()
200 struct device *dev = &isys->adev->auxdev.dev; in isys_csi2_create_media_links()
205 struct media_entity *sd = &isys->csi2[i].asd.sd.entity; in isys_csi2_create_media_links()
208 struct ipu6_isys_video *av = &isys->csi2[i].av[j]; in isys_csi2_create_media_links()
217 av->csi2 = &isys->csi2[i]; in isys_csi2_create_media_links()
224 static void isys_unregister_video_devices(struct ipu6_isys *isys) in isys_unregister_video_devices() argument
227 &isys->pdata->ipdata->csi2; in isys_unregister_video_devices()
232 ipu6_isys_video_cleanup(&isys->csi2[i].av[j]); in isys_unregister_video_devices()
235 static int isys_register_video_devices(struct ipu6_isys *isys) in isys_register_video_devices() argument
238 &isys->pdata->ipdata->csi2; in isys_register_video_devices()
244 struct ipu6_isys_video *av = &isys->csi2[i].av[j]; in isys_register_video_devices()
249 av->isys = isys; in isys_register_video_devices()
264 ipu6_isys_video_cleanup(&isys->csi2[i].av[j]); in isys_register_video_devices()
271 void isys_setup_hw(struct ipu6_isys *isys) in isys_setup_hw() argument
273 void __iomem *base = isys->pdata->base; in isys_setup_hw()
274 const u8 *thd = isys->pdata->ipdata->hw_variant.cdc_fifo_threshold; in isys_setup_hw()
278 nports = isys->pdata->ipdata->csi2.nports; in isys_setup_hw()
284 writel(irqs, base + isys->pdata->ipdata->csi2.ctrl0_irq_edge); in isys_setup_hw()
285 writel(irqs, base + isys->pdata->ipdata->csi2.ctrl0_irq_lnp); in isys_setup_hw()
286 writel(irqs, base + isys->pdata->ipdata->csi2.ctrl0_irq_mask); in isys_setup_hw()
287 writel(irqs, base + isys->pdata->ipdata->csi2.ctrl0_irq_enable); in isys_setup_hw()
289 base + isys->pdata->ipdata->csi2.ctrl0_irq_clear); in isys_setup_hw()
302 for (i = 0; i < isys->pdata->ipdata->hw_variant.cdc_fifos; i++) in isys_setup_hw()
324 stream = ipu6_isys_query_stream_by_source(csi2->isys, in ipu6_isys_csi2_isr()
333 stream = ipu6_isys_query_stream_by_source(csi2->isys, in ipu6_isys_csi2_isr()
345 struct ipu6_isys *isys = ipu6_bus_get_drvdata(adev); in isys_isr() local
346 void __iomem *base = isys->pdata->base; in isys_isr()
350 spin_lock(&isys->power_lock); in isys_isr()
351 if (!isys->power) { in isys_isr()
352 spin_unlock(&isys->power_lock); in isys_isr()
356 ctrl0_status = isys->pdata->ipdata->csi2.ctrl0_irq_status; in isys_isr()
357 ctrl0_clear = isys->pdata->ipdata->csi2.ctrl0_irq_clear; in isys_isr()
359 status_csi = readl(isys->pdata->base + ctrl0_status); in isys_isr()
360 status_sw = readl(isys->pdata->base + in isys_isr()
367 writel(status_csi, isys->pdata->base + ctrl0_clear); in isys_isr()
369 writel(status_sw, isys->pdata->base + in isys_isr()
372 if (isys->isr_csi2_bits & status_csi) { in isys_isr()
375 for (i = 0; i < isys->pdata->ipdata->csi2.nports; i++) { in isys_isr()
377 if (!isys->csi2[i].base) in isys_isr()
380 ipu6_isys_csi2_isr(&isys->csi2[i]); in isys_isr()
391 status_csi = readl(isys->pdata->base + ctrl0_status); in isys_isr()
392 status_sw |= readl(isys->pdata->base + in isys_isr()
394 } while ((status_csi & isys->isr_csi2_bits) || in isys_isr()
399 spin_unlock(&isys->power_lock); in isys_isr()
404 static void get_lut_ltrdid(struct ipu6_isys *isys, struct ltr_did *pltr_did) in get_lut_ltrdid() argument
406 struct isys_iwake_watermark *iwake_watermark = &isys->iwake_watermark; in get_lut_ltrdid()
418 static int set_iwake_register(struct ipu6_isys *isys, u32 index, u32 value) in set_iwake_register() argument
420 struct device *dev = &isys->adev->auxdev.dev; in set_iwake_register()
425 ret = ipu6_fw_isys_send_proxy_token(isys, req_id, index, offset, value); in set_iwake_register()
447 static void set_iwake_ltrdid(struct ipu6_isys *isys, u16 ltr, u16 did, in set_iwake_ltrdid() argument
450 struct device *dev = &isys->adev->auxdev.dev; in set_iwake_ltrdid()
453 struct ipu6_device *isp = isys->adev->isp; in set_iwake_ltrdid()
511 static void enable_iwake(struct ipu6_isys *isys, bool enable) in enable_iwake() argument
513 struct isys_iwake_watermark *iwake_watermark = &isys->iwake_watermark; in enable_iwake()
523 ret = set_iwake_register(isys, GDA_ENABLE_IWAKE_INDEX, enable); in enable_iwake()
530 void update_watermark_setting(struct ipu6_isys *isys) in update_watermark_setting() argument
532 struct isys_iwake_watermark *iwake_watermark = &isys->iwake_watermark; in update_watermark_setting()
534 struct device *dev = &isys->adev->auxdev.dev; in update_watermark_setting()
546 shift = isys->pdata->ipdata->sram_gran_shift; in update_watermark_setting()
547 max_sram_size = isys->pdata->ipdata->max_sram_size; in update_watermark_setting()
551 set_iwake_ltrdid(isys, 0, 0, LTR_IWAKE_OFF); in update_watermark_setting()
552 set_iwake_register(isys, GDA_IRQ_CRITICAL_THRESHOLD_INDEX, in update_watermark_setting()
570 enable_iwake(isys, false); in update_watermark_setting()
571 set_iwake_ltrdid(isys, 0, 0, LTR_IWAKE_OFF); in update_watermark_setting()
573 set_iwake_register(isys, GDA_IRQ_CRITICAL_THRESHOLD_INDEX, in update_watermark_setting()
578 enable_iwake(isys, true); in update_watermark_setting()
581 if (isys->pdata->ipdata->enhanced_iwake) { in update_watermark_setting()
582 ltr = isys->pdata->ipdata->ltr; in update_watermark_setting()
586 get_lut_ltrdid(isys, <rdid); in update_watermark_setting()
603 set_iwake_ltrdid(isys, ltr, did, ltr_did_type); in update_watermark_setting()
611 if (isys->pdata->ipdata->enhanced_iwake) { in update_watermark_setting()
612 set_iwake_register(isys, GDA_IWAKE_THRESHOLD_INDEX, in update_watermark_setting()
619 mem_open_threshold = isys->pdata->ipdata->memopen_threshold; in update_watermark_setting()
622 set_iwake_register(isys, GDA_MEMOPEN_THRESHOLD_INDEX, in update_watermark_setting()
625 set_iwake_register(isys, GDA_IWAKE_THRESHOLD_INDEX, in update_watermark_setting()
635 set_iwake_register(isys, GDA_IRQ_CRITICAL_THRESHOLD_INDEX, in update_watermark_setting()
639 isys->adev->isp->base + REG_PKGC_PMON_CFG); in update_watermark_setting()
641 isys->adev->isp->base + REG_PKGC_PMON_CFG); in update_watermark_setting()
646 static void isys_iwake_watermark_init(struct ipu6_isys *isys) in isys_iwake_watermark_init() argument
648 struct isys_iwake_watermark *iwake_watermark = &isys->iwake_watermark; in isys_iwake_watermark_init()
654 iwake_watermark->isys = isys; in isys_iwake_watermark_init()
659 static void isys_iwake_watermark_cleanup(struct ipu6_isys *isys) in isys_iwake_watermark_cleanup() argument
661 struct isys_iwake_watermark *iwake_watermark = &isys->iwake_watermark; in isys_iwake_watermark_cleanup()
675 struct ipu6_isys *isys = in isys_notifier_bound() local
681 if (s_asd->csi2.port >= isys->pdata->ipdata->csi2.nports) { in isys_notifier_bound()
682 dev_err(&isys->adev->auxdev.dev, "invalid csi2 port %u\n", in isys_notifier_bound()
689 dev_err(&isys->adev->auxdev.dev, "instantiate vcm failed\n"); in isys_notifier_bound()
693 dev_dbg(&isys->adev->auxdev.dev, "bind %s nlanes is %d port is %d\n", in isys_notifier_bound()
695 ret = isys_complete_ext_device_registration(isys, sd, &s_asd->csi2); in isys_notifier_bound()
699 return v4l2_device_register_subdev_nodes(&isys->v4l2_dev); in isys_notifier_bound()
704 struct ipu6_isys *isys = in isys_notifier_complete() local
707 return v4l2_device_register_subdev_nodes(&isys->v4l2_dev); in isys_notifier_complete()
716 static int isys_notifier_init(struct ipu6_isys *isys) in isys_notifier_init() argument
718 struct ipu6_device *isp = isys->adev->isp; in isys_notifier_init()
723 v4l2_async_nf_init(&isys->notifier, &isys->v4l2_dev); in isys_notifier_init()
743 s_asd = v4l2_async_nf_add_fwnode_remote(&isys->notifier, ep, in isys_notifier_init()
766 isys->notifier.ops = &isys_async_ops; in isys_notifier_init()
767 ret = v4l2_async_nf_register(&isys->notifier); in isys_notifier_init()
770 v4l2_async_nf_cleanup(&isys->notifier); in isys_notifier_init()
776 static void isys_notifier_cleanup(struct ipu6_isys *isys) in isys_notifier_cleanup() argument
778 v4l2_async_nf_unregister(&isys->notifier); in isys_notifier_cleanup()
779 v4l2_async_nf_cleanup(&isys->notifier); in isys_notifier_cleanup()
782 static int isys_register_devices(struct ipu6_isys *isys) in isys_register_devices() argument
784 struct device *dev = &isys->adev->auxdev.dev; in isys_register_devices()
785 struct pci_dev *pdev = isys->adev->isp->pdev; in isys_register_devices()
788 isys->media_dev.dev = dev; in isys_register_devices()
789 media_device_pci_init(&isys->media_dev, in isys_register_devices()
792 strscpy(isys->v4l2_dev.name, isys->media_dev.model, in isys_register_devices()
793 sizeof(isys->v4l2_dev.name)); in isys_register_devices()
795 ret = media_device_register(&isys->media_dev); in isys_register_devices()
799 isys->v4l2_dev.mdev = &isys->media_dev; in isys_register_devices()
800 isys->v4l2_dev.ctrl_handler = NULL; in isys_register_devices()
802 ret = v4l2_device_register(dev, &isys->v4l2_dev); in isys_register_devices()
806 ret = isys_register_video_devices(isys); in isys_register_devices()
810 ret = isys_csi2_register_subdevices(isys); in isys_register_devices()
814 ret = isys_csi2_create_media_links(isys); in isys_register_devices()
818 ret = isys_notifier_init(isys); in isys_register_devices()
825 isys_csi2_unregister_subdevices(isys); in isys_register_devices()
828 isys_unregister_video_devices(isys); in isys_register_devices()
831 v4l2_device_unregister(&isys->v4l2_dev); in isys_register_devices()
834 media_device_unregister(&isys->media_dev); in isys_register_devices()
835 media_device_cleanup(&isys->media_dev); in isys_register_devices()
842 static void isys_unregister_devices(struct ipu6_isys *isys) in isys_unregister_devices() argument
844 isys_unregister_video_devices(isys); in isys_unregister_devices()
845 isys_csi2_unregister_subdevices(isys); in isys_unregister_devices()
846 v4l2_device_unregister(&isys->v4l2_dev); in isys_unregister_devices()
847 media_device_unregister(&isys->media_dev); in isys_unregister_devices()
848 media_device_cleanup(&isys->media_dev); in isys_unregister_devices()
854 struct ipu6_isys *isys = ipu6_bus_get_drvdata(adev); in isys_runtime_pm_resume() local
859 if (!isys) in isys_runtime_pm_resume()
866 cpu_latency_qos_update_request(&isys->pm_qos, ISYS_PM_QOS_VALUE); in isys_runtime_pm_resume()
872 spin_lock_irqsave(&isys->power_lock, flags); in isys_runtime_pm_resume()
873 isys->power = 1; in isys_runtime_pm_resume()
874 spin_unlock_irqrestore(&isys->power_lock, flags); in isys_runtime_pm_resume()
876 isys_setup_hw(isys); in isys_runtime_pm_resume()
878 set_iwake_ltrdid(isys, 0, 0, LTR_ISYS_ON); in isys_runtime_pm_resume()
886 struct ipu6_isys *isys; in isys_runtime_pm_suspend() local
889 isys = dev_get_drvdata(dev); in isys_runtime_pm_suspend()
890 if (!isys) in isys_runtime_pm_suspend()
893 spin_lock_irqsave(&isys->power_lock, flags); in isys_runtime_pm_suspend()
894 isys->power = 0; in isys_runtime_pm_suspend()
895 spin_unlock_irqrestore(&isys->power_lock, flags); in isys_runtime_pm_suspend()
897 mutex_lock(&isys->mutex); in isys_runtime_pm_suspend()
898 isys->need_reset = false; in isys_runtime_pm_suspend()
899 mutex_unlock(&isys->mutex); in isys_runtime_pm_suspend()
901 isys->phy_termcal_val = 0; in isys_runtime_pm_suspend()
902 cpu_latency_qos_update_request(&isys->pm_qos, PM_QOS_DEFAULT_VALUE); in isys_runtime_pm_suspend()
904 set_iwake_ltrdid(isys, 0, 0, LTR_ISYS_OFF); in isys_runtime_pm_suspend()
913 struct ipu6_isys *isys = dev_get_drvdata(dev); in isys_suspend() local
916 if (isys->stream_opened) in isys_suspend()
934 static void free_fw_msg_bufs(struct ipu6_isys *isys) in free_fw_msg_bufs() argument
936 struct device *dev = &isys->adev->auxdev.dev; in free_fw_msg_bufs()
939 list_for_each_entry_safe(fwmsg, safe, &isys->framebuflist, head) in free_fw_msg_bufs()
943 list_for_each_entry_safe(fwmsg, safe, &isys->framebuflist_fw, head) in free_fw_msg_bufs()
948 static int alloc_fw_msg_bufs(struct ipu6_isys *isys, int amount) in alloc_fw_msg_bufs() argument
950 struct device *dev = &isys->adev->auxdev.dev; in alloc_fw_msg_bufs()
963 spin_lock_irqsave(&isys->listlock, flags); in alloc_fw_msg_bufs()
964 list_add(&addr->head, &isys->framebuflist); in alloc_fw_msg_bufs()
965 spin_unlock_irqrestore(&isys->listlock, flags); in alloc_fw_msg_bufs()
971 spin_lock_irqsave(&isys->listlock, flags); in alloc_fw_msg_bufs()
972 while (!list_empty(&isys->framebuflist)) { in alloc_fw_msg_bufs()
973 addr = list_first_entry(&isys->framebuflist, in alloc_fw_msg_bufs()
976 spin_unlock_irqrestore(&isys->listlock, flags); in alloc_fw_msg_bufs()
979 spin_lock_irqsave(&isys->listlock, flags); in alloc_fw_msg_bufs()
981 spin_unlock_irqrestore(&isys->listlock, flags); in alloc_fw_msg_bufs()
988 struct ipu6_isys *isys = stream->isys; in ipu6_get_fw_msg_buf() local
989 struct device *dev = &isys->adev->auxdev.dev; in ipu6_get_fw_msg_buf()
994 spin_lock_irqsave(&isys->listlock, flags); in ipu6_get_fw_msg_buf()
995 if (list_empty(&isys->framebuflist)) { in ipu6_get_fw_msg_buf()
996 spin_unlock_irqrestore(&isys->listlock, flags); in ipu6_get_fw_msg_buf()
999 ret = alloc_fw_msg_bufs(isys, 5); in ipu6_get_fw_msg_buf()
1003 spin_lock_irqsave(&isys->listlock, flags); in ipu6_get_fw_msg_buf()
1004 if (list_empty(&isys->framebuflist)) { in ipu6_get_fw_msg_buf()
1005 spin_unlock_irqrestore(&isys->listlock, flags); in ipu6_get_fw_msg_buf()
1010 msg = list_last_entry(&isys->framebuflist, struct isys_fw_msgs, head); in ipu6_get_fw_msg_buf()
1011 list_move(&msg->head, &isys->framebuflist_fw); in ipu6_get_fw_msg_buf()
1012 spin_unlock_irqrestore(&isys->listlock, flags); in ipu6_get_fw_msg_buf()
1018 void ipu6_cleanup_fw_msg_bufs(struct ipu6_isys *isys) in ipu6_cleanup_fw_msg_bufs() argument
1023 spin_lock_irqsave(&isys->listlock, flags); in ipu6_cleanup_fw_msg_bufs()
1024 list_for_each_entry_safe(fwmsg, fwmsg0, &isys->framebuflist_fw, head) in ipu6_cleanup_fw_msg_bufs()
1025 list_move(&fwmsg->head, &isys->framebuflist); in ipu6_cleanup_fw_msg_bufs()
1026 spin_unlock_irqrestore(&isys->listlock, flags); in ipu6_cleanup_fw_msg_bufs()
1029 void ipu6_put_fw_msg_buf(struct ipu6_isys *isys, u64 data) in ipu6_put_fw_msg_buf() argument
1038 spin_lock_irqsave(&isys->listlock, flags); in ipu6_put_fw_msg_buf()
1040 list_move(&msg->head, &isys->framebuflist); in ipu6_put_fw_msg_buf()
1041 spin_unlock_irqrestore(&isys->listlock, flags); in ipu6_put_fw_msg_buf()
1051 struct ipu6_isys *isys; in isys_probe() local
1058 isys = devm_kzalloc(&auxdev->dev, sizeof(*isys), GFP_KERNEL); in isys_probe()
1059 if (!isys) in isys_probe()
1065 isys->adev = adev; in isys_probe()
1066 isys->pdata = adev->pdata; in isys_probe()
1067 csi2_pdata = &isys->pdata->ipdata->csi2; in isys_probe()
1069 isys->csi2 = devm_kcalloc(&auxdev->dev, csi2_pdata->nports, in isys_probe()
1070 sizeof(*isys->csi2), GFP_KERNEL); in isys_probe()
1071 if (!isys->csi2) in isys_probe()
1079 isys->sensor_type = isys->pdata->ipdata->sensor_type_start; in isys_probe()
1081 spin_lock_init(&isys->streams_lock); in isys_probe()
1082 spin_lock_init(&isys->power_lock); in isys_probe()
1083 isys->power = 0; in isys_probe()
1084 isys->phy_termcal_val = 0; in isys_probe()
1086 mutex_init(&isys->mutex); in isys_probe()
1087 mutex_init(&isys->stream_mutex); in isys_probe()
1089 spin_lock_init(&isys->listlock); in isys_probe()
1090 INIT_LIST_HEAD(&isys->framebuflist); in isys_probe()
1091 INIT_LIST_HEAD(&isys->framebuflist_fw); in isys_probe()
1093 isys->line_align = IPU6_ISYS_2600_MEM_LINE_ALIGN; in isys_probe()
1094 isys->icache_prefetch = 0; in isys_probe()
1096 dev_set_drvdata(&auxdev->dev, isys); in isys_probe()
1098 isys_stream_init(isys); in isys_probe()
1111 cpu_latency_qos_add_request(&isys->pm_qos, PM_QOS_DEFAULT_VALUE); in isys_probe()
1113 ret = alloc_fw_msg_bufs(isys, 20); in isys_probe()
1117 isys_iwake_watermark_init(isys); in isys_probe()
1120 isys->phy_set_power = ipu6_isys_jsl_phy_set_power; in isys_probe()
1122 isys->phy_set_power = ipu6_isys_dwc_phy_set_power; in isys_probe()
1124 isys->phy_set_power = ipu6_isys_mcd_phy_set_power; in isys_probe()
1126 ret = isys_register_devices(isys); in isys_probe()
1135 free_fw_msg_bufs(isys); in isys_probe()
1147 mutex_destroy(&isys->streams[i].mutex); in isys_probe()
1149 mutex_destroy(&isys->mutex); in isys_probe()
1150 mutex_destroy(&isys->stream_mutex); in isys_probe()
1160 struct ipu6_isys *isys = dev_get_drvdata(&auxdev->dev); in isys_remove() local
1164 free_fw_msg_bufs(isys); in isys_remove()
1166 isys_unregister_devices(isys); in isys_remove()
1167 isys_notifier_cleanup(isys); in isys_remove()
1169 cpu_latency_qos_remove_request(&isys->pm_qos); in isys_remove()
1178 mutex_destroy(&isys->streams[i].mutex); in isys_remove()
1180 isys_iwake_watermark_cleanup(isys); in isys_remove()
1181 mutex_destroy(&isys->stream_mutex); in isys_remove()
1182 mutex_destroy(&isys->mutex); in isys_remove()
1223 struct ipu6_isys *isys = ipu6_bus_get_drvdata(adev); in isys_isr_one() local
1230 if (!isys->fwcom) in isys_isr_one()
1233 resp = ipu6_fw_isys_get_resp(isys->fwcom, IPU6_BASE_MSG_RECV_QUEUES); in isys_isr_one()
1261 stream = ipu6_isys_query_stream_by_handle(isys, resp->stream_handle); in isys_isr_one()
1343 ipu6_fw_isys_put_resp(isys->fwcom, IPU6_BASE_MSG_RECV_QUEUES); in isys_isr_one()