Add force-IAP mode to support firmware recovery mechanism based on
kernel-dapttion-mrst-2.6.37.6-16.1.src.rpm.

Signed-off-by: Mike Hsu <[email protected]>
Signed-off-by: Stanley Zeng <[email protected]>
Signed-off-by: Scott Liu <[email protected]>

---
 ektf2136.h |    1 +
 1 file changed, 1 insertion(+)

--- linux-2.6.37/include/linux/spi/ektf2136.old.h       2011-05-30
15:49:43.000000000 +0800
+++ linux-2.6.37/include/linux/spi/ektf2136.h   2011-05-30
15:50:03.000000000 +0800
@@ -30,5 +30,6 @@
 #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.c |   59
+++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 57 insertions(+), 2 deletions(-)

--- linux-2.6.37/drivers/input/touchscreen/ektf2136_spi.old.c
2011-05-30 15:44:33.000000000 +0800
+++ linux-2.6.37/drivers/input/touchscreen/ektf2136_spi.c
2011-05-30 15:48:24.000000000 +0800
@@ -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 @@
 /* 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 @@
        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;
@@ -382,6 +385,7 @@
                        break;
                }
        }
+
        ed->wait_sync_int = false;
 
        return rc;
@@ -521,6 +525,10 @@
        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)
@@ -563,6 +571,10 @@
        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)
@@ -603,6 +615,10 @@
        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)
@@ -644,6 +660,10 @@
        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)
@@ -687,6 +707,10 @@
        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)
@@ -754,6 +778,23 @@
                        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 = elan_spi_read_data(spi, buf_recv,
sizeof(buf_recv), "get_iap_hello");
+                       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 */
@@ -1534,6 +1575,8 @@
                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;
        }
@@ -1778,12 +1821,18 @@
        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)
                return ret;
 
+       mutex_lock(&ed->sysfs_mutex);
        ed->power_state = 0;
+       mutex_unlock(&ed->sysfs_mutex);
        msleep(100);
        return 0;
 }
@@ -1795,12 +1844,18 @@
        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)
                return ret;
 
+       mutex_lock(&ed->sysfs_mutex);
        ed->power_state = 1;
+       mutex_unlock(&ed->sysfs_mutex);
        msleep(100);
        return 0;
 }

Attachment: linux-2.6.37-ektf-firmware-recovery.patch
Description: linux-2.6.37-ektf-firmware-recovery.patch

_______________________________________________
MeeGo-kernel mailing list
[email protected]
http://lists.meego.com/listinfo/meego-kernel

Reply via email to