mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-13 16:16:15 -04:00
Ocean: DLKM: Improve ili9881h touch driver
- Add retry times for unexpected communication errors. - Change suspend & resume flow for current drain issue. - Fixed the communication errors when accessing node. Change-Id: I61db5696637082dd6d576b486b45172c5426a256 Signed-off-by: wengjun1 <wengjun1@motorola.com> Reviewed-on: https://gerrit.mot.com/1236756 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Hujun Liao <liaohj@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
d28d818543
commit
fbf658b188
6 changed files with 69 additions and 38 deletions
|
|
@ -243,7 +243,7 @@ enum ili9881_types {
|
|||
/* #define BATTERY_CHECK */
|
||||
|
||||
/*suspend TP power off*/
|
||||
#define SUSPEND_TP_POWER_OFF
|
||||
//#define SUSPEND_TP_POWER_OFF
|
||||
|
||||
static inline void ipio_kfree(void **mem)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -472,15 +472,6 @@ void core_config_ic_resume(void)
|
|||
mdelay(10);
|
||||
core_config_ic_reset();
|
||||
}
|
||||
/* sleep out */
|
||||
core_config_sleep_ctrl(true);
|
||||
|
||||
/* check system busy */
|
||||
if (core_config_check_cdc_busy(50, 10) < 0)
|
||||
ipio_err("Check busy is timout !\n");
|
||||
|
||||
/* sense start for TP */
|
||||
core_config_sense_ctrl(true);
|
||||
|
||||
core_fr_mode_control(&protocol->demo_mode);
|
||||
|
||||
|
|
|
|||
|
|
@ -226,9 +226,10 @@ static int parse_touch_package_v5_0(uint8_t pid)
|
|||
uint8_t check_sum = 0;
|
||||
uint32_t nX = 0, nY = 0;
|
||||
|
||||
for (i = 0 ; i < 9; i++)
|
||||
ipio_debug(DEBUG_FINGER_REPORT, "data[%d] = %x\n", i, g_fr_node->data[i]);
|
||||
|
||||
if(ipio_debug_level > 0)
|
||||
{
|
||||
dump_data(g_fr_node->data, 8, g_fr_node->len, 0, "touch report");
|
||||
}
|
||||
check_sum = core_fr_calc_checksum(&g_fr_node->data[0], (g_fr_node->len - 1));
|
||||
ipio_debug(DEBUG_FINGER_REPORT, "data = %x ; check_sum : %x\n", g_fr_node->data[g_fr_node->len - 1], check_sum);
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@
|
|||
|
||||
struct core_i2c_data *core_i2c;
|
||||
|
||||
#define I2C_RETRY_TIMES 3
|
||||
|
||||
#ifdef I2C_DMA
|
||||
static unsigned char *ilitek_dma_va;
|
||||
static dma_addr_t ilitek_dma_pa;
|
||||
|
|
@ -78,6 +80,7 @@ int core_i2c_write(uint8_t nSlaveId, uint8_t *pBuf, uint16_t nSize)
|
|||
int res = 0;
|
||||
uint8_t check_sum = 0;
|
||||
uint8_t *txbuf = NULL;
|
||||
int retry = 0;
|
||||
|
||||
struct i2c_msg msgs[] = {
|
||||
{
|
||||
|
|
@ -118,18 +121,25 @@ int core_i2c_write(uint8_t nSlaveId, uint8_t *pBuf, uint16_t nSize)
|
|||
msgs[0].len = nSize + 1;
|
||||
}
|
||||
}
|
||||
for (retry = 1; retry <= 3; retry++) {
|
||||
if (i2c_transfer(core_i2c->client->adapter, msgs, 1) < 0) {
|
||||
if (core_config->do_ic_reset) {
|
||||
/* ignore i2c error if doing ic reset */
|
||||
res = 0;
|
||||
} else {
|
||||
res = -EIO;
|
||||
ipio_err("I2C Write Error, res = %d retry = %d\n", res, retry);
|
||||
mdelay(20);
|
||||
if (retry == I2C_RETRY_TIMES)
|
||||
goto out;
|
||||
|
||||
if (i2c_transfer(core_i2c->client->adapter, msgs, 1) < 0) {
|
||||
if (core_config->do_ic_reset) {
|
||||
/* ignore i2c error if doing ic reset */
|
||||
}
|
||||
}
|
||||
else {
|
||||
res = 0;
|
||||
} else {
|
||||
res = -EIO;
|
||||
ipio_err("I2C Write Error, res = %d\n", res);
|
||||
goto out;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
ipio_kfree((void **)&txbuf);
|
||||
return res;
|
||||
|
|
@ -139,6 +149,7 @@ EXPORT_SYMBOL(core_i2c_write);
|
|||
int core_i2c_read(uint8_t nSlaveId, uint8_t *pBuf, uint16_t nSize)
|
||||
{
|
||||
int res = 0;
|
||||
int retry = 0;
|
||||
|
||||
struct i2c_msg msgs[] = {
|
||||
{
|
||||
|
|
@ -160,11 +171,18 @@ int core_i2c_read(uint8_t nSlaveId, uint8_t *pBuf, uint16_t nSize)
|
|||
msgs[0].buf = pBuf;
|
||||
}
|
||||
#endif /* I2C_DMA */
|
||||
|
||||
if (i2c_transfer(core_i2c->client->adapter, msgs, 1) < 0) {
|
||||
res = -EIO;
|
||||
ipio_err("I2C Read Error, res = %d\n", res);
|
||||
goto out;
|
||||
for (retry = 1; retry <= I2C_RETRY_TIMES; retry++) {
|
||||
if (i2c_transfer(core_i2c->client->adapter, msgs, 1) < 0) {
|
||||
res = -EIO;
|
||||
ipio_err("I2C Read Error, res = %d retry = %d\n", res, retry);
|
||||
mdelay(20);
|
||||
if (retry == I2C_RETRY_TIMES)
|
||||
goto out;
|
||||
}
|
||||
else {
|
||||
res = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef I2C_DMA
|
||||
if (nSize > 8)
|
||||
|
|
|
|||
|
|
@ -344,8 +344,16 @@ void core_protocol_func_control(int key, int ctrl)
|
|||
ipio_info("Found func's name: %s, key = %d\n", tmp->name, key);
|
||||
|
||||
/* last element is used to control this func */
|
||||
if (tmp->key != 9)
|
||||
tmp->cmd[tmp->len - 1] = ctrl;
|
||||
if (tmp->key != 9) {
|
||||
if (tmp->key == 1 && ctrl == 0) {
|
||||
ipio_info("TP enter deep sleep in\n");
|
||||
tmp->cmd[tmp->len - 1] = 0x03;
|
||||
} else {
|
||||
tmp->cmd[tmp->len - 1] = ctrl;
|
||||
}
|
||||
}
|
||||
ipio_info("Found func's name: %s, key = %d cmd: 0x%02X 0x%02X 0x%02X\n",\
|
||||
tmp->name, key, tmp->cmd[0], tmp->cmd[1], tmp->cmd[2]);
|
||||
|
||||
core_write(core_config->slave_i2c_addr, tmp->cmd, tmp->len);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -35,8 +35,10 @@
|
|||
#include "core/gesture.h"
|
||||
|
||||
#define USER_STR_BUFF 2000
|
||||
#define USER_DUG_BUFF_LEN 4096
|
||||
#define ILITEK_IOCTL_MAGIC 100
|
||||
#define ILITEK_IOCTL_MAXNR 21
|
||||
#define UPGRADE_RETRY_TIMES 3
|
||||
|
||||
#define ILITEK_IOCTL_I2C_WRITE_DATA _IOWR(ILITEK_IOCTL_MAGIC, 0, uint8_t*)
|
||||
#define ILITEK_IOCTL_I2C_SET_WRITE_LENGTH _IOWR(ILITEK_IOCTL_MAGIC, 1, int)
|
||||
|
|
@ -228,12 +230,12 @@ static ssize_t ilitek_proc_debug_message_read(struct file *filp,
|
|||
|
||||
mutex_lock(&ipd->ilitek_debug_mutex);
|
||||
|
||||
tmpbuf = vmalloc(4096); /* buf size if even */
|
||||
tmpbuf = vmalloc(USER_DUG_BUFF_LEN); /* buf size if even */
|
||||
if (ERR_ALLOC_MEM(tmpbuf)) {
|
||||
ipio_err("buffer vmalloc error\n");
|
||||
send_data_len +=
|
||||
snprintf(tmpbufback + send_data_len,
|
||||
(strlen(tmpbufback)-send_data_len),
|
||||
(sizeof(tmpbufback)-send_data_len),
|
||||
"buffer vmalloc error\n");
|
||||
ret = copy_to_user(buff, tmpbufback, send_data_len); /*ipd->debug_buf[0] */
|
||||
} else {
|
||||
|
|
@ -264,16 +266,16 @@ static ssize_t ilitek_proc_debug_message_read(struct file *filp,
|
|||
need_read_data_len);
|
||||
send_data_len +=
|
||||
snprintf(tmpbuf + send_data_len,
|
||||
(strlen(tmpbuf)-send_data_len),
|
||||
(USER_DUG_BUFF_LEN-send_data_len),
|
||||
"parse data err data len = %d\n",
|
||||
need_read_data_len);
|
||||
} else {
|
||||
for (i = 0 ; i < need_read_data_len ; i++) {
|
||||
send_data_len +=
|
||||
snprintf(tmpbuf + send_data_len,
|
||||
(strlen(tmpbuf)-send_data_len),
|
||||
(USER_DUG_BUFF_LEN-send_data_len),
|
||||
"%02X", ipd->debug_buf[0][i]);
|
||||
if (send_data_len >= 4096) {
|
||||
if (send_data_len >= USER_DUG_BUFF_LEN) {
|
||||
ipio_err
|
||||
("send_data_len = %d set 4096 i = %d\n",
|
||||
send_data_len, i);
|
||||
|
|
@ -283,7 +285,7 @@ static ssize_t ilitek_proc_debug_message_read(struct file *filp,
|
|||
}
|
||||
}
|
||||
send_data_len += snprintf(tmpbuf + send_data_len,
|
||||
(strlen(tmpbuf)-send_data_len), "\n\n");
|
||||
(USER_DUG_BUFF_LEN-send_data_len), "\n\n");
|
||||
|
||||
if (p == 5 || size == 4096 || size == 2048) {
|
||||
ipd->debug_data_frame--;
|
||||
|
|
@ -299,7 +301,7 @@ static ssize_t ilitek_proc_debug_message_read(struct file *filp,
|
|||
} else {
|
||||
ipio_err("no data send\n");
|
||||
send_data_len += snprintf(tmpbuf + send_data_len,
|
||||
(strlen(tmpbuf)-send_data_len), "no data send\n");
|
||||
(USER_DUG_BUFF_LEN-send_data_len), "no data send\n");
|
||||
}
|
||||
|
||||
/* Preparing to send data to user */
|
||||
|
|
@ -327,7 +329,7 @@ static ssize_t ilitek_proc_debug_message_read(struct file *filp,
|
|||
vfree(tmpbuf);
|
||||
tmpbuf = NULL;
|
||||
}
|
||||
|
||||
ipio_debug(DEBUG_NETLINK, "send len:%d\n", send_data_len);
|
||||
mutex_unlock(&ipd->ilitek_debug_mutex);
|
||||
mutex_unlock(&ipd->ilitek_debug_read_mutex);
|
||||
return send_data_len;
|
||||
|
|
@ -1800,6 +1802,7 @@ static DEVICE_ATTR(flashprog, 0444, drv_flash_prog_show, NULL);
|
|||
static ssize_t do_reflash_store(struct device *pDevice, struct device_attribute *pAttr, const char *pBuf, size_t nSize)
|
||||
{
|
||||
int ret;
|
||||
int retry = 0;
|
||||
char prefix[128] = "ILITEK";
|
||||
const char *chip_name = ipd->TP_IC_TYPE;
|
||||
|
||||
|
|
@ -1841,8 +1844,18 @@ static ssize_t do_reflash_store(struct device *pDevice, struct device_attribute
|
|||
|
||||
if (ipd->isEnablePollCheckPower)
|
||||
cancel_delayed_work_sync(&ipd->check_power_status_work);
|
||||
|
||||
ret = core_firmware_upgrade(g_user_buf, false);
|
||||
for (retry = 1; retry <= UPGRADE_RETRY_TIMES; retry++) {
|
||||
ret = core_firmware_upgrade(g_user_buf, false);
|
||||
if (ret < 0) {
|
||||
msleep(100);
|
||||
/* We do have to reset chip in order to move new code from flash to iram. */
|
||||
ipio_info("Upgrade fail Doing Soft Reset res = %d retry = %d\n", ret, retry);
|
||||
core_config_ic_reset();
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ilitek_platform_enable_irq();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue