Lines Matching +full:clk +full:- +full:mgr

1 // SPDX-License-Identifier: GPL-2.0-only
24 #include <linux/clk.h>
56 /* only used in non-DT mode */
156 if (ctx->pck_min >= 100000000) { in dpi_calc_dispc_cb()
164 ctx->dispc_cinfo.lck_div = lckd; in dpi_calc_dispc_cb()
165 ctx->dispc_cinfo.pck_div = pckd; in dpi_calc_dispc_cb()
166 ctx->dispc_cinfo.lck = lck; in dpi_calc_dispc_cb()
167 ctx->dispc_cinfo.pck = pck; in dpi_calc_dispc_cb()
183 if (m_dispc > 1 && m_dispc % 2 != 0 && ctx->pck_min >= 100000000) in dpi_calc_hsdiv_cb()
186 ctx->dsi_cinfo.mX[HSDIV_DISPC] = m_dispc; in dpi_calc_hsdiv_cb()
187 ctx->dsi_cinfo.clkout[HSDIV_DISPC] = dispc; in dpi_calc_hsdiv_cb()
189 return dispc_div_calc(dispc, ctx->pck_min, ctx->pck_max, in dpi_calc_hsdiv_cb()
200 ctx->dsi_cinfo.n = n; in dpi_calc_pll_cb()
201 ctx->dsi_cinfo.m = m; in dpi_calc_pll_cb()
202 ctx->dsi_cinfo.fint = fint; in dpi_calc_pll_cb()
203 ctx->dsi_cinfo.clkdco = clkdco; in dpi_calc_pll_cb()
205 return dss_pll_hsdiv_calc(ctx->pll, clkdco, in dpi_calc_pll_cb()
206 ctx->pck_min, dss_feat_get_param_max(FEAT_PARAM_DSS_FCK), in dpi_calc_pll_cb()
214 ctx->fck = fck; in dpi_calc_dss_cb()
216 return dispc_div_calc(fck, ctx->pck_min, ctx->pck_max, in dpi_calc_dss_cb()
227 ctx->pll = dpi->pll; in dpi_dsi_clk_calc()
228 ctx->pck_min = pck - 1000; in dpi_dsi_clk_calc()
229 ctx->pck_max = pck + 1000; in dpi_dsi_clk_calc()
234 clkin = clk_get_rate(ctx->pll->clkin); in dpi_dsi_clk_calc()
236 return dss_pll_calc(ctx->pll, clkin, in dpi_dsi_clk_calc()
249 * +/- ~15MHz. in dpi_dss_clk_calc()
257 ctx->pck_min = max(pck - 1000 * i * i * i, 0lu); in dpi_dss_clk_calc()
259 ctx->pck_min = 0; in dpi_dss_clk_calc()
260 ctx->pck_max = pck + 1000 * i * i * i; in dpi_dss_clk_calc()
262 ok = dss_div_calc(pck, ctx->pck_min, dpi_calc_dss_cb, ctx); in dpi_dss_clk_calc()
282 return -EINVAL; in dpi_set_dsi_clk()
284 r = dss_pll_set_config(dpi->pll, &ctx.dsi_cinfo); in dpi_set_dsi_clk()
291 dpi->mgr_config.clock_info = ctx.dispc_cinfo; in dpi_set_dsi_clk()
309 return -EINVAL; in dpi_set_dispc_clk()
315 dpi->mgr_config.clock_info = ctx.dispc_cinfo; in dpi_set_dispc_clk()
326 struct omap_dss_device *out = &dpi->output; in dpi_set_mode()
327 struct omap_overlay_manager *mgr = out->manager; in dpi_set_mode() local
328 struct omap_video_timings *t = &dpi->timings; in dpi_set_mode()
334 if (dpi->pll) in dpi_set_mode()
335 r = dpi_set_dsi_clk(dpi, mgr->id, t->pixelclock, &fck, in dpi_set_mode()
338 r = dpi_set_dispc_clk(dpi, t->pixelclock, &fck, in dpi_set_mode()
345 if (pck != t->pixelclock) { in dpi_set_mode()
347 t->pixelclock, pck); in dpi_set_mode()
349 t->pixelclock = pck; in dpi_set_mode()
352 dss_mgr_set_timings(mgr, t); in dpi_set_mode()
359 struct omap_dss_device *out = &dpi->output; in dpi_config_lcd_manager()
360 struct omap_overlay_manager *mgr = out->manager; in dpi_config_lcd_manager() local
362 dpi->mgr_config.io_pad_mode = DSS_IO_PAD_MODE_BYPASS; in dpi_config_lcd_manager()
364 dpi->mgr_config.stallmode = false; in dpi_config_lcd_manager()
365 dpi->mgr_config.fifohandcheck = false; in dpi_config_lcd_manager()
367 dpi->mgr_config.video_port_width = dpi->data_lines; in dpi_config_lcd_manager()
369 dpi->mgr_config.lcden_sig_polarity = 0; in dpi_config_lcd_manager()
371 dss_mgr_set_lcd_config(mgr, &dpi->mgr_config); in dpi_config_lcd_manager()
377 struct omap_dss_device *out = &dpi->output; in dpi_display_enable()
380 mutex_lock(&dpi->lock); in dpi_display_enable()
382 if (dss_has_feature(FEAT_DPI_USES_VDDS_DSI) && !dpi->vdds_dsi_reg) { in dpi_display_enable()
384 r = -ENODEV; in dpi_display_enable()
388 if (out->manager == NULL) { in dpi_display_enable()
390 r = -ENODEV; in dpi_display_enable()
395 r = regulator_enable(dpi->vdds_dsi_reg); in dpi_display_enable()
404 r = dss_dpi_select_source(out->port_num, out->manager->id); in dpi_display_enable()
408 if (dpi->pll) { in dpi_display_enable()
409 r = dss_pll_enable(dpi->pll); in dpi_display_enable()
422 r = dss_mgr_enable(out->manager); in dpi_display_enable()
426 mutex_unlock(&dpi->lock); in dpi_display_enable()
432 if (dpi->pll) in dpi_display_enable()
433 dss_pll_disable(dpi->pll); in dpi_display_enable()
439 regulator_disable(dpi->vdds_dsi_reg); in dpi_display_enable()
443 mutex_unlock(&dpi->lock); in dpi_display_enable()
450 struct omap_overlay_manager *mgr = dpi->output.manager; in dpi_display_disable() local
452 mutex_lock(&dpi->lock); in dpi_display_disable()
454 dss_mgr_disable(mgr); in dpi_display_disable()
456 if (dpi->pll) { in dpi_display_disable()
457 dss_select_lcd_clk_source(mgr->id, OMAP_DSS_CLK_SRC_FCK); in dpi_display_disable()
458 dss_pll_disable(dpi->pll); in dpi_display_disable()
464 regulator_disable(dpi->vdds_dsi_reg); in dpi_display_disable()
466 mutex_unlock(&dpi->lock); in dpi_display_disable()
476 mutex_lock(&dpi->lock); in dpi_set_timings()
478 dpi->timings = *timings; in dpi_set_timings()
480 mutex_unlock(&dpi->lock); in dpi_set_timings()
488 mutex_lock(&dpi->lock); in dpi_get_timings()
490 *timings = dpi->timings; in dpi_get_timings()
492 mutex_unlock(&dpi->lock); in dpi_get_timings()
499 struct omap_overlay_manager *mgr = dpi->output.manager; in dpi_check_timings() local
506 if (mgr && !dispc_mgr_timings_ok(mgr->id, timings)) in dpi_check_timings()
507 return -EINVAL; in dpi_check_timings()
509 if (timings->pixelclock == 0) in dpi_check_timings()
510 return -EINVAL; in dpi_check_timings()
512 if (dpi->pll) { in dpi_check_timings()
513 ok = dpi_dsi_clk_calc(dpi, timings->pixelclock, &ctx); in dpi_check_timings()
515 return -EINVAL; in dpi_check_timings()
519 ok = dpi_dss_clk_calc(timings->pixelclock, &ctx); in dpi_check_timings()
521 return -EINVAL; in dpi_check_timings()
531 timings->pixelclock = pck; in dpi_check_timings()
540 mutex_lock(&dpi->lock); in dpi_set_data_lines()
542 dpi->data_lines = data_lines; in dpi_set_data_lines()
544 mutex_unlock(&dpi->lock); in dpi_set_data_lines()
569 if (dpi->vdds_dsi_reg) in dpi_init_regulator()
572 vdds_dsi = devm_regulator_get(&dpi->pdev->dev, "vdds_dsi"); in dpi_init_regulator()
574 if (PTR_ERR(vdds_dsi) != -EPROBE_DEFER) in dpi_init_regulator()
579 dpi->vdds_dsi_reg = vdds_dsi; in dpi_init_regulator()
588 if (dpi->pll) in dpi_init_pll()
591 pll = dpi_get_pll(dpi->output.dispc_channel); in dpi_init_pll()
597 dss_ctrl_pll_set_control_mux(pll->id, dpi->output.dispc_channel); in dpi_init_pll()
604 dpi->pll = pll; in dpi_init_pll()
653 struct omap_overlay_manager *mgr; in dpi_connect() local
662 mgr = omap_dss_get_overlay_manager(dssdev->dispc_channel); in dpi_connect()
663 if (!mgr) in dpi_connect()
664 return -ENODEV; in dpi_connect()
666 r = dss_mgr_connect(mgr, dssdev); in dpi_connect()
673 dst->name); in dpi_connect()
674 dss_mgr_disconnect(mgr, dssdev); in dpi_connect()
684 WARN_ON(dst != dssdev->dst); in dpi_disconnect()
686 if (dst != dssdev->dst) in dpi_disconnect()
691 if (dssdev->manager) in dpi_disconnect()
692 dss_mgr_disconnect(dssdev->manager, dssdev); in dpi_disconnect()
712 struct omap_dss_device *out = &dpi->output; in dpi_init_output()
714 out->dev = &pdev->dev; in dpi_init_output()
715 out->id = OMAP_DSS_OUTPUT_DPI; in dpi_init_output()
716 out->output_type = OMAP_DISPLAY_TYPE_DPI; in dpi_init_output()
717 out->name = "dpi.0"; in dpi_init_output()
718 out->dispc_channel = dpi_get_channel(0); in dpi_init_output()
719 out->ops.dpi = &dpi_ops; in dpi_init_output()
720 out->owner = THIS_MODULE; in dpi_init_output()
728 struct omap_dss_device *out = &dpi->output; in dpi_uninit_output()
736 struct dpi_data *dpi = port->data; in dpi_init_output_port()
737 struct omap_dss_device *out = &dpi->output; in dpi_init_output_port()
747 out->name = "dpi.2"; in dpi_init_output_port()
750 out->name = "dpi.1"; in dpi_init_output_port()
754 out->name = "dpi.0"; in dpi_init_output_port()
758 out->dev = &pdev->dev; in dpi_init_output_port()
759 out->id = OMAP_DSS_OUTPUT_DPI; in dpi_init_output_port()
760 out->output_type = OMAP_DISPLAY_TYPE_DPI; in dpi_init_output_port()
761 out->dispc_channel = dpi_get_channel(port_num); in dpi_init_output_port()
762 out->port_num = port_num; in dpi_init_output_port()
763 out->ops.dpi = &dpi_ops; in dpi_init_output_port()
764 out->owner = THIS_MODULE; in dpi_init_output_port()
771 struct dpi_data *dpi = port->data; in dpi_uninit_output_port()
772 struct omap_dss_device *out = &dpi->output; in dpi_uninit_output_port()
782 dpi = devm_kzalloc(&pdev->dev, sizeof(*dpi), GFP_KERNEL); in dpi_bind()
784 return -ENOMEM; in dpi_bind()
786 dpi->pdev = pdev; in dpi_bind()
790 mutex_init(&dpi->lock); in dpi_bind()
811 return component_add(&pdev->dev, &dpi_component_ops); in dpi_probe()
816 component_del(&pdev->dev, &dpi_component_ops); in dpi_remove()
845 dpi = devm_kzalloc(&pdev->dev, sizeof(*dpi), GFP_KERNEL); in dpi_init_port()
847 return -ENOMEM; in dpi_init_port()
853 r = of_property_read_u32(ep, "data-lines", &datalines); in dpi_init_port()
859 dpi->data_lines = datalines; in dpi_init_port()
863 dpi->pdev = pdev; in dpi_init_port()
864 port->data = dpi; in dpi_init_port()
866 mutex_init(&dpi->lock); in dpi_init_port()
870 dpi->port_initialized = true; in dpi_init_port()
882 struct dpi_data *dpi = port->data; in dpi_uninit_port()
884 if (!dpi->port_initialized) in dpi_uninit_port()