post: add gpio hotkey support
authorMike Frysinger <vapier@gentoo.org>
Tue, 10 May 2011 07:01:21 +0000 (07:01 +0000)
committerWolfgang Denk <wd@denx.de>
Tue, 26 Jul 2011 14:47:39 +0000 (16:47 +0200)
Now that we have the generic GPIO layer, we can easily provide a common
implementation for the post_hotkeys_pressed() function based on it.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
post/post.c

index 1b7f2aa075e2ea0679857dd9be5e57eb4252c43a..ecea1e13a2fc0d050b5288a1cb4a51783652c390 100644 (file)
 #include <watchdog.h>
 #include <post.h>
 
+#ifdef CONFIG_SYS_POST_HOTKEYS_GPIO
+#include <asm/gpio.h>
+#endif
+
 #ifdef CONFIG_LOGBUFFER
 #include <logbuff.h>
 #endif
@@ -68,6 +72,23 @@ int post_init_f (void)
  */
 int __post_hotkeys_pressed(void)
 {
+#ifdef CONFIG_SYS_POST_HOTKEYS_GPIO
+       int ret;
+       unsigned gpio = CONFIG_SYS_POST_HOTKEYS_GPIO;
+
+       ret = gpio_request(gpio, "hotkeys");
+       if (ret) {
+               printf("POST: gpio hotkey request failed\n");
+               return 0;
+       }
+
+       gpio_direction_input(gpio);
+       ret = gpio_get_value(gpio);
+       gpio_free(gpio);
+
+       return ret;
+#endif
+
        return 0;       /* No hotkeys supported */
 }
 int post_hotkeys_pressed(void)