Lines Matching +full:mali +full:- +full:dp650
1 // SPDX-License-Identifier: GPL-2.0-only
6 * ARM Mali DP500/DP550/DP650 KMS/DRM driver
55 hwdev->hw->map.coeffs_base + MALIDP_COEF_TABLE_ADDR); in malidp_write_gamma_table()
58 hwdev->hw->map.coeffs_base + in malidp_write_gamma_table()
66 struct malidp_hw_device *hwdev = malidp->dev; in malidp_atomic_commit_update_gamma()
68 if (!crtc->state->color_mgmt_changed) in malidp_atomic_commit_update_gamma()
71 if (!crtc->state->gamma_lut) { in malidp_atomic_commit_update_gamma()
77 to_malidp_crtc_state(crtc->state); in malidp_atomic_commit_update_gamma()
79 if (!old_state->gamma_lut || (crtc->state->gamma_lut->base.id != in malidp_atomic_commit_update_gamma()
80 old_state->gamma_lut->base.id)) in malidp_atomic_commit_update_gamma()
81 malidp_write_gamma_table(hwdev, mc->gamma_coeffs); in malidp_atomic_commit_update_gamma()
93 struct malidp_hw_device *hwdev = malidp->dev; in malidp_atomic_commit_update_coloradj()
96 if (!crtc->state->color_mgmt_changed) in malidp_atomic_commit_update_coloradj()
99 if (!crtc->state->ctm) { in malidp_atomic_commit_update_coloradj()
104 to_malidp_crtc_state(crtc->state); in malidp_atomic_commit_update_coloradj()
106 if (!old_state->ctm || (crtc->state->ctm->base.id != in malidp_atomic_commit_update_coloradj()
107 old_state->ctm->base.id)) in malidp_atomic_commit_update_coloradj()
110 mc->coloradj_coeffs[i], in malidp_atomic_commit_update_coloradj()
111 hwdev->hw->map.coeffs_base + in malidp_atomic_commit_update_coloradj()
122 struct malidp_crtc_state *cs = to_malidp_crtc_state(crtc->state); in malidp_atomic_commit_se_config()
125 struct malidp_hw_device *hwdev = malidp->dev; in malidp_atomic_commit_se_config()
126 struct malidp_se_config *s = &cs->scaler_config; in malidp_atomic_commit_se_config()
127 struct malidp_se_config *old_s = &old_cs->scaler_config; in malidp_atomic_commit_se_config()
128 u32 se_control = hwdev->hw->map.se_base + in malidp_atomic_commit_se_config()
129 ((hwdev->hw->map.features & MALIDP_REGMAP_HAS_CLEARIRQ) ? in malidp_atomic_commit_se_config()
136 if (!s->scale_enable) { in malidp_atomic_commit_se_config()
143 hwdev->hw->se_set_scaling_coeffs(hwdev, s, old_s); in malidp_atomic_commit_se_config()
148 val |= s->enhancer_enable ? MALIDP_SE_ENH(3) : 0; in malidp_atomic_commit_se_config()
154 val = MALIDP_SE_SET_V_SIZE(s->input_h) | in malidp_atomic_commit_se_config()
155 MALIDP_SE_SET_H_SIZE(s->input_w); in malidp_atomic_commit_se_config()
157 val = MALIDP_SE_SET_V_SIZE(s->output_h) | in malidp_atomic_commit_se_config()
158 MALIDP_SE_SET_H_SIZE(s->output_w); in malidp_atomic_commit_se_config()
162 malidp_hw_write(hwdev, s->h_init_phase, scr + MALIDP_SE_H_INIT_PH); in malidp_atomic_commit_se_config()
163 malidp_hw_write(hwdev, s->h_delta_phase, scr + MALIDP_SE_H_DELTA_PH); in malidp_atomic_commit_se_config()
164 malidp_hw_write(hwdev, s->v_init_phase, scr + MALIDP_SE_V_INIT_PH); in malidp_atomic_commit_se_config()
165 malidp_hw_write(hwdev, s->v_delta_phase, scr + MALIDP_SE_V_DELTA_PH); in malidp_atomic_commit_se_config()
174 struct malidp_hw_device *hwdev = malidp->dev; in malidp_set_and_wait_config_valid()
177 hwdev->hw->set_config_valid(hwdev, 1); in malidp_set_and_wait_config_valid()
179 if (hwdev->hw->in_config_mode(hwdev)) { in malidp_set_and_wait_config_valid()
180 atomic_set(&malidp->config_valid, MALIDP_CONFIG_VALID_DONE); in malidp_set_and_wait_config_valid()
184 ret = wait_event_interruptible_timeout(malidp->wq, in malidp_set_and_wait_config_valid()
185 atomic_read(&malidp->config_valid) == MALIDP_CONFIG_VALID_DONE, in malidp_set_and_wait_config_valid()
188 return (ret > 0) ? 0 : -ETIMEDOUT; in malidp_set_and_wait_config_valid()
193 struct drm_device *drm = state->dev; in malidp_atomic_commit_hw_done()
197 malidp->event = malidp->crtc.state->event; in malidp_atomic_commit_hw_done()
198 malidp->crtc.state->event = NULL; in malidp_atomic_commit_hw_done()
200 if (malidp->crtc.state->active) { in malidp_atomic_commit_hw_done()
206 if (malidp->event) in malidp_atomic_commit_hw_done()
207 drm_crtc_vblank_get(&malidp->crtc); in malidp_atomic_commit_hw_done()
215 while (loop--) { in malidp_atomic_commit_hw_done()
222 } else if (malidp->event) { in malidp_atomic_commit_hw_done()
224 spin_lock_irq(&drm->event_lock); in malidp_atomic_commit_hw_done()
225 drm_crtc_send_vblank_event(&malidp->crtc, malidp->event); in malidp_atomic_commit_hw_done()
226 malidp->event = NULL; in malidp_atomic_commit_hw_done()
227 spin_unlock_irq(&drm->event_lock); in malidp_atomic_commit_hw_done()
234 struct drm_device *drm = state->dev; in malidp_atomic_commit_tail()
241 pm_runtime_get_sync(drm->dev); in malidp_atomic_commit_tail()
247 atomic_set(&malidp->config_valid, MALIDP_CONFIG_START); in malidp_atomic_commit_tail()
248 malidp->dev->hw->set_config_valid(malidp->dev, 0); in malidp_atomic_commit_tail()
268 pm_runtime_put(drm->dev); in malidp_atomic_commit_tail()
281 if (malidp_format_mod_supported(dev, mode_cmd->pixel_format, in malidp_verify_afbc_framebuffer_caps()
282 mode_cmd->modifier[0]) == false) in malidp_verify_afbc_framebuffer_caps()
285 if (mode_cmd->offsets[0] != 0) { in malidp_verify_afbc_framebuffer_caps()
290 switch (mode_cmd->modifier[0] & AFBC_SIZE_MASK) { in malidp_verify_afbc_framebuffer_caps()
292 if ((mode_cmd->width % 16) || (mode_cmd->height % 16)) { in malidp_verify_afbc_framebuffer_caps()
317 switch (mode_cmd->modifier[0] & AFBC_SIZE_MASK) { in malidp_verify_afbc_framebuffer_size()
329 n_superblocks = (mode_cmd->width / afbc_superblock_width) * in malidp_verify_afbc_framebuffer_size()
330 (mode_cmd->height / afbc_superblock_height); in malidp_verify_afbc_framebuffer_size()
332 bpp = malidp_format_get_bpp(info->format); in malidp_verify_afbc_framebuffer_size()
340 if ((mode_cmd->width * bpp) != (mode_cmd->pitches[0] * BITS_PER_BYTE)) { in malidp_verify_afbc_framebuffer_size()
343 (mode_cmd->pitches[0] * BITS_PER_BYTE), in malidp_verify_afbc_framebuffer_size()
344 mode_cmd->width, bpp); in malidp_verify_afbc_framebuffer_size()
348 objs = drm_gem_object_lookup(file, mode_cmd->handles[0]); in malidp_verify_afbc_framebuffer_size()
354 if (objs->size < afbc_size) { in malidp_verify_afbc_framebuffer_size()
356 objs->size, afbc_size); in malidp_verify_afbc_framebuffer_size()
380 if (mode_cmd->modifier[0]) { in malidp_fb_create()
382 return ERR_PTR(-EINVAL); in malidp_fb_create()
398 struct malidp_hw_device *hwdev = malidp->dev; in malidp_init()
404 drm->mode_config.min_width = hwdev->min_line_size; in malidp_init()
405 drm->mode_config.min_height = hwdev->min_line_size; in malidp_init()
406 drm->mode_config.max_width = hwdev->max_line_size; in malidp_init()
407 drm->mode_config.max_height = hwdev->max_line_size; in malidp_init()
408 drm->mode_config.funcs = &malidp_mode_config_funcs; in malidp_init()
409 drm->mode_config.helper_private = &malidp_mode_config_helpers; in malidp_init()
426 struct drm_device *drm = dev_get_drvdata(&pdev->dev); in malidp_irq_init()
428 struct malidp_hw_device *hwdev = malidp->dev; in malidp_irq_init()
463 u8 alignment = malidp_hw_get_pitch_align(malidp->dev, 1); in malidp_dumb_create()
465 args->pitch = ALIGN(DIV_ROUND_UP(args->width * args->bpp, 8), alignment); in malidp_dumb_create()
474 error_stats->num_errors = 0; in malidp_error_stats_init()
475 error_stats->last_error_status = 0; in malidp_error_stats_init()
476 error_stats->last_error_vblank = -1; in malidp_error_stats_init()
485 spin_lock_irqsave(&malidp->errors_lock, irqflags); in malidp_error()
486 error_stats->last_error_status = status; in malidp_error()
487 error_stats->last_error_vblank = vblank; in malidp_error()
488 error_stats->num_errors++; in malidp_error()
489 spin_unlock_irqrestore(&malidp->errors_lock, irqflags); in malidp_error()
506 struct drm_device *drm = m->private; in malidp_show_stats()
511 spin_lock_irqsave(&malidp->errors_lock, irqflags); in malidp_show_stats()
512 de_errors = malidp->de_errors; in malidp_show_stats()
513 se_errors = malidp->se_errors; in malidp_show_stats()
514 spin_unlock_irqrestore(&malidp->errors_lock, irqflags); in malidp_show_stats()
522 return single_open(file, malidp_show_stats, inode->i_private); in malidp_debugfs_open()
528 struct seq_file *m = file->private_data; in malidp_debugfs_write()
529 struct drm_device *drm = m->private; in malidp_debugfs_write()
533 spin_lock_irqsave(&malidp->errors_lock, irqflags); in malidp_debugfs_write()
534 malidp_error_stats_init(&malidp->de_errors); in malidp_debugfs_write()
535 malidp_error_stats_init(&malidp->se_errors); in malidp_debugfs_write()
536 spin_unlock_irqrestore(&malidp->errors_lock, irqflags); in malidp_debugfs_write()
551 struct malidp_drm *malidp = drm_to_malidp(minor->dev); in malidp_debugfs_init()
553 malidp_error_stats_init(&malidp->de_errors); in malidp_debugfs_init()
554 malidp_error_stats_init(&malidp->se_errors); in malidp_debugfs_init()
555 spin_lock_init(&malidp->errors_lock); in malidp_debugfs_init()
556 debugfs_create_file("debug", S_IRUGO | S_IWUSR, minor->debugfs_root, in malidp_debugfs_init()
557 minor->dev, &malidp_debugfs_fops); in malidp_debugfs_init()
569 .name = "mali-dp",
570 .desc = "ARM Mali Display Processor driver",
578 .compatible = "arm,mali-dp500",
582 .compatible = "arm,mali-dp550",
586 .compatible = "arm,mali-dp650",
597 const char *compatstr_dp500 = "arm,mali-dp500"; in malidp_is_compatible_hw_id()
609 dt_is_dp500 = strnstr(dev_id->compatible, compatstr_dp500, in malidp_is_compatible_hw_id()
610 sizeof(dev_id->compatible)) != NULL; in malidp_is_compatible_hw_id()
612 DRM_ERROR("Device-tree expects %s, but hardware %s DP500.\n", in malidp_is_compatible_hw_id()
613 dev_id->compatible, is_dp500 ? "is" : "is not"); in malidp_is_compatible_hw_id()
622 snprintf(buf, sizeof(buf), "arm,mali-dp%X", product_id); in malidp_is_compatible_hw_id()
623 if (!strnstr(dev_id->compatible, buf, in malidp_is_compatible_hw_id()
624 sizeof(dev_id->compatible))) { in malidp_is_compatible_hw_id()
625 DRM_ERROR("Device-tree expects %s, but hardware is DP%03X.\n", in malidp_is_compatible_hw_id()
626 dev_id->compatible, product_id); in malidp_is_compatible_hw_id()
637 const char *compatstr_dp500 = "arm,mali-dp500"; in malidp_has_sufficient_address_space()
639 if (!strnstr(dev_id->compatible, compatstr_dp500, in malidp_has_sufficient_address_space()
640 sizeof(dev_id->compatible))) in malidp_has_sufficient_address_space()
653 return sysfs_emit(buf, "%08x\n", malidp->core_id); in core_id_show()
670 struct malidp_hw_device *hwdev = malidp->dev; in malidp_runtime_pm_suspend()
673 WARN_ON(!hwdev->hw->in_config_mode(hwdev)); in malidp_runtime_pm_suspend()
677 hwdev->pm_suspended = true; in malidp_runtime_pm_suspend()
678 clk_disable_unprepare(hwdev->mclk); in malidp_runtime_pm_suspend()
679 clk_disable_unprepare(hwdev->aclk); in malidp_runtime_pm_suspend()
680 clk_disable_unprepare(hwdev->pclk); in malidp_runtime_pm_suspend()
689 struct malidp_hw_device *hwdev = malidp->dev; in malidp_runtime_pm_resume()
691 clk_prepare_enable(hwdev->pclk); in malidp_runtime_pm_resume()
692 clk_prepare_enable(hwdev->aclk); in malidp_runtime_pm_resume()
693 clk_prepare_enable(hwdev->mclk); in malidp_runtime_pm_resume()
694 hwdev->pm_suspended = false; in malidp_runtime_pm_resume()
719 drm = &malidp->base; in malidp_bind()
723 return -ENOMEM; in malidp_bind()
725 hwdev->hw = (struct malidp_hw *)of_device_get_match_data(dev); in malidp_bind()
726 malidp->dev = hwdev; in malidp_bind()
728 hwdev->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res); in malidp_bind()
729 if (IS_ERR(hwdev->regs)) in malidp_bind()
730 return PTR_ERR(hwdev->regs); in malidp_bind()
732 hwdev->pclk = devm_clk_get(dev, "pclk"); in malidp_bind()
733 if (IS_ERR(hwdev->pclk)) in malidp_bind()
734 return PTR_ERR(hwdev->pclk); in malidp_bind()
736 hwdev->aclk = devm_clk_get(dev, "aclk"); in malidp_bind()
737 if (IS_ERR(hwdev->aclk)) in malidp_bind()
738 return PTR_ERR(hwdev->aclk); in malidp_bind()
740 hwdev->mclk = devm_clk_get(dev, "mclk"); in malidp_bind()
741 if (IS_ERR(hwdev->mclk)) in malidp_bind()
742 return PTR_ERR(hwdev->mclk); in malidp_bind()
744 hwdev->pxlclk = devm_clk_get(dev, "pxlclk"); in malidp_bind()
745 if (IS_ERR(hwdev->pxlclk)) in malidp_bind()
746 return PTR_ERR(hwdev->pxlclk); in malidp_bind()
750 if (ret && ret != -ENODEV) in malidp_bind()
766 ret = -EINVAL; in malidp_bind()
771 DRM_ERROR("Insufficient address space in device-tree.\n"); in malidp_bind()
772 ret = -EINVAL; in malidp_bind()
777 ret = -EINVAL; in malidp_bind()
781 ret = hwdev->hw->query_hw(hwdev); in malidp_bind()
787 version = malidp_hw_read(hwdev, hwdev->hw->map.dc_base + MALIDP_DE_CORE_ID); in malidp_bind()
788 DRM_INFO("found ARM Mali-DP%3x version r%dp%d\n", version >> 16, in malidp_bind()
791 malidp->core_id = version; in malidp_bind()
793 ret = of_property_read_u32(dev->of_node, in malidp_bind()
794 "arm,malidp-arqos-value", in malidp_bind()
795 &hwdev->arqos_value); in malidp_bind()
797 hwdev->arqos_value = 0x0; in malidp_bind()
800 ret = of_property_read_u8_array(dev->of_node, in malidp_bind()
801 "arm,malidp-output-port-lines", in malidp_bind()
808 malidp_hw_write(hwdev, out_depth, hwdev->hw->map.out_depth_base); in malidp_bind()
809 hwdev->output_color_depth = out_depth; in malidp_bind()
811 atomic_set(&malidp->config_valid, MALIDP_CONFIG_VALID_INIT); in malidp_bind()
812 init_waitqueue_head(&malidp->wq); in malidp_bind()
819 malidp->crtc.port = of_graph_get_port_by_id(dev->of_node, 0); in malidp_bind()
830 WARN_ON(drm->mode_config.num_encoder > 2); in malidp_bind()
831 list_for_each_entry(encoder, &drm->mode_config.encoder_list, head) { in malidp_bind()
832 encoder->possible_clones = in malidp_bind()
833 (1 << drm->mode_config.num_encoder) - 1; in malidp_bind()
840 ret = drm_vblank_init(drm, drm->mode_config.num_crtc); in malidp_bind()
869 of_node_put(malidp->crtc.port); in malidp_bind()
870 malidp->crtc.port = NULL; in malidp_bind()
887 struct malidp_hw_device *hwdev = malidp->dev; in malidp_unbind()
896 of_node_put(malidp->crtc.port); in malidp_unbind()
897 malidp->crtc.port = NULL; in malidp_unbind()
916 return dev->of_node == np; in malidp_compare_dev()
924 if (!pdev->dev.of_node) in malidp_platform_probe()
925 return -ENODEV; in malidp_platform_probe()
928 port = of_graph_get_remote_node(pdev->dev.of_node, 0, 0); in malidp_platform_probe()
930 return -ENODEV; in malidp_platform_probe()
932 drm_of_component_match_add(&pdev->dev, &match, malidp_compare_dev, in malidp_platform_probe()
935 return component_master_add_with_match(&pdev->dev, &malidp_master_ops, in malidp_platform_probe()
941 component_master_del(&pdev->dev, &malidp_master_ops); in malidp_platform_remove()
986 .name = "mali-dp",
996 MODULE_DESCRIPTION("ARM Mali DP DRM driver");