diff mbox series

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

Message ID 20200517083705.22508-4-rayagonda.kokatanur@broadcom.com
State New
Headers show
Series add custome commands for broadcom NS3 soc | expand

Commit Message

Rayagonda Kokatanur May 17, 2020, 8:37 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

Comments

Simon Glass May 25, 2020, 5:03 p.m. UTC | #1
On Sun, 17 May 2020 at 02:37, Rayagonda Kokatanur
<rayagonda.kokatanur at broadcom.com> wrote:
>
> 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

Reviewed-by: Simon Glass <sjg at chromium.org>

I think handshake is one word these days.

Also please see below

>
> 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>

Fix order

> +
> +/* This command should be called after loading the nitro binaries */
> +static int do_chimp_hs(cmd_tbl_t *cmdtp, int flag, int argc,

Forgot to mention, this typedef has been removed sorry, so patches
need updating for that.

> +                      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",

You can drop 'Command to' since we know it is a command

> +        "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);
> --
> 2.17.1
>

Regards,
Simon
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);