aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQiang Liu <qiangliu@marvell.com>2015-06-26 19:35:53 +0800
committerQing Zhu <qzhu@marvell.com>2015-07-08 21:11:18 +0800
commit9608ccacaa20377d0995fd8bd10afc23f6873a85 (patch)
tree5601c372143602b50b95cbab35a2df9bc9adcac4
parent4c1f8a07edaef92e53cfb4f16237630d7813a0b3 (diff)
downloadpxa-v3.14-9608ccacaa20377d0995fd8bd10afc23f6873a85.tar.gz
input: touchscreen: add driver of mstar touchscreen
Enable mstar touchscreen panel, add Kconfig, Makefile. Change-Id: I803c55da4be10eedb47d4a3df6c9fd1ddb7213c0 Signed-off-by: Qiang Liu <qiangliu@marvell.com> Signed-off-by: yanggao <yanggao@marvell.com>
-rw-r--r--drivers/input/touchscreen/Kconfig1
-rw-r--r--drivers/input/touchscreen/Makefile1
-rw-r--r--drivers/input/touchscreen/mstarTouchPanel/Kconfig8
-rw-r--r--drivers/input/touchscreen/mstarTouchPanel/Makefile7
-rw-r--r--drivers/input/touchscreen/mstarTouchPanel/hipad_firmware_upgrade.c293
-rw-r--r--drivers/input/touchscreen/mstarTouchPanel/hipad_firmware_upgrade.h61
-rw-r--r--drivers/input/touchscreen/mstarTouchPanel/mstar_drv_common.c115
-rw-r--r--drivers/input/touchscreen/mstarTouchPanel/mstar_drv_common.h463
-rw-r--r--drivers/input/touchscreen/mstarTouchPanel/mstar_drv_ic_fw_porting_layer.c176
-rw-r--r--drivers/input/touchscreen/mstarTouchPanel/mstar_drv_ic_fw_porting_layer.h98
-rw-r--r--drivers/input/touchscreen/mstarTouchPanel/mstar_drv_main.c2122
-rw-r--r--drivers/input/touchscreen/mstarTouchPanel/mstar_drv_main.h174
-rw-r--r--drivers/input/touchscreen/mstarTouchPanel/mstar_drv_marvell.c141
-rw-r--r--drivers/input/touchscreen/mstarTouchPanel/mstar_drv_platform_interface.c213
-rw-r--r--drivers/input/touchscreen/mstarTouchPanel/mstar_drv_platform_interface.h48
-rw-r--r--drivers/input/touchscreen/mstarTouchPanel/mstar_drv_platform_porting_layer.c427
-rw-r--r--drivers/input/touchscreen/mstarTouchPanel/mstar_drv_platform_porting_layer.h93
-rw-r--r--drivers/input/touchscreen/mstarTouchPanel/mstar_drv_self_fw_control.c3769
-rw-r--r--drivers/input/touchscreen/mstarTouchPanel/mstar_drv_self_fw_control.h148
-rw-r--r--drivers/input/touchscreen/mstarTouchPanel/mstar_drv_utility_adaption.c500
-rw-r--r--drivers/input/touchscreen/mstarTouchPanel/mstar_drv_utility_adaption.h79
21 files changed, 8937 insertions, 0 deletions
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 9b28c2b0c96..33d94cb4078 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -980,6 +980,7 @@ config TOUCHSCREEN_MSG2138
To compile this driver as a module, choose M here: the
module will be called msg2138.
+source "drivers/input/touchscreen/mstarTouchPanel/Kconfig"
config TOUCHSCREEN_FT6206
tristate "FT6206 touchscreen driver"
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index 1295759920c..7db777f99b6 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -84,5 +84,6 @@ obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_DSX_I2C) += synaptics_dsx_i2c.o
obj-$(CONFIG_TOUCHSCREEN_MSG2133) += msg2133.o
obj-$(CONFIG_TOUCHSCREEN_88MS100) += 88ms100_touch.o
obj-$(CONFIG_TOUCHSCREEN_MSG2138) += msg2138.o
+obj-$(CONFIG_TOUCHSCREEN_MSTAR) += mstarTouchPanel/
obj-$(CONFIG_TOUCHSCREEN_FT6206) += ft6206_ts.o
obj-$(CONFIG_TOUCHSCREEN_FOCALTECH) += focaltech/
diff --git a/drivers/input/touchscreen/mstarTouchPanel/Kconfig b/drivers/input/touchscreen/mstarTouchPanel/Kconfig
new file mode 100644
index 00000000000..407cefa7962
--- /dev/null
+++ b/drivers/input/touchscreen/mstarTouchPanel/Kconfig
@@ -0,0 +1,8 @@
+#
+# TI's mstar Touchscreen driver.
+#
+config TOUCHSCREEN_MSTAR
+ tristate "MSTAR touchscreen driver"
+ depends on I2C
+ help
+ Say Y here if enable support for the MSTAR touchscreen controller.
diff --git a/drivers/input/touchscreen/mstarTouchPanel/Makefile b/drivers/input/touchscreen/mstarTouchPanel/Makefile
new file mode 100644
index 00000000000..298a4b6cc8a
--- /dev/null
+++ b/drivers/input/touchscreen/mstarTouchPanel/Makefile
@@ -0,0 +1,7 @@
+#
+# Makefile for Mstar Touchscreen shared transport driver based on Input Touchscreen
+#
+obj-$(CONFIG_TOUCHSCREEN_MSTAR) += mstar_drv.o
+mstar_drv-objs := mstar_drv_marvell.o mstar_drv_main.o mstar_drv_common.o mstar_drv_utility_adaption.o \
+ mstar_drv_platform_interface.o mstar_drv_self_fw_control.o \
+ mstar_drv_platform_porting_layer.o mstar_drv_ic_fw_porting_layer.o hipad_firmware_upgrade.o
diff --git a/drivers/input/touchscreen/mstarTouchPanel/hipad_firmware_upgrade.c b/drivers/input/touchscreen/mstarTouchPanel/hipad_firmware_upgrade.c
new file mode 100644
index 00000000000..4749f1266d7
--- /dev/null
+++ b/drivers/input/touchscreen/mstarTouchPanel/hipad_firmware_upgrade.c
@@ -0,0 +1,293 @@
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/input.h>
+#include <linux/interrupt.h>
+#include <linux/pm.h>
+#include <linux/slab.h>
+#include <linux/io.h>
+#include <linux/i2c.h>
+#include <linux/timer.h>
+#include <linux/miscdevice.h>
+#include <linux/uaccess.h>
+#include <linux/wakelock.h>
+#include <linux/mutex.h>
+#include <linux/i2c.h>
+
+#include "hipad_firmware_upgrade.h"
+
+static struct firmware_miscdevice *fw_mdev_list[MDEV_NUMS];
+
+static int fw_mdev_open(struct inode *inode, struct file *file)
+{
+ int minor = iminor(inode);
+ struct firmware_miscdevice *dev = fw_mdev_list[minor];
+
+ fw_mdev_debug("minor = %d, start\n", minor);
+
+ if (!dev) {
+ fw_mdev_err("dev = NULL\n");
+ return -ENOENT;
+ }
+
+ dev->fw_count = 0;
+ dev->is_prepare = 1;
+ file->private_data = dev;
+
+ fw_mdev_debug("minor = %d, end\n", minor);
+ return 0;
+}
+
+static int fw_mdev_release(struct inode *inode, struct file *file)
+{
+ file->private_data = NULL;
+ fw_mdev_debug("\n");
+ return 0;
+}
+
+static ssize_t fw_mdev_read(struct file *file, char __user *buff,
+ size_t size, loff_t *offset)
+{
+ return -EIO;
+}
+
+static ssize_t fw_mdev_write(struct file *file, const char __user *buff,
+ size_t size, loff_t *offset)
+{
+ struct firmware_miscdevice *mdev = file->private_data;
+
+ fw_mdev_debug("size = %d\n", size);
+
+ if (mdev == NULL || mdev->firmware_upgrade == NULL) {
+ fw_mdev_err("firemware_upgrade == NULL\n");
+ return -EINVAL;
+ }
+
+ mutex_lock(&mdev->lock);
+ wake_lock(&mdev->wake_lock);
+
+ mdev->firmware_upgrade(mdev, buff, size);
+
+ wake_unlock(&mdev->wake_lock);
+ mutex_unlock(&mdev->lock);
+
+ return size;
+}
+
+static ssize_t fw_mdev_attr_firmware_id_show(struct device *device,
+ struct device_attribute *attr, char *buff)
+{
+ struct firmware_miscdevice *mdev = dev_get_drvdata(device);
+ int size;
+
+ if (!mdev) {
+ fw_mdev_err("mdev is null\n");
+ return -EINVAL;
+ }
+
+ mutex_lock(&mdev->lock);
+ wake_lock(&mdev->wake_lock);
+ if (!mdev->get_firmware_id || !mdev->client) {
+ fw_mdev_err("!mdev->get_firmware_id||!mdev->client\n");
+ wake_unlock(&mdev->wake_lock);
+ mutex_unlock(&mdev->lock);
+ return -EINVAL;
+ }
+
+ size = mdev->get_firmware_id(mdev, buff, PAGE_SIZE);
+
+ wake_unlock(&mdev->wake_lock);
+ mutex_unlock(&mdev->lock);
+
+ return size;
+}
+
+static ssize_t fw_mdev_attr_firmware_size_store(struct device *device,
+ struct device_attribute *attr, const char *buff, size_t size)
+{
+ unsigned long val;
+ struct firmware_miscdevice *mdev = dev_get_drvdata(device);
+
+ if (!mdev) {
+ fw_mdev_err("mdev = NULL\n");
+ return -EINVAL;
+ }
+
+ mdev->fw_size = kstrtoul(buff, 10, &val);
+
+ return size;
+}
+
+static ssize_t fw_mdev_attr_firmware_size_show(struct device *device,
+ struct device_attribute *attr, char *buff)
+{
+ struct firmware_miscdevice *mdev = dev_get_drvdata(device);
+
+ if (!mdev) {
+ fw_mdev_err("mdev = NULL\n");
+ return -EINVAL;
+ }
+
+ return sprintf(buff, "%d", mdev->fw_size);
+}
+
+static struct device_attribute fw_mdev_device_attrs[] = {
+ __ATTR(firmware_id, S_IRUSR, fw_mdev_attr_firmware_id_show, NULL),
+ __ATTR(firmware_size, S_IRUSR|S_IWUSR, fw_mdev_attr_firmware_size_show,
+ fw_mdev_attr_firmware_size_store),
+};
+
+int fw_mdev_master_recv_from_i2c(struct i2c_client *client, short addr,
+ void *buff, size_t size)
+{
+ int ret;
+ struct i2c_msg msg = {
+ .addr = addr,
+ .flags = (client->flags & I2C_M_TEN) | I2C_M_RD,
+ .len = size,
+ .buf = buff
+ };
+
+ ret = i2c_transfer(client->adapter, &msg, 1);
+ if (ret == 1)
+ return size;
+
+ return likely(ret < 0) ? ret : -EFAULT;
+}
+EXPORT_SYMBOL_GPL(fw_mdev_master_recv_from_i2c);
+
+ssize_t fw_mdev_read_data(struct firmware_miscdevice *mdev, u8 addr,
+ void *buff, size_t size)
+{
+ struct i2c_client *client = get_client_from_mdev(mdev);
+ return fw_mdev_master_recv_from_i2c(client, addr, buff, size);
+}
+EXPORT_SYMBOL_GPL(fw_mdev_read_data);
+
+int fw_mdev_master_send_to_i2c(struct i2c_client *client, short addr,
+ const void *buff, size_t size)
+{
+ int ret;
+ struct i2c_msg msg = {
+ .addr = addr,
+ .flags = client->flags & I2C_M_TEN,
+ .len = size,
+ .buf = (__u8 *)buff
+ };
+
+ ret = i2c_transfer(client->adapter, &msg, 1);
+ if (ret == 1)
+ return size;
+
+ return likely(ret < 0) ? ret : -EFAULT;
+}
+EXPORT_SYMBOL_GPL(fw_mdev_master_send_to_i2c);
+
+ssize_t fw_mdev_write_data(struct firmware_miscdevice *mdev, u8 addr,
+ void *buff, size_t size)
+{
+ struct i2c_client *client = get_client_from_mdev(mdev);
+ return fw_mdev_master_send_to_i2c(client, addr, buff, size);
+}
+EXPORT_SYMBOL_GPL(fw_mdev_write_data);
+
+
+static const struct file_operations fw_mdev_fops = {
+ .owner = THIS_MODULE,
+ .write = fw_mdev_write,
+ .read = fw_mdev_read,
+ .open = fw_mdev_open,
+ .release = fw_mdev_release,
+};
+
+static int fw_misc_find_minor(void)
+{
+ int minor;
+
+ for (minor = 0; minor < ARRAY_SIZE(fw_mdev_list); minor++) {
+ if (fw_mdev_list[minor] == NULL)
+ return minor;
+ }
+
+ return -EBUSY;
+}
+
+int fw_mdev_register(struct firmware_miscdevice *mdev)
+{
+ int ret, i;
+ int minor;
+
+ if (!mdev || !mdev->firmware_upgrade) {
+ fw_mdev_err("Implement firmware_upgrade()\n");
+ return -EINVAL;
+ }
+
+ minor = fw_misc_find_minor();
+ mdev->dev.fops = &fw_mdev_fops;
+ ret = misc_register(&mdev->dev);
+ if (ret < 0) {
+ fw_mdev_err("ret = %d\n", ret);
+ return ret;
+ }
+
+ mutex_init(&mdev->lock);
+ wake_lock_init(&mdev->wake_lock,
+ WAKE_LOCK_SUSPEND, mdev->name);
+ mdev->minor = minor;
+ fw_mdev_list[mdev->minor] = mdev;
+
+ dev_set_drvdata(mdev->dev.this_device, mdev);
+
+ for (i = 0; i < ARRAY_SIZE(fw_mdev_device_attrs); i++) {
+ ret = device_create_file(mdev->dev.this_device,
+ &fw_mdev_device_attrs[i]);
+ if (ret)
+ goto err_create_file;
+ }
+
+ return ret;
+
+err_create_file:
+ while (--i >= 0)
+ device_remove_file(mdev->dev.this_device,
+ &fw_mdev_device_attrs[i]);
+
+ fw_mdev_list[mdev->minor] = NULL;
+ wake_lock_destroy(&mdev->wake_lock);
+ mutex_destroy(&mdev->lock);
+ misc_deregister(&mdev->dev);
+ return ret;
+}
+EXPORT_SYMBOL(fw_mdev_register);
+
+void fw_mdev_unregister(struct firmware_miscdevice *mdev)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(fw_mdev_device_attrs); i++) {
+ device_remove_file(mdev->dev.this_device,
+ &fw_mdev_device_attrs[i]);
+ }
+
+ fw_mdev_list[mdev->minor] = NULL;
+ wake_lock_destroy(&mdev->wake_lock);
+ mutex_destroy(&mdev->lock);
+ misc_deregister(&mdev->dev);
+}
+EXPORT_SYMBOL(fw_mdev_unregister);
+
+static int __init fw_mdev_init(void)
+{
+ pr_info("%s: enter\n", __func__);
+ return 0;
+}
+static void __exit fw_mdev_exit(void)
+{
+ pr_info(KERN_INFO "%s: exit\n", __func__);
+}
+
+module_init(fw_mdev_init);
+module_exit(fw_mdev_exit);
+
+MODULE_DESCRIPTION("Hipad Touchscreen Firmware Upgrade");
+MODULE_AUTHOR("Liao Ye<cjok.liao@gmail.com>");
+MODULE_LICENSE("GPL");
diff --git a/drivers/input/touchscreen/mstarTouchPanel/hipad_firmware_upgrade.h b/drivers/input/touchscreen/mstarTouchPanel/hipad_firmware_upgrade.h
new file mode 100644
index 00000000000..fb74584c468
--- /dev/null
+++ b/drivers/input/touchscreen/mstarTouchPanel/hipad_firmware_upgrade.h
@@ -0,0 +1,61 @@
+#ifndef _TS_FIRMWARE_H_
+#define _TS_FIRMWARE_H_
+
+#define FW_MDEV_DEBUG
+#ifdef FW_MDEV_DEBUG
+#define fw_mdev_debug(fmt, arg...) \
+ pr_err(KERN_ERR "[fm_mdev]%s@%d " fmt, __func__, __LINE__, ##arg)
+#define fw_mdev_err(fmt, arg...) \
+ pr_err(KERN_ERR "[fm_mdev]%s@%d " fmt, __func__, __LINE__, ##arg)
+#else
+#define fw_mdev_debug(fmt, arg...) do {} while (0)
+#define fw_mdev_err(fmt, arg...) do {} while (0)
+#endif
+
+#define MDEV_NUMS 32
+
+struct firmware_miscdevice {
+ void *private_data;
+
+ int minor;
+ struct miscdevice dev;
+ const char *name;
+ int fw_count;
+ int fw_size;
+ int is_prepare;
+ struct i2c_client *client;
+
+ struct wake_lock wake_lock;
+ struct mutex lock;
+
+ int (*firmware_upgrade)(struct firmware_miscdevice *mdev,
+ const char __user *fw_buf, int size);
+ int (*get_firmware_id)(struct firmware_miscdevice *mdev,
+ char *buff, size_t size);
+
+ ssize_t (*read_data)(struct firmware_miscdevice *mdev,
+ u8 addr, void *buff, size_t size);
+ ssize_t (*write_data)(struct firmware_miscdevice *mdev,
+ u8 addr, void *buff, size_t size);
+};
+
+int fw_mdev_register(struct firmware_miscdevice *mdev);
+void fw_mdev_unregister(struct firmware_miscdevice *mdev);
+ssize_t fw_mdev_write_data(struct firmware_miscdevice *mdev,
+ u8 addr, void *buff, size_t size);
+ssize_t fw_mdev_read_data(struct firmware_miscdevice *mdev,
+ u8 addr, void *buff, size_t size);
+
+static inline void set_client_to_mdev(struct firmware_miscdevice *mdev,
+ struct i2c_client *client)
+{
+ mdev->client = client;
+}
+
+static inline struct i2c_client *
+ get_client_from_mdev(struct firmware_miscdevice *mdev)
+{
+ return mdev->client;
+}
+
+#endif
diff --git a/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_common.c b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_common.c
new file mode 100644
index 00000000000..8ebd1cf830c
--- /dev/null
+++ b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_common.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2006-2014 MStar Semiconductor, Inc.
+ * All rights reserved.
+
+ * Unless otherwise stipulated in writing, any and all information contained
+ * herein regardless in any format shall remain the sole proprietary of
+ * MStar Semiconductor Inc. and be kept in strict confidence
+ * (??MStar Confidential Information??) by the recipient.
+ * Any unauthorized act including without limitation unauthorized disclosure,
+ * copying, use, reproduction, sale, distribution, modification, disassembling,
+ * reverse engineering and compiling of the contents of MStar Confidential
+ * Information is unlawful and strictly prohibited. MStar hereby reserves the
+ * rights to any and all damages, losses, costs and expenses resulting
+ * therefrom.
+*/
+
+/*
+ *
+ * @file mstar_drv_common.c
+ *
+ * @brief This file defines the interface of touch screen
+ *
+ *
+ */
+
+#include "mstar_drv_common.h"
+
+u32 TOUCH_SCREEN_X_MAX = 0;
+u32 TOUCH_SCREEN_Y_MAX = 0;
+u32 MS_TS_MSG_IC_GPIO_RST = 0;
+u32 MS_TS_MSG_IC_GPIO_INT = 0;
+
+static u32 _gCrc32Table[256];
+
+u32 DrvCommonCrcDoReflect(u32 nRef, s8 nCh)
+{
+ u32 nValue = 0;
+ u32 i = 0;
+
+ for (i = 1; i < (nCh + 1); i++) {
+ if (nRef & 1)
+ nValue |= 1 << (nCh - i);
+ nRef >>= 1;
+ }
+
+ return nValue;
+}
+
+u32 DrvCommonCrcGetValue(u32 nText, u32 nPrevCRC)
+{
+ u32 nCRC = nPrevCRC;
+
+ nCRC = (nCRC >> 8) ^ _gCrc32Table[(nCRC & 0xFF) ^ nText];
+
+ return nCRC;
+}
+
+void DrvCommonCrcInitTable(void)
+{
+ u32 nMagicNumber = 0x04c11db7;
+ u32 i, j;
+
+ for (i = 0; i <= 0xFF; i++) {
+ _gCrc32Table[i] = DrvCommonCrcDoReflect(i, 8) << 24;
+ for (j = 0; j < 8; j++)
+ _gCrc32Table[i] = (_gCrc32Table[i] << 1) ^
+ (_gCrc32Table[i]&(0x80000000L)?nMagicNumber:0);
+
+ _gCrc32Table[i] = DrvCommonCrcDoReflect(_gCrc32Table[i], 32);
+ }
+}
+
+u8 DrvCommonCalculateCheckSum(u8 *pMsg, u32 nLength)
+{
+ s32 nCheckSum = 0;
+ u32 i;
+
+ for (i = 0; i < nLength; i++)
+ nCheckSum += pMsg[i];
+
+ return (u8)((-nCheckSum) & 0xFF);
+}
+
+u32 DrvCommonConvertCharToHexDigit(char *pCh, u32 nLength)
+{
+ u32 nRetVal = 0;
+ u32 i;
+
+ DBG("nLength = %d\n", nLength);
+
+ for (i = 0; i < nLength; i++) {
+ char ch = *pCh++;
+ u32 n = 0;
+ u8 nIsValidDigit = 0;
+
+ if ((i == 0 && ch == '0') || (i == 1 && ch == 'x'))
+ continue;
+
+ if ('0' <= ch && ch <= '9') {
+ n = ch-'0';
+ nIsValidDigit = 1;
+ } else if ('a' <= ch && ch <= 'f') {
+ n = 10 + ch-'a';
+ nIsValidDigit = 1;
+ } else if ('A' <= ch && ch <= 'F') {
+ n = 10 + ch-'A';
+ nIsValidDigit = 1;
+ }
+
+ if (1 == nIsValidDigit)
+ nRetVal = n + nRetVal*16;
+ }
+
+ return nRetVal;
+}
diff --git a/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_common.h b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_common.h
new file mode 100644
index 00000000000..851b3a8aaaa
--- /dev/null
+++ b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_common.h
@@ -0,0 +1,463 @@
+/*
+ * Copyright (c) 2006-2014 MStar Semiconductor, Inc.
+ * All rights reserved.
+
+ * Unless otherwise stipulated in writing, any and all information contained
+ * herein regardless in any format shall remain the sole proprietary of
+ * MStar Semiconductor Inc. and be kept in strict confidence
+ * (??MStar Confidential Information??) by the recipient.
+ * Any unauthorized act including without limitation unauthorized disclosure,
+ * copying, use, reproduction, sale, distribution, modification, disassembling,
+ * reverse engineering and compiling of the contents of MStar Confidential
+ * Information is unlawful and strictly prohibited. MStar hereby reserves the
+ * rights to any and all damages, losses, costs and expenses resulting
+ * therefrom.
+ */
+
+/**
+ *
+ * @file mstar_drv_common.h
+ *
+ * @brief This file defines the interface of touch screen
+ *
+ *
+ */
+
+#ifndef __MSTAR_DRV_COMMON_H__
+#define __MSTAR_DRV_COMMON_H__
+
+/*--------------------------------------------------------------------------*/
+/* INCLUDE FILE */
+/*--------------------------------------------------------------------------*/
+
+#include <linux/i2c.h>
+#include <linux/input.h>
+#include <linux/gpio.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+
+#include <linux/firmware.h>
+#include <linux/platform_device.h>
+
+#include <linux/slab.h>
+#include <linux/regulator/consumer.h>
+#include <linux/module.h>
+#include <linux/pm_runtime.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
+#include <linux/cdev.h>
+#include <linux/wakelock.h>
+#include <linux/miscdevice.h>
+#include <linux/uaccess.h>
+#include <linux/proc_fs.h>
+
+/*--------------------------------------------------------------------------*/
+/* TOUCH DEVICE DRIVER RELEASE VERSION */
+/*--------------------------------------------------------------------------*/
+
+#define DEVICE_DRIVER_RELEASE_VERSION ("2.5.0.0")
+
+
+/*--------------------------------------------------------------------------*/
+/* COMPILE OPTION DEFINITION */
+/*--------------------------------------------------------------------------*/
+
+/*
+ * Note.
+ * The below compile option is used to enable the specific device driver code
+ * handling for distinct touch ic.
+ * Please enable the compile option depends on the touch ic that customer
+ * project are using and disable the others.
+ */
+/*#define CONFIG_ENABLE_CHIP_MSG21XXA */
+#define CONFIG_ENABLE_CHIP_MSG22XX
+/*#define CONFIG_ENABLE_CHIP_MSG26XXM */
+
+/*
+ * Note.
+ * The below compile option is used to enable the specific device driver code
+ * handling to make sure main board can supply power to touch ic for some
+ * specific BB chip of MTK(EX. MT6582)/SPRD(EX. SC7715)/QCOM(EX. MSM8610).
+ * By default, this compile option is disabled.
+ */
+#define CONFIG_ENABLE_REGULATOR_POWER_ON
+
+/*
+ * Note.
+ * The below compile option is used to enable the output log mechanism while
+ * touch device driver is running.
+ * If this compile option is not defined, the function for output log will
+ * be disabled.
+ * By default, this compile option is enabled.
+ */
+/*#define CONFIG_ENABLE_TOUCH_DRIVER_DEBUG */
+
+/*
+ * Note.
+ * The below compile option is used to enable the specific device driver code
+ * handling when touch panel support virtual key(EX. Menu, Home, Back, Search).
+ * If this compile option is not defined, the function for virtual key handling
+ * will be disabled.
+ * By default, this compile option is enabled.
+ */
+#define CONFIG_TP_HAVE_KEY
+
+/*
+ * Note.
+ * Since specific MTK BB chip report virtual key touch by using coordinate
+ * instead of key code, the below compile option is used to enable the code
+ * handling for reporting key with coordinate.
+ * This compile option is used for MTK platform only.
+ * By default, this compile option is disabled.
+ */
+#define CONFIG_ENABLE_REPORT_KEY_WITH_COORDINATE
+#ifdef CONFIG_ENABLE_REPORT_KEY_WITH_COORDINATE
+#define VIRTUAL_KEY
+#endif
+
+/*
+ * Note.
+ * The below compile option is used to enable debug mode data log for firmware.
+ * Please make sure firmware support debug mode data log first, then you can
+ * enable this compile option.
+ * Else, please disbale this compile option.
+ * By default, this compile option is disabled.
+ */
+/*#define CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+
+/*#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+
+/*
+ * Note.
+ * The below compile option is used to enable segment read debug mode finger
+ * touch data for MSG26XXM only.
+ * Since I2C transaction length limitation for some specific MTK BB
+ * chip(EX. MT6589/MT6572/...) or QCOM BB chip, the debug mode finger touch
+ * data of MSG26XXM can not be retrieved by one time I2C read operation.
+ * So we need to retrieve the complete finger touch data by segment read.
+ * By default, this compile option is enabled.
+ */
+#define CONFIG_ENABLE_SEGMENT_READ_FINGER_TOUCH_DATA
+
+#endif /*CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+/*#endif CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+
+/*
+ * Note.
+ * The below compile option is used to enable gesture wakeup.
+ * By default, this compile option is disabled.
+ */
+/*#define CONFIG_ENABLE_GESTURE_WAKEUP */
+
+/*#ifdef CONFIG_ENABLE_GESTURE_WAKEUP */
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+
+/*
+ * Note.
+ * The below compile option is used to enable device driver to support at most
+ * 64 types of gesture wakeup mode.
+ * If the below compile option is not enabled, device driver can only support
+ * at most 16 types of gesture wakeup mode.
+ * By the way, 64 types of gesture wakeup mode is ready for MSG22XX only.
+ * But, 64 types of gesture wakeup mode for MSG21XXA is not supported.
+ * Besides, 64 types of gesture wakeup mode for MSG26XXM is not ready yet.
+ * By default, this compile option is disabled.
+ */
+/*#define CONFIG_SUPPORT_64_TYPES_GESTURE_WAKEUP_MODE */
+
+/*
+ * Note.
+ * The below compile option is used to enable gesture debug mode.
+ * By default, this compile option is disabled.
+ */
+/*#define CONFIG_ENABLE_GESTURE_DEBUG_MODE */
+
+/*
+ * Note.
+ * The below compile option is used to enable gesture trajectory display mode.
+ * By default, this compile option is disabled.
+ */
+/*#define CONFIG_ENABLE_GESTURE_INFORMATION_MODE */
+
+#endif /*CONFIG_ENABLE_GESTURE_WAKEUP */
+/*#endif CONFIG_ENABLE_GESTURE_WAKEUP */
+
+
+/*
+ * Note.
+ * The below compile option is used to enable hipad firmware upgrade detection.
+ * Be careful, hipad firmware upgrade detection is not ready yet.
+ * By default, this compile option is disabled.
+ */
+/* #define CONFIG_HIPAD_FIRMWARE_UPGRADE */
+
+
+
+/*--------------------------------------------------------------------------*/
+/* PREPROCESSOR CONSTANT DEFINITION */
+/*--------------------------------------------------------------------------*/
+
+#define u8 unsigned char
+#define u16 unsigned short
+#define u32 unsigned int
+#define s8 signed char
+#define s16 signed short
+#define s32 signed int
+
+
+#if defined(CONFIG_ENABLE_CHIP_MSG21XXA) || \
+ defined(CONFIG_ENABLE_CHIP_MSG26XXM)
+/*0x62 // for MSG21XX/MSG21XXA/MSG26XXM */
+#define SLAVE_I2C_ID_DBBUS (0xC4>>1)
+#elif defined(CONFIG_ENABLE_CHIP_MSG22XX)
+#define SLAVE_I2C_ID_DBBUS (0xB2>>1) /*0x59 // for MSG22XX */
+#endif
+#define SLAVE_I2C_ID_DWI2C (0x4C>>1) /*0x26 */
+
+
+#define CHIP_TYPE_MSG21XX (0x01) /* EX. MSG2133 */
+/*
+ * EX. MSG2133A/MSG2138A(Besides, use version to distinguish MSG2133A/MSG2138A,
+ * you may refer to _DrvFwCtrlUpdateFirmwareCash())
+ */
+#define CHIP_TYPE_MSG21XXA (0x02)
+#define CHIP_TYPE_MSG26XXM (0x03) /* EX. MSG2633M */
+#define CHIP_TYPE_MSG22XX (0x7A) /* EX. MSG2238/MSG2256 */
+
+#define PACKET_TYPE_TOOTH_PATTERN (0x20)
+#define PACKET_TYPE_GESTURE_WAKEUP (0x50)
+#define PACKET_TYPE_GESTURE_DEBUG (0x51)
+#define PACKET_TYPE_GESTURE_INFORMATION (0x52)
+
+#define TOUCH_SCREEN_X_MIN (0)
+#define TOUCH_SCREEN_Y_MIN (0)
+/*
+ * Note.
+ * Please change the below touch screen resolution according to the touch panel
+ * that you are using.
+ */
+extern u32 TOUCH_SCREEN_X_MAX;
+extern u32 TOUCH_SCREEN_Y_MAX;
+/*
+ * Note.
+ * Please do not change the below setting.
+ */
+#define TPD_WIDTH (2048)
+#define TPD_HEIGHT (2048)
+
+
+#define BIT0 (1<<0)
+#define BIT1 (1<<1)
+#define BIT2 (1<<2)
+#define BIT3 (1<<3)
+#define BIT4 (1<<4)
+#define BIT5 (1<<5)
+#define BIT6 (1<<6)
+#define BIT7 (1<<7)
+#define BIT8 (1<<8)
+#define BIT9 (1<<9)
+#define BIT10 (1<<10)
+#define BIT11 (1<<11)
+#define BIT12 (1<<12)
+#define BIT13 (1<<13)
+#define BIT14 (1<<14)
+#define BIT15 (1<<15)
+
+
+#define MAX_DEBUG_REGISTER_NUM (10)
+/*
+ * 130KB. The size shall be large enough for stored any kind firmware size of
+ * MSG21XXA(33KB)/MSG22XX(48.5KB)/MSG26XXM(40KB)/MSG28XX(130KB).
+ */
+#define MAX_UPDATE_FIRMWARE_BUFFER_SIZE (130)
+/*
+ * Please change the value depends on the I2C transaction limitation for the
+ * platform that you are using.
+ */
+#define MAX_I2C_TRANSACTION_LENGTH_LIMIT (250)
+/* It is a fixed value and shall not be modified. */
+#define MAX_TOUCH_IC_REGISTER_BANK_SIZE (256)
+
+#define PROCFS_AUTHORITY (0666)
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+#define GESTURE_WAKEUP_MODE_DOUBLE_CLICK_FLAG 0x00000001
+#define GESTURE_WAKEUP_MODE_UP_DIRECT_FLAG 0x00000002
+#define GESTURE_WAKEUP_MODE_DOWN_DIRECT_FLAG 0x00000004
+#define GESTURE_WAKEUP_MODE_LEFT_DIRECT_FLAG 0x00000008
+#define GESTURE_WAKEUP_MODE_RIGHT_DIRECT_FLAG 0x00000010
+#define GESTURE_WAKEUP_MODE_m_CHARACTER_FLAG 0x00000020
+#define GESTURE_WAKEUP_MODE_W_CHARACTER_FLAG 0x00000040
+#define GESTURE_WAKEUP_MODE_C_CHARACTER_FLAG 0x00000080
+#define GESTURE_WAKEUP_MODE_e_CHARACTER_FLAG 0x00000100
+#define GESTURE_WAKEUP_MODE_V_CHARACTER_FLAG 0x00000200
+#define GESTURE_WAKEUP_MODE_O_CHARACTER_FLAG 0x00000400
+#define GESTURE_WAKEUP_MODE_S_CHARACTER_FLAG 0x00000800
+#define GESTURE_WAKEUP_MODE_Z_CHARACTER_FLAG 0x00001000
+#define GESTURE_WAKEUP_MODE_RESERVE1_FLAG 0x00002000
+#define GESTURE_WAKEUP_MODE_RESERVE2_FLAG 0x00004000
+#define GESTURE_WAKEUP_MODE_RESERVE3_FLAG 0X00008000
+
+#ifdef CONFIG_SUPPORT_64_TYPES_GESTURE_WAKEUP_MODE
+#define GESTURE_WAKEUP_MODE_RESERVE4_FLAG 0x00010000
+#define GESTURE_WAKEUP_MODE_RESERVE5_FLAG 0x00020000
+#define GESTURE_WAKEUP_MODE_RESERVE6_FLAG 0x00040000
+#define GESTURE_WAKEUP_MODE_RESERVE7_FLAG 0x00080000
+#define GESTURE_WAKEUP_MODE_RESERVE8_FLAG 0x00100000
+#define GESTURE_WAKEUP_MODE_RESERVE9_FLAG 0x00200000
+#define GESTURE_WAKEUP_MODE_RESERVE10_FLAG 0x00400000
+#define GESTURE_WAKEUP_MODE_RESERVE11_FLAG 0x00800000
+#define GESTURE_WAKEUP_MODE_RESERVE12_FLAG 0x01000000
+#define GESTURE_WAKEUP_MODE_RESERVE13_FLAG 0x02000000
+#define GESTURE_WAKEUP_MODE_RESERVE14_FLAG 0x04000000
+#define GESTURE_WAKEUP_MODE_RESERVE15_FLAG 0x08000000
+#define GESTURE_WAKEUP_MODE_RESERVE16_FLAG 0x10000000
+#define GESTURE_WAKEUP_MODE_RESERVE17_FLAG 0x20000000
+#define GESTURE_WAKEUP_MODE_RESERVE18_FLAG 0x40000000
+#define GESTURE_WAKEUP_MODE_RESERVE19_FLAG 0x80000000
+
+#define GESTURE_WAKEUP_MODE_RESERVE20_FLAG 0x00000001
+#define GESTURE_WAKEUP_MODE_RESERVE21_FLAG 0x00000002
+#define GESTURE_WAKEUP_MODE_RESERVE22_FLAG 0x00000004
+#define GESTURE_WAKEUP_MODE_RESERVE23_FLAG 0x00000008
+#define GESTURE_WAKEUP_MODE_RESERVE24_FLAG 0x00000010
+#define GESTURE_WAKEUP_MODE_RESERVE25_FLAG 0x00000020
+#define GESTURE_WAKEUP_MODE_RESERVE26_FLAG 0x00000040
+#define GESTURE_WAKEUP_MODE_RESERVE27_FLAG 0x00000080
+#define GESTURE_WAKEUP_MODE_RESERVE28_FLAG 0x00000100
+#define GESTURE_WAKEUP_MODE_RESERVE29_FLAG 0x00000200
+#define GESTURE_WAKEUP_MODE_RESERVE30_FLAG 0x00000400
+#define GESTURE_WAKEUP_MODE_RESERVE31_FLAG 0x00000800
+#define GESTURE_WAKEUP_MODE_RESERVE32_FLAG 0x00001000
+#define GESTURE_WAKEUP_MODE_RESERVE33_FLAG 0x00002000
+#define GESTURE_WAKEUP_MODE_RESERVE34_FLAG 0x00004000
+#define GESTURE_WAKEUP_MODE_RESERVE35_FLAG 0X00008000
+#define GESTURE_WAKEUP_MODE_RESERVE36_FLAG 0x00010000
+#define GESTURE_WAKEUP_MODE_RESERVE37_FLAG 0x00020000
+#define GESTURE_WAKEUP_MODE_RESERVE38_FLAG 0x00040000
+#define GESTURE_WAKEUP_MODE_RESERVE39_FLAG 0x00080000
+#define GESTURE_WAKEUP_MODE_RESERVE40_FLAG 0x00100000
+#define GESTURE_WAKEUP_MODE_RESERVE41_FLAG 0x00200000
+#define GESTURE_WAKEUP_MODE_RESERVE42_FLAG 0x00400000
+#define GESTURE_WAKEUP_MODE_RESERVE43_FLAG 0x00800000
+#define GESTURE_WAKEUP_MODE_RESERVE44_FLAG 0x01000000
+#define GESTURE_WAKEUP_MODE_RESERVE45_FLAG 0x02000000
+#define GESTURE_WAKEUP_MODE_RESERVE46_FLAG 0x04000000
+#define GESTURE_WAKEUP_MODE_RESERVE47_FLAG 0x08000000
+#define GESTURE_WAKEUP_MODE_RESERVE48_FLAG 0x10000000
+#define GESTURE_WAKEUP_MODE_RESERVE49_FLAG 0x20000000
+#define GESTURE_WAKEUP_MODE_RESERVE50_FLAG 0x40000000
+#define GESTURE_WAKEUP_MODE_RESERVE51_FLAG 0x80000000
+#endif /*CONFIG_SUPPORT_64_TYPES_GESTURE_WAKEUP_MODE */
+
+#define GESTURE_WAKEUP_PACKET_LENGTH (6)
+
+#ifdef CONFIG_ENABLE_GESTURE_DEBUG_MODE
+#define GESTURE_DEBUG_MODE_PACKET_LENGTH (128)
+#endif /*CONFIG_ENABLE_GESTURE_DEBUG_MODE */
+
+#ifdef CONFIG_ENABLE_GESTURE_INFORMATION_MODE
+#define GESTURE_WAKEUP_INFORMATION_PACKET_LENGTH (128)
+#endif /*CONFIG_ENABLE_GESTURE_INFORMATION_MODE */
+
+#endif /*CONFIG_ENABLE_GESTURE_WAKEUP */
+
+
+/*--------------------------------------------------------------------------*/
+/* PREPROCESSOR MACRO DEFINITION */
+/*--------------------------------------------------------------------------*/
+
+#ifdef CONFIG_ENABLE_TOUCH_DRIVER_DEBUG
+#define DBG(fmt, arg...) pr_info(fmt, ##arg)
+#define DBG(fmt, arg...) printk(fmt, ##arg)
+#else
+#define DBG(fmt, arg...)
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* DATA TYPE DEFINITION */
+/*--------------------------------------------------------------------------*/
+
+enum EmemType_e {
+ EMEM_ALL = 0,
+ EMEM_MAIN,
+ EMEM_INFO
+};
+
+enum ItoTestMode_e {
+ ITO_TEST_MODE_OPEN_TEST = 1,
+ ITO_TEST_MODE_SHORT_TEST = 2
+};
+
+enum ItoTestResult_e {
+ ITO_TEST_OK = 0,
+ ITO_TEST_FAIL,
+ ITO_TEST_GET_TP_TYPE_ERROR,
+ ITO_TEST_UNDEFINED_ERROR,
+ ITO_TEST_UNDER_TESTING
+
+};
+
+enum AddressMode_e {
+ ADDRESS_MODE_8BIT = 0,
+ ADDRESS_MODE_16BIT = 1
+};
+
+/*--------------------------------------------------------------------------*/
+/* GLOBAL VARIABLE DEFINITION */
+/*--------------------------------------------------------------------------*/
+
+extern struct i2c_client *g_I2cClient;
+extern u8 g_ChipType;
+
+#ifdef CONFIG_PM_RUNTIME
+extern const struct dev_pm_ops msg_ts_dev_pmops;
+#endif
+
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+extern struct FirmwareInfo_t g_FirmwareInfo;
+extern u8 g_LogModePacket[DEBUG_MODE_PACKET_LENGTH];
+extern u16 g_FirmwareMode;
+extern struct kobject *g_TouchKObj;
+extern struct kset *g_TouchKSet;
+extern u8 g_IsSwitchModeByAPK;
+#endif
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+extern u32 g_GestureWakeupMode[2];
+extern u8 g_GestureWakeupFlag;
+
+#ifdef CONFIG_ENABLE_GESTURE_DEBUG_MODE
+extern u8 g_LogGestureDebug[128];
+extern u8 g_GestureDebugFlag;
+extern u8 g_GestureDebugMode;
+
+extern struct kobject *g_GestureKObj;
+#endif
+#endif
+
+extern struct input_dev *g_InputDevice;
+
+#ifdef CONFIG_ENABLE_ITO_MP_TEST
+#if defined(CONFIG_ENABLE_CHIP_MSG26XXM)
+extern TestScopeInfo_t g_TestScopeInfo;
+#endif /* CONFIG_ENABLE_CHIP_MSG26XXM */
+#endif /* CONFIG_ENABLE_ITO_MP_TEST */
+
+#ifdef CONFIG_ENABLE_ITO_MP_TEST
+static ItoTestMode_e _gItoTestMode;
+#endif /* CONFIG_ENABLE_ITO_MP_TEST */
+
+/*--------------------------------------------------------------------------*/
+/* GLOBAL FUNCTION DECLARATION */
+/*--------------------------------------------------------------------------*/
+
+extern u8 DrvCommonCalculateCheckSum(u8 *pMsg, u32 nLength);
+extern u32 DrvCommonConvertCharToHexDigit(char *pCh, u32 nLength);
+extern u32 DrvCommonCrcDoReflect(u32 nRef, s8 nCh);
+extern u32 DrvCommonCrcGetValue(u32 nText, u32 nPrevCRC);
+extern void DrvCommonCrcInitTable(void);
+
+#endif /* __MSTAR_DRV_COMMON_H__ */
diff --git a/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_ic_fw_porting_layer.c b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_ic_fw_porting_layer.c
new file mode 100644
index 00000000000..175a0b0025d
--- /dev/null
+++ b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_ic_fw_porting_layer.c
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2006-2014 MStar Semiconductor, Inc.
+ * All rights reserved.
+
+ * Unless otherwise stipulated in writing, any and all information contained
+ * herein regardless in any format shall remain the sole proprietary of
+ * MStar Semiconductor Inc. and be kept in strict confidence
+ * (??MStar Confidential Information??) by the recipient.
+ * Any unauthorized act including without limitation unauthorized disclosure,
+ * copying, use, reproduction, sale,
+ * reverse engineering and compiling of the contents of MStar Confidential
+ * Information is unlawful and strictly prohibited. MStar hereby reserves the
+ * rights to any and all damages, losses, costs and expenses resulting
+ * therefrom.
+ */
+
+/**
+ *
+ * @file mstar_drv_ic_fw_porting_layer.c
+ *
+ * @brief This file defines the interface of touch screen
+ *
+ *
+ */
+
+#include "mstar_drv_ic_fw_porting_layer.h"
+
+void DrvIcFwLyrOptimizeCurrentConsumption(void)
+{
+ DrvFwCtrlOptimizeCurrentConsumption();
+}
+
+u8 DrvIcFwLyrGetChipType(void)
+{
+ return DrvFwCtrlGetChipType();
+}
+
+void DrvIcFwLyrGetCustomerFirmwareVersion(u16 *pMajor, u16 *pMinor,
+ u8 **ppVersion)
+{
+ DrvFwCtrlGetCustomerFirmwareVersion(pMajor, pMinor, ppVersion);
+}
+
+void DrvIcFwLyrGetPlatformFirmwareVersion(u8 **ppVersion)
+{
+ DrvFwCtrlGetPlatformFirmwareVersion(ppVersion);
+}
+
+s32 DrvIcFwLyrUpdateFirmware(u8 szFwData[][1024], enum EmemType_e eEmemType)
+{
+ return DrvFwCtrlUpdateFirmware(szFwData, eEmemType);
+}
+
+s32 DrvIcFwLyrUpdateFirmwareBySdCard(const char *pFilePath)
+{
+ return DrvFwCtrlUpdateFirmwareBySdCard(pFilePath);
+}
+
+u32 DrvIcFwLyrIsRegisterFingerTouchInterruptHandler(void)
+{
+ DBG("*** %s() ***\n", __func__);
+ /*
+ * Indicate that it is necessary to register interrupt handler
+ * with GPIO INT pin when firmware is running on IC
+ */
+ return 1;
+}
+
+void DrvIcFwLyrHandleFingerTouch(u8 *pPacket, u16 nLength)
+{
+ DrvFwCtrlHandleFingerTouch();
+}
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+
+void DrvIcFwLyrOpenGestureWakeup(u32 *pWakeupMode)
+{
+ DrvFwCtrlOpenGestureWakeup(pWakeupMode);
+}
+
+void DrvIcFwLyrCloseGestureWakeup(void)
+{
+ DrvFwCtrlCloseGestureWakeup();
+}
+
+#ifdef CONFIG_ENABLE_GESTURE_DEBUG_MODE
+void DrvIcFwLyrOpenGestureDebugMode(u8 nGestureFlag)
+{
+ DrvFwCtrlOpenGestureDebugMode(nGestureFlag);
+}
+void DrvIcFwLyrCloseGestureDebugMode(void)
+{
+
+ DrvFwCtrlCloseGestureDebugMode();
+}
+#endif /* CONFIG_ENABLE_GESTURE_DEBUG_MODE */
+
+#endif /* CONFIG_ENABLE_GESTURE_WAKEUP */
+
+
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+
+#if defined(CONFIG_ENABLE_CHIP_MSG26XXM)
+u16 DrvIcFwLyrGetFirmwareMode(void)
+{
+ return DrvFwCtrlGetFirmwareMode();
+}
+#endif /* CONFIG_ENABLE_CHIP_MSG26XXM */
+
+u16 DrvIcFwLyrChangeFirmwareMode(u16 nMode)
+{
+ return DrvFwCtrlChangeFirmwareMode(nMode);
+}
+
+void DrvIcFwLyrGetFirmwareInfo(struct FirmwareInfo_t *pInfo)
+{
+ DrvFwCtrlGetFirmwareInfo(pInfo);
+}
+
+void DrvIcFwLyrRestoreFirmwareModeToLogDataMode(void)
+{
+ DrvFwCtrlRestoreFirmwareModeToLogDataMode();
+}
+
+#endif /* CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+
+
+#ifdef CONFIG_ENABLE_ITO_MP_TEST
+
+void DrvIcFwLyrCreateMpTestWorkQueue(void)
+{
+ DrvMpTestCreateMpTestWorkQueue();
+}
+
+void DrvIcFwLyrScheduleMpTestWork(ItoTestMode_e eItoTestMode)
+{
+ DrvMpTestScheduleMpTestWork(eItoTestMode);
+}
+
+s32 DrvIcFwLyrGetMpTestResult(void)
+{
+ return DrvMpTestGetTestResult();
+}
+
+void DrvIcFwLyrGetMpTestFailChannel(ItoTestMode_e eItoTestMode,
+ u8 *pFailChannel, u32 *pFailChannelCount)
+{
+ return DrvMpTestGetTestFailChannel(eItoTestMode, pFailChannel,
+ pFailChannelCount);
+}
+
+void DrvIcFwLyrGetMpTestDataLog(ItoTestMode_e eItoTestMode, u8 *pDataLog,
+ u32 *pLength)
+{
+ return DrvMpTestGetTestDataLog(eItoTestMode, pDataLog, pLength);
+}
+
+#if defined(CONFIG_ENABLE_CHIP_MSG26XXM)
+void DrvIcFwLyrGetMpTestScope(TestScopeInfo_t *pInfo)
+{
+ return DrvMpTestGetTestScope(pInfo);
+}
+#endif /* CONFIG_ENABLE_CHIP_MSG26XXM */
+
+#endif /* CONFIG_ENABLE_ITO_MP_TEST */
+
+#ifdef CONFIG_ENABLE_SEGMENT_READ_FINGER_TOUCH_DATA
+
+#if defined(CONFIG_ENABLE_CHIP_MSG26XXM)
+void DrvIcFwLyrGetTouchPacketAddress(u16 *pDataAddress, u16 *pFlagAddress)
+{
+ return DrvFwCtrlGetTouchPacketAddress(pDataAddress, pFlagAddress);
+}
+#endif /* CONFIG_ENABLE_CHIP_MSG26XXM */
+
+#endif /* CONFIG_ENABLE_SEGMENT_READ_FINGER_TOUCH_DATA */
diff --git a/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_ic_fw_porting_layer.h b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_ic_fw_porting_layer.h
new file mode 100644
index 00000000000..e5ed00dd6e1
--- /dev/null
+++ b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_ic_fw_porting_layer.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2006-2014 MStar Semiconductor, Inc.
+ * All rights reserved.
+
+ * Unless otherwise stipulated in writing, any and all information contained
+ * herein regardless in any format shall remain the sole proprietary of
+ * MStar Semiconductor Inc. and be kept in strict confidence
+ * (??MStar Confidential Information??) by the recipient.
+ * Any unauthorized act including without limitation unauthorized disclosure,
+ * copying, use, reproduction, sale, distribution, modification, disassembling,
+ * reverse engineering and compiling of the contents of MStar Confidential
+ * Information is unlawful and strictly prohibited. MStar hereby reserves the
+ * rights to any and all damages, losses, costs and expenses resulting
+ * therefrom.
+*/
+
+/**
+ *
+ * @file mstar_drv_ic_fw_porting_layer.h
+ *
+ * @brief This file defines the interface of touch screen
+ *
+ *
+ */
+
+#ifndef __MSTAR_DRV_IC_FW_PORTING_LAYER_H__
+#define __MSTAR_DRV_IC_FW_PORTING_LAYER_H__
+
+#include "mstar_drv_common.h"
+#if defined(CONFIG_ENABLE_CHIP_MSG26XXM)
+#include "mstar_drv_mutual_fw_control.h"
+#ifdef CONFIG_ENABLE_ITO_MP_TEST
+#include "mstar_drv_mutual_mp_test.h"
+#endif /* CONFIG_ENABLE_ITO_MP_TEST */
+#elif defined(CONFIG_ENABLE_CHIP_MSG21XXA) || \
+ defined(CONFIG_ENABLE_CHIP_MSG22XX)
+#include "mstar_drv_self_fw_control.h"
+#ifdef CONFIG_ENABLE_ITO_MP_TEST
+#include "mstar_drv_self_mp_test.h"
+#endif /* CONFIG_ENABLE_ITO_MP_TEST */
+#endif
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+extern void DrvIcFwLyrOpenGestureWakeup(u32 *pWakeupMode);
+extern void DrvIcFwLyrCloseGestureWakeup(void);
+
+#ifdef CONFIG_ENABLE_GESTURE_DEBUG_MODE
+extern void DrvIcFwLyrOpenGestureDebugMode(u8 nGestureFlag);
+extern void DrvIcFwLyrCloseGestureDebugMode(void);
+#endif /* CONFIG_ENABLE_GESTURE_DEBUG_MODE */
+
+#endif /* CONFIG_ENABLE_GESTURE_WAKEUP */
+
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+extern u16 DrvIcFwLyrChangeFirmwareMode(u16 nMode);
+extern void DrvIcFwLyrGetFirmwareInfo(struct FirmwareInfo_t *pInfo);
+#if defined(CONFIG_ENABLE_CHIP_MSG26XXM)
+extern u16 DrvIcFwLyrGetFirmwareMode(void);
+#endif /* CONFIG_ENABLE_CHIP_MSG26XXM */
+extern void DrvIcFwLyrRestoreFirmwareModeToLogDataMode(void);
+#endif /* CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+
+#ifdef CONFIG_UPDATE_FIRMWARE_BY_SW_ID
+extern void DrvIcFwLyrCheckFirmwareUpdateBySwId(void);
+#endif /* CONFIG_UPDATE_FIRMWARE_BY_SW_ID */
+
+extern void DrvIcFwLyrOptimizeCurrentConsumption(void);
+extern u8 DrvIcFwLyrGetChipType(void);
+extern void DrvIcFwLyrGetCustomerFirmwareVersion(u16 *pMajor, u16 *pMinor,
+ u8 **ppVersion);
+extern void DrvIcFwLyrGetPlatformFirmwareVersion(u8 **ppVersion);
+extern void DrvIcFwLyrHandleFingerTouch(u8 *pPacket, u16 nLength);
+extern u32 DrvIcFwLyrIsRegisterFingerTouchInterruptHandler(void);
+extern s32 DrvIcFwLyrUpdateFirmware(u8 szFwData[][1024],
+ enum EmemType_e eEmemType);
+extern s32 DrvIcFwLyrUpdateFirmwareBySdCard(const char *pFilePath);
+
+#ifdef CONFIG_ENABLE_ITO_MP_TEST
+extern void DrvIcFwLyrCreateMpTestWorkQueue(void);
+extern void DrvIcFwLyrScheduleMpTestWork(ItoTestMode_e eItoTestMode);
+extern void DrvIcFwLyrGetMpTestDataLog(ItoTestMode_e eItoTestMode,
+ u8 *pDataLog, u32 *pLength);
+extern void DrvIcFwLyrGetMpTestFailChannel(ItoTestMode_e eItoTestMode,
+ u8 *pFailChannel, u32 *pFailChannelCount);
+extern s32 DrvIcFwLyrGetMpTestResult(void);
+#if defined(CONFIG_ENABLE_CHIP_MSG26XXM)
+extern void DrvIcFwLyrGetMpTestScope(TestScopeInfo_t *pInfo);
+#endif /* CONFIG_ENABLE_CHIP_MSG26XXM */
+#endif /* CONFIG_ENABLE_ITO_MP_TEST */
+
+#ifdef CONFIG_ENABLE_SEGMENT_READ_FINGER_TOUCH_DATA
+#if defined(CONFIG_ENABLE_CHIP_MSG26XXM)
+extern void DrvIcFwLyrGetTouchPacketAddress(u16 *pDataAddress,
+ u16 *pFlagAddress);
+#endif /* CONFIG_ENABLE_CHIP_MSG26XXM */
+#endif /* CONFIG_ENABLE_SEGMENT_READ_FINGER_TOUCH_DATA */
+
+#endif /* __MSTAR_DRV_IC_FW_PORTING_LAYER_H__ */
diff --git a/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_main.c b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_main.c
new file mode 100644
index 00000000000..f2773403884
--- /dev/null
+++ b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_main.c
@@ -0,0 +1,2122 @@
+/*
+ * Copyright (c) 2006-2014 MStar Semiconductor, Inc.
+ * All rights reserved.
+ *
+ * Unless otherwise stipulated in writing, any and all information contained
+ * herein regardless in any format shall remain the sole proprietary of
+ * MStar Semiconductor Inc. and be kept in strict confidence
+ * (??MStar Confidential Information??) by the recipient.
+ * Any unauthorized act including without limitation unauthorized disclosure,
+ * copying, use, reproduction, sale, distribution, modification, disassembling,
+ * reverse engineering and compiling of the contents of MStar Confidential
+ * Information is unlawful and strictly prohibited. MStar hereby reserves the
+ * rights to any and all damages, losses, costs and expenses resulting
+ * therefrom.
+ */
+
+/**
+ *
+ * @file mstar_drv_main.c
+ *
+ * @brief This file defines the interface of touch screen
+ *
+ *
+ */
+
+#include "mstar_drv_main.h"
+#include "mstar_drv_utility_adaption.h"
+#include "mstar_drv_platform_porting_layer.h"
+#include "mstar_drv_ic_fw_porting_layer.h"
+
+#ifdef CONFIG_HIPAD_FIRMWARE_UPGRADE
+#include "hipad_firmware_upgrade.h"
+#endif
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+#ifdef CONFIG_ENABLE_GESTURE_INFORMATION_MODE
+static u32 _gLogGestureCount;
+static u8 _gLogGestureInforType;
+#endif /* CONFIG_ENABLE_GESTURE_INFORMATION_MODE */
+#endif /* CONFIG_ENABLE_GESTURE_WAKEUP */
+
+static u32 _gIsUpdateComplete;
+static u8 *_gFwVersion; /* customer firmware version */
+
+static u16 _gDebugReg[MAX_DEBUG_REGISTER_NUM] = {0};
+static u16 _gDebugRegValue[MAX_DEBUG_REGISTER_NUM] = {0};
+static u32 _gDebugRegCount;
+static u8 *_gPlatformFwVersion; /* internal use firmware version for MStar */
+
+static struct proc_dir_entry *_gProcClass;
+static struct proc_dir_entry *_gProcMsTouchScreenMsg20xx;
+static struct proc_dir_entry *_gProcDevice;
+
+static const struct file_operations _gProcChipType = {
+ .read = DrvMainProcfsChipTypeRead,
+ .write = DrvMainProcfsChipTypeWrite,
+};
+
+static const struct file_operations _gProcFirmwareData = {
+ .read = DrvMainProcfsFirmwareDataRead,
+ .write = DrvMainProcfsFirmwareDataWrite,
+};
+
+static const struct file_operations _gProcApkFirmwareUpdate = {
+ .read = DrvMainProcfsFirmwareUpdateRead,
+ .write = DrvMainProcfsFirmwareUpdateWrite,
+};
+
+static const struct file_operations _gProcCustomerFirmwareVersion = {
+ .read = DrvMainProcfsCustomerFirmwareVersionRead,
+ .write = DrvMainProcfsCustomerFirmwareVersionWrite,
+};
+
+static const struct file_operations _gProcPlatformFirmwareVersion = {
+ .read = DrvMainProcfsPlatformFirmwareVersionRead,
+ .write = DrvMainProcfsPlatformFirmwareVersionWrite,
+};
+
+static const struct file_operations _gProcDeviceDriverVersion = {
+ .read = DrvMainProcfsDeviceDriverVersionRead,
+ .write = DrvMainProcfsDeviceDriverVersionWrite,
+};
+
+static const struct file_operations _gProcSdCardFirmwareUpdate = {
+ .read = DrvMainProcfsSdCardFirmwareUpdateRead,
+ .write = DrvMainProcfsSdCardFirmwareUpdateWrite,
+};
+
+static const struct file_operations _gProcFirmwareDebug = {
+ .read = DrvMainProcfsFirmwareDebugRead,
+ .write = DrvMainProcfsFirmwareDebugWrite,
+};
+
+static const struct file_operations _gProcFirmwareSetDebugValue = {
+ .read = DrvMainProcfsFirmwareSetDebugValueRead,
+ .write = DrvMainProcfsFirmwareSetDebugValueWrite,
+};
+
+#ifdef CONFIG_ENABLE_ITO_MP_TEST
+static const struct file_operations _gProcMpTest = {
+ .read = DrvMainProcfsMpTestRead,
+ .write = DrvMainProcfsMpTestWrite,
+};
+
+static const struct file_operations _gProcMpTestLog = {
+ .read = DrvMainProcfsMpTestLogRead,
+ .write = DrvMainProcfsMpTestLogWrite,
+};
+
+static const struct file_operations _gProcMpTestFailChannel = {
+ .read = DrvMainProcfsMpTestFailChannelRead,
+ .write = DrvMainProcfsMpTestFailChannelWrite,
+};
+
+static const struct file_operations _gProcMpTestScope = {
+ .read = DrvMainProcfsMpTestScopeRead,
+ .write = DrvMainProcfsMpTestScopeWrite,
+};
+#endif /* CONFIG_ENABLE_ITO_MP_TEST */
+
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+static const struct file_operations _gProcFirmwareMode = {
+ .read = DrvMainProcfsFirmwareModeRead,
+ .write = DrvMainProcfsFirmwareModeWrite,
+};
+
+static const struct file_operations _gProcFirmwareSensor = {
+ .read = DrvMainProcfsFirmwareSensorRead,
+ .write = DrvMainProcfsFirmwareSensorWrite,
+};
+
+static const struct file_operations _gProcFirmwarePacketHeader = {
+ .read = DrvMainProcfsFirmwarePacketHeaderRead,
+ .write = DrvMainProcfsFirmwarePacketHeaderWrite,
+};
+#endif /* CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+static const struct file_operations _gProcGestureWakeupMode = {
+ .read = DrvMainProcfsGestureWakeupModeRead,
+ .write = DrvMainProcfsGestureWakeupModeWrite,
+};
+#ifdef CONFIG_ENABLE_GESTURE_DEBUG_MODE
+static const struct file_operations _gProcGestureDebugMode = {
+ .read = DrvMainProcfsGestureDebugModeRead,
+ .write = DrvMainProcfsGestureDebugModeWrite,
+};
+#endif /* CONFIG_ENABLE_GESTURE_DEBUG_MODE */
+#ifdef CONFIG_ENABLE_GESTURE_INFORMATION_MODE
+static const struct file_operations _gProcGestureInforMode = {
+ .read = DrvMainProcfsGestureInforModeRead,
+ .write = DrvMainProcfsGestureInforModeWrite,
+};
+#endif /* CONFIG_ENABLE_GESTURE_INFORMATION_MODE */
+#endif /* CONFIG_ENABLE_GESTURE_WAKEUP */
+
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+struct kset *g_TouchKSet = NULL;
+struct kobject *g_TouchKObj = NULL;
+
+u8 g_IsSwitchModeByAPK = 0;
+#endif /* CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+
+#ifdef CONFIG_ENABLE_GESTURE_DEBUG_MODE
+struct kset *g_GestureKSet = NULL;
+struct kobject *g_GestureKObj = NULL;
+#endif /* CONFIG_ENABLE_GESTURE_DEBUG_MODE */
+
+#endif /* CONFIG_ENABLE_GESTURE_WAKEUP */
+
+#ifdef CONFIG_ENABLE_SEGMENT_READ_FINGER_TOUCH_DATA
+u16 g_FwPacketDataAddress = 0;
+u16 g_FwPacketFlagAddress = 0;
+u8 g_FwSupportSegment = 0;
+#endif /* CONFIG_ENABLE_SEGMENT_READ_FINGER_TOUCH_DATA */
+
+u8 g_FwData[MAX_UPDATE_FIRMWARE_BUFFER_SIZE][1024];
+u32 g_FwDataCount = 0;
+
+static s32 _DrvMainCreateProcfsDirEntry(void);
+
+ssize_t DrvMainProcfsChipTypeRead(struct file *pFile, char __user *pBuffer,
+ size_t nCount, loff_t *pPos)
+{
+ DBG("*** %s() ***\n", __func__);
+
+ return sprintf(pBuffer, "%d", g_ChipType);
+}
+
+ssize_t DrvMainProcfsChipTypeWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ DBG("*** %s() ***\n", __func__);
+ return nCount;
+}
+
+ssize_t DrvMainProcfsFirmwareDataRead(struct file *pFile, char __user *pBuffer,
+ size_t nCount, loff_t *pPos)
+{
+ DBG("*** %s() g_FwDataCount = %d ***\n", __func__, g_FwDataCount);
+ return g_FwDataCount;
+}
+
+ssize_t DrvMainProcfsFirmwareDataWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ u32 nNum = nCount / 1024;
+ u32 nRemainder = nCount % 1024;
+ u32 i;
+
+ DBG("*** %s() ***\n", __func__);
+
+ if (nNum > 0) {
+ for (i = 0; i < nNum; i++) {
+ memcpy(g_FwData[g_FwDataCount], pBuffer+(i*1024), 1024);
+ g_FwDataCount++;
+ }
+
+ /* Handle special firmware size like MSG22XX(48.5KB) */
+ if (nRemainder > 0) {
+ DBG("nRemainder = %d\n", nRemainder);
+ memcpy(g_FwData[g_FwDataCount], pBuffer+(i*1024),
+ nRemainder);
+ g_FwDataCount++;
+ }
+ } else {/* nCount < 1024 */
+ if (nCount > 0) {
+ memcpy(g_FwData[g_FwDataCount], pBuffer, nCount);
+ g_FwDataCount++;
+ }
+ }
+
+ DBG("*** g_FwDataCount = %d ***\n", g_FwDataCount);
+ if (pBuffer != NULL)
+ DBG("*** buf[0] = %c ***\n", pBuffer[0]);
+
+ return nCount;
+}
+
+ssize_t DrvMainProcfsFirmwareUpdateRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ DBG("*** %s() _gFwVersion = %s ***\n", __func__, _gFwVersion);
+
+ return sprintf(pBuffer, "%s\n", _gFwVersion);
+}
+
+ssize_t DrvMainProcfsFirmwareUpdateWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ DrvPlatformLyrDisableFingerTouchReport();
+
+ DBG("*** %s() g_FwDataCount = %d ***\n", __func__, g_FwDataCount);
+
+ if (0 != DrvIcFwLyrUpdateFirmware(g_FwData, EMEM_ALL)) {
+ _gIsUpdateComplete = 0;
+ DBG("Update FAILED\n");
+ } else {
+ _gIsUpdateComplete = 1;
+ DBG("Update SUCCESS\n");
+ }
+
+ DrvPlatformLyrEnableFingerTouchReport();
+
+ return nCount;
+}
+
+ssize_t DrvMainProcfsCustomerFirmwareVersionRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ DBG("*** %s() _gFwVersion = %s ***\n", __func__, _gFwVersion);
+
+ sprintf(pBuffer, "%s\n", _gFwVersion);
+ return 0;
+}
+
+ssize_t DrvMainProcfsCustomerFirmwareVersionWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ u16 nMajor = 0, nMinor = 0;
+
+ DrvIcFwLyrGetCustomerFirmwareVersion(&nMajor, &nMinor, &_gFwVersion);
+
+ DBG("*** %s() _gFwVersion = %s ***\n", __func__, _gFwVersion);
+
+ return nCount;
+}
+
+ssize_t DrvMainProcfsPlatformFirmwareVersionRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ DBG("*** %s() _gPlatformFwVersion = %s ***\n", __func__,
+ _gPlatformFwVersion);
+
+ return sprintf(pBuffer, "%s\n", _gPlatformFwVersion);
+}
+
+ssize_t DrvMainProcfsPlatformFirmwareVersionWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ DrvIcFwLyrGetPlatformFirmwareVersion(&_gPlatformFwVersion);
+
+ DBG("*** %s() _gPlatformFwVersion = %s ***\n", __func__,
+ _gPlatformFwVersion);
+
+ return nCount;
+}
+
+ssize_t DrvMainProcfsDeviceDriverVersionRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ DBG("*** %s() ***\n", __func__);
+ return sprintf(pBuffer, "%s", DEVICE_DRIVER_RELEASE_VERSION);
+}
+
+ssize_t DrvMainProcfsDeviceDriverVersionWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ DBG("*** %s() ***\n", __func__);
+
+ return nCount;
+}
+
+ssize_t DrvMainProcfsSdCardFirmwareUpdateRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ u16 nMajor = 0, nMinor = 0;
+
+ DrvIcFwLyrGetCustomerFirmwareVersion(&nMajor, &nMinor, &_gFwVersion);
+
+ DBG("*** %s() _gFwVersion = %s ***\n", __func__, _gFwVersion);
+
+ return sprintf(pBuffer, "%s\n", _gFwVersion);
+}
+
+ssize_t DrvMainProcfsSdCardFirmwareUpdateWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ char *pValid = NULL;
+ char *pTmpFilePath = NULL;
+ char szFilePath[100] = {0};
+
+ DBG("*** %s() ***\n", __func__);
+ DBG("pBuffer = %s\n", pBuffer);
+
+ if (pBuffer != NULL) {
+ pValid = strstr(pBuffer, ".bin");
+
+ if (pValid) {
+ pTmpFilePath = strsep((char **)&pBuffer, ".");
+
+ DBG("pTmpFilePath = %s\n", pTmpFilePath);
+
+ strcat(szFilePath, pTmpFilePath);
+ strcat(szFilePath, ".bin");
+
+ DBG("szFilePath = %s\n", szFilePath);
+
+ if (0 != DrvFwCtrlUpdateFirmwareBySdCard(szFilePath))
+ DBG("Update FAILED\n");
+ else
+ DBG("Update SUCCESS\n");
+ } else
+ DBG("The file type of the update firmware bin file",
+ "is not a .bin file.\n");
+ } else
+ DBG("The file path of the update firmware bin file is NULL.\n");
+
+ return nCount;
+}
+
+ssize_t DrvMainProcfsFirmwareDebugRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ u32 i;
+ u8 nBank, nAddr;
+ u16 szRegData[MAX_DEBUG_REGISTER_NUM] = {0};
+ u8 szOut[MAX_DEBUG_REGISTER_NUM*25] = {0}, szValue[10] = {0};
+
+ DBG("*** %s() ***\n", __func__);
+
+ DrvPlatformLyrTouchDeviceResetHw();
+
+ DbBusEnterSerialDebugMode();
+ DbBusStopMCU();
+ DbBusIICUseBus();
+ DbBusIICReshape();
+ mdelay(100);
+
+ for (i = 0; i < _gDebugRegCount; i++)
+ szRegData[i] = RegGet16BitValue(_gDebugReg[i]);
+
+ DbBusIICNotUseBus();
+ DbBusNotStopMCU();
+ DbBusExitSerialDebugMode();
+
+ for (i = 0; i < _gDebugRegCount; i++) {
+ nBank = (_gDebugReg[i] >> 8) & 0xFF;
+ nAddr = _gDebugReg[i] & 0xFF;
+
+ DBG("reg(0x%X,0x%X)=0x%04X\n", nBank, nAddr, szRegData[i]);
+
+ strcat(szOut, "reg(");
+ sprintf(szValue, "0x%X", nBank);
+ strcat(szOut, szValue);
+ strcat(szOut, ",");
+ sprintf(szValue, "0x%X", nAddr);
+ strcat(szOut, szValue);
+ strcat(szOut, ")=");
+ sprintf(szValue, "0x%04X", szRegData[i]);
+ strcat(szOut, szValue);
+ strcat(szOut, "\n");
+ }
+
+ return sprintf(pBuffer, "%s\n", szOut);
+}
+
+ssize_t DrvMainProcfsFirmwareDebugWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ u32 i;
+ char *pCh;
+
+ DBG("*** %s() ***\n", __func__);
+
+ if (pBuffer != NULL) {
+ DBG("*** %s() pBuffer[0] = %c ***\n", __func__, pBuffer[0]);
+ DBG("*** %s() pBuffer[1] = %c ***\n", __func__, pBuffer[1]);
+ DBG("*** %s() pBuffer[2] = %c ***\n", __func__, pBuffer[2]);
+ DBG("*** %s() pBuffer[3] = %c ***\n", __func__, pBuffer[3]);
+ DBG("*** %s() pBuffer[4] = %c ***\n", __func__, pBuffer[4]);
+ DBG("*** %s() pBuffer[5] = %c ***\n", __func__, pBuffer[5]);
+
+ DBG("nCount = %d\n", (int)nCount);
+
+ i = 0;
+ while ((pCh = strsep((char **)&pBuffer, " ,"))
+ && (i < MAX_DEBUG_REGISTER_NUM)) {
+ DBG("pCh = %s\n", pCh);
+
+ _gDebugReg[i] = DrvCommonConvertCharToHexDigit(pCh,
+ strlen(pCh));
+
+ DBG("_gDebugReg[%d] = 0x%04X\n", i, _gDebugReg[i]);
+ i++;
+ }
+ _gDebugRegCount = i;
+
+ DBG("_gDebugRegCount = %d\n", _gDebugRegCount);
+ }
+
+ return nCount;
+}
+
+ssize_t DrvMainProcfsFirmwareSetDebugValueRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ u32 i;
+ u8 nBank, nAddr;
+ u16 szRegData[MAX_DEBUG_REGISTER_NUM] = {0};
+ u8 szOut[MAX_DEBUG_REGISTER_NUM*25] = {0}, szValue[10] = {0};
+
+ DBG("*** %s() ***\n", __func__);
+
+ DrvPlatformLyrTouchDeviceResetHw();
+
+ DbBusEnterSerialDebugMode();
+ DbBusStopMCU();
+ DbBusIICUseBus();
+ DbBusIICReshape();
+ mdelay(100);
+
+ for (i = 0; i < _gDebugRegCount; i++)
+ szRegData[i] = RegGet16BitValue(_gDebugReg[i]);
+
+ DbBusIICNotUseBus();
+ DbBusNotStopMCU();
+ DbBusExitSerialDebugMode();
+
+ for (i = 0; i < _gDebugRegCount; i++) {
+ nBank = (_gDebugReg[i] >> 8) & 0xFF;
+ nAddr = _gDebugReg[i] & 0xFF;
+
+ DBG("reg(0x%X,0x%X)=0x%04X\n", nBank, nAddr, szRegData[i]);
+
+ strcat(szOut, "reg(");
+ sprintf(szValue, "0x%X", nBank);
+ strcat(szOut, szValue);
+ strcat(szOut, ",");
+ sprintf(szValue, "0x%X", nAddr);
+ strcat(szOut, szValue);
+ strcat(szOut, ")=");
+ sprintf(szValue, "0x%04X", szRegData[i]);
+ strcat(szOut, szValue);
+ strcat(szOut, "\n");
+ }
+
+ return sprintf(pBuffer, "%s\n", szOut);
+}
+
+ssize_t DrvMainProcfsFirmwareSetDebugValueWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ u32 i, j, k;
+ char *pCh;
+
+ DBG("*** %s() ***\n", __func__);
+
+ if (pBuffer != NULL) {
+ DBG("*** %s() pBuffer[0] = %c ***\n", __func__, pBuffer[0]);
+ DBG("*** %s() pBuffer[1] = %c ***\n", __func__, pBuffer[1]);
+
+ DBG("nCount = %d\n", (int)nCount);
+
+ i = 0;
+ j = 0;
+ k = 0;
+
+ while ((pCh = strsep((char **)&pBuffer, " ,")) && (i < 2)) {
+ DBG("pCh = %s\n", pCh);
+
+ if ((i%2) == 0) {
+ _gDebugReg[j] =
+ DrvCommonConvertCharToHexDigit(pCh,
+ strlen(pCh));
+ DBG("_gDebugReg[%d] = 0x%04X\n", j,
+ _gDebugReg[j]);
+ j++;
+ } else {
+ _gDebugRegValue[k] =
+ DrvCommonConvertCharToHexDigit(pCh,
+ strlen(pCh));
+ DBG("_gDebugRegValue[%d] = 0x%04X\n",
+ k, _gDebugRegValue[k]);
+ k++;
+ }
+
+ i++;
+ }
+ _gDebugRegCount = j;
+
+ DBG("_gDebugRegCount = %d\n", _gDebugRegCount);
+
+ DrvPlatformLyrTouchDeviceResetHw();
+
+ DbBusEnterSerialDebugMode();
+ DbBusStopMCU();
+ DbBusIICUseBus();
+ DbBusIICReshape();
+ mdelay(100);
+
+ for (i = 0; i < _gDebugRegCount; i++) {
+ RegSet16BitValue(_gDebugReg[i], _gDebugRegValue[i]);
+ DBG("_gDebugReg[%d] = 0x%04X, ",
+ "_gDebugRegValue[%d] = 0x%04X\n",
+ i, _gDebugReg[i],
+ i, _gDebugRegValue[i]);
+ }
+
+ DbBusIICNotUseBus();
+ DbBusNotStopMCU();
+ DbBusExitSerialDebugMode();
+ }
+
+ return nCount;
+}
+
+/*--------------------------------------------------------------------------*/
+
+#ifdef CONFIG_ENABLE_ITO_MP_TEST
+
+ssize_t DrvMainProcfsMpTestRead(struct file *pFile, char __user *pBuffer,
+ size_t nCount, loff_t *pPos)
+{
+ DBG("*** %s() ***\n", __func__);
+ DBG("*** ctp mp test status = %d ***\n", DrvIcFwLyrGetMpTestResult());
+
+ return sprintf(pBuffer, "%d", DrvIcFwLyrGetMpTestResult());
+}
+
+ssize_t DrvMainProcfsMpTestWrite(struct file *pFile, const char __user *pBuffer,
+ size_t nCount, loff_t *pPos)
+{
+ u32 nMode = 0;
+ s32 err;
+
+ DBG("*** %s() ***\n", __func__);
+
+ if (pBuffer != NULL) {
+ err = sscanf(pBuffer, "%x", &nMode);
+ if (0 == err)
+ return -EINVAL;
+
+ DBG("Mp Test Mode = 0x%x\n", nMode);
+
+ if (nMode == ITO_TEST_MODE_OPEN_TEST) {
+ _gItoTestMode = ITO_TEST_MODE_OPEN_TEST;
+ DBG("open test result : %d\n", _DrvMpTestItoOpenTest());
+ } else if (nMode == ITO_TEST_MODE_SHORT_TEST) {
+ _gItoTestMode = ITO_TEST_MODE_SHORT_TEST;
+ DrvIcFwLyrScheduleMpTestWork(ITO_TEST_MODE_SHORT_TEST);
+ } else
+ DBG("*** Undefined MP Test Mode ***\n");
+ }
+
+ return nCount;
+}
+
+ssize_t DrvMainProcfsMpTestLogRead(struct file *pFile, char __user *pBuffer,
+ size_t nCount, loff_t *pPos)
+{
+ u32 nLength = 0;
+
+ DBG("*** %s() ***\n", __func__);
+
+ DrvIcFwLyrGetMpTestDataLog(_gItoTestMode, pBuffer, &nLength);
+
+ return nLength;
+}
+
+ssize_t DrvMainProcfsMpTestLogWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ DBG("*** %s() ***\n", __func__);
+
+ return nCount;
+}
+
+ssize_t DrvMainProcfsMpTestFailChannelRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ u32 nNum = 0;
+
+ DBG("*** %s() ***\n", __func__);
+
+ DrvIcFwLyrGetMpTestFailChannel(_gItoTestMode, pBuffer, &nNum);
+
+ return nNum;
+}
+
+ssize_t DrvMainProcfsMpTestFailChannelWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ DBG("*** %s() ***\n", __func__);
+
+ return nCount;
+}
+
+ssize_t DrvMainProcfsMpTestScopeRead(struct file *pFile, char __user *pBuffer,
+ size_t nCount, loff_t *pPos)
+{
+ DBG("*** %s() ***\n", __func__);
+
+#if defined(CONFIG_ENABLE_CHIP_MSG26XXM)
+ DrvIcFwLyrGetMpTestScope(&g_TestScopeInfo);
+
+ return sprintf(pBuffer, "%d,%d", g_TestScopeInfo.nMx,
+ g_TestScopeInfo.nMy);
+#else
+ return 0;
+#endif /* CONFIG_ENABLE_CHIP_MSG26XXM */
+}
+
+ssize_t DrvMainProcfsMpTestScopeWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ DBG("*** %s() ***\n", __func__);
+
+ return nCount;
+}
+
+#endif /* CONFIG_ENABLE_ITO_MP_TEST */
+
+/*--------------------------------------------------------------------------*/
+#ifdef CONFIG_HIPAD_FIRMWARE_UPGRADE
+#define FW_SIZE (49 * 1024)
+static u8 fw_buf[FW_SIZE];
+int msg_firmware_upgrade(struct firmware_miscdevice *mdev,
+ const char __user *buff, int size)
+{
+ int ret = 0;
+
+ if (mdev->is_prepare) {
+ memset(fw_buf, 0, FW_SIZE);
+ mdev->is_prepare = 0;
+ }
+
+ if (copy_from_user(&fw_buf[mdev->fw_count], buff, size)) {
+ fw_mdev_err("copy_from_user failure\n");
+ return -EFAULT;
+ }
+ mdev->fw_count += size;
+
+ fw_mdev_debug("writen size = %d, fw_count = %d\n",
+ size, mdev->fw_count);
+
+ if (mdev->fw_count != mdev->fw_size)
+ return 0;
+
+ memcpy(g_FwData, fw_buf, mdev->fw_count);
+
+ DrvPlatformLyrDisableFingerTouchReport();
+
+ ret = DrvIcFwLyrUpdateFirmware(g_FwData, EMEM_ALL);
+ if (ret != 0) {
+ _gIsUpdateComplete = 0;
+ g_FwDataCount = 0;
+ pr_info("%s: Update FAILED\n", __func__);
+ } else {
+ _gIsUpdateComplete = 1;
+ g_FwDataCount = 0;
+ pr_info("%s: Update SUCCESS\n", __func__);
+ }
+
+ DrvPlatformLyrEnableFingerTouchReport();
+
+ return ret;
+}
+
+void msg_get_firmware_id(u16 *major, u16 *minor)
+{
+ DrvPlatformLyrDisableFingerTouchReport();
+ DrvIcFwLyrGetCustomerFirmwareVersion(major, minor, &_gFwVersion);
+ DrvPlatformLyrEnableFingerTouchReport();
+}
+#endif
+
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+
+ssize_t DrvMainProcfsFirmwareModeRead(struct file *pFile, char __user *pBuffer,
+ size_t nCount, loff_t *pPos)
+{
+ DBG("*** %s() ***\n", __func__);
+
+#if defined(CONFIG_ENABLE_CHIP_MSG26XXM)
+ DrvPlatformLyrDisableFingerTouchReport();
+
+ g_FirmwareMode = DrvIcFwLyrGetFirmwareMode();
+
+ DrvPlatformLyrEnableFingerTouchReport();
+
+ DBG("%s() firmware mode = 0x%x\n", __func__, g_FirmwareMode);
+
+ return sprintf(pBuffer, "%x", g_FirmwareMode);
+#elif defined(CONFIG_ENABLE_CHIP_MSG21XXA) || \
+ defined(CONFIG_ENABLE_CHIP_MSG22XX)
+ DrvPlatformLyrDisableFingerTouchReport();
+
+ DrvIcFwLyrGetFirmwareInfo(&g_FirmwareInfo);
+ g_FirmwareMode = g_FirmwareInfo.nFirmwareMode;
+
+ DrvPlatformLyrEnableFingerTouchReport();
+
+ DBG("%s() firmware mode = 0x%x, can change firmware mode = %d\n",
+ __func__, g_FirmwareInfo.nFirmwareMode,
+ g_FirmwareInfo.nIsCanChangeFirmwareMode);
+
+ return sprintf(pBuffer, "%x,%d", g_FirmwareInfo.nFirmwareMode,
+ g_FirmwareInfo.nIsCanChangeFirmwareMode);
+#endif
+}
+
+ssize_t DrvMainProcfsFirmwareModeWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ u32 nMode;
+ s32 err;
+
+ DBG("*** %s() ***\n", __func__);
+
+ if (pBuffer != NULL) {
+ err = sscanf(pBuffer, "%x", &nMode);
+ if (0 == err)
+ return -EINVAL;
+
+ DBG("firmware mode = 0x%x\n", nMode);
+
+ g_IsSwitchModeByAPK = 0;
+
+ DrvPlatformLyrDisableFingerTouchReport();
+
+ if (nMode == FIRMWARE_MODE_DEMO_MODE) {
+ /* demo mode */
+ g_FirmwareMode = DrvIcFwLyrChangeFirmwareMode(
+ FIRMWARE_MODE_DEMO_MODE);
+ } else if (nMode == FIRMWARE_MODE_DEBUG_MODE) {
+ /* debug mode */
+ g_FirmwareMode = DrvIcFwLyrChangeFirmwareMode(
+ FIRMWARE_MODE_DEBUG_MODE);
+ g_IsSwitchModeByAPK = 1;
+#if defined(CONFIG_ENABLE_CHIP_MSG21XXA) || defined(CONFIG_ENABLE_CHIP_MSG22XX)
+ } else if (nMode == FIRMWARE_MODE_RAW_DATA_MODE) {
+ /* raw data mode */
+ g_FirmwareMode = DrvIcFwLyrChangeFirmwareMode(
+ FIRMWARE_MODE_RAW_DATA_MODE);
+ g_IsSwitchModeByAPK = 1;
+ }
+#endif /* CONFIG_ENABLE_CHIP_MSG21XXA || CONFIG_ENABLE_CHIP_MSG22XX */
+ } else
+ DBG("*** Undefined Firmware Mode ***\n");
+
+ DrvPlatformLyrEnableFingerTouchReport();
+ }
+
+ DBG("*** g_FirmwareMode = 0x%x ***\n", g_FirmwareMode);
+
+ return nCount;
+}
+
+ssize_t DrvMainProcfsFirmwareSensorRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ DBG("*** %s() ***\n", __func__);
+
+#if defined(CONFIG_ENABLE_CHIP_MSG26XXM)
+ if (g_FirmwareInfo.nLogModePacketHeader == 0xA5 ||
+ g_FirmwareInfo.nLogModePacketHeader == 0xAB)
+ return sprintf(pBuffer, "%d,%d",
+ g_FirmwareInfo.nMx, g_FirmwareInfo.nMy);
+ else if (g_FirmwareInfo.nLogModePacketHeader == 0xA7)
+ return sprintf(pBuffer, "%d,%d,%d,%d",
+ g_FirmwareInfo.nMx,
+ g_FirmwareInfo.nMy,
+ g_FirmwareInfo.nSs,
+ g_FirmwareInfo.nSd);
+ else {
+ DBG("Undefined debug mode packet format : 0x%x\n",
+ g_FirmwareInfo.nLogModePacketHeader);
+ return 0;
+ }
+#elif defined(CONFIG_ENABLE_CHIP_MSG21XXA) || \
+ defined(CONFIG_ENABLE_CHIP_MSG22XX)
+ return sprintf(pBuffer, "%d", g_FirmwareInfo.nLogModePacketLength);
+#endif
+}
+
+ssize_t DrvMainProcfsFirmwareSensorWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ DBG("*** %s() ***\n", __func__);
+ return nCount;
+}
+
+ssize_t DrvMainProcfsFirmwarePacketHeaderRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ DBG("*** %s() ***\n", __func__);
+
+ return sprintf(pBuffer, "%d", g_FirmwareInfo.nLogModePacketHeader);
+}
+
+ssize_t DrvMainProcfsFirmwarePacketHeaderWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ DBG("*** %s() ***\n", __func__);
+ return nCount;
+}
+
+ssize_t DrvMainKObjectPacketShow(struct kobject *pKObj,
+ struct kobj_attribute *pAttr, char *pBuf)
+{
+ u32 i = 0;
+ u32 nLength = 0;
+
+ DBG("*** %s() ***\n", __func__);
+
+ if (strcmp(pAttr->attr.name, "packet") == 0) {
+ if (g_LogModePacket != NULL) {
+ DBG("g_FirmwareMode=%x, g_LogModePacket[0]=%x, ",
+ "g_LogModePacket[1]=%x\n",
+ g_FirmwareMode,
+ g_LogModePacket[0],
+ g_LogModePacket[1]);
+ DBG("g_LogModePacket[2]=%x, g_LogModePacket[3]=%x\n",
+ g_LogModePacket[2],
+ g_LogModePacket[3]);
+ DBG("g_LogModePacket[4]=%x, g_LogModePacket[5]=%x\n",
+ g_LogModePacket[4],
+ g_LogModePacket[5]);
+
+#if defined(CONFIG_ENABLE_CHIP_MSG26XXM)
+ if ((g_FirmwareMode == FIRMWARE_MODE_DEBUG_MODE) &&
+ (g_LogModePacket[0] == 0xA5 ||
+ g_LogModePacket[0] == 0xAB ||
+ g_LogModePacket[0] == 0xA7)) {
+#elif defined(CONFIG_ENABLE_CHIP_MSG21XXA) || \
+ defined(CONFIG_ENABLE_CHIP_MSG22XX)
+ if ((g_FirmwareMode == FIRMWARE_MODE_DEBUG_MODE
+ || g_FirmwareMode ==
+ FIRMWARE_MODE_RAW_DATA_MODE) &&
+ (g_LogModePacket[0] == 0x62)) {
+#endif
+ for (i = 0;
+ i < g_FirmwareInfo.nLogModePacketLength;
+ i++)
+ pBuf[i] = g_LogModePacket[i];
+
+ nLength = g_FirmwareInfo.nLogModePacketLength;
+ DBG("nLength = %d\n", nLength);
+ } else
+ DBG("CURRENT MODE IS NOT DEBUG ",
+ "MODE/WRONG DEBUG MODE HEADER\n");
+ } else
+ DBG("g_LogModePacket is NULL\n");
+ } else {
+ DBG("pAttr->attr.name = %s\n", pAttr->attr.name);
+ }
+
+ return nLength;
+}
+
+ssize_t DrvMainKObjectPacketStore(struct kobject *pKObj,
+ struct kobj_attribute *pAttr, const char *pBuf, size_t nCount)
+{
+ DBG("*** %s() ***\n", __func__);
+ return nCount;
+}
+
+static struct kobj_attribute packet_attr = __ATTR(packet, 0666,
+ DrvMainKObjectPacketShow, DrvMainKObjectPacketStore);
+
+/*
+ * Create a group of attributes so that we can create and
+ * destroy them all at once.
+ */
+static struct attribute *attrs[] = {
+ &packet_attr.attr,
+ NULL, /* need to NULL terminate the list of attributes */
+};
+
+/*
+ * An unnamed attribute group will put all of the attributes directly in
+ * the kobject directory. If we specify a name, a subdirectory will be
+ * created for the attributes with the directory being the name of the
+ * attribute group.
+ */
+struct attribute_group attr_group = {
+ .attrs = attrs,
+};
+#endif /* CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+
+ssize_t DrvMainProcfsGestureWakeupModeRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ DBG("*** %s() ***\n", __func__);
+
+#ifdef CONFIG_SUPPORT_64_TYPES_GESTURE_WAKEUP_MODE
+ DBG("g_GestureWakeupMode = 0x%x, 0x%x\n",
+ g_GestureWakeupMode[0],
+ g_GestureWakeupMode[1]);
+
+ return sprintf(pBuffer, "%x,%x",
+ g_GestureWakeupMode[0],
+ g_GestureWakeupMode[1]);
+#else
+ DBG("g_GestureWakeupMode = 0x%x\n", g_GestureWakeupMode[0]);
+
+ return sprintf(pBuffer, "%x", g_GestureWakeupMode[0]);
+#endif /* CONFIG_SUPPORT_64_TYPES_GESTURE_WAKEUP_MODE */
+}
+
+ssize_t DrvMainProcfsGestureWakeupModeWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ u32 nLength;
+ u32 nWakeupMode[2] = {0};
+ s32 err;
+
+ DBG("*** %s() ***\n", __func__);
+
+ if (pBuffer != NULL) {
+#ifdef CONFIG_SUPPORT_64_TYPES_GESTURE_WAKEUP_MODE
+ u32 i;
+ char *pCh;
+
+ i = 0;
+ while ((pCh = strsep((char **)&pBuffer, " ,")) && (i < 2)) {
+ DBG("pCh = %s\n", pCh);
+
+ nWakeupMode[i] = DrvCommonConvertCharToHexDigit(pCh,
+ strlen(pCh));
+ DBG("nWakeupMode[%d] = 0x%04X\n", i, nWakeupMode[i]);
+ i++;
+ }
+#else
+ err = sscanf(pBuffer, "%x", &nWakeupMode[0]);
+ if (0 == err)
+ return -EINVAL;
+
+ DBG("nWakeupMode = 0x%x\n", nWakeupMode[0]);
+#endif /* CONFIG_SUPPORT_64_TYPES_GESTURE_WAKEUP_MODE */
+
+ nLength = nCount;
+ DBG("nLength = %d\n", nLength);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_DOUBLE_CLICK_FLAG) ==
+ GESTURE_WAKEUP_MODE_DOUBLE_CLICK_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_DOUBLE_CLICK_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_DOUBLE_CLICK_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_UP_DIRECT_FLAG) ==
+ GESTURE_WAKEUP_MODE_UP_DIRECT_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_UP_DIRECT_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_UP_DIRECT_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_DOWN_DIRECT_FLAG) ==
+ GESTURE_WAKEUP_MODE_DOWN_DIRECT_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_DOWN_DIRECT_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_DOWN_DIRECT_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_LEFT_DIRECT_FLAG) ==
+ GESTURE_WAKEUP_MODE_LEFT_DIRECT_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_LEFT_DIRECT_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_LEFT_DIRECT_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_RIGHT_DIRECT_FLAG) ==
+ GESTURE_WAKEUP_MODE_RIGHT_DIRECT_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_RIGHT_DIRECT_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_RIGHT_DIRECT_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_m_CHARACTER_FLAG) ==
+ GESTURE_WAKEUP_MODE_m_CHARACTER_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_m_CHARACTER_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_m_CHARACTER_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_W_CHARACTER_FLAG) ==
+ GESTURE_WAKEUP_MODE_W_CHARACTER_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_W_CHARACTER_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_W_CHARACTER_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_C_CHARACTER_FLAG) ==
+ GESTURE_WAKEUP_MODE_C_CHARACTER_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_C_CHARACTER_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_C_CHARACTER_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_e_CHARACTER_FLAG) ==
+ GESTURE_WAKEUP_MODE_e_CHARACTER_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_e_CHARACTER_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_e_CHARACTER_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_V_CHARACTER_FLAG) ==
+ GESTURE_WAKEUP_MODE_V_CHARACTER_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_V_CHARACTER_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_V_CHARACTER_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_O_CHARACTER_FLAG) ==
+ GESTURE_WAKEUP_MODE_O_CHARACTER_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_O_CHARACTER_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_O_CHARACTER_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_S_CHARACTER_FLAG) ==
+ GESTURE_WAKEUP_MODE_S_CHARACTER_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_S_CHARACTER_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_S_CHARACTER_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_Z_CHARACTER_FLAG) ==
+ GESTURE_WAKEUP_MODE_Z_CHARACTER_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_Z_CHARACTER_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_Z_CHARACTER_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_RESERVE1_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE1_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_RESERVE1_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_RESERVE1_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_RESERVE2_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE2_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_RESERVE2_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_RESERVE2_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_RESERVE3_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE3_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_RESERVE3_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_RESERVE3_FLAG);
+
+#ifdef CONFIG_SUPPORT_64_TYPES_GESTURE_WAKEUP_MODE
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_RESERVE4_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE4_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_RESERVE4_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_RESERVE4_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_RESERVE5_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE5_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_RESERVE5_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_RESERVE5_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_RESERVE6_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE6_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_RESERVE6_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_RESERVE6_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_RESERVE7_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE7_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_RESERVE7_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_RESERVE7_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_RESERVE8_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE8_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_RESERVE8_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_RESERVE8_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_RESERVE9_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE9_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_RESERVE9_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_RESERVE9_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_RESERVE10_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE10_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_RESERVE10_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_RESERVE10_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_RESERVE11_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE11_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_RESERVE11_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_RESERVE11_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_RESERVE12_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE12_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_RESERVE12_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_RESERVE12_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_RESERVE13_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE13_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_RESERVE13_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_RESERVE13_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_RESERVE14_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE14_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_RESERVE14_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_RESERVE14_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_RESERVE15_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE15_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_RESERVE15_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_RESERVE15_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_RESERVE16_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE16_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_RESERVE16_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_RESERVE16_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_RESERVE17_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE17_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_RESERVE17_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_RESERVE17_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_RESERVE18_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE18_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_RESERVE18_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_RESERVE18_FLAG);
+
+ if ((nWakeupMode[0] & GESTURE_WAKEUP_MODE_RESERVE19_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE19_FLAG)
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] |
+ GESTURE_WAKEUP_MODE_RESERVE19_FLAG;
+ else
+ g_GestureWakeupMode[0] = g_GestureWakeupMode[0] &
+ (~GESTURE_WAKEUP_MODE_RESERVE19_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE20_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE20_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE20_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE20_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE21_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE21_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE21_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE21_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE22_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE22_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE22_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE22_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE23_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE23_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE23_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE23_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE24_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE24_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE24_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE24_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE25_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE25_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE25_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE25_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE26_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE26_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE26_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE26_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE27_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE27_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE27_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE27_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE28_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE28_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE28_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE28_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE29_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE29_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE29_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE29_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE30_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE30_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE30_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE30_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE31_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE31_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE31_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE31_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE32_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE32_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE32_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE32_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE33_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE33_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE33_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE33_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE34_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE34_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE34_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE34_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE35_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE35_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE35_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE35_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE36_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE36_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE36_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE36_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE37_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE37_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE37_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE37_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE38_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE38_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE38_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE38_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE39_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE39_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE39_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE39_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE40_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE40_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE40_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE40_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE41_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE41_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE41_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE41_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE42_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE42_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE42_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE42_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE43_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE43_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE43_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE43_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE44_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE44_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE44_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE44_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE45_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE45_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE45_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE45_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE46_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE46_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE46_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE46_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE47_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE47_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE47_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE47_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE48_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE48_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE48_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE48_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE49_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE49_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE49_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE49_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE50_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE50_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE50_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE50_FLAG);
+
+ if ((nWakeupMode[1] & GESTURE_WAKEUP_MODE_RESERVE51_FLAG) ==
+ GESTURE_WAKEUP_MODE_RESERVE51_FLAG)
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] |
+ GESTURE_WAKEUP_MODE_RESERVE51_FLAG;
+ else
+ g_GestureWakeupMode[1] = g_GestureWakeupMode[1] &
+ (~GESTURE_WAKEUP_MODE_RESERVE51_FLAG);
+#endif /* CONFIG_SUPPORT_64_TYPES_GESTURE_WAKEUP_MODE */
+
+ DBG("g_GestureWakeupMode = 0x%x, 0x%x\n",
+ g_GestureWakeupMode[0], g_GestureWakeupMode[1]);
+ }
+
+ return nCount;
+}
+
+#ifdef CONFIG_ENABLE_GESTURE_DEBUG_MODE
+
+ssize_t DrvMainProcfsGestureDebugModeRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos)
+
+{
+ DBG("*** %s() ***\n", __func__);
+
+ return sprintf(pBuffer, "%d", g_GestureDebugMode);
+}
+
+ssize_t DrvMainProcfsGestureDebugModeWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ u8 ucGestureMode[2];
+ u8 i;
+ char *pCh;
+
+ if (pBuffer != NULL) {
+ i = 0;
+ while ((pCh = strsep((char **)&pBuffer, " ,")) && (i < 2)) {
+ DBG("pCh = %s\n", pCh);
+
+ ucGestureMode[i] = DrvCommonConvertCharToHexDigit(pCh,
+ strlen(pCh));
+
+ DBG("ucGestureMode[%d] = 0x%04X\n",
+ i, ucGestureMode[i]);
+ i++;
+ }
+
+ g_GestureDebugMode = ucGestureMode[0];
+ g_GestureDebugFlag = ucGestureMode[1];
+
+ DBG("Gesture flag = 0x%x\n", g_GestureDebugFlag);
+
+ /* open gesture debug mode */
+ if (g_GestureDebugMode == 0x01) {
+ DrvIcFwLyrOpenGestureDebugMode(g_GestureDebugFlag);
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ /* close gesture debug mode */
+ } else if (g_GestureDebugMode == 0x00) {
+ DrvIcFwLyrCloseGestureDebugMode();
+ } else {
+ DBG("*** Undefined Gesture Debug Mode ***\n");
+ }
+ }
+
+ return nCount;
+}
+
+ssize_t DrvMainKObjectGestureDebugShow(struct kobject *pKObj,
+ struct kobj_attribute *pAttr, char *pBuf)
+{
+ u32 i = 0;
+ u32 nLength = 0;
+
+ DBG("*** %s() ***\n", __func__);
+
+ if (strcmp(pAttr->attr.name, "gesture_debug") == 0) {
+ if (g_LogGestureDebug != NULL) {
+ for (i = 0; i < 6; i++) {
+ DBG("g_LogGestureDebug[%d]=%x\n",
+ i, g_LogGestureDebug[i]);
+
+ if (g_LogGestureDebug[0] == 0xA7 &&
+ g_LogGestureDebug[3] == 0x51) {
+ for (i = 0; i < 0x80; i++)
+ pBuf[i] = g_LogGestureDebug[i];
+
+ nLength = 0x80;
+ DBG("nLength = %d\n", nLength);
+ } else
+ DBG("CURRENT MODE IS NOT GESTURE DEBUG ",
+ "MODE/WRONG GESTURE DEBUG MODE HEADER\n");
+ } else
+ DBG("g_LogGestureDebug is NULL\n");
+ } else
+ DBG("pAttr->attr.name = %s\n", pAttr->attr.name);
+
+ return nLength;
+}
+
+ssize_t DrvMainKObjectGestureDebugStore(struct kobject *pKObj,
+ struct kobj_attribute *pAttr, const char *pBuf, size_t nCount)
+{
+ DBG("*** %s() ***\n", __func__);
+ return nCount;
+}
+
+static struct kobj_attribute gesture_attr = __ATTR(gesture_debug, 0666,
+ DrvMainKObjectGestureDebugShow,
+ DrvMainKObjectGestureDebugStore);
+
+/*
+ * Create a group of attributes so that we can
+ * create and destroy them all at once.
+ */
+static struct attribute *gestureattrs[] = {
+ &gesture_attr.attr,
+ NULL, /* need to NULL terminate the list of attributes */
+};
+
+/*
+ * An unnamed attribute group will put all of the attributes directly in
+ * the kobject directory. If we specify a name, a subdirectory will be
+ * created for the attributes with the directory being the name of the
+ * attribute group.
+ */
+struct attribute_group gestureattr_group = {
+ .attrs = gestureattrs,
+};
+#endif /* CONFIG_ENABLE_GESTURE_DEBUG_MODE */
+
+#ifdef CONFIG_ENABLE_GESTURE_INFORMATION_MODE
+
+ssize_t DrvMainProcfsGestureInforModeRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ u8 szOut[GESTURE_WAKEUP_INFORMATION_PACKET_LENGTH*5] = {0},
+ szValue[10] = {0};
+ u32 szLogGestureInfo[GESTURE_WAKEUP_INFORMATION_PACKET_LENGTH] = {0};
+ u32 i = 0;
+
+ DBG("*** %s() ***\n", __func__);
+
+ _gLogGestureCount = 0;
+
+ /* FIRMWARE_GESTURE_INFORMATION_MODE_A */
+ if (_gLogGestureInforType == FIRMWARE_GESTURE_INFORMATION_MODE_A) {
+ for (i = 0; i < 2; i++) {/* 0 EventFlag; 1 RecordNum */
+ szLogGestureInfo[_gLogGestureCount] =
+ g_LogGestureInfor[4 + i];
+ _gLogGestureCount++;
+ }
+
+ /* 2~3 Xst Yst; 4~5 Xend Yend; 6~7 char_width char_height */
+ for (i = 2; i < 8; i++) {
+ szLogGestureInfo[_gLogGestureCount] =
+ g_LogGestureInfor[4 + i];
+ _gLogGestureCount++;
+ }
+ /* FIRMWARE_GESTURE_INFORMATION_MODE_B */
+ } else if (_gLogGestureInforType ==
+ FIRMWARE_GESTURE_INFORMATION_MODE_B) {
+ for (i = 0; i < 2; i++) {/* 0 EventFlag; 1 RecordNum */
+ szLogGestureInfo[_gLogGestureCount] =
+ g_LogGestureInfor[4 + i];
+ _gLogGestureCount++;
+ }
+
+ /* (X and Y)*RecordNum */
+ for (i = 0; i < g_LogGestureInfor[5]*2; i++) {
+ szLogGestureInfo[_gLogGestureCount] =
+ g_LogGestureInfor[12 + i];
+ _gLogGestureCount++;
+ }
+ /* FIRMWARE_GESTURE_INFORMATION_MODE_C */
+ } else if (_gLogGestureInforType ==
+ FIRMWARE_GESTURE_INFORMATION_MODE_C) {
+ for (i = 0; i < 6; i++) {/* header */
+ szLogGestureInfo[_gLogGestureCount] =
+ g_LogGestureInfor[i];
+ _gLogGestureCount++;
+ }
+
+ for (i = 6; i < 86; i++) {
+ szLogGestureInfo[_gLogGestureCount] =
+ g_LogGestureInfor[i];
+ _gLogGestureCount++;
+ }
+
+ /* dummy */
+ szLogGestureInfo[_gLogGestureCount] = g_LogGestureInfor[86];
+ _gLogGestureCount++;
+ /* checksum */
+ szLogGestureInfo[_gLogGestureCount] = g_LogGestureInfor[87];
+ _gLogGestureCount++;
+ } else
+ DBG("*** Undefined GESTURE INFORMATION MODE ***\n");
+
+ for (i = 0; i < _gLogGestureCount; i++) {
+ sprintf(szValue, "%d", szLogGestureInfo[i]);
+ strcat(szOut, szValue);
+ strcat(szOut, ",");
+ }
+
+ return sprintf(pBuffer, "%s\n", szOut);
+}
+
+ssize_t DrvMainProcfsGestureInforModeWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos)
+{
+ u32 nMode;
+ s32 err;
+
+ DBG("*** %s() ***\n", __func__);
+
+ if (pBuffer != NULL) {
+ err = sscanf(pBuffer, "%x", &nMode);
+ if (0 == err)
+ return -EINVAL;
+
+ _gLogGestureInforType = nMode;
+ }
+
+ DBG("*** _gLogGestureInforType type = 0x%x ***\n",
+ _gLogGestureInforType);
+
+ return nCount;
+}
+
+#endif /* CONFIG_ENABLE_GESTURE_INFORMATION_MODE */
+
+#endif /* CONFIG_ENABLE_GESTURE_WAKEUP */
+
+/*--------------------------------------------------------------------------*/
+#ifdef TW_TEST
+static struct class *_twTestClass;
+static struct device *_twTestDev;
+
+ssize_t twTestShow(struct device *twDevice, struct device_attribute *twAttr,
+ char *twBuf)
+{
+ int ret;
+ ret = _DrvMpTestItoOpenTest();
+ DBG("*** %s() ret = %d***\n", __func__, ret);
+
+ return sprintf(twBuf, "%d\n", ret);
+}
+
+static DEVICE_ATTR(twTest, S_IRUGO, twTestShow, NULL);
+#endif
+
+s32 DrvMainTouchDeviceInitialize(void)
+{
+ s32 nRetVal = 0;
+
+ DBG("*** %s() ***\n", __func__);
+
+ _DrvMainCreateProcfsDirEntry(); /* Create procfs directory entry */
+
+#ifdef CONFIG_ENABLE_ITO_MP_TEST
+ DrvIcFwLyrCreateMpTestWorkQueue();
+#ifdef TW_TEST
+
+ _twTestClass = class_create(THIS_MODULE, "mstar-twTest");
+ if (IS_ERR(_twTestClass))
+ DBG("Failed to create class(firmware)!\n");
+
+ _twTestDev = device_create(_twTestClass, NULL, 0, NULL, "msg2238");
+ if (IS_ERR(_twTestDev))
+ DBG("Failed to create device(_twTestDev)!\n");
+
+ if (device_create_file(_twTestDev, &dev_attr_twTest) < 0)
+ DBG("Failed to create device file(%s)!\n",
+ dev_attr_twTest.attr.name);
+
+
+ dev_set_drvdata(_twTestDev, NULL);
+
+#endif
+#endif /* CONFIG_ENABLE_ITO_MP_TEST */
+
+ g_ChipType = CHIP_TYPE_MSG22XX;
+
+ if (g_ChipType != 0) {/* To make sure TP is attached on cell phone. */
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+#if defined(CONFIG_ENABLE_CHIP_MSG26XXM)
+ /* get firmware mode for parsing packet judgement. */
+ g_FirmwareMode = DrvIcFwLyrGetFirmwareMode();
+#endif /* CONFIG_ENABLE_CHIP_MSG26XXM */
+
+ memset(&g_FirmwareInfo, 0x0, sizeof(FirmwareInfo_t));
+
+ DrvIcFwLyrGetFirmwareInfo(&g_FirmwareInfo);
+
+#if defined(CONFIG_ENABLE_CHIP_MSG21XXA) || defined(CONFIG_ENABLE_CHIP_MSG22XX)
+ g_FirmwareMode = g_FirmwareInfo.nFirmwareMode;
+#endif /* CONFIG_ENABLE_CHIP_MSG21XXA || CONFIG_ENABLE_CHIP_MSG22XX */
+#endif /* CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+
+#ifdef CONFIG_ENABLE_SEGMENT_READ_FINGER_TOUCH_DATA
+#if defined(CONFIG_ENABLE_CHIP_MSG26XXM)
+ DrvIcFwLyrGetTouchPacketAddress(&g_FwPacketDataAddress,
+ &g_FwPacketFlagAddress);
+#endif /* CONFIG_ENABLE_CHIP_MSG26XXM */
+#endif /* CONFIG_ENABLE_SEGMENT_READ_FINGER_TOUCH_DATA */
+
+ } else
+ nRetVal = -ENODEV;
+
+ return nRetVal;
+}
+
+/*=============================================================*/
+/* LOCAL FUNCTION DEFINITION */
+/*=============================================================*/
+
+static s32 _DrvMainCreateProcfsDirEntry(void)
+{
+ s32 nRetVal = 0;
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+ u8 *pDevicePath = NULL;
+#endif /* CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+#ifdef CONFIG_ENABLE_GESTURE_DEBUG_MODE
+ u8 *pGesturePath = NULL;
+#endif /* CONFIG_ENABLE_GESTURE_DEBUG_MODE */
+#endif /* CONFIG_ENABLE_GESTURE_WAKEUP */
+
+ DBG("*** %s() ***\n", __func__);
+ _gProcClass = proc_mkdir(PROC_NODE_CLASS, NULL);
+
+ _gProcMsTouchScreenMsg20xx =
+ proc_mkdir(PROC_NODE_MS_TOUCHSCREEN_MSG20XX, _gProcClass);
+
+ _gProcDevice = proc_mkdir(PROC_NODE_DEVICE, _gProcMsTouchScreenMsg20xx);
+
+ if (NULL == proc_create(PROC_NODE_CHIP_TYPE, PROCFS_AUTHORITY,
+ _gProcDevice, &_gProcChipType))
+ DBG("Failed to create procfs file node(%s)!\n",
+ PROC_NODE_CHIP_TYPE);
+ else
+ DBG("Create procfs file node(%s) OK!\n", PROC_NODE_CHIP_TYPE);
+
+ if (NULL == proc_create(PROC_NODE_FIRMWARE_DATA, PROCFS_AUTHORITY,
+ _gProcDevice, &_gProcFirmwareData))
+ DBG("Failed to create procfs file node(%s)!\n",
+ PROC_NODE_FIRMWARE_DATA);
+ else
+ DBG("Create procfs file node(%s) OK!\n",
+ PROC_NODE_FIRMWARE_DATA);
+
+ if (NULL == proc_create(PROC_NODE_FIRMWARE_UPDATE, PROCFS_AUTHORITY,
+ _gProcDevice, &_gProcApkFirmwareUpdate))
+ DBG("Failed to create procfs file node(%s)!\n",
+ PROC_NODE_FIRMWARE_UPDATE);
+ else
+ DBG("Create procfs file node(%s) OK!\n",
+ PROC_NODE_FIRMWARE_UPDATE);
+
+ if (NULL == proc_create(PROC_NODE_CUSTOMER_FIRMWARE_VERSION,
+ PROCFS_AUTHORITY, _gProcDevice,
+ &_gProcCustomerFirmwareVersion))
+ DBG("Failed to create procfs file node(%s)!\n",
+ PROC_NODE_CUSTOMER_FIRMWARE_VERSION);
+ else
+ DBG("Create procfs file node(%s) OK!\n",
+ PROC_NODE_CUSTOMER_FIRMWARE_VERSION);
+
+ if (NULL == proc_create(PROC_NODE_PLATFORM_FIRMWARE_VERSION,
+ PROCFS_AUTHORITY, _gProcDevice,
+ &_gProcPlatformFirmwareVersion))
+ DBG("Failed to create procfs file node(%s)!\n",
+ PROC_NODE_PLATFORM_FIRMWARE_VERSION);
+ else
+ DBG("Create procfs file node(%s) OK!\n",
+ PROC_NODE_PLATFORM_FIRMWARE_VERSION);
+
+ if (NULL == proc_create(PROC_NODE_DEVICE_DRIVER_VERSION,
+ PROCFS_AUTHORITY, _gProcDevice,
+ &_gProcDeviceDriverVersion))
+ DBG("Failed to create procfs file node(%s)!\n",
+ PROC_NODE_DEVICE_DRIVER_VERSION);
+ else
+ DBG("Create procfs file node(%s) OK!\n",
+ PROC_NODE_DEVICE_DRIVER_VERSION);
+
+ if (NULL == proc_create(PROC_NODE_SDCARD_FIRMWARE_UPDATE,
+ PROCFS_AUTHORITY, _gProcDevice,
+ &_gProcSdCardFirmwareUpdate))
+ DBG("Failed to create procfs file node(%s)!\n",
+ PROC_NODE_SDCARD_FIRMWARE_UPDATE);
+ else
+ DBG("Create procfs file node(%s) OK!\n",
+ PROC_NODE_SDCARD_FIRMWARE_UPDATE);
+
+ if (NULL == proc_create(PROC_NODE_FIRMWARE_DEBUG, PROCFS_AUTHORITY,
+ _gProcDevice, &_gProcFirmwareDebug))
+ DBG("Failed to create procfs file node(%s)!\n",
+ PROC_NODE_FIRMWARE_DEBUG);
+ else
+ DBG("Create procfs file node(%s) OK!\n",
+ PROC_NODE_FIRMWARE_DEBUG);
+
+ if (NULL == proc_create(PROC_NODE_FIRMWARE_SET_DEBUG_VALUE,
+ PROCFS_AUTHORITY,
+ _gProcDevice,
+ &_gProcFirmwareSetDebugValue))
+ DBG("Failed to create procfs file node(%s)!\n",
+ PROC_NODE_FIRMWARE_SET_DEBUG_VALUE);
+ else
+ DBG("Create procfs file node(%s) OK!\n",
+ PROC_NODE_FIRMWARE_SET_DEBUG_VALUE);
+
+#ifdef CONFIG_ENABLE_ITO_MP_TEST
+ if (NULL == proc_create(PROC_NODE_MP_TEST, PROCFS_AUTHORITY,
+ _gProcDevice, &_gProcMpTest))
+ DBG("Failed to create procfs file node(%s)!\n",
+ PROC_NODE_MP_TEST);
+ else
+ DBG("Create procfs file node(%s) OK!\n",
+ PROC_NODE_MP_TEST);
+
+ if (NULL == proc_create(PROC_NODE_MP_TEST_LOG,
+ PROCFS_AUTHORITY,
+ _gProcDevice,
+ &_gProcMpTestLog))
+ DBG("Failed to create procfs file node(%s)!\n",
+ PROC_NODE_MP_TEST_LOG);
+ else
+ DBG("Create procfs file node(%s) OK!\n",
+ PROC_NODE_MP_TEST_LOG);
+
+ if (NULL == proc_create(PROC_NODE_MP_TEST_FAIL_CHANNEL,
+ PROCFS_AUTHORITY,
+ _gProcDevice,
+ &_gProcMpTestFailChannel))
+ DBG("Failed to create procfs file node(%s)!\n",
+ PROC_NODE_MP_TEST_FAIL_CHANNEL);
+ else
+ DBG("Create procfs file node(%s) OK!\n",
+ PROC_NODE_MP_TEST_FAIL_CHANNEL);
+
+ if (NULL == proc_create(PROC_NODE_MP_TEST_SCOPE, PROCFS_AUTHORITY,
+ _gProcDevice, &_gProcMpTestScope))
+ DBG("Failed to create procfs file node(%s)!\n",
+ PROC_NODE_MP_TEST_SCOPE);
+ else
+ DBG("Create procfs file node(%s) OK!\n",
+ PROC_NODE_MP_TEST_SCOPE);
+#endif /* CONFIG_ENABLE_ITO_MP_TEST */
+
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+ if (NULL == proc_create(PROC_NODE_FIRMWARE_MODE, PROCFS_AUTHORITY,
+ _gProcDevice, &_gProcFirmwareMode))
+ DBG("Failed to create procfs file node(%s)!\n",
+ PROC_NODE_FIRMWARE_MODE);
+ else
+ DBG("Create procfs file node(%s) OK!\n",
+ PROC_NODE_FIRMWARE_MODE);
+
+ if (NULL == proc_create(PROC_NODE_FIRMWARE_SENSOR, PROCFS_AUTHORITY,
+ _gProcDevice, &_gProcFirmwareSensor))
+ DBG("Failed to create procfs file node(%s)!\n",
+ PROC_NODE_FIRMWARE_SENSOR);
+ else
+ DBG("Create procfs file node(%s) OK!\n",
+ PROC_NODE_FIRMWARE_SENSOR);
+
+ if (NULL == proc_create(PROC_NODE_FIRMWARE_PACKET_HEADER,
+ PROCFS_AUTHORITY,
+ _gProcDevice,
+ &_gProcFirmwarePacketHeader))
+ DBG("Failed to create procfs file node(%s)!\n",
+ PROC_NODE_FIRMWARE_PACKET_HEADER);
+ else
+ DBG("Create procfs file node(%s) OK!\n",
+ PROC_NODE_FIRMWARE_PACKET_HEADER);
+
+ /*
+ * create a kset with the name of "kset_example" which
+ * is located under /sys/kernel/
+ */
+ g_TouchKSet = kset_create_and_add("kset_example", NULL, kernel_kobj);
+ if (!g_TouchKSet) {
+ DBG("*** kset_create_and_add() failed, nRetVal = %d ***\n",
+ nRetVal);
+ nRetVal = -ENOMEM;
+ }
+
+ g_TouchKObj = kobject_create();
+ if (!g_TouchKObj) {
+ DBG("*** kobject_create() failed, nRetVal = %d ***\n", nRetVal);
+
+ nRetVal = -ENOMEM;
+ kset_unregister(g_TouchKSet);
+ g_TouchKSet = NULL;
+ }
+
+ g_TouchKObj->kset = g_TouchKSet;
+
+ nRetVal = kobject_add(g_TouchKObj, NULL, "%s", "kobject_example");
+ if (nRetVal != 0) {
+ DBG("*** kobject_add() failed, nRetVal = %d ***\n", nRetVal);
+
+ kobject_put(g_TouchKObj);
+ g_TouchKObj = NULL;
+ kset_unregister(g_TouchKSet);
+ g_TouchKSet = NULL;
+ }
+
+ /* create the files associated with this kobject */
+ nRetVal = sysfs_create_group(g_TouchKObj, &attr_group);
+ if (nRetVal != 0) {
+ DBG("*** sysfs_create_file() failed, nRetVal = %d ***\n",
+ nRetVal);
+
+ kobject_put(g_TouchKObj);
+ g_TouchKObj = NULL;
+ kset_unregister(g_TouchKSet);
+ g_TouchKSet = NULL;
+ }
+
+ pDevicePath = kobject_get_path(g_TouchKObj, GFP_KERNEL);
+ DBG("DEVPATH = %s\n", pDevicePath);
+#endif /* CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+ if (NULL == proc_create(PROC_NODE_GESTURE_WAKEUP_MODE,
+ PROCFS_AUTHORITY,
+ _gProcDevice,
+ &_gProcGestureWakeupMode))
+ DBG("Failed to create procfs file node(%s)!\n",
+ PROC_NODE_GESTURE_WAKEUP_MODE);
+ else
+ DBG("Create procfs file node(%s) OK!\n",
+ PROC_NODE_GESTURE_WAKEUP_MODE);
+
+#ifdef CONFIG_ENABLE_GESTURE_DEBUG_MODE
+ if (NULL == proc_create(PROC_NODE_GESTURE_DEBUG_MODE, PROCFS_AUTHORITY,
+ _gProcDevice, &_gProcGestureDebugMode))
+ DBG("Failed to create procfs file node(%s)!\n",
+ PROC_NODE_GESTURE_DEBUG_MODE);
+ else
+ DBG("Create procfs file node(%s) OK!\n",
+ PROC_NODE_GESTURE_DEBUG_MODE);
+
+ /*
+ * create a kset with the name of "kset_gesture"
+ * which is located under /sys/kernel/
+ */
+ g_GestureKSet = kset_create_and_add("kset_gesture", NULL, kernel_kobj);
+ if (!g_GestureKSet) {
+ DBG("*** kset_create_and_add() failed, nRetVal = %d ***\n",
+ nRetVal);
+ nRetVal = -ENOMEM;
+ }
+
+ g_GestureKObj = kobject_create();
+ if (!g_GestureKObj) {
+ DBG("*** kobject_create() failed, nRetVal = %d ***\n", nRetVal);
+
+ nRetVal = -ENOMEM;
+ kset_unregister(g_GestureKSet);
+ g_GestureKSet = NULL;
+ }
+
+ g_GestureKObj->kset = g_GestureKSet;
+
+ nRetVal = kobject_add(g_GestureKObj, NULL, "%s", "kobject_gesture");
+ if (nRetVal != 0) {
+ DBG("*** kobject_add() failed, nRetVal = %d ***\n", nRetVal);
+
+ kobject_put(g_GestureKObj);
+ g_GestureKObj = NULL;
+ kset_unregister(g_GestureKSet);
+ g_GestureKSet = NULL;
+ }
+
+ /* create the files associated with this g_GestureKObj */
+ nRetVal = sysfs_create_group(g_GestureKObj, &gestureattr_group);
+ if (nRetVal != 0) {
+ DBG("*** sysfs_create_file() failed, nRetVal = %d ***\n",
+ nRetVal);
+
+ kobject_put(g_GestureKObj);
+ g_GestureKObj = NULL;
+ kset_unregister(g_GestureKSet);
+ g_GestureKSet = NULL;
+ }
+
+ pGesturePath = kobject_get_path(g_GestureKObj, GFP_KERNEL);
+ DBG("DEVPATH = %s\n", pGesturePath);
+#endif /* CONFIG_ENABLE_GESTURE_DEBUG_MODE */
+
+#ifdef CONFIG_ENABLE_GESTURE_INFORMATION_MODE
+ if (NULL == proc_create(PROC_NODE_GESTURE_INFORMATION_MODE,
+ PROCFS_AUTHORITY,
+ _gProcDevice,
+ &_gProcGestureInforMode))
+ DBG("Failed to create procfs file node(%s)!\n",
+ PROC_NODE_GESTURE_INFORMATION_MODE);
+ else
+ DBG("Create procfs file node(%s) OK!\n",
+ PROC_NODE_GESTURE_INFORMATION_MODE);
+#endif /* CONFIG_ENABLE_GESTURE_INFORMATION_MODE */
+#endif /* CONFIG_ENABLE_GESTURE_WAKEUP */
+
+ return nRetVal;
+}
diff --git a/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_main.h b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_main.h
new file mode 100644
index 00000000000..26bbee0fcdf
--- /dev/null
+++ b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_main.h
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2006-2014 MStar Semiconductor, Inc.
+ * All rights reserved.
+
+ * Unless otherwise stipulated in writing, any and all information contained
+ * herein regardless in any format shall remain the sole proprietary of
+ * MStar Semiconductor Inc. and be kept in strict confidence
+ * (??MStar Confidential Information??) by the recipient.
+ * Any unauthorized act including without limitation unauthorized disclosure,
+ * copying, use, reproduction, sale, distribution, modification, disassembling,
+ * reverse engineering and compiling of the contents of MStar Confidential
+ * Information is unlawful and strictly prohibited. MStar hereby reserves the
+ * rights to any and all damages, losses, costs and expenses resulting
+ * therefrom.
+*/
+
+/**
+ *
+ * @file mstar_drv_main.h
+ *
+ * @brief This file defines the interface of touch screen
+ *
+ *
+ */
+
+#ifndef __MSTAR_DRV_MAIN_H__
+#define __MSTAR_DRV_MAIN_H__
+
+/*--------------------------------------------------------------------------*/
+/* INCLUDE FILE */
+/*--------------------------------------------------------------------------*/
+
+#include "mstar_drv_common.h"
+
+/*--------------------------------------------------------------------------*/
+/* PREPROCESSOR CONSTANT DEFINITION */
+/*--------------------------------------------------------------------------*/
+
+#define PROC_NODE_CLASS "class"
+#define PROC_NODE_MS_TOUCHSCREEN_MSG20XX "ms-touchscreen-msg20xx"
+#define PROC_NODE_DEVICE "device"
+#define PROC_NODE_CHIP_TYPE "chip_type"
+#define PROC_NODE_FIRMWARE_DATA "data"
+#define PROC_NODE_FIRMWARE_UPDATE "update"
+#define PROC_NODE_CUSTOMER_FIRMWARE_VERSION "version"
+#define PROC_NODE_PLATFORM_FIRMWARE_VERSION "platform_version"
+#define PROC_NODE_DEVICE_DRIVER_VERSION "driver_version"
+#define PROC_NODE_SDCARD_FIRMWARE_UPDATE "sdcard_update"
+#define PROC_NODE_FIRMWARE_DEBUG "debug"
+#define PROC_NODE_FIRMWARE_SET_DEBUG_VALUE "set_debug_value"
+
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+#define PROC_NODE_FIRMWARE_MODE "mode"
+#define PROC_NODE_FIRMWARE_SENSOR "sensor"
+#define PROC_NODE_FIRMWARE_PACKET_HEADER "header"
+#endif /* CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+#define PROC_NODE_GESTURE_WAKEUP_MODE "gesture_wakeup_mode"
+#ifdef CONFIG_ENABLE_GESTURE_DEBUG_MODE
+#define PROC_NODE_GESTURE_DEBUG_MODE "gesture_debug"
+#endif /* CONFIG_ENABLE_GESTURE_DEBUG_MODE */
+#ifdef CONFIG_ENABLE_GESTURE_INFORMATION_MODE
+#define PROC_NODE_GESTURE_INFORMATION_MODE "gesture_infor"
+#endif /* CONFIG_ENABLE_GESTURE_INFORMATION_MODE */
+#endif /* CONFIG_ENABLE_GESTURE_WAKEUP */
+
+/*--------------------------------------------------------------------------*/
+/* PREPROCESSOR MACRO DEFINITION */
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+/* DATA TYPE DEFINITION */
+/*--------------------------------------------------------------------------*/
+
+/*--------------------------------------------------------------------------*/
+/* GLOBAL FUNCTION DECLARATION */
+/*--------------------------------------------------------------------------*/
+
+extern ssize_t DrvMainProcfsChipTypeRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsChipTypeWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsFirmwareDataRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsFirmwareDataWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsFirmwareUpdateRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsFirmwareUpdateWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsCustomerFirmwareVersionRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsCustomerFirmwareVersionWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsPlatformFirmwareVersionRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsPlatformFirmwareVersionWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsDeviceDriverVersionRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsDeviceDriverVersionWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsSdCardFirmwareUpdateRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsSdCardFirmwareUpdateWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsFirmwareDebugRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsFirmwareDebugWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsFirmwareSetDebugValueRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsFirmwareSetDebugValueWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos);
+
+#ifdef CONFIG_HIPAD_FIRMWARE_UPGRADE
+extern int msg_firmware_upgrade(struct firmware_miscdevice *mdev,
+ const char __user *buff, int size);
+extern void msg_get_firmware_id(u16 *major, u16 *minor);
+#endif /* CONFIG_HIPAD_FIRMWARE_UPGRADE */
+
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+extern ssize_t DrvMainProcfsFirmwareModeRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsFirmwareModeWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsFirmwareSensorRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsFirmwareSensorWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsFirmwarePacketHeaderRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsFirmwarePacketHeaderWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainKObjectPacketShow(struct kobject *pKObj,
+ struct kobj_attribute *pAttr, char *pBuf);
+extern ssize_t DrvMainKObjectPacketStore(struct kobject *pKObj,
+ struct kobj_attribute *pAttr, const char *pBuf, size_t nCount);
+
+#endif /* CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+extern ssize_t DrvMainProcfsGestureWakeupModeRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsGestureWakeupModeWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos);
+
+#ifdef CONFIG_ENABLE_GESTURE_DEBUG_MODE
+extern ssize_t DrvMainProcfsGestureDebugModeRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsGestureDebugModeWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainKObjectGestureDebugShow(struct kobject *pKObj,
+ struct kobj_attribute *pAttr, char *pBuf);
+extern ssize_t DrvMainKObjectGestureDebugStore(struct kobject *pKObj,
+ struct kobj_attribute *pAttr, const char *pBuf, size_t nCount);
+
+#endif /* CONFIG_ENABLE_GESTURE_DEBUG_MODE */
+
+#ifdef CONFIG_ENABLE_GESTURE_INFORMATION_MODE
+extern ssize_t DrvMainProcfsGestureInforModeRead(struct file *pFile,
+ char __user *pBuffer, size_t nCount, loff_t *pPos);
+extern ssize_t DrvMainProcfsGestureInforModeWrite(struct file *pFile,
+ const char __user *pBuffer, size_t nCount, loff_t *pPos);
+
+extern u32 g_LogGestureInfor[GESTURE_WAKEUP_INFORMATION_PACKET_LENGTH];
+
+#endif /* CONFIG_ENABLE_GESTURE_INFORMATION_MODE */
+#endif /* CONFIG_ENABLE_GESTURE_WAKEUP */
+
+extern s32 DrvMainTouchDeviceInitialize(void);
+
+#endif /* __MSTAR_DRV_MAIN_H__ */
diff --git a/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_marvell.c b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_marvell.c
new file mode 100644
index 00000000000..6bbee404e39
--- /dev/null
+++ b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_marvell.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2006-2014 MStar Semiconductor, Inc.
+ * All rights reserved.
+
+ * Unless otherwise stipulated in writing, any and all information contained
+ * herein regardless in any format shall remain the sole proprietary of
+ * MStar Semiconductor Inc. and be kept in strict confidence
+ * (??MStar Confidential Information??) by the recipient.
+ * Any unauthorized act including without limitation unauthorized disclosure,
+ * copying, use, reproduction, sale, distribution, modification, disassembling,
+ * reverse engineering and compiling of the contents of MStar Confidential
+ * Information is unlawful and strictly prohibited. MStar hereby reserves the
+ * rights to any and all damages, losses, costs and expenses resulting
+ * therefrom.
+ */
+
+/**
+ *
+ * @file mstar_drv_marvell.c
+ *
+ * @brief This file defines the interface of touch screen
+ *
+ *
+ */
+
+/*
+ * adair mstar_drv_sprd.c --- mstar_drv_platform_interface.c
+ * --- mstar_drv_platform_porting_layer.c
+ * ---mstar_drv_ic_fw_porting_layer.c
+ * ---mstar_drv_self_fw_control.c
+ */
+
+#include "mstar_drv_platform_interface.h"
+
+
+#define MSG_TP_IC_NAME "msg2xxx"
+/*
+ * "msg21xxA" or "msg22xx" or "msg26xxM"
+ * Please define the mstar touch ic name based on
+ * the mutual-capacitive ic or self capacitive ic
+ * that you are using
+ */
+
+struct i2c_client *g_I2cClient = NULL;
+
+#ifdef CONFIG_ENABLE_REGULATOR_POWER_ON
+struct regulator *g_ReguVdd = NULL;
+#endif /* CONFIG_ENABLE_REGULATOR_POWER_ON */
+
+/* probe function is used for matching and initializing input device */
+static int /*__devinit*/ touch_driver_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+
+ DBG("*** %s ***\n", __func__);
+
+ if (client == NULL) {
+ DBG("i2c client is NULL\n");
+ return -1;
+ }
+ g_I2cClient = client;
+
+#ifdef CONFIG_ENABLE_REGULATOR_POWER_ON
+ g_ReguVdd = regulator_get(&g_I2cClient->dev, "mstar,v_tsp");
+#endif /* CONFIG_ENABLE_REGULATOR_POWER_ON */
+
+ return MsDrvInterfaceTouchDeviceProbe(g_I2cClient, id);
+}
+
+/*
+ * remove function is triggered when the input
+ * device is removed from input sub-system
+ */
+static int /*__devexit*/ touch_driver_remove(struct i2c_client *client)
+{
+ DBG("*** %s ***\n", __func__);
+
+ return MsDrvInterfaceTouchDeviceRemove(client);
+}
+
+/* The I2C device list is used for matching I2C device and I2C device driver. */
+static const struct i2c_device_id touch_device_id[] = {
+ {MSG_TP_IC_NAME, 0}, /* SLAVE_I2C_ID_DWI2C */
+ {}, /* should not omitted */
+};
+
+MODULE_DEVICE_TABLE(i2c, touch_device_id);
+
+#ifdef CONFIG_OF
+static const struct of_device_id msg_dts[] = {
+ { .compatible = "mstar,msg2238", },
+ {},
+};
+MODULE_DEVICE_TABLE(of, msg_dts);
+#endif
+
+static struct i2c_driver touch_device_driver = {
+ .driver = {
+ .name = MSG_TP_IC_NAME,
+ .owner = THIS_MODULE,
+#ifdef CONFIG_OF
+ .of_match_table = of_match_ptr(msg_dts),
+#endif
+#ifdef CONFIG_PM_RUNTIME
+ .pm = &msg_ts_dev_pmops,
+#endif
+ },
+ .probe = touch_driver_probe,
+ .remove = touch_driver_remove,
+ /* .remove = __devexit_p(touch_driver_remove), */
+ .id_table = touch_device_id,
+};
+
+static int __init touch_driver_init(void)
+{
+ int ret;
+
+ /* register driver */
+ ret = i2c_add_driver(&touch_device_driver);
+ if (ret < 0) {
+ DBG("add touch device driver i2c driver failed.\n");
+ return -ENODEV;
+ }
+ DBG("add touch device driver i2c driver.\n");
+
+ return ret;
+}
+
+static void __exit touch_driver_exit(void)
+{
+ DBG("remove touch device driver i2c driver.\n");
+
+ i2c_del_driver(&touch_device_driver);
+}
+
+module_init(touch_driver_init);
+module_exit(touch_driver_exit);
+
+MODULE_AUTHOR("ZiLi.Chen <chenzili@hipad.com>");
+MODULE_DESCRIPTION("Huamobile MSG22XX TouchScreen Driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_platform_interface.c b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_platform_interface.c
new file mode 100644
index 00000000000..282e0fceae9
--- /dev/null
+++ b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_platform_interface.c
@@ -0,0 +1,213 @@
+/*
+ * Copyright (c) 2006-2014 MStar Semiconductor, Inc.
+ * All rights reserved.
+
+ * Unless otherwise stipulated in writing, any and all information contained
+ * herein regardless in any format shall remain the sole proprietary of
+ * MStar Semiconductor Inc. and be kept in strict confidence
+ * (??MStar Confidential Information??) by the recipient.
+ * Any unauthorized act including without limitation unauthorized disclosure,
+ * copying, use, reproduction, sale, distribution, modification, disassembling,
+ * reverse engineering and compiling of the contents of MStar Confidential
+ * Information is unlawful and strictly prohibited. MStar hereby reserves the
+ * rights to any and all damages, losses, costs and expenses resulting
+ * therefrom.
+ */
+
+/**
+ *
+ * @file mstar_drv_platform_interface.c
+ *
+ * @brief This file defines the interface of touch screen
+ *
+ *
+ */
+
+#include "mstar_drv_platform_interface.h"
+#include "mstar_drv_main.h"
+#include "mstar_drv_ic_fw_porting_layer.h"
+#include "mstar_drv_platform_porting_layer.h"
+
+#ifdef CONFIG_HIPAD_FIRMWARE_UPGRADE
+#include "hipad_firmware_upgrade.h"
+#endif
+
+#ifdef CONFIG_PM_RUNTIME
+static u8 bSuspendRuned;
+static int msg_ts_suspend(struct device *dev)
+{
+ DBG("*** %s() ***\n", __func__);
+
+ DBG("suspend bSuspendRuned=%d\n", bSuspendRuned);
+ bSuspendRuned = 1;
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+ if (g_GestureWakeupMode[0] != 0x00000000 ||
+ g_GestureWakeupMode[1] != 0x00000000) {
+ DrvIcFwLyrOpenGestureWakeup(&g_GestureWakeupMode[0]);
+ return 0;
+ }
+#endif /* CONFIG_ENABLE_GESTURE_WAKEUP */
+
+ /* Send touch end for clearing point touch */
+ DrvPlatformLyrFingerTouchReleased(0, 0);
+ input_sync(g_InputDevice);
+
+ DrvPlatformLyrDisableFingerTouchReport();
+ DrvPlatformLyrTouchDevicePowerOff();
+#ifdef CONFIG_ENABLE_REGULATOR_POWER_ON
+ DrvPlatformLyrTouchDeviceRegulatorPowerOff();
+#endif
+ return 0;
+}
+
+static int msg_ts_resume(struct device *dev)
+{
+ DBG("*** %s() ***\n", __func__);
+
+ DBG("resume bSuspendRuned=%d\n", bSuspendRuned);
+ if (bSuspendRuned == 0)
+ return 0;
+ bSuspendRuned = 0;
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+#ifdef CONFIG_ENABLE_GESTURE_DEBUG_MODE
+ if (g_GestureDebugMode == 1)
+ DrvIcFwLyrCloseGestureDebugMode();
+#endif /* CONFIG_ENABLE_GESTURE_DEBUG_MODE */
+
+ if (g_GestureWakeupFlag == 1)
+ DrvIcFwLyrCloseGestureWakeup();
+ else
+ DrvPlatformLyrEnableFingerTouchReport();
+#endif /* CONFIG_ENABLE_GESTURE_WAKEUP */
+#ifdef CONFIG_ENABLE_REGULATOR_POWER_ON
+ DrvPlatformLyrTouchDeviceRegulatorPowerOn();
+#endif
+ DrvPlatformLyrTouchDevicePowerOn();
+
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+ /*
+ * Mark this function call for avoiding device driver
+ * may spend longer time to resume from suspend state.
+ */
+ DrvIcFwLyrRestoreFirmwareModeToLogDataMode();
+#endif /* CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+
+#ifndef CONFIG_ENABLE_GESTURE_WAKEUP
+ DrvPlatformLyrEnableFingerTouchReport();
+#endif /* CONFIG_ENABLE_GESTURE_WAKEUP */
+ return 0;
+}
+
+const struct dev_pm_ops msg_ts_dev_pmops = {
+ SET_RUNTIME_PM_OPS(msg_ts_suspend, msg_ts_resume, NULL)
+};
+#endif
+
+#ifdef CONFIG_HIPAD_FIRMWARE_UPGRADE
+struct firmware_miscdevice mdev;
+static int msg2238_get_firmware_id(struct firmware_miscdevice *mdev,
+ char *buff, size_t size)
+{
+ u16 major = 0, minor = 0;
+
+ msg_get_firmware_id(&major, &minor);
+
+ fw_mdev_debug("msg2238_get_firmware_id: major = %d, minor = %d\n",
+ major, minor);
+
+ return snprintf(buff, size, "%03d.%03d\n", major, minor);
+}
+
+static int msg2238_create_fw_mdev(struct firmware_miscdevice *mdev)
+{
+ int err;
+
+ mdev->name = "HUA-MSG22XX";
+ mdev->dev.name = "HUA-MSG22XX";
+
+ mdev->firmware_upgrade = msg_firmware_upgrade;
+ mdev->get_firmware_id = msg2238_get_firmware_id;
+ mdev->read_data = fw_mdev_read_data;
+ mdev->write_data = fw_mdev_write_data;
+ err = fw_mdev_register(mdev);
+ if (err)
+ fw_mdev_err("fw_mdev_register failre\n");
+
+ set_client_to_mdev(mdev, g_I2cClient);
+
+ return err;
+}
+
+static void msg2238_destroy_fw_mdev(struct firmware_miscdevice *mdev)
+{
+ fw_mdev_unregister(mdev);
+}
+#endif
+
+
+/* probe function is used for matching and initializing input device */
+s32 /*__devinit*/ MsDrvInterfaceTouchDeviceProbe(struct i2c_client *pClient,
+ const struct i2c_device_id *pDeviceId)
+{
+ s32 nRetVal = 0;
+
+ DBG("*** %s() ***\n", __func__);
+
+#ifdef CONFIG_OF
+ DrvPlatformLyrDts(pClient);
+#endif
+
+ DrvPlatformLyrInputDeviceInitialize(pClient);
+
+ DrvPlatformLyrTouchDeviceRequestGPIO();
+
+#ifdef CONFIG_ENABLE_REGULATOR_POWER_ON
+ DrvPlatformLyrTouchDeviceRegulatorPowerOn();
+#endif /* CONFIG_ENABLE_REGULATOR_POWER_ON */
+
+ DrvPlatformLyrTouchDevicePowerOn();
+
+ nRetVal = DrvMainTouchDeviceInitialize();
+ if (nRetVal == -ENODEV) {
+ DrvPlatformLyrTouchDeviceRemove(pClient);
+ return nRetVal;
+ }
+
+ DrvPlatformLyrTouchDeviceRegisterFingerTouchInterruptHandler();
+
+ DrvPlatformLyrTouchDeviceRegisterEarlySuspend();
+
+#ifdef CONFIG_HIPAD_FIRMWARE_UPGRADE
+ nRetVal = msg2238_create_fw_mdev(&mdev);
+ if (nRetVal)
+ fw_mdev_err("msg2238_create_fw_mdev ERROR = %d\n", nRetVal);
+#endif
+
+ DBG("*** MStar touch driver registered ***\n");
+
+ return nRetVal;
+}
+
+/*
+ * remove function is triggered when the input
+ * device is removed from input sub-system
+ */
+s32 /*__devexit*/ MsDrvInterfaceTouchDeviceRemove(struct i2c_client *pClient)
+{
+ DBG("*** %s() ***\n", __func__);
+#ifdef CONFIG_HIPAD_FIRMWARE_UPGRADE
+ msg2238_destroy_fw_mdev(&mdev);
+#endif
+
+ return DrvPlatformLyrTouchDeviceRemove(pClient);
+}
+
+void MsDrvInterfaceTouchDeviceSetIicDataRate(struct i2c_client *pClient,
+ u32 nIicDataRate)
+{
+ DBG("*** %s() ***\n", __func__);
+
+ DrvPlatformLyrSetIicDataRate(pClient, nIicDataRate);
+}
diff --git a/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_platform_interface.h b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_platform_interface.h
new file mode 100644
index 00000000000..310f5331b1f
--- /dev/null
+++ b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_platform_interface.h
@@ -0,0 +1,48 @@
+/*
+ *
+ * Copyright (c) 2006-2014 MStar Semiconductor, Inc.
+ * All rights reserved.
+ *
+ * Unless otherwise stipulated in writing, any and all information contained
+ * herein regardless in any format shall remain the sole proprietary of
+ * MStar Semiconductor Inc. and be kept in strict confidence
+ * (??MStar Confidential Information??) by the recipient.
+ * Any unauthorized act including without limitation unauthorized disclosure,
+ * copying, use, reproduction, sale, distribution, modification, disassembling,
+ * reverse engineering and compiling of the contents of MStar Confidential
+ * Information is unlawful and strictly prohibited. MStar hereby reserves the
+ * rights to any and all damages, losses, costs and expenses resulting
+ * therefrom.
+ */
+
+/**
+ *
+ * @file mstar_drv_platform_interface.h
+ *
+ * @brief This file defines the interface of touch screen
+ *
+ *
+ */
+
+#ifndef __MSTAR_DRV_PLATFORM_INTERFACE_H__
+#define __MSTAR_DRV_PLATFORM_INTERFACE_H__
+
+/*--------------------------------------------------------------------------*/
+/* INCLUDE FILE */
+/*--------------------------------------------------------------------------*/
+
+#include "mstar_drv_common.h"
+
+/*--------------------------------------------------------------------------*/
+/* GLOBAL FUNCTION DECLARATION */
+/*--------------------------------------------------------------------------*/
+
+extern s32 /*__devinit*/ MsDrvInterfaceTouchDeviceProbe(
+ struct i2c_client *pClient,
+ const struct i2c_device_id *pDeviceId);
+extern s32 /*__devexit*/ MsDrvInterfaceTouchDeviceRemove(
+ struct i2c_client *pClient);
+extern void MsDrvInterfaceTouchDeviceSetIicDataRate(
+ struct i2c_client *pClient, u32 nIicDataRate);
+
+#endif /* __MSTAR_DRV_PLATFORM_INTERFACE_H__ */
diff --git a/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_platform_porting_layer.c b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_platform_porting_layer.c
new file mode 100644
index 00000000000..5e5a988a2ab
--- /dev/null
+++ b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_platform_porting_layer.c
@@ -0,0 +1,427 @@
+/*
+ * Copyright (c) 2006-2014 MStar Semiconductor, Inc.
+ * All rights reserved.
+
+ * Unless otherwise stipulated in writing, any and all information contained
+ * herein regardless in any format shall remain the sole proprietary of
+ * MStar Semiconductor Inc. and be kept in strict confidence
+ * (??MStar Confidential Information??) by the recipient.
+ * Any unauthorized act including without limitation unauthorized disclosure,
+ * copying, use, reproduction, sale, distribution, modification, disassembling,
+ * reverse engineering and compiling of the contents of MStar Confidential
+ * Information is unlawful and strictly prohibited. MStar hereby reserves the
+ * rights to any and all damages, losses, costs and expenses resulting
+ * therefrom.
+ */
+
+/**
+ *
+ * @file mstar_drv_platform_porting_layer.c
+ *
+ * @brief This file defines the interface of touch screen
+ *
+ */
+
+#include "mstar_drv_platform_porting_layer.h"
+#include "mstar_drv_ic_fw_porting_layer.h"
+#include "mstar_drv_platform_interface.h"
+
+struct mutex g_Mutex;
+static struct work_struct _gFingerTouchWork;
+
+#ifdef CONFIG_TP_HAVE_KEY
+const int g_TpVirtualKey[] = {
+ TOUCH_KEY_MENU,
+ TOUCH_KEY_HOME,
+ TOUCH_KEY_BACK,
+ TOUCH_KEY_SEARCH
+};
+
+#ifdef CONFIG_ENABLE_REPORT_KEY_WITH_COORDINATE
+#define BUTTON_W (100)
+#define BUTTON_H (100)
+
+const int g_TpVirtualKeyDimLocal[MAX_KEY_NUM][4] = {
+ {80, 1300, 135, 100},
+ {180, 1300, 135, 100},
+ {300, 1300, 135, 100},
+ {420, 1300, 135, 100}
+};
+#ifdef VIRTUAL_KEY
+#define VIRT_KEYS(x...) __stringify(x)
+static ssize_t virtual_keys_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
+{
+ return sprintf(buf,
+ VIRT_KEYS(EV_KEY) ":" VIRT_KEYS(KEY_MENU)
+ ":80:1300:135:100" ":"
+ VIRT_KEYS(EV_KEY) ":" VIRT_KEYS(KEY_BACK)
+ ":300:1300:135:100" ":"
+ VIRT_KEYS(EV_KEY) ":" VIRT_KEYS(KEY_HOMEPAGE)
+ ":180:1300:135:100\n");
+}
+
+static struct kobj_attribute virtual_keys_attr = {
+ .attr = {
+ .name = "virtualkeys.msg2238",
+ .mode = S_IRUGO,
+ },
+ .show = &virtual_keys_show,
+};
+
+static struct attribute *props_attrs[] = {
+ &virtual_keys_attr.attr,
+ NULL
+};
+
+static struct attribute_group props_attr_group = {
+ .attrs = props_attrs,
+};
+
+static int msg_set_virtual_key(struct input_dev *input_dev)
+{
+ struct kobject *props_kobj;
+ int ret = 0;
+
+ props_kobj = kobject_create_and_add("board_properties", NULL);
+ if (props_kobj)
+ ret = sysfs_create_group(props_kobj, &props_attr_group);
+ if (!props_kobj || ret)
+ pr_err("failed to create board_properties\n");
+
+ return 0;
+}
+#endif
+#endif /*CONFIG_ENABLE_REPORT_KEY_WITH_COORDINATE */
+#endif /*CONFIG_TP_HAVE_KEY */
+
+struct input_dev *g_InputDevice = NULL;
+static int _gIrq = -1;
+
+/*
+ * read data through I2C then report data to input
+ * sub-system when interrupt occurred
+ */
+static void _DrvPlatformLyrFingerTouchDoWork(struct work_struct *pWork)
+{
+ DBG("*** %s() ***\n", __func__);
+
+ DrvIcFwLyrHandleFingerTouch(NULL, 0);
+ enable_irq(_gIrq);
+}
+
+/* The interrupt service routine will be triggered when interrupt occurred */
+static irqreturn_t _DrvPlatformLyrFingerTouchInterruptHandler(s32 nIrq,
+ void *pDeviceId)
+{
+ DBG("*** %s() ***\n", __func__);
+
+ disable_irq_nosync(_gIrq);
+ schedule_work(&_gFingerTouchWork);
+
+ return IRQ_HANDLED;
+}
+
+#ifdef CONFIG_ENABLE_REGULATOR_POWER_ON
+void DrvPlatformLyrTouchDeviceRegulatorPowerOn(void)
+{
+ s32 nRetVal = 0;
+
+ DBG("*** %s() ***\n", __func__);
+ /*
+ * For specific SPRD BB chip(ex. SC7715) or QCOM BB chip(ex. MSM8610),
+ * need to enable this function call for correctly power on Touch IC.
+ */
+ nRetVal = regulator_set_voltage(g_ReguVdd, 2800000, 2800000);
+
+ if (nRetVal)
+ DBG("Could not set to 2800mv.\n");
+
+ if (regulator_enable(g_ReguVdd))
+ DBG("Could not regulator_enable.\n");
+
+ mdelay(20);
+}
+
+void DrvPlatformLyrTouchDeviceRegulatorPowerOff(void)
+{
+ DBG("*** %s() ***\n", __func__);
+
+ regulator_disable(g_ReguVdd);
+}
+#endif /*CONFIG_ENABLE_REGULATOR_POWER_ON */
+
+void DrvPlatformLyrTouchDevicePowerOn(void)
+{
+ DBG("*** %s() ***\n", __func__);
+
+ gpio_direction_output(MS_TS_MSG_IC_GPIO_RST, 1);
+ udelay(100);
+ gpio_set_value(MS_TS_MSG_IC_GPIO_RST, 0);
+ mdelay(50);
+ gpio_set_value(MS_TS_MSG_IC_GPIO_RST, 1);
+ mdelay(100);
+}
+
+void DrvPlatformLyrTouchDevicePowerOff(void)
+{
+ DBG("*** %s() ***\n", __func__);
+
+ DrvIcFwLyrOptimizeCurrentConsumption();
+
+ gpio_set_value(MS_TS_MSG_IC_GPIO_RST, 0);
+}
+
+void DrvPlatformLyrTouchDeviceResetHw(void)
+{
+ DBG("*** %s() ***\n", __func__);
+
+ gpio_direction_output(MS_TS_MSG_IC_GPIO_RST, 1);
+ gpio_set_value(MS_TS_MSG_IC_GPIO_RST, 0);
+ mdelay(100);
+ gpio_set_value(MS_TS_MSG_IC_GPIO_RST, 1);
+ mdelay(100);
+}
+
+void DrvPlatformLyrDisableFingerTouchReport(void)
+{
+ DBG("*** %s() ***\n", __func__);
+ disable_irq(_gIrq);
+}
+
+void DrvPlatformLyrEnableFingerTouchReport(void)
+{
+ DBG("*** %s() ***\n", __func__);
+ enable_irq(_gIrq);
+}
+
+void DrvPlatformLyrFingerTouchPressed(s32 nX, s32 nY, s32 nPressure, s32 nId)
+{
+ DBG("*** %s() ***\n", __func__);
+ DBG("point touch pressed\n");
+
+ input_report_key(g_InputDevice, BTN_TOUCH, 1);
+#if defined(CONFIG_ENABLE_CHIP_MSG26XXM)
+ input_report_abs(g_InputDevice, ABS_MT_TRACKING_ID, nId);
+#endif /*CONFIG_ENABLE_CHIP_MSG26XXM */
+ input_report_abs(g_InputDevice, ABS_MT_TOUCH_MAJOR, 1);
+ input_report_abs(g_InputDevice, ABS_MT_WIDTH_MAJOR, 1);
+ input_report_abs(g_InputDevice, ABS_MT_POSITION_X, nX);
+ input_report_abs(g_InputDevice, ABS_MT_POSITION_Y, nY);
+
+ input_mt_sync(g_InputDevice);
+
+}
+
+void DrvPlatformLyrFingerTouchReleased(s32 nX, s32 nY)
+{
+ DBG("*** %s() ***\n", __func__);
+ DBG("point touch released\n");
+
+ input_report_key(g_InputDevice, BTN_TOUCH, 0);
+ input_mt_sync(g_InputDevice);
+
+}
+
+#ifdef CONFIG_OF
+void DrvPlatformLyrDts(struct i2c_client *pClient)
+{
+ struct device_node *np = pClient->dev.of_node;
+
+ of_property_read_u32(np, "mstar,abs-x-max", &TOUCH_SCREEN_X_MAX);
+ of_property_read_u32(np, "mstar,abs-y-max", &TOUCH_SCREEN_Y_MAX);
+ MS_TS_MSG_IC_GPIO_INT = of_get_named_gpio(np, "mstar,irq-gpios", 0);
+ MS_TS_MSG_IC_GPIO_RST = of_get_named_gpio(np, "mstar,reset-gpios", 0);
+}
+#endif
+
+#ifdef CONFIG_ENABLE_PROXIMITY_DETECTION
+
+static ssize_t firmware_psensor_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ DBG("%s\n", __func__);
+ if (g_EnableTpProximity)
+ return sprintf(buf, "on\n");
+ else
+ return sprintf(buf, "off\n");
+}
+
+static ssize_t firmware_psensor_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t size)
+{
+ DBG("%s buf = %s g_EnableTpProximity = %d\n",
+ __func__, buf, g_EnableTpProximity);
+ if (*buf == '0') {
+ in_call = 0;
+ DrvPlatformLyrTpPsEnable(0);
+ } else {
+ in_call = 1;
+ DrvPlatformLyrTpPsEnable(1);
+ }
+
+ return size;
+}
+
+static DEVICE_ATTR(active, 0777, firmware_psensor_show, firmware_psensor_store);
+
+#endif /*CONFIG_ENABLE_PROXIMITY_DETECTION */
+s32 DrvPlatformLyrInputDeviceInitialize(struct i2c_client *pClient)
+{
+ s32 nRetVal = 0;
+
+ DBG("*** %s() ***\n", __func__);
+
+ mutex_init(&g_Mutex);
+
+ /* allocate an input device */
+ g_InputDevice = input_allocate_device();
+ if (g_InputDevice == NULL) {
+ DBG("*** input device allocation failed ***\n");
+ return -ENOMEM;
+ }
+
+ g_InputDevice->name = pClient->name;
+ g_InputDevice->phys = "I2C";
+ g_InputDevice->dev.parent = &pClient->dev;
+ g_InputDevice->id.bustype = BUS_I2C;
+
+ /* set the supported event type for input device */
+ set_bit(EV_ABS, g_InputDevice->evbit);
+ set_bit(EV_SYN, g_InputDevice->evbit);
+ set_bit(EV_KEY, g_InputDevice->evbit);
+ set_bit(BTN_TOUCH, g_InputDevice->keybit);
+ set_bit(INPUT_PROP_DIRECT, g_InputDevice->propbit);
+
+#ifdef CONFIG_TP_HAVE_KEY
+ {
+ u32 i;
+ for (i = 0; i < MAX_KEY_NUM; i++)
+ input_set_capability(g_InputDevice, EV_KEY,
+ g_TpVirtualKey[i]);
+ }
+#endif
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+ input_set_capability(g_InputDevice, EV_KEY, KEY_POWER);
+ input_set_capability(g_InputDevice, EV_KEY, KEY_UP);
+ input_set_capability(g_InputDevice, EV_KEY, KEY_DOWN);
+ input_set_capability(g_InputDevice, EV_KEY, KEY_LEFT);
+ input_set_capability(g_InputDevice, EV_KEY, KEY_RIGHT);
+ input_set_capability(g_InputDevice, EV_KEY, KEY_W);
+ input_set_capability(g_InputDevice, EV_KEY, KEY_Z);
+ input_set_capability(g_InputDevice, EV_KEY, KEY_V);
+ input_set_capability(g_InputDevice, EV_KEY, KEY_O);
+ input_set_capability(g_InputDevice, EV_KEY, KEY_M);
+ input_set_capability(g_InputDevice, EV_KEY, KEY_C);
+ input_set_capability(g_InputDevice, EV_KEY, KEY_E);
+ input_set_capability(g_InputDevice, EV_KEY, KEY_S);
+#endif /*CONFIG_ENABLE_GESTURE_WAKEUP */
+
+#if defined(CONFIG_ENABLE_CHIP_MSG26XXM)
+ input_set_abs_params(g_InputDevice, ABS_MT_TRACKING_ID, 0, 255, 0, 0);
+#endif /*CONFIG_ENABLE_CHIP_MSG26XXM */
+ input_set_abs_params(g_InputDevice, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
+ input_set_abs_params(g_InputDevice, ABS_MT_WIDTH_MAJOR, 0, 15, 0, 0);
+ input_set_abs_params(g_InputDevice, ABS_MT_POSITION_X,
+ TOUCH_SCREEN_X_MIN, TOUCH_SCREEN_X_MAX, 0, 0);
+ input_set_abs_params(g_InputDevice, ABS_MT_POSITION_Y,
+ TOUCH_SCREEN_Y_MIN, TOUCH_SCREEN_Y_MAX, 0, 0);
+
+ /* register the input device to input sub-system */
+ nRetVal = input_register_device(g_InputDevice);
+ if (nRetVal < 0)
+ DBG("*** Unable to register touch input device ***\n");
+#ifdef VIRTUAL_KEY
+ msg_set_virtual_key(NULL);
+#endif
+
+ return nRetVal;
+}
+
+s32 DrvPlatformLyrTouchDeviceRequestGPIO(void)
+{
+ s32 nRetVal = 0;
+
+ DBG("*** %s() ***\n", __func__);
+
+ nRetVal = gpio_request(MS_TS_MSG_IC_GPIO_RST, "ts_rst_pin");
+ if (nRetVal < 0)
+ DBG("*** Failed to request GPIO %d, error %d ***\n",
+ MS_TS_MSG_IC_GPIO_RST, nRetVal);
+
+ nRetVal = gpio_request(MS_TS_MSG_IC_GPIO_INT, "ts_irq_pin");
+
+ if (nRetVal < 0)
+ DBG("*** Failed to request GPIO %d, error %d ***\n",
+ MS_TS_MSG_IC_GPIO_INT, nRetVal);
+
+ return nRetVal;
+}
+
+s32 DrvPlatformLyrTouchDeviceRegisterFingerTouchInterruptHandler(void)
+{
+ s32 nRetVal = 0;
+
+ DBG("*** %s() ***\n", __func__);
+
+ if (DrvIcFwLyrIsRegisterFingerTouchInterruptHandler()) {
+ /* initialize the finger touch work queue */
+ INIT_WORK(&_gFingerTouchWork, _DrvPlatformLyrFingerTouchDoWork);
+
+ _gIrq = gpio_to_irq(MS_TS_MSG_IC_GPIO_INT);
+
+ /* request an irq and register the isr */
+ nRetVal = request_irq(_gIrq /*MS_TS_MSG_IC_GPIO_INT*/,
+ _DrvPlatformLyrFingerTouchInterruptHandler,
+ IRQF_TRIGGER_RISING,
+ /* | IRQF_NO_SUSPEND */
+ /* IRQF_TRIGGER_FALLING */
+ "msg2xxx", NULL);
+
+ if (nRetVal != 0)
+ DBG("*** Unable to claim irq %d; error %d ***\n",
+ MS_TS_MSG_IC_GPIO_INT, nRetVal);
+ }
+
+ return nRetVal;
+}
+
+void DrvPlatformLyrTouchDeviceRegisterEarlySuspend(void)
+{
+ DBG("*** %s() ***\n", __func__);
+
+#ifdef CONFIG_PM_RUNTIME
+ pm_runtime_enable(&g_I2cClient->dev);
+ pm_runtime_forbid(&g_I2cClient->dev);
+#endif
+
+}
+
+/*
+ * remove function is triggered when the input device
+ * is removed from input sub-system
+ */
+s32 DrvPlatformLyrTouchDeviceRemove(struct i2c_client *pClient)
+{
+ DBG("*** %s() ***\n", __func__);
+
+ free_irq(_gIrq, g_InputDevice);
+ gpio_free(MS_TS_MSG_IC_GPIO_INT);
+ gpio_free(MS_TS_MSG_IC_GPIO_RST);
+ input_unregister_device(g_InputDevice);
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+ kset_unregister(g_TouchKSet);
+ kobject_put(g_TouchKObj);
+#endif /*CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+#ifdef CONFIG_PM_RUNTIME
+ pm_runtime_disable(&pClient->dev);
+#endif
+
+ return 0;
+}
+
+void DrvPlatformLyrSetIicDataRate(struct i2c_client *pClient, u32 nIicDataRate)
+{
+ DBG("*** %s() nIicDataRate = %d ***\n", __func__, nIicDataRate);
+}
diff --git a/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_platform_porting_layer.h b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_platform_porting_layer.h
new file mode 100644
index 00000000000..308cd3fe602
--- /dev/null
+++ b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_platform_porting_layer.h
@@ -0,0 +1,93 @@
+/*
+ *
+ * Copyright (c) 2006-2014 MStar Semiconductor, Inc.
+ * All rights reserved.
+ *
+ * Unless otherwise stipulated in writing, any and all information contained
+ * herein regardless in any format shall remain the sole proprietary of
+ * MStar Semiconductor Inc. and be kept in strict confidence
+ * (??MStar Confidential Information??) by the recipient.
+ * Any unauthorized act including without limitation unauthorized disclosure,
+ * copying, use, reproduction, sale, distribution, modification, disassembling,
+ * reverse engineering and compiling of the contents of MStar Confidential
+ * Information is unlawful and strictly prohibited. MStar hereby reserves the
+ * rights to any and all damages, losses, costs and expenses resulting
+ * therefrom.
+ */
+
+/**
+ *
+ * @file mstar_drv_platform_porting_layer.h
+ *
+ * @brief This file defines the interface of touch screen
+ *
+ *
+ */
+
+#ifndef __MSTAR_DRV_PLATFORM_PORTING_LAYER_H__
+#define __MSTAR_DRV_PLATFORM_PORTING_LAYER_H__
+
+/*--------------------------------------------------------------------------*/
+/* INCLUDE FILE */
+/*--------------------------------------------------------------------------*/
+
+#include "mstar_drv_common.h"
+
+/*--------------------------------------------------------------------------*/
+/* PREPROCESSOR CONSTANT DEFINITION */
+/*--------------------------------------------------------------------------*/
+
+/*
+ * Note.
+ * Please change the below GPIO pin setting to follow the platform that you
+ * are using(EX. MediaTek, Spreadtrum, Qualcomm).
+ */
+
+/*
+ * TODO : Please FAE colleague to confirm with customer device driver engineer
+ * about the value of RST and INT GPIO setting
+ */
+/* #define MS_TS_MSG_IC_GPIO_RST GPIO_TOUCH_RESET //53 //35 */
+/* #define MS_TS_MSG_IC_GPIO_INT GPIO_TOUCH_IRQ //52 //37 */
+extern u32 MS_TS_MSG_IC_GPIO_RST;
+extern u32 MS_TS_MSG_IC_GPIO_INT;
+
+#ifdef CONFIG_TP_HAVE_KEY
+#define TOUCH_KEY_MENU (139) /* 229 */
+#define TOUCH_KEY_HOME (172) /* 102 */
+#define TOUCH_KEY_BACK (158)
+#define TOUCH_KEY_SEARCH (217)
+
+#define MAX_KEY_NUM (4)
+#endif /* CONFIG_TP_HAVE_KEY */
+
+/*--------------------------------------------------------------------------*/
+/* GLOBAL FUNCTION DECLARATION */
+/*--------------------------------------------------------------------------*/
+#ifdef CONFIG_OF
+extern void DrvPlatformLyrDts(struct i2c_client *pClient);
+#endif
+extern void DrvPlatformLyrDisableFingerTouchReport(void);
+extern void DrvPlatformLyrEnableFingerTouchReport(void);
+extern void DrvPlatformLyrFingerTouchPressed(s32 nX, s32 nY, s32 nPressure,
+ s32 nId);
+extern void DrvPlatformLyrFingerTouchReleased(s32 nX, s32 nY);
+extern s32 DrvPlatformLyrInputDeviceInitialize(struct i2c_client *pClient);
+extern void DrvPlatformLyrSetIicDataRate(struct i2c_client *pClient,
+ u32 nIicDataRate);
+extern void DrvPlatformLyrTouchDevicePowerOff(void);
+extern void DrvPlatformLyrTouchDevicePowerOn(void);
+#ifdef CONFIG_ENABLE_REGULATOR_POWER_ON
+extern void DrvPlatformLyrTouchDeviceRegulatorPowerOn(void);
+extern void DrvPlatformLyrTouchDeviceRegulatorPowerOff(void);
+
+extern struct regulator *g_ReguVdd;
+
+#endif /* CONFIG_ENABLE_REGULATOR_POWER_ON */
+extern void DrvPlatformLyrTouchDeviceRegisterEarlySuspend(void);
+extern s32 DrvPlatformLyrTouchDeviceRegisterFingerTouchInterruptHandler(void);
+extern s32 DrvPlatformLyrTouchDeviceRemove(struct i2c_client *pClient);
+extern s32 DrvPlatformLyrTouchDeviceRequestGPIO(void);
+extern void DrvPlatformLyrTouchDeviceResetHw(void);
+
+#endif /* __MSTAR_DRV_PLATFORM_PORTING_LAYER_H__ */
diff --git a/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_self_fw_control.c b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_self_fw_control.c
new file mode 100644
index 00000000000..e2d07cc7c7d
--- /dev/null
+++ b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_self_fw_control.c
@@ -0,0 +1,3769 @@
+/*
+ * Copyright (c) 2006-2014 MStar Semiconductor, Inc.
+ * All rights reserved.
+
+ * Unless otherwise stipulated in writing, any and all information contained
+ * herein regardless in any format shall remain the sole proprietary of
+ * MStar Semiconductor Inc. and be kept in strict confidence
+ * (??MStar Confidential Information??) by the recipient.
+ * Any unauthorized act including without limitation unauthorized disclosure,
+ * copying, use, reproduction, sale, distribution, modification, disassembling,
+ * reverse engineering and compiling of the contents of MStar Confidential
+ * Information is unlawful and strictly prohibited. MStar hereby reserves the
+ * rights to any and all damages, losses, costs and expenses resulting
+ * therefrom.
+ */
+
+/**
+ *
+ * @file mstar_drv_self_fw_control.c
+ *
+ * @brief This file defines the interface of touch screen
+ *
+ *
+ */
+
+#include "mstar_drv_self_fw_control.h"
+#include "mstar_drv_utility_adaption.h"
+#include "mstar_drv_platform_porting_layer.h"
+
+#if defined(CONFIG_ENABLE_CHIP_MSG21XXA) || defined(CONFIG_ENABLE_CHIP_MSG22XX)
+
+static u8 _gTpVendorCode[3] = {0};
+
+static u8 _gDwIicInfoData[1024];
+/* used for MSG22XX */
+static u8 _gOneDimenFwData[MSG22XX_FIRMWARE_MAIN_BLOCK_SIZE * 1024 +
+ MSG22XX_FIRMWARE_INFO_BLOCK_SIZE] = {0};
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+static u32 _gGestureWakeupValue[2] = {0};
+#endif /* CONFIG_ENABLE_GESTURE_WAKEUP */
+
+u8 _gIsDisableFinagerTouch = 0;
+
+u8 g_ChipType = 0;
+u8 g_DemoModePacket[DEMO_MODE_PACKET_LENGTH] = {0};
+
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+struct FirmwareInfo_t g_FirmwareInfo;
+
+u8 g_LogModePacket[DEBUG_MODE_PACKET_LENGTH] = {0};
+u16 g_FirmwareMode = FIRMWARE_MODE_DEMO_MODE;
+#endif /* CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+
+#if defined(CONFIG_ENABLE_GESTURE_DEBUG_MODE)
+u8 _gGestureWakeupPacket[GESTURE_DEBUG_MODE_PACKET_LENGTH] = {0};
+#elif defined(CONFIG_ENABLE_GESTURE_INFORMATION_MODE)
+u8 _gGestureWakeupPacket[GESTURE_WAKEUP_INFORMATION_PACKET_LENGTH] = {0};
+#else
+#if defined(CONFIG_ENABLE_CHIP_MSG21XXA)
+u8 _gGestureWakeupPacket[DEMO_MODE_PACKET_LENGTH] = {0};
+#elif defined(CONFIG_ENABLE_CHIP_MSG22XX)
+u8 _gGestureWakeupPacket[GESTURE_WAKEUP_PACKET_LENGTH] = {0};
+#endif
+
+#endif /* CONFIG_ENABLE_GESTURE_DEBUG_MODE */
+
+#ifdef CONFIG_ENABLE_GESTURE_DEBUG_MODE
+u8 g_GestureDebugFlag = 0x00;
+u8 g_GestureDebugMode = 0x00;
+u8 g_LogGestureDebug[GESTURE_DEBUG_MODE_PACKET_LENGTH] = {0};
+#endif /* CONFIG_ENABLE_GESTURE_DEBUG_MODE */
+
+#ifdef CONFIG_ENABLE_GESTURE_INFORMATION_MODE
+u32 g_LogGestureInfor[GESTURE_WAKEUP_INFORMATION_PACKET_LENGTH] = {0};
+#endif /* CONFIG_ENABLE_GESTURE_INFORMATION_MODE */
+
+u32 g_GestureWakeupMode[2] = {0xFFFFFFFF, 0xFFFFFFFF};
+u8 g_GestureWakeupFlag = 0;
+#endif /* CONFIG_ENABLE_GESTURE_WAKEUP */
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+#ifdef CONFIG_ENABLE_GESTURE_INFORMATION_MODE
+static void _DrvFwCtrlCoordinate(u8 *pRawData, u32 *pTranX, u32 *pTranY);
+#endif /* CONFIG_ENABLE_GESTURE_INFORMATION_MODE */
+#endif /* CONFIG_ENABLE_GESTURE_WAKEUP */
+
+static void _DrvFwCtrlEraseEmemC32(void)
+{
+ DBG("*** %s() ***\n", __func__);
+
+ /* Erase all */
+
+ /* Enter gpio mode */
+ RegSet16BitValue(0x161E, 0xBEAF);
+
+ /* Before gpio mode, set the control pin as the orginal status */
+ RegSet16BitValue(0x1608, 0x0000);
+ RegSetLByteValue(0x160E, 0x10);
+ mdelay(10);
+
+ /* ptrim = 1, h'04[2] */
+ RegSetLByteValue(0x1608, 0x04);
+ RegSetLByteValue(0x160E, 0x10);
+ mdelay(10);
+
+ /* ptm = 6, h'04[12:14] = b'110 */
+ RegSetLByteValue(0x1609, 0x60);
+ RegSetLByteValue(0x160E, 0x10);
+
+ /* pmasi = 1, h'04[6] */
+ RegSetLByteValue(0x1608, 0x44);
+ /* pce = 1, h'04[11] */
+ RegSetLByteValue(0x1609, 0x68);
+ /* perase = 1, h'04[7] */
+ RegSetLByteValue(0x1608, 0xC4);
+ /* pnvstr = 1, h'04[5] */
+ RegSetLByteValue(0x1608, 0xE4);
+ /* pwe = 1, h'04[9] */
+ RegSetLByteValue(0x1609, 0x6A);
+ /* trigger gpio load */
+ RegSetLByteValue(0x160E, 0x10);
+}
+
+static void _DrvFwCtrlEraseEmemC33(enum EmemType_e eEmemType)
+{
+ DBG("*** %s() ***\n", __func__);
+
+ /* Stop mcu */
+ RegSet16BitValue(0x0FE6, 0x0001);
+
+ /* Disable watchdog */
+ RegSetLByteValue(0x3C60, 0x55);
+ RegSetLByteValue(0x3C61, 0xAA);
+
+ /* Set PROGRAM password */
+ RegSetLByteValue(0x161A, 0xBA);
+ RegSetLByteValue(0x161B, 0xAB);
+
+ /* Clear pce */
+ RegSetLByteValue(0x1618, 0x80);
+
+ if (eEmemType == EMEM_ALL)
+ RegSetLByteValue(0x1608, 0x10); /* mark */
+
+ RegSetLByteValue(0x1618, 0x40);
+ mdelay(10);
+
+ RegSetLByteValue(0x1618, 0x80);
+
+ /* erase trigger */
+ if (eEmemType == EMEM_MAIN)
+ RegSetLByteValue(0x160E, 0x04); /* erase main */
+ else
+ RegSetLByteValue(0x160E, 0x08); /* erase all block */
+}
+
+static void _DrvFwCtrlMsg22xxGetTpVendorCode(u8 *pTpVendorCode)
+{
+ DBG("*** %s() ***\n", __func__);
+
+ if (g_ChipType == CHIP_TYPE_MSG22XX) {
+ u16 nRegData1, nRegData2;
+
+ DrvPlatformLyrTouchDeviceResetHw();
+
+ DbBusEnterSerialDebugMode();
+ DbBusStopMCU();
+ DbBusIICUseBus();
+ DbBusIICReshape();
+ mdelay(100);
+
+ /* Stop mcu */
+ RegSetLByteValue(0x0FE6, 0x01);
+
+ /* Stop watchdog */
+ RegSet16BitValue(0x3C60, 0xAA55);
+
+ /* RIU password */
+ RegSet16BitValue(0x161A, 0xABBA);
+
+ /* Clear pce */
+ RegSet16BitValue(0x1618, (RegGet16BitValue(0x1618) | 0x80));
+
+ /*
+ * Set start address for tp vendor code on info block
+ * (Actually, start reading from 0xC1E8)
+ */
+ RegSet16BitValue(0x1600, 0xC1E9);
+
+ /* Enable burst mode */
+ /*
+ * RegSet16BitValue(0x160C,
+ * (RegGet16BitValue(0x160C) | 0x01));
+ */
+
+ /* Set pce */
+ RegSet16BitValue(0x1618, (RegGet16BitValue(0x1618) | 0x40));
+
+ RegSetLByteValue(0x160E, 0x01);
+
+ nRegData1 = RegGet16BitValue(0x1604);
+ nRegData2 = RegGet16BitValue(0x1606);
+
+ pTpVendorCode[0] = ((nRegData1 >> 8) & 0xFF);
+ pTpVendorCode[1] = (nRegData2 & 0xFF);
+ pTpVendorCode[2] = ((nRegData2 >> 8) & 0xFF);
+
+ DBG("pTpVendorCode[0] = 0x%x, %c\n",
+ pTpVendorCode[0],
+ pTpVendorCode[0]);
+ DBG("pTpVendorCode[1] = 0x%x, %c\n",
+ pTpVendorCode[1],
+ pTpVendorCode[1]);
+ DBG("pTpVendorCode[2] = 0x%x, %c\n",
+ pTpVendorCode[2],
+ pTpVendorCode[2]);
+
+ /* Clear burst mode */
+ /*
+ * RegSet16BitValue(0x160C,
+ * RegGet16BitValue(0x160C) & (~0x01));
+ */
+
+ RegSet16BitValue(0x1600, 0x0000);
+
+ /* Clear RIU password */
+ RegSet16BitValue(0x161A, 0x0000);
+
+ DbBusIICNotUseBus();
+ DbBusNotStopMCU();
+ DbBusExitSerialDebugMode();
+
+ DrvPlatformLyrTouchDeviceResetHw();
+ }
+}
+
+static u32 _DrvFwCtrlMsg22xxGetFirmwareCrcByHardware(enum EmemType_e eEmemType)
+{
+ u16 nCrcDown = 0;
+ u32 nRetVal = 0;
+
+ DBG("*** %s() eEmemType = %d ***\n", __func__, eEmemType);
+
+ DbBusEnterSerialDebugMode();
+ DbBusStopMCU();
+ DbBusIICUseBus();
+ DbBusIICReshape();
+ mdelay(100);
+
+ /* RIU password */
+ RegSet16BitValue(0x161A, 0xABBA);
+
+ /* Set PCE high */
+ RegSetLByteValue(0x1618, 0x40);
+
+ if (eEmemType == EMEM_MAIN) {
+ /* Set start address and end address for main block */
+ RegSet16BitValue(0x1600, 0x0000);
+ RegSet16BitValue(0x1640, 0xBFF8);
+ } else if (eEmemType == EMEM_INFO) {
+ /* Set start address and end address for info block */
+ RegSet16BitValue(0x1600, 0xC000);
+ RegSet16BitValue(0x1640, 0xC1F8);
+ }
+
+ /* CRC reset */
+ RegSet16BitValue(0x164E, 0x0001);
+
+ RegSet16BitValue(0x164E, 0x0000);
+
+ /* Trigger CRC check */
+ RegSetLByteValue(0x160E, 0x20);
+ mdelay(10);
+
+ nCrcDown = RegGet16BitValue(0x164E);
+
+ while (nCrcDown != 2) {
+ DBG("Wait CRC down\n");
+ mdelay(10);
+ nCrcDown = RegGet16BitValue(0x164E);
+ }
+
+ nRetVal = RegGet16BitValue(0x1652);
+ nRetVal = (nRetVal << 16) | RegGet16BitValue(0x1650);
+
+ DBG("Hardware CRC = 0x%x\n", nRetVal);
+
+ DbBusIICNotUseBus();
+ DbBusNotStopMCU();
+ DbBusExitSerialDebugMode();
+
+ return nRetVal;
+}
+
+static void _DrvFwCtrlMsg22xxConvertFwDataTwoDimenToOneDimen(
+ u8 szTwoDimenFwData[][1024], u8 *pOneDimenFwData)
+{
+ u32 i, j;
+
+ DBG("*** %s() ***\n", __func__);
+
+ for (i = 0; i < (MSG22XX_FIRMWARE_MAIN_BLOCK_SIZE+1); i++) {
+ if (i < MSG22XX_FIRMWARE_MAIN_BLOCK_SIZE) {
+ for (j = 0; j < 1024; j++)
+ pOneDimenFwData[i*1024+j] =
+ szTwoDimenFwData[i][j];
+ } else {
+ for (j = 0; j < 512; j++)
+ pOneDimenFwData[i*1024+j] =
+ szTwoDimenFwData[i][j];
+ }
+ }
+}
+
+static s32 _DrvFwCtrlParsePacket(u8 *pPacket, u16 nLength,
+ struct TouchInfo_t *pInfo)
+{
+ u8 nCheckSum = 0;
+ u32 nDeltaX = 0, nDeltaY = 0;
+ u32 nX = 0;
+ u32 nY = 0;
+#ifdef CONFIG_SWAP_X_Y
+ u32 nTempX;
+ u32 nTempY;
+#endif
+ u32 i = 0;
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+ u8 nCheckSumIndex = 0;
+#endif /* CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+
+ DBG("*** %s() ***\n", __func__);
+
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+ if (g_FirmwareMode == FIRMWARE_MODE_DEMO_MODE)
+ nCheckSumIndex = 7;
+ else if (g_FirmwareMode == FIRMWARE_MODE_DEBUG_MODE ||
+ g_FirmwareMode == FIRMWARE_MODE_RAW_DATA_MODE)
+ nCheckSumIndex = 31;
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+ if (g_GestureWakeupFlag == 1)
+ nCheckSumIndex = nLength-1;
+#endif /* CONFIG_ENABLE_GESTURE_WAKEUP */
+
+#endif /* CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+ nCheckSum = DrvCommonCalculateCheckSum(&pPacket[0], nCheckSumIndex);
+ DBG("check sum : [%x] == [%x]?\n",
+ pPacket[nCheckSumIndex], nCheckSum);
+#else
+ nCheckSum = DrvCommonCalculateCheckSum(&pPacket[0], (nLength-1));
+ DBG("check ksum : [%x] == [%x]?\n",
+ pPacket[nLength-1], nCheckSum);
+#endif /* CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+ if (g_GestureWakeupFlag == 1) {
+ u8 nWakeupMode = 0;
+ u8 bIsCorrectFormat = 0;
+
+ DBG("received raw data from touch panel as following:\n");
+ for (i = 0; i < 6; i++)
+ DBG("pPacket[%d]=%x ", i, pPacket[i]);
+
+ DBG("\n");
+
+ if (g_ChipType == CHIP_TYPE_MSG22XX &&
+ pPacket[0] == 0xA7 &&
+ pPacket[1] == 0x00 &&
+ pPacket[2] == 0x06 &&
+ pPacket[3] == PACKET_TYPE_GESTURE_WAKEUP) {
+ nWakeupMode = pPacket[4];
+ bIsCorrectFormat = 1;
+ }
+#ifdef CONFIG_ENABLE_GESTURE_DEBUG_MODE
+ else if (g_ChipType == CHIP_TYPE_MSG22XX &&
+ pPacket[0] == 0xA7 &&
+ pPacket[1] == 0x00 &&
+ pPacket[2] == 0x80 &&
+ pPacket[3] == PACKET_TYPE_GESTURE_DEBUG) {
+ u32 a = 0;
+
+ nWakeupMode = pPacket[4];
+ bIsCorrectFormat = 1;
+
+ for (a = 0; a < 0x80; a++)
+ g_LogGestureDebug[a] = pPacket[a];
+
+ if (!(pPacket[5] >> 7)) {/* LCM Light Flag = 0 */
+ nWakeupMode = 0xFE;
+ DBG("gesture debug mode LCM flag = 0\n");
+ }
+ }
+#endif /* CONFIG_ENABLE_GESTURE_DEBUG_MODE */
+
+#ifdef CONFIG_ENABLE_GESTURE_INFORMATION_MODE
+ else if (g_ChipType == CHIP_TYPE_MSG22XX &&
+ pPacket[0] == 0xA7 &&
+ pPacket[1] == 0x00 &&
+ pPacket[2] == 0x80 &&
+ pPacket[3] == PACKET_TYPE_GESTURE_INFORMATION) {
+ u32 a = 0;
+ u32 nTmpCount = 0;
+
+ nWakeupMode = pPacket[4];
+ bIsCorrectFormat = 1;
+
+ for (a = 0; a < 6; a++) {/* header */
+ g_LogGestureInfor[nTmpCount] = pPacket[a];
+ nTmpCount++;
+ }
+
+ /* parse packet to coordinate */
+ for (a = 6; a < 126; a = a+3) {
+ u32 nTranX = 0;
+ u32 nTranY = 0;
+
+ _DrvFwCtrlCoordinate(&pPacket[a],
+ &nTranX, &nTranY);
+ g_LogGestureInfor[nTmpCount] = nTranX;
+ nTmpCount++;
+ g_LogGestureInfor[nTmpCount] = nTranY;
+ nTmpCount++;
+ }
+
+ g_LogGestureInfor[nTmpCount] = pPacket[126]; /* Dummy */
+ nTmpCount++;
+ /* checksum */
+ g_LogGestureInfor[nTmpCount] = pPacket[127];
+ nTmpCount++;
+ DBG("gesture information mode Count = %d\n", nTmpCount);
+ }
+#endif /* CONFIG_ENABLE_GESTURE_INFORMATION_MODE */
+ else if (g_ChipType == CHIP_TYPE_MSG21XXA &&
+ pPacket[0] == 0x52 &&
+ pPacket[1] == 0xFF &&
+ pPacket[2] == 0xFF &&
+ pPacket[3] == 0xFF &&
+ pPacket[4] == 0xFF &&
+ pPacket[6] == 0xFF) {
+ nWakeupMode = pPacket[5];
+ bIsCorrectFormat = 1;
+ }
+
+ if (bIsCorrectFormat) {
+ DBG("nWakeupMode = 0x%x\n", nWakeupMode);
+
+ switch (nWakeupMode) {
+ case 0x58:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_DOUBLE_CLICK_FLAG;
+
+ DBG("Light up screen by DOUBLE_CLICK ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x60:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_UP_DIRECT_FLAG;
+
+ DBG("Light up screen by UP_DIRECT ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x61:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_DOWN_DIRECT_FLAG;
+
+ DBG("Light up screen by DOWN_DIRECT",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x62:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_LEFT_DIRECT_FLAG;
+
+ DBG("Light up screen by LEFT_DIRECT ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x63:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_RIGHT_DIRECT_FLAG;
+
+ DBG("Light up screen by RIGHT_DIRECT ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x64:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_m_CHARACTER_FLAG;
+
+ DBG("Light up screen by m_CHARACTER ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x65:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_W_CHARACTER_FLAG;
+
+ DBG("Light up screen by W_CHARACTER ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x66:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_C_CHARACTER_FLAG;
+
+ DBG("Light up screen by C_CHARACTER ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x67:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_e_CHARACTER_FLAG;
+
+ DBG("Light up screen by e_CHARACTER ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x68:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_V_CHARACTER_FLAG;
+
+ DBG("Light up screen by V_CHARACTER ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x69:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_O_CHARACTER_FLAG;
+
+ DBG("Light up screen by O_CHARACTER ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x6A:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_S_CHARACTER_FLAG;
+
+ DBG("Light up screen by S_CHARACTER ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x6B:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_Z_CHARACTER_FLAG;
+
+ DBG("Light up screen by Z_CHARACTER ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x6C:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_RESERVE1_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE1_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x6D:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_RESERVE2_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE2_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x6E:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_RESERVE3_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE3_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+#ifdef CONFIG_SUPPORT_64_TYPES_GESTURE_WAKEUP_MODE
+ case 0x6F:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_RESERVE4_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE4_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x70:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_RESERVE5_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE5_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x71:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_RESERVE6_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE6_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x72:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_RESERVE7_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE7_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x73:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_RESERVE8_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE8_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x74:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_RESERVE9_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE9_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x75:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_RESERVE10_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE10_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x76:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_RESERVE11_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE11_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x77:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_RESERVE12_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE12_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x78:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_RESERVE13_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE13_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x79:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_RESERVE14_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE14_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x7A:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_RESERVE15_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE15_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x7B:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_RESERVE16_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE16_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x7C:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_RESERVE17_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE17_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x7D:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_RESERVE18_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE18_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x7E:
+ _gGestureWakeupValue[0] =
+ GESTURE_WAKEUP_MODE_RESERVE19_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE19_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x7F:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE20_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE20_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x80:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE21_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE21_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x81:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE22_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE22_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x82:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE23_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE23_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x83:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE24_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE24_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x84:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE25_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE25_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x85:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE26_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE26_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x86:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE27_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE27_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x87:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE28_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE28_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x88:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE29_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE29_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x89:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE30_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE30_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x8A:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE31_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE31_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x8B:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE32_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE32_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x8C:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE33_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE33_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x8D:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE34_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE34_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x8E:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE35_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE35_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x8F:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE36_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE36_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x90:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE37_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE37_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x91:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE38_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE38_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x92:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE39_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE39_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x93:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE40_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE40_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x94:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE41_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE41_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x95:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE42_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE42_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x96:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE43_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE43_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x97:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE44_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE44_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x98:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE45_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE45_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x99:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE46_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE46_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x9A:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE47_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE47_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x9B:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE48_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE48_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x9C:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE49_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE49_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x9D:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE50_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE50_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+ case 0x9E:
+ _gGestureWakeupValue[1] =
+ GESTURE_WAKEUP_MODE_RESERVE51_FLAG;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_RESERVE51_FLAG ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+#endif
+#ifdef CONFIG_ENABLE_GESTURE_DEBUG_MODE
+ case 0xFF:
+ _gGestureWakeupValue[1] = 0xFF;
+
+ DBG("Light up screen by ",
+ "GESTURE_WAKEUP_MODE_FAIL ",
+ "gesture wakeup.\n");
+
+ input_report_key(g_InputDevice, KEY_POWER, 1);
+ input_sync(g_InputDevice);
+ input_report_key(g_InputDevice, KEY_POWER, 0);
+ input_sync(g_InputDevice);
+ break;
+#endif /* CONFIG_ENABLE_GESTURE_DEBUG_MODE */
+ default:
+ _gGestureWakeupValue[0] = 0;
+ _gGestureWakeupValue[1] = 0;
+ DBG("Un-supported gesture wakeup mode. ",
+ "Please check your device driver code.\n");
+ break;
+ }
+
+ DBG("_gGestureWakeupValue[0] = 0x%x\n",
+ _gGestureWakeupValue[0]);
+ DBG("_gGestureWakeupValue[1] = 0x%x\n",
+ _gGestureWakeupValue[1]);
+ } else {
+ DBG("gesture wakeup packet format is incorrect.\n");
+ }
+
+#ifdef CONFIG_ENABLE_GESTURE_DEBUG_MODE
+ /*
+ * Notify android application to retrieve log data mode
+ * packet from device driver by sysfs.
+ */
+ if (g_GestureKObj != NULL &&
+ pPacket[3] == PACKET_TYPE_GESTURE_DEBUG) {
+ char *pEnvp[2];
+ s32 nRetVal = 0;
+
+ pEnvp[0] = "STATUS=GET_GESTURE_DEBUG";
+ pEnvp[1] = NULL;
+
+ nRetVal = kobject_uevent_env(g_GestureKObj,
+ KOBJ_CHANGE, pEnvp);
+ DBG("kobject_uevent_env() nRetVal = %d\n", nRetVal);
+
+ }
+#endif /* CONFIG_ENABLE_GESTURE_DEBUG_MODE */
+
+ return -1;
+ }
+#endif /* CONFIG_ENABLE_GESTURE_WAKEUP */
+
+ DBG("received raw data from touch panel as following:\n");
+ for (i = 0; i < 8; i++)
+ DBG("pPacket[%d]=%x ", i, pPacket[i]);
+ DBG("\n");
+
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+ /* check the checksum of packet */
+ if ((pPacket[nCheckSumIndex] == nCheckSum) && (pPacket[0] == 0x52)) {
+#else
+ /* check the checksum of packet */
+ if ((pPacket[nLength-1] == nCheckSum) && (pPacket[0] == 0x52)) {
+#endif /* CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+ /* parse the packet to coordinate */
+ nX = (((pPacket[1] & 0xF0) << 4) | pPacket[2]);
+ nY = (((pPacket[1] & 0x0F) << 8) | pPacket[3]);
+
+ nDeltaX = (((pPacket[4] & 0xF0) << 4) | pPacket[5]);
+ nDeltaY = (((pPacket[4] & 0x0F) << 8) | pPacket[6]);
+
+ DBG("[x,y]=[%d,%d]\n", nX, nY);
+ DBG("[delta_x,delta_y]=[%d,%d]\n", nDeltaX, nDeltaY);
+
+#ifdef CONFIG_SWAP_X_Y
+ nTempY = nX;
+ nTempX = nY;
+ nX = nTempX;
+ nY = nTempY;
+
+ nTempY = nDeltaX;
+ nTempX = nDeltaY;
+ nDeltaX = nTempX;
+ nDeltaY = nTempY;
+#endif
+
+#ifdef CONFIG_REVERSE_X
+ nX = 2047 - nX;
+ nDeltaX = 4095 - nDeltaX;
+#endif
+
+#ifdef CONFIG_REVERSE_Y
+ nY = 2047 - nY;
+ nDeltaY = 4095 - nDeltaY;
+#endif
+
+ /*
+ * pPacket[0]: id,
+ * pPacket[1]~pPacket[3]: the first point abs,
+ * pPacket[4]~pPacket[6]: the relative distance between
+ * the first point abs and the second point abs
+ * when pPacket[1]~pPacket[4], pPacket[6] is 0xFF,
+ * keyevent, pPacket[5] to judge which key press.
+ * pPacket[1]~pPacket[6] all are 0xFF, release touch
+ */
+ if ((pPacket[1] == 0xFF) && (pPacket[2] == 0xFF) &&
+ (pPacket[3] == 0xFF) &&
+ (pPacket[4] == 0xFF) &&
+ (pPacket[6] == 0xFF)) {
+ pInfo->tPoint[0].nX = 0;/* final X coordinate */
+ pInfo->tPoint[0].nY = 0;/* final Y coordinate */
+ /*
+ * pPacket[5] is key value
+ * 0x00 is key up, 0xff is touch screen up
+ */
+ if ((pPacket[5] != 0x00) &&
+ (pPacket[5] != 0xFF)) {
+ DBG("touch key down pPacket[5]=%d\n",
+ pPacket[5]);
+
+ pInfo->nFingerNum = 1;
+ pInfo->nTouchKeyCode = pPacket[5];
+ pInfo->nTouchKeyMode = 1;
+
+#ifdef CONFIG_ENABLE_REPORT_KEY_WITH_COORDINATE
+ pInfo->nFingerNum = 1;
+ pInfo->nTouchKeyCode = 0;
+ pInfo->nTouchKeyMode = 0;
+
+ /* TOUCH_KEY_HOME */
+ if (pPacket[5] == 4) {
+ pInfo->tPoint[0].nX = g_TpVirtualKeyDimLocal[1][0];
+ pInfo->tPoint[0].nY = g_TpVirtualKeyDimLocal[1][1];
+ /* TOUCH_KEY_MENU */
+ } else if (pPacket[5] == 1) {
+ pInfo->tPoint[0].nX = g_TpVirtualKeyDimLocal[0][0];
+ pInfo->tPoint[0].nY = g_TpVirtualKeyDimLocal[0][1];
+ /* TOUCH_KEY_BACK */
+ } else if (pPacket[5] == 2) {
+ pInfo->tPoint[0].nX = g_TpVirtualKeyDimLocal[2][0];
+ pInfo->tPoint[0].nY = g_TpVirtualKeyDimLocal[2][1];
+ /* TOUCH_KEY_SEARCH */
+ } else if (pPacket[5] == 8) {
+ pInfo->tPoint[0].nX = g_TpVirtualKeyDimLocal[3][0];
+ pInfo->tPoint[0].nY = g_TpVirtualKeyDimLocal[3][1];
+ } else {
+ DBG("multi-key is pressed.\n");
+ return -1;
+ }
+#endif /* CONFIG_ENABLE_REPORT_KEY_WITH_COORDINATE */
+ } else { /* key up or touch up */
+ DBG("touch end\n");
+ pInfo->nFingerNum = 0; /* touch end */
+ pInfo->nTouchKeyCode = 0;
+ pInfo->nTouchKeyMode = 0;
+ }
+ } else {
+ /* Touch on screen... */
+ pInfo->nTouchKeyMode = 0;
+
+ if (
+#ifdef CONFIG_REVERSE_X
+ (nDeltaX == 4095)
+#else
+ (nDeltaX == 0)
+#endif
+ &&
+#ifdef CONFIG_REVERSE_Y
+ (nDeltaY == 4095)
+#else
+ (nDeltaY == 0)
+#endif
+ ) { /* one touch point */
+ pInfo->nFingerNum = 1; /* one touch */
+ pInfo->tPoint[0].nX =
+ (nX * TOUCH_SCREEN_X_MAX) /
+ TPD_WIDTH;
+ pInfo->tPoint[0].nY =
+ (nY * TOUCH_SCREEN_Y_MAX) /
+ TPD_HEIGHT;
+ DBG("[%s]: [x,y]=[%d,%d]\n", __func__,
+ nX, nY);
+ DBG("[%s]: point[x,y]=[%d,%d]\n",
+ __func__,
+ pInfo->tPoint[0].nX,
+ pInfo->tPoint[0].nY);
+ } else { /* two touch points */
+ u32 nX2, nY2;
+
+ pInfo->nFingerNum = 2; /* two touch */
+ /* Finger 1 */
+ pInfo->tPoint[0].nX =
+ (nX * TOUCH_SCREEN_X_MAX) /
+ TPD_WIDTH;
+ pInfo->tPoint[0].nY =
+ (nY * TOUCH_SCREEN_Y_MAX) /
+ TPD_HEIGHT;
+ DBG("[%s]: point1[x,y]=[%d,%d]\n",
+ __func__,
+ pInfo->tPoint[0].nX,
+ pInfo->tPoint[0].nY);
+ /* Finger 2 */
+ /*
+ * transform the unsigned
+ * value to signed value
+ */
+ if (nDeltaX > 2048)
+ nDeltaX -= 4096;
+
+ if (nDeltaY > 2048)
+ nDeltaY -= 4096;
+
+ nX2 = (u32)(nX + nDeltaX);
+ nY2 = (u32)(nY + nDeltaY);
+
+ pInfo->tPoint[1].nX =
+ (nX2 * TOUCH_SCREEN_X_MAX) /
+ TPD_WIDTH;
+ pInfo->tPoint[1].nY =
+ (nY2 * TOUCH_SCREEN_Y_MAX) /
+ TPD_HEIGHT;
+ DBG("[%s]: point2[x,y]=[%d,%d]\n",
+ __func__,
+ pInfo->tPoint[1].nX,
+ pInfo->tPoint[1].nY);
+ }
+ }
+ }
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+ else if (pPacket[nCheckSumIndex] == nCheckSum &&
+ pPacket[0] == 0x62) {
+ nX = ((pPacket[1] << 8) | pPacket[2]); /* Position_X */
+ nY = ((pPacket[3] << 8) | pPacket[4]); /* Position_Y */
+ /* Distance_X */
+ nDeltaX = ((pPacket[13] << 8) | pPacket[14]);
+ /* Distance_Y */
+ nDeltaY = ((pPacket[15] << 8) | pPacket[16]);
+
+ DBG("[x,y]=[%d,%d]\n", nX, nY);
+ DBG("[delta_x,delta_y]=[%d,%d]\n", nDeltaX, nDeltaY);
+
+#ifdef CONFIG_SWAP_X_Y
+ nTempY = nX;
+ nTempX = nY;
+ nX = nTempX;
+ nY = nTempY;
+
+ nTempY = nDeltaX;
+ nTempX = nDeltaY;
+ nDeltaX = nTempX;
+ nDeltaY = nTempY;
+#endif
+
+#ifdef CONFIG_REVERSE_X
+ nX = 2047 - nX;
+ nDeltaX = 4095 - nDeltaX;
+#endif
+
+#ifdef CONFIG_REVERSE_Y
+ nY = 2047 - nY;
+ nDeltaY = 4095 - nDeltaY;
+#endif
+
+ /*
+ * pPacket[0]:id,
+ * pPacket[1]~pPacket[4]:the first point abs,
+ * pPacket[13]~pPacket[16]:the relative distance
+ * between the first point abs and the second point
+ * abs when pPacket[1]~pPacket[7] is 0xFF, keyevent,
+ * pPacket[8] to judge which key press.
+ * pPacket[1]~pPacket[8] all are 0xFF, release touch
+ */
+ if ((pPacket[1] == 0xFF) && (pPacket[2] == 0xFF) &&
+ (pPacket[3] == 0xFF) &&
+ (pPacket[4] == 0xFF) &&
+ (pPacket[5] == 0xFF) &&
+ (pPacket[6] == 0xFF) &&
+ (pPacket[7] == 0xFF)) {
+ pInfo->tPoint[0].nX = 0;/* final X coordinate */
+ pInfo->tPoint[0].nY = 0;/* final Y coordinate */
+
+ /* pPacket[8] is key value */
+ /* 0x00 is key up, 0xff is touch screen up */
+ if ((pPacket[8] != 0x00) &&
+ (pPacket[8] != 0xFF)) {
+ DBG("touch key down pPacket[8]=%d\n",
+ pPacket[8]);
+ pInfo->nFingerNum = 1;
+ pInfo->nTouchKeyCode = pPacket[8];
+ pInfo->nTouchKeyMode = 1;
+
+#ifdef CONFIG_ENABLE_REPORT_KEY_WITH_COORDINATE
+ pInfo->nFingerNum = 1;
+ pInfo->nTouchKeyCode = 0;
+ pInfo->nTouchKeyMode = 0;
+
+ /* TOUCH_KEY_HOME */
+ if (pPacket[8] == 4) {
+ pInfo->tPoint[0].nX = g_TpVirtualKeyDimLocal[1][0];
+ pInfo->tPoint[0].nY = g_TpVirtualKeyDimLocal[1][1];
+ /* TOUCH_KEY_MENU */
+ } else if (pPacket[8] == 1) {
+ pInfo->tPoint[0].nX = g_TpVirtualKeyDimLocal[0][0];
+ pInfo->tPoint[0].nY = g_TpVirtualKeyDimLocal[0][1];
+ /* TOUCH_KEY_BACK */
+ } else if (pPacket[8] == 2) {
+ pInfo->tPoint[0].nX = g_TpVirtualKeyDimLocal[2][0];
+ pInfo->tPoint[0].nY = g_TpVirtualKeyDimLocal[2][1];
+ /* TOUCH_KEY_SEARCH */
+ } else if (pPacket[8] == 8) {
+ pInfo->tPoint[0].nX = g_TpVirtualKeyDimLocal[3][0];
+ pInfo->tPoint[0].nY = g_TpVirtualKeyDimLocal[3][1];
+ } else {
+ DBG("multi-key is pressed.\n");
+ return -1;
+ }
+#endif /* CONFIG_ENABLE_REPORT_KEY_WITH_COORDINATE */
+ } else { /* key up or touch up */
+ DBG("touch end\n");
+ pInfo->nFingerNum = 0; /* touch end */
+ pInfo->nTouchKeyCode = 0;
+ pInfo->nTouchKeyMode = 0;
+ }
+ } else {
+ /* Touch on screen... */
+ pInfo->nTouchKeyMode = 0;
+
+ /* if ((nDeltaX == 0) && (nDeltaY == 0)) */
+ if (
+#ifdef CONFIG_REVERSE_X
+ (nDeltaX == 4095)
+#else
+ (nDeltaX == 0)
+#endif
+ &&
+#ifdef CONFIG_REVERSE_Y
+ (nDeltaY == 4095)
+#else
+ (nDeltaY == 0)
+#endif
+ ) { /* one touch point */
+ pInfo->nFingerNum = 1; /* one touch */
+ pInfo->tPoint[0].nX =
+ (nX * TOUCH_SCREEN_X_MAX) /
+ TPD_WIDTH;
+ pInfo->tPoint[0].nY =
+ (nY * TOUCH_SCREEN_Y_MAX) /
+ TPD_HEIGHT;
+ DBG("[%s]: [x,y]=[%d,%d]\n",
+ __func__, nX, nY);
+ DBG("[%s]: point[x,y]=[%d,%d]\n",
+ __func__,
+ pInfo->tPoint[0].nX,
+ pInfo->tPoint[0].nY);
+ } else { /* two touch points */
+ u32 nX2, nY2;
+
+ pInfo->nFingerNum = 2; /* two touch */
+ /* Finger 1 */
+ pInfo->tPoint[0].nX =
+ (nX * TOUCH_SCREEN_X_MAX) /
+ TPD_WIDTH;
+ pInfo->tPoint[0].nY =
+ (nY * TOUCH_SCREEN_Y_MAX) /
+ TPD_HEIGHT;
+ DBG("[%s]: point1[x,y]=[%d,%d]\n",
+ __func__,
+ pInfo->tPoint[0].nX,
+ pInfo->tPoint[0].nY);
+ /*
+ * Finger 2
+ * transform the unsigned value
+ * to signed value
+ */
+ if (nDeltaX > 2048)
+ nDeltaX -= 4096;
+
+ if (nDeltaY > 2048)
+ nDeltaY -= 4096;
+
+ nX2 = (u32)(nX + nDeltaX);
+ nY2 = (u32)(nY + nDeltaY);
+
+ pInfo->tPoint[1].nX =
+ (nX2 * TOUCH_SCREEN_X_MAX) /
+ TPD_WIDTH;
+ pInfo->tPoint[1].nY =
+ (nY2 * TOUCH_SCREEN_Y_MAX) /
+ TPD_HEIGHT;
+ DBG("[%s]: point2[x,y]=[%d,%d]\n",
+ __func__,
+ pInfo->tPoint[1].nX,
+ pInfo->tPoint[1].nY);
+ }
+
+ /*
+ * Notify android application to retrieve log
+ * data mode packet from device driver by sysfs.
+ */
+ if (g_TouchKObj != NULL) {
+ char *pEnvp[2];
+ s32 nRetVal = 0;
+
+ pEnvp[0] = "STATUS=GET_PACKET";
+ pEnvp[1] = NULL;
+
+ nRetVal = kobject_uevent_env(
+ g_TouchKObj,
+ KOBJ_CHANGE,
+ pEnvp);
+ DBG("kobject_uevent_env() ",
+ "nRetVal = %d\n", nRetVal);
+ }
+ }
+ } else {
+ if (pPacket[nCheckSumIndex] != nCheckSum) {
+ DBG("WRONG CHECKSUM\n");
+ return -1;
+ }
+
+ if (g_FirmwareMode == FIRMWARE_MODE_DEMO_MODE &&
+ pPacket[0] != 0x52) {
+ DBG("WRONG DEMO MODE HEADER\n");
+ return -1;
+ } else if (g_FirmwareMode ==
+ FIRMWARE_MODE_DEBUG_MODE &&
+ pPacket[0] != 0x62) {
+ DBG("WRONG DEBUG MODE HEADER\n");
+ return -1;
+ } else if (g_FirmwareMode ==
+ FIRMWARE_MODE_RAW_DATA_MODE &&
+ pPacket[0] != 0x62) {
+ DBG("WRONG RAW DATA MODE HEADER\n");
+ return -1;
+ }
+ }
+#else
+ else {
+ DBG("pPacket[0]=0x%x, pPacket[7]=0x%x, nCheckSum=0x%x\n",
+ pPacket[0], pPacket[7], nCheckSum);
+
+ if (pPacket[nLength-1] != nCheckSum) {
+ DBG("WRONG CHECKSUM\n");
+ return -1;
+ }
+
+ if (pPacket[0] != 0x52) {
+ DBG("WRONG DEMO MODE HEADER\n");
+ return -1;
+ }
+ }
+#endif /* CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+
+ return 0;
+}
+
+static void _DrvFwCtrlStoreFirmwareData(u8 *pBuf, u32 nSize)
+{
+ u32 nCount = nSize / 1024;
+ u32 nRemainder = nSize % 1024;
+ u32 i;
+
+ DBG("*** %s() ***\n", __func__);
+
+ if (nCount > 0) {
+ for (i = 0; i < nCount; i++) {
+ memcpy(g_FwData[g_FwDataCount], pBuf+(i*1024), 1024);
+ g_FwDataCount++;
+ }
+
+ /* Handle special firmware size like MSG22XX(48.5KB) */
+ if (nRemainder > 0) {
+ DBG("nRemainder = %d\n", nRemainder);
+
+ memcpy(g_FwData[g_FwDataCount],
+ pBuf+(i*1024),
+ nRemainder);
+ g_FwDataCount++;
+ }
+ } else {
+ if (nSize > 0) {
+ memcpy(g_FwData[g_FwDataCount], pBuf, nSize);
+ g_FwDataCount++;
+ }
+ }
+
+ DBG("*** g_FwDataCount = %d ***\n", g_FwDataCount);
+
+ if (pBuf != NULL)
+ DBG("*** buf[0] = %c ***\n", pBuf[0]);
+}
+
+static u16 _DrvFwCtrlMsg21xxaGetSwId(enum EmemType_e eEmemType)
+{
+ u16 nRetVal = 0;
+ u16 nRegData = 0;
+ u8 szDbBusTxData[5] = {0};
+ u8 szDbBusRxData[4] = {0};
+
+ DBG("*** %s() eEmemType = %d ***\n", __func__, eEmemType);
+
+ DbBusEnterSerialDebugMode();
+ DbBusStopMCU();
+ DbBusIICUseBus();
+ DbBusIICReshape();
+ mdelay(100);
+
+ /* Stop mcu */
+ RegSetLByteValue(0x0FE6, 0x01); /* bank:mheg5, addr:h0073 */
+
+ /* Stop watchdog */
+ RegSet16BitValue(0x3C60, 0xAA55); /* bank:reg_PIU_MISC_0, addr:h0030 */
+
+ /* cmd */
+ RegSet16BitValue(0x3CE4, 0xA4AB); /* bank:reg_PIU_MISC_0, addr:h0072 */
+
+ /* TP SW reset */
+ RegSet16BitValue(0x1E04, 0x7d60); /* bank:chip, addr:h0002 */
+ RegSet16BitValue(0x1E04, 0x829F);
+
+ /* Start mcu */
+ RegSetLByteValue(0x0FE6, 0x00); /* bank:mheg5, addr:h0073 */
+
+ mdelay(100);
+
+ /* Polling 0x3CE4 is 0x5B58 */
+ do {
+ /* bank:reg_PIU_MISC_0, addr:h0072 */
+ nRegData = RegGet16BitValue(0x3CE4);
+ } while (nRegData != 0x5B58);
+
+ szDbBusTxData[0] = 0x72;
+ if (eEmemType == EMEM_MAIN) {/* Read SW ID from main block */
+ szDbBusTxData[1] = 0x7F;
+ szDbBusTxData[2] = 0x55;
+ } else if (eEmemType == EMEM_INFO) {/* Read SW ID from info block */
+ szDbBusTxData[1] = 0x83;
+ szDbBusTxData[2] = 0x00;
+ }
+
+ szDbBusTxData[3] = 0x00;
+ szDbBusTxData[4] = 0x04;
+
+ IicWriteData(SLAVE_I2C_ID_DWI2C, &szDbBusTxData[0], 5);
+ IicReadData(SLAVE_I2C_ID_DWI2C, &szDbBusRxData[0], 4);
+
+ DBG("szDbBusRxData[0,1,2,3] = 0x%x,0x%x,0x%x,0x%x\n",
+ szDbBusRxData[0], szDbBusRxData[1],
+ szDbBusRxData[2], szDbBusRxData[3]);
+
+ if ((szDbBusRxData[0] >= 0x30 && szDbBusRxData[0] <= 0x39) &&
+ (szDbBusRxData[1] >= 0x30 &&
+ szDbBusRxData[1] <= 0x39) &&
+ (szDbBusRxData[2] >= 0x31 &&
+ szDbBusRxData[2] <= 0x39))
+ nRetVal = (szDbBusRxData[0] - 0x30) * 100 +
+ (szDbBusRxData[1] - 0x30) * 10 +
+ (szDbBusRxData[2] - 0x30);
+
+ DBG("SW ID = 0x%x\n", nRetVal);
+
+ DbBusIICNotUseBus();
+ DbBusNotStopMCU();
+ DbBusExitSerialDebugMode();
+
+ return nRetVal;
+}
+
+static u16 _DrvFwCtrlMsg22xxGetSwId(enum EmemType_e eEmemType)
+{
+ u16 nRetVal = 0;
+ u16 nRegData1 = 0;
+
+ DBG("*** %s() eEmemType = %d ***\n", __func__, eEmemType);
+
+ DbBusEnterSerialDebugMode();
+ DbBusStopMCU();
+ DbBusIICUseBus();
+ DbBusIICReshape();
+ mdelay(100);
+
+ /* Stop mcu */
+ RegSetLByteValue(0x0FE6, 0x01);
+
+ /* Stop watchdog */
+ RegSet16BitValue(0x3C60, 0xAA55);
+
+ /* RIU password */
+ RegSet16BitValue(0x161A, 0xABBA);
+
+ /* Clear pce */
+ RegSet16BitValue(0x1618, (RegGet16BitValue(0x1618) | 0x80));
+
+ if (eEmemType == EMEM_MAIN) /* Read SW ID from main block */
+ /* Set start address for main block SW ID */
+ RegSet16BitValue(0x1600, 0xBFF4);
+ else if (eEmemType == EMEM_INFO) /* Read SW ID from info block */
+ /* Set start address for info block SW ID */
+ RegSet16BitValue(0x1600, 0xC1EC);
+
+ /*
+ Ex. SW ID in Main Block :
+ Major low byte at address 0xBFF4
+ Major high byte at address 0xBFF5
+
+ SW ID in Info Block :
+ Major low byte at address 0xC1EC
+ Major high byte at address 0xC1ED
+ */
+
+ /* Enable burst mode */
+ /* RegSet16BitValue(0x160C, (RegGet16BitValue(0x160C) | 0x01)); */
+
+ /* Set pce */
+ RegSet16BitValue(0x1618, (RegGet16BitValue(0x1618) | 0x40));
+
+ RegSetLByteValue(0x160E, 0x01);
+
+ nRegData1 = RegGet16BitValue(0x1604);
+ /* nRegData2 = RegGet16BitValue(0x1606); */
+
+ nRetVal = ((nRegData1 >> 8) & 0xFF) << 8;
+ nRetVal |= (nRegData1 & 0xFF);
+
+ /* Clear burst mode */
+ /* RegSet16BitValue(0x160C, RegGet16BitValue(0x160C) & (~0x01)); */
+
+ RegSet16BitValue(0x1600, 0x0000);
+
+ /* Clear RIU password */
+ RegSet16BitValue(0x161A, 0x0000);
+
+ DBG("SW ID = 0x%x\n", nRetVal);
+
+ DbBusIICNotUseBus();
+ DbBusNotStopMCU();
+ DbBusExitSerialDebugMode();
+
+ return nRetVal;
+}
+
+static void _DrvFwCtrlReadInfoC33(void)
+{
+ u8 szDbBusTxData[5] = {0};
+ u16 nRegData = 0;
+
+ DBG("*** %s() ***\n", __func__);
+
+ mdelay(300);
+
+ /* Stop Watchdog */
+ RegSetLByteValue(0x3C60, 0x55);
+ RegSetLByteValue(0x3C61, 0xAA);
+
+ RegSet16BitValue(0x3CE4, 0xA4AB);
+
+ RegSet16BitValue(0x1E04, 0x7d60);
+
+ /* TP SW reset */
+ RegSet16BitValue(0x1E04, 0x829F);
+ mdelay(10);
+
+ szDbBusTxData[0] = 0x10;
+ szDbBusTxData[1] = 0x0F;
+ szDbBusTxData[2] = 0xE6;
+ szDbBusTxData[3] = 0x00;
+ IicWriteData(SLAVE_I2C_ID_DBBUS, szDbBusTxData, 4);
+ mdelay(100);
+
+ do {
+ nRegData = RegGet16BitValue(0x3CE4);
+ } while (nRegData != 0x5B58);
+
+
+ szDbBusTxData[0] = 0x72;
+ szDbBusTxData[1] = 0x80;
+ szDbBusTxData[2] = 0x00;
+ szDbBusTxData[3] = 0x04; /* read 1024 bytes */
+ szDbBusTxData[4] = 0x00;
+
+ IicWriteData(SLAVE_I2C_ID_DWI2C, szDbBusTxData, 5);
+
+ mdelay(50);
+
+ /* Receive info data */
+ IicReadData(SLAVE_I2C_ID_DWI2C, &_gDwIicInfoData[0], 1024);
+}
+
+static s32 _DrvFwCtrlUpdateFirmwareC32(u8 szFwData[][1024],
+ enum EmemType_e eEmemType)
+{
+ u32 i, j;
+ u32 nCrcMain, nCrcMainTp;
+ u32 nCrcInfo, nCrcInfoTp;
+ u32 nCrcTemp;
+ u16 nRegData = 0;
+
+ DBG("*** %s() ***\n", __func__);
+
+ nCrcMain = 0xffffffff;
+ nCrcInfo = 0xffffffff;
+
+ /* Erase all */
+ _DrvFwCtrlEraseEmemC32();
+ mdelay(1000);
+
+ DrvPlatformLyrTouchDeviceResetHw();
+
+ DbBusEnterSerialDebugMode();
+ DbBusStopMCU();
+ DbBusIICUseBus();
+ DbBusIICReshape();
+ mdelay(100);
+
+ /* Reset watch dog */
+ RegSetLByteValue(0x3C60, 0x55);
+ RegSetLByteValue(0x3C61, 0xAA);
+
+ /* Program */
+
+ /* Polling 0x3CE4 is 0x1C70 */
+ do {
+ nRegData = RegGet16BitValue(0x3CE4);
+ } while (nRegData != 0x1C70);
+
+ RegSet16BitValue(0x3CE4, 0xE38F); /* for all-blocks */
+
+ /* Polling 0x3CE4 is 0x2F43 */
+ do {
+ nRegData = RegGet16BitValue(0x3CE4);
+ } while (nRegData != 0x2F43);
+
+ /* Calculate CRC 32 */
+ DrvCommonCrcInitTable();
+
+ for (i = 0; i < 33; i++) { /* total 33 KB : 2 byte per R/W */
+ if (i < 32) { /* emem_main */
+ if (i == 31) {
+ szFwData[i][1014] = 0x5A;
+ szFwData[i][1015] = 0xA5;
+
+ for (j = 0; j < 1016; j++)
+ nCrcMain = DrvCommonCrcGetValue(
+ szFwData[i][j],
+ nCrcMain);
+
+ nCrcTemp = nCrcMain;
+ nCrcTemp = nCrcTemp ^ 0xffffffff;
+
+ DBG("nCrcTemp=%x\n", nCrcTemp);
+
+ for (j = 0; j < 4; j++) {
+ szFwData[i][1023-j] =
+ nCrcTemp >> (8 * j) & 0xFF;
+
+ DBG("((nCrcTemp>>(8*%d)) & 0xFF)=%x\n",
+ j,
+ nCrcTemp>>(8*j)&0xFF);
+ DBG("Update main clock crc32 into bin ",
+ "buffer szFwData[%d][%d]=%x\n",
+ i, (1020+j), szFwData[i][1020+j]);
+ }
+ } else {
+ for (j = 0; j < 1024; j++)
+ nCrcMain = DrvCommonCrcGetValue(
+ szFwData[i][j],
+ nCrcMain);
+ }
+ } else { /* emem_info */
+ for (j = 0; j < 1024; j++)
+ nCrcInfo = DrvCommonCrcGetValue(
+ szFwData[i][j],
+ nCrcInfo);
+ }
+
+ IicWriteData(SLAVE_I2C_ID_DWI2C, szFwData[i], 1024);
+
+ /* Polling 0x3CE4 is 0xD0BC */
+ do {
+ nRegData = RegGet16BitValue(0x3CE4);
+ } while (nRegData != 0xD0BC);
+
+ RegSet16BitValue(0x3CE4, 0x2F43);
+ }
+
+ /* Write file done */
+ RegSet16BitValue(0x3CE4, 0x1380);
+
+ mdelay(10);
+ /* Polling 0x3CE4 is 0x9432 */
+ do {
+ nRegData = RegGet16BitValue(0x3CE4);
+ } while (nRegData != 0x9432);
+
+ nCrcMain = nCrcMain ^ 0xffffffff;
+ nCrcInfo = nCrcInfo ^ 0xffffffff;
+
+ /* CRC Main from TP */
+ nCrcMainTp = RegGet16BitValue(0x3C80);
+ nCrcMainTp = (nCrcMainTp << 16) | RegGet16BitValue(0x3C82);
+
+ /* CRC Info from TP */
+ nCrcInfoTp = RegGet16BitValue(0x3CA0);
+ nCrcInfoTp = (nCrcInfoTp << 16) | RegGet16BitValue(0x3CA2);
+
+ DBG("nCrcMain=0x%x, nCrcInfo=0x%x, nCrcMainTp=0x%x, nCrcInfoTp=0x%x\n",
+ nCrcMain, nCrcInfo, nCrcMainTp, nCrcInfoTp);
+
+ g_FwDataCount = 0; /* Reset g_FwDataCount to 0 after update firmware */
+
+ DbBusIICNotUseBus();
+ DbBusNotStopMCU();
+ DbBusExitSerialDebugMode();
+
+ DrvPlatformLyrTouchDeviceResetHw();
+
+
+ if ((nCrcMainTp != nCrcMain) || (nCrcInfoTp != nCrcInfo)) {
+ DBG("Update FAILED\n");
+ return -1;
+ }
+
+ DBG("Update SUCCESS\n");
+
+ return 0;
+}
+
+static s32 _DrvFwCtrlUpdateFirmwareC33(u8 szFwData[][1024],
+ enum EmemType_e eEmemType)
+{
+ u8 szLifeCounter[2];
+ u32 i, j;
+ u32 nCrcMain, nCrcMainTp;
+ u32 nCrcInfo, nCrcInfoTp;
+ u32 nCrcTemp;
+ u16 nRegData = 0;
+
+ DBG("*** %s() ***\n", __func__);
+
+ nCrcMain = 0xffffffff;
+ nCrcInfo = 0xffffffff;
+
+
+ _DrvFwCtrlReadInfoC33();
+
+ if (_gDwIicInfoData[0] == 'M' && _gDwIicInfoData[1] == 'S' &&
+ _gDwIicInfoData[2] == 'T' &&
+ _gDwIicInfoData[3] == 'A' &&
+ _gDwIicInfoData[4] == 'R' &&
+ _gDwIicInfoData[5] == 'T' &&
+ _gDwIicInfoData[6] == 'P' &&
+ _gDwIicInfoData[7] == 'C') {
+ _gDwIicInfoData[8] = szFwData[32][8];
+ _gDwIicInfoData[9] = szFwData[32][9];
+ _gDwIicInfoData[10] = szFwData[32][10];
+ _gDwIicInfoData[11] = szFwData[32][11];
+ /* updata life counter */
+ szLifeCounter[1] =
+ ((_gDwIicInfoData[13]<<8 | _gDwIicInfoData[12])+1)>>8 &
+ 0xFF;
+ szLifeCounter[0] =
+ ((_gDwIicInfoData[13]<<8 | _gDwIicInfoData[12])+1) &
+ 0xFF;
+ _gDwIicInfoData[12] = szLifeCounter[0];
+ _gDwIicInfoData[13] = szLifeCounter[1];
+
+ RegSet16BitValue(0x3CE4, 0x78C5);
+ RegSet16BitValue(0x1E04, 0x7d60);
+ /* TP SW reset */
+ RegSet16BitValue(0x1E04, 0x829F);
+
+ mdelay(50);
+
+ /* Polling 0x3CE4 is 0x2F43 */
+ do {
+ nRegData = RegGet16BitValue(0x3CE4);
+ } while (nRegData != 0x2F43);
+
+ /* Transmit lk info data */
+
+ IicWriteData(SLAVE_I2C_ID_DWI2C, &_gDwIicInfoData[0], 1024);
+
+ /* Polling 0x3CE4 is 0xD0BC */
+ do {
+ nRegData = RegGet16BitValue(0x3CE4);
+ } while (nRegData != 0xD0BC);
+ }
+
+ /* erase main */
+ _DrvFwCtrlEraseEmemC33(EMEM_MAIN);
+ mdelay(1000);
+
+ DrvPlatformLyrTouchDeviceResetHw();
+
+ DbBusEnterSerialDebugMode();
+ DbBusStopMCU();
+ DbBusIICUseBus();
+ DbBusIICReshape();
+ mdelay(100);
+
+ /* Program */
+
+ /* Polling 0x3CE4 is 0x1C70 */
+ if ((eEmemType == EMEM_ALL) || (eEmemType == EMEM_MAIN)) {
+ do {
+ nRegData = RegGet16BitValue(0x3CE4);
+ } while (nRegData != 0x1C70);
+ }
+
+ switch (eEmemType) {
+ case EMEM_ALL:
+ RegSet16BitValue(0x3CE4, 0xE38F); /* for all blocks */
+ break;
+ case EMEM_MAIN:
+ RegSet16BitValue(0x3CE4, 0x7731); /* for main block */
+ break;
+ case EMEM_INFO:
+ RegSet16BitValue(0x3CE4, 0x7731); /* for info block */
+
+ RegSetLByteValue(0x0FE6, 0x01);
+
+ RegSetLByteValue(0x3CE4, 0xC5);
+ RegSetLByteValue(0x3CE5, 0x78);
+
+ RegSetLByteValue(0x1E04, 0x9F);
+ RegSetLByteValue(0x1E05, 0x82);
+
+ RegSetLByteValue(0x0FE6, 0x00);
+ mdelay(100);
+ break;
+ }
+
+ /* Polling 0x3CE4 is 0x2F43 */
+ do {
+ nRegData = RegGet16BitValue(0x3CE4);
+ } while (nRegData != 0x2F43);
+
+ /* Calculate CRC 32 */
+ DrvCommonCrcInitTable();
+
+ for (i = 0; i < 33; i++) { /* total 33 KB : 2 byte per R/W */
+ if (eEmemType == EMEM_INFO)
+ i = 32;
+
+ if (i < 32) { /* emem_main */
+ if (i == 31) {
+ szFwData[i][1014] = 0x5A;
+ szFwData[i][1015] = 0xA5;
+
+ for (j = 0; j < 1016; j++)
+ nCrcMain = DrvCommonCrcGetValue(
+ szFwData[i][j],
+ nCrcMain);
+
+ nCrcTemp = nCrcMain;
+ nCrcTemp = nCrcTemp ^ 0xffffffff;
+
+ DBG("nCrcTemp=%x\n", nCrcTemp);
+
+ for (j = 0; j < 4; j++) {
+ szFwData[i][1023-j] =
+ nCrcTemp>>(8*j) & 0xFF;
+
+ DBG("((nCrcTemp>>(8*%d)) & 0xFF)=%x\n",
+ j,
+ nCrcTemp>>(8*j)&0xFF);
+ DBG("Update main clock crc32 into bin ",
+ "buffer szFwData[%d][%d]=%x\n",
+ i, (1020+j), szFwData[i][1020+j]);
+ }
+ } else {
+ for (j = 0; j < 1024; j++)
+ nCrcMain = DrvCommonCrcGetValue(
+ szFwData[i][j],
+ nCrcMain);
+ }
+ } else { /* emem_info */
+ for (j = 0; j < 1024; j++)
+ nCrcInfo = DrvCommonCrcGetValue(
+ _gDwIicInfoData[j],
+ nCrcInfo);
+
+ if (eEmemType == EMEM_MAIN)
+ break;
+ }
+
+ IicWriteData(SLAVE_I2C_ID_DWI2C, szFwData[i], 1024);
+
+ /* Polling 0x3CE4 is 0xD0BC */
+ do {
+ nRegData = RegGet16BitValue(0x3CE4);
+ } while (nRegData != 0xD0BC);
+
+ RegSet16BitValue(0x3CE4, 0x2F43);
+ }
+
+ if ((eEmemType == EMEM_ALL) || (eEmemType == EMEM_MAIN))
+ /* write file done and check crc */
+ RegSet16BitValue(0x3CE4, 0x1380);
+
+ mdelay(10);
+
+ if ((eEmemType == EMEM_ALL) || (eEmemType == EMEM_MAIN)) {
+ /* Polling 0x3CE4 is 0x9432 */
+ do {
+ nRegData = RegGet16BitValue(0x3CE4);
+ } while (nRegData != 0x9432);
+ }
+
+ nCrcMain = nCrcMain ^ 0xffffffff;
+ nCrcInfo = nCrcInfo ^ 0xffffffff;
+
+ if ((eEmemType == EMEM_ALL) || (eEmemType == EMEM_MAIN)) {
+ /* CRC Main from TP */
+ nCrcMainTp = RegGet16BitValue(0x3C80);
+ nCrcMainTp = (nCrcMainTp << 16) | RegGet16BitValue(0x3C82);
+
+ /* CRC Info from TP */
+ nCrcInfoTp = RegGet16BitValue(0x3CA0);
+ nCrcInfoTp = (nCrcInfoTp << 16) | RegGet16BitValue(0x3CA2);
+ }
+
+ DBG("nCrcMain=0x%x, nCrcInfo=0x%x, nCrcMainTp=0x%x, nCrcInfoTp=0x%x\n",
+ nCrcMain, nCrcInfo, nCrcMainTp, nCrcInfoTp);
+
+ g_FwDataCount = 0; /* Reset g_FwDataCount to 0 after update firmware */
+
+ DbBusIICNotUseBus();
+ DbBusNotStopMCU();
+ DbBusExitSerialDebugMode();
+
+ DrvPlatformLyrTouchDeviceResetHw();
+
+
+ if ((eEmemType == EMEM_ALL) || (eEmemType == EMEM_MAIN)) {
+ if ((nCrcMainTp != nCrcMain) || (nCrcInfoTp != nCrcInfo)) {
+ DBG("Update FAILED\n");
+ return -1;
+ }
+ }
+
+ DBG("Update SUCCESS\n");
+
+ return 0;
+}
+
+static s32 _DrvFwCtrlMsg22xxUpdateFirmware(u8 szFwData[][1024],
+ enum EmemType_e eEmemType)
+{
+ u32 i, index;
+ u32 nCrcMain, nCrcMainTp;
+ u32 nCrcInfo = 0, nCrcInfoTp = 0;
+ u32 nRemainSize, nBlockSize, nSize;
+ u16 nRegData = 0;
+
+ u8 szDbBusTxData[1024] = {0};
+ u32 nSizePerWrite = 1021;
+
+ DBG("*** %s() ***\n", __func__);
+
+
+ _DrvFwCtrlMsg22xxConvertFwDataTwoDimenToOneDimen(szFwData,
+ _gOneDimenFwData);
+
+ DrvPlatformLyrTouchDeviceResetHw();
+
+ DbBusEnterSerialDebugMode();
+ DbBusStopMCU();
+ DbBusIICUseBus();
+ DbBusIICReshape();
+
+ DBG("Erase start\n");
+
+ /* Stop mcu */
+ RegSet16BitValue(0x0FE6, 0x0001);
+
+ /* Disable watchdog */
+ RegSetLByteValue(0x3C60, 0x55);
+ RegSetLByteValue(0x3C61, 0xAA);
+
+ /* Set PROGRAM password */
+ RegSetLByteValue(0x161A, 0xBA);
+ RegSetLByteValue(0x161B, 0xAB);
+
+ if (eEmemType == EMEM_ALL) { /* 48KB + 512Byte */
+ DBG("Erase all block\n");
+
+ /* Clear pce */
+ RegSetLByteValue(0x1618, 0x80);
+ mdelay(100);
+
+ /* Chip erase */
+ RegSet16BitValue(0x160E, BIT3);
+
+ DBG("Wait erase done flag\n");
+
+ do { /* Wait erase done flag */
+ nRegData = RegGet16BitValue(0x1610); /* Memory status */
+ mdelay(50);
+ } while ((nRegData & BIT1) != BIT1);
+ } else if (eEmemType == EMEM_MAIN) { /* 48KB (32+8+8) */
+ DBG("Erase main block\n");
+
+ for (i = 0; i < 3; i++) {
+ /* Clear pce */
+ RegSetLByteValue(0x1618, 0x80);
+ mdelay(10);
+
+ if (i == 0)
+ RegSet16BitValue(0x1600, 0x0000);
+ else if (i == 1)
+ RegSet16BitValue(0x1600, 0x8000);
+ else if (i == 2)
+ RegSet16BitValue(0x1600, 0xA000);
+
+ /* Sector erase */
+ RegSet16BitValue(0x160E,
+ (RegGet16BitValue(0x160E) | BIT2));
+
+ DBG("Wait erase done flag\n");
+
+ do { /* Wait erase done flag */
+ /* Memory status */
+ nRegData = RegGet16BitValue(0x1610);
+ mdelay(50);
+ } while ((nRegData & BIT1) != BIT1);
+ }
+ } else if (eEmemType == EMEM_INFO) {/* 512Byte */
+ DBG("Erase info block\n");
+
+ /* Clear pce */
+ RegSetLByteValue(0x1618, 0x80);
+ mdelay(10);
+
+ RegSet16BitValue(0x1600, 0xC000);
+
+ /* Sector erase */
+ RegSet16BitValue(0x160E, (RegGet16BitValue(0x160E) | BIT2));
+
+ DBG("Wait erase done flag\n");
+
+ do { /* Wait erase done flag */
+ nRegData = RegGet16BitValue(0x1610); /* Memory status */
+ mdelay(50);
+ } while ((nRegData & BIT1) != BIT1);
+ }
+
+ DBG("Erase end\n");
+
+ /* Hold reset pin before program */
+ RegSetLByteValue(0x1E06, 0x00);
+
+ /* Program */
+
+ if (eEmemType == EMEM_ALL || eEmemType == EMEM_MAIN) { /* 48KB */
+ DBG("Program main block start\n");
+
+ /* Program main block */
+ RegSet16BitValue(0x161A, 0xABBA);
+ RegSet16BitValue(0x1618, (RegGet16BitValue(0x1618) | 0x80));
+
+ /* Set start address of main block */
+ RegSet16BitValue(0x1600, 0x0000);
+ /* Enable burst mode */
+ RegSet16BitValue(0x160C, (RegGet16BitValue(0x160C) | 0x01));
+
+ /* Program start */
+ szDbBusTxData[0] = 0x10;
+ szDbBusTxData[1] = 0x16;
+ szDbBusTxData[2] = 0x02;
+
+ IicWriteData(SLAVE_I2C_ID_DBBUS, &szDbBusTxData[0], 3);
+
+ szDbBusTxData[0] = 0x20;
+
+ IicWriteData(SLAVE_I2C_ID_DBBUS, &szDbBusTxData[0], 1);
+
+ nRemainSize = MSG22XX_FIRMWARE_MAIN_BLOCK_SIZE * 1024;/* 48KB */
+ index = 0;
+
+ while (nRemainSize > 0) {
+ if (nRemainSize > nSizePerWrite)
+ nBlockSize = nSizePerWrite;
+ else
+ nBlockSize = nRemainSize;
+
+ szDbBusTxData[0] = 0x10;
+ szDbBusTxData[1] = 0x16;
+ szDbBusTxData[2] = 0x02;
+
+ nSize = 3;
+
+ for (i = 0; i < nBlockSize; i++) {
+ szDbBusTxData[3+i] =
+ _gOneDimenFwData[index*nSizePerWrite+i];
+ nSize++;
+ }
+
+ index++;
+
+ IicWriteData(SLAVE_I2C_ID_DBBUS,
+ &szDbBusTxData[0], nSize);
+
+ nRemainSize = nRemainSize - nBlockSize;
+ }
+
+ /* Program end */
+ szDbBusTxData[0] = 0x21;
+
+ IicWriteData(SLAVE_I2C_ID_DBBUS, &szDbBusTxData[0], 1);
+
+ nRegData = RegGet16BitValue(0x160C);
+ RegSet16BitValue(0x160C, nRegData & (~0x01));
+
+ DBG("Wait main block write done flag\n");
+
+ /* Polling 0x1610 is 0x0002 */
+ do {
+ nRegData = RegGet16BitValue(0x1610);
+ nRegData = nRegData & BIT1;
+ mdelay(10);
+
+ } while (nRegData != BIT1); /* Wait write done flag */
+
+ DBG("Program main block end\n");
+ }
+
+ if (eEmemType == EMEM_ALL || eEmemType == EMEM_INFO) { /* 512 Byte */
+ DBG("Program info block start\n");
+
+ /* Program info block */
+ RegSet16BitValue(0x161A, 0xABBA);
+ RegSet16BitValue(0x1618, (RegGet16BitValue(0x1618) | 0x80));
+
+ /* Set start address of info block */
+ RegSet16BitValue(0x1600, 0xC000);
+ /* Enable burst mode */
+ RegSet16BitValue(0x160C, (RegGet16BitValue(0x160C) | 0x01));
+
+ /* Program start */
+ szDbBusTxData[0] = 0x10;
+ szDbBusTxData[1] = 0x16;
+ szDbBusTxData[2] = 0x02;
+
+ IicWriteData(SLAVE_I2C_ID_DBBUS, &szDbBusTxData[0], 3);
+
+ szDbBusTxData[0] = 0x20;
+
+ IicWriteData(SLAVE_I2C_ID_DBBUS, &szDbBusTxData[0], 1);
+
+ nRemainSize = MSG22XX_FIRMWARE_INFO_BLOCK_SIZE; /* 512Byte */
+ index = 0;
+
+ while (nRemainSize > 0) {
+ if (nRemainSize > nSizePerWrite)
+ nBlockSize = nSizePerWrite;
+ else
+ nBlockSize = nRemainSize;
+
+ szDbBusTxData[0] = 0x10;
+ szDbBusTxData[1] = 0x16;
+ szDbBusTxData[2] = 0x02;
+
+ nSize = 3;
+
+ for (i = 0; i < nBlockSize; i++) {
+ szDbBusTxData[3+i] =
+ _gOneDimenFwData[
+ MSG22XX_FIRMWARE_MAIN_BLOCK_SIZE*1024 +
+ index*nSizePerWrite + i];
+ nSize++;
+ }
+
+ index++;
+
+ IicWriteData(SLAVE_I2C_ID_DBBUS,
+ &szDbBusTxData[0], nSize);
+
+ nRemainSize = nRemainSize - nBlockSize;
+ }
+
+ /* Program end */
+ szDbBusTxData[0] = 0x21;
+
+ IicWriteData(SLAVE_I2C_ID_DBBUS, &szDbBusTxData[0], 1);
+
+ nRegData = RegGet16BitValue(0x160C);
+ RegSet16BitValue(0x160C, nRegData & (~0x01));
+
+ DBG("Wait info block write done flag\n");
+
+ /* Polling 0x1610 is 0x0002 */
+ do {
+ nRegData = RegGet16BitValue(0x1610);
+ nRegData = nRegData & BIT1;
+ mdelay(10);
+
+ } while (nRegData != BIT1); /* Wait write done flag */
+
+ DBG("Program info block end\n");
+ }
+
+ if (eEmemType == EMEM_ALL || eEmemType == EMEM_MAIN) {
+ /* Get CRC 32 from updated firmware bin file */
+ nCrcMain = _gOneDimenFwData[0xBFFF] << 24;
+ nCrcMain |= _gOneDimenFwData[0xBFFE] << 16;
+ nCrcMain |= _gOneDimenFwData[0xBFFD] << 8;
+ nCrcMain |= _gOneDimenFwData[0xBFFC];
+
+ /* CRC Main from TP */
+ DBG("Get Main CRC from TP\n");
+
+ nCrcMainTp = _DrvFwCtrlMsg22xxGetFirmwareCrcByHardware(
+ EMEM_MAIN);
+
+ DBG("nCrcMain=0x%x, nCrcMainTp=0x%x\n", nCrcMain, nCrcMainTp);
+ }
+
+ if (eEmemType == EMEM_ALL || eEmemType == EMEM_INFO) {
+ nCrcInfo = _gOneDimenFwData[0xC1FF] << 24;
+ nCrcInfo |= _gOneDimenFwData[0xC1FE] << 16;
+ nCrcInfo |= _gOneDimenFwData[0xC1FD] << 8;
+ nCrcInfo |= _gOneDimenFwData[0xC1FC];
+
+ /* CRC Info from TP */
+ DBG("Get Info CRC from TP\n");
+
+ nCrcInfoTp = _DrvFwCtrlMsg22xxGetFirmwareCrcByHardware(
+ EMEM_INFO);
+
+ DBG("nCrcInfo=0x%x, nCrcInfoTp=0x%x\n", nCrcInfo, nCrcInfoTp);
+ }
+
+ g_FwDataCount = 0; /* Reset g_FwDataCount to 0 after update firmware */
+
+ DbBusIICNotUseBus();
+ DbBusNotStopMCU();
+ DbBusExitSerialDebugMode();
+
+ DrvPlatformLyrTouchDeviceResetHw();
+
+
+ if (eEmemType == EMEM_ALL) {
+ if ((nCrcMainTp != nCrcMain) || (nCrcInfoTp != nCrcInfo)) {
+ DBG("Update FAILED\n");
+
+ return -1;
+ }
+ } else if (eEmemType == EMEM_MAIN) {
+ if (nCrcMainTp != nCrcMain) {
+ DBG("Update FAILED\n");
+
+ return -1;
+ }
+ } else if (eEmemType == EMEM_INFO) {
+ if (nCrcInfoTp != nCrcInfo) {
+ DBG("Update FAILED\n");
+
+ return -1;
+ }
+ }
+
+ DBG("Update SUCCESS\n");
+
+ return 0;
+}
+
+static s32 _DrvFwCtrlUpdateFirmwareCash(u8 szFwData[][1024])
+{
+ DBG("*** %s() ***\n", __func__);
+
+ DBG("g_ChipType = 0x%x\n", g_ChipType);
+
+ if (g_ChipType == CHIP_TYPE_MSG21XXA) {
+ u8 nChipVersion = 0;
+
+ DrvPlatformLyrTouchDeviceResetHw();
+
+ /* Erase TP Flash first */
+ DbBusEnterSerialDebugMode();
+ DbBusStopMCU();
+ DbBusIICUseBus();
+ DbBusIICReshape();
+ mdelay(100);
+
+ /* Stop MCU */
+ RegSetLByteValue(0x0FE6, 0x01);
+
+ /* Disable watchdog */
+ RegSet16BitValue(0x3C60, 0xAA55);
+
+ /* Difference between C2 and C3 */
+ /* c2:MSG2133(1) c32:MSG2133A(2) c33:MSG2138A(2) */
+ /* check ic type */
+ /* nChipType = RegGet16BitValue(0x1ECC) & 0xFF; */
+
+ /* check ic version */
+ nChipVersion = RegGet16BitValue(0x3CEA) & 0xFF;
+
+ DBG("chip version = 0x%x\n", nChipVersion);
+
+ if (nChipVersion == 3)
+ return _DrvFwCtrlUpdateFirmwareC33(szFwData, EMEM_MAIN);
+ else
+ return _DrvFwCtrlUpdateFirmwareC32(szFwData, EMEM_ALL);
+ } else if (g_ChipType == CHIP_TYPE_MSG22XX) { /* (0x7A) */
+ _DrvFwCtrlMsg22xxGetTpVendorCode(_gTpVendorCode);
+
+ /*
+ * for specific TP vendor which store some important
+ * information in info block, only update firmware for
+ * main block, do not update firmware for info block.
+ */
+ if (_gTpVendorCode[0] == 'C' && _gTpVendorCode[1] == 'N' &&
+ _gTpVendorCode[2] == 'T')
+ return _DrvFwCtrlMsg22xxUpdateFirmware(szFwData,
+ EMEM_MAIN);
+ else
+ return _DrvFwCtrlMsg22xxUpdateFirmware(szFwData,
+ EMEM_ALL);
+ } else { /* CHIP_TYPE_MSG21XX (0x01) */
+ DBG("Can not update firmware. Catch-2 is no need ",
+ "to be maintained now.\n");
+ /* Reset g_FwDataCount to 0 after update firmware */
+ g_FwDataCount = 0;
+
+ return -1;
+ }
+}
+
+static s32 _DrvFwCtrlUpdateFirmwareBySdCard(const char *pFilePath)
+{
+ s32 nRetVal = 0;
+ struct file *pfile = NULL;
+ struct inode *inode;
+ s32 fsize = 0;
+ u8 *pbt_buf = NULL;
+ mm_segment_t old_fs;
+ loff_t pos;
+ u16 eSwId = 0x0000;
+ u16 eVendorId = 0x0000;
+
+ DBG("*** %s() ***\n", __func__);
+
+ pfile = filp_open(pFilePath, O_RDONLY, 0);
+ if (IS_ERR(pfile)) {
+ DBG("Error occured while opening file %s.\n", pFilePath);
+ return -1;
+ }
+
+ inode = pfile->f_dentry->d_inode;
+ fsize = inode->i_size;
+
+ DBG("fsize = %d\n", fsize);
+
+ if (fsize <= 0) {
+ filp_close(pfile, NULL);
+ return -1;
+ }
+
+ /* read firmware */
+ pbt_buf = kmalloc(fsize, GFP_KERNEL);
+
+ old_fs = get_fs();
+ set_fs(KERNEL_DS);
+
+ pos = 0;
+ vfs_read(pfile, pbt_buf, fsize, &pos);
+
+ filp_close(pfile, NULL);
+ set_fs(old_fs);
+
+ _DrvFwCtrlStoreFirmwareData(pbt_buf, fsize);
+
+ kfree(pbt_buf);
+
+ DrvPlatformLyrDisableFingerTouchReport();
+
+ DrvPlatformLyrTouchDeviceResetHw();
+
+ if (g_ChipType == CHIP_TYPE_MSG21XXA) {
+ eVendorId = g_FwData[31][0x34F] << 8 | g_FwData[31][0x34E];
+ eSwId = _DrvFwCtrlMsg21xxaGetSwId(EMEM_MAIN);
+ } else if (g_ChipType == CHIP_TYPE_MSG22XX) {
+ eVendorId = g_FwData[47][1013] << 8 | g_FwData[47][1012];
+ eSwId = _DrvFwCtrlMsg22xxGetSwId(EMEM_MAIN);
+ }
+
+ DBG("eVendorId = 0x%x, eSwId = 0x%x\n", eVendorId, eSwId);
+
+ if (eSwId == eVendorId) {
+ /* 33KB && 48.5KB*/
+ if ((g_ChipType == CHIP_TYPE_MSG21XXA && fsize == 33792) ||
+ (g_ChipType == CHIP_TYPE_MSG22XX && fsize == 49664)) {
+ nRetVal = _DrvFwCtrlUpdateFirmwareCash(g_FwData);
+ } else {
+ DBG("The file size of the update firmware bin file is ",
+ "not supported, fsize = %d\n", fsize);
+ nRetVal = -1;
+ }
+ } else {
+ DBG("The vendor id of the update firmware bin file is ",
+ "different from the vendor id on e-flash.\n");
+ nRetVal = -1;
+ }
+
+ g_FwDataCount = 0; /* Reset g_FwDataCount to 0 after update firmware */
+
+ DrvPlatformLyrEnableFingerTouchReport();
+
+ return nRetVal;
+}
+
+void DrvFwCtrlOptimizeCurrentConsumption(void)
+{
+ u32 i;
+ u8 szDbBusTxData[27] = {0};
+
+ DBG("g_ChipType = 0x%x\n", g_ChipType);
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+ if (g_GestureWakeupFlag == 1)
+ return;
+
+#endif /* CONFIG_ENABLE_GESTURE_WAKEUP */
+
+ if (g_ChipType == CHIP_TYPE_MSG22XX) {
+ DBG("*** %s() ***\n", __func__);
+
+ DrvPlatformLyrTouchDeviceResetHw();
+
+ DbBusEnterSerialDebugMode();
+ DbBusStopMCU();
+ DbBusIICUseBus();
+ DbBusIICReshape();
+
+ RegSet16BitValue(0x1618, (RegGet16BitValue(0x1618) | 0x80));
+
+ /* Enable burst mode */
+ RegSet16BitValue(0x160C, (RegGet16BitValue(0x160C) | 0x01));
+
+ szDbBusTxData[0] = 0x10;
+ szDbBusTxData[1] = 0x11;
+ szDbBusTxData[2] = 0xA0; /* bank:0x11, addr:h0050 */
+
+ for (i = 0; i < 24; i++)
+ szDbBusTxData[i+3] = 0x11;
+
+ /* write 0x1111 for reg 0x1150~0x115B */
+ IicWriteData(SLAVE_I2C_ID_DBBUS, &szDbBusTxData[0], 3+24);
+
+ szDbBusTxData[0] = 0x10;
+ szDbBusTxData[1] = 0x11;
+ szDbBusTxData[2] = 0xB8; /* bank:0x11, addr:h005C */
+
+ for (i = 0; i < 6; i++)
+ szDbBusTxData[i+3] = 0xFF;
+
+ /* Write 0xFF for reg 0x115C~0x115E */
+ IicWriteData(SLAVE_I2C_ID_DBBUS, &szDbBusTxData[0], 3+6);
+
+ /* Clear burst mode */
+ RegSet16BitValue(0x160C, RegGet16BitValue(0x160C) & (~0x01));
+
+ DbBusIICNotUseBus();
+ DbBusNotStopMCU();
+ DbBusExitSerialDebugMode();
+ }
+}
+
+u8 DrvFwCtrlGetChipType(void)
+{
+ u8 nChipType = 0;
+
+ DBG("*** %s() ***\n", __func__);
+
+ DrvPlatformLyrTouchDeviceResetHw();
+
+ /* Erase TP Flash first */
+ DbBusEnterSerialDebugMode();
+ DbBusStopMCU();
+ DbBusIICUseBus();
+ DbBusIICReshape();
+ mdelay(100);
+
+ /* Stop MCU */
+ RegSetLByteValue(0x0FE6, 0x01);
+
+ /* Disable watchdog */
+ RegSet16BitValue(0x3C60, 0xAA55);
+
+ /* Difference between C2 and C3 */
+ /* c2:MSG2133(1) c32:MSG2133A(2) c33:MSG2138A(2) */
+ /* check ic type */
+ nChipType = RegGet16BitValue(0x1ECC) & 0xFF;
+
+ if (nChipType != CHIP_TYPE_MSG21XX && /* (0x01) */
+ nChipType != CHIP_TYPE_MSG21XXA && /* (0x02) */
+ nChipType != CHIP_TYPE_MSG26XXM && /* (0x03) */
+ nChipType != CHIP_TYPE_MSG22XX) /* (0x7A) */
+ nChipType = 0;
+
+ DBG("*** Chip Type = 0x%x ***\n", nChipType);
+
+ DbBusIICNotUseBus();
+ DbBusNotStopMCU();
+ DbBusExitSerialDebugMode();
+
+ DrvPlatformLyrTouchDeviceResetHw();
+
+ return nChipType;
+}
+
+void DrvFwCtrlGetCustomerFirmwareVersion(u16 *pMajor, u16 *pMinor,
+ u8 **ppVersion)
+{
+ DBG("*** %s() ***\n", __func__);
+
+ if (g_ChipType == CHIP_TYPE_MSG21XXA ||
+ g_ChipType == CHIP_TYPE_MSG21XX) {
+ u8 szDbBusTxData[3] = {0};
+ u8 szDbBusRxData[4] = {0};
+
+ szDbBusTxData[0] = 0x53;
+ szDbBusTxData[1] = 0x00;
+
+ if (g_ChipType == CHIP_TYPE_MSG21XXA)
+ szDbBusTxData[2] = 0x2A;
+ else if (g_ChipType == CHIP_TYPE_MSG21XX)
+ szDbBusTxData[2] = 0x74;
+ else
+ szDbBusTxData[2] = 0x2A;
+
+ mutex_lock(&g_Mutex);
+
+ DrvPlatformLyrTouchDeviceResetHw();
+
+ IicWriteData(SLAVE_I2C_ID_DWI2C, &szDbBusTxData[0], 3);
+ IicReadData(SLAVE_I2C_ID_DWI2C, &szDbBusRxData[0], 4);
+
+ mutex_unlock(&g_Mutex);
+
+ *pMajor = (szDbBusRxData[1]<<8) + szDbBusRxData[0];
+ *pMinor = (szDbBusRxData[3]<<8) + szDbBusRxData[2];
+ } else if (g_ChipType == CHIP_TYPE_MSG22XX) {
+ u16 nRegData1, nRegData2;
+
+ mutex_lock(&g_Mutex);
+
+ DrvPlatformLyrTouchDeviceResetHw();
+
+ DbBusEnterSerialDebugMode();
+ DbBusStopMCU();
+ DbBusIICUseBus();
+ DbBusIICReshape();
+ mdelay(100);
+
+ /* Stop mcu */
+ RegSetLByteValue(0x0FE6, 0x01);
+
+ /* Stop watchdog */
+ RegSet16BitValue(0x3C60, 0xAA55);
+
+ /* RIU password */
+ RegSet16BitValue(0x161A, 0xABBA);
+
+ /* Clear pce */
+ RegSet16BitValue(0x1618, (RegGet16BitValue(0x1618) | 0x80));
+
+ /*
+ * Set start address for customer
+ * firmware version on main block
+ */
+ RegSet16BitValue(0x1600, 0xBFF4);
+
+ /* Enable burst mode */
+ /*
+ * RegSet16BitValue(0x160C, (RegGet16BitValue(0x160C) | 0x01));
+ */
+
+ /* Set pce */
+ RegSet16BitValue(0x1618, (RegGet16BitValue(0x1618) | 0x40));
+
+ RegSetLByteValue(0x160E, 0x01);
+
+ nRegData1 = RegGet16BitValue(0x1604);
+ nRegData2 = RegGet16BitValue(0x1606);
+
+ *pMajor = (((nRegData1 >> 8) & 0xFF) << 8) + (nRegData1 & 0xFF);
+ *pMinor = (((nRegData2 >> 8) & 0xFF) << 8) + (nRegData2 & 0xFF);
+
+ /* Clear burst mode */
+ /*
+ * RegSet16BitValue(0x160C, RegGet16BitValue(0x160C) & (~0x01));
+ */
+
+ RegSet16BitValue(0x1600, 0x0000);
+
+ /* Clear RIU password */
+ RegSet16BitValue(0x161A, 0x0000);
+
+ DbBusIICNotUseBus();
+ DbBusNotStopMCU();
+ DbBusExitSerialDebugMode();
+
+ DrvPlatformLyrTouchDeviceResetHw();
+
+ mutex_unlock(&g_Mutex);
+ }
+
+ DBG("*** major = %d ***\n", *pMajor);
+ DBG("*** minor = %d ***\n", *pMinor);
+
+ if (*ppVersion == NULL)
+ *ppVersion = kzalloc(sizeof(u8)*6, GFP_KERNEL);
+
+ sprintf(*ppVersion, "%03d%03d", *pMajor, *pMinor);
+}
+
+void DrvFwCtrlGetPlatformFirmwareVersion(u8 **ppVersion)
+{
+ u32 i;
+ u16 nRegData1, nRegData2;
+ u8 szDbBusRxData[12] = {0};
+
+ DBG("*** %s() ***\n", __func__);
+
+ mutex_lock(&g_Mutex);
+
+ DrvPlatformLyrTouchDeviceResetHw();
+
+ DbBusEnterSerialDebugMode();
+ DbBusStopMCU();
+ DbBusIICUseBus();
+ DbBusIICReshape();
+ mdelay(100);
+
+ /* Only MSG22XX support platform firmware version */
+ if (g_ChipType == CHIP_TYPE_MSG22XX) {
+ /* Stop mcu */
+ RegSetLByteValue(0x0FE6, 0x01);
+
+ /* Stop watchdog */
+ RegSet16BitValue(0x3C60, 0xAA55);
+
+ /* RIU password */
+ RegSet16BitValue(0x161A, 0xABBA);
+
+ /* Clear pce */
+ RegSet16BitValue(0x1618, (RegGet16BitValue(0x1618) | 0x80));
+
+ /*
+ * Set start address for platform firmware version on info
+ * block(Actually, start reading from 0xC1F0)
+ */
+ RegSet16BitValue(0x1600, 0xC1F2);
+
+ /* Enable burst mode */
+ RegSet16BitValue(0x160C, (RegGet16BitValue(0x160C) | 0x01));
+
+ /* Set pce */
+ RegSet16BitValue(0x1618, (RegGet16BitValue(0x1618) | 0x40));
+
+ for (i = 0; i < 3; i++) {
+ RegSetLByteValue(0x160E, 0x01);
+
+ nRegData1 = RegGet16BitValue(0x1604);
+ nRegData2 = RegGet16BitValue(0x1606);
+
+ szDbBusRxData[i*4+0] = (nRegData1 & 0xFF);
+ szDbBusRxData[i*4+1] = ((nRegData1 >> 8) & 0xFF);
+
+ szDbBusRxData[i*4+2] = (nRegData2 & 0xFF);
+ szDbBusRxData[i*4+3] = ((nRegData2 >> 8) & 0xFF);
+ }
+
+ /* Clear burst mode */
+ RegSet16BitValue(0x160C, RegGet16BitValue(0x160C) & (~0x01));
+
+ RegSet16BitValue(0x1600, 0x0000);
+
+ /* Clear RIU password */
+ RegSet16BitValue(0x161A, 0x0000);
+
+ if (*ppVersion == NULL)
+ *ppVersion = kzalloc(sizeof(u8)*10, GFP_KERNEL);
+
+ sprintf(*ppVersion, "%c%c%c%c%c%c%c%c%c%c",
+ szDbBusRxData[2], szDbBusRxData[3],
+ szDbBusRxData[4], szDbBusRxData[5],
+ szDbBusRxData[6], szDbBusRxData[7],
+ szDbBusRxData[8], szDbBusRxData[9],
+ szDbBusRxData[10], szDbBusRxData[11]);
+ } else {
+ if (*ppVersion == NULL)
+ *ppVersion = kzalloc(sizeof(u8)*10, GFP_KERNEL);
+
+ sprintf(*ppVersion, "%s", "N/A");
+ }
+
+ DbBusIICNotUseBus();
+ DbBusNotStopMCU();
+ DbBusExitSerialDebugMode();
+
+ DrvPlatformLyrTouchDeviceResetHw();
+
+ mutex_unlock(&g_Mutex);
+
+ DBG("*** platform firmware version = %s ***\n", *ppVersion);
+}
+
+s32 DrvFwCtrlUpdateFirmware(u8 szFwData[][1024], enum EmemType_e eEmemType)
+{
+ DBG("*** %s() ***\n", __func__);
+
+ return _DrvFwCtrlUpdateFirmwareCash(szFwData);
+}
+
+s32 DrvFwCtrlUpdateFirmwareBySdCard(const char *pFilePath)
+{
+ s32 nRetVal = -1;
+
+ DBG("*** %s() ***\n", __func__);
+
+ if (g_ChipType == CHIP_TYPE_MSG21XXA ||
+ g_ChipType == CHIP_TYPE_MSG22XX)
+ nRetVal = _DrvFwCtrlUpdateFirmwareBySdCard(pFilePath);
+ else
+ DBG("This chip type (%d) does not support update firmware ",
+ "by sd card\n", g_ChipType);
+
+ return nRetVal;
+}
+
+void DrvFwCtrlHandleFingerTouch(void)
+{
+ struct TouchInfo_t tInfo;
+ u32 i;
+ u8 nTouchKeyCode = 0;
+ static u32 nLastKeyCode;
+ u8 *pPacket = NULL;
+ u16 nReportPacketLength = 0;
+
+ if (_gIsDisableFinagerTouch == 1) {
+ DBG("Skip finger touch for handling get firmware info ",
+ "or change firmware mode\n");
+ return;
+ }
+
+ mutex_lock(&g_Mutex);
+
+ memset(&tInfo, 0x0, sizeof(tInfo));
+
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+ if (g_FirmwareMode == FIRMWARE_MODE_DEMO_MODE) {
+ DBG("FIRMWARE_MODE_DEMO_MODE\n");
+
+ nReportPacketLength = DEMO_MODE_PACKET_LENGTH;
+ pPacket = g_DemoModePacket;
+ } else if (g_FirmwareMode == FIRMWARE_MODE_DEBUG_MODE) {
+ DBG("FIRMWARE_MODE_DEBUG_MODE\n");
+
+ if (g_FirmwareInfo.nLogModePacketHeader != 0x62) {
+ DBG("WRONG DEBUG MODE HEADER : 0x%x\n",
+ g_FirmwareInfo.nLogModePacketHeader);
+ goto End;
+ }
+
+ nReportPacketLength = g_FirmwareInfo.nLogModePacketLength;
+ pPacket = g_LogModePacket;
+ } else if (g_FirmwareMode == FIRMWARE_MODE_RAW_DATA_MODE) {
+ DBG("FIRMWARE_MODE_RAW_DATA_MODE\n");
+
+ if (g_FirmwareInfo.nLogModePacketHeader != 0x62) {
+ DBG("WRONG RAW DATA MODE HEADER : 0x%x\n",
+ g_FirmwareInfo.nLogModePacketHeader);
+ goto End;
+ }
+
+ nReportPacketLength = g_FirmwareInfo.nLogModePacketLength;
+ pPacket = g_LogModePacket;
+ } else {
+ DBG("WRONG FIRMWARE MODE : 0x%x\n", g_FirmwareMode);
+ goto End;
+ }
+#else
+ DBG("FIRMWARE_MODE_DEMO_MODE\n");
+
+ nReportPacketLength = DEMO_MODE_PACKET_LENGTH;
+ pPacket = g_DemoModePacket;
+#endif /* CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+
+#ifdef CONFIG_ENABLE_GESTURE_DEBUG_MODE
+ if (g_GestureDebugMode == 1 && g_GestureWakeupFlag == 1) {
+ DBG("Set gesture debug mode packet length, g_ChipType=%d\n",
+ g_ChipType);
+
+ if (g_ChipType == CHIP_TYPE_MSG22XX) {
+ nReportPacketLength = GESTURE_DEBUG_MODE_PACKET_LENGTH;
+ pPacket = _gGestureWakeupPacket;
+ } else {
+ DBG("This chip type does not support gesture ",
+ "debug mode.\n");
+ goto End;
+ }
+ } else if (g_GestureWakeupFlag == 1) {
+ DBG("Set gesture wakeup packet length, g_ChipType=%d\n",
+ g_ChipType);
+
+ if (g_ChipType == CHIP_TYPE_MSG22XX) {
+#ifdef CONFIG_ENABLE_GESTURE_INFORMATION_MODE
+ nReportPacketLength =
+ GESTURE_WAKEUP_INFORMATION_PACKET_LENGTH;
+#else
+ nReportPacketLength = GESTURE_WAKEUP_PACKET_LENGTH;
+#endif /* CONFIG_ENABLE_GESTURE_INFORMATION_MODE */
+ pPacket = _gGestureWakeupPacket;
+ } else if (g_ChipType == CHIP_TYPE_MSG21XXA) {
+ nReportPacketLength = DEMO_MODE_PACKET_LENGTH;
+ pPacket = _gGestureWakeupPacket;
+ } else {
+ DBG("This chip type does not support ",
+ "gesture wakeup.\n");
+ goto End;
+ }
+ }
+
+#else
+
+ if (g_GestureWakeupFlag == 1) {
+ DBG("Set gesture wakeup packet length, g_ChipType=%d\n",
+ g_ChipType);
+
+ if (g_ChipType == CHIP_TYPE_MSG22XX) {
+#ifdef CONFIG_ENABLE_GESTURE_INFORMATION_MODE
+ nReportPacketLength =
+ GESTURE_WAKEUP_INFORMATION_PACKET_LENGTH;
+#else
+ nReportPacketLength = GESTURE_WAKEUP_PACKET_LENGTH;
+#endif /* CONFIG_ENABLE_GESTURE_INFORMATION_MODE */
+
+ pPacket = _gGestureWakeupPacket;
+ } else if (g_ChipType == CHIP_TYPE_MSG21XXA) {
+ nReportPacketLength = DEMO_MODE_PACKET_LENGTH;
+ pPacket = _gGestureWakeupPacket;
+ } else {
+ DBG("This chip type does not support ",
+ "gesture wakeup.\n");
+ goto End;
+ }
+ }
+#endif /* CONFIG_ENABLE_GESTURE_DEBUG_MODE */
+
+#endif /* CONFIG_ENABLE_GESTURE_WAKEUP */
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+ if (g_GestureWakeupFlag == 1) {
+ u32 i = 0, rc;
+
+ while (i < 5) {
+ mdelay(50);
+
+ rc = IicReadData(SLAVE_I2C_ID_DWI2C, &pPacket[0],
+ nReportPacketLength);
+
+ if (rc > 0)
+ break;
+
+ i++;
+ }
+ } else
+ IicReadData(SLAVE_I2C_ID_DWI2C, &pPacket[0],
+ nReportPacketLength);
+#else
+ IicReadData(SLAVE_I2C_ID_DWI2C, &pPacket[0], nReportPacketLength);
+#endif /* CONFIG_ENABLE_GESTURE_WAKEUP */
+
+ if (0 == _DrvFwCtrlParsePacket(pPacket, nReportPacketLength, &tInfo)) {
+ if ((tInfo.nFingerNum) == 0) { /* touch end */
+ if (nLastKeyCode != 0) {
+ DBG("key touch released\n");
+
+ input_report_key(g_InputDevice, BTN_TOUCH, 0);
+ input_report_key(g_InputDevice,
+ nLastKeyCode, 0);
+
+ input_sync(g_InputDevice);
+
+ nLastKeyCode = 0; /* clear key status.. */
+ } else {
+ DrvPlatformLyrFingerTouchReleased(0, 0);
+
+ input_sync(g_InputDevice);
+ }
+ } else { /* touch on screen */
+ if (tInfo.nTouchKeyCode != 0) {
+#ifdef CONFIG_TP_HAVE_KEY
+ /* TOUCH_KEY_HOME */
+ if (tInfo.nTouchKeyCode == 4)
+ nTouchKeyCode = g_TpVirtualKey[1];
+ /* TOUCH_KEY_MENU */
+ else if (tInfo.nTouchKeyCode == 1)
+ nTouchKeyCode = g_TpVirtualKey[0];
+ /* TOUCH_KEY_BACK */
+ else if (tInfo.nTouchKeyCode == 2)
+ nTouchKeyCode = g_TpVirtualKey[2];
+ /* TOUCH_KEY_SEARCH */
+ else if (tInfo.nTouchKeyCode == 8)
+ nTouchKeyCode = g_TpVirtualKey[3];
+
+ if (nLastKeyCode != nTouchKeyCode) {
+ DBG("key touch pressed\n");
+ DBG("nTouchKeyCode = %d, ",
+ "nLastKeyCode = %d\n",
+ nTouchKeyCode,
+ nLastKeyCode);
+
+ nLastKeyCode = nTouchKeyCode;
+
+ input_report_key(g_InputDevice,
+ BTN_TOUCH, 1);
+ input_report_key(g_InputDevice,
+ nTouchKeyCode, 1);
+
+ input_sync(g_InputDevice);
+ }
+#endif /* CONFIG_TP_HAVE_KEY */
+ } else {
+ DBG("tInfo->nFingerNum = %d...............\n",
+ tInfo.nFingerNum);
+
+ for (i = 0; i < tInfo.nFingerNum; i++)
+ DrvPlatformLyrFingerTouchPressed(
+ tInfo.tPoint[i].nX,
+ tInfo.tPoint[i].nY,
+ 0, 0);
+
+ input_sync(g_InputDevice);
+ }
+ }
+ }
+
+#if defined(CONFIG_ENABLE_FIRMWARE_DATA_LOG) || \
+ defined(CONFIG_ENABLE_GESTURE_WAKEUP)
+End:
+#endif
+ mutex_unlock(&g_Mutex);
+}
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+
+void DrvFwCtrlOpenGestureWakeup(u32 *pMode)
+{
+ u8 szDbBusTxData[4] = {0};
+ u32 i = 0;
+ s32 rc;
+
+ DBG("*** %s() ***\n", __func__);
+
+ DBG("wakeup mode 0 = 0x%x\n", pMode[0]);
+ DBG("wakeup mode 1 = 0x%x\n", pMode[1]);
+
+#ifdef CONFIG_SUPPORT_64_TYPES_GESTURE_WAKEUP_MODE
+ szDbBusTxData[0] = 0x59;
+ szDbBusTxData[1] = 0x00;
+ szDbBusTxData[2] = ((pMode[1] & 0xFF000000) >> 24);
+ szDbBusTxData[3] = ((pMode[1] & 0x00FF0000) >> 16);
+
+ while (i < 5) {
+ rc = IicWriteData(SLAVE_I2C_ID_DWI2C, &szDbBusTxData[0], 4);
+ udelay(1000); /* delay 1ms */
+
+ if (rc > 0) {
+ DBG("Enable gesture wakeup index 0 success\n");
+ break;
+ }
+
+ mdelay(10);
+ i++;
+ }
+
+ if (i == 5)
+ DBG("Enable gesture wakeup index 0 failed\n");
+
+ szDbBusTxData[0] = 0x59;
+ szDbBusTxData[1] = 0x01;
+ szDbBusTxData[2] = ((pMode[1] & 0x0000FF00) >> 8);
+ szDbBusTxData[3] = ((pMode[1] & 0x000000FF) >> 0);
+
+ while (i < 5) {
+ rc = IicWriteData(SLAVE_I2C_ID_DWI2C, &szDbBusTxData[0], 4);
+ udelay(1000); /* delay 1ms */
+
+ if (rc > 0) {
+ DBG("Enable gesture wakeup index 1 success\n");
+ break;
+ }
+
+ mdelay(10);
+ i++;
+ }
+
+ if (i == 5)
+ DBG("Enable gesture wakeup index 1 failed\n");
+
+ szDbBusTxData[0] = 0x59;
+ szDbBusTxData[1] = 0x02;
+ szDbBusTxData[2] = ((pMode[0] & 0xFF000000) >> 24);
+ szDbBusTxData[3] = ((pMode[0] & 0x00FF0000) >> 16);
+
+ while (i < 5) {
+ rc = IicWriteData(SLAVE_I2C_ID_DWI2C, &szDbBusTxData[0], 4);
+ udelay(1000); /* delay 1ms */
+
+ if (rc > 0) {
+ DBG("Enable gesture wakeup index 2 success\n");
+ break;
+ }
+
+ mdelay(10);
+ i++;
+ }
+
+ if (i == 5)
+ DBG("Enable gesture wakeup index 2 failed\n");
+
+ szDbBusTxData[0] = 0x59;
+ szDbBusTxData[1] = 0x03;
+ szDbBusTxData[2] = ((pMode[0] & 0x0000FF00) >> 8);
+ szDbBusTxData[3] = ((pMode[0] & 0x000000FF) >> 0);
+
+ while (i < 5) {
+ rc = IicWriteData(SLAVE_I2C_ID_DWI2C, &szDbBusTxData[0], 4);
+ udelay(1000); /* delay 1ms */
+
+ if (rc > 0) {
+ DBG("Enable gesture wakeup index 3 success\n");
+ break;
+ }
+
+ mdelay(10);
+ i++;
+ }
+
+ if (i == 5)
+ DBG("Enable gesture wakeup index 3 failed\n");
+
+ g_GestureWakeupFlag = 1; /* gesture wakeup is enabled */
+
+#else
+
+ szDbBusTxData[0] = 0x58;
+ szDbBusTxData[1] = ((pMode[0] & 0x0000FF00) >> 8);
+ szDbBusTxData[2] = ((pMode[0] & 0x000000FF) >> 0);
+
+ while (i < 5) {
+ rc = IicWriteData(SLAVE_I2C_ID_DWI2C, &szDbBusTxData[0], 3);
+
+ if (rc > 0) {
+ DBG("Enable gesture wakeup success\n");
+ break;
+ }
+
+ mdelay(10);
+ i++;
+ }
+
+ if (i == 5)
+ DBG("Enable gesture wakeup failed\n");
+
+ g_GestureWakeupFlag = 1; /* gesture wakeup is enabled */
+#endif /* CONFIG_SUPPORT_64_TYPES_GESTURE_WAKEUP_MODE */
+}
+
+void DrvFwCtrlCloseGestureWakeup(void)
+{
+ DBG("*** %s() ***\n", __func__);
+
+ g_GestureWakeupFlag = 0; /* gesture wakeup is disabled */
+}
+
+#ifdef CONFIG_ENABLE_GESTURE_DEBUG_MODE
+void DrvFwCtrlOpenGestureDebugMode(u8 nGestureFlag)
+{
+ u8 szDbBusTxData[3] = {0};
+ s32 rc;
+
+ DBG("*** %s() ***\n", __func__);
+
+ DBG("Gesture Flag = 0x%x\n", nGestureFlag);
+
+ szDbBusTxData[0] = 0x30;
+ szDbBusTxData[1] = 0x01;
+ szDbBusTxData[2] = nGestureFlag;
+
+ rc = IicWriteData(SLAVE_I2C_ID_DWI2C, &szDbBusTxData[0], 3);
+ if (rc < 0)
+ DBG("Enable gesture debug mode failed\n");
+ else
+ DBG("Enable gesture debug mode success\n");
+
+ g_GestureDebugMode = 1; /* gesture debug mode is enabled */
+}
+
+void DrvFwCtrlCloseGestureDebugMode(void)
+{
+ u8 szDbBusTxData[3] = {0};
+ s32 rc;
+
+ DBG("*** %s() ***\n", __func__);
+
+ szDbBusTxData[0] = 0x30;
+ szDbBusTxData[1] = 0x00;
+ szDbBusTxData[2] = 0x00;
+
+ rc = IicWriteData(SLAVE_I2C_ID_DWI2C, &szDbBusTxData[0], 3);
+ if (rc < 0)
+ DBG("Disable gesture debug mode failed\n");
+ else
+ DBG("Disable gesture debug mode success\n");
+
+ g_GestureDebugMode = 0; /* gesture debug mode is disabled */
+}
+#endif /* CONFIG_ENABLE_GESTURE_DEBUG_MODE */
+
+#ifdef CONFIG_ENABLE_GESTURE_INFORMATION_MODE
+static void _DrvFwCtrlCoordinate(u8 *pRawData, u32 *pTranX, u32 *pTranY)
+{
+ u32 nX;
+ u32 nY;
+#ifdef CONFIG_SWAP_X_Y
+ u32 nTempX;
+ u32 nTempY;
+#endif
+ /* parse the packet to coordinate */
+ nX = (((pRawData[0] & 0xF0) << 4) | pRawData[1]);
+ nY = (((pRawData[0] & 0x0F) << 8) | pRawData[2]);
+
+ DBG("[x,y]=[%d,%d]\n", nX, nY);
+
+#ifdef CONFIG_SWAP_X_Y
+ nTempY = nX;
+ nTempX = nY;
+ nX = nTempX;
+ nY = nTempY;
+#endif
+
+#ifdef CONFIG_REVERSE_X
+ nX = 2047 - nX;
+#endif
+
+#ifdef CONFIG_REVERSE_Y
+ nY = 2047 - nY;
+#endif
+
+ /*
+ * pRawData[0]~nRawData[2] : the point abs,
+ * pRawData[0]~nRawData[2] all are 0xFF, release touch
+ */
+ if ((pRawData[0] == 0xFF) && (pRawData[1] == 0xFF) &&
+ (pRawData[2] == 0xFF)) {
+ *pTranX = 0; /* final X coordinate */
+ *pTranY = 0; /* final Y coordinate */
+ } else {
+ /* one touch point */
+ *pTranX = (nX * TOUCH_SCREEN_X_MAX) / TPD_WIDTH;
+ *pTranY = (nY * TOUCH_SCREEN_Y_MAX) / TPD_HEIGHT;
+ DBG("[%s]: [x,y]=[%d,%d]\n", __func__, nX, nY);
+ DBG("[%s]: point[x,y]=[%d,%d]\n", __func__, *pTranX, *pTranY);
+ }
+}
+#endif /* CONFIG_ENABLE_GESTURE_INFORMATION_MODE */
+
+#endif /* CONFIG_ENABLE_GESTURE_WAKEUP */
+
+/* -------------------------------------------------------------------------- */
+
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+
+u16 DrvFwCtrlChangeFirmwareMode(u16 nMode)
+{
+ u8 szDbBusTxData[2] = {0};
+ u32 i = 0;
+ s32 rc;
+
+ DBG("*** %s() *** nMode = 0x%x\n", __func__, nMode);
+
+ /*
+ * Disable finger touch ISR handling temporarily for device driver
+ * can send change firmware mode i2c command to firmware.
+ */
+ _gIsDisableFinagerTouch = 1;
+
+ szDbBusTxData[0] = 0x02;
+ szDbBusTxData[1] = (u8)nMode;
+
+
+ mutex_lock(&g_Mutex);
+
+ while (i < 5) {
+ rc = IicWriteData(SLAVE_I2C_ID_DWI2C, &szDbBusTxData[0], 2);
+ if (rc > 0) {
+ DBG("Change firmware mode success\n");
+ break;
+ }
+
+ mdelay(10);
+ i++;
+ }
+
+ if (i == 5)
+ DBG("Change firmware mode failed, rc = %d\n", rc);
+
+ mutex_unlock(&g_Mutex);
+
+ _gIsDisableFinagerTouch = 0;
+
+ return nMode;
+}
+
+void DrvFwCtrlGetFirmwareInfo(struct FirmwareInfo_t *pInfo)
+{
+ u8 szDbBusTxData[1] = {0};
+ u8 szDbBusRxData[8] = {0};
+ u32 i = 0;
+ s32 rc;
+
+ DBG("*** %s() ***\n", __func__);
+
+ /*
+ * Disable finger touch ISR handling temporarily for device driver
+ * can send get firmware info i2c command to firmware.
+ */
+ _gIsDisableFinagerTouch = 1;
+
+ szDbBusTxData[0] = 0x01;
+
+ mutex_lock(&g_Mutex);
+
+ while (i < 5) {
+ rc = IicWriteData(SLAVE_I2C_ID_DWI2C, &szDbBusTxData[0], 1);
+ if (rc > 0)
+ DBG("Get firmware info IicWriteData() success\n");
+
+ mdelay(20);
+ rc = IicReadData(SLAVE_I2C_ID_DWI2C, &szDbBusRxData[0], 8);
+ if (rc > 0) {
+ DBG("Get firmware info IicReadData() success\n");
+ break;
+ }
+
+ mdelay(10);
+ i++;
+ }
+
+ if (i == 5)
+ DBG("Get firmware info failed, rc = %d\n", rc);
+
+ mutex_unlock(&g_Mutex);
+
+ if ((szDbBusRxData[1] & 0x80) == 0x80)
+ pInfo->nIsCanChangeFirmwareMode = 0;
+ else
+ pInfo->nIsCanChangeFirmwareMode = 1;
+
+ pInfo->nFirmwareMode = szDbBusRxData[1] & 0x7F;
+ pInfo->nLogModePacketHeader = szDbBusRxData[2];
+ pInfo->nLogModePacketLength = (szDbBusRxData[3]<<8) + szDbBusRxData[4];
+
+ DBG("pInfo->nFirmwareMode=0x%x, pInfo->nLogModePacketHeader=0x%x, ",
+ "pInfo->nLogModePacketLength=%d, ",
+ "pInfo->nIsCanChangeFirmwareMode=%d\n",
+ pInfo->nFirmwareMode, pInfo->nLogModePacketHeader,
+ pInfo->nLogModePacketLength,
+ pInfo->nIsCanChangeFirmwareMode);
+
+ _gIsDisableFinagerTouch = 0;
+}
+
+void DrvFwCtrlRestoreFirmwareModeToLogDataMode(void)
+{
+ DBG("*** %s() g_IsSwitchModeByAPK = %d ***\n", __func__,
+ g_IsSwitchModeByAPK);
+
+ if (g_IsSwitchModeByAPK == 1) {
+ struct FirmwareInfo_t tInfo;
+
+ memset(&tInfo, 0x0, sizeof(FirmwareInfo_t));
+
+ DrvFwCtrlGetFirmwareInfo(&tInfo);
+
+ DBG("g_FirmwareMode = 0x%x, tInfo.nFirmwareMode = 0x%x\n",
+ g_FirmwareMode, tInfo.nFirmwareMode);
+
+ /*
+ * Since reset_hw() will reset the firmware mode to demo mode,
+ * we must reset the firmware mode again after reset_hw().
+ */
+ if (g_FirmwareMode == FIRMWARE_MODE_DEBUG_MODE &&
+ FIRMWARE_MODE_DEBUG_MODE != tInfo.nFirmwareMode)
+ g_FirmwareMode = DrvFwCtrlChangeFirmwareMode(
+ FIRMWARE_MODE_DEBUG_MODE);
+ else if (g_FirmwareMode == FIRMWARE_MODE_RAW_DATA_MODE &&
+ FIRMWARE_MODE_RAW_DATA_MODE !=
+ tInfo.nFirmwareMode)
+ g_FirmwareMode = DrvFwCtrlChangeFirmwareMode(
+ FIRMWARE_MODE_RAW_DATA_MODE);
+ else
+ DBG("firmware mode is not restored\n");
+ }
+}
+#endif /* CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+
+
+#ifdef CONFIG_ENABLE_PROXIMITY_DETECTION
+
+s32 DrvFwCtrlEnableProximity(void)
+{
+ u8 szDbBusTxData[4] = {0};
+ s32 rc;
+
+ DBG("*** %s() ***\n", __func__);
+
+ szDbBusTxData[0] = 0x52;
+ szDbBusTxData[1] = 0x00;
+
+ if (g_ChipType == CHIP_TYPE_MSG21XX)
+ szDbBusTxData[2] = 0x62;
+ else if (g_ChipType == CHIP_TYPE_MSG21XXA ||
+ g_ChipType == CHIP_TYPE_MSG22XX)
+ szDbBusTxData[2] = 0x4a;
+ else {
+ DBG("*** Un-recognized chip type = 0x%x ***\n", g_ChipType);
+ return -1;
+ }
+
+ szDbBusTxData[3] = 0xa0;
+
+ mutex_lock(&g_Mutex);
+ rc = IicWriteData(SLAVE_I2C_ID_DWI2C, &szDbBusTxData[0], 4);
+ mutex_unlock(&g_Mutex);
+
+ if (rc > 0) {
+ g_EnableTpProximity = 1;
+ DBG("Enable proximity detection success\n");
+ } else {
+ g_EnableTpProximity = 0;
+ DBG("Enable proximity detection failed\n");
+ }
+
+ return rc;
+}
+
+s32 DrvFwCtrlDisableProximity(void)
+{
+ u8 szDbBusTxData[4] = {0};
+ s32 rc;
+
+ DBG("*** %s() ***\n", __func__);
+
+ szDbBusTxData[0] = 0x52;
+ szDbBusTxData[1] = 0x00;
+
+ if (g_ChipType == CHIP_TYPE_MSG21XX)
+ szDbBusTxData[2] = 0x62;
+ else if (g_ChipType == CHIP_TYPE_MSG21XXA ||
+ g_ChipType == CHIP_TYPE_MSG22XX)
+ szDbBusTxData[2] = 0x4a;
+ else {
+ DBG("*** Un-recognized chip type = 0x%x ***\n", g_ChipType);
+ return -1;
+ }
+
+ szDbBusTxData[3] = 0xa1;
+
+ mutex_lock(&g_Mutex);
+ rc = IicWriteData(SLAVE_I2C_ID_DWI2C, &szDbBusTxData[0], 4);
+ mutex_unlock(&g_Mutex);
+
+ if (rc > 0)
+ DBG("Disable proximity detection success\n");
+ else
+ DBG("Disable proximity detection failed\n");
+
+ g_EnableTpProximity = 0;
+ g_FaceClosingTp = 0;
+
+ return rc;
+}
+
+#endif /* CONFIG_ENABLE_PROXIMITY_DETECTION */
+#endif /* CONFIG_ENABLE_CHIP_MSG21XXA || CONFIG_ENABLE_CHIP_MSG22XX */
diff --git a/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_self_fw_control.h b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_self_fw_control.h
new file mode 100644
index 00000000000..5446a75934d
--- /dev/null
+++ b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_self_fw_control.h
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2006-2014 MStar Semiconductor, Inc.
+ * All rights reserved.
+
+ * Unless otherwise stipulated in writing, any and all information contained
+ * herein regardless in any format shall remain the sole proprietary of
+ * MStar Semiconductor Inc. and be kept in strict confidence
+ * (??MStar Confidential Information??) by the recipient.
+ * Any unauthorized act including without limitation unauthorized disclosure,
+ * copying, use, reproduction, sale, distribution, modification, disassembling,
+ * reverse engineering and compiling of the contents of MStar Confidential
+ * Information is unlawful and strictly prohibited. MStar hereby reserves the
+ * rights to any and all damages, losses, costs and expenses resulting
+ * therefrom.
+ */
+
+/**
+ *
+ * @file mstar_drv_self_fw_control.h
+ *
+ * @brief This file defines the interface of touch screen
+ *
+ *
+ */
+
+#ifndef __MSTAR_DRV_SELF_FW_CONTROL_H__
+#define __MSTAR_DRV_SELF_FW_CONTROL_H__
+
+/*--------------------------------------------------------------------------*/
+/* INCLUDE FILE */
+/*--------------------------------------------------------------------------*/
+
+#include "mstar_drv_common.h"
+
+#if defined(CONFIG_ENABLE_CHIP_MSG21XXA) || defined(CONFIG_ENABLE_CHIP_MSG22XX)
+
+/*--------------------------------------------------------------------------*/
+/* COMPILE OPTION DEFINITION */
+/*--------------------------------------------------------------------------*/
+
+/* #define CONFIG_SWAP_X_Y */
+
+/* #define CONFIG_REVERSE_X */
+/* #define CONFIG_REVERSE_Y */
+
+/*--------------------------------------------------------------------------*/
+/* PREPROCESSOR CONSTANT DEFINITION */
+/*--------------------------------------------------------------------------*/
+
+#define DEMO_MODE_PACKET_LENGTH (8)
+#define MAX_TOUCH_NUM (2)
+
+#define MSG21XXA_FIRMWARE_MAIN_BLOCK_SIZE (32) /* 32K */
+#define MSG21XXA_FIRMWARE_INFO_BLOCK_SIZE (1) /* 1K */
+/* 33K */
+#define MSG21XXA_FIRMWARE_WHOLE_SIZE \
+ (MSG21XXA_FIRMWARE_MAIN_BLOCK_SIZE + MSG21XXA_FIRMWARE_INFO_BLOCK_SIZE)
+
+#define MSG22XX_FIRMWARE_MAIN_BLOCK_SIZE (48) /* 48K */
+#define MSG22XX_FIRMWARE_INFO_BLOCK_SIZE (512) /* 512Byte */
+
+
+#define FIRMWARE_MODE_DEMO_MODE (0x00)
+#define FIRMWARE_MODE_DEBUG_MODE (0x01)
+#define FIRMWARE_MODE_RAW_DATA_MODE (0x02)
+
+#define DEBUG_MODE_PACKET_LENGTH (128)
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+#ifdef CONFIG_ENABLE_GESTURE_INFORMATION_MODE
+#define FIRMWARE_GESTURE_INFORMATION_MODE_A (0x00)
+#define FIRMWARE_GESTURE_INFORMATION_MODE_B (0x01)
+#define FIRMWARE_GESTURE_INFORMATION_MODE_C (0x02)
+#endif /* CONFIG_ENABLE_GESTURE_INFORMATION_MODE */
+#endif /* CONFIG_ENABLE_GESTURE_WAKEUP */
+
+/*--------------------------------------------------------------------------*/
+/* DATA TYPE DEFINITION */
+/*--------------------------------------------------------------------------*/
+
+struct TouchPoint_t {
+ u16 nX;
+ u16 nY;
+};
+
+struct TouchInfo_t {
+ u8 nTouchKeyMode;
+ u8 nTouchKeyCode;
+ u8 nFingerNum;
+ struct TouchPoint_t tPoint[MAX_TOUCH_NUM];
+};
+
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+
+struct FirmwareInfo_t {
+ u8 nFirmwareMode;
+ u8 nLogModePacketHeader;
+ u16 nLogModePacketLength;
+ u8 nIsCanChangeFirmwareMode;
+};
+
+#endif /* CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+
+/*--------------------------------------------------------------------------*/
+/* GLOBAL FUNCTION DECLARATION */
+/*--------------------------------------------------------------------------*/
+
+#ifdef CONFIG_ENABLE_GESTURE_WAKEUP
+extern void DrvFwCtrlOpenGestureWakeup(u32 *pMode);
+extern void DrvFwCtrlCloseGestureWakeup(void);
+
+#ifdef CONFIG_ENABLE_GESTURE_DEBUG_MODE
+extern void DrvFwCtrlOpenGestureDebugMode(u8 nGestureFlag);
+extern void DrvFwCtrlCloseGestureDebugMode(void);
+#endif /* CONFIG_ENABLE_GESTURE_DEBUG_MODE */
+#endif /* CONFIG_ENABLE_GESTURE_WAKEUP */
+
+#ifdef CONFIG_ENABLE_FIRMWARE_DATA_LOG
+extern u16 DrvFwCtrlChangeFirmwareMode(u16 nMode);
+extern void DrvFwCtrlGetFirmwareInfo(struct FirmwareInfo_t *pInfo);
+extern void DrvFwCtrlRestoreFirmwareModeToLogDataMode(void);
+#endif /* CONFIG_ENABLE_FIRMWARE_DATA_LOG */
+
+extern void DrvFwCtrlOptimizeCurrentConsumption(void);
+extern u8 DrvFwCtrlGetChipType(void);
+extern void DrvFwCtrlGetCustomerFirmwareVersion(u16 *pMajor,
+ u16 *pMinor, u8 **ppVersion);
+extern void DrvFwCtrlGetPlatformFirmwareVersion(u8 **ppVersion);
+extern void DrvFwCtrlHandleFingerTouch(void);
+extern s32 DrvFwCtrlUpdateFirmware(u8 szFwData[][1024],
+ enum EmemType_e eEmemType);
+extern s32 DrvFwCtrlUpdateFirmwareBySdCard(const char *pFilePath);
+
+extern u8 g_FwData[MAX_UPDATE_FIRMWARE_BUFFER_SIZE][1024];
+extern u32 g_FwDataCount;
+extern struct mutex g_Mutex;
+
+#ifdef CONFIG_TP_HAVE_KEY
+extern const int g_TpVirtualKey[];
+
+#ifdef CONFIG_ENABLE_REPORT_KEY_WITH_COORDINATE
+extern const int g_TpVirtualKeyDimLocal[][4];
+#endif /* CONFIG_ENABLE_REPORT_KEY_WITH_COORDINATE */
+#endif /* CONFIG_TP_HAVE_KEY */
+
+#endif /* CONFIG_ENABLE_CHIP_MSG21XXA || CONFIG_ENABLE_CHIP_MSG22XX */
+
+#endif /* __MSTAR_DRV_SELF_FW_CONTROL_H__ */
diff --git a/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_utility_adaption.c b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_utility_adaption.c
new file mode 100644
index 00000000000..8f57df7e098
--- /dev/null
+++ b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_utility_adaption.c
@@ -0,0 +1,500 @@
+/*
+ * Copyright (c) 2006-2014 MStar Semiconductor, Inc.
+ * All rights reserved.
+
+ * Unless otherwise stipulated in writing, any and all information contained
+ * herein regardless in any format shall remain the sole proprietary of
+ * MStar Semiconductor Inc. and be kept in strict confidence
+ * (??MStar Confidential Information??) by the recipient.
+ * Any unauthorized act including without limitation unauthorized disclosure,
+ * copying, use, reproduction, sale, distribution, modification, disassembling,
+ * reverse engineering and compiling of the contents of MStar Confidential
+ * Information is unlawful and strictly prohibited. MStar hereby reserves the
+ * rights to any and all damages, losses, costs and expenses resulting
+ * therefrom.
+ */
+
+/**
+ *
+ * @file mstar_drv_utility_adaption.c
+ *
+ * @brief This file defines the interface of touch screen
+ *
+ *
+ */
+
+#include "mstar_drv_utility_adaption.h"
+
+u16 RegGet16BitValue(u16 nAddr)
+{
+ u8 tx_data[3] = {0x10, (nAddr >> 8) & 0xFF, nAddr & 0xFF};
+ u8 rx_data[2] = {0};
+
+ IicWriteData(SLAVE_I2C_ID_DBBUS, &tx_data[0], 3);
+ IicReadData(SLAVE_I2C_ID_DBBUS, &rx_data[0], 2);
+
+ return rx_data[1] << 8 | rx_data[0];
+}
+
+u8 RegGetLByteValue(u16 nAddr)
+{
+ u8 tx_data[3] = {0x10, (nAddr >> 8) & 0xFF, nAddr & 0xFF};
+ u8 rx_data = {0};
+
+ IicWriteData(SLAVE_I2C_ID_DBBUS, &tx_data[0], 3);
+ IicReadData(SLAVE_I2C_ID_DBBUS, &rx_data, 1);
+
+ return rx_data;
+}
+
+u8 RegGetHByteValue(u16 nAddr)
+{
+ u8 tx_data[3] = {0x10, (nAddr >> 8) & 0xFF, (nAddr & 0xFF) + 1};
+ u8 rx_data = {0};
+
+ IicWriteData(SLAVE_I2C_ID_DBBUS, &tx_data[0], 3);
+ IicReadData(SLAVE_I2C_ID_DBBUS, &rx_data, 1);
+
+ return rx_data;
+}
+
+void RegSet16BitValue(u16 nAddr, u16 nData)
+{
+ u8 tx_data[5] = {0x10, (nAddr >> 8) & 0xFF, nAddr & 0xFF, nData & 0xFF,
+ nData >> 8};
+ IicWriteData(SLAVE_I2C_ID_DBBUS, &tx_data[0], 5);
+}
+
+void RegSetLByteValue(u16 nAddr, u8 nData)
+{
+ u8 tx_data[4] = {0x10, (nAddr >> 8) & 0xFF, nAddr & 0xFF, nData};
+ IicWriteData(SLAVE_I2C_ID_DBBUS, &tx_data[0], 4);
+}
+
+void RegSetHByteValue(u16 nAddr, u8 nData)
+{
+ u8 tx_data[4] = {0x10, (nAddr >> 8) & 0xFF, (nAddr & 0xFF) + 1, nData};
+ IicWriteData(SLAVE_I2C_ID_DBBUS, &tx_data[0], 4);
+}
+
+/* Set bit on nData from 0 to 1 */
+void RegSet16BitValueOn(u16 nAddr, u16 nData)
+{
+ u16 rData = RegGet16BitValue(nAddr);
+ rData |= nData;
+ RegSet16BitValue(nAddr, rData);
+}
+
+/* Set bit on nData from 1 to 0 */
+void RegSet16BitValueOff(u16 nAddr, u16 nData)
+{
+ u16 rData = RegGet16BitValue(nAddr);
+ rData &= (~nData);
+ RegSet16BitValue(nAddr, rData);
+}
+
+u16 RegGet16BitValueByAddressMode(u16 nAddr, enum AddressMode_e eAddressMode)
+{
+ u16 nData = 0;
+
+ if (eAddressMode == ADDRESS_MODE_16BIT)
+ nAddr = nAddr - (nAddr & 0xFF) + ((nAddr & 0xFF) << 1);
+
+ nData = RegGet16BitValue(nAddr);
+
+ return nData;
+}
+
+void RegSet16BitValueByAddressMode(u16 nAddr, u16 nData,
+ enum AddressMode_e eAddressMode)
+{
+ if (eAddressMode == ADDRESS_MODE_16BIT)
+ nAddr = nAddr - (nAddr & 0xFF) + ((nAddr & 0xFF) << 1);
+
+ RegSet16BitValue(nAddr, nData);
+}
+
+void RegMask16BitValue(u16 nAddr, u16 nMask, u16 nData,
+ enum AddressMode_e eAddressMode)
+{
+ u16 nTmpData = 0;
+
+ if (nData > nMask)
+ return;
+
+ nTmpData = RegGet16BitValueByAddressMode(nAddr, eAddressMode);
+ nTmpData = (nTmpData & (~nMask));
+ nTmpData = (nTmpData | nData);
+ RegSet16BitValueByAddressMode(nAddr, nTmpData, eAddressMode);
+}
+
+void DbBusEnterSerialDebugMode(void)
+{
+ u8 data[5];
+
+ /* Enter the Serial Debug Mode */
+ data[0] = 0x53;
+ data[1] = 0x45;
+ data[2] = 0x52;
+ data[3] = 0x44;
+ data[4] = 0x42;
+
+ IicWriteData(SLAVE_I2C_ID_DBBUS, data, 5);
+}
+
+void DbBusExitSerialDebugMode(void)
+{
+ u8 data[1];
+
+ /* Exit the Serial Debug Mode */
+ data[0] = 0x45;
+
+ IicWriteData(SLAVE_I2C_ID_DBBUS, data, 1);
+
+}
+
+void DbBusIICUseBus(void)
+{
+ u8 data[1];
+
+ /* IIC Use Bus */
+ data[0] = 0x35;
+
+ IicWriteData(SLAVE_I2C_ID_DBBUS, data, 1);
+}
+
+void DbBusIICNotUseBus(void)
+{
+ u8 data[1];
+
+ /* IIC Not Use Bus */
+ data[0] = 0x34;
+
+ IicWriteData(SLAVE_I2C_ID_DBBUS, data, 1);
+}
+
+void DbBusIICReshape(void)
+{
+ u8 data[1];
+
+ /* IIC Re-shape */
+ data[0] = 0x71;
+
+ IicWriteData(SLAVE_I2C_ID_DBBUS, data, 1);
+}
+
+void DbBusStopMCU(void)
+{
+ u8 data[1];
+
+ /* Stop the MCU */
+ data[0] = 0x37;
+
+ IicWriteData(SLAVE_I2C_ID_DBBUS, data, 1);
+}
+
+void DbBusNotStopMCU(void)
+{
+ u8 data[1];
+
+ /* Not Stop the MCU */
+ data[0] = 0x36;
+
+ IicWriteData(SLAVE_I2C_ID_DBBUS, data, 1);
+}
+
+s32 IicWriteData(u8 nSlaveId, u8 *pBuf, u16 nSize)
+{
+ s32 rc = 0;
+
+ struct i2c_msg msgs[] = {
+ {
+ .addr = nSlaveId,
+ /*
+ * if read flag is undefined, then
+ * it means write flag.
+ */
+ .flags = 0,
+ .len = nSize,
+ .buf = pBuf,
+ },
+ };
+
+ /* If everything went ok (i.e. 1 msg transmitted), return #bytes
+ transmitted, else error code. */
+ if (g_I2cClient != NULL) {
+ rc = i2c_transfer(g_I2cClient->adapter, msgs, 1);
+
+ if (rc == 1)
+ rc = nSize;
+ else
+ PRINTF_ERR("IicWriteData() error %d\n", rc);
+ } else
+ PRINTF_ERR("i2c client is NULL\n");
+
+ return rc;
+}
+
+s32 IicReadData(u8 nSlaveId, u8 *pBuf, u16 nSize)
+{
+ s32 rc = 0;
+
+ struct i2c_msg msgs[] = {
+ {
+ .addr = nSlaveId,
+ .flags = I2C_M_RD, /* read flag */
+ .len = nSize,
+ .buf = pBuf,
+ },
+ };
+
+ /* If everything went ok (i.e. 1 msg transmitted), return #bytes
+ transmitted, else error code. */
+ if (g_I2cClient != NULL) {
+ rc = i2c_transfer(g_I2cClient->adapter, msgs, 1);
+
+ if (rc == 1)
+ rc = nSize;
+ else /* rc < 0 */
+ PRINTF_ERR("IicReadData() error %d\n", rc);
+ } else {
+ PRINTF_ERR("i2c client is NULL\n");
+ }
+
+ return rc;
+}
+
+s32 IicSegmentReadDataByDbBus(u8 nRegBank, u8 nRegAddr, u8 *pBuf,
+ u16 nSize, u16 nMaxI2cLengthLimit)
+{
+ s32 rc = 0;
+ u16 nLeft = nSize;
+ u16 nOffset = 0;
+ u16 nSegmentLength = 0;
+ u16 nReadSize = 0;
+ u16 nOver = 0;
+ u8 szWriteBuf[3] = {0};
+ u8 nNextRegBank = nRegBank;
+ u8 nNextRegAddr = nRegAddr;
+
+ struct i2c_msg msgs[2] = {
+ {
+ .addr = SLAVE_I2C_ID_DBBUS,
+ .flags = 0, /* write flag */
+ .len = 3,
+ .buf = szWriteBuf,
+ },
+ {
+ .addr = SLAVE_I2C_ID_DBBUS,
+ .flags = I2C_M_RD, /* read flag */
+ },
+ };
+
+ /*
+ * If everything went ok (i.e. 1 msg transmitted),
+ * return #bytes transmitted, else error code.
+ */
+ if (g_I2cClient != NULL) {
+ if (nMaxI2cLengthLimit >= 256)
+ nSegmentLength = 256;
+ else
+ nSegmentLength = 128;
+
+ /* add for debug */
+ PRINTF_ERR("nSegmentLength = %d\n", nSegmentLength);
+
+ while (nLeft > 0) {
+ szWriteBuf[0] = 0x10;
+ nRegBank = nNextRegBank;
+ szWriteBuf[1] = nRegBank;
+ nRegAddr = nNextRegAddr;
+ szWriteBuf[2] = nRegAddr;
+
+ PRINTF_ERR("nRegBank = 0x%x\n", nRegBank);
+ PRINTF_ERR("nRegAddr = 0x%x\n", nRegAddr);
+
+ msgs[1].buf = &pBuf[nOffset];
+
+ if (nLeft > nSegmentLength) {
+ if ((nRegAddr + nSegmentLength) <
+ MAX_TOUCH_IC_REGISTER_BANK_SIZE) {
+ nNextRegAddr = nRegAddr +
+ nSegmentLength;
+
+ PRINTF_ERR("nNextRegAddr = 0x%x\n",
+ nNextRegAddr);
+
+ msgs[1].len = nSegmentLength;
+ nLeft -= nSegmentLength;
+ nOffset += nSegmentLength;
+ } else if ((nRegAddr + nSegmentLength) ==
+ MAX_TOUCH_IC_REGISTER_BANK_SIZE) {
+ nNextRegAddr = 0x00;
+ /*
+ * shift to read data from next
+ * register bank
+ */
+ nNextRegBank = nRegBank + 1;
+
+ PRINTF_ERR("nNextRegBank = 0x%x\n",
+ nNextRegBank);
+
+ msgs[1].len = nSegmentLength;
+ nLeft -= nSegmentLength;
+ nOffset += nSegmentLength;
+ } else {
+ nNextRegAddr = 0x00;
+ /*
+ * shift to read data from next
+ * register bank
+ */
+ nNextRegBank = nRegBank + 1;
+
+ PRINTF_INFO("nNextRegBank = 0x%x\n",
+ nNextRegBank);
+
+ nOver = (nRegAddr + nSegmentLength) -
+ MAX_TOUCH_IC_REGISTER_BANK_SIZE;
+
+ PRINTF_ERR("nOver = 0x%x\n", nOver);
+
+ msgs[1].len = nSegmentLength - nOver;
+ nLeft -= msgs[1].len;
+ nOffset += msgs[1].len;
+ }
+ } else {
+ if ((nRegAddr + nLeft) <
+ MAX_TOUCH_IC_REGISTER_BANK_SIZE) {
+ nNextRegAddr = nRegAddr + nLeft;
+
+ PRINTF_ERR("nNextRegAddr = 0x%x\n",
+ nNextRegAddr);
+
+ msgs[1].len = nLeft;
+ nLeft = 0;
+ } else if ((nRegAddr + nLeft) ==
+ MAX_TOUCH_IC_REGISTER_BANK_SIZE) {
+ nNextRegAddr = 0x00;
+ /*
+ * shift to read data from next
+ * register bank
+ */
+ nNextRegBank = nRegBank + 1;
+
+ PRINTF_ERR("nNextRegBank = 0x%x\n",
+ nNextRegBank);
+ msgs[1].len = nLeft;
+ nLeft = 0;
+ /*
+ * ((nRegAddr + nLeft) >
+ * MAX_TOUCH_IC_REGISTER_BANK_SIZE)
+ */
+ } else {
+ nNextRegAddr = 0x00;
+ /*
+ * shift to read data from next
+ * register bank
+ */
+ nNextRegBank = nRegBank + 1;
+
+ PRINTF_ERR("nNextRegBank = 0x%x\n",
+ nNextRegBank);
+
+ nOver = (nRegAddr + nLeft) -
+ MAX_TOUCH_IC_REGISTER_BANK_SIZE;
+
+ PRINTF_ERR("nOver = 0x%x\n", nOver);
+
+ msgs[1].len = nLeft - nOver;
+ nLeft -= msgs[1].len;
+ nOffset += msgs[1].len;
+ }
+ }
+
+ rc = i2c_transfer(g_I2cClient->adapter, &msgs[0], 2);
+ if (rc == 2)
+ nReadSize = nReadSize + msgs[1].len;
+ else {
+ PRINTF_ERR("IicSegmentReadDataByDbBus()->");
+ PRINTF_ERR("i2c_transfer() error %d\n", rc);
+ return rc;
+ }
+ }
+ } else
+ PRINTF_ERR("i2c client is NULL\n");
+
+ return nReadSize;
+}
+
+s32 IicSegmentReadDataBySmBus(u16 nAddr, u8 *pBuf, u16 nSize,
+ u16 nMaxI2cLengthLimit)
+{
+ s32 rc = 0;
+ u16 nLeft = nSize;
+ u16 nOffset = 0;
+ u16 nReadSize = 0;
+ u8 szWriteBuf[3] = {0};
+
+ struct i2c_msg msgs[2] = {
+ {
+ .addr = SLAVE_I2C_ID_DWI2C,
+ .flags = 0, /* write flag */
+ .len = 3,
+ .buf = szWriteBuf,
+ },
+ {
+ .addr = SLAVE_I2C_ID_DWI2C,
+ .flags = I2C_M_RD, /* read flag */
+ },
+ };
+
+ /*
+ * If everything went ok (i.e. 1 msg transmitted),
+ * return #bytes transmitted, else error code.
+ */
+ if (g_I2cClient != NULL) {
+ while (nLeft > 0) {
+ szWriteBuf[0] = 0x53;
+ szWriteBuf[1] = ((nAddr + nOffset) >> 8) & 0xFF;
+ szWriteBuf[2] = (nAddr + nOffset) & 0xFF;
+
+ msgs[1].buf = &pBuf[nOffset];
+
+ if (nLeft > nMaxI2cLengthLimit) {
+ msgs[1].len = nMaxI2cLengthLimit;
+ nLeft -= nMaxI2cLengthLimit;
+ nOffset += nMaxI2cLengthLimit;
+ } else {
+ msgs[1].len = nLeft;
+ nLeft = 0;
+ }
+
+ rc = i2c_transfer(g_I2cClient->adapter, &msgs[0], 2);
+ if (rc == 2)
+ nReadSize = nReadSize + msgs[1].len;
+ else {
+ PRINTF_ERR("IicSegmentReadDataBySmBus()->");
+ PRINTF_ERR("i2c_transfer() error %d\n", rc);
+ return rc;
+ }
+ }
+ } else
+ PRINTF_ERR("i2c client is NULL\n");
+
+ return nReadSize;
+}
+
+void mstpMemSet(void *pDst, s8 nVal, u32 nSize)
+{
+ memset(pDst, nVal, nSize);
+}
+
+void mstpMemCopy(void *pDst, void *pSource, u32 nSize)
+{
+ memcpy(pDst, pSource, nSize);
+}
+
+void mstpDelay(u32 nTime)
+{
+ mdelay(nTime);
+}
diff --git a/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_utility_adaption.h b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_utility_adaption.h
new file mode 100644
index 00000000000..a48ab66b517
--- /dev/null
+++ b/drivers/input/touchscreen/mstarTouchPanel/mstar_drv_utility_adaption.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2006-2014 MStar Semiconductor, Inc.
+ * All rights reserved.
+
+ * Unless otherwise stipulated in writing, any and all information contained
+ * herein regardless in any format shall remain the sole proprietary of
+ * MStar Semiconductor Inc. and be kept in strict confidence
+ * (??MStar Confidential Information??) by the recipient.
+ * Any unauthorized act including without limitation unauthorized disclosure,
+ * copying, use, reproduction, sale, distribution, modification, disassembling,
+ * reverse engineering and compiling of the contents of MStar Confidential
+ * Information is unlawful and strictly prohibited. MStar hereby reserves the
+ * rights to any and all damages, losses, costs and expenses resulting
+ * therefrom.
+ */
+
+/*
+ *
+ * @file mstar_drv_utility_adaption.h
+ *
+ * @brief This file defines the interface of touch screen
+ *
+ *
+ */
+
+#ifndef __MSTAR_DRV_UTILITY_ADAPTION_H__
+#define __MSTAR_DRV_UTILITY_ADAPTION_H__ (1)
+
+
+#include "mstar_drv_common.h"
+
+#define BK_REG8_WL(addr, val) (RegSetLByteValue(addr, val))
+#define BK_REG8_WH(addr, val) (RegSetHByteValue(addr, val))
+#define BK_REG16_W(addr, val) (RegSet16BitValue(addr, val))
+#define BK_REG8_RL(addr) (RegGetLByteValue(addr))
+#define BK_REG8_RH(addr) (RegGetHByteValue(addr))
+#define BK_REG16_R(addr) (RegGet16BitValue(addr))
+
+#define PRINTF_EMERG(fmt, ...) pr_emerg(pr_fmt(fmt), ##__VA_ARGS__)
+#define PRINTF_ALERT(fmt, ...) pr_alert(pr_fmt(fmt), ##__VA_ARGS__)
+#define PRINTF_CRIT(fmt, ...) pr_crit(pr_fmt(fmt), ##__VA_ARGS__)
+#define PRINTF_ERR(fmt, ...) pr_err(pr_fmt(fmt), ##__VA_ARGS__)
+#define PRINTF_WARN(fmt, ...) pr_warn(pr_fmt(fmt), ##__VA_ARGS__)
+#define PRINTF_NOTICE(fmt, ...) pr_notice(pr_fmt(fmt), ##__VA_ARGS__)
+#define PRINTF_INFO(fmt, ...) pr_info(pr_fmt(fmt), ##__VA_ARGS__)
+#define PRINTF_DEBUG(fmt, ...) pr_debug(pr_fmt(fmt), ##__VA_ARGS__)
+
+extern u16 RegGet16BitValue(u16 nAddr);
+extern u8 RegGetLByteValue(u16 nAddr);
+extern u8 RegGetHByteValue(u16 nAddr);
+extern void RegSet16BitValue(u16 nAddr, u16 nData);
+extern void RegSetLByteValue(u16 nAddr, u8 nData);
+extern void RegSetHByteValue(u16 nAddr, u8 nData);
+extern void RegSet16BitValueOn(u16 nAddr, u16 nData);
+extern void RegSet16BitValueOff(u16 nAddr, u16 nData);
+extern u16 RegGet16BitValueByAddressMode(u16 nAddr,
+ enum AddressMode_e eAddressMode);
+extern void RegSet16BitValueByAddressMode(u16 nAddr, u16 nData,
+ enum AddressMode_e eAddressMode);
+extern void RegMask16BitValue(u16 nAddr, u16 nMask, u16 nData,
+ enum AddressMode_e eAddressMode);
+extern void DbBusEnterSerialDebugMode(void);
+extern void DbBusExitSerialDebugMode(void);
+extern void DbBusIICUseBus(void);
+extern void DbBusIICNotUseBus(void);
+extern void DbBusIICReshape(void);
+extern void DbBusStopMCU(void);
+extern void DbBusNotStopMCU(void);
+extern s32 IicWriteData(u8 nSlaveId, u8 *pBuf, u16 nSize);
+extern s32 IicReadData(u8 nSlaveId, u8 *pBuf, u16 nSize);
+extern s32 IicSegmentReadDataByDbBus(u8 nRegBank, u8 nRegAddr, u8 *pBuf,
+ u16 nSize, u16 nMaxI2cLengthLimit);
+extern s32 IicSegmentReadDataBySmBus(u16 nAddr, u8 *pBuf, u16 nSize,
+ u16 nMaxI2cLengthLimit);
+extern void mstpMemSet(void *pDst, s8 nVal, u32 nSize);
+extern void mstpMemCopy(void *pDst, void *pSource, u32 nSize);
+extern void mstpDelay(u32 nTime);
+
+#endif /* __MSTAR_DRV_UTILITY_ADAPTION_H__ */