[glsdk/meta-ti-glsdk.git] / recipes-bsp / u-boot / u-boot / 0045-BeagleBoard-Added-userbutton-command.patch
1 From f5146ac9d3af9c9cd4f4bc940c343d3ef75ac6f0 Mon Sep 17 00:00:00 2001
2 From: Jason Kridner <jkridner@beagleboard.org>
3 Date: Wed, 21 Jul 2010 07:41:25 -0500
4 Subject: [PATCH 45/51] BeagleBoard: Added userbutton command
6 Based on commit f1099c7c43caf5bac3bf6a65aa266fade4747072
7 Author: Greg Turner <gregturner@ti.com>
8 Date: Tue May 25 09:19:06 2010 -0500
10 New u-boot command for status of USER button on BeagleBoard-xM
12 Modified bootcmd to check the staus at boot time and set
13 filename of the boot script.
15 * Moved to a BeagleBoard specific file.
16 * Removed changes to default boot command from adding userbutton
17 command.
18 * Made to handle pre-xM boards.
19 * Flipped polarity of the return value to avoid confusion. Success (0)
20 is when the button is pressed. Failure (1) is when the button is NOT
21 pressed.
22 ---
23 board/ti/beagle/beagle.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++
24 1 files changed, 54 insertions(+), 0 deletions(-)
26 diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c
27 index a6a4961..66df719 100644
28 --- a/board/ti/beagle/beagle.c
29 +++ b/board/ti/beagle/beagle.c
30 @@ -40,6 +40,7 @@
31 #include <asm/arch/gpio.h>
32 #include <asm/mach-types.h>
33 #include "beagle.h"
34 +#include <command.h>
36 static struct {
37 unsigned int device_vendor;
38 @@ -290,3 +291,56 @@ void set_muxconf_regs(void)
39 MUX_BEAGLE();
40 }
42 +/*
43 + * This command returns the status of the user button on beagle xM
44 + * Input - none
45 + * Returns - 1 if button is held down
46 + * 0 if button is not held down
47 + */
48 +int do_userbutton (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
49 +{
50 + int button = 0;
51 + int gpio;
52 +
53 + /*
54 + * pass address parameter as argv[0] (aka command name),
55 + * and all remaining args
56 + */
57 + switch (beagle_revision) {
58 + case REVISION_AXBX:
59 + case REVISION_CX:
60 + case REVISION_C4:
61 + gpio = 7;
62 + break;
63 + case REVISION_XM:
64 + default:
65 + gpio = 4;
66 + break;
67 + }
68 + omap_request_gpio(gpio);
69 + omap_set_gpio_direction(gpio, 1);
70 + printf("The user button is currently ");
71 + if(omap_get_gpio_datain(gpio))
72 + {
73 + button = 1;
74 + printf("PRESSED.\n");
75 + }
76 + else
77 + {
78 + button = 0;
79 + printf("NOT pressed.\n");
80 + }
81 +
82 + omap_free_gpio(gpio);
83 +
84 + return !button;
85 +}
86 +
87 +/* -------------------------------------------------------------------- */
88 +
89 +U_BOOT_CMD(
90 + userbutton, CONFIG_SYS_MAXARGS, 1, do_userbutton,
91 + "Return the status of the BeagleBoard USER button",
92 + ""
93 +);
94 +
95 --
96 1.6.6.1