]> git.zerfleddert.de Git - ms2-fixes/commitdiff
enable hardware debouncing of keyboard gpios
authorMichael Gernoth <michael@gernoth.net>
Fri, 19 Aug 2011 11:53:35 +0000 (13:53 +0200)
committerMichael Gernoth <michael@gernoth.net>
Fri, 19 Aug 2011 11:53:35 +0000 (13:53 +0200)
MS2Debounce/assets/debounce.ko
debounce.c

index 26b98240a325243e91bf0a385636577f094e422c..456f4c1b7f2f7cd1aba999a8399cc519fd87a8fa 100644 (file)
Binary files a/MS2Debounce/assets/debounce.ko and b/MS2Debounce/assets/debounce.ko differ
index f2793a4c10f0c58ea3f67c1e5970be9c7247b5ec..46c0a63acf465469bc076fd6170c8c9ae751bc1a 100644 (file)
@@ -2,6 +2,10 @@
 #include <linux/device.h>
 #include <linux/platform_device.h>
 #include <linux/gpio_event.h>
+#include <mach/gpio.h>
+
+/* hardware debounce: (value + 1) * 31us */
+#define GPIO_DEBOUNCE_TIME              10240
 
 #define PREFIX "debounce: "
 
@@ -333,6 +337,28 @@ static struct device debounce_device = {
        .release = debounce_release,
 };
 
+static unsigned int mapphone_col_gpios[] = { 43, 53, 54, 55, 56, 57, 58, 63 };
+static unsigned int mapphone_row_gpios[] = { 34, 35, 36, 37, 38, 39, 40, 41 };
+
+static void hw_debounce_pin(int gpio, int enable) {
+       printk(KERN_INFO PREFIX "%sabling hardware debounce for GPIO %d\n", (enable?"En":"Dis"), gpio);
+       if (enable)
+               omap_set_gpio_debounce_time(gpio, GPIO_DEBOUNCE_TIME);
+       omap_set_gpio_debounce(gpio, enable);
+}
+
+static void hw_debounce(int enable) {
+       int i;
+
+       for (i = 0; i < (sizeof(mapphone_col_gpios) / sizeof(mapphone_col_gpios[0])); i++) {
+               hw_debounce_pin(mapphone_col_gpios[i], enable);
+       }
+
+       for (i = 0; i < (sizeof(mapphone_row_gpios) / sizeof(mapphone_row_gpios[0])); i++) {
+               hw_debounce_pin(mapphone_row_gpios[i], enable);
+       }
+}
+
 static int __init debounce_init(void)
 {
        struct device *event_dev = NULL;
@@ -359,6 +385,8 @@ static int __init debounce_init(void)
                return err;
        }
 
+       hw_debounce(1);
+
        err = device_create_file(&debounce_device, &dev_attr_debounce_delay);
        err = device_create_file(&debounce_device, &dev_attr_settle_time);
        err = device_create_file(&debounce_device, &dev_attr_poll_time);
@@ -402,6 +430,7 @@ static void __exit debounce_exit(void)
                gpio_evmi->settle_time = old_settle_time;
                gpio_evmi->poll_time = old_poll_time;
        }
+       hw_debounce(0);
        device_remove_file(&debounce_device, &dev_attr_debounce_delay);
        device_remove_file(&debounce_device, &dev_attr_settle_time);
        device_remove_file(&debounce_device, &dev_attr_poll_time);
Impressum, Datenschutz