@@ -47,6 +47,7 @@
* @board: keypad platform device
* @keymap: matrix scan code table for keycodes
* @clk: clock structure pointer
+ * @enable: flag to enable the driver event
*/
struct ske_keypad {
int irq;
@@ -55,9 +56,11 @@ struct ske_keypad {
struct ske_keypad_platform_data *board;
unsigned short keymap[SKE_KPD_KEYMAP_SIZE];
struct clk *clk;
+ bool enable;
};
+static ssize_t ske_show_attr_enable(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+ struct ske_keypad *keypad = platform_get_drvdata(pdev);
+ return sprintf(buf, "%d\n", keypad->enable);
+}
+
+static ssize_t ske_store_attr_enable(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t count)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+ struct ske_keypad *keypad = platform_get_drvdata(pdev);
+ unsigned long val;
+
+ if (strict_strtoul(buf, 0, &val))
+ return -EINVAL;
+
+ if (keypad->enable != val) {
+ keypad->enable = val;
+ if (!val) {
+ disable_irq(keypad->irq);
+ ske_keypad_set_bits(keypad, SKE_IMSC, ~SKE_KPIMA, 0x0);
+ clk_disable(keypad->clk);
+ } else {
+ clk_enable(keypad->clk);
+ enable_irq(keypad->irq);
+ ske_keypad_set_bits(keypad, SKE_IMSC, 0x0, SKE_KPIMA);
+ }
+ }
+ return count;
+}
+
+static DEVICE_ATTR(enable, S_IWUSR | S_IRUGO,
+ ske_show_attr_enable, ske_store_attr_enable);
+
+static struct attribute *ske_keypad_attrs[] = {
+ &dev_attr_enable.attr,
+ NULL,
+};
+
+static struct attribute_group ske_attr_group = {
+ .attrs = ske_keypad_attrs,
+};
+
/*
* ske_keypad_chip_init : init keypad controller configuration
*
@@ -186,7 +234,7 @@ static int __devinit ske_keypad_probe(struct platform_device *pdev)