Merge "input: touchscreen: focaltech: Add trusted touch support"

This commit is contained in:
qctecmdr 2022-07-05 00:25:45 -07:00 committed by Gerrit - the friendly Code Review server
commit fc203b7cce
4 changed files with 1081 additions and 49 deletions

View File

@ -12,3 +12,12 @@ config TOUCHSCREEN_FTS_DIRECTORY
string "Focaltech ts directory name"
default "focaltech_touch"
depends on TOUCHSCREEN_FTS
config FTS_TRUSTED_TOUCH
bool "Focaltech Trusted Touch"
depends on TOUCHSCREEN_FTS
help
Say Y here to enable Focaltech Trusted Touch.
If unsure, say N.
#endif

File diff suppressed because it is too large Load Diff

View File

@ -61,6 +61,7 @@
#include <linux/sched.h>
#include <linux/kthread.h>
#include <linux/dma-mapping.h>
#include <linux/haven/hh_irq_lend.h>
#include "focaltech_common.h"
/*****************************************************************************
@ -138,6 +139,33 @@ struct ts_event {
int area;
};
enum trusted_touch_mode_config {
TRUSTED_TOUCH_VM_MODE,
TRUSTED_TOUCH_MODE_NONE
};
#ifdef CONFIG_FTS_TRUSTED_TOUCH
#define TRUSTED_TOUCH_MEM_LABEL 0x7
struct trusted_touch_vm_info {
enum hh_irq_label irq_label;
enum hh_vm_names vm_name;
u32 hw_irq;
hh_memparcel_handle_t vm_mem_handle;
u32 *iomem_bases;
u32 *iomem_sizes;
u32 iomem_list_size;
void *mem_cookie;
#ifdef CONFIG_ARCH_QTI_VM
atomic_t tvm_owns_iomem;
atomic_t tvm_owns_irq;
#else
atomic_t pvm_owns_iomem;
atomic_t pvm_owns_irq;
#endif
};
#endif
struct fts_ts_data {
struct i2c_client *client;
struct spi_device *spi;
@ -190,6 +218,20 @@ struct fts_ts_data {
#elif defined(CONFIG_HAS_EARLYSUSPEND)
struct early_suspend early_suspend;
#endif
#ifdef CONFIG_FTS_TRUSTED_TOUCH
struct trusted_touch_vm_info *vm_info;
struct mutex fts_clk_io_ctrl_mutex;
const char *touch_environment;
struct completion trusted_touch_powerdown;
struct completion resource_checkpoint;
struct clk *core_clk;
struct clk *iface_clk;
atomic_t trusted_touch_initialized;
atomic_t trusted_touch_enabled;
atomic_t delayed_vm_probe_pending;
atomic_t trusted_touch_mode;
#endif
};
/*****************************************************************************
@ -258,4 +300,6 @@ int fts_ex_mode_recovery(struct fts_ts_data *ts_data);
void fts_irq_disable(void);
void fts_irq_enable(void);
int fts_ts_handle_trusted_touch_pvm(struct fts_ts_data *ts_data, int value);
int fts_ts_handle_trusted_touch_tvm(struct fts_ts_data *ts_data, int value);
#endif /* __LINUX_FOCALTECH_CORE_H__ */

View File

@ -633,7 +633,7 @@ static ssize_t fts_bootmode_show(
}
/* fts_tpfwver interface */
static ssize_t fts_tpfwver_show(
static ssize_t fts_fw_version_show(
struct device *dev, struct device_attribute *attr, char *buf)
{
struct fts_ts_data *ts_data = fts_data;
@ -659,7 +659,7 @@ static ssize_t fts_tpfwver_show(
return num_read_chars;
}
static ssize_t fts_tpfwver_store(
static ssize_t fts_fw_version_store(
struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
@ -1058,8 +1058,72 @@ static ssize_t fts_log_level_store(
return count;
}
#ifdef CONFIG_FTS_TRUSTED_TOUCH
static ssize_t trusted_touch_enable_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct i2c_client *client = to_i2c_client(dev);
struct fts_ts_data *info;
if (!client)
return scnprintf(buf, PAGE_SIZE, "client is null\n");
info = i2c_get_clientdata(client);
if (!info) {
FTS_ERROR("info is null\n");
return scnprintf(buf, PAGE_SIZE, "info is null\n");
}
return scnprintf(buf, PAGE_SIZE, "%d",
atomic_read(&info->trusted_touch_enabled));
}
static ssize_t trusted_touch_enable_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct i2c_client *client = to_i2c_client(dev);
struct fts_ts_data *info;
unsigned long value;
int err = 0;
if (!client)
return -EIO;
info = i2c_get_clientdata(client);
if (!info) {
FTS_ERROR("info is null\n");
return -EIO;
}
if (count > 2)
return -EINVAL;
err = kstrtoul(buf, 10, &value);
if (err != 0)
return err;
if (!atomic_read(&info->trusted_touch_initialized))
return -EIO;
#ifdef CONFIG_ARCH_QTI_VM
err = fts_ts_handle_trusted_touch_tvm(info, value);
if (err) {
pr_err("Failed to handle trusted touch in tvm\n");
return -EINVAL;
}
#else
err = fts_ts_handle_trusted_touch_pvm(info, value);
if (err) {
pr_err("Failed to handle trusted touch in pvm\n");
return -EINVAL;
}
#endif
err = count;
return err;
}
#endif
/* get the fw version example:cat fw_version */
static DEVICE_ATTR(fts_fw_version, S_IRUGO | S_IWUSR, fts_tpfwver_show, fts_tpfwver_store);
static DEVICE_ATTR_RW(fts_fw_version);
/* read and write register(s)
* All data type is **HEX**
@ -1082,6 +1146,9 @@ static DEVICE_ATTR(fts_irq, S_IRUGO | S_IWUSR, fts_irq_show, fts_irq_store);
static DEVICE_ATTR(fts_boot_mode, S_IRUGO | S_IWUSR, fts_bootmode_show, fts_bootmode_store);
static DEVICE_ATTR(fts_touch_point, S_IRUGO | S_IWUSR, fts_tpbuf_show, fts_tpbuf_store);
static DEVICE_ATTR(fts_log_level, S_IRUGO | S_IWUSR, fts_log_level_show, fts_log_level_store);
#ifdef CONFIG_FTS_TRUSTED_TOUCH
static DEVICE_ATTR_RW(trusted_touch_enable);
#endif
/* add your attr in here*/
static struct attribute *fts_attributes[] = {
@ -1094,6 +1161,9 @@ static struct attribute *fts_attributes[] = {
&dev_attr_fts_boot_mode.attr,
&dev_attr_fts_touch_point.attr,
&dev_attr_fts_log_level.attr,
#ifdef CONFIG_FTS_TRUSTED_TOUCH
&dev_attr_trusted_touch_enable.attr,
#endif
NULL
};