Permalink
Browse files

smdk4412: cypress-touchkey - add keydisabler

Change-Id: I85efd4c5b2d6a7283c430f5eca2a730ef6b03d18
  • Loading branch information...
1 parent ab95765 commit 1258e171ec984fc3200e738eb8e2fcda529bc7c3 @sbrissen sbrissen committed with Gerrit Code Review Mar 28, 2014
Showing with 42 additions and 0 deletions.
  1. +41 −0 drivers/input/keyboard/cypress/cypress-touchkey.c
  2. +1 −0 include/linux/i2c/touchkey_i2c.h
@@ -671,6 +671,10 @@ static irqreturn_t touchkey_interrupt(int irq, void *dev_id)
set_touchkey_debug('a');
+ if (!atomic_read(&tkey_i2c->keypad_enable)) {
+ return;
+ }
+
retry = 3;
while (retry--) {
ret = i2c_touchkey_read(tkey_i2c->client, KEYCODE_REG, data, 3);
@@ -1604,6 +1608,40 @@ static ssize_t set_touchkey_firm_status_show(struct device *dev,
return count;
}
+static ssize_t sec_keypad_enable_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct touchkey_i2c *tkey_i2c = dev_get_drvdata(dev);
+
+ return sprintf(buf, "%d\n", atomic_read(&tkey_i2c->keypad_enable));
+}
+
+static ssize_t sec_keypad_enable_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t count)
+{
+ struct touchkey_i2c *tkey_i2c = dev_get_drvdata(dev);
+
+ unsigned int val = 0;
+ sscanf(buf, "%d", &val);
+ val = (val == 0 ? 0 : 1);
+ atomic_set(&tkey_i2c->keypad_enable, val);
+ if (val) {
+ set_bit(KEY_BACK, tkey_i2c->input_dev->keybit);
+ set_bit(KEY_MENU, tkey_i2c->input_dev->keybit);
+ set_bit(KEY_HOME, tkey_i2c->input_dev->keybit);
+ } else {
+ clear_bit(KEY_BACK, tkey_i2c->input_dev->keybit);
+ clear_bit(KEY_MENU, tkey_i2c->input_dev->keybit);
+ clear_bit(KEY_HOME, tkey_i2c->input_dev->keybit);
+ }
+ input_sync(tkey_i2c->input_dev);
+
+ return count;
+}
+
+static DEVICE_ATTR(keypad_enable, S_IRUGO|S_IWUSR, sec_keypad_enable_show,
+ sec_keypad_enable_store);
+
static DEVICE_ATTR(recommended_version, S_IRUGO | S_IWUSR | S_IWGRP,
touch_version_read, touch_version_write);
static DEVICE_ATTR(updated_version, S_IRUGO | S_IWUSR | S_IWGRP,
@@ -1694,6 +1732,7 @@ static struct attribute *touchkey_attributes[] = {
&dev_attr_touchkey_threshold.attr,
&dev_attr_autocal_enable.attr,
&dev_attr_autocal_stat.attr,
+ &dev_attr_keypad_enable.attr,
#endif
&dev_attr_timeout.attr,
&dev_attr_force_disable.attr,
@@ -1764,6 +1803,8 @@ static int i2c_touchkey_probe(struct i2c_client *client,
set_bit(LED_MISC, input_dev->ledbit);
set_bit(EV_KEY, input_dev->evbit);
+ atomic_set(&tkey_i2c->keypad_enable, 1);
+
for (i = 1; i < touchkey_count; i++)
set_bit(touchkey_keycode[i], input_dev->keybit);
@@ -188,6 +188,7 @@ struct touchkey_i2c {
int (*power)(int on);
struct work_struct update_work;
int update_status;
+ atomic_t keypad_enable;
};
#endif /* _LINUX_CYPRESS_TOUCHKEY_I2C_H */

0 comments on commit 1258e17

Please sign in to comment.