#include <mach/gpio.h>
#include <linux/earlysuspend.h>
#include <linux/wakelock.h>
+#include <plat/board-mapphone.h>
#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;
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;
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();
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");
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;