@@ -463,11 +463,6 @@ static void vc4_hdmi_encoder_disable(struct drm_encoder *encoder)
463
463
HD_WRITE (VC4_HD_VID_CTL ,
464
464
HD_READ (VC4_HD_VID_CTL ) & ~VC4_HD_VID_CTL_ENABLE );
465
465
466
- HD_WRITE (VC4_HD_M_CTL , VC4_HD_M_SW_RST );
467
- udelay (1 );
468
- HD_WRITE (VC4_HD_M_CTL , 0 );
469
-
470
- clk_disable_unprepare (hdmi -> hsm_clock );
471
466
clk_disable_unprepare (hdmi -> pixel_clock );
472
467
473
468
ret = pm_runtime_put (& hdmi -> pdev -> dev );
@@ -509,16 +504,6 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder)
509
504
return ;
510
505
}
511
506
512
- /* This is the rate that is set by the firmware. The number
513
- * needs to be a bit higher than the pixel clock rate
514
- * (generally 148.5Mhz).
515
- */
516
- ret = clk_set_rate (hdmi -> hsm_clock , 163682864 );
517
- if (ret ) {
518
- DRM_ERROR ("Failed to set HSM clock rate: %d\n" , ret );
519
- return ;
520
- }
521
-
522
507
ret = clk_set_rate (hdmi -> pixel_clock ,
523
508
mode -> clock * 1000 *
524
509
((mode -> flags & DRM_MODE_FLAG_DBLCLK ) ? 2 : 1 ));
@@ -533,20 +518,6 @@ static void vc4_hdmi_encoder_enable(struct drm_encoder *encoder)
533
518
return ;
534
519
}
535
520
536
- ret = clk_prepare_enable (hdmi -> hsm_clock );
537
- if (ret ) {
538
- DRM_ERROR ("Failed to turn on HDMI state machine clock: %d\n" ,
539
- ret );
540
- clk_disable_unprepare (hdmi -> pixel_clock );
541
- return ;
542
- }
543
-
544
- HD_WRITE (VC4_HD_M_CTL , VC4_HD_M_SW_RST );
545
- udelay (1 );
546
- HD_WRITE (VC4_HD_M_CTL , 0 );
547
-
548
- HD_WRITE (VC4_HD_M_CTL , VC4_HD_M_ENABLE );
549
-
550
521
HDMI_WRITE (VC4_HDMI_SW_RESET_CONTROL ,
551
522
VC4_HDMI_SW_RESET_HDMI |
552
523
VC4_HDMI_SW_RESET_FORMAT_DETECT );
@@ -1205,6 +1176,23 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
1205
1176
return - EPROBE_DEFER ;
1206
1177
}
1207
1178
1179
+ /* This is the rate that is set by the firmware. The number
1180
+ * needs to be a bit higher than the pixel clock rate
1181
+ * (generally 148.5Mhz).
1182
+ */
1183
+ ret = clk_set_rate (hdmi -> hsm_clock , 163682864 );
1184
+ if (ret ) {
1185
+ DRM_ERROR ("Failed to set HSM clock rate: %d\n" , ret );
1186
+ goto err_put_i2c ;
1187
+ }
1188
+
1189
+ ret = clk_prepare_enable (hdmi -> hsm_clock );
1190
+ if (ret ) {
1191
+ DRM_ERROR ("Failed to turn on HDMI state machine clock: %d\n" ,
1192
+ ret );
1193
+ goto err_put_i2c ;
1194
+ }
1195
+
1208
1196
/* Only use the GPIO HPD pin if present in the DT, otherwise
1209
1197
* we'll use the HDMI core's register.
1210
1198
*/
@@ -1216,14 +1204,22 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
1216
1204
& hpd_gpio_flags );
1217
1205
if (hdmi -> hpd_gpio < 0 ) {
1218
1206
ret = hdmi -> hpd_gpio ;
1219
- goto err_put_i2c ;
1207
+ goto err_unprepare_hsm ;
1220
1208
}
1221
1209
1222
1210
hdmi -> hpd_active_low = hpd_gpio_flags & OF_GPIO_ACTIVE_LOW ;
1223
1211
}
1224
1212
1225
1213
vc4 -> hdmi = hdmi ;
1226
1214
1215
+ /* HDMI core must be enabled. */
1216
+ if (!(HD_READ (VC4_HD_M_CTL ) & VC4_HD_M_ENABLE )) {
1217
+ HD_WRITE (VC4_HD_M_CTL , VC4_HD_M_SW_RST );
1218
+ udelay (1 );
1219
+ HD_WRITE (VC4_HD_M_CTL , 0 );
1220
+
1221
+ HD_WRITE (VC4_HD_M_CTL , VC4_HD_M_ENABLE );
1222
+ }
1227
1223
pm_runtime_enable (dev );
1228
1224
1229
1225
drm_encoder_init (drm , hdmi -> encoder , & vc4_hdmi_encoder_funcs ,
@@ -1244,6 +1240,8 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
1244
1240
1245
1241
err_destroy_encoder :
1246
1242
vc4_hdmi_encoder_destroy (hdmi -> encoder );
1243
+ err_unprepare_hsm :
1244
+ clk_disable_unprepare (hdmi -> hsm_clock );
1247
1245
pm_runtime_disable (dev );
1248
1246
err_put_i2c :
1249
1247
put_device (& hdmi -> ddc -> dev );
@@ -1263,6 +1261,7 @@ static void vc4_hdmi_unbind(struct device *dev, struct device *master,
1263
1261
vc4_hdmi_connector_destroy (hdmi -> connector );
1264
1262
vc4_hdmi_encoder_destroy (hdmi -> encoder );
1265
1263
1264
+ clk_disable_unprepare (hdmi -> hsm_clock );
1266
1265
pm_runtime_disable (dev );
1267
1266
1268
1267
put_device (& hdmi -> ddc -> dev );
0 commit comments