diff mbox series

[32/36] bdinfo: m68k: Move m68k-specific info into its own file

Message ID 20200504231732.98778-24-sjg@chromium.org
State Superseded
Headers show
Series Tidy up the 'bd' command. | expand

Commit Message

Simon Glass May 4, 2020, 11:17 p.m. UTC
We don't really want to have m68k-specific code in a generic file. Create
a new arch-specific function to hold it, and move it into that.

Make the function weak so that any arch can implement it.

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

 arch/m68k/lib/Makefile |  1 +
 arch/m68k/lib/bdinfo.c | 29 +++++++++++++++++++++++++++++
 cmd/bdinfo.c           | 15 ---------------
 3 files changed, 30 insertions(+), 15 deletions(-)
 create mode 100644 arch/m68k/lib/bdinfo.c

Comments

Bin Meng May 6, 2020, 8:10 a.m. UTC | #1
On Tue, May 5, 2020 at 7:19 AM Simon Glass <sjg at chromium.org> wrote:
>
> We don't really want to have m68k-specific code in a generic file. Create
> a new arch-specific function to hold it, and move it into that.
>
> Make the function weak so that any arch can implement it.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
>  arch/m68k/lib/Makefile |  1 +
>  arch/m68k/lib/bdinfo.c | 29 +++++++++++++++++++++++++++++
>  cmd/bdinfo.c           | 15 ---------------
>  3 files changed, 30 insertions(+), 15 deletions(-)
>  create mode 100644 arch/m68k/lib/bdinfo.c
>

Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
Angelo Dureghello May 6, 2020, 8:11 p.m. UTC | #2
On Tue, May 5, 2020 at 1:19 AM Simon Glass <sjg at chromium.org> wrote:
>
> We don't really want to have m68k-specific code in a generic file. Create
> a new arch-specific function to hold it, and move it into that.
>
> Make the function weak so that any arch can implement it.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
>  arch/m68k/lib/Makefile |  1 +
>  arch/m68k/lib/bdinfo.c | 29 +++++++++++++++++++++++++++++
>  cmd/bdinfo.c           | 15 ---------------
>  3 files changed, 30 insertions(+), 15 deletions(-)
>  create mode 100644 arch/m68k/lib/bdinfo.c

Tested on stmark2

stmark2 $ bdi
boot_params = 0x47d96770
DRAM bank   = 0x00000000
-> start    = 0x40000000
-> size     = 0x08000000
memstart    = 0x40000000
memsize     = 0x08000000
flashstart  = 0x00000000
flashsize   = 0x00000000
flashoffset = 0x00000000
baudrate    = 115200 bps
relocaddr   = 0x47dd5000
reloc off   = 0xfffd4c00
Build       = 32-bit
fdt_blob    = 0x47d90670
new_fdt     = 0x47d90670
fdt_size    = 0x00002860
sramstart   = 0x00000000
sramsize    = 0x00000000
busfreq     =    120 MHz
mbar        = 0xfc000000
cpufreq     =    240 MHz
flbfreq     =     60 MHz
inpfreq     =     30 MHz


Tested-by: Angelo Dureghello <angelo.dureghello at timesys.com>
diff mbox series

Patch

diff --git a/arch/m68k/lib/Makefile b/arch/m68k/lib/Makefile
index a040f40eb8..b66d66afd2 100644
--- a/arch/m68k/lib/Makefile
+++ b/arch/m68k/lib/Makefile
@@ -7,6 +7,7 @@ 
 ## if the user asked for it
 lib-$(CONFIG_USE_PRIVATE_LIBGCC) += lshrdi3.o muldi3.o ashldi3.o
 
+obj-y	+= bdinfo.o
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
 obj-y	+= cache.o
 obj-y	+= interrupts.o
diff --git a/arch/m68k/lib/bdinfo.c b/arch/m68k/lib/bdinfo.c
new file mode 100644
index 0000000000..09a1abfc21
--- /dev/null
+++ b/arch/m68k/lib/bdinfo.c
@@ -0,0 +1,29 @@ 
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * PPC-specific information for the 'bd' command
+ *
+ * (C) Copyright 2003
+ * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+ */
+
+#include <common.h>
+#include <init.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+void arch_print_bdinfo(void)
+{
+	bd_t *bd = gd->bd;
+
+#if defined(CONFIG_SYS_MBAR)
+	bdinfo_print_num("mbar", bd->bi_mbar_base);
+#endif
+	bdinfo_print_mhz("cpufreq", bd->bi_intfreq);
+	if (IS_ENABLED(CONFIG_PCI))
+		bdinfo_print_mhz("pcifreq", bd->bi_pcifreq);
+#ifdef CONFIG_EXTRA_CLOCK
+	bdinfo_print_mhz("flbfreq", bd->bi_flbfreq);
+	bdinfo_print_mhz("inpfreq", bd->bi_inpfreq);
+	bdinfo_print_mhz("vcofreq", bd->bi_vcofreq);
+#endif
+}
diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c
index 570022052c..f0afdb153f 100644
--- a/cmd/bdinfo.c
+++ b/cmd/bdinfo.c
@@ -106,21 +106,6 @@  int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 	if (IS_ENABLED(CONFIG_PPC) || IS_ENABLED(CONFIG_M68K))
 		bdinfo_print_mhz("busfreq", bd->bi_busfreq);
 
-	/* The rest are used only by m68k */
-#ifdef CONFIG_M68K
-#if defined(CONFIG_SYS_MBAR)
-	bdinfo_print_num("mbar", bd->bi_mbar_base);
-#endif
-	bdinfo_print_mhz("cpufreq", bd->bi_intfreq);
-	if (IS_ENABLED(CONFIG_PCI))
-		bdinfo_print_mhz("pcifreq", bd->bi_pcifreq);
-#ifdef CONFIG_EXTRA_CLOCK
-	bdinfo_print_mhz("flbfreq", bd->bi_flbfreq);
-	bdinfo_print_mhz("inpfreq", bd->bi_inpfreq);
-	bdinfo_print_mhz("vcofreq", bd->bi_vcofreq);
-#endif
-#endif
-
 	return 0;
 }