From f07839f5a31fc64cb564b81dd9057cc01092f75c Mon Sep 17 00:00:00 2001 From: dengwei1 Date: Mon, 5 Nov 2018 11:26:06 +0800 Subject: [PATCH] channel: input add ilitek touch fw proc file input add ilitek touch fw proc file to get the fw state. Change-Id: I0b20c52930eca68ffabfe2100771f0d34437e48c Signed-off-by: dengwei1 Reviewed-on: https://gerrit.mot.com/1264419 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Xiangpo Zhao Submit-Approved: Jira Key --- drivers/input/touchscreen/ilitek_mmi/common.h | 1 + .../touchscreen/ilitek_mmi/core/config.c | 21 ++++++++++++ .../touchscreen/ilitek_mmi/core/config.h | 1 + .../input/touchscreen/ilitek_mmi/userspace.c | 32 +++++++++++++++++++ 4 files changed, 55 insertions(+) diff --git a/drivers/input/touchscreen/ilitek_mmi/common.h b/drivers/input/touchscreen/ilitek_mmi/common.h index 67b974e77c97..f3ec43e8193a 100644 --- a/drivers/input/touchscreen/ilitek_mmi/common.h +++ b/drivers/input/touchscreen/ilitek_mmi/common.h @@ -204,6 +204,7 @@ enum ili9881_types { #define ILI9881_ICE_MODE_ADDR 0x181062 #define ILI9881_PID_ADDR 0x4009C #define ILI9881_WDT_ADDR 0x5100C +#define ILI9881_PC_COUNTER_ADDR 0x44008 /* * Other settings diff --git a/drivers/input/touchscreen/ilitek_mmi/core/config.c b/drivers/input/touchscreen/ilitek_mmi/core/config.c index cbb6a9d351bf..727f49b56a6e 100644 --- a/drivers/input/touchscreen/ilitek_mmi/core/config.c +++ b/drivers/input/touchscreen/ilitek_mmi/core/config.c @@ -118,6 +118,27 @@ static uint32_t check_chip_id(uint32_t pid_data) return 0; } +uint32_t core_config_read_pc_counter(void) +{ + uint32_t pc_cnt = 0x0; + + if (!core_config->icemodeenable) { + if (core_config_ice_mode_enable() < 0) + ipio_err("Failed to enter ice mode\n"); + } + + /* Read fw status if it was hanging on a unknown status */ + pc_cnt = core_config_ice_mode_read(ILI9881_PC_COUNTER_ADDR); + ipio_info("pc counter = 0x%x\n", pc_cnt); + + if (core_config->icemodeenable) { + if (core_config_ice_mode_disable() < 0) + ipio_err("Failed to disable ice mode\n"); + } + return pc_cnt; +} +EXPORT_SYMBOL(core_config_read_pc_counter); + /* * Read & Write one byte in ICE Mode. */ diff --git a/drivers/input/touchscreen/ilitek_mmi/core/config.h b/drivers/input/touchscreen/ilitek_mmi/core/config.h index 0359487fd6aa..b3b63cb810e2 100644 --- a/drivers/input/touchscreen/ilitek_mmi/core/config.h +++ b/drivers/input/touchscreen/ilitek_mmi/core/config.h @@ -98,6 +98,7 @@ extern int core_config_ice_mode_write(uint32_t addr, uint32_t data, uint32_t siz extern uint32_t core_config_read_write_onebyte(uint32_t addr); extern int core_config_ice_mode_disable(void); extern int core_config_ice_mode_enable(void); +extern uint32_t core_config_read_pc_counter(void); /* Touch IC status */ extern int core_config_set_watch_dog(bool enable); diff --git a/drivers/input/touchscreen/ilitek_mmi/userspace.c b/drivers/input/touchscreen/ilitek_mmi/userspace.c index 4c46a5af8b51..60069e0ab6d9 100644 --- a/drivers/input/touchscreen/ilitek_mmi/userspace.c +++ b/drivers/input/touchscreen/ilitek_mmi/userspace.c @@ -144,6 +144,33 @@ int str2hex(char *str) EXPORT_SYMBOL(str2hex); +static ssize_t ilitek_proc_fw_pc_counter_read(struct file *pFile, char __user *buf, size_t nCount, loff_t *pos) +{ + uint32_t pc; + + if (*pos != 0) + return 0; + + memset(g_user_buf, 0, USER_STR_BUFF * sizeof(unsigned char)); + + mutex_lock(&ipd->plat_mutex); + + pc = core_config_read_pc_counter(); + + mutex_unlock(&ipd->plat_mutex); + + nCount = snprintf(g_user_buf, PAGE_SIZE, "pc counter = 0x%x\n", pc); + + pc = copy_to_user(buf, g_user_buf, nCount); + if (pc < 0) { + ipio_err("Failed to copy data to user space"); + } + + *pos += nCount; + + return nCount; +} + static ssize_t ilitek_proc_debug_switch_read(struct file *pFile, char __user *buff, size_t nCount, loff_t *pPos) @@ -1564,6 +1591,10 @@ struct file_operations proc_debug_message_switch_fops = { .read = ilitek_proc_debug_switch_read, }; +struct file_operations proc_fw_pc_counter_fops = { + .read = ilitek_proc_fw_pc_counter_read, +}; + /** * This struct lists all file nodes will be created under /proc filesystem. * @@ -1593,6 +1624,7 @@ proc_node_t proc_table[] = { {"oppo_mp_lcm_off", NULL, &proc_oppo_mp_lcm_off_fops, false}, {"debug_message", NULL, &proc_debug_message_fops, false}, {"debug_message_switch", NULL, &proc_debug_message_switch_fops, false}, + {"fw_pc_counter", NULL, &proc_fw_pc_counter_fops, false}, }; #define NETLINK_USER 21