From 7d56d5aa2b3258c493f038abd6d18c7533ea734b Mon Sep 17 00:00:00 2001 From: Greg Turner 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 --- 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