input: cypress-touchkey - Add keydisabler

This commit is contained in:
Robert Rozic
2019-08-05 09:06:04 +02:00
committed by Francescodario Cuzzocrea
parent 439e674d94
commit 841dff7d51
2 changed files with 46 additions and 0 deletions
@@ -302,6 +302,10 @@ static irqreturn_t cypress_touchkey_interrupt(int irq, void *dev_id)
int press;
int ret;
if (!atomic_read(&info->keypad_enable)) {
goto out;
}
ret = gpio_get_value(info->pdata->gpio_int);
if (ret) {
dev_err(&info->client->dev, "not real interrupt (%d).\n", ret);
@@ -940,6 +944,38 @@ static ssize_t autocalibration_status(struct device *dev,
return sprintf(buf, "Disabled\n");
}
static ssize_t sec_keypad_enable_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct cypress_touchkey_info *info = dev_get_drvdata(dev);
return sprintf(buf, "%d\n", atomic_read(&info->keypad_enable));
}
static ssize_t sec_keypad_enable_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct cypress_touchkey_info *info = dev_get_drvdata(dev);
int i;
unsigned int val = 0;
sscanf(buf, "%d", &val);
val = (val == 0 ? 0 : 1);
atomic_set(&info->keypad_enable, val);
if (val) {
for (i = 0; i < ARRAY_SIZE(info->keycode); i++)
set_bit(info->keycode[i], info->input_dev->keybit);
} else {
for (i = 0; i < ARRAY_SIZE(info->keycode); i++)
clear_bit(info->keycode[i], info->input_dev->keybit);
}
input_sync(info->input_dev);
return count;
}
static DEVICE_ATTR(keypad_enable, S_IRUGO|S_IWUSR, sec_keypad_enable_show,
sec_keypad_enable_store);
static DEVICE_ATTR(touchkey_firm_update_status,
S_IRUGO | S_IWUSR | S_IWGRP, touchkey_firm_status_show, NULL);
static DEVICE_ATTR(touchkey_firm_version_panel, S_IRUGO,
@@ -1155,6 +1191,8 @@ printk("[TKEY] %s _ %d\n",__func__,__LINE__);
set_bit(EV_LED, input_dev->evbit);
set_bit(LED_MISC, input_dev->ledbit);
atomic_set(&info->keypad_enable, 1);
for (i = 0; i < pdata->keycodes_size; i++) {
info->keycode[i] = pdata->touchkey_keycode[i];
set_bit(info->keycode[i], input_dev->keybit);
@@ -1279,6 +1317,13 @@ printk("[TKEY] %s _ %d\n",__func__,__LINE__);
dev_set_drvdata(sec_touchkey, info);
if (device_create_file(sec_touchkey,
&dev_attr_keypad_enable) < 0) {
pr_err("Failed to create device file(%s)!\n",
dev_attr_keypad_enable.attr.name);
goto err_sysfs;
}
if (device_create_file(sec_touchkey,
&dev_attr_touchkey_firm_update_status) < 0) {
pr_err("Failed to create device file(%s)!\n",
@@ -128,6 +128,7 @@ struct cypress_touchkey_info {
#if defined(CONFIG_GLOVE_TOUCH)
int glove_value;
#endif
atomic_t keypad_enable;
};