diff --git a/drivers/input/touchscreen/gtx8/Kconfig b/drivers/input/touchscreen/gtx8/Kconfig index dbbb15756a06b4..732830ebbb92a8 100644 --- a/drivers/input/touchscreen/gtx8/Kconfig +++ b/drivers/input/touchscreen/gtx8/Kconfig @@ -13,16 +13,6 @@ menuconfig TOUCHSCREEN_GOODIX_GTX8 if TOUCHSCREEN_GOODIX_GTX8 -config TOUCHSCREEN_GOODIX_GTX8_UPDATE - tristate "Goodix GTx8 firmware update module" - default y - help - Say Y here to enable support for doing firmware update. - - If unsure, say N. - - To compile this driver as a module, choose M here. - config TOUCHSCREEN_GOODIX_GTX8_GESTURE tristate "Goodix GTx8 gesture wakeup feature" default n diff --git a/drivers/input/touchscreen/gtx8/Makefile b/drivers/input/touchscreen/gtx8/Makefile index fba44bdf85d3a6..ecee8457c0d51d 100644 --- a/drivers/input/touchscreen/gtx8/Makefile +++ b/drivers/input/touchscreen/gtx8/Makefile @@ -1,5 +1,4 @@ obj-$(CONFIG_TOUCHSCREEN_GOODIX_GTX8) += goodix_core.o goodix_core-y := goodix_ts_i2c.o goodix_ts_core.o goodix_cfg_bin.o -obj-$(CONFIG_TOUCHSCREEN_GOODIX_GTX8_UPDATE) += goodix_gtx8_update.o obj-$(CONFIG_TOUCHSCREEN_GOODIX_GTX8_GESTURE) += goodix_ts_gesture.o obj-$(CONFIG_TOUCHSCREEN_GOODIX_GTX8_TOOLS) += goodix_ts_tools.o diff --git a/drivers/input/touchscreen/gtx8/goodix_cfg_bin.c b/drivers/input/touchscreen/gtx8/goodix_cfg_bin.c index 0f7ccb99cf4cb1..b255ae51c06a65 100644 --- a/drivers/input/touchscreen/gtx8/goodix_cfg_bin.c +++ b/drivers/input/touchscreen/gtx8/goodix_cfg_bin.c @@ -113,7 +113,7 @@ static int goodix_parse_cfg_bin(struct goodix_cfg_bin *cfg_bin) } /*debug, print pkg information*/ - ts_info("Driver bin info: ver %s, len %d, pkgs %d", + ts_debug("Driver bin info: ver %s, len %d, pkgs %d", cfg_bin->head.bin_version, cfg_bin->head.bin_len, cfg_bin->head.pkg_num); for (i = 0; i < cfg_bin->head.pkg_num; i++) { @@ -206,7 +206,7 @@ static int goodix_cfg_bin_proc(struct goodix_ts_core *core_data) /*parse cfg bin*/ r = goodix_parse_cfg_bin(cfg_bin); if (!r) { - ts_info("parse cfg bin SUCCESS"); + ts_debug("parse cfg bin SUCCESS"); } else { ts_err("parse cfg bin FAILED"); goto exit; @@ -215,25 +215,25 @@ static int goodix_cfg_bin_proc(struct goodix_ts_core *core_data) /*get register address and configuration from cfg bin*/ r = goodix_get_reg_and_cfg(ts_dev, cfg_bin); if (!r) { - ts_info("success get reg and cfg info from cfg bin"); + ts_debug("success get reg and cfg info from cfg bin"); } else { ts_err("failed get cfg and reg info, update fw then retry"); } /*debug*/ - ts_info("cfg_send_flag:0x%04x", ts_dev->reg.cfg_send_flag); - ts_info("pid:0x%04x", ts_dev->reg.pid); - ts_info("vid:0x%04x", ts_dev->reg.vid); - ts_info("sensor_id:0x%04x", ts_dev->reg.sensor_id); - ts_info("fw_mask:0x%04x", ts_dev->reg.fw_mask); - ts_info("fw_status:0x%04x", ts_dev->reg.fw_status); - ts_info("cfg_addr:0x%04x", ts_dev->reg.cfg_addr); - ts_info("esd:0x%04x", ts_dev->reg.esd); - ts_info("command:0x%04x", ts_dev->reg.command); - ts_info("coor:0x%04x", ts_dev->reg.coor); - ts_info("gesture:0x%04x", ts_dev->reg.gesture); - ts_info("fw_request:0x%04x", ts_dev->reg.fw_request); - ts_info("proximity:0x%04x", ts_dev->reg.proximity); + ts_debug("cfg_send_flag:0x%04x", ts_dev->reg.cfg_send_flag); + ts_debug("pid:0x%04x", ts_dev->reg.pid); + ts_debug("vid:0x%04x", ts_dev->reg.vid); + ts_debug("sensor_id:0x%04x", ts_dev->reg.sensor_id); + ts_debug("fw_mask:0x%04x", ts_dev->reg.fw_mask); + ts_debug("fw_status:0x%04x", ts_dev->reg.fw_status); + ts_debug("cfg_addr:0x%04x", ts_dev->reg.cfg_addr); + ts_debug("esd:0x%04x", ts_dev->reg.esd); + ts_debug("command:0x%04x", ts_dev->reg.command); + ts_debug("coor:0x%04x", ts_dev->reg.coor); + ts_debug("gesture:0x%04x", ts_dev->reg.gesture); + ts_debug("fw_request:0x%04x", ts_dev->reg.fw_request); + ts_debug("proximity:0x%04x", ts_dev->reg.proximity); exit: kfree(cfg_bin->cfg_pkgs); @@ -244,7 +244,7 @@ static int goodix_cfg_bin_proc(struct goodix_ts_core *core_data) else goodix_ts_blocking_notify(NOTIFY_CFG_BIN_SUCCESS, &r); - ts_info("cfg bin state %d, ret %d", ts_dev->cfg_bin_state, r); + ts_debug("cfg bin state %d, ret %d", ts_dev->cfg_bin_state, r); return r; } @@ -269,13 +269,13 @@ static int goodix_extract_cfg_pkg(struct goodix_ts_device *ts_dev, return -EINVAL; } if (ts_cfg->length) { - ts_info("get config type %d, len %d", + ts_debug("get config type %d, len %d", cfg_pkg->cnst_info.cfg_type, ts_cfg->length); memcpy(ts_cfg->data, cfg_pkg->cfg, ts_cfg->length); ts_cfg->initialized = TS_CFG_STABLE; mutex_init(&ts_cfg->lock); } else { - ts_info("no config data"); + ts_debug("no config data"); } /*get register info*/ @@ -336,12 +336,12 @@ static int goodix_get_reg_and_cfg(struct goodix_ts_device *ts_dev, continue; } - ts_info("ic_type:%d", ts_dev->ic_type); + ts_debug("ic_type:%d", ts_dev->ic_type); /* contrast sensor id */ addr = cfg_bin->cfg_pkgs[i].reg_info.sensor_id.addr; if (!addr) { - ts_info("pkg:%d, sensor_id reg is NULL", i); + ts_debug("pkg:%d, sensor_id reg is NULL", i); continue; } @@ -351,7 +351,7 @@ static int goodix_get_reg_and_cfg(struct goodix_ts_device *ts_dev, addr); goto get_default_pkg; } - ts_info("sensor id is %d", temp_sensor_id); + ts_debug("sensor id is %d", temp_sensor_id); /*sensor.reserved1 is a mask, if it's not ZERO, use it*/ if (cfg_bin->cfg_pkgs[i].reg_info.sensor_id.reserved1 != 0) temp_sensor_id &= cfg_bin->cfg_pkgs[i] @@ -416,7 +416,7 @@ static int goodix_get_reg_and_cfg(struct goodix_ts_device *ts_dev, continue; } - ts_info("try get package info: ic type %s, cfg type %d", + ts_debug("try get package info: ic type %s, cfg type %d", cfg_bin->cfg_pkgs[i].cnst_info.ic_type, cfg_bin->cfg_pkgs[i].cnst_info.cfg_type); /* currently only support normal and high_sense config */ @@ -428,7 +428,7 @@ static int goodix_get_reg_and_cfg(struct goodix_ts_device *ts_dev, if (!r) { ts_dev->cfg_bin_state = CFG_BIN_STATE_INITIALIZED; - ts_info("success parse cfg bin"); + ts_debug("success parse cfg bin"); } else { ts_err("failed parse cfg bin"); break; @@ -449,7 +449,7 @@ static int goodix_get_reg_and_cfg(struct goodix_ts_device *ts_dev, ts_dev->cfg_bin_state = CFG_BIN_STATE_ERROR; } else { ts_dev->cfg_bin_state = CFG_BIN_STATE_TEMP; - ts_info("get temp config data"); + ts_debug("get temp config data"); } r = -EINVAL; @@ -468,7 +468,7 @@ static int goodix_read_cfg_bin(struct device *dev, /*get cfg_bin_name*/ strlcpy(cfg_bin_name, TS_DEFAULT_CFG_BIN, sizeof(cfg_bin_name)); - ts_info("cfg_bin_name:%s", cfg_bin_name); + ts_debug("cfg_bin_name:%s", cfg_bin_name); for (i = 0; i < TS_RQST_FW_RETRY_TIMES; i++) { r = request_firmware(&firmware, cfg_bin_name, dev); @@ -477,7 +477,7 @@ static int goodix_read_cfg_bin(struct device *dev, cfg_bin_name, r, i + 1); msleep(1000); } else { - ts_info("Cfg_bin image [%s] is ready, try_times:%d", + ts_debug("Cfg_bin image [%s] is ready, try_times:%d", cfg_bin_name, i + 1); break; } @@ -564,7 +564,7 @@ static int goodix_later_init_thread(void *data) if (ret) ts_err("parse cfg bin encounter error, %d", ret); else - ts_info("success get cfg bin"); + ts_debug("success get cfg bin"); if (ts_dev->cfg_bin_state == CFG_BIN_STATE_ERROR) { ts_err("parse cfg bin encounter fatal err"); @@ -580,7 +580,7 @@ static int goodix_later_init_thread(void *data) ts_err("fw update failed, %d", ret); goto release_core; } - ts_info("fw update success retry parse cfg bin"); + ts_debug("fw update success retry parse cfg bin"); ret = goodix_cfg_bin_proc(ts_core); if (ret) { ts_err("failed parse cfg bin after fw update"); @@ -598,7 +598,7 @@ static int goodix_later_init_thread(void *data) } ret = goodix_ts_stage2_init(ts_core); if (!ret) { - ts_info("stage2 init success"); + ts_debug("stage2 init success"); return ret; } ts_err("stage2 init failed, %d", ret); diff --git a/drivers/input/touchscreen/gtx8/goodix_default_fw.h b/drivers/input/touchscreen/gtx8/goodix_default_fw.h deleted file mode 100644 index 00fd39d4b8404c..00000000000000 --- a/drivers/input/touchscreen/gtx8/goodix_default_fw.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _GOODIX_FIRMWARE_FW_H_ -#define _GOODIX_FIRMWARE_FW_H_ - -u8 goodix_default_fw[] = { 0x00 }; - -#endif diff --git a/drivers/input/touchscreen/gtx8/goodix_gtx8_update.c b/drivers/input/touchscreen/gtx8/goodix_gtx8_update.c deleted file mode 100644 index 6e636ee0594fd9..00000000000000 --- a/drivers/input/touchscreen/gtx8/goodix_gtx8_update.c +++ /dev/null @@ -1,1596 +0,0 @@ -/* - * Goodix Firmware Update Driver. - * - * Copyright (C) 2019 - 2020 Goodix, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be a reference - * to you, when you are integrating the GOODiX's CTP IC into your system, - * 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. - */ -#include "goodix_ts_core.h" -#include "goodix_cfg_bin.h" -#include "goodix_default_fw.h" -/* COMMON PART - START */ -#define TS_DEFAULT_FIRMWARE "goodix_firmware.bin" - -#define FW_HEADER_SIZE 256 -#define FW_SUBSYS_INFO_SIZE 8 -#define FW_SUBSYS_INFO_OFFSET 32 -#define FW_SUBSYS_MAX_NUM 28 - -#define ISP_MAX_BUFFERSIZE (1024 * 4) - -#define HW_REG_CPU_CTRL 0x2180 -#define HW_REG_DSP_MCU_POWER 0x2010 -#define HW_REG_RESET 0x2184 -#define HW_REG_SCRAMBLE 0x2218 -#define HW_REG_BANK_SELECT 0x2048 -#define HW_REG_ACCESS_PATCH0 0x204D -#define HW_REG_EC_SRM_START 0x204F -#define HW_REG_GIO_YS 0x2014 -#define HW_REG_ESD_KEY_EN 0x2318 -#define HW_REG_ESD_KEY_DIS 0x2324 -#define HW_REG_CPU_RUN_FROM 0x4506 /* for nor_L is 0x4006 */ -#define HW_REG_CPU_RUN_FROM_YS 0x4000 -#define HW_REG_ISP_RUN_FLAG 0x6006 -#define HW_REG_ISP_ADDR 0xC000 -#define HW_REG_ISP_BUFFER 0x6100 -#define HW_REG_SUBSYS_TYPE 0x6020 -#define HW_REG_FLASH_FLAG 0x6022 -#define HW_REG_CACHE 0x204B -#define HW_REG_ESD_KEY 0x2318 -#define HW_REG_WTD_TIMER 0x20B0 - -#define FLASH_ADDR_CONFIG_DATA 0x1E000 -#define FLASH_SUBSYS_TYPE_CONFIG 0x03 - -#define CPU_CTRL_PENDING 0x00 -#define CPU_CTRL_RUNNING 0x01 - -#define ISP_STAT_IDLE 0xFF -#define ISP_STAT_READY 0xAA -#define ISP_STAT_WRITING 0xAA -#define ISP_FLASH_SUCCESS 0xBB -#define ISP_FLASH_ERROR 0xCC -#define ISP_FLASH_CHECK_ERROR 0xDD -#define ISP_CMD_PREPARE 0x55 -#define ISP_CMD_FLASH 0xAA - -#define TS_CHECK_ISP_STATE_RETRY_TIMES 200 -#define TS_READ_FLASH_STATE_RETRY_TIMES 200 - -/** - * fw_subsys_info - subsystem firmware information - * @type: subsystem type - * @size: firmware size - * @flash_addr: flash address - * @data: firmware data - */ -struct fw_subsys_info { - u8 type; - u32 size; - u16 flash_addr; - const u8 *data; -}; - -#pragma pack(1) -/** - * firmware_info - * @size: fw total length - * @checksum: checksum of fw - * @hw_pid: mask pid string - * @hw_pid: mask vid code - * @fw_pid: fw pid string - * @fw_vid: fw vid code - * @subsys_num: number of fw subsystem - * @chip_type: chip type - * @protocol_ver: firmware packing - * protocol version - * @subsys: subsystem info - */ -struct firmware_info { - u32 size; - u16 checksum; - u8 hw_pid[6]; - u8 hw_vid[3]; - u8 fw_pid[8]; - u8 fw_vid[4]; - u8 subsys_num; - u8 chip_type; - u8 protocol_ver; - u8 reserved[2]; - struct fw_subsys_info subsys[FW_SUBSYS_MAX_NUM]; -}; - -#pragma pack() - -/** - * firmware_data - firmware data structure - * @fw_info: firmware information - * @firmware: firmware data structure - */ -struct firmware_data { - struct firmware_info fw_info; - const struct firmware *firmware; -}; - -enum update_status { - UPSTA_NOTWORK = 0, - UPSTA_PREPARING, - UPSTA_UPDATING, - UPSTA_ABORT, - UPSTA_SUCCESS, - UPSTA_FAILED -}; - -/** - * fw_update_ctrl - structure used to control the - * firmware update process - * @initialized: struct init state - * @mode: indicate weather reflash config or not, fw data source, - * and run on block mode or not. - * @status: update status - * @progress: indicate the progress of update - * @allow_reset: control the reset callback - * @allow_irq: control the irq callback - * @allow_suspend: control the suspend callback - * @allow_resume: allow resume callback - * @fw_data: firmware data - * @ts_dev: touch device - * @fw_name: firmware name - * @attr_fwimage: sysfs bin attrs, for storing fw image - * @fw_data_src: firmware data source form sysfs, request or head file - */ -struct fw_update_ctrl { - struct mutex mutex; - int initialized; - int mode; - enum update_status status; - unsigned int progress; - - bool allow_reset; - bool allow_irq; - bool allow_suspend; - bool allow_resume; - - struct firmware_data fw_data; - struct goodix_ts_device *ts_dev; - struct goodix_ts_core *core_data; - - char fw_name[32]; - struct bin_attribute attr_fwimage; -}; -static struct fw_update_ctrl goodix_fw_update_ctrl; -/** - * goodix_parse_firmware - parse firmware header information - * and subsystem information from firmware data buffer - * - * @fw_data: firmware struct, contains firmware header info - * and firmware data. - * return: 0 - OK, < 0 - error - */ -static int goodix_parse_firmware(struct firmware_data *fw_data) -{ - const struct firmware *firmware; - struct firmware_info *fw_info; - unsigned int i, fw_offset, info_offset; - u16 checksum; - int r = 0; - - if (!fw_data || !fw_data->firmware) { - ts_err("Invalid firmware data"); - return -EINVAL; - } - fw_info = &fw_data->fw_info; - - /* copy firmware head info */ - firmware = fw_data->firmware; - if (firmware->size < FW_SUBSYS_INFO_OFFSET) { - ts_err("Invalid firmware size:%zu", firmware->size); - r = -EINVAL; - goto err_size; - } - memcpy(fw_info, firmware->data, FW_SUBSYS_INFO_OFFSET); - - /* check firmware size */ - fw_info->size = be32_to_cpu(fw_info->size); - if (firmware->size != fw_info->size + 6) { - ts_err("Bad firmware, size not match"); - r = -EINVAL; - goto err_size; - } - - /* calculate checksum, note: sum of bytes, but check - * by u16 checksum - */ - for (i = 6, checksum = 0; i < firmware->size; i++) - checksum += firmware->data[i]; - - /* byte order change, and check */ - fw_info->checksum = be16_to_cpu(fw_info->checksum); - if (checksum != fw_info->checksum) { - ts_err("Bad firmware, checksum error %x(file) != %x(cal)", - fw_info->checksum, checksum); - r = -EINVAL; - goto err_size; - } - - if (fw_info->subsys_num > FW_SUBSYS_MAX_NUM) { - ts_err("Bad firmware, invalid subsys num: %d", - fw_info->subsys_num); - r = -EINVAL; - goto err_size; - } - - /* parse subsystem info */ - fw_offset = FW_HEADER_SIZE; - for (i = 0; i < fw_info->subsys_num; i++) { - info_offset = FW_SUBSYS_INFO_OFFSET + i * FW_SUBSYS_INFO_SIZE; - - fw_info->subsys[i].type = firmware->data[info_offset]; - fw_info->subsys[i].size = be32_to_cpup( - (__be32 *)&firmware->data[info_offset + 1]); - fw_info->subsys[i].flash_addr = be16_to_cpup( - (__be16 *)&firmware->data[info_offset + 5]); - - if (fw_offset > firmware->size) { - ts_err("Sybsys offset exceed Firmware size"); - goto err_size; - } - - fw_info->subsys[i].data = firmware->data + fw_offset; - fw_offset += fw_info->subsys[i].size; - } - - ts_info("Firmware package protocol: V%u", fw_info->protocol_ver); - ts_info("Firmware PID:GT%s", fw_info->fw_pid); - ts_info("Firmware VID:%02X%02X%02X%02x", fw_info->fw_vid[0], - fw_info->fw_vid[1], fw_info->fw_vid[2], fw_info->fw_vid[3]); - ts_info("Firmware chip type:%02X", fw_info->chip_type); - ts_info("Firmware size:%u", fw_info->size); - ts_info("Firmware subsystem num:%u", fw_info->subsys_num); -#ifdef CONFIG_GOODIX_DEBUG - for (i = 0; i < fw_info->subsys_num; i++) { - ts_debug("------------------------------------------"); - ts_debug("Index:%d", i); - ts_debug("Subsystem type:%02X", fw_info->subsys[i].type); - ts_debug("Subsystem size:%u", fw_info->subsys[i].size); - ts_debug("Subsystem flash_addr:%08X", - fw_info->subsys[i].flash_addr); - ts_debug("Subsystem Ptr:%p", fw_info->subsys[i].data); - } - ts_debug("------------------------------------------"); -#endif - -err_size: - return r; -} - -/** - * goodix_check_update - compare the version of firmware running in - * touch device with the version getting from the firmware file. - * @fw_info: firmware information to be compared - * return: 0 no need do update, - * otherwise need do update - */ -static int goodix_check_update(struct goodix_ts_device *dev, - const struct firmware_info *fw_info) -{ - struct goodix_ts_version fw_ver; - int ret = -EINVAL; - - /* read version from chip, if we got invalid - * firmware version, maybe firmware in flash is - * incorrect, so we need to update firmware - */ - ret = dev->hw_ops->read_version(dev, &fw_ver); - if (ret) { - ts_info("failed get active pid"); - return -EINVAL; - } - - if (fw_ver.valid) { - // should we compare PID before fw update? - // if fw patch demage the PID may unmatch but - // we should de update to recover it. - // TODO skip PID check - /*if (memcmp(fw_ver.pid, fw_info->fw_pid, dev->reg.pid_len)) { - ts_err("Product ID is not match %s != %s", - fw_ver.pid, fw_info->fw_pid); - return -EPERM; - }*/ - - ret = memcmp(fw_ver.vid, fw_info->fw_vid, dev->reg.vid_len); - if (ret == 0) { - ts_info("FW version is equal to the IC's"); - return 0; - } else if (ret > 0) { - ts_info("Warning: fw version is lower the IC's"); - } - } /* else invalid firmware, update firmware */ - - ts_info("Firmware needs to be updated"); - return ret; -} - -/** - * goodix_reg_write_confirm - write register and confirm the value - * in the register. - * @dev: pointer to touch device - * @addr: register address - * @data: pointer to data buffer - * @len: data length - * return: 0 write success and confirm ok - * < 0 failed - */ -static int goodix_reg_write_confirm(struct goodix_ts_device *dev, - unsigned int addr, unsigned char *data, - unsigned int len) -{ - u8 *cfm, cfm_buf[32]; - int r, i; - - if (len > sizeof(cfm_buf)) { - cfm = kzalloc(len, GFP_KERNEL); - if (!cfm) { - ts_err("Mem alloc failed"); - return -ENOMEM; - } - } else { - cfm = &cfm_buf[0]; - } - - for (i = 0; i < GOODIX_BUS_RETRY_TIMES; i++) { - r = dev->hw_ops->write_trans(dev, addr, data, len); - if (r < 0) - goto exit; - - r = dev->hw_ops->read_trans(dev, addr, cfm, len); - if (r < 0) - goto exit; - - if (memcmp(data, cfm, len)) { - ts_info("data[0]:0x%02x, data[1]:0x%02x," - "read cfm[0]:0x%02x, cfm[1]:0x%02x", - data[0], data[1], cfm[0], cfm[1]); - dev->hw_ops->read_trans(dev, 0x6022, cfm, 2); - ts_info("read 0x6022 data[0]:0x%02x, data[1]:0x%02x", - cfm[0], cfm[1]); - r = -EMEMCMP; - continue; - } else { - r = 0; - break; - } - } - -exit: - if (cfm != &cfm_buf[0]) - kfree(cfm); - return r; -} - -static inline int goodix_reg_write(struct goodix_ts_device *dev, - unsigned int addr, unsigned char *data, - unsigned int len) -{ - return dev->hw_ops->write_trans(dev, addr, data, len); -} - -static inline int goodix_reg_read(struct goodix_ts_device *dev, - unsigned int addr, unsigned char *data, - unsigned int len) -{ - return dev->hw_ops->read_trans(dev, addr, data, len); -} - -/** - * goodix_load_isp - load ISP program to device ram - * @dev: pointer to touch device - * @fw_data: firmware data - * return 0 ok, <0 error - */ -static int goodix_load_isp(struct goodix_ts_device *ts_dev, - struct firmware_data *fw_data) -{ - struct fw_subsys_info *fw_isp; - u8 reg_val[8] = { 0x00 }; - int r; - int i; - - fw_isp = &fw_data->fw_info.subsys[0]; - - ts_info("Loading ISP start"); - reg_val[0] = 0x00; - r = goodix_reg_write(ts_dev, HW_REG_BANK_SELECT, reg_val, 1); - if (r < 0) { - ts_err("Failed to select bank0"); - return r; - } - ts_debug("Success select bank0, Set 0x%x -->0x00", HW_REG_BANK_SELECT); - - reg_val[0] = 0x01; - r = goodix_reg_write(ts_dev, HW_REG_ACCESS_PATCH0, reg_val, 1); - if (r < 0) { - ts_err("Failed to enable patch0 access"); - return r; - } - ts_debug("Success select bank0, Set 0x%x -->0x01", - HW_REG_ACCESS_PATCH0); - - r = goodix_reg_write_confirm(ts_dev, HW_REG_ISP_ADDR, - (u8 *)fw_isp->data, fw_isp->size); - if (r < 0) { - ts_err("Loading ISP error"); - return r; - } - - ts_debug("Success send ISP data to IC"); - - reg_val[0] = 0x00; - r = goodix_reg_write_confirm(ts_dev, HW_REG_ACCESS_PATCH0, reg_val, 1); - if (r < 0) { - ts_err("Failed to disable patch0 access"); - return r; - } - ts_debug("Success forbid bank0 accedd, set 0x%x -->0x00", - HW_REG_ACCESS_PATCH0); - - reg_val[0] = 0x00; - reg_val[1] = 0x00; - r = goodix_reg_write(ts_dev, HW_REG_ISP_RUN_FLAG, reg_val, 2); - if (r < 0) { - ts_err("Failed to clear 0x%x", HW_REG_ISP_RUN_FLAG); - return r; - } - ts_debug("Success clear 0x%x", HW_REG_ISP_RUN_FLAG); - - memset(reg_val, 0x55, 8); - if (ts_dev->ic_type == IC_TYPE_YELLOWSTONE) - r = goodix_reg_write(ts_dev, HW_REG_CPU_RUN_FROM_YS, reg_val, - 8); - else - r = goodix_reg_write(ts_dev, HW_REG_CPU_RUN_FROM, reg_val, 8); - if (r < 0) { - ts_err("Failed set HW_REG_CPU_RUN_FROM flag"); - return r; - } - ts_info("Success write [8]0x55 to HW_REG_CPU_RUN_FROM"); - - reg_val[0] = 0x00; - r = goodix_reg_write(ts_dev, HW_REG_CPU_CTRL, reg_val, 1); - if (r < 0) { - ts_err("Failed to run isp"); - return r; - } - ts_debug("Success run isp, set 0x%x-->0x00", HW_REG_CPU_CTRL); - - /* check isp work state */ - for (i = 0; i < TS_CHECK_ISP_STATE_RETRY_TIMES; i++) { - msleep(10); - r = goodix_reg_read(ts_dev, HW_REG_ISP_RUN_FLAG, reg_val, 2); - if (r < 0 || (reg_val[0] == 0xAA && reg_val[1] == 0xBB)) - break; - } - if (reg_val[0] == 0xAA && reg_val[1] == 0xBB) { - ts_info("ISP working OK"); - return 0; - } - ts_err("ISP not work,0x%x=0x%x, 0x%x=0x%x", HW_REG_ISP_RUN_FLAG, - reg_val[0], HW_REG_ISP_RUN_FLAG + 1, reg_val[1]); - return -EFAULT; -} - -/** - * goodix_update_prepare - update prepare, loading ISP program - * and make sure the ISP is running. - * @fwu_ctrl: pointer to firmware control structure - * return: 0 ok, <0 error - */ -static int goodix_update_prepare(struct fw_update_ctrl *fwu_ctrl) -{ - struct goodix_ts_device *ts_dev = fwu_ctrl->ts_dev; - u8 reg_val[4] = { 0x00 }; - u8 temp_buf[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - int retry = 20; - int r; - - if (ts_dev->ic_type == IC_TYPE_YELLOWSTONE) - ts_dev->hw_ops->write(ts_dev, HW_REG_CPU_RUN_FROM_YS, temp_buf, - 8); - else - ts_dev->hw_ops->write(ts_dev, HW_REG_CPU_RUN_FROM, temp_buf, 8); - - /*reset IC*/ - fwu_ctrl->allow_reset = true; - ts_info("firmware update, reset"); - gpio_direction_output(ts_dev->board_data.reset_gpio, 0); - udelay(2000); - gpio_direction_output(ts_dev->board_data.reset_gpio, 1); - usleep_range(10000, 11000); - fwu_ctrl->allow_reset = false; - - retry = 100; - do { - if (ts_dev->ic_type != IC_TYPE_YELLOWSTONE) - break; - reg_val[0] = 0x00; - r = goodix_reg_write_confirm(ts_dev, HW_REG_GIO_YS, reg_val, 1); - if (r < 0) - ts_info("Failed to remove GIO hold flag, retry %d", - retry); - else - break; - } while (--retry); - if (!retry) { - ts_err("Failed to remove GIO flag"); - return -EINVAL; - } - - retry = 20; - for (retry = 0; retry < 20; retry++) { - if (ts_dev->ic_type == IC_TYPE_YELLOWSTONE) { - reg_val[0] = 0x00; - r = goodix_reg_write(ts_dev, HW_REG_ESD_KEY_DIS, - reg_val, 1); - if (r < 0) { - ts_info("failed dis esd key"); - continue; - } - reg_val[0] = 0x95; - r = goodix_reg_write(ts_dev, HW_REG_ESD_KEY_EN, reg_val, - 1); - if (r < 0) { - ts_info("failed open esd key"); - continue; - } - } - reg_val[0] = 0x24; - r = goodix_reg_write_confirm(ts_dev, HW_REG_CPU_CTRL, reg_val, - 1); - if (r < 0) { - ts_info("Failed to hold ss51, retry"); - msleep(20); - } else { - break; - } - } - if (retry >= 20) { - ts_err("Failed hold ss51,return =%d", r); - return -EINVAL; - } - ts_debug("Success hold ss51"); - - /* enable DSP & MCU power */ - reg_val[0] = 0x00; - r = goodix_reg_write_confirm(ts_dev, HW_REG_DSP_MCU_POWER, reg_val, 1); - if (r < 0) { - ts_err("Failed enable DSP&MCU power"); - return r; - } - ts_debug("Success enabled DSP&MCU power,set 0x%x-->0x00", - HW_REG_DSP_MCU_POWER); - - /* disable watchdog timer */ - reg_val[0] = 0x00; - r = goodix_reg_write(ts_dev, HW_REG_CACHE, reg_val, 1); - if (r < 0) { - ts_err("Failed to clear cache"); - return r; - } - ts_debug("Success clear cache"); - - if (ts_dev->ic_type == IC_TYPE_YELLOWSTONE) { - reg_val[0] = 0x00; - r = goodix_reg_write(ts_dev, HW_REG_WTD_TIMER, reg_val, 1); - } else { - reg_val[0] = 0x95; - r = goodix_reg_write(ts_dev, HW_REG_ESD_KEY, reg_val, 1); - reg_val[0] = 0x00; - r |= goodix_reg_write(ts_dev, HW_REG_WTD_TIMER, reg_val, 1); - - reg_val[0] = 0x27; - r |= goodix_reg_write(ts_dev, HW_REG_ESD_KEY, reg_val, 1); - } - if (r < 0) { - ts_err("Failed to disable watchdog"); - return r; - } - ts_info("Success disable watchdog"); - - /* set scramble */ - reg_val[0] = 0x00; - r = goodix_reg_write(ts_dev, HW_REG_SCRAMBLE, reg_val, 1); - if (r < 0) { - ts_err("Failed to set scramble"); - return r; - } - ts_debug("Success set scramble"); - - /* load ISP code and run form isp */ - r = goodix_load_isp(ts_dev, &fwu_ctrl->fw_data); - if (r < 0) - ts_err("Failed lode and run isp"); - - return r; -} - -/** - * goodix_format_fw_packet - format one flash packet - * @pkt: target firmware packet - * @flash_addr: flash address - * @size: packet size - * @data: packet data - */ -static int goodix_format_fw_packet(u8 *pkt, u32 flash_addr, u16 len, - const u8 *data) -{ - u16 checksum; - - if (!pkt || !data) - return -EINVAL; - - /* - * checksum rule:sum of data in one format is equal to zero - * data format: byte/le16/be16/le32/be32/le64/be64 - */ - pkt[0] = (len >> 8) & 0xff; - pkt[1] = len & 0xff; - /* u16 >> 16bit seems nosense but really important */ - pkt[2] = (flash_addr >> 16) & 0xff; - pkt[3] = (flash_addr >> 8) & 0xff; - memcpy(&pkt[4], data, len); - checksum = checksum_be16(pkt, len + 4); - checksum = 0 - checksum; - pkt[len + 4] = (checksum >> 8) & 0xff; - pkt[len + 5] = checksum & 0xff; - return 0; -} - -/** - * goodix_send_fw_packet - send one firmware packet to ISP - * @dev: target touch device - * @pkt: firmware packet - * return:0 ok, <0 error - */ -static int goodix_send_fw_packet(struct goodix_ts_device *dev, u8 type, u8 *pkt, - u32 len) -{ - u8 reg_val[4]; - int r, i; - - if (!pkt) - return -EINVAL; - - ts_info("target fw subsys type:0x%x, len %d", type, len); - r = goodix_reg_write_confirm(dev, HW_REG_ISP_BUFFER, pkt, len); - if (r < 0) { - ts_err("Failed to write firmware packet"); - return r; - } - - reg_val[0] = 0; - reg_val[1] = 0; - /* clear flash flag 0X6022 */ - r = goodix_reg_write_confirm(dev, HW_REG_FLASH_FLAG, reg_val, 2); - if (r < 0) { - ts_err("Failed to clear flash flag"); - return r; - } - - /* write subsystem type 0X8020*/ - reg_val[0] = type; - reg_val[1] = type; - r = goodix_reg_write_confirm(dev, HW_REG_SUBSYS_TYPE, reg_val, 2); - if (r < 0) { - ts_err("Failed write subsystem type to IC"); - return r; - } - - for (i = 0; i < TS_READ_FLASH_STATE_RETRY_TIMES; i++) { - r = goodix_reg_read(dev, HW_REG_FLASH_FLAG, reg_val, 2); - if (r < 0) { - ts_err("Failed read flash state"); - return r; - } - - /* flash haven't end */ - if (reg_val[0] == ISP_STAT_WRITING && - reg_val[1] == ISP_STAT_WRITING) { - ts_debug("Flash not ending..."); - usleep_range(55000, 56000); - continue; - } - if (reg_val[0] == ISP_FLASH_SUCCESS && - reg_val[1] == ISP_FLASH_SUCCESS) { - r = goodix_reg_read(dev, HW_REG_FLASH_FLAG, reg_val, 2); - if (!r && reg_val[0] == ISP_FLASH_SUCCESS && - reg_val[1] == ISP_FLASH_SUCCESS) { - ts_info("Flash subsystem ok"); - return 0; - } - } - if (reg_val[0] == ISP_FLASH_ERROR && - reg_val[1] == ISP_FLASH_ERROR) { - ts_err(" Flash subsystem failed"); - return -EAGAIN; - } - if (reg_val[0] == ISP_FLASH_CHECK_ERROR) { - ts_err("Subsystem checksum err"); - return -EAGAIN; - } - - usleep_range(250, 260); - } - - ts_err("Wait for flash end timeout, 0x6022= %x %x", reg_val[0], - reg_val[1]); - return -EAGAIN; -} - -/** - * goodix_flash_subsystem - flash subsystem firmware, - * Main flow of flashing firmware. - * Each firmware subsystem is divided into several - * packets, the max size of packet is limited to - * @{ISP_MAX_BUFFERSIZE} - * @dev: pointer to touch device - * @subsys: subsystem information - * return: 0 ok, < 0 error - */ -static int goodix_flash_subsystem(struct goodix_ts_device *dev, - struct fw_subsys_info *subsys) -{ - u16 data_size, offset; - u32 total_size; - u32 subsys_base_addr = subsys->flash_addr << 8; - u8 *fw_packet; - int r = 0, i; - - /* - * if bus(i2c/spi) error occued, then exit, we will do - * hardware reset and re-prepare ISP and then retry - * flashing - */ - total_size = subsys->size; - fw_packet = kzalloc(ISP_MAX_BUFFERSIZE + 6, GFP_KERNEL); - if (!fw_packet) { - ts_err("Failed alloc memory"); - return -EINVAL; - } - - offset = 0; - while (total_size > 0) { - data_size = total_size > ISP_MAX_BUFFERSIZE ? - ISP_MAX_BUFFERSIZE : - total_size; - ts_info("Flash firmware to %08x,size:%u bytes", - subsys_base_addr + offset, data_size); - - /* format one firmware packet */ - r = goodix_format_fw_packet(fw_packet, - subsys_base_addr + offset, - data_size, &subsys->data[offset]); - if (r < 0) { - ts_err("Invalid packet params"); - goto exit; - } - - /* send one firmware packet, retry 3 time if send failed */ - for (i = 0; i < 3; i++) { - r = goodix_send_fw_packet(dev, subsys->type, fw_packet, - data_size + 6); - if (!r) - break; - } - if (r) { - ts_err("Failed flash subsystem"); - goto exit; - } - offset += data_size; - total_size -= data_size; - } /* end while */ - -exit: - kfree(fw_packet); - return r; -} - -/** - * goodix_flash_firmware - flash firmware - * @dev: pointer to touch device - * @fw_data: firmware data - * return: 0 ok, < 0 error - */ -static int goodix_flash_firmware(struct goodix_ts_device *dev, - struct firmware_data *fw_data) -{ - struct fw_update_ctrl *fw_ctrl; - struct firmware_info *fw_info; - struct fw_subsys_info *fw_x; - int retry = GOODIX_BUS_RETRY_TIMES; - int i, r = 0, fw_num, prog_step; - u8 *fw_packet = NULL; - u8 *flash_cfg = NULL; - - /* start from subsystem 1, - * subsystem 0 is the ISP program - */ - fw_ctrl = container_of(fw_data, struct fw_update_ctrl, fw_data); - fw_info = &fw_data->fw_info; - fw_num = fw_info->subsys_num; - - /* we have 80% work here */ - prog_step = 80 / (fw_num - 1); - - for (i = 1; i < fw_num && retry;) { - ts_info("--- Start to flash subsystem[%d] ---", i); - fw_x = &fw_info->subsys[i]; - r = goodix_flash_subsystem(dev, fw_x); - if (r == 0) { - ts_info("--- End flash subsystem[%d]: OK ---", i); - fw_ctrl->progress += prog_step; - i++; - } else if (r == -EAGAIN) { - retry--; - ts_err("--- End flash subsystem%d: Fail, errno:%d, retry:%d ---", - i, r, GOODIX_BUS_RETRY_TIMES - retry); - } else if (r < 0) { /* bus error */ - ts_err("--- End flash subsystem%d: Fatal error:%d exit ---", - i, r); - break; - } - } - - kfree(fw_packet); - fw_packet = NULL; - kfree(flash_cfg); - flash_cfg = NULL; - return r; -} - -/** - * goodix_update_finish - update finished, free resource - * and reset flags--- - * @fwu_ctrl: pointer to fw_update_ctrl structure - * return: 0 ok, < 0 error - */ -static int goodix_update_finish(struct goodix_ts_device *ts_dev, - struct fw_update_ctrl *fwu_ctrl) -{ - u8 reg_val[8] = { 0 }; - int r = 0, i = 0; - - /* hold ss51 */ - reg_val[0] = 0x24; - r = goodix_reg_write(ts_dev, HW_REG_CPU_CTRL, reg_val, 1); - if (r < 0) - ts_err("Failed to hold ss51"); - - /* clear recovery flag */ - memset(reg_val, 0, sizeof(reg_val)); - if (ts_dev->ic_type == IC_TYPE_YELLOWSTONE) - r = goodix_reg_write(ts_dev, HW_REG_CPU_RUN_FROM_YS, reg_val, - 8); - else - r = goodix_reg_write(ts_dev, HW_REG_CPU_RUN_FROM, reg_val, 8); - if (r) { - ts_err("Failed set CPU run from normal firmware"); - return r; - } - - /* release ss51 */ - reg_val[0] = 0x00; - r = goodix_reg_write(ts_dev, HW_REG_CPU_CTRL, reg_val, 1); - if (r < 0) - ts_err("Failed to run ss51"); - - /*reset*/ - gpio_direction_output(ts_dev->board_data.reset_gpio, 0); - udelay(2000); - gpio_direction_output(ts_dev->board_data.reset_gpio, 1); - msleep(80); - - for (i = 0; ts_dev->ic_type == IC_TYPE_YELLOWSTONE && i < 100; i++) { - reg_val[0] = 0x00; - r = goodix_reg_write_confirm(ts_dev, HW_REG_GIO_YS, reg_val, 1); - if (!r) - break; - ts_info("failed set GIO flag, r %d", r); - } - if (i >= 100) - ts_err("failed set GIO flag, %d", r); - - return r; -} - -static int goodix_flash_config(struct goodix_ts_device *ts_dev) -{ - int ret; - u8 *fw_packet = NULL; - u8 *temp_data = NULL; - - if (!ts_dev || !ts_dev->cfg_bin_state || - !ts_dev->normal_cfg.initialized) { - ts_err("no valid config data for flash"); - return -EINVAL; - } - - temp_data = kzalloc(ISP_MAX_BUFFERSIZE, GFP_KERNEL); - fw_packet = kzalloc(ISP_MAX_BUFFERSIZE + 6, GFP_KERNEL); - if (!temp_data || !fw_packet) { - ts_err("Failed alloc memory"); - ret = -EINVAL; - goto exit; - } - - memset(temp_data, 0xFF, ISP_MAX_BUFFERSIZE); - ts_info("normal config length %d", ts_dev->normal_cfg.length); - memcpy(temp_data, ts_dev->normal_cfg.data, ts_dev->normal_cfg.length); - - /* format one firmware packet */ - ret = goodix_format_fw_packet(fw_packet, FLASH_ADDR_CONFIG_DATA, - ISP_MAX_BUFFERSIZE, temp_data); - if (ret < 0) { - ts_err("Invalid packet params"); - goto exit; - } - ts_debug("fw_pack:%*ph", 10, fw_packet); - ts_info("try flash config"); - ret = goodix_send_fw_packet(ts_dev, FLASH_SUBSYS_TYPE_CONFIG, fw_packet, - ISP_MAX_BUFFERSIZE + 6); - if (ret) - ts_err("failed flash config, ret %d", ret); - else - ts_info("success flash config with isp"); - -exit: - kfree(temp_data); - kfree(fw_packet); - return ret; -} - -/** - * goodix_fw_update_proc - firmware update process, the entry of - * firmware update flow - * @fwu_ctrl: firmware control - * return: 0 ok, < 0 error - */ -static int goodix_fw_update_proc(struct fw_update_ctrl *fwu_ctrl) -{ -#define FW_UPDATE_RETRY 2 - int retry0 = FW_UPDATE_RETRY; - int retry1 = FW_UPDATE_RETRY; - int r = 0; - - if (fwu_ctrl->status == UPSTA_PREPARING || - fwu_ctrl->status == UPSTA_UPDATING) { - ts_err("Firmware update already in progress"); - return -EINVAL; - } - - fwu_ctrl->progress = 0; - fwu_ctrl->status = UPSTA_PREPARING; - - r = goodix_parse_firmware(&fwu_ctrl->fw_data); - if (r < 0) { - fwu_ctrl->status = UPSTA_ABORT; - goto err_parse_fw; - } - - fwu_ctrl->progress = 10; - if (!(fwu_ctrl->mode & UPDATE_MODE_FORCE)) { - r = goodix_check_update(fwu_ctrl->ts_dev, - &fwu_ctrl->fw_data.fw_info); - if (!r) { - fwu_ctrl->status = UPSTA_ABORT; - ts_info("fw update skipped"); - goto err_check_update; - } - } else { - ts_info("force update mode"); - } - -start_update: - fwu_ctrl->progress = 20; - fwu_ctrl->status = UPSTA_UPDATING; /* show upgrading status */ - r = goodix_update_prepare(fwu_ctrl); - if ((r == -EBUS || r == -EAGAIN) && --retry0 > 0) { - ts_err("Bus error, retry prepare ISP:%d", - FW_UPDATE_RETRY - retry0); - goto start_update; - } else if (r < 0) { - ts_err("Failed to prepare ISP, exit update:%d", r); - fwu_ctrl->status = UPSTA_FAILED; - goto err_fw_prepare; - } - - if (GOODIX_FLASH_CONFIG_WITH_ISP && - fwu_ctrl->mode & UPDATE_MODE_FLASH_CFG) { - ts_info("need flash config with isp"); - goodix_flash_config(fwu_ctrl->ts_dev); - } - - /* progress: 20%~100% */ - r = goodix_flash_firmware(fwu_ctrl->ts_dev, &fwu_ctrl->fw_data); - if ((r == -EBUS || r == -ETIMEOUT) && --retry1 > 0) { - /* we will retry[twice] if returns bus error[i2c/spi] - * we will do hardware reset and re-prepare ISP and then retry - * flashing - */ - ts_err("Bus error, retry firmware update:%d", - FW_UPDATE_RETRY - retry1); - goto start_update; - } else if (r < 0) { - ts_err("Fatal error, exit update:%d", r); - fwu_ctrl->status = UPSTA_FAILED; - goto err_fw_flash; - } - - fwu_ctrl->status = UPSTA_SUCCESS; - -err_fw_flash: -err_fw_prepare: - goodix_update_finish(fwu_ctrl->ts_dev, fwu_ctrl); -err_check_update: -err_parse_fw: - if (fwu_ctrl->status == UPSTA_SUCCESS) - ts_info("Firmware update successfully"); - else if (fwu_ctrl->status == UPSTA_FAILED) - ts_err("Firmware update failed"); - - fwu_ctrl->progress = 100; /* 100% */ - ts_info("fw update ret %d", r); - return r; -} - -static struct goodix_ext_module goodix_fwu_module; - -/** - * goodix_request_firmware - request firmware data from user space - * - * @fw_data: firmware struct, contains firmware header info - * and firmware data pointer. - * return: 0 - OK, < 0 - error - */ -static int goodix_request_firmware(struct firmware_data *fw_data, - const char *name) -{ - struct fw_update_ctrl *fw_ctrl = - container_of(fw_data, struct fw_update_ctrl, fw_data); - struct device *dev = fw_ctrl->ts_dev->dev; - int r; - - ts_info("Request firmware image [%s]", name); - r = request_firmware(&fw_data->firmware, name, dev); - if (r < 0) - ts_err("Firmware image [%s] not available,errno:%d", name, r); - else - ts_info("Firmware image [%s] is ready", name); - return r; -} - -/** - * release firmware resources - * - */ -static inline void goodix_release_firmware(struct firmware_data *fw_data) -{ - if (fw_data->firmware) { - release_firmware(fw_data->firmware); - fw_data->firmware = NULL; - } -} - -static int goodix_fw_update_thread(void *data) -{ - struct fw_update_ctrl *fwu_ctrl = data; - struct firmware *temp_firmware = NULL; - int r = -EINVAL; - - mutex_lock(&fwu_ctrl->mutex); - - if (fwu_ctrl->mode & UPDATE_MODE_SRC_HEAD) { - ts_info("Firmware header update starts"); - temp_firmware = kzalloc(sizeof(struct firmware), GFP_KERNEL); - if (!temp_firmware) { - ts_err("Failed to allocate memory for firmware"); - goto out; - } - temp_firmware->size = sizeof(goodix_default_fw); - temp_firmware->data = goodix_default_fw; - fwu_ctrl->fw_data.firmware = temp_firmware; - } else if (fwu_ctrl->mode & UPDATE_MODE_SRC_REQUEST) { - ts_info("Firmware request update starts"); - r = goodix_request_firmware(&fwu_ctrl->fw_data, - fwu_ctrl->fw_name); - if (r < 0) { - fwu_ctrl->status = UPSTA_ABORT; - fwu_ctrl->progress = 100; - goto out; - } - } else if (fwu_ctrl->mode & UPDATE_MODE_SRC_SYSFS) { - if (!fwu_ctrl->fw_data.firmware) { - ts_err("Invalid firmware from sysfs"); - fwu_ctrl->status = UPSTA_ABORT; - fwu_ctrl->progress = 100; - r = -EINVAL; - goto out; - } - } else { - ts_err("unknown update mode 0x%x", fwu_ctrl->mode); - r = -EINVAL; - goto out; - } - - goodix_register_ext_module(&goodix_fwu_module); - /* DONT allow reset/irq/suspend/resume during update */ - fwu_ctrl->allow_irq = false; - fwu_ctrl->allow_suspend = false; - fwu_ctrl->allow_resume = false; - fwu_ctrl->allow_reset = false; - ts_debug("notify update start"); - goodix_ts_blocking_notify(NOTIFY_FWUPDATE_START, NULL); - - /* ready to update */ - ts_debug("start update proc"); - r = goodix_fw_update_proc(fwu_ctrl); - - fwu_ctrl->allow_reset = true; - fwu_ctrl->allow_irq = true; - fwu_ctrl->allow_suspend = true; - fwu_ctrl->allow_resume = true; - - /* clean */ - if (fwu_ctrl->mode & UPDATE_MODE_SRC_HEAD) { - kfree(fwu_ctrl->fw_data.firmware); - fwu_ctrl->fw_data.firmware = NULL; - temp_firmware = NULL; - } else if (fwu_ctrl->mode & UPDATE_MODE_SRC_REQUEST) { - goodix_release_firmware(&fwu_ctrl->fw_data); - } else if (fwu_ctrl->mode & UPDATE_MODE_SRC_SYSFS) { - vfree(fwu_ctrl->fw_data.firmware); - fwu_ctrl->fw_data.firmware = NULL; - } - goodix_unregister_ext_module(&goodix_fwu_module); -out: - fwu_ctrl->mode = UPDATE_MODE_DEFAULT; - mutex_unlock(&fwu_ctrl->mutex); - - if (r) { - ts_err("fw update failed, %d", r); - goodix_ts_blocking_notify(NOTIFY_FWUPDATE_FAILED, NULL); - } else { - ts_info("fw update success"); - goodix_ts_blocking_notify(NOTIFY_FWUPDATE_SUCCESS, NULL); - } - return r; -} - -/* - * goodix_sysfs_update_en_store: start fw update manually - * @buf: '1'[001] update in blocking mode with fwdata from sysfs - * '2'[010] update in blocking mode with fwdata from request - * '5'[101] update in unblocking mode with fwdata from sysfs - * '6'[110] update in unblocking mode with fwdata from request - */ -static ssize_t goodix_sysfs_update_en_store(struct goodix_ext_module *module, - const char *buf, size_t count) -{ - int ret = 0; - int mode = 0; - struct fw_update_ctrl *fw_ctrl = module->priv_data; - - if (!buf || count <= 0) { - ts_err("invalid params"); - return -EINVAL; - } - if (!fw_ctrl || !fw_ctrl->initialized) { - ts_err("fw module uninit"); - return -EINVAL; - } - - ts_info("set update mode:0x%x", buf[0]); - if (buf[0] == '1') { - mode = UPDATE_MODE_FORCE | UPDATE_MODE_BLOCK | - UPDATE_MODE_SRC_SYSFS; - } else if (buf[0] == '2') { - mode = UPDATE_MODE_FORCE | UPDATE_MODE_BLOCK | - UPDATE_MODE_SRC_REQUEST; - } else if (buf[0] == '5') { - mode = UPDATE_MODE_FORCE | UPDATE_MODE_SRC_SYSFS; - } else if (buf[0] == '6') { - mode = UPDATE_MODE_FORCE | UPDATE_MODE_SRC_REQUEST; - } else { - ts_err("invalid update mode:0x%x", buf[0]); - return -EINVAL; - } - - ret = goodix_do_fw_update(mode); - if (!ret) { - ts_info("success start update work"); - return count; - } - ts_err("failed start fw update work"); - return -EINVAL; -} - -static ssize_t -goodix_sysfs_update_progress_show(struct goodix_ext_module *module, char *buf) -{ - struct fw_update_ctrl *fw_ctrl = module->priv_data; - return scnprintf(buf, PAGE_SIZE, "%d\n", fw_ctrl->progress); -} - -static ssize_t goodix_sysfs_update_result_show(struct goodix_ext_module *module, - char *buf) -{ - char *result = NULL; - struct fw_update_ctrl *fw_ctrl = module->priv_data; - - ts_info("result show"); - switch (fw_ctrl->status) { - case UPSTA_NOTWORK: - result = "notwork"; - break; - case UPSTA_PREPARING: - result = "preparing"; - break; - case UPSTA_UPDATING: - result = "upgrading"; - break; - case UPSTA_ABORT: - result = "abort"; - break; - case UPSTA_SUCCESS: - result = "success"; - break; - case UPSTA_FAILED: - result = "failed"; - break; - default: - break; - } - - return scnprintf(buf, PAGE_SIZE, "%s\n", result); -} - -static ssize_t -goodix_sysfs_update_fwversion_show(struct goodix_ext_module *module, char *buf) -{ - struct goodix_ts_version fw_ver; - struct fw_update_ctrl *fw_ctrl = module->priv_data; - int r = 0; - char str[5]; - - /* read version from chip */ - r = fw_ctrl->ts_dev->hw_ops->read_version(fw_ctrl->ts_dev, &fw_ver); - if (!r) { - memcpy(str, fw_ver.pid, 4); - str[4] = '\0'; - return scnprintf( - buf, PAGE_SIZE, - "PID:%s VID:%02x %02x %02x %02x SENSOR_ID:%d\n", str, - fw_ver.vid[0], fw_ver.vid[1], fw_ver.vid[2], - fw_ver.vid[3], fw_ver.sensor_id); - } - return 0; -} - -static ssize_t goodix_sysfs_fwsize_show(struct goodix_ext_module *module, - char *buf) -{ - struct fw_update_ctrl *fw_ctrl = module->priv_data; - int r = -EINVAL; - - if (fw_ctrl && fw_ctrl->fw_data.firmware) - r = snprintf(buf, PAGE_SIZE, "%zu\n", - fw_ctrl->fw_data.firmware->size); - return r; -} - -static ssize_t goodix_sysfs_fwsize_store(struct goodix_ext_module *module, - const char *buf, size_t count) -{ - struct fw_update_ctrl *fw_ctrl = module->priv_data; - struct firmware *fw; - u8 **data; - size_t size = 0; - - if (!fw_ctrl) - return -EINVAL; - - if (sscanf(buf, "%zu", &size) < 0 || !size) { - ts_err("Failed to get fwsize"); - return -EFAULT; - } - - /* use vmalloc to alloc huge memory */ - fw = vmalloc(sizeof(*fw) + size); - if (fw == NULL) { - ts_err("Failed to alloc memory,size:%zu", size + sizeof(*fw)); - return -ENOMEM; - } - mutex_lock(&fw_ctrl->mutex); - memset(fw, 0x00, sizeof(*fw) + size); - data = (u8 **)&fw->data; - *data = (u8 *)fw + sizeof(struct firmware); - fw->size = size; - fw_ctrl->fw_data.firmware = fw; - fw_ctrl->mode = UPDATE_MODE_SRC_SYSFS; - mutex_unlock(&fw_ctrl->mutex); - return count; -} - -static ssize_t goodix_sysfs_fwimage_store(struct file *file, - struct kobject *kobj, - struct bin_attribute *attr, char *buf, - loff_t pos, size_t count) -{ - struct fw_update_ctrl *fw_ctrl; - struct firmware_data *fw_data; - - fw_ctrl = container_of(attr, struct fw_update_ctrl, attr_fwimage); - fw_data = &fw_ctrl->fw_data; - - if (!fw_data->firmware) { - ts_err("Need set fw image size first"); - return -ENOMEM; - } - - if (fw_data->firmware->size == 0) { - ts_err("Invalid firmware size"); - return -EINVAL; - } - - if (pos + count > fw_data->firmware->size) - return -EFAULT; - mutex_lock(&fw_ctrl->mutex); - memcpy((u8 *)&fw_data->firmware->data[pos], buf, count); - mutex_unlock(&fw_ctrl->mutex); - return count; -} - -/* this interface has ben deprecated */ -static ssize_t goodix_sysfs_force_update_store(struct goodix_ext_module *module, - const char *buf, size_t count) -{ - return count; -} - -static struct goodix_ext_attribute goodix_fwu_attrs[] = { - __EXTMOD_ATTR(update_en, S_IWUGO, NULL, goodix_sysfs_update_en_store), - __EXTMOD_ATTR(progress, S_IRUGO, goodix_sysfs_update_progress_show, - NULL), - __EXTMOD_ATTR(result, S_IRUGO, goodix_sysfs_update_result_show, NULL), - __EXTMOD_ATTR(fwversion, S_IRUGO, goodix_sysfs_update_fwversion_show, - NULL), - __EXTMOD_ATTR(fwsize, S_IRUGO | S_IWUGO, goodix_sysfs_fwsize_show, - goodix_sysfs_fwsize_store), - __EXTMOD_ATTR(force_update, S_IWUGO, NULL, - goodix_sysfs_force_update_store), -}; - -static int goodix_fw_sysfs_init(struct goodix_ts_core *core_data, - struct goodix_ext_module *module) -{ - struct fw_update_ctrl *fw_ctrl = module->priv_data; - struct kobj_type *ktype; - int ret = 0, i; - - ktype = goodix_get_default_ktype(); - ret = kobject_init_and_add(&module->kobj, ktype, - &core_data->pdev->dev.kobj, "fwupdate"); - if (ret) { - ts_err("Create fwupdate sysfs node error!"); - goto exit_sysfs_init; - } - - ret = 0; - for (i = 0; i < ARRAY_SIZE(goodix_fwu_attrs) && !ret; i++) - ret = sysfs_create_file(&module->kobj, - &goodix_fwu_attrs[i].attr); - if (ret) { - ts_err("failed create fwu sysfs files"); - while (--i >= 0) - sysfs_remove_file(&module->kobj, - &goodix_fwu_attrs[i].attr); - - kobject_put(&module->kobj); - ret = -EINVAL; - goto exit_sysfs_init; - } - - fw_ctrl->attr_fwimage.attr.name = "fwimage"; - fw_ctrl->attr_fwimage.attr.mode = S_IRUGO | S_IWUGO; - fw_ctrl->attr_fwimage.size = 0; - fw_ctrl->attr_fwimage.write = goodix_sysfs_fwimage_store; - ret = sysfs_create_bin_file(&module->kobj, &fw_ctrl->attr_fwimage); - -exit_sysfs_init: - return ret; -} - -static void goodix_fw_sysfs_remove(struct goodix_ext_module *module) -{ - struct fw_update_ctrl *fw_ctrl = module->priv_data; - int i; - - sysfs_remove_bin_file(&module->kobj, &fw_ctrl->attr_fwimage); - - for (i = 0; i < ARRAY_SIZE(goodix_fwu_attrs); i++) - sysfs_remove_file(&module->kobj, &goodix_fwu_attrs[i].attr); - - kobject_put(&module->kobj); -} - -int goodix_do_fw_update(int mode) -{ - struct task_struct *fwu_thrd; - struct fw_update_ctrl *fwu_ctrl = &goodix_fw_update_ctrl; - int ret; - - if (!fwu_ctrl->initialized) { - ts_err("fw mode uninit"); - return -EINVAL; - } - - fwu_ctrl->mode = mode; - ts_debug("fw update mode 0x%x", mode); - if (fwu_ctrl->mode & UPDATE_MODE_BLOCK) { - ret = goodix_fw_update_thread(fwu_ctrl); - ts_info("fw update return %d", ret); - return ret; - } else { - /* create and run update thread */ - fwu_thrd = kthread_run(goodix_fw_update_thread, fwu_ctrl, - "goodix-fwu"); - if (IS_ERR_OR_NULL(fwu_thrd)) { - ts_err("Failed to create update thread:%ld", - PTR_ERR(fwu_thrd)); - return -EFAULT; - } - ts_info("success create fw update thread"); - return 0; - } -} - -static int goodix_fw_update_init(struct goodix_ts_core *core_data, - struct goodix_ext_module *module) -{ - int ret = 0; - struct goodix_ts_board_data *ts_bdata = board_data(core_data); - - if (goodix_fw_update_ctrl.initialized) { - ts_info("no need reinit"); - return ret; - } - - if (!core_data || !ts_bdata || !core_data->ts_dev) { - ts_err("core_data && ts_dev can't be null"); - return -ENODEV; - } - - mutex_lock(&goodix_fw_update_ctrl.mutex); - module->priv_data = &goodix_fw_update_ctrl; - - goodix_fw_update_ctrl.ts_dev = core_data->ts_dev; - goodix_fw_update_ctrl.allow_reset = true; - goodix_fw_update_ctrl.allow_irq = true; - goodix_fw_update_ctrl.allow_suspend = true; - goodix_fw_update_ctrl.allow_resume = true; - goodix_fw_update_ctrl.core_data = core_data; - goodix_fw_update_ctrl.mode = 0; - /* find a valid firmware image name */ - if (ts_bdata && ts_bdata->fw_name) - strlcpy(goodix_fw_update_ctrl.fw_name, ts_bdata->fw_name, - sizeof(goodix_fw_update_ctrl.fw_name)); - else - strlcpy(goodix_fw_update_ctrl.fw_name, TS_DEFAULT_FIRMWARE, - sizeof(goodix_fw_update_ctrl.fw_name)); - - ret = goodix_fw_sysfs_init(core_data, module); - if (ret) { - ts_err("failed create fwupate sysfs node"); - goto err_out; - } - - goodix_fw_update_ctrl.initialized = 1; -err_out: - mutex_unlock(&goodix_fw_update_ctrl.mutex); - return ret; -} - -static int goodix_fw_update_exit(struct goodix_ts_core *core_data, - struct goodix_ext_module *module) -{ - return 0; -} - -static int goodix_fw_before_suspend(struct goodix_ts_core *core_data, - struct goodix_ext_module *module) -{ - struct fw_update_ctrl *fwu_ctrl = module->priv_data; - - return fwu_ctrl->allow_suspend ? EVT_HANDLED : EVT_CANCEL_SUSPEND; -} - -static int goodix_fw_before_resume(struct goodix_ts_core *core_data, - struct goodix_ext_module *module) -{ - struct fw_update_ctrl *fwu_ctrl = module->priv_data; - - return fwu_ctrl->allow_resume ? EVT_HANDLED : EVT_CANCEL_RESUME; -} - -static int goodix_fw_after_resume(struct goodix_ts_core *core_data, - struct goodix_ext_module *module) -{ - return 0; -} - -static int goodix_fw_irq_event(struct goodix_ts_core *core_data, - struct goodix_ext_module *module) -{ - struct fw_update_ctrl *fwu_ctrl = module->priv_data; - - return fwu_ctrl->allow_irq ? EVT_HANDLED : EVT_CANCEL_IRQEVT; -} - -static int goodix_fw_before_reset(struct goodix_ts_core *core_data, - struct goodix_ext_module *module) -{ - struct fw_update_ctrl *fwu_ctrl = module->priv_data; - - return fwu_ctrl->allow_reset ? EVT_HANDLED : EVT_CANCEL_RESET; -} - -static const struct goodix_ext_module_funcs goodix_ext_funcs = { - .init = goodix_fw_update_init, - .exit = goodix_fw_update_exit, - .before_reset = goodix_fw_before_reset, - .after_reset = NULL, - .before_suspend = goodix_fw_before_suspend, - .after_suspend = NULL, - .before_resume = goodix_fw_before_resume, - .after_resume = goodix_fw_after_resume, - .irq_event = goodix_fw_irq_event, -}; - -static struct goodix_ext_module goodix_fwu_module = { - .name = "goodix-fwu", - .funcs = &goodix_ext_funcs, - .priority = EXTMOD_PRIO_FWUPDATE, -}; - -static int __init goodix_fwu_module_init(void) -{ - ts_info("goodix_fwupdate_module_ini IN"); - mutex_init(&goodix_fw_update_ctrl.mutex); - return goodix_register_ext_module(&goodix_fwu_module); -} - -static void __exit goodix_fwu_module_exit(void) -{ - mutex_lock(&goodix_fw_update_ctrl.mutex); - goodix_unregister_ext_module(&goodix_fwu_module); - if (goodix_fw_update_ctrl.initialized) { - goodix_fw_sysfs_remove(&goodix_fwu_module); - goodix_fw_update_ctrl.initialized = 0; - } - mutex_lock(&goodix_fw_update_ctrl.mutex); -} - -module_init(goodix_fwu_module_init); -module_exit(goodix_fwu_module_exit); - -MODULE_DESCRIPTION("Goodix FWU Module"); -MODULE_AUTHOR("Goodix, Inc."); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/input/touchscreen/gtx8/goodix_ts_core.c b/drivers/input/touchscreen/gtx8/goodix_ts_core.c index 6b867736e43ef8..dc87720cf5576e 100644 --- a/drivers/input/touchscreen/gtx8/goodix_ts_core.c +++ b/drivers/input/touchscreen/gtx8/goodix_ts_core.c @@ -63,7 +63,7 @@ static void __do_register_ext_module(struct work_struct *work) struct goodix_ext_module *ext_module, *next; struct list_head *insert_point = &goodix_modules.head; - ts_info("__do_register_ext_module IN"); + ts_debug("__do_register_ext_module IN"); if (core_module_prob_sate == CORE_MODULE_PROB_FAILED || core_module_prob_sate == CORE_MODULE_REMOVED) { @@ -86,7 +86,7 @@ static void __do_register_ext_module(struct work_struct *work) return; } - ts_info("start register ext_module"); + ts_debug("start register ext_module"); /* priority level *must* be set */ if (module->priority == EXTMOD_PRIO_RESERVED) { @@ -99,7 +99,7 @@ static void __do_register_ext_module(struct work_struct *work) list_for_each_entry_safe(ext_module, next, &goodix_modules.head, list) { if (ext_module == module) { - ts_info("Module [%s] already exists", + ts_debug("Module [%s] already exists", module->name); mutex_unlock(&goodix_modules.mutex); return; @@ -131,7 +131,7 @@ static void __do_register_ext_module(struct work_struct *work) goodix_modules.count++; mutex_unlock(&goodix_modules.mutex); - ts_info("Module [%s] registered,priority:%u", module->name, + ts_debug("Module [%s] registered,priority:%u", module->name, module->priority); } @@ -154,12 +154,12 @@ int goodix_register_ext_module(struct goodix_ext_module *module) init_completion(&goodix_modules.core_comp); } - ts_info("goodix_register_ext_module IN"); + ts_debug("goodix_register_ext_module IN"); INIT_WORK(&module->work, __do_register_ext_module); schedule_work(&module->work); - ts_info("goodix_register_ext_module OUT"); + ts_debug("goodix_register_ext_module OUT"); return 0; } @@ -213,7 +213,7 @@ int goodix_unregister_ext_module(struct goodix_ext_module *module) if (module->funcs && module->funcs->exit) module->funcs->exit(goodix_modules.core_data, module); - ts_info("Module [%s] unregistered", module->name ? module->name : " "); + ts_debug("Module [%s] unregistered", module->name ? module->name : " "); return 0; } EXPORT_SYMBOL_GPL(goodix_unregister_ext_module); @@ -242,7 +242,7 @@ static void goodix_remove_all_ext_modules(void) static void goodix_ext_sysfs_release(struct kobject *kobj) { - ts_info("Kobject released!"); + ts_debug("Kobject released!"); } #define to_ext_module(kobj) container_of(kobj, struct goodix_ext_module, kobj) @@ -548,7 +548,7 @@ static ssize_t goodix_ts_send_cfg_store(struct device *dev, GOODIX_DEFAULT_CFG_NAME, r); goto exit; } else - ts_info("cfg file [%s] is ready", GOODIX_DEFAULT_CFG_NAME); + ts_debug("cfg file [%s] is ready", GOODIX_DEFAULT_CFG_NAME); config = kzalloc(sizeof(*config), GFP_KERNEL); if (config == NULL) @@ -711,7 +711,7 @@ static ssize_t goodix_ts_reg_rw_store(struct device *dev, goto err_out; } rw_addr = (u16)result; - ts_info("rw addr is 0x%x\n", rw_addr); + ts_debug("rw addr is 0x%x\n", rw_addr); } /* get length */ @@ -725,7 +725,7 @@ static ssize_t goodix_ts_reg_rw_store(struct device *dev, goto err_out; } rw_len = (u32)result; - ts_info("rw length info is %d\n", rw_len); + ts_debug("rw length info is %d\n", rw_len); if (rw_len > sizeof(store_buf)) { ts_err("data len > %lu\n", sizeof(store_buf)); goto err_out; @@ -746,7 +746,7 @@ static ssize_t goodix_ts_reg_rw_store(struct device *dev, goto err_out; } store_buf[i] = (u8)result; - ts_info("get data[%d]=0x%x\n", i, store_buf[i]); + ts_debug("get data[%d]=0x%x\n", i, store_buf[i]); } } ret = ts_dev->hw_ops->write(ts_dev, rw_addr, store_buf, rw_len); @@ -756,7 +756,7 @@ static ssize_t goodix_ts_reg_rw_store(struct device *dev, goto err_out; } - ts_info("%s write to addr (%x) with data %*ph\n", "success", rw_addr, + ts_debug("%s write to addr (%x) with data %*ph\n", "success", rw_addr, rw_len, store_buf); return count; @@ -806,7 +806,7 @@ static ssize_t goodix_sysfs_config_write(struct file *file, int ret; if (pos != 0 || count > GOODIX_CFG_MAX_SIZE) { - ts_info("pos(%d) != 0, cfg size %zu", (int)pos, count); + ts_debug("pos(%d) != 0, cfg size %zu", (int)pos, count); return -EINVAL; } @@ -825,7 +825,7 @@ static ssize_t goodix_sysfs_config_write(struct file *file, count = -EINVAL; ts_err("send config failed %d", ret); } else { - ts_info("send config success"); + ts_debug("send config success"); } kfree(config); @@ -1077,7 +1077,7 @@ int goodix_ts_irq_setup(struct goodix_ts_core *core_data) else core_data->irq = ts_bdata->irq; - ts_info("IRQ:%u,flags:%d", core_data->irq, (int)ts_bdata->irq_flags); + ts_debug("IRQ:%u,flags:%d", core_data->irq, (int)ts_bdata->irq_flags); r = devm_request_threaded_irq(&core_data->pdev->dev, core_data->irq, NULL, goodix_ts_threadirq_func, ts_bdata->irq_flags | IRQF_ONESHOT, @@ -1125,7 +1125,7 @@ static int goodix_ts_power_init(struct goodix_ts_core *core_data) struct device *dev = NULL; int r = 0; - ts_info("Power init"); + ts_debug("Power init"); /* dev:i2c client device or spi slave device*/ dev = core_data->ts_dev->dev; ts_bdata = board_data(core_data); @@ -1140,7 +1140,7 @@ static int goodix_ts_power_init(struct goodix_ts_core *core_data) } core_data->avdd_load = ts_bdata->avdd_load; } else { - ts_info("Avdd name is NULL[skip]"); + ts_debug("Avdd name is NULL[skip]"); } return r; @@ -1156,7 +1156,7 @@ int goodix_ts_power_on(struct goodix_ts_core *core_data) struct goodix_ts_board_data *ts_bdata = board_data(core_data); int r; - ts_info("Device power on"); + ts_debug("Device power on"); if (core_data->power_on) return 0; @@ -1173,12 +1173,12 @@ int goodix_ts_power_on(struct goodix_ts_core *core_data) if (r < 0) ts_err("enable 3v3 fail!"); - ts_info("set regulator load SUCCESS"); + ts_debug("set regulator load SUCCESS"); } r = regulator_enable(core_data->avdd); if (!r) { - ts_info("regulator enable SUCCESS"); + ts_debug("regulator enable SUCCESS"); if (ts_bdata->power_on_delay_us) usleep_range(ts_bdata->power_on_delay_us, ts_bdata->power_on_delay_us); @@ -1201,14 +1201,14 @@ int goodix_ts_power_off(struct goodix_ts_core *core_data) struct goodix_ts_board_data *ts_bdata = board_data(core_data); int r; - ts_info("Device power off"); + ts_debug("Device power off"); if (!core_data->power_on) return 0; if (core_data->avdd) { r = regulator_disable(core_data->avdd); if (!r) { - ts_info("regulator disable SUCCESS"); + ts_debug("regulator disable SUCCESS"); if (ts_bdata->power_off_delay_us) usleep_range(ts_bdata->power_off_delay_us, ts_bdata->power_off_delay_us); @@ -1235,7 +1235,7 @@ static int goodix_ts_pinctrl_init(struct goodix_ts_core *core_data) /* get pinctrl handler from of node */ core_data->pinctrl = devm_pinctrl_get(core_data->ts_dev->dev); if (IS_ERR_OR_NULL(core_data->pinctrl)) { - ts_info("Failed to get pinctrl handler[need confirm]"); + ts_debug("Failed to get pinctrl handler[need confirm]"); core_data->pinctrl = NULL; return -EINVAL; } @@ -1286,7 +1286,7 @@ static int goodix_ts_gpio_setup(struct goodix_ts_core *core_data) struct goodix_ts_board_data *ts_bdata = board_data(core_data); int r = 0; - ts_info("GPIO setup,reset-gpio:%d, irq-gpio:%d", ts_bdata->reset_gpio, + ts_debug("GPIO setup,reset-gpio:%d, irq-gpio:%d", ts_bdata->reset_gpio, ts_bdata->irq_gpio); /* * after kenerl3.13, gpio_ api is deprecated, new @@ -1507,9 +1507,9 @@ static void goodix_ts_esd_on(struct goodix_ts_core *core) atomic_set(&ts_esd->esd_on, 1); if (!schedule_delayed_work(&ts_esd->esd_work, 2 * HZ)) { - ts_info("esd work already in workqueue"); + ts_debug("esd work already in workqueue"); } - ts_info("esd on"); + ts_debug("esd on"); } /** @@ -1522,7 +1522,7 @@ static void goodix_ts_esd_off(struct goodix_ts_core *core) atomic_set(&ts_esd->esd_on, 0); ret = cancel_delayed_work_sync(&ts_esd->esd_work); - ts_info("Esd off, esd work state %d", ret); + ts_debug("Esd off, esd work state %d", ret); } /** @@ -1570,7 +1570,7 @@ int goodix_ts_esd_init(struct goodix_ts_core *core) int r; if (!dev->hw_ops->check_hw || !dev->reg.esd) { - ts_info("missing key info for esd check"); + ts_debug("missing key info for esd check"); return 0; } @@ -1619,7 +1619,7 @@ static int goodix_ts_suspend(struct goodix_ts_core *core_data) struct goodix_ts_device *ts_dev = core_data->ts_dev; int r; - ts_info("Suspend start"); + ts_debug("Suspend start"); /* * notify suspend event, inform the esd protector @@ -1639,7 +1639,7 @@ static int goodix_ts_suspend(struct goodix_ts_core *core_data) ext_module); if (r == EVT_CANCEL_SUSPEND) { mutex_unlock(&goodix_modules.mutex); - ts_info("Canceled by module:%s", + ts_debug("Canceled by module:%s", ext_module->name); goto out; } @@ -1676,7 +1676,7 @@ static int goodix_ts_suspend(struct goodix_ts_core *core_data) ext_module); if (r == EVT_CANCEL_SUSPEND) { mutex_unlock(&goodix_modules.mutex); - ts_info("Canceled by module:%s", + ts_debug("Canceled by module:%s", ext_module->name); goto out; } @@ -1685,7 +1685,7 @@ static int goodix_ts_suspend(struct goodix_ts_core *core_data) mutex_unlock(&goodix_modules.mutex); out: - ts_info("Suspend end"); + ts_debug("Suspend end"); return 0; } @@ -1699,7 +1699,7 @@ static int goodix_ts_resume(struct goodix_ts_core *core_data) struct goodix_ts_device *ts_dev = core_data->ts_dev; int r; - ts_info("Resume start"); + ts_debug("Resume start"); goodix_ts_release_connects(core_data); mutex_lock(&goodix_modules.mutex); @@ -1713,7 +1713,7 @@ static int goodix_ts_resume(struct goodix_ts_core *core_data) ext_module); if (r == EVT_CANCEL_RESUME) { mutex_unlock(&goodix_modules.mutex); - ts_info("Canceled by module:%s", + ts_debug("Canceled by module:%s", ext_module->name); goto out; } @@ -1746,7 +1746,7 @@ static int goodix_ts_resume(struct goodix_ts_core *core_data) ext_module); if (r == EVT_CANCEL_RESUME) { mutex_unlock(&goodix_modules.mutex); - ts_info("Canceled by module:%s", + ts_debug("Canceled by module:%s", ext_module->name); goto out; } @@ -1760,7 +1760,7 @@ static int goodix_ts_resume(struct goodix_ts_core *core_data) * notify resume event, inform the esd protector * and charger detector to turn on the work */ - ts_info("try notify resume"); + ts_debug("try notify resume"); goodix_ts_blocking_notify(NOTIFY_RESUME, NULL); out: ts_debug("Resume end"); @@ -1856,13 +1856,13 @@ static int goodix_generic_noti_callback(struct notifier_block *self, const struct goodix_ts_hw_ops *hw_ops = ts_hw_ops(ts_core); int r; - ts_info("notify event type 0x%x", (unsigned int)action); + ts_debug("notify event type 0x%x", (unsigned int)action); switch (action) { case NOTIFY_FWUPDATE_SUCCESS: case NOTIFY_FWUPDATE_FAILED: r = hw_ops->read_version(ts_dev, &ts_dev->chip_version); if (r < 0) - ts_info("failed read fw version info[ignore]"); + ts_debug("failed read fw version info[ignore]"); break; default: break; @@ -1879,12 +1879,12 @@ int goodix_ts_stage2_init(struct goodix_ts_core *core_data) /* send normal-cfg to firmware */ r = ts_dev->hw_ops->send_config(ts_dev, &(ts_dev->normal_cfg)); if (r < 0) { - ts_info("failed send normal config[ignore]"); + ts_debug("failed send normal config[ignore]"); } r = ts_dev->hw_ops->read_version(ts_dev, &ts_dev->chip_version); if (r < 0) - ts_info("failed read fw version info[ignore]"); + ts_debug("failed read fw version info[ignore]"); /* alloc/config/register input device */ r = goodix_ts_input_dev_config(core_data); @@ -1903,10 +1903,10 @@ int goodix_ts_stage2_init(struct goodix_ts_core *core_data) /* request irq line */ r = goodix_ts_irq_setup(core_data); if (r < 0) { - ts_info("failed set irq"); + ts_debug("failed set irq"); goto exit; } - ts_info("success register irq"); + ts_debug("success register irq"); #ifdef CONFIG_FB core_data->fb_notifier.notifier_call = goodix_ts_fb_notifier_callback; @@ -1943,7 +1943,7 @@ static int goodix_ts_probe(struct platform_device *pdev) struct goodix_ts_device *ts_device; int r; - ts_info("goodix_ts_probe IN"); + ts_debug("goodix_ts_probe IN"); ts_device = pdev->dev.platform_data; if (!ts_device || !ts_device->hw_ops) { @@ -1998,7 +1998,7 @@ static int goodix_ts_probe(struct platform_device *pdev) /* Try start a thread to get config-bin info */ r = goodix_start_later_init(core_data); if (r) { - ts_info("Failed start cfg_bin_proc"); + ts_debug("Failed start cfg_bin_proc"); goto out; } @@ -2068,10 +2068,10 @@ static struct platform_driver goodix_ts_driver = { int goodix_ts_core_init(void) { - ts_info("Core layer init"); + ts_debug("Core layer init"); if (!goodix_modules.initialized) { /* this may init by outer modules register event */ - ts_info("init modules struct"); + ts_debug("init modules struct"); goodix_modules.initialized = true; INIT_LIST_HEAD(&goodix_modules.head); mutex_init(&goodix_modules.mutex); @@ -2085,7 +2085,7 @@ int goodix_ts_core_init(void) /* uninit module manually */ int goodix_ts_core_release(struct goodix_ts_core *core_data) { - ts_info("goodix core module removed"); + ts_debug("goodix core module removed"); platform_driver_unregister(&goodix_ts_driver); goodix_ts_dev_release(); diff --git a/drivers/input/touchscreen/gtx8/goodix_ts_gesture.c b/drivers/input/touchscreen/gtx8/goodix_ts_gesture.c index 4c8e291df12f9c..9030891338f6ea 100644 --- a/drivers/input/touchscreen/gtx8/goodix_ts_gesture.c +++ b/drivers/input/touchscreen/gtx8/goodix_ts_gesture.c @@ -71,7 +71,7 @@ static ssize_t gsx_gesture_type_show(struct goodix_ext_module *module, unsigned char *type; if (atomic_read(&gsx_gesture->registered) != 1) { - ts_info("Gesture module not register!"); + ts_debug("Gesture module not register!"); return -EPERM; } type = kzalloc(256, GFP_KERNEL); @@ -134,7 +134,7 @@ static ssize_t gsx_gesture_enable_store(struct goodix_ext_module *module, int ret; if (sscanf(buf, "%u", &tmp) != 1) { - ts_info("Parameter illegal"); + ts_debug("Parameter illegal"); return -EINVAL; } ts_debug("Tmp value =%d", tmp); @@ -146,7 +146,7 @@ static ssize_t gsx_gesture_enable_store(struct goodix_ext_module *module, } ret = goodix_register_ext_module(&gsx_gesture->module); if (!ret) { - ts_info("Gesture module registered!"); + ts_debug("Gesture module registered!"); atomic_set(&gsx_gesture->registered, 1); } else { atomic_set(&gsx_gesture->registered, 0); @@ -161,10 +161,10 @@ static ssize_t gsx_gesture_enable_store(struct goodix_ext_module *module, ret = goodix_unregister_ext_module(&gsx_gesture->module); if (!ret) { atomic_set(&gsx_gesture->registered, 0); - ts_info("Gesture module unregistered success"); + ts_debug("Gesture module unregistered success"); } else { atomic_set(&gsx_gesture->registered, 1); - ts_info("Gesture module unregistered failed"); + ts_debug("Gesture module unregistered failed"); } } else { ts_err("Parameter error!"); @@ -179,11 +179,11 @@ static ssize_t gsx_gesture_data_show(struct goodix_ext_module *module, ssize_t count; if (atomic_read(&gsx_gesture->registered) != 1) { - ts_info("Gesture module not register!"); + ts_debug("Gesture module not register!"); return -EPERM; } if (!buf) { - ts_info("Parameter error!"); + ts_debug("Parameter error!"); return -EPERM; } read_lock(&gsx_gesture->rwlock); @@ -336,7 +336,7 @@ static int gsx_gesture_ist(struct goodix_ts_core *core_data, checksum = checksum_u8(temp_data, key_data_len); if (checksum) { ts_err("Gesture data checksum error:0x%x", checksum); - ts_info("Gesture data %*ph", (int)sizeof(temp_data), temp_data); + ts_debug("Gesture data %*ph", (int)sizeof(temp_data), temp_data); goto re_send_ges_cmd; } @@ -355,19 +355,19 @@ static int gsx_gesture_ist(struct goodix_ts_core *core_data, if (QUERYBIT(gsx_gesture->gesture_type, gsx_type)) { /* do resume routine */ - ts_info("Gesture match success, resume IC"); + ts_debug("Gesture match success, resume IC"); input_report_key(core_data->input_dev, KEY_POWER, 1); input_sync(core_data->input_dev); input_report_key(core_data->input_dev, KEY_POWER, 0); input_sync(core_data->input_dev); goto gesture_ist_exit; } else { - ts_info("Unsupported gesture:%x", temp_data[2]); + ts_debug("Unsupported gesture:%x", temp_data[2]); } re_send_ges_cmd: if (gsx_enter_gesture_mode(core_data->ts_dev)) - ts_info("warning: failed re_send gesture cmd\n"); + ts_debug("warning: failed re_send gesture cmd\n"); gesture_ist_exit: ts_dev->hw_ops->write_trans(ts_dev, ts_dev->reg.gesture, &clear_reg, 1); return EVT_CANCEL_IRQEVT; @@ -398,7 +398,7 @@ static int gsx_gesture_before_suspend(struct goodix_ts_core *core_data, if (ret != 0) ts_err("failed enter gesture mode"); else - ts_info("Set IC in gesture mode"); + ts_debug("Set IC in gesture mode"); return EVT_CANCEL_SUSPEND; } @@ -414,7 +414,7 @@ static int __init goodix_gsx_gesture_init(void) { /* initialize core_data->ts_dev->gesture_cmd */ int result; - ts_info("gesture module init"); + ts_debug("gesture module init"); gsx_gesture = kzalloc(sizeof(struct gesture_module), GFP_KERNEL); if (!gsx_gesture) result = -ENOMEM; @@ -435,7 +435,7 @@ static int __init goodix_gsx_gesture_init(void) static void __exit goodix_gsx_gesture_exit(void) { int i, ret; - ts_info("gesture module exit"); + ts_debug("gesture module exit"); if (atomic_read(&gsx_gesture->registered)) { ret = goodix_unregister_ext_module(&gsx_gesture->module); atomic_set(&gsx_gesture->registered, 0); diff --git a/drivers/input/touchscreen/gtx8/goodix_ts_i2c.c b/drivers/input/touchscreen/gtx8/goodix_ts_i2c.c index 84529f5b76b86f..88c2ff07012660 100644 --- a/drivers/input/touchscreen/gtx8/goodix_ts_i2c.c +++ b/drivers/input/touchscreen/gtx8/goodix_ts_i2c.c @@ -148,7 +148,7 @@ static int goodix_parse_dt(struct device_node *node, ts_err("invalid reset-gpio in dt: %d", r); return -EINVAL; } - ts_info("get reset-gpio[%d] from dt", r); + ts_debug("get reset-gpio[%d] from dt", r); board_data->reset_gpio = r; r = of_get_named_gpio(node, "goodix,irq-gpio", 0); @@ -156,7 +156,7 @@ static int goodix_parse_dt(struct device_node *node, ts_err("invalid irq-gpio in dt: %d", r); return -EINVAL; } - ts_info("get irq-gpio[%d] from dt", r); + ts_debug("get irq-gpio[%d] from dt", r); board_data->irq_gpio = r; r = of_property_read_u32(node, "goodix,irq-flags", @@ -169,12 +169,12 @@ static int goodix_parse_dt(struct device_node *node, memset(board_data->avdd_name, 0, sizeof(board_data->avdd_name)); r = of_property_read_string(node, "goodix,avdd-name", &name_tmp); if (!r) { - ts_info("avdd name form dt: %s", name_tmp); + ts_debug("avdd name from dt: %s", name_tmp); if (strlen(name_tmp) < sizeof(board_data->avdd_name)) strncpy(board_data->avdd_name, name_tmp, sizeof(board_data->avdd_name)); else - ts_info("invalid avdd name length: %ld > %ld", + ts_debug("invalid avdd name length: %ld > %ld", strlen(name_tmp), sizeof(board_data->avdd_name)); } @@ -235,9 +235,9 @@ static int goodix_parse_dt(struct device_node *node, board_data->pen_enable = of_property_read_bool(node, "goodix,pen-enable"); if (board_data->pen_enable) - ts_info("goodix pen enabled"); + ts_debug("goodix pen enabled"); - ts_info("***key:%d, %d, %d, %d", board_data->panel_key_map[0], + ts_debug("***key:%d, %d, %d, %d", board_data->panel_key_map[0], board_data->panel_key_map[1], board_data->panel_key_map[2], board_data->panel_key_map[3]); @@ -356,7 +356,7 @@ int goodix_i2c_read_trans(struct goodix_ts_device *dev, unsigned int reg, address += transfer_length; break; } - ts_info("I2c read retry[%d]:0x%x", retry + 1, reg); + ts_debug("I2c read retry[%d]:0x%x", retry + 1, reg); msleep(20); } if (unlikely(retry == GOODIX_BUS_RETRY_TIMES)) { @@ -485,7 +485,7 @@ static int goodix_set_i2c_doze_mode(struct goodix_ts_device *dev, int enable) if (i >= TS_DOZE_ENABLE_RETRY_TIMES) ts_err("i2c doze mode enable failed"); } else { - /*ts_info("doze count not euqal 0, + /*ts_debug("doze count not euqal 0, * so skip doze mode enable"); */ result = 0; @@ -802,7 +802,7 @@ static int goodix_read_version(struct goodix_ts_device *dev, } if (sensor_id_mask != 0) { version->sensor_id = buffer[0] & sensor_id_mask; - ts_info("sensor_id_mask:0x%02x, sensor_id:0x%02x", + ts_debug("sensor_id_mask:0x%02x, sensor_id:0x%02x", sensor_id_mask, version->sensor_id); } else { version->sensor_id = buffer[0]; @@ -810,7 +810,7 @@ static int goodix_read_version(struct goodix_ts_device *dev, version->valid = true; - ts_info("PID:%s,SensorID:%d, VID:%*ph", version->pid, + ts_debug("PID:%s,SensorID:%d, VID:%*ph", version->pid, version->sensor_id, (int)sizeof(version->vid), version->vid); exit: /*enable doze mode, just valid for normandy @@ -922,7 +922,7 @@ static int _do_goodix_send_config(struct goodix_ts_device *dev, break; usleep_range(10000, 11000); } - ts_info("send config result: %*ph", 3, buf); + ts_debug("send config result: %*ph", 3, buf); /* set 0x7D to end send config process */ goodix_cmd_init(dev, &ts_cmd, COMMAND_END_SEND_CFG_YS, 0, dev->reg.command); @@ -941,7 +941,7 @@ static int _do_goodix_send_config(struct goodix_ts_device *dev, if (buf[2] != TS_CFG_REPLY_DATA_EQU) ts_err("failed send cfg"); else - ts_info("config data equal with flash"); + ts_debug("config data equal with flash"); r = -EINVAL; goto exit; } @@ -962,7 +962,7 @@ static int _do_goodix_send_config(struct goodix_ts_device *dev, } } - ts_info("Send cfg SUCCESS"); + ts_debug("Send cfg SUCCESS"); r = 0; exit: @@ -996,7 +996,7 @@ static int _do_goodix_send_config(struct goodix_ts_device *dev, bag_num = cfg[TS_CFG_BAG_NUM_INDEX]; bag_start = TS_CFG_BAG_START_INDEX; - ts_info("cfg bag_num:%d, cfg length:%d", bag_num, length); + ts_debug("cfg bag_num:%d, cfg length:%d", bag_num, length); for (j = 0; j < bag_num; j++) { if (bag_start >= length - 1) { ts_err("ERROR, overflow!!bag_start:%d, cfg_len:%d", @@ -1027,7 +1027,7 @@ static int _do_goodix_send_config(struct goodix_ts_device *dev, } ret = 0; - ts_info("configuration check SUCCESS"); + ts_debug("configuration check SUCCESS"); exit: return ret; @@ -1051,7 +1051,7 @@ static int goodix_send_config(struct goodix_ts_device *dev, // return -EINVAL; // } - ts_info("ver:%02xh,size:%d", config->data[0], config->length); + ts_debug("ver:%02xh,size:%d", config->data[0], config->length); mutex_lock(&config->lock); /*disable doze mode*/ @@ -1093,7 +1093,7 @@ static int goodix_read_config_ys(struct goodix_ts_device *dev, u8 *buf) goto err_out; } - ts_info("config_version:%u, vub_bags:%u", buf[0], sub_bags); + ts_debug("config_version:%u, vub_bags:%u", buf[0], sub_bags); for (i = 0; i < sub_bags; i++) { /* read sub head [0]: sub bag num, [1]: sub bag length */ ret = goodix_i2c_read(dev, cfg_addr + offset, buf + offset, 2); @@ -1157,7 +1157,7 @@ static int goodix_read_config_nor(struct goodix_ts_device *dev, u8 *buf) goto err_out; } - ts_info("config_version:%u, vub_bags:%u", buf[0], sub_bags); + ts_debug("config_version:%u, vub_bags:%u", buf[0], sub_bags); for (i = 0; i < sub_bags; i++) { /* read sub head [0]: sub bag num, [1]: sub bag length */ ret = goodix_i2c_read(dev, cfg_addr + offset, buf + offset, 2); @@ -1275,7 +1275,7 @@ int goodix_hw_reset(struct goodix_ts_device *dev) u8 data[2] = { 0x00 }; int r = 0; - ts_info("HW reset"); + ts_debug("HW reset"); gpio_direction_output(dev->board_data.reset_gpio, 0); udelay(2000); @@ -1288,7 +1288,7 @@ int goodix_hw_reset(struct goodix_ts_device *dev) if (r < 0) ts_err("IC reset, init dynamic esd FAILED"); } else { - ts_info("reg.esd is NULL, skip dynamic esd init"); + ts_debug("reg.esd is NULL, skip dynamic esd init"); } return 0; @@ -1312,30 +1312,30 @@ static int goodix_request_handler(struct goodix_ts_device *dev) switch (buffer[0]) { case REQUEST_CONFIG: - ts_info("HW request config"); + ts_debug("HW request config"); r = goodix_send_config(dev, &(dev->normal_cfg)); if (r != 0) - ts_info("request config, send config failed"); + ts_debug("request config, send config failed"); break; case REQUEST_BAKREF: - ts_info("HW request bakref"); + ts_debug("HW request bakref"); break; case REQUEST_RESET: - ts_info("HW requset reset"); + ts_debug("HW requset reset"); r = goodix_hw_reset(dev); if (r != 0) - ts_info("request reset, reset failed"); + ts_debug("request reset, reset failed"); break; case REQUEST_RELOADFW: - ts_info("HW request reload fw"); + ts_debug("HW request reload fw"); goodix_do_fw_update(UPDATE_MODE_FORCE | UPDATE_MODE_SRC_REQUEST); break; case REQUEST_IDLE: - ts_info("HW request idle"); + ts_debug("HW request idle"); break; default: - ts_info("Unknown hw request:%d", buffer[0]); + ts_debug("Unknown hw request:%d", buffer[0]); break; } @@ -1378,7 +1378,7 @@ static void goodix_parse_finger_nor(struct goodix_ts_device *dev, for (i = 0; i < touch_num; i++) { id = coor_data[0]; if (id >= GOODIX_MAX_TOUCH) { - ts_info("invalid finger id =%d", id); + ts_debug("invalid finger id =%d", id); break; } x = le16_to_cpup((__be16 *)(coor_data + 1)); @@ -1438,7 +1438,7 @@ static void goodix_parse_finger_ys(struct goodix_ts_device *dev, for (i = 0; i < touch_num; i++) { id = (coor_data[0] >> 4) & 0x0F; if (id >= GOODIX_MAX_TOUCH) { - ts_info("invalid finger id =%d", id); + ts_debug("invalid finger id =%d", id); break; } x = be16_to_cpup((__be16 *)(coor_data + 2)); @@ -1525,7 +1525,7 @@ static void goodix_parse_pen_ys(struct goodix_ts_device *dev, struct goodix_pen_data *pen_data, unsigned char *buf, int touch_num) { - ts_info("unsupported"); + ts_debug("unsupported"); } static int goodix_touch_handler_ys(struct goodix_ts_device *dev, @@ -1741,7 +1741,7 @@ static int goodix_hw_suspend(struct goodix_ts_device *dev) if (sleep_cmd.initialized) { r = goodix_send_command(dev, &sleep_cmd); if (!r) - ts_info("Chip in sleep mode"); + ts_debug("Chip in sleep mode"); } else { ts_err("Uninitialized sleep command"); } @@ -1774,7 +1774,7 @@ static int goodix_esd_check(struct goodix_ts_device *dev) r = dev->hw_ops->read_trans(dev, TS_REG_ESD_TICK_R, &data, 1); if (r < 0 || (data == GOODIX_ESD_TICK_WRITE_DATA)) { - ts_info("dynamic esd occur, r:%d, data:0x%02x", r, data); + ts_debug("dynamic esd occur, r:%d, data:0x%02x", r, data); r = -EINVAL; goto exit; } @@ -1805,7 +1805,7 @@ static struct platform_device *goodix_pdev; static void goodix_pdev_release(struct device *dev) { - ts_info("goodix pdev released"); + ts_debug("goodix pdev released"); } static int goodix_i2c_probe(struct i2c_client *client) @@ -1813,7 +1813,7 @@ static int goodix_i2c_probe(struct i2c_client *client) struct goodix_ts_device *ts_device = NULL; int r = 0; - ts_info("goodix_i2c_probe IN"); + ts_debug("goodix_i2c_probe IN"); r = i2c_check_functionality(client->adapter, I2C_FUNC_I2C); if (!r) @@ -1830,7 +1830,7 @@ static int goodix_i2c_probe(struct i2c_client *client) r = goodix_parse_dt(client->dev.of_node, &ts_device->board_data); if (r < 0) { - ts_err("failed parse device info form dts, %d", r); + ts_err("failed parse device info from dts, %d", r); return -EINVAL; } } else { @@ -1871,7 +1871,7 @@ static int goodix_i2c_probe(struct i2c_client *client) ts_err("failed register platform driver, %d", r); goto err_pdriver; } - ts_info("i2c probe out"); + ts_debug("i2c probe out"); return r; err_pdriver: @@ -1879,7 +1879,7 @@ static int goodix_i2c_probe(struct i2c_client *client) err_pdev: kfree(goodix_pdev); goodix_pdev = NULL; - ts_info("i2c probe out, %d", r); + ts_debug("i2c probe out, %d", r); return r; } @@ -1941,14 +1941,14 @@ void goodix_ts_dev_release(void) static int __init goodix_i2c_init(void) { - ts_info("Goodix driver init"); + ts_debug("Goodix driver init"); return i2c_add_driver(&goodix_i2c_driver); } static void __exit goodix_i2c_exit(void) { i2c_del_driver(&goodix_i2c_driver); - ts_info("Goodix driver exit"); + ts_debug("Goodix driver exit"); } module_init(goodix_i2c_init); diff --git a/drivers/input/touchscreen/gtx8/goodix_ts_tools.c b/drivers/input/touchscreen/gtx8/goodix_ts_tools.c index 960944778283f7..f67a76c1ffb999 100644 --- a/drivers/input/touchscreen/gtx8/goodix_ts_tools.c +++ b/drivers/input/touchscreen/gtx8/goodix_ts_tools.c @@ -148,7 +148,7 @@ static int read_config_data(struct goodix_ts_device *ts_dev, void __user *arg) (i2c_msg_head[2] << 16) + (i2c_msg_head[3] << 24); length = i2c_msg_head[4] + (i2c_msg_head[5] << 8) + (i2c_msg_head[6] << 16) + (i2c_msg_head[7] << 24); - ts_info("read config,reg_addr=0x%x, length=%d", reg_addr, length); + ts_debug("read config,reg_addr=0x%x, length=%d", reg_addr, length); tmp_buf = kzalloc(length, GFP_KERNEL); if (!tmp_buf) { ts_err("failed alloc memory"); @@ -355,15 +355,15 @@ static long goodix_tools_ioctl(struct file *file, unsigned int cmd, mutex_lock(&dev->mutex); dev->ops_mode |= IRQ_FALG; mutex_unlock(&dev->mutex); - ts_info("IRQ enabled"); + ts_debug("IRQ enabled"); } else if (arg == 0) { goodix_ts_irq_enable(dev->ts_core, false); mutex_lock(&dev->mutex); dev->ops_mode &= ~IRQ_FALG; mutex_unlock(&dev->mutex); - ts_info("IRQ disabled"); + ts_debug("IRQ disabled"); } else { - ts_info("Irq already set with, arg = %ld", arg); + ts_debug("Irq already set with, arg = %ld", arg); } ret = 0; break; @@ -406,7 +406,7 @@ static long goodix_tools_ioctl(struct file *file, unsigned int cmd, ts_err("Failed send config"); ret = -EAGAIN; } else { - ts_info("Send config success"); + ts_debug("Send config success"); ret = 0; } } @@ -414,7 +414,7 @@ static long goodix_tools_ioctl(struct file *file, unsigned int cmd, case GTP_READ_CONFIG: ret = read_config_data(ts_dev, (void __user *)arg); if (ret > 0) - ts_info("success read config:len=%d", ret); + ts_debug("success read config:len=%d", ret); else ts_err("failed read config:ret=0x%x", ret); break; @@ -445,7 +445,7 @@ static long goodix_tools_ioctl(struct file *file, unsigned int cmd, ts_err("failed copy driver version info to user"); break; default: - ts_info("Invalid cmd"); + ts_debug("Invalid cmd"); ret = -ENOTTY; break; } @@ -475,11 +475,11 @@ static int goodix_tools_open(struct inode *inode, struct file *file) int ret = 0; file->private_data = goodix_tools_dev; - ts_info("tools open"); + ts_debug("tools open"); /* Only the first time open device need to register module */ ret = goodix_register_ext_module(&goodix_tools_dev->module); if (ret) { - ts_info("failed register to core module"); + ts_debug("failed register to core module"); } return ret; @@ -607,7 +607,7 @@ static void __exit goodix_tools_exit(void) { misc_deregister(&goodix_tools_miscdev); kfree(goodix_tools_dev); - ts_info("Goodix tools miscdev exit"); + ts_debug("Goodix tools miscdev exit"); } module_init(goodix_tools_init);