Browse Source

touch: pt: Touch_offload using Glink

Enabled Glink interface for Parade Touch Sensor.

Change-Id: Ie5a63797eec8ed329484d751fbb843f5876a4229
Signed-off-by: Srikanth Katteboina <[email protected]>
Srikanth Katteboina 1 year ago
parent
commit
a405414d95
1 changed files with 57 additions and 3 deletions
  1. 57 3
      pt/pt_core.c

+ 57 - 3
pt/pt_core.c

@@ -31,6 +31,8 @@
 #include <linux/gpio.h>
 #include <linux/kthread.h>
 #include <linux/suspend.h>
+#include <glink_interface.h>
+#include <linux/remoteproc/qcom_rproc.h>
 #include "pt_regs.h"
 #if defined(CONFIG_PANEL_NOTIFIER)
 #include <linux/soc/qcom/panel_event_notifier.h>
@@ -74,16 +76,20 @@ enum core_states {
 static int pt_enable_i2c_regulator(struct pt_core_data *cd, bool en);
 #endif
 
+#define PT_AMBIENT_MODE
+
+#ifdef PT_AMBIENT_MODE
 static int pt_device_exit(struct i2c_client *client);
 int pt_device_entry(struct device *dev,
 		u16 irq, size_t xfer_buf_size);
+#endif
 
 static const char *pt_driver_core_name = PT_CORE_NAME;
 static const char *pt_driver_core_version = PT_DRIVER_VERSION;
 static const char *pt_driver_core_date = PT_DRIVER_DATE;
 enum core_states pt_core_state = STATE_NONE;
 
-
+uint32_t pt_slate_resp_ack;
 struct pt_hid_field {
 	int report_count;
 	int report_size;
@@ -10816,6 +10822,7 @@ static int pt_core_suspend(struct device *dev)
 				"%s: Error on disabling i2c regulator\n", __func__);
 	}
 	pt_debug(cd->dev, DL_INFO, "%s Suspend exit - rc = %d\n", __func__, rc);
+
 	return rc;
 }
 
@@ -15053,14 +15060,22 @@ static ssize_t pt_pip2_gpio_read_show(struct device *dev,
  * PARAMETERS:
  *      *client - pointer to i2c client structure
  ******************************************************************************/
+#ifdef PT_AMBIENT_MODE
 static int pt_device_exit(struct i2c_client *client)
 {
 
 		struct pt_core_data *cd = i2c_get_clientdata(client);
 		struct device *dev = cd->dev;
 
+		void *glink_pt_send_msg;
+		int glink_touch_enter = TOUCH_ENTER;
+
 		pt_debug(dev, DL_INFO,"%s: Start pt_device_exit\n", __func__);
 
+		glink_pt_send_msg = &glink_touch_enter;
+		pt_debug(dev, DL_INFO, "[touch]glink_pt_send_msg = %0x\n", glink_pt_send_msg);
+		glink_touch_tx_msg(glink_pt_send_msg, TOUCH_MSG_SIZE);
+
 		if (active_panel)
 			panel_event_notifier_unregister(cd->entry);
 		pt_core_state = STATE_SUSPEND;
@@ -15078,10 +15093,9 @@ static int pt_device_exit(struct i2c_client *client)
 		cancel_work_sync(&cd->suspend_work);
 
 		pt_stop_wd_timer(cd);
-
 		device_init_wakeup(dev, 0);
-
 		disable_irq_nosync(cd->irq);
+
 		if (cd->cpdata->setup_irq)
 			cd->cpdata->setup_irq(cd->cpdata, PT_MT_IRQ_FREE, dev);
 
@@ -15094,6 +15108,7 @@ static int pt_device_exit(struct i2c_client *client)
 		pt_debug(dev, DL_INFO,"%s: End pt_device_exit \n", __func__);
 		return 0;
 }
+#endif
 
 /*******************************************************************************
  * FUNCTION: pt_touch_offload_store
@@ -17713,6 +17728,32 @@ err_pinctrl_get:
 	return retval;
 }
 
+void touch_notify_glink_pt_channel_state(bool state)
+{
+	pr_info("%s:[touch] touch_notify_glink\n", __func__);
+}
+
+void glink_touch_pt_rx_msg(void *data, int len)
+{
+	int rc = 0;
+	pr_info("%s: TOUCH_RX_MSG Start:\n", __func__);
+
+	if (len > TOUCH_GLINK_INTENT_SIZE) {
+		pr_err("Invalid TOUCH glink intent size\n");
+		return;
+	}
+	/* check SLATE response */
+	pt_slate_resp_ack = *(uint32_t *)&data[8];
+	if (pt_slate_resp_ack == 0x01) {
+			pr_err("Bad SLATE response\n");
+			rc = -EINVAL;
+			goto err_ret;
+	}
+	pr_info("%s: TOUCH_RX_MSG End:\n", __func__);
+err_ret:
+return;
+}
+
 /*******************************************************************************
  *******************************************************************************
  * FUNCTION: pt_probe
@@ -17937,6 +17978,8 @@ int pt_probe(const struct pt_bus_ops *ops, struct device *dev,
 	 */
 	cd->bus_ops = ops;
 
+	glink_touch_channel_init(&touch_notify_glink_pt_channel_state, &glink_touch_pt_rx_msg);
+
 	/*
 	 * When the IRQ GPIO is not direclty accessible and no function is
 	 * defined to get the IRQ status, the IRQ passed in must be assigned
@@ -18234,6 +18277,7 @@ error_no_pdata:
  * PARAMETERS:
  *      *dev  - pointer to core device
  ******************************************************************************/
+#ifdef PT_AMBIENT_MODE
 int pt_device_entry(struct device *dev,
 				u16 irq, size_t xfer_buf_size)
 {
@@ -18241,6 +18285,8 @@ int pt_device_entry(struct device *dev,
 		struct pt_platform_data *pdata = dev_get_platdata(dev);
 		struct i2c_client *client = to_i2c_client(dev);
 		int rc = 0;
+		void *glink_pt_send_msg;
+		int glink_touch_exit = TOUCH_EXIT;
 
 		pt_debug(dev, DL_INFO, "%s: Start pt_device_entry\n", __func__);
 
@@ -18248,6 +18294,12 @@ int pt_device_entry(struct device *dev,
 		cd->pdata   = pdata;
 		cd->cpdata  = pdata->core_pdata;
 
+		glink_pt_send_msg = &glink_touch_exit;
+		pt_debug(dev, DL_INFO, "[touch]glink_pt_send_msg = %d\n", glink_pt_send_msg);
+		glink_touch_tx_msg(glink_pt_send_msg, TOUCH_MSG_SIZE);
+
+		msleep(150);
+
 		if (!rc && cd->ts_pinctrl) {
 				/*
 				 * Pinctrl handle is optional. If pinctrl handle is found
@@ -18376,6 +18428,8 @@ pt_error_detect:
 			cd->cpdata->setup_power(cd->cpdata, PT_MT_POWER_OFF, dev);
 		return rc;
 }
+#endif
+
 EXPORT_SYMBOL_GPL(pt_probe);
 
 /*******************************************************************************