Lines Matching +full:imx6sx +full:- +full:lcdif

1 // SPDX-License-Identifier: GPL-2.0-or-later
7 * Copyright (C) 2008-2009 Freescale Semiconductor, Inc. All Rights Reserved.
12 #include <linux/dma-mapping.h>
81 clk_prepare_enable(mxsfb->clk_axi); in mxsfb_enable_axi_clk()
86 clk_disable_unprepare(mxsfb->clk_axi); in mxsfb_disable_axi_clk()
97 return ERR_PTR(-EINVAL); in mxsfb_fb_create()
99 if (mode_cmd->width * info->cpp[0] != mode_cmd->pitches[0]) { in mxsfb_fb_create()
100 dev_dbg(dev->dev, "Invalid pitch: fb width must match pitch\n"); in mxsfb_fb_create()
101 return ERR_PTR(-EINVAL); in mxsfb_fb_create()
119 struct drm_device *drm = mxsfb->drm; in mxsfb_attach_bridge()
125 ret = drm_of_find_panel_or_bridge(drm->dev->of_node, 0, 0, &panel, in mxsfb_attach_bridge()
131 bridge = devm_drm_panel_bridge_add_typed(drm->dev, panel, in mxsfb_attach_bridge()
138 return -ENODEV; in mxsfb_attach_bridge()
140 ret = drm_bridge_attach(&mxsfb->encoder, bridge, NULL, 0); in mxsfb_attach_bridge()
142 return dev_err_probe(drm->dev, ret, "Failed to attach bridge\n"); in mxsfb_attach_bridge()
144 mxsfb->bridge = bridge; in mxsfb_attach_bridge()
151 mxsfb->connector = drm_connector_list_iter_next(&iter); in mxsfb_attach_bridge()
160 struct mxsfb_drm_private *mxsfb = drm->dev_private; in mxsfb_irq_handler()
164 reg = readl(mxsfb->base + LCDC_CTRL1); in mxsfb_irq_handler()
167 drm_crtc_handle_vblank(&mxsfb->crtc); in mxsfb_irq_handler()
168 if (mxsfb->crc_active) { in mxsfb_irq_handler()
169 crc = readl(mxsfb->base + LCDC_V4_CRC_STAT); in mxsfb_irq_handler()
170 vbc = drm_crtc_accurate_vblank_count(&mxsfb->crtc); in mxsfb_irq_handler()
171 drm_crtc_add_crc_entry(&mxsfb->crtc, true, vbc, &crc); in mxsfb_irq_handler()
175 writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR); in mxsfb_irq_handler()
182 struct mxsfb_drm_private *mxsfb = drm->dev_private; in mxsfb_irq_disable()
187 writel(CTRL1_CUR_FRAME_DONE_IRQ_EN, mxsfb->base + LCDC_CTRL1 + REG_CLR); in mxsfb_irq_disable()
188 writel(CTRL1_CUR_FRAME_DONE_IRQ, mxsfb->base + LCDC_CTRL1 + REG_CLR); in mxsfb_irq_disable()
196 return -ENOTCONN; in mxsfb_irq_install()
200 return request_irq(irq, mxsfb_irq_handler, 0, dev->driver->name, dev); in mxsfb_irq_install()
205 struct mxsfb_drm_private *mxsfb = dev->dev_private; in mxsfb_irq_uninstall()
208 free_irq(mxsfb->irq, dev); in mxsfb_irq_uninstall()
214 struct platform_device *pdev = to_platform_device(drm->dev); in mxsfb_load()
219 mxsfb = devm_kzalloc(&pdev->dev, sizeof(*mxsfb), GFP_KERNEL); in mxsfb_load()
221 return -ENOMEM; in mxsfb_load()
223 mxsfb->drm = drm; in mxsfb_load()
224 drm->dev_private = mxsfb; in mxsfb_load()
225 mxsfb->devdata = devdata; in mxsfb_load()
228 mxsfb->base = devm_ioremap_resource(drm->dev, res); in mxsfb_load()
229 if (IS_ERR(mxsfb->base)) in mxsfb_load()
230 return PTR_ERR(mxsfb->base); in mxsfb_load()
232 mxsfb->clk = devm_clk_get(drm->dev, NULL); in mxsfb_load()
233 if (IS_ERR(mxsfb->clk)) in mxsfb_load()
234 return PTR_ERR(mxsfb->clk); in mxsfb_load()
236 mxsfb->clk_axi = devm_clk_get_optional(drm->dev, "axi"); in mxsfb_load()
237 if (IS_ERR(mxsfb->clk_axi)) in mxsfb_load()
238 return PTR_ERR(mxsfb->clk_axi); in mxsfb_load()
240 mxsfb->clk_disp_axi = devm_clk_get(drm->dev, "disp_axi"); in mxsfb_load()
241 if (IS_ERR(mxsfb->clk_disp_axi)) in mxsfb_load()
242 mxsfb->clk_disp_axi = NULL; in mxsfb_load()
244 ret = dma_set_mask_and_coherent(drm->dev, DMA_BIT_MASK(32)); in mxsfb_load()
248 pm_runtime_enable(drm->dev); in mxsfb_load()
255 dev_err(drm->dev, "Failed to initialize KMS pipeline\n"); in mxsfb_load()
259 ret = drm_vblank_init(drm, drm->mode_config.num_crtc); in mxsfb_load()
261 dev_err(drm->dev, "Failed to initialise vblank\n"); in mxsfb_load()
266 drm_crtc_vblank_off(&mxsfb->crtc); in mxsfb_load()
270 dev_err_probe(drm->dev, ret, "Cannot connect bridge\n"); in mxsfb_load()
274 drm->mode_config.min_width = MXSFB_MIN_XRES; in mxsfb_load()
275 drm->mode_config.min_height = MXSFB_MIN_YRES; in mxsfb_load()
276 drm->mode_config.max_width = MXSFB_MAX_XRES; in mxsfb_load()
277 drm->mode_config.max_height = MXSFB_MAX_YRES; in mxsfb_load()
278 drm->mode_config.funcs = &mxsfb_mode_config_funcs; in mxsfb_load()
279 drm->mode_config.helper_private = &mxsfb_mode_config_helpers; in mxsfb_load()
286 mxsfb->irq = ret; in mxsfb_load()
288 pm_runtime_get_sync(drm->dev); in mxsfb_load()
289 ret = mxsfb_irq_install(drm, mxsfb->irq); in mxsfb_load()
290 pm_runtime_put_sync(drm->dev); in mxsfb_load()
293 dev_err(drm->dev, "Failed to install IRQ handler\n"); in mxsfb_load()
306 pm_runtime_disable(drm->dev); in mxsfb_load()
316 pm_runtime_get_sync(drm->dev); in mxsfb_unload()
318 pm_runtime_put_sync(drm->dev); in mxsfb_unload()
320 drm->dev_private = NULL; in mxsfb_unload()
322 pm_runtime_disable(drm->dev); in mxsfb_unload()
331 .name = "mxsfb-drm",
339 { .compatible = "fsl,imx23-lcdif", .data = &mxsfb_devdata[MXSFB_V3], },
340 { .compatible = "fsl,imx28-lcdif", .data = &mxsfb_devdata[MXSFB_V4], },
341 { .compatible = "fsl,imx6sx-lcdif", .data = &mxsfb_devdata[MXSFB_V6], },
350 of_match_device(mxsfb_dt_ids, &pdev->dev); in mxsfb_probe()
353 if (!pdev->dev.of_node) in mxsfb_probe()
354 return -ENODEV; in mxsfb_probe()
356 drm = drm_dev_alloc(&mxsfb_driver, &pdev->dev); in mxsfb_probe()
360 ret = mxsfb_load(drm, of_id->data); in mxsfb_probe()