[glsdk/meta-ti-glsdk.git] / recipes-bsp / u-boot / u-boot / 0008-BeagleBoard-Added-userbutton-command.patch
1 From 31110e039b1982590df08c66e53924f454e3e3f1 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 08/16] 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 * Used latest revision getting function.
23 * Used latest macros for board revision.
24 ---
25 board/ti/beagle/beagle.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++
26 1 files changed, 55 insertions(+), 0 deletions(-)
28 diff --git a/board/ti/beagle/beagle.c b/board/ti/beagle/beagle.c
29 index 56e7afc..04e4259 100644
30 --- a/board/ti/beagle/beagle.c
31 +++ b/board/ti/beagle/beagle.c
32 @@ -38,6 +38,7 @@
33 #include <asm/arch/gpio.h>
34 #include <asm/mach-types.h>
35 #include "beagle.h"
36 +#include <command.h>
38 #define TWL4030_I2C_BUS 0
39 #define EXPANSION_EEPROM_I2C_BUS 1
40 @@ -339,3 +340,57 @@ int board_mmc_init(bd_t *bis)
41 return 0;
42 }
43 #endif
44 +
45 +/*
46 + * This command returns the status of the user button on beagle xM
47 + * Input - none
48 + * Returns - 1 if button is held down
49 + * 0 if button is not held down
50 + */
51 +int do_userbutton (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
52 +{
53 + int button = 0;
54 + int gpio;
55 +
56 + /*
57 + * pass address parameter as argv[0] (aka command name),
58 + * and all remaining args
59 + */
60 + switch (get_board_revision()) {
61 + case REVISION_AXBX:
62 + case REVISION_CX:
63 + case REVISION_C4:
64 + gpio = 7;
65 + break;
66 + case REVISION_XM_A:
67 + case REVISION_XM_B:
68 + default:
69 + gpio = 4;
70 + break;
71 + }
72 + omap_request_gpio(gpio);
73 + omap_set_gpio_direction(gpio, 1);
74 + printf("The user button is currently ");
75 + if(omap_get_gpio_datain(gpio))
76 + {
77 + button = 1;
78 + printf("PRESSED.\n");
79 + }
80 + else
81 + {
82 + button = 0;
83 + printf("NOT pressed.\n");
84 + }
85 +
86 + omap_free_gpio(gpio);
87 +
88 + return !button;
89 +}
90 +
91 +/* -------------------------------------------------------------------- */
92 +
93 +U_BOOT_CMD(
94 + userbutton, CONFIG_SYS_MAXARGS, 1, do_userbutton,
95 + "Return the status of the BeagleBoard USER button",
96 + ""
97 +);
98 --
99 1.6.6.1