45 while ((timeout < 20000) &&
52 DRM_INFO(
"MIPI: HS Data FIFO was never cleared!\n");
55 static void mdfld_wait_for_HS_CTRL_FIFO(
struct drm_device *dev,
u32 pipe)
63 while ((timeout < 20000) && (
REG_READ(gen_fifo_stat_reg)
69 DRM_INFO(
"MIPI: HS CMD FIFO was never cleared!\n");
72 static void mdfld_wait_for_DPI_CTRL_FIFO(
struct drm_device *dev,
u32 pipe)
80 while ((timeout < 20000) && ((
REG_READ(gen_fifo_stat_reg) &
87 DRM_ERROR(
"MIPI: DPI FIFO was never cleared\n");
90 static void mdfld_wait_for_SPL_PKG_SENT(
struct drm_device *dev,
u32 pipe)
98 while ((timeout < 20000) && (!(
REG_READ(intr_stat_reg)
104 if (timeout == 20000)
105 DRM_ERROR(
"MIPI: SPL_PKT_SENT_INTERRUPT was not sent successfully!\n");
110 static void dsi_set_device_ready_state(
struct drm_device *dev,
int state,
116 static void dsi_set_pipe_plane_enable_state(
struct drm_device *dev,
137 dev_err(&dev->pdev->dev,
"%s: Pipe enable timeout\n",
164 dev_err(&dev->pdev->dev,
"%s: Pipe disable timeout\n",
168 dev_err(&dev->pdev->dev,
"%s: FIFO not empty\n",
179 mdfld_dsi_encoder_get_config(dsi_encoder);
184 dev_err(dev->dev,
"DPI panel is already off\n");
189 dsi_set_pipe_plane_enable_state(dev, 0, pipe);
190 mdfld_dsi_dpi_shut_down(dpi_output, pipe);
191 dsi_set_device_ready_state(dev, 0, pipe);
200 mdfld_dsi_encoder_get_config(dsi_encoder);
205 dev_err(dev->dev,
"DPI panel is already on\n");
210 mdfld_dsi_dpi_shut_down(dpi_output, pipe);
211 dsi_set_device_ready_state(dev, 0, pipe);
213 dsi_set_device_ready_state(dev, 1, pipe);
217 dsi_set_pipe_plane_enable_state(dev, 1, pipe);
237 DRM_INFO(
"Enter mrst init TPO MIPI display.\n");
242 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
244 mdfld_wait_for_HS_CTRL_FIFO(dev, pipe);
248 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
250 mdfld_wait_for_HS_CTRL_FIFO(dev, pipe);
254 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
256 mdfld_wait_for_HS_CTRL_FIFO(dev, pipe);
260 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
262 mdfld_wait_for_HS_CTRL_FIFO(dev, pipe);
266 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
268 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
270 mdfld_wait_for_HS_CTRL_FIFO(dev, pipe);
274 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
276 mdfld_wait_for_HS_CTRL_FIFO(dev, pipe);
280 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
282 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
284 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
286 mdfld_wait_for_HS_CTRL_FIFO(dev, pipe);
290 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
292 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
294 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
296 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
298 mdfld_wait_for_HS_CTRL_FIFO(dev, pipe);
302 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
304 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
306 mdfld_wait_for_HS_CTRL_FIFO(dev, pipe);
310 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
312 mdfld_wait_for_HS_CTRL_FIFO(dev, pipe);
316 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
318 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
320 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
322 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
324 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
326 mdfld_wait_for_HS_CTRL_FIFO(dev, pipe);
330 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
332 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
334 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
336 mdfld_wait_for_HS_CTRL_FIFO(dev, pipe);
340 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
342 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
344 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
346 mdfld_wait_for_HS_CTRL_FIFO(dev, pipe);
350 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
352 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
354 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
356 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
358 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
360 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
362 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
364 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
366 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
368 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
370 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
372 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
374 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
376 mdfld_wait_for_HS_CTRL_FIFO(dev, pipe);
380 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
382 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
384 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
386 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
388 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
390 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
392 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
394 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
396 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
398 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
400 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
402 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
404 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
406 mdfld_wait_for_HS_CTRL_FIFO(dev, pipe);
410 mdfld_wait_for_HS_DATA_FIFO(dev, pipe);
412 mdfld_wait_for_HS_CTRL_FIFO(dev, pipe);
416 static u16 mdfld_dsi_dpi_to_byte_clock_count(
int pixel_clock_count,
417 int num_lane,
int bpp)
419 return (
u16)((pixel_clock_count *
bpp) / (num_lane * 8));
430 int num_lane,
int bpp)
432 int pclk_hsync, pclk_hfp, pclk_hbp, pclk_hactive;
433 int pclk_vsync, pclk_vfp, pclk_vbp;
448 dpi_timing->
hsync_count = mdfld_dsi_dpi_to_byte_clock_count(
449 pclk_hsync, num_lane, bpp);
450 dpi_timing->
hbp_count = mdfld_dsi_dpi_to_byte_clock_count(
451 pclk_hbp, num_lane, bpp);
452 dpi_timing->
hfp_count = mdfld_dsi_dpi_to_byte_clock_count(
453 pclk_hfp, num_lane, bpp);
454 dpi_timing->
hactive_count = mdfld_dsi_dpi_to_byte_clock_count(
455 pclk_hactive, num_lane, bpp);
456 dpi_timing->
vsync_count = mdfld_dsi_dpi_to_byte_clock_count(
457 pclk_vsync, num_lane, bpp);
458 dpi_timing->
vbp_count = mdfld_dsi_dpi_to_byte_clock_count(
459 pclk_vbp, num_lane, bpp);
460 dpi_timing->
vfp_count = mdfld_dsi_dpi_to_byte_clock_count(
461 pclk_vfp, num_lane, bpp);
488 switch (dsi_config->
bpp) {
499 DRM_ERROR(
"unsupported color format, bpp = %d\n",
575 DSI_INTR_STATE_SPL_PKG_SENT);
581 mdfld_wait_for_SPL_PKG_SENT(dev, pipe);
585 DSI_INTR_STATE_SPL_PKG_SENT);
609 mdfld_wait_for_DPI_CTRL_FIFO(dev, pipe);
614 DSI_INTR_STATE_SPL_PKG_SENT);
633 static void mdfld_dsi_dpi_set_power(
struct drm_encoder *encoder,
bool on)
639 mdfld_dsi_encoder_get_config(dsi_encoder);
640 int pipe = mdfld_dsi_encoder_get_pipe(dsi_encoder);
652 mdfld_dsi_configure_up(dsi_encoder, pipe);
660 mdfld_dsi_tpo_ic_init(dsi_config, pipe);
665 mdfld_dsi_dpi_shut_down(dpi_output, pipe);
667 mdfld_dsi_configure_down(dsi_encoder, pipe);
669 mdfld_dsi_dpi_shut_down(dpi_output, pipe);
692 mdfld_dsi_encoder_get_config(dsi_encoder);
712 mdfld_dsi_dpi_set_power(encoder,
false);
717 mdfld_dsi_dpi_set_power(encoder,
true);
723 static void mipi_set_properties(
struct mdfld_dsi_config *dsi_config,
int pipe)
741 static void mdfld_mipi_set_video_timing(
struct mdfld_dsi_config *dsi_config,
770 static void mdfld_mipi_config(
struct mdfld_dsi_config *dsi_config,
int pipe)
789 mdfld_mipi_set_video_timing(dsi_config, pipe);
792 static void mdfld_set_pipe_timing(
struct mdfld_dsi_config *dsi_config,
int pipe)
820 mdfld_dsi_encoder_get_config(dsi_encoder);
823 int pipe = mdfld_dsi_encoder_get_pipe(dsi_encoder);
862 dev_err(&dev->pdev->dev,
"%s: DSI PLL lock timeout\n",
867 mipi_set_properties(dsi_config, pipe);
868 mdfld_mipi_config(dsi_config, pipe);
869 mdfld_set_pipe_timing(dsi_config, pipe);
918 mdfld_dsi_tpo_ic_init(dsi_config, pipe);
943 pipe = dsi_connector->
pipe;
946 dsi_config = mdfld_dsi_get_config(dsi_connector);
949 if (p_funcs->
reset) {
950 ret = p_funcs->
reset(pipe);
952 DRM_ERROR(
"Panel %d hard-reset failed\n", pipe);
964 DRM_ERROR(
"Panel %d get power mode failed\n", pipe);
967 DRM_INFO(
"pipe %d power mode 0x%x\n", pipe, data);
974 DRM_ERROR(
"No memory\n");
978 if (dsi_connector->
pipe)
989 dsi_config = mdfld_dsi_get_config(dsi_connector);
992 connector = &dsi_connector->
base.base;
993 encoder = &dpi_output->
base.base.base;
998 drm_encoder_helper_add(encoder,
1005 if (dsi_connector->
pipe) {
1013 dsi_connector->
base.encoder = &dpi_output->
base.base;
1015 return &dpi_output->
base;