tusb1064: handlle cc1/cc2 direction

Added code to program TUSB1064 chip to handle CC1/CC2 cable insertions.

Change-Id: I19e15e88a75811b67ca69cfb27577bdf15bda9d6
Signed-off-by: Rajesh Bharathwaj <rajeshbharathwaj@codeaurora.org>
diff --git a/drivers/misc/tusb1064.c b/drivers/misc/tusb1064.c
index 234e21a..b9f40e9 100644
--- a/drivers/misc/tusb1064.c
+++ b/drivers/misc/tusb1064.c
@@ -23,6 +23,7 @@
 #include <linux/kernel.h>
 #include <linux/gpio.h>
 #include <linux/delay.h>
+#include "tusb1064.h"
 
 struct tusb1064 {
 	struct device *dev;
@@ -80,21 +81,23 @@
 	return 0;
 }
 
-void tusb1064_flip(bool flip)
+void tusb1064_usb_event(bool flip)
 {
 	if (pdata) {
 		if (flip) {
-			pr_debug("%s flipping the switch\n", __func__);
-			/*AUXn->SBU2, AUXp->SBU1*/
-			tusb1064_write(pdata->i2c_client, 0x13, 0x2F);
+			if (standalone_mode)
+				tusb1064_write(pdata->i2c_client, 0x0A, 0x05);
+			else
+				tusb1064_write(pdata->i2c_client, 0x0A, 0x06);
 		} else {
-			pr_debug("%s not flipping the switch\n", __func__);
-			/*AUXn->SBU2, AUXp->SBU1*/
-			tusb1064_write(pdata->i2c_client, 0x13, 0x1F);
+			if (standalone_mode)
+				tusb1064_write(pdata->i2c_client, 0x0A, 0x01);
+			else
+				tusb1064_write(pdata->i2c_client, 0x0A, 0x02);
 		}
 	}
 }
-EXPORT_SYMBOL(tusb1064_flip);
+EXPORT_SYMBOL(tusb1064_usb_event);
 
 static int tusb1064_probe(struct i2c_client *client,
 	const struct i2c_device_id *id)
@@ -140,19 +143,6 @@
 			goto fail;
 
 		pr_debug("%s setting SBU1 to AUXN, SBU2 to AUXP\n", __func__);
-		/*AUXn->SBU2, AUXp->SBU1 */
-		if (tusb1064_write(pdata->i2c_client, 0x13, 0x1F) < 0)
-			goto fail;
-		//tusb1064_write(pdata, 0x13, 0x01);//AUXn->SBU1, AUXp->SBU2
-
-		/*Enable 4-lane DP */
-		if (tusb1064_write(pdata->i2c_client, 0x10, 0x55) < 0)
-			goto fail;
-		/*Enable 4-lane DP */
-		if (tusb1064_write(pdata->i2c_client, 0x11, 0x55) < 0)
-			goto fail;
-		//pr_err("setting SBU1 to AUXp and SBU2 to AUXN\n");
-		//tusb1064_write(pdata, 0x13, 0x8F);//Enable 4-lane DP
 	}
 	tusb1064_read(pdata->i2c_client, 0x0A, buf, 2);
 	tusb1064_read(pdata->i2c_client, 0x13, buf, 2);
diff --git a/drivers/misc/tusb1064.h b/drivers/misc/tusb1064.h
new file mode 100644
index 0000000..effecdc
--- /dev/null
+++ b/drivers/misc/tusb1064.h
@@ -0,0 +1,18 @@
+/* Copyright (c) 2020 The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __TUSB1064_H_
+#define __TUSB1064_H_
+
+void tusb1064_usb_event(bool flip);
+
+#endif /* __TUSB1064_H_ */