Loading drivers/input/touchscreen/focaltech_touch/Kconfig +0 −1 Original line number Diff line number Diff line Loading @@ -20,4 +20,3 @@ config FTS_TRUSTED_TOUCH Say Y here to enable Focaltech Trusted Touch. If unsure, say N. #endif drivers/input/touchscreen/focaltech_touch/focaltech_common.h +5 −6 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ /***************************************************************************** * Macro definitions using #define *****************************************************************************/ #define FTS_DRIVER_VERSION "Focaltech V3.1 20190807" #define FTS_DRIVER_VERSION "Focaltech V3.2 20200422" #define BYTE_OFF_0(x) (u8)((x) & 0xFF) #define BYTE_OFF_8(x) (u8)(((x) >> 8) & 0xFF) Loading @@ -49,12 +49,10 @@ #define FLAG_HID_BIT 10 #define FLAG_IDC_BIT 11 #define IC_SERIALS (FTS_CHIP_TYPE & FLAGBITS(0, FLAG_ICSERIALS_LEN-1)) #define IC_SERIALS(type) ((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 {{0x81, 0x54, 0x52, 0x54, 0x52, 0x00, 0x00, 0x54, 0x5C}} #define FTS_CHIP_IDC(type) (((type) & FLAGBIT(FLAG_IDC_BIT)) == FLAGBIT(FLAG_IDC_BIT)) #define FTS_HID_SUPPORTTED(type) (((type) & FLAGBIT(FLAG_HID_BIT)) == FLAGBIT(FLAG_HID_BIT)) #define FILE_NAME_LENGTH 128 #define ENABLE 1 Loading @@ -67,6 +65,7 @@ #define FTS_CMD_READ_ID 0x90 #define FTS_CMD_READ_ID_LEN 4 #define FTS_CMD_READ_ID_LEN_INCELL 1 #define FTS_CMD_READ_FW_CONF 0xA8 /*register address*/ #define FTS_REG_INT_CNT 0x8F #define FTS_REG_FLOW_WORK_CNT 0x91 Loading drivers/input/touchscreen/focaltech_touch/focaltech_config.h +42 −7 Original line number Diff line number Diff line Loading @@ -55,6 +55,9 @@ #define _FT8656 0x86560818 #define _FT8006S_AA 0x86320819 #define _FT7250 0x7250081A #define _FT7120 0x7120081B #define _FT8720 0x8720081C #define _FT8016 0x8016081D #define _FT5416 0x54160402 Loading @@ -77,6 +80,7 @@ #define _FT3327 0x33270402 #define _FT3427 0x34270402 #define _FT7311 0x73110402 #define _FT5526_V00 0x5526C402 #define _FT5626 0x56260401 #define _FT5726 0x57260401 Loading @@ -93,6 +97,7 @@ #define _FT6336G 0x6336A003 #define _FT6336U 0x6336D003 #define _FT6436U 0x6436D003 #define _FT6436T 0x6436E003 #define _FT3267 0x32670004 #define _FT3367 0x33670004 Loading @@ -100,10 +105,21 @@ #define _FT3327DQQ_XXX 0x3327D482 #define _FT5446DQS_XXX 0x5446D482 #define _FT3427_003 0x3427D482 #define _FT3427G_003 0x3427A482 #define _FT5446_003 0x5446D482 #define _FT5446_Q03 0x5446C482 #define _FT5446_P03 0x5446A481 #define _FT5426_003 0x5426D482 #define _FT5526_003 0x5526D482 #define _FT3518 0x35180481 #define _FT3518U 0x3518D481 #define _FT3558 0x35580481 #define _FT3528 0x35280481 #define _FT5536 0x55360481 #define _FT5536L 0x5536E481 #define _FT3418 0x34180481 #define _FT5446U 0x5446D083 #define _FT5456U 0x5456D083 Loading @@ -115,6 +131,7 @@ #define _FT7302 0x73020084 #define _FT7202 0x72020084 #define _FT3308 0x33080084 #define _FT6446 0x64460084 #define _FT6346U 0x6346D085 #define _FT6346G 0x6346A085 Loading @@ -122,13 +139,26 @@ #define _FT3068 0x30680085 #define _FT3168 0x31680085 #define _FT3268 0x32680085 /*************************************************/ /* * choose your ic chip type of focaltech */ #define FTS_CHIP_TYPE _FT3518 #define _FT6146 0x61460085 #define _FT5726_003 0x5726D486 #define _FT5726_V03 0x5726C486 #define _FT3618 0x36180487 #define _FT5646 0x56460487 #define _FT3A58 0x3A580487 #define _FT3B58 0x3B580487 #define _FT3D58 0x3D580487 #define _FT5936 0x59360487 #define _FT5A36 0x5A360487 #define _FT5B36 0x5B360487 #define _FT5D36 0x5D360487 #define _FT5946 0x59460487 #define _FT5A46 0x5A460487 #define _FT5B46 0x5B460487 #define _FT5D46 0x5D460487 #define _FT3658U 0x3658D488 /******************* Enables *********************/ /*********** 1 to enable, 0 to disable ***********/ Loading Loading @@ -163,6 +193,11 @@ */ #define FTS_ESDCHECK_EN 0 /* * Production test enable * 1: enable, 0:disable(default) */ #define FTS_TEST_EN 0 /* * Pinctrl enable Loading drivers/input/touchscreen/focaltech_touch/focaltech_core.c +166 −31 Original line number Diff line number Diff line Loading @@ -90,6 +90,11 @@ struct fts_ts_data *fts_data; static struct drm_panel *active_panel; #endif static struct ft_chip_t ctype[] = { {0x88, 0x56, 0x52, 0x00, 0x00, 0x00, 0x00, 0x56, 0xB2}, {0x81, 0x54, 0x52, 0x54, 0x52, 0x00, 0x00, 0x54, 0x5C}, }; /***************************************************************************** * Static function prototypes *****************************************************************************/ Loading Loading @@ -1323,22 +1328,24 @@ void fts_hid2std(void) int ret = 0; u8 buf[3] = {0xEB, 0xAA, 0x09}; if (fts_data->bus_type != BUS_TYPE_I2C) return; ret = fts_write(buf, 3); if (ret < 0) { FTS_ERROR("hid2std cmd write fail"); return; } msleep(10); msleep(20); buf[0] = buf[1] = buf[2] = 0; ret = fts_read(NULL, 0, buf, 3); if (ret < 0) { if (ret < 0) FTS_ERROR("hid2std cmd read fail"); } else if ((0xEB == buf[0]) && (0xAA == buf[1]) && (0x08 == buf[2])) { else if ((buf[0] == 0xEB) && (buf[1] == 0xAA) && (buf[2] == 0x08)) FTS_DEBUG("hidi2c change to stdi2c successful"); } else { else FTS_DEBUG("hidi2c change to stdi2c not support or fail"); } } Loading @@ -1347,7 +1354,6 @@ static int fts_get_chip_types( u8 id_h, u8 id_l, bool fw_valid) { int i = 0; struct ft_chip_t ctype[] = FTS_CHIP_TYPE_MAPPING; u32 ctype_entries = sizeof(ctype) / sizeof(struct ft_chip_t); if ((0x0 == id_h) || (0x0 == id_l)) { Loading Loading @@ -1423,9 +1429,10 @@ static int fts_get_ic_information(struct fts_ts_data *ts_data) int ret = 0; int cnt = 0; u8 chip_id[2] = { 0 }; u32 type = ts_data->pdata->type; ts_data->ic_info.is_incell = FTS_CHIP_IDC; ts_data->ic_info.hid_supported = FTS_HID_SUPPORTTED; ts_data->ic_info.is_incell = FTS_CHIP_IDC(type); ts_data->ic_info.hid_supported = FTS_HID_SUPPORTTED(type); do { ret = fts_read_reg(FTS_REG_CHIP_ID, &chip_id[0]); Loading Loading @@ -1893,8 +1900,10 @@ static int fts_input_init(struct fts_ts_data *ts_data) /* Init and register Input device */ input_dev->name = FTS_DRIVER_NAME; if (ts_data->bus_type == BUS_TYPE_I2C) input_dev->id.bustype = BUS_I2C; else input_dev->id.bustype = BUS_SPI; input_dev->dev.parent = ts_data->dev; input_set_drvdata(input_dev, ts_data); Loading Loading @@ -1943,8 +1952,8 @@ static int fts_report_buffer_init(struct fts_ts_data *ts_data) int point_num = 0; int events_num = 0; point_num = ts_data->pdata->max_touch_number; ts_data->pnt_buf_size = point_num * FTS_ONE_TCH_LEN + 3; point_num = FTS_MAX_POINTS_SUPPORT; ts_data->pnt_buf_size = FTS_TOUCH_DATA_LEN + FTS_GESTURE_DATA_LEN; ts_data->point_buf = (u8 *)kzalloc(ts_data->pnt_buf_size + 1, GFP_KERNEL); if (!ts_data->point_buf) { FTS_ERROR("failed to alloc memory for point buf"); Loading Loading @@ -2396,6 +2405,12 @@ static int fts_parse_dt(struct device *dev, struct fts_ts_platform_data *pdata) FTS_INFO("max touch number:%d, irq gpio:%d, reset gpio:%d", pdata->max_touch_number, pdata->irq_gpio, pdata->reset_gpio); ret = of_property_read_u32(np, "focaltech,ic-type", &temp_val); if (ret < 0) pdata->type = _FT3518; else pdata->type = temp_val; FTS_FUNC_EXIT(); return 0; } Loading Loading @@ -2561,9 +2576,8 @@ static int fts_ts_probe_delayed(struct fts_ts_data *fts_data) } #endif #if (!FTS_CHIP_IDC) if (!FTS_CHIP_IDC(fts_data->pdata->type)) fts_reset_proc(200); #endif ret = fts_get_ic_information(fts_data); if (ret) { Loading Loading @@ -2974,7 +2988,7 @@ static int fts_ts_check_default_tp(struct device_node *dt, const char *prop) return ret; } static int fts_ts_probe(struct i2c_client *client, const struct i2c_device_id *id) static int fts_ts_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret = 0; struct fts_ts_data *ts_data = NULL; Loading Loading @@ -3011,6 +3025,7 @@ static int fts_ts_probe(struct i2c_client *client, const struct i2c_device_id *i ts_data->dev = &client->dev; ts_data->log_level = 1; ts_data->fw_is_running = 0; ts_data->bus_type = BUS_TYPE_I2C; i2c_set_clientdata(client, ts_data); ret = fts_ts_probe_entry(ts_data); Loading @@ -3024,12 +3039,12 @@ static int fts_ts_probe(struct i2c_client *client, const struct i2c_device_id *i return 0; } static int fts_ts_remove(struct i2c_client *client) static int fts_ts_i2c_remove(struct i2c_client *client) { return fts_ts_remove_entry(i2c_get_clientdata(client)); } static const struct i2c_device_id fts_ts_id[] = { static const struct i2c_device_id fts_ts_i2c_id[] = { {FTS_DRIVER_NAME, 0}, {}, }; Loading @@ -3039,34 +3054,154 @@ static const struct of_device_id fts_dt_match[] = { }; MODULE_DEVICE_TABLE(of, fts_dt_match); static struct i2c_driver fts_ts_driver = { .probe = fts_ts_probe, .remove = fts_ts_remove, static struct i2c_driver fts_ts_i2c_driver = { .probe = fts_ts_i2c_probe, .remove = fts_ts_i2c_remove, .driver = { .name = FTS_DRIVER_NAME, .owner = THIS_MODULE, .of_match_table = of_match_ptr(fts_dt_match), }, .id_table = fts_ts_id, .id_table = fts_ts_i2c_id, }; static int __init fts_ts_init(void) static int __init fts_ts_i2c_init(void) { int ret = 0; FTS_FUNC_ENTER(); ret = i2c_add_driver(&fts_ts_driver); if ( ret != 0 ) { ret = i2c_add_driver(&fts_ts_i2c_driver); if (ret != 0) FTS_ERROR("Focaltech touch screen driver init failed!"); FTS_FUNC_EXIT(); return ret; } static void __exit fts_ts_i2c_exit(void) { i2c_del_driver(&fts_ts_i2c_driver); } static int fts_ts_spi_probe(struct spi_device *spi) { int ret = 0; struct fts_ts_data *ts_data = NULL; struct device_node *dp = spi->dev.of_node; FTS_INFO("Touch Screen(SPI BUS) driver prboe..."); ret = fts_ts_check_dt(dp); if (ret == -EPROBE_DEFER) return ret; if (ret) { if (!fts_ts_check_default_tp(dp, "qcom,spi-touch-active")) ret = -EPROBE_DEFER; else ret = -ENODEV; return ret; } spi->mode = SPI_MODE_0; spi->bits_per_word = 8; ret = spi_setup(spi); if (ret) { FTS_ERROR("spi setup fail"); return ret; } /* malloc memory for global struct variable */ ts_data = kzalloc(sizeof(*ts_data), GFP_KERNEL); if (!ts_data) { FTS_ERROR("allocate memory for fts_data fail"); return -ENOMEM; } fts_data = ts_data; ts_data->spi = spi; ts_data->dev = &spi->dev; ts_data->log_level = 1; ts_data->bus_type = BUS_TYPE_SPI_V2; spi_set_drvdata(spi, ts_data); ret = fts_ts_probe_entry(ts_data); if (ret) { FTS_ERROR("Touch Screen(SPI BUS) driver probe fail"); kfree_safe(ts_data); return ret; } FTS_INFO("Touch Screen(SPI BUS) driver prboe successfully"); return 0; } static int fts_ts_spi_remove(struct spi_device *spi) { return fts_ts_remove_entry(spi_get_drvdata(spi)); } static const struct spi_device_id fts_ts_spi_id[] = { {FTS_DRIVER_NAME, 0}, {}, }; static struct spi_driver fts_ts_spi_driver = { .probe = fts_ts_spi_probe, .remove = fts_ts_spi_remove, .driver = { .name = FTS_DRIVER_NAME, .owner = THIS_MODULE, #if defined(CONFIG_PM) && FTS_PATCH_COMERR_PM .pm = &fts_dev_pm_ops, #endif .of_match_table = of_match_ptr(fts_dt_match), }, .id_table = fts_ts_spi_id, }; static int __init fts_ts_spi_init(void) { int ret = 0; FTS_FUNC_ENTER(); ret = spi_register_driver(&fts_ts_spi_driver); if (ret != 0) FTS_ERROR("Focaltech touch screen driver init failed!"); FTS_FUNC_EXIT(); return ret; } static void __exit fts_ts_spi_exit(void) { spi_unregister_driver(&fts_ts_spi_driver); } static int __init fts_ts_init(void) { int ret = 0; ret = fts_ts_i2c_init(); if (ret) FTS_ERROR("Focaltech I2C driver init failed!"); ret = fts_ts_spi_init(); if (ret) FTS_ERROR("Focaltech SPI driver init failed!"); return ret; } static void __exit fts_ts_exit(void) { i2c_del_driver(&fts_ts_driver); fts_ts_i2c_exit(); fts_ts_spi_exit(); } #ifdef CONFIG_ARCH_QTI_VM module_init(fts_ts_init); #else Loading drivers/input/touchscreen/focaltech_touch/focaltech_core.h +28 −1 Original line number Diff line number Diff line Loading @@ -103,6 +103,16 @@ #define FTX_MAX_COMMMAND_LENGTH 16 /***************************************************************************** * Alternative mode (When something goes wrong, the modules may be able to solve the problem.) *****************************************************************************/ /* * For commnication error in PM(deep sleep) state */ #define FTS_PATCH_COMERR_PM 0 #define FTS_TIMEOUT_COMERR_PM 700 /***************************************************************************** * Private enumerations, structures and unions using typedef *****************************************************************************/ Loading @@ -114,6 +124,7 @@ struct ftxxxx_proc { }; struct fts_ts_platform_data { u32 type; u32 irq_gpio; u32 irq_gpio_flags; u32 reset_gpio; Loading Loading @@ -237,6 +248,10 @@ struct fts_ts_data { int log_level; int fw_is_running; /* confirm fw is running when using spi:default 0 */ int dummy_byte; #if defined(CONFIG_PM) && FTS_PATCH_COMERR_PM struct completion pm_completion; bool pm_suspend; #endif bool suspended; bool fw_loading; bool irq_disabled; Loading @@ -250,6 +265,7 @@ struct fts_ts_data { struct ts_event *events; u8 *bus_tx_buf; u8 *bus_rx_buf; int bus_type; u8 *point_buf; int pnt_buf_size; int touchs; Loading Loading @@ -286,6 +302,13 @@ struct fts_ts_data { #endif }; enum _FTS_BUS_TYPE { BUS_TYPE_NONE, BUS_TYPE_I2C, BUS_TYPE_SPI, BUS_TYPE_SPI_V2, }; /***************************************************************************** * Global variable or extern global variabls/functions *****************************************************************************/ Loading Loading @@ -327,6 +350,11 @@ int fts_esdcheck_suspend(void); int fts_esdcheck_resume(void); #endif /* Production test */ #if FTS_TEST_EN int fts_test_init(struct fts_ts_data *ts_data); int fts_test_exit(struct fts_ts_data *ts_data); #endif /* Point Report Check*/ #if FTS_POINT_REPORT_CHECK_EN Loading @@ -338,7 +366,6 @@ void fts_prc_queue_work(struct fts_ts_data *ts_data); /* 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 */ Loading Loading
drivers/input/touchscreen/focaltech_touch/Kconfig +0 −1 Original line number Diff line number Diff line Loading @@ -20,4 +20,3 @@ config FTS_TRUSTED_TOUCH Say Y here to enable Focaltech Trusted Touch. If unsure, say N. #endif
drivers/input/touchscreen/focaltech_touch/focaltech_common.h +5 −6 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ /***************************************************************************** * Macro definitions using #define *****************************************************************************/ #define FTS_DRIVER_VERSION "Focaltech V3.1 20190807" #define FTS_DRIVER_VERSION "Focaltech V3.2 20200422" #define BYTE_OFF_0(x) (u8)((x) & 0xFF) #define BYTE_OFF_8(x) (u8)(((x) >> 8) & 0xFF) Loading @@ -49,12 +49,10 @@ #define FLAG_HID_BIT 10 #define FLAG_IDC_BIT 11 #define IC_SERIALS (FTS_CHIP_TYPE & FLAGBITS(0, FLAG_ICSERIALS_LEN-1)) #define IC_SERIALS(type) ((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 {{0x81, 0x54, 0x52, 0x54, 0x52, 0x00, 0x00, 0x54, 0x5C}} #define FTS_CHIP_IDC(type) (((type) & FLAGBIT(FLAG_IDC_BIT)) == FLAGBIT(FLAG_IDC_BIT)) #define FTS_HID_SUPPORTTED(type) (((type) & FLAGBIT(FLAG_HID_BIT)) == FLAGBIT(FLAG_HID_BIT)) #define FILE_NAME_LENGTH 128 #define ENABLE 1 Loading @@ -67,6 +65,7 @@ #define FTS_CMD_READ_ID 0x90 #define FTS_CMD_READ_ID_LEN 4 #define FTS_CMD_READ_ID_LEN_INCELL 1 #define FTS_CMD_READ_FW_CONF 0xA8 /*register address*/ #define FTS_REG_INT_CNT 0x8F #define FTS_REG_FLOW_WORK_CNT 0x91 Loading
drivers/input/touchscreen/focaltech_touch/focaltech_config.h +42 −7 Original line number Diff line number Diff line Loading @@ -55,6 +55,9 @@ #define _FT8656 0x86560818 #define _FT8006S_AA 0x86320819 #define _FT7250 0x7250081A #define _FT7120 0x7120081B #define _FT8720 0x8720081C #define _FT8016 0x8016081D #define _FT5416 0x54160402 Loading @@ -77,6 +80,7 @@ #define _FT3327 0x33270402 #define _FT3427 0x34270402 #define _FT7311 0x73110402 #define _FT5526_V00 0x5526C402 #define _FT5626 0x56260401 #define _FT5726 0x57260401 Loading @@ -93,6 +97,7 @@ #define _FT6336G 0x6336A003 #define _FT6336U 0x6336D003 #define _FT6436U 0x6436D003 #define _FT6436T 0x6436E003 #define _FT3267 0x32670004 #define _FT3367 0x33670004 Loading @@ -100,10 +105,21 @@ #define _FT3327DQQ_XXX 0x3327D482 #define _FT5446DQS_XXX 0x5446D482 #define _FT3427_003 0x3427D482 #define _FT3427G_003 0x3427A482 #define _FT5446_003 0x5446D482 #define _FT5446_Q03 0x5446C482 #define _FT5446_P03 0x5446A481 #define _FT5426_003 0x5426D482 #define _FT5526_003 0x5526D482 #define _FT3518 0x35180481 #define _FT3518U 0x3518D481 #define _FT3558 0x35580481 #define _FT3528 0x35280481 #define _FT5536 0x55360481 #define _FT5536L 0x5536E481 #define _FT3418 0x34180481 #define _FT5446U 0x5446D083 #define _FT5456U 0x5456D083 Loading @@ -115,6 +131,7 @@ #define _FT7302 0x73020084 #define _FT7202 0x72020084 #define _FT3308 0x33080084 #define _FT6446 0x64460084 #define _FT6346U 0x6346D085 #define _FT6346G 0x6346A085 Loading @@ -122,13 +139,26 @@ #define _FT3068 0x30680085 #define _FT3168 0x31680085 #define _FT3268 0x32680085 /*************************************************/ /* * choose your ic chip type of focaltech */ #define FTS_CHIP_TYPE _FT3518 #define _FT6146 0x61460085 #define _FT5726_003 0x5726D486 #define _FT5726_V03 0x5726C486 #define _FT3618 0x36180487 #define _FT5646 0x56460487 #define _FT3A58 0x3A580487 #define _FT3B58 0x3B580487 #define _FT3D58 0x3D580487 #define _FT5936 0x59360487 #define _FT5A36 0x5A360487 #define _FT5B36 0x5B360487 #define _FT5D36 0x5D360487 #define _FT5946 0x59460487 #define _FT5A46 0x5A460487 #define _FT5B46 0x5B460487 #define _FT5D46 0x5D460487 #define _FT3658U 0x3658D488 /******************* Enables *********************/ /*********** 1 to enable, 0 to disable ***********/ Loading Loading @@ -163,6 +193,11 @@ */ #define FTS_ESDCHECK_EN 0 /* * Production test enable * 1: enable, 0:disable(default) */ #define FTS_TEST_EN 0 /* * Pinctrl enable Loading
drivers/input/touchscreen/focaltech_touch/focaltech_core.c +166 −31 Original line number Diff line number Diff line Loading @@ -90,6 +90,11 @@ struct fts_ts_data *fts_data; static struct drm_panel *active_panel; #endif static struct ft_chip_t ctype[] = { {0x88, 0x56, 0x52, 0x00, 0x00, 0x00, 0x00, 0x56, 0xB2}, {0x81, 0x54, 0x52, 0x54, 0x52, 0x00, 0x00, 0x54, 0x5C}, }; /***************************************************************************** * Static function prototypes *****************************************************************************/ Loading Loading @@ -1323,22 +1328,24 @@ void fts_hid2std(void) int ret = 0; u8 buf[3] = {0xEB, 0xAA, 0x09}; if (fts_data->bus_type != BUS_TYPE_I2C) return; ret = fts_write(buf, 3); if (ret < 0) { FTS_ERROR("hid2std cmd write fail"); return; } msleep(10); msleep(20); buf[0] = buf[1] = buf[2] = 0; ret = fts_read(NULL, 0, buf, 3); if (ret < 0) { if (ret < 0) FTS_ERROR("hid2std cmd read fail"); } else if ((0xEB == buf[0]) && (0xAA == buf[1]) && (0x08 == buf[2])) { else if ((buf[0] == 0xEB) && (buf[1] == 0xAA) && (buf[2] == 0x08)) FTS_DEBUG("hidi2c change to stdi2c successful"); } else { else FTS_DEBUG("hidi2c change to stdi2c not support or fail"); } } Loading @@ -1347,7 +1354,6 @@ static int fts_get_chip_types( u8 id_h, u8 id_l, bool fw_valid) { int i = 0; struct ft_chip_t ctype[] = FTS_CHIP_TYPE_MAPPING; u32 ctype_entries = sizeof(ctype) / sizeof(struct ft_chip_t); if ((0x0 == id_h) || (0x0 == id_l)) { Loading Loading @@ -1423,9 +1429,10 @@ static int fts_get_ic_information(struct fts_ts_data *ts_data) int ret = 0; int cnt = 0; u8 chip_id[2] = { 0 }; u32 type = ts_data->pdata->type; ts_data->ic_info.is_incell = FTS_CHIP_IDC; ts_data->ic_info.hid_supported = FTS_HID_SUPPORTTED; ts_data->ic_info.is_incell = FTS_CHIP_IDC(type); ts_data->ic_info.hid_supported = FTS_HID_SUPPORTTED(type); do { ret = fts_read_reg(FTS_REG_CHIP_ID, &chip_id[0]); Loading Loading @@ -1893,8 +1900,10 @@ static int fts_input_init(struct fts_ts_data *ts_data) /* Init and register Input device */ input_dev->name = FTS_DRIVER_NAME; if (ts_data->bus_type == BUS_TYPE_I2C) input_dev->id.bustype = BUS_I2C; else input_dev->id.bustype = BUS_SPI; input_dev->dev.parent = ts_data->dev; input_set_drvdata(input_dev, ts_data); Loading Loading @@ -1943,8 +1952,8 @@ static int fts_report_buffer_init(struct fts_ts_data *ts_data) int point_num = 0; int events_num = 0; point_num = ts_data->pdata->max_touch_number; ts_data->pnt_buf_size = point_num * FTS_ONE_TCH_LEN + 3; point_num = FTS_MAX_POINTS_SUPPORT; ts_data->pnt_buf_size = FTS_TOUCH_DATA_LEN + FTS_GESTURE_DATA_LEN; ts_data->point_buf = (u8 *)kzalloc(ts_data->pnt_buf_size + 1, GFP_KERNEL); if (!ts_data->point_buf) { FTS_ERROR("failed to alloc memory for point buf"); Loading Loading @@ -2396,6 +2405,12 @@ static int fts_parse_dt(struct device *dev, struct fts_ts_platform_data *pdata) FTS_INFO("max touch number:%d, irq gpio:%d, reset gpio:%d", pdata->max_touch_number, pdata->irq_gpio, pdata->reset_gpio); ret = of_property_read_u32(np, "focaltech,ic-type", &temp_val); if (ret < 0) pdata->type = _FT3518; else pdata->type = temp_val; FTS_FUNC_EXIT(); return 0; } Loading Loading @@ -2561,9 +2576,8 @@ static int fts_ts_probe_delayed(struct fts_ts_data *fts_data) } #endif #if (!FTS_CHIP_IDC) if (!FTS_CHIP_IDC(fts_data->pdata->type)) fts_reset_proc(200); #endif ret = fts_get_ic_information(fts_data); if (ret) { Loading Loading @@ -2974,7 +2988,7 @@ static int fts_ts_check_default_tp(struct device_node *dt, const char *prop) return ret; } static int fts_ts_probe(struct i2c_client *client, const struct i2c_device_id *id) static int fts_ts_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret = 0; struct fts_ts_data *ts_data = NULL; Loading Loading @@ -3011,6 +3025,7 @@ static int fts_ts_probe(struct i2c_client *client, const struct i2c_device_id *i ts_data->dev = &client->dev; ts_data->log_level = 1; ts_data->fw_is_running = 0; ts_data->bus_type = BUS_TYPE_I2C; i2c_set_clientdata(client, ts_data); ret = fts_ts_probe_entry(ts_data); Loading @@ -3024,12 +3039,12 @@ static int fts_ts_probe(struct i2c_client *client, const struct i2c_device_id *i return 0; } static int fts_ts_remove(struct i2c_client *client) static int fts_ts_i2c_remove(struct i2c_client *client) { return fts_ts_remove_entry(i2c_get_clientdata(client)); } static const struct i2c_device_id fts_ts_id[] = { static const struct i2c_device_id fts_ts_i2c_id[] = { {FTS_DRIVER_NAME, 0}, {}, }; Loading @@ -3039,34 +3054,154 @@ static const struct of_device_id fts_dt_match[] = { }; MODULE_DEVICE_TABLE(of, fts_dt_match); static struct i2c_driver fts_ts_driver = { .probe = fts_ts_probe, .remove = fts_ts_remove, static struct i2c_driver fts_ts_i2c_driver = { .probe = fts_ts_i2c_probe, .remove = fts_ts_i2c_remove, .driver = { .name = FTS_DRIVER_NAME, .owner = THIS_MODULE, .of_match_table = of_match_ptr(fts_dt_match), }, .id_table = fts_ts_id, .id_table = fts_ts_i2c_id, }; static int __init fts_ts_init(void) static int __init fts_ts_i2c_init(void) { int ret = 0; FTS_FUNC_ENTER(); ret = i2c_add_driver(&fts_ts_driver); if ( ret != 0 ) { ret = i2c_add_driver(&fts_ts_i2c_driver); if (ret != 0) FTS_ERROR("Focaltech touch screen driver init failed!"); FTS_FUNC_EXIT(); return ret; } static void __exit fts_ts_i2c_exit(void) { i2c_del_driver(&fts_ts_i2c_driver); } static int fts_ts_spi_probe(struct spi_device *spi) { int ret = 0; struct fts_ts_data *ts_data = NULL; struct device_node *dp = spi->dev.of_node; FTS_INFO("Touch Screen(SPI BUS) driver prboe..."); ret = fts_ts_check_dt(dp); if (ret == -EPROBE_DEFER) return ret; if (ret) { if (!fts_ts_check_default_tp(dp, "qcom,spi-touch-active")) ret = -EPROBE_DEFER; else ret = -ENODEV; return ret; } spi->mode = SPI_MODE_0; spi->bits_per_word = 8; ret = spi_setup(spi); if (ret) { FTS_ERROR("spi setup fail"); return ret; } /* malloc memory for global struct variable */ ts_data = kzalloc(sizeof(*ts_data), GFP_KERNEL); if (!ts_data) { FTS_ERROR("allocate memory for fts_data fail"); return -ENOMEM; } fts_data = ts_data; ts_data->spi = spi; ts_data->dev = &spi->dev; ts_data->log_level = 1; ts_data->bus_type = BUS_TYPE_SPI_V2; spi_set_drvdata(spi, ts_data); ret = fts_ts_probe_entry(ts_data); if (ret) { FTS_ERROR("Touch Screen(SPI BUS) driver probe fail"); kfree_safe(ts_data); return ret; } FTS_INFO("Touch Screen(SPI BUS) driver prboe successfully"); return 0; } static int fts_ts_spi_remove(struct spi_device *spi) { return fts_ts_remove_entry(spi_get_drvdata(spi)); } static const struct spi_device_id fts_ts_spi_id[] = { {FTS_DRIVER_NAME, 0}, {}, }; static struct spi_driver fts_ts_spi_driver = { .probe = fts_ts_spi_probe, .remove = fts_ts_spi_remove, .driver = { .name = FTS_DRIVER_NAME, .owner = THIS_MODULE, #if defined(CONFIG_PM) && FTS_PATCH_COMERR_PM .pm = &fts_dev_pm_ops, #endif .of_match_table = of_match_ptr(fts_dt_match), }, .id_table = fts_ts_spi_id, }; static int __init fts_ts_spi_init(void) { int ret = 0; FTS_FUNC_ENTER(); ret = spi_register_driver(&fts_ts_spi_driver); if (ret != 0) FTS_ERROR("Focaltech touch screen driver init failed!"); FTS_FUNC_EXIT(); return ret; } static void __exit fts_ts_spi_exit(void) { spi_unregister_driver(&fts_ts_spi_driver); } static int __init fts_ts_init(void) { int ret = 0; ret = fts_ts_i2c_init(); if (ret) FTS_ERROR("Focaltech I2C driver init failed!"); ret = fts_ts_spi_init(); if (ret) FTS_ERROR("Focaltech SPI driver init failed!"); return ret; } static void __exit fts_ts_exit(void) { i2c_del_driver(&fts_ts_driver); fts_ts_i2c_exit(); fts_ts_spi_exit(); } #ifdef CONFIG_ARCH_QTI_VM module_init(fts_ts_init); #else Loading
drivers/input/touchscreen/focaltech_touch/focaltech_core.h +28 −1 Original line number Diff line number Diff line Loading @@ -103,6 +103,16 @@ #define FTX_MAX_COMMMAND_LENGTH 16 /***************************************************************************** * Alternative mode (When something goes wrong, the modules may be able to solve the problem.) *****************************************************************************/ /* * For commnication error in PM(deep sleep) state */ #define FTS_PATCH_COMERR_PM 0 #define FTS_TIMEOUT_COMERR_PM 700 /***************************************************************************** * Private enumerations, structures and unions using typedef *****************************************************************************/ Loading @@ -114,6 +124,7 @@ struct ftxxxx_proc { }; struct fts_ts_platform_data { u32 type; u32 irq_gpio; u32 irq_gpio_flags; u32 reset_gpio; Loading Loading @@ -237,6 +248,10 @@ struct fts_ts_data { int log_level; int fw_is_running; /* confirm fw is running when using spi:default 0 */ int dummy_byte; #if defined(CONFIG_PM) && FTS_PATCH_COMERR_PM struct completion pm_completion; bool pm_suspend; #endif bool suspended; bool fw_loading; bool irq_disabled; Loading @@ -250,6 +265,7 @@ struct fts_ts_data { struct ts_event *events; u8 *bus_tx_buf; u8 *bus_rx_buf; int bus_type; u8 *point_buf; int pnt_buf_size; int touchs; Loading Loading @@ -286,6 +302,13 @@ struct fts_ts_data { #endif }; enum _FTS_BUS_TYPE { BUS_TYPE_NONE, BUS_TYPE_I2C, BUS_TYPE_SPI, BUS_TYPE_SPI_V2, }; /***************************************************************************** * Global variable or extern global variabls/functions *****************************************************************************/ Loading Loading @@ -327,6 +350,11 @@ int fts_esdcheck_suspend(void); int fts_esdcheck_resume(void); #endif /* Production test */ #if FTS_TEST_EN int fts_test_init(struct fts_ts_data *ts_data); int fts_test_exit(struct fts_ts_data *ts_data); #endif /* Point Report Check*/ #if FTS_POINT_REPORT_CHECK_EN Loading @@ -338,7 +366,6 @@ void fts_prc_queue_work(struct fts_ts_data *ts_data); /* 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 */ Loading