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,58 @@
BUILD_INFAE := spi
BUILD_PLATFORM := mtk
BUILD_MODULE := n
ccflags-y += -Wall
ifeq ($(BUILD_PLATFORM),mtk)
platform=ilitek_plat_mtk
ccflags-y += -I$(srctree)/drivers/spi/mediatek/mt6797/
ccflags-y += -I$(srctree)/drivers/input/touchscreen/ILITEK_V2/
ccflags-y += -I$(srctree)/drivers/input/touchscreen/ILITEK_V2/firmware/
ccflags-y += -I$(srctree)/drivers/input/touchscreen/mediatek/
ccflags-y += -I$(srctree)/drivers/misc/mediatek/include/mt-plat/
ccflags-y += -I$(srctree)/drivers/misc/mediatek/include/mt-plat/$(MTK_PLATFORM)/include/
endif
ifeq ($(BUILD_PLATFORM),qcom)
platform=ilitek_plat_qcom
ccflags-y += -I$(srctree)/drivers/input/touchscreen/ILITEK_V2/
ccflags-y += -I$(srctree)/drivers/input/touchscreen/ILITEK_V2/firmware/
endif
ifeq ($(BUILD_INFAE),i2c)
interface=ilitek_i2c
fwupdate=ilitek_flash
endif
ifeq ($(BUILD_INFAE),spi)
interface=ilitek_spi
fwupdate=ilitek_hostdl
endif
ifeq ($(BUILD_MODULE),n)
obj-y += ilitek_main.o \
$(interface).o \
$(platform).o \
ilitek_ic.o \
ilitek_touch.o \
$(fwupdate).o \
ilitek_node.o \
tpd_control.o \
tpd_button.o \
tpd_debug.o \
tpd_default.o \
tpd_misc.o \
tpd_setting.o
else
obj-m += ilitek.o
ilitek-y := ilitek_main.o \
$(interface).o \
$(platform).o \
ilitek_ic.o \
ilitek_touch.o \
ilitek_mp.o \
$(fwupdate).o \
ilitek_node.o
endif
@@ -0,0 +1,91 @@
/*
* ILITEK Touch IC driver
*
* Copyright (C) 2011 ILI Technology Corporation.
*
* Author: Dicky Chiang <dicky_chiang@ilitek.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __ILITEK_FW_H
#define __ILITEK_FW_H
/* define names and paths for the variety of tp modules */
#define DEF_INI_NAME_PATH "/sdcard/mp.ini"
#define DEF_FW_FILP_PATH "/sdcard/ILITEK_FW"
#define DEF_INI_REQUEST_PATH "mp.ini"
#define DEF_FW_REQUEST_PATH "ILITEK_FW"
static unsigned char CTPM_FW_DEF[] = {
#include "9881H_MTK_90Hz_V0x00.0x00_AP_0x01_MP_0x01_SPI_SLAVE_20200818.ili"
};
#define CSOT_INI_NAME_PATH "/sdcard/mp_csot.ini"
#define CSOT_FW_FILP_PATH "/sdcard/ILITEK_FW_CSOT"
#define CSOT_INI_REQUEST_PATH "mp_csot.ini"
#define CSOT_FW_REQUEST_PATH "ILITEK_FW_CSOT"
static unsigned char CTPM_FW_CSOT[] = {
0xFF,
};
#define AUO_INI_NAME_PATH "/sdcard/mp_auo.ini"
#define AUO_FW_FILP_PATH "/sdcard/ILITEK_FW_AUO"
#define AUO_INI_REQUEST_PATH "mp_auo.ini"
#define AUO_FW_REQUEST_PATH "ILITEK_FW_AUO"
static unsigned char CTPM_FW_AUO[] = {
0xFF,
};
#define BOE_INI_NAME_PATH "/sdcard/mp_boe.ini"
#define BOE_FW_FILP_PATH "/sdcard/ILITEK_FW_BOE"
#define BOE_INI_REQUEST_PATH "mp_boe.ini"
#define BOE_FW_REQUEST_PATH "ILITEK_FW_BOE"
static unsigned char CTPM_FW_BOE[] = {
0xFF,
};
#define INX_INI_NAME_PATH "/sdcard/mp_inx.ini"
#define INX_FW_FILP_PATH "/sdcard/ILITEK_FW_INX"
#define INX_INI_REQUEST_PATH "mp_inx.ini"
#define INX_FW_REQUEST_PATH "ILITEK_FW_INX"
static unsigned char CTPM_FW_INX[] = {
0xFF,
};
#define DJ_INI_NAME_PATH "/sdcard/mp_dj.ini"
#define DJ_FW_FILP_PATH "/sdcard/ILITEK_FW_DJ"
#define DJ_INI_REQUEST_PATH "mp_dj.ini"
#define DJ_FW_REQUEST_PATH "ILITEK_FW_DJ"
static unsigned char CTPM_FW_DJ[] = {
0xFF,
};
#define TXD_INI_NAME_PATH "/sdcard/mp_txd.ini"
#define TXD_FW_FILP_PATH "/sdcard/ILITEK_FW_TXD"
#define TXD_INI_REQUEST_PATH "mp_txd.ini"
#define TXD_FW_REQUEST_PATH "ILITEK_FW_TXD"
static unsigned char CTPM_FW_TXD[] = {
0xFF,
};
#define TM_INI_NAME_PATH "/sdcard/mp_tm.ini"
#define TM_FW_FILP_PATH "/sdcard/ILITEK_FW_TM"
#define TM_INI_REQUEST_PATH "mp_tm.ini"
#define TM_FW_REQUEST_PATH "ILITEK_FW_TM"
static unsigned char CTPM_FW_TM[] = {
0xFF,
};
#endif
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,963 @@
/*
* ILITEK Touch IC driver
*
* Copyright (C) 2011 ILI Technology Corporation.
*
* Author: Dicky Chiang <dicky_chiang@ilitek.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "ilitek.h"
#define UPDATE_PASS 0
#define UPDATE_FAIL -1
#define TIMEOUT_SECTOR 500
#define TIMEOUT_PAGE 3500
#define TIMEOUT_PROGRAM 10
static struct touch_fw_data {
u8 block_number;
u32 start_addr;
u32 end_addr;
u32 new_fw_cb;
u32 dl_ges_sa;
int delay_after_upgrade;
bool isCRC;
bool isboot;
int hex_tag;
} tfd;
static struct flash_block_info {
char *name;
u32 start;
u32 end;
u32 len;
u32 mem_start;
u32 fix_mem_start;
u8 mode;
} fbi[FW_BLOCK_INFO_NUM];
u8 *pfw;
u8 *CTPM_FW;
static u32 HexToDec(char *phex, s32 len)
{
u32 ret = 0, temp = 0, i;
s32 shift = (len - 1) * 4;
for (i = 0; i < len; shift -= 4, i++) {
if ((phex[i] >= '0') && (phex[i] <= '9'))
temp = phex[i] - '0';
else if ((phex[i] >= 'a') && (phex[i] <= 'f'))
temp = (phex[i] - 'a') + 10;
else if ((phex[i] >= 'A') && (phex[i] <= 'F'))
temp = (phex[i] - 'A') + 10;
ret |= (temp << shift);
}
return ret;
}
static int CalculateCRC32(u32 start_addr, u32 len, u8 *pfw)
{
int i = 0, j = 0;
int crc_poly = 0x04C11DB7;
int tmp_crc = 0xFFFFFFFF;
for (i = start_addr; i < start_addr + len; i++) {
tmp_crc ^= (pfw[i] << 24);
for (j = 0; j < 8; j++) {
if ((tmp_crc & 0x80000000) != 0)
tmp_crc = tmp_crc << 1 ^ crc_poly;
else
tmp_crc = tmp_crc << 1;
}
}
return tmp_crc;
}
static int host_download_dma_check(u32 start_addr, u32 block_size)
{
int count = 50;
u32 busy = 0;
u8 dma_int_bit = 0;
u32 pid = idev->chip->pid;
if (((pid>>8) == ILI9881H) || ((pid>>8) == ILI7807G) || ((pid>>8) == ILI7807R))
dma_int_bit = 1;
else
dma_int_bit = 2;
/* dma1 src1 address */
if (ilitek_ice_mode_write(0x072104, start_addr, 4) < 0)
ipio_err("Write dma1 src1 address failed\n");
/* dma1 src1 format */
if (ilitek_ice_mode_write(0x072108, 0x80000001, 4) < 0)
ipio_err("Write dma1 src1 format failed\n");
/* dma1 dest address */
if (ilitek_ice_mode_write(0x072114, 0x00030000, 4) < 0)
ipio_err("Write dma1 src1 format failed\n");
/* dma1 dest format */
if (ilitek_ice_mode_write(0x072118, 0x80000000, 4) < 0)
ipio_err("Write dma1 dest format failed\n");
/* Block size*/
if (ilitek_ice_mode_write(0x07211C, block_size, 4) < 0)
ipio_err("Write block size (%d) failed\n", block_size);
idev->chip->hd_dma_check_crc_off();
/* Dma1 stop */
if (ilitek_ice_mode_write(0x072100, 0x02000000, 4) < 0)
ipio_err("Write dma1 stop failed\n");
/* crc on */
if (ilitek_ice_mode_write(0x041016, 0x01, 1) < 0)
ipio_err("Write crc on failed\n");
/* clr int */
if (ilitek_ice_mode_write(0x048006, dma_int_bit, 1) < 0)
ipio_err("Write clr int failed\n");
/* Dma1 start */
if (ilitek_ice_mode_write(0x072100, 0x01000000, 4) < 0)
ipio_err("Write dma1 start failed\n");
/* Polling BIT0 */
while (count > 0) {
mdelay(1);
if (ilitek_ice_mode_read(0x048006, &busy, sizeof(u8)) < 0)
ipio_err("Read busy error\n");
ipio_debug("busy = %x\n", busy);
if ((busy & dma_int_bit) == dma_int_bit)
break;
count--;
}
if (count <= 0) {
ipio_err("BIT0 is busy\n");
return -1;
}
if (ilitek_ice_mode_read(0x04101C, &busy, sizeof(u32)) < 0) {
ipio_err("Read dma crc error\n");
return -1;
}
return busy;
}
static int ilitek_tddi_fw_iram_read(u8 *buf, u32 start, int len)
{
int limit = SPI_RX_BUF_SIZE;
int addr = 0, loop = 0, tmp_len = len, cnt = 0;
u8 cmd[4] = {0};
if (!buf) {
ipio_err("buf is null\n");
return -ENOMEM;
}
if (len % limit)
loop = (len / limit) + 1;
else
loop = len / limit;
for (cnt = 0, addr = start; cnt < loop; cnt++, addr += limit) {
if (tmp_len > limit)
tmp_len = limit;
cmd[0] = 0x25;
cmd[3] = (char)((addr & 0x00FF0000) >> 16);
cmd[2] = (char)((addr & 0x0000FF00) >> 8);
cmd[1] = (char)((addr & 0x000000FF));
if (idev->write(cmd, 4) < 0) {
ipio_err("Failed to write iram data\n");
return -ENODEV;
}
if (idev->read(buf + cnt * limit, tmp_len) < 0) {
ipio_err("Failed to Read iram data\n");
return -ENODEV;
}
tmp_len = len - cnt * limit;
idev->fw_update_stat = ((len - tmp_len) * 100) / len;
ipio_info("Reading iram data .... %d%c", idev->fw_update_stat, '%');
}
return 0;
}
int ilitek_fw_dump_iram_data(u32 start, u32 end, bool save, bool mcu)
{
struct file *f = NULL;
mm_segment_t old_fs;
loff_t pos = 0;
int wdt, i, ret = 0;
int len, tmp = ipio_debug_level;
bool ice = atomic_read(&idev->ice_stat);
if (!ice) {
ret = ilitek_ice_mode_ctrl(ENABLE, mcu);
if (ret < 0) {
ipio_err("Enable ice mode failed\n");
return ret;
}
}
wdt = ilitek_tddi_ic_watch_dog_ctrl(ILI_READ, DISABLE);
if (wdt) {
ret = ilitek_tddi_ic_watch_dog_ctrl(ILI_WRITE, DISABLE);
if (ret < 0) {
ipio_err("Disable WDT failed during dumping iram\n");
goto out;
}
}
len = end - start + 1;
if (len >= MAX_HEX_FILE_SIZE) {
ipio_err("len is larger than buffer, abort\n");
ret = -EINVAL;
goto out;
}
for (i = 0; i < MAX_HEX_FILE_SIZE; i++)
idev->update_buf[i] = 0xFF;
ret = ilitek_tddi_fw_iram_read(idev->update_buf, start, len);
if (ret < 0) {
ipio_err("Read IRAM data failed\n");
goto out;
}
if (save) {
f = filp_open(DUMP_IRAM_PATH, O_WRONLY | O_CREAT | O_TRUNC, 644);
if (ERR_ALLOC_MEM(f)) {
ipio_err("Failed to open the file at %ld.\n", PTR_ERR(f));
ret = -ENOMEM;
goto out;
}
old_fs = get_fs();
set_fs(get_ds());
set_fs(KERNEL_DS);
pos = 0;
vfs_write(f, idev->update_buf, len, &pos);
set_fs(old_fs);
filp_close(f, NULL);
ipio_info("Save iram data to %s\n", DUMP_IRAM_PATH);
} else {
ipio_debug_level = DEBUG_ALL;
ilitek_dump_data(idev->update_buf, 8, len, 0, "IRAM");
ipio_debug_level = tmp;
}
out:
if (wdt) {
if (ilitek_tddi_ic_watch_dog_ctrl(ILI_WRITE, ENABLE) < 0)
ipio_err("Enable WDT failed during dumping iram\n");
}
if (!ice) {
if (ilitek_ice_mode_ctrl(DISABLE, mcu) < 0)
ipio_err("Enable ice mode failed after code reset\n");
}
ipio_info("Dump IRAM %s\n", (ret < 0) ? "FAIL" : "SUCCESS");
return ret;
}
static int ilitek_tddi_fw_iram_program(u32 start, u8 *w_buf, u32 w_len, u32 split_len)
{
int i = 0, j = 0, addr = 0;
u32 end = start + w_len;
bool fix_4_alignment = false;
if (split_len % 4 > 0)
ipio_err("Since split_len must be four-aligned, it must be a multiple of four");
if (split_len != 0) {
for (addr = start, i = 0; addr < end; addr += split_len, i += split_len) {
if ((addr + split_len) > end) {
split_len = end - addr;
if (split_len % 4 != 0)
fix_4_alignment = true;
}
idev->update_buf[0] = SPI_WRITE;
idev->update_buf[1] = 0x25;
idev->update_buf[2] = (char)((addr & 0x000000FF));
idev->update_buf[3] = (char)((addr & 0x0000FF00) >> 8);
idev->update_buf[4] = (char)((addr & 0x00FF0000) >> 16);
for (j = 0; j < split_len; j++)
idev->update_buf[5 + j] = w_buf[i + j];
if (fix_4_alignment) {
ipio_info("org split_len = 0x%X\n", split_len);
ipio_info("idev->update_buf[5 + 0x%X] = 0x%X\n", split_len - 4, idev->update_buf[5 + split_len - 4]);
ipio_info("idev->update_buf[5 + 0x%X] = 0x%X\n", split_len - 3, idev->update_buf[5 + split_len - 3]);
ipio_info("idev->update_buf[5 + 0x%X] = 0x%X\n", split_len - 2, idev->update_buf[5 + split_len - 2]);
ipio_info("idev->update_buf[5 + 0x%X] = 0x%X\n", split_len - 1, idev->update_buf[5 + split_len - 1]);
for (j = 0; j < (4 - (split_len % 4)); j++) {
idev->update_buf[5 + j + split_len] = 0xFF;
ipio_info("idev->update_buf[5 + 0x%X] = 0x%X\n",j + split_len, idev->update_buf[5 + j + split_len]);
}
ipio_info("split_len %% 4 = %d\n", split_len % 4);
split_len = split_len + (4 - (split_len % 4));
ipio_info("fix split_len = 0x%X\n", split_len);
}
if (idev->spi_write_then_read(idev->spi, idev->update_buf, split_len + 5, NULL, 0)) {
ipio_err("Failed to write data via SPI in host download (%x)\n", split_len + 5);
return -EIO;
}
idev->fw_update_stat = (i * 100) / w_len;
}
} else {
for (i = 0; i < MAX_HEX_FILE_SIZE; i++)
idev->update_buf[i] = 0xFF;
idev->update_buf[0] = SPI_WRITE;
idev->update_buf[1] = 0x25;
idev->update_buf[2] = (char)((start & 0x000000FF));
idev->update_buf[3] = (char)((start & 0x0000FF00) >> 8);
idev->update_buf[4] = (char)((start & 0x00FF0000) >> 16);
memcpy(&idev->update_buf[5], w_buf, w_len);
if (w_len % 4 != 0) {
ipio_info("org w_len = %d\n", w_len);
w_len = w_len + (4 - (w_len % 4));
ipio_info("w_len = %d w_len %% 4 = %d\n", w_len, w_len % 4);
}
/* It must be supported by platforms that have the ability to transfer all data at once. */
if (idev->spi_write_then_read(idev->spi, idev->update_buf, w_len + 5, NULL, 0) < 0) {
ipio_err("Failed to write data via SPI in host download (%x)\n", w_len + 5);
return -EIO;
}
}
return 0;
}
static int ilitek_tddi_fw_iram_upgrade(u8 *pfw, bool mcu)
{
int i, ret = UPDATE_PASS;
u32 mode, crc, dma, iram_crc = 0;
u8 *fw_ptr = NULL, crc_temp[4], crc_len = 4;
bool iram_crc_err = false;
if (!idev->ddi_rest_done) {
if (idev->actual_tp_mode != P5_X_FW_GESTURE_MODE)
ilitek_tddi_reset_ctrl(idev->reset);
ret = ilitek_ice_mode_ctrl(ENABLE, mcu);
if (ret < 0)
return -EFW_ICE_MODE;
} else {
/* Restore it if the wq of load_fw_ddi has been called. */
idev->ddi_rest_done = false;
}
ret = ilitek_tddi_ic_watch_dog_ctrl(ILI_WRITE, DISABLE);
if (ret < 0)
return -EFW_WDT;
/* Point to pfw with different addresses for getting its block data. */
fw_ptr = pfw;
if (idev->actual_tp_mode == P5_X_FW_TEST_MODE) {
mode = MP;
} else if (idev->actual_tp_mode == P5_X_FW_GESTURE_MODE) {
mode = GESTURE;
crc_len = 0;
} else {
mode = AP;
}
/* Program data to iram acorrding to each block */
for (i = 0; i < FW_BLOCK_INFO_NUM; i++) {
if (fbi[i].mode == mode && fbi[i].len != 0) {
ipio_debug("Download %s code from hex 0x%x to IRAM 0x%x, len = 0x%x\n",
fbi[i].name, fbi[i].start, fbi[i].mem_start, fbi[i].len);
#if SPI_DMA_TRANSFER_SPLIT
if (ilitek_tddi_fw_iram_program(fbi[i].mem_start, (fw_ptr + fbi[i].start), fbi[i].len, SPI_UPGRADE_LEN) < 0)
ipio_err("IRAM program failed\n");
#else
if (ilitek_tddi_fw_iram_program(fbi[i].mem_start, (fw_ptr + fbi[i].start), fbi[i].len, 0) < 0)
ipio_err("IRAM program failed\n");
#endif
// Check crc
crc = CalculateCRC32(fbi[i].start, fbi[i].len - crc_len, fw_ptr);
dma = host_download_dma_check(fbi[i].mem_start, fbi[i].len - crc_len);
if (mode != GESTURE) {
ilitek_tddi_fw_iram_read(crc_temp, (fbi[i].mem_start + fbi[i].len - crc_len), sizeof(crc_temp));
iram_crc = crc_temp[0] << 24 | crc_temp[1] << 16 |crc_temp[2] << 8 | crc_temp[3];
if (iram_crc != dma)
iram_crc_err = true;
}
ipio_info("%s CRC is %s hex(%x) : dma(%x) : iram(%x), calculation len is 0x%x\n",
fbi[i].name,((crc != dma)||(iram_crc_err)) ? "Invalid !" : "Correct !", crc, dma, iram_crc, fbi[i].len - crc_len);
if ((crc != dma)|| iram_crc_err) {
ipio_err("CRC Error! print iram data with first 16 bytes\n");
ilitek_fw_dump_iram_data(0x0, 0xF, false, OFF);
return -EFW_CRC;
}
}
}
if (idev->actual_tp_mode != P5_X_FW_GESTURE_MODE) {
if (ilitek_tddi_reset_ctrl(TP_IC_CODE_RST) < 0) {
ipio_err("TP Code reset failed during iram programming\n");
ret = -EFW_REST;
return ret;
}
}
if (ilitek_ice_mode_ctrl(DISABLE, mcu) < 0) {
ipio_err("Disable ice mode failed after code reset\n");
ret = -EFW_ICE_MODE;
}
/* Waiting for fw ready sending first cmd */
if (!idev->info_from_hex || (idev->chip->core_ver < CORE_VER_1410))
mdelay(100);
return ret;
}
static int ilitek_fw_calc_file_crc(u8 *pfw)
{
int i;
u32 ex_addr, data_crc, file_crc;
for (i = 0; i < ARRAY_SIZE(fbi); i++) {
if (fbi[i].end == 0)
continue;
ex_addr = fbi[i].end;
data_crc = CalculateCRC32(fbi[i].start, fbi[i].len - 4, pfw);
file_crc = pfw[ex_addr - 3] << 24 | pfw[ex_addr - 2] << 16 | pfw[ex_addr - 1] << 8 | pfw[ex_addr];
ipio_debug("data crc = %x, file crc = %x\n", data_crc, file_crc);
if (data_crc != file_crc) {
ipio_err("Content of fw file is broken. (%d, %x, %x)\n",
i, data_crc, file_crc);
return -1;
}
}
ipio_info("Content of fw file is correct\n");
return 0;
}
static void ilitek_tddi_fw_update_block_info(u8 *pfw)
{
u32 ges_area_section, ges_info_addr, ges_fw_start, ges_fw_end;
u32 ap_end, ap_len = 0;
u32 fw_info_addr = 0, fw_mp_ver_addr = 0;
ipio_info("Tag = %x\n", tfd.hex_tag);
if (tfd.hex_tag == BLOCK_TAG_AF) {
fbi[AP].mem_start = (fbi[AP].fix_mem_start != INT_MAX) ? fbi[AP].fix_mem_start : 0;
fbi[DATA].mem_start = (fbi[DATA].fix_mem_start != INT_MAX) ? fbi[DATA].fix_mem_start : DLM_START_ADDRESS;
fbi[TUNING].mem_start = (fbi[TUNING].fix_mem_start != INT_MAX) ? fbi[TUNING].fix_mem_start : fbi[DATA].mem_start + fbi[DATA].len;
fbi[MP].mem_start = (fbi[MP].fix_mem_start != INT_MAX) ? fbi[MP].fix_mem_start : 0;
fbi[GESTURE].mem_start = (fbi[GESTURE].fix_mem_start != INT_MAX) ? fbi[GESTURE].fix_mem_start : 0;
/* Parsing gesture info form AP code */
ges_info_addr = (fbi[AP].end + 1 - 60);
ges_area_section = (pfw[ges_info_addr + 3] << 24) + (pfw[ges_info_addr + 2] << 16) + (pfw[ges_info_addr + 1] << 8) + pfw[ges_info_addr];
fbi[GESTURE].mem_start = (pfw[ges_info_addr + 7] << 24) + (pfw[ges_info_addr + 6] << 16) + (pfw[ges_info_addr + 5] << 8) + pfw[ges_info_addr + 4];
ap_end = (pfw[ges_info_addr + 11] << 24) + (pfw[ges_info_addr + 10] << 16) + (pfw[ges_info_addr + 9] << 8) + pfw[ges_info_addr + 8];
if (ap_end != fbi[GESTURE].mem_start)
ap_len = ap_end - fbi[GESTURE].mem_start + 1;
ges_fw_start = (pfw[ges_info_addr + 15] << 24) + (pfw[ges_info_addr + 14] << 16) + (pfw[ges_info_addr + 13] << 8) + pfw[ges_info_addr + 12];
ges_fw_end = (pfw[ges_info_addr + 19] << 24) + (pfw[ges_info_addr + 18] << 16) + (pfw[ges_info_addr + 17] << 8) + pfw[ges_info_addr + 16];
if (ges_fw_end != ges_fw_start)
fbi[GESTURE].len = ges_fw_end - ges_fw_start; //address was automatically added one when it was generated
/* update gesture address */
fbi[GESTURE].start = ges_fw_start;
} else {
memset(fbi, 0x0, sizeof(fbi));
fbi[AP].start = 0;
fbi[AP].mem_start = 0;
fbi[AP].len = MAX_AP_FIRMWARE_SIZE;
fbi[DATA].start = DLM_HEX_ADDRESS;
fbi[DATA].mem_start = DLM_START_ADDRESS;
fbi[DATA].len = MAX_DLM_FIRMWARE_SIZE;
fbi[MP].start = MP_HEX_ADDRESS;
fbi[MP].mem_start = 0;
fbi[MP].len = MAX_MP_FIRMWARE_SIZE;
/* Parsing gesture info form AP code */
ges_info_addr = (MAX_AP_FIRMWARE_SIZE - 60);
ges_area_section = (pfw[ges_info_addr + 3] << 24) + (pfw[ges_info_addr + 2] << 16) + (pfw[ges_info_addr + 1] << 8) + pfw[ges_info_addr];
fbi[GESTURE].mem_start = (pfw[ges_info_addr + 7] << 24) + (pfw[ges_info_addr + 6] << 16) + (pfw[ges_info_addr + 5] << 8) + pfw[ges_info_addr + 4];
ap_end = (pfw[ges_info_addr + 11] << 24) + (pfw[ges_info_addr + 10] << 16) + (pfw[ges_info_addr + 9] << 8) + pfw[ges_info_addr + 8];
if (ap_end != fbi[GESTURE].mem_start)
ap_len = ap_end - fbi[GESTURE].mem_start + 1;
ges_fw_start = (pfw[ges_info_addr + 15] << 24) + (pfw[ges_info_addr + 14] << 16) + (pfw[ges_info_addr + 13] << 8) + pfw[ges_info_addr + 12];
ges_fw_end = (pfw[ges_info_addr + 19] << 24) + (pfw[ges_info_addr + 18] << 16) + (pfw[ges_info_addr + 17] << 8) + pfw[ges_info_addr + 16];
if (ges_fw_end != ges_fw_start)
fbi[GESTURE].len = ges_fw_end - ges_fw_start; //address was automatically added one when it was generated
/* update gesture address */
fbi[GESTURE].start = ges_fw_start;
}
ipio_info("==== Gesture loader info ====\n");
ipio_info("gesture move to ap addr => start = 0x%x, ap_end = 0x%x, ap_len = 0x%x\n", fbi[GESTURE].mem_start, ap_end, ap_len);
ipio_info("gesture hex addr => start = 0x%x, gesture_end = 0x%x, gesture_len = 0x%x\n", ges_fw_start, ges_fw_end, fbi[GESTURE].len);
ipio_info("=============================\n");
fbi[AP].name = "AP";
fbi[DATA].name = "DATA";
fbi[TUNING].name = "TUNING";
fbi[MP].name = "MP";
fbi[GESTURE].name = "GESTURE";
/* upgrade mode define */
fbi[DATA].mode = fbi[AP].mode = fbi[TUNING].mode = AP;
fbi[MP].mode = MP;
fbi[GESTURE].mode = GESTURE;
/* copy fw info */
fw_info_addr = fbi[AP].end - INFO_HEX_ST_ADDR;
ipio_info("Parsing hex info start addr = 0x%x\n", fw_info_addr);
ipio_memcpy(idev->fw_info, pfw + fw_info_addr, sizeof(idev->fw_info), sizeof(idev->fw_info));
/* copy fw mp ver */
fw_mp_ver_addr = fbi[MP].end - INFO_MP_HEX_ADDR;
ipio_info("Parsing hex mp ver addr = 0x%x\n", fw_mp_ver_addr);
ipio_memcpy(idev->fw_mp_ver, pfw + fw_mp_ver_addr, sizeof(idev->fw_mp_ver), sizeof(idev->fw_mp_ver));
/* copy fw core ver */
idev->chip->core_ver = (idev->fw_info[68] << 24) | (idev->fw_info[69] << 16) |
(idev->fw_info[70] << 8) | idev->fw_info[71];
ipio_info("New FW Core version = %x\n", idev->chip->core_ver);
/* Get hex fw vers */
tfd.new_fw_cb = (idev->fw_info[48] << 24) | (idev->fw_info[49] << 16) |
(idev->fw_info[50] << 8) | idev->fw_info[51];
/* Get hex report info block*/
ipio_memcpy(&idev->rib, idev->fw_info, sizeof(idev->rib), sizeof(idev->rib));
ipio_info("report_info_block : nReportByPixel = %d, nIsHostDownload = %d, nIsSPIICE = %d, nIsSPISLAVE = %d\n",
idev->rib.nReportByPixel, idev->rib.nIsHostDownload, idev->rib.nIsSPIICE, idev->rib.nIsSPISLAVE);
ipio_info("report_info_block : nIsI2C = %d, nReserved00 = %d, nReserved01 = %x, nReserved02 = %x, nReserved03 = %x\n",
idev->rib.nIsI2C, idev->rib.nReserved00, idev->rib.nReserved01, idev->rib.nReserved02, idev->rib.nReserved03);
/* Calculate update address */
ipio_info("New FW ver = 0x%x\n", tfd.new_fw_cb);
ipio_info("star_addr = 0x%06X, end_addr = 0x%06X, Block Num = %d\n", tfd.start_addr, tfd.end_addr, tfd.block_number);
}
static int ilitek_tddi_fw_ili_convert(u8 *pfw)
{
int i = 0, block_enable = 0, num = 0, size;
u8 block;
u32 Addr;
if (ERR_ALLOC_MEM(idev->md_fw_ili))
return -ENOMEM;
CTPM_FW = idev->md_fw_ili;
size = idev->md_fw_ili_size;
if (size < ILI_FILE_HEADER || size > MAX_HEX_FILE_SIZE) {
ipio_err("size of ILI file is invalid\n");
return -EINVAL;
}
if (CTPM_FW[22] != 0xFF && CTPM_FW[23] != 0xFF &&
CTPM_FW[24] != 0xFF && CTPM_FW[25] != 0xFF) {
ipio_err("Invaild ILI format, abort!\n");
return -EINVAL;
}
ipio_info("Start to parse ILI file, type = %d, block_count = %d\n", CTPM_FW[32], CTPM_FW[33]);
memset(fbi, 0x0, sizeof(fbi));
tfd.start_addr = 0;
tfd.end_addr = 0;
tfd.hex_tag = 0;
block_enable = CTPM_FW[32];
if (block_enable == 0) {
tfd.hex_tag = BLOCK_TAG_AE;
goto out;
}
tfd.hex_tag = BLOCK_TAG_AF;
for (i = 0; i < (FW_BLOCK_INFO_NUM - 3); i++) {
if (((block_enable >> i) & 0x01) == 0x01) {
num = i + 1;
if (num > 5) {
fbi[num].start = (CTPM_FW[0 + (i - 5) * 6] << 16) + (CTPM_FW[1 + (i - 5) * 6] << 8) + (CTPM_FW[2 + (i - 5) * 6]);
fbi[num].end = (CTPM_FW[3 + (i - 5) * 6] << 16) + (CTPM_FW[4 + (i - 5) * 6] << 8) + (CTPM_FW[5 + (i - 5) * 6]);
fbi[num].fix_mem_start = INT_MAX;
} else {
fbi[num].start = (CTPM_FW[34 + i * 6] << 16) + (CTPM_FW[35 + i * 6] << 8) + (CTPM_FW[36 + i * 6]);
fbi[num].end = (CTPM_FW[37 + i * 6] << 16) + (CTPM_FW[38 + i * 6] << 8) + (CTPM_FW[39 + i * 6]);
fbi[num].fix_mem_start = INT_MAX;
}
if (fbi[num].start == fbi[num].end)
continue;
fbi[num].len = fbi[num].end - fbi[num].start + 1;
ipio_debug("Block[%d]: start_addr = %x, end = %x\n", num, fbi[num].start, fbi[num].end);
if (num == GESTURE)
idev->gesture_load_code = true;
}
}
if ((block_enable & 0x80) == 0x80) {
for (i = 0; i < 3; i++) {
Addr = (CTPM_FW[6 + i * 4] << 16) + (CTPM_FW[7 + i * 4] << 8) + (CTPM_FW[8 + i * 4]);
block = CTPM_FW[9 + i * 4];
if ((block != 0) && (Addr != 0x000000)) {
fbi[block].fix_mem_start = Addr;
ipio_debug("Tag 0xB0: change Block[%d] to addr = 0x%x\n", block, fbi[block].fix_mem_start);
}
}
}
out:
memcpy(pfw, CTPM_FW + ILI_FILE_HEADER, size - ILI_FILE_HEADER);
if (ilitek_fw_calc_file_crc(pfw) < 0)
return -1;
tfd.block_number = CTPM_FW[33];
tfd.end_addr = size - ILI_FILE_HEADER;
return 0;
}
static int ilitek_tddi_fw_hex_convert(u8 *phex, int size, u8 *pfw)
{
int block = 0;
u32 i = 0, j = 0, k = 0, num = 0;
u32 len = 0, addr = 0, type = 0;
u32 start_addr = 0x0, end_addr = 0x0, ex_addr = 0;
u32 offset;
memset(fbi, 0x0, sizeof(fbi));
/* Parsing HEX file */
for (; i < size;) {
len = HexToDec(&phex[i + 1], 2);
addr = HexToDec(&phex[i + 3], 4);
type = HexToDec(&phex[i + 7], 2);
if (type == 0x04) {
ex_addr = HexToDec(&phex[i + 9], 4);
} else if (type == 0x02) {
ex_addr = HexToDec(&phex[i + 9], 4);
ex_addr = ex_addr >> 12;
} else if (type == BLOCK_TAG_AE || type == BLOCK_TAG_AF) {
/* insert block info extracted from hex */
tfd.hex_tag = type;
if (tfd.hex_tag == BLOCK_TAG_AF)
num = HexToDec(&phex[i + 9 + 6 + 6], 2);
else
num = block;
if (num > FW_BLOCK_INFO_NUM) {
ipio_err("ERROR! block num is larger than its define (%d, %d)\n",
num, FW_BLOCK_INFO_NUM);
return -EINVAL;
}
fbi[num].start = HexToDec(&phex[i + 9], 6);
fbi[num].end = HexToDec(&phex[i + 9 + 6], 6);
fbi[num].fix_mem_start = INT_MAX;
fbi[num].len = fbi[num].end - fbi[num].start + 1;
ipio_info("Block[%d]: start_addr = %x, end = %x", num, fbi[num].start, fbi[num].end);
if (num == GESTURE)
idev->gesture_load_code = true;
block++;
} else if (type == BLOCK_TAG_B0 && tfd.hex_tag == BLOCK_TAG_AF) {
num = HexToDec(&phex[i + 9 + 6], 2);
if (num > FW_BLOCK_INFO_NUM) {
ipio_err("ERROR! block num is larger than its define (%d, %d)\n",
num, FW_BLOCK_INFO_NUM);
return -EINVAL;
}
fbi[num].fix_mem_start = HexToDec(&phex[i + 9], 6);
ipio_info("Tag 0xB0: change Block[%d] to addr = 0x%x\n", num, fbi[num].fix_mem_start);
}
addr = addr + (ex_addr << 16);
if (phex[i + 1 + 2 + 4 + 2 + (len * 2) + 2] == 0x0D)
offset = 2;
else
offset = 1;
if (addr > MAX_HEX_FILE_SIZE) {
ipio_err("Invalid hex format %d\n", addr);
return -1;
}
if (type == 0x00) {
end_addr = addr + len;
if (addr < start_addr)
start_addr = addr;
/* fill data */
for (j = 0, k = 0; j < (len * 2); j += 2, k++)
pfw[addr + k] = HexToDec(&phex[i + 9 + j], 2);
}
i += 1 + 2 + 4 + 2 + (len * 2) + 2 + offset;
}
if (ilitek_fw_calc_file_crc(pfw) < 0)
return -1;
tfd.start_addr = start_addr;
tfd.end_addr = end_addr;
tfd.block_number = block;
return 0;
}
static int ilitek_tdd_fw_hex_open(u8 op, u8 *pfw)
{
int ret = 0, fsize = 0;
const struct firmware *fw = NULL;
struct file *f = NULL;
mm_segment_t old_fs;
loff_t pos = 0;
ipio_info("Open file method = %s, path = %s\n",
op ? "FILP_OPEN" : "REQUEST_FIRMWARE",
op ? idev->md_fw_filp_path : idev->md_fw_rq_path);
switch (op) {
case REQUEST_FIRMWARE:
if (request_firmware(&fw, idev->md_fw_rq_path, idev->dev) < 0) {
ipio_err("Request firmware failed, try again\n");
if (request_firmware(&fw, idev->md_fw_rq_path, idev->dev) < 0) {
ipio_err("Request firmware failed after retry\n");
ret = -1;
goto out;
}
}
fsize = fw->size;
ipio_info("fsize = %d\n", fsize);
if (fsize <= 0) {
ipio_err("The size of file is invaild\n");
release_firmware(fw);
ret = -1;
goto out;
}
idev->tp_fw.size = 0;
idev->tp_fw.data = vmalloc(fsize);
if (ERR_ALLOC_MEM(idev->tp_fw.data)) {
ipio_err("Failed to allocate tp_fw by vmalloc, try again\n");
idev->tp_fw.data = vmalloc(fsize);
if (ERR_ALLOC_MEM(idev->tp_fw.data)) {
ipio_err("Failed to allocate tp_fw after retry\n");
release_firmware(fw);
ret = -ENOMEM;
goto out;
}
}
/* Copy fw data got from request_firmware to global */
ipio_memcpy((u8 *)idev->tp_fw.data, fw->data, fsize * sizeof(*fw->data), fsize);
idev->tp_fw.size = fsize;
release_firmware(fw);
break;
case FILP_OPEN:
f = filp_open(idev->md_fw_filp_path, O_RDONLY, 0644);
if (ERR_ALLOC_MEM(f)) {
ipio_err("Failed to open the file, %ld\n", PTR_ERR(f));
ret = -1;
goto out;
}
fsize = f->f_inode->i_size;
ipio_info("fsize = %d\n", fsize);
if (fsize <= 0) {
ipio_err("The size of file is invaild\n");
filp_close(f, NULL);
ret = -1;
goto out;
}
idev->tp_fw.size = 0;
idev->tp_fw.data = vmalloc(fsize);
if (ERR_ALLOC_MEM(idev->tp_fw.data)) {
ipio_err("Failed to allocate tp_fw by vmalloc, try again\n");
idev->tp_fw.data = vmalloc(fsize);
if (ERR_ALLOC_MEM(idev->tp_fw.data)) {
ipio_err("Failed to allocate tp_fw after retry\n");
filp_close(f, NULL);
ret = -ENOMEM;
goto out;
}
}
/* ready to map user's memory to obtain data by reading files */
old_fs = get_fs();
set_fs(get_ds());
set_fs(KERNEL_DS);
pos = 0;
vfs_read(f, (u8 *)idev->tp_fw.data, fsize, &pos);
set_fs(old_fs);
filp_close(f, NULL);
idev->tp_fw.size = fsize;
break;
default:
ipio_err("Unknown open file method, %d\n", op);
break;
}
if (ERR_ALLOC_MEM(idev->tp_fw.data) || idev->tp_fw.size <= 0) {
ipio_err("fw data/size is invaild\n");
ret = -1;
goto out;
}
/* Convert hex and copy data from tp_fw.data to pfw */
if (ilitek_tddi_fw_hex_convert((u8 *)idev->tp_fw.data, idev->tp_fw.size, pfw) < 0) {
ipio_err("Convert hex file failed\n");
ret = -1;
}
out:
ipio_vfree((void **)&(idev->tp_fw.data));
return ret;
}
int ilitek_tddi_fw_upgrade(int op)
{
int i, ret = 0, retry = 3;
if (!idev->boot || idev->force_fw_update || ERR_ALLOC_MEM(pfw)) {
idev->gesture_load_code = false;
if (ERR_ALLOC_MEM(pfw)) {
ipio_vfree((void **)&pfw);
pfw = vmalloc(MAX_HEX_FILE_SIZE * sizeof(u8));
if (ERR_ALLOC_MEM(pfw)) {
ipio_err("Failed to allocate pfw memory, %ld\n", PTR_ERR(pfw));
ipio_vfree((void **)&pfw);
ret = -ENOMEM;
goto out;
}
}
for (i = 0; i < MAX_HEX_FILE_SIZE; i++)
pfw[i] = 0xFF;
if (ilitek_tdd_fw_hex_open(op, pfw) < 0) {
ipio_err("Open hex file fail, try upgrade from ILI file\n");
/*
* They might not be aware of a broken hex file if we recover
* fw from ILI file. We should force them to check
* hex files they attempt to update via device node.
*/
if (idev->node_update) {
ipio_err("Ignore update from ILI file\n");
ipio_vfree((void **)&pfw);
return -EFW_CONVERT_FILE;
}
if (ilitek_tddi_fw_ili_convert(pfw) < 0) {
ipio_err("Convert ILI file error\n");
ret = -EFW_CONVERT_FILE;
goto out;
}
}
ilitek_tddi_fw_update_block_info(pfw);
if (idev->chip->core_ver >= CORE_VER_1470 && idev->rib.nIsHostDownload == 0) {
ipio_err("hex file interface no match error\n");
return -EFW_INTERFACE;
}
}
do {
ret = ilitek_tddi_fw_iram_upgrade(pfw, OFF);
if (ret == UPDATE_PASS)
break;
ipio_err("Upgrade failed, do retry %d times\n", (3 - retry));
} while (--retry > 0);
if (ret != UPDATE_PASS) {
ipio_err("Failed to upgrade fw");
if (ilitek_tddi_reset_ctrl(idev->reset) < 0)
ipio_err("TP reset failed while erasing data\n");
idev->xch_num = 0;
idev->ych_num = 0;
return ret;
}
out:
ilitek_tddi_ic_get_core_ver();
ilitek_tddi_ic_get_protocl_ver();
ilitek_tddi_ic_get_fw_ver();
ilitek_tddi_ic_get_tp_info();
ilitek_tddi_ic_get_panel_info();
ilitek_tddi_ic_func_ctrl_reset();
return ret;
}
void ilitek_tddi_fw_read_flash_info(bool mcu)
{
return;
}
void ilitek_tddi_flash_clear_dma(void)
{
return;
}
void ilitek_tddi_flash_dma_write(u32 start, u32 end, u32 len)
{
return;
}
int ilitek_tddi_fw_dump_flash_data(u32 start, u32 end, bool user, bool mcu)
{
return 0;
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,467 @@
/*
* ILITEK Touch IC driver
*
* Copyright (C) 2011 ILI Technology Corporation.
*
* Author: Dicky Chiang <dicky_chiang@ilitek.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "ilitek.h"
#define DTS_INT_GPIO "touch,irq-gpio"
#define DTS_RESET_GPIO "touch,reset-gpio"
#define DTS_OF_NAME "ilitek"
#define MTK_RST_GPIO GTP_RST_PORT
#define MTK_INT_GPIO GTP_INT_PORT
extern struct tpd_device *tpd;
void ilitek_plat_tp_reset(void)
{
ipio_info("edge delay = %d\n", idev->rst_edge_delay);
/* Need accurate power sequence, do not change it to msleep */
tpd_gpio_output(idev->tp_rst, 1);
mdelay(1);
tpd_gpio_output(idev->tp_rst, 0);
mdelay(5);
tpd_gpio_output(idev->tp_rst, 1);
mdelay(idev->rst_edge_delay);
}
void ilitek_plat_input_register(void)
{
int i;
idev->input = tpd->dev;
if (tpd_dts_data.use_tpd_button) {
for (i = 0; i < tpd_dts_data.tpd_key_num; i++)
input_set_capability(idev->input, EV_KEY, tpd_dts_data.tpd_key_local[i]);
}
/* set the supported event type for input device */
set_bit(EV_ABS, idev->input->evbit);
set_bit(EV_SYN, idev->input->evbit);
set_bit(EV_KEY, idev->input->evbit);
set_bit(BTN_TOUCH, idev->input->keybit);
set_bit(BTN_TOOL_FINGER, idev->input->keybit);
set_bit(INPUT_PROP_DIRECT, idev->input->propbit);
if (MT_PRESSURE)
input_set_abs_params(idev->input, ABS_MT_PRESSURE, 0, 255, 0, 0);
if (MT_B_TYPE) {
#if KERNEL_VERSION(3, 7, 0) <= LINUX_VERSION_CODE
input_mt_init_slots(idev->input, MAX_TOUCH_NUM, INPUT_MT_DIRECT);
#else
input_mt_init_slots(idev->input, MAX_TOUCH_NUM);
#endif /* LINUX_VERSION_CODE */
} else {
input_set_abs_params(idev->input, ABS_MT_TRACKING_ID, 0, MAX_TOUCH_NUM, 0, 0);
}
/* Gesture keys register */
input_set_capability(idev->input, EV_KEY, KEY_POWER);
input_set_capability(idev->input, EV_KEY, KEY_GESTURE_UP);
input_set_capability(idev->input, EV_KEY, KEY_GESTURE_DOWN);
input_set_capability(idev->input, EV_KEY, KEY_GESTURE_LEFT);
input_set_capability(idev->input, EV_KEY, KEY_GESTURE_RIGHT);
input_set_capability(idev->input, EV_KEY, KEY_GESTURE_O);
input_set_capability(idev->input, EV_KEY, KEY_GESTURE_E);
input_set_capability(idev->input, EV_KEY, KEY_GESTURE_M);
input_set_capability(idev->input, EV_KEY, KEY_GESTURE_W);
input_set_capability(idev->input, EV_KEY, KEY_GESTURE_S);
input_set_capability(idev->input, EV_KEY, KEY_GESTURE_V);
input_set_capability(idev->input, EV_KEY, KEY_GESTURE_Z);
input_set_capability(idev->input, EV_KEY, KEY_GESTURE_C);
input_set_capability(idev->input, EV_KEY, KEY_GESTURE_F);
__set_bit(KEY_GESTURE_POWER, idev->input->keybit);
__set_bit(KEY_GESTURE_UP, idev->input->keybit);
__set_bit(KEY_GESTURE_DOWN, idev->input->keybit);
__set_bit(KEY_GESTURE_LEFT, idev->input->keybit);
__set_bit(KEY_GESTURE_RIGHT, idev->input->keybit);
__set_bit(KEY_GESTURE_O, idev->input->keybit);
__set_bit(KEY_GESTURE_E, idev->input->keybit);
__set_bit(KEY_GESTURE_M, idev->input->keybit);
__set_bit(KEY_GESTURE_W, idev->input->keybit);
__set_bit(KEY_GESTURE_S, idev->input->keybit);
__set_bit(KEY_GESTURE_V, idev->input->keybit);
__set_bit(KEY_GESTURE_Z, idev->input->keybit);
__set_bit(KEY_GESTURE_C, idev->input->keybit);
__set_bit(KEY_GESTURE_F, idev->input->keybit);
}
#if REGULATOR_POWER
void ilitek_plat_regulator_power_on(bool status)
{
ipio_info("%s\n", status ? "POWER ON" : "POWER OFF");
if (status) {
if (idev->vdd) {
if (regulator_enable(idev->vdd) < 0)
ipio_err("regulator_enable VDD fail\n");
}
if (idev->vcc) {
if (regulator_enable(idev->vcc) < 0)
ipio_err("regulator_enable VCC fail\n");
}
} else {
if (idev->vdd) {
if (regulator_disable(idev->vdd) < 0)
ipio_err("regulator_enable VDD fail\n");
}
if (idev->vcc) {
if (regulator_disable(idev->vcc) < 0)
ipio_err("regulator_enable VCC fail\n");
}
}
atomic_set(&idev->ice_stat, DISABLE);
mdelay(5);
}
static void ilitek_plat_regulator_power_init(void)
{
const char *vdd_name = "vdd";
const char *vcc_name = "vcc";
idev->vdd = regulator_get(tpd->tpd_dev, vdd_name);
if (ERR_ALLOC_MEM(idev->vdd)) {
ipio_err("regulator_get VDD fail\n");
idev->vdd = NULL;
}
tpd->reg = idev->vdd;
if (regulator_set_voltage(idev->vdd, VDD_VOLTAGE, VDD_VOLTAGE) < 0)
ipio_err("Failed to set VDD %d\n", VDD_VOLTAGE);
idev->vcc = regulator_get(idev->dev, vcc_name);
if (ERR_ALLOC_MEM(idev->vcc)) {
ipio_err("regulator_get VCC fail.\n");
idev->vcc = NULL;
}
if (regulator_set_voltage(idev->vcc, VCC_VOLTAGE, VCC_VOLTAGE) < 0)
ipio_err("Failed to set VCC %d\n", VCC_VOLTAGE);
ilitek_plat_regulator_power_on(true);
}
#endif
static int ilitek_plat_gpio_register(void)
{
int ret = 0;
idev->tp_int = MTK_INT_GPIO;
idev->tp_rst = MTK_RST_GPIO;
ipio_info("TP INT: %d\n", idev->tp_int);
ipio_info("TP RESET: %d\n", idev->tp_rst);
if (!gpio_is_valid(idev->tp_int)) {
ipio_err("Invalid INT gpio: %d\n", idev->tp_int);
return -EBADR;
}
if (!gpio_is_valid(idev->tp_rst)) {
ipio_err("Invalid RESET gpio: %d\n", idev->tp_rst);
return -EBADR;
}
gpio_direction_input(idev->tp_int);
return ret;
}
void ilitek_plat_irq_disable(void)
{
unsigned long flag;
spin_lock_irqsave(&idev->irq_spin, flag);
if (atomic_read(&idev->irq_stat) == DISABLE)
goto out;
if (!idev->irq_num) {
ipio_err("gpio_to_irq (%d) is incorrect\n", idev->irq_num);
goto out;
}
disable_irq_nosync(idev->irq_num);
atomic_set(&idev->irq_stat, DISABLE);
ipio_debug("Disable irq success\n");
out:
spin_unlock_irqrestore(&idev->irq_spin, flag);
}
void ilitek_plat_irq_enable(void)
{
unsigned long flag;
spin_lock_irqsave(&idev->irq_spin, flag);
if (atomic_read(&idev->irq_stat) == ENABLE)
goto out;
if (!idev->irq_num) {
ipio_err("gpio_to_irq (%d) is incorrect\n", idev->irq_num);
goto out;
}
enable_irq(idev->irq_num);
atomic_set(&idev->irq_stat, ENABLE);
ipio_debug("Enable irq success\n");
out:
spin_unlock_irqrestore(&idev->irq_spin, flag);
}
static irqreturn_t ilitek_plat_isr_top_half(int irq, void *dev_id)
{
if (irq != idev->irq_num) {
ipio_err("Incorrect irq number (%d)\n", irq);
return IRQ_NONE;
}
if (atomic_read(&idev->cmd_int_check) == ENABLE) {
atomic_set(&idev->cmd_int_check, DISABLE);
ipio_debug("MP INT detected, ignore\n");
wake_up(&(idev->inq));
return IRQ_HANDLED;
}
if (idev->prox_near) {
ipio_info("Proximity event, ignore interrupt!\n");
return IRQ_HANDLED;
}
ipio_debug("report: %d, rst: %d, fw: %d, switch: %d, mp: %d, sleep: %d, esd: %d\n",
idev->report,
atomic_read(&idev->tp_reset),
atomic_read(&idev->fw_stat),
atomic_read(&idev->tp_sw_mode),
atomic_read(&idev->mp_stat),
atomic_read(&idev->tp_sleep),
atomic_read(&idev->esd_stat));
if (!idev->report || atomic_read(&idev->tp_reset) ||
atomic_read(&idev->fw_stat) || atomic_read(&idev->tp_sw_mode) ||
atomic_read(&idev->mp_stat) || atomic_read(&idev->tp_sleep) ||
atomic_read(&idev->esd_stat)) {
ipio_debug("ignore interrupt !\n");
return IRQ_HANDLED;
}
return IRQ_WAKE_THREAD;
}
static irqreturn_t ilitek_plat_isr_bottom_half(int irq, void *dev_id)
{
if (mutex_is_locked(&idev->touch_mutex)) {
ipio_debug("touch is locked, ignore\n");
return IRQ_HANDLED;
}
mutex_lock(&idev->touch_mutex);
ilitek_tddi_report_handler();
mutex_unlock(&idev->touch_mutex);
return IRQ_HANDLED;
}
void ilitek_plat_irq_unregister(void)
{
devm_free_irq(idev->dev, idev->irq_num, NULL);
}
int ilitek_plat_irq_register(int type)
{
int ret = 0;
static bool get_irq_pin;
struct device_node *node;
atomic_set(&idev->irq_stat, DISABLE);
if (get_irq_pin == false) {
node = of_find_matching_node(NULL, touch_of_match);
if (node)
idev->irq_num = irq_of_parse_and_map(node, 0);
ipio_info("idev->irq_num = %d\n", idev->irq_num);
get_irq_pin = true;
}
ret = devm_request_threaded_irq(idev->dev, idev->irq_num,
ilitek_plat_isr_top_half,
ilitek_plat_isr_bottom_half,
type | IRQF_ONESHOT, "ilitek", NULL);
if (type == IRQF_TRIGGER_FALLING)
ipio_info("IRQ TYPE = IRQF_TRIGGER_FALLING\n");
if (type == IRQF_TRIGGER_RISING)
ipio_info("IRQ TYPE = IRQF_TRIGGER_RISING\n");
if (ret != 0)
ipio_err("Failed to register irq handler, irq = %d, ret = %d\n", idev->irq_num, ret);
atomic_set(&idev->irq_stat, ENABLE);
return ret;
}
static void tpd_resume(struct device *h)
{
if (ilitek_tddi_sleep_handler(TP_RESUME) < 0)
ipio_err("TP resume failed\n");
}
static void tpd_suspend(struct device *h)
{
if (ilitek_tddi_sleep_handler(TP_DEEP_SLEEP) < 0)
ipio_err("TP suspend failed\n");
}
static int ilitek_tp_pm_suspend(struct device *dev)
{
ipio_info("CALL BACK TP PM SUSPEND");
idev->pm_suspend = true;
#if KERNEL_VERSION(3, 12, 0) >= LINUX_VERSION_CODE
idev->pm_completion.done = 0;
#else
reinit_completion(&idev->pm_completion);
#endif /* LINUX_VERSION_CODE */
return 0;
}
static int ilitek_tp_pm_resume(struct device *dev)
{
ipio_info("CALL BACK TP PM RESUME");
idev->pm_suspend = false;
complete(&idev->pm_completion);
return 0;
}
static int ilitek_plat_probe(void)
{
ipio_info("platform probe\n");
#if REGULATOR_POWER
ilitek_plat_regulator_power_init();
#endif
if (ilitek_plat_gpio_register() < 0)
ipio_err("Register gpio failed\n");
if (ilitek_tddi_init() < 0) {
ipio_err("platform probe failed\n");
return -ENODEV;
}
ilitek_plat_irq_register(idev->irq_tirgger_type);
tpd_load_status = 1;
idev->pm_suspend = false;
init_completion(&idev->pm_completion);
ipio_info("ILITEK Driver loaded successfully!");
return 0;
}
static int ilitek_plat_remove(void)
{
ipio_info("remove plat dev\n");
ilitek_tddi_dev_remove();
return 0;
}
static const struct dev_pm_ops tp_pm_ops = {
.suspend = ilitek_tp_pm_suspend,
.resume = ilitek_tp_pm_resume,
};
static const struct of_device_id tp_match_table[] = {
{.compatible = DTS_OF_NAME},
{},
};
#ifdef ROI
struct ts_device_ops ilitek_ops = {
.chip_roi_rawdata = ilitek_knuckle_roi_rawdata,
.chip_roi_switch = ilitek_knuckle_roi_switch,
};
#endif
static struct ilitek_hwif_info hwif = {
.bus_type = TDDI_INTERFACE,
.plat_type = TP_PLAT_MTK,
.owner = THIS_MODULE,
.name = TDDI_DEV_ID,
.of_match_table = of_match_ptr(tp_match_table),
.plat_probe = ilitek_plat_probe,
.plat_remove = ilitek_plat_remove,
.pm = &tp_pm_ops,
};
static int tpd_local_init(void)
{
ipio_info("TPD init device driver\n");
if (ilitek_tddi_dev_init(&hwif) < 0) {
ipio_err("Failed to register i2c/spi bus driver\n");
return -ENODEV;
}
if (tpd_load_status == 0) {
ipio_err("Add error touch panel driver\n");
return -1;
}
if (tpd_dts_data.use_tpd_button) {
tpd_button_setting(tpd_dts_data.tpd_key_num, tpd_dts_data.tpd_key_local,
tpd_dts_data.tpd_key_dim_local);
}
tpd_type_cap = 1;
return 0;
}
static struct tpd_driver_t tpd_device_driver = {
.tpd_device_name = TDDI_DEV_ID,
.tpd_local_init = tpd_local_init,
.suspend = tpd_suspend,
.resume = tpd_resume,
};
static int __init ilitek_plat_dev_init(void)
{
int ret = 0;
ipio_info("ILITEK TP driver init for MTK\n");
tpd_get_dts_info();
ret = tpd_driver_add(&tpd_device_driver);
if (ret < 0) {
ipio_err("ILITEK add TP driver failed\n");
tpd_driver_remove(&tpd_device_driver);
return -ENODEV;
}
return 0;
}
static void __exit ilitek_plat_dev_exit(void)
{
ipio_info("ilitek driver has been removed\n");
tpd_driver_remove(&tpd_device_driver);
}
module_init(ilitek_plat_dev_init);
module_exit(ilitek_plat_dev_exit);
MODULE_AUTHOR("ILITEK");
MODULE_LICENSE("GPL");
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,55 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#undef TRACE_SYSTEM
#define TRACE_SYSTEM met_touch
#if !defined(__TRACE_MET_FTRACE_TOUCH_H__) || defined(TRACE_HEADER_MULTI_READ)
#define __TRACE_MET_FTRACE_TOUCH_H__
#include <linux/tracepoint.h>
/*
* Tracepoint for MET_touch
*/
TRACE_EVENT(MET_touch,
TP_PROTO(char *touch_type, long tsec, long tusec,
char *mode, int value),
TP_ARGS(touch_type, tsec, tusec, mode, value),
TP_STRUCT__entry(
__array(char, _touch_type, 16)
__field(long, _tsec)
__field(long, _tusec)
__array(char, _mode, 16)
__field(int, _value)
),
TP_fast_assign(
memcpy(__entry->_touch_type, touch_type, 16);
__entry->_tsec = tsec;
__entry->_tusec = tusec;
memcpy(__entry->_mode, mode, 16);
__entry->_value = value;
),
TP_printk("%s,%ld.%06ld,%s,%x",
__entry->_touch_type,
__entry->_tsec,
__entry->_tusec,
__entry->_mode,
__entry->_value
)
);
#endif /* __TRACE_MET_FTRACE_TOUCH_H__ */
/* This part must be outside protection */
#undef TRACE_INCLUDE_PATH
#undef linux
#define TRACE_INCLUDE_PATH .
#define TRACE_INCLUDE_FILE met_ftrace_touch
#include <trace/define_trace.h>
+184
View File
@@ -0,0 +1,184 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#ifndef __TPD_H
#define __TPD_H
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/input.h>
#include <linux/interrupt.h>
#include <linux/time.h>
#include <linux/types.h>
#include <linux/seq_file.h>
#include <linux/list.h>
#include <linux/proc_fs.h>
#include <linux/slab.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#include <generated/autoconf.h>
#include <linux/kobject.h>
#include <linux/regulator/consumer.h>
#include <linux/pinctrl/consumer.h>
/*debug macros */
#define TPD_DEBUG
#define TPD_DEBUG_CODE
/* #define TPD_DEBUG_TRACK */
#define TPD_DMESG(a, arg...) \
pr_info(TPD_DEVICE ":[%s:%d] " a, __func__, __LINE__, ##arg)
#if defined(TPD_DEBUG)
#undef TPD_DEBUG
#define TPD_DEBUG(a, arg...) \
pr_info(TPD_DEVICE ":[%s:%d] " a, __func__, __LINE__, ##arg)
#else
#define TPD_DEBUG(arg...)
#endif
#define SPLIT ", "
/* register, address, configurations */
#define TPD_DEVICE "mtk-tpd"
#define TPD_X 0
#define TPD_Y 1
#define TPD_Z1 2
#define TPD_Z2 3
#define TP_DELAY (2*HZ/100)
#define TP_DRV_MAX_COUNT (20)
#define TPD_WARP_CNT (4)
#define TPD_VIRTUAL_KEY_MAX (10)
/* various mode */
#define TPD_MODE_NORMAL 0
#define TPD_MODE_KEYPAD 1
#define TPD_MODE_SW 2
#define TPD_MODE_FAV_SW 3
#define TPD_MODE_FAV_HW 4
#define TPD_MODE_RAW_DATA 5
#undef TPD_RES_X
#undef TPD_RES_Y
extern unsigned long TPD_RES_X;
extern unsigned long TPD_RES_Y;
extern int tpd_load_status; /* 0: failed, 1: success */
extern int tpd_mode;
extern int tpd_mode_axis;
extern int tpd_mode_min;
extern int tpd_mode_max;
extern int tpd_mode_keypad_tolerance;
extern int tpd_em_debounce_time;
extern int tpd_em_debounce_time0;
extern int tpd_em_debounce_time1;
extern int tpd_em_asamp;
extern int tpd_em_auto_time_interval;
extern int tpd_em_sample_cnt;
extern int tpd_calmat[];
extern int tpd_def_calmat[];
extern int tpd_calmat[];
extern int tpd_def_calmat[];
extern int TPD_DO_WARP;
extern int tpd_wb_start[];
extern int tpd_wb_end[];
extern int tpd_v_magnify_x;
extern int tpd_v_magnify_y;
extern unsigned int DISP_GetScreenHeight(void);
extern unsigned int DISP_GetScreenWidth(void);
#if defined(CONFIG_MTK_S3320) || defined(CONFIG_MTK_S3320_47) || \
defined(CONFIG_MTK_S3320_50)
extern void synaptics_init_sysfs(void);
#endif /* CONFIG_MTK_S3320 */
extern void tpd_button_init(void);
struct tpd_device {
struct device *tpd_dev;
struct regulator *reg;
struct regulator *io_reg;
struct input_dev *dev;
struct input_dev *kpd;
struct timer_list timer;
struct tasklet_struct tasklet;
int btn_state;
};
struct tpd_key_dim_local {
int key_x;
int key_y;
int key_width;
int key_height;
};
struct tpd_filter_t {
int enable; /*0: disable, 1: enable*/
int pixel_density; /*XXX pixel/cm*/
int W_W[3][4];/*filter custom setting prameters*/
unsigned int VECLOCITY_THRESHOLD[3];/*filter speed custom settings*/
};
struct tpd_dts_info {
int tpd_resolution[2];
int touch_max_num;
int use_tpd_button;
int tpd_key_num;
int tpd_key_local[4];
bool tpd_use_ext_gpio;
int rst_ext_gpio_num;
struct tpd_key_dim_local tpd_key_dim_local[4];
struct tpd_filter_t touch_filter;
};
extern struct tpd_dts_info tpd_dts_data;
struct tpd_attrs {
struct device_attribute **attr;
int num;
};
struct tpd_driver_t {
char *tpd_device_name;
int (*tpd_local_init)(void);
void (*suspend)(struct device *h);
void (*resume)(struct device *h);
int tpd_have_button;
struct tpd_attrs attrs;
};
/* #ifdef TPD_HAVE_BUTTON */
void tpd_button(unsigned int x, unsigned int y, unsigned int down);
void tpd_button_init(void);
ssize_t tpd_virtual_key(char *buf);
/* #ifndef TPD_BUTTON_HEIGHT */
/* #define TPD_BUTTON_HEIGHT TPD_RES_Y */
/* #endif */
extern int tpd_driver_add(struct tpd_driver_t *tpd_drv);
extern int tpd_driver_remove(struct tpd_driver_t *tpd_drv);
void tpd_button_setting(int keycnt, void *keys, void *keys_dim);
extern int tpd_em_spl_num;
extern int tpd_em_pressure_threshold;
extern struct tpd_device *tpd;
extern void tpd_get_dts_info(void);
#define GTP_RST_PORT 174
#define GTP_INT_PORT 0
extern void tpd_gpio_as_int(int pin);
extern void tpd_gpio_output(int pin, int level);
extern void tpd_gpio_mode_set(void);
extern const struct of_device_id touch_of_match[];
#ifdef TPD_DEBUG_CODE
#include "tpd_debug.h"
#endif
#ifdef TPD_DEBUG_TRACK
int DAL_Clean(void);
int DAL_Printf(const char *fmt, ...);
int LCD_LayerEnable(int id, BOOL enable);
#endif
#ifdef TPD_HAVE_CALIBRATION
#include "tpd_calibrate.h"
#endif
#include "tpd_default.h"
/* switch touch panel into different mode */
void _tpd_switch_single_mode(void);
void _tpd_switch_multiple_mode(void);
void _tpd_switch_sleep_mode(void);
void _tpd_switch_normal_mode(void);
#endif
@@ -0,0 +1,123 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#include "tpd.h"
/* #ifdef TPD_HAVE_BUTTON */
/* static int tpd_keys[TPD_KEY_COUNT] = TPD_KEYS; */
/* static int tpd_keys_dim[TPD_KEY_COUNT][4] = TPD_KEYS_DIM; */
static unsigned int tpd_keycnt;
static int tpd_keys[TPD_VIRTUAL_KEY_MAX] = { 0 };
static int tpd_keys_dim[TPD_VIRTUAL_KEY_MAX][4]; /* = {0}; */
static ssize_t mtk_virtual_keys_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
int i, j;
for (i = 0, j = 0; i < tpd_keycnt; i++)
j += snprintf(buf+j, PAGE_SIZE-j, "%s%s:%d:%d:%d:%d:%d%s", buf,
__stringify(EV_KEY), tpd_keys[i],
tpd_keys_dim[i][0], tpd_keys_dim[i][1],
tpd_keys_dim[i][2], tpd_keys_dim[i][3],
(i == tpd_keycnt - 1 ? "\n" : ":"));
return j;
}
static struct kobj_attribute mtk_virtual_keys_attr = {
.attr = {
.name = "virtualkeys.mtk-tpd",
.mode = 0644,
},
.show = &mtk_virtual_keys_show,
};
static struct attribute *mtk_properties_attrs[] = {
&mtk_virtual_keys_attr.attr,
NULL
};
static struct attribute_group mtk_properties_attr_group = {
.attrs = mtk_properties_attrs,
};
struct kobject *properties_kobj;
void tpd_button_init(void)
{
int ret = 0, i = 0;
/* if((tpd->kpd=input_allocate_device())==NULL) return -ENOMEM; */
tpd->kpd = input_allocate_device();
/* struct input_dev kpd initialization and registration */
tpd->kpd->name = TPD_DEVICE "-kpd";
set_bit(EV_KEY, tpd->kpd->evbit);
/* set_bit(EV_REL, tpd->kpd->evbit); */
/* set_bit(EV_ABS, tpd->kpd->evbit); */
for (i = 0; i < tpd_keycnt; i++)
__set_bit(tpd_keys[i], tpd->kpd->keybit);
tpd->kpd->id.bustype = BUS_HOST;
tpd->kpd->id.vendor = 0x0001;
tpd->kpd->id.product = 0x0001;
tpd->kpd->id.version = 0x0100;
if (input_register_device(tpd->kpd))
TPD_DMESG("input_register_device failed.(kpd)\n");
set_bit(EV_KEY, tpd->dev->evbit);
for (i = 0; i < tpd_keycnt; i++)
__set_bit(tpd_keys[i], tpd->dev->keybit);
properties_kobj = kobject_create_and_add("board_properties", NULL);
if (properties_kobj)
ret = sysfs_create_group(properties_kobj,
&mtk_properties_attr_group);
if (!properties_kobj || ret)
TPD_DEBUG("failed to create board_properties\n");
}
void tpd_button(unsigned int x, unsigned int y, unsigned int down)
{
int i;
bool report;
if (down) {
for (i = 0; i < tpd_keycnt; i++) {
report = x >= tpd_keys_dim[i][0] -
(tpd_keys_dim[i][2] / 2) &&
x <= tpd_keys_dim[i][0] +
(tpd_keys_dim[i][2] / 2) &&
y >= tpd_keys_dim[i][1] -
(tpd_keys_dim[i][3] / 2) &&
y <= tpd_keys_dim[i][1] +
(tpd_keys_dim[i][3] / 2) &&
!(tpd->btn_state & (1 << i));
if (report) {
input_report_key(tpd->kpd, tpd_keys[i], 1);
input_sync(tpd->kpd);
tpd->btn_state |= (1 << i);
TPD_DEBUG("press key %d (%d)\n",
i, tpd_keys[i]);
}
}
} else {
for (i = 0; i < tpd_keycnt; i++) {
if (tpd->btn_state & (1 << i)) {
input_report_key(tpd->kpd, tpd_keys[i], 0);
input_sync(tpd->kpd);
TPD_DEBUG("release key %d (%d)\n",
i, tpd_keys[i]);
}
}
tpd->btn_state = 0;
}
}
void tpd_button_setting(int keycnt, void *keys, void *keys_dim)
{
tpd_keycnt = keycnt;
memcpy(tpd_keys, keys, keycnt * 4);
memcpy(tpd_keys_dim, keys_dim, keycnt * 4 * 4);
}
/* #endif */
@@ -0,0 +1,761 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#include "tpd.h"
#include <linux/slab.h>
#include <linux/device.h>
#include <linux/miscdevice.h>
#include <linux/device.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/fb.h>
#ifdef CONFIG_MTK_MT6306_GPIO_SUPPORT
#include <mtk_6306_gpio.h>
#endif
#ifdef CONFIG_COMPAT
#include <linux/compat.h>
#endif
#if defined(CONFIG_MTK_S3320) || defined(CONFIG_MTK_S3320_50) \
|| defined(CONFIG_MTK_S3320_47) || defined(CONFIG_MTK_MIT200) \
|| defined(CONFIG_TOUCHSCREEN_SYNAPTICS_S3528) \
|| defined(CONFIG_MTK_S7020) \
|| defined(CONFIG_TOUCHSCREEN_MTK_SYNAPTICS_3320_50)
#include <linux/input/mt.h>
#endif /* CONFIG_MTK_S3320 */
/* for magnify velocity******************************************** */
#define TOUCH_IOC_MAGIC 'A'
#define TPD_GET_VELOCITY_CUSTOM_X _IO(TOUCH_IOC_MAGIC, 0)
#define TPD_GET_VELOCITY_CUSTOM_Y _IO(TOUCH_IOC_MAGIC, 1)
#define TPD_GET_FILTER_PARA _IOWR(TOUCH_IOC_MAGIC, 2, struct tpd_filter_t)
#ifdef CONFIG_COMPAT
#define COMPAT_TPD_GET_FILTER_PARA _IOWR(TOUCH_IOC_MAGIC, \
2, struct tpd_filter_t)
#endif
struct tpd_filter_t tpd_filter;
struct tpd_dts_info tpd_dts_data;
struct pinctrl *pinctrl1;
struct pinctrl_state *pins_default;
struct pinctrl_state *eint_as_int, *eint_output0,
*eint_output1, *rst_output0, *rst_output1,
*pins_spi_mode;
const struct of_device_id touch_of_match[] = {
{ .compatible = "goodix,touch", },
{},
};
void tpd_get_dts_info(void)
{
struct device_node *node1 = NULL;
int key_dim_local[16], i;
node1 = of_find_matching_node(node1, touch_of_match);
if (node1) {
of_property_read_u32(node1,
"tpd-max-touch-num", &tpd_dts_data.touch_max_num);
of_property_read_u32(node1,
"use-tpd-button", &tpd_dts_data.use_tpd_button);
pr_debug("[tpd]use-tpd-button = %d\n",
tpd_dts_data.use_tpd_button);
if (of_property_read_u32_array(node1, "tpd-resolution",
tpd_dts_data.tpd_resolution,
ARRAY_SIZE(tpd_dts_data.tpd_resolution))) {
pr_debug("[tpd] resulution is %d %d",
tpd_dts_data.tpd_resolution[0],
tpd_dts_data.tpd_resolution[1]);
}
if (tpd_dts_data.use_tpd_button) {
of_property_read_u32(node1,
"tpd-key-num", &tpd_dts_data.tpd_key_num);
if (of_property_read_u32_array(node1, "tpd-key-local",
tpd_dts_data.tpd_key_local,
ARRAY_SIZE(tpd_dts_data.tpd_key_local)))
pr_debug("tpd-key-local: %d %d %d %d",
tpd_dts_data.tpd_key_local[0],
tpd_dts_data.tpd_key_local[1],
tpd_dts_data.tpd_key_local[2],
tpd_dts_data.tpd_key_local[3]);
if (of_property_read_u32_array(node1,
"tpd-key-dim-local",
key_dim_local, ARRAY_SIZE(key_dim_local))) {
memcpy(tpd_dts_data.tpd_key_dim_local,
key_dim_local, sizeof(key_dim_local));
for (i = 0; i < 4; i++) {
pr_debug("[tpd]key[%d].key_x = %d\n", i,
tpd_dts_data
.tpd_key_dim_local[i]
.key_x);
pr_debug("[tpd]key[%d].key_y = %d\n", i,
tpd_dts_data
.tpd_key_dim_local[i]
.key_y);
pr_debug("[tpd]key[%d].key_W = %d\n", i,
tpd_dts_data
.tpd_key_dim_local[i]
.key_width);
pr_debug("[tpd]key[%d].key_H = %d\n", i,
tpd_dts_data
.tpd_key_dim_local[i]
.key_height);
}
}
}
of_property_read_u32(node1, "tpd-filter-enable",
&tpd_dts_data.touch_filter.enable);
if (tpd_dts_data.touch_filter.enable) {
of_property_read_u32(node1,
"tpd-filter-pixel-density",
&tpd_dts_data.touch_filter.pixel_density);
if (of_property_read_u32_array(node1,
"tpd-filter-custom-prameters",
(u32 *)tpd_dts_data.touch_filter.W_W,
ARRAY_SIZE(tpd_dts_data.touch_filter.W_W)))
pr_debug("get tpd-filter-custom-parameters");
if (of_property_read_u32_array(node1,
"tpd-filter-custom-speed",
tpd_dts_data.touch_filter.VECLOCITY_THRESHOLD,
ARRAY_SIZE(tpd_dts_data
.touch_filter
.VECLOCITY_THRESHOLD)))
pr_debug("get tpd-filter-custom-speed");
}
memcpy(&tpd_filter,
&tpd_dts_data.touch_filter, sizeof(tpd_filter));
pr_debug("[tpd]tpd-filter-enable = %d, pixel_density = %d\n",
tpd_filter.enable, tpd_filter.pixel_density);
tpd_dts_data.tpd_use_ext_gpio =
of_property_read_bool(node1, "tpd-use-ext-gpio");
of_property_read_u32(node1,
"tpd-rst-ext-gpio-num",
&tpd_dts_data.rst_ext_gpio_num);
} else {
TPD_DMESG("can't find touch compatible custom node\n");
}
}
static DEFINE_MUTEX(tpd_set_gpio_mutex);
void tpd_gpio_as_int(int pin)
{
mutex_lock(&tpd_set_gpio_mutex);
TPD_DEBUG("[tpd]%s\n", __func__);
if (pin == 1)
pinctrl_select_state(pinctrl1, eint_as_int);
mutex_unlock(&tpd_set_gpio_mutex);
}
void tpd_gpio_mode_set(void)
{
mutex_lock(&tpd_set_gpio_mutex);
TPD_DEBUG("[tpd]%s set gpio mode!\n", __func__);
pinctrl_select_state(pinctrl1, pins_spi_mode);
mutex_unlock(&tpd_set_gpio_mutex);
}
void tpd_gpio_output(int pin, int level)
{
mutex_lock(&tpd_set_gpio_mutex);
TPD_DEBUG("%s pin = %d, level = %d\n", __func__, pin, level);
if (pin == 1) {
if (level)
pinctrl_select_state(pinctrl1, eint_output1);
else
pinctrl_select_state(pinctrl1, eint_output0);
} else {
if (tpd_dts_data.tpd_use_ext_gpio) {
#ifdef CONFIG_MTK_MT6306_GPIO_SUPPORT
mt6306_set_gpio_dir(
tpd_dts_data.rst_ext_gpio_num, 1);
mt6306_set_gpio_out(
tpd_dts_data.rst_ext_gpio_num, level);
#endif
} else {
if (level)
pinctrl_select_state(pinctrl1, rst_output1);
else
pinctrl_select_state(pinctrl1, rst_output0);
}
}
mutex_unlock(&tpd_set_gpio_mutex);
}
int tpd_get_gpio_info(struct platform_device *pdev)
{
int ret;
TPD_DEBUG("[tpd %d] mt_tpd_pinctrl+++++++++++++++++\n", pdev->id);
pinctrl1 = devm_pinctrl_get(&pdev->dev);
if (IS_ERR(pinctrl1)) {
ret = PTR_ERR(pinctrl1);
dev_info(&pdev->dev, "fwq Cannot find pinctrl1!\n");
return ret;
}
pins_default = pinctrl_lookup_state(pinctrl1, "default");
if (IS_ERR(pins_default)) {
ret = PTR_ERR(pins_default);
TPD_DMESG("Cannot find pinctrl default %d!\n", ret);
}
eint_as_int = pinctrl_lookup_state(pinctrl1, "state_eint_as_int");
if (IS_ERR(eint_as_int)) {
ret = PTR_ERR(eint_as_int);
TPD_DMESG("Cannot find pinctrl state_eint_as_int!\n");
return ret;
}
eint_output0 = pinctrl_lookup_state(pinctrl1, "state_eint_output0");
if (IS_ERR(eint_output0)) {
ret = PTR_ERR(eint_output0);
TPD_DMESG("Cannot find pinctrl state_eint_output0!\n");
return ret;
}
eint_output1 = pinctrl_lookup_state(pinctrl1, "state_eint_output1");
if (IS_ERR(eint_output1)) {
ret = PTR_ERR(eint_output1);
TPD_DMESG("Cannot find pinctrl state_eint_output1!\n");
return ret;
}
pins_spi_mode = pinctrl_lookup_state(pinctrl1, "state_spi_mode");
if (IS_ERR(pins_spi_mode)) {
ret = PTR_ERR(pins_spi_mode);
TPD_DMESG("Cannot find pinctrl state_spi_mode!\n");
return ret;
}
if (tpd_dts_data.tpd_use_ext_gpio == false) {
rst_output0 =
pinctrl_lookup_state(pinctrl1, "state_rst_output0");
if (IS_ERR(rst_output0)) {
ret = PTR_ERR(rst_output0);
TPD_DMESG("Cannot find pinctrl state_rst_output0!\n");
return ret;
}
rst_output1 =
pinctrl_lookup_state(pinctrl1, "state_rst_output1");
if (IS_ERR(rst_output1)) {
ret = PTR_ERR(rst_output1);
TPD_DMESG("Cannot find pinctrl state_rst_output1!\n");
return ret;
}
}
TPD_DEBUG("[tpd%d] mt_tpd_pinctrl----------\n", pdev->id);
return 0;
}
static int tpd_misc_open(struct inode *inode, struct file *file)
{
return nonseekable_open(inode, file);
}
static int tpd_misc_release(struct inode *inode, struct file *file)
{
return 0;
}
#ifdef CONFIG_COMPAT
static long tpd_compat_ioctl(
struct file *file, unsigned int cmd,
unsigned long arg)
{
long ret;
void __user *arg32 = compat_ptr(arg);
if (!file->f_op || !file->f_op->unlocked_ioctl)
return -ENOTTY;
switch (cmd) {
case COMPAT_TPD_GET_FILTER_PARA:
if (arg32 == NULL) {
pr_info("invalid argument.");
return -EINVAL;
}
ret = file->f_op->unlocked_ioctl(file, TPD_GET_FILTER_PARA,
(unsigned long)arg32);
if (ret) {
pr_info("TPD_GET_FILTER_PARA unlocked_ioctl failed.");
return ret;
}
break;
default:
pr_info("tpd: unknown IOCTL: 0x%08x\n", cmd);
ret = -ENOIOCTLCMD;
break;
}
return ret;
}
#endif
static long tpd_unlocked_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
/* char strbuf[256]; */
void __user *data;
long err = 0;
if (_IOC_DIR(cmd) & _IOC_READ)
err = !access_ok(VERIFY_WRITE,
(void __user *)arg, _IOC_SIZE(cmd));
else if (_IOC_DIR(cmd) & _IOC_WRITE)
err = !access_ok(VERIFY_READ,
(void __user *)arg, _IOC_SIZE(cmd));
if (err) {
pr_info("tpd: access error: %08X, (%2d, %2d)\n",
cmd, _IOC_DIR(cmd), _IOC_SIZE(cmd));
return -EFAULT;
}
switch (cmd) {
case TPD_GET_VELOCITY_CUSTOM_X:
data = (void __user *)arg;
if (data == NULL) {
err = -EINVAL;
break;
}
if (copy_to_user(data,
&tpd_v_magnify_x, sizeof(tpd_v_magnify_x))) {
err = -EFAULT;
break;
}
break;
case TPD_GET_VELOCITY_CUSTOM_Y:
data = (void __user *)arg;
if (data == NULL) {
err = -EINVAL;
break;
}
if (copy_to_user(data,
&tpd_v_magnify_y, sizeof(tpd_v_magnify_y))) {
err = -EFAULT;
break;
}
break;
case TPD_GET_FILTER_PARA:
data = (void __user *) arg;
if (data == NULL) {
err = -EINVAL;
TPD_DMESG("GET_FILTER_PARA: data is null\n");
break;
}
if (copy_to_user(data, &tpd_filter,
sizeof(struct tpd_filter_t))) {
TPD_DMESG("GET_FILTER_PARA: copy data error\n");
err = -EFAULT;
break;
}
break;
default:
pr_info("tpd: unknown IOCTL: 0x%08x\n", cmd);
err = -ENOIOCTLCMD;
break;
}
return err;
}
static struct work_struct touch_resume_work;
static struct workqueue_struct *touch_resume_workqueue;
static const struct file_operations tpd_fops = {
/* .owner = THIS_MODULE, */
.open = tpd_misc_open,
.release = tpd_misc_release,
.unlocked_ioctl = tpd_unlocked_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = tpd_compat_ioctl,
#endif
};
/*---------------------------------------------------------------------------*/
static struct miscdevice tpd_misc_device = {
.minor = MISC_DYNAMIC_MINOR,
.name = "touch",
.fops = &tpd_fops,
};
/* ********************************************** */
/* #endif */
/* function definitions */
static int __init tpd_device_init(void);
static void __exit tpd_device_exit(void);
static int tpd_probe(struct platform_device *pdev);
static int tpd_remove(struct platform_device *pdev);
static struct work_struct tpd_init_work;
static struct workqueue_struct *tpd_init_workqueue;
static int tpd_suspend_flag;
int tpd_register_flag;
/* global variable definitions */
struct tpd_device *tpd;
static struct tpd_driver_t tpd_driver_list[TP_DRV_MAX_COUNT]; /* = {0}; */
struct platform_device tpd_device = {
.name = TPD_DEVICE,
.id = -1,
};
const struct dev_pm_ops tpd_pm_ops = {
.suspend = NULL,
.resume = NULL,
};
static struct platform_driver tpd_driver = {
.remove = tpd_remove,
.shutdown = NULL,
.probe = tpd_probe,
.driver = {
.name = TPD_DEVICE,
.pm = &tpd_pm_ops,
.owner = THIS_MODULE,
.of_match_table = touch_of_match,
},
};
static struct tpd_driver_t *g_tpd_drv;
/* hh: use fb_notifier */
static struct notifier_block tpd_fb_notifier;
/* use fb_notifier */
static void touch_resume_workqueue_callback(struct work_struct *work)
{
TPD_DEBUG("GTP %s\n", __func__);
g_tpd_drv->resume(NULL);
tpd_suspend_flag = 0;
}
static int tpd_fb_notifier_callback(
struct notifier_block *self,
unsigned long event, void *data)
{
struct fb_event *evdata = NULL;
int blank;
int err = 0;
TPD_DEBUG("%s\n", __func__);
evdata = data;
/* If we aren't interested in this event, skip it immediately ... */
if (event != FB_EVENT_BLANK)
return 0;
blank = *(int *)evdata->data;
TPD_DMESG("fb_notify(blank=%d)\n", blank);
switch (blank) {
case FB_BLANK_UNBLANK:
TPD_DMESG("LCD ON Notify\n");
if (g_tpd_drv && tpd_suspend_flag) {
err = queue_work(touch_resume_workqueue,
&touch_resume_work);
if (!err) {
TPD_DMESG("start resume_workqueue failed\n");
return err;
}
}
break;
case FB_BLANK_POWERDOWN:
TPD_DMESG("LCD OFF Notify\n");
if (g_tpd_drv && !tpd_suspend_flag) {
err = cancel_work_sync(&touch_resume_work);
if (!err)
TPD_DMESG("cancel resume_workqueue failed\n");
g_tpd_drv->suspend(NULL);
}
tpd_suspend_flag = 1;
break;
default:
break;
}
return 0;
}
/* Add driver: if find TPD_TYPE_CAPACITIVE driver successfully, loading it */
int tpd_driver_add(struct tpd_driver_t *tpd_drv)
{
int i;
if (g_tpd_drv != NULL) {
TPD_DMESG("touch driver exist\n");
return -1;
}
/* check parameter */
if (tpd_drv == NULL)
return -1;
tpd_drv->tpd_have_button = tpd_dts_data.use_tpd_button;
/* R-touch */
if (strcmp(tpd_drv->tpd_device_name, "generic") == 0) {
tpd_driver_list[0].tpd_device_name = tpd_drv->tpd_device_name;
tpd_driver_list[0].tpd_local_init = tpd_drv->tpd_local_init;
tpd_driver_list[0].suspend = tpd_drv->suspend;
tpd_driver_list[0].resume = tpd_drv->resume;
tpd_driver_list[0].tpd_have_button = tpd_drv->tpd_have_button;
return 0;
}
for (i = 1; i < TP_DRV_MAX_COUNT; i++) {
/* add tpd driver into list */
if (tpd_driver_list[i].tpd_device_name == NULL) {
tpd_driver_list[i].tpd_device_name =
tpd_drv->tpd_device_name;
tpd_driver_list[i].tpd_local_init =
tpd_drv->tpd_local_init;
tpd_driver_list[i].suspend = tpd_drv->suspend;
tpd_driver_list[i].resume = tpd_drv->resume;
tpd_driver_list[i].tpd_have_button =
tpd_drv->tpd_have_button;
tpd_driver_list[i].attrs = tpd_drv->attrs;
break;
}
if (strcmp(tpd_driver_list[i].tpd_device_name,
tpd_drv->tpd_device_name) == 0)
return 1; /* driver exist */
}
return 0;
}
int tpd_driver_remove(struct tpd_driver_t *tpd_drv)
{
int i = 0;
/* check parameter */
if (tpd_drv == NULL)
return -1;
for (i = 0; i < TP_DRV_MAX_COUNT; i++) {
/* find it */
if (strcmp(tpd_driver_list[i].tpd_device_name,
tpd_drv->tpd_device_name) == 0) {
memset(&tpd_driver_list[i], 0,
sizeof(struct tpd_driver_t));
break;
}
}
return 0;
}
static void tpd_create_attributes(struct device *dev, struct tpd_attrs *attrs)
{
int num = attrs->num;
for (; num > 0;) {
if (device_create_file(dev, attrs->attr[--num]))
pr_info("mtk_tpd: tpd create attributes file failed\n");
}
}
/* touch panel probe */
static int tpd_probe(struct platform_device *pdev)
{
int touch_type = 1; /* 0:R-touch, 1: Cap-touch */
int i = 0;
#ifndef CONFIG_CUSTOM_LCM_X
#ifdef CONFIG_LCM_WIDTH
unsigned long tpd_res_x = 0, tpd_res_y = 0;
int ret = 0;
#endif
#endif
TPD_DMESG("enter %s, %d\n", __func__, __LINE__);
if (misc_register(&tpd_misc_device))
pr_info("mtk_tpd: tpd_misc_device register failed\n");
tpd_get_gpio_info(pdev);
tpd = kmalloc(sizeof(struct tpd_device), GFP_KERNEL);
if (tpd == NULL)
return -ENOMEM;
memset(tpd, 0, sizeof(struct tpd_device));
/* allocate input device */
tpd->dev = input_allocate_device();
if (tpd->dev == NULL) {
kfree(tpd);
return -ENOMEM;
}
/* TPD_RES_X = simple_strtoul(LCM_WIDTH, NULL, 0); */
/* TPD_RES_Y = simple_strtoul(LCM_HEIGHT, NULL, 0); */
#ifdef CONFIG_MTK_LCM_PHYSICAL_ROTATION
if (strncmp(CONFIG_MTK_LCM_PHYSICAL_ROTATION, "90", 2) == 0
|| strncmp(CONFIG_MTK_LCM_PHYSICAL_ROTATION, "270", 3) == 0) {
#ifdef CONFIG_MTK_FB
/*Fix build errors,as some projects cannot support these apis while bring up*/
TPD_RES_Y = DISP_GetScreenWidth();
TPD_RES_X = DISP_GetScreenHeight();
#endif
} else
#endif
{
#ifdef CONFIG_CUSTOM_LCM_X
#ifndef CONFIG_FPGA_EARLY_PORTING
#if defined(CONFIG_MTK_FB) && defined(CONFIG_MTK_LCM)
/*Fix build errors,as some projects cannot support these apis while bring up*/
TPD_RES_X = DISP_GetScreenWidth();
TPD_RES_Y = DISP_GetScreenHeight();
#else
/*for some projects, we do not use mtk framebuffer*/
TPD_RES_X = tpd_dts_data.tpd_resolution[0];
TPD_RES_Y = tpd_dts_data.tpd_resolution[1];
#endif
#endif
#else
#ifdef CONFIG_LCM_WIDTH
ret = kstrtoul(CONFIG_LCM_WIDTH, 0, &tpd_res_x);
if (ret < 0) {
pr_info("Touch down get lcm_x failed");
return ret;
}
TPD_RES_X = tpd_res_x;
ret = kstrtoul(CONFIG_LCM_HEIGHT, 0, &tpd_res_x);
if (ret < 0) {
pr_info("Touch down get lcm_y failed");
return ret;
}
TPD_RES_Y = tpd_res_y;
#endif
#endif
}
pr_debug("mtk_tpd: TPD_RES_X = %lu, TPD_RES_Y = %lu\n",
TPD_RES_X, TPD_RES_Y);
tpd_mode = TPD_MODE_NORMAL;
tpd_mode_axis = 0;
tpd_mode_min = TPD_RES_Y / 2;
tpd_mode_max = TPD_RES_Y;
tpd_mode_keypad_tolerance = TPD_RES_X * TPD_RES_X / 1600;
/* struct input_dev dev initialization and registration */
tpd->dev->name = TPD_DEVICE;
set_bit(EV_ABS, tpd->dev->evbit);
set_bit(EV_KEY, tpd->dev->evbit);
set_bit(ABS_X, tpd->dev->absbit);
set_bit(ABS_Y, tpd->dev->absbit);
set_bit(ABS_PRESSURE, tpd->dev->absbit);
#if !defined(CONFIG_MTK_S3320) && !defined(CONFIG_MTK_S3320_47)\
&& !defined(CONFIG_MTK_S3320_50) && !defined(CONFIG_MTK_MIT200) \
&& !defined(CONFIG_TOUCHSCREEN_SYNAPTICS_S3528) \
&& !defined(CONFIG_MTK_S7020) \
&& !defined(CONFIG_TOUCHSCREEN_MTK_SYNAPTICS_3320_50)
set_bit(BTN_TOUCH, tpd->dev->keybit);
#endif /* CONFIG_MTK_S3320 */
set_bit(INPUT_PROP_DIRECT, tpd->dev->propbit);
/* save dev for regulator_get() before tpd_local_init() */
tpd->tpd_dev = &pdev->dev;
for (i = 1; i < TP_DRV_MAX_COUNT; i++) {
/* add tpd driver into list */
if (tpd_driver_list[i].tpd_device_name != NULL) {
tpd_driver_list[i].tpd_local_init();
/* msleep(1); */
if (tpd_load_status == 1) {
TPD_DMESG("%s, tpd_driver_name=%s\n", __func__,
tpd_driver_list[i].tpd_device_name);
g_tpd_drv = &tpd_driver_list[i];
break;
}
}
}
if (g_tpd_drv == NULL) {
if (tpd_driver_list[0].tpd_device_name != NULL) {
g_tpd_drv = &tpd_driver_list[0];
/* touch_type:0: r-touch, 1: C-touch */
touch_type = 0;
g_tpd_drv->tpd_local_init();
TPD_DMESG("Generic touch panel driver\n");
} else {
TPD_DMESG("no touch driver is loaded!!\n");
return 0;
}
}
touch_resume_workqueue = create_singlethread_workqueue("touch_resume");
INIT_WORK(&touch_resume_work, touch_resume_workqueue_callback);
/* use fb_notifier */
tpd_fb_notifier.notifier_call = tpd_fb_notifier_callback;
if (fb_register_client(&tpd_fb_notifier))
TPD_DMESG("register fb_notifier fail!\n");
/* TPD_TYPE_CAPACITIVE handle */
if (touch_type == 1) {
set_bit(ABS_MT_TRACKING_ID, tpd->dev->absbit);
set_bit(ABS_MT_TOUCH_MAJOR, tpd->dev->absbit);
set_bit(ABS_MT_TOUCH_MINOR, tpd->dev->absbit);
set_bit(ABS_MT_POSITION_X, tpd->dev->absbit);
set_bit(ABS_MT_POSITION_Y, tpd->dev->absbit);
input_set_abs_params(tpd->dev,
ABS_MT_POSITION_X, 0, TPD_RES_X, 0, 0);
input_set_abs_params(tpd->dev,
ABS_MT_POSITION_Y, 0, TPD_RES_Y, 0, 0);
#if defined(CONFIG_MTK_S3320) || defined(CONFIG_MTK_S3320_47) \
|| defined(CONFIG_MTK_S3320_50) || defined(CONFIG_MTK_MIT200) \
|| defined(CONFIG_TOUCHSCREEN_SYNAPTICS_S3528) \
|| defined(CONFIG_MTK_S7020) \
|| defined(CONFIG_TOUCHSCREEN_MTK_SYNAPTICS_3320_50)
input_set_abs_params(tpd->dev,
ABS_MT_PRESSURE, 0, 255, 0, 0);
input_set_abs_params(tpd->dev,
ABS_MT_WIDTH_MAJOR, 0, 15, 0, 0);
input_set_abs_params(tpd->dev, ABS_MT_WIDTH_MINOR, 0, 15, 0, 0);
input_mt_init_slots(tpd->dev, 10, 0);
#else
input_set_abs_params(tpd->dev,
ABS_MT_TOUCH_MAJOR, 0, 100, 0, 0);
input_set_abs_params(tpd->dev,
ABS_MT_TOUCH_MINOR, 0, 100, 0, 0);
#endif /* CONFIG_MTK_S3320 */
TPD_DMESG("Cap touch panel driver\n");
}
input_set_abs_params(tpd->dev, ABS_X, 0, TPD_RES_X, 0, 0);
input_set_abs_params(tpd->dev, ABS_Y, 0, TPD_RES_Y, 0, 0);
input_abs_set_res(tpd->dev, ABS_X, TPD_RES_X);
input_abs_set_res(tpd->dev, ABS_Y, TPD_RES_Y);
input_set_abs_params(tpd->dev, ABS_PRESSURE, 0, 255, 0, 0);
input_set_abs_params(tpd->dev, ABS_MT_TRACKING_ID, 0, 10, 0, 0);
if (input_register_device(tpd->dev))
TPD_DMESG("input_register_device failed.(tpd)\n");
else
tpd_register_flag = 1;
if (g_tpd_drv->tpd_have_button)
tpd_button_init();
if (g_tpd_drv->attrs.num)
tpd_create_attributes(&pdev->dev, &g_tpd_drv->attrs);
return 0;
}
static int tpd_remove(struct platform_device *pdev)
{
input_unregister_device(tpd->dev);
return 0;
}
/* called when loaded into kernel */
static void tpd_init_work_callback(struct work_struct *work)
{
TPD_DEBUG("MediaTek touch panel driver init\n");
if (platform_driver_register(&tpd_driver) != 0)
TPD_DMESG("unable to register touch panel driver.\n");
}
static int __init tpd_device_init(void)
{
int res = 0;
tpd_init_workqueue = create_singlethread_workqueue("mtk-tpd");
INIT_WORK(&tpd_init_work, tpd_init_work_callback);
res = queue_work(tpd_init_workqueue, &tpd_init_work);
if (!res)
pr_info("tpd : touch device init failed res:%d\n", res);
return 0;
}
/* should never be called */
static void __exit tpd_device_exit(void)
{
TPD_DMESG("MediaTek touch panel driver exit\n");
/* input_unregister_device(tpd->dev); */
platform_driver_unregister(&tpd_driver);
}
late_initcall(tpd_device_init);
module_exit(tpd_device_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("MediaTek touch panel driver");
MODULE_AUTHOR("Kirby Wu<kirby.wu@mediatek.com>");
@@ -0,0 +1,437 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#include <linux/vmalloc.h>
#include <linux/uaccess.h>
#include <linux/major.h>
#include <linux/miscdevice.h>
#include <linux/i2c.h>
#include <linux/delay.h>
#include "tpd.h"
#include "met_ftrace_touch.h"
#ifdef TPD_DEBUG_CODE
int tpd_fail_count;
int tpd_trial_count;
int tpd_debug_nr;
module_param(tpd_debug_nr, int, 0644);
module_param(tpd_fail_count, int, 0644);
module_param(tpd_trial_count, int, 0644);
int tpd_debug_time;
long tpd_last_2_int_time[2] = { 0 };
long tpd_last_down_time;
int tpd_start_profiling;
int tpd_down_status;
module_param(tpd_debug_time, int, 0644);
void tpd_debug_set_time(void)
{
struct timeval t;
if (!tpd_debug_time && !tpd_em_log)
return;
do_gettimeofday(&t);
tpd_last_2_int_time[0] = tpd_last_2_int_time[1];
tpd_last_2_int_time[1] = (t.tv_sec & 0xFFF) * 1000000 + t.tv_usec;
/* */
/* Start profiling while receive touch DOWN event */
/* Stop profiling while the first frame is upadted */
/* */
if (!tpd_down_status) {
tpd_start_profiling = 1;
tpd_last_down_time = tpd_last_2_int_time[1];
}
}
#ifdef TPD_DEBUG_TRACK
int tpd_debug_track;
int tpd_debug_track_color;
int tpd_debug_touch_up;
module_param(tpd_debug_track, int, 0644);
void tpd_draw(int x, int y)
{
UINT16 *buf = (UINT16 *) dal_fb_addr;
buf = buf + (x + y * TPD_RES_X);
tpd_debug_track_color += (tpd_debug_track_color >= 31 ? 0 : 1);
*buf = (0xffe0 + tpd_debug_track_color);
}
void tpd_down_debug_track(int x, int y)
{
if (tpd_debug_touch_up == 1) {
DAL_Clean();
tpd_debug_touch_up = 0;
}
LCD_LayerEnable(5, TRUE);
tpd_draw(x - 1, y - 1);
tpd_draw(x, y - 1);
tpd_draw(x + 1, y - 1);
tpd_draw(x - 1, y);
tpd_draw(x + 1, y);
tpd_draw(x - 1, y + 1);
tpd_draw(x, y + 1);
tpd_draw(x + 1, y + 1);
}
void tpd_up_debug_track(int x, int y)
{
if (x == 0 && y == 0) {
tpd_debug_track_color = 0;
DAL_Clean();
}
tpd_debug_touch_up = 1;
}
#endif /* TPD_DEBUG_TRACK */
#define BUFFER_SIZE 128
int tpd_em_log;
module_param(tpd_em_log, int, 0664);
void tpd_enable_em_log(int enable)
{
if (enable)
tpd_em_log = 1;
else
tpd_em_log = 0;
}
EXPORT_SYMBOL(tpd_enable_em_log);
int tpd_em_log_to_fs;
module_param(tpd_em_log_to_fs, int, 0664);
int tpd_em_log_first = 1;
struct tpd_em_log_struct {
struct list_head list;
char data[BUFFER_SIZE];
};
static LIST_HEAD(tpd_em_log_list);
int tpd_log_line_buffer = 128; /* per line 128 bytes */
int tpd_log_line_cnt = 1024 * 10;
module_param(tpd_log_line_buffer, int, 0664);
module_param(tpd_log_line_cnt, int, 0664);
struct tpd_debug_log_buf {
unsigned int head;
unsigned int tail;
spinlock_t buffer_lock;
unsigned int cnt;
unsigned char *buffer;
};
struct tpd_debug_log_buf tpd_buf;
static int tpd_debug_log_open(struct inode *inode, struct file *file)
{
if (tpd_buf.buffer == NULL)
tpd_buf.buffer =
vmalloc(tpd_log_line_cnt * tpd_log_line_buffer);
if (tpd_buf.buffer == NULL) {
pr_info("tpd_log: nomem for tpd_buf->buffer\n");
return -ENOMEM;
}
spin_lock(&tpd_buf.buffer_lock);
tpd_buf.head = tpd_buf.tail = 0;
tpd_buf.cnt = 0;
spin_unlock(&tpd_buf.buffer_lock);
file->private_data = &tpd_buf;
pr_debug("[tpd_em_log]: open log file\n");
return 0;
}
static int tpd_debug_log_release(struct inode *inode, struct file *file)
{
unsigned char *tmp_buffer = NULL;
pr_debug("[tpd_em_log]: close log file\n");
spin_lock(&tpd_buf.buffer_lock);
tmp_buffer = tpd_buf.buffer;
tpd_buf.buffer = NULL;
spin_unlock(&tpd_buf.buffer_lock);
if (tmp_buffer)
vfree(tmp_buffer);
/* free(tpd_buf); */
return 0;
}
static ssize_t tpd_debug_log_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos)
{
return 0;
}
static ssize_t tpd_debug_log_read(struct file *file, char __user *buffer,
size_t count, loff_t *ppos)
{
struct tpd_debug_log_buf *tpd_buf =
(struct tpd_debug_log_buf *)file->private_data;
unsigned int retval = 0, unit = tpd_log_line_buffer;
unsigned char *tmp_buf = NULL;
if (tpd_buf == NULL)
return -ENOMEM;
if (tpd_buf->head == tpd_buf->tail && (file->f_flags & O_NONBLOCK))
return -EAGAIN;
while ((count - retval) >= unit) {
spin_lock_irq(&tpd_buf->buffer_lock);
if (tpd_buf->head != tpd_buf->tail) {
tmp_buf = &tpd_buf->buffer[tpd_buf->tail++ * unit];
tpd_buf->tail &= tpd_log_line_cnt - 1;
} else {
spin_unlock_irq(&tpd_buf->buffer_lock);
break;
}
spin_unlock_irq(&tpd_buf->buffer_lock);
/* pr_info("%s, tmp_buf:0x%x\n", tmp_buf, tmp_buf); */
if (copy_to_user(buffer + retval, tmp_buf, unit))
return -EFAULT;
retval += unit;
}
return retval;
}
static unsigned char *tpd_log_find_buffer(void)
{
unsigned char *buffer = NULL;
unsigned int unit = tpd_log_line_buffer;
if (tpd_buf.buffer == NULL) {
pr_info("[tpd_em_log] :tpd_buf.buffer is NULL\n");
return NULL;
}
spin_lock(&tpd_buf.buffer_lock);
buffer = &tpd_buf.buffer[tpd_buf.head++ * unit];
tpd_buf.head &= tpd_log_line_cnt - 1;
spin_unlock(&tpd_buf.buffer_lock);
if (tpd_buf.head == tpd_buf.tail) {
snprintf(buffer, unit, "[tpd_em_log] overlay !!!!!\n");
return NULL;
}
memset(buffer, 0, unit);
return buffer;
}
static const struct file_operations tpd_debug_log_fops = {
.owner = THIS_MODULE,
.read = tpd_debug_log_read,
.write = tpd_debug_log_write,
.open = tpd_debug_log_open,
.release = tpd_debug_log_release,
};
static struct miscdevice tpd_debug_log_dev = {
.minor = MISC_DYNAMIC_MINOR,
.name = "tpd_em_log",
.fops = &tpd_debug_log_fops,
};
#ifndef CREATE_TRACE_POINTS
#define CREATE_TRACE_POINTS
#endif
noinline void MET_touch(int raw_x, int raw_y,
int cal_x, int cal_y, int p, int down)
{
struct timeval t;
do_gettimeofday(&t);
if ((tpd_down_status == 0 && down == 1) ||
(tpd_down_status == 1 && down == 0)) {
trace_MET_touch("EV_KEY",
t.tv_sec, t.tv_usec, "BTN_TOUCH", down);
tpd_down_status = !tpd_down_status;
}
if (tpd_down_status) {
trace_MET_touch("EV_ABS", t.tv_sec, t.tv_usec, "X", raw_x);
trace_MET_touch("EV_ABS", t.tv_sec, t.tv_usec, "Y", raw_y);
}
}
void tpd_em_log_output(int raw_x, int raw_y,
int cal_x, int cal_y, int p, int down)
{
if (down == TPD_TYPE_INT_DOWN) {
pr_debug("[tpd_em_log] int trigger down\n");
} else if (down == TPD_TYPE_INT_UP) {
pr_debug("[tpd_em_log] int trigger up\n");
} else if (down == TPD_TYPE_TIMER) {
pr_debug("[tpd_em_log] timer trigger\n");
} else if (down == TPD_TYPE_RAW_DATA) {
if (tpd_em_log == TPD_TYPE_RAW_DATA) {
pr_debug("[tpd_em_log] rx=%d,ry=%d,rz1=%d"
SPLIT "rz2=%d,p=%d,r\n",
raw_x, raw_y, cal_x, cal_y, p);
}
} else if (down == TPD_TYPE_REJECT1) {
pr_debug("[tpd_em_log] the first or last point is rejected\n");
} else if (down == TPD_TYPE_REJECT2) {
pr_debug
("[tpd_em_log] pressure(%d) > NICE_PRESSURE(%d)"
SPLIT "debounce debt0:%d ms, debt1:%d ms, spl_num:%d\n",
raw_x, raw_y, cal_x, cal_y, p);
} else if (down == TPD_TYPE_FIST_LATENCY) {
pr_debug("[tpd_em_log] The first touch latency is %d ms\n",
raw_x / 1000);
} else if (down && tpd_down_status == 0) {
pr_debug("[tpd_em_log] rx=%d,ry=%d,cx=%d"
SPLIT "cy=%d,p=%d,d(+%ld ms)\n",
raw_x, raw_y, cal_x, cal_y, p,
(tpd_last_2_int_time[1] -
tpd_last_2_int_time[0]) / 1000);
} else if (down && tpd_down_status != 0) {
pr_debug("[tpd_em_log] rx=%d,ry=%d,cx=%d"
SPLIT "cy=%d,p=%d,m(+%ld ms)\n",
raw_x, raw_y, cal_x, cal_y, p,
(tpd_last_2_int_time[1] -
tpd_last_2_int_time[0]) / 1000);
} else {
pr_debug("[tpd_em_log] rx=%d,ry=%d,cx=%d"
SPLIT "cy=%d,p=%d,u(+%ld ms)\n",
raw_x, raw_y, cal_x, cal_y, p,
(tpd_last_2_int_time[1] -
tpd_last_2_int_time[0]) / 1000);
}
}
void tpd_em_log_store(int raw_x, int raw_y,
int cal_x, int cal_y, int p, int down)
{
/* static struct proc_dir_entry *entry = NULL; */
/* struct tpd_em_log_struct *tpd_em_log_struct_new; */
struct timeval t;
unsigned char *buffer = NULL;
/* unsigned int unit = tpd_log_line_buffer; */
/* pr_info("[tpd_em_log]: start register log file"); */
buffer = tpd_log_find_buffer();
if (buffer == NULL) {
pr_info("not buffer\n");
return;
}
do_gettimeofday(&t);
if (down == TPD_TYPE_INT_DOWN) {
snprintf(buffer, tpd_log_line_buffer,
"[%5lu.%06lu][tpd_em_log] int trigger down\n",
(t.tv_sec & 0xFFF), t.tv_usec);
} else if (down == TPD_TYPE_INT_UP) {
snprintf(buffer, tpd_log_line_buffer,
"[%5lu.%06lu][tpd_em_log] int trigger up\n",
(t.tv_sec & 0xFFF), t.tv_usec);
} else if (down == TPD_TYPE_TIMER) {
snprintf(buffer, tpd_log_line_buffer,
"[%5lu.%06lu][tpd_em_log] timer trigger\n",
(t.tv_sec & 0xFFF), t.tv_usec);
} else if (down == TPD_TYPE_RAW_DATA) {
if (tpd_em_log == TPD_TYPE_RAW_DATA) {
snprintf(buffer, tpd_log_line_buffer,
"[%5lu.%06lu][tpd_em_log]"
SPLIT "rx=%d,ry=%d,rz1=%d,rz2=%d,p=%d,r\n",
(t.tv_sec & 0xFFF), t.tv_usec,
raw_x, raw_y, cal_x, cal_y, p);
}
} else if (down == TPD_TYPE_REJECT1) {
snprintf(buffer, tpd_log_line_buffer,
"[%5lu.%06lu][tpd_em_log]"
SPLIT "the first or last point is rejected\n",
(t.tv_sec & 0xFFF), t.tv_usec);
} else if (down == TPD_TYPE_REJECT2) {
snprintf(buffer, tpd_log_line_buffer,
"[%5lu.%06lu][tpd_em_log]"
SPLIT "pressure(%d) > NICE_PRESSURE(%d), "
SPLIT "debounce debt0:%d, debt1:%d, spl_num:%d\n",
(t.tv_sec & 0xFFF), t.tv_usec,
raw_x, raw_y, cal_x, cal_y, p);
} else if (down == TPD_TYPE_FIST_LATENCY) {
snprintf(buffer, tpd_log_line_buffer,
"[%5lu.%06lu][tpd_em_log]"
SPLIT "The first touch latency is %d ms\n",
(t.tv_sec & 0xFFF), t.tv_usec, raw_x / 1000);
} else if (down && tpd_down_status == 0) {
snprintf(buffer, tpd_log_line_buffer,
"[%5lu.%06lu][tpd_em_log]"
SPLIT "rx=%d,ry=%d,cx=%d,cy=%d,p=%d,d(+%ld ms)\n",
(t.tv_sec & 0xFFF), t.tv_usec,
raw_x, raw_y, cal_x, cal_y, p,
(tpd_last_2_int_time[1] -
tpd_last_2_int_time[0]) / 1000);
} else if (down && tpd_down_status != 0) {
snprintf(buffer, tpd_log_line_buffer,
"[%5lu.%06lu][tpd_em_log]"
SPLIT "rx=%d,ry=%d,cx=%d,cy=%d,p=%d,d(+%ld ms)\n",
(t.tv_sec & 0xFFF), t.tv_usec,
raw_x, raw_y, cal_x, cal_y, p,
(tpd_last_2_int_time[1] -
tpd_last_2_int_time[0]) / 1000);
} else {
snprintf(buffer, tpd_log_line_buffer,
"[%5lu.%06lu][tpd_em_log]"
SPLIT "rx=%d,ry=%d,cx=%d,cy=%d,p=%d,u(+%ld ms)\n",
(t.tv_sec & 0xFFF), t.tv_usec,
raw_x, raw_y, cal_x, cal_y, p,
(tpd_last_2_int_time[1] -
tpd_last_2_int_time[0]) / 1000);
}
/* list_add_tail(&tpd_em_log_struct_new->list, &tpd_em_log_list); */
}
void tpd_em_log_release(void)
{
struct tpd_em_log_struct *p, *p_tmp;
if (!tpd_em_log_first) {
remove_proc_entry("tpd_em_log", NULL);
list_for_each_entry_safe(p, p_tmp, &tpd_em_log_list, list) {
list_del(&p->list);
kfree(p);
}
tpd_em_log_first = 1;
tpd_em_log_to_fs = 0;
}
}
static int __init tpd_log_init(void)
{
if (misc_register(&tpd_debug_log_dev) < 0) {
pr_info("[tpd_em_log] :register device failed\n");
return -1;
}
pr_info("[tpd_em_log] :register device successfully\n");
spin_lock_init(&tpd_buf.buffer_lock);
return 0;
}
int tpd_debuglog;
module_param(tpd_debuglog, int, 0664);
module_init(tpd_log_init);
#endif /* TPD_DEBUG_CODE */
@@ -0,0 +1,144 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#ifndef TPD_DEBUG_H
#define TPD_DEBUG_H
#ifdef TPD_DEBUG_CODE
#include<linux/i2c.h>
extern int tpd_debug_nr;
void tpd_debug_set_time(void);
extern int tpd_debug_time;
extern long tpd_last_2_int_time[2];
extern long tpd_last_down_time;
extern int tpd_start_profiling;
extern int tpd_down_status;
#define TPD_DEBUG_PRINT_INT \
do { \
if (tpd_debug_time) { \
pr_info("tp_int\n"); \
} \
} while (0)
#define TPD_DEBUG_PRINT_UP \
do { \
if (pending == 0 && tpd_debug_time) { \
tpd_down_status = 0; \
pr_debug("up on %ld ms (+%ld ms)\n", \
(tpd_last_2_int_time[1] - tpd_last_down_time) / 1000, \
(tpd_last_2_int_time[1] - tpd_last_2_int_time[0]) / 1000); \
} \
} while (0)
#define TPD_DEBUG_PRINT_DOWN \
do { \
if (tpd_debug_time) { \
if (tpd_down_status == 0)\
pr_debug("down on 0 ms\n"); \
else \
pr_debug("move on %ld ms (+%ld ms)\n", \
(tpd_last_2_int_time[1] - \
tpd_last_down_time) / 1000, \
(tpd_last_2_int_time[1] -\
tpd_last_2_int_time[0]) / 1000); \
tpd_down_status = 1; \
} \
} while (0)
#define TPD_DEBUG_SET_TIME do { tpd_debug_set_time(); } while (0)
extern int tpd_em_log;
extern int tpd_em_log_to_fs;
extern int tpd_type_cap;
void tpd_em_log_output(int raw_x,
int raw_y, int cal_x, int cal_y, int p, int down);
void tpd_em_log_store(int raw_x,
int raw_y, int cal_x, int cal_y, int p, int down);
void tpd_em_log_release(void);
void tpd_enable_em_log(int enable);
#ifndef CREATE_TRACE_POINTS
#define CREATE_TRACE_POINTS
#endif
noinline void MET_touch(int raw_x, int raw_y,
int cal_x, int cal_y, int p, int down);
#define TPD_TYPE_RAW_DATA 2
#define TPD_TYPE_INT_DOWN 3
#define TPD_TYPE_INT_UP 4
#define TPD_TYPE_TIMER 5
#define TPD_TYPE_REJECT1 6
#define TPD_TYPE_REJECT2 7
#define TPD_TYPE_FIST_LATENCY 8
#define TPD_EM_PRINT(raw_x, raw_y, cal_x, cal_y, p, down)\
do { \
if (tpd_em_log) {\
if (!tpd_em_log_to_fs) { \
tpd_em_log_output(raw_x, \
raw_y, cal_x, cal_y, p, down); \
} else { \
tpd_em_log_store(raw_x, \
raw_y, cal_x, cal_y, p, down); \
tpd_em_log_output(raw_x, \
raw_y, cal_x, cal_y, p, down); \
} \
} else { \
if (tpd_em_log_to_fs) { \
tpd_em_log_release(); \
} \
} \
MET_touch(raw_x, raw_y, cal_x, cal_y, p, down); \
} while (0)
#ifdef TPD_DEBUG_TRACK
extern void *dal_fb_addr;
extern int tpd_debug_track;
void tpd_up_debug_track(int x, int y);
void tpd_down_debug_track(int x, int y);
#define TPD_UP_DEBUG_TRACK(x, y) \
do { \
if (tpd_debug_track) \
tpd_up_debug_track(x, y); \
} while (0)
#define TPD_DOWN_DEBUG_TRACK(x, y) \
do { \
if (tpd_debug_track) \
tpd_down_debug_track(x, y); \
} while (0)
#endif /* TPD_DEBUG_TRACK */
#endif /* TPD_DEBUG_CODE */
/* Macros that will be embedded in code */
#ifndef TPD_DEBUG_SET_TIME
#define TPD_DEBUG_SET_TIME
#endif
#ifndef TPD_DEBUG_PRINT_UP
#define TPD_DEBUG_PRINT_UP
#endif
#ifndef TPD_DEBUG_PRINT_DOWN
#define TPD_DEBUG_PRINT_DOWN
#endif
#ifndef TPD_UP_DEBUG_TRACK
#define TPD_UP_DEBUG_TRACK(x, y)
#endif
#ifndef TPD_DOWN_DEBUG_TRACK
#define TPD_DOWN_DEBUG_TRACK(x, y)
#endif
#endif /* TPD_DEBUG_H */
@@ -0,0 +1,20 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#include "tpd.h"
/* #ifndef TPD_CUSTOM_TREMBLE_TOLERANCE */
int tpd_trembling_tolerance(int t, int p)
{
if (t > 5 || p > 120)
return 200;
if (p > 90)
return 64;
if (p > 80)
return 36;
return 26;
}
/* #endif */
@@ -0,0 +1,10 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#ifndef TPD_FAT_TOUCH
#define TPD_FAT_TOUCH 120
#endif
int tpd_trembling_tolerance(int t, int p);
@@ -0,0 +1,48 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#include "tpd.h"
int tpd_calibrate_en;
module_param(tpd_calibrate_en, int, 0664);
int tpd_show_version;
module_param(tpd_show_version, int, 0664);
/* switch touch panel into single scan mode for decreasing interference */
void tpd_switch_single_mode(void)
{
#ifdef HAVE_SINGLE_MULTIPLE_SCAN_MODE
_tpd_switch_single_mode();
#endif
}
EXPORT_SYMBOL(tpd_switch_single_mode);
/* switch touch panel into multiple scan mode for better performance */
void tpd_switch_multiple_mode(void)
{
#ifdef HAVE_SINGLE_MULTIPLE_SCAN_MODE
_tpd_switch_multiple_mode();
#endif
}
EXPORT_SYMBOL(tpd_switch_multiple_mode);
/* switch touch panel into deep sleep mode */
void tpd_switch_sleep_mode(void)
{
#ifdef HAVE_SLEEP_NORMAL_MODE
_tpd_switch_sleep_mode();
#endif
}
EXPORT_SYMBOL(tpd_switch_sleep_mode);
/* switch touch panel back to normal mode */
void tpd_switch_normal_mode(void)
{
#ifdef HAVE_SLEEP_NORMAL_MODE
_tpd_switch_normal_mode();
#endif
}
EXPORT_SYMBOL(tpd_switch_normal_mode);
@@ -0,0 +1,69 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2019 MediaTek Inc.
*/
#include "tpd.h"
unsigned long TPD_RES_X = 480;
unsigned long TPD_RES_Y = 800;
/* #if (defined(TPD_HAVE_CALIBRATION) && !defined(TPD_CUSTOM_CALIBRATION)) */
int tpd_calmat[8] = { 0 };
int tpd_def_calmat[8] = { 0 };
int tpd_calmat_size = 8;
int tpd_def_calmat_size = 8;
module_param_array(tpd_calmat, int, &tpd_calmat_size, 0664);
module_param_array(tpd_def_calmat, int, &tpd_def_calmat_size, 0444);
/* #endif */
/* #ifdef TPD_TYPE_CAPACITIVE */
int tpd_type_cap;
int tpd_v_magnify_x = 10;
int tpd_v_magnify_y = 10;
module_param(tpd_v_magnify_x, int, 0664);
module_param(tpd_v_magnify_y, int, 0664);
module_param(tpd_type_cap, int, 0444);
int tpd_firmware_version[2] = { 0, 0 };
int tpd_firmware_version_size = 2;
module_param_array(tpd_firmware_version, int, &tpd_firmware_version_size, 0444);
int tpd_mode = TPD_MODE_NORMAL;
int tpd_mode_axis;
int tpd_mode_min = 400; /* TPD_RES_Y/2; */
int tpd_mode_max = 800; /* TPD_RES_Y; */
/* TPD_RES_X*TPD_RES_X/1600; */
int tpd_mode_keypad_tolerance = 480 * 480 / 1600;
module_param(tpd_mode, int, 0664);
module_param(tpd_mode_axis, int, 0664);
module_param(tpd_mode_min, int, 0664);
module_param(tpd_mode_max, int, 0664);
module_param(tpd_mode_keypad_tolerance, int, 0664);
int tpd_em_debounce_time0 = 1;
int tpd_em_debounce_time; /* =0 */
int tpd_em_debounce_time1 = 4;
module_param(tpd_em_debounce_time0, int, 0664);
module_param(tpd_em_debounce_time1, int, 0664);
module_param(tpd_em_debounce_time, int, 0664);
int tpd_em_spl_num = 1;
module_param(tpd_em_spl_num, int, 0664);
int tpd_em_pressure_threshold;
module_param(tpd_em_pressure_threshold, int, 0664);
int tpd_em_auto_time_interval = 10;
module_param(tpd_em_auto_time_interval, int, 0664);
int tpd_em_sample_cnt = 16;
module_param(tpd_em_sample_cnt, int, 0664);
int tpd_load_status;
module_param(tpd_load_status, int, 0664);
int tpd_em_asamp = 1;
module_param(tpd_em_asamp, int, 0664);