From df08fa99ef0a300d1e526981ad8342fefb1f90e1 Mon Sep 17 00:00:00 2001 From: wangyq13 Date: Tue, 21 Dec 2021 18:30:55 +0800 Subject: [PATCH] input: goodix_v1510: add charging and gtp-tools node - Add charging detection function - Add gtp-tools node for cqa test - Remove software esd check for touch, touch firmware itself to recover Change-Id: Id3b398f302370baddf56b5973813d5a09591460e Signed-off-by: wangyq13 Reviewed-on: https://gerrit.mot.com/2150842 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Jun Weng Reviewed-by: Huosheng Liao Submit-Approved: Jira Key --- .../touchscreen/goodix_gtx8_v1510_mmi/Kbuild | 2 +- .../goodix_gtx8_v1510_mmi/goodix_ts_core.c | 9 ++++- .../goodix_gtx8_v1510_mmi/goodix_ts_i2c.c | 7 +++- .../goodix_gtx8_v1510_mmi/goodix_ts_mmi.c | 37 ++++++++++++++++++- .../goodix_gtx8_v1510_mmi/goodix_ts_tools.c | 11 +----- 5 files changed, 52 insertions(+), 14 deletions(-) diff --git a/drivers/input/touchscreen/goodix_gtx8_v1510_mmi/Kbuild b/drivers/input/touchscreen/goodix_gtx8_v1510_mmi/Kbuild index 9cc90fd340b5..d6ec17b1c9a4 100644 --- a/drivers/input/touchscreen/goodix_gtx8_v1510_mmi/Kbuild +++ b/drivers/input/touchscreen/goodix_gtx8_v1510_mmi/Kbuild @@ -4,7 +4,7 @@ EXTRA_CFLAGS += \ -I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/include obj-m := goodix_v1510_mmi.o -goodix_v1510_mmi-objs = goodix_ts_i2c.o goodix_ts_core.o goodix_ts_test.o goodix_cfg_bin.o goodix_gtx8_update.o goodix_ts_gesture.o +goodix_v1510_mmi-objs = goodix_ts_i2c.o goodix_ts_core.o goodix_ts_test.o goodix_cfg_bin.o goodix_gtx8_update.o goodix_ts_gesture.o goodix_ts_tools.o ifneq ($(filter m y,$(CONFIG_DRM_PANEL_NOTIFICATIONS)),) EXTRA_CFLAGS += -DCONFIG_DRM_PANEL_NOTIFICATIONS diff --git a/drivers/input/touchscreen/goodix_gtx8_v1510_mmi/goodix_ts_core.c b/drivers/input/touchscreen/goodix_gtx8_v1510_mmi/goodix_ts_core.c index 4c7ea78eb1a0..de981e59ed2a 100644 --- a/drivers/input/touchscreen/goodix_gtx8_v1510_mmi/goodix_ts_core.c +++ b/drivers/input/touchscreen/goodix_gtx8_v1510_mmi/goodix_ts_core.c @@ -51,6 +51,8 @@ extern int goodix_ts_mmi_dev_register(struct platform_device *ts_device); extern void goodix_ts_mmi_dev_unregister(struct platform_device *ts_device); extern int __init goodix_gsx_gesture_init(void); extern void __exit goodix_gsx_gesture_exit(void); +extern int __init goodix_tools_init(void); +extern void __exit goodix_tools_exit(void); struct goodix_module goodix_modules; @@ -2222,7 +2224,8 @@ int goodix_ts_stage2_init(struct goodix_ts_core *core_data) goodix_ts_procfs_init(core_data); /* esd protector */ - goodix_ts_esd_init(core_data); + if (core_data->ts_dev->board_data.esd_default_on) + goodix_ts_esd_init(core_data); return 0; exit: goodix_ts_pen_dev_remove(core_data); @@ -2331,6 +2334,10 @@ static int goodix_ts_probe(struct platform_device *pdev) ts_err("Failed start cfg_bin_proc, %d", r); goto later_thread_err; } + + /* debug node init */ + goodix_tools_init(); + complete_all(&goodix_modules.core_comp); ts_info("goodix_ts_core probe success"); return 0; diff --git a/drivers/input/touchscreen/goodix_gtx8_v1510_mmi/goodix_ts_i2c.c b/drivers/input/touchscreen/goodix_gtx8_v1510_mmi/goodix_ts_i2c.c index a518e2dcd501..c8b368456113 100644 --- a/drivers/input/touchscreen/goodix_gtx8_v1510_mmi/goodix_ts_i2c.c +++ b/drivers/input/touchscreen/goodix_gtx8_v1510_mmi/goodix_ts_i2c.c @@ -233,6 +233,11 @@ static int goodix_parse_dt(struct device_node *node, ts_debug("[DT]x:%d, y:%d, w:%d, p:%d", board_data->panel_max_x, board_data->panel_max_y, board_data->panel_max_w, board_data->panel_max_p); + + board_data->esd_default_on= of_property_read_bool(node, + "goodix,esd-default-on"); + if (board_data->esd_default_on) + ts_info("goodix esd-default-on enabled"); return 0; } #endif @@ -618,7 +623,7 @@ int goodix_i2c_write_trans_once(struct goodix_ts_device *dev, unsigned int reg, return 0; } -static void goodix_cmd_init(struct goodix_ts_device *dev, +void goodix_cmd_init(struct goodix_ts_device *dev, struct goodix_ts_cmd *ts_cmd, u8 cmds, u16 cmd_data, u32 reg_addr) { diff --git a/drivers/input/touchscreen/goodix_gtx8_v1510_mmi/goodix_ts_mmi.c b/drivers/input/touchscreen/goodix_gtx8_v1510_mmi/goodix_ts_mmi.c index 9af7e9a395ec..8dc42f5f1af6 100644 --- a/drivers/input/touchscreen/goodix_gtx8_v1510_mmi/goodix_ts_mmi.c +++ b/drivers/input/touchscreen/goodix_gtx8_v1510_mmi/goodix_ts_mmi.c @@ -29,6 +29,11 @@ } extern int gsx_gesture_before_suspend_mmi(struct goodix_ts_core *core_data); +extern void goodix_cmd_init(struct goodix_ts_device *dev, + struct goodix_ts_cmd *ts_cmd, + u8 cmds, u16 cmd_data, u32 reg_addr); +extern int goodix_send_command(struct goodix_ts_device *dev, + struct goodix_ts_cmd *cmd); static int goodix_ts_mmi_methods_get_vendor(struct device *dev, void *cdata) { return scnprintf(TO_CHARP(cdata), TS_MMI_MAX_VENDOR_LEN, "%s", "goodix"); @@ -164,10 +169,38 @@ static int goodix_ts_mmi_methods_power(struct device *dev, int on) { } } -#define CHARGER_MODE_CMD 0xAF +#define CHARGER_ENTER_MODE_CMD 0x06 +#define CHARGER_EXIT_MODE_CMD 0x07 static int goodix_ts_mmi_charger_mode(struct device *dev, int mode) { - return 0; + int ret = 0; + struct goodix_ts_device *ts_dev; + struct platform_device *pdev; + struct goodix_ts_core *core_data; + struct goodix_ts_cmd charge_cmd; + + GET_GOODIX_DATA(dev); + ts_dev = core_data->ts_dev; + + if (mode) + goodix_cmd_init(ts_dev, &charge_cmd, CHARGER_ENTER_MODE_CMD, + 0, ts_dev->reg.command); + else + goodix_cmd_init(ts_dev, &charge_cmd, CHARGER_EXIT_MODE_CMD, + 0, ts_dev->reg.command); + + if (charge_cmd.initialized) { + ret= goodix_send_command(ts_dev, &charge_cmd); + if (ret < 0) + ts_err("Failed to set charger mode\n"); + } else { + ts_err("Uninitialized charge command"); + } + + msleep(16); + ts_info("Success to %s charger mode\n", mode ? "Enable" : "Disable"); + + return ret; } static int goodix_ts_mmi_panel_state(struct device *dev, diff --git a/drivers/input/touchscreen/goodix_gtx8_v1510_mmi/goodix_ts_tools.c b/drivers/input/touchscreen/goodix_gtx8_v1510_mmi/goodix_ts_tools.c index 91c8a3bdc5ce..6c832dc8c36e 100644 --- a/drivers/input/touchscreen/goodix_gtx8_v1510_mmi/goodix_ts_tools.c +++ b/drivers/input/touchscreen/goodix_gtx8_v1510_mmi/goodix_ts_tools.c @@ -608,7 +608,7 @@ static struct goodix_ext_module_funcs goodix_tools_module_funcs = { * * return: 0 success, else failed */ -static int __init goodix_tools_init(void) +int __init goodix_tools_init(void) { int ret; @@ -637,16 +637,9 @@ static int __init goodix_tools_init(void) return ret; } -static void __exit goodix_tools_exit(void) +void __exit goodix_tools_exit(void) { misc_deregister(&goodix_tools_miscdev); kfree(goodix_tools_dev); ts_info("Goodix tools miscdev exit"); } - -late_initcall(goodix_tools_init); -module_exit(goodix_tools_exit); - -MODULE_DESCRIPTION("Goodix tools Module"); -MODULE_AUTHOR("Goodix, Inc."); -MODULE_LICENSE("GPL v2");