Эх сурвалжийг харах

disp: msm: dp: Parse device tree for 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 <[email protected]>
Soutrik Mukhopadhyay 2 жил өмнө
parent
commit
5073940a9a
3 өөрчлөгдсөн 37 нэмэгдсэн , 11 устгасан
  1. 19 9
      msm/dp/dp_aux.c
  2. 8 1
      msm/dp/dp_aux.h
  3. 10 1
      msm/dp/dp_display.c

+ 19 - 9
msm/dp/dp_aux.c

@@ -8,7 +8,8 @@
 
 #if IS_ENABLED(CONFIG_QCOM_FSA4480_I2C)
 #include <linux/soc/qcom/fsa4480-i2c.h>
-#elif IS_ENABLED(CONFIG_QCOM_WCD939X_I2C)
+#endif
+#if IS_ENABLED(CONFIG_QCOM_WCD939X_I2C)
 #include <linux/soc/qcom/wcd939x-i2c.h>
 #endif
 
@@ -877,7 +878,8 @@ 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, void *ipc_log_context)
+		struct dp_aux_bridge *aux_bridge, void *ipc_log_context,
+		enum dp_aux_switch_type switch_type)
 {
 	int rc = 0;
 	struct dp_aux_private *aux;
@@ -918,15 +920,23 @@ struct dp_aux *dp_aux_get(struct device *dev, struct dp_catalog_aux *catalog,
 	dp_aux->set_sim_mode = dp_aux_set_sim_mode;
 	dp_aux->ipc_log_context = ipc_log_context;
 
+	/*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:

+ 8 - 1
msm/dp/dp_aux.h

@@ -30,6 +30,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,
@@ -64,7 +70,8 @@ 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, void *ipc_log_context);
+		struct dp_aux_bridge *aux_bridge, void *ipc_log_context,
+		enum dp_aux_switch_type switch_type);
 void dp_aux_put(struct dp_aux *aux);
 
 #endif /*__DP_AUX_H_*/

+ 10 - 1
msm/dp/dp_display.c

@@ -170,6 +170,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;
@@ -2119,8 +2120,16 @@ 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, g_dp_display->dp_aux_ipc_log);
+			dp->aux_switch_node, dp->aux_bridge, g_dp_display->dp_aux_ipc_log,
+			dp->switch_type);
 	if (IS_ERR(dp->aux)) {
 		rc = PTR_ERR(dp->aux);
 		DP_ERR("failed to initialize aux, rc = %d\n", rc);