[PATCH 1/4] openrisc: drop <config.h> usage
Ahmad Fatoum
a.fatoum at pengutronix.de
Fri Nov 28 02:58:41 PST 2025
From: Ahmad Fatoum <a.fatoum at barebox.org>
Generation per-board config.h headers is a left-over from times long
past. For most boards it's no longer possible anyway due to multi-image
suppot, but for legacy boards that still use it, let's switch away from
this magic in preparation for removal.
Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
arch/openrisc/Kconfig | 2 +-
arch/openrisc/Makefile | 4 ++++
arch/openrisc/boards/generic/config.h | 25 -------------------------
arch/openrisc/cpu/barebox.lds.S | 2 +-
arch/openrisc/cpu/start.S | 2 +-
arch/openrisc/include/asm/config.h | 15 +++++++++++++++
arch/openrisc/lib/board.c | 5 +++--
arch/openrisc/lib/clock.c | 1 +
arch/openrisc/lib/cpuinfo.c | 3 ++-
9 files changed, 28 insertions(+), 31 deletions(-)
delete mode 100644 arch/openrisc/boards/generic/config.h
create mode 100644 arch/openrisc/include/asm/config.h
diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index d79743962a42..41a4efc691c7 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -16,7 +16,7 @@ config ARCH_MKIMAGE_NAME
# not used
config ARCH_TEXT_BASE
hex
- default 0x00000000
+ default 0x1f80000
config BUILTIN_DTB
bool "link a DTB into the barebox image"
diff --git a/arch/openrisc/Makefile b/arch/openrisc/Makefile
index 609b998de98e..b7b84f78392b 100644
--- a/arch/openrisc/Makefile
+++ b/arch/openrisc/Makefile
@@ -31,4 +31,8 @@ dts := arch/openrisc/dts
%.dtb: scripts
$(Q)$(MAKE) $(build)=$(dts) $(dts)/$@
+TEXT_BASE = $(CONFIG_ARCH_TEXT_BASE)
+
+KBUILD_CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE)
+
KBUILD_IMAGE := barebox
diff --git a/arch/openrisc/boards/generic/config.h b/arch/openrisc/boards/generic/config.h
deleted file mode 100644
index 2d836d0063ed..000000000000
--- a/arch/openrisc/boards/generic/config.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-#ifndef _GENERIC_NAMES_H_
-#define _GENERIC_NAMES_H_
-
-#define CONFIG_SYS_CLK_FREQ 50000000
-
-#define OPENRISC_TIMER_FREQ CONFIG_SYS_CLK_FREQ
-
-#define OPENRISC_SOPC_MEMORY_BASE 0x00000000
-#define OPENRISC_SOPC_MEMORY_SIZE 0x02000000
-
-/* We reserve 512K for barebox */
-#define BAREBOX_RESERVED_SIZE 0x80000
-
-/* Barebox will be at top of main memory */
-#define OPENRISC_SOPC_TEXT_BASE (OPENRISC_SOPC_MEMORY_BASE + OPENRISC_SOPC_MEMORY_SIZE - BAREBOX_RESERVED_SIZE)
-
-/*
-* TEXT_BASE is defined here because STACK_BASE definition
-* in include/asm-generic/memory_layout.h uses this name
-*/
-
-#define TEXT_BASE OPENRISC_SOPC_TEXT_BASE
-
-#endif
diff --git a/arch/openrisc/cpu/barebox.lds.S b/arch/openrisc/cpu/barebox.lds.S
index 26bb622edc27..3473181b0231 100644
--- a/arch/openrisc/cpu/barebox.lds.S
+++ b/arch/openrisc/cpu/barebox.lds.S
@@ -13,7 +13,7 @@
*
*/
-#include <config.h>
+#include <asm/config.h>
#include <asm/barebox.lds.h>
OUTPUT_FORMAT(BAREBOX_OUTPUT_FORMAT)
diff --git a/arch/openrisc/cpu/start.S b/arch/openrisc/cpu/start.S
index c448d3775f37..974eda212139 100644
--- a/arch/openrisc/cpu/start.S
+++ b/arch/openrisc/cpu/start.S
@@ -14,7 +14,7 @@
*
*/
-#include <config.h>
+#include <asm/config.h>
#include <asm-generic/memory_layout.h>
#include <asm/spr-defs.h>
diff --git a/arch/openrisc/include/asm/config.h b/arch/openrisc/include/asm/config.h
new file mode 100644
index 000000000000..85d777db8f63
--- /dev/null
+++ b/arch/openrisc/include/asm/config.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef _OPENRISC_ASM_CONFIG_H_
+#define _OPENRISC_ASM_CONFIG_H_
+
+#define CFG_SYS_CLK_FREQ 50000000
+
+#define OPENRISC_TIMER_FREQ CFG_SYS_CLK_FREQ
+
+#define OPENRISC_SOPC_MEMORY_BASE 0x00000000
+#define OPENRISC_SOPC_MEMORY_SIZE 0x02000000
+
+/* We reserve 512K for barebox */
+#define BAREBOX_RESERVED_SIZE 0x80000
+
+#endif
diff --git a/arch/openrisc/lib/board.c b/arch/openrisc/lib/board.c
index c6f34ed412d7..3556f3ecee31 100644
--- a/arch/openrisc/lib/board.c
+++ b/arch/openrisc/lib/board.c
@@ -19,14 +19,15 @@
#include <memory.h>
#include <asm-generic/memory_layout.h>
#include <debug_ll.h>
+#include <asm/config.h>
/* Called from assembly */
void openrisc_start_barebox(void);
void __noreturn openrisc_start_barebox(void)
{
- mem_malloc_init((void *)(OPENRISC_SOPC_TEXT_BASE - MALLOC_SIZE),
- (void *)(OPENRISC_SOPC_TEXT_BASE - 1));
+ mem_malloc_init((void *)(TEXT_BASE - MALLOC_SIZE),
+ (void *)(TEXT_BASE - 1));
putc_ll('>');
diff --git a/arch/openrisc/lib/clock.c b/arch/openrisc/lib/clock.c
index 651b163f13cb..a45de30f9426 100644
--- a/arch/openrisc/lib/clock.c
+++ b/arch/openrisc/lib/clock.c
@@ -16,6 +16,7 @@
#include <common.h>
#include <clock.h>
#include <init.h>
+#include <asm/config.h>
#include <asm/system.h>
#include <asm/openrisc_exc.h>
diff --git a/arch/openrisc/lib/cpuinfo.c b/arch/openrisc/lib/cpuinfo.c
index d94178ea59de..4aa4d35bf91d 100644
--- a/arch/openrisc/lib/cpuinfo.c
+++ b/arch/openrisc/lib/cpuinfo.c
@@ -16,6 +16,7 @@
#include <common.h>
#include <command.h>
+#include <asm/config.h>
#include <asm/system.h>
#include <asm/cache.h>
#include <asm/openrisc_exc.h>
@@ -114,7 +115,7 @@ static int checkcpu(void)
char impl_str[50];
printf("CPU: OpenRISC-%x00 (rev %d) @ %d MHz\n",
- ver, rev, (CONFIG_SYS_CLK_FREQ / 1000000));
+ ver, rev, (CFG_SYS_CLK_FREQ / 1000000));
if (vr2) {
cpu_implementation(vr2, impl_str);
--
2.47.3
More information about the barebox
mailing list