From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/3] openrisc: implement C debug_ll for NS16550
Date: Wed, 14 Aug 2024 18:14:34 +0200 [thread overview]
Message-ID: <20240814161435.566270-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240814161435.566270-1-a.fatoum@pengutronix.de>
The early startup code is written in assembly, so the C DEBUG_LL
implementation isn't as useful, but it can still come in handy as
debugging aid, so let's add it.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/openrisc/Kconfig | 1 +
arch/openrisc/include/asm/debug_ll.h | 36 ++++++++++++++++++++++++++++
arch/openrisc/lib/board.c | 3 +++
common/Kconfig.debug_ll | 4 ++++
4 files changed, 44 insertions(+)
create mode 100644 arch/openrisc/include/asm/debug_ll.h
diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index 4ae03b748c79..102071686e4f 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -7,6 +7,7 @@ config OPENRISC
select HAVE_CONFIGURABLE_MEMORY_LAYOUT
select GENERIC_FIND_NEXT_BIT
select ARCH_HAS_SJLJ
+ select HAS_DEBUG_LL
default y
# not used
diff --git a/arch/openrisc/include/asm/debug_ll.h b/arch/openrisc/include/asm/debug_ll.h
new file mode 100644
index 000000000000..35d436094096
--- /dev/null
+++ b/arch/openrisc/include/asm/debug_ll.h
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __ASM_DEBUG_LL__
+#define __ASM_DEBUG_LL__
+
+#include <io.h>
+
+#if defined CONFIG_DEBUG_OPENRISC_NS16550
+
+#define DEBUG_LL_UART_BASE IOMEM(0x90000000)
+
+static inline uint8_t debug_ll_read_reg(void __iomem *base, int reg)
+{
+ return readb(base + reg);
+}
+
+static inline void debug_ll_write_reg(void __iomem *base, int reg, uint8_t val)
+{
+ writeb(val, base + reg);
+}
+
+#include <debug_ll/ns16550.h>
+
+static inline void debug_ll_init(void)
+{
+ /* already configured */
+}
+
+static inline void PUTC_LL(int c)
+{
+ debug_ll_ns16550_putc(DEBUG_LL_UART_BASE, c);
+}
+
+#endif
+
+#endif
diff --git a/arch/openrisc/lib/board.c b/arch/openrisc/lib/board.c
index 9591120fee4b..c6f34ed412d7 100644
--- a/arch/openrisc/lib/board.c
+++ b/arch/openrisc/lib/board.c
@@ -18,6 +18,7 @@
#include <init.h>
#include <memory.h>
#include <asm-generic/memory_layout.h>
+#include <debug_ll.h>
/* Called from assembly */
void openrisc_start_barebox(void);
@@ -27,5 +28,7 @@ void __noreturn openrisc_start_barebox(void)
mem_malloc_init((void *)(OPENRISC_SOPC_TEXT_BASE - MALLOC_SIZE),
(void *)(OPENRISC_SOPC_TEXT_BASE - 1));
+ putc_ll('>');
+
start_barebox();
}
diff --git a/common/Kconfig.debug_ll b/common/Kconfig.debug_ll
index 3f6f3e7c3bdb..1f9255b1a45b 100644
--- a/common/Kconfig.debug_ll
+++ b/common/Kconfig.debug_ll
@@ -350,6 +350,10 @@ config DEBUG_SEMIHOSTING
Say Y here if you want low-level debugging support
using semihosting writec.
+config DEBUG_OPENRISC_NS16550
+ bool "OpenRISC NS16550 console"
+ depends on OPENRISC
+
endchoice
config DEBUG_LL_NS16550
--
2.39.2
next prev parent reply other threads:[~2024-08-14 16:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-14 16:14 [PATCH 1/3] debug_ll: ns16550: fix prototype in documentation comment Ahmad Fatoum
2024-08-14 16:14 ` Ahmad Fatoum [this message]
2024-08-14 16:14 ` [PATCH 3/3] ci: container: downgrade OpenRISC toolchain from 14.2.0 to 13.1.0 Ahmad Fatoum
2024-08-15 8:49 ` (subset) " Sascha Hauer
2024-08-18 7:14 ` Stafford Horne
2024-08-18 17:09 ` Ahmad Fatoum
2024-08-22 16:43 ` Ahmad Fatoum
2024-08-23 6:21 ` Stafford Horne
2024-08-15 8:50 ` (subset) [PATCH 1/3] debug_ll: ns16550: fix prototype in documentation comment Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240814161435.566270-2-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox