mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] mfd: rave-sp: Emulate firmware/bootloader mode reporting on RDU2
@ 2019-09-07 23:59 Andrey Smirnov
  2019-09-09  8:46 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Andrey Smirnov @ 2019-09-07 23:59 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

Add code to emulate firmware/bootloader mode reporting via
"general_status" field on RDU2. This is needed to correctly report if
RAVE SP is in bootloader of application mode during startup.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/mfd/rave-sp.c       | 18 ++++++++++++++++--
 include/linux/mfd/rave-sp.h |  1 +
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/rave-sp.c b/drivers/mfd/rave-sp.c
index 1448c4143f..67f7d4c654 100644
--- a/drivers/mfd/rave-sp.c
+++ b/drivers/mfd/rave-sp.c
@@ -640,6 +640,7 @@ static int rave_sp_emulated_get_status(struct rave_sp *sp,
 		[0] = RAVE_SP_CMD_GET_FIRMWARE_VERSION,
 		[1] = 0,
 	};
+	u8 firmware_mode;
 	int ret;
 
 	ret = rave_sp_exec(sp, cmd, sizeof(cmd), &status->firmware_version,
@@ -648,8 +649,21 @@ static int rave_sp_emulated_get_status(struct rave_sp *sp,
 		return ret;
 
 	cmd[0] = RAVE_SP_CMD_GET_BOOTLOADER_VERSION;
-	return rave_sp_exec(sp, cmd, sizeof(cmd), &status->bootloader_version,
-			    sizeof(status->bootloader_version));
+	ret = rave_sp_exec(sp, cmd, sizeof(cmd), &status->bootloader_version,
+			   sizeof(status->bootloader_version));
+	if (ret)
+		return ret;
+
+	cmd[0] = RAVE_SP_CMD_GET_OPERATIONAL_MODE;
+	ret = rave_sp_exec(sp, cmd, sizeof(cmd), &firmware_mode,
+			   sizeof(firmware_mode));
+	if (ret)
+		return ret;
+
+	status->general_status =
+		firmware_mode ? RAVE_SP_STATUS_GS_FIRMWARE_MODE : 0;
+
+	return 0;
 }
 
 static int rave_sp_get_status(struct rave_sp *sp)
diff --git a/include/linux/mfd/rave-sp.h b/include/linux/mfd/rave-sp.h
index 7b3187cb74..92315c6e12 100644
--- a/include/linux/mfd/rave-sp.h
+++ b/include/linux/mfd/rave-sp.h
@@ -14,6 +14,7 @@
 enum rave_sp_command {
 	RAVE_SP_CMD_GET_FIRMWARE_VERSION	= 0x20,
 	RAVE_SP_CMD_GET_BOOTLOADER_VERSION	= 0x21,
+	RAVE_SP_CMD_GET_OPERATIONAL_MODE	= 0x25,
 	RAVE_SP_CMD_BOOT_SOURCE			= 0x26,
 	RAVE_SP_CMD_GET_BOARD_COPPER_REV	= 0x2B,
 	RAVE_SP_CMD_GET_GPIO_STATE		= 0x2F,
-- 
2.21.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-09-09  8:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-07 23:59 [PATCH] mfd: rave-sp: Emulate firmware/bootloader mode reporting on RDU2 Andrey Smirnov
2019-09-09  8:46 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox