Lines Matching full:lvds

40  * struct rockchip_lvds_soc_data - rockchip lvds Soc private data
41 * @probe: LVDS platform probe function
42 * @helper_funcs: LVDS connector helper functions
45 int (*probe)(struct platform_device *pdev, struct rockchip_lvds *lvds);
56 int output; /* rgb lvds or dual lvds output */
78 static inline void rk3288_writel(struct rockchip_lvds *lvds, u32 offset, in rk3288_writel() argument
81 writel_relaxed(val, lvds->regs + offset); in rk3288_writel()
82 if (lvds->output == DISPLAY_OUTPUT_LVDS) in rk3288_writel()
84 writel_relaxed(val, lvds->regs + offset + RK3288_LVDS_CH1_OFFSET); in rk3288_writel()
103 else if (strncmp(s, "lvds", 4) == 0) in rockchip_lvds_name_to_output()
121 struct rockchip_lvds *lvds = connector_to_lvds(connector); in rockchip_lvds_connector_get_modes() local
122 struct drm_panel *panel = lvds->panel; in rockchip_lvds_connector_get_modes()
145 static int rk3288_lvds_poweron(struct rockchip_lvds *lvds) in rk3288_lvds_poweron() argument
150 ret = clk_enable(lvds->pclk); in rk3288_lvds_poweron()
152 DRM_DEV_ERROR(lvds->dev, "failed to enable lvds pclk %d\n", ret); in rk3288_lvds_poweron()
155 ret = pm_runtime_resume_and_get(lvds->dev); in rk3288_lvds_poweron()
157 DRM_DEV_ERROR(lvds->dev, "failed to get pm runtime: %d\n", ret); in rk3288_lvds_poweron()
158 clk_disable(lvds->pclk); in rk3288_lvds_poweron()
164 if (lvds->output == DISPLAY_OUTPUT_RGB) { in rk3288_lvds_poweron()
167 rk3288_writel(lvds, RK3288_LVDS_CH0_REG0, val); in rk3288_lvds_poweron()
168 rk3288_writel(lvds, RK3288_LVDS_CH0_REG2, in rk3288_lvds_poweron()
170 rk3288_writel(lvds, RK3288_LVDS_CH0_REG4, in rk3288_lvds_poweron()
177 rk3288_writel(lvds, RK3288_LVDS_CH0_REG5, in rk3288_lvds_poweron()
187 rk3288_writel(lvds, RK3288_LVDS_CH0_REG0, val); in rk3288_lvds_poweron()
188 rk3288_writel(lvds, RK3288_LVDS_CH0_REG1, in rk3288_lvds_poweron()
195 rk3288_writel(lvds, RK3288_LVDS_CH0_REG2, in rk3288_lvds_poweron()
204 rk3288_writel(lvds, RK3288_LVDS_CH0_REG4, 0x00); in rk3288_lvds_poweron()
205 rk3288_writel(lvds, RK3288_LVDS_CH0_REG5, 0x00); in rk3288_lvds_poweron()
207 rk3288_writel(lvds, RK3288_LVDS_CH0_REG3, in rk3288_lvds_poweron()
209 rk3288_writel(lvds, RK3288_LVDS_CH0_REGD, in rk3288_lvds_poweron()
211 rk3288_writel(lvds, RK3288_LVDS_CH0_REG20, in rk3288_lvds_poweron()
214 rk3288_writel(lvds, RK3288_LVDS_CFG_REGC, in rk3288_lvds_poweron()
216 rk3288_writel(lvds, RK3288_LVDS_CFG_REG21, in rk3288_lvds_poweron()
222 static void rk3288_lvds_poweroff(struct rockchip_lvds *lvds) in rk3288_lvds_poweroff() argument
227 rk3288_writel(lvds, RK3288_LVDS_CFG_REG21, in rk3288_lvds_poweroff()
229 rk3288_writel(lvds, RK3288_LVDS_CFG_REGC, in rk3288_lvds_poweroff()
233 ret = regmap_write(lvds->grf, RK3288_LVDS_GRF_SOC_CON7, val); in rk3288_lvds_poweroff()
235 DRM_DEV_ERROR(lvds->dev, "Could not write to GRF: %d\n", ret); in rk3288_lvds_poweroff()
237 pm_runtime_put(lvds->dev); in rk3288_lvds_poweroff()
238 clk_disable(lvds->pclk); in rk3288_lvds_poweroff()
244 struct rockchip_lvds *lvds = encoder_to_lvds(encoder); in rk3288_lvds_grf_config() local
251 if (lvds->output == DISPLAY_OUTPUT_RGB) in rk3288_lvds_grf_config()
252 if (lvds->pins && !IS_ERR(lvds->pins->default_state)) in rk3288_lvds_grf_config()
253 pinctrl_select_state(lvds->pins->p, in rk3288_lvds_grf_config()
254 lvds->pins->default_state); in rk3288_lvds_grf_config()
255 val = lvds->format | LVDS_CH0_EN; in rk3288_lvds_grf_config()
256 if (lvds->output == DISPLAY_OUTPUT_RGB) in rk3288_lvds_grf_config()
258 else if (lvds->output == DISPLAY_OUTPUT_DUAL_LVDS) in rk3288_lvds_grf_config()
266 ret = regmap_write(lvds->grf, RK3288_LVDS_GRF_SOC_CON7, val); in rk3288_lvds_grf_config()
268 DRM_DEV_ERROR(lvds->dev, "Could not write to GRF: %d\n", ret); in rk3288_lvds_grf_config()
273 static int rk3288_lvds_set_vop_source(struct rockchip_lvds *lvds, in rk3288_lvds_set_vop_source() argument
279 ret = drm_of_encoder_active_endpoint_id(lvds->dev->of_node, encoder); in rk3288_lvds_set_vop_source()
287 ret = regmap_write(lvds->grf, RK3288_LVDS_GRF_SOC_CON6, val); in rk3288_lvds_set_vop_source()
296 struct rockchip_lvds *lvds = encoder_to_lvds(encoder); in rk3288_lvds_encoder_enable() local
300 drm_panel_prepare(lvds->panel); in rk3288_lvds_encoder_enable()
302 ret = rk3288_lvds_poweron(lvds); in rk3288_lvds_encoder_enable()
304 DRM_DEV_ERROR(lvds->dev, "failed to power on 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 configure LVDS: %d\n", ret); in rk3288_lvds_encoder_enable()
312 drm_panel_unprepare(lvds->panel); in rk3288_lvds_encoder_enable()
316 ret = rk3288_lvds_set_vop_source(lvds, encoder); in rk3288_lvds_encoder_enable()
318 DRM_DEV_ERROR(lvds->dev, "failed to set VOP source: %d\n", ret); in rk3288_lvds_encoder_enable()
319 drm_panel_unprepare(lvds->panel); in rk3288_lvds_encoder_enable()
323 drm_panel_enable(lvds->panel); in rk3288_lvds_encoder_enable()
328 struct rockchip_lvds *lvds = encoder_to_lvds(encoder); in rk3288_lvds_encoder_disable() local
330 drm_panel_disable(lvds->panel); in rk3288_lvds_encoder_disable()
331 rk3288_lvds_poweroff(lvds); in rk3288_lvds_encoder_disable()
332 drm_panel_unprepare(lvds->panel); in rk3288_lvds_encoder_disable()
335 static int px30_lvds_poweron(struct rockchip_lvds *lvds) in px30_lvds_poweron() argument
339 ret = pm_runtime_resume_and_get(lvds->dev); in px30_lvds_poweron()
341 DRM_DEV_ERROR(lvds->dev, "failed to get pm runtime: %d\n", ret); in px30_lvds_poweron()
345 /* Enable LVDS mode */ in px30_lvds_poweron()
346 ret = regmap_update_bits(lvds->grf, PX30_LVDS_GRF_PD_VO_CON1, in px30_lvds_poweron()
350 pm_runtime_put(lvds->dev); in px30_lvds_poweron()
355 static void px30_lvds_poweroff(struct rockchip_lvds *lvds) in px30_lvds_poweroff() argument
357 regmap_update_bits(lvds->grf, PX30_LVDS_GRF_PD_VO_CON1, in px30_lvds_poweroff()
361 pm_runtime_put(lvds->dev); in px30_lvds_poweroff()
367 struct rockchip_lvds *lvds = encoder_to_lvds(encoder); in px30_lvds_grf_config() local
369 if (lvds->output != DISPLAY_OUTPUT_LVDS) { in px30_lvds_grf_config()
370 DRM_DEV_ERROR(lvds->dev, "Unsupported display output %d\n", in px30_lvds_grf_config()
371 lvds->output); in px30_lvds_grf_config()
376 return regmap_update_bits(lvds->grf, PX30_LVDS_GRF_PD_VO_CON1, in px30_lvds_grf_config()
377 PX30_LVDS_FORMAT(lvds->format), in px30_lvds_grf_config()
378 PX30_LVDS_FORMAT(lvds->format)); in px30_lvds_grf_config()
381 static int px30_lvds_set_vop_source(struct rockchip_lvds *lvds, in px30_lvds_set_vop_source() argument
386 vop = drm_of_encoder_active_endpoint_id(lvds->dev->of_node, encoder); in px30_lvds_set_vop_source()
390 return regmap_update_bits(lvds->grf, PX30_LVDS_GRF_PD_VO_CON1, in px30_lvds_set_vop_source()
397 struct rockchip_lvds *lvds = encoder_to_lvds(encoder); in px30_lvds_encoder_enable() local
401 drm_panel_prepare(lvds->panel); in px30_lvds_encoder_enable()
403 ret = px30_lvds_poweron(lvds); in px30_lvds_encoder_enable()
405 DRM_DEV_ERROR(lvds->dev, "failed to power on LVDS: %d\n", ret); in px30_lvds_encoder_enable()
406 drm_panel_unprepare(lvds->panel); in px30_lvds_encoder_enable()
412 DRM_DEV_ERROR(lvds->dev, "failed to configure LVDS: %d\n", ret); in px30_lvds_encoder_enable()
413 drm_panel_unprepare(lvds->panel); in px30_lvds_encoder_enable()
417 ret = px30_lvds_set_vop_source(lvds, encoder); in px30_lvds_encoder_enable()
419 DRM_DEV_ERROR(lvds->dev, "failed to set VOP source: %d\n", ret); in px30_lvds_encoder_enable()
420 drm_panel_unprepare(lvds->panel); in px30_lvds_encoder_enable()
424 drm_panel_enable(lvds->panel); in px30_lvds_encoder_enable()
429 struct rockchip_lvds *lvds = encoder_to_lvds(encoder); in px30_lvds_encoder_disable() local
431 drm_panel_disable(lvds->panel); in px30_lvds_encoder_disable()
432 px30_lvds_poweroff(lvds); in px30_lvds_encoder_disable()
433 drm_panel_unprepare(lvds->panel); in px30_lvds_encoder_disable()
451 struct rockchip_lvds *lvds) in rk3288_lvds_probe() argument
455 lvds->regs = devm_platform_ioremap_resource(pdev, 0); in rk3288_lvds_probe()
456 if (IS_ERR(lvds->regs)) in rk3288_lvds_probe()
457 return PTR_ERR(lvds->regs); in rk3288_lvds_probe()
459 lvds->pclk = devm_clk_get(lvds->dev, "pclk_lvds"); in rk3288_lvds_probe()
460 if (IS_ERR(lvds->pclk)) { in rk3288_lvds_probe()
461 DRM_DEV_ERROR(lvds->dev, "could not get pclk_lvds\n"); in rk3288_lvds_probe()
462 return PTR_ERR(lvds->pclk); in rk3288_lvds_probe()
465 lvds->pins = devm_kzalloc(lvds->dev, sizeof(*lvds->pins), in rk3288_lvds_probe()
467 if (!lvds->pins) in rk3288_lvds_probe()
470 lvds->pins->p = devm_pinctrl_get(lvds->dev); in rk3288_lvds_probe()
471 if (IS_ERR(lvds->pins->p)) { in rk3288_lvds_probe()
472 DRM_DEV_ERROR(lvds->dev, "no pinctrl handle\n"); in rk3288_lvds_probe()
473 devm_kfree(lvds->dev, lvds->pins); in rk3288_lvds_probe()
474 lvds->pins = NULL; in rk3288_lvds_probe()
476 lvds->pins->default_state = in rk3288_lvds_probe()
477 pinctrl_lookup_state(lvds->pins->p, "lcdc"); in rk3288_lvds_probe()
478 if (IS_ERR(lvds->pins->default_state)) { in rk3288_lvds_probe()
479 DRM_DEV_ERROR(lvds->dev, "no default pinctrl state\n"); in rk3288_lvds_probe()
480 devm_kfree(lvds->dev, lvds->pins); in rk3288_lvds_probe()
481 lvds->pins = NULL; in rk3288_lvds_probe()
485 ret = clk_prepare(lvds->pclk); in rk3288_lvds_probe()
487 DRM_DEV_ERROR(lvds->dev, "failed to prepare pclk_lvds\n"); in rk3288_lvds_probe()
495 struct rockchip_lvds *lvds) in px30_lvds_probe() argument
500 ret = regmap_update_bits(lvds->grf, PX30_LVDS_GRF_PD_VO_CON1, in px30_lvds_probe()
507 lvds->dphy = devm_phy_get(&pdev->dev, "dphy"); in px30_lvds_probe()
508 if (IS_ERR(lvds->dphy)) in px30_lvds_probe()
509 return PTR_ERR(lvds->dphy); in px30_lvds_probe()
511 ret = phy_init(lvds->dphy); in px30_lvds_probe()
515 ret = phy_set_mode(lvds->dphy, PHY_MODE_LVDS); in px30_lvds_probe()
519 return phy_power_on(lvds->dphy); in px30_lvds_probe()
534 .compatible = "rockchip,rk3288-lvds",
538 .compatible = "rockchip,px30-lvds",
548 struct rockchip_lvds *lvds = dev_get_drvdata(dev); in rockchip_lvds_bind() local
558 lvds->drm_dev = drm_dev; in rockchip_lvds_bind()
562 "can't found port point, please init lvds panel port!\n"); in rockchip_lvds_bind()
569 &lvds->panel, &lvds->bridge); in rockchip_lvds_bind()
576 DRM_DEV_ERROR(dev, "lvds port does not have any children\n"); in rockchip_lvds_bind()
583 if (lvds->panel) in rockchip_lvds_bind()
584 remote = lvds->panel->dev->of_node; in rockchip_lvds_bind()
586 remote = lvds->bridge->of_node; in rockchip_lvds_bind()
589 lvds->output = DISPLAY_OUTPUT_RGB; in rockchip_lvds_bind()
591 lvds->output = rockchip_lvds_name_to_output(name); in rockchip_lvds_bind()
593 if (lvds->output < 0) { in rockchip_lvds_bind()
595 ret = lvds->output; in rockchip_lvds_bind()
601 lvds->format = LVDS_VESA_18; in rockchip_lvds_bind()
603 lvds->format = rockchip_lvds_name_to_format(name); in rockchip_lvds_bind()
605 if (lvds->format < 0) { in rockchip_lvds_bind()
607 ret = lvds->format; in rockchip_lvds_bind()
611 encoder = &lvds->encoder.encoder; in rockchip_lvds_bind()
622 drm_encoder_helper_add(encoder, lvds->soc_data->helper_funcs); in rockchip_lvds_bind()
623 connector = &lvds->connector; in rockchip_lvds_bind()
625 if (lvds->panel) { in rockchip_lvds_bind()
639 ret = drm_bridge_attach(encoder, lvds->bridge, NULL, in rockchip_lvds_bind()
644 connector = drm_bridge_connector_init(lvds->drm_dev, encoder); in rockchip_lvds_bind()
682 struct rockchip_lvds *lvds = dev_get_drvdata(dev); in rockchip_lvds_unbind() local
685 encoder_funcs = lvds->soc_data->helper_funcs; in rockchip_lvds_unbind()
686 encoder_funcs->disable(&lvds->encoder.encoder); in rockchip_lvds_unbind()
688 drm_connector_cleanup(&lvds->connector); in rockchip_lvds_unbind()
689 drm_encoder_cleanup(&lvds->encoder.encoder); in rockchip_lvds_unbind()
700 struct rockchip_lvds *lvds; in rockchip_lvds_probe() local
707 lvds = devm_kzalloc(&pdev->dev, sizeof(*lvds), GFP_KERNEL); in rockchip_lvds_probe()
708 if (!lvds) in rockchip_lvds_probe()
711 lvds->dev = dev; in rockchip_lvds_probe()
715 lvds->soc_data = match->data; in rockchip_lvds_probe()
717 lvds->grf = syscon_regmap_lookup_by_phandle(dev->of_node, in rockchip_lvds_probe()
719 if (IS_ERR(lvds->grf)) { in rockchip_lvds_probe()
721 return PTR_ERR(lvds->grf); in rockchip_lvds_probe()
724 ret = lvds->soc_data->probe(pdev, lvds); in rockchip_lvds_probe()
730 dev_set_drvdata(dev, lvds); in rockchip_lvds_probe()
735 clk_unprepare(lvds->pclk); in rockchip_lvds_probe()
743 struct rockchip_lvds *lvds = platform_get_drvdata(pdev); in rockchip_lvds_remove() local
746 clk_unprepare(lvds->pclk); in rockchip_lvds_remove()
753 .name = "rockchip-lvds",