diff mbox series

[v1,48/49] cmd: bcm: add command for chimp hand shake

Message ID 20200427105207.5659-49-rayagonda.kokatanur@broadcom.com
State Superseded
Headers show
Series add support for broadcom NS3 soc | expand

Commit Message

Rayagonda Kokatanur April 27, 2020, 10:52 a.m. UTC
From: Bharat Kumar Reddy Gooty <bharat.gooty at broadcom.com>

Add command for chimp handshake.

Signed-off-by: Bharat Kumar Reddy Gooty <bharat.gooty at broadcom.com>
Signed-off-by: Rayagonda Kokatanur <rayagonda.kokatanur at broadcom.com>
---
 cmd/bcm/Makefile          |  1 +
 cmd/bcm/chimp_handshake.c | 32 ++++++++++++++++++++++++++++++++
 include/brcm/chimp.h      |  6 ++++++
 3 files changed, 39 insertions(+)
 create mode 100644 cmd/bcm/chimp_handshake.c
diff mbox series

Patch

diff --git a/cmd/bcm/Makefile b/cmd/bcm/Makefile
index 671c0fbd43..49a3f38357 100644
--- a/cmd/bcm/Makefile
+++ b/cmd/bcm/Makefile
@@ -3,4 +3,5 @@ 
 
 obj-$(CONFIG_CMD_BCM_LOGSETUP) += logsetup.o
 obj-y += chimp_boot.o
+obj-y += chimp_handshake.o
 obj-y += nitro_image_load.o
diff --git a/cmd/bcm/chimp_handshake.c b/cmd/bcm/chimp_handshake.c
new file mode 100644
index 0000000000..7b9c766dd3
--- /dev/null
+++ b/cmd/bcm/chimp_handshake.c
@@ -0,0 +1,32 @@ 
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2020 Broadcom
+ */
+
+#include <brcm/chimp.h>
+#include <common.h>
+
+/* This command should be called after loading the nitro binaries */
+static int do_chimp_hs(cmd_tbl_t *cmdtp, int flag, int argc,
+		       char *const argv[])
+{
+	int ret = CMD_RET_USAGE;
+	u32 hstatus;
+
+	/* Returns 1, if handshake call is success */
+	if (chimp_handshake_status_optee(0, &hstatus) == BCM_CHIMP_SUCCESS)
+		ret = CMD_RET_SUCCESS;
+
+	if (hstatus == CHIMP_HANDSHAKE_SUCCESS)
+		printf("ChiMP Handshake successful\n");
+	else
+		printf("ERROR: ChiMP Handshake status 0x%x\n", hstatus);
+
+	return ret;
+}
+
+U_BOOT_CMD
+	(chimp_hs, 1, 1, do_chimp_hs,
+	 "Command to verify the Chimp hand shake",
+	 "chimp_hs\n"
+);
diff --git a/include/brcm/chimp.h b/include/brcm/chimp.h
index 9099a70ef5..f384603dc7 100644
--- a/include/brcm/chimp.h
+++ b/include/brcm/chimp.h
@@ -15,6 +15,12 @@ 
 
 #define BCM_CHIMP_RUNNIG_GOOD	0x8000
 
+enum {
+	CHIMP_HANDSHAKE_SUCCESS = 0,
+	CHIMP_HANDSHAKE_WAIT_ERROR,
+	CHIMP_HANDSHAKE_WAIT_TIMEOUT,
+};
+
 #ifdef CONFIG_CHIMP_OPTEE
 int chimp_fastboot_optee(void);
 int chimp_health_status_optee(u32 *status);