From fd3d2b00a6faca079d565c13e09548661022af3b Mon Sep 17 00:00:00 2001 From: haojl2 Date: Wed, 12 Jun 2019 15:52:56 +0800 Subject: [PATCH] defender: TP: Update driver version to V3.1 TP: Update driver version to support 8756. Change-Id: I8dbcae57f1d0b95f7db9cb512d78cd04309182e9 Signed-off-by: haojl2 Reviewed-on: https://gerrit.mot.com/1369383 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Guobin Zhang Submit-Approved: Jira Key Reviewed-on: https://gerrit.mot.com/1371167 Reviewed-by: Jianqi Yang Reviewed-on: https://gerrit.mot.com/1371911 --- .../focaltech_0flash_mmi/focaltech_common.h | 8 +- .../focaltech_0flash_mmi/focaltech_config.h | 16 +- .../focaltech_0flash_mmi/focaltech_core.c | 37 +- .../focaltech_0flash_mmi/focaltech_core.h | 4 +- .../focaltech_0flash_mmi/focaltech_ex_fun.c | 29 +- .../focaltech_0flash_mmi/focaltech_flash.c | 2 +- .../focaltech_0flash_mmi/focaltech_flash.h | 5 + .../focaltech_0flash_mmi/focaltech_spi.c | 400 +++++++----------- .../focaltech_test/focaltech_test.c | 4 +- .../focaltech_test/focaltech_test_ini.c | 18 +- .../focaltech_test/focaltech_test_ini.h | 4 +- 11 files changed, 262 insertions(+), 265 deletions(-) diff --git a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_common.h b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_common.h index 043ec26daa6d..14a98f707f9c 100755 --- a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_common.h +++ b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_common.h @@ -36,7 +36,7 @@ /***************************************************************************** * Macro definitions using #define *****************************************************************************/ -#define FTS_DRIVER_VERSION "Focaltech V3.0 20190102" +#define FTS_DRIVER_VERSION "Focaltech V3.1 20190420" #define BYTE_OFF_0(x) (u8)((x) & 0xFF) #define BYTE_OFF_8(x) (u8)((x >> 8) & 0xFF) @@ -54,7 +54,13 @@ #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)) +#if defined(CONFIG_INPUT_FOCALTECH_0FLASH_MMI_IC_NAME_FT8756) +#define FTS_CHIP_TYPE_MAPPING {{0x15, 0x87, 0x56, 0x87, 0x56, 0xF7, 0xA6, 0x00, 0x00}} +#elif defined(CONFIG_INPUT_FOCALTECH_0FLASH_MMI_IC_NAME_FT8719) #define FTS_CHIP_TYPE_MAPPING {{0x0D,0x87, 0x19, 0x87, 0x19, 0x87, 0xA9, 0x87, 0xB9}} +#else +#define FTS_CHIP_TYPE_MAPPING {{0x0D,0x87, 0x19, 0x87, 0x19, 0x87, 0xA9, 0x87, 0xB9}} +#endif #define FILE_NAME_LENGTH 128 #define ENABLE 1 diff --git a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_config.h b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_config.h index 95d1656a9a1e..d1d2356bb40e 100755 --- a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_config.h +++ b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_config.h @@ -49,6 +49,10 @@ #define _FT7251 0x72510812 #define _FT7252 0x72520813 #define _FT8613S 0x8613C814 +#define _FT8756 0x87560815 +#define _FT8302 0x83020816 +#define _FT8009 0x80090817 +#define _FT8656 0x86560818 #define _FT5416 0x54160402 #define _FT5426 0x54260402 @@ -109,12 +113,22 @@ #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 */ -#ifdef CONFIG_INPUT_FOCALTECH_0FLASH_MMI_IC_NAME_FT8719 +#if defined(CONFIG_INPUT_FOCALTECH_0FLASH_MMI_IC_NAME_FT8756) +#define FTS_CHIP_TYPE _FT8756 +#define FTS_CHIP_NAME "ft8756" +#elif defined(CONFIG_INPUT_FOCALTECH_0FLASH_MMI_IC_NAME_FT8719) #define FTS_CHIP_TYPE _FT8719 #define FTS_CHIP_NAME "ft8719" #else diff --git a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_core.c b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_core.c index a3bdae68d2ba..30aa7cafa2a7 100755 --- a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_core.c +++ b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_core.c @@ -56,7 +56,7 @@ #define INTERVAL_READ_REG 200 /* unit:ms */ #define TIMEOUT_READ_REG 1000 /* unit:ms */ #if FTS_POWER_SOURCE_CUST_EN -#define FTS_VTG_MIN_UV 2600000 +#define FTS_VTG_MIN_UV 2800000 #define FTS_VTG_MAX_UV 3300000 #define FTS_I2C_VTG_MIN_UV 1800000 #define FTS_I2C_VTG_MAX_UV 1800000 @@ -564,13 +564,16 @@ static int fts_read_touchdata(struct fts_ts_data *data) memset(buf, 0xFF, data->pnt_buf_size); - ret = fts_read(NULL, 0, buf + 1, data->pnt_buf_size - 1); - if ((0xEF == buf[2]) && (0xEF == buf[3]) && (0xEF == buf[4])) { + buf[0] = 0x01; + ret = fts_read(buf, 1, buf + 1, data->pnt_buf_size - 1); + if ((0xEF == buf[1]) && (0xEF == buf[2]) && (0xEF == buf[3])) { /* check if need recovery fw */ fts_fw_recovery(); return 1; - } else if ((ret < 0) || ((buf[1] & 0xF0) != 0x90)) { - FTS_ERROR("touch data(%x) fail,ret:%d", buf[1], ret); + } + + if ((ret < 0) || ((buf[1] & 0xF0) != 0x90)) { + FTS_ERROR("touch data(%x) abnormal,ret:%d", buf[1], ret); return -EIO; } @@ -609,9 +612,10 @@ static int fts_read_parse_touchdata(struct fts_ts_data *data) data->touch_point = 0; if (data->ic_info.is_incell) { - if ((data->point_num == 0x0F) && (buf[1] == 0xFF) && (buf[2] == 0xFF) - && (buf[3] == 0xFF) && (buf[4] == 0xFF) && (buf[5] == 0xFF) && (buf[6] == 0xFF)) { + if ((data->point_num == 0x0F) && (buf[2] == 0xFF) && (buf[3] == 0xFF) + && (buf[4] == 0xFF) && (buf[5] == 0xFF) && (buf[6] == 0xFF)) { FTS_DEBUG("touch buff is 0xff, need recovery state"); + fts_release_all_finger(); fts_tp_state_recovery(data); return -EIO; } @@ -1338,6 +1342,7 @@ static int fts_ts_probe_entry(struct fts_ts_data *ts_data) int pdata_size = sizeof(struct fts_ts_platform_data); FTS_FUNC_ENTER(); + FTS_INFO("%s", FTS_DRIVER_VERSION); ts_data->pdata = kzalloc(pdata_size, GFP_KERNEL); if (!ts_data->pdata) { FTS_ERROR("allocate memory for platform_data fail"); @@ -1367,7 +1372,11 @@ static int fts_ts_probe_entry(struct fts_ts_data *ts_data) mutex_init(&ts_data->bus_lock); /* Init communication interface */ - fts_bus_init(ts_data); + ret = fts_bus_init(ts_data); + if (ret) { + FTS_ERROR("bus initialize fail"); + goto err_bus_init; + } ret = fts_input_init(ts_data); if (ret) { @@ -1508,8 +1517,9 @@ err_report_buffer: err_input_init: if (ts_data->ts_workqueue) destroy_workqueue(ts_data->ts_workqueue); - - kfree_safe(ts_data->bus_buf); +err_bus_init: + kfree_safe(ts_data->bus_tx_buf); + kfree_safe(ts_data->bus_rx_buf); kfree_safe(ts_data->pdata); FTS_FUNC_EXIT(); @@ -1685,7 +1695,14 @@ static int fts_ts_probe(struct spi_device *spi) struct fts_ts_data *ts_data = NULL; FTS_INFO("Touch Screen(SPI BUS) driver prboe..."); +#if defined(CONFIG_INPUT_FOCALTECH_0FLASH_MMI_IC_NAME_FT8756) + spi->mode = SPI_MODE_0; +#elif defined(CONFIG_INPUT_FOCALTECH_0FLASH_MMI_IC_NAME_FT8719) spi->mode = SPI_MODE_1; +#else + spi->mode = SPI_MODE_1; +#endif + spi->bits_per_word = 8; if (spi->max_speed_hz > FTS_SPI_CLK_MAX) spi->max_speed_hz = FTS_SPI_CLK_MAX; diff --git a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_core.h b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_core.h index 7ffb9b223ff3..b6d3b6f34061 100755 --- a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_core.h +++ b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_core.h @@ -168,7 +168,8 @@ struct fts_ts_data { bool charger_mode; /* multi-touch */ struct ts_event *events; - u8 *bus_buf; + u8 *bus_tx_buf; + u8 *bus_rx_buf; u8 *point_buf; int pnt_buf_size; int touchs; @@ -253,7 +254,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_fw_resume(void); int fts_fw_recovery(void); int fts_upgrade_bin(char *fw_name, bool force); int fts_enter_test_environment(bool test_state); diff --git a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_ex_fun.c b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_ex_fun.c index 878be0e2036b..9a2e96ed0e05 100755 --- a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_ex_fun.c +++ b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_ex_fun.c @@ -89,7 +89,7 @@ static ssize_t fts_debug_write( int buflen = count; int writelen = 0; int ret = 0; - char tmp[25]; + char tmp[PROC_BUF_SIZE]; struct fts_ts_data *ts_data = fts_data; struct ftxxxx_proc *proc = &ts_data->proc; @@ -160,7 +160,7 @@ static ssize_t fts_debug_write( break; case PROC_HW_RESET: - snprintf(tmp, PAGE_SIZE, "%s", writebuf + 1); + snprintf(tmp, PROC_BUF_SIZE, "%s", writebuf + 1); tmp[buflen - 1] = '\0'; if (strncmp(tmp, "focal_driver", 12) == 0) { FTS_INFO("APK execute HW Reset"); @@ -289,7 +289,7 @@ static int fts_debug_write( int buflen = count; int writelen = 0; int ret = 0; - char tmp[25]; + char tmp[PROC_BUF_SIZE]; struct fts_ts_data *ts_data = fts_data; struct ftxxxx_proc *proc = &ts_data->proc; @@ -360,7 +360,7 @@ static int fts_debug_write( break; case PROC_HW_RESET: - snprintf(tmp, PAGE_SIZE, "%s", writebuf + 1); + snprintf(tmp, PROC_BUF_SIZE, "%s", writebuf + 1); tmp[buflen - 1] = '\0'; if (strncmp(tmp, "focal_driver", 12) == 0) { FTS_INFO("APK execute HW Reset"); @@ -368,6 +368,23 @@ static int fts_debug_write( } break; + case PROC_SET_BOOT_MODE: + FTS_DEBUG("[APK]: PROC_SET_BOOT_MODE = %x", writebuf[1]); + if (0 == writebuf[1]) { + ts_data->fw_is_running = true; + } else { + ts_data->fw_is_running = false; + } + break; + case PROC_ENTER_TEST_ENVIRONMENT: + FTS_DEBUG("[APK]: PROC_ENTER_TEST_ENVIRONMENT = %x", writebuf[1]); + if (0 == writebuf[1]) { + fts_enter_test_environment(0); + } else { + fts_enter_test_environment(1); + } + break; + default: break; } @@ -971,7 +988,7 @@ static ssize_t fts_fwupgradebin_store( return -EINVAL; } memset(fwname, 0, sizeof(fwname)); - snprintf(fwname, PAGE_SIZE, "%s", buf); + snprintf(fwname, FILE_NAME_LENGTH, "%s", buf); fwname[count - 1] = '\0'; FTS_INFO("upgrade with bin file through sysfs node"); @@ -1001,7 +1018,7 @@ static ssize_t fts_fwforceupg_store( return -EINVAL; } memset(fwname, 0, sizeof(fwname)); - snprintf(fwname, PAGE_SIZE, "%s", buf); + snprintf(fwname, FILE_NAME_LENGTH, "%s", buf); fwname[count - 1] = '\0'; FTS_INFO("force upgrade through sysfs node"); diff --git a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_flash.c b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_flash.c index 83f8a0c9e332..fdbc04d1d2db 100755 --- a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_flash.c +++ b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_flash.c @@ -574,7 +574,7 @@ int fts_enter_test_environment(bool test_state) return 0; } -int fts_fw_resume(void) +static int fts_fw_resume(void) { int ret = 0; struct fts_upgrade *upg = fwupgrade; diff --git a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_flash.h b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_flash.h index 4e823ff5919d..bc5bc9c4a5d3 100755 --- a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_flash.h +++ b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_flash.h @@ -22,10 +22,14 @@ * 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 @@ -69,6 +73,7 @@ #define FTS_MIN_LEN 0x120 #define FTS_MAX_LEN_FILE (128 * 1024) #define FTS_MAX_LEN_APP (64 * 1024) +#define FTS_MAX_LEN_APP_PARAMS (32 * 1024) #define FTS_MAX_LEN_SECTOR (4 * 1024) #define FTS_CONIFG_VENDORID_OFF 0x04 #define FTS_CONIFG_MODULEID_OFF 0x1E diff --git a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_spi.c b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_spi.c index 4155f6e2ee93..6b2ac3500790 100755 --- a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_spi.c +++ b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_spi.c @@ -21,11 +21,11 @@ * * Author: FocalTech Driver Team * -* Created: 2018-11-17 +* Created: 2019-03-21 * -* Abstract: spi communication with TP +* Abstract: new spi protocol communication with TP * -* Version: v1.1 +* Version: v1.0 * * Revision History: * @@ -39,20 +39,16 @@ /***************************************************************************** * Private constant and macro definitions using #define *****************************************************************************/ -#define STATUS_PACKAGE 0x05 -#define COMMAND_PACKAGE 0xC0 -#define DATA_PACKAGE 0x3F -#define BUSY_QUERY_TIMEOUT 100 -#define BUSY_QUERY_DELAY 150 /* unit: us */ +#define SPI_RETRY_NUMBER 3 #define CS_HIGH_DELAY 150 /* unit: us */ -#define DELAY_AFTER_FIRST_BYTE 30 -#define SPI_HEADER_LENGTH 4 #define SPI_BUF_LENGTH 256 #define DATA_CRC_EN 0x20 #define WRITE_CMD 0x00 #define READ_CMD (0x80 | DATA_CRC_EN) +#define SPI_DUMMY_BYTE 3 +#define SPI_HEADER_LENGTH (SPI_DUMMY_BYTE + 6) /***************************************************************************** * Private enumerations, structures and unions using typedef *****************************************************************************/ @@ -78,25 +74,14 @@ static int fts_spi_transfer(u8 *tx_buf, u8 *rx_buf, u32 len) int ret = 0; struct spi_device *spi = fts_data->spi; struct spi_message msg; - struct spi_transfer xfer[2]; - - memset(&xfer[0], 0, sizeof(struct spi_transfer)); - memset(&xfer[1], 0, sizeof(struct spi_transfer)); + struct spi_transfer xfer = { + .tx_buf = tx_buf, + .rx_buf = rx_buf, + .len = len, + }; spi_message_init(&msg); - xfer[0].tx_buf = &tx_buf[0]; - if (rx_buf) - xfer[0].rx_buf = &rx_buf[0]; - xfer[0].len = 1; - xfer[0].delay_usecs = DELAY_AFTER_FIRST_BYTE; - spi_message_add_tail(&xfer[0], &msg); - if (len > 1) { - xfer[1].tx_buf = &tx_buf[1]; - if (rx_buf) - xfer[1].rx_buf = &rx_buf[1]; - xfer[1].len = len - 1; - spi_message_add_tail(&xfer[1], &msg); - } + spi_message_add_tail(&xfer, &msg); ret = spi_sync(spi, &msg); if (ret) { @@ -104,7 +89,6 @@ static int fts_spi_transfer(u8 *tx_buf, u8 *rx_buf, u32 len) return ret; } - udelay(CS_HIGH_DELAY); return ret; } @@ -141,245 +125,176 @@ static int rdata_check(u8 *rdata, u32 rlen) return 0; } -static int fts_wait_idle(void) -{ - int ret = 0; - int i = 0; - int status = 0xFF; - u8 cmd[2] = {STATUS_PACKAGE, 0xFF}; - u8 value[2] = { 0 }; - - for (i = 0; i < BUSY_QUERY_TIMEOUT; i++) { - udelay(BUSY_QUERY_DELAY); - ret = fts_spi_transfer(cmd, value, 2); - if (ret >= 0) { - status = (int)value[1]; - if ((fts_data->fw_is_running && (0x01 == (status & 0x81))) - || (!fts_data->fw_is_running && (0x00 == (status & 0x81)))) - { - break; - } - } - } - - if (i >= BUSY_QUERY_TIMEOUT) { - FTS_ERROR("spi is busy, status:0x%x", status); - return -EIO; - } - - return (int)status; -} - -static int fts_cmdpkg_wirte(u8 ctrl, u8 *cmd, u32 cmdlen) -{ - int i = 0; - int pos = 0; - u8 buf[FTX_MAX_COMMMAND_LENGTH] = { 0 }; - - if (!cmd || (cmdlen >= FTX_MAX_COMMMAND_LENGTH - SPI_HEADER_LENGTH)) { - FTS_ERROR("cmd/cmdlen fail"); - return -EINVAL; - } - - buf[pos++] = COMMAND_PACKAGE; - buf[pos++] = ctrl | (cmdlen & 0x0F); - for (i = 0; i < cmdlen; i++) { - buf[pos++] = cmd[i]; - } - - return fts_spi_transfer(buf, NULL, pos); -} - -static int fts_boot_write(u8 *cmd, u32 cmdlen, u8 *data, u32 datalen) -{ - int ret = 0; - u8 *txbuf = NULL; - u32 txlen = 0; - u8 tmpcmd[FTX_MAX_COMMMAND_LENGTH] = { 0 }; - - if ((!cmd) || (!cmdlen) - || (cmdlen > FTX_MAX_COMMMAND_LENGTH - SPI_HEADER_LENGTH)) { - FTS_ERROR("cmd/cmdlen is invalid"); - return -EINVAL; - } - - mutex_lock(&fts_data->bus_lock); - /* wait spi idle */ - ret = fts_wait_idle(); - if (ret < 0) { - FTS_ERROR("wait spi idle fail"); - goto err_boot_write; - } - - /* write cmd */ - memcpy(tmpcmd, cmd, cmdlen); - if (fts_data->fw_is_running && data && datalen) { - tmpcmd[cmdlen++] = (datalen >> 8) & 0xFF; - tmpcmd[cmdlen++] = datalen & 0xFF; - } - ret = fts_cmdpkg_wirte(WRITE_CMD, tmpcmd, cmdlen); - if (ret < 0) { - FTS_ERROR("command package wirte fail"); - goto err_boot_write; - } - - /* have data, transfer data */ - if (data && datalen) { - /* wait spi idle */ - ret = fts_wait_idle(); - if (ret < 0) { - FTS_ERROR("wait spi idle from cmd fail"); - goto err_boot_write; - } - - /* write data */ - if (datalen > SPI_BUF_LENGTH - SPI_HEADER_LENGTH) { - txbuf = kzalloc(datalen + SPI_HEADER_LENGTH, GFP_KERNEL); - if (NULL == txbuf) { - FTS_ERROR("txbuf malloc fail"); - ret = -ENOMEM; - goto err_boot_write; - } - } else { - txbuf = fts_data->bus_buf; - } - memset(txbuf, 0xFF, datalen + SPI_HEADER_LENGTH); - txbuf[0] = DATA_PACKAGE; - txlen = datalen + 1; - memcpy(txbuf + 1, data, datalen); - - ret = fts_spi_transfer(txbuf, NULL, txlen); - if (ret < 0) { - FTS_ERROR("data wirte fail"); - } - - if (txbuf && (datalen > SPI_BUF_LENGTH - SPI_HEADER_LENGTH)) { - kfree(txbuf); - txbuf = NULL; - } - } - -err_boot_write: - mutex_unlock(&fts_data->bus_lock); - return ret; -} - int fts_write(u8 *writebuf, u32 writelen) { - u8 *cmd = NULL; - u32 cmdlen = 0; - u8 *data = NULL; - u32 datalen = 0; + int ret = 0; + int i = 0; + struct fts_ts_data *ts_data = fts_data; + u8 *txbuf = NULL; + u8 *rxbuf = NULL; + u32 txlen = 0; + u32 txlen_need = writelen + SPI_HEADER_LENGTH; + u32 datalen = writelen - 1; if (!writebuf || !writelen) { FTS_ERROR("writebuf/len is invalid"); return -EINVAL; } - if (1 == writelen) { - cmd = writebuf; - cmdlen = 1; - data = NULL; - datalen = 0; - } else { - cmd = writebuf; - cmdlen = 1; - if (!fts_data->fw_is_running) { - if ((cmd[0] == 0xAE) || (cmd[0] == 0x85) || (cmd[0] == 0xF2)) { - cmdlen = 6; - } else if (cmd[0] == 0xCC) { - cmdlen = 7; - } + mutex_lock(&ts_data->bus_lock); + if (txlen_need > SPI_BUF_LENGTH) { + txbuf = kzalloc(txlen_need, GFP_KERNEL); + if (NULL == txbuf) { + FTS_ERROR("txbuf malloc fail"); + ret = -ENOMEM; + goto err_write; } - data = writebuf + cmdlen; - datalen = writelen - cmdlen; + + rxbuf = kzalloc(txlen_need, GFP_KERNEL); + if (NULL == rxbuf) { + FTS_ERROR("rxbuf malloc fail"); + ret = -ENOMEM; + goto err_write; + } + } else { + txbuf = ts_data->bus_tx_buf; + rxbuf = ts_data->bus_rx_buf; + memset(txbuf, 0x0, SPI_BUF_LENGTH); + memset(rxbuf, 0x0, SPI_BUF_LENGTH); } - return fts_boot_write(&cmd[0], cmdlen, data, datalen); + txbuf[txlen++] = writebuf[0]; + txbuf[txlen++] = WRITE_CMD; + txbuf[txlen++] = (datalen >> 8) & 0xFF; + txbuf[txlen++] = datalen & 0xFF; + if (datalen > 0) { + txlen = txlen + SPI_DUMMY_BYTE; + memcpy(&txbuf[txlen], &writebuf[1], datalen); + txlen = txlen + datalen; + } + + for (i = 0; i < SPI_RETRY_NUMBER; i++) { + ret = fts_spi_transfer(txbuf, rxbuf, txlen); + if ((0 == ret) && ((rxbuf[3] & 0xA0) == 0)) { + break; + } else { + FTS_DEBUG("data write(status=%x),retry=%d,ret=%d", + rxbuf[3], i, ret); + ret = -EIO; + udelay(CS_HIGH_DELAY); + } + } + +err_write: + if (txlen_need > SPI_BUF_LENGTH) { + if (txbuf) { + kfree(txbuf); + txbuf = NULL; + } + + if (rxbuf) { + kfree(rxbuf); + rxbuf = NULL; + } + } + + mutex_unlock(&ts_data->bus_lock); + return ret; } int fts_write_reg(u8 addr, u8 value) { - return fts_boot_write(&addr, 1, &value, 1); + u8 writebuf[2] = { 0 }; + + writebuf[0] = addr; + writebuf[1] = value; + return fts_write(writebuf, 2); } 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; u8 *txbuf = NULL; + u8 *rxbuf = NULL; u32 txlen = 0; + u32 txlen_need = datalen + SPI_HEADER_LENGTH; u8 ctrl = READ_CMD; - u8 tmpcmd[FTX_MAX_COMMMAND_LENGTH] = { 0 }; + u32 dp = 0; - mutex_lock(&fts_data->bus_lock); - if (cmd && cmdlen) { - /* wait spi idle */ - ret = fts_wait_idle(); - if (ret < 0) { - FTS_ERROR("wait spi idle fail"); - goto boot_read_err; + if (!cmd || !cmdlen || !data || !datalen) { + FTS_ERROR("cmd/cmdlen/data/datalen is invalid"); + return -EINVAL; + } + + mutex_lock(&ts_data->bus_lock); + if (txlen_need > SPI_BUF_LENGTH) { + txbuf = kzalloc(txlen_need, GFP_KERNEL); + if (NULL == txbuf) { + FTS_ERROR("txbuf malloc fail"); + ret = -ENOMEM; + goto err_read; } - /* write cmd */ - memcpy(tmpcmd, cmd, cmdlen); - if (fts_data->fw_is_running) { - tmpcmd[cmdlen++] = (datalen >> 8) & 0xFF; - tmpcmd[cmdlen++] = datalen & 0xFF; - } - ret = fts_cmdpkg_wirte(ctrl, tmpcmd, cmdlen); - if (ret < 0) { - FTS_ERROR("command package wirte fail"); - goto boot_read_err; + rxbuf = kzalloc(txlen_need, GFP_KERNEL); + if (NULL == rxbuf) { + FTS_ERROR("rxbuf malloc fail"); + ret = -ENOMEM; + goto err_read; } + } else { + txbuf = ts_data->bus_tx_buf; + rxbuf = ts_data->bus_rx_buf; + memset(txbuf, 0x0, SPI_BUF_LENGTH); + memset(rxbuf, 0x0, SPI_BUF_LENGTH); + } - /* wait spi idle */ - ret = fts_wait_idle(); - if (ret < 0) { - FTS_ERROR("wait spi idle from cmd fail"); - goto boot_read_err; + txbuf[txlen++] = cmd[0]; + txbuf[txlen++] = ctrl; + txbuf[txlen++] = (datalen >> 8) & 0xFF; + txbuf[txlen++] = datalen & 0xFF; + dp = txlen + SPI_DUMMY_BYTE; + txlen = dp + datalen; + if (ctrl & DATA_CRC_EN) { + txlen = txlen + 2; + } + + for (i = 0; i < SPI_RETRY_NUMBER; i++) { + ret = fts_spi_transfer(txbuf, rxbuf, txlen); + if ((0 == ret) && ((rxbuf[3] & 0xA0) == 0)) { + memcpy(data, &rxbuf[dp], datalen); + /* crc check */ + if (ctrl & DATA_CRC_EN) { + ret = rdata_check(&rxbuf[dp], txlen - dp); + if (ret < 0) { + FTS_INFO("read data(addr:%x) crc check incorrect", cmd[0]); + goto err_read; + } + } + break; + } else { + FTS_DEBUG("data read(status=%x),retry=%d,ret=%d", + rxbuf[3], i, ret); + ret = -EIO; + udelay(CS_HIGH_DELAY); } } - if (data && datalen) { - /* write data */ - if (datalen > SPI_BUF_LENGTH - SPI_HEADER_LENGTH) { - txbuf = kzalloc(datalen + SPI_HEADER_LENGTH, GFP_KERNEL); - if (NULL == txbuf) { - FTS_ERROR("txbuf kalloc fail"); - ret = -ENOMEM; - goto boot_read_err; - } - } else { - txbuf = fts_data->bus_buf; - } - memset(txbuf, 0xFF, datalen + SPI_HEADER_LENGTH); - txbuf[0] = DATA_PACKAGE; - txlen = datalen + 1; - if (ctrl & DATA_CRC_EN) { - txlen = txlen + 2; - } - ret = fts_spi_transfer(txbuf, txbuf, txlen); - if (ret < 0) { - FTS_ERROR("data read fail"); - goto boot_read_err; - } - memcpy(data, &txbuf[1], datalen); - /* crc check */ - if (ctrl & DATA_CRC_EN) { - ret = rdata_check(&txbuf[1], txlen - 1); - if (ret < 0) { - FTS_INFO("read data crc check incorrect"); - goto boot_read_err; - } - } - - if (txbuf && (datalen > SPI_BUF_LENGTH - SPI_HEADER_LENGTH)) { +err_read: + if (txlen_need > SPI_BUF_LENGTH) { + if (txbuf) { kfree(txbuf); txbuf = NULL; } + + if (rxbuf) { + kfree(rxbuf); + rxbuf = NULL; + } } -boot_read_err: - mutex_unlock(&fts_data->bus_lock); + + mutex_unlock(&ts_data->bus_lock); return ret; } @@ -391,12 +306,17 @@ int fts_read_reg(u8 addr, u8 *value) int fts_bus_init(struct fts_ts_data *ts_data) { FTS_FUNC_ENTER(); - ts_data->bus_buf = kzalloc(SPI_BUF_LENGTH, GFP_KERNEL); - if (NULL == ts_data->bus_buf) { - FTS_ERROR("failed to allocate memory for bus_buf"); + ts_data->bus_tx_buf = kzalloc(SPI_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(SPI_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; } @@ -404,11 +324,15 @@ int fts_bus_init(struct fts_ts_data *ts_data) int fts_bus_exit(struct fts_ts_data *ts_data) { FTS_FUNC_ENTER(); - if (ts_data && ts_data->bus_buf) { - kfree(ts_data->bus_buf); - ts_data->bus_buf = NULL; + 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; } diff --git a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_test/focaltech_test.c b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_test/focaltech_test.c index 0faf0a15f0f7..b1213d350d93 100755 --- a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_test/focaltech_test.c +++ b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_test/focaltech_test.c @@ -1001,9 +1001,9 @@ int get_rawdata_mc(u8 fre, u8 fir, int *rawdata) } /* fir enable/disable */ - ret = fts_test_write_reg(FACTORY_REG_FIR, 1); + ret = fts_test_write_reg(FACTORY_REG_FIR, fir); if (ret < 0) { - FTS_TEST_SAVE_ERR("set fir fail,ret=%d\n", fir); + FTS_TEST_SAVE_ERR("set fir fail,ret=%d\n", ret); return ret; } diff --git a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_test/focaltech_test_ini.c b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_test/focaltech_test_ini.c index 846390bd057c..970c2adb4aec 100755 --- a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_test/focaltech_test_ini.c +++ b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_test/focaltech_test_ini.c @@ -104,6 +104,18 @@ struct ini_ic_type ic_types[] = { {"FT8613S", 0x94000014}, {"FT8756", 0x95000015}, + {"FT8656", 0x95010018}, + + {"FT8302", 0x97000016}, + + {"FT8009", 0x98000017}, + + {"FT3068", 0x65010085}, + {"FT3168", 0x65020085}, + {"FT3067", 0x65030085}, + {"FT3268", 0x65040085}, + {"FT6346U", 0x65050085}, + {"FT6346G", 0x65060085}, }; /***************************************************************************** @@ -449,7 +461,7 @@ static int ini_parse_section(struct ini_data *ini, char *line_buffer) return -EINVAL; } - if ((ini->section_num < 0) || (ini->section_num > MAX_INI_SECTION_NUM)) { + if ((ini->section_num < 0) || (ini->section_num >= MAX_INI_SECTION_NUM)) { FTS_TEST_ERROR("section_num(%d) fail", ini->section_num); return -EINVAL; } @@ -737,7 +749,7 @@ static int init_node_valid(void) for (cnt = 0; cnt < node_num; cnt++) { i = cnt / chy + 1; j = cnt % chy + 1; - snprintf(str, MAX_KEYWORD_VALUE_LEN, "InvalidNode[%d][%d]", i, j); + snprintf(str, MAX_KEYWORD_NAME_LEN, "InvalidNode[%d][%d]", i, j); get_keyword_value("INVALID_NODE", str, &tdata->node_valid[cnt]); } } @@ -750,7 +762,7 @@ static int init_node_valid(void) for (cnt = 0; cnt < node_num; cnt++) { i = (cnt >= chy) ? 2 : 1; j = (cnt >= chy) ? (cnt - chy + 1) : (cnt + 1); - snprintf(str, MAX_KEYWORD_VALUE_LEN, "InvalidNodeS[%d][%d]", i, j); + snprintf(str, MAX_KEYWORD_NAME_LEN, "InvalidNodeS[%d][%d]", i, j); get_keyword_value("INVALID_NODES", str, &tdata->node_valid_sc[cnt]); } } diff --git a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_test/focaltech_test_ini.h b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_test/focaltech_test_ini.h index 2f072d60d973..13677b23360a 100755 --- a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_test/focaltech_test_ini.h +++ b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_test/focaltech_test_ini.h @@ -69,6 +69,7 @@ struct ini_data { "RAWDATA_TEST", \ "LCD_NOISE_TEST", \ "KEY_SHORT_TEST", \ + "MUX_OPEN_TEST", \ } #define BASIC_THRESHOLD_INCELL { \ @@ -105,9 +106,10 @@ struct ini_data { } #define TEST_ITEM_SC { \ + "RAWDATA_TEST", \ "CB_TEST", \ "DELTA_CB_TEST", \ - "RAWDATA_TEST", \ + "WEAK_SHORT_TEST", \ } #define BASIC_THRESHOLD_SC { \