Initial commit: Linux kernel 4.19 for Unplugged OS

This commit is contained in:
ziv committed 2025-10-06 13:52:42 +00:00
commit d30235b04c
80519 files changed
+35800681

No files matched your search

@@ -0,0 +1,248 @@
#
# Touchscreen driver configuration
#
if TOUCHSCREEN_MTK_GT911
config GT911_CONFIG
string "GT911 for Mediatek config"
config GTP_DRIVER_SEND_CFG
bool "GT911 send config by driver feature"
help
Say Y here if you have GT911 touch panel GTP_DRIVER_SEND_CFG.
If unsure, say N.
Used for send config. Should check your config with goodix.
Sometimes it is not latest
config GTP_CUSTOM_CFG
bool "GT911 custom config option"
help
Say Y here if you have GT911 touch panel GTP_CUSTOM_CFG.
If unsure, say N.
Used for send custom config. Usually we modify touch resoluton
through it.
config GTP_HAVE_TOUCH_KEY
bool "GT911 touch key option"
help
Say Y here if you have GT911 touch panel GTP_HAVE_TOUCH_KEY.
If unsure, say N.
Used for touch keypad. such as some virtual key, home key, search
key, back key etc.
config GTP_CHANGE_X2Y
bool "GT911 chang x2y option"
help
Say Y here if you have GT911 touch panel GTP_CHANGE_X2Y.
If unsure, say N.
Used for change coordinate x to y. Usually we make coodirnate map
same as lcm rotation through it.
config GTP_COMPATIBLE_MODE
bool "GT911 compatible mode option"
help
Say Y here if you have GT911 touch panel GTP_COMPATIBLE_MODE.
If unsure, say N.
Used for enable compatible mode. If enable ,will compatibel some
gt9xxF chip in this driver
config GTP_WARP_X_ON
bool "GT911 warp x option"
help
Say Y here if you have GT911 touch panel GTP_WARP_X_ON.
If unsure, say N.
Used for warp coordinate x on.
comaptible for GT9XX chip.
config GTP_WARP_Y_ON
bool "GT911 warp y option"
help
Say Y here if you have GT911 touch panel GTP_WARP_Y_ON.
If unsure, say N.
Used for warp coordinate y on.
compatible for GT9XX chip.
config GTP_GESTURE_WAKEUP
bool "GT911 gesture wakeup feature"
help
Say Y here if you have GT911 touch panel GTP_GESTURE_WAKEUP.
If unsure, say N.
Used for enable gesture wake up. Should not diasble power while
driver suspend.
config GTP_HOTKNOT
bool "GT911 hotknot feature"
help
Say Y here if you have GT911 touch panel GTP_HOTKNOT.
If unsure, say N.
Used for enable hotknot. Should check your firmware
whether support with goodix.
config HOTKNOT_TYPE
bool "GT911 hotknot type option"
help
Say Y here if you have GT911 touch panel HOTKNOT_TYPE.
If unsure, say N.
Used for config hotknot type. Should check your firmware
whether support with goodix.
config HOTKNOT_BLOCK_RW
bool "GT911 hotknot block RW option"
help
Say Y here if you have GT911 touch panel HOTKNOT_BLOCK_RW.
If unsure, say N.
Used for config hotknot block read or write. Should check your
firmware whether support with goodix.
config GTP_PROXIMITY
bool "GT911 proximity feature"
help
Say Y here if you have GT911 touch panel GTP_PROXIMITY.
If unsure, say N.
Used for enable proximity feature. Should check your firmware
whether support with goodix.
config GTP_WITH_STYLUS
bool "GT911 with stylus option"
help
Say Y here if you have GT911 touch panel GTP_WITH_STYLUS.
If unsure, say N.
Used for stylus feature. Should check your firmware
whether support with goodix.
config GTP_HAVE_STYLUS_KEY
bool "GT911 stylus key feature"
help
Say Y here if you have GT911 touch panel GTP_HAVE_STYLUS_KEY.
If unsure, say N.
Used for stylus key option. Should check your firmware
whether support with goodix.
config GTP_AUTO_UPDATE
bool "GT911 firmware auto update feature"
help
Say Y here if you have GT911 touch panel GTP_AUTO_UPDATE.
If unsure, say N.
Used for auto update firmware feature.
compatible for GT9XX chip.
config GTP_HEADER_FW_UPDATE
bool "GT911 firmware header update feature"
help
Say Y here if you have GT911 touch panel GTP_HEADER_FW_UPDATE.
If unsure, say N.
Used for auto update firmware header feature.
compatible for GT9XX chip.
config GTP_FW_DOWNLOAD
bool "GT911 firmware download feature"
help
Say Y here if you have GT911 touch panel GTP_FW_DOWNLOAD.
If unsure, say N.
Used for download firmware feature. Usually it will be enable while
we use apk to update firmware.
config GTP_CREATE_WR_NODE
bool "GT911 create WR node feature"
help
Say Y here if you have GT911 touch panel GTP_CREATE_WR_NODE.
If unsure, say N.
Used for create write and read node , which user space will debug touch
through proc node.
config GTP_ESD_PROTECT
bool "GT911 ESD protect feature"
help
Say Y here if you have GT911 touch panel GTP_ESD_PROTECT.
If unsure, say N.
Used for esd protect. Should check your firmware
whether support with goodix.
config GTP_CHARGER_DETECT
bool "GT911 charger detect feature"
help
Say Y here if you have GT911 touch panel GTP_CHARGER_DETECT.
If unsure, say N.
Used for charger protect. Should check your firmware
whether support with goodix.
config GTP_CHARGER_SWITCH
bool "GT911 charger switch feature"
help
Say Y here if you have GT911 touch panel GTP_CHARGER_SWITCH.
If unsure, say N.
Used for charger switch. Should check your firmware
whether support with goodix.
config GTP_DEBUG_ARRAY_ON
bool "GT911 debug array feature"
help
Say Y here if you have GT911 touch panel GTP_DEBUG_ARRAY_ON.
If unsure, say N.
Used for debug array feature.
comaptible for GT9XX chip.
config GTP_DEBUG_FUNC_ON
bool "GT911 debug feature"
help
Say Y here if you have GT911 touch panel GTP_DEBUG_FUNC_ON.
If unsure, say N.
Used for debug feature.
compatible for GT9XX chip.
config GTP_POWER_CTRL_SLEEP
bool "GT911 power cntrol while sleep"
help
Say Y here if you have GT911 touch panel GTP_POWER_CTRL_SLEEP.
If unsure, say N.
Will disable power while device suspend. if you support gesture
wake up feature, do not enable this feature.
endif
@@ -0,0 +1,9 @@
# Linux driver folder
ccflags-y += -I$(srctree)/drivers/input/touchscreen/mediatek/
ccflags-y += -I$(srctree)/drivers/input/touchscreen/mediatek/GT911/include/$(CONFIG_GT911_CONFIG)/
ccflags-y += -I$(srctree)/drivers/misc/mediatek/include/mt-plat/
obj-y += goodix_tool.o
obj-y += gt9xx_driver.o
obj-y += gt9xx_update.o
@@ -0,0 +1,406 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#include "tpd.h"
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/kthread.h>
#include <linux/sched.h>
#include <linux/time.h>
#include <linux/uaccess.h>
#include <linux/wait.h>
#include "include/tpd_gt9xx_common.h"
#include <linux/device.h>
#include <linux/proc_fs.h> /*proc*/
#pragma pack(1)
struct st_cmd_head {
u8 wr; /* write read flag - 0:R 1:W 2:PID 3: */
u8 flag; /* 0:no need flag/int 1: need flag 2:need int */
u8 flag_addr[2]; /* flag address */
u8 flag_val; /* flag val */
u8 flag_relation; /* flag_val:flag 0:not equal 1:equal 2:> 3:< */
u16 circle; /* polling cycle */
u8 times; /* plling times */
u8 retry; /* I2C retry times */
u16 delay; /* delay before read or after write */
u16 data_len; /* data length */
u8 addr_len; /* address length */
u8 addr[2]; /* address */
u8 res[3]; /* reserved */
u8 *data; /* data pointer */
};
#pragma pack()
struct st_cmd_head cmd_head;
#define DATA_LENGTH_UINT 512
#define CMD_HEAD_LENGTH (sizeof(struct st_cmd_head) - sizeof(u8 *))
#define GOODIX_ENTRY_NAME "goodix_tool"
static char procname[20] = {0};
static struct i2c_client *gt_client;
#if 0
static struct proc_dir_entry *goodix_proc_entry;
#endif
static s32 goodix_tool_write(struct file *filp, const char __user *buff,
unsigned long len, void *data);
static s32 goodix_tool_read(char *page, char **start, off_t off, int count,
int *eof, void *data);
static s32 (*tool_i2c_read)(u8 *, u16);
static s32 (*tool_i2c_write)(u8 *, u16);
s32 DATA_LENGTH;
s8 IC_TYPE[16] = "GT9XX";
static void tool_set_proc_name(char *procname)
{
sprintf(procname, "gmnode");
}
static ssize_t goodix_tool_upper_read(struct file *file, char __user *buffer,
size_t count, loff_t *ppos)
{
return goodix_tool_read(buffer, NULL, 0, count, NULL, ppos);
}
static ssize_t goodix_tool_upper_write(struct file *file,
const char __user *buffer, size_t count,
loff_t *ppos)
{
return goodix_tool_write(file, buffer, count, ppos);
}
static const struct file_operations gt_tool_fops = {
.write = goodix_tool_upper_write, .read = goodix_tool_upper_read};
static s32 tool_i2c_read_no_extra(u8 *buf, u16 len)
{
s32 ret = -1;
ret = gtp_i2c_read(gt_client, buf, len + GTP_ADDR_LENGTH);
return ret;
}
static s32 tool_i2c_write_no_extra(u8 *buf, u16 len)
{
s32 ret = -1;
ret = gtp_i2c_write(gt_client, buf, len);
return ret;
}
static s32 tool_i2c_read_with_extra(u8 *buf, u16 len)
{
s32 ret = -1;
u8 pre[2] = {0x0f, 0xff};
u8 end[2] = {0x80, 0x00};
tool_i2c_write_no_extra(pre, 2);
ret = tool_i2c_read_no_extra(buf, len);
tool_i2c_write_no_extra(end, 2);
return ret;
}
static s32 tool_i2c_write_with_extra(u8 *buf, u16 len)
{
s32 ret = -1;
u8 pre[2] = {0x0f, 0xff};
u8 end[2] = {0x80, 0x00};
tool_i2c_write_no_extra(pre, 2);
ret = tool_i2c_write_no_extra(buf, len);
tool_i2c_write_no_extra(end, 2);
return ret;
}
static void register_i2c_func(void)
{
/* if (!strncmp(IC_TYPE, "GT818", 5) || !strncmp(IC_TYPE, "GT816", 5) */
/* || !strncmp(IC_TYPE, "GT811", 5) || !strncmp(IC_TYPE, "GT818F", 6) */
/* || !strncmp(IC_TYPE, "GT827", 5) || !strncmp(IC_TYPE,"GT828", 5) */
/* || !strncmp(IC_TYPE, "GT813", 5)) */
if (strncmp(IC_TYPE, "GT8110", 6) && strncmp(IC_TYPE, "GT8105", 6) &&
strncmp(IC_TYPE, "GT801", 5) && strncmp(IC_TYPE, "GT800", 5) &&
strncmp(IC_TYPE, "GT801PLUS", 9) && strncmp(IC_TYPE, "GT811", 5) &&
strncmp(IC_TYPE, "GTxxx", 5) && strncmp(IC_TYPE, "GT9XX", 5)) {
tool_i2c_read = tool_i2c_read_with_extra;
tool_i2c_write = tool_i2c_write_with_extra;
GTP_DEBUG("I2C function: with pre and end cmd!");
} else {
tool_i2c_read = tool_i2c_read_no_extra;
tool_i2c_write = tool_i2c_write_no_extra;
GTP_INFO("I2C function: without pre and end cmd!");
}
}
static void unregister_i2c_func(void)
{
tool_i2c_read = NULL;
tool_i2c_write = NULL;
GTP_INFO("I2C function: unregister i2c transfer function!");
}
s32 init_wr_node(struct i2c_client *client)
{
s32 i;
gt_client = i2c_client_point;
memset(&cmd_head, 0, sizeof(cmd_head));
cmd_head.data = NULL;
i = 5;
while ((!cmd_head.data) && i) {
cmd_head.data = kzalloc(i * DATA_LENGTH_UINT, GFP_KERNEL);
if (cmd_head.data != NULL)
break;
i--;
}
if (i) {
DATA_LENGTH = i * DATA_LENGTH_UINT + GTP_ADDR_LENGTH;
GTP_INFO("Applied memory size:%d.", DATA_LENGTH);
} else {
GTP_ERROR("Apply for memory failed.");
return FAIL;
}
cmd_head.addr_len = 2;
cmd_head.retry = 5;
register_i2c_func();
tool_set_proc_name(procname);
#if 0 /* fix 3.10 */
goodix_proc_entry = create_proc_entry(gtp_tool_entry, 0664, NULL);
if (goodix_proc_entry == NULL) {
GTP_ERROR("Couldn't create proc entry!");
return FAIL;
}
GTP_INFO("Create proc entry success!");
goodix_proc_entry->write_proc = goodix_tool_write;
goodix_proc_entry->read_proc = goodix_tool_read;
#else
if (proc_create(procname, 0660, NULL, &gt_tool_fops) == NULL) {
GTP_ERROR("create_proc_entry %s failed", procname);
return -1;
}
#endif
return SUCCESS;
}
void uninit_wr_node(void)
{
kfree(cmd_head.data);
cmd_head.data = NULL;
unregister_i2c_func();
remove_proc_entry(procname, NULL);
}
static u8 relation(u8 src, u8 dst, u8 rlt)
{
u8 ret = 0;
switch (rlt) {
case 0:
ret = (src != dst) ? true : false;
break;
case 1:
ret = (src == dst) ? true : false;
GTP_DEBUG("equal:src:0x%02x dst:0x%02x ret:%d.", src, dst,
(s32)ret);
break;
case 2:
ret = (src > dst) ? true : false;
break;
case 3:
ret = (src < dst) ? true : false;
break;
case 4:
ret = (src & dst) ? true : false;
break;
case 5:
ret = (!(src | dst)) ? true : false;
break;
default:
ret = false;
break;
}
return ret;
}
/*
*******************************************************
*Function:
* Comfirm function.
*Input:
* None.
*Output:
* Return write length.
*********************************************************
*/
static u8 comfirm(void)
{
s32 i = 0;
u8 buf[32];
/* memcpy(&buf[GTP_ADDR_LENGTH - cmd_head.addr_len], */
/* &cmd_head.flag_addr, cmd_head.addr_len); */
/* memcpy(buf, &cmd_head.flag_addr, cmd_head.addr_len);*/
/*Modified by Scott, 2012-02-17 */
memcpy(buf, cmd_head.flag_addr, cmd_head.addr_len);
for (i = 0; i < cmd_head.times; i++) {
if (tool_i2c_read(buf, 1) <= 0) {
GTP_ERROR("Read flag data failed!");
return FAIL;
}
if (true == relation(buf[GTP_ADDR_LENGTH], cmd_head.flag_val,
cmd_head.flag_relation)) {
GTP_DEBUG("value at flag addr:0x%02x.",
buf[GTP_ADDR_LENGTH]);
GTP_DEBUG("flag value:0x%02x.", cmd_head.flag_val);
break;
}
msleep(cmd_head.circle);
}
if (i >= cmd_head.times) {
GTP_ERROR("Didn't get the flag to continue!");
return FAIL;
}
return SUCCESS;
}
/*
* ******************************************************
* Function:
* Goodix tool write function.
* Input:
* standard proc write function param.
* Output:
* Return write length.
* *******************************************************
*/
static s32 goodix_tool_write(struct file *filp, const char __user *buff,
unsigned long len, void *data)
{
return 0;
}
/*
*******************************************************
*Function:
* Goodix tool read function.
*Input:
* standard proc read function param.
*Output:
* Return read length.
********************************************************
*/
static s32 goodix_tool_read(char *page, char **start, off_t off, int count,
int *eof, void *data)
{
GTP_DEBUG_FUNC();
if (cmd_head.wr % 2) {
return FAIL;
} else if (!cmd_head.wr) {
u16 len = 0;
s16 data_len = 0;
u16 loc = 0;
if (cmd_head.flag == 1) {
if (comfirm() == FAIL) {
GTP_ERROR("[READ]Comfirm fail!");
return FAIL;
}
} else if (cmd_head.flag == 2) {
/* Need interrupt! */
}
memcpy(cmd_head.data, cmd_head.addr, cmd_head.addr_len);
GTP_DEBUG("[CMD HEAD DATA] ADDR:0x%02x%02x.", cmd_head.data[0],
cmd_head.data[1]);
GTP_DEBUG("[CMD HEAD ADDR] ADDR:0x%02x%02x.", cmd_head.addr[0],
cmd_head.addr[1]);
if (cmd_head.delay)
msleep(cmd_head.delay);
data_len = cmd_head.data_len;
while (data_len > 0) {
if (data_len > DATA_LENGTH)
len = DATA_LENGTH;
else
len = data_len;
data_len -= DATA_LENGTH;
if (tool_i2c_read(cmd_head.data, len) <= 0) {
GTP_ERROR("[READ]Read data failed!");
return FAIL;
}
memcpy(&page[loc], &cmd_head.data[GTP_ADDR_LENGTH],
len);
loc += len;
GTP_DEBUG_ARRAY(&cmd_head.data[GTP_ADDR_LENGTH], len);
GTP_DEBUG_ARRAY(page, len);
}
} else if (cmd_head.wr == 2) {
/* memcpy(page, "gt8", cmd_head.data_len); */
/* memcpy(page, "GT818", 5); */
/* page[5] = 0; */
GTP_DEBUG("Return ic type:%s len:%d.", page,
(s32)cmd_head.data_len);
return cmd_head.data_len;
/* return sizeof(IC_TYPE_NAME); */
} else if (cmd_head.wr == 4) {
page[0] = show_len >> 8;
page[1] = show_len & 0xff;
page[2] = total_len >> 8;
page[3] = total_len & 0xff;
return cmd_head.data_len;
} else if (cmd_head.wr == 6) {
/* Read error code! */
} else if (cmd_head.wr == 8) { /* Read driver version */
/* memcpy(page, GTP_DRIVER_VERSION, strlen(GTP_DRIVER_VERSION));
*/
s32 tmp_len;
tmp_len = strlen(GTP_DRIVER_VERSION);
memcpy(page, GTP_DRIVER_VERSION, tmp_len);
page[tmp_len] = 0;
}
return cmd_head.data_len;
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,80 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _GT9XX_CONFIG_H_
#define _GT9XX_CONFIG_H_
/*
***************************PART2:TODO
* define**********************************
* STEP_1(REQUIRED):Change config table.
* TODO: puts the config info corresponded to your TP here,
* the following is just
* a sample config, send this config should cause the chip cannot work normally
*/
#define CTP_CFG_GROUP1 \
{ \
0x41, 0x20, 0x03, 0x00, 0x05, 0x05, 0x38, 0x00, 0x01, 0x0F, \
0x28, 0x07, 0x55, 0x37, 0x03, 0x05, 0x00, 0x00, 0x00, \
0x00, 0x11, 0x11, 0x05, 0x0C, 0x0E, 0x0F, 0x0B, 0x8C, \
0x2E, 0x0E, 0x2F, 0x2D, 0x7F, 0x08, 0x00, 0x00, 0x00, \
0x9A, 0x02, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x5A, 0x94, 0xC5, \
0x02, 0x05, 0x00, 0x00, 0x04, 0xD9, 0x27, 0x00, 0xB6, \
0x2F, 0x00, 0x99, 0x39, 0x00, 0x85, 0x44, 0x00, 0x73, \
0x52, 0x00, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, \
0x0E, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x18, 0x1C, \
0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x24, 0x26, 0x28, \
0x29, 0x2A, 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, \
0x0F, 0x10, 0x12, 0x13, 0x14, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x0E, 0x01, \
}
#define CTP_CFG_GROUP1_CHARGER \
{ \
}
/* TODO puts your group2 config info here,if need. */
#define CTP_CFG_GROUP2 \
{ \
}
/* TODO puts your group2 config info here,if need. */
#define CTP_CFG_GROUP2_CHARGER \
{ \
}
/* TODO puts your group3 config info here,if need. */
#define CTP_CFG_GROUP3 \
{ \
}
/* TODO puts your group3 config info here,if need. */
#define CTP_CFG_GROUP3_CHARGER \
{ \
}
/* TODO: define your config for Sensor_ID == 3 here, if needed */
#define CTP_CFG_GROUP4 \
{ \
}
/* TODO: define your config for Sensor_ID == 4 here, if needed */
#define CTP_CFG_GROUP5 \
{ \
}
/* TODO: define your config for Sensor_ID == 5 here, if needed */
#define CTP_CFG_GROUP6 \
{ \
}
#endif /* _GT1X_CONFIG_H_ */
@@ -0,0 +1,82 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _GT9XX_CONFIG_H_
#define _GT9XX_CONFIG_H_
/*
***************************PART2:TODO
* define**********************************
* STEP_1(REQUIRED):Change config table.
* TODO: puts the config info corresponded to your TP here,
* the following is just
* a sample config, send this config should cause the chip cannot work normally
*/
#define CTP_CFG_GROUP1 \
{ \
0x41, 0x20, 0x03, 0x00, 0x05, 0x05, 0x38, 0x06, 0x01, 0x0F, \
0x28, 0x07, 0x55, 0x37, 0x03, 0x05, 0x00, 0x00, 0x00, \
0x00, 0x11, 0x11, 0x05, 0x0C, 0x0E, 0x0F, 0x0B, 0x8C, \
0x2E, 0x0E, 0x2F, 0x2D, 0x7F, 0x08, 0x00, 0x00, 0x00, \
0x9A, 0x02, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x5A, 0x94, 0xC5, \
0x02, 0x05, 0x00, 0x00, 0x04, 0xD9, 0x27, 0x00, 0xB6, \
0x2F, 0x00, 0x99, 0x39, 0x00, 0x85, 0x44, 0x00, 0x73, \
0x52, 0x00, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x1A, 0x0D, 0x03, 0x06, 0x00, 0x21, 0x43, 0x06, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, \
0x0E, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x18, 0x1C, \
0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x24, 0x26, 0x28, \
0x29, 0x2A, 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, \
0x0F, 0x10, 0x12, 0x13, 0x14, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x6E, 0x01, \
}
/* default config for K82 */
#define CTP_CFG_GROUP1_CHARGER \
{ \
}
/* TODO puts your group2 config info here,if need. */
#define CTP_CFG_GROUP2 \
{ \
}
/* TODO puts your group2 config info here,if need. */
#define CTP_CFG_GROUP2_CHARGER \
{ \
}
/* TODO puts your group3 config info here,if need. */
#define CTP_CFG_GROUP3 \
{ \
}
/* TODO puts your group3 config info here,if need. */
#define CTP_CFG_GROUP3_CHARGER \
{ \
}
/* TODO: define your config for Sensor_ID == 3 here, if needed */
#define CTP_CFG_GROUP4 \
{ \
}
/* TODO: define your config for Sensor_ID == 4 here, if needed */
#define CTP_CFG_GROUP5 \
{ \
}
/* TODO: define your config for Sensor_ID == 5 here, if needed */
#define CTP_CFG_GROUP6 \
{ \
}
#endif /* _GT9XX_CONFIG_H_ */
@@ -0,0 +1,65 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef _GT9XX_CONFIG_H_
#define _GT9XX_CONFIG_H_
#define CTP_CFG_GROUP1 \
{ \
0x42, 0x20, 0x03, 0x00, 0x05, 0x05, 0x38, 0x06, 0x01, 0x88, \
0x28, 0x07, 0x55, 0x37, 0x03, 0x04, 0x01, 0x01, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x17, 0x19, 0x20, 0x14, 0x8C, \
0x2E, 0x0E, 0x2B, 0x29, 0xA0, 0x0B, 0x00, 0x00, 0x00, \
0x99, 0x03, 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x1A, 0x42, 0x94, 0xC5, \
0x02, 0x05, 0x00, 0x00, 0x04, 0xB4, 0x1C, 0x00, 0x97, \
0x22, 0x00, 0x80, 0x29, 0x00, 0x6C, 0x32, 0x00, 0x5D, \
0x3C, 0x00, 0x5D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x28, 0x28, 0x03, 0x06, 0x00, 0x31, 0x85, 0x0D, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, \
0x0E, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1A, 0x1C, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x18, 0x1C, \
0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x24, 0x26, 0x28, \
0x29, 0x2A, 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, \
0x0F, 0x10, 0x12, 0x13, 0x14, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x60, 0x01 \
}
#define CTP_CFG_GROUP1_CHARGER \
{ \
}
#define CTP_CFG_GROUP2 \
{ \
}
#define CTP_CFG_GROUP2_CHARGER \
{ \
}
#define CTP_CFG_GROUP3 \
{ \
}
#define CTP_CFG_GROUP3_CHARGER \
{ \
}
#define CTP_CFG_GROUP4 \
{ \
}
#define CTP_CFG_GROUP5 \
{ \
}
#define CTP_CFG_GROUP6 \
{ \
}
#endif
@@ -0,0 +1,351 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#ifndef TPD_CUSTOM_GT9XX_H__
#define TPD_CUSTOM_GT9XX_H__
#include <linux/hrtimer.h>
#include <linux/string.h>
#include <linux/vmalloc.h>
/* #include <linux/io.h> */
#include <linux/bitops.h>
#include <linux/byteorder/generic.h>
#include <linux/delay.h>
#include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/input.h>
#include <linux/kernel.h>
#include <linux/kthread.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/slab.h>
#ifdef CONFIG_HAS_EARLYSUSPEND
#include <linux/earlysuspend.h>
#endif
#include <linux/interrupt.h>
#include <linux/time.h>
#include <linux/jiffies.h>
#include <linux/proc_fs.h>
#include <linux/uaccess.h>
extern struct tpd_device *tpd;
extern u16 show_len;
extern u16 total_len;
extern u8 gtp_rawdiff_mode;
extern unsigned int tpd_rst_gpio_number;
extern unsigned int tpd_int_gpio_number;
extern unsigned int touch_irq;
extern s32 gtp_send_cfg(struct i2c_client *client);
extern void gtp_reset_guitar(struct i2c_client *client, s32 ms);
extern void gtp_int_sync(void);
extern u8 gup_init_update_proc(struct i2c_client *client);
extern u8 gup_init_fw_proc(struct i2c_client *client);
extern s32 gtp_i2c_read(struct i2c_client *client, u8 *buf, s32 len);
extern s32 gtp_i2c_write(struct i2c_client *client, u8 *buf, s32 len);
extern int i2c_write_bytes(struct i2c_client *client, u16 addr, u8 *txbuf,
int len);
extern int i2c_read_bytes(struct i2c_client *client, u16 addr, u8 *rxbuf,
int len);
/* ***************************PART1:ON/OFF define*************************/
/*
*****************************************
* Notice : all customizable feature shuold import
* to defconfig/Kconfig/dts file.
* Do not config it here
*******************************************
*/
/*#define GTP_CUSTOM_CFG 0*/ /*config in defconfig*/
/* driver send config to TP on intilization (for no config built in TP flash) */
/*#define GTP_DRIVER_SEND_CFG 1*/ /*config in defconfig*/
/*#define GTP_HAVE_TOUCH_KEY 0*/ /*config in defconfig*/
/*#define GTP_POWER_CTRL_SLEEP 1*/
/*config in defconfig*/ /* turn off power on suspend */
/*#define GTP_AUTO_UPDATE 1*/
/*config in defconfig*/ /* update FW to TP FLASH */
/*#define GTP_CHANGE_X2Y 0*/ /*config in defconfig*/ /* set for se1 */
/* auto updated fw by gtp_default_FW in gt9xx_firmware.h, */
/* function together with */
/* GTP_AUTO_UPDATE */
/*#define GTP_HEADER_FW_UPDATE 1*/ /*config in defconfig*/
/* auto update config by .cfg file, function together with GTP_AUTO_UPDATE */
/*Now GT911 do not use this option.If use please add it to*/
/* Kconfig and config in */
/* defconfig*/
/*#define GTP_AUTO_UPDATE_CFG 0*/
/* if gt9xxf, better enable it if hardware platform supported */
/*Now GT911 do not use this option.If use please add it to*/
/* Kconfig and config in */
/* defconfig*/
/*#define GTP_SUPPORT_I2C_DMA 1*/
/*#define GTP_COMPATIBLE_MODE 1*/
/*config in defconfig*/ /* compatible with GT9XXF */
/*#define GTP_ESD_PROTECT 0*/
/*config in defconfig*/ /* esd protection with a cycle of 2 seconds */
/*#define GTP_CREATE_WR_NODE 1*/ /*config in defconfig*/
/*Now GT911 do not use this option.If use please add it to Kconfig */
/* and config in */
/* defconfig*/
/*#define GUP_USE_HEADER_FILE 0*/
/*#define GTP_FW_DOWNLOAD 0*/
/*config in defconfig*/ /* update FW to TP SRAM */
/* #define GTP_CHARGER_DETECT */
#define GTP_CONFIG_MIN_LENGTH 186
#define GTP_CONFIG_MAX_LENGTH 240
/* #define GTP_CHARGER_SWITCH 0*/
/*config in defconfig*/ /* charger plugin & plugout detect */
/*Now GT911 do not use this option.If use please add it to*/
/* Kconfig and config in */
/* defconfig*/
/*#define GTP_WITH_PEN 0*/
/*Now GT911 do not use this option.If use please add it to */
/*Kconfig and config in */
/* defconfig*/
/*#define GTP_SLIDE_WAKEUP 0*/
/* double-click wakup, function together with GTP_SLIDE_WAKEUP */
/*Now GT911 do not use this option.If use please add it to */
/*Kconfig and config in */
/* defconfig*/
/*#define GTP_DBL_CLK_WAKEUP 0*/
/*#define HOTKNOT_BLOCK_RW 0*/ /*config in defconfig*/
/* #define GTP_PROXIMITY */ /*config in defconfig*/
/* #define TPD_HAVE_BUTTON*/
/*report key as coordinate,Vibration feedback */ /*config in dts file */
/* #define TPD_WARP_X */ /*config in defconfig*/
/* #define TPD_WARP_Y */ /*config in defconfig*/
#define GTP_INFO_ON 0
#define GTP_DEBUG_ON 0
#define GTP_DEBUG_ARRAY_ON 0
#define GTP_DEBUG_FUNC_ON 0
#define CFG_GROUP_LEN(p_cfg_grp) ARRAY_SIZE(p_cfg_grp)
#define FLASHLESS_FLASH_WORKROUND 0
#ifdef CONFIG_GTP_COMPATIBLE_MODE
extern void force_reset_guitar(void);
#endif
/* STEP_3(optional):Custom set some config by themself,if need. */
#ifdef CONFIG_GTP_CUSTOM_CFG
#define GTP_MAX_HEIGHT 800
#define GTP_MAX_WIDTH 480
#define GTP_INT_TRIGGER 0 /* 0:Rising 1:Falling */
#else
#define GTP_MAX_HEIGHT 4096
#define GTP_MAX_WIDTH 4096
#define GTP_INT_TRIGGER 1
#endif
#define GTP_MAX_TOUCH 5
#define VELOCITY_CUSTOM
#define TPD_VELOCITY_CUSTOM_X 15
#define TPD_VELOCITY_CUSTOM_Y 15
#ifdef CONFIG_GTP_CREATE_WR_NODE
extern s32 init_wr_node(struct i2c_client *client);
extern void uninit_wr_node(void);
#endif
#ifdef CONFIG_GTP_CHARGER_DETECT
extern bool upmu_get_pchr_chrdet(void);
#endif
#ifdef CONFIG_GTP_ESD_PROTECT
extern void gtp_esd_switch(struct i2c_client *client, s32 on);
#endif
#define UPDATE_FUNCTIONS
#ifdef UPDATE_FUNCTIONS
extern s32 gup_enter_update_mode(struct i2c_client *client);
extern void gup_leave_update_mode(void);
extern s32 gup_update_proc(void *dir);
#endif
extern struct i2c_client *i2c_client_point;
#ifdef VELOCITY_CUSTOM
extern int tpd_v_magnify_x;
extern int tpd_v_magnify_y;
#endif
/* STEP_4(optional):If this project have touch key,Set touch key config. */
#ifdef CONFIG_GTP_HAVE_TOUCH_KEY
#define GTP_KEY_TAB \
{ \
KEY_MENU, KEY_HOME, KEY_BACK, KEY_SEND \
}
#endif
/* ***************************PART3:OTHER */
/* define********************************* */
#define GTP_DRIVER_VERSION "V2.1<2014/01/10>"
#define GTP_I2C_NAME "Goodix-TS"
#define GT91XX_CONFIG_PROC_FILE "gt9xx_config"
#define GTP_POLL_TIME 10
#define GTP_ADDR_LENGTH 2
#define GTP_CONFIG_MIN_LENGTH 186
#define GTP_CONFIG_MAX_LENGTH 240
#define FAIL 0
#define SUCCESS 1
#define SWITCH_OFF 0
#define SWITCH_ON 1
/* ******************** For GT9XXF Start ***********************/
#ifdef CONFIG_GTP_COMPATIBLE_MODE
enum CHIP_TYPE_T {
CHIP_TYPE_GT9 = 0,
CHIP_TYPE_GT9F = 1,
};
#endif
#define GTP_REG_MATRIX_DRVNUM 0x8069
#define GTP_REG_MATRIX_SENNUM 0x806A
#define GTP_REG_RQST 0x8043
#define GTP_REG_BAK_REF 0x99D0
#define GTP_REG_MAIN_CLK 0x8020
#define GTP_REG_CHIP_TYPE 0x8000
#define GTP_REG_HAVE_KEY 0x804E
#define GTP_REG_HN_STATE 0xAB10
#define GTP_FL_FW_BURN 0x00
#define GTP_FL_ESD_RECOVERY 0x01
#define GTP_FL_READ_REPAIR 0x02
#define GTP_BAK_REF_SEND 0
#define GTP_BAK_REF_STORE 1
#define CFG_LOC_DRVA_NUM 29
#define CFG_LOC_DRVB_NUM 30
#define CFG_LOC_SENS_NUM 31
#define GTP_CHK_FW_MAX 1000
#define GTP_CHK_FS_MNT_MAX 300
#define GTP_BAK_REF_PATH "/data/gtp_ref.bin"
#define GTP_MAIN_CLK_PATH "/data/gtp_clk.bin"
#define GTP_RQST_CONFIG 0x01
#define GTP_RQST_BAK_REF 0x02
#define GTP_RQST_RESET 0x03
#define GTP_RQST_MAIN_CLOCK 0x04
#define GTP_RQST_HOTKNOT_CODE 0x20
#define GTP_RQST_RESPONDED 0x00
#define GTP_RQST_IDLE 0xFF
#define HN_DEVICE_PAIRED 0x80
#define HN_MASTER_DEPARTED 0x40
#define HN_SLAVE_DEPARTED 0x20
#define HN_MASTER_SEND 0x10
#define HN_SLAVE_RECEIVED 0x08
/* ******************** For GT9XXF End ***********************/
/* Register define */
#define GTP_READ_COOR_ADDR 0x814E
#define GTP_REG_SLEEP 0x8040
#define GTP_REG_SENSOR_ID 0x814A
#define GTP_REG_CONFIG_DATA 0x8047
#define GTP_REG_VERSION 0x8140
#define GTP_REG_HW_INFO 0x4220
#define GTP_REG_REFRESH_RATE 0x8056
#define RESOLUTION_LOC 3
#define TRIGGER_LOC 8
#define GTP_DMA_MAX_TRANSACTION_LENGTH 255 /* for DMA mode */
#define GTP_DMA_MAX_I2C_TRANSFER_SIZE \
(GTP_DMA_MAX_TRANSACTION_LENGTH - GTP_ADDR_LENGTH)
#define MAX_TRANSACTION_LENGTH 8
#define TPD_I2C_NUMBER 0
#define I2C_MASTER_CLOCK 300
#define MAX_I2C_TRANSFER_SIZE (MAX_TRANSACTION_LENGTH - GTP_ADDR_LENGTH)
#define TPD_MAX_RESET_COUNT 3
/* #define TPD_CALIBRATION_MATRIX {962,0,0,0,1600,0,0,0} */
#define TPD_CALIBRATION_MATRIX_ROTATION_NORMAL \
{ \
0, 2559, 0, -6557, 0, 5238784, 0, 0 \
}
#define TPD_CALIBRATION_MATRIX_ROTATION_FACTORY \
{ \
0, 2559, 0, -6557, 0, 5238784, 0, 0 \
}
#define TPD_RESET_ISSUE_WORKAROUND
#define TPD_HAVE_CALIBRATION
#define TPD_NO_GPIO
#define TPD_RESET_ISSUE_WORKAROUND
#ifdef TPD_WARP_X
#undef TPD_WARP_X
#define TPD_WARP_X(x_max, x) (x_max - 1 - x)
#else
#define TPD_WARP_X(x_max, x) x
#endif
#ifdef TPD_WARP_Y
#undef TPD_WARP_Y
#define TPD_WARP_Y(y_max, y) (y_max - 1 - y)
#else
#define TPD_WARP_Y(y_max, y) y
#endif
/* Log define */
#define GTP_INFO(fmt, arg...) \
do { \
if (GTP_INFO_ON) \
pr_debug("<<-GTP-INFO->> " fmt "\n", ##arg); \
} while (0)
#define GTP_ERROR(fmt, arg...) pr_info("<<-GTP-ERROR->> " fmt "\n", ##arg)
#define GTP_DEBUG(fmt, arg...) \
do { \
if (GTP_DEBUG_ON) \
pr_debug("<<-GTP-DEBUG->> [%d]" fmt "\n", __LINE__, \
##arg); \
} while (0)
#define GTP_DEBUG_ARRAY(array, num) \
do { \
s32 i; \
u8 *a = array; \
if (GTP_DEBUG_ARRAY_ON) { \
pr_debug("<<-GTP-DEBUG-ARRAY->>\n"); \
for (i = 0; i < (num); i++) { \
pr_debug("%02x ", (a)[i]); \
if ((i + 1) % 10 == 0) \
pr_debug("\n"); \
} \
pr_debug("\n"); \
} \
} while (0)
#define GTP_DEBUG_FUNC() \
do { \
if (GTP_DEBUG_FUNC_ON) \
pr_debug("<<-GTP-FUNC->> Func:%s@Line:%d\n", __func__, \
__LINE__); \
} while (0)
#define GTP_SWAP(x, y) \
do { \
typeof(x) z = x; \
x = y; \
y = z; \
} while (0)
/* ****************************PART4:UPDATE */
/* define******************************* */
/* Error no */
#define ERROR_NO_FILE 2 /* ENOENT */
#define ERROR_FILE_READ 23 /* ENFILE */
#define ERROR_FILE_TYPE 21 /* EISDIR */
#define ERROR_GPIO_REQUEST 4 /* EINTR */
#define ERROR_I2C_TRANSFER 5 /* EIO */
#define ERROR_NO_RESPONSE 16 /* EBUSY */
#define ERROR_TIMEOUT 110 /* ETIMEDOUT */
/* *****************************End of Part III********************************
*/
#endif /* TPD_CUSTOM_GT9XX_H__ */