Lines Matching refs:csiphy

127 static int csiphy_set_clock_rates(struct csiphy_device *csiphy)  in csiphy_set_clock_rates()  argument
129 struct device *dev = csiphy->camss->dev; in csiphy_set_clock_rates()
134 u8 bpp = csiphy_get_bpp(csiphy->formats, csiphy->nformats, in csiphy_set_clock_rates()
135 csiphy->fmt[MSM_CSIPHY_PAD_SINK].code); in csiphy_set_clock_rates()
136 u8 num_lanes = csiphy->cfg.csi2->lane_cfg.num_data; in csiphy_set_clock_rates()
138 link_freq = camss_get_link_freq(&csiphy->subdev.entity, bpp, num_lanes); in csiphy_set_clock_rates()
142 for (i = 0; i < csiphy->nclocks; i++) { in csiphy_set_clock_rates()
143 struct camss_clock *clock = &csiphy->clock[i]; in csiphy_set_clock_rates()
145 if (csiphy->rate_set[i]) { in csiphy_set_clock_rates()
173 csiphy->timer_clk_rate = round_rate; in csiphy_set_clock_rates()
175 ret = clk_set_rate(clock->clk, csiphy->timer_clk_rate); in csiphy_set_clock_rates()
195 struct csiphy_device *csiphy = v4l2_get_subdevdata(sd); in csiphy_set_power() local
196 struct device *dev = csiphy->camss->dev; in csiphy_set_power()
205 ret = csiphy_set_clock_rates(csiphy); in csiphy_set_power()
211 ret = camss_enable_clocks(csiphy->nclocks, csiphy->clock, dev); in csiphy_set_power()
217 enable_irq(csiphy->irq); in csiphy_set_power()
219 csiphy->ops->reset(csiphy); in csiphy_set_power()
221 csiphy->ops->hw_version_read(csiphy, dev); in csiphy_set_power()
223 disable_irq(csiphy->irq); in csiphy_set_power()
225 camss_disable_clocks(csiphy->nclocks, csiphy->clock); in csiphy_set_power()
242 static int csiphy_stream_on(struct csiphy_device *csiphy) in csiphy_stream_on() argument
244 struct csiphy_config *cfg = &csiphy->cfg; in csiphy_stream_on()
246 u8 lane_mask = csiphy->ops->get_lane_mask(&cfg->csi2->lane_cfg); in csiphy_stream_on()
247 u8 bpp = csiphy_get_bpp(csiphy->formats, csiphy->nformats, in csiphy_stream_on()
248 csiphy->fmt[MSM_CSIPHY_PAD_SINK].code); in csiphy_stream_on()
249 u8 num_lanes = csiphy->cfg.csi2->lane_cfg.num_data; in csiphy_stream_on()
252 link_freq = camss_get_link_freq(&csiphy->subdev.entity, bpp, num_lanes); in csiphy_stream_on()
255 dev_err(csiphy->camss->dev, in csiphy_stream_on()
260 if (csiphy->base_clk_mux) { in csiphy_stream_on()
261 val = readl_relaxed(csiphy->base_clk_mux); in csiphy_stream_on()
269 writel_relaxed(val, csiphy->base_clk_mux); in csiphy_stream_on()
275 csiphy->ops->lanes_enable(csiphy, cfg, link_freq, lane_mask); in csiphy_stream_on()
286 static void csiphy_stream_off(struct csiphy_device *csiphy) in csiphy_stream_off() argument
288 csiphy->ops->lanes_disable(csiphy, &csiphy->cfg); in csiphy_stream_off()
301 struct csiphy_device *csiphy = v4l2_get_subdevdata(sd); in csiphy_set_stream() local
305 ret = csiphy_stream_on(csiphy); in csiphy_set_stream()
307 csiphy_stream_off(csiphy); in csiphy_set_stream()
322 __csiphy_get_format(struct csiphy_device *csiphy, in __csiphy_get_format() argument
328 return v4l2_subdev_get_try_format(&csiphy->subdev, sd_state, in __csiphy_get_format()
331 return &csiphy->fmt[pad]; in __csiphy_get_format()
342 static void csiphy_try_format(struct csiphy_device *csiphy, in csiphy_try_format() argument
354 for (i = 0; i < csiphy->nformats; i++) in csiphy_try_format()
355 if (fmt->code == csiphy->formats[i].code) in csiphy_try_format()
359 if (i >= csiphy->nformats) in csiphy_try_format()
373 *fmt = *__csiphy_get_format(csiphy, sd_state, in csiphy_try_format()
392 struct csiphy_device *csiphy = v4l2_get_subdevdata(sd); in csiphy_enum_mbus_code() local
396 if (code->index >= csiphy->nformats) in csiphy_enum_mbus_code()
399 code->code = csiphy->formats[code->index].code; in csiphy_enum_mbus_code()
404 format = __csiphy_get_format(csiphy, sd_state, in csiphy_enum_mbus_code()
425 struct csiphy_device *csiphy = v4l2_get_subdevdata(sd); in csiphy_enum_frame_size() local
434 csiphy_try_format(csiphy, sd_state, fse->pad, &format, fse->which); in csiphy_enum_frame_size()
444 csiphy_try_format(csiphy, sd_state, fse->pad, &format, fse->which); in csiphy_enum_frame_size()
463 struct csiphy_device *csiphy = v4l2_get_subdevdata(sd); in csiphy_get_format() local
466 format = __csiphy_get_format(csiphy, sd_state, fmt->pad, fmt->which); in csiphy_get_format()
487 struct csiphy_device *csiphy = v4l2_get_subdevdata(sd); in csiphy_set_format() local
490 format = __csiphy_get_format(csiphy, sd_state, fmt->pad, fmt->which); in csiphy_set_format()
494 csiphy_try_format(csiphy, sd_state, fmt->pad, &fmt->format, in csiphy_set_format()
500 format = __csiphy_get_format(csiphy, sd_state, in csiphy_set_format()
505 csiphy_try_format(csiphy, sd_state, MSM_CSIPHY_PAD_SRC, in csiphy_set_format()
548 struct csiphy_device *csiphy, in msm_csiphy_subdev_init() argument
556 csiphy->camss = camss; in msm_csiphy_subdev_init()
557 csiphy->id = id; in msm_csiphy_subdev_init()
558 csiphy->cfg.combo_mode = 0; in msm_csiphy_subdev_init()
561 csiphy->ops = &csiphy_ops_2ph_1_0; in msm_csiphy_subdev_init()
562 csiphy->formats = csiphy_formats_8x16; in msm_csiphy_subdev_init()
563 csiphy->nformats = ARRAY_SIZE(csiphy_formats_8x16); in msm_csiphy_subdev_init()
566 csiphy->ops = &csiphy_ops_3ph_1_0; in msm_csiphy_subdev_init()
567 csiphy->formats = csiphy_formats_8x96; in msm_csiphy_subdev_init()
568 csiphy->nformats = ARRAY_SIZE(csiphy_formats_8x96); in msm_csiphy_subdev_init()
571 csiphy->ops = &csiphy_ops_3ph_1_0; in msm_csiphy_subdev_init()
572 csiphy->formats = csiphy_formats_sdm845; in msm_csiphy_subdev_init()
573 csiphy->nformats = ARRAY_SIZE(csiphy_formats_sdm845); in msm_csiphy_subdev_init()
580 csiphy->base = devm_platform_ioremap_resource_byname(pdev, res->reg[0]); in msm_csiphy_subdev_init()
581 if (IS_ERR(csiphy->base)) in msm_csiphy_subdev_init()
582 return PTR_ERR(csiphy->base); in msm_csiphy_subdev_init()
586 csiphy->base_clk_mux = in msm_csiphy_subdev_init()
588 if (IS_ERR(csiphy->base_clk_mux)) in msm_csiphy_subdev_init()
589 return PTR_ERR(csiphy->base_clk_mux); in msm_csiphy_subdev_init()
591 csiphy->base_clk_mux = NULL; in msm_csiphy_subdev_init()
600 csiphy->irq = ret; in msm_csiphy_subdev_init()
601 snprintf(csiphy->irq_name, sizeof(csiphy->irq_name), "%s_%s%d", in msm_csiphy_subdev_init()
602 dev_name(dev), MSM_CSIPHY_NAME, csiphy->id); in msm_csiphy_subdev_init()
604 ret = devm_request_irq(dev, csiphy->irq, csiphy->ops->isr, in msm_csiphy_subdev_init()
606 csiphy->irq_name, csiphy); in msm_csiphy_subdev_init()
614 csiphy->nclocks = 0; in msm_csiphy_subdev_init()
615 while (res->clock[csiphy->nclocks]) in msm_csiphy_subdev_init()
616 csiphy->nclocks++; in msm_csiphy_subdev_init()
618 csiphy->clock = devm_kcalloc(dev, in msm_csiphy_subdev_init()
619 csiphy->nclocks, sizeof(*csiphy->clock), in msm_csiphy_subdev_init()
621 if (!csiphy->clock) in msm_csiphy_subdev_init()
624 csiphy->rate_set = devm_kcalloc(dev, in msm_csiphy_subdev_init()
625 csiphy->nclocks, in msm_csiphy_subdev_init()
626 sizeof(*csiphy->rate_set), in msm_csiphy_subdev_init()
628 if (!csiphy->rate_set) in msm_csiphy_subdev_init()
631 for (i = 0; i < csiphy->nclocks; i++) { in msm_csiphy_subdev_init()
632 struct camss_clock *clock = &csiphy->clock[i]; in msm_csiphy_subdev_init()
665 csiphy->rate_set[i] = true; in msm_csiphy_subdev_init()
671 csiphy->rate_set[i] = true; in msm_csiphy_subdev_init()
693 struct csiphy_device *csiphy; in csiphy_link_setup() local
700 csiphy = v4l2_get_subdevdata(sd); in csiphy_link_setup()
705 csiphy->cfg.csid_id = csid->id; in csiphy_link_setup()
748 int msm_csiphy_register_entity(struct csiphy_device *csiphy, in msm_csiphy_register_entity() argument
751 struct v4l2_subdev *sd = &csiphy->subdev; in msm_csiphy_register_entity()
752 struct media_pad *pads = csiphy->pads; in msm_csiphy_register_entity()
753 struct device *dev = csiphy->camss->dev; in msm_csiphy_register_entity()
760 MSM_CSIPHY_NAME, csiphy->id); in msm_csiphy_register_entity()
761 v4l2_set_subdevdata(sd, csiphy); in msm_csiphy_register_entity()
793 void msm_csiphy_unregister_entity(struct csiphy_device *csiphy) in msm_csiphy_unregister_entity() argument
795 v4l2_device_unregister_subdev(&csiphy->subdev); in msm_csiphy_unregister_entity()
796 media_entity_cleanup(&csiphy->subdev.entity); in msm_csiphy_unregister_entity()