From 2291c2c42eb29cb987637a2322aca8341d9e80a5 Mon Sep 17 00:00:00 2001 From: Piotr Dymacz Date: Thu, 22 Feb 2018 15:11:56 +0100 Subject: [PATCH] Make it possible to support devices with no buttons Signed-off-by: Piotr Dymacz --- u-boot/Makefile | 9 ++++++--- u-boot/board/ar7240/common/common.c | 2 +- u-boot/common/cmd_custom.c | 5 +++-- u-boot/common/main.c | 8 +++++--- u-boot/include/env_scripts.h | 9 +++------ 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/u-boot/Makefile b/u-boot/Makefile index fb9d8ee..1801a87 100644 --- a/u-boot/Makefile +++ b/u-boot/Makefile @@ -157,9 +157,12 @@ define config_init $(call echo_yellow, GPIO reset button:\tnot specified) \ ) - $(if $(filter $(5),1), - $(call echo_yellow, Button active low:\tyes), \ - $(call echo_yellow, Button active low:\tno) \ + $(if $(5), + $(if $(filter $(5),1), + $(call echo_yellow, Button active low:\tyes), \ + $(call echo_yellow, Button active low:\tno) \ + ), \ + $(call echo_yellow, Button active low:\tn/a) \ ) $(if $(filter $(COMPRESSED_UBOOT),1), \ diff --git a/u-boot/board/ar7240/common/common.c b/u-boot/board/ar7240/common/common.c index 9410075..1633bb8 100644 --- a/u-boot/board/ar7240/common/common.c +++ b/u-boot/board/ar7240/common/common.c @@ -272,7 +272,7 @@ void macaddr_init(u8 *mac_addr) */ int reset_button_status(void) { -#ifdef CONFIG_GPIO_RESET_BTN +#if defined(CONFIG_GPIO_RESET_BTN) u32 gpio; gpio = qca_soc_reg_read(QCA_GPIO_IN_REG); diff --git a/u-boot/common/cmd_custom.c b/u-boot/common/cmd_custom.c index ee4afdd..a1c9908 100644 --- a/u-boot/common/cmd_custom.c +++ b/u-boot/common/cmd_custom.c @@ -248,7 +248,8 @@ U_BOOT_CMD(defenv, 1, 0, do_default_env, "reset environment variables to their d * button && echo pressed! * button || echo not pressed! */ -#if defined(CONFIG_CMD_BUTTON) +#if defined(CONFIG_CMD_BUTTON) &&\ + defined(CONFIG_GPIO_RESET_BTN) int do_button(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) { #if defined(CFG_HUSH_PARSER) @@ -267,7 +268,7 @@ int do_button(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) U_BOOT_CMD(button, 1, 1, do_button, "get reset button status\n", NULL); -#endif /* CONFIG_CMD_BUTTON */ +#endif /* CONFIG_CMD_BUTTON && CONFIG_GPIO_RESET_BTN */ /* * Allows to delay execution diff --git a/u-boot/common/main.c b/u-boot/common/main.c index 2d87e62..95cafdf 100644 --- a/u-boot/common/main.c +++ b/u-boot/common/main.c @@ -162,7 +162,8 @@ void main_loop(void) char *bootcmd; int rc = 0; -#if defined(CONFIG_BTN_RECOVERY_SCRIPT) +#if defined(CONFIG_BTN_RECOVERY_SCRIPT) &&\ + defined(CONFIG_GPIO_RESET_BTN) int stop_boot; char *c; #endif @@ -193,7 +194,8 @@ void main_loop(void) #endif /* Recovery mode before normal boot */ -#if defined(CONFIG_BTN_RECOVERY_SCRIPT) +#if defined(CONFIG_BTN_RECOVERY_SCRIPT) &&\ + defined(CONFIG_GPIO_RESET_BTN) if (reset_button_status()) { #if defined(CONFIG_SILENT_CONSOLE) if (gd->flags & GD_FLG_SILENT) { @@ -256,7 +258,7 @@ void main_loop(void) printf_err("recovery script is missing in env!\n\n"); } } -#endif /* CONFIG_RECOVERY_MODE */ +#endif /* CONFIG_BTN_RECOVERY_SCRIPT && CONFIG_GPIO_RESET_BTN */ #if defined(CONFIG_BOOTDELAY) &&\ (CONFIG_BOOTDELAY >= 0) diff --git a/u-boot/include/env_scripts.h b/u-boot/include/env_scripts.h index 513b3ea..ddd0232 100644 --- a/u-boot/include/env_scripts.h +++ b/u-boot/include/env_scripts.h @@ -112,7 +112,8 @@ /* * Recovery */ -#if defined(CONFIG_BTN_RECOVERY_SCRIPT) +#if defined(CONFIG_BTN_RECOVERY_SCRIPT) &&\ + defined(CONFIG_GPIO_RESET_BTN) #if !defined(CONFIG_CMD_BUTTON) ||\ !defined(CONFIG_CMD_SLEEP) ||\ @@ -122,10 +123,6 @@ #error "Commands setexpr, itest, sleep, button and led{on, off} are required for recovery" #endif - #if !defined(CONFIG_GPIO_RESET_BTN) - #error "Reset button definition is required for recovery" - #endif - #if defined(CONFIG_CMD_HTTPD) #define SCRIPT_HTTP_PART_1 \ "echo - 3s for web based recovery;" @@ -186,6 +183,6 @@ "setenv cnt;" \ "fi\0" -#endif /* CONFIG_BTN_RECOVERY_SCRIPT */ +#endif /* CONFIG_BTN_RECOVERY_SCRIPT && CONFIG_GPIO_RESET_BTN */ #endif /* _ENV_SCRIPTS_H_ */ -- 2.25.1