+/* hardware debounce: (time + 1) * 31us */
+static void hw_debounce_set(int enable, int time) {
+ int i;
+
+ if (gpio_evmi == NULL)
+ return;
+
+ for (i = 0; i < gpio_evmi->ninputs; i++) {
+ int gpio = gpio_evmi->input_gpios[i];
+
+ if ((time != -1) && (time != hw_debounce_time) && hw_debounce) {
+ printk(KERN_INFO PREFIX "Setting hardware debounce time for GPIO %d to %d (%dus)\n", gpio, time, (time+1)*31);
+ omap_set_gpio_debounce_time(gpio, time);
+ }
+
+ if ((enable != -1) && (enable != hw_debounce)) {
+ printk(KERN_INFO PREFIX "%sabling hardware debounce for GPIO %d\n", (enable?"En":"Dis"), gpio);
+ omap_set_gpio_debounce(gpio, enable);
+ }
+ }
+}
+
+static void set_irq_types(void) {
+ int err;
+ unsigned int irq;
+ unsigned long type;
+ int i;
+
+ if (gpio_evmi == NULL)
+ return;
+
+ switch (gpio_evmi->flags & (GPIOKPF_ACTIVE_HIGH|GPIOKPF_LEVEL_TRIGGERED_IRQ)) {
+ default:
+ type = IRQ_TYPE_EDGE_FALLING;
+ break;
+ case GPIOKPF_ACTIVE_HIGH:
+ type = IRQ_TYPE_EDGE_RISING;
+ break;
+ case GPIOKPF_LEVEL_TRIGGERED_IRQ:
+ type = IRQ_TYPE_LEVEL_LOW;
+ break;
+ case GPIOKPF_LEVEL_TRIGGERED_IRQ | GPIOKPF_ACTIVE_HIGH:
+ type = IRQ_TYPE_LEVEL_HIGH;
+ break;
+ }
+
+ printk(KERN_INFO PREFIX "Settinhg IRQ type to 0x%lx\n", type);
+
+ for (i = 0; i < gpio_evmi->ninputs; i++) {
+
+ err = irq = gpio_to_irq(gpio_evmi->input_gpios[i]);
+
+ if (err < 0)
+ return;
+
+ err = set_irq_type(irq, type);
+ }
+}
+