1 /* 2 * 3 * FocalTech fts TouchScreen driver. 4 * 5 * Copyright (c) 2012-2018, Focaltech Ltd. All rights reserved. 6 * 7 * This software is licensed under the terms of the GNU General Public 8 * License version 2, as published by the Free Software Foundation, and 9 * may be copied, distributed, and modified under those terms. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 */ 17 /***************************************************************************** 18 * 19 * File Name: focaltech_common.h 20 * 21 * Author: Focaltech Driver Team 22 * 23 * Created: 2016-08-16 24 * 25 * Abstract: 26 * 27 * Reference: 28 * 29 *****************************************************************************/ 30 31 #ifndef __LINUX_FOCALTECH_COMMON_H__ 32 #define __LINUX_FOCALTECH_COMMON_H__ 33 34 #include "focaltech_config.h" 35 36 /***************************************************************************** 37 * Macro definitions using #define 38 *****************************************************************************/ 39 #define FTS_DRIVER_VERSION "Focaltech V3.0a 20180929" 40 41 #define BYTE_OFF_0(x) (u8)((x) & 0xFF) 42 #define BYTE_OFF_8(x) (u8)((x >> 8) & 0xFF) 43 #define BYTE_OFF_16(x) (u8)((x >> 16) & 0xFF) 44 #define BYTE_OFF_24(x) (u8)((x >> 24) & 0xFF) 45 #define FLAGBIT(x) (0x00000001 << (x)) 46 #define FLAGBITS(x, y) ((0xFFFFFFFF >> (32 - (y) - 1)) << (x)) 47 48 #define FLAG_ICSERIALS_LEN 8 49 #define FLAG_HID_BIT 10 50 #define FLAG_IDC_BIT 11 51 52 #define IC_SERIALS (FTS_CHIP_TYPE & FLAGBITS(0, FLAG_ICSERIALS_LEN-1)) 53 #define IC_TO_SERIALS(x) ((x) & FLAGBITS(0, FLAG_ICSERIALS_LEN-1)) 54 #define FTS_CHIP_IDC ((FTS_CHIP_TYPE & FLAGBIT(FLAG_IDC_BIT)) == FLAGBIT(FLAG_IDC_BIT)) 55 #define FTS_HID_SUPPORTTED ((FTS_CHIP_TYPE & FLAGBIT(FLAG_HID_BIT)) == FLAGBIT(FLAG_HID_BIT)) 56 57 #define FTS_CHIP_TYPE_MAPPING {{0x10,0x82, 0x01, 0x80, 0x06, 0x80, 0xC6, 0x80, 0xB6}} 58 59 #define I2C_BUFFER_LENGTH_MAXINUM 256 60 #define FILE_NAME_LENGTH 128 61 #define ENABLE 1 62 #define DISABLE 0 63 #define VALID 1 64 #define INVALID 0 65 #define FTS_CMD_START1 0x55 66 #define FTS_CMD_START2 0xAA 67 #define FTS_CMD_START_DELAY 10 68 #define FTS_CMD_READ_ID 0x90 69 #define FTS_CMD_READ_ID_LEN 4 70 #define FTS_CMD_READ_ID_LEN_INCELL 1 71 /*register address*/ 72 #define FTS_REG_INT_CNT 0x8F 73 #define FTS_REG_FLOW_WORK_CNT 0x91 74 #define FTS_REG_WORKMODE 0x00 75 #define FTS_REG_WORKMODE_FACTORY_VALUE 0x40 76 #define FTS_REG_WORKMODE_WORK_VALUE 0x00 77 #define FTS_REG_ESDCHECK_DISABLE 0x8D 78 #define FTS_REG_CHIP_ID 0xA3 79 #define FTS_REG_CHIP_ID2 0x9F 80 #define FTS_REG_POWER_MODE 0xA5 81 #define FTS_REG_POWER_MODE_SLEEP_VALUE 0x03 82 #define FTS_REG_FW_VER 0xA6 83 #define FTS_REG_VENDOR_ID 0xA8 84 #define FTS_REG_LCD_BUSY_NUM 0xAB 85 #define FTS_REG_FACE_DEC_MODE_EN 0xB0 86 #define FTS_REG_FACE_DEC_MODE_STATUS 0x01 87 #define FTS_REG_IDE_PARA_VER_ID 0xB5 88 #define FTS_REG_IDE_PARA_STATUS 0xB6 89 #define FTS_REG_GLOVE_MODE_EN 0xC0 90 #define FTS_REG_COVER_MODE_EN 0xC1 91 #define FTS_REG_CHARGER_MODE_EN 0x8B 92 #define FTS_REG_GESTURE_EN 0xD0 93 #define FTS_REG_GESTURE_OUTPUT_ADDRESS 0xD3 94 #define FTS_REG_MODULE_ID 0xE3 95 #define FTS_REG_LIC_VER 0xE4 96 #define FTS_REG_ESD_SATURATE 0xED 97 98 #define FTS_SYSFS_ECHO_ON(buf) (buf[0] == '1') 99 #define FTS_SYSFS_ECHO_OFF(buf) (buf[0] == '0') 100 101 #define kfree_safe(pbuf) do {\ 102 if (pbuf) {\ 103 kfree(pbuf);\ 104 pbuf = NULL;\ 105 }\ 106 } while(0) 107 108 /***************************************************************************** 109 * Alternative mode (When something goes wrong, the modules may be able to solve the problem.) 110 *****************************************************************************/ 111 /* 112 * point report check 113 * default: disable 114 */ 115 #define FTS_POINT_REPORT_CHECK_EN 0 116 117 /***************************************************************************** 118 * Global variable or extern global variabls/functions 119 *****************************************************************************/ 120 struct ft_chip_t { 121 u64 type; 122 u8 chip_idh; 123 u8 chip_idl; 124 u8 rom_idh; 125 u8 rom_idl; 126 u8 pb_idh; 127 u8 pb_idl; 128 u8 bl_idh; 129 u8 bl_idl; 130 }; 131 132 struct ts_ic_info { 133 bool is_incell; 134 bool hid_supported; 135 struct ft_chip_t ids; 136 }; 137 138 /***************************************************************************** 139 * DEBUG function define here 140 *****************************************************************************/ 141 #if FTS_DEBUG_EN 142 #define FTS_DEBUG_LEVEL 1 143 #if (FTS_DEBUG_LEVEL == 2) 144 #define FTS_DEBUG(fmt, args...) printk("[FTS][%s]"fmt"\n", __func__, ##args) 145 #else 146 #define FTS_DEBUG(fmt, args...) printk("[FTS]"fmt"\n", ##args) 147 #endif 148 #define FTS_FUNC_ENTER() printk("[FTS]%s: Enter\n", __func__) 149 #define FTS_FUNC_EXIT() printk("[FTS]%s: Exit(%d)\n", __func__, __LINE__) 150 #else /* #if FTS_DEBUG_EN*/ 151 #define FTS_DEBUG(fmt, args...) 152 #define FTS_FUNC_ENTER() 153 #define FTS_FUNC_EXIT() 154 #endif 155 156 #define FTS_INFO(fmt, args...) printk(KERN_INFO "[FTS][Info]"fmt"\n", ##args) 157 #define FTS_ERROR(fmt, args...) printk(KERN_ERR "[FTS][Error]"fmt"\n", ##args) 158 159 #endif /* __LINUX_FOCALTECH_COMMON_H__ */ 160