coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
dsi_common.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef SOC_MEDIATEK_DSI_COMMON_H
4 #define SOC_MEDIATEK_DSI_COMMON_H
5 
6 #include <commonlib/helpers.h>
7 #include <edid.h>
8 #include <mipi/dsi.h>
9 #include <types.h>
10 #include <soc/addressmap.h>
11 
17 };
18 
19 /* video mode */
20 enum {
22  /* video burst mode */
24  /* video pulse mode */
26  /* enable auto vertical count mode */
28  /* enable hsync-end packets in vsync-pulse and v-porch area */
30  /* disable hfront-porch area */
32  /* disable hback-porch area */
34  /* disable hsync-active area */
36  /* flush display FIFO on vsync pulse */
38  /* disable EoT packets in HS mode */
40  /* device supports non-continuous clock behavior (DSI spec 5.6.1) */
42  /* transmit data in low power */
44  /* dsi per line's data end same time on all lanes */
46 };
47 
48 struct dsi_regs {
61  u32 dsi_lfr_con; /* Available since MT8183 */
62  u32 dsi_lfr_sta; /* Available since MT8183 */
63  u32 dsi_size_con; /* Available since MT8183 */
64  u32 dsi_vfp_early_stop; /* Available since MT8183 */
72  u8 reserved2[156];
83  u32 dsi_force_commit; /* Available since MT8183 */
84  u8 reserved6[108];
85  u32 dsi_cmdq[128];
86 };
87 static struct dsi_regs *const dsi0 = (void *)DSI0_BASE;
88 
94 
95 /* DSI_INTSTA */
96 enum {
102  DSI_BUSY = BIT(31),
103 };
104 
105 /* DSI_CON_CTRL */
106 enum {
108  DSI_EN = BIT(1),
110  DSI_DUAL = BIT(4),
111 };
112 
113 /* DSI_MODE_CTRL */
114 enum {
115  MODE = 3,
116  CMD_MODE = 0,
120  FRM_MODE = BIT(16),
121  MIX_MODE = BIT(17)
122 };
123 
124 /* DSI_TXRX_CTRL */
125 enum {
128 };
129 
130 /* DSI_PSCTRL */
131 enum {
132  DSI_PS_WC = 0x3fff,
133  DSI_PS_SEL = (3 << 16),
138 
140 };
141 
142 /* DSI_SIZE_CON */
143 enum {
146 };
147 
148 /* DSI_CMDQ_SIZE */
149 enum {
150  CMDQ_SIZE = 0x3f,
151 };
152 
153 /* DSI_PHY_LCCON */
154 enum {
157  LC_WAKEUP_EN = BIT(2)
158 };
159 
160 /*DSI_PHY_LD0CON */
161 enum {
164  LD0_WAKEUP_EN = BIT(2)
165 };
166 
167 enum {
168  LPX = (0xff << 0),
169  HS_PRPR = (0xff << 8),
170  HS_ZERO = (0xff << 16),
171  HS_TRAIL = (0xff << 24)
172 };
173 
174 enum {
175  TA_GO = (0xff << 0),
176  TA_SURE = (0xff << 8),
177  TA_GET = (0xff << 16),
178  DA_HS_EXIT = (0xff << 24)
179 };
180 
181 enum {
182  CONT_DET = (0xff << 0),
183  CLK_ZERO = (0xf << 16),
184  CLK_TRAIL = (0xff << 24)
185 };
186 
187 enum {
188  CLK_HS_PRPR = (0xff << 0),
189  CLK_HS_POST = (0xff << 8),
190  CLK_HS_EXIT = (0xf << 16)
191 };
192 
193 /* DSI_VM_CMD_CON */
194 enum {
197 };
198 
199 /* DSI_CMDQ0 */
200 enum {
201  CONFIG = (0xff << 0),
204  BTA = BIT(2),
205  DATA_ID = (0xff << 8),
206  DATA_0 = (0xff << 16),
207  DATA_1 = (0xff << 24),
208 };
209 
210 /* DSI_FORCE_COMMIT */
211 enum {
214 };
215 
221 
226 
230 
234 
236 };
237 
238 /* Functions that each SOC should provide. */
239 void mtk_dsi_reset(void);
240 void mtk_dsi_configure_mipi_tx(u32 data_rate, u32 lanes);
241 
242 /* Functions as weak no-ops that can be overridden. */
243 void mtk_dsi_override_phy_timing(struct mtk_phy_timing *timing);
244 
245 /* Public API provided in common/dsi.c */
247 int mtk_dsi_init(u32 mode_flags, u32 format, u32 lanes, const struct edid *edid,
248  const u8 *init_commands);
249 
250 #endif /* SOC_MEDIATEK_DSI_COMMON_H */
@ DSI_EN
Definition: dsi_common.h:108
@ DSI_RESET
Definition: dsi_common.h:107
@ DPHY_RESET
Definition: dsi_common.h:109
@ DSI_DUAL
Definition: dsi_common.h:110
@ LC_HS_TX_EN
Definition: dsi_common.h:155
@ LC_ULPM_EN
Definition: dsi_common.h:156
@ LC_WAKEUP_EN
Definition: dsi_common.h:157
@ CMDQ_SIZE
Definition: dsi_common.h:150
@ CONFIG
Definition: dsi_common.h:201
@ DATA_ID
Definition: dsi_common.h:205
@ DATA_0
Definition: dsi_common.h:206
@ DATA_1
Definition: dsi_common.h:207
@ LONG_PACKET
Definition: dsi_common.h:203
@ SHORT_PACKET
Definition: dsi_common.h:202
@ BTA
Definition: dsi_common.h:204
mipi_dsi_pixel_format
Definition: dsi_common.h:12
@ MIPI_DSI_FMT_RGB565
Definition: dsi_common.h:16
@ MIPI_DSI_FMT_RGB666
Definition: dsi_common.h:14
@ MIPI_DSI_FMT_RGB666_PACKED
Definition: dsi_common.h:15
@ MIPI_DSI_FMT_RGB888
Definition: dsi_common.h:13
@ PACKED_PS_16BIT_RGB565
Definition: dsi_common.h:134
@ DSI_PS_WC
Definition: dsi_common.h:132
@ PACKED_PS_18BIT_RGB666
Definition: dsi_common.h:136
@ DSI_PS_SEL
Definition: dsi_common.h:133
@ DSI_PSCON_CUSTOM_HEADER_SHIFT
Definition: dsi_common.h:139
@ PACKED_PS_24BIT_RGB888
Definition: dsi_common.h:137
@ LOOSELY_PS_18BIT_RGB666
Definition: dsi_common.h:135
@ TS_VFP_EN
Definition: dsi_common.h:196
@ VM_CMD_EN
Definition: dsi_common.h:195
@ DSI_SIZE_CON_WIDTH_SHIFT
Definition: dsi_common.h:145
@ DSI_SIZE_CON_HEIGHT_SHIFT
Definition: dsi_common.h:144
@ DSI_FORCE_COMMIT_ALWAYS
Definition: dsi_common.h:213
@ DSI_FORCE_COMMIT_USE_MMSYS
Definition: dsi_common.h:212
int mtk_dsi_init(u32 mode_flags, u32 format, u32 lanes, const struct edid *edid, const u8 *init_commands)
Definition: dsi.c:360
@ CMD_DONE_INT_FLAG
Definition: dsi_common.h:98
@ EXT_TE_RDY_INT_FLAG
Definition: dsi_common.h:101
@ TE_RDY_INT_FLAG
Definition: dsi_common.h:99
@ VM_DONE_INT_FLAG
Definition: dsi_common.h:100
@ DSI_BUSY
Definition: dsi_common.h:102
@ LPRX_RD_RDY_INT_FLAG
Definition: dsi_common.h:97
@ MIPI_DSI_MODE_VIDEO_HSE
Definition: dsi_common.h:29
@ MIPI_DSI_MODE_LINE_END
Definition: dsi_common.h:45
@ MIPI_DSI_MODE_EOT_PACKET
Definition: dsi_common.h:39
@ MIPI_DSI_MODE_VIDEO_HSA
Definition: dsi_common.h:35
@ MIPI_DSI_MODE_VSYNC_FLUSH
Definition: dsi_common.h:37
@ MIPI_DSI_MODE_VIDEO_BURST
Definition: dsi_common.h:23
@ MIPI_DSI_CLOCK_NON_CONTINUOUS
Definition: dsi_common.h:41
@ MIPI_DSI_MODE_VIDEO_AUTO_VERT
Definition: dsi_common.h:27
@ MIPI_DSI_MODE_VIDEO_SYNC_PULSE
Definition: dsi_common.h:25
@ MIPI_DSI_MODE_VIDEO_HFP
Definition: dsi_common.h:31
@ MIPI_DSI_MODE_VIDEO_HBP
Definition: dsi_common.h:33
@ MIPI_DSI_MODE_VIDEO
Definition: dsi_common.h:21
@ MIPI_DSI_MODE_LPM
Definition: dsi_common.h:43
@ DA_HS_EXIT
Definition: dsi_common.h:178
@ TA_SURE
Definition: dsi_common.h:176
@ TA_GO
Definition: dsi_common.h:175
@ TA_GET
Definition: dsi_common.h:177
void mtk_dsi_override_phy_timing(struct mtk_phy_timing *timing)
Definition: mainboard.c:68
int mtk_dsi_bpp_from_format(u32 format)
@ LD0_ULPM_EN
Definition: dsi_common.h:163
@ LD0_RM_TRIG_EN
Definition: dsi_common.h:162
@ LD0_WAKEUP_EN
Definition: dsi_common.h:164
check_member(dsi_regs, dsi_phy_lccon, 0x104)
static struct dsi_regs *const dsi0
Definition: dsi_common.h:87
void mtk_dsi_configure_mipi_tx(u32 data_rate, u32 lanes)
Definition: mtk_mipi_dphy.c:10
void mtk_dsi_reset(void)
Definition: mtk_mipi_dphy.c:65
@ HS_ZERO
Definition: dsi_common.h:170
@ LPX
Definition: dsi_common.h:168
@ HS_PRPR
Definition: dsi_common.h:169
@ HS_TRAIL
Definition: dsi_common.h:171
@ CLK_TRAIL
Definition: dsi_common.h:184
@ CLK_ZERO
Definition: dsi_common.h:183
@ CONT_DET
Definition: dsi_common.h:182
@ CMD_MODE
Definition: dsi_common.h:116
@ SYNC_EVENT_MODE
Definition: dsi_common.h:118
@ BURST_MODE
Definition: dsi_common.h:119
@ MODE
Definition: dsi_common.h:115
@ SYNC_PULSE_MODE
Definition: dsi_common.h:117
@ FRM_MODE
Definition: dsi_common.h:120
@ MIX_MODE
Definition: dsi_common.h:121
@ EOTP_DISABLE
Definition: dsi_common.h:126
@ NON_CONTINUOUS_CLK
Definition: dsi_common.h:127
@ CLK_HS_PRPR
Definition: dsi_common.h:188
@ CLK_HS_EXIT
Definition: dsi_common.h:190
@ CLK_HS_POST
Definition: dsi_common.h:189
#define BIT(nr)
Definition: ec_commands.h:45
@ DSI0_BASE
Definition: addressmap.h:54
uint32_t u32
Definition: stdint.h:51
uint8_t u8
Definition: stdint.h:45
u32 dsi_lfr_sta
Definition: dsi_common.h:62
u32 dsi_phy_lccon
Definition: dsi_common.h:73
u32 dsi_phy_timecon2
Definition: dsi_common.h:78
u32 reserved1[4]
Definition: dsi_common.h:65
u32 dsi_txrx_ctrl
Definition: dsi_common.h:55
u32 dsi_inten
Definition: dsi_common.h:51
u32 dsi_vm_cmd_con
Definition: dsi_common.h:81
u32 dsi_phy_timecon1
Definition: dsi_common.h:77
u8 reserved5[92]
Definition: dsi_common.h:82
u32 dsi_phy_timecon0
Definition: dsi_common.h:76
u32 dsi_bllp_wc
Definition: dsi_common.h:69
u32 dsi_vfp_nl
Definition: dsi_common.h:59
u32 dsi_vbp_nl
Definition: dsi_common.h:58
u32 dsi_hsa_wc
Definition: dsi_common.h:66
u32 dsi_cmdq_size
Definition: dsi_common.h:70
u32 dsi_vact_nl
Definition: dsi_common.h:60
u8 reserved4[16]
Definition: dsi_common.h:80
u32 dsi_intsta
Definition: dsi_common.h:52
u32 dsi_psctrl
Definition: dsi_common.h:56
u32 dsi_hstx_cklp_wc
Definition: dsi_common.h:71
u8 reserved0[4]
Definition: dsi_common.h:50
u8 reserved2[156]
Definition: dsi_common.h:72
u32 dsi_phy_ld0con
Definition: dsi_common.h:74
u32 dsi_mode_ctrl
Definition: dsi_common.h:54
u32 dsi_size_con
Definition: dsi_common.h:63
u8 reserved6[108]
Definition: dsi_common.h:84
u8 reserved3[4]
Definition: dsi_common.h:75
u32 dsi_con_ctrl
Definition: dsi_common.h:53
u32 dsi_cmdq[128]
Definition: dsi_common.h:85
u32 dsi_start
Definition: dsi_common.h:49
u32 dsi_vsa_nl
Definition: dsi_common.h:57
u32 dsi_vfp_early_stop
Definition: dsi_common.h:64
u32 dsi_hfp_wc
Definition: dsi_common.h:68
u32 dsi_hbp_wc
Definition: dsi_common.h:67
u32 dsi_phy_timecon3
Definition: dsi_common.h:79
u32 dsi_lfr_con
Definition: dsi_common.h:61
u32 dsi_force_commit
Definition: dsi_common.h:83
Definition: edid.h:49