DLKM/sarsensor:add tcmd test interfaces for abov mmi

1. add fw_download_status sys interface;
2. add int_state sys interface.

port form:
https://gerrit.mot.com/#/c/1539901/

Change-Id: I809e33078d66fe04b1b3678a690e5e19c7bdddf0
Signed-off-by: chenlj2 <chenlj2@motorola.com>
Reviewed-on: https://gerrit.mot.com/1540822
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Wen Xie <xiewen3@motorola.com>
Reviewed-by: Tao Sun <suntao2@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
chenlj2 2020-04-23 15:08:36 +08:00 • committed by Lijun Chen
commit d52429660e
2 changed files with 45 additions and 1 deletions

View file

@ -668,6 +668,26 @@ static ssize_t reset_store(struct class *class,
static CLASS_ATTR_RW(reset);
static ssize_t int_state_show(struct class *class,
struct class_attribute *attr,
char *buf)
{
pabovXX_t this = abov_sar_ptr;
LOG_DBG("Reading INT line state\n");
return snprintf(buf, 8, "%d\n", this->int_state);
}
static CLASS_ATTR_RO(int_state);
static ssize_t fw_download_status_show(struct class *class,
struct class_attribute *attr,
char *buf)
{
pabovXX_t this = abov_sar_ptr;
LOG_DBG("Reading fw download state\n");
return snprintf(buf, 8, "%d", this->fw_dl_status);
}
static CLASS_ATTR_RO(fw_download_status);
static ssize_t enable_show(struct class *class,
struct class_attribute *attr,
char *buf)
@ -1291,11 +1311,13 @@ static int abov_fw_update(bool force)
} else {
LOG_INFO("Firmware is latest,exiting fw upgrade...\n");
fw_upgrade = false;
this->fw_dl_status = 0;
rc = -EIO;
goto rel_fw;
}
if (fw_upgrade) {
this->fw_dl_status = 2;
for (update_loop = 0; update_loop < 10; update_loop++) {
rc = _abov_fw_update(client, &fw->data[32], fw->size-32);
if (rc < 0)
@ -1307,8 +1329,11 @@ static int abov_fw_update(bool force)
break;
}
}
if (update_loop >= 10)
if (update_loop >= 10) {
this->fw_dl_status = 1;
rc = -EIO;
}
this->fw_dl_status = 0;
}
rel_fw:
@ -1703,6 +1728,18 @@ static int abov_probe(struct i2c_client *client, const struct i2c_device_id *id)
return ret;
}
ret = class_create_file(&capsense_class, &class_attr_int_state);
if (ret < 0) {
LOG_DBG("Create int_state file failed (%d)\n", ret);
return ret;
}
ret = class_create_file(&capsense_class, &class_attr_fw_download_status);
if (ret < 0) {
LOG_DBG("Create fw_download_status file failed (%d)\n", ret);
return ret;
}
ret = class_create_file(&capsense_class, &class_attr_enable);
if (ret < 0) {
LOG_ERR("Create enable file failed (%d)\n", ret);
@ -1780,6 +1817,7 @@ static int abov_probe(struct i2c_client *client, const struct i2c_device_id *id)
}
this->loading_fw = false;
this->fw_dl_status = 1;
if (isForceUpdate == true) {
INIT_WORK(&this->fw_update_work, capsense_fore_update_work);
} else {
@ -1963,6 +2001,7 @@ static irqreturn_t abovXX_interrupt_thread(int irq, void *data)
mutex_lock(&this->mutex);
LOG_DBG("abovXX_irq\n");
this->int_state = 1;
if ((!this->get_nirq_low) || this->get_nirq_low(this->board->irq_gpio))
abovXX_process_interrupt(this, 1);
else
@ -1996,6 +2035,7 @@ static irqreturn_t abovXX_irq(int irq, void *pvoid)
if (pvoid) {
this = (pabovXX_t)pvoid;
LOG_DBG("abovXX_irq\n");
this->int_state = 1;
if ((!this->get_nirq_low) || this->get_nirq_low(this->board->irq_gpio)) {
LOG_DBG("abovXX_irq - Schedule Work\n");
abovXX_schedule_work(this, 0);
@ -2099,6 +2139,7 @@ int abovXX_sar_init(pabovXX_t this)
LOG_ERR("irq %d busy?\n", this->irq);
return err;
}
this->int_state = 0;
#ifdef USE_THREADED_IRQ
LOG_INFO("registered with threaded irq (%d)\n", this->irq);
#else

View file

@ -249,6 +249,8 @@ struct abovXX {
int read_flag;
int irq;
int irqTimeout;
/* interrupt check flag */
int int_state;
char irq_disabled;
/* whether irq should be ignored.. cases if enable/disable irq is not used
* or does not work properly */
@ -262,6 +264,7 @@ struct abovXX {
struct notifier_block ps_notif;
bool ps_is_present;
bool loading_fw;
int fw_dl_status;
struct work_struct fw_update_work;