diff mbox series

[U-Boot,v3,17/17] riscv: Move do_reset() to a common place

Message ID 1537970122-26443-18-git-send-email-bmeng.cn@gmail.com
State Accepted
Commit b984ddc2dd332117ef1345255a99dc248c826b74
Delegated to: Andes
Headers show
Series riscv: Add QEMU virt board support | expand

Commit Message

Bin Meng Sept. 26, 2018, 1:55 p.m. UTC
We don't have a reset method on any RISC-V board yet. Instead of
adding the same 'unsupported' message for each CPU variant it might
make more sense to add a generic do_reset function for all CPU
variants to lib/, similar to the one for ARM (arch/arm/lib/reset.c).

Suggested-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

---

Changes in v3:
- reword the reset message a little, and call hang() in the end

Changes in v2:
- new patch to move do_reset() to a common place

 arch/riscv/cpu/ax25/cpu.c |  9 ---------
 arch/riscv/cpu/qemu/cpu.c |  8 --------
 arch/riscv/lib/Makefile   |  1 +
 arch/riscv/lib/reset.c    | 17 +++++++++++++++++
 4 files changed, 18 insertions(+), 17 deletions(-)
 create mode 100644 arch/riscv/lib/reset.c

Comments

Lukas Auer Sept. 30, 2018, 10:02 p.m. UTC | #1
Hi Bin,

On Wed, 2018-09-26 at 06:55 -0700, Bin Meng wrote:
> We don't have a reset method on any RISC-V board yet. Instead of
> adding the same 'unsupported' message for each CPU variant it might
> make more sense to add a generic do_reset function for all CPU
> variants to lib/, similar to the one for ARM (arch/arm/lib/reset.c).
> 
> Suggested-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> 
> ---
> 
> Changes in v3:
> - reword the reset message a little, and call hang() in the end
> 
> Changes in v2:
> - new patch to move do_reset() to a common place
> 
>  arch/riscv/cpu/ax25/cpu.c |  9 ---------
>  arch/riscv/cpu/qemu/cpu.c |  8 --------
>  arch/riscv/lib/Makefile   |  1 +
>  arch/riscv/lib/reset.c    | 17 +++++++++++++++++
>  4 files changed, 18 insertions(+), 17 deletions(-)
>  create mode 100644 arch/riscv/lib/reset.c
> 
> diff --git a/arch/riscv/cpu/ax25/cpu.c b/arch/riscv/cpu/ax25/cpu.c
> index ab05b57..fddcc15 100644
> --- a/arch/riscv/cpu/ax25/cpu.c
> +++ b/arch/riscv/cpu/ax25/cpu.c
> @@ -6,9 +6,6 @@
>  
>  /* CPU specific code */
>  #include <common.h>
> -#include <command.h>
> -#include <watchdog.h>
> -#include <asm/cache.h>
>  
>  /*
>   * cleanup_before_linux() is called just before we call linux
> @@ -24,9 +21,3 @@ int cleanup_before_linux(void)
>  
>  	return 0;
>  }
> -
> -int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const
> argv[])
> -{
> -	disable_interrupts();
> -	panic("ax25-ae350 wdt not support yet.\n");
> -}
> diff --git a/arch/riscv/cpu/qemu/cpu.c b/arch/riscv/cpu/qemu/cpu.c
> index a064639..6c7a327 100644
> --- a/arch/riscv/cpu/qemu/cpu.c
> +++ b/arch/riscv/cpu/qemu/cpu.c
> @@ -4,7 +4,6 @@
>   */
>  
>  #include <common.h>
> -#include <command.h>
>  
>  /*
>   * cleanup_before_linux() is called just before we call linux
> @@ -20,10 +19,3 @@ int cleanup_before_linux(void)
>  
>  	return 0;
>  }
> -
> -int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const
> argv[])
> -{
> -	printf("reset unsupported yet\n");
> -
> -	return 0;
> -}
> diff --git a/arch/riscv/lib/Makefile b/arch/riscv/lib/Makefile
> index cc562f9..b58db89 100644
> --- a/arch/riscv/lib/Makefile
> +++ b/arch/riscv/lib/Makefile
> @@ -10,6 +10,7 @@ obj-$(CONFIG_CMD_BOOTM) += bootm.o
>  obj-$(CONFIG_CMD_GO) += boot.o
>  obj-y	+= cache.o
>  obj-y	+= interrupts.o
> +obj-y	+= reset.o
>  obj-y   += setjmp.o
>  
>  # For building EFI apps
> diff --git a/arch/riscv/lib/reset.c b/arch/riscv/lib/reset.c
> new file mode 100644
> index 0000000..a6aa8e2
> --- /dev/null
> +++ b/arch/riscv/lib/reset.c
> @@ -0,0 +1,17 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
> + */
> +
> +#include <common.h>
> +#include <command.h>
> +
> +int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const
> argv[])
> +{
> +	printf("resetting ...\n");
> +
> +	printf("reset unsupported yet\n");
> +	hang();
> +
> +	return 0;
> +}

Reviewed-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de>

Small nit here. The Sentence "reset unsupported yet" is not
grammatically correct and should say "reset not supported yet" instead.

Everything else looks great, so it probably doesn't make sense to
resend the whole series to fix this.

Thanks,
Lukas
diff mbox series

Patch

diff --git a/arch/riscv/cpu/ax25/cpu.c b/arch/riscv/cpu/ax25/cpu.c
index ab05b57..fddcc15 100644
--- a/arch/riscv/cpu/ax25/cpu.c
+++ b/arch/riscv/cpu/ax25/cpu.c
@@ -6,9 +6,6 @@ 
 
 /* CPU specific code */
 #include <common.h>
-#include <command.h>
-#include <watchdog.h>
-#include <asm/cache.h>
 
 /*
  * cleanup_before_linux() is called just before we call linux
@@ -24,9 +21,3 @@  int cleanup_before_linux(void)
 
 	return 0;
 }
-
-int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
-{
-	disable_interrupts();
-	panic("ax25-ae350 wdt not support yet.\n");
-}
diff --git a/arch/riscv/cpu/qemu/cpu.c b/arch/riscv/cpu/qemu/cpu.c
index a064639..6c7a327 100644
--- a/arch/riscv/cpu/qemu/cpu.c
+++ b/arch/riscv/cpu/qemu/cpu.c
@@ -4,7 +4,6 @@ 
  */
 
 #include <common.h>
-#include <command.h>
 
 /*
  * cleanup_before_linux() is called just before we call linux
@@ -20,10 +19,3 @@  int cleanup_before_linux(void)
 
 	return 0;
 }
-
-int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
-{
-	printf("reset unsupported yet\n");
-
-	return 0;
-}
diff --git a/arch/riscv/lib/Makefile b/arch/riscv/lib/Makefile
index cc562f9..b58db89 100644
--- a/arch/riscv/lib/Makefile
+++ b/arch/riscv/lib/Makefile
@@ -10,6 +10,7 @@  obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-$(CONFIG_CMD_GO) += boot.o
 obj-y	+= cache.o
 obj-y	+= interrupts.o
+obj-y	+= reset.o
 obj-y   += setjmp.o
 
 # For building EFI apps
diff --git a/arch/riscv/lib/reset.c b/arch/riscv/lib/reset.c
new file mode 100644
index 0000000..a6aa8e2
--- /dev/null
+++ b/arch/riscv/lib/reset.c
@@ -0,0 +1,17 @@ 
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
+ */
+
+#include <common.h>
+#include <command.h>
+
+int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	printf("resetting ...\n");
+
+	printf("reset unsupported yet\n");
+	hang();
+
+	return 0;
+}