Lines Matching +full:rockchip +full:- +full:vop

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd
5 * Mark Yao <mark.yao@rock-chips.com>
6 * Sandy Huang <hjc@rock-chips.com>
45 * rockchip_lvds_soc_data - rockchip lvds Soc private data
74 writel_relaxed(val, lvds->regs + offset); in rk3288_writel()
75 if (lvds->output == DISPLAY_OUTPUT_LVDS) in rk3288_writel()
77 writel_relaxed(val, lvds->regs + offset + RK3288_LVDS_CH1_OFFSET); in rk3288_writel()
82 if (strncmp(s, "jeida-18", 8) == 0) in rockchip_lvds_name_to_format()
84 else if (strncmp(s, "jeida-24", 8) == 0) in rockchip_lvds_name_to_format()
86 else if (strncmp(s, "vesa-24", 7) == 0) in rockchip_lvds_name_to_format()
89 return -EINVAL; in rockchip_lvds_name_to_format()
101 return -EINVAL; in rockchip_lvds_name_to_output()
115 struct drm_panel *panel = lvds->panel; in rockchip_lvds_connector_get_modes()
132 s->output_mode = ROCKCHIP_OUT_MODE_P888; in rockchip_lvds_encoder_atomic_check()
133 s->output_type = DRM_MODE_CONNECTOR_LVDS; in rockchip_lvds_encoder_atomic_check()
143 ret = clk_enable(lvds->pclk); in rk3288_lvds_poweron()
145 DRM_DEV_ERROR(lvds->dev, "failed to enable lvds pclk %d\n", ret); in rk3288_lvds_poweron()
148 ret = pm_runtime_get_sync(lvds->dev); in rk3288_lvds_poweron()
150 DRM_DEV_ERROR(lvds->dev, "failed to get pm runtime: %d\n", ret); in rk3288_lvds_poweron()
151 clk_disable(lvds->pclk); in rk3288_lvds_poweron()
157 if (lvds->output == DISPLAY_OUTPUT_RGB) { in rk3288_lvds_poweron()
226 ret = regmap_write(lvds->grf, RK3288_LVDS_GRF_SOC_CON7, val); in rk3288_lvds_poweroff()
228 DRM_DEV_ERROR(lvds->dev, "Could not write to GRF: %d\n", ret); in rk3288_lvds_poweroff()
230 pm_runtime_put(lvds->dev); in rk3288_lvds_poweroff()
231 clk_disable(lvds->pclk); in rk3288_lvds_poweroff()
238 u8 pin_hsync = (mode->flags & DRM_MODE_FLAG_PHSYNC) ? 1 : 0; in rk3288_lvds_grf_config()
239 u8 pin_dclk = (mode->flags & DRM_MODE_FLAG_PCSYNC) ? 1 : 0; in rk3288_lvds_grf_config()
244 if (lvds->output == DISPLAY_OUTPUT_RGB) in rk3288_lvds_grf_config()
245 if (lvds->pins && !IS_ERR(lvds->pins->default_state)) in rk3288_lvds_grf_config()
246 pinctrl_select_state(lvds->pins->p, in rk3288_lvds_grf_config()
247 lvds->pins->default_state); in rk3288_lvds_grf_config()
248 val = lvds->format | LVDS_CH0_EN; in rk3288_lvds_grf_config()
249 if (lvds->output == DISPLAY_OUTPUT_RGB) in rk3288_lvds_grf_config()
251 else if (lvds->output == DISPLAY_OUTPUT_DUAL_LVDS) in rk3288_lvds_grf_config()
254 if ((mode->htotal - mode->hsync_start) & 0x01) in rk3288_lvds_grf_config()
259 ret = regmap_write(lvds->grf, RK3288_LVDS_GRF_SOC_CON7, val); in rk3288_lvds_grf_config()
261 DRM_DEV_ERROR(lvds->dev, "Could not write to GRF: %d\n", ret); in rk3288_lvds_grf_config()
272 ret = drm_of_encoder_active_endpoint_id(lvds->dev->of_node, encoder); in rk3288_lvds_set_vop_source()
280 ret = regmap_write(lvds->grf, RK3288_LVDS_GRF_SOC_CON6, val); in rk3288_lvds_set_vop_source()
290 struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; in rk3288_lvds_encoder_enable()
293 drm_panel_prepare(lvds->panel); in rk3288_lvds_encoder_enable()
297 DRM_DEV_ERROR(lvds->dev, "failed to power on LVDS: %d\n", ret); in rk3288_lvds_encoder_enable()
298 drm_panel_unprepare(lvds->panel); in rk3288_lvds_encoder_enable()
304 DRM_DEV_ERROR(lvds->dev, "failed to configure LVDS: %d\n", ret); in rk3288_lvds_encoder_enable()
305 drm_panel_unprepare(lvds->panel); in rk3288_lvds_encoder_enable()
311 DRM_DEV_ERROR(lvds->dev, "failed to set VOP source: %d\n", ret); in rk3288_lvds_encoder_enable()
312 drm_panel_unprepare(lvds->panel); in rk3288_lvds_encoder_enable()
316 drm_panel_enable(lvds->panel); in rk3288_lvds_encoder_enable()
323 drm_panel_disable(lvds->panel); in rk3288_lvds_encoder_disable()
325 drm_panel_unprepare(lvds->panel); in rk3288_lvds_encoder_disable()
332 ret = pm_runtime_get_sync(lvds->dev); in px30_lvds_poweron()
334 DRM_DEV_ERROR(lvds->dev, "failed to get pm runtime: %d\n", ret); in px30_lvds_poweron()
339 return regmap_update_bits(lvds->grf, PX30_LVDS_GRF_PD_VO_CON1, in px30_lvds_poweron()
346 regmap_update_bits(lvds->grf, PX30_LVDS_GRF_PD_VO_CON1, in px30_lvds_poweroff()
350 pm_runtime_put(lvds->dev); in px30_lvds_poweroff()
358 if (lvds->output != DISPLAY_OUTPUT_LVDS) { in px30_lvds_grf_config()
359 DRM_DEV_ERROR(lvds->dev, "Unsupported display output %d\n", in px30_lvds_grf_config()
360 lvds->output); in px30_lvds_grf_config()
361 return -EINVAL; in px30_lvds_grf_config()
365 return regmap_update_bits(lvds->grf, PX30_LVDS_GRF_PD_VO_CON1, in px30_lvds_grf_config()
366 PX30_LVDS_FORMAT(lvds->format), in px30_lvds_grf_config()
367 PX30_LVDS_FORMAT(lvds->format)); in px30_lvds_grf_config()
373 int vop; in px30_lvds_set_vop_source() local
375 vop = drm_of_encoder_active_endpoint_id(lvds->dev->of_node, encoder); in px30_lvds_set_vop_source()
376 if (vop < 0) in px30_lvds_set_vop_source()
377 return vop; in px30_lvds_set_vop_source()
379 return regmap_update_bits(lvds->grf, PX30_LVDS_GRF_PD_VO_CON1, in px30_lvds_set_vop_source()
381 PX30_LVDS_VOP_SEL(vop)); in px30_lvds_set_vop_source()
387 struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; in px30_lvds_encoder_enable()
390 drm_panel_prepare(lvds->panel); in px30_lvds_encoder_enable()
394 DRM_DEV_ERROR(lvds->dev, "failed to power on LVDS: %d\n", ret); in px30_lvds_encoder_enable()
395 drm_panel_unprepare(lvds->panel); in px30_lvds_encoder_enable()
401 DRM_DEV_ERROR(lvds->dev, "failed to configure LVDS: %d\n", ret); in px30_lvds_encoder_enable()
402 drm_panel_unprepare(lvds->panel); in px30_lvds_encoder_enable()
408 DRM_DEV_ERROR(lvds->dev, "failed to set VOP source: %d\n", ret); in px30_lvds_encoder_enable()
409 drm_panel_unprepare(lvds->panel); in px30_lvds_encoder_enable()
413 drm_panel_enable(lvds->panel); in px30_lvds_encoder_enable()
420 drm_panel_disable(lvds->panel); in px30_lvds_encoder_disable()
422 drm_panel_unprepare(lvds->panel); in px30_lvds_encoder_disable()
446 lvds->regs = devm_ioremap_resource(lvds->dev, res); in rk3288_lvds_probe()
447 if (IS_ERR(lvds->regs)) in rk3288_lvds_probe()
448 return PTR_ERR(lvds->regs); in rk3288_lvds_probe()
450 lvds->pclk = devm_clk_get(lvds->dev, "pclk_lvds"); in rk3288_lvds_probe()
451 if (IS_ERR(lvds->pclk)) { in rk3288_lvds_probe()
452 DRM_DEV_ERROR(lvds->dev, "could not get pclk_lvds\n"); in rk3288_lvds_probe()
453 return PTR_ERR(lvds->pclk); in rk3288_lvds_probe()
456 lvds->pins = devm_kzalloc(lvds->dev, sizeof(*lvds->pins), in rk3288_lvds_probe()
458 if (!lvds->pins) in rk3288_lvds_probe()
459 return -ENOMEM; in rk3288_lvds_probe()
461 lvds->pins->p = devm_pinctrl_get(lvds->dev); in rk3288_lvds_probe()
462 if (IS_ERR(lvds->pins->p)) { in rk3288_lvds_probe()
463 DRM_DEV_ERROR(lvds->dev, "no pinctrl handle\n"); in rk3288_lvds_probe()
464 devm_kfree(lvds->dev, lvds->pins); in rk3288_lvds_probe()
465 lvds->pins = NULL; in rk3288_lvds_probe()
467 lvds->pins->default_state = in rk3288_lvds_probe()
468 pinctrl_lookup_state(lvds->pins->p, "lcdc"); in rk3288_lvds_probe()
469 if (IS_ERR(lvds->pins->default_state)) { in rk3288_lvds_probe()
470 DRM_DEV_ERROR(lvds->dev, "no default pinctrl state\n"); in rk3288_lvds_probe()
471 devm_kfree(lvds->dev, lvds->pins); in rk3288_lvds_probe()
472 lvds->pins = NULL; in rk3288_lvds_probe()
476 ret = clk_prepare(lvds->pclk); in rk3288_lvds_probe()
478 DRM_DEV_ERROR(lvds->dev, "failed to prepare pclk_lvds\n"); in rk3288_lvds_probe()
491 ret = regmap_update_bits(lvds->grf, PX30_LVDS_GRF_PD_VO_CON1, in px30_lvds_probe()
498 lvds->dphy = devm_phy_get(&pdev->dev, "dphy"); in px30_lvds_probe()
499 if (IS_ERR(lvds->dphy)) in px30_lvds_probe()
500 return PTR_ERR(lvds->dphy); in px30_lvds_probe()
502 phy_init(lvds->dphy); in px30_lvds_probe()
506 phy_set_mode(lvds->dphy, PHY_MODE_LVDS); in px30_lvds_probe()
510 return phy_power_on(lvds->dphy); in px30_lvds_probe()
525 .compatible = "rockchip,rk3288-lvds",
529 .compatible = "rockchip,px30-lvds",
549 lvds->drm_dev = drm_dev; in rockchip_lvds_bind()
550 port = of_graph_get_port_by_id(dev->of_node, 1); in rockchip_lvds_bind()
554 return -EINVAL; in rockchip_lvds_bind()
559 ret = drm_of_find_panel_or_bridge(dev->of_node, 1, endpoint_id, in rockchip_lvds_bind()
560 &lvds->panel, &lvds->bridge); in rockchip_lvds_bind()
568 ret = -EINVAL; in rockchip_lvds_bind()
572 ret = -EPROBE_DEFER; in rockchip_lvds_bind()
575 if (lvds->panel) in rockchip_lvds_bind()
576 remote = lvds->panel->dev->of_node; in rockchip_lvds_bind()
578 remote = lvds->bridge->of_node; in rockchip_lvds_bind()
579 if (of_property_read_string(dev->of_node, "rockchip,output", &name)) in rockchip_lvds_bind()
581 lvds->output = DISPLAY_OUTPUT_RGB; in rockchip_lvds_bind()
583 lvds->output = rockchip_lvds_name_to_output(name); in rockchip_lvds_bind()
585 if (lvds->output < 0) { in rockchip_lvds_bind()
587 ret = lvds->output; in rockchip_lvds_bind()
591 if (of_property_read_string(remote, "data-mapping", &name)) in rockchip_lvds_bind()
593 lvds->format = LVDS_VESA_18; in rockchip_lvds_bind()
595 lvds->format = rockchip_lvds_name_to_format(name); in rockchip_lvds_bind()
597 if (lvds->format < 0) { in rockchip_lvds_bind()
598 DRM_DEV_ERROR(dev, "invalid data-mapping format [%s]\n", name); in rockchip_lvds_bind()
599 ret = lvds->format; in rockchip_lvds_bind()
603 encoder = &lvds->encoder; in rockchip_lvds_bind()
604 encoder->possible_crtcs = drm_of_find_possible_crtcs(drm_dev, in rockchip_lvds_bind()
605 dev->of_node); in rockchip_lvds_bind()
609 DRM_DEV_ERROR(drm_dev->dev, in rockchip_lvds_bind()
614 drm_encoder_helper_add(encoder, lvds->soc_data->helper_funcs); in rockchip_lvds_bind()
616 if (lvds->panel) { in rockchip_lvds_bind()
617 connector = &lvds->connector; in rockchip_lvds_bind()
618 connector->dpms = DRM_MODE_DPMS_OFF; in rockchip_lvds_bind()
623 DRM_DEV_ERROR(drm_dev->dev, in rockchip_lvds_bind()
633 DRM_DEV_ERROR(drm_dev->dev, in rockchip_lvds_bind()
638 ret = drm_bridge_attach(encoder, lvds->bridge, NULL, 0); in rockchip_lvds_bind()
640 DRM_DEV_ERROR(drm_dev->dev, in rockchip_lvds_bind()
670 encoder_funcs = lvds->soc_data->helper_funcs; in rockchip_lvds_unbind()
671 encoder_funcs->disable(&lvds->encoder); in rockchip_lvds_unbind()
673 drm_connector_cleanup(&lvds->connector); in rockchip_lvds_unbind()
674 drm_encoder_cleanup(&lvds->encoder); in rockchip_lvds_unbind()
684 struct device *dev = &pdev->dev; in rockchip_lvds_probe()
689 if (!dev->of_node) in rockchip_lvds_probe()
690 return -ENODEV; in rockchip_lvds_probe()
692 lvds = devm_kzalloc(&pdev->dev, sizeof(*lvds), GFP_KERNEL); in rockchip_lvds_probe()
694 return -ENOMEM; in rockchip_lvds_probe()
696 lvds->dev = dev; in rockchip_lvds_probe()
697 match = of_match_node(rockchip_lvds_dt_ids, dev->of_node); in rockchip_lvds_probe()
699 return -ENODEV; in rockchip_lvds_probe()
700 lvds->soc_data = match->data; in rockchip_lvds_probe()
702 lvds->grf = syscon_regmap_lookup_by_phandle(dev->of_node, in rockchip_lvds_probe()
703 "rockchip,grf"); in rockchip_lvds_probe()
704 if (IS_ERR(lvds->grf)) { in rockchip_lvds_probe()
705 DRM_DEV_ERROR(dev, "missing rockchip,grf property\n"); in rockchip_lvds_probe()
706 return PTR_ERR(lvds->grf); in rockchip_lvds_probe()
709 ret = lvds->soc_data->probe(pdev, lvds); in rockchip_lvds_probe()
717 ret = component_add(&pdev->dev, &rockchip_lvds_component_ops); in rockchip_lvds_probe()
720 clk_unprepare(lvds->pclk); in rockchip_lvds_probe()
728 struct rockchip_lvds *lvds = dev_get_drvdata(&pdev->dev); in rockchip_lvds_remove()
730 component_del(&pdev->dev, &rockchip_lvds_component_ops); in rockchip_lvds_remove()
731 clk_unprepare(lvds->pclk); in rockchip_lvds_remove()
740 .name = "rockchip-lvds",