[PATCH 07/10] am335x, guardian: update swi logic

Gireesh.Hiremath at in.bosch.com Gireesh.Hiremath at in.bosch.com
Wed Jan 6 16:31:53 CET 2021


From: Gireesh Hiremath <Gireesh.Hiremath at in.bosch.com>

read boot_mode_gpio and set the swi status

Signed-off-by: Gireesh Hiremath <Gireesh.Hiremath at in.bosch.com>
---
 board/bosch/guardian/board.c      | 15 +++++++++++++--
 include/configs/am335x_guardian.h |  2 +-
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/board/bosch/guardian/board.c b/board/bosch/guardian/board.c
index 394c56d72e..9911e99c09 100644
--- a/board/bosch/guardian/board.c
+++ b/board/bosch/guardian/board.c
@@ -241,8 +241,19 @@ static void set_bootmode_env(void)
 		goto err;
 	}
 
-	value = dm_gpio_get_value(&boot_mode_desc);
-	value ? env_set("swi_status", "0") : env_set("swi_status", "1");
+	dm_gpio_set_dir_flags(&boot_mode_desc, GPIOD_IS_IN);
+	udelay(10);
+
+	ret = dm_gpio_get_value(&boot_mode_desc);
+	if (ret == 0) {
+		env_set("swi_status", "1");
+	} else if (ret == 1) {
+		env_set("swi_status", "0");
+	} else {
+		printf("swi status gpio error\n");
+		goto err;
+	}
+
 	return;
 
 err:
diff --git a/include/configs/am335x_guardian.h b/include/configs/am335x_guardian.h
index 16ef639d9b..7db349d35b 100644
--- a/include/configs/am335x_guardian.h
+++ b/include/configs/am335x_guardian.h
@@ -69,7 +69,6 @@
 		"setenv rootflags \"bulk_read,chk_data_crc\"; " \
 		"setenv ethact usb_ether; " \
 		"if test \"${swi_status}\" -eq 1; then " \
-		  "setenv extrabootargs \"swi_attached\"; " \
 		  "if dhcp; then " \
 		    "sleep 1; " \
 		    "if tftp \"${tftp_load_addr}\" \"bootscript.scr\"; then " \
@@ -79,6 +78,7 @@
 		    "setcurs 15 1; " \
 		    "lcdputs \"DHCP Failed\"; " \
 		  "fi; " \
+		  "setenv extrabootargs $extrabootargs \"swi_attached\"; " \
 		"fi;" \
 		"run bootcmd_ubifs0;\0" \
 	"altbootcmd=" \
-- 
2.20.1



More information about the U-Boot mailing list