Lines Matching +full:panel +full:- +full:dpi

1 // SPDX-License-Identifier: GPL-2.0-only
7 * DOC: VC4 DPI module
9 * The VC4 DPI hardware supports MIPI DPI type 4 and Nokia ViSSI
10 * signals. On BCM2835, these can be routed out to GPIO0-27 with the
24 #include <linux/media-bus-format.h>
43 /* The format field takes the ORDER-shuffled pixel valve data and
79 /* Power gate to the device, full reset at 0 -> 1 transition */
86 /* General DPI hardware state. */
106 readl(dpi->regs + (offset)); \
112 writel(val, dpi->regs + (offset)); \
122 struct drm_device *dev = encoder->dev; in vc4_dpi_encoder_disable()
123 struct vc4_dpi *dpi = to_vc4_dpi(encoder); in vc4_dpi_encoder_disable() local
129 clk_disable_unprepare(dpi->pixel_clock); in vc4_dpi_encoder_disable()
136 struct drm_device *dev = encoder->dev; in vc4_dpi_encoder_enable()
137 struct drm_display_mode *mode = &encoder->crtc->mode; in vc4_dpi_encoder_enable()
138 struct vc4_dpi *dpi = to_vc4_dpi(encoder); in vc4_dpi_encoder_enable() local
145 /* Look up the connector attached to DPI so we can get the in vc4_dpi_encoder_enable()
152 if (connector_scan->encoder == encoder) { in vc4_dpi_encoder_enable()
163 if (connector->display_info.num_bus_formats) { in vc4_dpi_encoder_enable()
164 u32 bus_format = connector->display_info.bus_formats[0]; in vc4_dpi_encoder_enable()
208 if (connector->display_info.bus_flags & DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE) in vc4_dpi_encoder_enable()
211 if (connector->display_info.bus_flags & DRM_BUS_FLAG_DE_LOW) in vc4_dpi_encoder_enable()
215 if (mode->flags & DRM_MODE_FLAG_CSYNC) { in vc4_dpi_encoder_enable()
216 if (mode->flags & DRM_MODE_FLAG_NCSYNC) in vc4_dpi_encoder_enable()
221 if (mode->flags & DRM_MODE_FLAG_NHSYNC) in vc4_dpi_encoder_enable()
223 else if (!(mode->flags & DRM_MODE_FLAG_PHSYNC)) in vc4_dpi_encoder_enable()
226 if (mode->flags & DRM_MODE_FLAG_NVSYNC) in vc4_dpi_encoder_enable()
228 else if (!(mode->flags & DRM_MODE_FLAG_PVSYNC)) in vc4_dpi_encoder_enable()
237 ret = clk_set_rate(dpi->pixel_clock, mode->clock * 1000); in vc4_dpi_encoder_enable()
241 ret = clk_prepare_enable(dpi->pixel_clock); in vc4_dpi_encoder_enable()
251 if (mode->flags & DRM_MODE_FLAG_INTERLACE) in vc4_dpi_encoder_mode_valid()
265 struct drm_device *drm = encoder->dev; in vc4_dpi_late_register()
266 struct vc4_dpi *dpi = to_vc4_dpi(encoder); in vc4_dpi_late_register() local
268 vc4_debugfs_add_regset32(drm, "dpi_regs", &dpi->regset); in vc4_dpi_late_register()
278 { .compatible = "brcm,bcm2835-dpi", .data = NULL },
282 /* Sets up the next link in the display chain, whether it's a panel or
285 static int vc4_dpi_init_bridge(struct vc4_dpi *dpi) in vc4_dpi_init_bridge() argument
287 struct drm_device *drm = dpi->encoder.base.dev; in vc4_dpi_init_bridge()
288 struct device *dev = &dpi->pdev->dev; in vc4_dpi_init_bridge()
291 bridge = drmm_of_get_bridge(drm, dev->of_node, 0, 0); in vc4_dpi_init_bridge()
296 if (PTR_ERR(bridge) == -ENODEV) in vc4_dpi_init_bridge()
302 return drm_bridge_attach(&dpi->encoder.base, bridge, NULL, 0); in vc4_dpi_init_bridge()
307 struct vc4_dpi *dpi = ptr; in vc4_dpi_disable_clock() local
309 clk_disable_unprepare(dpi->core_clock); in vc4_dpi_disable_clock()
316 struct vc4_dpi *dpi; in vc4_dpi_bind() local
319 dpi = drmm_kzalloc(drm, sizeof(*dpi), GFP_KERNEL); in vc4_dpi_bind()
320 if (!dpi) in vc4_dpi_bind()
321 return -ENOMEM; in vc4_dpi_bind()
323 dpi->encoder.type = VC4_ENCODER_TYPE_DPI; in vc4_dpi_bind()
324 dpi->pdev = pdev; in vc4_dpi_bind()
325 dpi->regs = vc4_ioremap_regs(pdev, 0); in vc4_dpi_bind()
326 if (IS_ERR(dpi->regs)) in vc4_dpi_bind()
327 return PTR_ERR(dpi->regs); in vc4_dpi_bind()
328 dpi->regset.base = dpi->regs; in vc4_dpi_bind()
329 dpi->regset.regs = dpi_regs; in vc4_dpi_bind()
330 dpi->regset.nregs = ARRAY_SIZE(dpi_regs); in vc4_dpi_bind()
335 return -ENODEV; in vc4_dpi_bind()
338 dpi->core_clock = devm_clk_get(dev, "core"); in vc4_dpi_bind()
339 if (IS_ERR(dpi->core_clock)) { in vc4_dpi_bind()
340 ret = PTR_ERR(dpi->core_clock); in vc4_dpi_bind()
341 if (ret != -EPROBE_DEFER) in vc4_dpi_bind()
346 dpi->pixel_clock = devm_clk_get(dev, "pixel"); in vc4_dpi_bind()
347 if (IS_ERR(dpi->pixel_clock)) { in vc4_dpi_bind()
348 ret = PTR_ERR(dpi->pixel_clock); in vc4_dpi_bind()
349 if (ret != -EPROBE_DEFER) in vc4_dpi_bind()
354 ret = clk_prepare_enable(dpi->core_clock); in vc4_dpi_bind()
360 ret = devm_add_action_or_reset(dev, vc4_dpi_disable_clock, dpi); in vc4_dpi_bind()
364 ret = drmm_encoder_init(drm, &dpi->encoder.base, in vc4_dpi_bind()
371 drm_encoder_helper_add(&dpi->encoder.base, &vc4_dpi_encoder_helper_funcs); in vc4_dpi_bind()
373 ret = vc4_dpi_init_bridge(dpi); in vc4_dpi_bind()
377 dev_set_drvdata(dev, dpi); in vc4_dpi_bind()
388 return component_add(&pdev->dev, &vc4_dpi_ops); in vc4_dpi_dev_probe()
393 component_del(&pdev->dev, &vc4_dpi_ops); in vc4_dpi_dev_remove()