Lines Matching +full:rk3399 +full:- +full:grf
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>
44 * struct rockchip_dp_chip_data - splite the grf setting of kind of chips
45 * @lcdsel_grf_reg: grf register offset of lcdc select
65 struct regmap *grf; member
88 reset_control_assert(dp->rst); in rockchip_dp_pre_init()
90 reset_control_deassert(dp->rst); in rockchip_dp_pre_init()
100 ret = clk_prepare_enable(dp->pclk); in rockchip_dp_poweron_start()
102 DRM_DEV_ERROR(dp->dev, "failed to enable pclk %d\n", ret); in rockchip_dp_poweron_start()
108 DRM_DEV_ERROR(dp->dev, "failed to dp pre init %d\n", ret); in rockchip_dp_poweron_start()
109 clk_disable_unprepare(dp->pclk); in rockchip_dp_poweron_start()
120 clk_disable_unprepare(dp->pclk); in rockchip_dp_powerdown()
128 struct drm_display_info *di = &connector->display_info; in rockchip_dp_get_modes()
132 if ((di->color_formats & mask)) { in rockchip_dp_get_modes()
134 di->color_formats &= ~mask; in rockchip_dp_get_modes()
135 di->color_formats |= DRM_COLOR_FORMAT_RGB444; in rockchip_dp_get_modes()
136 di->bpc = 8; in rockchip_dp_get_modes()
173 return conn_state->crtc; in rockchip_dp_drm_get_new_crtc()
191 if (old_crtc_state && old_crtc_state->self_refresh_active) in rockchip_dp_drm_encoder_enable()
194 ret = drm_of_encoder_active_endpoint_id(dp->dev->of_node, encoder); in rockchip_dp_drm_encoder_enable()
199 val = dp->data->lcdsel_lit; in rockchip_dp_drm_encoder_enable()
201 val = dp->data->lcdsel_big; in rockchip_dp_drm_encoder_enable()
203 DRM_DEV_DEBUG(dp->dev, "vop %s output to dp\n", (ret) ? "LIT" : "BIG"); in rockchip_dp_drm_encoder_enable()
205 ret = clk_prepare_enable(dp->grfclk); in rockchip_dp_drm_encoder_enable()
207 DRM_DEV_ERROR(dp->dev, "failed to enable grfclk %d\n", ret); in rockchip_dp_drm_encoder_enable()
211 ret = regmap_write(dp->grf, dp->data->lcdsel_grf_reg, val); in rockchip_dp_drm_encoder_enable()
213 DRM_DEV_ERROR(dp->dev, "Could not write to GRF: %d\n", ret); in rockchip_dp_drm_encoder_enable()
215 clk_disable_unprepare(dp->grfclk); in rockchip_dp_drm_encoder_enable()
232 /* If we're not entering self-refresh, no need to wait for vact */ in rockchip_dp_drm_encoder_disable()
233 if (!new_crtc_state || !new_crtc_state->self_refresh_active) in rockchip_dp_drm_encoder_disable()
238 DRM_DEV_ERROR(dp->dev, "line flag irq timed out\n"); in rockchip_dp_drm_encoder_disable()
247 struct drm_display_info *di = &conn_state->connector->display_info; in rockchip_dp_drm_encoder_atomic_check()
257 s->output_mode = ROCKCHIP_OUT_MODE_AAAA; in rockchip_dp_drm_encoder_atomic_check()
258 s->output_type = DRM_MODE_CONNECTOR_eDP; in rockchip_dp_drm_encoder_atomic_check()
259 s->output_bpc = di->bpc; in rockchip_dp_drm_encoder_atomic_check()
274 struct device *dev = dp->dev; in rockchip_dp_of_probe()
275 struct device_node *np = dev->of_node; in rockchip_dp_of_probe()
277 dp->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf"); in rockchip_dp_of_probe()
278 if (IS_ERR(dp->grf)) { in rockchip_dp_of_probe()
279 DRM_DEV_ERROR(dev, "failed to get rockchip,grf property\n"); in rockchip_dp_of_probe()
280 return PTR_ERR(dp->grf); in rockchip_dp_of_probe()
283 dp->grfclk = devm_clk_get(dev, "grf"); in rockchip_dp_of_probe()
284 if (PTR_ERR(dp->grfclk) == -ENOENT) { in rockchip_dp_of_probe()
285 dp->grfclk = NULL; in rockchip_dp_of_probe()
286 } else if (PTR_ERR(dp->grfclk) == -EPROBE_DEFER) { in rockchip_dp_of_probe()
287 return -EPROBE_DEFER; in rockchip_dp_of_probe()
288 } else if (IS_ERR(dp->grfclk)) { in rockchip_dp_of_probe()
289 DRM_DEV_ERROR(dev, "failed to get grf clock\n"); in rockchip_dp_of_probe()
290 return PTR_ERR(dp->grfclk); in rockchip_dp_of_probe()
293 dp->pclk = devm_clk_get(dev, "pclk"); in rockchip_dp_of_probe()
294 if (IS_ERR(dp->pclk)) { in rockchip_dp_of_probe()
296 return PTR_ERR(dp->pclk); in rockchip_dp_of_probe()
299 dp->rst = devm_reset_control_get(dev, "dp"); in rockchip_dp_of_probe()
300 if (IS_ERR(dp->rst)) { in rockchip_dp_of_probe()
302 return PTR_ERR(dp->rst); in rockchip_dp_of_probe()
310 struct drm_encoder *encoder = &dp->encoder.encoder; in rockchip_dp_drm_create_encoder()
311 struct drm_device *drm_dev = dp->drm_dev; in rockchip_dp_drm_create_encoder()
312 struct device *dev = dp->dev; in rockchip_dp_drm_create_encoder()
315 encoder->possible_crtcs = drm_of_find_possible_crtcs(drm_dev, in rockchip_dp_drm_create_encoder()
316 dev->of_node); in rockchip_dp_drm_create_encoder()
317 DRM_DEBUG_KMS("possible_crtcs = 0x%x\n", encoder->possible_crtcs); in rockchip_dp_drm_create_encoder()
338 dp->drm_dev = drm_dev; in rockchip_dp_bind()
346 dp->plat_data.encoder = &dp->encoder.encoder; in rockchip_dp_bind()
348 ret = analogix_dp_bind(dp->adp, drm_dev); in rockchip_dp_bind()
354 dp->encoder.encoder.funcs->destroy(&dp->encoder.encoder); in rockchip_dp_bind()
363 analogix_dp_unbind(dp->adp); in rockchip_dp_unbind()
364 dp->encoder.encoder.funcs->destroy(&dp->encoder.encoder); in rockchip_dp_unbind()
374 struct device *dev = &pdev->dev; in rockchip_dp_probe()
382 return -ENODEV; in rockchip_dp_probe()
384 ret = drm_of_find_panel_or_bridge(dev->of_node, 1, 0, &panel, NULL); in rockchip_dp_probe()
390 return -ENOMEM; in rockchip_dp_probe()
392 dp->dev = dev; in rockchip_dp_probe()
393 dp->adp = ERR_PTR(-ENODEV); in rockchip_dp_probe()
394 dp->data = dp_data; in rockchip_dp_probe()
395 dp->plat_data.panel = panel; in rockchip_dp_probe()
396 dp->plat_data.dev_type = dp->data->chip_type; in rockchip_dp_probe()
397 dp->plat_data.power_on_start = rockchip_dp_poweron_start; in rockchip_dp_probe()
398 dp->plat_data.power_off = rockchip_dp_powerdown; in rockchip_dp_probe()
399 dp->plat_data.get_modes = rockchip_dp_get_modes; in rockchip_dp_probe()
407 dp->adp = analogix_dp_probe(dev, &dp->plat_data); in rockchip_dp_probe()
408 if (IS_ERR(dp->adp)) in rockchip_dp_probe()
409 return PTR_ERR(dp->adp); in rockchip_dp_probe()
418 analogix_dp_remove(dp->adp); in rockchip_dp_probe()
426 component_del(&pdev->dev, &rockchip_dp_component_ops); in rockchip_dp_remove()
427 analogix_dp_remove(dp->adp); in rockchip_dp_remove()
437 if (IS_ERR(dp->adp)) in rockchip_dp_suspend()
440 return analogix_dp_suspend(dp->adp); in rockchip_dp_suspend()
447 if (IS_ERR(dp->adp)) in rockchip_dp_resume()
450 return analogix_dp_resume(dp->adp); in rockchip_dp_resume()
476 {.compatible = "rockchip,rk3288-dp", .data = &rk3288_dp },
477 {.compatible = "rockchip,rk3399-edp", .data = &rk3399_edp },
486 .name = "rockchip-dp",