| 1 |
|
| 2 |
|
| 3 |
#include <device/mmio.h> |
| 4 |
#include <console/console.h> |
| 5 |
#include <edid.h> |
| 6 |
#include <soc/clock.h> |
| 7 |
#include <soc/display/mdssreg.h> |
| 8 |
|
| 9 |
#define MDSS_MDP_MAX_PREFILL_FETCH 24 |
| 10 |
|
| 11 |
static void mdss_source_pipe_config(struct edid *edid) |
| 12 |
{ |
| 13 |
uint32_t img_size, out_size, stride; |
| 14 |
uint32_t fb_off = 0; |
| 15 |
uint32_t flip_bits = 0; |
| 16 |
uint32_t src_xy = 0; |
| 17 |
uint32_t dst_xy = 0; |
| 18 |
|
| 19 |
|
| 20 |
img_size = (edid->mode.va << 16) | edid->mode.ha; |
| 21 |
out_size = img_size; |
| 22 |
stride = (edid->mode.ha * edid->framebuffer_bits_per_pixel/8); |
| 23 |
|
| 24 |
dst_xy = (edid->mode.vborder << 16) | edid->mode.hborder; |
| 25 |
src_xy = dst_xy; |
| 26 |
|
| 27 |
printk(BIOS_INFO, "%s: src=%x fb_off=%x src_xy=%x dst_xy=%x\n", |
| 28 |
__func__, out_size, fb_off, src_xy, dst_xy); |
| 29 |
|
| 30 |
write32(&mdp_sspp->sspp_src_ystride0, stride); |
| 31 |
write32(&mdp_sspp->sspp_src_size, out_size); |
| 32 |
write32(&mdp_sspp->sspp_out_size, out_size); |
| 33 |
write32(&mdp_sspp->sspp_src_xy, src_xy); |
| 34 |
write32(&mdp_sspp->sspp_out_xy, dst_xy); |
| 35 |
|
| 36 |
|
| 37 |
write32(&mdp_sspp->sspp_src_format, 0x000236ff); |
| 38 |
write32(&mdp_sspp->sspp_src_unpack_pattern, 0x03020001); |
| 39 |
|
| 40 |
flip_bits |= SW_PIX_EXT_OVERRIDE; |
| 41 |
write32(&mdp_sspp->sspp_sw_pic_ext_c0_req_pixels, out_size); |
| 42 |
write32(&mdp_sspp->sspp_sw_pic_ext_c1c2_req_pixels, out_size); |
| 43 |
write32(&mdp_sspp->sspp_sw_pic_ext_c3_req_pixels, out_size); |
| 44 |
write32(&mdp_sspp->sspp_src_op_mode, flip_bits); |
| 45 |
} |
| 46 |
|
| 47 |
static void mdss_vbif_setup(void) |
| 48 |
{ |
| 49 |
write32(&vbif_rt->vbif_out_axi_amemtype_conf0, 0x33333333); |
| 50 |
write32(&vbif_rt->vbif_out_axi_amemtype_conf1, 0x00333333); |
| 51 |
} |
| 52 |
|
| 53 |
static void mdss_intf_fetch_start_config(struct edid *edid) |
| 54 |
{ |
| 55 |
uint32_t v_total, h_total, fetch_start, vfp_start; |
| 56 |
uint32_t prefetch_avail, prefetch_needed; |
| 57 |
uint32_t fetch_enable = PROG_FETCH_START_EN; |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
if ((edid->mode.vbl - edid->mode.vso + 1) >= MDSS_MDP_MAX_PREFILL_FETCH) |
| 66 |
return; |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
v_total = edid->mode.va + edid->mode.vbl; |
| 73 |
h_total = edid->mode.ha + edid->mode.hbl; |
| 74 |
vfp_start = edid->mode.va + edid->mode.vbl - edid->mode.vso; |
| 75 |
prefetch_avail = v_total - vfp_start; |
| 76 |
prefetch_needed = MDSS_MDP_MAX_PREFILL_FETCH - edid->mode.vbl + edid->mode.vso; |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
if (prefetch_avail > prefetch_needed) |
| 84 |
prefetch_avail = prefetch_needed; |
| 85 |
|
| 86 |
fetch_start = (v_total - prefetch_avail) * h_total + h_total + 1; |
| 87 |
write32(&mdp_intf->intf_prof_fetch_start, fetch_start); |
| 88 |
write32(&mdp_intf->intf_config, fetch_enable); |
| 89 |
} |
| 90 |
|
| 91 |
static void mdss_layer_mixer_setup(struct edid *edid) |
| 92 |
{ |
| 93 |
uint32_t mdp_rgb_size; |
| 94 |
uint32_t left_staging_level; |
| 95 |
|
| 96 |
|
| 97 |
mdp_rgb_size = (edid->mode.va << 16) | edid->mode.ha; |
| 98 |
|
| 99 |
write32(&mdp_layer_mixer->layer_out_size, mdp_rgb_size); |
| 100 |
write32(&mdp_layer_mixer->layer_op_mode, 0x0); |
| 101 |
for (int i = 0; i < 6; i++) { |
| 102 |
write32(&mdp_layer_mixer->layer_blend[i].layer_blend_op, 0x100); |
| 103 |
write32(&mdp_layer_mixer->layer_blend[i].layer_blend_const_alpha, 0x00ff0000); |
| 104 |
} |
| 105 |
|
| 106 |
|
| 107 |
left_staging_level = BORDER_OUT; |
| 108 |
left_staging_level |= VIG_0_OUT; |
| 109 |
|
| 110 |
|
| 111 |
write32(&mdp_ctl->ctl_layer0, left_staging_level); |
| 112 |
} |
| 113 |
|
| 114 |
static void mdss_vbif_qos_remapper_setup(void) |
| 115 |
{ |
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
write32(&vbif_rt->qos_rp_remap[0].vbif_xinl_qos_rp_remap, 0x00000003); |
| 123 |
write32(&vbif_rt->qos_rp_remap[1].vbif_xinl_qos_rp_remap, 0x11111113); |
| 124 |
write32(&vbif_rt->qos_rp_remap[2].vbif_xinl_qos_rp_remap, 0x22222224); |
| 125 |
write32(&vbif_rt->qos_rp_remap[3].vbif_xinl_qos_rp_remap, 0x33333334); |
| 126 |
write32(&vbif_rt->qos_rp_remap[4].vbif_xinl_qos_rp_remap, 0x44444445); |
| 127 |
write32(&vbif_rt->qos_rp_remap[7].vbif_xinl_qos_rp_remap, 0x77777776); |
| 128 |
write32(&vbif_rt->qos_lvl_remap[0].vbif_xinl_qos_lvl_remap, 0x00000003); |
| 129 |
write32(&vbif_rt->qos_lvl_remap[1].vbif_xinl_qos_lvl_remap, 0x11111113); |
| 130 |
write32(&vbif_rt->qos_lvl_remap[2].vbif_xinl_qos_lvl_remap, 0x22222224); |
| 131 |
write32(&vbif_rt->qos_lvl_remap[3].vbif_xinl_qos_lvl_remap, 0x33333334); |
| 132 |
write32(&vbif_rt->qos_lvl_remap[4].vbif_xinl_qos_lvl_remap, 0x44444445); |
| 133 |
write32(&vbif_rt->qos_lvl_remap[5].vbif_xinl_qos_lvl_remap, 0x77777776); |
| 134 |
} |
| 135 |
|
| 136 |
void mdp_dsi_video_config(struct edid *edid) |
| 137 |
{ |
| 138 |
mdss_intf_tg_setup(edid); |
| 139 |
mdss_intf_fetch_start_config(edid); |
| 140 |
mdss_vbif_setup(); |
| 141 |
mdss_vbif_qos_remapper_setup(); |
| 142 |
mdss_source_pipe_config(edid); |
| 143 |
mdss_layer_mixer_setup(edid); |
| 144 |
mdss_ctrl_config(); |
| 145 |
write32(&mdp_intf->intf_mux, 0x0F0000); |
| 146 |
} |
| 147 |
|
| 148 |
void mdp_dsi_video_on(void) |
| 149 |
{ |
| 150 |
uint32_t ctl0_reg_val; |
| 151 |
|
| 152 |
ctl0_reg_val = VIG_0 | LAYER_MIXER_0 | CTL | INTF; |
| 153 |
write32(&mdp_ctl->ctl_intf_flush, INTF_FLUSH); |
| 154 |
write32(&mdp_ctl->ctl_flush, ctl0_reg_val); |
| 155 |
} |