summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSurya Teja Kudiri <quic_skudiri@quicinc.com>2022-09-15 13:11:19 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2022-11-17 09:44:41 -0800
commitd159c64f47f46f03482894c11ac33a82233f70ce (patch)
tree34e8a93d5a9a7a8fdb2a0a2837d0ab25f7b2ca48
parentdceb5b3d372b8cfd2605aaa0bc09ee23eb52ba8f (diff)
downloadtouch-d159c64f47f46f03482894c11ac33a82233f70ce.tar.gz
touch: paradetech touch driver upgrade
Upgrading parade tech touch driver code from kernel 5.4 to kernel 5.15. Change-Id: I0052e905813f0dc2c3a374b10cd6bcb243502673 Signed-off-by: Surya Teja Kudiri <quic_skudiri@quicinc.com>
-rw-r--r--pt/pt_core.c20
-rw-r--r--pt/pt_core.h230
-rw-r--r--pt/pt_device_access.c27
-rw-r--r--pt/pt_devtree.c2
-rw-r--r--pt/pt_platform.c2
-rw-r--r--pt/pt_platform.h69
-rw-r--r--pt/pt_regs.h9
7 files changed, 332 insertions, 27 deletions
diff --git a/pt/pt_core.c b/pt/pt_core.c
index 02610bf..dfbee33 100644
--- a/pt/pt_core.c
+++ b/pt/pt_core.c
@@ -32,6 +32,7 @@
#include <linux/kthread.h>
#include <linux/suspend.h>
#include "pt_regs.h"
+#include <linux/soc/qcom/panel_event_notifier.h>
#define PINCTRL_STATE_ACTIVE "pmx_ts_active"
#define PINCTRL_STATE_SUSPEND "pmx_ts_suspend"
@@ -3786,7 +3787,7 @@ static int pt_pip1_read_data_block_(struct pt_core_data *cd,
return 0;
if (read_buf_size >= *actual_read_len &&
- *actual_read_len < PT_MAX_PIP2_MSG_SIZE)
+ *actual_read_len < PT_MAX_PIP2_MSG_SIZE)
memcpy(read_buf, &cd->response_buf[10], *actual_read_len);
else
return -EPROTO;
@@ -10782,7 +10783,7 @@ static int pt_core_suspend(struct device *dev)
cd->wait_until_wake = 0;
mutex_unlock(&cd->system_lock);
- if (mem_sleep_current == PM_SUSPEND_MEM) {
+ if (pm_suspend_via_firmware()) {
rc = pt_core_suspend_(cd->dev);
cd->quick_boot = true;
} else {
@@ -10978,7 +10979,7 @@ static int pt_core_resume(struct device *dev)
return 0;
- if (mem_sleep_current == PM_SUSPEND_MEM) {
+ if (pm_suspend_via_firmware()) {
rc = pt_core_restore(cd->dev);
} else {
pt_debug(cd->dev, DL_INFO, "%s start\n", __func__);
@@ -11550,9 +11551,9 @@ int _pt_read_us_file(struct device *dev, u8 *file_path, u8 *buf, int *size)
}
pt_debug(dev, DL_WARN, "%s: path = %s\n", __func__, file_path);
- oldfs = get_fs();
- set_fs(KERNEL_DS);
- filp = filp_open(file_path, O_RDONLY, 0400);
+ oldfs = force_uaccess_begin();
+ filp = filp_open_block(file_path, O_RDONLY, 0400);
+
if (IS_ERR(filp)) {
pt_debug(dev, DL_ERROR, "%s: Failed to open %s\n", __func__,
file_path);
@@ -11593,7 +11594,11 @@ int _pt_read_us_file(struct device *dev, u8 *file_path, u8 *buf, int *size)
goto exit;
}
filp->private_data = inode->i_private;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0))
+ if (filp->f_op->read(filp, buf, read_len, &(filp->f_pos)) != read_len) {
+#else
if (vfs_read(filp, buf, read_len, &(filp->f_pos)) != read_len) {
+#endif
pt_debug(dev, DL_ERROR, "%s: file read error.\n", __func__);
rc = -EINVAL;
goto exit;
@@ -11604,8 +11609,9 @@ exit:
if (filp_close(filp, NULL) != 0)
pt_debug(dev, DL_ERROR, "%s: file close error.\n", __func__);
err:
- set_fs(oldfs);
+ force_uaccess_end(oldfs);
return rc;
+
}
/*******************************************************************************
diff --git a/pt/pt_core.h b/pt/pt_core.h
new file mode 100644
index 0000000..7924277
--- /dev/null
+++ b/pt/pt_core.h
@@ -0,0 +1,230 @@
+/*
+ * pt_core.h
+ * Parade TrueTouch(TM) Standard Product Core Module.
+ * For use with Parade touchscreen controllers.
+ * Supported parts include:
+ * TMA5XX
+ * TMA448
+ * TMA445A
+ * TT21XXX
+ * TT31XXX
+ * TT4XXXX
+ * TT7XXX
+ * TC3XXX
+ *
+ * Copyright (C) 2015-2020 Parade Technologies
+ *
+ * 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.
+ *
+ * Contact Parade Technologies at www.parade.com <ttdrivers@paradetech.com>
+ */
+
+#ifndef _LINUX_PT_CORE_H
+#define _LINUX_PT_CORE_H
+
+#include <linux/stringify.h>
+#include <drm/drm_panel.h>
+
+#define PT_I2C_NAME "pt_i2c_adapter"
+#define PT_SPI_NAME "pt_spi_adapter"
+
+#define PT_CORE_NAME "pt_core"
+#define PT_MT_NAME "pt_mt"
+#define PT_BTN_NAME "pt_btn"
+#define PT_PROXIMITY_NAME "pt_proximity"
+
+#define PT_DRIVER_NAME TTDL
+#define PT_DRIVER_MAJOR 04
+#define PT_DRIVER_MINOR 11
+
+#define PT_DRIVER_REVCTRL 977092
+
+#define PT_DRIVER_VERSION \
+__stringify(PT_DRIVER_NAME) \
+"." __stringify(PT_DRIVER_MAJOR) \
+"." __stringify(PT_DRIVER_MINOR) \
+"." __stringify(PT_DRIVER_REVCTRL)
+
+#define PT_DRIVER_DATE "20201210"
+
+/* abs settings */
+#define PT_IGNORE_VALUE -1
+
+enum pt_core_platform_flags {
+ PT_CORE_FLAG_NONE,
+ PT_CORE_FLAG_POWEROFF_ON_SLEEP = 0x02,
+ PT_CORE_FLAG_RESTORE_PARAMETERS = 0x04,
+ PT_CORE_FLAG_DEEP_STANDBY = 0x08,
+ PT_CORE_FLAG_SKIP_SYS_SLEEP = 0x10,
+ PT_CORE_FLAG_SKIP_RUNTIME = 0x20,
+ PT_CORE_FLAG_SKIP_RESUME = 0x40,
+};
+
+enum pt_core_platform_easy_wakeup_gesture {
+ PT_CORE_EWG_NONE,
+ PT_CORE_EWG_TAP_TAP,
+ PT_CORE_EWG_TWO_FINGER_SLIDE,
+ PT_CORE_EWG_RESERVED,
+ PT_CORE_EWG_WAKE_ON_INT_FROM_HOST = 0xFF,
+};
+
+enum pt_loader_platform_flags {
+ PT_LOADER_FLAG_NONE,
+ PT_LOADER_FLAG_CALIBRATE_AFTER_FW_UPGRADE,
+ /* Use CONFIG_VER field in TT_CFG to decide TT_CFG update */
+ PT_LOADER_FLAG_CHECK_TTCONFIG_VERSION,
+ PT_LOADER_FLAG_CALIBRATE_AFTER_TTCONFIG_UPGRADE,
+};
+
+enum CONFIG_DUT_GENERATION {
+ CONFIG_DUT_AUTO_DETECT = 0x00,
+ CONFIG_DUT_PIP1_ONLY = 0x01,
+ CONFIG_DUT_PIP2_CAPABLE = 0x02,
+};
+
+enum pt_core_platform_panel_id_flags {
+ PT_PANEL_ID_DISABLE = 0x00,
+ PT_PANEL_ID_BY_BL = 0x01,
+ PT_PANEL_ID_BY_SYS_INFO = 0x02,
+ PT_PANEL_ID_BY_MFG_DATA = 0x04,
+};
+
+struct touch_settings {
+ const uint8_t *data;
+ uint32_t size;
+ uint8_t tag;
+};
+
+struct pt_touch_firmware {
+ const uint8_t *img;
+ uint32_t size;
+ const uint8_t *ver;
+ uint8_t vsize;
+ uint8_t panel_id;
+};
+
+struct pt_touch_config {
+ struct touch_settings *param_regs;
+ struct touch_settings *param_size;
+ const uint8_t *fw_ver;
+ uint8_t fw_vsize;
+ uint8_t panel_id;
+};
+
+struct pt_loader_platform_data {
+ struct pt_touch_firmware *fw;
+ struct pt_touch_config *ttconfig;
+ struct pt_touch_firmware **fws;
+ struct pt_touch_config **ttconfigs;
+ u32 flags;
+};
+
+typedef int (*pt_platform_read) (struct device *dev, void *buf, int size);
+
+#define PT_TOUCH_SETTINGS_MAX 32
+
+struct pt_core_platform_data {
+ int irq_gpio;
+ u32 irq_gpio_flags;
+ int rst_gpio;
+ u32 rst_gpio_flags;
+ int ddi_rst_gpio;
+ int vddi_gpio;
+ int vcc_gpio;
+ int avdd_gpio;
+ int avee_gpio;
+ int level_irq_udelay;
+ u16 hid_desc_register;
+ u16 vendor_id;
+ u16 product_id;
+
+ int (*xres)(struct pt_core_platform_data *pdata,
+ struct device *dev);
+ int (*init)(struct pt_core_platform_data *pdata,
+ int on, struct device *dev);
+ int (*power)(struct pt_core_platform_data *pdata,
+ int on, struct device *dev, atomic_t *ignore_irq);
+ int (*detect)(struct pt_core_platform_data *pdata,
+ struct device *dev, pt_platform_read read);
+ int (*irq_stat)(struct pt_core_platform_data *pdata,
+ struct device *dev);
+ int (*setup_power)(struct pt_core_platform_data *pdata,
+ int on, struct device *dev);
+ int (*setup_irq)(struct pt_core_platform_data *pdata,
+ int on, struct device *dev);
+ struct touch_settings *sett[PT_TOUCH_SETTINGS_MAX];
+ u32 flags;
+ u8 easy_wakeup_gesture;
+ u8 config_dut_generation;
+ u8 watchdog_force_stop;
+ u8 panel_id_support;
+
+ struct device_node *node;
+ struct pinctrl *pinctrl;
+ struct pinctrl_state *pins_active;
+ struct pinctrl_state *pins_suspend;
+ struct pinctrl_state *pins_release;
+
+ struct drm_panel *active_panel;
+};
+
+struct touch_framework {
+ const int16_t *abs;
+ uint8_t size;
+ uint8_t enable_vkeys;
+} __packed;
+
+enum pt_mt_platform_power_state {
+ PT_MT_POWER_OFF = 0x00,
+ PT_MT_POWER_ON = 0x01
+};
+
+enum pt_mt_platform_irq_state {
+ PT_MT_IRQ_FREE = 0x00,
+ PT_MT_IRQ_REG = 0x01
+};
+
+enum pt_mt_platform_flags {
+ PT_MT_FLAG_NONE,
+ PT_MT_FLAG_HOVER = 0x04,
+ PT_MT_FLAG_FLIP = 0x08,
+ PT_MT_FLAG_INV_X = 0x10,
+ PT_MT_FLAG_INV_Y = 0x20,
+ PT_MT_FLAG_VKEYS = 0x40,
+ PT_MT_FLAG_NO_TOUCH_ON_LO = 0x80,
+};
+
+struct pt_mt_platform_data {
+ struct touch_framework *frmwrk;
+ unsigned short flags;
+ char const *inp_dev_name;
+ int vkeys_x;
+ int vkeys_y;
+};
+
+struct pt_btn_platform_data {
+ char const *inp_dev_name;
+};
+
+struct pt_proximity_platform_data {
+ struct touch_framework *frmwrk;
+ char const *inp_dev_name;
+};
+
+struct pt_platform_data {
+ struct pt_core_platform_data *core_pdata;
+ struct pt_mt_platform_data *mt_pdata;
+ struct pt_btn_platform_data *btn_pdata;
+ struct pt_proximity_platform_data *prox_pdata;
+ struct pt_loader_platform_data *loader_pdata;
+};
+
+#endif /* _LINUX_PT_CORE_H */
diff --git a/pt/pt_device_access.c b/pt/pt_device_access.c
index 8cb9152..611483a 100644
--- a/pt/pt_device_access.c
+++ b/pt/pt_device_access.c
@@ -2028,10 +2028,10 @@ static int save_header(char *out_buf, int index, struct result *result)
char time_buf[100] = {0};
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0))
- struct timespec ts;
+ struct timespec64 ts;
- getnstimeofday(&ts);
- rtc_time_to_tm(ts.tv_sec, &tm);
+ ktime_get_real_ts64(&ts);
+ rtc_time64_to_tm(ts.tv_sec, &tm);
#else
struct timex txc;
@@ -2117,7 +2117,6 @@ int save_engineering_data(struct device *dev, char *out_buf, int index,
tx_num = cmcp_info->tx_num;
rx_num = cmcp_info->rx_num;
btn_num = cmcp_info->btn_num;
-
fw_revision_control = dad->si->ttdata.revctrl;
fw_config_ver = dad->si->ttdata.fw_ver_conf;
/*calculate silicon id*/
@@ -2246,11 +2245,11 @@ int save_engineering_data(struct device *dev, char *out_buf, int index,
index = prepare_print_data(
out_buf,
&tmp, index, 1);
- for (j = 1; j < tx_num; j++)
- index = prepare_print_data(
- out_buf,
- &cmcp_info->cm_sensor_column_delta[(j-1)*rx_num+i],
- index, 1);
+ for (j = 1; j < tx_num; j++)
+ index = prepare_print_data(
+ out_buf,
+ &cmcp_info->cm_sensor_column_delta[(j-1)*rx_num+i],
+ index, 1);
index = prepare_print_string(
out_buf,
"\n", index);
@@ -2284,11 +2283,11 @@ int save_engineering_data(struct device *dev, char *out_buf, int index,
index = prepare_print_data(
out_buf, &i,
index, 1);
- for (j = 0; j < tx_num; j++)
- index = prepare_print_data(
- out_buf,
- &cmcp_info->cm_sensor_row_delta[j*rx_num+i-1],
- index, 1);
+ for (j = 0; j < tx_num; j++)
+ index = prepare_print_data(
+ out_buf,
+ &cmcp_info->cm_sensor_row_delta[j*rx_num+i-1],
+ index, 1);
index = prepare_print_string(
out_buf,
"\n", index);
diff --git a/pt/pt_devtree.c b/pt/pt_devtree.c
index aa54f65..5482c1d 100644
--- a/pt/pt_devtree.c
+++ b/pt/pt_devtree.c
@@ -31,7 +31,7 @@
#include <linux/err.h>
#include <linux/of_device.h>
#include <linux/slab.h>
-#include <linux/pt_platform.h>
+#include "pt_platform.h"
#include "pt_regs.h"
#define MAX_NAME_LENGTH 64
diff --git a/pt/pt_platform.c b/pt/pt_platform.c
index 35734fa..b91fc3f 100644
--- a/pt/pt_platform.c
+++ b/pt/pt_platform.c
@@ -28,7 +28,7 @@
*/
#include "pt_regs.h"
-#include <linux/pt_platform.h>
+#include "pt_platform.h"
#ifdef CONFIG_TOUCHSCREEN_PARADE_PLATFORM_FW_UPGRADE
/* FW for Panel ID = 0x00 */
diff --git a/pt/pt_platform.h b/pt/pt_platform.h
new file mode 100644
index 0000000..17b490f
--- /dev/null
+++ b/pt/pt_platform.h
@@ -0,0 +1,69 @@
+/*
+ * pt_platform.h
+ * Parade TrueTouch(TM) Standard Product Platform Module.
+ * For use with Parade touchscreen controllers.
+ * Supported parts include:
+ * TMA5XX
+ * TMA448
+ * TMA445A
+ * TT21XXX
+ * TT31XXX
+ * TT4XXXX
+ * TT7XXX
+ * TC3XXX
+ *
+ * Copyright (C) 2015-2020 Parade Technologies
+ *
+ * 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.
+ *
+ * Contact Parade Technologies at www.parade.com <ttdrivers@paradetech.com>
+ */
+
+#ifndef _LINUX_PT_PLATFORM_H
+#define _LINUX_PT_PLATFORM_H
+
+#include "pt_core.h"
+#include <linux/irq.h>
+
+#if defined(CONFIG_TOUCHSCREEN_PARADE) \
+ || defined(CONFIG_TOUCHSCREEN_PARADE_MODULE)
+extern struct pt_loader_platform_data _pt_loader_platform_data;
+extern irqreturn_t pt_irq(int irq, void *handle);
+
+int pt_xres(struct pt_core_platform_data *pdata, struct device *dev);
+int pt_init(struct pt_core_platform_data *pdata, int on,
+ struct device *dev);
+int pt_power(struct pt_core_platform_data *pdata, int on,
+ struct device *dev, atomic_t *ignore_irq);
+#ifdef PT_DETECT_HW
+int pt_detect(struct pt_core_platform_data *pdata,
+ struct device *dev, pt_platform_read read);
+#else
+#define pt_detect NULL
+#endif
+int pt_irq_stat(struct pt_core_platform_data *pdata,
+ struct device *dev);
+int pt_setup_power(struct pt_core_platform_data *pdata, int on,
+ struct device *dev);
+int pt_setup_irq(struct pt_core_platform_data *pdata, int on,
+ struct device *dev);
+#else /* !CONFIG_TOUCHSCREEN_PARADE */
+static struct pt_loader_platform_data _pt_loader_platform_data;
+#define pt_xres NULL
+#define pt_init NULL
+#define pt_power NULL
+#define pt_irq_stat NULL
+#define pt_detect NULL
+#define pt_setup_power NULL
+#define pt_setup_irq NULL
+#endif /* CONFIG_TOUCHSCREEN_PARADE */
+
+#endif /* _LINUX_PT_PLATFORM_H */
diff --git a/pt/pt_regs.h b/pt/pt_regs.h
index c79746d..0552e61 100644
--- a/pt/pt_regs.h
+++ b/pt/pt_regs.h
@@ -74,10 +74,11 @@
#include <linux/suspend.h>
#include <linux/stringify.h>
#include <linux/types.h>
-#include <linux/uaccess.h>
+#include <linux/fs.h>
+#include <asm/uaccess.h>
#include <linux/workqueue.h>
#include <linux/version.h>
-#include <linux/pt_core.h>
+#include "pt_core.h"
#include <linux/i2c.h>
#include <linux/of_gpio.h>
@@ -1728,9 +1729,9 @@ static inline int pt_proximity_release(struct device *dev) { return 0; }
static inline unsigned int pt_get_time_stamp(void)
{
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0))
- struct timespec ts;
+ struct timespec64 ts;
- getnstimeofday(&ts);
+ ktime_get_real_ts64(&ts);
return (ts.tv_sec*1000 + ts.tv_nsec/1000000);
#else
struct timeval tv;