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,235 @@
#
# GT9157 Touchscreen driver configuration
#
menu "GT9157 Touchscreen Config"
depends on TOUCHSCREEN_MTK_GT9157
config GTP_USE_PINCTRL
bool "GT9157 GPIO use Pinctrl"
default y
help
Say Y here if you want use pinctrl subsystem to operate gpio.
Say N here if you want use libgpio to operate gpio.
Build in 2.x kernel should say N.
Default set to Y
config GTP_FIRMWARE
string "GT9157 firmawre group"
default "firmware1"
config GTP_CONFIG
string "GT9157 config data group"
default "config1"
config GTP_DRIVER_SEND_CFG
bool "GT9157 driver send config"
default y
help
Say Y here if you have GT9 touch panel GTP_DRIVER_SEND_CFG.
When turn this option on, driver will send config group data
to touch IC to set touch IC status.
If unsure, say N.
config GTP_CUSTOM_CFG
bool "GT9157 custom config"
help
Say Y here if you have GT9 touch panel GTP_CUSTOM_CFG.
When turn this option on, you can customize the config group data,
which can send to touch IC to set touch IC status.
If unsure, say N.
config GTP_HAVE_TOUCH_KEY
bool "GT9157 touch key enable"
default y
help
Say Y here if you have GT9 touch panel GTP_HAVE_TOUCH_KEY.
When turn this option on, you can use touch virtual key function,
it will report key event to input subsystem.
If unsure, say N.
config GTP_CHANGE_X2Y
bool "GT9157 X2Y"
help
Say Y here if you have GT9 touch panel GTP_CHANGE_X2Y.
When turn this option on, coordinate x and y will swap,
check the coordinate and see whether you want it.
If unsure, say N.
config GTP_COMPATIBLE_MODE
bool "GT9157 flahless compatible"
help
Say Y here if you have GT9 touch panel GTP_COMPATIBLE_MODE.
When turn this option on, driver will check touch IC type,
and support GT9F wilth old style.
If unsure, say N.
config GTP_WARP_X_ON
bool "GT9157 swap x"
help
Say Y here if you have GT9 touch panel GTP_WARP_X_ON.
When turn this option on, coordinate x will change to (x_max - 1 -x),
check the coordinate and see whether you want it.
If unsure, say N.
config GTP_WARP_Y_ON
bool "GT9157 swap y"
help
Say Y here if you have GT9 touch panel GTP_WARP_Y_ON.
When turn this option on, coordinate y will change to (y_max - 1 -y),
check the coordinate and see whether you want it.
If unsure, say N.
config GTP_GESTURE_WAKEUP
bool "GT9157 gesture wakeup"
help
Say Y here if you have GT9 touch panel GTP_GESTURE_WAKEUP.
When turn this option on, driver will support wakeup by gesture in when
display off.
If unsure, say N.
config GTP_HOTKNOT
bool "GT9157 hotknot"
default y
help
Say Y here if you have GT9 touch panel GTP_HOTKNOT.
When turn this option on, driver will support hotknot function, it can transfer
data by two panels touch each other.
If unsure, say N.
config HOTKNOT_BLOCK_RW
bool "GT9157 hotknot blocking rw"
help
Say Y here if you have GT9 touch panel HOTKNOT_BLOCK_RW.
When turn this option on, driver will support hotknot read and write with block
unit, to improve transfer speed.
If unsure, say N.
config GTP_PROXIMITY
bool "GT9157 proximity"
help
Say Y here if you have GT9 touch panel GTP_PROXIMITY.
When turn this option on, driver will use hwmsonser to check status, to prevent
report uneccesary misoperation to input system.
If unsure, say N.
config GTP_WITH_PEN
bool "GT9157 pen enable"
help
Say Y here if you have GT9 touch panel GTP_WITH_PEN.
When turn this option on, driver will support pen touch function, allow use to
use pen to operate touch panel.
If unsure, say N.
config GTP_AUTO_UPDATE
bool "GT9157 firmware auto update"
help
Say Y here if you have GT9 touch panel GTP_AUTO_UPDATE.
When turn this option on, driver will enable upgrade touch IC function when boot
up, it will cost extra time, which part to upgrade depend on other options.
If unsure, say N.
config GTP_AUTO_UPDATE_CFG
bool "GT9157 config data auto update"
help
Say Y here if you have GT9 touch panel GTP_AUTO_UPDATE_CFG.
When turn this option on, driver will upgrade touch IC config data when boot up,
it will cost extra time.
If unsure, say N.
config GTP_HEADER_FW_UPDATE
bool "GT9157 firmware in header file"
help
Say Y here if you have GT9 touch panel GTP_HEADER_FW_UPDATE.
When turn this option on, driver will upgrade touch IC firmware when boot up,
it will cost extra time.
If unsure, say N.
config GTP_REQUEST_FW_UPDATE
bool "GT9157 firmware in request firmware"
help
Say Y here if you have GT9 touch panel GTP_REQUEST_FW_UPDATE.
When turn this option on, driver will search firmware in data partition,
it will cost extra time.
If unsure, say N.
config GTP_SUPPORT_I2C_DMA
bool "GT9157 support i2c dma"
help
Say Y here if you have GT9 touch panel GTP_SUPPORT_I2C_DMA.
When turn this option on, driver will use i2c dma mode, usually it will have
a better speed.
If unsure, say N.
config GTP_CREATE_WR_NODE
bool "GT9157 create debug node"
help
Say Y here if you have GT9 touch panel GTP_CREATE_WR_NODE.
When turn this option on, driver will create writeable node to let tool debug,
sometimes it is not allowed since it has potential security issue.
If unsure, say N.
config GTP_ESD_PROTECT
bool "GT9157 esd protection"
help
Say Y here if you have GT9 touch panel GTP_ESD_PROTECT.
When turn this option on, driver will enable ESD(Electo-Static discharge) protect,
it will make touch work more stable, but performance may worse.
If unsure, say N.
config GTP_CHARGER_DETECT
bool "GT9157 charger detection"
help
Say Y here if you have GT9 touch panel GTP_CHARGER_DETECT.
When turn this option on, driver detect charge mode periodic.
Usually not neccessay.
If unsure, say N.
config GTP_CHARGER_SWITCH
bool "GT9157 charger detection"
help
Say Y here if you have GT9 touch panel GTP_CHARGER_SWITCH.
When turn this option on, driver can send charge group data to touch IC.
Usually not neccessay.
If unsure, say N.
config GTP_DEBUG_ARRAY_ON
bool "GT9157 debug array"
help
Say Y here if you have GT9 touch panel GTP_DEBUG_ARRAY_ON.
When turn this option on, macro GTP_DEBUG_ARRAY will print array member, otherwise
it will do nothing.
If unsure, say N.
config GTP_DEBUG_FUNC_ON
bool "GT9157 debug func on"
help
Say Y here if you have GT9 touch panel GTP_DEBUG_FUNC_ON.
When turn this option on, macro GTP_DEBUG_FUNC will print function name and line,
otherwise it will do nothing.
If unsure, say N.
config GTP_DEBUG_ON
bool "GT9157 debug on"
help
Say Y here if you have GT9 touch panel GTP_DEBUG_ON.
When turn this option on, macro GTP_DEBUG will print the content string, otherwise
it will do nothing.
If unsure, say N.
config GTP_POWER_CTRL_SLEEP
bool "GT9157 power down when sleeping"
help
Say Y here if you have GT9 touch panel GTP_POWER_CTRL_SLEEP.
When turn this option on, driver will use i2c send data to control touch IC sleep,
otherwise it will use regulator subsystem.
If unsure, say N.
config GTP_HEIGHT_WIDTH_ROTATE
bool "GT9157 rotate height and width"
help
Say Y here if you have GT9 touch panel GTP_HEIGHT_WIDTH_ROTATE.
When turn this option on, driver will rotate the height and
width for some screen, otherwise it will do nothing.
If unsure, say N.
endmenu
@@ -0,0 +1,12 @@
# Linux driver folder
ccflags-y += -I$(srctree)/drivers/input/touchscreen/mediatek/GT9157/
ccflags-y += -I$(srctree)/drivers/input/touchscreen/mediatek/GT9157/include/
ccflags-y += -I$(srctree)/drivers/input/touchscreen/mediatek/
ccflags-y += -I$(srctree)/drivers/misc/mediatek/hwmon/include/
ccflags-y += -I$(srctree)/drivers/misc/mediatek/include/mt-plat/
ccflags-y += -I$(srctree)/drivers/misc/mediatek/include/mt-plat/$(MTK_PLATFORM)/include/
obj-y += gt9xx_driver.o
obj-y += gt9xx_extents.o
obj-y += gt9xx_update.o
obj-y += goodix_tool.o
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,474 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#include "include/tpd_gt9xx_common.h"
#include <asm/ioctl.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/interrupt.h>
#include <linux/kthread.h>
#include <linux/miscdevice.h>
#include <linux/proc_fs.h>
#include <linux/sched.h>
#include <linux/time.h>
#include <linux/uaccess.h>
#include <linux/wait.h>
#ifdef CONFIG_GTP_GESTURE_WAKEUP
#define GESTURE_NODE "goodix_gesture"
#define GTP_REG_WAKEUP_GESTURE 0x814B
#define GTP_REG_WAKEUP_GESTURE_DETAIL 0x9420
#define SETBIT(longlong, bit) (longlong[bit / 8] |= (1 << bit % 8))
#define CLEARBIT(longlong, bit) (longlong[bit / 8] &= (~(1 << bit % 8)))
#define QUERYBIT(longlong, bit) (!!(longlong[bit / 8] & (1 << bit % 8)))
static u8 gestures_flag[32];
struct gesture_data gesture_data;
static struct mutex gesture_data_mutex;
static inline s32 ges_i2c_write_bytes(u16 addr, u8 *buf, s32 len)
{
return i2c_write_bytes(i2c_client_point, addr, buf, len);
}
static inline s32 ges_i2c_read_bytes(u16 addr, u8 *buf, s32 len)
{
return i2c_read_bytes(i2c_client_point, addr, buf, len);
}
static ssize_t gtp_gesture_data_read(struct file *file, char __user *page,
size_t size, loff_t *ppos)
{
s32 ret = -1;
GTP_DEBUG("visit %s. ppos:%d", __func__, (int)*ppos);
if (*ppos)
return 0;
if (size == 4) {
ret = copy_to_user(((u8 __user *)page), "GT1X", 4);
return 4;
}
ret = simple_read_from_buffer(page, size, ppos, &gesture_data,
sizeof(gesture_data));
GTP_DEBUG("Got the gesture data.");
return ret;
}
static ssize_t gtp_gesture_data_write(struct file *filp,
const char __user *buff, size_t len,
loff_t *off)
{
s32 ret = 0;
ret = copy_from_user(&gesture_data.enabled, buff, 1);
if (ret) {
GTP_ERROR("copy_from_user failed.");
return -EPERM;
}
GTP_DEBUG("gesture enabled:%x, ret:%d", gesture_data.enabled, ret);
return len;
}
s8 gtp_enter_doze(void)
{
int ret = -1;
s8 retry = 0;
u8 i2c_control_buf[1] = {8};
GTP_DEBUG("Entering doze mode.");
while (retry++ < 5) {
ret = ges_i2c_write_bytes(0x8046, i2c_control_buf, 1);
if (ret < 0) {
GTP_DEBUG("failed to set doze flag into 0x8046, %d",
retry);
continue;
}
ret = ges_i2c_write_bytes(0x8040, i2c_control_buf, 1);
if (!ret) {
gesture_data.doze_status = DOZE_ENABLED;
GTP_INFO("Gesture mode enabled.");
return ret;
}
msleep(20);
}
GTP_ERROR("GTP send doze cmd failed.");
return ret;
}
s32 gesture_event_handler(struct input_dev *dev)
{
u8 doze_buf[4] = {0};
unsigned int key_code;
s32 ret = 0;
int len, extra_len;
if (gesture_data.doze_status == DOZE_ENABLED) {
ret = ges_i2c_read_bytes(GTP_REG_WAKEUP_GESTURE, doze_buf, 4);
GTP_DEBUG("0x%x = 0x%02X,0x%02X,0x%02X,0x%02X",
GTP_REG_WAKEUP_GESTURE, doze_buf[0], doze_buf[1],
doze_buf[2], doze_buf[3]);
/*GTP_DEBUG("0x%x = 0x%02X,0x%02X", GTP_REG_WAKEUP_GESTURE, */
/* doze_buf[0], doze_buf[1]); */
if (ret == 0 && doze_buf[0] != 0) {
if (!QUERYBIT(gestures_flag, doze_buf[0])) {
GTP_INFO(
"Sorry, this gesture has been disabled.");
doze_buf[0] = 0x00;
ges_i2c_write_bytes(GTP_REG_WAKEUP_GESTURE,
doze_buf, 1);
gtp_enter_doze();
return 0;
}
mutex_lock(&gesture_data_mutex);
len = doze_buf[1] & 0x7F;
if (len > GESTURE_MAX_POINT_COUNT) {
GTP_ERROR(
"Gesture contain too many points!(%d)",
len);
len = GESTURE_MAX_POINT_COUNT;
}
if (len > 0) {
ret = ges_i2c_read_bytes(
GTP_REG_WAKEUP_GESTURE_DETAIL,
&gesture_data.data[4], len * 4);
if (ret < 0) {
GTP_DEBUG("Read gesture data failed.");
mutex_unlock(&gesture_data_mutex);
return 0;
}
}
extra_len = doze_buf[1] & 0x80 ? doze_buf[3] : 0;
if (extra_len > 80) {
GTP_ERROR(
"Gesture contain too many extra data!(%d)",
extra_len);
extra_len = 80;
}
if (extra_len > 0) {
ret = ges_i2c_read_bytes(
GTP_REG_WAKEUP_GESTURE + 4,
&gesture_data.data[4 + len * 4],
extra_len);
if (ret < 0) {
GTP_DEBUG(
"Read extra gesture data failed.");
mutex_unlock(&gesture_data_mutex);
return 0;
}
}
doze_buf[2] &= ~0x30;
doze_buf[2] |= extra_len > 0 ? 0x20 : 0x10;
gesture_data.data[0] = doze_buf[0]; /* gesture type */
gesture_data.data[1] = len; /* gesture points number */
gesture_data.data[2] = doze_buf[2];
gesture_data.data[3] = extra_len;
mutex_unlock(&gesture_data_mutex);
key_code = doze_buf[0] < 16 ? KEY_F3 : KEY_F2;
GTP_DEBUG("Gesture: 0x%02X, points: %d", doze_buf[0],
doze_buf[1]);
doze_buf[0] = 0;
ges_i2c_write_bytes(GTP_REG_WAKEUP_GESTURE, doze_buf,
1);
input_report_key(dev, key_code, 1);
input_sync(dev);
input_report_key(dev, key_code, 0);
input_sync(dev);
return 2; /* doze enabled and get valid gesture data */
}
return 1; /* doze enabled, but no invalid gesutre data */
}
return 0; /* doze not enabled */
}
void gesture_clear_wakeup_data(void)
{
mutex_lock(&gesture_data_mutex);
memset(gesture_data.data, 0, 4);
mutex_unlock(&gesture_data_mutex);
}
#define GOODIX_MAGIC_NUMBER 'G'
#define NEGLECT_SIZE_MASK (~(_IOC_SIZEMASK << _IOC_SIZESHIFT))
#define GESTURE_ENABLE_TOTALLY _IO(GOODIX_MAGIC_NUMBER, 1)
#define GESTURE_DISABLE_TOTALLY _IO(GOODIX_MAGIC_NUMBER, 2)
#define GESTURE_ENABLE_PARTLY _IO(GOODIX_MAGIC_NUMBER, 3)
#define GESTURE_DISABLE_PARTLY _IO(GOODIX_MAGIC_NUMBER, 4)
#define GESTURE_DATA_OBTAIN \
(_IOR(GOODIX_MAGIC_NUMBER, 6, u8) & NEGLECT_SIZE_MASK)
#define GESTURE_DATA_ERASE _IO(GOODIX_MAGIC_NUMBER, 7)
#define IO_IIC_READ (_IOR(GOODIX_MAGIC_NUMBER, 100, u8) & NEGLECT_SIZE_MASK)
#define IO_IIC_WRITE (_IOW(GOODIX_MAGIC_NUMBER, 101, u8) & NEGLECT_SIZE_MASK)
#define IO_RESET_GUITAR _IO(GOODIX_MAGIC_NUMBER, 102)
#define IO_DISABLE_IRQ _IO(GOODIX_MAGIC_NUMBER, 103)
#define IO_ENABLE_IRQ _IO(GOODIX_MAGIC_NUMBER, 104)
#define IO_GET_VERSION (_IOR(GOODIX_MAGIC_NUMBER, 110, u8) & NEGLECT_SIZE_MASK)
#define IO_PRINT (_IOW(GOODIX_MAGIC_NUMBER, 111, u8) & NEGLECT_SIZE_MASK)
#define IO_VERSION "V1.0-20141015"
#define CMD_HEAD_LENGTH 20
static s32 io_iic_read(u8 *data, void __user *arg)
{
s32 err = -1;
s32 data_length = 0;
u16 addr = 0;
err = copy_from_user(data, arg, CMD_HEAD_LENGTH);
if (err) {
GTP_DEBUG("Can't access the memory.");
return err;
}
addr = data[0] << 8 | data[1];
data_length = data[2] << 8 | data[3];
err = ges_i2c_read_bytes(addr, &data[CMD_HEAD_LENGTH], data_length);
if (!err) {
err = copy_to_user(&((u8 __user *)arg)[CMD_HEAD_LENGTH],
&data[CMD_HEAD_LENGTH], data_length);
if (err) {
GTP_ERROR(
"ERROR when copy to user.[addr: %04x], [read length:%d]",
addr, data_length);
return err;
}
err = CMD_HEAD_LENGTH + data_length;
}
GTP_DEBUG("IIC_READ.addr:0x%4x, length:%d, ret:%d", addr, data_length,
err);
GTP_DEBUG_ARRAY((&data[CMD_HEAD_LENGTH]), data_length);
return err;
}
static s32 io_iic_write(u8 *data)
{
s32 err = -1;
s32 data_length = 0;
u16 addr = 0;
addr = data[0] << 8 | data[1];
data_length = data[2] << 8 | data[3];
err = ges_i2c_write_bytes(addr, &data[CMD_HEAD_LENGTH], data_length);
if (!err)
err = CMD_HEAD_LENGTH + data_length;
GTP_DEBUG("IIC_WRITE.addr:0x%4x, length:%d, ret:%d", addr, data_length,
err);
GTP_DEBUG_ARRAY((&data[CMD_HEAD_LENGTH]), data_length);
return err;
}
static long gtp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
u32 value = 0;
s32 ret = 0;
u8 *data = NULL;
if (_IOC_DIR(cmd)) {
s32 err = -1;
s32 data_length = _IOC_SIZE(cmd);
data = kzalloc(data_length, GFP_KERNEL);
memset(data, 0, data_length);
if (_IOC_DIR(cmd) & _IOC_WRITE) {
err = copy_from_user(data, (void __user *)arg,
data_length);
if (err) {
GTP_DEBUG("Can't access the memory.");
kfree(data);
return -1;
}
}
} else {
value = (u32)arg;
}
switch (cmd & NEGLECT_SIZE_MASK) {
case IO_GET_VERSION:
if ((u8 __user *)arg) {
ret = copy_to_user(((u8 __user *)arg), IO_VERSION,
sizeof(IO_VERSION));
if (!ret)
ret = sizeof(IO_VERSION);
GTP_INFO("%s", IO_VERSION);
}
break;
case IO_IIC_READ:
ret = io_iic_read(data, (void __user *)arg);
break;
case IO_IIC_WRITE:
ret = io_iic_write(data);
break;
case IO_RESET_GUITAR:
gtp_reset_guitar(i2c_client_point, 10);
break;
case IO_DISABLE_IRQ: {
gtp_irq_disable();
#ifdef CONFIG_GTP_ESD_PROTECT
gtp_esd_switch(i2c_client_point, SWITCH_OFF);
#endif
break;
}
case IO_ENABLE_IRQ: {
gtp_irq_enable();
}
#ifdef CONFIG_GTP_ESD_PROTECT
gtp_esd_switch(i2c_client_point, SWITCH_ON);
#endif
break;
case IO_PRINT:
if (data)
GTP_INFO("%s", (char *)data);
break;
case GESTURE_ENABLE_TOTALLY:
GTP_DEBUG("ENABLE_GESTURE_TOTALLY");
gesture_data.enabled = 1;
break;
case GESTURE_DISABLE_TOTALLY:
GTP_DEBUG("DISABLE_GESTURE_TOTALLY");
gesture_data.enabled = 0;
break;
case GESTURE_ENABLE_PARTLY:
SETBIT(gestures_flag, (u8)value);
gesture_data.enabled = 1;
GTP_DEBUG(
"ENABLE_GESTURE_PARTLY, gesture = 0x%02X, gesture_data.enabled = %d",
value, gesture_data.enabled);
break;
case GESTURE_DISABLE_PARTLY:
CLEARBIT(gestures_flag, (u8)value);
GTP_DEBUG(
"DISABLE_GESTURE_PARTLY, gesture = 0x%02X, gesture_data.enabled = %d",
value, gesture_data.enabled);
break;
case GESTURE_DATA_OBTAIN:
GTP_DEBUG("OBTAIN_GESTURE_DATA");
mutex_lock(&gesture_data_mutex);
if (gesture_data.data[1] > GESTURE_MAX_POINT_COUNT)
gesture_data.data[1] = GESTURE_MAX_POINT_COUNT;
if (gesture_data.data[3] > 80)
gesture_data.data[3] = 80;
ret = copy_to_user(((u8 __user *)arg), &gesture_data.data,
4 + gesture_data.data[1] * 4 +
gesture_data.data[3]);
mutex_unlock(&gesture_data_mutex);
if (ret)
GTP_ERROR("ERROR when copy gesture data to user.");
else
ret = 4 + gesture_data.data[1] * 4 +
gesture_data.data[3];
break;
case GESTURE_DATA_ERASE:
GTP_DEBUG("ERASE_GESTURE_DATA");
gesture_clear_wakeup_data();
break;
default:
GTP_INFO("Unknown cmd.");
ret = -1;
break;
}
if (data != NULL)
kfree(data);
return ret;
}
#ifdef CONFIG_COMPAT
static long gtp_compat_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
void __user *arg32 = compat_ptr(arg);
if (!file->f_op || !file->f_op->unlocked_ioctl)
return -ENOMEM;
return file->f_op->unlocked_ioctl(file, cmd, (unsigned long)arg32);
}
#endif
static int gtp_gesture_open(struct inode *node, struct file *flip)
{
GTP_DEBUG("gesture node is opened.");
return 0;
}
static int gtp_gesture_release(struct inode *node, struct file *filp)
{
GTP_DEBUG("gesture node is closed.");
return 0;
}
static const struct file_operations gtp_fops = {
.owner = THIS_MODULE,
.open = gtp_gesture_open,
.release = gtp_gesture_release,
.read = gtp_gesture_data_read,
.write = gtp_gesture_data_write,
.unlocked_ioctl = gtp_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = gtp_compat_ioctl,
#endif
};
s32 gtp_extents_init(void)
{
struct proc_dir_entry *proc_entry = NULL;
mutex_init(&gesture_data_mutex);
memset(gestures_flag, 0, sizeof(gestures_flag));
memset((u8 *)&gesture_data, 0, sizeof(struct gesture_data));
proc_entry = proc_create(GESTURE_NODE, 0444, NULL, &gtp_fops);
if (proc_entry == NULL) {
GTP_ERROR("Couldn't create proc entry[GESTURE_NODE]!");
return -1;
}
return 0;
}
void gtp_extents_exit(void)
{
remove_proc_entry(GESTURE_NODE, NULL);
}
#endif /* GTP_GESTURE_WAKEUP */
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,96 @@
/* 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. */
#define CTP_CFG_GROUP0 \
{ \
0x48, 0xD0, 0x02, 0x00, 0x05, 0x05, 0xB4, 0xD2, 0x01, 0xC8, \
0x23, 0x0F, 0x55, 0x41, 0x03, 0x05, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x0A, 0x16, 0x16, 0x20, 0x14, 0x8A, \
0x2B, 0x0C, 0x71, 0x73, 0xB2, 0x04, 0xFF, 0xFC, 0x00, \
0x64, 0x33, 0x11, 0x00, 0x80, 0x00, 0x00, 0x14, 0x19, \
0x11, 0x51, 0x25, 0x12, 0x5A, 0x46, 0xAA, 0x94, 0xD5, \
0x95, 0x00, 0x00, 0x14, 0x04, 0x85, 0x4C, 0x00, 0x81, \
0x5B, 0x00, 0x80, 0x6D, 0x00, 0x7F, 0x82, 0x00, 0x80, \
0x9C, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, \
0x0C, 0x00, 0x00, 0x1E, 0x46, 0x28, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x18, 0x16, 0x14, 0x12, 0x10, 0x0E, \
0x0C, 0x0A, 0x08, 0x06, 0x04, 0x02, 0xFF, 0xFF, 0x00, \
0x03, 0x14, 0x19, 0x04, 0x04, 0x21, 0x43, 0xB8, 0x0F, \
0x10, 0x0A, 0x19, 0x2A, 0x40, 0x04, 0x1F, 0x1E, 0x20, \
0x1D, 0x21, 0x1C, 0x22, 0x18, 0x24, 0x16, 0x26, 0x0A, \
0x00, 0x0C, 0x02, 0x0F, 0x04, 0x10, 0x06, 0x12, 0x08, \
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 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, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, \
0x7D, 0x01 \
}
#define GTP_CFG_GROUP0_CHARGER \
{ \
}
/* TODO puts your group2 config info here,if need. */
#define CTP_CFG_GROUP1 \
{ \
}
/* TODO puts your group2 config info here,if need. */
#define GTP_CFG_GROUP1_CHARGER \
{ \
}
/* TODO puts your group3 config info here,if need. */
#define CTP_CFG_GROUP2 \
{ \
}
/* TODO puts your group3 config info here,if need. */
#define GTP_CFG_GROUP2_CHARGER \
{ \
}
/* TODO: define your config for Sensor_ID == 3 here, if needed */
#define CTP_CFG_GROUP3 \
{ \
}
/* TODO puts your group3 config info here,if need. */
#define GTP_CFG_GROUP3_CHARGER \
{ \
}
/* TODO: define your config for Sensor_ID == 4 here, if needed */
#define CTP_CFG_GROUP4 \
{ \
}
/* TODO puts your group4 config info here,if need. */
#define GTP_CFG_GROUP4_CHARGER \
{ \
}
/* TODO: define your config for Sensor_ID == 5 here, if needed */
#define CTP_CFG_GROUP5 \
{ \
}
/* TODO puts your group5 config info here,if need. */
#define GTP_CFG_GROUP5_CHARGER \
{ \
}
#endif /* _GT1X_CONFIG_H_ */
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,370 @@
/* 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/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>
/* Pre-defined definition */
#define UPDATE_FUNCTIONS
#define GTP_CONFIG_MIN_LENGTH 186
#define GTP_CONFIG_MAX_LENGTH 240
#ifdef CONFIG_GTP_DEBUG_ON
#define GTP_DEBUG_ON 1
#else
#define GTP_DEBUG_ON 0
#endif
#ifdef CONFIG_GTP_DEBUG_ARRAY_ON
#define GTP_DEBUG_ARRAY_ON 1
#else
#define GTP_DEBUG_ARRAY_ON 0
#endif
#ifdef CONFIG_GTP_DEBUG_FUNC_ON
#define GTP_DEBUG_FUNC_ON 1
#else
#define GTP_DEBUG_FUNC_ON 0
#endif
#define CFG_GROUP_LEN(p_cfg_grp) (ARRAY_SIZE(p_cfg_grp) / sizeof(p_cfg_grp[0]))
#if (defined(CONFIG_GTP_ESD_PROTECT) || defined(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 1920
#define GTP_MAX_WIDTH 1080
#define GTP_INT_TRIGGER 0 /* 0:Rising 1:Falling */
#else
#ifndef CONFIG_GTP_HEIGHT_WIDTH_ROTATE
#define GTP_MAX_HEIGHT 1280
#define GTP_MAX_WIDTH 800
#else
#define GTP_MAX_HEIGHT 800
#define GTP_MAX_WIDTH 1280
#endif
#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
#define GTP_RST_GPIO 0
#define GTP_IRQ_GPIO 1
/* STEP_4(optional):If this project have touch key,Set touch key config. */
#ifdef CONFIG_GTP_HAVE_TOUCH_KEY
#define TPD_KEY_COUNT 4
#define TPD_KEYS \
{ \
KEY_BACK, KEY_HOMEPAGE, KEY_MENU, KEY_SEARCH \
}
#define GTP_KEY_TAB \
{ \
KEY_MENU, KEY_HOMEPAGE, KEY_BACK, KEY_SEND \
}
#endif
/* ***************************PART3:OTHER */
/* define********************************* */
#define GTP_DRIVER_VERSION "V2.6<2016/07/28>"
#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 ***********************/
#if defined(CONFIG_GTP_COMPATIBLE_MODE) || defined(CONFIG_GTP_HOTKNOT)
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_RESET_ISSUE_WORKAROUND
#define TPD_HAVE_CALIBRATION
#define TPD_NO_GPIO
#define TPD_RESET_ISSUE_WORKAROUND
#ifdef CONFIG_GTP_WARP_X_ON
#define TPD_WARP_X(x_max, x) (x_max - 1 - x)
#else
#define TPD_WARP_X(x_max, x) x
#endif
#ifdef CONFIG_GTP_WARP_Y_ON
#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...) pr_info("<<-GTP-INFO->> " fmt "\n", ##arg)
#define GTP_ERROR(fmt, arg...) pr_debug("<<-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 */
#define UPDATE_FUNCTIONS
extern u16 show_len;
extern u16 total_len;
extern u8 gtp_rawdiff_mode;
extern u8 gtp_loading_fw;
extern int tpd_halt;
extern s32 gtp_init_panel(void *v_client);
extern void gtp_reset_guitar(struct i2c_client *client, s32 ms);
extern void gtp_int_sync(s32 ms);
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);
extern s32 gtp_i2c_read_dbl_check(struct i2c_client *client, u16 addr,
u8 *rxbuf, int len);
extern void gtp_gpio_output(int gpio_type, int level);
extern void gtp_gpio_input(int gpio_type);
extern void gtp_irq_enable(void);
extern void gtp_irq_disable(void);
extern struct i2c_client *i2c_client_point;
#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 u8 gtp_updating_fw;
#ifdef CONFIG_GTP_HOTKNOT
u8 *gup_load_calibration_from_file(char *filepath);
s32 gup_load_calibration(u8 *firmware, s32 length, u8 need_check);
extern s32 gup_load_hotknot_fw(void);
extern s32 gup_load_authorization_fw(void);
extern s32 gup_recovery_touch(void);
extern s32 gup_load_touch_fw(char *filepath);
extern u8 gtp_hotknot_enabled;
extern u8 wait_hotknot_state;
extern u8 got_hotknot_state;
extern u8 got_hotknot_extra_state;
extern u8 hotknot_paired_flag;
extern wait_queue_head_t bp_waiter;
#endif
#ifdef CONFIG_GTP_ESD_PROTECT
extern void gtp_esd_switch(struct i2c_client *client, s32 on);
#endif
extern struct tpd_device *tpd;
#ifdef VELOCITY_CUSTOM
extern int tpd_v_magnify_x;
extern int tpd_v_magnify_y;
#endif
#ifdef CONFIG_GTP_SUPPORT_I2C_DMA
s32 i2c_dma_write(struct i2c_client *client, u16 addr, u8 *txbuf, s32 len);
s32 i2c_dma_read(struct i2c_client *client, u16 addr, u8 *rxbuf, s32 len);
#endif
#ifdef CONFIG_GTP_CHARGER_DETECT
extern bool upmu_is_chr_det(void);
extern bool upmu_get_pchr_chrdet(void);
#endif
#ifdef CONFIG_GTP_CREATE_WR_NODE
extern s32 init_wr_node(struct i2c_client *);
extern void uninit_wr_node(void);
#endif
extern u8 gup_check_fs_mounted(char *path_name);
extern u8 gup_clk_calibration(void);
extern s32 gup_fw_download_proc(void *dir, u8 dwn_mode);
void gtp_get_chip_type(struct i2c_client *client);
extern u8 cfg_len;
extern u8 gtp_resetting;
#if defined(CONFIG_GTP_COMPATIBLE_MODE) || defined(CONFIG_GTP_HOTKNOT)
extern u8 gtp_fw_startup(struct i2c_client *client);
extern unsigned char gtp_touch_fw[];
extern enum chip_type_t gtp_chip_type;
#endif
#ifdef CONFIG_GTP_COMPATIBLE_MODE
extern u8 rqst_processing;
s32 gup_load_touch_fw(char *filepath);
s32 gup_fw_download_proc(void *dir, u8 dwn_mode);
#endif
#ifdef CONFIG_GTP_GESTURE_WAKEUP
#define GESTURE_MAX_POINT_COUNT 64
enum doze_t {
DOZE_DISABLED = 0,
DOZE_ENABLED = 1,
DOZE_WAKEUP = 2,
};
#pragma pack(1)
struct gesture_data {
int enabled;
enum doze_t doze_status;
u8 ic_msg[6]; /*from the first byte */
u8 gestures[4];
u8 data[3 + GESTURE_MAX_POINT_COUNT * 4 +
80]; /*80 bytes for extra data */
};
#pragma pack()
extern struct gesture_data gesture_data;
extern s32 gesture_event_handler(struct input_dev *dev);
extern s8 gtp_enter_doze(void);
extern s32 gtp_extents_init(void);
extern void gtp_extents_exit(void);
#endif
/*****************************End of Part III********************************/
#endif /* TPD_CUSTOM_GT9XX_H__ */