From: Michael Gernoth Date: Wed, 7 Sep 2011 06:12:10 +0000 (+0200) Subject: change padconfig to drive the matrix active high, needs UI integration X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/ms2-fixes/commitdiff_plain/126529c5b9a099c6ce08f3557e6aa3f57a4e75dc change padconfig to drive the matrix active high, needs UI integration --- diff --git a/MS2Debounce/assets/debounce.ko b/MS2Debounce/assets/debounce.ko index 54912b8..df79df7 100644 Binary files a/MS2Debounce/assets/debounce.ko and b/MS2Debounce/assets/debounce.ko differ diff --git a/debounce.c b/debounce.c index 9b8af30..b69e1bc 100644 --- a/debounce.c +++ b/debounce.c @@ -7,9 +7,24 @@ #include #include #include +#include #define PREFIX "debounce: " +#define PADCONF_PULL_UP ( OMAP343X_PADCONF_OFF_WAKEUP_ENABLED | \ + OMAP343X_PADCONF_INPUT_ENABLED | \ + OMAP343X_PADCONF_PULL_UP | \ + OMAP343X_PADCONF_PUD_ENABLED | \ + OMAP343X_PADCONF_MUXMODE4 ) + +#define PADCONF_PULL_DOWN ( OMAP343X_PADCONF_OFF_WAKEUP_ENABLED | \ + OMAP343X_PADCONF_INPUT_ENABLED | \ + OMAP343X_PADCONF_PULL_DOWN | \ + OMAP343X_PADCONF_PUD_ENABLED | \ + OMAP343X_PADCONF_MUXMODE4 ) + +#define OMAP_CTRL_REGADDR(reg) (OMAP2_L4_IO_ADDRESS(OMAP343X_CTRL_BASE) + (reg)) + static unsigned old_flags = 0; static ktime_t old_debounce_delay; static ktime_t old_settle_time; @@ -360,6 +375,7 @@ static ssize_t show_active_high_flag(struct device *dev, struct device_attribute static ssize_t store_active_high_flag(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { unsigned flag; + int i; if (!gpio_evmi) return -ENODEV; @@ -368,8 +384,14 @@ static ssize_t store_active_high_flag(struct device *dev, struct device_attribut if (flag) { gpio_evmi->flags |= GPIOKPF_ACTIVE_HIGH; + for (i = 0x7a; i <= 0x88; i += 2) { + __raw_writew(PADCONF_PULL_DOWN, OMAP_CTRL_REGADDR(i)); + } } else { gpio_evmi->flags &= ~GPIOKPF_ACTIVE_HIGH; + for (i = 0x7a; i <= 0x88; i += 2) { + __raw_writew(PADCONF_PULL_UP, OMAP_CTRL_REGADDR(i)); + } } set_irq_types(); @@ -613,6 +635,8 @@ static int __init debounce_init(void) static void __exit debounce_exit(void) { + int i; + if (gpio_evmi) { if (gpio_evmi->debounce_delay.tv.nsec != old_debounce_delay.tv.nsec) { printk(KERN_INFO PREFIX "Restoring debounce_delay\n"); @@ -623,6 +647,15 @@ static void __exit debounce_exit(void) printk(KERN_INFO PREFIX "Restoring flags\n"); gpio_evmi->flags = old_flags; printk(KERN_INFO PREFIX "flags: 0x%x\n", gpio_evmi->flags); + if (gpio_evmi->flags & GPIOKPF_ACTIVE_HIGH) { + for (i = 0x7a; i <= 0x88; i += 2) { + __raw_writew(PADCONF_PULL_DOWN, OMAP_CTRL_REGADDR(i)); + } + } else { + for (i = 0x7a; i <= 0x88; i += 2) { + __raw_writew(PADCONF_PULL_UP, OMAP_CTRL_REGADDR(i)); + } + } set_irq_types(); } gpio_evmi->settle_time = old_settle_time;