[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 2/8] xen/arm: Add NXP LINFlexD UART early printk support


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: "Andrei Cherechesu (OSS)" <andrei.cherechesu@xxxxxxxxxxx>
  • Date: Mon, 30 Sep 2024 14:47:08 +0300
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XqXlCdVjUT3pnys22jpUDXfmJf7XqwEbQ1D4Bno9CNY=; b=k7033n+eqWqct7VXLGZtpV+jeHm3CkI+BJaCyltMuZJoK+1oWpC0VO+KtR9xN2meTUhKpfWMYgJasTBikTeGzOEie1kkEBZDzelNaoOQQbU2aQpM00an5aYTpZIwpLrh0GxUdMoeUisY3ns9OuQ1OQF+5wdXjtQL0SAW9riEzUrA2q3dZ1396lfxtxMTOfDLMExfZSF0JFblgRU5uGREJpKf2/Qxctl1/ZqrJdB+JO9sP2kjfYnDp6O7VljNnfrrUMHWfbrVxwWbVkE6L/d/i6doDPKWcf7y/EzHzzKiSG0FBzUHr1SqQChFsL6/BEJ1lWso9+SHbCzXvHL9a43aVg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XnFL9mAX0A6+3PNmDCr3zbsV5TEaKxBBm11xZXDCVcP3i59NL0Pg9AokhWgMmse4EDWgKU0l4uVD53cjeTDMiz2OiP2jFV0rdrIFoSWXjgsJ/vWW/gjO8GW1g8O51IXJSWhaqOz9RwO1sxPHM1JET5dF+qR24Spc+JVkUzEQPy0qkla6iYdkY7pNIOuO8f3Xhmf9j49ycefg1GJ6rmYnRqNyfEpiCX9Z/p32qEmVm5N8x7LKivGBAXIYUwHjF6uFRU3AO2YyoVZZyu3kpRVeFxqDM1tt9cAq0QHD2il3x58ILdFEXy0YPsfMvfJS6LrorZVRNd50BO5sTTZU70wHfw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com;
  • Cc: andrei.cherechesu@xxxxxxxxxxx, S32@xxxxxxx, Andrei Cherechesu <andrei.cherechesu@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Julien Grall <jgrall@xxxxxxxxxx>
  • Delivery-date: Mon, 30 Sep 2024 11:47:45 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Andrei Cherechesu <andrei.cherechesu@xxxxxxx>

This adds support for early printk debug via the NXP LINFlexD
UART controller.

Signed-off-by: Andrei Cherechesu <andrei.cherechesu@xxxxxxx>
Signed-off-by: Peter van der Perk <peter.vander.perk@xxxxxxx>
Acked-by: Julien Grall <jgrall@xxxxxxxxxx>
---
 xen/arch/arm/Kconfig.debug           | 12 ++++++
 xen/arch/arm/arm64/debug-linflex.inc | 58 ++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+)
 create mode 100644 xen/arch/arm/arm64/debug-linflex.inc

diff --git a/xen/arch/arm/Kconfig.debug b/xen/arch/arm/Kconfig.debug
index 2fa0acd2a3..7660e599c0 100644
--- a/xen/arch/arm/Kconfig.debug
+++ b/xen/arch/arm/Kconfig.debug
@@ -44,6 +44,14 @@ choice
                        Say Y here if you wish the early printk to direct their
                        output to a i.MX LPUART.
 
+       config EARLY_UART_CHOICE_LINFLEX
+               select EARLY_UART_LINFLEX
+               depends on ARM_64
+               bool "Early printk via NXP LINFlexD UART"
+               help
+                       Say Y here if you wish the early printk to direct their
+                       output to an NXP LINFlexD UART.
+
        config EARLY_UART_CHOICE_MESON
                select EARLY_UART_MESON
                depends on ARM_64
@@ -89,6 +97,9 @@ config EARLY_UART_EXYNOS4210
 config EARLY_UART_IMX_LPUART
        select EARLY_PRINTK
        bool
+config EARLY_UART_LINFLEX
+       select EARLY_PRINTK
+       bool
 config EARLY_UART_MESON
        select EARLY_PRINTK
        bool
@@ -167,6 +178,7 @@ config EARLY_PRINTK_INC
        default "debug-cadence.inc" if EARLY_UART_CADENCE
        default "debug-exynos4210.inc" if EARLY_UART_EXYNOS4210
        default "debug-imx-lpuart.inc" if EARLY_UART_IMX_LPUART
+       default "debug-linflex.inc" if EARLY_UART_LINFLEX
        default "debug-meson.inc" if EARLY_UART_MESON
        default "debug-mvebu.inc" if EARLY_UART_MVEBU
        default "debug-pl011.inc" if EARLY_UART_PL011
diff --git a/xen/arch/arm/arm64/debug-linflex.inc 
b/xen/arch/arm/arm64/debug-linflex.inc
new file mode 100644
index 0000000000..cf4f5ce224
--- /dev/null
+++ b/xen/arch/arm/arm64/debug-linflex.inc
@@ -0,0 +1,58 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * xen/arch/arm/arm64/debug-linflex.inc
+ *
+ * NXP LINFlexD UART specific debug code
+ *
+ * Andrei Cherechesu <andrei.cherechesu@xxxxxxx>
+ * Copyright 2018, 2021, 2023-2024 NXP
+ */
+
+#include <asm/asm_defns.h>
+#include <asm/linflex-uart.h>
+
+/*
+ * wait LINFlexD UART to be ready to transmit
+ * xb: register which contains the UART base address
+ * c: scratch register number
+ */
+.macro early_uart_ready xb, c
+    ldr   w\c, [\xb, #UARTCR]       /* <= Control Register */
+    and   w\c, w\c, #UARTCR_TFBM    /* Check Buffer/FIFO (0/1) Mode */
+    cbz   w\c, 2f                   /* Buffer Mode => return */
+1:
+    ldrb  w\c, [\xb, #UARTSR]       /* <= Status Register */
+    tst   w\c, #UARTSR_DTFTFF       /* FIFO Mode => Check DTF bit */
+    b.ne  1b
+2:
+.endm
+
+/*
+ * LINFlexD UART transmit character
+ * xb: register which contains the UART base address
+ * wt: register which contains the character to transmit
+ */
+.macro early_uart_transmit xb, wt
+    strb  \wt, [\xb, #BDRL]
+
+    ldr   \wt, [\xb, #UARTCR]       /* <= Control Register */
+    and   \wt, \wt, #UARTCR_TFBM    /* Check Buffer/FIFO (0/1) Mode */
+    cbnz  \wt, 2f                   /* FIFO Mode => goto exit */
+
+3:  /* Buffer Mode */
+    ldrb  \wt, [\xb, #UARTSR]       /* <= Status Register */
+    and   \wt, \wt, #UARTSR_DTFTFF  /* Check Transmission Completed */
+    cbz   \wt, 3b
+
+    ldr   \wt, [\xb, #UARTSR]       /* <= Status Register */
+    orr   \wt, \wt, #UARTSR_DTFTFF  /* Clear DTF bit */
+    str   \wt, [\xb, #UARTSR]
+2:
+.endm
+
+/*
+ * Local variables:
+ * mode: ASM
+ * indent-tabs-mode: nil
+ * End:
+ */
-- 
2.45.2




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.