/* Source for:
 * Cypress TrueTouch(TM) Standard Product I2C touchscreen driver.
 * drivers/input/touchscreen/cyttsp-i2c.c
 *
 * Copyright (C) 2009, 2010 Cypress Semiconductor, Inc.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2, and only version 2, as published by the
 * Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * Cypress reserves the right to make changes without further notice
 * to the materials described herein. Cypress does not assume any
 * liability arising out of the application described herein.
 *
 * Contact Cypress Semiconductor at www.cypress.com
 *
 */

#include <linux/delay.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/slab.h>
#include <linux/gpio.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/timer.h>
#include <linux/byteorder/generic.h>
#include <linux/bitops.h>
#include <linux/pm_runtime.h>
#include <linux/firmware.h>
#include <linux/mutex.h>
#include <linux/regulator/consumer.h>
#ifdef CONFIG_HAS_EARLYSUSPEND
#include <linux/earlysuspend.h>
#endif /* CONFIG_HAS_EARLYSUSPEND */

#define CY_DECLARE_GLOBALS

#include <linux/cyttsp.h>

uint32_t cyttsp_tsdebug1 = 0xff;
module_param_named(tsdebug1, cyttsp_tsdebug1, uint, 0664);

#define FW_FNAME_LEN 40
#define TTSP_BUFF_SIZE 50

/* CY TTSP I2C Driver private data */
struct cyttsp {
	struct i2c_client *client;
	struct input_dev *input;
	struct timer_list timer;
	struct mutex mutex;
	char phys[32];
	struct cyttsp_platform_data *platform_data;
	u8 num_prv_st_tch;
	u16 fw_start_addr;
	u16 act_trk[CY_NUM_TRK_ID];
	u16 prv_st_tch[CY_NUM_ST_TCH_ID];
	u16 prv_mt_tch[CY_NUM_MT_TCH_ID];
	u16 prv_mt_pos[CY_NUM_TRK_ID][2];
	atomic_t irq_enabled;
	bool cyttsp_update_fw;
	bool cyttsp_fwloader_mode;
	bool is_suspended;
	struct regulator **vdd;
	char fw_fname[FW_FNAME_LEN];
#ifdef CONFIG_HAS_EARLYSUSPEND
	struct early_suspend early_suspend;
#endif /* CONFIG_HAS_EARLYSUSPEND */
};
static u8 irq_cnt;		/* comparison counter with register valuw */
static u32 irq_cnt_total;	/* total interrupts */
static u32 irq_err_cnt;		/* count number of touch interrupts with err */
#define CY_IRQ_CNT_MASK	0x000000FF	/* mapped for sizeof count in reg */
#define CY_IRQ_CNT_REG	0x00		/* tt_undef[0]=reg 0x1B - Gen3 only */

#ifdef CONFIG_HAS_EARLYSUSPEND
static void cyttsp_early_suspend(struct early_suspend *handler);
static void cyttsp_late_resume(struct early_suspend *handler);
#endif /* CONFIG_HAS_EARLYSUSPEND */


/* ****************************************************************************
 * Prototypes for static functions
 * ************************************************************************** */
static irqreturn_t cyttsp_irq(int irq, void *handle);
static int cyttsp_inlist(u16 prev_track[],
			u8 cur_trk_id, u8 *prev_loc, u8 num_touches);
static int cyttsp_next_avail_inlist(u16 cur_trk[],
			u8 *new_loc, u8 num_touches);
static int cyttsp_putbl(struct cyttsp *ts, int show,
			int show_status, int show_version, int show_cid);
static int __devinit cyttsp_probe(struct i2c_client *client,
			const struct i2c_device_id *id);
static int __devexit cyttsp_remove(struct i2c_client *client);
static int cyttsp_resume(struct device *dev);
static int cyttsp_suspend(struct device *dev);

/* Static variables */
static struct cyttsp_gen3_xydata_t g_xy_data;
static struct cyttsp_bootloader_data_t g_bl_data;
static struct cyttsp_sysinfo_data_t g_sysinfo_data;
static const struct i2c_device_id cyttsp_id[] = {
	{ CY_I2C_NAME, 0 },  { }
};
static u8 bl_cmd[] = {
	CY_BL_FILE0, CY_BL_CMD, CY_BL_EXIT,
	CY_BL_KEY0, CY_BL_KEY1, CY_BL_KEY2,
	CY_BL_KEY3, CY_BL_KEY4, CY_BL_KEY5,
	CY_BL_KEY6, CY_BL_KEY7};

MODULE_DEVICE_TABLE(i2c, cyttsp_id);

#ifdef CONFIG_PM
static const struct dev_pm_ops cyttsp_pm_ops = {
#ifndef CONFIG_HAS_EARLYSUSPEND
	.suspend = cyttsp_suspend,
	.resume = cyttsp_resume,
#endif
};
#endif

static struct i2c_driver cyttsp_driver = {
	.driver = {
		.name = CY_I2C_NAME,
		.owner = THIS_MODULE,
#ifdef CONFIG_PM
		.pm = &cyttsp_pm_ops,
#endif
	},
	.probe = cyttsp_probe,
	.remove = __devexit_p(cyttsp_remove),
	.id_table = cyttsp_id,
};

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Cypress TrueTouch(R) Standard touchscreen driver");
MODULE_AUTHOR("Cypress");

static ssize_t cyttsp_irq_status(struct device *dev,
				struct device_attribute *attr, char *buf)
{
	struct i2c_client *client = container_of(dev, struct i2c_client, dev);
	struct cyttsp *ts = i2c_get_clientdata(client);
	return snprintf(buf, TTSP_BUFF_SIZE, "%u\n",
				atomic_read(&ts->irq_enabled));
}

static ssize_t cyttsp_irq_enable(struct device *dev,
				struct device_attribute *attr,
				const char *buf, size_t size)
{
	struct i2c_client *client = container_of(dev, struct i2c_client, dev);
	struct cyttsp *ts = i2c_get_clientdata(client);
	int err = 0;
	unsigned long value;

	if (size > 2)
		return -EINVAL;

	err = strict_strtoul(buf, 10, &value);
	if (err != 0)
		return err;

	switch (value) {
	case 0:
		if (atomic_cmpxchg(&ts->irq_enabled, 1, 0)) {
			pr_info("touch irq disabled!\n");
			disable_irq_nosync(ts->client->irq);
		}
		err = size;
		break;
	case 1:
		if (!atomic_cmpxchg(&ts->irq_enabled, 0, 1)) {
			pr_info("touch irq enabled!\n");
			enable_irq(ts->client->irq);
		}
		err = size;
		break;
	default:
		pr_info("cyttsp_irq_enable failed -> irq_enabled = %d\n",
		atomic_read(&ts->irq_enabled));
		err = -EINVAL;
		break;
	}

	return err;
}

static DEVICE_ATTR(irq_enable, 0664, cyttsp_irq_status, cyttsp_irq_enable);

static ssize_t cyttsp_fw_show(struct device *dev,
				struct device_attribute *attr, char *buf)
{
	return snprintf(buf, TTSP_BUFF_SIZE, "%d.%d.%d\n", g_bl_data.appid_lo,
				g_bl_data.appver_hi, g_bl_data.appver_lo);
}

static DEVICE_ATTR(cyttsp_fw_ver, 0664, cyttsp_fw_show, NULL);

/* firmware flashing block */
#define BLK_SIZE     16
#define DATA_REC_LEN 64
#define BLK_SEED     0xff
#define RECAL_REG    0x1b

enum bl_commands {
	BL_CMD_WRBLK     = 0x39,
	BL_CMD_INIT      = 0x38,
	BL_CMD_TERMINATE = 0x3b,
};
/* TODO: Add key as part of platform data */
#define KEY_CS  (0 + 1 + 2 + 3 + 4 + 5 + 6 + 7)
#define KEY {0, 1, 2, 3, 4, 5, 6, 7}

static const  char _key[] = KEY;
#define KEY_LEN sizeof(_key)

static int rec_cnt;
struct fw_record {
	u8 seed;
	u8 cmd;
	u8 key[KEY_LEN];
	u8 blk_hi;
	u8 blk_lo;
	u8 data[DATA_REC_LEN];
	u8 data_cs;
	u8 rec_cs;
};
#define fw_rec_size (sizeof(struct fw_record))

struct cmd_record {
	u8 reg;
	u8 seed;
	u8 cmd;
	u8 key[KEY_LEN];
};
#define cmd_rec_size (sizeof(struct cmd_record))

static struct fw_record data_record = {
	.seed = BLK_SEED,
	.cmd = BL_CMD_WRBLK,
	.key = KEY,
};

static const struct cmd_record terminate_rec = {
	.reg = 0,
	.seed = BLK_SEED,
	.cmd = BL_CMD_TERMINATE,
	.key = KEY,
};
static const struct cmd_record initiate_rec = {
	.reg = 0,
	.seed = BLK_SEED,
	.cmd = BL_CMD_INIT,
	.key = KEY,
};

#define BL_REC1_ADDR          0x0780
#define BL_REC2_ADDR          0x07c0
#define BL_CHECKSUM_MASK      0x01

#define ID_INFO_REC           ":40078000"
#define ID_INFO_OFFSET_IN_REC 77

#define REC_START_CHR     ':'
#define REC_LEN_OFFSET     1
#define REC_ADDR_HI_OFFSET 3
#define REC_ADDR_LO_OFFSET 5
#define REC_TYPE_OFFSET    7
#define REC_DATA_OFFSET    9
#define REC_LINE_SIZE	141

#define NUM_CHAR_IN_HEX 2
#define ID_INFO_REC_LEN 9

static int cyttsp_soft_reset(struct cyttsp *ts)
{
	int retval = 0, tries = 0;
	u8 host_reg = CY_SOFT_RESET_MODE;

	do {
		retval = i2c_smbus_write_i2c_block_data(ts->client,
				CY_REG_BASE, sizeof(host_reg), &host_reg);
		if (retval < 0)
			msleep(20);
	} while (tries++ < 10 && (retval < 0));

	if (retval < 0) {
		pr_err("%s: failed\n", __func__);
		return retval;
	}

	tries = 0;
	do {
		msleep(20);
		cyttsp_putbl(ts, 1, true, true, false);
	} while (g_bl_data.bl_status != 0x10 &&
		g_bl_data.bl_status != 0x11 &&
		tries++ < 100);

	if (g_bl_data.bl_status != 0x11 && g_bl_data.bl_status != 0x10)
		return -EINVAL;

	return 0;
}

static void cyttsp_exit_bl_mode(struct cyttsp *ts)
{
	int retval, tries = 0;

	do {
		retval = i2c_smbus_write_i2c_block_data(ts->client,
			CY_REG_BASE, sizeof(bl_cmd), bl_cmd);
		if (retval < 0)
			msleep(20);
	} while (tries++ < 10 && (retval < 0));
}

static void cyttsp_set_sysinfo_mode(struct cyttsp *ts)
{
	int retval, tries = 0;
	u8 host_reg = CY_SYSINFO_MODE;

	do {
		retval = i2c_smbus_write_i2c_block_data(ts->client,
			CY_REG_BASE, sizeof(host_reg), &host_reg);
		if (retval < 0)
			msleep(20);
	} while (tries++ < 10 && (retval < 0));

	/* wait for TTSP Device to complete switch to SysInfo mode */
	if (!(retval < 0)) {
		retval = i2c_smbus_read_i2c_block_data(ts->client,
				CY_REG_BASE,
				sizeof(struct cyttsp_sysinfo_data_t),
				(u8 *)&g_sysinfo_data);
	} else
		pr_err("%s: failed\n", __func__);
}

static void cyttsp_set_opmode(struct cyttsp *ts)
{
	int retval, tries = 0;
	u8 host_reg = CY_OP_MODE;

	do {
		retval = i2c_smbus_write_i2c_block_data(ts->client,
				CY_REG_BASE, sizeof(host_reg), &host_reg);
		if (retval < 0)
			msleep(20);
	} while (tries++ < 10 && (retval < 0));
}

static int str2uc(char *str, u8 *val)
{
	char substr[3];
	unsigned long ulval;
	int rc;

	if (!str)
		return -EINVAL;

	if (strnlen(str, NUM_CHAR_IN_HEX) < 2)
		return -EINVAL;

	substr[0] = str[0];
	substr[1] = str[1];
	substr[2] = '\0';

	rc = strict_strtoul(substr, 16, &ulval);
	if (rc != 0)
		return rc;

	*val = (u8) ulval;

	return 0;
}

static int flash_block(struct cyttsp *ts, u8 *blk, int len)
{
	int retval, i, tries = 0;
	char buf[(2 * (BLK_SIZE + 1)) + 1];
	char *p = buf;

	for (i = 0; i < len; i++, p += 2)
		snprintf(p, TTSP_BUFF_SIZE, "%02x", blk[i]);
	pr_debug("%s: size %d, pos %ld payload %s\n",
		       __func__, len, (long)0, buf);

	do {
		retval = i2c_smbus_write_i2c_block_data(ts->client,
			CY_REG_BASE, len, blk);
		if (retval < 0)
			msleep(20);
	} while (tries++ < 20 && (retval < 0));

	if (retval < 0) {
		pr_err("%s: failed\n", __func__);
		return retval;
	}

	return 0;
}

static int flash_command(struct cyttsp *ts, const struct cmd_record *record)
{
	return flash_block(ts, (u8 *)record, cmd_rec_size);
}

static void init_data_record(struct fw_record *rec, unsigned short addr)
{
	addr >>= 6;
	rec->blk_hi = (addr >> 8) & 0xff;
	rec->blk_lo = addr & 0xff;
	rec->rec_cs = rec->blk_hi + rec->blk_lo +
			(unsigned char)(BLK_SEED + BL_CMD_WRBLK + KEY_CS);
	rec->data_cs = 0;
}

static int check_record(struct cyttsp *ts, u8 *rec)
{
	int rc;
	u16 addr;
	u8 r_len, type, hi_off, lo_off;

	rc = str2uc(rec + REC_LEN_OFFSET, &r_len);
	if (rc < 0)
		return rc;

	rc = str2uc(rec + REC_TYPE_OFFSET, &type);
	if (rc < 0)
		return rc;

	if (*rec != REC_START_CHR || r_len != DATA_REC_LEN || type != 0)
		return -EINVAL;

	rc = str2uc(rec + REC_ADDR_HI_OFFSET, &hi_off);
	if (rc < 0)
		return rc;

	rc = str2uc(rec + REC_ADDR_LO_OFFSET, &lo_off);
	if (rc < 0)
		return rc;

	addr = (hi_off << 8) | lo_off;

	if (addr >= ts->fw_start_addr || addr == BL_REC1_ADDR
			|| addr == BL_REC2_ADDR)
		return 0;

	return -EINVAL;
}

static struct fw_record *prepare_record(u8 *rec)
{
	int i, rc;
	u16 addr;
	u8 hi_off, lo_off;
	u8 *p;

	rc = str2uc(rec + REC_ADDR_HI_OFFSET, &hi_off);
	if (rc < 0)
		return ERR_PTR((long) rc);

	rc = str2uc(rec + REC_ADDR_LO_OFFSET, &lo_off);
	if (rc < 0)
		return ERR_PTR((long) rc);

	addr = (hi_off << 8) | lo_off;

	init_data_record(&data_record, addr);
	p = rec + REC_DATA_OFFSET;
	for (i = 0; i < DATA_REC_LEN; i++) {
		rc = str2uc(p, &data_record.data[i]);
		if (rc < 0)
			return ERR_PTR((long) rc);
		data_record.data_cs += data_record.data[i];
		data_record.rec_cs += data_record.data[i];
		p += 2;
	}
	data_record.rec_cs += data_record.data_cs;

	return &data_record;
}

static int flash_record(struct cyttsp *ts, const struct fw_record *record)
{
	int len = fw_rec_size;
	int blk_len, rc;
	u8 *rec = (u8 *)record;
	u8 data[BLK_SIZE + 1];
	u8 blk_offset;

	for (blk_offset = 0; len; len -= blk_len) {
		data[0] = blk_offset;
		blk_len = len > BLK_SIZE ? BLK_SIZE : len;
		memcpy(data + 1, rec, blk_len);
		rec += blk_len;
		rc = flash_block(ts, data, blk_len + 1);
		if (rc < 0)
			return rc;
		blk_offset += blk_len;
	}
	return 0;
}

static int flash_data_rec(struct cyttsp *ts, u8 *buf)
{
	struct fw_record *rec;
	int rc, tries;

	if (!buf)
		return -EINVAL;

	rc = check_record(ts, buf);

	if (rc < 0) {
		pr_debug("%s: record ignored %s", __func__, buf);
		return 0;
	}

	rec = prepare_record(buf);
	if (IS_ERR_OR_NULL(rec))
		return PTR_ERR(rec);

	rc = flash_record(ts, rec);
	if (rc < 0)
		return rc;

	tries = 0;
	do {
		if (rec_cnt%2)
			msleep(20);
		cyttsp_putbl(ts, 4, true, false, false);
	} while (g_bl_data.bl_status != 0x10 &&
		g_bl_data.bl_status != 0x11 &&
		tries++ < 100);
	rec_cnt++;
	return rc;
}

static int cyttspfw_flash_firmware(struct cyttsp *ts, const u8 *data,
					int data_len)
{
	u8 *buf;
	int i, j;
	int rc, tries = 0;

	/* initiate bootload: this will erase all the existing data */
	rc = flash_command(ts, &initiate_rec);
	if (rc < 0)
		return rc;

	do {
		msleep(100);
		cyttsp_putbl(ts, 4, true, false, false);
	} while (g_bl_data.bl_status != 0x10 &&
		g_bl_data.bl_status != 0x11 &&
		tries++ < 100);

	buf = kzalloc(REC_LINE_SIZE + 1, GFP_KERNEL);
	if (!buf) {
		pr_err("%s: no memory\n", __func__);
		return -ENOMEM;
	}

	rec_cnt = 0;
	/* flash data records */
	for (i = 0, j = 0; i < data_len; i++, j++) {
		if ((data[i] == REC_START_CHR) && j) {
			buf[j] = 0;
			rc = flash_data_rec(ts, buf);
			if (rc < 0)
				return rc;
			j = 0;
		}
		buf[j] = data[i];
	}

	/* flash last data record */
	if (j) {
		buf[j] = 0;
		rc = flash_data_rec(ts, buf);
		if (rc < 0)
			return rc;
	}

	kfree(buf);

	/* termiate bootload */
	tries = 0;
	rc = flash_command(ts, &terminate_rec);
	do {
		msleep(100);
		cyttsp_putbl(ts, 4, true, false, false);
	} while (g_bl_data.bl_status != 0x10 &&
		g_bl_data.bl_status != 0x11 &&
		tries++ < 100);

	return rc;
}

static int get_hex_fw_ver(u8 *p, u8 *ttspver_hi, u8 *ttspver_lo,
			u8 *appid_hi, u8 *appid_lo, u8 *appver_hi,
			u8 *appver_lo, u8 *cid_0, u8 *cid_1, u8 *cid_2)
{
	int rc;

	p = p + ID_INFO_OFFSET_IN_REC;
	rc = str2uc(p, ttspver_hi);
	if (rc < 0)
		return rc;
	p += 2;
	rc = str2uc(p, ttspver_lo);
	if (rc < 0)
		return rc;
	p += 2;
	rc = str2uc(p, appid_hi);
	if (rc < 0)
		return rc;
	p += 2;
	rc = str2uc(p, appid_lo);
	if (rc < 0)
		return rc;
	p += 2;
	rc = str2uc(p, appver_hi);
	if (rc < 0)
		return rc;
	p += 2;
	rc = str2uc(p, appver_lo);
	if (rc < 0)
		return rc;
	p += 2;
	rc = str2uc(p, cid_0);
	if (rc < 0)
		return rc;
	p += 2;
	rc = str2uc(p, cid_1);
	if (rc < 0)
		return rc;
	p += 2;
	rc = str2uc(p, cid_2);
	if (rc < 0)
		return rc;

	return 0;
}

static void cyttspfw_flash_start(struct cyttsp *ts, const u8 *data,
				int data_len, u8 *buf, bool force)
{
	int rc;
	u8 ttspver_hi = 0, ttspver_lo = 0, fw_upgrade = 0;
	u8 appid_hi = 0, appid_lo = 0;
	u8 appver_hi = 0, appver_lo = 0;
	u8 cid_0 = 0, cid_1 = 0, cid_2 = 0;
	char *p = buf;

	/* get hex firmware version */
	rc = get_hex_fw_ver(p, &ttspver_hi, &ttspver_lo,
		&appid_hi, &appid_lo, &appver_hi,
		&appver_lo, &cid_0, &cid_1, &cid_2);

	if (rc < 0) {
		pr_err("%s: unable to get hex firmware version\n", __func__);
		return;
	}

	/* disable interrupts before flashing */
	if (ts->client->irq == 0)
		del_timer(&ts->timer);
	else
		disable_irq(ts->client->irq);

	/* enter bootloader idle mode */
	rc = cyttsp_soft_reset(ts);

	if (rc < 0) {
		pr_err("%s: try entering into idle mode"
				" second time\n", __func__);
		msleep(1000);
		rc = cyttsp_soft_reset(ts);
	}

	if (rc < 0) {
		pr_err("%s: try again later\n", __func__);
		return;
	}


	pr_info("Current firmware: %d.%d.%d", g_bl_data.appid_lo,
				g_bl_data.appver_hi, g_bl_data.appver_lo);
	pr_info("New firmware: %d.%d.%d", appid_lo, appver_hi, appver_lo);

	if (force)
		fw_upgrade = 1;
	else if (!(g_bl_data.bl_status & BL_CHECKSUM_MASK) &&
			(appid_lo == ts->platform_data->correct_fw_ver))
		fw_upgrade = 1;
	else
		if ((appid_hi == g_bl_data.appid_hi) &&
			(appid_lo == g_bl_data.appid_lo)) {
			if (appver_hi > g_bl_data.appver_hi) {
				fw_upgrade = 1;
			} else if ((appver_hi == g_bl_data.appver_hi) &&
					 (appver_lo > g_bl_data.appver_lo)) {
					fw_upgrade = 1;
				} else {
					fw_upgrade = 0;
					pr_info("%s: Firmware version "
					"lesser/equal to existing firmware, "
					"upgrade not needed\n", __func__);
				}
		} else {
			fw_upgrade = 0;
			pr_info("%s: Firware versions do not match, "
						"cannot upgrade\n", __func__);
		}

	if (fw_upgrade) {
		pr_info("%s: Starting firmware upgrade\n", __func__);
		rc = cyttspfw_flash_firmware(ts, data, data_len);
		if (rc < 0)
			pr_err("%s: firmware upgrade failed\n", __func__);
		else
			pr_info("%s: firmware upgrade success\n", __func__);
	}

	/* enter bootloader idle mode */
	cyttsp_soft_reset(ts);
	/* exit bootloader mode */
	cyttsp_exit_bl_mode(ts);
	msleep(100);
	/* set sysinfo details */
	cyttsp_set_sysinfo_mode(ts);
	/* enter application mode */
	cyttsp_set_opmode(ts);

	/* enable interrupts */
	if (ts->client->irq == 0)
		mod_timer(&ts->timer, jiffies + TOUCHSCREEN_TIMEOUT);
	else
		enable_irq(ts->client->irq);
}

static void cyttspfw_upgrade_start(struct cyttsp *ts, const u8 *data,
					int data_len, bool force)
{
	int i, j;
	u8 *buf;

	buf = kzalloc(REC_LINE_SIZE + 1, GFP_KERNEL);
	if (!buf) {
		pr_err("%s: no memory\n", __func__);
		return;
	}

	for (i = 0, j = 0; i < data_len; i++, j++) {
		if ((data[i] == REC_START_CHR) && j) {
			buf[j] = 0;
			j = 0;
			if (!strncmp(buf, ID_INFO_REC,
				strnlen(ID_INFO_REC, ID_INFO_REC_LEN))) {
				cyttspfw_flash_start(ts, data, data_len,
							buf, force);
				break;
			}
		}
		buf[j] = data[i];
	}

	/* check in the last record of firmware */
	if (j) {
		buf[j] = 0;
		if (!strncmp(buf, ID_INFO_REC,
			strnlen(ID_INFO_REC, ID_INFO_REC_LEN))) {
			cyttspfw_flash_start(ts, data, data_len,
						buf, force);
		}
	}

	kfree(buf);
}

static void cyttspfw_upgrade(struct device *dev, bool force)
{
	struct cyttsp *ts = dev_get_drvdata(dev);
	const struct firmware *cyttsp_fw;
	int retval = 0;

	if (ts->is_suspended == true) {
		pr_err("%s: in suspend state, resume it\n", __func__);
		retval = cyttsp_resume(dev);
		if (retval < 0) {
			pr_err("%s: unable to resume\n", __func__);
			return;
		}
	}

	retval = request_firmware(&cyttsp_fw, ts->fw_fname, dev);
	if (retval < 0) {
		pr_err("%s: %s request failed(%d)\n", __func__,
						ts->fw_fname, retval);
	} else {
		/* check and start upgrade */
		cyttspfw_upgrade_start(ts, cyttsp_fw->data,
				cyttsp_fw->size, force);
		release_firmware(cyttsp_fw);
	}
}

static ssize_t cyttsp_update_fw_show(struct device *dev,
				struct device_attribute *attr, char *buf)
{
	struct cyttsp *ts = dev_get_drvdata(dev);
	return snprintf(buf, 2, "%d\n", ts->cyttsp_fwloader_mode);
}

static ssize_t cyttsp_force_update_fw_store(struct device *dev,
				struct device_attribute *attr,
				const char *buf, size_t size)
{
	struct cyttsp *ts = dev_get_drvdata(dev);
	unsigned long val;
	int rc;

	if (size > 2)
		return -EINVAL;

	rc = strict_strtoul(buf, 10, &val);
	if (rc != 0)
		return rc;

	mutex_lock(&ts->mutex);
	if (!ts->cyttsp_fwloader_mode  && val) {
		ts->cyttsp_fwloader_mode = 1;
		cyttspfw_upgrade(dev, true);
		ts->cyttsp_fwloader_mode = 0;
	}
	mutex_unlock(&ts->mutex);
	return size;
}

static DEVICE_ATTR(cyttsp_force_update_fw, 0664, cyttsp_update_fw_show,
					cyttsp_force_update_fw_store);

static ssize_t cyttsp_update_fw_store(struct device *dev,
				struct device_attribute *attr,
				const char *buf, size_t size)
{
	struct cyttsp *ts = dev_get_drvdata(dev);
	unsigned long val;
	int rc;

	if (size > 2)
		return -EINVAL;

	rc = strict_strtoul(buf, 10, &val);
	if (rc != 0)
		return rc;

	mutex_lock(&ts->mutex);
	if (!ts->cyttsp_fwloader_mode  && val) {
		ts->cyttsp_fwloader_mode = 1;
		cyttspfw_upgrade(dev, false);
		ts->cyttsp_fwloader_mode = 0;
	}
	mutex_unlock(&ts->mutex);

	return size;
}

static DEVICE_ATTR(cyttsp_update_fw, 0664, cyttsp_update_fw_show,
					cyttsp_update_fw_store);

static ssize_t cyttsp_fw_name_show(struct device *dev,
				struct device_attribute *attr, char *buf)
{
	struct cyttsp *ts = dev_get_drvdata(dev);
	return snprintf(buf, FW_FNAME_LEN - 1, "%s\n", ts->fw_fname);
}

static ssize_t cyttsp_fw_name_store(struct device *dev,
				struct device_attribute *attr,
				const char *buf, size_t size)
{
	struct cyttsp *ts = dev_get_drvdata(dev);

	if (size > FW_FNAME_LEN - 1)
		return -EINVAL;

	strlcpy(ts->fw_fname, buf, size);
	if (ts->fw_fname[size-1] == '\n')
		ts->fw_fname[size-1] = 0;

	return size;
}

static DEVICE_ATTR(cyttsp_fw_name, 0664, cyttsp_fw_name_show,
					cyttsp_fw_name_store);

static void cyttsp_xy_handler(struct cyttsp *ts)
{
	u8 id, tilt, rev_x, rev_y;
	u8 i, loc;
	u8 prv_tch;		/* number of previous touches */
	u8 cur_tch;	/* number of current touches */
	u16 tmp_trk[CY_NUM_MT_TCH_ID];
	u16 snd_trk[CY_NUM_MT_TCH_ID];
	u16 cur_trk[CY_NUM_TRK_ID];
	u16 cur_st_tch[CY_NUM_ST_TCH_ID];
	u16 cur_mt_tch[CY_NUM_MT_TCH_ID];
	/* if NOT CY_USE_TRACKING_ID then
	 * only uses CY_NUM_MT_TCH_ID positions */
	u16 cur_mt_pos[CY_NUM_TRK_ID][2];
	/* if NOT CY_USE_TRACKING_ID then
	 * only uses CY_NUM_MT_TCH_ID positions */
	u8 cur_mt_z[CY_NUM_TRK_ID];
	u8 curr_tool_width;
	u16 st_x1, st_y1;
	u8 st_z1;
	u16 st_x2, st_y2;
	u8 st_z2;
	s32 retval;
	int val;

	cyttsp_xdebug("TTSP handler start 1:\n");

	/* get event data from CYTTSP device */
	i = CY_NUM_RETRY;
	do {
		retval = i2c_smbus_read_i2c_block_data(ts->client,
			CY_REG_BASE,
			sizeof(struct cyttsp_gen3_xydata_t), (u8 *)&g_xy_data);
	} while ((retval < CY_OK) && --i);

	if (retval < CY_OK) {
		/* return immediately on
		 * failure to read device on the i2c bus */
		goto exit_xy_handler;
	}

	cyttsp_xdebug("TTSP handler start 2:\n");

	/* compare own irq counter with the device irq counter */
	if (ts->client->irq) {
		u8 host_reg;
		u8 cur_cnt;
		if (ts->platform_data->use_hndshk) {

			host_reg = g_xy_data.hst_mode & CY_HNDSHK_BIT ?
				g_xy_data.hst_mode & ~CY_HNDSHK_BIT :
				g_xy_data.hst_mode | CY_HNDSHK_BIT;
			retval = i2c_smbus_write_i2c_block_data(ts->client,
				CY_REG_BASE, sizeof(host_reg), &host_reg);
		}
		cur_cnt = g_xy_data.tt_undef[CY_IRQ_CNT_REG];
		irq_cnt_total++;
		irq_cnt++;
		if (irq_cnt != cur_cnt) {
			irq_err_cnt++;
			cyttsp_debug("i_c_ER: dv=%d fw=%d hm=%02X t=%lu te=%lu\n", \
				irq_cnt, \
				cur_cnt, g_xy_data.hst_mode, \
				(unsigned long)irq_cnt_total, \
				(unsigned long)irq_err_cnt);
		} else {
			cyttsp_debug("i_c_ok: dv=%d fw=%d hm=%02X t=%lu te=%lu\n", \
				irq_cnt, \
				cur_cnt, g_xy_data.hst_mode, \
				(unsigned long)irq_cnt_total, \
				(unsigned long)irq_err_cnt);
		}
		irq_cnt = cur_cnt;
	}

	/* Get the current num touches and return if there are no touches */
	if ((GET_BOOTLOADERMODE(g_xy_data.tt_mode) == 1) ||
		(GET_HSTMODE(g_xy_data.hst_mode) != CY_OK)) {
		u8 host_reg, tries;
		/* the TTSP device has suffered spurious reset or mode switch */
		cyttsp_debug( \
			"Spurious err opmode (tt_mode=%02X hst_mode=%02X)\n", \
			g_xy_data.tt_mode, g_xy_data.hst_mode);
		cyttsp_debug("Reset TTSP Device; Terminating active tracks\n");
		/* terminate all active tracks */
		cur_tch = CY_NTCH;
		/* reset TTSP part and take it back out of Bootloader mode */
		/* reset TTSP Device back to bootloader mode */
		host_reg = CY_SOFT_RESET_MODE;
		retval = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE,
			sizeof(host_reg), &host_reg);
		/* wait for TTSP Device to complete reset back to bootloader */
		tries = 0;
		do {
			mdelay(1);
			cyttsp_putbl(ts, 1, false, false, false);
		} while (g_bl_data.bl_status != 0x10 &&
			g_bl_data.bl_status != 0x11 &&
			tries++ < 100);
		retval = cyttsp_putbl(ts, 1, true, true, true);
		/* switch back to operational mode */
		/* take TTSP device out of bootloader mode;
		 * switch back to TrueTouch operational mode */
		if (!(retval < CY_OK)) {
			int tries;
			retval = i2c_smbus_write_i2c_block_data(ts->client,
				CY_REG_BASE,
				sizeof(bl_cmd), bl_cmd);
			/* wait for TTSP Device to complete
			 * switch to Operational mode */
			tries = 0;
			do {
				mdelay(100);
				cyttsp_putbl(ts, 2, false, false, false);
			} while (GET_BOOTLOADERMODE(g_bl_data.bl_status) &&
				tries++ < 100);
			cyttsp_putbl(ts, 2, true, false, false);
		}
		goto exit_xy_handler;
	} else {
		cur_tch = GET_NUM_TOUCHES(g_xy_data.tt_stat);
		if (IS_LARGE_AREA(g_xy_data.tt_stat)) {
			/* terminate all active tracks */
			cur_tch = CY_NTCH;
			cyttsp_debug("Large obj detect (tt_stat=0x%02X). Terminate act trks\n", \
			    g_xy_data.tt_stat);
		} else if (cur_tch > CY_NUM_MT_TCH_ID) {
			/* if the number of fingers on the touch surface
			 * is more than the maximum then
			 * there will be no new track information
			 * even for the original touches.
			 * Therefore, terminate all active tracks.
			 */
			cur_tch = CY_NTCH;
			cyttsp_debug("Num touch err (tt_stat=0x%02X). Terminate act trks\n", \
			    g_xy_data.tt_stat);
		}
	}

	/* set tool size */
	curr_tool_width = CY_SMALL_TOOL_WIDTH;

	/* translate Gen2 interface data into comparable Gen3 data */
	if (ts->platform_data->gen == CY_GEN2) {
		struct cyttsp_gen2_xydata_t *pxy_gen2_data;
		pxy_gen2_data = (struct cyttsp_gen2_xydata_t *)(&g_xy_data);

		/* use test data? */
		cyttsp_testdat(&g_xy_data, &tt_gen2_testray, \
			sizeof(struct cyttsp_gen3_xydata_t));

		if (ts->platform_data->disable_ghost_det &&
				(cur_tch == CY_GEN2_GHOST))
			cur_tch = CY_GEN2_2TOUCH;

		if (pxy_gen2_data->evnt_idx == CY_GEN2_NOTOUCH) {
			cur_tch = 0;
		} else if (cur_tch == CY_GEN2_GHOST) {
			cur_tch = 0;
		} else if (cur_tch == CY_GEN2_2TOUCH) {
			/* stuff artificial track ID1 and ID2 */
			g_xy_data.touch12_id = 0x12;
			g_xy_data.z1 = CY_MAXZ;
			g_xy_data.z2 = CY_MAXZ;
			cur_tch--;			/* 2 touches */
		} else if (cur_tch == CY_GEN2_1TOUCH) {
			/* stuff artificial track ID1 and ID2 */
			g_xy_data.touch12_id = 0x12;
			g_xy_data.z1 = CY_MAXZ;
			g_xy_data.z2 = CY_NTCH;
			if (pxy_gen2_data->evnt_idx == CY_GEN2_TOUCH2) {
				/* push touch 2 data into touch1
				 * (first finger up; second finger down) */
				/* stuff artificial track ID1 for touch2 info */
				g_xy_data.touch12_id = 0x20;
				/* stuff touch 1 with touch 2 coordinate data */
				g_xy_data.x1 = g_xy_data.x2;
				g_xy_data.y1 = g_xy_data.y2;
			}
		} else {
			cur_tch = 0;
		}
	} else {
		/* use test data? */
		cyttsp_testdat(&g_xy_data, &tt_gen3_testray, \
			sizeof(struct cyttsp_gen3_xydata_t));
	}



	/* clear current active track ID array and count previous touches */
	for (id = 0, prv_tch = CY_NTCH;
		id < CY_NUM_TRK_ID; id++) {
		cur_trk[id] = CY_NTCH;
		prv_tch += ts->act_trk[id];
	}

	/* send no events if no previous touches and no new touches */
	if ((prv_tch == CY_NTCH) &&
		((cur_tch == CY_NTCH) ||
		(cur_tch > CY_NUM_MT_TCH_ID))) {
		goto exit_xy_handler;
	}

	cyttsp_debug("prev=%d  curr=%d\n", prv_tch, cur_tch);

	for (id = 0; id < CY_NUM_ST_TCH_ID; id++) {
		/* clear current single touches array */
		cur_st_tch[id] = CY_IGNR_TCH;
	}

	/* clear single touch positions */
	st_x1 = CY_NTCH;
	st_y1 = CY_NTCH;
	st_z1 = CY_NTCH;
	st_x2 = CY_NTCH;
	st_y2 = CY_NTCH;
	st_z2 = CY_NTCH;

	for (id = 0; id < CY_NUM_MT_TCH_ID; id++) {
		/* clear current multi-touches array and
		 * multi-touch positions/z */
		cur_mt_tch[id] = CY_IGNR_TCH;
	}

	if (ts->platform_data->use_trk_id) {
		for (id = 0; id < CY_NUM_MT_TCH_ID; id++) {
			cur_mt_pos[id][CY_XPOS] = 0;
			cur_mt_pos[id][CY_YPOS] = 0;
			cur_mt_z[id] = 0;
		}
	} else {
		for (id = 0; id < CY_NUM_TRK_ID; id++) {
			cur_mt_pos[id][CY_XPOS] = 0;
			cur_mt_pos[id][CY_YPOS] = 0;
			cur_mt_z[id] = 0;
		}
	}

	/* Determine if display is tilted */
	if (FLIP_DATA(ts->platform_data->flags))
		tilt = true;
	else
		tilt = false;

	/* Check for switch in origin */
	if (REVERSE_X(ts->platform_data->flags))
		rev_x = true;
	else
		rev_x = false;

	if (REVERSE_Y(ts->platform_data->flags))
		rev_y = true;
	else
		rev_y = false;

	if (cur_tch) {
		struct cyttsp_gen2_xydata_t *pxy_gen2_data;
		struct cyttsp_gen3_xydata_t *pxy_gen3_data;
		switch (ts->platform_data->gen) {
		case CY_GEN2: {
			pxy_gen2_data =
				(struct cyttsp_gen2_xydata_t *)(&g_xy_data);
			cyttsp_xdebug("TTSP Gen2 report:\n");
			cyttsp_xdebug("%02X %02X %02X\n", \
				pxy_gen2_data->hst_mode, \
				pxy_gen2_data->tt_mode, \
				pxy_gen2_data->tt_stat);
			cyttsp_xdebug("%04X %04X %02X  %02X\n", \
				pxy_gen2_data->x1, \
				pxy_gen2_data->y1, \
				pxy_gen2_data->z1, \
				pxy_gen2_data->evnt_idx);
			cyttsp_xdebug("%04X %04X %02X\n", \
				pxy_gen2_data->x2, \
				pxy_gen2_data->y2, \
				pxy_gen2_data->tt_undef1);
			cyttsp_xdebug("%02X %02X %02X\n", \
				pxy_gen2_data->gest_cnt, \
				pxy_gen2_data->gest_id, \
				pxy_gen2_data->gest_set);
			break;
		}
		case CY_GEN3:
		default: {
			pxy_gen3_data =
				(struct cyttsp_gen3_xydata_t *)(&g_xy_data);
			cyttsp_xdebug("TTSP Gen3 report:\n");
			cyttsp_xdebug("%02X %02X %02X\n", \
				pxy_gen3_data->hst_mode,
				pxy_gen3_data->tt_mode,
				pxy_gen3_data->tt_stat);
			cyttsp_xdebug("%04X %04X %02X  %02X", \
				pxy_gen3_data->x1,
				pxy_gen3_data->y1,
				pxy_gen3_data->z1, \
				pxy_gen3_data->touch12_id);
			cyttsp_xdebug("%04X %04X %02X\n", \
				pxy_gen3_data->x2, \
				pxy_gen3_data->y2, \
				pxy_gen3_data->z2);
			cyttsp_xdebug("%02X %02X %02X\n", \
				pxy_gen3_data->gest_cnt, \
				pxy_gen3_data->gest_id, \
				pxy_gen3_data->gest_set);
			cyttsp_xdebug("%04X %04X %02X  %02X\n", \
				pxy_gen3_data->x3, \
				pxy_gen3_data->y3, \
				pxy_gen3_data->z3, \
				pxy_gen3_data->touch34_id);
			cyttsp_xdebug("%04X %04X %02X\n", \
				pxy_gen3_data->x4, \
				pxy_gen3_data->y4, \
				pxy_gen3_data->z4);
			break;
		}
		}
	}

	/* process the touches */
	switch (cur_tch) {
	case 4: {
		g_xy_data.x4 = be16_to_cpu(g_xy_data.x4);
		g_xy_data.y4 = be16_to_cpu(g_xy_data.y4);
		if (tilt)
			FLIP_XY(g_xy_data.x4, g_xy_data.y4);

		if (rev_x) {
			val = INVERT_X(g_xy_data.x4,
					ts->platform_data->panel_maxx);
			if (val >= 0)
				g_xy_data.x4 = val;
			else
				pr_debug("X value is negative. Please configure"
					" maxx in platform data structure\n");
		}
		if (rev_y) {
			val = INVERT_X(g_xy_data.y4,
					ts->platform_data->panel_maxy);
			if (val >= 0)
				g_xy_data.y4 = val;
			else
				pr_debug("Y value is negative. Please configure"
					" maxy in platform data structure\n");

		}
		id = GET_TOUCH4_ID(g_xy_data.touch34_id);
		if (ts->platform_data->use_trk_id) {
			cur_mt_pos[CY_MT_TCH4_IDX][CY_XPOS] =
				g_xy_data.x4;
			cur_mt_pos[CY_MT_TCH4_IDX][CY_YPOS] =
				g_xy_data.y4;
			cur_mt_z[CY_MT_TCH4_IDX] = g_xy_data.z4;
		} else {
			cur_mt_pos[id][CY_XPOS] = g_xy_data.x4;
			cur_mt_pos[id][CY_YPOS] = g_xy_data.y4;
			cur_mt_z[id] = g_xy_data.z4;
		}
		cur_mt_tch[CY_MT_TCH4_IDX] = id;
		cur_trk[id] = CY_TCH;
		if (ts->prv_st_tch[CY_ST_FNGR1_IDX] <
			CY_NUM_TRK_ID) {
			if (ts->prv_st_tch[CY_ST_FNGR1_IDX] == id) {
				st_x1 = g_xy_data.x4;
				st_y1 = g_xy_data.y4;
				st_z1 = g_xy_data.z4;
				cur_st_tch[CY_ST_FNGR1_IDX] = id;
			} else if (ts->prv_st_tch[CY_ST_FNGR2_IDX] == id) {
				st_x2 = g_xy_data.x4;
				st_y2 = g_xy_data.y4;
				st_z2 = g_xy_data.z4;
				cur_st_tch[CY_ST_FNGR2_IDX] = id;
			}
		}
		cyttsp_xdebug("4th XYZ:% 3d,% 3d,% 3d  ID:% 2d\n\n", \
			g_xy_data.x4, g_xy_data.y4, g_xy_data.z4, \
			(g_xy_data.touch34_id & 0x0F));
		/* do not break */
	}
	case 3: {
		g_xy_data.x3 = be16_to_cpu(g_xy_data.x3);
		g_xy_data.y3 = be16_to_cpu(g_xy_data.y3);
		if (tilt)
			FLIP_XY(g_xy_data.x3, g_xy_data.y3);

		if (rev_x) {
			val = INVERT_X(g_xy_data.x3,
					ts->platform_data->panel_maxx);
			if (val >= 0)
				g_xy_data.x3 = val;
			else
				pr_debug("X value is negative. Please configure"
					" maxx in platform data structure\n");

		}
		if (rev_y) {
			val = INVERT_X(g_xy_data.y3,
					ts->platform_data->panel_maxy);
			if (val >= 0)
				g_xy_data.y3 = val;
			else
				pr_debug("Y value is negative. Please configure"
					" maxy in platform data structure\n");

		}
		id = GET_TOUCH3_ID(g_xy_data.touch34_id);
		if (ts->platform_data->use_trk_id) {
			cur_mt_pos[CY_MT_TCH3_IDX][CY_XPOS] =
				g_xy_data.x3;
			cur_mt_pos[CY_MT_TCH3_IDX][CY_YPOS] =
				g_xy_data.y3;
			cur_mt_z[CY_MT_TCH3_IDX] = g_xy_data.z3;
		} else {
			cur_mt_pos[id][CY_XPOS] = g_xy_data.x3;
			cur_mt_pos[id][CY_YPOS] = g_xy_data.y3;
			cur_mt_z[id] = g_xy_data.z3;
		}
		cur_mt_tch[CY_MT_TCH3_IDX] = id;
		cur_trk[id] = CY_TCH;
		if (ts->prv_st_tch[CY_ST_FNGR1_IDX] <
			CY_NUM_TRK_ID) {
			if (ts->prv_st_tch[CY_ST_FNGR1_IDX] == id) {
				st_x1 = g_xy_data.x3;
				st_y1 = g_xy_data.y3;
				st_z1 = g_xy_data.z3;
				cur_st_tch[CY_ST_FNGR1_IDX] = id;
			} else if (ts->prv_st_tch[CY_ST_FNGR2_IDX] == id) {
				st_x2 = g_xy_data.x3;
				st_y2 = g_xy_data.y3;
				st_z2 = g_xy_data.z3;
				cur_st_tch[CY_ST_FNGR2_IDX] = id;
			}
		}
		cyttsp_xdebug("3rd XYZ:% 3d,% 3d,% 3d  ID:% 2d\n", \
			g_xy_data.x3, g_xy_data.y3, g_xy_data.z3, \
			((g_xy_data.touch34_id >> 4) & 0x0F));
		/* do not break */
	}
	case 2: {
		g_xy_data.x2 = be16_to_cpu(g_xy_data.x2);
		g_xy_data.y2 = be16_to_cpu(g_xy_data.y2);
		if (tilt)
			FLIP_XY(g_xy_data.x2, g_xy_data.y2);

		if (rev_x) {
			val = INVERT_X(g_xy_data.x2,
					ts->platform_data->panel_maxx);
			if (val >= 0)
				g_xy_data.x2 = val;
			else
				pr_debug("X value is negative. Please configure"
					" maxx in platform data structure\n");
		}
		if (rev_y) {
			val = INVERT_X(g_xy_data.y2,
					ts->platform_data->panel_maxy);
			if (val >= 0)
				g_xy_data.y2 = val;
			else
				pr_debug("Y value is negative. Please configure"
					" maxy in platform data structure\n");
		}
		id = GET_TOUCH2_ID(g_xy_data.touch12_id);
		if (ts->platform_data->use_trk_id) {
			cur_mt_pos[CY_MT_TCH2_IDX][CY_XPOS] =
				g_xy_data.x2;
			cur_mt_pos[CY_MT_TCH2_IDX][CY_YPOS] =
				g_xy_data.y2;
			cur_mt_z[CY_MT_TCH2_IDX] = g_xy_data.z2;
		} else {
			cur_mt_pos[id][CY_XPOS] = g_xy_data.x2;
			cur_mt_pos[id][CY_YPOS] = g_xy_data.y2;
			cur_mt_z[id] = g_xy_data.z2;
		}
		cur_mt_tch[CY_MT_TCH2_IDX] = id;
		cur_trk[id] = CY_TCH;
		if (ts->prv_st_tch[CY_ST_FNGR1_IDX] <
			CY_NUM_TRK_ID) {
			if (ts->prv_st_tch[CY_ST_FNGR1_IDX] == id) {
				st_x1 = g_xy_data.x2;
				st_y1 = g_xy_data.y2;
				st_z1 = g_xy_data.z2;
				cur_st_tch[CY_ST_FNGR1_IDX] = id;
			} else if (ts->prv_st_tch[CY_ST_FNGR2_IDX] == id) {
				st_x2 = g_xy_data.x2;
				st_y2 = g_xy_data.y2;
				st_z2 = g_xy_data.z2;
				cur_st_tch[CY_ST_FNGR2_IDX] = id;
			}
		}
		cyttsp_xdebug("2nd XYZ:% 3d,% 3d,% 3d  ID:% 2d\n", \
			g_xy_data.x2, g_xy_data.y2, g_xy_data.z2, \
			(g_xy_data.touch12_id & 0x0F));
		/* do not break */
	}
	case 1:	{
		g_xy_data.x1 = be16_to_cpu(g_xy_data.x1);
		g_xy_data.y1 = be16_to_cpu(g_xy_data.y1);
		if (tilt)
			FLIP_XY(g_xy_data.x1, g_xy_data.y1);

		if (rev_x) {
			val = INVERT_X(g_xy_data.x1,
					ts->platform_data->panel_maxx);
			if (val >= 0)
				g_xy_data.x1 = val;
			else
				pr_debug("X value is negative. Please configure"
					" maxx in platform data structure\n");
		}
		if (rev_y) {
			val = INVERT_X(g_xy_data.y1,
					ts->platform_data->panel_maxy);
			if (val >= 0)
				g_xy_data.y1 = val;
			else
				pr_debug("Y value is negative. Please configure"
					" maxy in platform data structure");
		}
		id = GET_TOUCH1_ID(g_xy_data.touch12_id);
		if (ts->platform_data->use_trk_id) {
			cur_mt_pos[CY_MT_TCH1_IDX][CY_XPOS] =
				g_xy_data.x1;
			cur_mt_pos[CY_MT_TCH1_IDX][CY_YPOS] =
				g_xy_data.y1;
			cur_mt_z[CY_MT_TCH1_IDX] = g_xy_data.z1;
		} else {
			cur_mt_pos[id][CY_XPOS] = g_xy_data.x1;
			cur_mt_pos[id][CY_YPOS] = g_xy_data.y1;
			cur_mt_z[id] = g_xy_data.z1;
		}
		cur_mt_tch[CY_MT_TCH1_IDX] = id;
		cur_trk[id] = CY_TCH;
		if (ts->prv_st_tch[CY_ST_FNGR1_IDX] <
			CY_NUM_TRK_ID) {
			if (ts->prv_st_tch[CY_ST_FNGR1_IDX] == id) {
				st_x1 = g_xy_data.x1;
				st_y1 = g_xy_data.y1;
				st_z1 = g_xy_data.z1;
				cur_st_tch[CY_ST_FNGR1_IDX] = id;
			} else if (ts->prv_st_tch[CY_ST_FNGR2_IDX] == id) {
				st_x2 = g_xy_data.x1;
				st_y2 = g_xy_data.y1;
				st_z2 = g_xy_data.z1;
				cur_st_tch[CY_ST_FNGR2_IDX] = id;
			}
		}
		cyttsp_xdebug("1st XYZ:% 3d,% 3d,% 3d  ID:% 2d\n", \
			g_xy_data.x1, g_xy_data.y1, g_xy_data.z1, \
			((g_xy_data.touch12_id >> 4) & 0x0F));
		break;
	}
	case 0:
	default:{
		break;
	}
	}

	/* handle Single Touch signals */
	if (ts->platform_data->use_st) {
		cyttsp_xdebug("ST STEP 0 - ST1 ID=%d  ST2 ID=%d\n", \
			cur_st_tch[CY_ST_FNGR1_IDX], \
			cur_st_tch[CY_ST_FNGR2_IDX]);
		if (cur_st_tch[CY_ST_FNGR1_IDX] > CY_NUM_TRK_ID) {
			/* reassign finger 1 and 2 positions to new tracks */
			if (cur_tch > 0) {
				/* reassign st finger1 */
				if (ts->platform_data->use_trk_id) {
					id = CY_MT_TCH1_IDX;
					cur_st_tch[CY_ST_FNGR1_IDX] = cur_mt_tch[id];
				} else {
					id = GET_TOUCH1_ID(g_xy_data.touch12_id);
					cur_st_tch[CY_ST_FNGR1_IDX] = id;
				}
				st_x1 = cur_mt_pos[id][CY_XPOS];
				st_y1 = cur_mt_pos[id][CY_YPOS];
				st_z1 = cur_mt_z[id];
				cyttsp_xdebug("ST STEP 1 - ST1 ID=%3d\n", \
					cur_st_tch[CY_ST_FNGR1_IDX]);
				if ((cur_tch > 1) &&
					(cur_st_tch[CY_ST_FNGR2_IDX] >
					CY_NUM_TRK_ID)) {
					/* reassign st finger2 */
					if (cur_tch > 1) {
						if (ts->platform_data->use_trk_id) {
							id = CY_MT_TCH2_IDX;
							cur_st_tch[CY_ST_FNGR2_IDX] = cur_mt_tch[id];
						} else {
							id = GET_TOUCH2_ID(g_xy_data.touch12_id);
							cur_st_tch[CY_ST_FNGR2_IDX] = id;
						}
						st_x2 = cur_mt_pos[id][CY_XPOS];
						st_y2 = cur_mt_pos[id][CY_YPOS];
						st_z2 = cur_mt_z[id];
						cyttsp_xdebug("ST STEP 2 - ST2 ID=%3d\n", \
							cur_st_tch[CY_ST_FNGR2_IDX]);
					}
				}
			}
		} else if (cur_st_tch[CY_ST_FNGR2_IDX] > CY_NUM_TRK_ID) {
			if (cur_tch > 1) {
				/* reassign st finger2 */
				if (ts->platform_data->use_trk_id) {
					/* reassign st finger2 */
					id = CY_MT_TCH2_IDX;
					cur_st_tch[CY_ST_FNGR2_IDX] =
						cur_mt_tch[id];
				} else {
					/* reassign st finger2 */
					id = GET_TOUCH2_ID(g_xy_data.touch12_id);
					cur_st_tch[CY_ST_FNGR2_IDX] = id;
				}
				st_x2 = cur_mt_pos[id][CY_XPOS];
				st_y2 = cur_mt_pos[id][CY_YPOS];
				st_z2 = cur_mt_z[id];
				cyttsp_xdebug("ST STEP 3 - ST2 ID=%3d\n", \
					cur_st_tch[CY_ST_FNGR2_IDX]);
			}
		}
		/* if the 1st touch is missing and there is a 2nd touch,
		 * then set the 1st touch to 2nd touch and terminate 2nd touch
		 */
		if ((cur_st_tch[CY_ST_FNGR1_IDX] > CY_NUM_TRK_ID) &&
		    (cur_st_tch[CY_ST_FNGR2_IDX] < CY_NUM_TRK_ID)) {
			st_x1 = st_x2;
			st_y1 = st_y2;
			st_z1 = st_z2;
			cur_st_tch[CY_ST_FNGR1_IDX] =
				cur_st_tch[CY_ST_FNGR2_IDX];
			cur_st_tch[CY_ST_FNGR2_IDX] =
				CY_IGNR_TCH;
		}
		/* if the 2nd touch ends up equal to the 1st touch,
		 * then just report a single touch */
		if (cur_st_tch[CY_ST_FNGR1_IDX] ==
			cur_st_tch[CY_ST_FNGR2_IDX]) {
			cur_st_tch[CY_ST_FNGR2_IDX] =
				CY_IGNR_TCH;
		}
		/* set Single Touch current event signals */
		if (cur_st_tch[CY_ST_FNGR1_IDX] < CY_NUM_TRK_ID) {
			input_report_abs(ts->input,
				ABS_X, st_x1);
			input_report_abs(ts->input,
				ABS_Y, st_y1);
			input_report_abs(ts->input,
				ABS_PRESSURE, st_z1);
			input_report_key(ts->input,
				BTN_TOUCH,
				CY_TCH);
			input_report_abs(ts->input,
				ABS_TOOL_WIDTH,
				curr_tool_width);
			cyttsp_debug("ST->F1:%3d X:%3d Y:%3d Z:%3d\n", \
				cur_st_tch[CY_ST_FNGR1_IDX], \
				st_x1, st_y1, st_z1);
			if (cur_st_tch[CY_ST_FNGR2_IDX] < CY_NUM_TRK_ID) {
				input_report_key(ts->input, BTN_2, CY_TCH);
				input_report_abs(ts->input, ABS_HAT0X, st_x2);
				input_report_abs(ts->input, ABS_HAT0Y, st_y2);
				cyttsp_debug("ST->F2:%3d X:%3d Y:%3d Z:%3d\n", \
					cur_st_tch[CY_ST_FNGR2_IDX],
					st_x2, st_y2, st_z2);
			} else {
				input_report_key(ts->input,
					BTN_2,
					CY_NTCH);
			}
		} else {
			input_report_abs(ts->input, ABS_PRESSURE, CY_NTCH);
			input_report_key(ts->input, BTN_TOUCH, CY_NTCH);
			input_report_key(ts->input, BTN_2, CY_NTCH);
		}
		/* update platform data for the current single touch info */
		ts->prv_st_tch[CY_ST_FNGR1_IDX] = cur_st_tch[CY_ST_FNGR1_IDX];
		ts->prv_st_tch[CY_ST_FNGR2_IDX] = cur_st_tch[CY_ST_FNGR2_IDX];

	}

	/* handle Multi-touch signals */
	if (ts->platform_data->use_mt) {
		if (ts->platform_data->use_trk_id) {
			/* terminate any previous touch where the track
			 * is missing from the current event */
			for (id = 0; id < CY_NUM_TRK_ID; id++) {
				if ((ts->act_trk[id] != CY_NTCH) &&
					(cur_trk[id] == CY_NTCH)) {
					input_report_abs(ts->input,
						ABS_MT_TRACKING_ID,
						id);
					input_report_abs(ts->input,
						ABS_MT_TOUCH_MAJOR,
						CY_NTCH);
					input_report_abs(ts->input,
						ABS_MT_WIDTH_MAJOR,
						curr_tool_width);
					input_report_abs(ts->input,
						ABS_MT_POSITION_X,
						ts->prv_mt_pos[id][CY_XPOS]);
					input_report_abs(ts->input,
						ABS_MT_POSITION_Y,
						ts->prv_mt_pos[id][CY_YPOS]);
					CY_MT_SYNC(ts->input);
					ts->act_trk[id] = CY_NTCH;
					ts->prv_mt_pos[id][CY_XPOS] = 0;
					ts->prv_mt_pos[id][CY_YPOS] = 0;
				}
			}
			/* set Multi-Touch current event signals */
			for (id = 0; id < CY_NUM_MT_TCH_ID; id++) {
				if (cur_mt_tch[id] < CY_NUM_TRK_ID) {
					input_report_abs(ts->input,
						ABS_MT_TRACKING_ID,
						cur_mt_tch[id]);
					input_report_abs(ts->input,
						ABS_MT_TOUCH_MAJOR,
						cur_mt_z[id]);
					input_report_abs(ts->input,
						ABS_MT_WIDTH_MAJOR,
						curr_tool_width);
					input_report_abs(ts->input,
						ABS_MT_POSITION_X,
						cur_mt_pos[id][CY_XPOS]);
					input_report_abs(ts->input,
						ABS_MT_POSITION_Y,
						cur_mt_pos[id][CY_YPOS]);
					CY_MT_SYNC(ts->input);
					ts->act_trk[id] = CY_TCH;
					ts->prv_mt_pos[id][CY_XPOS] =
						cur_mt_pos[id][CY_XPOS];
					ts->prv_mt_pos[id][CY_YPOS] =
						cur_mt_pos[id][CY_YPOS];
				}
			}
		} else {
			/* set temporary track array elements to voids */
			for (id = 0; id < CY_NUM_MT_TCH_ID; id++) {
				tmp_trk[id] = CY_IGNR_TCH;
				snd_trk[id] = CY_IGNR_TCH;
			}

			/* get what is currently active */
			for (i = 0, id = 0;
				id < CY_NUM_TRK_ID && i < CY_NUM_MT_TCH_ID;
				id++) {
				if (cur_trk[id] == CY_TCH) {
					/* only incr counter if track found */
					tmp_trk[i] = id;
					i++;
				}
			}
			cyttsp_xdebug("T1: t0=%d, t1=%d, t2=%d, t3=%d\n", \
				tmp_trk[0], tmp_trk[1], tmp_trk[2], \
				tmp_trk[3]);
			cyttsp_xdebug("T1: p0=%d, p1=%d, p2=%d, p3=%d\n", \
				ts->prv_mt_tch[0], ts->prv_mt_tch[1], \
				ts->prv_mt_tch[2], ts->prv_mt_tch[3]);

			/* pack in still active previous touches */
			for (id = 0, prv_tch = 0;
				id < CY_NUM_MT_TCH_ID; id++) {
				if (tmp_trk[id] < CY_NUM_TRK_ID) {
					if (cyttsp_inlist(ts->prv_mt_tch,
						tmp_trk[id], &loc,
						CY_NUM_MT_TCH_ID)) {
						loc &= CY_NUM_MT_TCH_ID - 1;
						snd_trk[loc] = tmp_trk[id];
						prv_tch++;
						cyttsp_xdebug("inlist s[%d]=%d t[%d]=%d l=%d p=%d\n", \
							loc, snd_trk[loc], \
							id, tmp_trk[id], \
							loc, prv_tch);
					} else {
						cyttsp_xdebug("not inlist s[%d]=%d t[%d]=%d l=%d \n", \
							id, snd_trk[id], \
							id, tmp_trk[id], \
							loc);
					}
				}
			}
			cyttsp_xdebug("S1: s0=%d, s1=%d, s2=%d, s3=%d p=%d\n", \
				snd_trk[0], snd_trk[1], snd_trk[2], \
				snd_trk[3], prv_tch);

			/* pack in new touches */
			for (id = 0; id < CY_NUM_MT_TCH_ID; id++) {
				if (tmp_trk[id] < CY_NUM_TRK_ID) {
					if (!cyttsp_inlist(snd_trk, tmp_trk[id], &loc, CY_NUM_MT_TCH_ID)) {
						cyttsp_xdebug("not inlist t[%d]=%d l=%d\n", \
							id, tmp_trk[id], loc);
						if (cyttsp_next_avail_inlist(snd_trk, &loc, CY_NUM_MT_TCH_ID)) {
							loc &= CY_NUM_MT_TCH_ID - 1;
							snd_trk[loc] = tmp_trk[id];
							cyttsp_xdebug("put inlist s[%d]=%d t[%d]=%d\n",
								loc, snd_trk[loc], id, tmp_trk[id]);
						}
					} else {
						cyttsp_xdebug("is in list s[%d]=%d t[%d]=%d loc=%d\n", \
							id, snd_trk[id], id, tmp_trk[id], loc);
					}
				}
			}
			cyttsp_xdebug("S2: s0=%d, s1=%d, s2=%d, s3=%d\n", \
				snd_trk[0], snd_trk[1],
				snd_trk[2], snd_trk[3]);

			/* sync motion event signals for each current touch */
			for (id = 0; id < CY_NUM_MT_TCH_ID; id++) {
				/* z will either be 0 (NOTOUCH) or
				 * some pressure (TOUCH) */
				cyttsp_xdebug("MT0 prev[%d]=%d temp[%d]=%d send[%d]=%d\n", \
					id, ts->prv_mt_tch[id], \
					id, tmp_trk[id], \
					id, snd_trk[id]);
				if (snd_trk[id] < CY_NUM_TRK_ID) {
					input_report_abs(ts->input,
						ABS_MT_TOUCH_MAJOR,
						cur_mt_z[snd_trk[id]]);
					input_report_abs(ts->input,
						ABS_MT_WIDTH_MAJOR,
						curr_tool_width);
					input_report_abs(ts->input,
						ABS_MT_POSITION_X,
						cur_mt_pos[snd_trk[id]][CY_XPOS]);
					input_report_abs(ts->input,
						ABS_MT_POSITION_Y,
						cur_mt_pos[snd_trk[id]][CY_YPOS]);
					CY_MT_SYNC(ts->input);
					cyttsp_debug("MT1->TID:%2d X:%3d Y:%3d Z:%3d touch-sent\n", \
						snd_trk[id], \
						cur_mt_pos[snd_trk[id]][CY_XPOS], \
						cur_mt_pos[snd_trk[id]][CY_YPOS], \
						cur_mt_z[snd_trk[id]]);
				} else if (ts->prv_mt_tch[id] < CY_NUM_TRK_ID) {
					/* void out this touch */
					input_report_abs(ts->input,
						ABS_MT_TOUCH_MAJOR,
						CY_NTCH);
					input_report_abs(ts->input,
						ABS_MT_WIDTH_MAJOR,
						curr_tool_width);
					input_report_abs(ts->input,
						ABS_MT_POSITION_X,
						ts->prv_mt_pos[ts->prv_mt_tch[id]][CY_XPOS]);
					input_report_abs(ts->input,
						ABS_MT_POSITION_Y,
						ts->prv_mt_pos[ts->prv_mt_tch[id]][CY_YPOS]);
					CY_MT_SYNC(ts->input);
					cyttsp_debug("MT2->TID:%2d X:%3d Y:%3d Z:%3d lift off-sent\n", \
						ts->prv_mt_tch[id], \
						ts->prv_mt_pos[ts->prv_mt_tch[id]][CY_XPOS], \
						ts->prv_mt_pos[ts->prv_mt_tch[id]][CY_YPOS], \
						CY_NTCH);
				} else {
					/* do not stuff any signals for this
					 * previously and currently
					 * void touches */
					cyttsp_xdebug("MT3->send[%d]=%d - No touch - NOT sent\n", \
							id, snd_trk[id]);
				}
			}

			/* save current posted tracks to
			 * previous track memory */
			for (id = 0; id < CY_NUM_MT_TCH_ID; id++) {
				ts->prv_mt_tch[id] = snd_trk[id];
				if (snd_trk[id] < CY_NUM_TRK_ID) {
					ts->prv_mt_pos[snd_trk[id]][CY_XPOS] =
						cur_mt_pos[snd_trk[id]][CY_XPOS];
					ts->prv_mt_pos[snd_trk[id]][CY_YPOS] =
						cur_mt_pos[snd_trk[id]][CY_YPOS];
					cyttsp_xdebug("MT4->TID:%2d X:%3d Y:%3d Z:%3d save for previous\n", \
						snd_trk[id], \
						ts->prv_mt_pos[snd_trk[id]][CY_XPOS], \
						ts->prv_mt_pos[snd_trk[id]][CY_YPOS], \
						CY_NTCH);
				}
			}
			for (id = 0; id < CY_NUM_TRK_ID; id++)
				ts->act_trk[id] = CY_NTCH;
			for (id = 0; id < CY_NUM_MT_TCH_ID; id++) {
				if (snd_trk[id] < CY_NUM_TRK_ID)
					ts->act_trk[snd_trk[id]] = CY_TCH;
			}
		}
	}

	/* handle gestures */
	if (ts->platform_data->use_gestures) {
		if (g_xy_data.gest_id) {
			input_report_key(ts->input,
				BTN_3, CY_TCH);
			input_report_abs(ts->input,
				ABS_HAT1X, g_xy_data.gest_id);
			input_report_abs(ts->input,
				ABS_HAT2Y, g_xy_data.gest_cnt);
		}
	}

	/* signal the view motion event */
	input_sync(ts->input);

	for (id = 0; id < CY_NUM_TRK_ID; id++) {
		/* update platform data for the current MT information */
		ts->act_trk[id] = cur_trk[id];
	}

exit_xy_handler:
	/* restart event timer */
	if (ts->client->irq == 0)
		mod_timer(&ts->timer, jiffies + TOUCHSCREEN_TIMEOUT);
	return;
}

static int cyttsp_inlist(u16 prev_track[], u8 cur_trk_id,
			u8 *prev_loc, u8 num_touches)
{
	u8 id = 0;

	*prev_loc = CY_IGNR_TCH;

		cyttsp_xdebug("IN p[%d]=%d c=%d n=%d loc=%d\n", \
			id, prev_track[id], cur_trk_id, \
			num_touches, *prev_loc);
	for (id = 0, *prev_loc = CY_IGNR_TCH;
		(id < num_touches); id++) {
		cyttsp_xdebug("p[%d]=%d c=%d n=%d loc=%d\n", \
			id, prev_track[id], cur_trk_id, \
			num_touches, *prev_loc);
		if (prev_track[id] == cur_trk_id) {
			*prev_loc = id;
			break;
		}
	}
	cyttsp_xdebug("OUT p[%d]=%d c=%d n=%d loc=%d\n", \
		id, prev_track[id], cur_trk_id, num_touches, *prev_loc);

	return ((*prev_loc < CY_NUM_TRK_ID) ? true : false);
}

static int cyttsp_next_avail_inlist(u16 cur_trk[],
			u8 *new_loc, u8 num_touches)
{
	u8 id;

	for (id = 0, *new_loc = CY_IGNR_TCH;
		(id < num_touches); id++) {
		if (cur_trk[id] > CY_NUM_TRK_ID) {
			*new_loc = id;
			break;
		}
	}

	return ((*new_loc < CY_NUM_TRK_ID) ? true : false);
}

/* Timer function used as dummy interrupt driver */
static void cyttsp_timer(unsigned long handle)
{
	struct cyttsp *ts = (struct cyttsp *) handle;

	cyttsp_xdebug("TTSP Device timer event\n");

	/* schedule motion signal handling */
	cyttsp_xy_handler(ts);

	return;
}



/* ************************************************************************
 * ISR function. This function is general, initialized in drivers init
 * function
 * ************************************************************************ */
static irqreturn_t cyttsp_irq(int irq, void *handle)
{
	struct cyttsp *ts = (struct cyttsp *) handle;

	cyttsp_xdebug("%s: Got IRQ\n", CY_I2C_NAME);

	cyttsp_xy_handler(ts);

	return IRQ_HANDLED;
}

/* ************************************************************************
 * Probe initialization functions
 * ************************************************************************ */
static int cyttsp_putbl(struct cyttsp *ts, int show,
			int show_status, int show_version, int show_cid)
{
	int retval = CY_OK;

	int num_bytes = (show_status * 3) + (show_version * 6) + (show_cid * 3);

	if (show_cid)
		num_bytes = sizeof(struct cyttsp_bootloader_data_t);
	else if (show_version)
		num_bytes = sizeof(struct cyttsp_bootloader_data_t) - 3;
	else
		num_bytes = sizeof(struct cyttsp_bootloader_data_t) - 9;

	if (show) {
		retval = i2c_smbus_read_i2c_block_data(ts->client,
			CY_REG_BASE, num_bytes, (u8 *)&g_bl_data);
		if (show_status) {
			cyttsp_debug("BL%d: f=%02X s=%02X err=%02X bl=%02X%02X bld=%02X%02X\n", \
				show, \
				g_bl_data.bl_file, \
				g_bl_data.bl_status, \
				g_bl_data.bl_error, \
				g_bl_data.blver_hi, g_bl_data.blver_lo, \
				g_bl_data.bld_blver_hi, g_bl_data.bld_blver_lo);
		}
		if (show_version) {
			cyttsp_debug("BL%d: ttspver=0x%02X%02X appid=0x%02X%02X appver=0x%02X%02X\n", \
				show, \
				g_bl_data.ttspver_hi, g_bl_data.ttspver_lo, \
				g_bl_data.appid_hi, g_bl_data.appid_lo, \
				g_bl_data.appver_hi, g_bl_data.appver_lo);
		}
		if (show_cid) {
			cyttsp_debug("BL%d: cid=0x%02X%02X%02X\n", \
				show, \
				g_bl_data.cid_0, \
				g_bl_data.cid_1, \
				g_bl_data.cid_2);
		}
	}

	return retval;
}

#ifdef CY_INCLUDE_LOAD_FILE
#define CY_MAX_I2C_LEN	256
#define CY_MAX_TRY		10
#define CY_BL_PAGE_SIZE	16
#define CY_BL_NUM_PAGES	5
static int cyttsp_i2c_wr_blk_chunks(struct cyttsp *ts, u8 command,
	u8 length, const u8 *values)
{
	int retval = CY_OK;
	int block = 1;

	u8 dataray[CY_MAX_I2C_LEN];

	/* first page already includes the bl page offset */
	retval = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE,
		CY_BL_PAGE_SIZE+1, values);
	values += CY_BL_PAGE_SIZE+1;
	length -= CY_BL_PAGE_SIZE+1;

	/* rem blocks require bl page offset stuffing */
	while (length &&
		(block < CY_BL_NUM_PAGES) &&
		!(retval < CY_OK)) {
		udelay(43*2);	/* TRM * 2 */
		dataray[0] = CY_BL_PAGE_SIZE*block;
		memcpy(&dataray[1], values,
			length >= CY_BL_PAGE_SIZE ?
			CY_BL_PAGE_SIZE : length);
		retval = i2c_smbus_write_i2c_block_data(ts->client,
			CY_REG_BASE,
			length >= CY_BL_PAGE_SIZE ?
			CY_BL_PAGE_SIZE + 1 : length+1, dataray);
		values += CY_BL_PAGE_SIZE;
		length = length >= CY_BL_PAGE_SIZE ?
			length - CY_BL_PAGE_SIZE : 0;
		block++;
	}

	return retval;
}

static int cyttsp_bootload_app(struct cyttsp *ts)
{
	int retval = CY_OK;
	int i, tries;
	u8 host_reg;

	cyttsp_debug("load new firmware \n");
	/* reset TTSP Device back to bootloader mode */
	host_reg = CY_SOFT_RESET_MODE;
	retval = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE,
		sizeof(host_reg), &host_reg);
	/* wait for TTSP Device to complete reset back to bootloader */
	tries = 0;
	do {
		mdelay(1);
		cyttsp_putbl(ts, 3, false, false, false);
	} while (g_bl_data.bl_status != 0x10 &&
		g_bl_data.bl_status != 0x11 &&
		tries++ < 100);
	cyttsp_debug("load file - tver=0x%02X%02X a_id=0x%02X%02X aver=0x%02X%02X\n", \
		cyttsp_fw_tts_verh, cyttsp_fw_tts_verl, \
		cyttsp_fw_app_idh, cyttsp_fw_app_idl, \
		cyttsp_fw_app_verh, cyttsp_fw_app_verl);

	/* download new TTSP Application to the Bootloader */
	if (!(retval < CY_OK)) {
		i = 0;
		/* send bootload initiation command */
		if (cyttsp_fw[i].Command == CY_BL_INIT_LOAD) {
			g_bl_data.bl_file = 0;
			g_bl_data.bl_status = 0;
			g_bl_data.bl_error = 0;
			retval = i2c_smbus_write_i2c_block_data(ts->client,
				CY_REG_BASE,
				cyttsp_fw[i].Length, cyttsp_fw[i].Block);
			/* delay to allow bl to get ready for block writes */
			i++;
			tries = 0;
			do {
				mdelay(100);
				cyttsp_putbl(ts, 4, false, false, false);
			} while (g_bl_data.bl_status != 0x10 &&
				g_bl_data.bl_status != 0x11 &&
				tries++ < 100);
			cyttsp_debug("wait init f=%02X, s=%02X, e=%02X t=%d\n", \
				g_bl_data.bl_file, g_bl_data.bl_status, \
				g_bl_data.bl_error, tries);
			/* send bootload firmware load blocks */
			if (!(retval < CY_OK)) {
				while (cyttsp_fw[i].Command == CY_BL_WRITE_BLK) {
					retval = cyttsp_i2c_wr_blk_chunks(ts,
						CY_REG_BASE,
						cyttsp_fw[i].Length,
						cyttsp_fw[i].Block);
					cyttsp_xdebug("BL DNLD Rec=% 3d Len=% 3d Addr=%04X\n", \
						cyttsp_fw[i].Record, \
						cyttsp_fw[i].Length, \
						cyttsp_fw[i].Address);
					i++;
					if (retval < CY_OK) {
						cyttsp_debug("BL fail Rec=%3d retval=%d\n", \
							cyttsp_fw[i-1].Record, \
							retval);
						break;
					} else {
						tries = 0;
						cyttsp_putbl(ts, 5, false, false, false);
						while (!((g_bl_data.bl_status == 0x10) &&
							(g_bl_data.bl_error == 0x20)) &&
							!((g_bl_data.bl_status == 0x11) &&
							(g_bl_data.bl_error == 0x20)) &&
							(tries++ < 100)) {
							mdelay(1);
							cyttsp_putbl(ts, 5, false, false, false);
						}
					}
				}

				if (!(retval < CY_OK)) {
					while (i < cyttsp_fw_records) {
						retval = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE,
							cyttsp_fw[i].Length,
							cyttsp_fw[i].Block);
						i++;
						tries = 0;
						do {
							mdelay(100);
							cyttsp_putbl(ts, 6, true, false, false);
						} while (g_bl_data.bl_status != 0x10 &&
							g_bl_data.bl_status != 0x11 &&
							tries++ < 100);
						cyttsp_debug("wait term f=%02X, s=%02X, e=%02X t=%d\n", \
							g_bl_data.bl_file, \
							g_bl_data.bl_status, \
							g_bl_data.bl_error, \
							tries);
						if (retval < CY_OK)
							break;
					}
				}
			}
		}
	}

	/* reset TTSP Device back to bootloader mode */
	host_reg = CY_SOFT_RESET_MODE;
	retval = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE,
		sizeof(host_reg), &host_reg);
	/* wait for TTSP Device to complete reset back to bootloader */
	tries = 0;
	do {
		mdelay(1);
		cyttsp_putbl(ts, 3, false, false, false);
	} while (g_bl_data.bl_status != 0x10 &&
		g_bl_data.bl_status != 0x11 &&
		tries++ < 100);

	/* set arg2 to non-0 to activate */
	retval = cyttsp_putbl(ts, 8, true, true, true);

	return retval;
}
#else
static int cyttsp_bootload_app(struct cyttsp *ts)
{
	cyttsp_debug("no-load new firmware \n");
	return CY_OK;
}
#endif /* CY_INCLUDE_LOAD_FILE */


static int cyttsp_power_on(struct cyttsp *ts)
{
	int retval = CY_OK;
	u8 host_reg;
	int tries;

	cyttsp_debug("Power up \n");

	/* check if the TTSP device has a bootloader installed */
	host_reg = CY_SOFT_RESET_MODE;
	retval = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE,
		sizeof(host_reg), &host_reg);
	tries = 0;
	do {
		mdelay(1);

		/* set arg2 to non-0 to activate */
		retval = cyttsp_putbl(ts, 1, true, true, true);
		cyttsp_info("BL%d: f=%02X s=%02X err=%02X bl=%02X%02X bld=%02X%02X R=%d\n", \
			101, \
			g_bl_data.bl_file, g_bl_data.bl_status, \
			g_bl_data.bl_error, \
			g_bl_data.blver_hi, g_bl_data.blver_lo, \
			g_bl_data.bld_blver_hi, g_bl_data.bld_blver_lo,
			retval);
		cyttsp_info("BL%d: tver=%02X%02X a_id=%02X%02X aver=%02X%02X\n", \
			102, \
			g_bl_data.ttspver_hi, g_bl_data.ttspver_lo, \
			g_bl_data.appid_hi, g_bl_data.appid_lo, \
			g_bl_data.appver_hi, g_bl_data.appver_lo);
		cyttsp_info("BL%d: c_id=%02X%02X%02X\n", \
			103, \
			g_bl_data.cid_0, g_bl_data.cid_1, g_bl_data.cid_2);
	} while (!(retval < CY_OK) &&
		!GET_BOOTLOADERMODE(g_bl_data.bl_status) &&
		!(g_bl_data.bl_file == CY_OP_MODE + CY_LOW_PWR_MODE) &&
		tries++ < 100);

	/* is bootloader missing? */
	if (!(retval < CY_OK)) {
		cyttsp_xdebug("Ret=%d  Check if bootloader is missing...\n", \
			retval);
		if (!GET_BOOTLOADERMODE(g_bl_data.bl_status)) {
			/* skip all bl and sys info and go to op mode */
			if (!(retval < CY_OK)) {
				cyttsp_xdebug("Bl is missing (ret=%d)\n", \
					retval);
				host_reg = CY_OP_MODE/* + CY_LOW_PWR_MODE*/;
				retval = i2c_smbus_write_i2c_block_data(ts->client, CY_REG_BASE,
					sizeof(host_reg), &host_reg);
				/* wait for TTSP Device to complete switch to
				 * Operational mode */
				mdelay(1000);
				goto bypass;
			}
		}
	}


	/* take TTSP out of bootloader mode; go to TrueTouch operational mode */
	if (!(retval < CY_OK)) {
		cyttsp_xdebug1("exit bootloader; go operational\n");
		tries = 0;
		do {
			msleep(100);
			retval = i2c_smbus_write_i2c_block_data(ts->client,
				CY_REG_BASE, sizeof(bl_cmd), bl_cmd);
			if (retval == CY_OK)
				break;
		} while (tries++ < 5);

		if (retval == CY_OK) {
			tries = 0;
			do {
				msleep(100);
				cyttsp_putbl(ts, 4, true, false, false);
				cyttsp_info("BL%d: f=%02X s=%02X err=%02X" \
					"bl=%02X%02X bld=%02X%02X\n", 104, \
					g_bl_data.bl_file, \
					g_bl_data.bl_status, \
					g_bl_data.bl_error, \
					g_bl_data.blver_hi, \
					g_bl_data.blver_lo, \
					g_bl_data.bld_blver_hi, \
					g_bl_data.bld_blver_lo);
			} while (GET_BOOTLOADERMODE(g_bl_data.bl_status) &&
				tries++ < 5);
		}
	}

	if (!(retval < CY_OK) &&
		cyttsp_app_load()) {
		if (CY_DIFF(g_bl_data.ttspver_hi, cyttsp_tts_verh())  ||
			CY_DIFF(g_bl_data.ttspver_lo, cyttsp_tts_verl())  ||
			CY_DIFF(g_bl_data.appid_hi, cyttsp_app_idh())  ||
			CY_DIFF(g_bl_data.appid_lo, cyttsp_app_idl())  ||
			CY_DIFF(g_bl_data.appver_hi, cyttsp_app_verh())  ||
			CY_DIFF(g_bl_data.appver_lo, cyttsp_app_verl())  ||
			CY_DIFF(g_bl_data.cid_0, cyttsp_cid_0())  ||
			CY_DIFF(g_bl_data.cid_1, cyttsp_cid_1())  ||
			CY_DIFF(g_bl_data.cid_2, cyttsp_cid_2())  ||
			cyttsp_force_fw_load()) {
			cyttsp_debug("blttsp=0x%02X%02X flttsp=0x%02X%02X force=%d\n", \
				g_bl_data.ttspver_hi, g_bl_data.ttspver_lo, \
				cyttsp_tts_verh(), cyttsp_tts_verl(), \
				cyttsp_force_fw_load());
			cyttsp_debug("blappid=0x%02X%02X flappid=0x%02X%02X\n", \
				g_bl_data.appid_hi, g_bl_data.appid_lo, \
				cyttsp_app_idh(), cyttsp_app_idl());
			cyttsp_debug("blappver=0x%02X%02X flappver=0x%02X%02X\n", \
				g_bl_data.appver_hi, g_bl_data.appver_lo, \
				cyttsp_app_verh(), cyttsp_app_verl());
			cyttsp_debug("blcid=0x%02X%02X%02X flcid=0x%02X%02X%02X\n", \
				g_bl_data.cid_0, \
				g_bl_data.cid_1, \
				g_bl_data.cid_2, \
				cyttsp_cid_0(), \
				cyttsp_cid_1(), \
				cyttsp_cid_2());
			/* enter bootloader to load new app into TTSP Device */
			retval = cyttsp_bootload_app(ts);
			/* take TTSP device out of bootloader mode;
			 * switch back to TrueTouch operational mode */
			if (!(retval < CY_OK)) {
				retval = i2c_smbus_write_i2c_block_data(ts->client,
					CY_REG_BASE,
					sizeof(bl_cmd), bl_cmd);
				/* wait for TTSP Device to complete
				 * switch to Operational mode */
				tries = 0;
				do {
					mdelay(100);
					cyttsp_putbl(ts, 9, false, false, false);
				} while (GET_BOOTLOADERMODE(g_bl_data.bl_status) &&
					tries++ < 100);
				cyttsp_putbl(ts, 9, true, false, false);
			}
		}
	}

bypass:
	/* switch to System Information mode to read versions
	 * and set interval registers */
	if (!(retval < CY_OK)) {
		cyttsp_debug("switch to sysinfo mode \n");
		host_reg = CY_SYSINFO_MODE;
		retval = i2c_smbus_write_i2c_block_data(ts->client,
			CY_REG_BASE, sizeof(host_reg), &host_reg);
		/* wait for TTSP Device to complete switch to SysInfo mode */
		mdelay(100);
		if (!(retval < CY_OK)) {
			retval = i2c_smbus_read_i2c_block_data(ts->client,
				CY_REG_BASE,
				sizeof(struct cyttsp_sysinfo_data_t),
				(u8 *)&g_sysinfo_data);
			cyttsp_debug("SI2: hst_mode=0x%02X mfg_cmd=0x%02X mfg_stat=0x%02X\n", \
				g_sysinfo_data.hst_mode, \
				g_sysinfo_data.mfg_cmd, \
				g_sysinfo_data.mfg_stat);
			cyttsp_debug("SI2: bl_ver=0x%02X%02X\n", \
				g_sysinfo_data.bl_verh, \
				g_sysinfo_data.bl_verl);
			cyttsp_debug("SI2: sysinfo act_int=0x%02X tch_tmout=0x%02X lp_int=0x%02X\n", \
				g_sysinfo_data.act_intrvl, \
				g_sysinfo_data.tch_tmout, \
				g_sysinfo_data.lp_intrvl);
			cyttsp_info("SI%d: tver=%02X%02X a_id=%02X%02X aver=%02X%02X\n", \
				102, \
				g_sysinfo_data.tts_verh, \
				g_sysinfo_data.tts_verl, \
				g_sysinfo_data.app_idh, \
				g_sysinfo_data.app_idl, \
				g_sysinfo_data.app_verh, \
				g_sysinfo_data.app_verl);
			cyttsp_info("SI%d: c_id=%02X%02X%02X\n", \
				103, \
				g_sysinfo_data.cid[0], \
				g_sysinfo_data.cid[1], \
				g_sysinfo_data.cid[2]);
			if (!(retval < CY_OK) &&
				(CY_DIFF(ts->platform_data->act_intrvl,
					CY_ACT_INTRVL_DFLT)  ||
				CY_DIFF(ts->platform_data->tch_tmout,
					CY_TCH_TMOUT_DFLT) ||
				CY_DIFF(ts->platform_data->lp_intrvl,
					CY_LP_INTRVL_DFLT))) {
				if (!(retval < CY_OK)) {
					u8 intrvl_ray[sizeof(ts->platform_data->act_intrvl) +
						sizeof(ts->platform_data->tch_tmout) +
						sizeof(ts->platform_data->lp_intrvl)];
					u8 i = 0;

					intrvl_ray[i++] =
						ts->platform_data->act_intrvl;
					intrvl_ray[i++] =
						ts->platform_data->tch_tmout;
					intrvl_ray[i++] =
						ts->platform_data->lp_intrvl;

					cyttsp_debug("SI2: platinfo act_intrvl=0x%02X tch_tmout=0x%02X lp_intrvl=0x%02X\n", \
						ts->platform_data->act_intrvl, \
						ts->platform_data->tch_tmout, \
						ts->platform_data->lp_intrvl);
					/* set intrvl registers */
					retval = i2c_smbus_write_i2c_block_data(
						ts->client,
						CY_REG_ACT_INTRVL,
						sizeof(intrvl_ray), intrvl_ray);
					mdelay(CY_DLY_SYSINFO);
				}
			}
		}
		/* switch back to Operational mode */
		cyttsp_debug("switch back to operational mode \n");
		if (!(retval < CY_OK)) {
			host_reg = CY_OP_MODE/* + CY_LOW_PWR_MODE*/;
			retval = i2c_smbus_write_i2c_block_data(ts->client,
				CY_REG_BASE,
				sizeof(host_reg), &host_reg);
			/* wait for TTSP Device to complete
			 * switch to Operational mode */
			mdelay(100);
		}
	}
	/* init gesture setup;
	 * this is required even if not using gestures
	 * in order to set the active distance */
	if (!(retval < CY_OK)) {
		u8 gesture_setup;
		cyttsp_debug("init gesture setup \n");
		gesture_setup = ts->platform_data->gest_set;
		retval = i2c_smbus_write_i2c_block_data(ts->client,
			CY_REG_GEST_SET,
			sizeof(gesture_setup), &gesture_setup);
		mdelay(CY_DLY_DFLT);
	}

	if (!(retval < CY_OK))
		ts->platform_data->power_state = CY_ACTIVE_STATE;
	else
		ts->platform_data->power_state = CY_IDLE_STATE;

	cyttsp_debug("Retval=%d Power state is %s\n", \
		retval, \
		ts->platform_data->power_state == CY_ACTIVE_STATE ? \
		 "ACTIVE" : "IDLE");

	return retval;
}

static int cyttsp_power_device(struct cyttsp *ts, bool on)
{
	int rc = 0, i;
	const struct cyttsp_regulator *reg_info =
				ts->platform_data->regulator_info;
	u8 num_reg = ts->platform_data->num_regulators;

	if (!reg_info) {
		pr_err("regulator pdata not specified\n");
		return -EINVAL;
	}

	if (on == false) /* Turn off the regulators */
		goto ts_reg_disable;

	ts->vdd = kzalloc(num_reg * sizeof(struct regulator *), GFP_KERNEL);
	if (!ts->vdd) {
		pr_err("unable to allocate memory\n");
		return -ENOMEM;
	}

	for (i = 0; i < num_reg; i++) {
		ts->vdd[i] = regulator_get(&ts->client->dev, reg_info[i].name);
		if (IS_ERR(ts->vdd[i])) {
			rc = PTR_ERR(ts->vdd[i]);
			pr_err("%s:regulator get failed rc=%d\n",
							__func__, rc);
			goto error_vdd;
		}

		if (regulator_count_voltages(ts->vdd[i]) > 0) {
			rc = regulator_set_voltage(ts->vdd[i],
				reg_info[i].min_uV, reg_info[i].max_uV);
			if (rc) {
				pr_err("%s: regulator_set_voltage"
					"failed rc =%d\n", __func__, rc);
				regulator_put(ts->vdd[i]);
				goto error_vdd;
			}
		}

		rc = regulator_set_optimum_mode(ts->vdd[i],
						reg_info[i].hpm_load_uA);
		if (rc < 0) {
			pr_err("%s: regulator_set_optimum_mode failed rc=%d\n",
								__func__, rc);

			regulator_set_voltage(ts->vdd[i], 0,
						reg_info[i].max_uV);
			regulator_put(ts->vdd[i]);
			goto error_vdd;
		}

		rc = regulator_enable(ts->vdd[i]);
		if (rc) {
			pr_err("%s: regulator_enable failed rc =%d\n",
								__func__, rc);
			regulator_set_optimum_mode(ts->vdd[i], 0);
			regulator_set_voltage(ts->vdd[i], 0,
						reg_info[i].max_uV);
			regulator_put(ts->vdd[i]);
			goto error_vdd;
		}
	}

	return rc;

ts_reg_disable:
	i = ts->platform_data->num_regulators;
error_vdd:
	while (--i >= 0) {
		if (regulator_count_voltages(ts->vdd[i]) > 0)
			regulator_set_voltage(ts->vdd[i], 0,
						reg_info[i].max_uV);
		regulator_set_optimum_mode(ts->vdd[i], 0);
		regulator_disable(ts->vdd[i]);
		regulator_put(ts->vdd[i]);
	}
	kfree(ts->vdd);
	return rc;
}

/* cyttsp_initialize: Driver Initialization. This function takes
 * care of the following tasks:
 * 1. Create and register an input device with input layer
 * 2. Take CYTTSP device out of bootloader mode; go operational
 * 3. Start any timers/Work queues.  */
static int cyttsp_initialize(struct i2c_client *client, struct cyttsp *ts)
{
	struct input_dev *input_device;
	int error = 0;
	int retval = CY_OK;
	u8 id;

	/* Create the input device and register it. */
	input_device = input_allocate_device();
	if (!input_device) {
		error = -ENOMEM;
		cyttsp_xdebug1("err input allocate device\n");
		goto error_free_device;
	}

	if (!client) {
		error = ~ENODEV;
		cyttsp_xdebug1("err client is Null\n");
		goto error_free_device;
	}

	if (!ts) {
		error = ~ENODEV;
		cyttsp_xdebug1("err context is Null\n");
		goto error_free_device;
	}

	ts->input = input_device;
	input_device->name = CY_I2C_NAME;
	input_device->phys = ts->phys;
	input_device->dev.parent = &client->dev;

	/* init the touch structures */
	ts->num_prv_st_tch = CY_NTCH;
	for (id = 0; id < CY_NUM_TRK_ID; id++) {
		ts->act_trk[id] = CY_NTCH;
		ts->prv_mt_pos[id][CY_XPOS] = 0;
		ts->prv_mt_pos[id][CY_YPOS] = 0;
	}

	for (id = 0; id < CY_NUM_MT_TCH_ID; id++)
		ts->prv_mt_tch[id] = CY_IGNR_TCH;

	for (id = 0; id < CY_NUM_ST_TCH_ID; id++)
		ts->prv_st_tch[id] = CY_IGNR_TCH;

	set_bit(EV_SYN, input_device->evbit);
	set_bit(EV_KEY, input_device->evbit);
	set_bit(EV_ABS, input_device->evbit);
	set_bit(BTN_TOUCH, input_device->keybit);
	set_bit(BTN_2, input_device->keybit);
	if (ts->platform_data->use_gestures)
		set_bit(BTN_3, input_device->keybit);

	input_set_abs_params(input_device, ABS_X, ts->platform_data->disp_minx,
		ts->platform_data->disp_maxx, 0, 0);
	input_set_abs_params(input_device, ABS_Y, ts->platform_data->disp_miny,
		ts->platform_data->disp_maxy, 0, 0);
	input_set_abs_params(input_device,
		ABS_TOOL_WIDTH, 0, CY_LARGE_TOOL_WIDTH, 0 , 0);
	input_set_abs_params(input_device,
		ABS_PRESSURE, 0, CY_MAXZ, 0, 0);
	input_set_abs_params(input_device,
		ABS_HAT0X, 0, ts->platform_data->panel_maxx, 0, 0);
	input_set_abs_params(input_device,
		ABS_HAT0Y, 0, ts->platform_data->panel_maxy, 0, 0);
	if (ts->platform_data->use_gestures) {
		input_set_abs_params(input_device,
			ABS_HAT1X, 0, CY_MAXZ, 0, 0);
		input_set_abs_params(input_device,
			ABS_HAT1Y, 0, CY_MAXZ, 0, 0);
	}
	if (ts->platform_data->use_mt) {
		input_set_abs_params(input_device, ABS_MT_POSITION_X,
			ts->platform_data->disp_minx,
			ts->platform_data->disp_maxx, 0, 0);
		input_set_abs_params(input_device, ABS_MT_POSITION_Y,
			ts->platform_data->disp_miny,
			ts->platform_data->disp_maxy, 0, 0);
		input_set_abs_params(input_device,
			ABS_MT_TOUCH_MAJOR, 0, CY_MAXZ, 0, 0);
		input_set_abs_params(input_device,
			ABS_MT_WIDTH_MAJOR, 0, CY_LARGE_TOOL_WIDTH, 0, 0);
		if (ts->platform_data->use_trk_id) {
			input_set_abs_params(input_device,
				ABS_MT_TRACKING_ID, 0, CY_NUM_TRK_ID, 0, 0);
		}
	}

	/* set dummy key to make driver work with virtual keys */
	input_set_capability(input_device, EV_KEY, KEY_PROG1);

	cyttsp_info("%s: Register input device\n", CY_I2C_NAME);
	error = input_register_device(input_device);
	if (error) {
		cyttsp_alert("%s: Failed to register input device\n", \
			CY_I2C_NAME);
		retval = error;
		goto error_free_device;
	}

	if (gpio_is_valid(ts->platform_data->resout_gpio)) {
		/* configure touchscreen reset out gpio */
		retval = gpio_request(ts->platform_data->resout_gpio,
						"cyttsp_resout_gpio");
		if (retval) {
			pr_err("%s: unable to request reset gpio %d\n",
				__func__, ts->platform_data->resout_gpio);
			goto error_free_device;
		}

		retval = gpio_direction_output(
					ts->platform_data->resout_gpio, 1);
		if (retval) {
			pr_err("%s: unable to set direction for gpio %d\n",
				__func__, ts->platform_data->resout_gpio);
			goto error_resout_gpio_dir;
		}
	}

	if (gpio_is_valid(ts->platform_data->sleep_gpio)) {
		/* configure touchscreen reset out gpio */
		retval = gpio_request(ts->platform_data->sleep_gpio,
						"cy8c_sleep_gpio");
		if (retval) {
			pr_err("%s: unable to request sleep gpio %d\n",
				__func__, ts->platform_data->sleep_gpio);
			goto error_sleep_gpio_req;
		}

		retval = gpio_direction_output(
					ts->platform_data->sleep_gpio, 0);
		if (retval) {
			pr_err("%s: unable to set direction for gpio %d\n",
			__func__, ts->platform_data->resout_gpio);
			goto error_sleep_gpio_dir;
		}
	}

	if (gpio_is_valid(ts->platform_data->irq_gpio)) {
		/* configure touchscreen irq gpio */
		retval = gpio_request(ts->platform_data->irq_gpio,
							"ts_irq_gpio");
		if (retval) {
			pr_err("%s: unable to request gpio [%d]\n", __func__,
						ts->platform_data->irq_gpio);
			goto error_irq_gpio_req;
		}
		retval = gpio_direction_input(ts->platform_data->irq_gpio);
		if (retval) {
			pr_err("%s: unable to set_direction for gpio [%d]\n",
					__func__, ts->platform_data->irq_gpio);
			goto error_irq_gpio_dir;
		}
	}

	if (ts->platform_data->regulator_info) {
		retval = cyttsp_power_device(ts, true);
		if (retval) {
			pr_err("%s: Unable to power device %d\n",
						 __func__, retval);
			goto error_irq_gpio_dir;
		}
	}

	/* Power on the chip and make sure that I/Os are set as specified
	 * in the platform */
	if (ts->platform_data->init) {
		retval = ts->platform_data->init(client);
		if (retval) {
			pr_err("%s: ts init failed\n", __func__);
			goto error_power_device;
		}
	}

	msleep(100);

	/* check this device active by reading first byte/register */
	retval = i2c_smbus_read_byte_data(ts->client, 0x01);
	if (retval < 0) {
		pr_err("%s: i2c sanity check failed\n", __func__);
		goto error_power_device;
	}

	retval = cyttsp_power_on(ts);
	if (retval < 0) {
		pr_err("%s: cyttsp_power_on failed\n", __func__);
		goto error_power_device;
	}

	/* Timer or Interrupt setup */
	if (ts->client->irq == 0) {
		cyttsp_info("Setting up timer\n");
		setup_timer(&ts->timer, cyttsp_timer, (unsigned long) ts);
		mod_timer(&ts->timer, jiffies + TOUCHSCREEN_TIMEOUT);
	} else {
		cyttsp_info("Setting up interrupt\n");
		error = request_threaded_irq(client->irq, NULL, cyttsp_irq,
			IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
			client->dev.driver->name, ts);
		if (error) {
			cyttsp_alert("error: could not request irq\n");
			retval = error;
			goto error_power_device;
		}
	}

	irq_cnt = 0;
	irq_cnt_total = 0;
	irq_err_cnt = 0;

	atomic_set(&ts->irq_enabled, 1);
	retval = device_create_file(&ts->client->dev, &dev_attr_irq_enable);
	if (retval < CY_OK) {
		cyttsp_alert("File device creation failed: %d\n", retval);
		retval = -ENODEV;
		goto error_free_irq;
	}

	retval = device_create_file(&client->dev, &dev_attr_cyttsp_fw_ver);
	if (retval) {
		cyttsp_alert("sysfs entry for firmware version failed\n");
		goto error_rm_dev_file_irq_en;
	}

	ts->cyttsp_fwloader_mode = 0;
	retval = device_create_file(&client->dev, &dev_attr_cyttsp_update_fw);
	if (retval) {
		cyttsp_alert("sysfs entry for firmware update failed\n");
		goto error_rm_dev_file_fw_ver;
	}

	retval = device_create_file(&client->dev,
				&dev_attr_cyttsp_force_update_fw);
	if (retval) {
		cyttsp_alert("sysfs entry for force firmware update failed\n");
		goto error_rm_dev_file_update_fw;
	}
	if (ts->platform_data->correct_fw_ver) {
		if (g_bl_data.appid_lo != ts->platform_data->correct_fw_ver)
			pr_warn("%s: Invalid firmware version detected;"
				" Please update.\n", __func__);
	}

	retval = device_create_file(&client->dev,
				&dev_attr_cyttsp_fw_name);
	if (retval) {
		cyttsp_alert("sysfs entry for file name selection failed\n");
		goto error_rm_dev_file_fupdate_fw;
	}

	cyttsp_info("%s: Successful registration\n", CY_I2C_NAME);

	goto success;

error_rm_dev_file_fupdate_fw:
	device_remove_file(&client->dev, &dev_attr_cyttsp_force_update_fw);
error_rm_dev_file_update_fw:
	device_remove_file(&client->dev, &dev_attr_cyttsp_update_fw);
error_rm_dev_file_fw_ver:
	device_remove_file(&client->dev, &dev_attr_cyttsp_fw_ver);
error_rm_dev_file_irq_en:
	device_remove_file(&client->dev, &dev_attr_irq_enable);
error_free_irq:
	if (ts->client->irq)
		free_irq(client->irq, ts);
error_power_device:
	if (ts->platform_data->regulator_info)
		cyttsp_power_device(ts, false);
error_irq_gpio_dir:
	if (gpio_is_valid(ts->platform_data->irq_gpio))
		gpio_free(ts->platform_data->irq_gpio);
error_irq_gpio_req:
	if (gpio_is_valid(ts->platform_data->sleep_gpio))
		gpio_direction_output(ts->platform_data->sleep_gpio, 1);
error_sleep_gpio_dir:
	if (gpio_is_valid(ts->platform_data->sleep_gpio))
		gpio_free(ts->platform_data->sleep_gpio);
error_sleep_gpio_req:
	if (gpio_is_valid(ts->platform_data->resout_gpio))
		gpio_direction_output(ts->platform_data->resout_gpio, 0);
error_resout_gpio_dir:
	if (gpio_is_valid(ts->platform_data->resout_gpio))
		gpio_free(ts->platform_data->resout_gpio);
error_free_device:
	if (input_device)
		input_free_device(input_device);

success:
	return retval;
}

/* I2C driver probe function */
static int __devinit cyttsp_probe(struct i2c_client *client,
			const struct i2c_device_id *id)
{
	struct cyttsp *ts;
	int error;
	int retval = CY_OK;

	cyttsp_info("Start Probe 1.2\n");

	/* allocate and clear memory */
	ts = kzalloc(sizeof(struct cyttsp), GFP_KERNEL);
	if (ts == NULL) {
		cyttsp_xdebug1("err kzalloc for cyttsp\n");
		return -ENOMEM;
	}

	/* Enable runtime PM ops, start in ACTIVE mode */
	error = pm_runtime_set_active(&client->dev);
	if (error < 0)
		dev_dbg(&client->dev, "unable to set runtime pm state\n");
	pm_runtime_enable(&client->dev);

	if (!(retval < CY_OK)) {
		/* register driver_data */
		ts->client = client;
		ts->platform_data = client->dev.platform_data;

		if (ts->platform_data->fw_fname)
			strlcpy(ts->fw_fname, ts->platform_data->fw_fname,
							FW_FNAME_LEN - 1);
		else
			strlcpy(ts->fw_fname, "cyttsp.hex", FW_FNAME_LEN - 1);

		if (ts->platform_data->gen == CY_GEN3) {
			ts->fw_start_addr = 0x0b00;
		} else if (ts->platform_data->gen == CY_GEN2) {
			ts->fw_start_addr = 0x0880;
		} else {
			pr_err("%s: unsupported cypress chip\n", __func__);
			kfree(ts);
			return -EINVAL;
		}

		i2c_set_clientdata(client, ts);

		error = cyttsp_initialize(client, ts);
		if (error) {
			cyttsp_xdebug1("err cyttsp_initialize\n");
			/* deallocate memory */
			kfree(ts);
/*
			i2c_del_driver(&cyttsp_driver);
*/
			return -ENODEV;
		}
	}

#ifdef CONFIG_HAS_EARLYSUSPEND
	if (!(retval < CY_OK)) {
		ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
		ts->early_suspend.suspend = cyttsp_early_suspend;
		ts->early_suspend.resume = cyttsp_late_resume;
		register_early_suspend(&ts->early_suspend);
	}
#endif /* CONFIG_HAS_EARLYSUSPEND */
	device_init_wakeup(&client->dev, ts->platform_data->wakeup);
	mutex_init(&ts->mutex);

	cyttsp_info("Start Probe %s\n", \
		(retval < CY_OK) ? "FAIL" : "PASS");

	return retval;
}

#ifdef CONFIG_PM
static int cyttsp_regulator_lpm(struct cyttsp *ts, bool on)
{
	int rc = 0, i;
	const struct cyttsp_regulator *reg_info =
			ts->platform_data->regulator_info;
	u8 num_reg = ts->platform_data->num_regulators;

	if (on == false)
		goto regulator_hpm;

	for (i = 0; i < num_reg; i++) {
		rc = regulator_set_optimum_mode(ts->vdd[i],
					reg_info[i].lpm_load_uA);
		if (rc < 0) {
			pr_err("%s: regulator_set_optimum failed rc = %d\n",
							__func__, rc);
			goto fail_regulator_lpm;
		}

	}

	return 0;

regulator_hpm:
	for (i = 0; i < num_reg; i++) {
		rc = regulator_set_optimum_mode(ts->vdd[i],
					reg_info[i].hpm_load_uA);
		if (rc < 0) {
			pr_err("%s: regulator_set_optimum failed"
				"rc = %d\n", __func__, rc);
			goto fail_regulator_hpm;
		}
	}

	return 0;

fail_regulator_lpm:
	while (i--)
		regulator_set_optimum_mode(ts->vdd[i],
					reg_info[i].hpm_load_uA);

	return rc;

fail_regulator_hpm:
	while (i--)
		regulator_set_optimum_mode(ts->vdd[i],
					reg_info[i].lpm_load_uA);

	return rc;
}

/* Function to manage power-on resume */
static int cyttsp_resume(struct device *dev)
{
	struct cyttsp *ts = dev_get_drvdata(dev);
	int retval = CY_OK;

	cyttsp_debug("Wake Up\n");

	if (ts->is_suspended == false) {
		pr_err("%s: in wakeup state\n", __func__);
		return 0;
	}

	if (device_may_wakeup(dev)) {
		if (ts->client->irq)
			disable_irq_wake(ts->client->irq);
		return 0;
	}

	/* re-enable the interrupt prior to wake device */
	if (ts->client->irq)
		enable_irq(ts->client->irq);

	if (ts->platform_data->use_sleep &&
		(ts->platform_data->power_state != CY_ACTIVE_STATE)) {
		if (ts->platform_data->resume)
			retval = ts->platform_data->resume(ts->client);
		else
			retval = cyttsp_regulator_lpm(ts, false);
		/* take TTSP device out of bootloader mode;
		 * switch back to TrueTouch operational mode */
		if (!(retval < CY_OK)) {
			int tries = 0;
			do {
				msleep(100);
				retval = i2c_smbus_write_i2c_block_data(
					ts->client, CY_REG_BASE,
					sizeof(bl_cmd), bl_cmd);
				if (retval == CY_OK)
					break;
			} while (tries++ < 2);
			/* wait for TTSP Device to complete
			 * switch to Operational mode */
			tries = 0;
			do {
				msleep(100);
				cyttsp_putbl(ts, 16, false, false, false);
			} while (GET_BOOTLOADERMODE(g_bl_data.bl_status) &&
				tries++ < 2);
			cyttsp_putbl(ts, 16, true, false, false);
		}
	}

	if (!(retval < CY_OK) &&
		(GET_HSTMODE(g_bl_data.bl_file) == CY_OK)) {
		ts->platform_data->power_state = CY_ACTIVE_STATE;

		/* re-enable the timer after resuming */
		if (ts->client->irq == 0)
			mod_timer(&ts->timer, jiffies + TOUCHSCREEN_TIMEOUT);
	} else
		retval = -ENODEV;

	ts->is_suspended = false;
	cyttsp_debug("Wake Up %s\n", \
		(retval < CY_OK) ? "FAIL" : "PASS");

	return retval;
}

/* Function to manage low power suspend */
static int cyttsp_suspend(struct device *dev)
{
	struct cyttsp *ts = dev_get_drvdata(dev);
	u8 sleep_mode = CY_OK;
	int retval = CY_OK;

	cyttsp_debug("Enter Sleep\n");

	if (ts->is_suspended == true) {
		pr_err("%s: in sleep state\n", __func__);
		return 0;
	}

	mutex_lock(&ts->mutex);
	if (ts->cyttsp_fwloader_mode) {
		pr_err("%s:firmware upgrade mode:"
			"suspend not allowed\n", __func__);
		mutex_unlock(&ts->mutex);
		return -EBUSY;
	}
	mutex_unlock(&ts->mutex);

	if (device_may_wakeup(dev)) {
		if (ts->client->irq)
			enable_irq_wake(ts->client->irq);
		return 0;
	}

	if (ts->client->irq == 0)
		del_timer(&ts->timer);
	else
		disable_irq(ts->client->irq);

	if (!(retval < CY_OK)) {
		if (ts->platform_data->use_sleep &&
			(ts->platform_data->power_state == CY_ACTIVE_STATE)) {
			if (ts->platform_data->suspend) {
				retval =
				ts->platform_data->suspend(ts->client);
			} else {
				retval = cyttsp_regulator_lpm(ts, true);
			}
			if (ts->platform_data->use_sleep & CY_USE_DEEP_SLEEP_SEL)
				sleep_mode = CY_DEEP_SLEEP_MODE;
			else
				sleep_mode = CY_LOW_PWR_MODE;

			if (!(retval < CY_OK)) {
				retval =
				i2c_smbus_write_i2c_block_data(ts->client,
								CY_REG_BASE,
					sizeof(sleep_mode), &sleep_mode);
			}
		}
	}

	if (!(retval < CY_OK)) {
		if (sleep_mode == CY_DEEP_SLEEP_MODE)
			ts->platform_data->power_state = CY_SLEEP_STATE;
		else if (sleep_mode == CY_LOW_PWR_MODE)
			ts->platform_data->power_state = CY_LOW_PWR_STATE;
	}

	ts->is_suspended = true;
	cyttsp_debug("Sleep Power state is %s\n", \
		(ts->platform_data->power_state == CY_ACTIVE_STATE) ? \
		"ACTIVE" : \
		((ts->platform_data->power_state == CY_SLEEP_STATE) ? \
		"SLEEP" : "LOW POWER"));

	return retval;
}
#endif

/* registered in driver struct */
static int __devexit cyttsp_remove(struct i2c_client *client)
{
	/* clientdata registered on probe */
	struct cyttsp *ts = i2c_get_clientdata(client);
	int err;

	cyttsp_alert("Unregister\n");

	pm_runtime_set_suspended(&client->dev);
	pm_runtime_disable(&client->dev);

	device_init_wakeup(&client->dev, 0);
	device_remove_file(&ts->client->dev, &dev_attr_irq_enable);
	device_remove_file(&client->dev, &dev_attr_cyttsp_fw_ver);
	device_remove_file(&client->dev, &dev_attr_cyttsp_update_fw);
	device_remove_file(&client->dev, &dev_attr_cyttsp_force_update_fw);
	device_remove_file(&client->dev, &dev_attr_cyttsp_fw_name);

	/* free up timer or irq */
	if (ts->client->irq == 0) {
		err = del_timer(&ts->timer);
		if (err < CY_OK)
			cyttsp_alert("error: failed to delete timer\n");
	} else
		free_irq(client->irq, ts);

	if (ts->platform_data->regulator_info)
		cyttsp_power_device(ts, false);

#ifdef CONFIG_HAS_EARLYSUSPEND
	unregister_early_suspend(&ts->early_suspend);
#endif /* CONFIG_HAS_EARLYSUSPEND */

	mutex_destroy(&ts->mutex);

	if (gpio_is_valid(ts->platform_data->sleep_gpio)) {
		gpio_direction_output(ts->platform_data->sleep_gpio, 1);
		gpio_free(ts->platform_data->sleep_gpio);
	}

	if (gpio_is_valid(ts->platform_data->resout_gpio)) {
		gpio_direction_output(ts->platform_data->resout_gpio, 0);
		gpio_free(ts->platform_data->resout_gpio);
	}

	if (gpio_is_valid(ts->platform_data->irq_gpio))
		gpio_free(ts->platform_data->irq_gpio);

	/* housekeeping */
	kfree(ts);

	cyttsp_alert("Leaving\n");

	return 0;
}

#ifdef CONFIG_HAS_EARLYSUSPEND
static void cyttsp_early_suspend(struct early_suspend *handler)
{
	struct cyttsp *ts;

	ts = container_of(handler, struct cyttsp, early_suspend);
	cyttsp_suspend(&ts->client->dev);
}

static void cyttsp_late_resume(struct early_suspend *handler)
{
	struct cyttsp *ts;

	ts = container_of(handler, struct cyttsp, early_suspend);
	cyttsp_resume(&ts->client->dev);
}
#endif  /* CONFIG_HAS_EARLYSUSPEND */

static int cyttsp_init(void)
{
	int ret;

	cyttsp_info("Cypress TrueTouch(R) Standard Product\n");
	cyttsp_info("I2C Touchscreen Driver (Built %s @ %s)\n", \
		__DATE__, __TIME__);

	ret = i2c_add_driver(&cyttsp_driver);

	return ret;
}

static void cyttsp_exit(void)
{
	return i2c_del_driver(&cyttsp_driver);
}

module_init(cyttsp_init);
module_exit(cyttsp_exit);
MODULE_FIRMWARE("cyttsp.fw");

