From 0a9bb868d07d9d78e4b92d2794a003d8a8e35dbb Mon Sep 17 00:00:00 2001 From: Soutrik Mukhopadhyay Date: Mon, 22 May 2023 14:46:28 +0530 Subject: [PATCH] disp: msm: dp: Parse device tree to find specific aux switch Changes to select particular dp_aux_switch based on board requirements. Currently provision to support both fsa4480 and wcd939x as aux switches are provided. Change-Id: Iafbee4d91d14aafb1e7a37ddfa2b1ea0d0e5e784 Signed-off-by: Soutrik Mukhopadhyay --- msm/dp/dp_aux.c | 27 ++++++++++++++++++--------- msm/dp/dp_aux.h | 8 +++++++- msm/dp/dp_display.c | 10 +++++++++- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/msm/dp/dp_aux.c b/msm/dp/dp_aux.c index a0c2e288..efb1ccc4 100644 --- a/msm/dp/dp_aux.c +++ b/msm/dp/dp_aux.c @@ -8,7 +8,8 @@ #if IS_ENABLED(CONFIG_QCOM_FSA4480_I2C) #include -#elif IS_ENABLED(CONFIG_QCOM_WCD939X_I2C) +#endif +#if IS_ENABLED(CONFIG_QCOM_WCD939X_I2C) #include #endif @@ -863,7 +864,7 @@ end: struct dp_aux *dp_aux_get(struct device *dev, struct dp_catalog_aux *catalog, struct dp_parser *parser, struct device_node *aux_switch, - struct dp_aux_bridge *aux_bridge) + struct dp_aux_bridge *aux_bridge, enum dp_aux_switch_type switch_type) { int rc = 0; struct dp_aux_private *aux; @@ -902,15 +903,23 @@ struct dp_aux *dp_aux_get(struct device *dev, struct dp_catalog_aux *catalog, dp_aux->abort = dp_aux_abort_transaction; dp_aux->set_sim_mode = dp_aux_set_sim_mode; + /*Condition to avoid allocating function pointers for aux bypass mode*/ + if (switch_type != DP_AUX_SWITCH_BYPASS) { #if IS_ENABLED(CONFIG_QCOM_FSA4480_I2C) - dp_aux->switch_configure = dp_aux_configure_fsa_switch; - dp_aux->switch_register_notifier = fsa4480_reg_notifier; - dp_aux->switch_unregister_notifier = fsa4480_unreg_notifier; -#elif IS_ENABLED(CONFIG_QCOM_WCD939X_I2C) - dp_aux->switch_configure = dp_aux_configure_wcd_switch; - dp_aux->switch_register_notifier = wcd_usbss_reg_notifier; - dp_aux->switch_unregister_notifier = wcd_usbss_unreg_notifier; + if (switch_type == DP_AUX_SWITCH_FSA4480) { + dp_aux->switch_configure = dp_aux_configure_fsa_switch; + dp_aux->switch_register_notifier = fsa4480_reg_notifier; + dp_aux->switch_unregister_notifier = fsa4480_unreg_notifier; + } #endif +#if IS_ENABLED(CONFIG_QCOM_WCD939X_I2C) + if (switch_type == DP_AUX_SWITCH_WCD939x) { + dp_aux->switch_configure = dp_aux_configure_wcd_switch; + dp_aux->switch_register_notifier = wcd_usbss_reg_notifier; + dp_aux->switch_unregister_notifier = wcd_usbss_unreg_notifier; + } +#endif + } return dp_aux; error: diff --git a/msm/dp/dp_aux.h b/msm/dp/dp_aux.h index a9c431e5..d3778b11 100644 --- a/msm/dp/dp_aux.h +++ b/msm/dp/dp_aux.h @@ -26,6 +26,12 @@ #define DP_STATE_AUX_TIMEOUT BIT(12) #define DP_STATE_PLL_LOCKED BIT(13) +enum dp_aux_switch_type { + DP_AUX_SWITCH_BYPASS, + DP_AUX_SWITCH_FSA4480, + DP_AUX_SWITCH_WCD939x, +}; + enum dp_aux_error { DP_AUX_ERR_NONE = 0, DP_AUX_ERR_ADDR = -1, @@ -60,7 +66,7 @@ struct dp_aux { struct dp_aux *dp_aux_get(struct device *dev, struct dp_catalog_aux *catalog, struct dp_parser *parser, struct device_node *aux_switch, - struct dp_aux_bridge *aux_bridge); + struct dp_aux_bridge *aux_bridge, enum dp_aux_switch_type switch_type); void dp_aux_put(struct dp_aux *aux); #endif /*__DP_AUX_H_*/ diff --git a/msm/dp/dp_display.c b/msm/dp/dp_display.c index 1e19fb09..f2e45c3c 100644 --- a/msm/dp/dp_display.c +++ b/msm/dp/dp_display.c @@ -168,6 +168,7 @@ struct dp_display_private { enum drm_connector_status cached_connector_status; enum dp_display_states state; + enum dp_aux_switch_type switch_type; struct platform_device *pdev; struct device_node *aux_switch_node; @@ -2161,8 +2162,15 @@ static int dp_init_sub_modules(struct dp_display_private *dp) dp->no_aux_switch = true; } + if (!strcmp(dp->aux_switch_node->name, "fsa4480")) + dp->switch_type = DP_AUX_SWITCH_FSA4480; + else if (!strcmp(dp->aux_switch_node->name, "wcd939x_i2c")) + dp->switch_type = DP_AUX_SWITCH_WCD939x; + else + dp->switch_type = DP_AUX_SWITCH_BYPASS; + dp->aux = dp_aux_get(dev, &dp->catalog->aux, dp->parser, - dp->aux_switch_node, dp->aux_bridge); + dp->aux_switch_node, dp->aux_bridge, dp->switch_type); if (IS_ERR(dp->aux)) { rc = PTR_ERR(dp->aux); DP_ERR("failed to initialize aux, rc = %d\n", rc);