Lines Matching +full:keembay +full:- +full:display
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright © 2018-2020 Intel Corporation
34 ret = clk_prepare_enable(kmb->kmb_clk.clk_lcd); in kmb_display_clk_enable()
36 drm_err(&kmb->drm, "Failed to enable LCD clock: %d\n", ret); in kmb_display_clk_enable()
48 kmb->kmb_clk.clk_lcd = devm_clk_get(dev, "clk_lcd"); in kmb_initialize_clocks()
49 if (IS_ERR(kmb->kmb_clk.clk_lcd)) { in kmb_initialize_clocks()
50 drm_err(&kmb->drm, "clk_get() failed clk_lcd\n"); in kmb_initialize_clocks()
51 return PTR_ERR(kmb->kmb_clk.clk_lcd); in kmb_initialize_clocks()
54 kmb->kmb_clk.clk_pll0 = devm_clk_get(dev, "clk_pll0"); in kmb_initialize_clocks()
55 if (IS_ERR(kmb->kmb_clk.clk_pll0)) { in kmb_initialize_clocks()
56 drm_err(&kmb->drm, "clk_get() failed clk_pll0 "); in kmb_initialize_clocks()
57 return PTR_ERR(kmb->kmb_clk.clk_pll0); in kmb_initialize_clocks()
59 kmb->sys_clk_mhz = clk_get_rate(kmb->kmb_clk.clk_pll0) / 1000000; in kmb_initialize_clocks()
60 drm_info(&kmb->drm, "system clk = %d Mhz", kmb->sys_clk_mhz); in kmb_initialize_clocks()
62 ret = kmb_dsi_clk_init(kmb->kmb_dsi); in kmb_initialize_clocks()
65 clk_set_rate(kmb->kmb_clk.clk_lcd, KMB_LCD_DEFAULT_CLK); in kmb_initialize_clocks()
66 if (clk_get_rate(kmb->kmb_clk.clk_lcd) != KMB_LCD_DEFAULT_CLK) { in kmb_initialize_clocks()
67 drm_err(&kmb->drm, "failed to set to clk_lcd to %d\n", in kmb_initialize_clocks()
69 return -1; in kmb_initialize_clocks()
71 drm_dbg(&kmb->drm, "clk_lcd = %ld\n", clk_get_rate(kmb->kmb_clk.clk_lcd)); in kmb_initialize_clocks()
77 msscam = syscon_regmap_lookup_by_compatible("intel,keembay-msscam"); in kmb_initialize_clocks()
79 drm_err(&kmb->drm, "failed to get msscam syscon"); in kmb_initialize_clocks()
80 return -1; in kmb_initialize_clocks()
91 clk_disable_unprepare(kmb->kmb_clk.clk_lcd); in kmb_display_clk_disable()
104 return ERR_PTR(-ENOMEM); in kmb_map_mmio()
106 mem = devm_ioremap_resource(drm->dev, res); in kmb_map_mmio()
115 struct platform_device *pdev = to_platform_device(drm->dev); in kmb_hw_init()
120 kmb->lcd_mmio = kmb_map_mmio(drm, pdev, "lcd"); in kmb_hw_init()
121 if (IS_ERR(kmb->lcd_mmio)) { in kmb_hw_init()
122 drm_err(&kmb->drm, "failed to map LCD registers\n"); in kmb_hw_init()
123 return -ENOMEM; in kmb_hw_init()
127 ret = kmb_dsi_map_mmio(kmb->kmb_dsi); in kmb_hw_init()
131 /* Enable display clocks */ in kmb_hw_init()
132 kmb_initialize_clocks(kmb, &pdev->dev); in kmb_hw_init()
134 /* Register irqs here - section 17.3 in databook in kmb_hw_init()
135 * lists LCD at 79 and 82 for MIPI under MSS CPU - in kmb_hw_init()
143 drm_err(&kmb->drm, "irq_lcd not found"); in kmb_hw_init()
148 ret = of_reserved_mem_device_init(drm->dev); in kmb_hw_init()
149 if (ret && ret != -ENODEV) in kmb_hw_init()
152 spin_lock_init(&kmb->irq_lock); in kmb_hw_init()
154 kmb->irq_lcd = irq_lcd; in kmb_hw_init()
159 of_reserved_mem_device_release(drm->dev); in kmb_hw_init()
178 drm->mode_config.min_width = KMB_FB_MIN_WIDTH; in kmb_setup_mode_config()
179 drm->mode_config.min_height = KMB_FB_MIN_HEIGHT; in kmb_setup_mode_config()
180 drm->mode_config.max_width = KMB_FB_MAX_WIDTH; in kmb_setup_mode_config()
181 drm->mode_config.max_height = KMB_FB_MAX_HEIGHT; in kmb_setup_mode_config()
182 drm->mode_config.preferred_depth = 24; in kmb_setup_mode_config()
183 drm->mode_config.funcs = &kmb_mode_config_funcs; in kmb_setup_mode_config()
190 ret = kmb_dsi_encoder_init(drm, kmb->kmb_dsi); in kmb_setup_mode_config()
192 kmb->crtc.port = of_graph_get_port_by_id(drm->dev->of_node, 0); in kmb_setup_mode_config()
193 ret = drm_vblank_init(drm, drm->mode_config.num_crtc); in kmb_setup_mode_config()
196 pm_runtime_disable(drm->dev); in kmb_setup_mode_config()
213 spin_lock(&kmb->irq_lock); in handle_lcd_irq()
225 if (kmb->plane_status[plane_id].disable) { in handle_lcd_irq()
232 kmb->plane_status[plane_id].ctrl); in handle_lcd_irq()
247 kmb->plane_status[plane_id].disable = false; in handle_lcd_irq()
250 if (kmb->kmb_under_flow) { in handle_lcd_irq()
252 dma0_state = (kmb->layer_no == 0) ? in handle_lcd_irq()
254 dma1_state = (kmb->layer_no == 0) ? in handle_lcd_irq()
266 LCD_LAYERn_DMA_CFG(kmb->layer_no), in handle_lcd_irq()
269 kmb->kmb_flush_done = 1; in handle_lcd_irq()
270 kmb->kmb_under_flow = 0; in handle_lcd_irq()
287 if (kmb->kmb_flush_done) { in handle_lcd_irq()
290 (kmb->layer_no), in handle_lcd_irq()
292 kmb->kmb_flush_done = 0; in handle_lcd_irq()
294 drm_crtc_handle_vblank(&kmb->crtc); in handle_lcd_irq()
307 /* LAYER0 - VL0 */ in handle_lcd_irq()
311 kmb->kmb_under_flow++; in handle_lcd_irq()
312 drm_info(&kmb->drm, in handle_lcd_irq()
314 val, kmb->kmb_under_flow); in handle_lcd_irq()
328 kmb->layer_no = 0; in handle_lcd_irq()
332 drm_dbg(&kmb->drm, in handle_lcd_irq()
335 drm_dbg(&kmb->drm, in handle_lcd_irq()
338 drm_dbg(&kmb->drm, in handle_lcd_irq()
341 /* LAYER1 - VL1 */ in handle_lcd_irq()
345 kmb->kmb_under_flow++; in handle_lcd_irq()
346 drm_info(&kmb->drm, in handle_lcd_irq()
348 val, kmb->kmb_under_flow); in handle_lcd_irq()
361 kmb->layer_no = 1; in handle_lcd_irq()
364 /* LAYER1 - VL1 */ in handle_lcd_irq()
366 drm_dbg(&kmb->drm, in handle_lcd_irq()
369 drm_dbg(&kmb->drm, in handle_lcd_irq()
372 drm_dbg(&kmb->drm, in handle_lcd_irq()
375 /* LAYER2 - GL0 */ in handle_lcd_irq()
377 drm_dbg(&kmb->drm, in handle_lcd_irq()
380 drm_dbg(&kmb->drm, in handle_lcd_irq()
383 /* LAYER3 - GL1 */ in handle_lcd_irq()
385 drm_dbg(&kmb->drm, in handle_lcd_irq()
388 drm_dbg(&kmb->drm, in handle_lcd_irq()
392 spin_unlock(&kmb->irq_lock); in handle_lcd_irq()
422 return -ENOTCONN; in kmb_irq_install()
426 return request_irq(irq, kmb_isr, 0, drm->driver->name, drm); in kmb_irq_install()
434 free_irq(kmb->irq_lcd, drm); in kmb_irq_uninstall()
446 .name = "kmb-drm",
447 .desc = "KEEMBAY DISPLAY DRIVER",
455 struct device *dev = &pdev->dev; in kmb_remove()
461 of_node_put(kmb->crtc.port); in kmb_remove()
462 kmb->crtc.port = NULL; in kmb_remove()
463 pm_runtime_get_sync(drm->dev); in kmb_remove()
465 pm_runtime_put_sync(drm->dev); in kmb_remove()
466 pm_runtime_disable(drm->dev); in kmb_remove()
468 of_reserved_mem_device_release(drm->dev); in kmb_remove()
476 kmb_dsi_host_unregister(kmb->kmb_dsi); in kmb_remove()
482 struct device *dev = get_device(&pdev->dev); in kmb_probe()
489 /* The bridge (ADV 7535) will return -EPROBE_DEFER until it in kmb_probe()
492 * -EPROBE_DEFER until the bridge is loaded. Probe will be called again in kmb_probe()
496 dsi_in = of_graph_get_endpoint_by_regs(dev->of_node, 0, 0); in kmb_probe()
499 return -EINVAL; in kmb_probe()
505 return -EINVAL; in kmb_probe()
513 return -EINVAL; in kmb_probe()
518 ret = kmb_dsi_host_bridge_init(get_device(&dsi_pdev->dev)); in kmb_probe()
520 if (ret == -EPROBE_DEFER) { in kmb_probe()
521 return -EPROBE_DEFER; in kmb_probe()
533 dev_set_drvdata(dev, &kmb->drm); in kmb_probe()
536 kmb->kmb_dsi = kmb_dsi_init(dsi_pdev); in kmb_probe()
537 if (IS_ERR(kmb->kmb_dsi)) { in kmb_probe()
538 drm_err(&kmb->drm, "failed to initialize DSI\n"); in kmb_probe()
539 ret = PTR_ERR(kmb->kmb_dsi); in kmb_probe()
543 kmb->kmb_dsi->dev = &dsi_pdev->dev; in kmb_probe()
544 kmb->kmb_dsi->pdev = dsi_pdev; in kmb_probe()
545 ret = kmb_hw_init(&kmb->drm, 0); in kmb_probe()
549 ret = kmb_setup_mode_config(&kmb->drm); in kmb_probe()
553 ret = kmb_irq_install(&kmb->drm, kmb->irq_lcd); in kmb_probe()
555 drm_err(&kmb->drm, "failed to install IRQ handler\n"); in kmb_probe()
559 drm_kms_helper_poll_init(&kmb->drm); in kmb_probe()
562 ret = drm_dev_register(&kmb->drm, 0); in kmb_probe()
566 drm_client_setup(&kmb->drm, NULL); in kmb_probe()
571 drm_kms_helper_poll_fini(&kmb->drm); in kmb_probe()
573 pm_runtime_disable(kmb->drm.dev); in kmb_probe()
575 drm_crtc_cleanup(&kmb->crtc); in kmb_probe()
576 drm_mode_config_cleanup(&kmb->drm); in kmb_probe()
579 kmb_dsi_host_unregister(kmb->kmb_dsi); in kmb_probe()
585 {.compatible = "intel,keembay-display"},
598 kmb->state = drm_atomic_helper_suspend(drm); in kmb_pm_suspend()
599 if (IS_ERR(kmb->state)) { in kmb_pm_suspend()
601 return PTR_ERR(kmb->state); in kmb_pm_suspend()
615 drm_atomic_helper_resume(drm, kmb->state); in kmb_pm_resume()
627 .name = "kmb-drm",
636 MODULE_DESCRIPTION("Keembay Display driver");