mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 30/50] ARM: omap: Use ns16550 debug_ll helper
Date: Fri,  3 Mar 2023 10:21:11 +0100	[thread overview]
Message-ID: <20230303092131.3063587-31-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20230303092131.3063587-1-s.hauer@pengutronix.de>

The omap UART is ns16550 compatible, so use the existing ns16550
debug_ll helper to provide debug_ll functionality.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/boards/afi-gf/lowlevel.c            |  2 +-
 arch/arm/boards/beagle/lowlevel.c            |  2 +-
 arch/arm/boards/beaglebone/lowlevel.c        |  2 +-
 arch/arm/boards/myirtech-x335x/lowlevel.c    |  2 +-
 arch/arm/boards/phytec-som-am335x/lowlevel.c |  2 +-
 arch/arm/boards/vscom-baltos/lowlevel.c      |  2 +-
 arch/arm/boards/wago-pfc-am35xx/lowlevel.c   |  2 +-
 include/mach/omap/debug_ll.h                 | 63 ++++++++++----------
 8 files changed, 37 insertions(+), 40 deletions(-)

diff --git a/arch/arm/boards/afi-gf/lowlevel.c b/arch/arm/boards/afi-gf/lowlevel.c
index 1b08d14205..d1c8e98434 100644
--- a/arch/arm/boards/afi-gf/lowlevel.c
+++ b/arch/arm/boards/afi-gf/lowlevel.c
@@ -226,7 +226,7 @@ static noinline int gf_sram_init(void)
 
 	am33xx_uart_soft_reset((void *)AM33XX_UART2_BASE);
 	am33xx_enable_uart2_pin_mux();
-	omap_uart_lowlevel_init((void *)AM33XX_UART2_BASE);
+	omap_debug_ll_init();
 	putc_ll('>');
 
 	barebox_arm_entry(0x80000000, SZ_256M, fdt);
diff --git a/arch/arm/boards/beagle/lowlevel.c b/arch/arm/boards/beagle/lowlevel.c
index ff822e5c24..bd944c4f67 100644
--- a/arch/arm/boards/beagle/lowlevel.c
+++ b/arch/arm/boards/beagle/lowlevel.c
@@ -196,7 +196,7 @@ static noinline int beagle_board_init(void)
 
 	mux_config();
 
-	omap_uart_lowlevel_init((void *)OMAP3_UART3_BASE);
+	omap_debug_ll_init();
 
 	/* Dont reconfigure SDRAM while running in SDRAM! */
 	if (!in_sdram)
diff --git a/arch/arm/boards/beaglebone/lowlevel.c b/arch/arm/boards/beaglebone/lowlevel.c
index 6978723fbb..b1ba66434b 100644
--- a/arch/arm/boards/beaglebone/lowlevel.c
+++ b/arch/arm/boards/beaglebone/lowlevel.c
@@ -132,7 +132,7 @@ static noinline int beaglebone_sram_init(void)
 
 	am33xx_uart_soft_reset((void *)AM33XX_UART0_BASE);
 	am33xx_enable_uart0_pin_mux();
-	omap_uart_lowlevel_init((void *)AM33XX_UART0_BASE);
+	omap_debug_ll_init();
 	putc_ll('>');
 
 	barebox_arm_entry(0x80000000, sdram_size, fdt);
diff --git a/arch/arm/boards/myirtech-x335x/lowlevel.c b/arch/arm/boards/myirtech-x335x/lowlevel.c
index 66d2dc1a53..eb42182098 100644
--- a/arch/arm/boards/myirtech-x335x/lowlevel.c
+++ b/arch/arm/boards/myirtech-x335x/lowlevel.c
@@ -91,7 +91,7 @@ ENTRY_FUNCTION(start_am33xx_myirtech_sram, bootinfo, r1, r2)
 	if (IS_ENABLED(CONFIG_DEBUG_LL)) {
 		am33xx_uart_soft_reset(IOMEM(AM33XX_UART0_BASE));
 		am33xx_enable_uart0_pin_mux();
-		omap_uart_lowlevel_init(IOMEM(AM33XX_UART0_BASE));
+		omap_debug_ll_init();
 		putc_ll('>');
 	}
 
diff --git a/arch/arm/boards/phytec-som-am335x/lowlevel.c b/arch/arm/boards/phytec-som-am335x/lowlevel.c
index 445ec18d5a..2e2bdc9169 100644
--- a/arch/arm/boards/phytec-som-am335x/lowlevel.c
+++ b/arch/arm/boards/phytec-som-am335x/lowlevel.c
@@ -163,7 +163,7 @@ static noinline void physom_board_init(void *fdt, int sdram, int module_family)
 
 	am33xx_uart_soft_reset((void *)AM33XX_UART0_BASE);
 	am33xx_enable_uart0_pin_mux();
-	omap_uart_lowlevel_init((void *)AM33XX_UART0_BASE);
+	omap_debug_ll_init();
 	putc_ll('>');
 
 	am335x_barebox_entry(fdt);
diff --git a/arch/arm/boards/vscom-baltos/lowlevel.c b/arch/arm/boards/vscom-baltos/lowlevel.c
index f1dcc731a0..80046a3b05 100644
--- a/arch/arm/boards/vscom-baltos/lowlevel.c
+++ b/arch/arm/boards/vscom-baltos/lowlevel.c
@@ -97,7 +97,7 @@ static noinline void baltos_sram_init(void)
 
 	am33xx_uart_soft_reset((void *)AM33XX_UART0_BASE);
 	am33xx_enable_uart0_pin_mux();
-	omap_uart_lowlevel_init((void *)AM33XX_UART0_BASE);
+	omap_debug_ll_init();
 	putc_ll('>');
 
 	am335x_barebox_entry(fdt);
diff --git a/arch/arm/boards/wago-pfc-am35xx/lowlevel.c b/arch/arm/boards/wago-pfc-am35xx/lowlevel.c
index 04e036c233..cff6bfbfeb 100644
--- a/arch/arm/boards/wago-pfc-am35xx/lowlevel.c
+++ b/arch/arm/boards/wago-pfc-am35xx/lowlevel.c
@@ -184,7 +184,7 @@ static noinline void pfc200_board_init(void)
 
 	if (IS_ENABLED(CONFIG_DEBUG_LL)) {
 		am33xx_uart_soft_reset(IOMEM(OMAP3_UART3_BASE));
-		omap_uart_lowlevel_init(IOMEM(OMAP3_UART3_BASE));
+		omap_debug_ll_init();
 		putc_ll('>');
 	}
 
diff --git a/include/mach/omap/debug_ll.h b/include/mach/omap/debug_ll.h
index 2e723dcb82..b696c3cb37 100644
--- a/include/mach/omap/debug_ll.h
+++ b/include/mach/omap/debug_ll.h
@@ -22,32 +22,6 @@
 #include <mach/omap/omap4-silicon.h>
 #include <mach/omap/am33xx-silicon.h>
 
-#define LSR_THRE	0x20	/* Xmit holding register empty */
-#define LCR_BKSE	0x80	/* Bank select enable */
-#define LSR		(5 << 2)
-#define THR		(0 << 2)
-#define DLL		(0 << 2)
-#define IER		(1 << 2)
-#define DLM		(1 << 2)
-#define FCR		(2 << 2)
-#define LCR		(3 << 2)
-#define MCR		(4 << 2)
-#define MDR		(8 << 2)
-
-static inline void omap_uart_lowlevel_init(void __iomem *base)
-{
-	writeb(0x00, base + LCR);
-	writeb(0x00, base + IER);
-	writeb(0x07, base + MDR);
-	writeb(LCR_BKSE, base + LCR);
-	writeb(26, base + DLL); /* 115200 */
-	writeb(0, base + DLM);
-	writeb(0x03, base + LCR);
-	writeb(0x03, base + MCR);
-	writeb(0x07, base + FCR);
-	writeb(0x00, base + MDR);
-}
-
 #ifdef CONFIG_DEBUG_LL
 
 #ifdef CONFIG_DEBUG_OMAP3_UART
@@ -63,17 +37,40 @@ static inline void omap_uart_lowlevel_init(void __iomem *base)
 #define __OMAP_UART_BASE(soc, num) soc##_UART##num##_BASE
 #define OMAP_UART_BASE(soc, num) __OMAP_UART_BASE(soc, num)
 
-static inline void PUTC_LL(char c)
+static inline uint8_t debug_ll_read_reg(int reg)
 {
 	void __iomem *base = (void *)OMAP_UART_BASE(OMAP_DEBUG_SOC,
 			CONFIG_DEBUG_OMAP_UART_PORT);
 
-	/* Wait until there is space in the FIFO */
-	while ((readb(base + LSR) & LSR_THRE) == 0);
-	/* Send the character */
-	writeb(c, base + THR);
-	/* Wait to make sure it hits the line, in case we die too soon. */
-	while ((readb(base + LSR) & LSR_THRE) == 0);
+	return readb(base + (reg << 2));
+}
+
+static inline void debug_ll_write_reg(int reg, uint8_t val)
+{
+	void __iomem *base = (void *)OMAP_UART_BASE(OMAP_DEBUG_SOC,
+			CONFIG_DEBUG_OMAP_UART_PORT);
+
+	writeb(val, base + (reg << 2));
+}
+
+#include <debug_ll/ns16550.h>
+
+static inline void omap_debug_ll_init(void)
+{
+	unsigned int divisor;
+
+	divisor = debug_ll_ns16550_calc_divisor(48000000);
+	debug_ll_ns16550_init(divisor);
+}
+
+static inline void PUTC_LL(int c)
+{
+	debug_ll_ns16550_putc(c);
+}
+
+#else
+static inline void omap_debug_ll_init(void)
+{
 }
 #endif
 
-- 
2.30.2




  parent reply	other threads:[~2023-03-03  9:30 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-03  9:20 [PATCH 00/50] ARM: multi-arch support Sascha Hauer
2023-03-03  9:20 ` [PATCH 01/50] ARM: i.MX: Move mach header files to include/mach/imx Sascha Hauer
2023-03-03  9:20 ` [PATCH 02/50] ARM: Rockchip: Move mach header files to include/mach/rockchip Sascha Hauer
2023-03-03  9:20 ` [PATCH 03/50] ARM: Zynqmp: Move mach header files to include/mach/zynqmp Sascha Hauer
2023-03-03  9:20 ` [PATCH 04/50] ARM: mvebu: Move mach header files to include/mach/mvebu Sascha Hauer
2023-03-03  9:20 ` [PATCH 05/50] ARM: davinci: Move mach header files to include/mach/davinci Sascha Hauer
2023-03-03  9:20 ` [PATCH 06/50] ARM: bcm283x: Move mach header files to include/mach/bcm283x Sascha Hauer
2023-03-03  9:20 ` [PATCH 07/50] ARM: stm32mp: Move mach header files to include/mach/stm32mp Sascha Hauer
2023-03-03  9:20 ` [PATCH 08/50] ARM: zynq: Move mach header files to include/mach/zynq Sascha Hauer
2023-03-03  9:20 ` [PATCH 09/50] ARM: vexpress: Move mach header files to include/mach/vexpress Sascha Hauer
2023-03-03  9:20 ` [PATCH 10/50] ARM: versatile: Move mach header files to include/mach/versatile Sascha Hauer
2023-03-03  9:20 ` [PATCH 11/50] ARM: layerscape: Move mach header files to include/mach/layerscape Sascha Hauer
2023-03-03  9:20 ` [PATCH 12/50] ARM: tegra: Move mach header files to include/mach/tegra Sascha Hauer
2023-03-03  9:20 ` [PATCH 13/50] ARM: uemd: Move mach header files to include/mach/uemd Sascha Hauer
2023-03-03  9:20 ` [PATCH 14/50] ARM: socfpga: Move mach header files to include/mach/socfpga Sascha Hauer
2023-03-03  9:20 ` [PATCH 15/50] ARM: pxa: Move mach header files to include/mach/pxa Sascha Hauer
2023-03-03  9:20 ` [PATCH 16/50] ARM: omap: Move mach header files to include/mach/omap Sascha Hauer
2023-03-03  9:20 ` [PATCH 17/50] ARM: nomadik: Move mach header files to include/mach/nomadik Sascha Hauer
2023-03-03  9:20 ` [PATCH 18/50] ARM: mxs: Move mach header files to include/mach/mxs Sascha Hauer
2023-03-03  9:21 ` [PATCH 19/50] ARM: ep93xx: Move mach header files to include/mach/ep93xx Sascha Hauer
2023-03-03  9:21 ` [PATCH 20/50] ARM: digic: Move mach header files to include/mach/digic Sascha Hauer
2023-03-03  9:21 ` [PATCH 21/50] ARM: clps711x: Move mach header files to include/mach/clps711x Sascha Hauer
2023-03-03  9:21 ` [PATCH 22/50] ARM: at91: Move mach header files to include/mach/at91 Sascha Hauer
2023-03-03  9:21 ` [PATCH 23/50] ARM: Drop mach dir include path Sascha Hauer
2023-03-03  9:21 ` [PATCH 24/50] include/mach/: use unique double inclusion protectors Sascha Hauer
2023-03-03  9:21 ` [PATCH 25/50] ARM: i.MX: Only provide PUTC_LL() when activated Sascha Hauer
2023-03-03  9:21 ` [PATCH 26/50] debug_ll ns16550: Do not define PUTC_LL() Sascha Hauer
2023-03-03  9:21 ` [PATCH 27/50] debug_ll ns16550: Use CONFIG_BAUDRATE Sascha Hauer
2023-03-03  9:21 ` [PATCH 28/50] ARM: Rockchip: Use ns16550 debug_ll helper Sascha Hauer
2023-03-03  9:21 ` [PATCH 29/50] ARM: Rockchip: Only provide PUTC_LL() when activated Sascha Hauer
2023-03-03  9:21 ` Sascha Hauer [this message]
2023-03-03  9:21 ` [PATCH 31/50] ARM: omap: " Sascha Hauer
2023-03-03  9:21 ` [PATCH 32/50] ARM: omap: usbboot: Enable USB communication when needed Sascha Hauer
2023-03-03  9:21 ` [PATCH 33/50] ARM: omap: Make multi-arch safe Sascha Hauer
2023-03-03  9:21 ` [PATCH 34/50] ARM: Rockchip: Make safe for multi-arch Sascha Hauer
2023-03-03  9:21 ` [PATCH 35/50] pm_domains: Enable explicitly when we have power-domain providers Sascha Hauer
2023-03-03  9:21 ` [PATCH 36/50] ARM: add multi-arch support Sascha Hauer
2023-03-03  9:21 ` [PATCH 37/50] ARM: omap: Add support for multi-arch Sascha Hauer
2023-03-03  9:21 ` [PATCH 38/50] ARM: zynqmp: Add multi-arch support Sascha Hauer
2023-03-03  9:21 ` [PATCH 39/50] ARM: i.MX: Add missing include Sascha Hauer
2023-03-03  9:21 ` [PATCH 40/50] ARM: i.MX: move board selection into menu Sascha Hauer
2023-03-03  9:21 ` [PATCH 41/50] ARM: stm32mp: Only provide PUTC_LL() when activated Sascha Hauer
2023-03-03  9:21 ` [PATCH 42/50] ARM: stm32mp: Make safe for multi-arch Sascha Hauer
2023-03-03  9:21 ` [PATCH 43/50] ARM: stm32mp: Add multi-arch support Sascha Hauer
2023-03-03  9:21 ` [PATCH 44/50] ARM: vexpress: Drop unnecessary initcall Sascha Hauer
2023-03-03  9:21 ` [PATCH 45/50] ARM: vexpress: Only provide PUTC_LL() when activated Sascha Hauer
2023-03-03  9:21 ` [PATCH 46/50] ARM: vexpress: Add multi-arch support Sascha Hauer
2023-03-03  9:21 ` [PATCH 47/50] ARM: bcm283x: Only provide PUTC_LL() when activated Sascha Hauer
2023-03-03  9:21 ` [PATCH 48/50] ARM: bcm283x: Add multi-arch support Sascha Hauer
2023-03-03  9:21 ` [PATCH 49/50] ARM: Add multi_v7_defconfig Sascha Hauer
2023-03-03  9:21 ` [PATCH 50/50] ARM: Add multi_v8_defconfig 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=20230303092131.3063587-31-s.hauer@pengutronix.de \
    --to=s.hauer@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