Lines Matching +full:keembay +full:- +full:msscam

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright © 2018-2020 Intel Corporation
33 ret = clk_prepare_enable(kmb->kmb_clk.clk_lcd); in kmb_display_clk_enable()
35 drm_err(&kmb->drm, "Failed to enable LCD clock: %d\n", ret); in kmb_display_clk_enable()
45 struct regmap *msscam; in kmb_initialize_clocks() local
47 kmb->kmb_clk.clk_lcd = devm_clk_get(dev, "clk_lcd"); in kmb_initialize_clocks()
48 if (IS_ERR(kmb->kmb_clk.clk_lcd)) { in kmb_initialize_clocks()
49 drm_err(&kmb->drm, "clk_get() failed clk_lcd\n"); in kmb_initialize_clocks()
50 return PTR_ERR(kmb->kmb_clk.clk_lcd); in kmb_initialize_clocks()
53 kmb->kmb_clk.clk_pll0 = devm_clk_get(dev, "clk_pll0"); in kmb_initialize_clocks()
54 if (IS_ERR(kmb->kmb_clk.clk_pll0)) { in kmb_initialize_clocks()
55 drm_err(&kmb->drm, "clk_get() failed clk_pll0 "); in kmb_initialize_clocks()
56 return PTR_ERR(kmb->kmb_clk.clk_pll0); in kmb_initialize_clocks()
58 kmb->sys_clk_mhz = clk_get_rate(kmb->kmb_clk.clk_pll0) / 1000000; in kmb_initialize_clocks()
59 drm_info(&kmb->drm, "system clk = %d Mhz", kmb->sys_clk_mhz); in kmb_initialize_clocks()
61 ret = kmb_dsi_clk_init(kmb->kmb_dsi); in kmb_initialize_clocks()
64 clk_set_rate(kmb->kmb_clk.clk_lcd, KMB_LCD_DEFAULT_CLK); in kmb_initialize_clocks()
65 if (clk_get_rate(kmb->kmb_clk.clk_lcd) != KMB_LCD_DEFAULT_CLK) { in kmb_initialize_clocks()
66 drm_err(&kmb->drm, "failed to set to clk_lcd to %d\n", in kmb_initialize_clocks()
68 return -1; in kmb_initialize_clocks()
70 drm_dbg(&kmb->drm, "clk_lcd = %ld\n", clk_get_rate(kmb->kmb_clk.clk_lcd)); in kmb_initialize_clocks()
76 msscam = syscon_regmap_lookup_by_compatible("intel,keembay-msscam"); in kmb_initialize_clocks()
77 if (IS_ERR(msscam)) { in kmb_initialize_clocks()
78 drm_err(&kmb->drm, "failed to get msscam syscon"); in kmb_initialize_clocks()
79 return -1; in kmb_initialize_clocks()
83 regmap_update_bits(msscam, MSS_CAM_CLK_CTRL, 0x1fff, 0x1fff); in kmb_initialize_clocks()
84 regmap_update_bits(msscam, MSS_CAM_RSTN_CTRL, 0xffffffff, 0xffffffff); in kmb_initialize_clocks()
90 clk_disable_unprepare(kmb->kmb_clk.clk_lcd); in kmb_display_clk_disable()
103 return ERR_PTR(-ENOMEM); in kmb_map_mmio()
105 mem = devm_ioremap_resource(drm->dev, res); in kmb_map_mmio()
114 struct platform_device *pdev = to_platform_device(drm->dev); in kmb_hw_init()
119 kmb->lcd_mmio = kmb_map_mmio(drm, pdev, "lcd"); in kmb_hw_init()
120 if (IS_ERR(kmb->lcd_mmio)) { in kmb_hw_init()
121 drm_err(&kmb->drm, "failed to map LCD registers\n"); in kmb_hw_init()
122 return -ENOMEM; in kmb_hw_init()
126 ret = kmb_dsi_map_mmio(kmb->kmb_dsi); in kmb_hw_init()
131 kmb_initialize_clocks(kmb, &pdev->dev); in kmb_hw_init()
133 /* Register irqs here - section 17.3 in databook in kmb_hw_init()
134 * lists LCD at 79 and 82 for MIPI under MSS CPU - in kmb_hw_init()
142 drm_err(&kmb->drm, "irq_lcd not found"); in kmb_hw_init()
147 ret = of_reserved_mem_device_init(drm->dev); in kmb_hw_init()
148 if (ret && ret != -ENODEV) in kmb_hw_init()
151 spin_lock_init(&kmb->irq_lock); in kmb_hw_init()
153 kmb->irq_lcd = irq_lcd; in kmb_hw_init()
158 of_reserved_mem_device_release(drm->dev); in kmb_hw_init()
177 drm->mode_config.min_width = KMB_FB_MIN_WIDTH; in kmb_setup_mode_config()
178 drm->mode_config.min_height = KMB_FB_MIN_HEIGHT; in kmb_setup_mode_config()
179 drm->mode_config.max_width = KMB_FB_MAX_WIDTH; in kmb_setup_mode_config()
180 drm->mode_config.max_height = KMB_FB_MAX_HEIGHT; in kmb_setup_mode_config()
181 drm->mode_config.preferred_depth = 24; in kmb_setup_mode_config()
182 drm->mode_config.funcs = &kmb_mode_config_funcs; in kmb_setup_mode_config()
189 ret = kmb_dsi_encoder_init(drm, kmb->kmb_dsi); in kmb_setup_mode_config()
191 kmb->crtc.port = of_graph_get_port_by_id(drm->dev->of_node, 0); in kmb_setup_mode_config()
192 ret = drm_vblank_init(drm, drm->mode_config.num_crtc); in kmb_setup_mode_config()
195 pm_runtime_disable(drm->dev); in kmb_setup_mode_config()
212 spin_lock(&kmb->irq_lock); in handle_lcd_irq()
224 if (kmb->plane_status[plane_id].disable) { in handle_lcd_irq()
231 kmb->plane_status[plane_id].ctrl); in handle_lcd_irq()
246 kmb->plane_status[plane_id].disable = false; in handle_lcd_irq()
249 if (kmb->kmb_under_flow) { in handle_lcd_irq()
251 dma0_state = (kmb->layer_no == 0) ? in handle_lcd_irq()
253 dma1_state = (kmb->layer_no == 0) ? in handle_lcd_irq()
265 LCD_LAYERn_DMA_CFG(kmb->layer_no), in handle_lcd_irq()
268 kmb->kmb_flush_done = 1; in handle_lcd_irq()
269 kmb->kmb_under_flow = 0; in handle_lcd_irq()
286 if (kmb->kmb_flush_done) { in handle_lcd_irq()
289 (kmb->layer_no), in handle_lcd_irq()
291 kmb->kmb_flush_done = 0; in handle_lcd_irq()
293 drm_crtc_handle_vblank(&kmb->crtc); in handle_lcd_irq()
306 /* LAYER0 - VL0 */ in handle_lcd_irq()
310 kmb->kmb_under_flow++; in handle_lcd_irq()
311 drm_info(&kmb->drm, in handle_lcd_irq()
313 val, kmb->kmb_under_flow); in handle_lcd_irq()
327 kmb->layer_no = 0; in handle_lcd_irq()
331 drm_dbg(&kmb->drm, in handle_lcd_irq()
334 drm_dbg(&kmb->drm, in handle_lcd_irq()
337 drm_dbg(&kmb->drm, in handle_lcd_irq()
340 /* LAYER1 - VL1 */ in handle_lcd_irq()
344 kmb->kmb_under_flow++; in handle_lcd_irq()
345 drm_info(&kmb->drm, in handle_lcd_irq()
347 val, kmb->kmb_under_flow); in handle_lcd_irq()
360 kmb->layer_no = 1; in handle_lcd_irq()
363 /* LAYER1 - VL1 */ in handle_lcd_irq()
365 drm_dbg(&kmb->drm, in handle_lcd_irq()
368 drm_dbg(&kmb->drm, in handle_lcd_irq()
371 drm_dbg(&kmb->drm, in handle_lcd_irq()
374 /* LAYER2 - GL0 */ in handle_lcd_irq()
376 drm_dbg(&kmb->drm, in handle_lcd_irq()
379 drm_dbg(&kmb->drm, in handle_lcd_irq()
382 /* LAYER3 - GL1 */ in handle_lcd_irq()
384 drm_dbg(&kmb->drm, in handle_lcd_irq()
387 drm_dbg(&kmb->drm, in handle_lcd_irq()
391 spin_unlock(&kmb->irq_lock); in handle_lcd_irq()
421 return -ENOTCONN; in kmb_irq_install()
425 return request_irq(irq, kmb_isr, 0, drm->driver->name, drm); in kmb_irq_install()
433 free_irq(kmb->irq_lcd, drm); in kmb_irq_uninstall()
444 .name = "kmb-drm",
445 .desc = "KEEMBAY DISPLAY DRIVER",
453 struct device *dev = &pdev->dev; in kmb_remove()
459 of_node_put(kmb->crtc.port); in kmb_remove()
460 kmb->crtc.port = NULL; in kmb_remove()
461 pm_runtime_get_sync(drm->dev); in kmb_remove()
463 pm_runtime_put_sync(drm->dev); in kmb_remove()
464 pm_runtime_disable(drm->dev); in kmb_remove()
466 of_reserved_mem_device_release(drm->dev); in kmb_remove()
474 kmb_dsi_host_unregister(kmb->kmb_dsi); in kmb_remove()
480 struct device *dev = get_device(&pdev->dev); in kmb_probe()
487 /* The bridge (ADV 7535) will return -EPROBE_DEFER until it in kmb_probe()
490 * -EPROBE_DEFER until the bridge is loaded. Probe will be called again in kmb_probe()
494 dsi_in = of_graph_get_endpoint_by_regs(dev->of_node, 0, 0); in kmb_probe()
497 return -EINVAL; in kmb_probe()
503 return -EINVAL; in kmb_probe()
511 return -EINVAL; in kmb_probe()
516 ret = kmb_dsi_host_bridge_init(get_device(&dsi_pdev->dev)); in kmb_probe()
518 if (ret == -EPROBE_DEFER) { in kmb_probe()
519 return -EPROBE_DEFER; in kmb_probe()
531 dev_set_drvdata(dev, &kmb->drm); in kmb_probe()
534 kmb->kmb_dsi = kmb_dsi_init(dsi_pdev); in kmb_probe()
535 if (IS_ERR(kmb->kmb_dsi)) { in kmb_probe()
536 drm_err(&kmb->drm, "failed to initialize DSI\n"); in kmb_probe()
537 ret = PTR_ERR(kmb->kmb_dsi); in kmb_probe()
541 kmb->kmb_dsi->dev = &dsi_pdev->dev; in kmb_probe()
542 kmb->kmb_dsi->pdev = dsi_pdev; in kmb_probe()
543 ret = kmb_hw_init(&kmb->drm, 0); in kmb_probe()
547 ret = kmb_setup_mode_config(&kmb->drm); in kmb_probe()
551 ret = kmb_irq_install(&kmb->drm, kmb->irq_lcd); in kmb_probe()
553 drm_err(&kmb->drm, "failed to install IRQ handler\n"); in kmb_probe()
557 drm_kms_helper_poll_init(&kmb->drm); in kmb_probe()
560 ret = drm_dev_register(&kmb->drm, 0); in kmb_probe()
564 drm_fbdev_dma_setup(&kmb->drm, 0); in kmb_probe()
569 drm_kms_helper_poll_fini(&kmb->drm); in kmb_probe()
571 pm_runtime_disable(kmb->drm.dev); in kmb_probe()
573 drm_crtc_cleanup(&kmb->crtc); in kmb_probe()
574 drm_mode_config_cleanup(&kmb->drm); in kmb_probe()
577 kmb_dsi_host_unregister(kmb->kmb_dsi); in kmb_probe()
583 {.compatible = "intel,keembay-display"},
596 kmb->state = drm_atomic_helper_suspend(drm); in kmb_pm_suspend()
597 if (IS_ERR(kmb->state)) { in kmb_pm_suspend()
599 return PTR_ERR(kmb->state); in kmb_pm_suspend()
613 drm_atomic_helper_resume(drm, kmb->state); in kmb_pm_resume()
625 .name = "kmb-drm",
634 MODULE_DESCRIPTION("Keembay Display driver");