1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
From 7d56d5aa2b3258c493f038abd6d18c7533ea734b Mon Sep 17 00:00:00 2001
From: Greg Turner <gregturner@ti.com>
Date: Tue, 25 May 2010 09:19:06 -0500
Subject: [PATCH] BeagleBoard: New command for status of USER button
Modified bootcmd to check the staus at boot time and set filename of the boot script.
Signed-off-by: Jason Kridner <jkridner@beagleboard.org>
---
common/cmd_boot.c | 45 ++++++++++++++++++++++++++++++++++++++++
include/configs/omap3_beagle.h | 11 +++++++++
2 files changed, 56 insertions(+), 0 deletions(-)
diff --git a/common/cmd_boot.c b/common/cmd_boot.c
index bfc1db2..4caf674 100644
--- a/common/cmd_boot.c
+++ b/common/cmd_boot.c
@@ -35,6 +35,51 @@ unsigned long do_go_exec (ulong (*entry)(int, char *[]), int argc, char *argv[])
return entry (argc, argv);
}
+/*
+ * This command returns the status of the user button on beagle xM
+ * Input - none
+ * Returns - 1 if button is held down
+ * 0 if button is not held down
+ */
+int do_userbutton (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ int button = 0;
+
+ //printf ("## Return Status of User button\n");
+
+ /*
+ * pass address parameter as argv[0] (aka command name),
+ * and all remaining args
+ */
+ omap_request_gpio(4);
+ omap_set_gpio_direction(4, 1);
+ printf("The user button is currently ");
+ if(omap_get_gpio_datain(4))
+ {
+ button = 1;
+ }
+ else
+ {
+ button = 0;
+ printf("NOT ");
+ }
+
+ printf("pressed.\n");
+
+ omap_free_gpio(4);
+
+ return button;
+}
+
+/* -------------------------------------------------------------------- */
+
+U_BOOT_CMD(
+ userbutton, CONFIG_SYS_MAXARGS, 1, do_userbutton,
+ "Return the status of the user button",
+ ""
+);
+
+
int do_go (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
ulong addr, rc;
diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h
index eaa8779..555b350 100644
--- a/include/configs/omap3_beagle.h
+++ b/include/configs/omap3_beagle.h
@@ -254,8 +254,19 @@
"run ramargs; " \
"bootm ${loadaddr}\0" \
+/*
+ * The default bootcmd checks the status of the user button
+ * and sets the boot script accordingly.
+ * If the user button is NOT pressed: bootscr = boot.scr
+ * If the user button is pressed: bootscr = user.scr
+ */
#define CONFIG_BOOTCOMMAND \
"if mmc init ${mmcdev}; then " \
+ "if userbutton; then " \
+ "setenv bootscr boot.scr; " \
+ "else " \
+ "setenv bootscr user.scr;" \
+ "fi;" \
"if run loadbootscript; then " \
"run bootscript; " \
"else " \
--
1.5.6.4
|