Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/msm/dp: wait for hpd high before aux transaction

The source device should ensure the sink is ready before proceeding to
read the sink capability or perform any aux transactions. The sink
will indicate its readiness by asserting the HPD line. The controller
driver needs to wait for the hpd line to be asserted by the sink before
it performs any aux transactions.

The eDP sink is assumed to be always connected. It needs power from the
source and its HPD line will be asserted only after the panel is powered
on. The panel power will be enabled from the panel-edp driver and only
after that, the hpd line will be asserted.

Whereas for DP, the sink can be hotplugged and unplugged anytime. The hpd
line gets asserted to indicate the sink is connected and ready. Hence
there is no need to wait for the hpd line to be asserted for a DP sink.

Signed-off-by: Sankeerth Billakanti <quic_sbillaka@quicinc.com>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Patchwork: https://patchwork.freedesktop.org/patch/483312/
Link: https://lore.kernel.org/r/1650887072-16652-4-git-send-email-quic_sbillaka@quicinc.com
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

authored by

Sankeerth Billakanti and committed by
Dmitry Baryshkov
86d56a77 391c96ff

+37 -3
+20 -1
drivers/gpu/drm/msm/dp/dp_aux.c
··· 34 34 bool no_send_addr; 35 35 bool no_send_stop; 36 36 bool initted; 37 + bool is_edp; 37 38 u32 offset; 38 39 u32 segment; 39 40 ··· 338 337 goto exit; 339 338 } 340 339 340 + /* 341 + * For eDP it's important to give a reasonably long wait here for HPD 342 + * to be asserted. This is because the panel driver may have _just_ 343 + * turned on the panel and then tried to do an AUX transfer. The panel 344 + * driver has no way of knowing when the panel is ready, so it's up 345 + * to us to wait. For DP we never get into this situation so let's 346 + * avoid ever doing the extra long wait for DP. 347 + */ 348 + if (aux->is_edp) { 349 + ret = dp_catalog_aux_wait_for_hpd_connect_state(aux->catalog); 350 + if (ret) { 351 + DRM_DEBUG_DP("Panel not ready for aux transactions\n"); 352 + goto exit; 353 + } 354 + } 355 + 341 356 dp_aux_update_offset_and_segment(aux, msg); 342 357 dp_aux_transfer_helper(aux, msg, true); 343 358 ··· 508 491 drm_dp_aux_unregister(dp_aux); 509 492 } 510 493 511 - struct drm_dp_aux *dp_aux_get(struct device *dev, struct dp_catalog *catalog) 494 + struct drm_dp_aux *dp_aux_get(struct device *dev, struct dp_catalog *catalog, 495 + bool is_edp) 512 496 { 513 497 struct dp_aux_private *aux; 514 498 ··· 524 506 525 507 init_completion(&aux->comp); 526 508 aux->cmd_busy = false; 509 + aux->is_edp = is_edp; 527 510 mutex_init(&aux->mutex); 528 511 529 512 aux->dev = dev;
+2 -1
drivers/gpu/drm/msm/dp/dp_aux.h
··· 16 16 void dp_aux_deinit(struct drm_dp_aux *dp_aux); 17 17 void dp_aux_reconfig(struct drm_dp_aux *dp_aux); 18 18 19 - struct drm_dp_aux *dp_aux_get(struct device *dev, struct dp_catalog *catalog); 19 + struct drm_dp_aux *dp_aux_get(struct device *dev, struct dp_catalog *catalog, 20 + bool is_edp); 20 21 void dp_aux_put(struct drm_dp_aux *aux); 21 22 22 23 #endif /*__DP_AUX_H_*/
+13
drivers/gpu/drm/msm/dp/dp_catalog.c
··· 245 245 phy_calibrate(phy); 246 246 } 247 247 248 + int dp_catalog_aux_wait_for_hpd_connect_state(struct dp_catalog *dp_catalog) 249 + { 250 + u32 state; 251 + struct dp_catalog_private *catalog = container_of(dp_catalog, 252 + struct dp_catalog_private, dp_catalog); 253 + 254 + /* poll for hpd connected status every 2ms and timeout after 500ms */ 255 + return readl_poll_timeout(catalog->io->dp_controller.aux.base + 256 + REG_DP_DP_HPD_INT_STATUS, 257 + state, state & DP_DP_HPD_STATE_STATUS_CONNECTED, 258 + 2000, 500000); 259 + } 260 + 248 261 static void dump_regs(void __iomem *base, int len) 249 262 { 250 263 int i;
+1
drivers/gpu/drm/msm/dp/dp_catalog.h
··· 85 85 void dp_catalog_aux_reset(struct dp_catalog *dp_catalog); 86 86 void dp_catalog_aux_enable(struct dp_catalog *dp_catalog, bool enable); 87 87 void dp_catalog_aux_update_cfg(struct dp_catalog *dp_catalog); 88 + int dp_catalog_aux_wait_for_hpd_connect_state(struct dp_catalog *dp_catalog); 88 89 u32 dp_catalog_aux_get_irq(struct dp_catalog *dp_catalog); 89 90 90 91 /* DP Controller APIs */
+1 -1
drivers/gpu/drm/msm/dp/dp_display.c
··· 783 783 goto error; 784 784 } 785 785 786 - dp->aux = dp_aux_get(dev, dp->catalog); 786 + dp->aux = dp_aux_get(dev, dp->catalog, dp->dp_display.is_edp); 787 787 if (IS_ERR(dp->aux)) { 788 788 rc = PTR_ERR(dp->aux); 789 789 DRM_ERROR("failed to initialize aux, rc = %d\n", rc);