coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
ddp.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <console/console.h>
4 #include <device/mmio.h>
5 #include <edid.h>
6 #include <soc/addressmap.h>
7 #include <soc/ddp.h>
8 
10 {
11  /* ovl0->ovl0_2l */
21 }
22 
23 static void disp_config_main_path_mutex(void)
24 {
26 
27  /* Clock source from DSI0 */
30  write32(&disp_mutex->mutex[0].en, BIT(0));
31 }
32 
33 static void ovl_bgclr_in_sel(u32 idx)
34 {
35  setbits32(&disp_ovl[idx]->datapath_con, BIT(2));
36 }
37 
38 static void ovl_layer_smi_id_en(u32 idx)
39 {
40  printk(BIOS_INFO, "%s\n", __func__);
41 
42  setbits32(&disp_ovl[idx]->datapath_con, BIT(0));
43 }
44 
46 {
47  struct disp_ccorr_regs *const regs = disp_ccorr;
48  int enable_relay = 0;
49 
50  printk(BIOS_INFO, "%s\n", __func__);
51 
52  write32(&regs->size, width << 16 | height);
53 
54  if (enable_relay) {
56  clrbits32(&regs->cfg, PQ_ENGINE_EN);
57  } else {
59  setbits32(&regs->cfg, PQ_ENGINE_EN);
60  }
61 
62  write32(&regs->en, PQ_EN);
63 }
64 
65 static void aal_config(u32 width, u32 height)
66 {
67  struct disp_aal_regs *const regs = disp_aal;
68  int enable_relay = 1;
69 
70  printk(BIOS_INFO, "%s\n", __func__);
71 
72  write32(&regs->size, width << 16 | height);
73  write32(&regs->output_size, width << 16 | height);
74 
75  if (enable_relay) {
77  clrbits32(&regs->cfg, PQ_ENGINE_EN);
78  } else {
80  setbits32(&regs->cfg, PQ_ENGINE_EN);
81  }
82 
83  write32(&regs->en, PQ_EN);
84 }
85 
87 {
88  struct disp_gamma_regs *const regs = disp_gamma;
89  int enable_relay = 0;
90 
91  printk(BIOS_INFO, "%s\n", __func__);
92 
93  write32(&regs->size, width << 16 | height);
94 
95  if (enable_relay)
97  else
99 
100  write32(&regs->en, PQ_EN);
101 }
102 
104 {
105  struct disp_postmask_regs *const regs = disp_postmask;
106  int enable_relay = 1;
107 
108  printk(BIOS_INFO, "%s\n", __func__);
109 
110  write32(&regs->size, width << 16 | height);
111 
112  if (enable_relay)
113  setbits32(&regs->cfg, PQ_RELAY_MODE);
114  else
115  clrbits32(&regs->cfg, PQ_RELAY_MODE);
116 
117  write32(&regs->en, PQ_EN);
118 }
119 
121 {
122  struct disp_dither_regs *const regs = disp_dither;
123  int enable_relay = 1;
124 
125  printk(BIOS_INFO, "%s\n", __func__);
126 
127  write32(&regs->size, width << 16 | height);
128 
129  if (enable_relay)
130  setbits32(&regs->cfg, PQ_RELAY_MODE);
131  else
132  clrbits32(&regs->cfg, PQ_RELAY_MODE);
133 
134  write32(&regs->en, PQ_EN);
135 }
136 
137 
138 static void main_disp_path_setup(u32 width, u32 height, u32 vrefresh)
139 {
140  u32 idx = 0;
141  u32 pixel_clk = width * height * vrefresh;
142 
143  printk(BIOS_INFO, "%s\n", __func__);
144 
145  for (idx = 0; idx < MAIN_PATH_OVL_NR; idx++) {
146  ovl_set_roi(idx, width, height, idx ? 0 : 0xff0000ff);
147  ovl_layer_smi_id_en(idx);
148  }
149 
150  rdma_config(width, height, pixel_clk, 5 * KiB);
159 }
160 
161 static void disp_clock_on(void)
162 {
164 
166 
168 }
169 
170 void mtk_ddp_init(void)
171 {
172  disp_clock_on();
173  /* Turn off M4U port. */
175 }
176 
177 void mtk_ddp_mode_set(const struct edid *edid)
178 {
179  u32 fmt = OVL_INFMT_RGBA8888;
181  u32 width = edid->mode.ha;
182  u32 height = edid->mode.va;
183  u32 vrefresh = edid->mode.refresh;
184 
185  printk(BIOS_INFO, "%s display resolution: %dx%d@%d bpp %d\n",
186  __func__, width, height, vrefresh, bpp);
187 
188  if (!vrefresh) {
189  vrefresh = 60;
190  printk(BIOS_INFO, "%s invalid vrefresh %d\n",
191  __func__, vrefresh);
192  }
193 
194  main_disp_path_setup(width, height, vrefresh);
195  rdma_start();
196  ovl_layer_config(fmt, bpp, width, height);
197  ovl_bgclr_in_sel(1);
198 }
static void write32(void *addr, uint32_t val)
Definition: mmio.h:40
static int width
Definition: bochs.c:42
#define KiB
Definition: helpers.h:75
void color_start(u32 width, u32 height)
Definition: ddp.c:47
void rdma_config(u32 width, u32 height, u32 pixel_clk, u32 fifo_size)
Definition: ddp.c:23
void ovl_set_roi(u32 idx, u32 width, u32 height, u32 color)
Definition: ddp.c:12
void rdma_start(void)
Definition: ddp.c:18
void ovl_layer_config(u32 fmt, u32 bpp, u32 width, u32 height)
Definition: ddp.c:56
#define printk(level,...)
Definition: stdlib.h:16
@ OVL_INFMT_RGBA8888
Definition: ddp_common.h:123
static struct disp_ovl_regs *const disp_ovl[2]
Definition: ddp_common.h:61
#define BIT(nr)
Definition: ec_commands.h:45
#define setbits32(addr, set)
Definition: mmio.h:21
#define clrbits32(addr, clear)
Definition: mmio.h:26
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
void mtk_ddp_init(void)
Definition: ddp.c:61
void mtk_ddp_mode_set(const struct edid *edid)
Definition: ddp.c:66
@ MUTEX_MOD_MAIN_PATH
Definition: ddp.h:240
static struct disp_mutex_regs *const disp_mutex
Definition: ddp.h:231
static struct mmsys_cfg_regs *const mmsys_cfg
Definition: ddp.h:133
static struct disp_pq_regs *const disp_ccorr
Definition: ddp.h:168
static struct disp_pq_regs *const disp_aal
Definition: ddp.h:170
static struct disp_pq_regs *const disp_gamma
Definition: ddp.h:172
@ CG_CON0_DISP_ALL
Definition: ddp.h:65
static struct disp_pq_regs *const disp_dither
Definition: ddp.h:174
@ MUTEX_SOF_DSI0
Definition: ddp.h:147
#define MAIN_PATH_OVL_NR
Definition: ddp.h:10
#define PQ_ENGINE_EN
Definition: ddp.h:247
@ CG_CON2_DISP_ALL
Definition: ddp.h:195
#define SMI_LARB_PORT_L0_OVL_RDMA0
Definition: ddp.h:16
static struct disp_postmask_regs *const disp_postmask
Definition: ddp.h:254
#define PQ_RELAY_MODE
Definition: ddp.h:246
#define PQ_EN
Definition: ddp.h:245
static void ovl_layer_smi_id_en(u32 idx)
Definition: ddp.c:38
static void gamma_config(u32 width, u32 height)
Definition: ddp.c:86
static void dither_config(u32 width, u32 height)
Definition: ddp.c:120
static void main_disp_path_setup(u32 width, u32 height, u32 vrefresh)
Definition: ddp.c:138
static void aal_config(u32 width, u32 height)
Definition: ddp.c:65
static void postmask_config(u32 width, u32 height)
Definition: ddp.c:103
static void ovl_bgclr_in_sel(u32 idx)
Definition: ddp.c:33
static void disp_config_main_path_connection(void)
Definition: ddp.c:9
static void disp_clock_on(void)
Definition: ddp.c:161
static void ccorr_config(u32 width, u32 height)
Definition: ddp.c:45
static void disp_config_main_path_mutex(void)
Definition: ddp.c:23
@ CG_CON1_DISP_ALL
Definition: ddp.h:100
@ OVL0_MOUT_EN_DISP_RDMA0
Definition: ddp.h:119
@ DISP_OVL0_2L_GO_BLEND
Definition: ddp.h:117
@ DISP_OVL0_GO_BG
Definition: ddp.h:116
@ DITHER0_MOUT_DSI0
Definition: ddp.h:120
@ RDMA0_SEL_IN_OVL0_2L
Definition: ddp.h:124
@ AAL0_SEL_IN_CCORR0
Definition: ddp.h:127
@ CCORR0_SOUT_AAL0
Definition: ddp.h:126
@ DSI0_SEL_IN_DITHER0
Definition: ddp.h:128
@ RDMA0_SOUT_COLOR0
Definition: ddp.h:125
@ SMI_LARB0
Definition: addressmap.h:62
uint32_t u32
Definition: stdint.h:51
struct disp_mutex_regs::@798 mutex[6]
unsigned int refresh
Definition: edid.h:24
unsigned int va
Definition: edid.h:30
unsigned int ha
Definition: edid.h:25
Definition: edid.h:49
unsigned int framebuffer_bits_per_pixel
Definition: edid.h:58
struct edid_mode mode
Definition: edid.h:72
u32 ccorr0_sout_sel
Definition: ddp.h:39
u32 mmsys_cg_con0
Definition: ddp.h:63
u32 aal0_sel_in
Definition: ddp.h:40
u32 dsi0_sel_in
Definition: ddp.h:50
u32 mmsys_cg_con2
Definition: ddp.h:28
u32 mmsys_ovl_mout_en
Definition: ddp.h:27
u32 rdma0_sel_in
Definition: ddp.h:37
u32 mmsys_cg_con1
Definition: ddp.h:67
u32 dither0_mout_en
Definition: ddp.h:41
u32 rdma0_sout_sel
Definition: ddp.h:38
u32 ovl0_2l_mout_en
Definition: ddp.h:32
#define height