Lines Matching refs:csiphy

137 static int csiphy_set_clock_rates(struct csiphy_device *csiphy)  in csiphy_set_clock_rates()  argument
139 struct device *dev = csiphy->camss->dev; in csiphy_set_clock_rates()
144 u8 bpp = csiphy_get_bpp(csiphy->res->formats->formats, csiphy->res->formats->nformats, in csiphy_set_clock_rates()
145 csiphy->fmt[MSM_CSIPHY_PAD_SINK].code); in csiphy_set_clock_rates()
146 u8 num_lanes = csiphy->cfg.csi2->lane_cfg.num_data; in csiphy_set_clock_rates()
148 link_freq = camss_get_link_freq(&csiphy->subdev.entity, bpp, num_lanes); in csiphy_set_clock_rates()
152 for (i = 0; i < csiphy->nclocks; i++) { in csiphy_set_clock_rates()
153 struct camss_clock *clock = &csiphy->clock[i]; in csiphy_set_clock_rates()
155 if (csiphy->rate_set[i]) { in csiphy_set_clock_rates()
183 csiphy->timer_clk_rate = round_rate; in csiphy_set_clock_rates()
185 ret = clk_set_rate(clock->clk, csiphy->timer_clk_rate); in csiphy_set_clock_rates()
205 struct csiphy_device *csiphy = v4l2_get_subdevdata(sd); in csiphy_set_power() local
206 struct device *dev = csiphy->camss->dev; in csiphy_set_power()
215 ret = csiphy_set_clock_rates(csiphy); in csiphy_set_power()
221 ret = camss_enable_clocks(csiphy->nclocks, csiphy->clock, dev); in csiphy_set_power()
227 enable_irq(csiphy->irq); in csiphy_set_power()
229 csiphy->res->hw_ops->reset(csiphy); in csiphy_set_power()
231 csiphy->res->hw_ops->hw_version_read(csiphy, dev); in csiphy_set_power()
233 disable_irq(csiphy->irq); in csiphy_set_power()
235 camss_disable_clocks(csiphy->nclocks, csiphy->clock); in csiphy_set_power()
252 static int csiphy_stream_on(struct csiphy_device *csiphy) in csiphy_stream_on() argument
254 struct csiphy_config *cfg = &csiphy->cfg; in csiphy_stream_on()
256 u8 lane_mask = csiphy->res->hw_ops->get_lane_mask(&cfg->csi2->lane_cfg); in csiphy_stream_on()
257 u8 bpp = csiphy_get_bpp(csiphy->res->formats->formats, csiphy->res->formats->nformats, in csiphy_stream_on()
258 csiphy->fmt[MSM_CSIPHY_PAD_SINK].code); in csiphy_stream_on()
259 u8 num_lanes = csiphy->cfg.csi2->lane_cfg.num_data; in csiphy_stream_on()
262 link_freq = camss_get_link_freq(&csiphy->subdev.entity, bpp, num_lanes); in csiphy_stream_on()
265 dev_err(csiphy->camss->dev, in csiphy_stream_on()
270 if (csiphy->base_clk_mux) { in csiphy_stream_on()
271 val = readl_relaxed(csiphy->base_clk_mux); in csiphy_stream_on()
279 writel_relaxed(val, csiphy->base_clk_mux); in csiphy_stream_on()
285 csiphy->res->hw_ops->lanes_enable(csiphy, cfg, link_freq, lane_mask); in csiphy_stream_on()
296 static void csiphy_stream_off(struct csiphy_device *csiphy) in csiphy_stream_off() argument
298 csiphy->res->hw_ops->lanes_disable(csiphy, &csiphy->cfg); in csiphy_stream_off()
311 struct csiphy_device *csiphy = v4l2_get_subdevdata(sd); in csiphy_set_stream() local
315 ret = csiphy_stream_on(csiphy); in csiphy_set_stream()
317 csiphy_stream_off(csiphy); in csiphy_set_stream()
332 __csiphy_get_format(struct csiphy_device *csiphy, in __csiphy_get_format() argument
340 return &csiphy->fmt[pad]; in __csiphy_get_format()
351 static void csiphy_try_format(struct csiphy_device *csiphy, in csiphy_try_format() argument
363 for (i = 0; i < csiphy->res->formats->nformats; i++) in csiphy_try_format()
364 if (fmt->code == csiphy->res->formats->formats[i].code) in csiphy_try_format()
368 if (i >= csiphy->res->formats->nformats) in csiphy_try_format()
382 *fmt = *__csiphy_get_format(csiphy, sd_state, in csiphy_try_format()
401 struct csiphy_device *csiphy = v4l2_get_subdevdata(sd); in csiphy_enum_mbus_code() local
405 if (code->index >= csiphy->res->formats->nformats) in csiphy_enum_mbus_code()
408 code->code = csiphy->res->formats->formats[code->index].code; in csiphy_enum_mbus_code()
413 format = __csiphy_get_format(csiphy, sd_state, in csiphy_enum_mbus_code()
434 struct csiphy_device *csiphy = v4l2_get_subdevdata(sd); in csiphy_enum_frame_size() local
443 csiphy_try_format(csiphy, sd_state, fse->pad, &format, fse->which); in csiphy_enum_frame_size()
453 csiphy_try_format(csiphy, sd_state, fse->pad, &format, fse->which); in csiphy_enum_frame_size()
472 struct csiphy_device *csiphy = v4l2_get_subdevdata(sd); in csiphy_get_format() local
475 format = __csiphy_get_format(csiphy, sd_state, fmt->pad, fmt->which); in csiphy_get_format()
496 struct csiphy_device *csiphy = v4l2_get_subdevdata(sd); in csiphy_set_format() local
499 format = __csiphy_get_format(csiphy, sd_state, fmt->pad, fmt->which); in csiphy_set_format()
503 csiphy_try_format(csiphy, sd_state, fmt->pad, &fmt->format, in csiphy_set_format()
509 format = __csiphy_get_format(csiphy, sd_state, in csiphy_set_format()
514 csiphy_try_format(csiphy, sd_state, MSM_CSIPHY_PAD_SRC, in csiphy_set_format()
566 struct csiphy_device *csiphy, in msm_csiphy_subdev_init() argument
574 csiphy->camss = camss; in msm_csiphy_subdev_init()
575 csiphy->id = id; in msm_csiphy_subdev_init()
576 csiphy->cfg.combo_mode = 0; in msm_csiphy_subdev_init()
577 csiphy->res = &res->csiphy; in msm_csiphy_subdev_init()
581 csiphy->base = devm_platform_ioremap_resource_byname(pdev, res->reg[0]); in msm_csiphy_subdev_init()
582 if (IS_ERR(csiphy->base)) in msm_csiphy_subdev_init()
583 return PTR_ERR(csiphy->base); in msm_csiphy_subdev_init()
587 csiphy->base_clk_mux = in msm_csiphy_subdev_init()
589 if (IS_ERR(csiphy->base_clk_mux)) in msm_csiphy_subdev_init()
590 return PTR_ERR(csiphy->base_clk_mux); in msm_csiphy_subdev_init()
592 csiphy->base_clk_mux = NULL; in msm_csiphy_subdev_init()
601 csiphy->irq = ret; in msm_csiphy_subdev_init()
602 snprintf(csiphy->irq_name, sizeof(csiphy->irq_name), "%s_%s%d", in msm_csiphy_subdev_init()
603 dev_name(dev), MSM_CSIPHY_NAME, csiphy->id); in msm_csiphy_subdev_init()
605 ret = devm_request_irq(dev, csiphy->irq, csiphy->res->hw_ops->isr, in msm_csiphy_subdev_init()
607 csiphy->irq_name, csiphy); in msm_csiphy_subdev_init()
615 csiphy->nclocks = 0; in msm_csiphy_subdev_init()
616 while (res->clock[csiphy->nclocks]) in msm_csiphy_subdev_init()
617 csiphy->nclocks++; in msm_csiphy_subdev_init()
619 csiphy->clock = devm_kcalloc(dev, in msm_csiphy_subdev_init()
620 csiphy->nclocks, sizeof(*csiphy->clock), in msm_csiphy_subdev_init()
622 if (!csiphy->clock) in msm_csiphy_subdev_init()
625 csiphy->rate_set = devm_kcalloc(dev, in msm_csiphy_subdev_init()
626 csiphy->nclocks, in msm_csiphy_subdev_init()
627 sizeof(*csiphy->rate_set), in msm_csiphy_subdev_init()
629 if (!csiphy->rate_set) in msm_csiphy_subdev_init()
632 for (i = 0; i < csiphy->nclocks; i++) { in msm_csiphy_subdev_init()
633 struct camss_clock *clock = &csiphy->clock[i]; in msm_csiphy_subdev_init()
661 csiphy->rate_set[i] = csiphy_match_clock_name(clock->name, in msm_csiphy_subdev_init()
663 if (csiphy->rate_set[i]) in msm_csiphy_subdev_init()
667 csiphy->rate_set[i] = csiphy_match_clock_name(clock->name, in msm_csiphy_subdev_init()
669 if (csiphy->rate_set[i]) in msm_csiphy_subdev_init()
673 csiphy->rate_set[i] = csiphy_match_clock_name(clock->name, "csiphy%d", k); in msm_csiphy_subdev_init()
674 if (csiphy->rate_set[i]) in msm_csiphy_subdev_init()
698 struct csiphy_device *csiphy; in csiphy_link_setup() local
705 csiphy = v4l2_get_subdevdata(sd); in csiphy_link_setup()
710 csiphy->cfg.csid_id = csid->id; in csiphy_link_setup()
753 int msm_csiphy_register_entity(struct csiphy_device *csiphy, in msm_csiphy_register_entity() argument
756 struct v4l2_subdev *sd = &csiphy->subdev; in msm_csiphy_register_entity()
757 struct media_pad *pads = csiphy->pads; in msm_csiphy_register_entity()
758 struct device *dev = csiphy->camss->dev; in msm_csiphy_register_entity()
765 MSM_CSIPHY_NAME, csiphy->id); in msm_csiphy_register_entity()
766 v4l2_set_subdevdata(sd, csiphy); in msm_csiphy_register_entity()
798 void msm_csiphy_unregister_entity(struct csiphy_device *csiphy) in msm_csiphy_unregister_entity() argument
800 v4l2_device_unregister_subdev(&csiphy->subdev); in msm_csiphy_unregister_entity()
801 media_entity_cleanup(&csiphy->subdev.entity); in msm_csiphy_unregister_entity()