@@ -528,31 +528,16 @@ gen11_dsi_setup_dphy_timings(struct intel_encoder *encoder,
528528 enum port port ;
529529 enum phy phy ;
530530
531- /* Program T-INIT master registers */
532- for_each_dsi_port (port , intel_dsi -> ports )
533- intel_de_rmw (dev_priv , ICL_DSI_T_INIT_MASTER (port ),
534- DSI_T_INIT_MASTER_MASK , intel_dsi -> init_count );
535-
536531 /* Program DPHY clock lanes timings */
537- for_each_dsi_port (port , intel_dsi -> ports ) {
532+ for_each_dsi_port (port , intel_dsi -> ports )
538533 intel_de_write (dev_priv , DPHY_CLK_TIMING_PARAM (port ),
539534 intel_dsi -> dphy_reg );
540535
541- /* shadow register inside display core */
542- intel_de_write (dev_priv , DSI_CLK_TIMING_PARAM (port ),
543- intel_dsi -> dphy_reg );
544- }
545-
546536 /* Program DPHY data lanes timings */
547- for_each_dsi_port (port , intel_dsi -> ports ) {
537+ for_each_dsi_port (port , intel_dsi -> ports )
548538 intel_de_write (dev_priv , DPHY_DATA_TIMING_PARAM (port ),
549539 intel_dsi -> dphy_data_lane_reg );
550540
551- /* shadow register inside display core */
552- intel_de_write (dev_priv , DSI_DATA_TIMING_PARAM (port ),
553- intel_dsi -> dphy_data_lane_reg );
554- }
555-
556541 /*
557542 * If DSI link operating at or below an 800 MHz,
558543 * TA_SURE should be override and programmed to
@@ -561,16 +546,10 @@ gen11_dsi_setup_dphy_timings(struct intel_encoder *encoder,
561546 */
562547 if (DISPLAY_VER (dev_priv ) == 11 ) {
563548 if (afe_clk (encoder , crtc_state ) <= 800000 ) {
564- for_each_dsi_port (port , intel_dsi -> ports ) {
549+ for_each_dsi_port (port , intel_dsi -> ports )
565550 intel_de_rmw (dev_priv , DPHY_TA_TIMING_PARAM (port ),
566551 TA_SURE_MASK ,
567552 TA_SURE_OVERRIDE | TA_SURE (0 ));
568-
569- /* shadow register inside display core */
570- intel_de_rmw (dev_priv , DSI_TA_TIMING_PARAM (port ),
571- TA_SURE_MASK ,
572- TA_SURE_OVERRIDE | TA_SURE (0 ));
573- }
574553 }
575554 }
576555
@@ -581,6 +560,41 @@ gen11_dsi_setup_dphy_timings(struct intel_encoder *encoder,
581560 }
582561}
583562
563+ static void
564+ gen11_dsi_setup_timings (struct intel_encoder * encoder ,
565+ const struct intel_crtc_state * crtc_state )
566+ {
567+ struct drm_i915_private * dev_priv = to_i915 (encoder -> base .dev );
568+ struct intel_dsi * intel_dsi = enc_to_intel_dsi (encoder );
569+ enum port port ;
570+
571+ /* Program T-INIT master registers */
572+ for_each_dsi_port (port , intel_dsi -> ports )
573+ intel_de_rmw (dev_priv , ICL_DSI_T_INIT_MASTER (port ),
574+ DSI_T_INIT_MASTER_MASK , intel_dsi -> init_count );
575+
576+ /* shadow register inside display core */
577+ for_each_dsi_port (port , intel_dsi -> ports )
578+ intel_de_write (dev_priv , DSI_CLK_TIMING_PARAM (port ),
579+ intel_dsi -> dphy_reg );
580+
581+ /* shadow register inside display core */
582+ for_each_dsi_port (port , intel_dsi -> ports )
583+ intel_de_write (dev_priv , DSI_DATA_TIMING_PARAM (port ),
584+ intel_dsi -> dphy_data_lane_reg );
585+
586+ /* shadow register inside display core */
587+ if (DISPLAY_VER (dev_priv ) == 11 ) {
588+ if (afe_clk (encoder , crtc_state ) <= 800000 ) {
589+ for_each_dsi_port (port , intel_dsi -> ports ) {
590+ intel_de_rmw (dev_priv , DSI_TA_TIMING_PARAM (port ),
591+ TA_SURE_MASK ,
592+ TA_SURE_OVERRIDE | TA_SURE (0 ));
593+ }
594+ }
595+ }
596+ }
597+
584598static void gen11_dsi_gate_clocks (struct intel_encoder * encoder )
585599{
586600 struct drm_i915_private * dev_priv = to_i915 (encoder -> base .dev );
@@ -1090,11 +1104,15 @@ gen11_dsi_enable_port_and_phy(struct intel_encoder *encoder,
10901104 /* step 4c: configure voltage swing and skew */
10911105 gen11_dsi_voltage_swing_program_seq (encoder );
10921106
1107+ /* setup D-PHY timings */
1108+ gen11_dsi_setup_dphy_timings (encoder , crtc_state );
1109+
10931110 /* enable DDI buffer */
10941111 gen11_dsi_enable_ddi_buffer (encoder );
10951112
1096- /* setup D-PHY timings */
1097- gen11_dsi_setup_dphy_timings (encoder , crtc_state );
1113+ gen11_dsi_gate_clocks (encoder );
1114+
1115+ gen11_dsi_setup_timings (encoder , crtc_state );
10981116
10991117 /* Since transcoder is configured to take events from GPIO */
11001118 gen11_dsi_config_util_pin (encoder , true);
@@ -1104,9 +1122,6 @@ gen11_dsi_enable_port_and_phy(struct intel_encoder *encoder,
11041122
11051123 /* Step (4h, 4i, 4j, 4k): Configure transcoder */
11061124 gen11_dsi_configure_transcoder (encoder , crtc_state );
1107-
1108- /* Step 4l: Gate DDI clocks */
1109- gen11_dsi_gate_clocks (encoder );
11101125}
11111126
11121127static void gen11_dsi_powerup_panel (struct intel_encoder * encoder )
@@ -1138,12 +1153,7 @@ static void gen11_dsi_powerup_panel(struct intel_encoder *encoder)
11381153 "error setting max return pkt size%d\n" , tmp );
11391154 }
11401155
1141- /* panel power on related mipi dsi vbt sequences */
1142- intel_dsi_vbt_exec_sequence (intel_dsi , MIPI_SEQ_POWER_ON );
1143- msleep (intel_dsi -> panel_on_delay );
1144- intel_dsi_vbt_exec_sequence (intel_dsi , MIPI_SEQ_DEASSERT_RESET );
11451156 intel_dsi_vbt_exec_sequence (intel_dsi , MIPI_SEQ_INIT_OTP );
1146- intel_dsi_vbt_exec_sequence (intel_dsi , MIPI_SEQ_DISPLAY_ON );
11471157
11481158 /* ensure all panel commands dispatched before enabling transcoder */
11491159 wait_for_cmds_dispatched_to_panel (encoder );
@@ -1154,6 +1164,14 @@ static void gen11_dsi_pre_pll_enable(struct intel_atomic_state *state,
11541164 const struct intel_crtc_state * crtc_state ,
11551165 const struct drm_connector_state * conn_state )
11561166{
1167+ struct intel_dsi * intel_dsi = enc_to_intel_dsi (encoder );
1168+
1169+ intel_dsi_wait_panel_power_cycle (intel_dsi );
1170+
1171+ intel_dsi_vbt_exec_sequence (intel_dsi , MIPI_SEQ_POWER_ON );
1172+ msleep (intel_dsi -> panel_on_delay );
1173+ intel_dsi_vbt_exec_sequence (intel_dsi , MIPI_SEQ_DEASSERT_RESET );
1174+
11571175 /* step2: enable IO power */
11581176 gen11_dsi_enable_io_power (encoder );
11591177
@@ -1225,9 +1243,7 @@ static void gen11_dsi_enable(struct intel_atomic_state *state,
12251243 const struct drm_connector_state * conn_state )
12261244{
12271245 struct intel_dsi * intel_dsi = enc_to_intel_dsi (encoder );
1228- struct intel_crtc * crtc = to_intel_crtc (conn_state -> crtc );
1229-
1230- drm_WARN_ON (state -> base .dev , crtc_state -> has_pch_encoder );
1246+ struct intel_crtc * crtc = to_intel_crtc (crtc_state -> uapi .crtc );
12311247
12321248 /* Wa_1409054076:icl,jsl,ehl */
12331249 icl_apply_kvmr_pipe_a_wa (encoder , crtc -> pipe , true);
@@ -1238,6 +1254,8 @@ static void gen11_dsi_enable(struct intel_atomic_state *state,
12381254 /* step6d: enable dsi transcoder */
12391255 gen11_dsi_enable_transcoder (encoder );
12401256
1257+ intel_dsi_vbt_exec_sequence (intel_dsi , MIPI_SEQ_DISPLAY_ON );
1258+
12411259 /* step7: enable backlight */
12421260 intel_backlight_enable (crtc_state , conn_state );
12431261 intel_dsi_vbt_exec_sequence (intel_dsi , MIPI_SEQ_BACKLIGHT_ON );
@@ -1271,8 +1289,6 @@ static void gen11_dsi_powerdown_panel(struct intel_encoder *encoder)
12711289 struct intel_dsi * intel_dsi = enc_to_intel_dsi (encoder );
12721290
12731291 intel_dsi_vbt_exec_sequence (intel_dsi , MIPI_SEQ_DISPLAY_OFF );
1274- intel_dsi_vbt_exec_sequence (intel_dsi , MIPI_SEQ_ASSERT_RESET );
1275- intel_dsi_vbt_exec_sequence (intel_dsi , MIPI_SEQ_POWER_OFF );
12761292
12771293 /* ensure cmds dispatched to panel */
12781294 wait_for_cmds_dispatched_to_panel (encoder );
@@ -1373,11 +1389,21 @@ static void gen11_dsi_disable(struct intel_atomic_state *state,
13731389 const struct drm_connector_state * old_conn_state )
13741390{
13751391 struct intel_dsi * intel_dsi = enc_to_intel_dsi (encoder );
1376- struct intel_crtc * crtc = to_intel_crtc (old_conn_state -> crtc );
13771392
13781393 /* step1: turn off backlight */
13791394 intel_dsi_vbt_exec_sequence (intel_dsi , MIPI_SEQ_BACKLIGHT_OFF );
13801395 intel_backlight_disable (old_conn_state );
1396+ }
1397+
1398+ static void gen11_dsi_post_disable (struct intel_atomic_state * state ,
1399+ struct intel_encoder * encoder ,
1400+ const struct intel_crtc_state * old_crtc_state ,
1401+ const struct drm_connector_state * old_conn_state )
1402+ {
1403+ struct intel_dsi * intel_dsi = enc_to_intel_dsi (encoder );
1404+ struct intel_crtc * crtc = to_intel_crtc (old_crtc_state -> uapi .crtc );
1405+
1406+ intel_crtc_vblank_off (old_crtc_state );
13811407
13821408 /* step2d,e: disable transcoder and wait */
13831409 gen11_dsi_disable_transcoder (encoder );
@@ -1391,25 +1417,23 @@ static void gen11_dsi_disable(struct intel_atomic_state *state,
13911417 /* step2h,i,j: deconfig trancoder */
13921418 gen11_dsi_deconfigure_trancoder (encoder );
13931419
1420+ intel_dsc_disable (old_crtc_state );
1421+ skl_scaler_disable (old_crtc_state );
1422+
13941423 /* step3: disable port */
13951424 gen11_dsi_disable_port (encoder );
13961425
13971426 gen11_dsi_config_util_pin (encoder , false);
13981427
13991428 /* step4: disable IO power */
14001429 gen11_dsi_disable_io_power (encoder );
1401- }
14021430
1403- static void gen11_dsi_post_disable (struct intel_atomic_state * state ,
1404- struct intel_encoder * encoder ,
1405- const struct intel_crtc_state * old_crtc_state ,
1406- const struct drm_connector_state * old_conn_state )
1407- {
1408- intel_crtc_vblank_off (old_crtc_state );
1431+ intel_dsi_vbt_exec_sequence (intel_dsi , MIPI_SEQ_ASSERT_RESET );
14091432
1410- intel_dsc_disable (old_crtc_state );
1433+ msleep (intel_dsi -> panel_off_delay );
1434+ intel_dsi_vbt_exec_sequence (intel_dsi , MIPI_SEQ_POWER_OFF );
14111435
1412- skl_scaler_disable ( old_crtc_state );
1436+ intel_dsi -> panel_power_off_time = ktime_get_boottime ( );
14131437}
14141438
14151439static enum drm_mode_status gen11_dsi_mode_valid (struct drm_connector * connector ,
@@ -1909,15 +1933,17 @@ static void icl_dsi_add_properties(struct intel_connector *connector)
19091933 fixed_mode -> vdisplay );
19101934}
19111935
1912- void icl_dsi_init (struct drm_i915_private * dev_priv )
1936+ void icl_dsi_init (struct drm_i915_private * dev_priv ,
1937+ const struct intel_bios_encoder_data * devdata )
19131938{
19141939 struct intel_dsi * intel_dsi ;
19151940 struct intel_encoder * encoder ;
19161941 struct intel_connector * intel_connector ;
19171942 struct drm_connector * connector ;
19181943 enum port port ;
19191944
1920- if (!intel_bios_is_dsi_present (dev_priv , & port ))
1945+ port = intel_bios_encoder_port (devdata );
1946+ if (port == PORT_NONE )
19211947 return ;
19221948
19231949 intel_dsi = kzalloc (sizeof (* intel_dsi ), GFP_KERNEL );
@@ -1934,6 +1960,8 @@ void icl_dsi_init(struct drm_i915_private *dev_priv)
19341960 intel_dsi -> attached_connector = intel_connector ;
19351961 connector = & intel_connector -> base ;
19361962
1963+ encoder -> devdata = devdata ;
1964+
19371965 /* register DSI encoder with DRM subsystem */
19381966 drm_encoder_init (& dev_priv -> drm , & encoder -> base , & gen11_dsi_encoder_funcs ,
19391967 DRM_MODE_ENCODER_DSI , "DSI %c" , port_name (port ));
@@ -1957,6 +1985,7 @@ void icl_dsi_init(struct drm_i915_private *dev_priv)
19571985 encoder -> get_power_domains = gen11_dsi_get_power_domains ;
19581986 encoder -> disable_clock = gen11_dsi_gate_clocks ;
19591987 encoder -> is_clock_enabled = gen11_dsi_is_clock_enabled ;
1988+ encoder -> shutdown = intel_dsi_shutdown ;
19601989
19611990 /* register DSI connector with DRM subsystem */
19621991 drm_connector_init (& dev_priv -> drm , connector , & gen11_dsi_connector_funcs ,
@@ -1968,7 +1997,8 @@ void icl_dsi_init(struct drm_i915_private *dev_priv)
19681997 /* attach connector to encoder */
19691998 intel_connector_attach_encoder (intel_connector , encoder );
19701999
1971- encoder -> devdata = intel_bios_encoder_data_lookup (dev_priv , port );
2000+ intel_dsi -> panel_power_off_time = ktime_get_boottime ();
2001+
19722002 intel_bios_init_panel_late (dev_priv , & intel_connector -> panel , encoder -> devdata , NULL );
19732003
19742004 mutex_lock (& dev_priv -> drm .mode_config .mutex );
0 commit comments