diff mbox series

[v2,12/18] am335x, guardian: update swi logic

Message ID 20210422133152.16231-13-Gireesh.Hiremath@in.bosch.com
State Changes Requested
Delegated to: Lokesh Vutla
Headers show
Series am335x, guardian: update board specific changes | expand

Commit Message

Gireesh Hiremath April 22, 2021, 1:31 p.m. UTC
From: Gireesh Hiremath <Gireesh.Hiremath@in.bosch.com>

read boot mode gpio and set the swi status

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

Patch

diff --git a/board/bosch/guardian/board.c b/board/bosch/guardian/board.c
index 12d047b74b..8704806047 100644
--- a/board/bosch/guardian/board.c
+++ b/board/bosch/guardian/board.c
@@ -205,8 +205,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 fa6e02d09b..b966df08c6 100644
--- a/include/configs/am335x_guardian.h
+++ b/include/configs/am335x_guardian.h
@@ -68,13 +68,13 @@ 
 		"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 " \
 		      "source \"${tftp_load_addr}\"; " \
 		    "fi; " \
 		  "fi; " \
+		  "setenv extrabootargs $extrabootargs \"swi_attached\"; " \
 		"fi;" \
 		"run bootcmd_ubifs0;\0" \
 	"altbootcmd=" \