From 8025e451a98d9cb0c3ee50f4c1900ceb825b428e Mon Sep 17 00:00:00 2001 From: Ravikanth Tuniki Date: Wed, 2 Dec 2020 10:38:31 +0530 Subject: [PATCH] input: touchscreen: nt36xxx: Add Chip id and firmware Add novatek chip id and firmware during boot up to enable touch. Change-Id: I382ae51c7bb4bf270c2e01b484281fcc24270062 Signed-off-by: Ravikanth Tuniki --- drivers/input/touchscreen/nt36xxx/nt36xxx.c | 20 +++++++++++-------- drivers/input/touchscreen/nt36xxx/nt36xxx.h | 4 ++-- .../touchscreen/nt36xxx/nt36xxx_fw_update.c | 12 +++++++---- .../touchscreen/nt36xxx/nt36xxx_mem_map.h | 10 ++++++++++ 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/drivers/input/touchscreen/nt36xxx/nt36xxx.c b/drivers/input/touchscreen/nt36xxx/nt36xxx.c index de496cc1e4b8..c2bdc214892c 100644 --- a/drivers/input/touchscreen/nt36xxx/nt36xxx.c +++ b/drivers/input/touchscreen/nt36xxx/nt36xxx.c @@ -1121,8 +1121,8 @@ void nvt_stop_crc_reboot(void) * * return: * Executive outcomes. 0---NVT IC. -1---not NVT IC. - *******************************************************/ -static int8_t nvt_ts_check_chip_ver_trim(void) +*******************************************************/ +static int8_t nvt_ts_check_chip_ver_trim(uint32_t chip_ver_trim_addr) { uint8_t buf[8] = {0}; int32_t retry = 0; @@ -1142,9 +1142,9 @@ static int8_t nvt_ts_check_chip_ver_trim(void) CTP_I2C_WRITE(ts->client, I2C_HW_Address, buf, 2); msleep(10); - nvt_set_page(I2C_BLDR_Address, 0x1F64E); + nvt_set_page(I2C_BLDR_Address, chip_ver_trim_addr); - buf[0] = 0x4E; + buf[0] = chip_ver_trim_addr & 0xFF; buf[1] = 0x00; buf[2] = 0x00; buf[3] = 0x00; @@ -1292,11 +1292,15 @@ static int32_t nvt_ts_late_probe(struct i2c_client *client, } //---check chip version trim--- - ret = nvt_ts_check_chip_ver_trim(); + ret = nvt_ts_check_chip_ver_trim(CHIP_VER_TRIM_ADDR); if (ret) { - NVT_ERR("chip is not identified\n"); - ret = -EINVAL; - goto err_chipvertrim_failed; + NVT_LOG("try to check from old chip ver trim address\n"); + ret = nvt_ts_check_chip_ver_trim(CHIP_VER_TRIM_OLD_ADDR); + if (ret) { + NVT_ERR("chip is not identified\n"); + ret = -EINVAL; + goto err_chipvertrim_failed; + } } nvt_bootloader_reset(); diff --git a/drivers/input/touchscreen/nt36xxx/nt36xxx.h b/drivers/input/touchscreen/nt36xxx/nt36xxx.h index eef848bfe9dd..d3ae17038eaa 100644 --- a/drivers/input/touchscreen/nt36xxx/nt36xxx.h +++ b/drivers/input/touchscreen/nt36xxx/nt36xxx.h @@ -62,7 +62,7 @@ //---Touch info.--- #define TOUCH_DEFAULT_MAX_WIDTH 1080 -#define TOUCH_DEFAULT_MAX_HEIGHT 1920 +#define TOUCH_DEFAULT_MAX_HEIGHT 2408 #define TOUCH_MAX_FINGER_NUM 10 #define TOUCH_KEY_NUM 0 #if TOUCH_KEY_NUM > 0 @@ -82,7 +82,7 @@ extern const uint16_t touch_key_array[TOUCH_KEY_NUM]; #if WAKEUP_GESTURE extern const uint16_t gesture_key_array[]; #endif -#define BOOT_UPDATE_FIRMWARE 0 +#define BOOT_UPDATE_FIRMWARE 1 #define BOOT_UPDATE_FIRMWARE_NAME "novatek_ts_fw.bin" //---ESD Protect.--- diff --git a/drivers/input/touchscreen/nt36xxx/nt36xxx_fw_update.c b/drivers/input/touchscreen/nt36xxx/nt36xxx_fw_update.c index 52086dc58eae..0161dbf88eaa 100644 --- a/drivers/input/touchscreen/nt36xxx/nt36xxx_fw_update.c +++ b/drivers/input/touchscreen/nt36xxx/nt36xxx_fw_update.c @@ -47,7 +47,10 @@ static int32_t nvt_get_fw_need_write_size(const struct firmware *fw_entry) for (i = total_sectors_to_check; i > 0; i--) { /* printk("current end flag address checked = 0x%X\n", i * FLASH_SECTOR_SIZE - NVT_FLASH_END_FLAG_LEN); */ /* check if there is end flag "NVT" at the end of this sector */ - if (memcmp(&fw_entry->data[i * FLASH_SECTOR_SIZE - NVT_FLASH_END_FLAG_LEN], "NVT", NVT_FLASH_END_FLAG_LEN) == 0) { + if ((memcmp((const char *)&fw_entry->data[i * FLASH_SECTOR_SIZE - + NVT_FLASH_END_FLAG_LEN], "NVT", NVT_FLASH_END_FLAG_LEN) == 0) || + (memcmp((const char *)&fw_entry->data[i * FLASH_SECTOR_SIZE - + NVT_FLASH_END_FLAG_LEN], "MOD", NVT_FLASH_END_FLAG_LEN) == 0)) { fw_need_write_size = i * FLASH_SECTOR_SIZE; NVT_LOG("fw_need_write_size = %zu(0x%zx)\n", fw_need_write_size, fw_need_write_size); return 0; @@ -75,7 +78,7 @@ int32_t update_firmware_request(char *filename) NVT_LOG("filename is %s\n", filename); - ret = request_firmware_nowarn(&fw_entry, filename, &ts->client->dev); + ret = request_firmware(&fw_entry, filename, &ts->client->dev); if (ret) { NVT_ERR("firmware load failed, ret=%d\n", ret); return ret; @@ -966,10 +969,11 @@ int32_t nvt_check_flash_end_flag(void) } //buf[3:5] => NVT End Flag - strlcpy(nvt_end_flag, &buf[3], NVT_FLASH_END_FLAG_LEN); + strlcpy(nvt_end_flag, &buf[3], sizeof(nvt_end_flag)); NVT_LOG("nvt_end_flag=%s (%02X %02X %02X)\n", nvt_end_flag, buf[3], buf[4], buf[5]); - if (memcmp(nvt_end_flag, "NVT", NVT_FLASH_END_FLAG_LEN) == 0) { + if ((memcmp(nvt_end_flag, "NVT", NVT_FLASH_END_FLAG_LEN) == 0) || + (memcmp(nvt_end_flag, "MOD", NVT_FLASH_END_FLAG_LEN) == 0)) { return 0; } else { NVT_ERR("\"NVT\" end flag not found!\n"); diff --git a/drivers/input/touchscreen/nt36xxx/nt36xxx_mem_map.h b/drivers/input/touchscreen/nt36xxx/nt36xxx_mem_map.h index 94040a41c3d2..bdfb71aac99e 100644 --- a/drivers/input/touchscreen/nt36xxx/nt36xxx_mem_map.h +++ b/drivers/input/touchscreen/nt36xxx/nt36xxx_mem_map.h @@ -16,6 +16,8 @@ * more details. * */ +#define CHIP_VER_TRIM_ADDR 0x3F004 +#define CHIP_VER_TRIM_OLD_ADDR 0x1F64E struct nvt_ts_mem_map { uint32_t EVENT_BUF_ADDR; @@ -173,6 +175,14 @@ struct nvt_ts_trim_id_table { }; static const struct nvt_ts_trim_id_table trim_id_table[] = { + {.id = {0x20, 0xFF, 0xFF, 0x72, 0x66, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, + .mmap = &NT36675_memory_map, .hwinfo = &NT36675_hw_info}, + {.id = {0x00, 0xFF, 0xFF, 0x80, 0x66, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, + .mmap = &NT36675_memory_map, .hwinfo = &NT36675_hw_info}, + {.id = {0x0C, 0xFF, 0xFF, 0x25, 0x65, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, + .mmap = &NT36672A_memory_map, .hwinfo = &NT36672A_hw_info}, + {.id = {0x0E, 0xFF, 0xFF, 0x72, 0x66, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, + .mmap = &NT36675_memory_map, .hwinfo = &NT36675_hw_info}, {.id = {0x0C, 0xFF, 0xFF, 0x72, 0x66, 0x03}, .mask = {1, 0, 0, 1, 1, 1}, .mmap = &NT36675_memory_map, .hwinfo = &NT36675_hw_info}, {.id = {0xFF, 0xFF, 0xFF, 0x26, 0x65, 0x03}, .mask = {0, 0, 0, 1, 1, 1},