Lines Matching +full:tegra210 +full:- +full:pmc
1 // SPDX-License-Identifier: GPL-2.0-only
16 #include <soc/tegra/pmc.h>
36 stats->frames = 0; in tegra_dc_stats_reset()
37 stats->vblank = 0; in tegra_dc_stats_reset()
38 stats->underflow = 0; in tegra_dc_stats_reset()
39 stats->overflow = 0; in tegra_dc_stats_reset()
58 offset = 0x000 + (offset - 0x500); in tegra_plane_offset()
59 return plane->offset + offset; in tegra_plane_offset()
63 offset = 0x180 + (offset - 0x700); in tegra_plane_offset()
64 return plane->offset + offset; in tegra_plane_offset()
68 offset = 0x1c0 + (offset - 0x800); in tegra_plane_offset()
69 return plane->offset + offset; in tegra_plane_offset()
72 dev_WARN(plane->dc->dev, "invalid offset: %x\n", offset); in tegra_plane_offset()
74 return plane->offset + offset; in tegra_plane_offset()
80 return tegra_dc_readl(plane->dc, tegra_plane_offset(plane, offset)); in tegra_plane_readl()
86 tegra_dc_writel(plane->dc, value, tegra_plane_offset(plane, offset)); in tegra_plane_writel()
91 struct device_node *np = dc->dev->of_node; in tegra_dc_has_output()
96 if (it.node == dev->of_node) in tegra_dc_has_output()
103 * Double-buffered registers have two copies: ASSEMBLY and ACTIVE. When the
108 * Triple-buffered registers have three copies: ASSEMBLY, ARM and ACTIVE. The
145 outf.full = max_t(u32, outf.full - dfixed_const(1), dfixed_const(1)); in compute_dda_inc()
146 inf.full -= dfixed_const(1); in compute_dda_inc()
174 /* disable blending for non-overlapping case */ in tegra_plane_setup_blending_legacy()
178 state = to_tegra_plane_state(plane->base.state); in tegra_plane_setup_blending_legacy()
180 if (state->opaque) { in tegra_plane_setup_blending_legacy()
182 * Since custom fix-weight blending isn't utilized and weight in tegra_plane_setup_blending_legacy()
199 switch (state->base.normalized_zpos) { in tegra_plane_setup_blending_legacy()
201 if (state->blending[0].alpha && in tegra_plane_setup_blending_legacy()
202 state->blending[1].alpha) in tegra_plane_setup_blending_legacy()
224 if (state->blending[i].alpha && in tegra_plane_setup_blending_legacy()
225 state->blending[i].top) in tegra_plane_setup_blending_legacy()
229 switch (state->base.normalized_zpos) { in tegra_plane_setup_blending_legacy()
231 if (state->blending[0].alpha && in tegra_plane_setup_blending_legacy()
232 state->blending[1].alpha) in tegra_plane_setup_blending_legacy()
242 if (state->blending[0].alpha && in tegra_plane_setup_blending_legacy()
243 state->blending[0].top) in tegra_plane_setup_blending_legacy()
246 if (state->blending[1].alpha && in tegra_plane_setup_blending_legacy()
247 state->blending[1].top) in tegra_plane_setup_blending_legacy()
253 switch (state->base.normalized_zpos) { in tegra_plane_setup_blending_legacy()
266 if (!state->blending[0].top && state->blending[1].top) { in tegra_plane_setup_blending_legacy()
302 value = K2(255) | K1(255) | WINDOW_LAYER_DEPTH(255 - window->zpos); in tegra_plane_setup_blending()
310 struct tegra_dc *dc = plane->dc; in tegra_plane_use_horizontal_filtering()
312 if (window->src.w == window->dst.w) in tegra_plane_use_horizontal_filtering()
315 if (plane->index == 0 && dc->soc->has_win_a_without_filters) in tegra_plane_use_horizontal_filtering()
325 struct tegra_dc *dc = plane->dc; in tegra_plane_use_vertical_filtering()
327 if (window->src.h == window->dst.h) in tegra_plane_use_vertical_filtering()
330 if (plane->index == 0 && dc->soc->has_win_a_without_filters) in tegra_plane_use_vertical_filtering()
333 if (plane->index == 2 && dc->soc->has_win_c_without_vert_filter) in tegra_plane_use_vertical_filtering()
343 struct tegra_dc *dc = plane->dc; in tegra_dc_setup_window()
351 yuv = tegra_plane_format_is_yuv(window->format, &planar); in tegra_dc_setup_window()
353 bpp = window->bits_per_pixel / 8; in tegra_dc_setup_window()
357 tegra_plane_writel(plane, window->format, DC_WIN_COLOR_DEPTH); in tegra_dc_setup_window()
358 tegra_plane_writel(plane, window->swap, DC_WIN_BYTE_SWAP); in tegra_dc_setup_window()
360 value = V_POSITION(window->dst.y) | H_POSITION(window->dst.x); in tegra_dc_setup_window()
363 value = V_SIZE(window->dst.h) | H_SIZE(window->dst.w); in tegra_dc_setup_window()
366 h_offset = window->src.x * bpp; in tegra_dc_setup_window()
367 v_offset = window->src.y; in tegra_dc_setup_window()
368 h_size = window->src.w * bpp; in tegra_dc_setup_window()
369 v_size = window->src.h; in tegra_dc_setup_window()
371 if (window->reflect_x) in tegra_dc_setup_window()
372 h_offset += (window->src.w - 1) * bpp; in tegra_dc_setup_window()
374 if (window->reflect_y) in tegra_dc_setup_window()
375 v_offset += window->src.h - 1; in tegra_dc_setup_window()
387 h_dda = compute_dda_inc(window->src.w, window->dst.w, false, bpp); in tegra_dc_setup_window()
388 v_dda = compute_dda_inc(window->src.h, window->dst.h, true, bpp); in tegra_dc_setup_window()
393 h_dda = compute_initial_dda(window->src.x); in tegra_dc_setup_window()
394 v_dda = compute_initial_dda(window->src.y); in tegra_dc_setup_window()
402 tegra_plane_writel(plane, window->base[0], DC_WINBUF_START_ADDR); in tegra_dc_setup_window()
405 tegra_plane_writel(plane, window->base[1], DC_WINBUF_START_ADDR_U); in tegra_dc_setup_window()
406 tegra_plane_writel(plane, window->base[2], DC_WINBUF_START_ADDR_V); in tegra_dc_setup_window()
407 value = window->stride[1] << 16 | window->stride[0]; in tegra_dc_setup_window()
410 tegra_plane_writel(plane, window->stride[0], DC_WIN_LINE_STRIDE); in tegra_dc_setup_window()
416 if (dc->soc->supports_block_linear) { in tegra_dc_setup_window()
417 unsigned long height = window->tiling.value; in tegra_dc_setup_window()
419 switch (window->tiling.mode) { in tegra_dc_setup_window()
436 switch (window->tiling.mode) { in tegra_dc_setup_window()
449 * No need to handle this here because ->atomic_check in tegra_dc_setup_window()
472 } else if (window->bits_per_pixel < 24) { in tegra_dc_setup_window()
476 if (window->reflect_x) in tegra_dc_setup_window()
479 if (window->reflect_y) in tegra_dc_setup_window()
484 * Enable horizontal 6-tap filter and set filtering in tegra_dc_setup_window()
511 * Enable vertical 2-tap filter and set filtering in tegra_dc_setup_window()
514 for (i = 0, k = 128; i < 16; i++, k -= 8) in tegra_dc_setup_window()
522 if (dc->soc->has_legacy_blending) in tegra_dc_setup_window()
535 /* non-native formats */
613 unsigned int rotation = state->rotation; in tegra_plane_atomic_check()
614 struct tegra_bo_tiling *tiling = &plane_state->tiling; in tegra_plane_atomic_check()
616 struct tegra_dc *dc = to_tegra_dc(state->crtc); in tegra_plane_atomic_check()
620 if (!state->crtc) in tegra_plane_atomic_check()
623 err = tegra_plane_format(state->fb->format->format, in tegra_plane_atomic_check()
624 &plane_state->format, in tegra_plane_atomic_check()
625 &plane_state->swap); in tegra_plane_atomic_check()
635 if (dc->soc->has_legacy_blending) { in tegra_plane_atomic_check()
641 err = tegra_fb_get_tiling(state->fb, tiling); in tegra_plane_atomic_check()
645 if (tiling->mode == TEGRA_BO_TILING_MODE_BLOCK && in tegra_plane_atomic_check()
646 !dc->soc->supports_block_linear) { in tegra_plane_atomic_check()
648 return -EINVAL; in tegra_plane_atomic_check()
657 if (tegra_fb_is_bottom_up(state->fb)) in tegra_plane_atomic_check()
663 plane_state->reflect_x = true; in tegra_plane_atomic_check()
665 plane_state->reflect_x = false; in tegra_plane_atomic_check()
668 plane_state->reflect_y = true; in tegra_plane_atomic_check()
670 plane_state->reflect_y = false; in tegra_plane_atomic_check()
677 if (state->fb->format->num_planes > 2) { in tegra_plane_atomic_check()
678 if (state->fb->pitches[2] != state->fb->pitches[1]) { in tegra_plane_atomic_check()
679 DRM_ERROR("unsupported UV-plane configuration\n"); in tegra_plane_atomic_check()
680 return -EINVAL; in tegra_plane_atomic_check()
698 if (!old_state || !old_state->crtc) in tegra_plane_atomic_disable()
709 struct tegra_plane_state *state = to_tegra_plane_state(plane->state); in tegra_plane_atomic_update()
710 struct drm_framebuffer *fb = plane->state->fb; in tegra_plane_atomic_update()
716 if (!plane->state->crtc || !plane->state->fb) in tegra_plane_atomic_update()
719 if (!plane->state->visible) in tegra_plane_atomic_update()
723 window.src.x = plane->state->src.x1 >> 16; in tegra_plane_atomic_update()
724 window.src.y = plane->state->src.y1 >> 16; in tegra_plane_atomic_update()
725 window.src.w = drm_rect_width(&plane->state->src) >> 16; in tegra_plane_atomic_update()
726 window.src.h = drm_rect_height(&plane->state->src) >> 16; in tegra_plane_atomic_update()
727 window.dst.x = plane->state->dst.x1; in tegra_plane_atomic_update()
728 window.dst.y = plane->state->dst.y1; in tegra_plane_atomic_update()
729 window.dst.w = drm_rect_width(&plane->state->dst); in tegra_plane_atomic_update()
730 window.dst.h = drm_rect_height(&plane->state->dst); in tegra_plane_atomic_update()
731 window.bits_per_pixel = fb->format->cpp[0] * 8; in tegra_plane_atomic_update()
732 window.reflect_x = state->reflect_x; in tegra_plane_atomic_update()
733 window.reflect_y = state->reflect_y; in tegra_plane_atomic_update()
736 window.zpos = plane->state->normalized_zpos; in tegra_plane_atomic_update()
737 window.tiling = state->tiling; in tegra_plane_atomic_update()
738 window.format = state->format; in tegra_plane_atomic_update()
739 window.swap = state->swap; in tegra_plane_atomic_update()
741 for (i = 0; i < fb->format->num_planes; i++) { in tegra_plane_atomic_update()
742 window.base[i] = state->iova[i] + fb->offsets[i]; in tegra_plane_atomic_update()
747 * function, so it's safe to ignore the V-plane pitch here. in tegra_plane_atomic_update()
750 window.stride[i] = fb->pitches[i]; in tegra_plane_atomic_update()
778 return 1 << drm->mode_config.num_crtc; in tegra_plane_get_possible_crtcs()
794 return ERR_PTR(-ENOMEM); in tegra_primary_plane_create()
797 plane->offset = 0xa00; in tegra_primary_plane_create()
798 plane->index = 0; in tegra_primary_plane_create()
799 plane->dc = dc; in tegra_primary_plane_create()
801 num_formats = dc->soc->num_primary_formats; in tegra_primary_plane_create()
802 formats = dc->soc->primary_formats; in tegra_primary_plane_create()
803 modifiers = dc->soc->modifiers; in tegra_primary_plane_create()
805 err = drm_universal_plane_init(drm, &plane->base, possible_crtcs, in tegra_primary_plane_create()
813 drm_plane_helper_add(&plane->base, &tegra_plane_helper_funcs); in tegra_primary_plane_create()
814 drm_plane_create_zpos_property(&plane->base, plane->index, 0, 255); in tegra_primary_plane_create()
816 err = drm_plane_create_rotation_property(&plane->base, in tegra_primary_plane_create()
823 dev_err(dc->dev, "failed to create rotation property: %d\n", in tegra_primary_plane_create()
826 return &plane->base; in tegra_primary_plane_create()
840 if (!state->crtc) in tegra_cursor_atomic_check()
844 if ((state->src_w >> 16 != state->crtc_w) || in tegra_cursor_atomic_check()
845 (state->src_h >> 16 != state->crtc_h)) in tegra_cursor_atomic_check()
846 return -EINVAL; in tegra_cursor_atomic_check()
849 if (state->src_w != state->src_h) in tegra_cursor_atomic_check()
850 return -EINVAL; in tegra_cursor_atomic_check()
852 if (state->crtc_w != 32 && state->crtc_w != 64 && in tegra_cursor_atomic_check()
853 state->crtc_w != 128 && state->crtc_w != 256) in tegra_cursor_atomic_check()
854 return -EINVAL; in tegra_cursor_atomic_check()
866 struct tegra_plane_state *state = to_tegra_plane_state(plane->state); in tegra_cursor_atomic_update()
867 struct tegra_dc *dc = to_tegra_dc(plane->state->crtc); in tegra_cursor_atomic_update()
871 if (!plane->state->crtc || !plane->state->fb) in tegra_cursor_atomic_update()
874 switch (plane->state->crtc_w) { in tegra_cursor_atomic_update()
893 plane->state->crtc_w, plane->state->crtc_h); in tegra_cursor_atomic_update()
897 value |= (state->iova[0] >> 10) & 0x3fffff; in tegra_cursor_atomic_update()
901 value = (state->iova[0] >> 32) & 0x3; in tegra_cursor_atomic_update()
920 value = (plane->state->crtc_y & 0x3fff) << 16 | in tegra_cursor_atomic_update()
921 (plane->state->crtc_x & 0x3fff); in tegra_cursor_atomic_update()
932 if (!old_state || !old_state->crtc) in tegra_cursor_atomic_disable()
935 dc = to_tegra_dc(old_state->crtc); in tegra_cursor_atomic_disable()
961 return ERR_PTR(-ENOMEM); in tegra_dc_cursor_plane_create()
968 * need to special-casing the cursor plane. in tegra_dc_cursor_plane_create()
970 plane->index = 6; in tegra_dc_cursor_plane_create()
971 plane->dc = dc; in tegra_dc_cursor_plane_create()
976 err = drm_universal_plane_init(drm, &plane->base, possible_crtcs, in tegra_dc_cursor_plane_create()
985 drm_plane_helper_add(&plane->base, &tegra_cursor_plane_helper_funcs); in tegra_dc_cursor_plane_create()
986 drm_plane_create_zpos_immutable_property(&plane->base, 255); in tegra_dc_cursor_plane_create()
988 return &plane->base; in tegra_dc_cursor_plane_create()
998 /* non-native formats */
1081 return ERR_PTR(-ENOMEM); in tegra_dc_overlay_plane_create()
1083 plane->offset = 0xa00 + 0x200 * index; in tegra_dc_overlay_plane_create()
1084 plane->index = index; in tegra_dc_overlay_plane_create()
1085 plane->dc = dc; in tegra_dc_overlay_plane_create()
1087 num_formats = dc->soc->num_overlay_formats; in tegra_dc_overlay_plane_create()
1088 formats = dc->soc->overlay_formats; in tegra_dc_overlay_plane_create()
1095 err = drm_universal_plane_init(drm, &plane->base, possible_crtcs, in tegra_dc_overlay_plane_create()
1103 drm_plane_helper_add(&plane->base, &tegra_plane_helper_funcs); in tegra_dc_overlay_plane_create()
1104 drm_plane_create_zpos_property(&plane->base, plane->index, 0, 255); in tegra_dc_overlay_plane_create()
1106 err = drm_plane_create_rotation_property(&plane->base, in tegra_dc_overlay_plane_create()
1113 dev_err(dc->dev, "failed to create rotation property: %d\n", in tegra_dc_overlay_plane_create()
1116 return &plane->base; in tegra_dc_overlay_plane_create()
1125 for (i = 0; i < dc->soc->num_wgrps; i++) { in tegra_dc_add_shared_planes()
1126 const struct tegra_windowgroup_soc *wgrp = &dc->soc->wgrps[i]; in tegra_dc_add_shared_planes()
1128 if (wgrp->dc == dc->pipe) { in tegra_dc_add_shared_planes()
1129 for (j = 0; j < wgrp->num_windows; j++) { in tegra_dc_add_shared_planes()
1130 unsigned int index = wgrp->windows[j]; in tegra_dc_add_shared_planes()
1133 wgrp->index, in tegra_dc_add_shared_planes()
1143 plane->type = DRM_PLANE_TYPE_PRIMARY; in tegra_dc_add_shared_planes()
1165 if (dc->soc->supports_cursor) in tegra_dc_add_planes()
1176 while (i--) in tegra_dc_add_planes()
1196 if (crtc->state) in tegra_crtc_reset()
1197 tegra_crtc_atomic_destroy_state(crtc, crtc->state); in tegra_crtc_reset()
1199 __drm_atomic_helper_crtc_reset(crtc, &state->base); in tegra_crtc_reset()
1205 struct tegra_dc_state *state = to_dc_state(crtc->state); in tegra_crtc_atomic_duplicate_state()
1212 __drm_atomic_helper_crtc_duplicate_state(crtc, ©->base); in tegra_crtc_atomic_duplicate_state()
1213 copy->clk = state->clk; in tegra_crtc_atomic_duplicate_state()
1214 copy->pclk = state->pclk; in tegra_crtc_atomic_duplicate_state()
1215 copy->div = state->div; in tegra_crtc_atomic_duplicate_state()
1216 copy->planes = state->planes; in tegra_crtc_atomic_duplicate_state()
1218 return ©->base; in tegra_crtc_atomic_duplicate_state()
1447 struct drm_info_node *node = s->private; in tegra_dc_show_regs()
1448 struct tegra_dc *dc = node->info_ent->data; in tegra_dc_show_regs()
1452 drm_modeset_lock(&dc->base.mutex, NULL); in tegra_dc_show_regs()
1454 if (!dc->base.state->active) { in tegra_dc_show_regs()
1455 err = -EBUSY; in tegra_dc_show_regs()
1462 seq_printf(s, "%-40s %#05x %08x\n", tegra_dc_regs[i].name, in tegra_dc_show_regs()
1467 drm_modeset_unlock(&dc->base.mutex); in tegra_dc_show_regs()
1473 struct drm_info_node *node = s->private; in tegra_dc_show_crc()
1474 struct tegra_dc *dc = node->info_ent->data; in tegra_dc_show_crc()
1478 drm_modeset_lock(&dc->base.mutex, NULL); in tegra_dc_show_crc()
1480 if (!dc->base.state->active) { in tegra_dc_show_crc()
1481 err = -EBUSY; in tegra_dc_show_crc()
1489 drm_crtc_wait_one_vblank(&dc->base); in tegra_dc_show_crc()
1490 drm_crtc_wait_one_vblank(&dc->base); in tegra_dc_show_crc()
1498 drm_modeset_unlock(&dc->base.mutex); in tegra_dc_show_crc()
1504 struct drm_info_node *node = s->private; in tegra_dc_show_stats()
1505 struct tegra_dc *dc = node->info_ent->data; in tegra_dc_show_stats()
1507 seq_printf(s, "frames: %lu\n", dc->stats.frames); in tegra_dc_show_stats()
1508 seq_printf(s, "vblank: %lu\n", dc->stats.vblank); in tegra_dc_show_stats()
1509 seq_printf(s, "underflow: %lu\n", dc->stats.underflow); in tegra_dc_show_stats()
1510 seq_printf(s, "overflow: %lu\n", dc->stats.overflow); in tegra_dc_show_stats()
1524 struct drm_minor *minor = crtc->dev->primary; in tegra_dc_late_register()
1529 root = crtc->debugfs_entry; in tegra_dc_late_register()
1534 dc->debugfs_files = kmemdup(debugfs_files, sizeof(debugfs_files), in tegra_dc_late_register()
1536 if (!dc->debugfs_files) in tegra_dc_late_register()
1537 return -ENOMEM; in tegra_dc_late_register()
1540 dc->debugfs_files[i].data = dc; in tegra_dc_late_register()
1542 drm_debugfs_create_files(dc->debugfs_files, count, root, minor); in tegra_dc_late_register()
1550 struct drm_minor *minor = crtc->dev->primary; in tegra_dc_early_unregister()
1553 drm_debugfs_remove_files(dc->debugfs_files, count, minor); in tegra_dc_early_unregister()
1554 kfree(dc->debugfs_files); in tegra_dc_early_unregister()
1555 dc->debugfs_files = NULL; in tegra_dc_early_unregister()
1563 if (dc->syncpt && !dc->soc->has_nvdisplay) in tegra_dc_get_vblank_counter()
1564 return host1x_syncpt_read(dc->syncpt); in tegra_dc_get_vblank_counter()
1567 return (u32)drm_crtc_vblank_count(&dc->base); in tegra_dc_get_vblank_counter()
1613 if (!dc->soc->has_nvdisplay) { in tegra_dc_set_timings()
1620 value = ((mode->vsync_end - mode->vsync_start) << 16) | in tegra_dc_set_timings()
1621 ((mode->hsync_end - mode->hsync_start) << 0); in tegra_dc_set_timings()
1624 value = ((mode->vtotal - mode->vsync_end) << 16) | in tegra_dc_set_timings()
1625 ((mode->htotal - mode->hsync_end) << 0); in tegra_dc_set_timings()
1628 value = ((mode->vsync_start - mode->vdisplay) << 16) | in tegra_dc_set_timings()
1629 ((mode->hsync_start - mode->hdisplay) << 0); in tegra_dc_set_timings()
1632 value = (mode->vdisplay << 16) | mode->hdisplay; in tegra_dc_set_timings()
1639 * tegra_dc_state_setup_clock - check clock settings and store them in atomic
1648 * 0 on success or a negative error-code on failure.
1657 if (!clk_has_parent(dc->clk, clk)) in tegra_dc_state_setup_clock()
1658 return -EINVAL; in tegra_dc_state_setup_clock()
1660 state->clk = clk; in tegra_dc_state_setup_clock()
1661 state->pclk = pclk; in tegra_dc_state_setup_clock()
1662 state->div = div; in tegra_dc_state_setup_clock()
1673 err = clk_set_parent(dc->clk, state->clk); in tegra_dc_commit_state()
1675 dev_err(dc->dev, "failed to set parent clock: %d\n", err); in tegra_dc_commit_state()
1685 if (state->pclk > 0) { in tegra_dc_commit_state()
1686 err = clk_set_rate(state->clk, state->pclk); in tegra_dc_commit_state()
1688 dev_err(dc->dev, in tegra_dc_commit_state()
1690 state->pclk); in tegra_dc_commit_state()
1693 DRM_DEBUG_KMS("rate: %lu, div: %u\n", clk_get_rate(dc->clk), in tegra_dc_commit_state()
1694 state->div); in tegra_dc_commit_state()
1695 DRM_DEBUG_KMS("pclk: %lu\n", state->pclk); in tegra_dc_commit_state()
1697 if (!dc->soc->has_nvdisplay) { in tegra_dc_commit_state()
1698 value = SHIFT_CLK_DIVIDER(state->div) | PIXEL_CLK_DIVIDER_PCD1; in tegra_dc_commit_state()
1702 err = clk_set_rate(dc->clk, state->pclk); in tegra_dc_commit_state()
1704 dev_err(dc->dev, "failed to set clock %pC to %lu Hz: %d\n", in tegra_dc_commit_state()
1705 dc->clk, state->pclk, err); in tegra_dc_commit_state()
1740 dev_dbg(dc->dev, "timeout waiting for DC to become idle\n"); in tegra_dc_wait_idle()
1741 return -ETIMEDOUT; in tegra_dc_wait_idle()
1763 * these bits has the side-effect of stopping the display controller. in tegra_crtc_atomic_disable()
1777 if (dc->rgb) { in tegra_crtc_atomic_disable()
1784 tegra_dc_stats_reset(&dc->stats); in tegra_crtc_atomic_disable()
1787 spin_lock_irq(&crtc->dev->event_lock); in tegra_crtc_atomic_disable()
1789 if (crtc->state->event) { in tegra_crtc_atomic_disable()
1790 drm_crtc_send_vblank_event(crtc, crtc->state->event); in tegra_crtc_atomic_disable()
1791 crtc->state->event = NULL; in tegra_crtc_atomic_disable()
1794 spin_unlock_irq(&crtc->dev->event_lock); in tegra_crtc_atomic_disable()
1796 err = host1x_client_suspend(&dc->client); in tegra_crtc_atomic_disable()
1798 dev_err(dc->dev, "failed to suspend: %d\n", err); in tegra_crtc_atomic_disable()
1804 struct drm_display_mode *mode = &crtc->state->adjusted_mode; in tegra_crtc_atomic_enable()
1805 struct tegra_dc_state *state = to_dc_state(crtc->state); in tegra_crtc_atomic_enable()
1810 err = host1x_client_resume(&dc->client); in tegra_crtc_atomic_enable()
1812 dev_err(dc->dev, "failed to resume: %d\n", err); in tegra_crtc_atomic_enable()
1817 if (dc->syncpt) { in tegra_crtc_atomic_enable()
1818 u32 syncpt = host1x_syncpt_id(dc->syncpt), enable; in tegra_crtc_atomic_enable()
1820 if (dc->soc->has_nvdisplay) in tegra_crtc_atomic_enable()
1832 if (dc->soc->has_nvdisplay) { in tegra_crtc_atomic_enable()
1879 if (dc->soc->supports_background_color) in tegra_crtc_atomic_enable()
1891 if (dc->soc->supports_interlacing) { in tegra_crtc_atomic_enable()
1902 if (!dc->soc->has_nvdisplay) { in tegra_crtc_atomic_enable()
1910 if (dc->soc->has_nvdisplay) { in tegra_crtc_atomic_enable()
1925 if (crtc->state->event) { in tegra_crtc_atomic_begin()
1926 spin_lock_irqsave(&crtc->dev->event_lock, flags); in tegra_crtc_atomic_begin()
1929 drm_crtc_send_vblank_event(crtc, crtc->state->event); in tegra_crtc_atomic_begin()
1931 drm_crtc_arm_vblank_event(crtc, crtc->state->event); in tegra_crtc_atomic_begin()
1933 spin_unlock_irqrestore(&crtc->dev->event_lock, flags); in tegra_crtc_atomic_begin()
1935 crtc->state->event = NULL; in tegra_crtc_atomic_begin()
1942 struct tegra_dc_state *state = to_dc_state(crtc->state); in tegra_crtc_atomic_flush()
1946 value = state->planes << 8 | GENERAL_UPDATE; in tegra_crtc_atomic_flush()
1950 value = state->planes | GENERAL_ACT_REQ; in tegra_crtc_atomic_flush()
1972 dev_dbg(dc->dev, "%s(): frame end\n", __func__); in tegra_dc_irq()
1974 dc->stats.frames++; in tegra_dc_irq()
1979 dev_dbg(dc->dev, "%s(): vertical blank\n", __func__); in tegra_dc_irq()
1981 drm_crtc_handle_vblank(&dc->base); in tegra_dc_irq()
1982 dc->stats.vblank++; in tegra_dc_irq()
1987 dev_dbg(dc->dev, "%s(): underflow\n", __func__); in tegra_dc_irq()
1989 dc->stats.underflow++; in tegra_dc_irq()
1994 dev_dbg(dc->dev, "%s(): overflow\n", __func__); in tegra_dc_irq()
1996 dc->stats.overflow++; in tegra_dc_irq()
2000 dev_dbg_ratelimited(dc->dev, "%s(): head underflow\n", __func__); in tegra_dc_irq()
2001 dc->stats.underflow++; in tegra_dc_irq()
2011 if (!dc->soc->wgrps) in tegra_dc_has_window_groups()
2014 for (i = 0; i < dc->soc->num_wgrps; i++) { in tegra_dc_has_window_groups()
2015 const struct tegra_windowgroup_soc *wgrp = &dc->soc->wgrps[i]; in tegra_dc_has_window_groups()
2017 if (wgrp->dc == dc->pipe && wgrp->num_windows > 0) in tegra_dc_has_window_groups()
2026 struct drm_device *drm = dev_get_drvdata(client->host); in tegra_dc_init()
2029 struct tegra_drm *tegra = drm->dev_private; in tegra_dc_init()
2048 if (dc->soc->has_nvdisplay) in tegra_dc_init()
2049 client->parent = &tegra->hub->client; in tegra_dc_init()
2051 dc->syncpt = host1x_syncpt_request(client, flags); in tegra_dc_init()
2052 if (!dc->syncpt) in tegra_dc_init()
2053 dev_warn(dc->dev, "failed to allocate syncpoint\n"); in tegra_dc_init()
2056 if (err < 0 && err != -ENODEV) { in tegra_dc_init()
2057 dev_err(client->dev, "failed to attach to domain: %d\n", err); in tegra_dc_init()
2061 if (dc->soc->wgrps) in tegra_dc_init()
2071 if (dc->soc->supports_cursor) { in tegra_dc_init()
2086 err = drm_crtc_init_with_planes(drm, &dc->base, primary, cursor, in tegra_dc_init()
2091 drm_crtc_helper_add(&dc->base, &tegra_crtc_helper_funcs); in tegra_dc_init()
2097 if (dc->soc->pitch_align > tegra->pitch_align) in tegra_dc_init()
2098 tegra->pitch_align = dc->soc->pitch_align; in tegra_dc_init()
2101 if (err < 0 && err != -ENODEV) { in tegra_dc_init()
2102 dev_err(dc->dev, "failed to initialize RGB output: %d\n", err); in tegra_dc_init()
2106 err = devm_request_irq(dc->dev, dc->irq, tegra_dc_irq, 0, in tegra_dc_init()
2107 dev_name(dc->dev), dc); in tegra_dc_init()
2109 dev_err(dc->dev, "failed to request IRQ#%u: %d\n", dc->irq, in tegra_dc_init()
2118 client->dev->dma_parms = client->host->dma_parms; in tegra_dc_init()
2130 host1x_syncpt_free(dc->syncpt); in tegra_dc_init()
2144 client->dev->dma_parms = NULL; in tegra_dc_exit()
2146 devm_free_irq(dc->dev, dc->irq, dc); in tegra_dc_exit()
2150 dev_err(dc->dev, "failed to shutdown RGB output: %d\n", err); in tegra_dc_exit()
2155 host1x_syncpt_free(dc->syncpt); in tegra_dc_exit()
2163 struct device *dev = client->dev; in tegra_dc_runtime_suspend()
2166 err = reset_control_assert(dc->rst); in tegra_dc_runtime_suspend()
2172 if (dc->soc->has_powergate) in tegra_dc_runtime_suspend()
2173 tegra_powergate_power_off(dc->powergate); in tegra_dc_runtime_suspend()
2175 clk_disable_unprepare(dc->clk); in tegra_dc_runtime_suspend()
2184 struct device *dev = client->dev; in tegra_dc_runtime_resume()
2193 if (dc->soc->has_powergate) { in tegra_dc_runtime_resume()
2194 err = tegra_powergate_sequence_power_up(dc->powergate, dc->clk, in tegra_dc_runtime_resume()
2195 dc->rst); in tegra_dc_runtime_resume()
2201 err = clk_prepare_enable(dc->clk); in tegra_dc_runtime_resume()
2207 err = reset_control_deassert(dc->rst); in tegra_dc_runtime_resume()
2217 clk_disable_unprepare(dc->clk); in tegra_dc_runtime_resume()
2423 .compatible = "nvidia,tegra194-dc",
2426 .compatible = "nvidia,tegra186-dc",
2429 .compatible = "nvidia,tegra210-dc",
2432 .compatible = "nvidia,tegra124-dc",
2435 .compatible = "nvidia,tegra114-dc",
2438 .compatible = "nvidia,tegra30-dc",
2441 .compatible = "nvidia,tegra20-dc",
2455 err = of_property_read_u32(dc->dev->of_node, "nvidia,head", &value); in tegra_dc_parse_dt()
2457 dev_err(dc->dev, "missing \"nvidia,head\" property\n"); in tegra_dc_parse_dt()
2472 if (np == dc->dev->of_node) { in tegra_dc_parse_dt()
2481 dc->pipe = value; in tegra_dc_parse_dt()
2491 return dc->pipe == pipe; in tegra_dc_match_by_pipe()
2501 if (dc->soc->coupled_pm && dc->pipe == 1) { in tegra_dc_couple()
2506 partner = driver_find_device(dc->dev->driver, NULL, NULL, in tegra_dc_couple()
2509 return -EPROBE_DEFER; in tegra_dc_couple()
2511 link = device_link_add(dc->dev, partner, flags); in tegra_dc_couple()
2513 dev_err(dc->dev, "failed to link controllers\n"); in tegra_dc_couple()
2514 return -EINVAL; in tegra_dc_couple()
2517 dev_dbg(dc->dev, "coupled to %s\n", dev_name(partner)); in tegra_dc_couple()
2528 dc = devm_kzalloc(&pdev->dev, sizeof(*dc), GFP_KERNEL); in tegra_dc_probe()
2530 return -ENOMEM; in tegra_dc_probe()
2532 dc->soc = of_device_get_match_data(&pdev->dev); in tegra_dc_probe()
2534 INIT_LIST_HEAD(&dc->list); in tegra_dc_probe()
2535 dc->dev = &pdev->dev; in tegra_dc_probe()
2545 dc->clk = devm_clk_get(&pdev->dev, NULL); in tegra_dc_probe()
2546 if (IS_ERR(dc->clk)) { in tegra_dc_probe()
2547 dev_err(&pdev->dev, "failed to get clock\n"); in tegra_dc_probe()
2548 return PTR_ERR(dc->clk); in tegra_dc_probe()
2551 dc->rst = devm_reset_control_get(&pdev->dev, "dc"); in tegra_dc_probe()
2552 if (IS_ERR(dc->rst)) { in tegra_dc_probe()
2553 dev_err(&pdev->dev, "failed to get reset\n"); in tegra_dc_probe()
2554 return PTR_ERR(dc->rst); in tegra_dc_probe()
2558 err = clk_prepare_enable(dc->clk); in tegra_dc_probe()
2564 err = reset_control_assert(dc->rst); in tegra_dc_probe()
2570 clk_disable_unprepare(dc->clk); in tegra_dc_probe()
2572 if (dc->soc->has_powergate) { in tegra_dc_probe()
2573 if (dc->pipe == 0) in tegra_dc_probe()
2574 dc->powergate = TEGRA_POWERGATE_DIS; in tegra_dc_probe()
2576 dc->powergate = TEGRA_POWERGATE_DISB; in tegra_dc_probe()
2578 tegra_powergate_power_off(dc->powergate); in tegra_dc_probe()
2581 dc->regs = devm_platform_ioremap_resource(pdev, 0); in tegra_dc_probe()
2582 if (IS_ERR(dc->regs)) in tegra_dc_probe()
2583 return PTR_ERR(dc->regs); in tegra_dc_probe()
2585 dc->irq = platform_get_irq(pdev, 0); in tegra_dc_probe()
2586 if (dc->irq < 0) in tegra_dc_probe()
2587 return -ENXIO; in tegra_dc_probe()
2590 if (err < 0 && err != -ENODEV) { in tegra_dc_probe()
2593 if (err == -EPROBE_DEFER) in tegra_dc_probe()
2596 dev_printk(level, dc->dev, "failed to probe RGB output: %d\n", in tegra_dc_probe()
2602 pm_runtime_enable(&pdev->dev); in tegra_dc_probe()
2604 INIT_LIST_HEAD(&dc->client.list); in tegra_dc_probe()
2605 dc->client.ops = &dc_client_ops; in tegra_dc_probe()
2606 dc->client.dev = &pdev->dev; in tegra_dc_probe()
2608 err = host1x_client_register(&dc->client); in tegra_dc_probe()
2610 dev_err(&pdev->dev, "failed to register host1x client: %d\n", in tegra_dc_probe()
2618 pm_runtime_disable(&pdev->dev); in tegra_dc_probe()
2629 err = host1x_client_unregister(&dc->client); in tegra_dc_remove()
2631 dev_err(&pdev->dev, "failed to unregister host1x client: %d\n", in tegra_dc_remove()
2638 dev_err(&pdev->dev, "failed to remove RGB output: %d\n", err); in tegra_dc_remove()
2642 pm_runtime_disable(&pdev->dev); in tegra_dc_remove()
2649 .name = "tegra-dc",