From 6b33e5f7047ea9a09604189c00d4cc7f8583a19d Mon Sep 17 00:00:00 2001 From: Ravikanth Tuniki Date: Thu, 3 Dec 2020 13:25:02 +0530 Subject: [PATCH] input: touchscreen: nt36xxx: Fix Propagation This change propagates the missing fixes in novatek tcm touch driver from msm-4.19 to msm-5.4. Change-Id: Ie404c8412f7efa847b8e14965bcaf45568225502 Signed-off-by: Ravikanth Tuniki --- drivers/input/touchscreen/Kconfig | 2 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/nt36xxx/Kconfig | 3 +- drivers/input/touchscreen/nt36xxx/Makefile | 2 +- drivers/input/touchscreen/nt36xxx/nt36xxx.c | 723 ++++++++++-------- drivers/input/touchscreen/nt36xxx/nt36xxx.h | 11 +- .../touchscreen/nt36xxx/nt36xxx_mp_ctrlram.c | 1 - 7 files changed, 411 insertions(+), 332 deletions(-) diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 38830610149c..da97ad1a8bc3 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig @@ -1330,4 +1330,6 @@ config TOUCHSCREEN_SYNAPTICS_DSX source "drivers/input/touchscreen/synaptics_dsx/Kconfig" +source "drivers/input/touchscreen/nt36xxx/Kconfig" + endif diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 808ad790adeb..d29fcb32e572 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile @@ -114,3 +114,4 @@ obj-$(CONFIG_TOUCHSCREEN_ST) += st/ obj-$(CONFIG_TOUCHSCREEN_FTS) += focaltech_touch/ obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_TCM) += synaptics_tcm/ obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_DSX) += synaptics_dsx/ +obj-$(CONFIG_TOUCHSCREEN_NT36XXX) += nt36xxx/ diff --git a/drivers/input/touchscreen/nt36xxx/Kconfig b/drivers/input/touchscreen/nt36xxx/Kconfig index c331f9135d9f..fbdf03fdc29a 100644 --- a/drivers/input/touchscreen/nt36xxx/Kconfig +++ b/drivers/input/touchscreen/nt36xxx/Kconfig @@ -2,9 +2,8 @@ # # Novatek NT36xxx touchscreen driver configuration # -config TOUCHSCREEN_NT36xxx +config TOUCHSCREEN_NT36XXX bool "Novatek NT36xxx" - default y help Say Y here if you have a Novatek NT36xxx touchscreen connected to your system. diff --git a/drivers/input/touchscreen/nt36xxx/Makefile b/drivers/input/touchscreen/nt36xxx/Makefile index 80954c784bf2..ad3fedd437ca 100644 --- a/drivers/input/touchscreen/nt36xxx/Makefile +++ b/drivers/input/touchscreen/nt36xxx/Makefile @@ -5,4 +5,4 @@ # Each configuration option enables a list of files. -obj-$(CONFIG_TOUCHSCREEN_NT36xxx) += nt36xxx.o nt36xxx_fw_update.o nt36xxx_ext_proc.o nt36xxx_mp_ctrlram.o +obj-$(CONFIG_TOUCHSCREEN_NT36XXX) += nt36xxx.o nt36xxx_fw_update.o nt36xxx_ext_proc.o nt36xxx_mp_ctrlram.o diff --git a/drivers/input/touchscreen/nt36xxx/nt36xxx.c b/drivers/input/touchscreen/nt36xxx/nt36xxx.c index e4d66bf06e7c..de496cc1e4b8 100644 --- a/drivers/input/touchscreen/nt36xxx/nt36xxx.c +++ b/drivers/input/touchscreen/nt36xxx/nt36xxx.c @@ -26,10 +26,9 @@ #include #include -#if defined(CONFIG_FB) -#ifdef CONFIG_DRM_MSM -#include -#endif +#if defined(CONFIG_DRM_PANEL) +#include +#elif defined(CONFIG_FB) #include #include #elif defined(CONFIG_HAS_EARLYSUSPEND) @@ -61,17 +60,19 @@ extern void nvt_mp_proc_deinit(void); struct nvt_ts_data *ts; +#if defined(CONFIG_DRM_PANEL) +static struct drm_panel *active_panel; +#endif + #if BOOT_UPDATE_FIRMWARE static struct workqueue_struct *nvt_fwu_wq; extern void Boot_Update_Firmware(struct work_struct *work); #endif -#if defined(CONFIG_FB) -#ifdef _MSM_DRM_NOTIFY_H_ +#if defined(CONFIG_DRM_PANEL) static int nvt_drm_notifier_callback(struct notifier_block *self, unsigned long event, void *data); -#else +#elif defined(CONFIG_FB) static int nvt_fb_notifier_callback(struct notifier_block *self, unsigned long event, void *data); -#endif #elif defined(CONFIG_HAS_EARLYSUSPEND) static void nvt_ts_early_suspend(struct early_suspend *h); static void nvt_ts_late_resume(struct early_suspend *h); @@ -106,12 +107,12 @@ const uint16_t gesture_key_array[] = { static uint8_t bTouchIsAwake = 0; /******************************************************* -Description: - Novatek touchscreen irq enable/disable function. - -return: - n.a. -*******************************************************/ + * Description: + * Novatek touchscreen irq enable/disable function. + * + * return: + * n.a. + *******************************************************/ static void nvt_irq_enable(bool enable) { struct irq_desc *desc; @@ -133,12 +134,12 @@ static void nvt_irq_enable(bool enable) } /******************************************************* -Description: - Novatek touchscreen i2c read function. - -return: - Executive outcomes. 2---succeed. -5---I/O error -*******************************************************/ + * Description: + * Novatek touchscreen i2c read function. + * + * return: + * Executive outcomes. 2---succeed. -5---I/O error + *******************************************************/ int32_t CTP_I2C_READ(struct i2c_client *client, uint16_t address, uint8_t *buf, uint16_t len) { @@ -177,12 +178,12 @@ int32_t CTP_I2C_READ(struct i2c_client *client, uint16_t address, uint8_t *buf, } /******************************************************* -Description: - Novatek touchscreen i2c write function. - -return: - Executive outcomes. 1---succeed. -5---I/O error -*******************************************************/ + * Description: + * Novatek touchscreen i2c write function. + * + * return: + * Executive outcomes. 1---succeed. -5---I/O error + *******************************************************/ int32_t CTP_I2C_WRITE(struct i2c_client *client, uint16_t address, uint8_t *buf, uint16_t len) { @@ -215,12 +216,12 @@ int32_t CTP_I2C_WRITE(struct i2c_client *client, uint16_t address, uint8_t *buf, } /******************************************************* -Description: - Novatek touchscreen set index/page/addr address. - -return: - Executive outcomes. 0---succeed. -5---access fail. -*******************************************************/ + * Description: + * Novatek touchscreen set index/page/addr address. + * + * return: + * Executive outcomes. 0---succeed. -5---access fail. + ********************************************************/ int32_t nvt_set_page(uint16_t i2c_addr, uint32_t addr) { uint8_t buf[4] = {0}; @@ -233,13 +234,13 @@ int32_t nvt_set_page(uint16_t i2c_addr, uint32_t addr) } /******************************************************* -Description: - Novatek touchscreen reset MCU then into idle mode - function. - -return: - n.a. -*******************************************************/ + * Description: + * Novatek touchscreen reset MCU then into idle mode + * function. + * + * return: + * n.a. + *******************************************************/ void nvt_sw_reset_idle(void) { uint8_t buf[4]={0}; @@ -253,12 +254,12 @@ void nvt_sw_reset_idle(void) } /******************************************************* -Description: - Novatek touchscreen reset MCU (boot) function. - -return: - n.a. -*******************************************************/ + * Description: + * Novatek touchscreen reset MCU (boot) function. + * + * return: + * n.a. + *******************************************************/ void nvt_bootloader_reset(void) { uint8_t buf[8] = {0}; @@ -277,12 +278,12 @@ void nvt_bootloader_reset(void) } /******************************************************* -Description: - Novatek touchscreen clear FW status function. - -return: - Executive outcomes. 0---succeed. -1---fail. -*******************************************************/ + * Description: + * Novatek touchscreen clear FW status function. + * + * return: + * Executive outcomes. 0---succeed. -1---fail. + *******************************************************/ int32_t nvt_clear_fw_status(void) { uint8_t buf[8] = {0}; @@ -318,12 +319,12 @@ int32_t nvt_clear_fw_status(void) } /******************************************************* -Description: - Novatek touchscreen check FW status function. - -return: - Executive outcomes. 0---succeed. -1---failed. -*******************************************************/ + * Description: + * Novatek touchscreen check FW status function. + * + * return: + * Executive outcomes. 0---succeed. -1---failed. + *******************************************************/ int32_t nvt_check_fw_status(void) { uint8_t buf[8] = {0}; @@ -354,12 +355,12 @@ int32_t nvt_check_fw_status(void) } /******************************************************* -Description: - Novatek touchscreen check FW reset state function. - -return: - Executive outcomes. 0---succeed. -1---failed. -*******************************************************/ + * Description: + * Novatek touchscreen check FW reset state function. + * + * return: + * Executive outcomes. 0---succeed. -1---failed. + ******************************************************/ int32_t nvt_check_fw_reset_state(RST_COMPLETE_STATE check_reset_state) { uint8_t buf[8] = {0}; @@ -392,13 +393,13 @@ int32_t nvt_check_fw_reset_state(RST_COMPLETE_STATE check_reset_state) } /******************************************************* -Description: - Novatek touchscreen get novatek project id information - function. - -return: - Executive outcomes. 0---success. -1---fail. -*******************************************************/ + * Description: + * Novatek touchscreen get novatek project id information + * function. + * + * return: + * Executive outcomes. 0---success. -1---fail. + *******************************************************/ int32_t nvt_read_pid(void) { uint8_t buf[3] = {0}; @@ -479,20 +480,21 @@ info_retry: } /******************************************************* - Create Device Node (Proc Entry) -*******************************************************/ + * Create Device Node (Proc Entry) + *******************************************************/ #if NVT_TOUCH_PROC static struct proc_dir_entry *NVT_proc_entry; #define DEVICE_NAME "NVTflash" /******************************************************* -Description: - Novatek touchscreen /proc/NVTflash read function. - -return: - Executive outcomes. 2---succeed. -5,-14---failed. -*******************************************************/ -static ssize_t nvt_flash_read(struct file *file, char __user *buff, size_t count, loff_t *offp) + * Description: + * Novatek touchscreen /proc/NVTflash read function. + * + * return: + * Executive outcomes. 2---succeed. -5,-14---failed. + *******************************************************/ +static ssize_t nvt_flash_read(struct file *file, char __user *buff, + size_t count, loff_t *offp) { uint8_t str[68] = {0}; int32_t ret = -1; @@ -567,12 +569,12 @@ static ssize_t nvt_flash_read(struct file *file, char __user *buff, size_t count } /******************************************************* -Description: - Novatek touchscreen /proc/NVTflash open function. - -return: - Executive outcomes. 0---succeed. -12---failed. -*******************************************************/ + * Description: + * Novatek touchscreen /proc/NVTflash open function. + * + * return: + * Executive outcomes. 0---succeed. -12---failed. + *******************************************************/ static int32_t nvt_flash_open(struct inode *inode, struct file *file) { struct nvt_flash_data *dev; @@ -590,12 +592,12 @@ static int32_t nvt_flash_open(struct inode *inode, struct file *file) } /******************************************************* -Description: - Novatek touchscreen /proc/NVTflash close function. - -return: - Executive outcomes. 0---succeed. -*******************************************************/ + * Description: + * Novatek touchscreen /proc/NVTflash close function. + * + * return: + * Executive outcomes. 0---succeed. + *******************************************************/ static int32_t nvt_flash_close(struct inode *inode, struct file *file) { struct nvt_flash_data *dev = file->private_data; @@ -612,12 +614,12 @@ static const struct file_operations nvt_flash_fops = { }; /******************************************************* -Description: - Novatek touchscreen /proc/NVTflash initial function. - -return: - Executive outcomes. 0---succeed. -12---failed. -*******************************************************/ + * Description: + * Novatek touchscreen /proc/NVTflash initial function. + * + * return: + * Executive outcomes. 0---succeed. -12---failed. + *******************************************************/ static int32_t nvt_flash_proc_init(void) { NVT_proc_entry = proc_create(DEVICE_NAME, 0444, NULL,&nvt_flash_fops); @@ -636,12 +638,12 @@ static int32_t nvt_flash_proc_init(void) } /******************************************************* -Description: - Novatek touchscreen /proc/NVTflash deinitial function. - -return: - n.a. -*******************************************************/ + * Description: + * Novatek touchscreen /proc/NVTflash deinitial function. + * + * return: + * n.a. + *******************************************************/ static void nvt_flash_proc_deinit(void) { if (NVT_proc_entry != NULL) { @@ -673,12 +675,12 @@ static void nvt_flash_proc_deinit(void) #define FUNCPAGE_GESTURE 1 /******************************************************* -Description: - Novatek touchscreen wake up gesture key report function. - -return: - n.a. -*******************************************************/ + * Description: + * Novatek touchscreen wake up gesture key report function. + * + * return: + * n.a. + *******************************************************/ void nvt_ts_wakeup_gesture_report(uint8_t gesture_id, uint8_t *data) { uint32_t keycode = 0; @@ -762,12 +764,12 @@ void nvt_ts_wakeup_gesture_report(uint8_t gesture_id, uint8_t *data) #endif /******************************************************* -Description: - Novatek touchscreen parse device tree function. - -return: - n.a. -*******************************************************/ + * Description: + * Novatek touchscreen parse device tree function. + * + * return: + * n.a. + *******************************************************/ #ifdef CONFIG_OF static void nvt_parse_dt(struct device *dev) { @@ -792,12 +794,12 @@ static void nvt_parse_dt(struct device *dev) #endif /******************************************************* -Description: - Novatek touchscreen config and request gpio - -return: - Executive outcomes. 0---succeed. not 0---failed. -*******************************************************/ + * Description: + * Novatek touchscreen config and request gpio + * + * return: + * Executive outcomes. 0---succeed. not 0---failed. + *******************************************************/ static int nvt_gpio_config(struct nvt_ts_data *ts) { int32_t ret = 0; @@ -833,12 +835,12 @@ err_request_reset_gpio: } /******************************************************* -Description: - Novatek touchscreen deconfig gpio - -return: - n.a. -*******************************************************/ + * Description: + * Novatek touchscreen deconfig gpio + * + * return: + * n.a. + *******************************************************/ static void nvt_gpio_deconfig(struct nvt_ts_data *ts) { if (gpio_is_valid(ts->irq_gpio)) @@ -901,12 +903,12 @@ static void nvt_esd_check_func(struct work_struct *work) #define POINT_DATA_LEN 65 /******************************************************* -Description: - Novatek touchscreen work function. - -return: - n.a. -*******************************************************/ + * Description: + * Novatek touchscreen work function. + * + * return: + * n.a. + *******************************************************/ static irqreturn_t nvt_ts_work_func(int irq, void *data) { int32_t ret = -1; @@ -936,14 +938,6 @@ static irqreturn_t nvt_ts_work_func(int irq, void *data) NVT_ERR("CTP_I2C_READ failed.(%d)\n", ret); goto XFER_ERROR; } -/* - //--- dump I2C buf --- - for (i = 0; i < 10; i++) { - printk("%02X %02X %02X %02X %02X %02X ", - point_data[1+i*6], point_data[2+i*6], point_data[3+i*6], point_data[4+i*6], point_data[5+i*6], point_data[6+i*6]); - } - printk("\n"); -*/ if (nvt_fw_recovery(point_data)) { #if NVT_TOUCH_ESD_PROTECT @@ -1060,11 +1054,11 @@ XFER_ERROR: } /******************************************************* -Description: - Novatek touchscreen check and stop crc reboot loop. - -return: - n.a. + * Description: + * Novatek touchscreen check and stop crc reboot loop. + * + * return: + * n.a. *******************************************************/ void nvt_stop_crc_reboot(void) { @@ -1115,19 +1109,19 @@ void nvt_stop_crc_reboot(void) break; } if (retry == 0) - NVT_ERR("CRC auto reboot is not able to be stopped! buf[1]=0x%02X\n", buf[1]); + NVT_ERR("CRC auto reboot is not able to be stopped!\n"); } return; } /******************************************************* -Description: - Novatek touchscreen check chip version trim function. - -return: - Executive outcomes. 0---NVT IC. -1---not NVT IC. -*******************************************************/ + * Description: + * Novatek touchscreen check chip version trim function. + * + * return: + * Executive outcomes. 0---NVT IC. -1---not NVT IC. + *******************************************************/ static int8_t nvt_ts_check_chip_ver_trim(void) { uint8_t buf[8] = {0}; @@ -1203,34 +1197,93 @@ out: return ret; } -/******************************************************* -Description: - Novatek touchscreen driver probe function. +#if defined(CONFIG_DRM_PANEL) +static int nvt_ts_check_dt(struct device_node *np) +{ + int i; + int count; + struct device_node *node; + struct drm_panel *panel; -return: - Executive outcomes. 0---succeed. negative---failed -*******************************************************/ -static int32_t nvt_ts_probe(struct i2c_client *client, const struct i2c_device_id *id) + count = of_count_phandle_with_args(np, "panel", NULL); + if (count <= 0) + return 0; + + for (i = 0; i < count; i++) { + node = of_parse_phandle(np, "panel", i); + panel = of_drm_find_panel(node); + of_node_put(node); + if (!IS_ERR(panel)) { + active_panel = panel; + NVT_LOG(" %s:find\n", __func__); + return 0; + } + } + + NVT_ERR(" %s: not find\n", __func__); + return -ENODEV; +} + +static int nvt_ts_check_default_tp(struct device_node *dt, const char *prop) +{ + const char **active_tp = NULL; + int count, tmp, score = 0; + const char *active; + int ret, i; + + count = of_property_count_strings(dt->parent, prop); + if (count <= 0 || count > 3) + return -ENODEV; + + active_tp = kcalloc(count, sizeof(char *), GFP_KERNEL); + if (!active_tp) { + NVT_ERR("FTS alloc failed\n"); + return -ENOMEM; + } + + ret = of_property_read_string_array(dt->parent, prop, + active_tp, count); + if (ret < 0) { + NVT_ERR("fail to read %s %d\n", prop, ret); + ret = -ENODEV; + goto out; + } + + for (i = 0; i < count; i++) { + active = active_tp[i]; + if (active != NULL) { + tmp = of_device_is_compatible(dt, active); + if (tmp > 0) + score++; + } + } + + if (score <= 0) { + NVT_ERR("not match this driver\n"); + ret = -ENODEV; + goto out; + } + ret = 0; +out: + kfree(active_tp); + return ret; +} +#endif + +/******************************************************* + * Description: + * Novatek touchscreen driver probe function. + * + * return: + * Executive outcomes. 0---succeed. negative---failed + *******************************************************/ +static int32_t nvt_ts_late_probe(struct i2c_client *client, + const struct i2c_device_id *id) { int32_t ret = 0; #if ((TOUCH_KEY_NUM > 0) || WAKEUP_GESTURE) int32_t retry = 0; #endif - - NVT_LOG("start\n"); - - ts = kmalloc(sizeof(struct nvt_ts_data), GFP_KERNEL); - if (ts == NULL) { - NVT_ERR("failed to allocated memory for nvt ts data\n"); - return -ENOMEM; - } - - ts->client = client; - i2c_set_clientdata(client, ts); - - //---parse dts--- - nvt_parse_dt(&client->dev); - //---request and config GPIOs--- ret = nvt_gpio_config(ts); if (ret) { @@ -1238,19 +1291,6 @@ static int32_t nvt_ts_probe(struct i2c_client *client, const struct i2c_device_i goto err_gpio_config_failed; } - //---check i2c func.--- - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { - NVT_ERR("i2c_check_functionality failed. (no I2C_FUNC_I2C)\n"); - ret = -ENODEV; - goto err_check_functionality_failed; - } - - mutex_init(&ts->lock); - mutex_init(&ts->xbuf_lock); - - // need 10ms delay after POR(power on reset) - msleep(10); - //---check chip version trim--- ret = nvt_ts_check_chip_ver_trim(); if (ret) { @@ -1397,33 +1437,6 @@ static int32_t nvt_ts_probe(struct i2c_client *client, const struct i2c_device_i } #endif -#if defined(CONFIG_FB) -#ifdef _MSM_DRM_NOTIFY_H_ - ts->drm_notif.notifier_call = nvt_drm_notifier_callback; - ret = msm_drm_register_client(&ts->drm_notif); - if(ret) { - NVT_ERR("register drm_notifier failed. ret=%d\n", ret); - goto err_register_drm_notif_failed; - } -#else - ts->fb_notif.notifier_call = nvt_fb_notifier_callback; - ret = fb_register_client(&ts->fb_notif); - if(ret) { - NVT_ERR("register fb_notifier failed. ret=%d\n", ret); - goto err_register_fb_notif_failed; - } -#endif -#elif defined(CONFIG_HAS_EARLYSUSPEND) - ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; - ts->early_suspend.suspend = nvt_ts_early_suspend; - ts->early_suspend.resume = nvt_ts_late_resume; - ret = register_early_suspend(&ts->early_suspend); - if(ret) { - NVT_ERR("register early suspend failed. ret=%d\n", ret); - goto err_register_early_suspend_failed; - } -#endif - bTouchIsAwake = 1; NVT_LOG("end\n"); @@ -1431,20 +1444,6 @@ static int32_t nvt_ts_probe(struct i2c_client *client, const struct i2c_device_i return 0; -#if defined(CONFIG_FB) -#ifdef _MSM_DRM_NOTIFY_H_ - if (msm_drm_unregister_client(&ts->drm_notif)) - NVT_ERR("Error occurred while unregistering drm_notifier.\n"); -err_register_drm_notif_failed: -#else - if (fb_unregister_client(&ts->fb_notif)) - NVT_ERR("Error occurred while unregistering fb_notifier.\n"); -err_register_fb_notif_failed: -#endif -#elif defined(CONFIG_HAS_EARLYSUSPEND) - unregister_early_suspend(&ts->early_suspend); -err_register_early_suspend_failed: -#endif #if NVT_TOUCH_MP nvt_mp_proc_deinit(); err_mp_proc_init_failed: @@ -1487,38 +1486,116 @@ err_input_register_device_failed: } err_input_dev_alloc_failed: err_chipvertrim_failed: - mutex_destroy(&ts->xbuf_lock); - mutex_destroy(&ts->lock); -err_check_functionality_failed: nvt_gpio_deconfig(ts); err_gpio_config_failed: - i2c_set_clientdata(client, NULL); - if (ts) { - kfree(ts); - ts = NULL; - } + NVT_ERR("ret = %d\n", ret); return ret; } /******************************************************* -Description: - Novatek touchscreen driver release function. + * Description: + * Novatek touchscreen driver probe function. + * + * return: + * Executive outcomes. 0---succeed. negative---failed + *******************************************************/ +static int32_t nvt_ts_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + int32_t ret = 0; +#if defined(CONFIG_DRM) + struct device_node *dp = client->dev.of_node; +#endif -return: - Executive outcomes. 0---succeed. -*******************************************************/ + NVT_LOG("start\n"); + +#if defined(CONFIG_DRM) + if (nvt_ts_check_dt(dp)) { + if (!nvt_ts_check_default_tp(dp, "qcom,i2c-touch-active")) + ret = -EPROBE_DEFER; + else + ret = -ENODEV; + + return ret; + } +#endif + + ts = devm_kzalloc(&client->dev, sizeof(struct nvt_ts_data), GFP_KERNEL); + if (ts == NULL) { + NVT_ERR("failed to allocated memory for nvt ts data\n"); + return -ENOMEM; + } + + ts->client = client; + i2c_set_clientdata(client, ts); + + //---parse dts--- + nvt_parse_dt(&client->dev); + + //---check i2c func.--- + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { + NVT_ERR("i2c_check_functionality failed. (no I2C_FUNC_I2C)\n"); + return -ENODEV; + } + + mutex_init(&ts->lock); + mutex_init(&ts->xbuf_lock); + + ts->id = id; + +#if defined(CONFIG_DRM) + ts->drm_notif.notifier_call = nvt_drm_notifier_callback; + + if (active_panel && + drm_panel_notifier_register(active_panel, + &ts->drm_notif) < 0) { + NVT_ERR("register notifier failed!\n"); + goto err_register_drm_notif_failed; + } +#elif defined(CONFIG_HAS_EARLYSUSPEND) + ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; + ts->early_suspend.suspend = nvt_ts_early_suspend; + ts->early_suspend.resume = nvt_ts_late_resume; + ret = register_early_suspend(&ts->early_suspend); + if (ret) { + NVT_ERR("register early suspend failed. ret=%d\n", ret); + goto err_register_early_suspend_failed; + } +#endif + + NVT_LOG("end\n"); + return 0; + +#if defined(CONFIG_DRM) + if (active_panel) + drm_panel_notifier_unregister(active_panel, &ts->drm_notif); +err_register_drm_notif_failed: + +#elif defined(CONFIG_HAS_EARLYSUSPEND) + unregister_early_suspend(&ts->early_suspend); +err_register_early_suspend_failed: +#endif + + return -ENODEV; +} + +/******************************************************* + * Description: + * Novatek touchscreen driver release function. + * + * return: + * Executive outcomes. 0---succeed. + *******************************************************/ static int32_t nvt_ts_remove(struct i2c_client *client) { NVT_LOG("Removing driver...\n"); -#if defined(CONFIG_FB) -#ifdef _MSM_DRM_NOTIFY_H_ - if (msm_drm_unregister_client(&ts->drm_notif)) - NVT_ERR("Error occurred while unregistering drm_notifier.\n"); -#else +#if defined(CONFIG_DRM_PANEL) + if (active_panel) + drm_panel_notifier_unregister(active_panel, &ts->drm_notif); +#elif defined(CONFIG_FB) if (fb_unregister_client(&ts->fb_notif)) NVT_ERR("Error occurred while unregistering fb_notifier.\n"); -#endif #elif defined(CONFIG_HAS_EARLYSUSPEND) unregister_early_suspend(&ts->early_suspend); #endif @@ -1551,7 +1628,8 @@ static int32_t nvt_ts_remove(struct i2c_client *client) #endif #if WAKEUP_GESTURE - device_init_wakeup(&ts->input_dev->dev, 0); + if (ts->input_dev) + device_init_wakeup(&ts->input_dev->dev, 0); #endif nvt_irq_enable(false); @@ -1583,14 +1661,12 @@ static void nvt_ts_shutdown(struct i2c_client *client) nvt_irq_enable(false); -#if defined(CONFIG_FB) -#ifdef _MSM_DRM_NOTIFY_H_ - if (msm_drm_unregister_client(&ts->drm_notif)) - NVT_ERR("Error occurred while unregistering drm_notifier.\n"); -#else +#if defined(CONFIG_DRM_PANEL) + if (active_panel) + drm_panel_notifier_unregister(active_panel, &ts->drm_notif); +#elif defined(CONFIG_FB) if (fb_unregister_client(&ts->fb_notif)) NVT_ERR("Error occurred while unregistering fb_notifier.\n"); -#endif #elif defined(CONFIG_HAS_EARLYSUSPEND) unregister_early_suspend(&ts->early_suspend); #endif @@ -1623,17 +1699,18 @@ static void nvt_ts_shutdown(struct i2c_client *client) #endif #if WAKEUP_GESTURE - device_init_wakeup(&ts->input_dev->dev, 0); + if (ts->input_dev) + device_init_wakeup(&ts->input_dev->dev, 0); #endif } /******************************************************* -Description: - Novatek touchscreen driver suspend function. - -return: - Executive outcomes. 0---succeed. -*******************************************************/ + * Description: + * Novatek touchscreen driver suspend function. + * + * return: + * Executive outcomes. 0---succeed. + *******************************************************/ static int32_t nvt_ts_suspend(struct device *dev) { uint8_t buf[4] = {0}; @@ -1704,30 +1781,31 @@ static int32_t nvt_ts_suspend(struct device *dev) } /******************************************************* -Description: - Novatek touchscreen driver resume function. - -return: - Executive outcomes. 0---succeed. -*******************************************************/ + * Description: + * Novatek touchscreen driver resume function. + * + * return: + * Executive outcomes. 0---succeed. + *******************************************************/ static int32_t nvt_ts_resume(struct device *dev) { - if (bTouchIsAwake) { - NVT_LOG("Touch is already resume\n"); + NVT_LOG("start\n"); + + if (bTouchIsAwake || ts->fw_ver == 0) { + nvt_ts_late_probe(ts->client, ts->id); + NVT_LOG("nvt_ts_late_probe\n"); return 0; } mutex_lock(&ts->lock); - NVT_LOG("start\n"); - - // please make sure display reset(RESX) sequence and mipi dsi cmds sent before this + // make sure display reset(RESX) sequence and dsi cmds sent before this #if NVT_TOUCH_SUPPORT_HW_RST gpio_set_value(ts->reset_gpio, 1); #endif - // need to uncomment the following code for NT36672, NT36772 IC due to no boot-load when RESX/TP_RESX - //nvt_bootloader_reset(); + // NT36772 IC due to no boot-load when RESX/TP_RESX + // nvt_bootloader_reset(); if (nvt_check_fw_reset_state(RESET_STATE_REK)) { NVT_ERR("FW is not ready! Try to bootloader reset...\n"); nvt_bootloader_reset(); @@ -1753,38 +1831,39 @@ static int32_t nvt_ts_resume(struct device *dev) return 0; } - -#if defined(CONFIG_FB) -#ifdef _MSM_DRM_NOTIFY_H_ -static int nvt_drm_notifier_callback(struct notifier_block *self, unsigned long event, void *data) +#if defined(CONFIG_DRM_PANEL) +static int nvt_drm_notifier_callback(struct notifier_block *self, + unsigned long event, void *data) { - struct msm_drm_notifier *evdata = data; + struct drm_panel_notifier *evdata = data; int *blank; struct nvt_ts_data *ts = container_of(self, struct nvt_ts_data, drm_notif); - if (!evdata || (evdata->id != 0)) + if (!evdata || !evdata->data || !ts) return 0; - if (evdata->data && ts) { - blank = evdata->data; - if (event == MSM_DRM_EARLY_EVENT_BLANK) { - if (*blank == MSM_DRM_BLANK_POWERDOWN) { - NVT_LOG("event=%lu, *blank=%d\n", event, *blank); - nvt_ts_suspend(&ts->client->dev); - } - } else if (event == MSM_DRM_EVENT_BLANK) { - if (*blank == MSM_DRM_BLANK_UNBLANK) { - NVT_LOG("event=%lu, *blank=%d\n", event, *blank); - nvt_ts_resume(&ts->client->dev); - } + blank = evdata->data; + + if (event == DRM_PANEL_EARLY_EVENT_BLANK) { + if (*blank == DRM_PANEL_BLANK_POWERDOWN) { + NVT_LOG("event=%lu, *blank=%d\n", event, *blank); + nvt_ts_suspend(&ts->client->dev); + } + } else if (event == DRM_PANEL_EVENT_BLANK) { + if (*blank == DRM_PANEL_BLANK_UNBLANK) { + NVT_LOG("event=%lu, *blank=%d\n", event, *blank); + nvt_ts_resume(&ts->client->dev); } } return 0; } -#else -static int nvt_fb_notifier_callback(struct notifier_block *self, unsigned long event, void *data) + +#elif defined(CONFIG_FB) + +static int nvt_fb_notifier_callback(struct notifier_block *self, + unsigned long event, void *data) { struct fb_event *evdata = data; int *blank; @@ -1807,27 +1886,27 @@ static int nvt_fb_notifier_callback(struct notifier_block *self, unsigned long e return 0; } -#endif + #elif defined(CONFIG_HAS_EARLYSUSPEND) /******************************************************* -Description: - Novatek touchscreen driver early suspend function. - -return: - n.a. -*******************************************************/ + * Description: + * Novatek touchscreen driver early suspend function. + * + * return: + * n.a. + *******************************************************/ static void nvt_ts_early_suspend(struct early_suspend *h) { nvt_ts_suspend(ts->client, PMSG_SUSPEND); } /******************************************************* -Description: - Novatek touchscreen driver late resume function. - -return: - n.a. -*******************************************************/ + * Description: + * Novatek touchscreen driver late resume function. + * + * return: + * n.a. + * *******************************************************/ static void nvt_ts_late_resume(struct early_suspend *h) { nvt_ts_resume(ts->client); @@ -1860,12 +1939,12 @@ static struct i2c_driver nvt_i2c_driver = { }; /******************************************************* -Description: - Driver Install function. - -return: - Executive Outcomes. 0---succeed. not 0---failed. -********************************************************/ + * Description: + * Driver Install function. + * + * return: + * Executive Outcomes. 0---succeed. not 0---failed. + ********************************************************/ static int32_t __init nvt_driver_init(void) { int32_t ret = 0; @@ -1885,19 +1964,19 @@ err_driver: } /******************************************************* -Description: - Driver uninstall function. - -return: - n.a. -********************************************************/ + * Description: + * Driver uninstall function. + * + * return: + * n.a. + ********************************************************/ static void __exit nvt_driver_exit(void) { i2c_del_driver(&nvt_i2c_driver); } -//late_initcall(nvt_driver_init); -module_init(nvt_driver_init); +late_initcall(nvt_driver_init); +//module_init(nvt_driver_init); module_exit(nvt_driver_exit); MODULE_DESCRIPTION("Novatek Touchscreen Driver"); diff --git a/drivers/input/touchscreen/nt36xxx/nt36xxx.h b/drivers/input/touchscreen/nt36xxx/nt36xxx.h index 0a3daf342639..eef848bfe9dd 100644 --- a/drivers/input/touchscreen/nt36xxx/nt36xxx.h +++ b/drivers/input/touchscreen/nt36xxx/nt36xxx.h @@ -71,14 +71,14 @@ extern const uint16_t touch_key_array[TOUCH_KEY_NUM]; #define TOUCH_FORCE_NUM 1000 /* Enable only when module have tp reset pin and connected to host */ -#define NVT_TOUCH_SUPPORT_HW_RST 0 +#define NVT_TOUCH_SUPPORT_HW_RST 1 //---Customerized func.--- #define NVT_TOUCH_PROC 1 #define NVT_TOUCH_EXT_PROC 1 #define NVT_TOUCH_MP 1 #define MT_PROTOCOL_B 1 -#define WAKEUP_GESTURE 1 +#define WAKEUP_GESTURE 0 #if WAKEUP_GESTURE extern const uint16_t gesture_key_array[]; #endif @@ -95,12 +95,11 @@ struct nvt_ts_data { struct delayed_work nvt_fwu_work; uint16_t addr; int8_t phys[32]; -#if defined(CONFIG_FB) -#ifdef _MSM_DRM_NOTIFY_H_ + const struct i2c_device_id *id; +#if defined(CONFIG_DRM_PANEL) struct notifier_block drm_notif; -#else +#elif defined(CONFIG_FB) struct notifier_block fb_notif; -#endif #elif defined(CONFIG_HAS_EARLYSUSPEND) struct early_suspend early_suspend; #endif diff --git a/drivers/input/touchscreen/nt36xxx/nt36xxx_mp_ctrlram.c b/drivers/input/touchscreen/nt36xxx/nt36xxx_mp_ctrlram.c index 4f128aae38df..c14b0c86b906 100644 --- a/drivers/input/touchscreen/nt36xxx/nt36xxx_mp_ctrlram.c +++ b/drivers/input/touchscreen/nt36xxx/nt36xxx_mp_ctrlram.c @@ -532,7 +532,6 @@ static int32_t nvt_read_fw_noise(int32_t *xdata) uint32_t y = 0; int32_t iArrayIndex = 0; int32_t frame_num = 0; - uint32_t rawdata_diff_min_offset = 0; #if TOUCH_KEY_NUM > 0 int32_t k = 0; #endif /* #if TOUCH_KEY_NUM > 0 */