Lines Matching +full:rk3288 +full:- +full:vop
1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * Author: Andy Yan <andy.yan@rock-chips.com>
7 * Yakir Yang <ykk@rock-chips.com>
8 * Jeff Chen <jeff.chen@rock-chips.com>
46 * struct rockchip_dp_chip_data - splite the grf setting of kind of chips
48 * @lcdsel_big: reg value of selecting vop big for eDP
49 * @lcdsel_lit: reg value of selecting vop little for eDP
78 reset_control_assert(dp->rst); in rockchip_dp_pre_init()
80 reset_control_deassert(dp->rst); in rockchip_dp_pre_init()
90 ret = clk_prepare_enable(dp->pclk); in rockchip_dp_poweron_start()
92 DRM_DEV_ERROR(dp->dev, "failed to enable pclk %d\n", ret); in rockchip_dp_poweron_start()
98 DRM_DEV_ERROR(dp->dev, "failed to dp pre init %d\n", ret); in rockchip_dp_poweron_start()
99 clk_disable_unprepare(dp->pclk); in rockchip_dp_poweron_start()
110 clk_disable_unprepare(dp->pclk); in rockchip_dp_powerdown()
118 struct drm_display_info *di = &connector->display_info; in rockchip_dp_get_modes()
119 /* VOP couldn't output YUV video format for eDP rightly */ in rockchip_dp_get_modes()
122 if ((di->color_formats & mask)) { in rockchip_dp_get_modes()
124 di->color_formats &= ~mask; in rockchip_dp_get_modes()
125 di->color_formats |= DRM_COLOR_FORMAT_RGB444; in rockchip_dp_get_modes()
126 di->bpc = 8; in rockchip_dp_get_modes()
163 return conn_state->crtc; in rockchip_dp_drm_get_new_crtc()
181 if (old_crtc_state && old_crtc_state->self_refresh_active) in rockchip_dp_drm_encoder_enable()
184 ret = drm_of_encoder_active_endpoint_id(dp->dev->of_node, encoder); in rockchip_dp_drm_encoder_enable()
189 val = dp->data->lcdsel_lit; in rockchip_dp_drm_encoder_enable()
191 val = dp->data->lcdsel_big; in rockchip_dp_drm_encoder_enable()
193 DRM_DEV_DEBUG(dp->dev, "vop %s output to dp\n", (ret) ? "LIT" : "BIG"); in rockchip_dp_drm_encoder_enable()
195 ret = clk_prepare_enable(dp->grfclk); in rockchip_dp_drm_encoder_enable()
197 DRM_DEV_ERROR(dp->dev, "failed to enable grfclk %d\n", ret); in rockchip_dp_drm_encoder_enable()
201 ret = regmap_write(dp->grf, dp->data->lcdsel_grf_reg, val); in rockchip_dp_drm_encoder_enable()
203 DRM_DEV_ERROR(dp->dev, "Could not write to GRF: %d\n", ret); in rockchip_dp_drm_encoder_enable()
205 clk_disable_unprepare(dp->grfclk); in rockchip_dp_drm_encoder_enable()
222 /* If we're not entering self-refresh, no need to wait for vact */ in rockchip_dp_drm_encoder_disable()
223 if (!new_crtc_state || !new_crtc_state->self_refresh_active) in rockchip_dp_drm_encoder_disable()
228 DRM_DEV_ERROR(dp->dev, "line flag irq timed out\n"); in rockchip_dp_drm_encoder_disable()
237 struct drm_display_info *di = &conn_state->connector->display_info; in rockchip_dp_drm_encoder_atomic_check()
240 * The hardware IC designed that VOP must output the RGB10 video in rockchip_dp_drm_encoder_atomic_check()
242 * then eDP controller should cut down the video data, not via VOP in rockchip_dp_drm_encoder_atomic_check()
243 * controller, that's why we need to hardcode the VOP output mode in rockchip_dp_drm_encoder_atomic_check()
247 s->output_mode = ROCKCHIP_OUT_MODE_AAAA; in rockchip_dp_drm_encoder_atomic_check()
248 s->output_type = DRM_MODE_CONNECTOR_eDP; in rockchip_dp_drm_encoder_atomic_check()
249 s->output_bpc = di->bpc; in rockchip_dp_drm_encoder_atomic_check()
264 struct device *dev = dp->dev; in rockchip_dp_of_probe()
265 struct device_node *np = dev->of_node; in rockchip_dp_of_probe()
267 dp->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf"); in rockchip_dp_of_probe()
268 if (IS_ERR(dp->grf)) { in rockchip_dp_of_probe()
270 return PTR_ERR(dp->grf); in rockchip_dp_of_probe()
273 dp->grfclk = devm_clk_get(dev, "grf"); in rockchip_dp_of_probe()
274 if (PTR_ERR(dp->grfclk) == -ENOENT) { in rockchip_dp_of_probe()
275 dp->grfclk = NULL; in rockchip_dp_of_probe()
276 } else if (PTR_ERR(dp->grfclk) == -EPROBE_DEFER) { in rockchip_dp_of_probe()
277 return -EPROBE_DEFER; in rockchip_dp_of_probe()
278 } else if (IS_ERR(dp->grfclk)) { in rockchip_dp_of_probe()
280 return PTR_ERR(dp->grfclk); in rockchip_dp_of_probe()
283 dp->pclk = devm_clk_get(dev, "pclk"); in rockchip_dp_of_probe()
284 if (IS_ERR(dp->pclk)) { in rockchip_dp_of_probe()
286 return PTR_ERR(dp->pclk); in rockchip_dp_of_probe()
289 dp->rst = devm_reset_control_get(dev, "dp"); in rockchip_dp_of_probe()
290 if (IS_ERR(dp->rst)) { in rockchip_dp_of_probe()
292 return PTR_ERR(dp->rst); in rockchip_dp_of_probe()
300 struct drm_encoder *encoder = &dp->encoder; in rockchip_dp_drm_create_encoder()
301 struct drm_device *drm_dev = dp->drm_dev; in rockchip_dp_drm_create_encoder()
302 struct device *dev = dp->dev; in rockchip_dp_drm_create_encoder()
305 encoder->possible_crtcs = drm_of_find_possible_crtcs(drm_dev, in rockchip_dp_drm_create_encoder()
306 dev->of_node); in rockchip_dp_drm_create_encoder()
307 DRM_DEBUG_KMS("possible_crtcs = 0x%x\n", encoder->possible_crtcs); in rockchip_dp_drm_create_encoder()
328 dp->drm_dev = drm_dev; in rockchip_dp_bind()
336 dp->plat_data.encoder = &dp->encoder; in rockchip_dp_bind()
338 ret = analogix_dp_bind(dp->adp, drm_dev); in rockchip_dp_bind()
344 dp->encoder.funcs->destroy(&dp->encoder); in rockchip_dp_bind()
353 analogix_dp_unbind(dp->adp); in rockchip_dp_unbind()
354 dp->encoder.funcs->destroy(&dp->encoder); in rockchip_dp_unbind()
364 struct device *dev = &pdev->dev; in rockchip_dp_probe()
372 return -ENODEV; in rockchip_dp_probe()
374 ret = drm_of_find_panel_or_bridge(dev->of_node, 1, 0, &panel, NULL); in rockchip_dp_probe()
380 return -ENOMEM; in rockchip_dp_probe()
382 dp->dev = dev; in rockchip_dp_probe()
383 dp->adp = ERR_PTR(-ENODEV); in rockchip_dp_probe()
384 dp->data = dp_data; in rockchip_dp_probe()
385 dp->plat_data.panel = panel; in rockchip_dp_probe()
386 dp->plat_data.dev_type = dp->data->chip_type; in rockchip_dp_probe()
387 dp->plat_data.power_on_start = rockchip_dp_poweron_start; in rockchip_dp_probe()
388 dp->plat_data.power_off = rockchip_dp_powerdown; in rockchip_dp_probe()
389 dp->plat_data.get_modes = rockchip_dp_get_modes; in rockchip_dp_probe()
397 dp->adp = analogix_dp_probe(dev, &dp->plat_data); in rockchip_dp_probe()
398 if (IS_ERR(dp->adp)) in rockchip_dp_probe()
399 return PTR_ERR(dp->adp); in rockchip_dp_probe()
408 component_del(&pdev->dev, &rockchip_dp_component_ops); in rockchip_dp_remove()
409 analogix_dp_remove(dp->adp); in rockchip_dp_remove()
419 if (IS_ERR(dp->adp)) in rockchip_dp_suspend()
422 return analogix_dp_suspend(dp->adp); in rockchip_dp_suspend()
429 if (IS_ERR(dp->adp)) in rockchip_dp_resume()
432 return analogix_dp_resume(dp->adp); in rockchip_dp_resume()
458 {.compatible = "rockchip,rk3288-dp", .data = &rk3288_dp },
459 {.compatible = "rockchip,rk3399-edp", .data = &rk3399_edp },
468 .name = "rockchip-dp",