max77759_charger: disable DC when rtx enabled

When rtx enabled, disable DC and switch to MW charging.

Bug: 194864623
Signed-off-by: Wasb Liu <wasbliu@google.com>
Change-Id: I119772e4bdd98cf87ed08e84c0e7d9fa971748e4
(cherry picked from commit 8d4b70853ee9455fe0f6e5fbc7882bd585846236)
diff --git a/max77759.h b/max77759.h
index 35d02ba..ea7b8ed 100644
--- a/max77759.h
+++ b/max77759.h
@@ -128,6 +128,8 @@
 	bool pogo_vout;	/* pogo 5v vout */
 
 	u8 reg;
+
+	struct gvotable_election *dc_avail_votable;	/* DC_AVAIL */
 };
 
 /* internal system values */
diff --git a/max77759_charger.c b/max77759_charger.c
index 8eac855..7ce20c6 100644
--- a/max77759_charger.c
+++ b/max77759_charger.c
@@ -711,12 +711,6 @@
 			return -EINVAL;
 		}
 
-		if (dc_on) {
-			pr_warn("%s: no wlc_tx with dc_on for now\n", __func__);
-			/* TODO: GSU_MODE_USB_DC_WLC_TX */
-			wlc_tx = 0;
-		}
-
 		if (uc_data->ext_otg_only && cb_data->otg_on) {
 			pr_warn("%s: no wlc_tx with otg_on for now\n", __func__);
 			wlc_tx = 0;
@@ -766,14 +760,10 @@
 		dc_on = false;
 	} else if (wlc_tx) {
 
+		/* Disable DC when Rtx is on will handle by dc_avail_votable */
 		if (!buck_on) {
 			mode = MAX77759_CHGR_MODE_ALL_OFF;
 			usecase = GSU_MODE_WLC_TX;
-		} else if (dc_on) {
-			/* TODO: turn off DC and run off MW */
-			pr_err("WLC_TX+DC is not supported yet\n");
-			mode = MAX77759_CHGR_MODE_ALL_OFF;
-			usecase = GSU_MODE_USB_DC;
 		} else if (chgr_on) {
 			mode = MAX77759_CHGR_MODE_CHGR_BUCK_ON;
 			usecase = GSU_MODE_USB_CHG_WLC_TX;
@@ -831,6 +821,12 @@
 
 	}
 
+	if (!cb_data->dc_avail_votable)
+		cb_data->dc_avail_votable = gvotable_election_get_handle(VOTABLE_DC_CHG_AVAIL);
+	if (cb_data->dc_avail_votable)
+		gvotable_cast_int_vote(cb_data->dc_avail_votable,
+				       "WLC_TX", wlc_tx? 0 : 1, wlc_tx);
+
 	/* reg might be ignored later */
 	cb_data->reg = _chg_cnfg_00_cp_en_set(cb_data->reg, dc_on);
 	cb_data->reg = _chg_cnfg_00_mode_set(cb_data->reg, mode);