From 8250cd3d74425eb7121cf4550fb685e07121f3c8 Mon Sep 17 00:00:00 2001 From: Konstantin Makariev Date: Thu, 10 Dec 2020 13:46:07 -0600 Subject: [PATCH] stmicro_mmi: update driver to version 5.2.19 Added support for multiple ST chipsets Change-Id: Iaf54dc69f28eaf90f0308028bde20e3a3af1fb84 Signed-off-by: Konstantin Makariev Reviewed-on: https://gerrit.mot.com/1824927 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Ling Jin Submit-Approved: Jira Key --- drivers/input/touchscreen/stmicro_mmi/fts.c | 82 +++++++++++++++++++ drivers/input/touchscreen/stmicro_mmi/fts.h | 4 +- .../stmicro_mmi/fts_lib/ftsFlash.c | 44 +++++++++- .../stmicro_mmi/fts_lib/ftsHardware.h | 18 ++++ 4 files changed, 143 insertions(+), 5 deletions(-) diff --git a/drivers/input/touchscreen/stmicro_mmi/fts.c b/drivers/input/touchscreen/stmicro_mmi/fts.c index 05c22277c899..93362f0fd8ce 100644 --- a/drivers/input/touchscreen/stmicro_mmi/fts.c +++ b/drivers/input/touchscreen/stmicro_mmi/fts.c @@ -3127,6 +3127,88 @@ static void fts_interrupt_enable(struct fts_ts_info *info) static int fts_init(struct fts_ts_info *info) { int error; + u8 readData[3]; + +#if !defined(I2C_INTERFACE) && defined(SPI4_WIRE) + /* configure manually SPI4 because when no fw is running the chip use + * SPI3 by default */ + u8 cmd[1] = {0x00}; + + logError(0, "%s Setting SPI4 mode...\n", tag); + cmd[0] = 0x10; + error = fts_writeU8UX(FTS_CMD_HW_REG_W, ADDR_SIZE_HW_REG, + ADDR_GPIO_DIRECTION, cmd, 1); + if (error < OK) { + logError(1, "%s can not set gpio dir ERROR %08X\n", + tag, error); + return error; + } + + cmd[0] = 0x02; + error = fts_writeU8UX(FTS_CMD_HW_REG_W, ADDR_SIZE_HW_REG, + ADDR_GPIO_PULLUP, cmd, 1); + if (error < OK) { + logError(1, "%s can not set gpio pull-up ERROR %08X\n", + tag, error); + return error; + } + +#if defined(ALIX) || defined (SALIXP) +#if defined(ALIX) + cmd[0] = 0x70; +#else + cmd[0] = 0x07; +#endif + error = fts_writeU8UX(FTS_CMD_HW_REG_W, ADDR_SIZE_HW_REG, + ADDR_GPIO_CONFIG_REG3, cmd, 1); + if (error < OK) { + logError(1, "%s can not set gpio config ERROR %08X\n", + tag, error); + return error; + } + +#else + cmd[0] = 0x07; + error = fts_writeU8UX(FTS_CMD_HW_REG_W, ADDR_SIZE_HW_REG, + ADDR_GPIO_CONFIG_REG2, cmd, 1); + if (error < OK) { + logError(1, "%s can not set gpio config ERROR %08X\n", + tag, error); + return error; + } +#endif + + cmd[0] = 0x30; + error = fts_writeU8UX(FTS_CMD_HW_REG_W, ADDR_SIZE_HW_REG, + ADDR_GPIO_CONFIG_REG0, cmd, 1); + if (error < OK) { + logError(1, "%s can not set gpio config ERROR %08X\n", + tag, error); + return error; + } + + cmd[0] = SPI4_MASK; + error = fts_writeU8UX(FTS_CMD_HW_REG_W, ADDR_SIZE_HW_REG, ADDR_ICR, cmd, + 1); + if (error < OK) { + logError(1, "%s can not set spi4 mode ERROR %08X\n", + tag, error); + return error; + } + msleep(1); /* wait for the GPIO to stabilize */ +#endif + logError(1, "%s Reading chip id\n", tag); + error = fts_writeReadU8UX(FTS_CMD_HW_REG_R, ADDR_SIZE_HW_REG, + ADDR_DCHIP_ID, readData, 2, DUMMY_FIFO); + logError(1, "%s chip id: %02X %02X!\n",tag, readData[0], readData[1]); + + if((readData[0] != DCHIP_ID_0) || (readData[1] != DCHIP_ID_1)) + { + logError(1, "%s wrong chip id detected!\n", tag); + return ERROR_OP_NOT_ALLOW; + } + else + logError(1, "%s chip id read successful!\n", tag); error = fts_system_reset(); diff --git a/drivers/input/touchscreen/stmicro_mmi/fts.h b/drivers/input/touchscreen/stmicro_mmi/fts.h index 85857a4ea785..a301de129374 100644 --- a/drivers/input/touchscreen/stmicro_mmi/fts.h +++ b/drivers/input/touchscreen/stmicro_mmi/fts.h @@ -45,8 +45,8 @@ */ /* **** CODE CONFIGURATION **** */ #define FTS_TS_DRV_NAME "fts" /* /< driver name */ -#define FTS_TS_DRV_VERSION "5.2.18" /* /< driver version string format */ -#define FTS_TS_DRV_VER 0x05021200 /* driver version u32 format */ +#define FTS_TS_DRV_VERSION "5.2.19" /* /< driver version string format */ +#define FTS_TS_DRV_VER 0x05021300 /* driver version u32 format */ #define DEBUG /* /< define to print more logs in the kernel log and better * follow the code flow */ diff --git a/drivers/input/touchscreen/stmicro_mmi/fts_lib/ftsFlash.c b/drivers/input/touchscreen/stmicro_mmi/fts_lib/ftsFlash.c index 8b7dd0f5f8c8..20112d9ffb47 100644 --- a/drivers/input/touchscreen/stmicro_mmi/fts_lib/ftsFlash.c +++ b/drivers/input/touchscreen/stmicro_mmi/fts_lib/ftsFlash.c @@ -293,6 +293,21 @@ int hold_m3(void) return ret; } +#if defined(ALIX) || defined (SALIXP) +#if defined(ALIX) + cmd[0] = 0x70; +#else + cmd[0] = 0x07; +#endif + ret = fts_writeU8UX(FTS_CMD_HW_REG_W, ADDR_SIZE_HW_REG, + ADDR_GPIO_CONFIG_REG3, cmd, 1); + if (ret < OK) { + logError(1, "%s hold_m3: can not set gpio config ERROR %08X\n", + tag, ret); + return ret; + } + +#else cmd[0] = 0x07; ret = fts_writeU8UX(FTS_CMD_HW_REG_W, ADDR_SIZE_HW_REG, ADDR_GPIO_CONFIG_REG2, cmd, 1); @@ -301,6 +316,7 @@ int hold_m3(void) tag, ret); return ret; } +#endif cmd[0] = 0x30; ret = fts_writeU8UX(FTS_CMD_HW_REG_W, ADDR_SIZE_HW_REG, @@ -683,6 +699,16 @@ int flash_erase_page_by_page(ErasePage keep_cx, Firmware *fw) u8 flash_panel_start_page = FLASH_PANEL_PAGE_START; u8 flash_panel_end_page = FLASH_PANEL_PAGE_END; +#ifdef SALIXP + u8 cmd[10] = { FTS_CMD_HW_REG_W, 0x20, 0x00, 0x00, FLASH_ERASE_CODE0, + 0x80, 0x00, 0xFF, 0x1C, 0x90 }; + u8 cmd2[11] = { FTS_CMD_HW_REG_W, 0x20, 0x00, + 0x01, 0x28, + 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; + u8 mask[6] = { 0 }; + u8 mask_cnt = 6; +#else u8 cmd1[6] = { FTS_CMD_HW_REG_W, 0x20, 0x00, 0x00, FLASH_ERASE_CODE0 + 1, 0x00 }; u8 cmd[6] = { FTS_CMD_HW_REG_W, 0x20, 0x00, 0x00, FLASH_ERASE_CODE0, @@ -692,6 +718,8 @@ int flash_erase_page_by_page(ErasePage keep_cx, Firmware *fw) 0xFF, 0xFF, 0xFF, 0xFF }; u8 mask[4] = { 0 }; + u8 mask_cnt = 4; +#endif if ((fw->fw_code_size == 0) || (fw->panel_config_size == 0) || (fw->cx_area_size == 0) || (fw->fw_config_size == 0)) { @@ -719,19 +747,21 @@ int flash_erase_page_by_page(ErasePage keep_cx, Firmware *fw) for (i = flash_cx_start_page; i <= flash_cx_end_page && keep_cx >= SKIP_PANEL_CX_INIT; i++) { logError(0, "%s Skipping erase CX page %d!\n", tag, i); - fromIDtoMask(i, mask, 4); + fromIDtoMask(i, mask, mask_cnt); + } for (i = flash_panel_start_page; i <= flash_panel_end_page && keep_cx >= SKIP_PANEL_INIT; i++) { logError(0, "%s Skipping erase Panel Init page %d!\n", tag, i); - fromIDtoMask(i, mask, 4); + fromIDtoMask(i, mask, mask_cnt); + } logError(0, "%s Setting the page mask = ", tag); - for (i = 0; i < 4; i++) { + for (i = 0; i < mask_cnt; i++) { cmd2[5 + i] = cmd2[5 + i] & (~mask[i]); logError(0, "%02X ", cmd2[5 + i]); } @@ -745,6 +775,7 @@ int flash_erase_page_by_page(ErasePage keep_cx, Firmware *fw) return ERROR_BUS_W; } +#ifndef SALIXP if (fts_write(cmd1, ARRAY_SIZE(cmd1)) < OK) { logError(1, "%s flash_erase_page_by_page: Disable info ERROR %08X\n", @@ -752,6 +783,7 @@ int flash_erase_page_by_page(ErasePage keep_cx, Firmware *fw) ERROR_BUS_W); return ERROR_BUS_W; } +#endif logError(0, "%s Command erase pages sent ...\n", tag); if (fts_write(cmd, ARRAY_SIZE(cmd)) < OK) { @@ -783,8 +815,14 @@ int flash_erase_page_by_page(ErasePage keep_cx, Firmware *fw) int start_flash_dma(void) { int status; + +#ifdef SALIXP + u8 cmd[12] = { FLASH_CMD_WRITE_REGISTER, 0x20, 0x00, 0x00, + 0x6B, 0x00, 0xFF, 0x1C, 0x10, 0x00, 0x00, FLASH_DMA_CODE1 }; +#else u8 cmd[12] = { FLASH_CMD_WRITE_REGISTER, 0x20, 0x00, 0x00, 0x6B, 0x00, 0x40, 0x42, 0x0F, 0x00, 0x00, FLASH_DMA_CODE1 }; +#endif /* write the command to erase the flash */ diff --git a/drivers/input/touchscreen/stmicro_mmi/fts_lib/ftsHardware.h b/drivers/input/touchscreen/stmicro_mmi/fts_lib/ftsHardware.h index 58f1a55355f1..c87c6f1b20a1 100644 --- a/drivers/input/touchscreen/stmicro_mmi/fts_lib/ftsHardware.h +++ b/drivers/input/touchscreen/stmicro_mmi/fts_lib/ftsHardware.h @@ -25,10 +25,18 @@ /* DIGITAL CHIP INFO */ //#define ALIX +//#define WALNUT +//#define SALIXP #ifdef ALIX #define DCHIP_ID_0 0x36 /* /< LSB chip ID for FTM5 */ #define DCHIP_ID_1 0x48 /* /< MSB chip ID for FTM5 */ +#elif defined(WALNUT) +#define DCHIP_ID_0 0x36 /* /< LSB chip ID for FTM5 */ +#define DCHIP_ID_1 0x50 /* /< MSB chip ID for FTM5 */ +#elif defined(SALIXP) +#define DCHIP_ID_0 0x36 /* /< LSB chip ID for FTM5 */ +#define DCHIP_ID_1 0x40 /* /< MSB chip ID for FTM5 */ #else #define DCHIP_ID_0 0x36 /* /< LSB chip ID for FTM5 */ #define DCHIP_ID_1 0x39 /* /< MSB chip ID for FTM5 */ @@ -106,8 +114,14 @@ #define FLASH_ERASE_CODE0 0x6A #define FLASH_DMA_CODE0 0x71 #define FLASH_DMA_CONFIG 0x72 + +#ifdef SALIXP +#define FLASH_NUM_PAGE 48 /* /< number of pages in main + * flash */ +#else #define FLASH_NUM_PAGE 32 /* /< number of pages in main * flash */ +#endif #define FLASH_CX_PAGE_START 28 /* /< starting page which * contain Cx data */ @@ -300,6 +314,10 @@ #define ADDR_GPIO_CONFIG_REG2 ((u64)0x000000002000003F) /* /< address of * GPIO config register */ +#define ADDR_GPIO_CONFIG_REG3 ((u64)0x000000002000003E) /* /< address of + * GPIO config register + */ + /**@}*/