Dear all, Due to TS firmware updating procedure can’t guarantee 100% successful.
Therefore, IAP recovery mechanism is added to ensure the TS firmware can be recovered by driver. Please help to review and integrate the patch, thanks Subject: Add support for IAP recovery mechanism Add support for IAP recovery mechanism Signed-off-by: Mike Hsu <[email protected]> Signed-off-by: Stanley Zeng <[email protected]> --- ektf2136_spi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/include/linux/spi/ektf2136_spi.h 2011-05-16 02:24:24.031250000 +0000 +++ b/include/linux/spi/ektf2136_spi.h 2011-05-01 13:45:17.922182000 +0000 @@ -30,5 +30,5 @@ struct elan_sr_hdr { #define IOCTL_MINOR_HW_ID _IOR(DEV_IOCTLID, 4, int) #define IOCTL_MAJOR_BC_VER _IOR(DEV_IOCTLID, 5, int) #define IOCTL_MINOR_BC_VER _IOR(DEV_IOCTLID, 6, int) - +#define IOCTL_IAP_MODE _IOR(DEV_IOCTLID, 7, int) #endif --- ektf2136_spi_Add_iap_recovery_mechanism.c | 54 +++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) --- a/drivers/input/touchscreen/ektf2136_spi.c 2011-05-01 22:36:20.458182004 +0000 +++ b/drivers/input/touchscreen/ektf2136_spi.c 2011-05-01 22:48:07.502182004 +0000 @@ -30,11 +30,11 @@ #include <linux/pm_runtime.h> #define DRV_NAME "ektf2136_spi" -#define DRIVER_VERSION "v3.0.2" +#define DRIVER_VERSION "v3.0.3" #define DRV_MA_VER 3 #define DRV_MI_VER 0 -#define DRV_SUB_MI_VER 2 +#define DRV_SUB_MI_VER 3 static const char ELAN_TS_NAME[] = "ektf2136_spi"; @@ -50,6 +50,7 @@ static const char ELAN_TS_NAME[] = "ektf /* Firmware protocol status flag */ #define PRO_SPI_WRT_CMD_SYNC 0x00000001 #define PRO_HID_MOD_CHECKSUM 0x00000002 +#define PRO_UPDATE_FW_MODE 0x00000080 /* Convert from rows or columns into resolution */ #define ELAN_TS_RESOLUTION(n) ((n - 1) * 64) @@ -118,6 +119,8 @@ struct elan_data { int cols; u8 power_state; /* Power state 0:sleep 1:active */ u8 user_power; /* Power forced on if 1 */ +#define IAP_MODE_ENABLE 1 /* TS is in IAP mode already */ + unsigned int iap_mode; /* Firmware update mode or 0 for normal */ struct hrtimer timer; struct work_struct work; @@ -505,6 +508,10 @@ static int elan_touch_get_fw_ver(struct u8 buf_recv[4]; int rc; + /* Command not support in IAP recovery mode */ + if (ed->protocol & PRO_UPDATE_FW_MODE) + return 0; + rc = elan_spi_write_cmd(spi, get_fw_ver_cmd, sizeof(get_fw_ver_cmd), "get_fw_ver_cmd"); if (rc < 0) @@ -546,6 +553,10 @@ static int elan_touch_get_power_state(st u8 buf_recv[4]; int ret = 0; + /* Command not support in IAP recovery mode */ + if (ed->protocol & PRO_UPDATE_FW_MODE) + return 0; + ret = elan_spi_write_cmd(ed->spi, get_power_state, sizeof(get_power_state), "get_power_state"); if (ret < 0) @@ -585,6 +596,10 @@ static int elan_touch_get_bc_ver(struct u8 buf_recv[4]; int rc; + /* Command not support in IAP recovery mode */ + if (ed->protocol & PRO_UPDATE_FW_MODE) + return 0; + rc = elan_spi_write_cmd(spi, get_bc_ver_cmd, sizeof(get_bc_ver_cmd), "get_bc_ver_cmd"); if (rc < 0) @@ -625,6 +640,10 @@ static int elan_touch_get_hw_id(struct s u8 buf_recv[4]; int rc; + /* Command not support in IAP recovery mode */ + if (ed->protocol & PRO_UPDATE_FW_MODE) + return 0; + rc = elan_spi_write_cmd(spi, get_hw_id_cmd, sizeof(get_hw_id_cmd), "get_hw_id_cmd"); if (rc < 0) @@ -667,6 +686,10 @@ static int elan_touch_get_resolution(str u8 buf_recv[17]; int rc; + /* Command not support in IAP recovery mode */ + if (ed->protocol & PRO_UPDATE_FW_MODE) + return 0; + rc = elan_spi_write_cmd(spi, get_resolution_cmd, sizeof(get_resolution_cmd), "get_resolution_cmd"); if (rc < 0) @@ -732,6 +755,23 @@ static int elan_touch_init_panel(struct ed->protocol = ed->protocol | PRO_HID_MOD_CHECKSUM; ed->rx_size = IDX_PACKET_SIZE_XY_CHECKSUM; } + + if (buf_recv[3] & PRO_UPDATE_FW_MODE) { + ed->protocol = ed->protocol | PRO_UPDATE_FW_MODE; + ed->iap_mode = IAP_MODE_ENABLE; + + rc = spi_read(spi, buf_recv, sizeof(buf_recv)); + if (rc) + return rc; + + dev_dbg(&spi->dev, "iap hello packet: [0x%02x 0x%02x 0x%02x 0x%02x]\n", + buf_recv[0], buf_recv[1], buf_recv[2], buf_recv[3]); + ed->major_hw_id = buf_recv[1]; + ed->minor_hw_id = buf_recv[0]; + ed->major_bc_version = buf_recv[3]; + ed->minor_bc_version = buf_recv[2]; + } + } /* Save the base rx size as we will need this once we switch in and out of raw mode */ @@ -1510,6 +1550,8 @@ static long elan_iap_ioctl(struct file * return put_user(ed->major_bc_version, argp); case IOCTL_MINOR_BC_VER: return put_user(ed->minor_bc_version, argp); + case IOCTL_IAP_MODE: + return put_user(ed->iap_mode, argp); default: return -ENOTTY; } @@ -1754,6 +1796,10 @@ static int ektf2136_runtime_suspend(stru static const u8 set_sleep_cmd[] = {0x54, 0x50, 0x00, 0x01}; int ret; + /* Command not support in IAP recovery mode */ + if (ed->protocol & PRO_UPDATE_FW_MODE) + return 0; + ret = elan_spi_write_cmd(ed->spi, set_sleep_cmd, sizeof(set_sleep_cmd), "set_sleep_cmd"); if (ret < 0) @@ -1773,6 +1819,10 @@ static int ektf2136_runtime_resume(struc static const u8 set_active_cmd[] = {0x54, 0x58, 0x00, 0x01}; int ret; + /* Command not support in IAP recovery mode */ + if (ed->protocol & PRO_UPDATE_FW_MODE) + return 0; + ret = elan_spi_write_cmd(ed->spi, set_active_cmd, sizeof(set_active_cmd), "set_active_cmd"); if (ret < 0)
ektf2136_spi_Add_iap_recovery_mechanism.patch
Description: Binary data
_______________________________________________ MeeGo-kernel mailing list [email protected] http://lists.meego.com/listinfo/meego-kernel
