drm/msm/dp: add API to take DP register snapshot
authorAbhinav Kumar <abhinavk@codeaurora.org>
Fri, 16 Apr 2021 20:57:22 +0000 (13:57 -0700)
committerRob Clark <robdclark@chromium.org>
Wed, 23 Jun 2021 14:32:13 +0000 (07:32 -0700)
Add an API to take a snapshot of DP controller registers. This API
will be used by the msm_disp_snapshot module to capture the DP
snapshot.

Signed-off-by: Abhinav Kumar <abhinavk@codeaurora.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/1618606645-19695-5-git-send-email-abhinavk@codeaurora.org
Signed-off-by: Rob Clark <robdclark@chromium.org>
drivers/gpu/drm/msm/dp/dp_catalog.c
drivers/gpu/drm/msm/dp/dp_catalog.h
drivers/gpu/drm/msm/dp/dp_display.c
drivers/gpu/drm/msm/msm_drv.h

index f4f53f2..854c41d 100644 (file)
@@ -62,6 +62,15 @@ struct dp_catalog_private {
        u8 aux_lut_cfg_index[PHY_AUX_CFG_MAX];
 };
 
+void dp_catalog_snapshot(struct dp_catalog *dp_catalog, struct msm_disp_state *disp_state)
+{
+       struct dp_catalog_private *catalog = container_of(dp_catalog,
+                       struct dp_catalog_private, dp_catalog);
+
+       msm_disp_snapshot_add_block(disp_state, catalog->io->dp_controller.len,
+                       catalog->io->dp_controller.base, "dp_ctrl");
+}
+
 static inline u32 dp_read_aux(struct dp_catalog_private *catalog, u32 offset)
 {
        offset += MSM_DP_CONTROLLER_AUX_OFFSET;
index 176a902..e7e8b13 100644 (file)
@@ -9,6 +9,7 @@
 #include <drm/drm_modes.h>
 
 #include "dp_parser.h"
+#include "disp/msm_disp_snapshot.h"
 
 /* interrupts */
 #define DP_INTR_HPD            BIT(0)
@@ -71,6 +72,9 @@ struct dp_catalog {
        u32 audio_data;
 };
 
+/* Debug module */
+void dp_catalog_snapshot(struct dp_catalog *dp_catalog, struct msm_disp_state *disp_state);
+
 /* AUX APIs */
 u32 dp_catalog_aux_read_data(struct dp_catalog *dp_catalog);
 int dp_catalog_aux_write_data(struct dp_catalog *dp_catalog);
index cdec0a3..13447f7 100644 (file)
@@ -1039,6 +1039,35 @@ int dp_display_get_test_bpp(struct msm_dp *dp)
                dp_display->link->test_video.test_bit_depth);
 }
 
+void msm_dp_snapshot(struct msm_dp *dp)
+{
+       struct dp_display_private *dp_display;
+       struct drm_device *drm;
+       struct msm_disp_state *disp_state;
+
+       dp_display = container_of(dp, struct dp_display_private, dp_display);
+       drm = dp->drm_dev;
+       disp_state = msm_disp_state_get(drm);
+
+       /*
+        * if we are reading registers we need the link clocks to be on
+        * however till DP cable is connected this will not happen as we
+        * do not know the resolution to power up with. Hence check the
+        * power_on status before dumping DP registers to avoid crash due
+        * to unclocked access
+        */
+       mutex_lock(&dp_display->event_mutex);
+
+       if (!dp->power_on) {
+               mutex_unlock(&dp_display->event_mutex);
+               return;
+       }
+
+       dp_catalog_snapshot(dp_display->catalog, disp_state);
+
+       mutex_unlock(&dp_display->event_mutex);
+}
+
 static void dp_display_config_hpd(struct dp_display_private *dp)
 {
 
index ac206c1..9c40bac 100644 (file)
@@ -367,6 +367,7 @@ void msm_dp_display_mode_set(struct msm_dp *dp, struct drm_encoder *encoder,
                                struct drm_display_mode *mode,
                                struct drm_display_mode *adjusted_mode);
 void msm_dp_irq_postinstall(struct msm_dp *dp_display);
+void msm_dp_snapshot(struct msm_dp *dp_display);
 
 void msm_dp_debugfs_init(struct msm_dp *dp_display, struct drm_minor *minor);