Lines Matching full:csi2
24 #include "ipu6-isys-csi2.h"
26 #include "ipu6-platform-isys-csi2-reg.h"
80 s64 ipu6_isys_csi2_get_link_freq(struct ipu6_isys_csi2 *csi2) in ipu6_isys_csi2_get_link_freq() argument
86 if (!csi2) in ipu6_isys_csi2_get_link_freq()
89 dev = &csi2->isys->adev->auxdev.dev; in ipu6_isys_csi2_get_link_freq()
90 src_pad = media_entity_remote_source_pad_unique(&csi2->asd.sd.entity); in ipu6_isys_csi2_get_link_freq()
93 csi2->asd.sd.name, PTR_ERR(src_pad)); in ipu6_isys_csi2_get_link_freq()
98 if (WARN(!ext_sd, "Failed to get subdev for %s\n", csi2->asd.sd.name)) in ipu6_isys_csi2_get_link_freq()
108 struct ipu6_isys_csi2 *csi2 = to_ipu6_isys_csi2(asd); in csi2_subscribe_event() local
109 struct device *dev = &csi2->isys->adev->auxdev.dev; in csi2_subscribe_event()
111 dev_dbg(dev, "csi2 subscribe event(type %u id %u)\n", in csi2_subscribe_event()
130 * The input system CSI2+ receiver has several
170 ipu6_isys_csi2_calc_timing(struct ipu6_isys_csi2 *csi2, in ipu6_isys_csi2_calc_timing() argument
173 struct device *dev = &csi2->isys->adev->auxdev.dev; in ipu6_isys_csi2_calc_timing()
176 link_freq = ipu6_isys_csi2_get_link_freq(csi2); in ipu6_isys_csi2_calc_timing()
200 void ipu6_isys_register_errors(struct ipu6_isys_csi2 *csi2) in ipu6_isys_register_errors() argument
202 u32 irq = readl(csi2->base + CSI_PORT_REG_BASE_IRQ_CSI + in ipu6_isys_register_errors()
204 struct ipu6_isys *isys = csi2->isys; in ipu6_isys_register_errors()
207 mask = isys->pdata->ipdata->csi2.irq_mask; in ipu6_isys_register_errors()
208 writel(irq & mask, csi2->base + CSI_PORT_REG_BASE_IRQ_CSI + in ipu6_isys_register_errors()
210 csi2->receiver_errors |= irq & mask; in ipu6_isys_register_errors()
213 void ipu6_isys_csi2_error(struct ipu6_isys_csi2 *csi2) in ipu6_isys_csi2_error() argument
215 struct device *dev = &csi2->isys->adev->auxdev.dev; in ipu6_isys_csi2_error()
221 ipu6_isys_register_errors(csi2); in ipu6_isys_csi2_error()
222 status = csi2->receiver_errors; in ipu6_isys_csi2_error()
223 csi2->receiver_errors = 0; in ipu6_isys_csi2_error()
228 dev_err_ratelimited(dev, "csi2-%i error: %s\n", in ipu6_isys_csi2_error()
229 csi2->port, errors[i].error_string); in ipu6_isys_csi2_error()
238 struct ipu6_isys_csi2 *csi2 = to_ipu6_isys_csi2(asd); in ipu6_isys_csi2_set_stream() local
239 struct ipu6_isys *isys = csi2->isys; in ipu6_isys_csi2_set_stream()
247 dev_dbg(dev, "stream %s CSI2-%u with %u lanes\n", enable ? "on" : "off", in ipu6_isys_csi2_set_stream()
248 csi2->port, nlanes); in ipu6_isys_csi2_set_stream()
250 cfg.port = csi2->port; in ipu6_isys_csi2_set_stream()
253 mask = isys->pdata->ipdata->csi2.irq_mask; in ipu6_isys_csi2_set_stream()
254 nports = isys->pdata->ipdata->csi2.nports; in ipu6_isys_csi2_set_stream()
257 writel(0, csi2->base + CSI_REG_CSI_FE_ENABLE); in ipu6_isys_csi2_set_stream()
258 writel(0, csi2->base + CSI_REG_PPI2CSI_ENABLE); in ipu6_isys_csi2_set_stream()
261 csi2->base + CSI_PORT_REG_BASE_IRQ_CSI + in ipu6_isys_csi2_set_stream()
264 csi2->base + CSI_PORT_REG_BASE_IRQ_CSI + in ipu6_isys_csi2_set_stream()
267 csi2->base + CSI_PORT_REG_BASE_IRQ_CSI_SYNC + in ipu6_isys_csi2_set_stream()
270 csi2->base + CSI_PORT_REG_BASE_IRQ_CSI_SYNC + in ipu6_isys_csi2_set_stream()
276 (isys->pdata->ipdata->csi2.fw_access_port_ofs, in ipu6_isys_csi2_set_stream()
277 csi2->port)); in ipu6_isys_csi2_set_stream()
279 CSI_REG_HUB_DRV_ACCESS_PORT(csi2->port)); in ipu6_isys_csi2_set_stream()
285 writel(0x1, csi2->base + CSI_REG_PORT_GPREG_SRST); in ipu6_isys_csi2_set_stream()
287 writel(0x0, csi2->base + CSI_REG_PORT_GPREG_SRST); in ipu6_isys_csi2_set_stream()
293 (isys->pdata->ipdata->csi2.fw_access_port_ofs, i)); in ipu6_isys_csi2_set_stream()
298 csi2->base + CSI_PORT_REG_BASE_IRQ_CSI + in ipu6_isys_csi2_set_stream()
301 csi2->base + CSI_PORT_REG_BASE_IRQ_CSI + in ipu6_isys_csi2_set_stream()
304 csi2->base + CSI_PORT_REG_BASE_IRQ_CSI + in ipu6_isys_csi2_set_stream()
307 csi2->base + CSI_PORT_REG_BASE_IRQ_CSI + in ipu6_isys_csi2_set_stream()
310 csi2->base + CSI_PORT_REG_BASE_IRQ_CSI + in ipu6_isys_csi2_set_stream()
314 * Using event from firmware instead of irq to handle CSI2 sync event in ipu6_isys_csi2_set_stream()
315 * which can reduce system wakeups. If CSI2 sync irq enabled, we need in ipu6_isys_csi2_set_stream()
316 * disable the firmware CSI2 sync event to avoid duplicate handling. in ipu6_isys_csi2_set_stream()
318 writel(0xffffffff, csi2->base + CSI_PORT_REG_BASE_IRQ_CSI_SYNC + in ipu6_isys_csi2_set_stream()
320 writel(0, csi2->base + CSI_PORT_REG_BASE_IRQ_CSI_SYNC + in ipu6_isys_csi2_set_stream()
322 writel(0xffffffff, csi2->base + CSI_PORT_REG_BASE_IRQ_CSI_SYNC + in ipu6_isys_csi2_set_stream()
324 writel(0, csi2->base + CSI_PORT_REG_BASE_IRQ_CSI_SYNC + in ipu6_isys_csi2_set_stream()
326 writel(0xffffffff, csi2->base + CSI_PORT_REG_BASE_IRQ_CSI_SYNC + in ipu6_isys_csi2_set_stream()
330 writel(0, csi2->base + CSI_REG_CSI_FE_MODE); in ipu6_isys_csi2_set_stream()
331 writel(CSI_SENSOR_INPUT, csi2->base + CSI_REG_CSI_FE_MUX_CTRL); in ipu6_isys_csi2_set_stream()
333 csi2->base + CSI_REG_CSI_FE_SYNC_CNTR_SEL); in ipu6_isys_csi2_set_stream()
335 csi2->base + CSI_REG_PPI2CSI_CONFIG_PPI_INTF); in ipu6_isys_csi2_set_stream()
337 writel(1, csi2->base + CSI_REG_PPI2CSI_ENABLE); in ipu6_isys_csi2_set_stream()
338 writel(1, csi2->base + CSI_REG_CSI_FE_ENABLE); in ipu6_isys_csi2_set_stream()
342 dev_err(dev, "csi-%d phy power up failed %d\n", csi2->port, in ipu6_isys_csi2_set_stream()
353 struct ipu6_isys_csi2 *csi2 = to_ipu6_isys_csi2(asd); in ipu6_isys_csi2_enable_streams() local
367 ret = ipu6_isys_csi2_calc_timing(csi2, &timing, CSI2_ACCINV); in ipu6_isys_csi2_enable_streams()
371 ret = ipu6_isys_csi2_set_stream(sd, &timing, csi2->nlanes, true); in ipu6_isys_csi2_enable_streams()
518 void ipu6_isys_csi2_cleanup(struct ipu6_isys_csi2 *csi2) in ipu6_isys_csi2_cleanup() argument
520 if (!csi2->isys) in ipu6_isys_csi2_cleanup()
523 v4l2_device_unregister_subdev(&csi2->asd.sd); in ipu6_isys_csi2_cleanup()
524 v4l2_subdev_cleanup(&csi2->asd.sd); in ipu6_isys_csi2_cleanup()
525 ipu6_isys_subdev_cleanup(&csi2->asd); in ipu6_isys_csi2_cleanup()
526 csi2->isys = NULL; in ipu6_isys_csi2_cleanup()
529 int ipu6_isys_csi2_init(struct ipu6_isys_csi2 *csi2, in ipu6_isys_csi2_init() argument
536 csi2->isys = isys; in ipu6_isys_csi2_init()
537 csi2->base = base; in ipu6_isys_csi2_init()
538 csi2->port = index; in ipu6_isys_csi2_init()
540 csi2->asd.sd.entity.ops = &csi2_entity_ops; in ipu6_isys_csi2_init()
541 csi2->asd.isys = isys; in ipu6_isys_csi2_init()
542 ret = ipu6_isys_subdev_init(&csi2->asd, &csi2_sd_ops, 0, in ipu6_isys_csi2_init()
547 csi2->asd.source = IPU6_FW_ISYS_STREAM_SRC_CSI2_PORT0 + index; in ipu6_isys_csi2_init()
548 csi2->asd.supported_codes = csi2_supported_codes; in ipu6_isys_csi2_init()
549 snprintf(csi2->asd.sd.name, sizeof(csi2->asd.sd.name), in ipu6_isys_csi2_init()
550 IPU6_ISYS_ENTITY_PREFIX " CSI2 %u", index); in ipu6_isys_csi2_init()
551 v4l2_set_subdevdata(&csi2->asd.sd, &csi2->asd); in ipu6_isys_csi2_init()
552 ret = v4l2_subdev_init_finalize(&csi2->asd.sd); in ipu6_isys_csi2_init()
558 ret = v4l2_device_register_subdev(&isys->v4l2_dev, &csi2->asd.sd); in ipu6_isys_csi2_init()
567 ipu6_isys_csi2_cleanup(csi2); in ipu6_isys_csi2_init()
576 struct ipu6_isys_csi2 *csi2 = ipu6_isys_subdev_to_csi2(stream->asd); in ipu6_isys_csi2_sof_event_by_stream() local
584 dev_dbg(dev, "sof_event::csi2-%i sequence: %i, vc: %d\n", in ipu6_isys_csi2_sof_event_by_stream()
585 csi2->port, ev.u.frame_sync.frame_sequence, stream->vc); in ipu6_isys_csi2_sof_event_by_stream()
591 struct ipu6_isys_csi2 *csi2 = ipu6_isys_subdev_to_csi2(stream->asd); in ipu6_isys_csi2_eof_event_by_stream() local
594 dev_dbg(dev, "eof_event::csi2-%i sequence: %i\n", in ipu6_isys_csi2_eof_event_by_stream()
595 csi2->port, frame_sequence); in ipu6_isys_csi2_eof_event_by_stream()
599 struct ipu6_isys_csi2 *csi2, in ipu6_isys_csi2_get_remote_desc() argument
604 struct device *dev = &csi2->isys->adev->auxdev.dev; in ipu6_isys_csi2_get_remote_desc()
615 pad = media_pad_remote_pad_first(&csi2->asd.pad[CSI2_PAD_SINK]); in ipu6_isys_csi2_get_remote_desc()
641 if (desc_entry->bus.csi2.vc >= NR_OF_CSI2_VC) { in ipu6_isys_csi2_get_remote_desc()
642 dev_err(dev, "invalid vc %d\n", desc_entry->bus.csi2.vc); in ipu6_isys_csi2_get_remote_desc()