mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
dirvers: input: touchscreen: add focaltech ft5436
Signed-off-by: Weixin Zhou <zwx@rock-chips.com> Change-Id: I51437c0b5c81698d2b7e451d2843a55d23c3eb28
This commit is contained in:
@@ -1401,6 +1401,14 @@ config TOUCHSCREEN_FTS
|
||||
Say Y here if you have Focaltech touch panel.
|
||||
If unsure, say N.
|
||||
|
||||
config TOUCHSCREEN_FT5436
|
||||
bool "Focaltech Touchscreen FT5436"
|
||||
depends on I2C
|
||||
default n
|
||||
help
|
||||
Say Y here if you have Focaltech touch panel.
|
||||
If unsure, say N.
|
||||
|
||||
source "drivers/input/touchscreen/cyttsp5/Kconfig"
|
||||
|
||||
endif
|
||||
|
||||
@@ -126,4 +126,5 @@ obj-$(CONFIG_TOUCHSCREEN_VTL_CT36X) += vtl_ts/
|
||||
obj-$(CONFIG_TOUCHSCREEN_GT1X) += gt1x/
|
||||
obj-$(CONFIG_TOUCHSCREEN_HYN_CST2XX) += hyn_cst2xx/
|
||||
obj-$(CONFIG_TOUCHSCREEN_FTS) += focaltech_touch/
|
||||
obj-$(CONFIG_TOUCHSCREEN_FT5436) += focaltech_touch_ft5436/
|
||||
obj-$(CONFIG_TOUCHSCREEN_CYPRESS_CYTTSP5) += cyttsp5/
|
||||
|
||||
16
drivers/input/touchscreen/focaltech_touch_ft5436/Makefile
Normal file
16
drivers/input/touchscreen/focaltech_touch_ft5436/Makefile
Normal file
@@ -0,0 +1,16 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
# Makefile for the focaltech touchscreen drivers.
|
||||
#
|
||||
|
||||
# Makefile for the focaltech touchscreen drivers.
|
||||
|
||||
obj-y += focaltech_core.o
|
||||
obj-y += focaltech_ex_fun.o
|
||||
obj-y += focaltech_ex_mode.o
|
||||
obj-y += focaltech_gesture.o
|
||||
obj-y += focaltech_esdcheck.o
|
||||
obj-y += focaltech_point_report_check.o
|
||||
obj-y += focaltech_i2c.o
|
||||
obj-y += focaltech_flash.o
|
||||
obj-y += focaltech_flash/
|
||||
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
*
|
||||
* FocalTech fts TouchScreen driver.
|
||||
*
|
||||
* Copyright (c) 2012-2019, Focaltech Ltd. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
/*****************************************************************************
|
||||
*
|
||||
* File Name: focaltech_common.h
|
||||
*
|
||||
* Author: Focaltech Driver Team
|
||||
*
|
||||
* Created: 2016-08-16
|
||||
*
|
||||
* Abstract:
|
||||
*
|
||||
* Reference:
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __LINUX_FOCALTECH_COMMON_H__
|
||||
#define __LINUX_FOCALTECH_COMMON_H__
|
||||
|
||||
#include "focaltech_config.h"
|
||||
|
||||
/*****************************************************************************
|
||||
* Macro definitions using #define
|
||||
*****************************************************************************/
|
||||
#define FTS_DRIVER_VERSION "Focaltech V3.1 20190807"
|
||||
|
||||
#define BYTE_OFF_0(x) (u8)((x) & 0xFF)
|
||||
#define BYTE_OFF_8(x) (u8)(((x) >> 8) & 0xFF)
|
||||
#define BYTE_OFF_16(x) (u8)(((x) >> 16) & 0xFF)
|
||||
#define BYTE_OFF_24(x) (u8)(((x) >> 24) & 0xFF)
|
||||
#define FLAGBIT(x) (0x00000001 << (x))
|
||||
#define FLAGBITS(x, y) ((0xFFFFFFFF >> (32 - (y) - 1)) & (0xFFFFFFFF << (x)))
|
||||
|
||||
#define FLAG_ICSERIALS_LEN 8
|
||||
#define FLAG_HID_BIT 10
|
||||
#define FLAG_IDC_BIT 11
|
||||
|
||||
#define IC_SERIALS (FTS_CHIP_TYPE & FLAGBITS(0, FLAG_ICSERIALS_LEN-1))
|
||||
#define IC_TO_SERIALS(x) ((x) & FLAGBITS(0, FLAG_ICSERIALS_LEN-1))
|
||||
#define FTS_CHIP_IDC ((FTS_CHIP_TYPE & FLAGBIT(FLAG_IDC_BIT)) == FLAGBIT(FLAG_IDC_BIT))
|
||||
#define FTS_HID_SUPPORTTED ((FTS_CHIP_TYPE & FLAGBIT(FLAG_HID_BIT)) == FLAGBIT(FLAG_HID_BIT))
|
||||
|
||||
#define FTS_CHIP_TYPE_MAPPING {{0x02, 0x54, 0x22, 0x54, 0x22, 0x00, 0x00, 0x54, 0x2C}}
|
||||
|
||||
#define FILE_NAME_LENGTH 128
|
||||
#define ENABLE 1
|
||||
#define DISABLE 0
|
||||
#define VALID 1
|
||||
#define INVALID 0
|
||||
#define FTS_CMD_START1 0x55
|
||||
#define FTS_CMD_START2 0xAA
|
||||
#define FTS_CMD_START_DELAY 12
|
||||
#define FTS_CMD_READ_ID 0x90
|
||||
#define FTS_CMD_READ_ID_LEN 4
|
||||
#define FTS_CMD_READ_ID_LEN_INCELL 1
|
||||
/*register address*/
|
||||
#define FTS_REG_INT_CNT 0x8F
|
||||
#define FTS_REG_FLOW_WORK_CNT 0x91
|
||||
#define FTS_REG_WORKMODE 0x00
|
||||
#define FTS_REG_WORKMODE_FACTORY_VALUE 0x40
|
||||
#define FTS_REG_WORKMODE_WORK_VALUE 0x00
|
||||
#define FTS_REG_ESDCHECK_DISABLE 0x8D
|
||||
#define FTS_REG_CHIP_ID 0xA3
|
||||
#define FTS_REG_CHIP_ID2 0x9F
|
||||
#define FTS_REG_POWER_MODE 0xA5
|
||||
#define FTS_REG_POWER_MODE_SLEEP 0x03
|
||||
#define FTS_REG_FW_VER 0xA6
|
||||
#define FTS_REG_VENDOR_ID 0xA8
|
||||
#define FTS_REG_LCD_BUSY_NUM 0xAB
|
||||
#define FTS_REG_FACE_DEC_MODE_EN 0xB0
|
||||
#define FTS_REG_FACTORY_MODE_DETACH_FLAG 0xB4
|
||||
#define FTS_REG_FACE_DEC_MODE_STATUS 0x01
|
||||
#define FTS_REG_IDE_PARA_VER_ID 0xB5
|
||||
#define FTS_REG_IDE_PARA_STATUS 0xB6
|
||||
#define FTS_REG_GLOVE_MODE_EN 0xC0
|
||||
#define FTS_REG_COVER_MODE_EN 0xC1
|
||||
#define FTS_REG_CHARGER_MODE_EN 0x8B
|
||||
#define FTS_REG_GESTURE_EN 0xD0
|
||||
#define FTS_REG_GESTURE_OUTPUT_ADDRESS 0xD3
|
||||
#define FTS_REG_MODULE_ID 0xE3
|
||||
#define FTS_REG_LIC_VER 0xE4
|
||||
#define FTS_REG_ESD_SATURATE 0xED
|
||||
|
||||
#define FTS_SYSFS_ECHO_ON(buf) (buf[0] == '1')
|
||||
#define FTS_SYSFS_ECHO_OFF(buf) (buf[0] == '0')
|
||||
|
||||
#define kfree_safe(pbuf) do {\
|
||||
if (pbuf) {\
|
||||
kfree(pbuf);\
|
||||
pbuf = NULL;\
|
||||
}\
|
||||
} while(0)
|
||||
|
||||
/*****************************************************************************
|
||||
* Alternative mode (When something goes wrong, the modules may be able to solve the problem.)
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* point report check
|
||||
* default: disable
|
||||
*/
|
||||
#define FTS_POINT_REPORT_CHECK_EN 0
|
||||
|
||||
/*****************************************************************************
|
||||
* Global variable or extern global variabls/functions
|
||||
*****************************************************************************/
|
||||
struct ft_chip_t {
|
||||
u64 type;
|
||||
u8 chip_idh;
|
||||
u8 chip_idl;
|
||||
u8 rom_idh;
|
||||
u8 rom_idl;
|
||||
u8 pb_idh;
|
||||
u8 pb_idl;
|
||||
u8 bl_idh;
|
||||
u8 bl_idl;
|
||||
};
|
||||
|
||||
struct ts_ic_info {
|
||||
bool is_incell;
|
||||
bool hid_supported;
|
||||
struct ft_chip_t ids;
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
* DEBUG function define here
|
||||
*****************************************************************************/
|
||||
#if FTS_DEBUG_EN
|
||||
#define FTS_DEBUG(fmt, args...) do { \
|
||||
printk("[FTS_TS]%s:"fmt"\n", __func__, ##args); \
|
||||
} while (0)
|
||||
|
||||
#define FTS_FUNC_ENTER() do { \
|
||||
printk("[FTS_TS]%s: Enter\n", __func__); \
|
||||
} while (0)
|
||||
|
||||
#define FTS_FUNC_EXIT() do { \
|
||||
printk("[FTS_TS]%s: Exit(%d)\n", __func__, __LINE__); \
|
||||
} while (0)
|
||||
#else /* #if FTS_DEBUG_EN*/
|
||||
#define FTS_DEBUG(fmt, args...)
|
||||
#define FTS_FUNC_ENTER()
|
||||
#define FTS_FUNC_EXIT()
|
||||
#endif
|
||||
|
||||
#define FTS_INFO(fmt, args...) do { \
|
||||
printk(KERN_INFO "[FTS_TS/I]%s:"fmt"\n", __func__, ##args); \
|
||||
} while (0)
|
||||
|
||||
#define FTS_ERROR(fmt, args...) do { \
|
||||
printk(KERN_ERR "[FTS_TS/E]%s:"fmt"\n", __func__, ##args); \
|
||||
} while (0)
|
||||
#endif /* __LINUX_FOCALTECH_COMMON_H__ */
|
||||
@@ -0,0 +1,241 @@
|
||||
/*
|
||||
*
|
||||
* FocalTech TouchScreen driver.
|
||||
*
|
||||
* Copyright (c) 2012-2019, FocalTech Systems, Ltd., all rights reserved.
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
/************************************************************************
|
||||
*
|
||||
* File Name: focaltech_config.h
|
||||
*
|
||||
* Author: Focaltech Driver Team
|
||||
*
|
||||
* Created: 2016-08-08
|
||||
*
|
||||
* Abstract: global configurations
|
||||
*
|
||||
* Version: v1.0
|
||||
*
|
||||
************************************************************************/
|
||||
#ifndef _LINUX_FOCLATECH_CONFIG_H_
|
||||
#define _LINUX_FOCLATECH_CONFIG_H_
|
||||
|
||||
/**************************************************/
|
||||
/****** G: A, I: B, S: C, U: D ******************/
|
||||
/****** chip type defines, do not modify *********/
|
||||
#define _FT8716 0x87160805
|
||||
#define _FT8736 0x87360806
|
||||
#define _FT8006M 0x80060807
|
||||
#define _FT8607 0x86070809
|
||||
#define _FT8006U 0x8006D80B
|
||||
#define _FT8006S 0x8006A80B
|
||||
#define _FT8613 0x8613080C
|
||||
#define _FT8719 0x8719080D
|
||||
#define _FT8739 0x8739080E
|
||||
#define _FT8615 0x8615080F
|
||||
#define _FT8201 0x82010810
|
||||
#define _FT8006P 0x86220811
|
||||
#define _FT7251 0x72510812
|
||||
#define _FT7252 0x72520813
|
||||
#define _FT8613S 0x8613C814
|
||||
#define _FT8756 0x87560815
|
||||
#define _FT8302 0x83020816
|
||||
#define _FT8009 0x80090817
|
||||
#define _FT8656 0x86560818
|
||||
#define _FT8006S_AA 0x86320819
|
||||
#define _FT7250 0x7250081A
|
||||
|
||||
|
||||
#define _FT5416 0x54160402
|
||||
#define _FT5426 0x54260402
|
||||
#define _FT5435 0x54350402
|
||||
#define _FT5436 0x54360402
|
||||
#define _FT5526 0x55260402
|
||||
#define _FT5526I 0x5526B402
|
||||
#define _FT5446 0x54460402
|
||||
#define _FT5346 0x53460402
|
||||
#define _FT5446I 0x5446B402
|
||||
#define _FT5346I 0x5346B402
|
||||
#define _FT7661 0x76610402
|
||||
#define _FT7511 0x75110402
|
||||
#define _FT7421 0x74210402
|
||||
#define _FT7681 0x76810402
|
||||
#define _FT3C47U 0x3C47D402
|
||||
#define _FT3417 0x34170402
|
||||
#define _FT3517 0x35170402
|
||||
#define _FT3327 0x33270402
|
||||
#define _FT3427 0x34270402
|
||||
#define _FT7311 0x73110402
|
||||
|
||||
#define _FT5626 0x56260401
|
||||
#define _FT5726 0x57260401
|
||||
#define _FT5826B 0x5826B401
|
||||
#define _FT5826S 0x5826C401
|
||||
#define _FT7811 0x78110401
|
||||
#define _FT3D47 0x3D470401
|
||||
#define _FT3617 0x36170401
|
||||
#define _FT3717 0x37170401
|
||||
#define _FT3817B 0x3817B401
|
||||
#define _FT3517U 0x3517D401
|
||||
|
||||
#define _FT6236U 0x6236D003
|
||||
#define _FT6336G 0x6336A003
|
||||
#define _FT6336U 0x6336D003
|
||||
#define _FT6436U 0x6436D003
|
||||
|
||||
#define _FT3267 0x32670004
|
||||
#define _FT3367 0x33670004
|
||||
|
||||
#define _FT3327DQQ_XXX 0x3327D482
|
||||
#define _FT5446DQS_XXX 0x5446D482
|
||||
|
||||
#define _FT3518 0x35180481
|
||||
#define _FT3558 0x35580481
|
||||
#define _FT3528 0x35280481
|
||||
#define _FT5536 0x55360481
|
||||
|
||||
#define _FT5446U 0x5446D083
|
||||
#define _FT5456U 0x5456D083
|
||||
#define _FT3417U 0x3417D083
|
||||
#define _FT5426U 0x5426D083
|
||||
#define _FT3428 0x34280083
|
||||
#define _FT3437U 0x3437D083
|
||||
|
||||
#define _FT7302 0x73020084
|
||||
#define _FT7202 0x72020084
|
||||
#define _FT3308 0x33080084
|
||||
|
||||
#define _FT6346U 0x6346D085
|
||||
#define _FT6346G 0x6346A085
|
||||
#define _FT3067 0x30670085
|
||||
#define _FT3068 0x30680085
|
||||
#define _FT3168 0x31680085
|
||||
#define _FT3268 0x32680085
|
||||
|
||||
/*************************************************/
|
||||
|
||||
/*
|
||||
* choose your ic chip type of focaltech
|
||||
*/
|
||||
#define FTS_CHIP_TYPE _FT5436
|
||||
|
||||
/******************* Enables *********************/
|
||||
/*********** 1 to enable, 0 to disable ***********/
|
||||
|
||||
/*
|
||||
* show debug log info
|
||||
* enable it for debug, disable it for release
|
||||
*/
|
||||
#define FTS_DEBUG_EN 0
|
||||
|
||||
/*
|
||||
* Linux MultiTouch Protocol
|
||||
* 1: Protocol B(default), 0: Protocol A
|
||||
*/
|
||||
#define FTS_MT_PROTOCOL_B_EN 0
|
||||
|
||||
/*
|
||||
* Report Pressure in multitouch
|
||||
* 1:enable(default),0:disable
|
||||
*/
|
||||
#define FTS_REPORT_PRESSURE_EN 1
|
||||
|
||||
/*
|
||||
* Gesture function enable
|
||||
* default: disable
|
||||
*/
|
||||
#define FTS_GESTURE_EN 0
|
||||
|
||||
/*
|
||||
* ESD check & protection
|
||||
* default: disable
|
||||
*/
|
||||
#define FTS_ESDCHECK_EN 0
|
||||
|
||||
|
||||
/*
|
||||
* Pinctrl enable
|
||||
* default: disable
|
||||
*/
|
||||
#define FTS_PINCTRL_EN 0
|
||||
|
||||
/*
|
||||
* Customer power enable
|
||||
* enable it when customer need control TP power
|
||||
* default: disable
|
||||
*/
|
||||
#define FTS_POWER_SOURCE_CUST_EN 1
|
||||
|
||||
/****************************************************/
|
||||
|
||||
/********************** Upgrade ****************************/
|
||||
/*
|
||||
* auto upgrade
|
||||
*/
|
||||
#define FTS_AUTO_UPGRADE_EN 1
|
||||
|
||||
/*
|
||||
* auto upgrade for lcd cfg
|
||||
*/
|
||||
#define FTS_AUTO_LIC_UPGRADE_EN 0
|
||||
|
||||
/*
|
||||
* Numbers of modules support
|
||||
*/
|
||||
#define FTS_GET_MODULE_NUM 0
|
||||
|
||||
/*
|
||||
* module_id: mean vendor_id generally, also maybe gpio or lcm_id...
|
||||
* If means vendor_id, the FTS_MODULE_ID = PANEL_ID << 8 + VENDOR_ID
|
||||
* FTS_GET_MODULE_NUM == 0/1, no check module id, you may ignore them
|
||||
* FTS_GET_MODULE_NUM >= 2, compatible with FTS_MODULE2_ID
|
||||
* FTS_GET_MODULE_NUM >= 3, compatible with FTS_MODULE3_ID
|
||||
*/
|
||||
#define FTS_MODULE_ID 0x0000
|
||||
#define FTS_MODULE2_ID 0x0000
|
||||
#define FTS_MODULE3_ID 0x0000
|
||||
|
||||
/*
|
||||
* Need set the following when get firmware via firmware_request()
|
||||
* For example: if module'vendor is tianma,
|
||||
* #define FTS_MODULE_NAME "tianma"
|
||||
* then file_name will be "focaltech_ts_fw_tianma"
|
||||
* You should rename fw to "focaltech_ts_fw_tianma", and push it into
|
||||
* etc/firmware or by customers
|
||||
*/
|
||||
#define FTS_MODULE_NAME ""
|
||||
#define FTS_MODULE2_NAME ""
|
||||
#define FTS_MODULE3_NAME ""
|
||||
|
||||
/*
|
||||
* FW.i file for auto upgrade, you must replace it with your own
|
||||
* define your own fw_file, the sample one to be replaced is invalid
|
||||
* NOTE: if FTS_GET_MODULE_NUM > 1, it's the fw corresponding with FTS_VENDOR_ID
|
||||
*/
|
||||
#define FTS_UPGRADE_FW_FILE "include/firmware/fw_sample.h"
|
||||
|
||||
/*
|
||||
* if FTS_GET_MODULE_NUM >= 2, fw corrsponding with FTS_VENDOR_ID2
|
||||
* define your own fw_file, the sample one is invalid
|
||||
*/
|
||||
#define FTS_UPGRADE_FW2_FILE "include/firmware/fw_sample.h"
|
||||
|
||||
/*
|
||||
* if FTS_GET_MODULE_NUM >= 3, fw corrsponding with FTS_VENDOR_ID3
|
||||
* define your own fw_file, the sample one is invalid
|
||||
*/
|
||||
#define FTS_UPGRADE_FW3_FILE "include/firmware/fw_sample.h"
|
||||
|
||||
/*********************************************************/
|
||||
|
||||
#endif /* _LINUX_FOCLATECH_CONFIG_H_ */
|
||||
1745
drivers/input/touchscreen/focaltech_touch_ft5436/focaltech_core.c
Normal file
1745
drivers/input/touchscreen/focaltech_touch_ft5436/focaltech_core.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,263 @@
|
||||
/*
|
||||
*
|
||||
* FocalTech TouchScreen driver.
|
||||
*
|
||||
* Copyright (c) 2012-2019, Focaltech Ltd. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
/*****************************************************************************
|
||||
*
|
||||
* File Name: focaltech_core.h
|
||||
|
||||
* Author: Focaltech Driver Team
|
||||
*
|
||||
* Created: 2016-08-08
|
||||
*
|
||||
* Abstract:
|
||||
*
|
||||
* Reference:
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __LINUX_FOCALTECH_CORE_H__
|
||||
#define __LINUX_FOCALTECH_CORE_H__
|
||||
/*****************************************************************************
|
||||
* Included header files
|
||||
*****************************************************************************/
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/spi/spi.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/input/mt.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/irq.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
#include <asm/uaccess.h>
|
||||
#include <linux/firmware.h>
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/wait.h>
|
||||
#include <linux/time.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/kthread.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
#include "focaltech_common.h"
|
||||
#include "../tp_suspend.h"
|
||||
|
||||
/*****************************************************************************
|
||||
* Private constant and macro definitions using #define
|
||||
*****************************************************************************/
|
||||
#define FTS_MAX_POINTS_SUPPORT 10 /* constant value, can't be changed */
|
||||
#define FTS_MAX_KEYS 4
|
||||
#define FTS_KEY_DIM 10
|
||||
#define FTS_ONE_TCH_LEN 6
|
||||
#define FTS_TOUCH_DATA_LEN (FTS_MAX_POINTS_SUPPORT * FTS_ONE_TCH_LEN + 3)
|
||||
|
||||
#define FTS_GESTURE_POINTS_MAX 6
|
||||
#define FTS_GESTURE_DATA_LEN (FTS_GESTURE_POINTS_MAX * 4 + 4)
|
||||
|
||||
#define FTS_MAX_ID 0x0A
|
||||
#define FTS_TOUCH_X_H_POS 3
|
||||
#define FTS_TOUCH_X_L_POS 4
|
||||
#define FTS_TOUCH_Y_H_POS 5
|
||||
#define FTS_TOUCH_Y_L_POS 6
|
||||
#define FTS_TOUCH_PRE_POS 7
|
||||
#define FTS_TOUCH_AREA_POS 8
|
||||
#define FTS_TOUCH_POINT_NUM 2
|
||||
#define FTS_TOUCH_EVENT_POS 3
|
||||
#define FTS_TOUCH_ID_POS 5
|
||||
#define FTS_COORDS_ARR_SIZE 4
|
||||
#define FTS_X_MIN_DISPLAY_DEFAULT 0
|
||||
#define FTS_Y_MIN_DISPLAY_DEFAULT 0
|
||||
#define FTS_X_MAX_DISPLAY_DEFAULT 720
|
||||
#define FTS_Y_MAX_DISPLAY_DEFAULT 1280
|
||||
|
||||
#define FTS_TOUCH_DOWN 0
|
||||
#define FTS_TOUCH_UP 1
|
||||
#define FTS_TOUCH_CONTACT 2
|
||||
#define EVENT_DOWN(flag) ((FTS_TOUCH_DOWN == flag) || (FTS_TOUCH_CONTACT == flag))
|
||||
#define EVENT_UP(flag) (FTS_TOUCH_UP == flag)
|
||||
#define EVENT_NO_DOWN(data) (!data->point_num)
|
||||
|
||||
#define FTX_MAX_COMPATIBLE_TYPE 4
|
||||
#define FTX_MAX_COMMMAND_LENGTH 16
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Private enumerations, structures and unions using typedef
|
||||
*****************************************************************************/
|
||||
struct ftxxxx_proc {
|
||||
struct proc_dir_entry *proc_entry;
|
||||
u8 opmode;
|
||||
u8 cmd_len;
|
||||
u8 cmd[FTX_MAX_COMMMAND_LENGTH];
|
||||
};
|
||||
|
||||
struct fts_ts_platform_data {
|
||||
u32 irq_gpio;
|
||||
u32 irq_gpio_flags;
|
||||
u32 reset_gpio;
|
||||
u32 reset_gpio_flags;
|
||||
u32 pwr_gpio;
|
||||
u32 pwr_gpio_flags;
|
||||
bool have_key;
|
||||
u32 key_number;
|
||||
u32 keys[FTS_MAX_KEYS];
|
||||
u32 key_y_coords[FTS_MAX_KEYS];
|
||||
u32 key_x_coords[FTS_MAX_KEYS];
|
||||
u32 x_max;
|
||||
u32 y_max;
|
||||
u32 x_min;
|
||||
u32 y_min;
|
||||
u32 max_touch_number;
|
||||
};
|
||||
|
||||
struct ts_event {
|
||||
int x; /*x coordinate */
|
||||
int y; /*y coordinate */
|
||||
int p; /* pressure */
|
||||
int flag; /* touch event flag: 0 -- down; 1-- up; 2 -- contact */
|
||||
int id; /*touch ID */
|
||||
int area;
|
||||
};
|
||||
|
||||
struct fts_ts_data {
|
||||
struct i2c_client *client;
|
||||
struct spi_device *spi;
|
||||
struct device *dev;
|
||||
struct input_dev *input_dev;
|
||||
struct fts_ts_platform_data *pdata;
|
||||
struct ts_ic_info ic_info;
|
||||
struct workqueue_struct *ts_workqueue;
|
||||
struct work_struct fwupg_work;
|
||||
struct delayed_work esdcheck_work;
|
||||
struct delayed_work prc_work;
|
||||
struct work_struct resume_work;
|
||||
struct ftxxxx_proc proc;
|
||||
spinlock_t irq_lock;
|
||||
struct mutex report_mutex;
|
||||
struct mutex bus_lock;
|
||||
int irq;
|
||||
int log_level;
|
||||
int fw_is_running; /* confirm fw is running when using spi:default 0 */
|
||||
int dummy_byte;
|
||||
bool suspended;
|
||||
bool fw_loading;
|
||||
bool irq_disabled;
|
||||
bool power_disabled;
|
||||
bool glove_mode;
|
||||
bool cover_mode;
|
||||
bool charger_mode;
|
||||
bool gesture_mode; /* gesture enable or disable, default: disable */
|
||||
/* multi-touch */
|
||||
struct ts_event *events;
|
||||
u8 *bus_tx_buf;
|
||||
u8 *bus_rx_buf;
|
||||
u8 *point_buf;
|
||||
int pnt_buf_size;
|
||||
int touchs;
|
||||
int key_state;
|
||||
int touch_point;
|
||||
int point_num;
|
||||
struct regulator *vdd;
|
||||
struct regulator *vcc_i2c;
|
||||
#if FTS_PINCTRL_EN
|
||||
struct pinctrl *pinctrl;
|
||||
struct pinctrl_state *pins_active;
|
||||
struct pinctrl_state *pins_suspend;
|
||||
struct pinctrl_state *pins_release;
|
||||
#endif
|
||||
#if defined(CONFIG_FB)
|
||||
struct tp_device tp;
|
||||
#elif defined(CONFIG_HAS_EARLYSUSPEND)
|
||||
struct early_suspend early_suspend;
|
||||
#endif
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
* Global variable or extern global variabls/functions
|
||||
*****************************************************************************/
|
||||
extern struct fts_ts_data *fts_data;
|
||||
|
||||
/* communication interface */
|
||||
int fts_read(u8 *cmd, u32 cmdlen, u8 *data, u32 datalen);
|
||||
int fts_read_reg(u8 addr, u8 *value);
|
||||
int fts_write(u8 *writebuf, u32 writelen);
|
||||
int fts_write_reg(u8 addr, u8 value);
|
||||
void fts_hid2std(void);
|
||||
int fts_bus_init(struct fts_ts_data *ts_data);
|
||||
int fts_bus_exit(struct fts_ts_data *ts_data);
|
||||
|
||||
/* Gesture functions */
|
||||
int fts_gesture_init(struct fts_ts_data *ts_data);
|
||||
int fts_gesture_exit(struct fts_ts_data *ts_data);
|
||||
void fts_gesture_recovery(struct fts_ts_data *ts_data);
|
||||
int fts_gesture_readdata(struct fts_ts_data *ts_data, u8 *data);
|
||||
int fts_gesture_suspend(struct fts_ts_data *ts_data);
|
||||
int fts_gesture_resume(struct fts_ts_data *ts_data);
|
||||
|
||||
/* Apk and functions */
|
||||
int fts_create_apk_debug_channel(struct fts_ts_data *);
|
||||
void fts_release_apk_debug_channel(struct fts_ts_data *);
|
||||
|
||||
/* ADB functions */
|
||||
int fts_create_sysfs(struct fts_ts_data *ts_data);
|
||||
int fts_remove_sysfs(struct fts_ts_data *ts_data);
|
||||
|
||||
/* ESD */
|
||||
#if FTS_ESDCHECK_EN
|
||||
int fts_esdcheck_init(struct fts_ts_data *ts_data);
|
||||
int fts_esdcheck_exit(struct fts_ts_data *ts_data);
|
||||
int fts_esdcheck_switch(bool enable);
|
||||
int fts_esdcheck_proc_busy(bool proc_debug);
|
||||
int fts_esdcheck_set_intr(bool intr);
|
||||
int fts_esdcheck_suspend(void);
|
||||
int fts_esdcheck_resume(void);
|
||||
#endif
|
||||
|
||||
|
||||
/* Point Report Check*/
|
||||
#if FTS_POINT_REPORT_CHECK_EN
|
||||
int fts_point_report_check_init(struct fts_ts_data *ts_data);
|
||||
int fts_point_report_check_exit(struct fts_ts_data *ts_data);
|
||||
void fts_prc_queue_work(struct fts_ts_data *ts_data);
|
||||
#endif
|
||||
|
||||
/* FW upgrade */
|
||||
int fts_fwupg_init(struct fts_ts_data *ts_data);
|
||||
int fts_fwupg_exit(struct fts_ts_data *ts_data);
|
||||
int fts_upgrade_bin(char *fw_name, bool force);
|
||||
int fts_enter_test_environment(bool test_state);
|
||||
|
||||
/* Other */
|
||||
int fts_reset_proc(int hdelayms);
|
||||
int fts_wait_tp_to_valid(void);
|
||||
void fts_release_all_finger(void);
|
||||
void fts_tp_state_recovery(struct fts_ts_data *ts_data);
|
||||
int fts_ex_mode_init(struct fts_ts_data *ts_data);
|
||||
int fts_ex_mode_exit(struct fts_ts_data *ts_data);
|
||||
int fts_ex_mode_recovery(struct fts_ts_data *ts_data);
|
||||
|
||||
void fts_irq_disable(void);
|
||||
void fts_irq_enable(void);
|
||||
#endif /* __LINUX_FOCALTECH_CORE_H__ */
|
||||
@@ -0,0 +1,464 @@
|
||||
/*
|
||||
*
|
||||
* FocalTech TouchScreen driver.
|
||||
*
|
||||
* Copyright (c) 2012-2019, FocalTech Systems, Ltd., all rights reserved.
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* File Name: focaltech_esdcheck.c
|
||||
*
|
||||
* Author: Focaltech Driver Team
|
||||
*
|
||||
* Created: 2016-08-03
|
||||
*
|
||||
* Abstract: ESD check function
|
||||
*
|
||||
* Version: v1.0
|
||||
*
|
||||
* Revision History:
|
||||
* v1.0:
|
||||
* First release. By luougojin 2016-08-03
|
||||
* v1.1: By luougojin 2017-02-15
|
||||
* 1. Add LCD_ESD_PATCH to control idc_esdcheck_lcderror
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Included header files
|
||||
*****************************************************************************/
|
||||
#include "focaltech_core.h"
|
||||
|
||||
#if FTS_ESDCHECK_EN
|
||||
/*****************************************************************************
|
||||
* Private constant and macro definitions using #define
|
||||
*****************************************************************************/
|
||||
#define ESDCHECK_WAIT_TIME 1000 /* ms */
|
||||
#define LCD_ESD_PATCH 0
|
||||
#define ESDCHECK_INTRCNT_MAX 2
|
||||
|
||||
/*****************************************************************************
|
||||
* Private enumerations, structures and unions using typedef
|
||||
*****************************************************************************/
|
||||
struct fts_esdcheck_st {
|
||||
u8 mode : 1; /* 1- need check esd 0- no esd check */
|
||||
u8 suspend : 1;
|
||||
u8 proc_debug : 1; /* apk or adb use */
|
||||
u8 intr : 1; /* 1- Interrupt trigger */
|
||||
u8 unused : 4;
|
||||
u8 intr_cnt;
|
||||
u8 flow_work_hold_cnt; /* Flow Work Cnt(reg0x91) keep a same value for x times. >=5 times is ESD, need reset */
|
||||
u8 flow_work_cnt_last; /* Save Flow Work Cnt(reg0x91) value */
|
||||
u32 hardware_reset_cnt;
|
||||
u32 nack_cnt;
|
||||
u32 dataerror_cnt;
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
* Static variables
|
||||
*****************************************************************************/
|
||||
static struct fts_esdcheck_st fts_esdcheck_data;
|
||||
|
||||
/*****************************************************************************
|
||||
* Global variable or extern global variabls/functions
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Static function prototypes
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* functions body
|
||||
*****************************************************************************/
|
||||
#if LCD_ESD_PATCH
|
||||
int lcd_need_reset;
|
||||
static int tp_need_recovery; /* LCD reset cause Tp reset */
|
||||
int idc_esdcheck_lcderror(struct fts_ts_data *ts_data)
|
||||
{
|
||||
int ret = 0;
|
||||
u8 val = 0;
|
||||
|
||||
FTS_DEBUG("check LCD ESD");
|
||||
if ( (tp_need_recovery == 1) && (lcd_need_reset == 0) ) {
|
||||
tp_need_recovery = 0;
|
||||
/* LCD reset, need recover TP state */
|
||||
fts_release_all_finger();
|
||||
fts_tp_state_recovery(ts_data);
|
||||
}
|
||||
|
||||
ret = fts_read_reg(FTS_REG_ESD_SATURATE, &val);
|
||||
if ( ret < 0) {
|
||||
FTS_ERROR("read reg0xED fail,ret:%d", ret);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (val == 0xAA) {
|
||||
/*
|
||||
* 1. Set flag lcd_need_reset = 1;
|
||||
* 2. LCD driver need reset(recovery) LCD and set lcd_need_reset to 0
|
||||
* 3. recover TP state
|
||||
*/
|
||||
FTS_INFO("LCD ESD, need execute LCD reset");
|
||||
lcd_need_reset = 1;
|
||||
tp_need_recovery = 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int fts_esdcheck_tp_reset(struct fts_ts_data *ts_data)
|
||||
{
|
||||
FTS_FUNC_ENTER();
|
||||
|
||||
fts_esdcheck_data.flow_work_hold_cnt = 0;
|
||||
fts_esdcheck_data.hardware_reset_cnt++;
|
||||
|
||||
fts_reset_proc(200);
|
||||
fts_release_all_finger();
|
||||
fts_tp_state_recovery(ts_data);
|
||||
|
||||
FTS_FUNC_EXIT();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool get_chip_id(struct fts_ts_data *ts_data)
|
||||
{
|
||||
int ret = 0;
|
||||
int i = 0;
|
||||
u8 reg_value = 0;
|
||||
u8 reg_addr = 0;
|
||||
u8 chip_id = ts_data->ic_info.ids.chip_idh;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
reg_addr = FTS_REG_CHIP_ID;
|
||||
ret = fts_read(®_addr, 1, ®_value, 1);
|
||||
if (ret < 0) {
|
||||
FTS_ERROR("read chip id fail,ret:%d", ret);
|
||||
fts_esdcheck_data.nack_cnt++;
|
||||
} else {
|
||||
if (reg_value == chip_id) {
|
||||
break;
|
||||
} else {
|
||||
FTS_DEBUG("read chip_id:%x,retry:%d", reg_value, i);
|
||||
fts_esdcheck_data.dataerror_cnt++;
|
||||
}
|
||||
}
|
||||
msleep(10);
|
||||
}
|
||||
|
||||
/* if can't get correct data in 3 times, then need hardware reset */
|
||||
if (i >= 3) {
|
||||
FTS_ERROR("read chip id 3 times fail, need execute TP reset");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: get_flow_cnt
|
||||
* Brief: Read flow cnt(0x91)
|
||||
* Input:
|
||||
* Output:
|
||||
* Return: 1(true) - Reg 0x91(flow cnt) abnormal: hold a value for 5 times
|
||||
* 0(false) - Reg 0x91(flow cnt) normal
|
||||
*****************************************************************************/
|
||||
static bool get_flow_cnt(struct fts_ts_data *ts_data)
|
||||
{
|
||||
int ret = 0;
|
||||
u8 reg_value = 0;
|
||||
u8 reg_addr = 0;
|
||||
|
||||
reg_addr = FTS_REG_FLOW_WORK_CNT;
|
||||
ret = fts_read(®_addr, 1, ®_value, 1);
|
||||
if (ret < 0) {
|
||||
FTS_ERROR("read reg0x91 fail,ret:%d", ret);
|
||||
fts_esdcheck_data.nack_cnt++;
|
||||
} else {
|
||||
if ( reg_value == fts_esdcheck_data.flow_work_cnt_last ) {
|
||||
FTS_DEBUG("reg0x91,val:%x,last:%x", reg_value,
|
||||
fts_esdcheck_data.flow_work_cnt_last);
|
||||
fts_esdcheck_data.flow_work_hold_cnt++;
|
||||
} else {
|
||||
fts_esdcheck_data.flow_work_hold_cnt = 0;
|
||||
}
|
||||
|
||||
fts_esdcheck_data.flow_work_cnt_last = reg_value;
|
||||
}
|
||||
|
||||
/* Flow Work Cnt keep a value for 5 times, need execute TP reset */
|
||||
if (fts_esdcheck_data.flow_work_hold_cnt >= 5) {
|
||||
FTS_DEBUG("reg0x91 keep a value for 5 times, need execute TP reset");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static int esdcheck_algorithm(struct fts_ts_data *ts_data)
|
||||
{
|
||||
int ret = 0;
|
||||
u8 reg_value = 0;
|
||||
u8 reg_addr = 0;
|
||||
bool hardware_reset = 0;
|
||||
|
||||
/* 1. esdcheck is interrupt, then return */
|
||||
if (fts_esdcheck_data.intr == 1) {
|
||||
fts_esdcheck_data.intr_cnt++;
|
||||
if (fts_esdcheck_data.intr_cnt > ESDCHECK_INTRCNT_MAX)
|
||||
fts_esdcheck_data.intr = 0;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 2. check power state, if suspend, no need check esd */
|
||||
if (fts_esdcheck_data.suspend == 1) {
|
||||
FTS_DEBUG("In suspend, not check esd");
|
||||
/* because in suspend state, adb can be used, when upgrade FW, will
|
||||
* active ESD check(active = 1); But in suspend, then will don't
|
||||
* queue_delayed_work, when resume, don't check ESD again
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 3. check fts_esdcheck_data.proc_debug state, if 1-proc busy, no need check esd*/
|
||||
if (fts_esdcheck_data.proc_debug == 1) {
|
||||
FTS_INFO("In apk/adb command mode, not check esd");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 4. In factory mode, can't check esd */
|
||||
reg_addr = FTS_REG_WORKMODE;
|
||||
ret = fts_read_reg(reg_addr, ®_value);
|
||||
if ( ret < 0 ) {
|
||||
fts_esdcheck_data.nack_cnt++;
|
||||
} else if ( (reg_value & 0x70) != FTS_REG_WORKMODE_WORK_VALUE) {
|
||||
FTS_DEBUG("not in work mode(%x), no check esd", reg_value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 5. IDC esd check lcd default:close */
|
||||
#if LCD_ESD_PATCH
|
||||
idc_esdcheck_lcderror(ts_data);
|
||||
#endif
|
||||
|
||||
/* 6. Get Chip ID */
|
||||
hardware_reset = get_chip_id(ts_data);
|
||||
|
||||
/* 7. get Flow work cnt: 0x91 If no change for 5 times, then ESD and reset */
|
||||
if (!hardware_reset) {
|
||||
hardware_reset = get_flow_cnt(ts_data);
|
||||
}
|
||||
|
||||
/* 8. If need hardware reset, then handle it here */
|
||||
if (hardware_reset == 1) {
|
||||
FTS_DEBUG("NoACK=%d, Error Data=%d, Hardware Reset=%d",
|
||||
fts_esdcheck_data.nack_cnt,
|
||||
fts_esdcheck_data.dataerror_cnt,
|
||||
fts_esdcheck_data.hardware_reset_cnt);
|
||||
fts_esdcheck_tp_reset(ts_data);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void esdcheck_func(struct work_struct *work)
|
||||
{
|
||||
struct fts_ts_data *ts_data = container_of(work,
|
||||
struct fts_ts_data, esdcheck_work.work);
|
||||
|
||||
if (ENABLE == fts_esdcheck_data.mode) {
|
||||
esdcheck_algorithm(ts_data);
|
||||
queue_delayed_work(ts_data->ts_workqueue, &ts_data->esdcheck_work,
|
||||
msecs_to_jiffies(ESDCHECK_WAIT_TIME));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int fts_esdcheck_set_intr(bool intr)
|
||||
{
|
||||
/* interrupt don't add debug message */
|
||||
fts_esdcheck_data.intr = intr;
|
||||
fts_esdcheck_data.intr_cnt = (u8)intr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fts_esdcheck_get_status(void)
|
||||
{
|
||||
/* interrupt don't add debug message */
|
||||
return fts_esdcheck_data.mode;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: fts_esdcheck_proc_busy
|
||||
* Brief: When APK or ADB command access TP via driver, then need set proc_debug,
|
||||
* then will not check ESD.
|
||||
* Input:
|
||||
* Output:
|
||||
* Return:
|
||||
*****************************************************************************/
|
||||
int fts_esdcheck_proc_busy(bool proc_debug)
|
||||
{
|
||||
fts_esdcheck_data.proc_debug = proc_debug;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: fts_esdcheck_switch
|
||||
* Brief: FTS esd check function switch.
|
||||
* Input: enable: 1 - Enable esd check
|
||||
* 0 - Disable esd check
|
||||
* Output:
|
||||
* Return:
|
||||
*****************************************************************************/
|
||||
int fts_esdcheck_switch(bool enable)
|
||||
{
|
||||
struct fts_ts_data *ts_data = fts_data;
|
||||
FTS_FUNC_ENTER();
|
||||
if (fts_esdcheck_data.mode == ENABLE) {
|
||||
if (enable) {
|
||||
FTS_DEBUG("ESD check start");
|
||||
fts_esdcheck_data.flow_work_hold_cnt = 0;
|
||||
fts_esdcheck_data.flow_work_cnt_last = 0;
|
||||
fts_esdcheck_data.intr = 0;
|
||||
fts_esdcheck_data.intr_cnt = 0;
|
||||
queue_delayed_work(ts_data->ts_workqueue,
|
||||
&ts_data->esdcheck_work,
|
||||
msecs_to_jiffies(ESDCHECK_WAIT_TIME));
|
||||
} else {
|
||||
FTS_DEBUG("ESD check stop");
|
||||
cancel_delayed_work_sync(&ts_data->esdcheck_work);
|
||||
}
|
||||
}
|
||||
|
||||
FTS_FUNC_EXIT();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fts_esdcheck_suspend(void)
|
||||
{
|
||||
FTS_FUNC_ENTER();
|
||||
fts_esdcheck_switch(DISABLE);
|
||||
fts_esdcheck_data.suspend = 1;
|
||||
fts_esdcheck_data.intr = 0;
|
||||
fts_esdcheck_data.intr_cnt = 0;
|
||||
FTS_FUNC_EXIT();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fts_esdcheck_resume( void )
|
||||
{
|
||||
FTS_FUNC_ENTER();
|
||||
fts_esdcheck_switch(ENABLE);
|
||||
fts_esdcheck_data.suspend = 0;
|
||||
fts_esdcheck_data.intr = 0;
|
||||
fts_esdcheck_data.intr_cnt = 0;
|
||||
FTS_FUNC_EXIT();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t fts_esdcheck_store(
|
||||
struct device *dev,
|
||||
struct device_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
struct input_dev *input_dev = fts_data->input_dev;
|
||||
|
||||
mutex_lock(&input_dev->mutex);
|
||||
if (FTS_SYSFS_ECHO_ON(buf)) {
|
||||
FTS_DEBUG("enable esdcheck");
|
||||
fts_esdcheck_data.mode = ENABLE;
|
||||
fts_esdcheck_switch(ENABLE);
|
||||
} else if (FTS_SYSFS_ECHO_OFF(buf)) {
|
||||
FTS_DEBUG("disable esdcheck");
|
||||
fts_esdcheck_switch(DISABLE);
|
||||
fts_esdcheck_data.mode = DISABLE;
|
||||
}
|
||||
mutex_unlock(&input_dev->mutex);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t fts_esdcheck_show(
|
||||
struct device *dev, struct device_attribute *attr, char *buf)
|
||||
{
|
||||
int count;
|
||||
struct input_dev *input_dev = fts_data->input_dev;
|
||||
|
||||
mutex_lock(&input_dev->mutex);
|
||||
count = snprintf(buf, PAGE_SIZE, "Esd check: %s\n", \
|
||||
fts_esdcheck_get_status() ? "On" : "Off");
|
||||
mutex_unlock(&input_dev->mutex);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/* sysfs esd node
|
||||
* read example: cat fts_esd_mode ---read esd mode
|
||||
* write example:echo 01 > fts_esd_mode ---make esdcheck enable
|
||||
*
|
||||
*/
|
||||
static DEVICE_ATTR (fts_esd_mode, S_IRUGO | S_IWUSR, fts_esdcheck_show, fts_esdcheck_store);
|
||||
|
||||
static struct attribute *fts_esd_mode_attrs[] = {
|
||||
|
||||
&dev_attr_fts_esd_mode.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static struct attribute_group fts_esd_group = {
|
||||
.attrs = fts_esd_mode_attrs,
|
||||
};
|
||||
|
||||
int fts_create_esd_sysfs(struct device *dev)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret = sysfs_create_group(&dev->kobj, &fts_esd_group);
|
||||
if ( ret != 0) {
|
||||
FTS_ERROR("fts_create_esd_sysfs(sysfs) create fail");
|
||||
sysfs_remove_group(&dev->kobj, &fts_esd_group);
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fts_esdcheck_init(struct fts_ts_data *ts_data)
|
||||
{
|
||||
FTS_FUNC_ENTER();
|
||||
|
||||
if (ts_data->ts_workqueue) {
|
||||
INIT_DELAYED_WORK(&ts_data->esdcheck_work, esdcheck_func);
|
||||
} else {
|
||||
FTS_ERROR("fts workqueue is NULL, can't run esd check function");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
memset((u8 *)&fts_esdcheck_data, 0, sizeof(struct fts_esdcheck_st));
|
||||
|
||||
fts_esdcheck_data.mode = ENABLE;
|
||||
fts_esdcheck_data.intr = 0;
|
||||
fts_esdcheck_data.intr_cnt = 0;
|
||||
fts_esdcheck_switch(ENABLE);
|
||||
fts_create_esd_sysfs(ts_data->dev);
|
||||
FTS_FUNC_EXIT();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fts_esdcheck_exit(struct fts_ts_data *ts_data)
|
||||
{
|
||||
sysfs_remove_group(&ts_data->dev->kobj, &fts_esd_group);
|
||||
return 0;
|
||||
}
|
||||
#endif /* FTS_ESDCHECK_EN */
|
||||
|
||||
1181
drivers/input/touchscreen/focaltech_touch_ft5436/focaltech_ex_fun.c
Normal file
1181
drivers/input/touchscreen/focaltech_touch_ft5436/focaltech_ex_fun.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,307 @@
|
||||
/*
|
||||
*
|
||||
* FocalTech ftxxxx TouchScreen driver.
|
||||
*
|
||||
* Copyright (c) 2012-2019, Focaltech Ltd. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* File Name: focaltech_ex_mode.c
|
||||
*
|
||||
* Author: Focaltech Driver Team
|
||||
*
|
||||
* Created: 2016-08-31
|
||||
*
|
||||
* Abstract:
|
||||
*
|
||||
* Reference:
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* 1.Included header files
|
||||
*****************************************************************************/
|
||||
#include "focaltech_core.h"
|
||||
|
||||
/*****************************************************************************
|
||||
* 2.Private constant and macro definitions using #define
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* 3.Private enumerations, structures and unions using typedef
|
||||
*****************************************************************************/
|
||||
enum _ex_mode {
|
||||
MODE_GLOVE = 0,
|
||||
MODE_COVER,
|
||||
MODE_CHARGER,
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
* 4.Static variables
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* 5.Global variable or extern global variabls/functions
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* 6.Static function prototypes
|
||||
*******************************************************************************/
|
||||
static int fts_ex_mode_switch(enum _ex_mode mode, u8 value)
|
||||
{
|
||||
int ret = 0;
|
||||
u8 m_val = 0;
|
||||
|
||||
if (value)
|
||||
m_val = 0x01;
|
||||
else
|
||||
m_val = 0x00;
|
||||
|
||||
switch (mode) {
|
||||
case MODE_GLOVE:
|
||||
ret = fts_write_reg(FTS_REG_GLOVE_MODE_EN, m_val);
|
||||
if (ret < 0) {
|
||||
FTS_ERROR("MODE_GLOVE switch to %d fail", m_val);
|
||||
}
|
||||
break;
|
||||
case MODE_COVER:
|
||||
ret = fts_write_reg(FTS_REG_COVER_MODE_EN, m_val);
|
||||
if (ret < 0) {
|
||||
FTS_ERROR("MODE_COVER switch to %d fail", m_val);
|
||||
}
|
||||
break;
|
||||
case MODE_CHARGER:
|
||||
ret = fts_write_reg(FTS_REG_CHARGER_MODE_EN, m_val);
|
||||
if (ret < 0) {
|
||||
FTS_ERROR("MODE_CHARGER switch to %d fail", m_val);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
FTS_ERROR("mode(%d) unsupport", mode);
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t fts_glove_mode_show(
|
||||
struct device *dev, struct device_attribute *attr, char *buf)
|
||||
{
|
||||
int count = 0;
|
||||
u8 val = 0;
|
||||
struct fts_ts_data *ts_data = fts_data;
|
||||
struct input_dev *input_dev = ts_data->input_dev;
|
||||
|
||||
mutex_lock(&input_dev->mutex);
|
||||
fts_read_reg(FTS_REG_GLOVE_MODE_EN, &val);
|
||||
count = snprintf(buf + count, PAGE_SIZE, "Glove Mode:%s\n",
|
||||
ts_data->glove_mode ? "On" : "Off");
|
||||
count += snprintf(buf + count, PAGE_SIZE, "Glove Reg(0xC0):%d\n", val);
|
||||
mutex_unlock(&input_dev->mutex);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t fts_glove_mode_store(
|
||||
struct device *dev,
|
||||
struct device_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
int ret = 0;
|
||||
struct fts_ts_data *ts_data = fts_data;
|
||||
|
||||
if (FTS_SYSFS_ECHO_ON(buf)) {
|
||||
if (!ts_data->glove_mode) {
|
||||
FTS_DEBUG("enter glove mode");
|
||||
ret = fts_ex_mode_switch(MODE_GLOVE, ENABLE);
|
||||
if (ret >= 0) {
|
||||
ts_data->glove_mode = ENABLE;
|
||||
}
|
||||
}
|
||||
} else if (FTS_SYSFS_ECHO_OFF(buf)) {
|
||||
if (ts_data->glove_mode) {
|
||||
FTS_DEBUG("exit glove mode");
|
||||
ret = fts_ex_mode_switch(MODE_GLOVE, DISABLE);
|
||||
if (ret >= 0) {
|
||||
ts_data->glove_mode = DISABLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FTS_DEBUG("glove mode:%d", ts_data->glove_mode);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
static ssize_t fts_cover_mode_show(
|
||||
struct device *dev, struct device_attribute *attr, char *buf)
|
||||
{
|
||||
int count = 0;
|
||||
u8 val = 0;
|
||||
struct fts_ts_data *ts_data = fts_data;
|
||||
struct input_dev *input_dev = ts_data->input_dev;
|
||||
|
||||
mutex_lock(&input_dev->mutex);
|
||||
fts_read_reg(FTS_REG_COVER_MODE_EN, &val);
|
||||
count = snprintf(buf + count, PAGE_SIZE, "Cover Mode:%s\n",
|
||||
ts_data->cover_mode ? "On" : "Off");
|
||||
count += snprintf(buf + count, PAGE_SIZE, "Cover Reg(0xC1):%d\n", val);
|
||||
mutex_unlock(&input_dev->mutex);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t fts_cover_mode_store(
|
||||
struct device *dev,
|
||||
struct device_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
int ret = 0;
|
||||
struct fts_ts_data *ts_data = fts_data;
|
||||
|
||||
if (FTS_SYSFS_ECHO_ON(buf)) {
|
||||
if (!ts_data->cover_mode) {
|
||||
FTS_DEBUG("enter cover mode");
|
||||
ret = fts_ex_mode_switch(MODE_COVER, ENABLE);
|
||||
if (ret >= 0) {
|
||||
ts_data->cover_mode = ENABLE;
|
||||
}
|
||||
}
|
||||
} else if (FTS_SYSFS_ECHO_OFF(buf)) {
|
||||
if (ts_data->cover_mode) {
|
||||
FTS_DEBUG("exit cover mode");
|
||||
ret = fts_ex_mode_switch(MODE_COVER, DISABLE);
|
||||
if (ret >= 0) {
|
||||
ts_data->cover_mode = DISABLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FTS_DEBUG("cover mode:%d", ts_data->cover_mode);
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t fts_charger_mode_show(
|
||||
struct device *dev, struct device_attribute *attr, char *buf)
|
||||
{
|
||||
int count = 0;
|
||||
u8 val = 0;
|
||||
struct fts_ts_data *ts_data = fts_data;
|
||||
struct input_dev *input_dev = ts_data->input_dev;
|
||||
|
||||
mutex_lock(&input_dev->mutex);
|
||||
fts_read_reg(FTS_REG_CHARGER_MODE_EN, &val);
|
||||
count = snprintf(buf + count, PAGE_SIZE, "Charger Mode:%s\n",
|
||||
ts_data->charger_mode ? "On" : "Off");
|
||||
count += snprintf(buf + count, PAGE_SIZE, "Charger Reg(0x8B):%d\n", val);
|
||||
mutex_unlock(&input_dev->mutex);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t fts_charger_mode_store(
|
||||
struct device *dev,
|
||||
struct device_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
int ret = 0;
|
||||
struct fts_ts_data *ts_data = fts_data;
|
||||
|
||||
if (FTS_SYSFS_ECHO_ON(buf)) {
|
||||
if (!ts_data->charger_mode) {
|
||||
FTS_DEBUG("enter charger mode");
|
||||
ret = fts_ex_mode_switch(MODE_CHARGER, ENABLE);
|
||||
if (ret >= 0) {
|
||||
ts_data->charger_mode = ENABLE;
|
||||
}
|
||||
}
|
||||
} else if (FTS_SYSFS_ECHO_OFF(buf)) {
|
||||
if (ts_data->charger_mode) {
|
||||
FTS_DEBUG("exit charger mode");
|
||||
ret = fts_ex_mode_switch(MODE_CHARGER, DISABLE);
|
||||
if (ret >= 0) {
|
||||
ts_data->charger_mode = DISABLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FTS_DEBUG("charger mode:%d", ts_data->glove_mode);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/* read and write charger mode
|
||||
* read example: cat fts_glove_mode ---read glove mode
|
||||
* write example:echo 1 > fts_glove_mode ---write glove mode to 01
|
||||
*/
|
||||
static DEVICE_ATTR(fts_glove_mode, S_IRUGO | S_IWUSR,
|
||||
fts_glove_mode_show, fts_glove_mode_store);
|
||||
|
||||
static DEVICE_ATTR(fts_cover_mode, S_IRUGO | S_IWUSR,
|
||||
fts_cover_mode_show, fts_cover_mode_store);
|
||||
|
||||
static DEVICE_ATTR(fts_charger_mode, S_IRUGO | S_IWUSR,
|
||||
fts_charger_mode_show, fts_charger_mode_store);
|
||||
|
||||
static struct attribute *fts_touch_mode_attrs[] = {
|
||||
&dev_attr_fts_glove_mode.attr,
|
||||
&dev_attr_fts_cover_mode.attr,
|
||||
&dev_attr_fts_charger_mode.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static struct attribute_group fts_touch_mode_group = {
|
||||
.attrs = fts_touch_mode_attrs,
|
||||
};
|
||||
|
||||
int fts_ex_mode_recovery(struct fts_ts_data *ts_data)
|
||||
{
|
||||
if (ts_data->glove_mode) {
|
||||
fts_ex_mode_switch(MODE_GLOVE, ENABLE);
|
||||
}
|
||||
|
||||
if (ts_data->cover_mode) {
|
||||
fts_ex_mode_switch(MODE_COVER, ENABLE);
|
||||
}
|
||||
|
||||
if (ts_data->charger_mode) {
|
||||
fts_ex_mode_switch(MODE_CHARGER, ENABLE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fts_ex_mode_init(struct fts_ts_data *ts_data)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ts_data->glove_mode = DISABLE;
|
||||
ts_data->cover_mode = DISABLE;
|
||||
ts_data->charger_mode = DISABLE;
|
||||
|
||||
ret = sysfs_create_group(&ts_data->dev->kobj, &fts_touch_mode_group);
|
||||
if (ret < 0) {
|
||||
FTS_ERROR("create sysfs(ex_mode) fail");
|
||||
sysfs_remove_group(&ts_data->dev->kobj, &fts_touch_mode_group);
|
||||
return ret;
|
||||
} else {
|
||||
FTS_DEBUG("create sysfs(ex_mode) succeedfully");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fts_ex_mode_exit(struct fts_ts_data *ts_data)
|
||||
{
|
||||
sysfs_remove_group(&ts_data->dev->kobj, &fts_touch_mode_group);
|
||||
return 0;
|
||||
}
|
||||
2011
drivers/input/touchscreen/focaltech_touch_ft5436/focaltech_flash.c
Normal file
2011
drivers/input/touchscreen/focaltech_touch_ft5436/focaltech_flash.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,205 @@
|
||||
/************************************************************************
|
||||
* Copyright (C) 2012-2019, Focaltech Systems (R)£¬All Rights Reserved.
|
||||
*
|
||||
* File Name: focaltech_flash.h
|
||||
*
|
||||
* Author: Focaltech Driver Team
|
||||
*
|
||||
* Created: 2016-08-07
|
||||
*
|
||||
* Abstract:
|
||||
*
|
||||
************************************************************************/
|
||||
#ifndef __LINUX_FOCALTECH_FLASH_H__
|
||||
#define __LINUX_FOCALTECH_FLASH_H__
|
||||
|
||||
/*****************************************************************************
|
||||
* 1.Included header files
|
||||
*****************************************************************************/
|
||||
#include "focaltech_core.h"
|
||||
|
||||
/*****************************************************************************
|
||||
* Private constant and macro definitions using #define
|
||||
*****************************************************************************/
|
||||
#define FTS_CMD_RESET 0x07
|
||||
#define FTS_ROMBOOT_CMD_SET_PRAM_ADDR 0xAD
|
||||
#define FTS_ROMBOOT_CMD_SET_PRAM_ADDR_LEN 4
|
||||
#define FTS_ROMBOOT_CMD_WRITE 0xAE
|
||||
#define FTS_ROMBOOT_CMD_START_APP 0x08
|
||||
#define FTS_DELAY_PRAMBOOT_START 10
|
||||
#define FTS_ROMBOOT_CMD_ECC 0xCC
|
||||
#define FTS_PRAM_SADDR 0x000000
|
||||
#define FTS_DRAM_SADDR 0xD00000
|
||||
|
||||
#define FTS_CMD_READ 0x03
|
||||
#define FTS_CMD_READ_DELAY 1
|
||||
#define FTS_CMD_READ_LEN 4
|
||||
#define FTS_CMD_FLASH_TYPE 0x05
|
||||
#define FTS_CMD_FLASH_MODE 0x09
|
||||
#define FLASH_MODE_WRITE_FLASH_VALUE 0x0A
|
||||
#define FLASH_MODE_UPGRADE_VALUE 0x0B
|
||||
#define FLASH_MODE_LIC_VALUE 0x0C
|
||||
#define FLASH_MODE_PARAM_VALUE 0x0D
|
||||
#define FTS_CMD_ERASE_APP 0x61
|
||||
#define FTS_REASE_APP_DELAY 1350
|
||||
#define FTS_ERASE_SECTOR_DELAY 60
|
||||
#define FTS_RETRIES_REASE 50
|
||||
#define FTS_RETRIES_DELAY_REASE 200
|
||||
#define FTS_CMD_FLASH_STATUS 0x6A
|
||||
#define FTS_CMD_FLASH_STATUS_LEN 2
|
||||
#define FTS_CMD_FLASH_STATUS_NOP 0x0000
|
||||
#define FTS_CMD_FLASH_STATUS_ECC_OK 0xF055
|
||||
#define FTS_CMD_FLASH_STATUS_ERASE_OK 0xF0AA
|
||||
#define FTS_CMD_FLASH_STATUS_WRITE_OK 0x1000
|
||||
#define FTS_CMD_ECC_INIT 0x64
|
||||
#define FTS_CMD_ECC_CAL 0x65
|
||||
#define FTS_CMD_ECC_CAL_LEN 6
|
||||
#define FTS_RETRIES_ECC_CAL 10
|
||||
#define FTS_RETRIES_DELAY_ECC_CAL 50
|
||||
#define FTS_CMD_ECC_READ 0x66
|
||||
#define FTS_CMD_DATA_LEN 0xB0
|
||||
#define FTS_CMD_APP_DATA_LEN_INCELL 0x7A
|
||||
#define FTS_CMD_DATA_LEN_LEN 4
|
||||
#define FTS_CMD_WRITE 0xBF
|
||||
#define FTS_RETRIES_WRITE 100
|
||||
#define FTS_RETRIES_DELAY_WRITE 1
|
||||
#define FTS_CMD_WRITE_LEN 6
|
||||
#define FTS_DELAY_READ_ID 20
|
||||
#define FTS_DELAY_UPGRADE_RESET 80
|
||||
#define PRAMBOOT_MIN_SIZE 0x120
|
||||
#define PRAMBOOT_MAX_SIZE (64*1024)
|
||||
#define FTS_FLASH_PACKET_LENGTH 32 /* max=128 */
|
||||
#define FTS_MAX_LEN_ECC_CALC 0xFFFE /* must be even */
|
||||
#define FTS_MIN_LEN 0x120
|
||||
#define FTS_MAX_LEN_FILE (128 * 1024)
|
||||
#define FTS_MAX_LEN_APP (64 * 1024)
|
||||
#define FTS_MAX_LEN_SECTOR (4 * 1024)
|
||||
#define FTS_CONIFG_VENDORID_OFF 0x04
|
||||
#define FTS_CONIFG_MODULEID_OFF 0x1E
|
||||
#define FTS_CONIFG_PROJECTID_OFF 0x20
|
||||
#define FTS_APPINFO_OFF 0x100
|
||||
#define FTS_APPINFO_APPLEN_OFF 0x00
|
||||
#define FTS_APPINFO_APPLEN2_OFF 0x12
|
||||
#define FTS_REG_UPGRADE 0xFC
|
||||
#define FTS_REG_UPGRADE2 0xBC
|
||||
#define FTS_UPGRADE_AA 0xAA
|
||||
#define FTS_UPGRADE_55 0x55
|
||||
#define FTS_DELAY_UPGRADE_AA 10
|
||||
#define FTS_UPGRADE_LOOP 30
|
||||
#define FTS_HEADER_LEN 32
|
||||
#define FTS_FW_BIN_FILEPATH "/sdcard/"
|
||||
#define FTS_FW_IDE_SIG "IDE_"
|
||||
#define FTS_FW_IDE_SIG_LEN 4
|
||||
#define MAX_MODULE_VENDOR_NAME_LEN 16
|
||||
|
||||
#define FTS_ROMBOOT_CMD_ECC_NEW_LEN 7
|
||||
#define FTS_ECC_FINISH_TIMEOUT 100
|
||||
#define FTS_ROMBOOT_CMD_ECC_FINISH 0xCE
|
||||
#define FTS_ROMBOOT_CMD_ECC_FINISH_OK_A5 0xA5
|
||||
#define FTS_ROMBOOT_CMD_ECC_FINISH_OK_00 0x00
|
||||
#define FTS_ROMBOOT_CMD_ECC_READ 0xCD
|
||||
#define AL2_FCS_COEF ((1 << 15) + (1 << 10) + (1 << 3))
|
||||
|
||||
#define FTS_APP_INFO_OFFSET 0x100
|
||||
|
||||
enum FW_STATUS {
|
||||
FTS_RUN_IN_ERROR,
|
||||
FTS_RUN_IN_APP,
|
||||
FTS_RUN_IN_ROM,
|
||||
FTS_RUN_IN_PRAM,
|
||||
FTS_RUN_IN_BOOTLOADER,
|
||||
};
|
||||
|
||||
enum FW_FLASH_MODE {
|
||||
FLASH_MODE_APP,
|
||||
FLASH_MODE_LIC,
|
||||
FLASH_MODE_PARAM,
|
||||
FLASH_MODE_ALL,
|
||||
};
|
||||
|
||||
enum ECC_CHECK_MODE {
|
||||
ECC_CHECK_MODE_XOR,
|
||||
ECC_CHECK_MODE_CRC16,
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
* Private enumerations, structures and unions using typedef
|
||||
*****************************************************************************/
|
||||
/* IC info */
|
||||
struct upgrade_func {
|
||||
u64 ctype[FTX_MAX_COMPATIBLE_TYPE];
|
||||
u32 fwveroff;
|
||||
u32 fwcfgoff;
|
||||
u32 appoff;
|
||||
u32 licoff;
|
||||
u32 paramcfgoff;
|
||||
u32 paramcfgveroff;
|
||||
u32 paramcfg2off;
|
||||
int pram_ecc_check_mode;
|
||||
int fw_ecc_check_mode;
|
||||
bool new_return_value_from_ic;
|
||||
bool appoff_handle_in_ic;
|
||||
bool is_reset_register_BC;
|
||||
bool read_boot_id_need_reset;
|
||||
bool hid_supported;
|
||||
bool pramboot_supported;
|
||||
u8 *pramboot;
|
||||
u32 pb_length;
|
||||
int (*init)(u8 *, u32);
|
||||
int (*upgrade)(u8 *, u32);
|
||||
int (*get_hlic_ver)(u8 *);
|
||||
int (*lic_upgrade)(u8 *, u32);
|
||||
int (*param_upgrade)(u8 *, u32);
|
||||
int (*force_upgrade)(u8 *, u32);
|
||||
};
|
||||
|
||||
struct upgrade_setting_nf {
|
||||
u8 rom_idh;
|
||||
u8 rom_idl;
|
||||
u16 reserved;
|
||||
u32 app2_offset;
|
||||
u32 ecclen_max;
|
||||
u8 eccok_val;
|
||||
u8 upgsts_boot;
|
||||
u8 delay_init;
|
||||
bool spi_pe;
|
||||
bool half_length;
|
||||
bool fd_check;
|
||||
bool drwr_support;
|
||||
};
|
||||
|
||||
struct upgrade_module {
|
||||
int id;
|
||||
char vendor_name[MAX_MODULE_VENDOR_NAME_LEN];
|
||||
u8 *fw_file;
|
||||
u32 fw_len;
|
||||
};
|
||||
|
||||
struct fts_upgrade {
|
||||
struct fts_ts_data *ts_data;
|
||||
struct upgrade_module *module_info;
|
||||
struct upgrade_func *func;
|
||||
struct upgrade_setting_nf *setting_nf;
|
||||
int module_id;
|
||||
bool fw_from_request;
|
||||
u8 *fw;
|
||||
u32 fw_length;
|
||||
u8 *lic;
|
||||
u32 lic_length;
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
* Global variable or extern global variabls/functions
|
||||
*****************************************************************************/
|
||||
extern struct upgrade_func upgrade_func_ft5422;
|
||||
|
||||
/*****************************************************************************
|
||||
* Static function prototypes
|
||||
*****************************************************************************/
|
||||
int fts_fwupg_reset_in_boot(void);
|
||||
int fts_fwupg_enter_into_boot(void);
|
||||
int fts_fwupg_erase(u32 delay);
|
||||
int fts_fwupg_ecc_cal(u32 saddr, u32 len);
|
||||
int fts_flash_write_buf(u32 saddr, u8 *buf, u32 len, u32 delay);
|
||||
int fts_fwupg_upgrade(struct fts_upgrade *upg);
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
# Makefile for the focaltech touchscreen drivers.
|
||||
#
|
||||
|
||||
obj-y += focaltech_upgrade_ft5436.o
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
*
|
||||
* FocalTech fts TouchScreen driver.
|
||||
*
|
||||
* Copyright (c) 2012-2019, Focaltech Ltd. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* File Name: focaltech_upgrade_ft5422.c
|
||||
*
|
||||
* Author: Focaltech Driver Team
|
||||
*
|
||||
* Created: 2016-08-15
|
||||
*
|
||||
* Abstract:
|
||||
*
|
||||
* Reference:
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*****************************************************************************
|
||||
* 1.Included header files
|
||||
*****************************************************************************/
|
||||
#include "../focaltech_flash.h"
|
||||
|
||||
/*****************************************************************************
|
||||
* Static function prototypes
|
||||
*****************************************************************************/
|
||||
static int fts_ft5422_init(u8 *buf, u32 len)
|
||||
{
|
||||
if ((!buf) || (len < FTS_MIN_LEN)) {
|
||||
FTS_ERROR("upg is null/fw length fail");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
upgrade_func_ft5422.fwveroff = len - 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* Name: fts_ft5422_upgrade
|
||||
* Brief:
|
||||
* Input:
|
||||
* Output:
|
||||
* Return: return 0 if success, otherwise return error code
|
||||
***********************************************************************/
|
||||
static int fts_ft5422_upgrade(u8 *buf, u32 len)
|
||||
{
|
||||
int ret = 0;
|
||||
u32 start_addr = 0;
|
||||
u8 cmd[4] = { 0 };
|
||||
int ecc_in_host = 0;
|
||||
int ecc_in_tp = 0;
|
||||
|
||||
if (NULL == buf) {
|
||||
FTS_ERROR("fw buf is null");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if ((len < FTS_MIN_LEN) || (len > (60 * 1024))) {
|
||||
FTS_ERROR("fw buffer len(%x) fail", len);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* enter into upgrade environment */
|
||||
ret = fts_fwupg_enter_into_boot();
|
||||
if (ret < 0) {
|
||||
FTS_ERROR("enter into pramboot/bootloader fail,ret=%d", ret);
|
||||
goto fw_reset;
|
||||
}
|
||||
|
||||
cmd[0] = FTS_CMD_FLASH_MODE;
|
||||
cmd[1] = FLASH_MODE_UPGRADE_VALUE;
|
||||
ret = fts_write(cmd, 2);
|
||||
if (ret < 0) {
|
||||
FTS_ERROR("upgrade mode(09) cmd write fail");
|
||||
goto fw_reset;
|
||||
}
|
||||
|
||||
cmd[0] = FTS_CMD_DATA_LEN;
|
||||
cmd[1] = BYTE_OFF_16(len);
|
||||
cmd[2] = BYTE_OFF_8(len);
|
||||
cmd[3] = BYTE_OFF_0(len);
|
||||
ret = fts_write(cmd, FTS_CMD_DATA_LEN_LEN);
|
||||
if (ret < 0) {
|
||||
FTS_ERROR("data len cmd write fail");
|
||||
goto fw_reset;
|
||||
}
|
||||
|
||||
ret = fts_fwupg_erase(FTS_REASE_APP_DELAY);
|
||||
if (ret < 0) {
|
||||
FTS_ERROR("erase cmd write fail");
|
||||
goto fw_reset;
|
||||
}
|
||||
|
||||
/* write app */
|
||||
start_addr = upgrade_func_ft5422.appoff;
|
||||
ecc_in_host = fts_flash_write_buf(start_addr, buf, len, 1);
|
||||
if (ecc_in_host < 0 ) {
|
||||
FTS_ERROR("lcd initial code write fail");
|
||||
goto fw_reset;
|
||||
}
|
||||
|
||||
/* ecc */
|
||||
ecc_in_tp = fts_fwupg_ecc_cal(start_addr, len);
|
||||
if (ecc_in_tp < 0 ) {
|
||||
FTS_ERROR("ecc read fail");
|
||||
goto fw_reset;
|
||||
}
|
||||
|
||||
FTS_INFO("ecc in tp:%x, host:%x", ecc_in_tp, ecc_in_host);
|
||||
if (ecc_in_tp != ecc_in_host) {
|
||||
FTS_ERROR("ecc check fail");
|
||||
goto fw_reset;
|
||||
}
|
||||
|
||||
FTS_INFO("upgrade success, reset to normal boot");
|
||||
ret = fts_fwupg_reset_in_boot();
|
||||
if (ret < 0) {
|
||||
FTS_ERROR("reset to normal boot fail");
|
||||
}
|
||||
|
||||
msleep(200);
|
||||
return 0;
|
||||
|
||||
fw_reset:
|
||||
FTS_INFO("upgrade fail, reset to normal boot");
|
||||
ret = fts_fwupg_reset_in_boot();
|
||||
if (ret < 0) {
|
||||
FTS_ERROR("reset to normal boot fail");
|
||||
}
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
struct upgrade_func upgrade_func_ft5422 = {
|
||||
.ctype = {0x02},
|
||||
.fwveroff = 0x0000,
|
||||
.fwcfgoff = 0xD780,
|
||||
.appoff = 0x0000,
|
||||
.pramboot_supported = false,
|
||||
.hid_supported = true,
|
||||
.init = fts_ft5422_init,
|
||||
.upgrade = fts_ft5422_upgrade,
|
||||
};
|
||||
@@ -0,0 +1,460 @@
|
||||
/*
|
||||
*
|
||||
* FocalTech TouchScreen driver.
|
||||
*
|
||||
* Copyright (c) 2012-2019, Focaltech Ltd. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* File Name: focaltech_gestrue.c
|
||||
*
|
||||
* Author: Focaltech Driver Team
|
||||
*
|
||||
* Created: 2016-08-08
|
||||
*
|
||||
* Abstract:
|
||||
*
|
||||
* Reference:
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* 1.Included header files
|
||||
*****************************************************************************/
|
||||
#include "focaltech_core.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Private constant and macro definitions using #define
|
||||
*****************************************************************************/
|
||||
#define KEY_GESTURE_U KEY_U
|
||||
#define KEY_GESTURE_UP KEY_UP
|
||||
#define KEY_GESTURE_DOWN KEY_DOWN
|
||||
#define KEY_GESTURE_LEFT KEY_LEFT
|
||||
#define KEY_GESTURE_RIGHT KEY_RIGHT
|
||||
#define KEY_GESTURE_O KEY_O
|
||||
#define KEY_GESTURE_E KEY_E
|
||||
#define KEY_GESTURE_M KEY_M
|
||||
#define KEY_GESTURE_L KEY_L
|
||||
#define KEY_GESTURE_W KEY_W
|
||||
#define KEY_GESTURE_S KEY_S
|
||||
#define KEY_GESTURE_V KEY_V
|
||||
#define KEY_GESTURE_C KEY_C
|
||||
#define KEY_GESTURE_Z KEY_Z
|
||||
|
||||
#define GESTURE_LEFT 0x20
|
||||
#define GESTURE_RIGHT 0x21
|
||||
#define GESTURE_UP 0x22
|
||||
#define GESTURE_DOWN 0x23
|
||||
#define GESTURE_DOUBLECLICK 0x24
|
||||
#define GESTURE_O 0x30
|
||||
#define GESTURE_W 0x31
|
||||
#define GESTURE_M 0x32
|
||||
#define GESTURE_E 0x33
|
||||
#define GESTURE_L 0x44
|
||||
#define GESTURE_S 0x46
|
||||
#define GESTURE_V 0x54
|
||||
#define GESTURE_Z 0x41
|
||||
#define GESTURE_C 0x34
|
||||
|
||||
/*****************************************************************************
|
||||
* Private enumerations, structures and unions using typedef
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* gesture_id - mean which gesture is recognised
|
||||
* point_num - points number of this gesture
|
||||
* coordinate_x - All gesture point x coordinate
|
||||
* coordinate_y - All gesture point y coordinate
|
||||
* mode - gesture enable/disable, need enable by host
|
||||
* - 1:enable gesture function(default) 0:disable
|
||||
* active - gesture work flag,
|
||||
* always set 1 when suspend, set 0 when resume
|
||||
*/
|
||||
struct fts_gesture_st {
|
||||
u8 gesture_id;
|
||||
u8 point_num;
|
||||
u16 coordinate_x[FTS_GESTURE_POINTS_MAX];
|
||||
u16 coordinate_y[FTS_GESTURE_POINTS_MAX];
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
* Static variables
|
||||
*****************************************************************************/
|
||||
static struct fts_gesture_st fts_gesture_data;
|
||||
|
||||
/*****************************************************************************
|
||||
* Global variable or extern global variabls/functions
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Static function prototypes
|
||||
*****************************************************************************/
|
||||
static ssize_t fts_gesture_show(
|
||||
struct device *dev, struct device_attribute *attr, char *buf)
|
||||
{
|
||||
int count = 0;
|
||||
u8 val = 0;
|
||||
struct fts_ts_data *ts_data = fts_data;
|
||||
|
||||
mutex_lock(&ts_data->input_dev->mutex);
|
||||
fts_read_reg(FTS_REG_GESTURE_EN, &val);
|
||||
count = snprintf(buf, PAGE_SIZE, "Gesture Mode:%s\n",
|
||||
ts_data->gesture_mode ? "On" : "Off");
|
||||
count += snprintf(buf + count, PAGE_SIZE, "Reg(0xD0)=%d\n", val);
|
||||
mutex_unlock(&ts_data->input_dev->mutex);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t fts_gesture_store(
|
||||
struct device *dev,
|
||||
struct device_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
struct fts_ts_data *ts_data = fts_data;
|
||||
|
||||
mutex_lock(&ts_data->input_dev->mutex);
|
||||
if (FTS_SYSFS_ECHO_ON(buf)) {
|
||||
FTS_DEBUG("enable gesture");
|
||||
ts_data->gesture_mode = ENABLE;
|
||||
} else if (FTS_SYSFS_ECHO_OFF(buf)) {
|
||||
FTS_DEBUG("disable gesture");
|
||||
ts_data->gesture_mode = DISABLE;
|
||||
}
|
||||
mutex_unlock(&ts_data->input_dev->mutex);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t fts_gesture_buf_show(
|
||||
struct device *dev, struct device_attribute *attr, char *buf)
|
||||
{
|
||||
int count = 0;
|
||||
int i = 0;
|
||||
struct input_dev *input_dev = fts_data->input_dev;
|
||||
struct fts_gesture_st *gesture = &fts_gesture_data;
|
||||
|
||||
mutex_lock(&input_dev->mutex);
|
||||
count = snprintf(buf, PAGE_SIZE, "Gesture ID:%d\n", gesture->gesture_id);
|
||||
count += snprintf(buf + count, PAGE_SIZE, "Gesture PointNum:%d\n",
|
||||
gesture->point_num);
|
||||
count += snprintf(buf + count, PAGE_SIZE, "Gesture Points Buffer:\n");
|
||||
|
||||
/* save point data,max:6 */
|
||||
for (i = 0; i < FTS_GESTURE_POINTS_MAX; i++) {
|
||||
count += snprintf(buf + count, PAGE_SIZE, "%3d(%4d,%4d) ", i,
|
||||
gesture->coordinate_x[i], gesture->coordinate_y[i]);
|
||||
if ((i + 1) % 4 == 0)
|
||||
count += snprintf(buf + count, PAGE_SIZE, "\n");
|
||||
}
|
||||
count += snprintf(buf + count, PAGE_SIZE, "\n");
|
||||
mutex_unlock(&input_dev->mutex);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t fts_gesture_buf_store(
|
||||
struct device *dev,
|
||||
struct device_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
|
||||
/* sysfs gesture node
|
||||
* read example: cat fts_gesture_mode ---read gesture mode
|
||||
* write example:echo 1 > fts_gesture_mode --- write gesture mode to 1
|
||||
*
|
||||
*/
|
||||
static DEVICE_ATTR(fts_gesture_mode, S_IRUGO | S_IWUSR, fts_gesture_show,
|
||||
fts_gesture_store);
|
||||
/*
|
||||
* read example: cat fts_gesture_buf --- read gesture buf
|
||||
*/
|
||||
static DEVICE_ATTR(fts_gesture_buf, S_IRUGO | S_IWUSR,
|
||||
fts_gesture_buf_show, fts_gesture_buf_store);
|
||||
|
||||
static struct attribute *fts_gesture_mode_attrs[] = {
|
||||
&dev_attr_fts_gesture_mode.attr,
|
||||
&dev_attr_fts_gesture_buf.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static struct attribute_group fts_gesture_group = {
|
||||
.attrs = fts_gesture_mode_attrs,
|
||||
};
|
||||
|
||||
static int fts_create_gesture_sysfs(struct device *dev)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret = sysfs_create_group(&dev->kobj, &fts_gesture_group);
|
||||
if (ret) {
|
||||
FTS_ERROR("gesture sys node create fail");
|
||||
sysfs_remove_group(&dev->kobj, &fts_gesture_group);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void fts_gesture_report(struct input_dev *input_dev, int gesture_id)
|
||||
{
|
||||
int gesture;
|
||||
|
||||
FTS_DEBUG("gesture_id:0x%x", gesture_id);
|
||||
switch (gesture_id) {
|
||||
case GESTURE_LEFT:
|
||||
gesture = KEY_GESTURE_LEFT;
|
||||
break;
|
||||
case GESTURE_RIGHT:
|
||||
gesture = KEY_GESTURE_RIGHT;
|
||||
break;
|
||||
case GESTURE_UP:
|
||||
gesture = KEY_GESTURE_UP;
|
||||
break;
|
||||
case GESTURE_DOWN:
|
||||
gesture = KEY_GESTURE_DOWN;
|
||||
break;
|
||||
case GESTURE_DOUBLECLICK:
|
||||
gesture = KEY_GESTURE_U;
|
||||
break;
|
||||
case GESTURE_O:
|
||||
gesture = KEY_GESTURE_O;
|
||||
break;
|
||||
case GESTURE_W:
|
||||
gesture = KEY_GESTURE_W;
|
||||
break;
|
||||
case GESTURE_M:
|
||||
gesture = KEY_GESTURE_M;
|
||||
break;
|
||||
case GESTURE_E:
|
||||
gesture = KEY_GESTURE_E;
|
||||
break;
|
||||
case GESTURE_L:
|
||||
gesture = KEY_GESTURE_L;
|
||||
break;
|
||||
case GESTURE_S:
|
||||
gesture = KEY_GESTURE_S;
|
||||
break;
|
||||
case GESTURE_V:
|
||||
gesture = KEY_GESTURE_V;
|
||||
break;
|
||||
case GESTURE_Z:
|
||||
gesture = KEY_GESTURE_Z;
|
||||
break;
|
||||
case GESTURE_C:
|
||||
gesture = KEY_GESTURE_C;
|
||||
break;
|
||||
default:
|
||||
gesture = -1;
|
||||
break;
|
||||
}
|
||||
/* report event key */
|
||||
if (gesture != -1) {
|
||||
FTS_DEBUG("Gesture Code=%d", gesture);
|
||||
input_report_key(input_dev, gesture, 1);
|
||||
input_sync(input_dev);
|
||||
input_report_key(input_dev, gesture, 0);
|
||||
input_sync(input_dev);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: fts_gesture_readdata
|
||||
* Brief: Read information about gesture: enable flag/gesture points..., if ges-
|
||||
* ture enable, save gesture points' information, and report to OS.
|
||||
* It will be called this function every intrrupt when FTS_GESTURE_EN = 1
|
||||
*
|
||||
* gesture data length: 1(enable) + 1(reserve) + 2(header) + 6 * 4
|
||||
* Input: ts_data - global struct data
|
||||
* data - gesture data buffer if non-flash, else NULL
|
||||
* Output:
|
||||
* Return: 0 - read gesture data successfully, the report data is gesture data
|
||||
* 1 - tp not in suspend/gesture not enable in TP FW
|
||||
* -Exx - error
|
||||
*****************************************************************************/
|
||||
int fts_gesture_readdata(struct fts_ts_data *ts_data, u8 *data)
|
||||
{
|
||||
int ret = 0;
|
||||
int i = 0;
|
||||
int index = 0;
|
||||
u8 buf[FTS_GESTURE_DATA_LEN] = { 0 };
|
||||
struct input_dev *input_dev = ts_data->input_dev;
|
||||
struct fts_gesture_st *gesture = &fts_gesture_data;
|
||||
|
||||
if (!ts_data->suspended || !ts_data->gesture_mode) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
ret = fts_read_reg(FTS_REG_GESTURE_EN, &buf[0]);
|
||||
if ((ret < 0) || (buf[0] != ENABLE)) {
|
||||
FTS_DEBUG("gesture not enable in fw, don't process gesture");
|
||||
return 1;
|
||||
}
|
||||
|
||||
buf[2] = FTS_REG_GESTURE_OUTPUT_ADDRESS;
|
||||
ret = fts_read(&buf[2], 1, &buf[2], FTS_GESTURE_DATA_LEN - 2);
|
||||
if (ret < 0) {
|
||||
FTS_ERROR("read gesture header data fail");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* init variable before read gesture point */
|
||||
memset(gesture->coordinate_x, 0, FTS_GESTURE_POINTS_MAX * sizeof(u16));
|
||||
memset(gesture->coordinate_y, 0, FTS_GESTURE_POINTS_MAX * sizeof(u16));
|
||||
gesture->gesture_id = buf[2];
|
||||
gesture->point_num = buf[3];
|
||||
FTS_DEBUG("gesture_id=%d, point_num=%d",
|
||||
gesture->gesture_id, gesture->point_num);
|
||||
|
||||
/* save point data,max:6 */
|
||||
for (i = 0; i < FTS_GESTURE_POINTS_MAX; i++) {
|
||||
index = 4 * i + 4;
|
||||
gesture->coordinate_x[i] = (u16)(((buf[0 + index] & 0x0F) << 8)
|
||||
+ buf[1 + index]);
|
||||
gesture->coordinate_y[i] = (u16)(((buf[2 + index] & 0x0F) << 8)
|
||||
+ buf[3 + index]);
|
||||
}
|
||||
|
||||
/* report gesture to OS */
|
||||
fts_gesture_report(input_dev, gesture->gesture_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void fts_gesture_recovery(struct fts_ts_data *ts_data)
|
||||
{
|
||||
if (ts_data->gesture_mode && ts_data->suspended) {
|
||||
FTS_DEBUG("gesture recovery...");
|
||||
fts_write_reg(0xD1, 0xFF);
|
||||
fts_write_reg(0xD2, 0xFF);
|
||||
fts_write_reg(0xD5, 0xFF);
|
||||
fts_write_reg(0xD6, 0xFF);
|
||||
fts_write_reg(0xD7, 0xFF);
|
||||
fts_write_reg(0xD8, 0xFF);
|
||||
fts_write_reg(FTS_REG_GESTURE_EN, ENABLE);
|
||||
}
|
||||
}
|
||||
|
||||
int fts_gesture_suspend(struct fts_ts_data *ts_data)
|
||||
{
|
||||
int i = 0;
|
||||
u8 state = 0xFF;
|
||||
|
||||
FTS_FUNC_ENTER();
|
||||
if (enable_irq_wake(ts_data->irq)) {
|
||||
FTS_DEBUG("enable_irq_wake(irq:%d) fail", ts_data->irq);
|
||||
}
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
fts_write_reg(0xD1, 0xFF);
|
||||
fts_write_reg(0xD2, 0xFF);
|
||||
fts_write_reg(0xD5, 0xFF);
|
||||
fts_write_reg(0xD6, 0xFF);
|
||||
fts_write_reg(0xD7, 0xFF);
|
||||
fts_write_reg(0xD8, 0xFF);
|
||||
fts_write_reg(FTS_REG_GESTURE_EN, ENABLE);
|
||||
msleep(1);
|
||||
fts_read_reg(FTS_REG_GESTURE_EN, &state);
|
||||
if (state == ENABLE)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i >= 5)
|
||||
FTS_ERROR("make IC enter into gesture(suspend) fail,state:%x", state);
|
||||
else
|
||||
FTS_INFO("Enter into gesture(suspend) successfully");
|
||||
|
||||
FTS_FUNC_EXIT();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fts_gesture_resume(struct fts_ts_data *ts_data)
|
||||
{
|
||||
int i = 0;
|
||||
u8 state = 0xFF;
|
||||
|
||||
FTS_FUNC_ENTER();
|
||||
if (disable_irq_wake(ts_data->irq)) {
|
||||
FTS_DEBUG("disable_irq_wake(irq:%d) fail", ts_data->irq);
|
||||
}
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
fts_write_reg(FTS_REG_GESTURE_EN, DISABLE);
|
||||
msleep(1);
|
||||
fts_read_reg(FTS_REG_GESTURE_EN, &state);
|
||||
if (state == DISABLE)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i >= 5)
|
||||
FTS_ERROR("make IC exit gesture(resume) fail,state:%x", state);
|
||||
else
|
||||
FTS_INFO("resume from gesture successfully");
|
||||
|
||||
FTS_FUNC_EXIT();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fts_gesture_init(struct fts_ts_data *ts_data)
|
||||
{
|
||||
struct input_dev *input_dev = ts_data->input_dev;
|
||||
|
||||
FTS_FUNC_ENTER();
|
||||
input_set_capability(input_dev, EV_KEY, KEY_POWER);
|
||||
input_set_capability(input_dev, EV_KEY, KEY_GESTURE_U);
|
||||
input_set_capability(input_dev, EV_KEY, KEY_GESTURE_UP);
|
||||
input_set_capability(input_dev, EV_KEY, KEY_GESTURE_DOWN);
|
||||
input_set_capability(input_dev, EV_KEY, KEY_GESTURE_LEFT);
|
||||
input_set_capability(input_dev, EV_KEY, KEY_GESTURE_RIGHT);
|
||||
input_set_capability(input_dev, EV_KEY, KEY_GESTURE_O);
|
||||
input_set_capability(input_dev, EV_KEY, KEY_GESTURE_E);
|
||||
input_set_capability(input_dev, EV_KEY, KEY_GESTURE_M);
|
||||
input_set_capability(input_dev, EV_KEY, KEY_GESTURE_L);
|
||||
input_set_capability(input_dev, EV_KEY, KEY_GESTURE_W);
|
||||
input_set_capability(input_dev, EV_KEY, KEY_GESTURE_S);
|
||||
input_set_capability(input_dev, EV_KEY, KEY_GESTURE_V);
|
||||
input_set_capability(input_dev, EV_KEY, KEY_GESTURE_Z);
|
||||
input_set_capability(input_dev, EV_KEY, KEY_GESTURE_C);
|
||||
|
||||
__set_bit(KEY_GESTURE_RIGHT, input_dev->keybit);
|
||||
__set_bit(KEY_GESTURE_LEFT, input_dev->keybit);
|
||||
__set_bit(KEY_GESTURE_UP, input_dev->keybit);
|
||||
__set_bit(KEY_GESTURE_DOWN, input_dev->keybit);
|
||||
__set_bit(KEY_GESTURE_U, input_dev->keybit);
|
||||
__set_bit(KEY_GESTURE_O, input_dev->keybit);
|
||||
__set_bit(KEY_GESTURE_E, input_dev->keybit);
|
||||
__set_bit(KEY_GESTURE_M, input_dev->keybit);
|
||||
__set_bit(KEY_GESTURE_W, input_dev->keybit);
|
||||
__set_bit(KEY_GESTURE_L, input_dev->keybit);
|
||||
__set_bit(KEY_GESTURE_S, input_dev->keybit);
|
||||
__set_bit(KEY_GESTURE_V, input_dev->keybit);
|
||||
__set_bit(KEY_GESTURE_C, input_dev->keybit);
|
||||
__set_bit(KEY_GESTURE_Z, input_dev->keybit);
|
||||
|
||||
fts_create_gesture_sysfs(ts_data->dev);
|
||||
|
||||
memset(&fts_gesture_data, 0, sizeof(struct fts_gesture_st));
|
||||
ts_data->gesture_mode = FTS_GESTURE_EN;
|
||||
|
||||
FTS_FUNC_EXIT();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fts_gesture_exit(struct fts_ts_data *ts_data)
|
||||
{
|
||||
FTS_FUNC_ENTER();
|
||||
sysfs_remove_group(&ts_data->dev->kobj, &fts_gesture_group);
|
||||
FTS_FUNC_EXIT();
|
||||
return 0;
|
||||
}
|
||||
193
drivers/input/touchscreen/focaltech_touch_ft5436/focaltech_i2c.c
Normal file
193
drivers/input/touchscreen/focaltech_touch_ft5436/focaltech_i2c.c
Normal file
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
*
|
||||
* FocalTech TouchScreen driver.
|
||||
*
|
||||
* Copyright (c) 2012-2019, FocalTech Systems, Ltd., all rights reserved.
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* File Name: focaltech_i2c.c
|
||||
*
|
||||
* Author: Focaltech Driver Team
|
||||
*
|
||||
* Created: 2016-08-04
|
||||
*
|
||||
* Abstract: i2c communication with TP
|
||||
*
|
||||
* Version: v1.0
|
||||
*
|
||||
* Revision History:
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Included header files
|
||||
*****************************************************************************/
|
||||
#include "focaltech_core.h"
|
||||
|
||||
/*****************************************************************************
|
||||
* Private constant and macro definitions using #define
|
||||
*****************************************************************************/
|
||||
#define I2C_RETRY_NUMBER 3
|
||||
#define I2C_BUF_LENGTH 256
|
||||
|
||||
/*****************************************************************************
|
||||
* Private enumerations, structures and unions using typedef
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Static variables
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Global variable or extern global variabls/functions
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Static function prototypes
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* functions body
|
||||
*****************************************************************************/
|
||||
int fts_read(u8 *cmd, u32 cmdlen, u8 *data, u32 datalen)
|
||||
{
|
||||
int ret = 0;
|
||||
int i = 0;
|
||||
struct fts_ts_data *ts_data = fts_data;
|
||||
struct i2c_msg msg_list[2];
|
||||
struct i2c_msg *msg = NULL;
|
||||
int msg_num = 0;
|
||||
|
||||
/* must have data when read */
|
||||
if (!ts_data || !ts_data->client || !data || !datalen
|
||||
|| (datalen >= I2C_BUF_LENGTH) || (cmdlen >= I2C_BUF_LENGTH)) {
|
||||
FTS_ERROR("fts_data/client/cmdlen(%d)/data/datalen(%d) is invalid",
|
||||
cmdlen, datalen);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mutex_lock(&ts_data->bus_lock);
|
||||
memset(&msg_list[0], 0, sizeof(struct i2c_msg));
|
||||
memset(&msg_list[1], 0, sizeof(struct i2c_msg));
|
||||
memcpy(ts_data->bus_tx_buf, cmd, cmdlen);
|
||||
msg_list[0].addr = ts_data->client->addr;
|
||||
msg_list[0].flags = 0;
|
||||
msg_list[0].len = cmdlen;
|
||||
msg_list[0].buf = ts_data->bus_tx_buf;
|
||||
msg_list[1].addr = ts_data->client->addr;
|
||||
msg_list[1].flags = I2C_M_RD;
|
||||
msg_list[1].len = datalen;
|
||||
msg_list[1].buf = ts_data->bus_rx_buf;
|
||||
if (cmd && cmdlen) {
|
||||
msg = &msg_list[0];
|
||||
msg_num = 2;
|
||||
} else {
|
||||
msg = &msg_list[1];
|
||||
msg_num = 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < I2C_RETRY_NUMBER; i++) {
|
||||
ret = i2c_transfer(ts_data->client->adapter, msg, msg_num);
|
||||
if (ret < 0) {
|
||||
FTS_ERROR("i2c_transfer(read) fail,ret:%d", ret);
|
||||
} else {
|
||||
memcpy(data, ts_data->bus_rx_buf, datalen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mutex_unlock(&ts_data->bus_lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int fts_write(u8 *writebuf, u32 writelen)
|
||||
{
|
||||
int ret = 0;
|
||||
int i = 0;
|
||||
struct fts_ts_data *ts_data = fts_data;
|
||||
struct i2c_msg msgs;
|
||||
|
||||
if (!ts_data || !ts_data->client || !writebuf || !writelen
|
||||
|| (writelen >= I2C_BUF_LENGTH)) {
|
||||
FTS_ERROR("fts_data/client/data/datalen(%d) is invalid", writelen);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mutex_lock(&ts_data->bus_lock);
|
||||
memset(&msgs, 0, sizeof(struct i2c_msg));
|
||||
memcpy(ts_data->bus_tx_buf, writebuf, writelen);
|
||||
msgs.addr = ts_data->client->addr;
|
||||
msgs.flags = 0;
|
||||
msgs.len = writelen;
|
||||
msgs.buf = ts_data->bus_tx_buf;
|
||||
for (i = 0; i < I2C_RETRY_NUMBER; i++) {
|
||||
ret = i2c_transfer(ts_data->client->adapter, &msgs, 1);
|
||||
if (ret < 0) {
|
||||
FTS_ERROR("i2c_transfer(write) fail,ret:%d", ret);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
mutex_unlock(&ts_data->bus_lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int fts_read_reg(u8 addr, u8 *value)
|
||||
{
|
||||
return fts_read(&addr, 1, value, 1);
|
||||
}
|
||||
|
||||
int fts_write_reg(u8 addr, u8 value)
|
||||
{
|
||||
u8 buf[2] = { 0 };
|
||||
|
||||
buf[0] = addr;
|
||||
buf[1] = value;
|
||||
return fts_write(buf, sizeof(buf));
|
||||
}
|
||||
|
||||
int fts_bus_init(struct fts_ts_data *ts_data)
|
||||
{
|
||||
FTS_FUNC_ENTER();
|
||||
ts_data->bus_tx_buf = kzalloc(I2C_BUF_LENGTH, GFP_KERNEL);
|
||||
if (NULL == ts_data->bus_tx_buf) {
|
||||
FTS_ERROR("failed to allocate memory for bus_tx_buf");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
ts_data->bus_rx_buf = kzalloc(I2C_BUF_LENGTH, GFP_KERNEL);
|
||||
if (NULL == ts_data->bus_rx_buf) {
|
||||
FTS_ERROR("failed to allocate memory for bus_rx_buf");
|
||||
return -ENOMEM;
|
||||
}
|
||||
FTS_FUNC_EXIT();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fts_bus_exit(struct fts_ts_data *ts_data)
|
||||
{
|
||||
FTS_FUNC_ENTER();
|
||||
if (ts_data && ts_data->bus_tx_buf) {
|
||||
kfree(ts_data->bus_tx_buf);
|
||||
ts_data->bus_tx_buf = NULL;
|
||||
}
|
||||
|
||||
if (ts_data && ts_data->bus_rx_buf) {
|
||||
kfree(ts_data->bus_rx_buf);
|
||||
ts_data->bus_rx_buf = NULL;
|
||||
}
|
||||
FTS_FUNC_EXIT();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
*
|
||||
* FocalTech TouchScreen driver.
|
||||
*
|
||||
* Copyright (c) 2012-2019, FocalTech Systems, Ltd., all rights reserved.
|
||||
*
|
||||
* This software is licensed under the terms of the GNU General Public
|
||||
* License version 2, as published by the Free Software Foundation, and
|
||||
* may be copied, distributed, and modified under those terms.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* File Name: focaltech_point_report_check.c
|
||||
*
|
||||
* Author: Focaltech Driver Team
|
||||
*
|
||||
* Created: 2016-11-16
|
||||
*
|
||||
* Abstract: point report check function
|
||||
*
|
||||
* Version: v1.0
|
||||
*
|
||||
* Revision History:
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Included header files
|
||||
*****************************************************************************/
|
||||
#include "focaltech_core.h"
|
||||
|
||||
#if FTS_POINT_REPORT_CHECK_EN
|
||||
/*****************************************************************************
|
||||
* Private constant and macro definitions using #define
|
||||
*****************************************************************************/
|
||||
#define POINT_REPORT_CHECK_WAIT_TIME 200 /* unit:ms */
|
||||
|
||||
/*****************************************************************************
|
||||
* functions body
|
||||
*****************************************************************************/
|
||||
/*****************************************************************************
|
||||
* Name: fts_prc_func
|
||||
* Brief: fts point report check work func, report whole up of points
|
||||
* Input:
|
||||
* Output:
|
||||
* Return:
|
||||
*****************************************************************************/
|
||||
static void fts_prc_func(struct work_struct *work)
|
||||
{
|
||||
struct fts_ts_data *ts_data = container_of(work,
|
||||
struct fts_ts_data, prc_work.work);
|
||||
struct input_dev *input_dev = ts_data->input_dev;
|
||||
#if FTS_MT_PROTOCOL_B_EN
|
||||
u32 finger_count = 0;
|
||||
u32 max_touches = fts_data->pdata->max_touch_number;
|
||||
#endif
|
||||
|
||||
FTS_FUNC_ENTER();
|
||||
mutex_lock(&ts_data->report_mutex);
|
||||
|
||||
#if FTS_MT_PROTOCOL_B_EN
|
||||
for (finger_count = 0; finger_count < max_touches; finger_count++) {
|
||||
input_mt_slot(input_dev, finger_count);
|
||||
input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, false);
|
||||
}
|
||||
#else
|
||||
input_mt_sync(input_dev);
|
||||
#endif
|
||||
input_report_key(input_dev, BTN_TOUCH, 0);
|
||||
input_sync(input_dev);
|
||||
|
||||
mutex_unlock(&ts_data->report_mutex);
|
||||
|
||||
FTS_FUNC_EXIT();
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: fts_prc_queue_work
|
||||
* Brief: fts point report check queue work, call it when interrupt comes
|
||||
* Input:
|
||||
* Output:
|
||||
* Return:
|
||||
*****************************************************************************/
|
||||
void fts_prc_queue_work(struct fts_ts_data *ts_data)
|
||||
{
|
||||
cancel_delayed_work_sync(&ts_data->prc_work);
|
||||
queue_delayed_work(ts_data->ts_workqueue, &ts_data->prc_work,
|
||||
msecs_to_jiffies(POINT_REPORT_CHECK_WAIT_TIME));
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: fts_point_report_check_init
|
||||
* Brief:
|
||||
* Input:
|
||||
* Output:
|
||||
* Return: < 0: Fail to create esd check queue
|
||||
*****************************************************************************/
|
||||
int fts_point_report_check_init(struct fts_ts_data *ts_data)
|
||||
{
|
||||
FTS_FUNC_ENTER();
|
||||
|
||||
if (ts_data->ts_workqueue) {
|
||||
INIT_DELAYED_WORK(&ts_data->prc_work, fts_prc_func);
|
||||
} else {
|
||||
FTS_ERROR("fts workqueue is NULL, can't run point report check function");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
FTS_FUNC_EXIT();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Name: fts_point_report_check_exit
|
||||
* Brief:
|
||||
* Input:
|
||||
* Output:
|
||||
* Return:
|
||||
*****************************************************************************/
|
||||
int fts_point_report_check_exit(struct fts_ts_data *ts_data)
|
||||
{
|
||||
FTS_FUNC_ENTER();
|
||||
|
||||
FTS_FUNC_EXIT();
|
||||
return 0;
|
||||
}
|
||||
#endif /* FTS_POINT_REPORT_CHECK_EN */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user